请看一下锁定合约示例。它使用以下内容:
ext_whitelist::is_whitelisted(
staking_pool_account_id.clone(),
&self.staking_pool_whitelist_account_id,
NO_DEPOSIT,
gas::whitelist::IS_WHITELISTED,
)
.then(ext_self_owner::on_whitelist_is_whitelisted(
staking_pool_account_id,
&env::current_account_id(),
NO_DEPOSIT,
gas::owner_callbacks::ON_WHITELIST_IS_WHITELISTED,
))
from https://github.com/near/core-contracts/blob/cd221798a77d646d5f1200910d45326d11951732/lockup/src/owner.rs#L29-L40 https://github.com/near/core-contracts/blob/cd221798a77d646d5f1200910d45326d11951732/lockup/src/owner.rs#L29-L40
第一个调用接口是(<arg_0>, <arg_1>, ..., <arg_n>, <ACCOUNT_ID>, <ATTACHED_DEPOSIT>, <ATTACHED_GAS>)
-
<arg_0>, <arg_1>, ..., <arg_n>
- 来自下面定义的接口的参数
-
<ACCOUNT_ID>
- 部署要调用的合约的账户
-
<ATTACHED_DEPOSIT>
- 附加到呼叫的 yocto-NEAR 金额
-
<ATTACHED_GAS>
- 传递给调用的 Gas 量
后来它使用以下方法将回调附加到第一个承诺.then
。回调只是另一个异步函数调用。
高级接口ext_whitelist
定义如下:
#[ext_contract(ext_whitelist)]
pub trait ExtStakingPoolWhitelist {
fn is_whitelisted(&self, staking_pool_account_id: AccountId) -> bool;
}
from https://github.com/near/core-contracts/blob/cd221798a77d646d5f1200910d45326d11951732/lockup/src/lib.rs#L64-L67 https://github.com/near/core-contracts/blob/cd221798a77d646d5f1200910d45326d11951732/lockup/src/lib.rs#L64-L67