Nearprotocol near sdk rs:view调用尝试调用附加的\u存款失败,但合同中似乎没有任何内容查看附加的\u存款

Nearprotocol near sdk rs:view调用尝试调用附加的\u存款失败,但合同中似乎没有任何内容查看附加的\u存款,nearprotocol,Nearprotocol,我在合同中采用以下方法: #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] pub struct MyContract { ..., } #[near_bindgen] impl MyContract { ... pub fn is_account_whitelisted(account_id: &AccountId) -> bool {

我在合同中采用以下方法:

#[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())
    }
    ...
}

它失败了

...
FunctionCallError(HostError(ProhibitedInView { method_name: "attached_deposit" })).
{
  "error": "wasm execution failed with error: FunctionCallError(HostError(ProhibitedInView { method_name: \"attached_deposit\" }))",
...

我是否需要以某种方式对该方法进行注释,我调用的方法是否不对,或者我在该方法中是否使用了某种东西导致调用
附加的\u deposit

多亏了Evgeny的评论,我发现目前只有当一个方法的第一个参数是不可变的self时,它才被认为是视图方法。以下是指向near sdk rs中相关代码的链接:


它很可能很快就会被修复,但同时解决它的方法是添加不可变的self作为第一个参数。

它看起来像是sdk附近的一个
bug。因为出于某种原因,它将
作为非查看方法处理,该方法会检查附加的存款。但是在查看调用期间,在运行时禁止附加的存款调用。
...
FunctionCallError(HostError(ProhibitedInView { method_name: "attached_deposit" })).
{
  "error": "wasm execution failed with error: FunctionCallError(HostError(ProhibitedInView { method_name: \"attached_deposit\" }))",
...