-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imp: allow memo strings instead of keys for transfer authorizations (#…
…6268) * imp: allow memo strings instead of keys for transfer authorizations * add changelog * handle error from compact * return error * improve test * not enforce that memo strings of allowed packet data must be JSON-encoded strings * use slices contains to check if memo is allowed * Update modules/apps/transfer/types/transfer_authorization.go Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com> * Update modules/apps/transfer/types/transfer_authorization.go Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com> * lint --------- Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com> (cherry picked from commit 0a22b7a) # Conflicts: # docs/docs/02-apps/01-transfer/08-authorizations.md # modules/apps/transfer/types/authz.pb.go # modules/apps/transfer/types/keys.go # modules/apps/transfer/types/transfer_authorization.go # modules/apps/transfer/types/transfer_authorization_test.go # proto/ibc/applications/transfer/v1/authz.proto
- Loading branch information
1 parent
2e7e3ea
commit e1b16cc
Showing
7 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Authorizations | ||
sidebar_label: Authorizations | ||
sidebar_position: 8 | ||
slug: /apps/transfer/authorizations | ||
--- | ||
# `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](https://docs.cosmos.network/v0.47/modules/authz) 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 `SourcePort` and a `SourceChannel` which together comprise the unique transfer channel identifier over which authorized funds can be transferred. | ||
|
||
- a `SpendLimit` that specifies the maximum amount of tokens the grantee can transfer. The `SpendLimit` is 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 the `SpendLimit` will 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 function `UnboundedSpendLimit` in the `types` package of the `transfer` module provides the sentinel value that can be used. This `SpendLimit` may also be updated to increase or decrease the limit as the granter wishes. | ||
|
||
- an `AllowList` list 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 the `TransferAuthorization`. | ||
|
||
- an `AllowedPacketData` list 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 (a `memo` field with non-empty content will be denied). If this list includes a single element equal to `"*"`, then any content in `memo` field will be allowed. | ||
|
||
Setting a `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 `memo` field is not allowed by `AllowedPacketData` | ||
|
||
Below is the `TransferAuthorization` message: | ||
|
||
```go | ||
func NewTransferAuthorization(allocations ...Allocation) *TransferAuthorization { | ||
return &TransferAuthorization{ | ||
Allocations: allocations, | ||
} | ||
} | ||
|
||
type Allocation struct { | ||
// the port on which the packet will be sent | ||
SourcePort string | ||
// the channel by which the packet will be sent | ||
SourceChannel string | ||
// spend limitation on the channel | ||
SpendLimit sdk.Coins | ||
// allow list of receivers, an empty allow list permits any receiver address | ||
AllowList []string | ||
// allow list of memo strings, an empty list prohibits all memo strings; | ||
// a list only with "*" permits any memo string | ||
AllowedPacketData []string | ||
} | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters