forked from Kava-Labs/kava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update evmutil specs (Kava-Labs#1356)
- Loading branch information
Showing
6 changed files
with
172 additions
and
28 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
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,65 @@ | ||
<!-- | ||
order: 3 | ||
--> | ||
|
||
# Messages | ||
|
||
Users can submit various messages to the evmutil module which trigger state changes detailed below. | ||
|
||
## MsgConvertERC20ToCoin | ||
|
||
`MsgConvertCoinToERC20` converts a Kava ERC20 coin to sdk.Coin. | ||
|
||
```protobuf | ||
service Msg { | ||
// ConvertERC20ToCoin defines a method for converting Kava ERC20 to sdk.Coin. | ||
rpc ConvertERC20ToCoin(MsgConvertERC20ToCoin) returns (MsgConvertERC20ToCoinResponse); | ||
} | ||
// MsgConvertERC20ToCoin defines a conversion from Kava ERC20 to sdk.Coin. | ||
message MsgConvertERC20ToCoin { | ||
// EVM 0x hex address initiating the conversion. | ||
string initiator = 1; | ||
// Kava bech32 address that will receive the converted sdk.Coin. | ||
string receiver = 2; | ||
// EVM 0x hex address of the ERC20 contract. | ||
string kava_erc20_address = 3; | ||
// ERC20 token amount to convert. | ||
string amount = 4 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
]; | ||
} | ||
``` | ||
|
||
### State Changes | ||
|
||
- The `EnabledConversionPairs` param from `x/evmutil` is checked to ensure the conversion pair is enabled. | ||
- The initiator's ERC20 token from `kava_erc20_address` is locked by transferring it from the initiator's 0x address to the `x/evmutil` module account's 0x address. | ||
- The same amount of sdk.Coin are minted for the corresponding denom of the `kava_erc20_address` in the `EnabledConversionPairs` param. The coins are then transferred to the receiver's Kava address. | ||
|
||
## MsgConvertCoinToERC20 | ||
|
||
`MsgConvertCoinToERC20` converts sdk.Coin to Kava ERC20. | ||
|
||
```protobuf | ||
service Msg { | ||
// ConvertCoinToERC20 defines a method for converting sdk.Coin to Kava ERC20. | ||
rpc ConvertCoinToERC20(MsgConvertCoinToERC20) returns (MsgConvertCoinToERC20Response); | ||
} | ||
// MsgConvertCoinToERC20 defines a conversion from sdk.Coin to Kava ERC20. | ||
message MsgConvertCoinToERC20 { | ||
// Kava bech32 address initiating the conversion. | ||
string initiator = 1; | ||
// EVM 0x hex address that will receive the converted Kava ERC20 tokens. | ||
string receiver = 2; | ||
// Amount is the sdk.Coin amount to convert. | ||
cosmos.base.v1beta1.Coin amount = 3; | ||
} | ||
``` | ||
|
||
### State Changes | ||
|
||
- The `EnabledConversionPairs` param from `x/evmutil` is checked to ensure the conversion pair is enabled. | ||
- The specified sdk.Coin is moved from the initiator's address to the module account and burned. | ||
- The same amount of ERC20 coins are sent from the `x/evmutil` module account to the 0x receiver address. |
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,31 @@ | ||
<!-- | ||
order: 4 | ||
--> | ||
|
||
# Events | ||
|
||
The evmutil module emits the following events: | ||
|
||
## Handlers | ||
|
||
### MsgConvertERC20ToCoin | ||
|
||
| Type | Attribute Key | Attribute Value | | ||
| --------------------- | ------------- | ------------------ | | ||
| convert_erc20_to_coin | erc20_address | `{erc20 address}` | | ||
| convert_erc20_to_coin | initiator | `{initiator}` | | ||
| convert_erc20_to_coin | receiver | `{receiver}` | | ||
| convert_erc20_to_coin | amount | `{amount}` | | ||
| message | module | evmutil | | ||
| message | sender | {'sender address}' | | ||
|
||
### MsgConvertCoinToERC20 | ||
|
||
| Type | Attribute Key | Attribute Value | | ||
| --------------------- | ------------- | ------------------ | | ||
| convert_coin_to_erc20 | initiator | `{initiator}` | | ||
| convert_coin_to_erc20 | receiver | `{receiver}` | | ||
| convert_coin_to_erc20 | erc20_address | `{erc20_address}` | | ||
| convert_coin_to_erc20 | amount | `{amount}` | | ||
| message | module | evmutil | | ||
| message | sender | {'sender address}' | |
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,22 @@ | ||
<!-- | ||
order: 5 | ||
--> | ||
|
||
# Parameters | ||
|
||
The evmutil module contains the following parameters: | ||
|
||
| Key | Type | Example | | ||
| ---------------------- | ---------------------- | ------------- | | ||
| EnabledConversionPairs | array (ConversionPair) | [{see below}] | | ||
|
||
Example parameters for `ConversionPair`: | ||
|
||
| Key | Type | Example | Description | | ||
| ------------------ | ------ | -------------------------------------------- | ---------------------------------- | | ||
| kava_erc20_Address | string | "0x43d8814fdfb9b8854422df13f1c66e34e4fa91fd" | ERC20 contract address | | ||
| denom | string | "erc20/chain/usdc" | sdk.Coin denom for the ERC20 token | | ||
|
||
## EnabledConversionPairs | ||
|
||
The enabled conversion pairs parameter is an array of ConversionPair entries mapping an erc20 address to a sdk.Coin denom. Only erc20 contract addresses that are in this list can be converted to sdk.Coin and vice versa. |
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