TransferAuthorization 为 ibc.applications.transfer.v1.MsgTransfer 实现了 Authorization 接口。它允许授权方将代表自己提交 MsgTransfer 的权限授予被授权方。关于通过 x/authz 模块授予权限的更多细节,请参阅 Cosmos SDK 文档。
更具体地说,授权方允许被授权方通过指定通道转出属于授权方的资金。
对于指定通道,授权方必须能够为特定面额设置支出上限,以允许被授权方转移该面额的资产。
授权方还可以指定允许接收资金的地址列表。如果该列表为空,则允许所有地址接收。
其包含以下内容:
SourcePort和SourceChannel,二者共同构成唯一的转账通道标识符,授权资金可通过该通道转移。SpendLimit,用于指定被授权方可转移的最大代币数量。随着代币被转出,SpendLimit会相应更新;但如果金额使用 256 位无符号整数最大值这一哨兵值(即 2^256 - 1),则SpendLimit不会更新(请注意,使用该哨兵值将授予被授权方转移授权方账户中该面额 全部 可用代币的权限)。transfer模块types包中的辅助函数UnboundedSpendLimit提供了可使用的该哨兵值。授权方也可以根据需要更新SpendLimit,以提高或降低限额。AllowList列表,用于指定允许接收资金的地址列表。如果该列表为空,则允许所有地址从TransferAuthorization接收资金。AllowedPacketData列表,用于指定允许出现在数据包memo字段中的备注字符串列表。如果该列表为空,则只允许空memo(包含非空内容的memo字段会被拒绝)。如果该列表只包含一个值为"*"的元素,则memo字段中允许包含任意内容。
TransferAuthorization 预期会失败:
- 支出上限为 nil
- 支出上限的面额不是合法的 coin 类型
- 源端口 ID 非法
- 源通道 ID 非法
AllowList中存在重复项memo字段不被AllowedPacketData允许
TransferAuthorization 消息:
TransferAuthorization implements the Authorization interface for ibc.applications.transfer.v1.MsgTransfer. It allows a granter to grant a grantee the privilege to submit MsgTransfer on its behalf. Please see the Cosmos SDK docs for more details on granting privileges via the x/authz module.
More specifically, the granter allows the grantee to transfer funds that belong to the granter over a specified channel.
For the specified channel, the granter must be able to specify a spend limit of a specific denomination they wish to allow the grantee to be able to transfer.
The granter may be able to specify the list of addresses that they allow to receive funds. If empty, then all addresses are allowed.
It takes:
- a
SourcePortand aSourceChannelwhich together comprise the unique transfer channel identifier over which authorized funds can be transferred. - a
SpendLimitthat specifies the maximum amount of tokens the grantee can transfer. TheSpendLimitis updated as the tokens are transferred, unless the sentinel value of the maximum value for a 256-bit unsigned integer (i.e. 2^256 - 1) is used for the amount, in which case theSpendLimitwill not be updated (please be aware that using this sentinel value will grant the grantee the privilege to transfer all the tokens of a given denomination available at the granter’s account). The helper functionUnboundedSpendLimitin thetypespackage of thetransfermodule provides the sentinel value that can be used. ThisSpendLimitmay also be updated to increase or decrease the limit as the granter wishes. - an
AllowListlist that specifies the list of addresses that are allowed to receive funds. If this list is empty, then all addresses are allowed to receive funds from theTransferAuthorization. - an
AllowedPacketDatalist that specifies the list of memo strings that are allowed to be included in the memo field of the packet. If this list is empty, then only an empty memo is allowed (amemofield with non-empty content will be denied). If this list includes a single element equal to"*", then any content inmemofield will be allowed.
TransferAuthorization is expected to fail if:
- the spend limit is nil
- the denomination of the spend limit is an invalid coin type
- the source port ID is invalid
- the source channel ID is invalid
- there are duplicate entries in the
AllowList - the
memofield is not allowed byAllowedPacketData
TransferAuthorization message: