Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token factory documentation #1545

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/upgrades/v9/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func CreateUpgradeHandler(
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ExecuteProp214(ctx, keepers.GAMMKeeper)
// We set the app version to pre-upgrade because it will be incremented by one

// We set the app version to pre-upgrade because it will be incremented by one
// after the upgrade is applied by the handler.
if err := keepers.UpgradeKeeper.SetAppVersion(ctx, preUpgradeAppVersion); err != nil {
return nil, err
Expand Down
71 changes: 71 additions & 0 deletions x/tokenfactory/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,74 @@ created denom. Once a denom is created, the original creator is given
accounts using the authz module. The `ChangeAdmin` functionality,
allows changing the master admin account, or even setting it to
`""`, meaning no account has admin privileges of the asset.


## Messages

### CreateDenom
- Creates a denom of `factory/{creator address}/{nonce}` given the denom creator address and the denom nonce. The case a denom has a slash in its nonce is handled within the module.
``` {.go}
message MsgCreateDenom {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
string nonce = 2 [ (gogoproto.moretags) = "yaml:\"nonce\"" ];
}
```

**State Modifications:**
- Fund community pool with the denom creation fee from the creator address, set in `Params`
- Set `DenomMetaData` via bank keeper
- Set `AuthorityMetadata` for the given denom to store the admin for the created denom `factory/{creator address}/{nonce}`. Admin is automatically set as the Msg sender
- Add denom to the `CreatorPrefixStore`, where a state of denoms created per creator is kept

### Mint
- Minting of a specific denom is only allowed for the creator of the denom registered during `CreateDenom`
``` {.go}
message MsgMint {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
}
```

**State Modifications:**
- Saftey check the following
- Check that the denom minting is created via `tokenfactory` module
- Check that the sender of the message is the admin of the denom
- Mint designated amount of tokens for the denom via `bank` module



### Burn
- Burning of a specific denom is only allowed for the creator of the denom registered during `CreateDenom`
``` {.go}
message MsgBurn {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
cosmos.base.v1beta1.Coin amount = 2 [
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.nullable) = false
];
}
```

**State Modifications:**
- Saftey check the following
- Check that the denom minting is created via `tokenfactory` module
- Check that the sender of the message is the admin of the denom
- Burn designated amount of tokens for the denom via `bank` module


### ChangeAdmin
- Burning of a specific denom is only allowed for the creator of the denom registered during `CreateDenom`
``` {.go}
message MsgChangeAdmin {
string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ];
string denom = 2 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
string newAdmin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ];
}
```

**State Modifications:**
- Check that sender of the message is the admin of denom
- Modify `AuthorityMetadata` state entry to change the admin of the denom