Closed happyJ2024 closed 1 year ago
The UI and the interaction design can be viewed at https://www.figma.com/file/UHdJBdCbMUCDoJ7GdcE9Cr/moombeam?node-id=25%3A8190&t=GIn4sJz0bj43E8jE-0
target_seconds_per_block : apr.utils.js getBlockTargetSeconds, default is 12s
blocks_per_round: chain constant, 当前页面已有该值roundInfo.length
当执行了api.tx.parachainStaking.scheduleRevokeDelegation(collator) 操作后, 会在链上生成一个schedule记录。
已知当前用户参与的collator列表
通过 api.query.parachainStaking.delegationScheduledRequests(collator) 查找得到 某个 collator下的 schedule记录 结构如下:
[
[
[
jcSQcu5RXtWXKPN78zJogNyqsff1j4ffgoJ2njNcDbZ3qNEh5 // collator
]
[
{
delegator: jcS3Mpk2s3UdoBTW6QaniZnhn7xbMtfYX7ZZQJGg1DVNcNkk9 //delegator
whenExecutable: 62,948 // 真正能执行确认动作的roundIndex
action: {
Revoke: 3,100,000,000,000,000 // 动作, token数量
}
}
]
]
]
匹配当前用户地址和 schedule记录, 如果没有关联, 说明用户没有等待中的revoke操作 如果有关联, 得到 whenExecutable_roundIndex
已知参数: current_roundIndex, current_blockNumber, whenExecutable_roundIndex, target_seconds_per_block , blocks_per_round
*est_blocks_v1= (whenExecutable_roundIndex - current_roundIndex ) blocks_per_round **
est_blocks_v2= est_blocks_v1 - ( blocks_finished_in_current_round )
*est_seconds = est_blocks_v2 target_seconds_per_block**
api.constants. parachainStaking.leaveDelegatorsDelay
当 whenExecutable_roundIndex <= current_roundIndex , 此时 execute按钮出现了, 可以执行确认动作
api.tx.xxxx
取消
比如: 用户 U, Collator A,B U stake 给 A,B => 显示两条记录, 此时两条都有 revoke按钮
execute 为什么有 delegator参数, 而 cancel 没有这个参数? execute 可以由别人代为执行 cancel 只能自己执行,默认是针对当前caller
finished and ready to test on the test env.
https://www.notion.so/web3builders/Web3Go-Moonbeam-staking-pallet-Unstaking-Scheduled-unstaking-doc-8713a31bf27c4978a284e8991cd69931 unstaking文档