【发布时间】:2021-02-11 10:20:20
【问题描述】:
如果我发送带有 2 个合约 fn 调用的交易,如果第一个失败,第二个会被执行吗?
示例代码:
const actions = [
TX.functionCall("select_staking_pool", { staking_pool_account_id: stakingPool }, this.BASE_GAS.muln(3), new BN(0)),
TX.functionCall("deposit_and_stake", { amount: near.ntoy(amountNear) }, this.BASE_GAS.muln(5), new BN(0))
]
return near.broadcast_tx_commit_actions(actions, sender, lockupContract, privateKey)
我确实执行了这批,但结果没有给我明确的答案:https://explorer.testnet.near.org/transactions/DcchgGdzAVEvNqRReHkjsmrTr5PoaMoibs3fyKoKBYSe
第一次 fn 调用 code 使用跨合约调用和回调 code 来检查合约是否被列入白名单,但我在收据日志中看不到回调日志 code。我假设第一次调用失败,因为第二次失败并出现错误:“未选择质押池”
这是完整的结果:
{
"status": {
"Failure": {
"ActionError": {
"index": 1,
"kind": {
"FunctionCallError": {
"HostError": {
"GuestPanic": {
"panic_msg": "panicked at 'Staking pool is not selected', src/internal.rs:90:9"
}
}
}
}
}
}
},
"transaction": {
"signer_id": "lucio.testnet",
"public_key": "ed25519:Cvqie7SJ6xmLNA5KoTAYoUAkhD25KaJLG6N9oSmzT9FK",
"nonce": 33,
"receiver_id": "274e981786efcabbe87794f20348c1b2af6e7963.lockupy.testnet",
"actions": [
{
"FunctionCall": {
"method_name": "select_staking_pool",
"args": "eyJzdGFraW5nX3Bvb2xfYWNjb3VudF9pZCI6Im5vcnRoZXJubGlnaHRzLnN0YWtpbmdwb29sIn0=",
"gas": 75000000000000,
"deposit": "0"
}
},
{
"FunctionCall": {
"method_name": "deposit_and_stake",
"args": "eyJhbW91bnQiOiIxMDk0OTkwMDAwMDAwMDAwMDAwMDAwMDAwMDAwIn0=",
"gas": 125000000000000,
"deposit": "0"
}
}
],
"signature": "ed25519:gzCsrcobVtjuD6FE4qDhgo9zdk2feBp6dfa66NZYLPTnwypF7g8mDM7yubcnkVcF1sPzEFeEfJtQ4hwwnhrxTa6",
"hash": "EjiQBjzF6Ea74wSHkjmZMkhTGwgYxbUdeVKUvzaA8X7k"
},
"transaction_outcome": {
"proof": [],
"block_hash": "3xEuw43E1W4FP2q1Un6XLsDSbhRc7c7FMtGWWL6i3KJj",
"id": "EjiQBjzF6Ea74wSHkjmZMkhTGwgYxbUdeVKUvzaA8X7k",
"outcome": {
"logs": [],
"receipt_ids": [
"75pJCVuheYCjX82RspQzoKm5v7NSG1QNUaPK7DRzZYNt"
],
"gas_burnt": 4748079879222,
"tokens_burnt": "474807987922200000000",
"executor_id": "lucio.testnet",
"status": {
"SuccessReceiptId": "75pJCVuheYCjX82RspQzoKm5v7NSG1QNUaPK7DRzZYNt"
}
}
},
"receipts_outcome": [
{
"proof": [
{
"hash": "55YXLhqDc63f8n4MdZNwi6TdmtFkaYp18wKwm7qFmDo5",
"direction": "Left"
}
],
"block_hash": "DB3p49tiSBfRLv5diDUStajtDiMNs2KroKfRcr2cQDnV",
"id": "75pJCVuheYCjX82RspQzoKm5v7NSG1QNUaPK7DRzZYNt",
"outcome": {
"logs": [
"Selecting staking pool @northernlights.stakingpool. Going to check whitelist first."
],
"receipt_ids": [
"HXStMQuf5aWKVpWDM1Hf4EdA3S4FLTGjmYaF2WAYRcUz"
],
"gas_burnt": 20291176638173,
"tokens_burnt": "2029117663817300000000",
"executor_id": "274e981786efcabbe87794f20348c1b2af6e7963.lockupy.testnet",
"status": {
"Failure": {
"ActionError": {
"index": 1,
"kind": {
"FunctionCallError": {
"HostError": {
"GuestPanic": {
"panic_msg": "panicked at 'Staking pool is not selected', src/internal.rs:90:9"
}
}
}
}
}
}
}
}
},
{
"proof": [],
"block_hash": "2kua8s7vjix2MiMHZ7Rzbrhyv8UbGFEpvWeT67H2qCYM",
"id": "HXStMQuf5aWKVpWDM1Hf4EdA3S4FLTGjmYaF2WAYRcUz",
"outcome": {
"logs": [],
"receipt_ids": [],
"gas_burnt": 0,
"tokens_burnt": "0",
"executor_id": "lucio.testnet",
"status": {
"SuccessValue": ""
}
}
}
]
}
编辑:PS。看起来第一个函数调用静默失败(关于 Tx 结果)。我测试了与 2 个单独事务相同的调用,第一个 (select_staking_pool) 成功。
【问题讨论】:
标签: nearprotocol