I have the following method in my contract:
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
pub struct MyContract {
...,
}
#[near_bindgen]
impl MyContract {
...
pub fn is_account_whitelisted(account_id: &AccountId) -> bool {
Self::account_task_ordinals_map().contains_key(account_id)
}
fn account_task_ordinals_map() -> LookupMap<AccountId, Option<u32>> {
LookupMap::new(b"o".to_vec())
}
...
}
is_account_whitelisted is intended to be used as a view method. I then later use it from near-api-js in the following way:
window.contract = await near.loadContract(nearConfig.contractName, {
viewMethods: ['is_account_whitelisted', ...],
changeMethods: [...],
sender: window.walletAccount.getAccountId()
});
...
window.contract.is_account_whitelisted({'account_id': window.walletAccount.getAccountId()}).then(m => console.log(m));
and it fails with
...
FunctionCallError(HostError(ProhibitedInView { method_name: "attached_deposit" })).
{
"error": "wasm execution failed with error: FunctionCallError(HostError(ProhibitedInView { method_name: \"attached_deposit\" }))",
...
Do I need to annotate the method in some way, am I not calling it right, or is there something that I use in the method that causes the call to the attached_deposit?