-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1943 from CosmWasm/go-gen-fixes
go-gen fixes
Showing
7 changed files
with
347 additions
and
18 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,24 @@ | ||
// SendMsg contains instructions for a Cosmos-SDK/SendMsg | ||
// It has a fixed interface here and should be converted into the proper SDK format before dispatching | ||
type SendMsg struct { | ||
Amount []Coin `json:"amount"` | ||
ToAddress string `json:"to_address"` | ||
} | ||
|
||
// BurnMsg will burn the given coins from the contract's account. | ||
// There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. | ||
// Important if a contract controls significant token supply that must be retired. | ||
type BurnMsg struct { | ||
Amount []Coin `json:"amount"` | ||
} | ||
|
||
type BankMsg struct { | ||
Send *SendMsg `json:"send,omitempty"` | ||
Burn *BurnMsg `json:"burn,omitempty"` | ||
} | ||
|
||
// Coin is a string representation of the sdk.Coin type (more portable than sdk.Int) | ||
type Coin struct { | ||
Amount string `json:"amount"` // string encoing of decimal value, eg. "12.3456" | ||
Denom string `json:"denom"` // type, eg. "ATOM" | ||
} |
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,32 @@ | ||
// SetWithdrawAddressMsg is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). | ||
// `delegator_address` is automatically filled with the current contract's address. | ||
type SetWithdrawAddressMsg struct { | ||
// Address contains the `delegator_address` of a MsgSetWithdrawAddress | ||
Address string `json:"address"` | ||
} | ||
|
||
// WithdrawDelegatorRewardMsg is translated to a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). | ||
// `delegator_address` is automatically filled with the current contract's address. | ||
type WithdrawDelegatorRewardMsg struct { | ||
// Validator contains `validator_address` of a MsgWithdrawDelegatorReward | ||
Validator string `json:"validator"` | ||
} | ||
|
||
// FundCommunityPoolMsg is translated to a [MsgFundCommunityPool](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#LL69C1-L76C2). | ||
// `depositor` is automatically filled with the current contract's address | ||
type FundCommunityPoolMsg struct { | ||
// Amount is the list of coins to be send to the community pool | ||
Amount []Coin `json:"amount"` | ||
} | ||
|
||
type DistributionMsg struct { | ||
SetWithdrawAddress *SetWithdrawAddressMsg `json:"set_withdraw_address,omitempty"` | ||
WithdrawDelegatorReward *WithdrawDelegatorRewardMsg `json:"withdraw_delegator_reward,omitempty"` | ||
FundCommunityPool *FundCommunityPoolMsg `json:"fund_community_pool,omitempty"` | ||
} | ||
|
||
// Coin is a string representation of the sdk.Coin type (more portable than sdk.Int) | ||
type Coin struct { | ||
Amount string `json:"amount"` // string encoing of decimal value, eg. "12.3456" | ||
Denom string `json:"denom"` // type, eg. "ATOM" | ||
} |
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,47 @@ | ||
type TransferMsg struct { | ||
Amount Coin `json:"amount"` | ||
ChannelID string `json:"channel_id"` | ||
Memo string `json:"memo,omitempty"` // this is not yet in wasmvm, but will be soon | ||
Timeout IBCTimeout `json:"timeout"` | ||
ToAddress string `json:"to_address"` | ||
} | ||
type SendPacketMsg struct { | ||
ChannelID string `json:"channel_id"` | ||
Data []byte `json:"data"` | ||
Timeout IBCTimeout `json:"timeout"` | ||
} | ||
type CloseChannelMsg struct { | ||
ChannelID string `json:"channel_id"` | ||
} | ||
|
||
type IBCMsg struct { | ||
Transfer *TransferMsg `json:"transfer,omitempty"` | ||
SendPacket *SendPacketMsg `json:"send_packet,omitempty"` | ||
CloseChannel *CloseChannelMsg `json:"close_channel,omitempty"` | ||
} | ||
|
||
// Coin is a string representation of the sdk.Coin type (more portable than sdk.Int) | ||
type Coin struct { | ||
Amount string `json:"amount"` // string encoing of decimal value, eg. "12.3456" | ||
Denom string `json:"denom"` // type, eg. "ATOM" | ||
} | ||
|
||
// IBCTimeout is the timeout for an IBC packet. At least one of block and timestamp is required. | ||
type IBCTimeout struct { | ||
Block *IBCTimeoutBlock `json:"block,omitempty"` // in wasmvm, this does not have "omitempty" | ||
// Nanoseconds since UNIX epoch | ||
Timestamp *Uint64 `json:"timestamp,omitempty"` | ||
} | ||
|
||
// IBCTimeoutBlock Height is a monotonically increasing data type | ||
// that can be compared against another Height for the purposes of updating and | ||
// freezing clients. | ||
// Ordering is (revision_number, timeout_height) | ||
type IBCTimeoutBlock struct { | ||
// block height after which the packet times out. | ||
// the height within the given revision | ||
Height uint64 `json:"height"` | ||
// the version that the client is currently on | ||
// (eg. after reseting the chain this could increment 1 as height drops to 0) | ||
Revision uint64 `json:"revision"` | ||
} |
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,25 @@ | ||
type DelegateMsg struct { | ||
Amount Coin `json:"amount"` | ||
Validator string `json:"validator"` | ||
} | ||
type UndelegateMsg struct { | ||
Amount Coin `json:"amount"` | ||
Validator string `json:"validator"` | ||
} | ||
type RedelegateMsg struct { | ||
Amount Coin `json:"amount"` | ||
DstValidator string `json:"dst_validator"` | ||
SrcValidator string `json:"src_validator"` | ||
} | ||
|
||
type StakingMsg struct { | ||
Delegate *DelegateMsg `json:"delegate,omitempty"` | ||
Undelegate *UndelegateMsg `json:"undelegate,omitempty"` | ||
Redelegate *RedelegateMsg `json:"redelegate,omitempty"` | ||
} | ||
|
||
// Coin is a string representation of the sdk.Coin type (more portable than sdk.Int) | ||
type Coin struct { | ||
Amount string `json:"amount"` // string encoing of decimal value, eg. "12.3456" | ||
Denom string `json:"denom"` // type, eg. "ATOM" | ||
} |
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,115 @@ | ||
// ExecuteMsg is used to call another defined contract on this chain. | ||
// The calling contract requires the callee to be defined beforehand, | ||
// and the address should have been defined in initialization. | ||
// And we assume the developer tested the ABIs and coded them together. | ||
// | ||
// Since a contract is immutable once it is deployed, we don't need to transform this. | ||
// If it was properly coded and worked once, it will continue to work throughout upgrades. | ||
type ExecuteMsg struct { | ||
// ContractAddr is the sdk.AccAddress of the contract, which uniquely defines | ||
// the contract ID and instance ID. The sdk module should maintain a reverse lookup table. | ||
ContractAddr string `json:"contract_addr"` | ||
// Send is an optional amount of coins this contract sends to the called contract | ||
Funds []Coin `json:"funds"` | ||
// Msg is assumed to be a json-encoded message, which will be passed directly | ||
// as `userMsg` when calling `Handle` on the above-defined contract | ||
Msg []byte `json:"msg"` | ||
} | ||
|
||
// InstantiateMsg will create a new contract instance from a previously uploaded CodeID. | ||
// This allows one contract to spawn "sub-contracts". | ||
type InstantiateMsg struct { | ||
// Admin (optional) may be set here to allow future migrations from this address | ||
Admin string `json:"admin,omitempty"` | ||
// CodeID is the reference to the wasm byte code as used by the Cosmos-SDK | ||
CodeID uint64 `json:"code_id"` | ||
// Send is an optional amount of coins this contract sends to the called contract | ||
Funds []Coin `json:"funds"` | ||
// Label is optional metadata to be stored with a contract instance. | ||
Label string `json:"label"` | ||
// Msg is assumed to be a json-encoded message, which will be passed directly | ||
// as `userMsg` when calling `Instantiate` on a new contract with the above-defined CodeID | ||
Msg []byte `json:"msg"` | ||
} | ||
|
||
// Instantiate2Msg will create a new contract instance from a previously uploaded CodeID | ||
// using the predictable address derivation. | ||
type Instantiate2Msg struct { | ||
// Admin (optional) may be set here to allow future migrations from this address | ||
Admin string `json:"admin,omitempty"` | ||
// CodeID is the reference to the wasm byte code as used by the Cosmos-SDK | ||
CodeID uint64 `json:"code_id"` | ||
// Send is an optional amount of coins this contract sends to the called contract | ||
Funds []Coin `json:"funds"` | ||
// Label is optional metadata to be stored with a contract instance. | ||
Label string `json:"label"` | ||
// Msg is assumed to be a json-encoded message, which will be passed directly | ||
// as `userMsg` when calling `Instantiate` on a new contract with the above-defined CodeID | ||
Msg []byte `json:"msg"` | ||
Salt []byte `json:"salt"` | ||
} | ||
|
||
// MigrateMsg will migrate an existing contract from it's current wasm code (logic) | ||
// to another previously uploaded wasm code. It requires the calling contract to be | ||
// listed as "admin" of the contract to be migrated. | ||
type MigrateMsg struct { | ||
// ContractAddr is the sdk.AccAddress of the target contract, to migrate. | ||
ContractAddr string `json:"contract_addr"` | ||
// Msg is assumed to be a json-encoded message, which will be passed directly | ||
// as `userMsg` when calling `Migrate` on the above-defined contract | ||
Msg []byte `json:"msg"` | ||
// NewCodeID is the reference to the wasm byte code for the new logic to migrate to | ||
NewCodeID uint64 `json:"new_code_id"` | ||
} | ||
|
||
// UpdateAdminMsg is the Go counterpart of WasmMsg::UpdateAdmin | ||
// (https://github.com/CosmWasm/cosmwasm/blob/v0.14.0-beta5/packages/std/src/results/cosmos_msg.rs#L158-L160). | ||
type UpdateAdminMsg struct { | ||
// Admin is the sdk.AccAddress of the new admin. | ||
Admin string `json:"admin"` | ||
// ContractAddr is the sdk.AccAddress of the target contract. | ||
ContractAddr string `json:"contract_addr"` | ||
} | ||
|
||
// ClearAdminMsg is the Go counterpart of WasmMsg::ClearAdmin | ||
// (https://github.com/CosmWasm/cosmwasm/blob/v0.14.0-beta5/packages/std/src/results/cosmos_msg.rs#L158-L160). | ||
type ClearAdminMsg struct { | ||
// ContractAddr is the sdk.AccAddress of the target contract. | ||
ContractAddr string `json:"contract_addr"` | ||
} | ||
|
||
// The message types of the wasm module. | ||
// | ||
// See https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto | ||
type WasmMsg struct { | ||
// Dispatches a call to another contract at a known address (with known ABI). | ||
// | ||
// This is translated to a [MsgExecuteContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L68-L78). `sender` is automatically filled with the current contract's address. | ||
Execute *ExecuteMsg `json:"execute,omitempty"` | ||
// Instantiates a new contracts from previously uploaded Wasm code. | ||
// | ||
// The contract address is non-predictable. But it is guaranteed that when emitting the same Instantiate message multiple times, multiple instances on different addresses will be generated. See also Instantiate2. | ||
// | ||
// This is translated to a [MsgInstantiateContract](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L53-L71). `sender` is automatically filled with the current contract's address. | ||
Instantiate *InstantiateMsg `json:"instantiate,omitempty"` | ||
// Instantiates a new contracts from previously uploaded Wasm code using a predictable address derivation algorithm implemented in [`cosmwasm_std::instantiate2_address`]. | ||
// | ||
// This is translated to a [MsgInstantiateContract2](https://github.com/CosmWasm/wasmd/blob/v0.29.2/proto/cosmwasm/wasm/v1/tx.proto#L73-L96). `sender` is automatically filled with the current contract's address. `fix_msg` is automatically set to false. | ||
Instantiate2 *Instantiate2Msg `json:"instantiate2,omitempty"` | ||
// Migrates a given contracts to use new wasm code. Passes a MigrateMsg to allow us to customize behavior. | ||
// | ||
// Only the contract admin (as defined in wasmd), if any, is able to make this call. | ||
// | ||
// This is translated to a [MsgMigrateContract](https://github.com/CosmWasm/wasmd/blob/v0.14.0/x/wasm/internal/types/tx.proto#L86-L96). `sender` is automatically filled with the current contract's address. | ||
Migrate *MigrateMsg `json:"migrate,omitempty"` | ||
// Sets a new admin (for migrate) on the given contract. Fails if this contract is not currently admin of the target contract. | ||
UpdateAdmin *UpdateAdminMsg `json:"update_admin,omitempty"` | ||
// Clears the admin on the given contract, so no more migration possible. Fails if this contract is not currently admin of the target contract. | ||
ClearAdmin *ClearAdminMsg `json:"clear_admin,omitempty"` | ||
} | ||
|
||
// Coin is a string representation of the sdk.Coin type (more portable than sdk.Int) | ||
type Coin struct { | ||
Amount string `json:"amount"` // string encoing of decimal value, eg. "12.3456" | ||
Denom string `json:"denom"` // type, eg. "ATOM" | ||
} |