-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
644 additions
and
56 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<!-- | ||
order: 4 | ||
--> | ||
|
||
# Messages | ||
|
||
The asset module exposes the following messages: | ||
|
||
## MessageCreateToken | ||
|
||
```go | ||
type MsgCreateToken struct { | ||
Creator string | ||
Manager string | ||
Name string | ||
Symbol string | ||
Decimal string | ||
ExcludedPrivileges []string | ||
AddNewPrivileges bool | ||
} | ||
``` | ||
|
||
`MessageCreateToken` allows a whitelisted account to create a token with custom configuration. | ||
|
||
## MessageAllocateToken | ||
|
||
```go | ||
type MsgAllocateToken struct { | ||
Manager string | ||
TokenID string | ||
Balances []Balance | ||
VestingBalances []VestingAccount | ||
} | ||
``` | ||
|
||
`MessageAllocateToken` can only be executed by the token manager once after their token is successfully created. It will allocate tokens (either vesting or liquid) to the list of accounts sepecifed in the message. | ||
|
||
## MessageAssignPrivilege | ||
|
||
```go | ||
type MsgAssignPrivilege struct { | ||
Manager string | ||
TokenID string | ||
AssignedTo []string | ||
Privilege string | ||
} | ||
``` | ||
|
||
`MessageAssignPrivilege` allows the token manager to assign a privilege to the chosen addresses. This message will fail if the privilege is in the list of `ExcludedPrivileges` specified when creating the token. | ||
|
||
## MessageUnassignPrivilege | ||
|
||
```go | ||
type MsgAssignPrivilege struct { | ||
Manager string | ||
TokenID string | ||
UnassignedFrom []string | ||
Privilege string | ||
} | ||
``` | ||
|
||
`MessageUnassignPrivilege` allows the token manager to unassign a privilege from the chosen addresses. | ||
|
||
## MessageDisablePrivilege | ||
|
||
```go | ||
type MsgDisablePrivilege struct { | ||
Manager string | ||
TokenID string | ||
DisabledPrivilege string | ||
} | ||
``` | ||
|
||
`MessageDisablePrivilege` allows the token manager to disable a privilege permanently, it will also unassigns all the accounts with that privilege. | ||
|
||
## MessageExecutePrivilege | ||
|
||
```go | ||
type PrivilegeMsg interface { | ||
Privilege() string | ||
} | ||
|
||
type MsgExecute struct { | ||
Address string | ||
TokenID string | ||
PrivilegeMsg PrivilegeMsg | ||
} | ||
``` | ||
|
||
`PrivilegeMsg` allows privileged accounts to execute logic of its privilege. For that reason, it has different implementations defined by each types of privilege instead of the `Asset Module`. These implementations and the logic to handle them are registered into the module via `RegisterPrivilege` method. |
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,5 @@ | ||
<!-- | ||
order: 5 | ||
--> | ||
|
||
# Client |
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,56 @@ | ||
<!-- | ||
order: 6 | ||
--> | ||
|
||
# Logic | ||
|
||
This file describes the core logics in this module. | ||
|
||
## Token creation process | ||
|
||
This process is triggered by `MsgCreateToken`. | ||
|
||
Validation: | ||
|
||
- Check if `Creator` is whitelisted. We only allow some certain accounts to create tokens, these accounts is determined via gov proposal. | ||
- Check if the token with the same denom has already existed. | ||
|
||
Flow: | ||
|
||
1. The denom for the token will be derived from `Creator` and `Symbol` with the format of `asset/{Manager}/{Symbol}` | ||
2. Save the token basic information (name, symbol, decimal and description) in the x/bank metadata store | ||
3. Save the token management info (`Manager`, `ExcludedPrivileges` and `AddNewPrivilege`) in the x/asset store. | ||
|
||
Note that here we prefixed the token denom with the manager address in order to allow many different creators to create token with the same symbol, differentiate their denom by including in their creator. | ||
|
||
## Register a privilege | ||
|
||
Each type of privilege enables a set of messages to be executed. | ||
|
||
MintPrivilege { | ||
storeKey | ||
mintKeeper MintKeeper | ||
bankKeeper BankKeeper | ||
} | ||
|
||
func Wrap | ||
|
||
```go | ||
type handler func(ctx, store, msg) | ||
|
||
|
||
MintPrivilege func Handle (ctx, store, msg) error{ | ||
func | ||
|
||
|
||
} | ||
|
||
type Privilege interface { | ||
|
||
RegisterMsgHandlers(msgType string, MsgHandler func(ctx, store, msg) ) | ||
RegisterCodec() | ||
RegisterQuerier(queryType string, ) | ||
|
||
} | ||
|
||
``` |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!-- | ||
order: 4 | ||
order: 5 | ||
--> | ||
|
||
# Events | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!-- | ||
order: 4 | ||
order: 6 | ||
--> | ||
|
||
# Client | ||
|