如果我有以下方法来测试predecessor_account_id
行为
pub fn get_pred_acc(&self) -> (String {
let prev_acc = env::predecessor_account_id().to_string();
return prev_acc;
}
并尝试从前端调用它
const contract = await this.near.loadContract(window.nearConfig.contractName, {
viewMethods: ["get_pred_acc", ],
changeMethods: [],
sender: this.accountId,
});
const acc = await contract.get_pred_acc();
我收到以下错误:
未捕获(承诺中)错误:查询调用/通量协议/get_account_id 失败:wasm 执行失败并出现错误:FunctionCallError(HostError(ProhibitedInView("predecessor_account_id")))。
{ "error": "wasm 执行失败并出现错误:FunctionCallError(HostError(ProhibitedInView(\"predecessor_account_id\")))",
"logs": []
}