From e2668ad80ddba3c9eaad7b0e3cdace5ba31be86e Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Fri, 3 Jan 2025 14:51:07 +0800 Subject: [PATCH 01/10] feat: IWrappedA0GIBase --- .../interfaces/contracts/IWrappedA0GIBase.sol | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 precompiles/interfaces/contracts/IWrappedA0GIBase.sol diff --git a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol new file mode 100644 index 00000000..e5a9aa7a --- /dev/null +++ b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: LGPL-3.0-only +pragma solidity >=0.8.0; + +/** + * @title WrappedA0GIBase is a precompile for wrapped a0gi(wA0GI), it enables wA0GI mint/burn native 0g token directly. + */ +interface IWrappedA0GIBase { + struct Supply { + uint256 cap; + uint256 total; + } + + /** + * @dev set the wA0GI address. + * It is designed to be called by governance module only so it's not implemented at EVM precompile side. + * @param + */ + // function setWA0GI(address addr) external; + + /** + * @dev set the cap for a minter. + * It is designed to be called by governance module only so it's not implemented at EVM precompile side. + * @param minter minter address + * @param cap mint cap + */ + // function setMinterCap(address minter, uint256 cap) external; + + /** + * @dev get the mint supply of given address + * @param minter minter address + */ + function minterSupply(address minter) external view returns (Supply memory); + + /** + * @dev mint a0gi to given address directly, add corresponding amount to minter's mint supply. + * If sender's final mint supply exceeds its mint cap, the transaction will revert. + * Can only be called by + * + * @param minter minter address + * @param to recipient address + * @param amount amount to mint + */ + function mint(address minter, address to, uint256 amount) external; + + /** + * @dev burn given amount of a0gi on behalf of minter, reduce corresponding amount from sender's mint supply. + * @param minter minter address + * @param amount amount to burn + */ + function burn(address minter, uint256 amount) external; +} From 0ff16c798aaac4a79bf0f813953402b27e34ea84 Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:22:25 +0800 Subject: [PATCH 02/10] fmt: proto --- .../proto/cosmos/auth/v1beta1/auth.proto | 4 +- .../proto/cosmos/bank/v1beta1/bank.proto | 2 +- .../cosmos/base/store/v1beta1/listening.proto | 22 +++--- .../cosmos/distribution/v1beta1/tx.proto | 4 +- .../cosmos/evidence/v1beta1/evidence.proto | 6 +- .../proto/cosmos/evidence/v1beta1/tx.proto | 2 +- third_party/proto/cosmos/gov/v1/gov.proto | 30 ++++---- third_party/proto/cosmos/gov/v1/tx.proto | 24 +++---- .../proto/cosmos/gov/v1beta1/gov.proto | 18 ++--- third_party/proto/cosmos/gov/v1beta1/tx.proto | 16 ++--- .../proto/cosmos/mint/v1beta1/mint.proto | 27 +++++++- third_party/proto/cosmos/tx/v1beta1/tx.proto | 6 +- .../cosmos/upgrade/v1beta1/upgrade.proto | 6 +- .../proto/cosmos/vesting/v1beta1/tx.proto | 4 +- .../cosmos/vesting/v1beta1/vesting.proto | 2 +- third_party/proto/ethermint/evm/v1/evm.proto | 19 ++---- .../applications/transfer/v1/transfer.proto | 4 +- third_party/proto/tendermint/abci/types.proto | 68 +++++++++---------- .../proto/tendermint/types/evidence.proto | 2 +- .../proto/tendermint/types/params.proto | 2 +- .../proto/tendermint/types/types.proto | 28 ++++---- 21 files changed, 157 insertions(+), 139 deletions(-) diff --git a/third_party/proto/cosmos/auth/v1beta1/auth.proto b/third_party/proto/cosmos/auth/v1beta1/auth.proto index 0578453c..f09df382 100644 --- a/third_party/proto/cosmos/auth/v1beta1/auth.proto +++ b/third_party/proto/cosmos/auth/v1beta1/auth.proto @@ -17,8 +17,8 @@ message BaseAccount { option (gogoproto.equal) = false; option (cosmos_proto.implements_interface) = "cosmos.auth.v1beta1.AccountI"; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"]; + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"]; uint64 account_number = 3; uint64 sequence = 4; } diff --git a/third_party/proto/cosmos/bank/v1beta1/bank.proto b/third_party/proto/cosmos/bank/v1beta1/bank.proto index 483540db..f81bb923 100644 --- a/third_party/proto/cosmos/bank/v1beta1/bank.proto +++ b/third_party/proto/cosmos/bank/v1beta1/bank.proto @@ -98,7 +98,7 @@ message Metadata { string description = 1; // denom_units represents the list of DenomUnit's for a given coin repeated DenomUnit denom_units = 2; - // base represents the evm denom (should be the DenomUnit with exponent = 0). + // base represents the base denom (should be the DenomUnit with exponent = 0). string base = 3; // display indicates the suggested denom that should be // displayed in clients. diff --git a/third_party/proto/cosmos/base/store/v1beta1/listening.proto b/third_party/proto/cosmos/base/store/v1beta1/listening.proto index 753f7c16..d6f71289 100644 --- a/third_party/proto/cosmos/base/store/v1beta1/listening.proto +++ b/third_party/proto/cosmos/base/store/v1beta1/listening.proto @@ -20,15 +20,15 @@ message StoreKVPair { // BlockMetadata contains all the abci event data of a block // the file streamer dump them into files together with the state changes. message BlockMetadata { - // DeliverTx encapulate deliver tx request and response. - message DeliverTx { - tendermint.abci.RequestDeliverTx request = 1; - tendermint.abci.ResponseDeliverTx response = 2; - } - tendermint.abci.RequestBeginBlock request_begin_block = 1; - tendermint.abci.ResponseBeginBlock response_begin_block = 2; - repeated DeliverTx deliver_txs = 3; - tendermint.abci.RequestEndBlock request_end_block = 4; - tendermint.abci.ResponseEndBlock response_end_block = 5; - tendermint.abci.ResponseCommit response_commit = 6; + // DeliverTx encapulate deliver tx request and response. + message DeliverTx { + tendermint.abci.RequestDeliverTx request = 1; + tendermint.abci.ResponseDeliverTx response = 2; + } + tendermint.abci.RequestBeginBlock request_begin_block = 1; + tendermint.abci.ResponseBeginBlock response_begin_block = 2; + repeated DeliverTx deliver_txs = 3; + tendermint.abci.RequestEndBlock request_end_block = 4; + tendermint.abci.ResponseEndBlock response_end_block = 5; + tendermint.abci.ResponseCommit response_commit = 6; } diff --git a/third_party/proto/cosmos/distribution/v1beta1/tx.proto b/third_party/proto/cosmos/distribution/v1beta1/tx.proto index 957747cf..b921879a 100644 --- a/third_party/proto/cosmos/distribution/v1beta1/tx.proto +++ b/third_party/proto/cosmos/distribution/v1beta1/tx.proto @@ -162,8 +162,8 @@ message MsgCommunityPoolSpend { option (amino.name) = "cosmos-sdk/distr/MsgCommunityPoolSpend"; // authority is the address that controls the module (defaults to x/gov unless overwritten). - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string recipient = 2; + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string recipient = 2; repeated cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true, diff --git a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto index 8dca3201..195be98b 100644 --- a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto +++ b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto @@ -18,14 +18,14 @@ message Equivocation { option (gogoproto.equal) = false; // height is the equivocation height. - int64 height = 1; + int64 height = 1; // time is the equivocation time. - google.protobuf.Timestamp time = 2 + google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdtime) = true]; // power is the equivocation validator power. - int64 power = 3; + int64 power = 3; // consensus_address is the equivocation validator consensus address. string consensus_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; diff --git a/third_party/proto/cosmos/evidence/v1beta1/tx.proto b/third_party/proto/cosmos/evidence/v1beta1/tx.proto index f5646e2d..e6fe5c45 100644 --- a/third_party/proto/cosmos/evidence/v1beta1/tx.proto +++ b/third_party/proto/cosmos/evidence/v1beta1/tx.proto @@ -29,7 +29,7 @@ message MsgSubmitEvidence { option (gogoproto.goproto_getters) = false; // submitter is the signer account address of evidence. - string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // evidence defines the evidence of misbehavior. google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "cosmos.evidence.v1beta1.Evidence"]; diff --git a/third_party/proto/cosmos/gov/v1/gov.proto b/third_party/proto/cosmos/gov/v1/gov.proto index 49bfcc26..491b0d29 100644 --- a/third_party/proto/cosmos/gov/v1/gov.proto +++ b/third_party/proto/cosmos/gov/v1/gov.proto @@ -32,17 +32,17 @@ message WeightedVoteOption { VoteOption option = 1; // weight is the vote weight associated with the vote option. - string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"]; + string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"]; } // Deposit defines an amount deposited by an account address to an active // proposal. message Deposit { // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; @@ -51,33 +51,33 @@ message Deposit { // Proposal defines the core field members of a governance proposal. message Proposal { // id defines the unique id of the proposal. - uint64 id = 1; + uint64 id = 1; // messages are the arbitrary messages to be executed if the proposal passes. repeated google.protobuf.Any messages = 2; // status defines the proposal status. - ProposalStatus status = 3; + ProposalStatus status = 3; // final_tally_result is the final tally result of the proposal. When // querying a proposal via gRPC, this field is not populated until the // proposal's voting period has ended. - TallyResult final_tally_result = 4; + TallyResult final_tally_result = 4; // submit_time is the time of proposal submission. - google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true]; // deposit_end_time is the end time for deposition. - google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true]; // total_deposit is the total deposit on the proposal. - repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // voting_start_time is the starting time to vote on a proposal. - google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true]; // voting_end_time is the end time of voting on a proposal. - google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true]; // metadata is any arbitrary metadata attached to the proposal. string metadata = 10; @@ -122,11 +122,11 @@ enum ProposalStatus { // TallyResult defines a standard tally for a governance proposal. message TallyResult { // yes_count is the number of yes votes on a proposal. - string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"]; + string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"]; // abstain_count is the number of abstain votes on a proposal. - string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"]; + string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"]; // no_count is the number of no votes on a proposal. - string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"]; + string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"]; // no_with_veto_count is the number of no with veto votes on a proposal. string no_with_veto_count = 4 [(cosmos_proto.scalar) = "cosmos.Int"]; } @@ -138,7 +138,7 @@ message Vote { uint64 proposal_id = 1; // voter is the voter address of the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; reserved 3; diff --git a/third_party/proto/cosmos/gov/v1/tx.proto b/third_party/proto/cosmos/gov/v1/tx.proto index 1708066c..0cac6558 100644 --- a/third_party/proto/cosmos/gov/v1/tx.proto +++ b/third_party/proto/cosmos/gov/v1/tx.proto @@ -46,13 +46,13 @@ message MsgSubmitProposal { option (amino.name) = "cosmos-sdk/v1/MsgSubmitProposal"; // messages are the arbitrary messages to be executed if proposal passes. - repeated google.protobuf.Any messages = 1; + repeated google.protobuf.Any messages = 1; // initial_deposit is the deposit value that must be paid at proposal submission. repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // proposer is the account address of the proposer. - string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // metadata is any arbitrary metadata attached to the proposal. string metadata = 4; @@ -95,16 +95,16 @@ message MsgVote { option (amino.name) = "cosmos-sdk/v1/MsgVote"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // option defines the vote option. - VoteOption option = 3; + VoteOption option = 3; // metadata is any arbitrary metadata attached to the Vote. - string metadata = 4; + string metadata = 4; } // MsgVoteResponse defines the Msg/Vote response type. @@ -116,16 +116,16 @@ message MsgVoteWeighted { option (amino.name) = "cosmos-sdk/v1/MsgVoteWeighted"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // options defines the weighted vote options. - repeated WeightedVoteOption options = 3; + repeated WeightedVoteOption options = 3; // metadata is any arbitrary metadata attached to the VoteWeighted. - string metadata = 4; + string metadata = 4; } // MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. @@ -137,10 +137,10 @@ message MsgDeposit { option (amino.name) = "cosmos-sdk/v1/MsgDeposit"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; diff --git a/third_party/proto/cosmos/gov/v1beta1/gov.proto b/third_party/proto/cosmos/gov/v1beta1/gov.proto index dc8fcfd3..b8996a4a 100644 --- a/third_party/proto/cosmos/gov/v1beta1/gov.proto +++ b/third_party/proto/cosmos/gov/v1beta1/gov.proto @@ -39,7 +39,7 @@ message WeightedVoteOption { VoteOption option = 1; // weight is the vote weight associated with the vote option. - string weight = 2 [ + string weight = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false @@ -55,7 +55,7 @@ message TextProposal { option (gogoproto.equal) = true; // title of the proposal. - string title = 1; + string title = 1; // description associated with the proposal. string description = 2; @@ -68,10 +68,10 @@ message Deposit { option (gogoproto.equal) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [ @@ -86,20 +86,20 @@ message Proposal { option (gogoproto.equal) = true; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // content is the proposal's content. google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"]; // status defines the proposal status. - ProposalStatus status = 3; + ProposalStatus status = 3; // final_tally_result is the final tally result of the proposal. When // querying a proposal via gRPC, this field is not populated until the // proposal's voting period has ended. - TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // submit_time is the time of proposal submission. - google.protobuf.Timestamp submit_time = 5 + google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // deposit_end_time is the end time for deposition. @@ -188,7 +188,7 @@ message Vote { uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (amino.field_name) = "id", (amino.dont_omitempty) = true]; // voter is the voter address of the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Deprecated: Prefer to use `options` instead. This field is set in queries // if and only if `len(options) == 1` and that option has weight 1. In all // other cases, this field will default to VOTE_OPTION_UNSPECIFIED. diff --git a/third_party/proto/cosmos/gov/v1beta1/tx.proto b/third_party/proto/cosmos/gov/v1beta1/tx.proto index 0afa1d56..a976137d 100644 --- a/third_party/proto/cosmos/gov/v1beta1/tx.proto +++ b/third_party/proto/cosmos/gov/v1beta1/tx.proto @@ -71,13 +71,13 @@ message MsgVote { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // option defines the vote option. - VoteOption option = 3; + VoteOption option = 3; } // MsgVoteResponse defines the Msg/Vote response type. @@ -96,13 +96,13 @@ message MsgVoteWeighted { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // options defines the weighted vote options. - repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. @@ -121,10 +121,10 @@ message MsgDeposit { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [ diff --git a/third_party/proto/cosmos/mint/v1beta1/mint.proto b/third_party/proto/cosmos/mint/v1beta1/mint.proto index 49b00a5d..c9ea8f84 100644 --- a/third_party/proto/cosmos/mint/v1beta1/mint.proto +++ b/third_party/proto/cosmos/mint/v1beta1/mint.proto @@ -55,5 +55,30 @@ message Params { (gogoproto.nullable) = false ]; // expected blocks per year - uint64 blocks_per_year = 6; + uint64 blocks_per_year = 6; + string max_staked_ratio = 7 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string apy_at_max_staked_ratio = 8 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string min_staked_ratio = 9 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string apy_at_min_staked_ratio = 10 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string decay_rate = 11 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } diff --git a/third_party/proto/cosmos/tx/v1beta1/tx.proto b/third_party/proto/cosmos/tx/v1beta1/tx.proto index 558b1da6..a71a3e11 100644 --- a/third_party/proto/cosmos/tx/v1beta1/tx.proto +++ b/third_party/proto/cosmos/tx/v1beta1/tx.proto @@ -234,18 +234,18 @@ message Tip { string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -// AuxSignerData is the intermediary format that an gas signer (e.g. a +// AuxSignerData is the intermediary format that an auxiliary signer (e.g. a // tipper) builds and sends to the fee payer (who will build and broadcast the // actual tx). AuxSignerData is not a valid tx in itself, and will be rejected // by the node if sent directly as-is. // // Since: cosmos-sdk 0.46 message AuxSignerData { - // address is the bech32-encoded address of the gas signer. If using + // address is the bech32-encoded address of the auxiliary signer. If using // AuxSignerData across different chains, the bech32 prefix of the target // chain (where the final transaction is broadcasted) should be used. string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the gas signer + // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer // signs. Note: we use the same sign doc even if we're signing with // LEGACY_AMINO_JSON. SignDocDirectAux sign_doc = 2; diff --git a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto index 0a967168..327ef5af 100644 --- a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +++ b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -56,13 +56,13 @@ message SoftwareUpgradeProposal { option (gogoproto.goproto_stringer) = false; // title of the proposal - string title = 1; + string title = 1; // description of the proposal string description = 2; // plan of the proposal - Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software @@ -77,7 +77,7 @@ message CancelSoftwareUpgradeProposal { option (gogoproto.goproto_stringer) = false; // title of the proposal - string title = 1; + string title = 1; // description of the proposal string description = 2; diff --git a/third_party/proto/cosmos/vesting/v1beta1/tx.proto b/third_party/proto/cosmos/vesting/v1beta1/tx.proto index 42d3213f..30b726a6 100644 --- a/third_party/proto/cosmos/vesting/v1beta1/tx.proto +++ b/third_party/proto/cosmos/vesting/v1beta1/tx.proto @@ -86,8 +86,8 @@ message MsgCreatePeriodicVestingAccount { option (gogoproto.equal) = false; - string from_address = 1; - string to_address = 2; + string from_address = 1; + string to_address = 2; // start of vesting as unix time (in seconds). int64 start_time = 3; repeated Period vesting_periods = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; diff --git a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto index 7ab1fb79..e772b186 100644 --- a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto +++ b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto @@ -44,7 +44,7 @@ message ContinuousVestingAccount { BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; // Vesting start time, as unix timestamp (in seconds). - int64 start_time = 2; + int64 start_time = 2; } // DelayedVestingAccount implements the VestingAccount interface. It vests all diff --git a/third_party/proto/ethermint/evm/v1/evm.proto b/third_party/proto/ethermint/evm/v1/evm.proto index 43b3e7a5..875619ff 100644 --- a/third_party/proto/ethermint/evm/v1/evm.proto +++ b/third_party/proto/ethermint/evm/v1/evm.proto @@ -18,17 +18,12 @@ message Params { repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""]; // chain_config defines the EVM chain configuration parameters ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; - // eip712_allowed_msgs contains list of allowed eip712 msgs and their types + // list of allowed eip712 msgs and their types repeated EIP712AllowedMsg eip712_allowed_msgs = 6 [(gogoproto.customname) = "EIP712AllowedMsgs", (gogoproto.nullable) = false]; // allow_unprotected_txs defines if replay-protected (i.e non EIP155 // signed) transactions can be executed on the state machine. bool allow_unprotected_txs = 7; - // enabled_precompiles contains list of hex-encoded evm addresses of enabled precompiled contracts. - // Precompile must be registered before it can be enabled. - // enabled_precompiles should be sorted in ascending order and unique. - // sorting and uniqueness are checked against bytes representation of addresses - repeated string enabled_precompiles = 8; } // ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values @@ -251,20 +246,20 @@ message TraceConfig { // EIP712AllowedMsg stores an allowed legacy msg and its eip712 type. message EIP712AllowedMsg { - // msg_type_url is a msg's proto type name. ie "/cosmos.bank.v1beta1.MsgSend" + // msg's proto type name. ie "/cosmos.bank.v1beta1.MsgSend" string msg_type_url = 1; - // msg_value_type_name is a name of the eip712 value type. ie "MsgValueSend" + // name of the eip712 value type. ie "MsgValueSend" string msg_value_type_name = 2; - // value_types is a list of msg value types + // types of the msg value repeated EIP712MsgAttrType value_types = 3 [(gogoproto.nullable) = false]; - // nested_types is a list of msg value nested types + // nested types of the msg value repeated EIP712NestedMsgType nested_types = 4 [(gogoproto.nullable) = false]; } -// EIP712NestedMsgType is the eip712 type of a single message. +// EIP712MsgType is the eip712 type of a single message. message EIP712NestedMsgType { // name of the nested type. ie "Fee", "Coin" string name = 1; @@ -275,8 +270,6 @@ message EIP712NestedMsgType { // EIP712MsgAttrType is the eip712 type of a single message attribute. message EIP712MsgAttrType { - // name string name = 1; - // type string type = 2; } diff --git a/third_party/proto/ibc/applications/transfer/v1/transfer.proto b/third_party/proto/ibc/applications/transfer/v1/transfer.proto index cb50559c..21710747 100644 --- a/third_party/proto/ibc/applications/transfer/v1/transfer.proto +++ b/third_party/proto/ibc/applications/transfer/v1/transfer.proto @@ -6,13 +6,13 @@ option go_package = "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"; import "gogoproto/gogo.proto"; -// DenomTrace contains the evm denomination for ICS20 fungible tokens and the +// DenomTrace contains the base denomination for ICS20 fungible tokens and the // source tracing information path. message DenomTrace { // path defines the chain of port/channel identifiers used for tracing the // source of the fungible token. string path = 1; - // evm denomination of the relayed fungible token. + // base denomination of the relayed fungible token. string base_denom = 2; } diff --git a/third_party/proto/tendermint/abci/types.proto b/third_party/proto/tendermint/abci/types.proto index cf9927d7..0c57bf0c 100644 --- a/third_party/proto/tendermint/abci/types.proto +++ b/third_party/proto/tendermint/abci/types.proto @@ -103,8 +103,8 @@ message RequestListSnapshots {} // offers a snapshot to the application message RequestOfferSnapshot { - Snapshot snapshot = 1; // snapshot offered by peers - bytes app_hash = 2; // light client-verified app hash for snapshot height + Snapshot snapshot = 1; // snapshot offered by peers + bytes app_hash = 2; // light client-verified app hash for snapshot height } // loads a snapshot chunk @@ -205,8 +205,8 @@ message ResponseInitChain { message ResponseQuery { uint32 code = 1; // bytes data = 2; // use "value" instead. - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 index = 5; bytes key = 6; bytes value = 7; @@ -223,15 +223,15 @@ message ResponseBeginBlock { message ResponseCheckTx { uint32 code = 1; bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 gas_wanted = 5 [json_name = "gas_wanted"]; int64 gas_used = 6 [json_name = "gas_used"]; repeated Event events = 7 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; - string codespace = 8; - string sender = 9; - int64 priority = 10; + string codespace = 8; + string sender = 9; + int64 priority = 10; // mempool_error is set by CometBFT. // ABCI applictions creating a ResponseCheckTX should not set mempool_error. @@ -241,8 +241,8 @@ message ResponseCheckTx { message ResponseDeliverTx { uint32 code = 1; bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 gas_wanted = 5 [json_name = "gas_wanted"]; int64 gas_used = 6 [json_name = "gas_used"]; repeated Event events = 7 [ @@ -273,12 +273,12 @@ message ResponseOfferSnapshot { Result result = 1; enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Snapshot accepted, apply chunks - ABORT = 2; // Abort all snapshot restoration - REJECT = 3; // Reject this specific snapshot, try others - REJECT_FORMAT = 4; // Reject all snapshots of this format, try others - REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Snapshot accepted, apply chunks + ABORT = 2; // Abort all snapshot restoration + REJECT = 3; // Reject this specific snapshot, try others + REJECT_FORMAT = 4; // Reject all snapshots of this format, try others + REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others } } @@ -288,16 +288,16 @@ message ResponseLoadSnapshotChunk { message ResponseApplySnapshotChunk { Result result = 1; - repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply - repeated string reject_senders = 3; // Chunk senders to reject and ban + repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply + repeated string reject_senders = 3; // Chunk senders to reject and ban enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Chunk successfully accepted - ABORT = 2; // Abort all snapshot restoration - RETRY = 3; // Retry chunk (combine with refetch and reject) - RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) - REJECT_SNAPSHOT = 5; // Reject this snapshot, try others + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Chunk successfully accepted + ABORT = 2; // Abort all snapshot restoration + RETRY = 3; // Retry chunk (combine with refetch and reject) + RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) + REJECT_SNAPSHOT = 5; // Reject this snapshot, try others } } @@ -346,7 +346,7 @@ message Event { message EventAttribute { string key = 1; string value = 2; - bool index = 3; // nondeterministic + bool index = 3; // nondeterministic } // TxResult contains results of executing the transaction. @@ -364,9 +364,9 @@ message TxResult { // Validator message Validator { - bytes address = 1; // The first 20 bytes of SHA256(public key) + bytes address = 1; // The first 20 bytes of SHA256(public key) // PubKey pub_key = 2 [(gogoproto.nullable)=false]; - int64 power = 3; // The voting power + int64 power = 3; // The voting power } // ValidatorUpdate @@ -384,7 +384,7 @@ message VoteInfo { message ExtendedVoteInfo { Validator validator = 1 [(gogoproto.nullable) = false]; bool signed_last_block = 2; - bytes vote_extension = 3; // Reserved for future use + bytes vote_extension = 3; // Reserved for future use } enum MisbehaviorType { @@ -412,11 +412,11 @@ message Misbehavior { // State Sync Types message Snapshot { - uint64 height = 1; // The height at which the snapshot was taken - uint32 format = 2; // The application-specific snapshot format - uint32 chunks = 3; // Number of chunks in the snapshot - bytes hash = 4; // Arbitrary snapshot hash, equal only if identical - bytes metadata = 5; // Arbitrary application metadata + uint64 height = 1; // The height at which the snapshot was taken + uint32 format = 2; // The application-specific snapshot format + uint32 chunks = 3; // Number of chunks in the snapshot + bytes hash = 4; // Arbitrary snapshot hash, equal only if identical + bytes metadata = 5; // Arbitrary application metadata } //---------------------------------------- diff --git a/third_party/proto/tendermint/types/evidence.proto b/third_party/proto/tendermint/types/evidence.proto index 1f35049b..06f30ec2 100644 --- a/third_party/proto/tendermint/types/evidence.proto +++ b/third_party/proto/tendermint/types/evidence.proto @@ -30,7 +30,7 @@ message LightClientAttackEvidence { int64 common_height = 2; repeated tendermint.types.Validator byzantine_validators = 3; int64 total_voting_power = 4; - google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } message EvidenceList { diff --git a/third_party/proto/tendermint/types/params.proto b/third_party/proto/tendermint/types/params.proto index 66963eec..e8f56c2e 100644 --- a/third_party/proto/tendermint/types/params.proto +++ b/third_party/proto/tendermint/types/params.proto @@ -26,7 +26,7 @@ message BlockParams { // Note: must be greater or equal to -1 int64 max_gas = 2; - reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792 + reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792 } // EvidenceParams determine how we handle evidence of malfeasance. diff --git a/third_party/proto/tendermint/types/types.proto b/third_party/proto/tendermint/types/types.proto index 425f041d..b4c31671 100644 --- a/third_party/proto/tendermint/types/types.proto +++ b/third_party/proto/tendermint/types/types.proto @@ -66,19 +66,19 @@ message Header { BlockID last_block_id = 5 [(gogoproto.nullable) = false]; // hashes of block data - bytes last_commit_hash = 6; // commit from validators from the last block - bytes data_hash = 7; // transactions + bytes last_commit_hash = 6; // commit from validators from the last block + bytes data_hash = 7; // transactions // hashes from the app output from the prev block - bytes validators_hash = 8; // validators for the current block - bytes next_validators_hash = 9; // validators for the next block - bytes consensus_hash = 10; // consensus params for current block - bytes app_hash = 11; // state after txs from the previous block - bytes last_results_hash = 12; // root hash of all results from the txs from the previous block + bytes validators_hash = 8; // validators for the current block + bytes next_validators_hash = 9; // validators for the next block + bytes consensus_hash = 10; // consensus params for current block + bytes app_hash = 11; // state after txs from the previous block + bytes last_results_hash = 12; // root hash of all results from the txs from the previous block // consensus info - bytes evidence_hash = 13; // evidence included in the block - bytes proposer_address = 14; // original proposer of the block + bytes evidence_hash = 13; // evidence included in the block + bytes proposer_address = 14; // original proposer of the block } // Data contains the set of transactions included in the block @@ -99,9 +99,9 @@ message Vote { [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil. google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes validator_address = 6; - int32 validator_index = 7; - bytes signature = 8; + bytes validator_address = 6; + int32 validator_index = 7; + bytes signature = 8; } // Commit contains the evidence that a block was committed by a set of validators. @@ -118,7 +118,7 @@ message CommitSig { bytes validator_address = 2; google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 4; + bytes signature = 4; } message Proposal { @@ -129,7 +129,7 @@ message Proposal { BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 7; + bytes signature = 7; } message SignedHeader { From aff086bf7b08cea438bd0da75b9ea5550dcd9432 Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:23:01 +0800 Subject: [PATCH 03/10] feat: wrapped-a0gi-base skeleton --- app/app.go | 21 +- .../interfaces/contracts/IWrappedA0GIBase.sol | 10 +- .../wrapped-a0gi-base/IWrappedA0GIBase.json | 74 + precompiles/wrapped-a0gi-base/contract.go | 253 +++ precompiles/wrapped-a0gi-base/types.go | 8 + .../wrapped-a0gi-base/wrapped_a0gi_base.go | 65 + proto/zgc/dasigners/v1/dasigners.proto | 2 +- proto/zgc/wrappeda0gibase/genesis.proto | 15 + proto/zgc/wrappeda0gibase/query.proto | 27 + proto/zgc/wrappeda0gibase/tx.proto | 47 + x/wrapped-a0gi-base/cli/query.go | 23 + x/wrapped-a0gi-base/cli/tx.go | 22 + x/wrapped-a0gi-base/genesis.go | 22 + x/wrapped-a0gi-base/keeper/abci.go | 8 + x/wrapped-a0gi-base/keeper/grpc_query.go | 14 + x/wrapped-a0gi-base/keeper/keeper.go | 26 + x/wrapped-a0gi-base/keeper/msg_server.go | 38 + x/wrapped-a0gi-base/module.go | 168 ++ x/wrapped-a0gi-base/types/codec.go | 45 + x/wrapped-a0gi-base/types/errors.go | 7 + x/wrapped-a0gi-base/types/genesis.go | 18 + x/wrapped-a0gi-base/types/genesis.pb.go | 326 +++ x/wrapped-a0gi-base/types/keys.go | 12 + x/wrapped-a0gi-base/types/msg.go | 92 + x/wrapped-a0gi-base/types/query.pb.go | 616 ++++++ x/wrapped-a0gi-base/types/query.pb.gw.go | 171 ++ x/wrapped-a0gi-base/types/tx.pb.go | 1750 +++++++++++++++++ 27 files changed, 3872 insertions(+), 8 deletions(-) create mode 100644 precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json create mode 100644 precompiles/wrapped-a0gi-base/contract.go create mode 100644 precompiles/wrapped-a0gi-base/types.go create mode 100644 precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go create mode 100644 proto/zgc/wrappeda0gibase/genesis.proto create mode 100644 proto/zgc/wrappeda0gibase/query.proto create mode 100644 proto/zgc/wrappeda0gibase/tx.proto create mode 100644 x/wrapped-a0gi-base/cli/query.go create mode 100644 x/wrapped-a0gi-base/cli/tx.go create mode 100644 x/wrapped-a0gi-base/genesis.go create mode 100644 x/wrapped-a0gi-base/keeper/abci.go create mode 100644 x/wrapped-a0gi-base/keeper/grpc_query.go create mode 100644 x/wrapped-a0gi-base/keeper/keeper.go create mode 100644 x/wrapped-a0gi-base/keeper/msg_server.go create mode 100644 x/wrapped-a0gi-base/module.go create mode 100644 x/wrapped-a0gi-base/types/codec.go create mode 100644 x/wrapped-a0gi-base/types/errors.go create mode 100644 x/wrapped-a0gi-base/types/genesis.go create mode 100644 x/wrapped-a0gi-base/types/genesis.pb.go create mode 100644 x/wrapped-a0gi-base/types/keys.go create mode 100644 x/wrapped-a0gi-base/types/msg.go create mode 100644 x/wrapped-a0gi-base/types/query.pb.go create mode 100644 x/wrapped-a0gi-base/types/query.pb.gw.go create mode 100644 x/wrapped-a0gi-base/types/tx.pb.go diff --git a/app/app.go b/app/app.go index 0879f353..e558b416 100644 --- a/app/app.go +++ b/app/app.go @@ -111,6 +111,7 @@ import ( "github.com/0glabs/0g-chain/chaincfg" dasignersprecompile "github.com/0glabs/0g-chain/precompiles/dasigners" stakingprecompile "github.com/0glabs/0g-chain/precompiles/staking" + wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base" "github.com/0glabs/0g-chain/x/bep3" bep3keeper "github.com/0glabs/0g-chain/x/bep3/keeper" @@ -140,6 +141,9 @@ import ( validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting" validatorvestingrest "github.com/0glabs/0g-chain/x/validator-vesting/client/rest" validatorvestingtypes "github.com/0glabs/0g-chain/x/validator-vesting/types" + wrappeda0gibase "github.com/0glabs/0g-chain/x/wrapped-a0gi-base" + wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" + wrappeda0gibasetypes "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" "github.com/ethereum/go-ethereum/common" ) @@ -187,6 +191,7 @@ var ( dasigners.AppModuleBasic{}, consensus.AppModuleBasic{}, ibcwasm.AppModuleBasic{}, + wrappeda0gibase.AppModuleBasic{}, ) // module account permissions @@ -275,6 +280,7 @@ type App struct { dasignersKeeper dasignerskeeper.Keeper consensusParamsKeeper consensusparamkeeper.Keeper precisebankKeeper precisebankkeeper.Keeper + wrappeda0gibaseKeeper wrappeda0gibasekeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -327,6 +333,7 @@ func NewApp( vestingtypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, precisebanktypes.StoreKey, ibcwasmtypes.StoreKey, + wrappeda0gibasetypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -496,11 +503,10 @@ func NewApp( app.accountKeeper, ) - // dasigners keeper - app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper, govAuthAddrStr) // precopmiles precompiles := make(map[common.Address]vm.PrecompiledContract) // dasigners + app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper, govAuthAddrStr) daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper) if err != nil { panic(fmt.Sprintf("initialize dasigners precompile failed: %v", err)) @@ -512,6 +518,13 @@ func NewApp( panic(fmt.Sprintf("initialize staking precompile failed: %v", err)) } precompiles[stakingPrecompile.Address()] = stakingPrecompile + // wrapped wrapped a0gi base + app.wrappeda0gibaseKeeper = wrappeda0gibasekeeper.NewKeeper(keys[wrappeda0gibasetypes.StoreKey], appCodec, govAuthAddrStr) + wrappeda0gibasePrecompile, err := wrappeda0gibaseprecompile.NewWrappedA0giBasePrecompile(app.wrappeda0gibaseKeeper) + if err != nil { + panic(fmt.Sprintf("initialize wrapped a0gi base precompile failed: %v", err)) + } + precompiles[wrappeda0gibasePrecompile.Address()] = wrappeda0gibasePrecompile app.evmKeeper = evmkeeper.NewKeeper( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], @@ -695,6 +708,7 @@ func NewApp( council.NewAppModule(app.CouncilKeeper), ibcwasm.NewAppModule(app.ibcWasmClientKeeper), dasigners.NewAppModule(app.dasignersKeeper, *app.stakingKeeper), + wrappeda0gibase.NewAppModule(app.wrappeda0gibaseKeeper), ) // Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list. @@ -742,6 +756,7 @@ func NewApp( precisebanktypes.ModuleName, ibcwasmtypes.ModuleName, dasignerstypes.ModuleName, + wrappeda0gibasetypes.ModuleName, ) // Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list. @@ -779,6 +794,7 @@ func NewApp( precisebanktypes.ModuleName, ibcwasmtypes.ModuleName, dasignerstypes.ModuleName, + wrappeda0gibasetypes.ModuleName, ) // Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list @@ -815,6 +831,7 @@ func NewApp( crisistypes.ModuleName, // runs the invariants at genesis, should run after other modules ibcwasmtypes.ModuleName, dasignerstypes.ModuleName, + wrappeda0gibasetypes.ModuleName, ) app.mm.RegisterInvariants(&app.crisisKeeper) diff --git a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol index e5a9aa7a..eaf5a246 100644 --- a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol +++ b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: LGPL-3.0-only pragma solidity >=0.8.0; +struct Supply { + uint256 cap; + uint256 total; +} + /** * @title WrappedA0GIBase is a precompile for wrapped a0gi(wA0GI), it enables wA0GI mint/burn native 0g token directly. */ interface IWrappedA0GIBase { - struct Supply { - uint256 cap; - uint256 total; - } - /** * @dev set the wA0GI address. * It is designed to be called by governance module only so it's not implemented at EVM precompile side. diff --git a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json new file mode 100644 index 00000000..2d051720 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json @@ -0,0 +1,74 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "minterSupply", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "cap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "total", + "type": "uint256" + } + ], + "internalType": "struct Supply", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/precompiles/wrapped-a0gi-base/contract.go b/precompiles/wrapped-a0gi-base/contract.go new file mode 100644 index 00000000..9eccaf96 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/contract.go @@ -0,0 +1,253 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package wrappeda0gibase + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// Wrappeda0gibaseMetaData contains all meta data concerning the Wrappeda0gibase contract. +var Wrappeda0gibaseMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// Wrappeda0gibaseABI is the input ABI used to generate the binding from. +// Deprecated: Use Wrappeda0gibaseMetaData.ABI instead. +var Wrappeda0gibaseABI = Wrappeda0gibaseMetaData.ABI + +// Wrappeda0gibase is an auto generated Go binding around an Ethereum contract. +type Wrappeda0gibase struct { + Wrappeda0gibaseCaller // Read-only binding to the contract + Wrappeda0gibaseTransactor // Write-only binding to the contract + Wrappeda0gibaseFilterer // Log filterer for contract events +} + +// Wrappeda0gibaseCaller is an auto generated read-only Go binding around an Ethereum contract. +type Wrappeda0gibaseCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// Wrappeda0gibaseTransactor is an auto generated write-only Go binding around an Ethereum contract. +type Wrappeda0gibaseTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// Wrappeda0gibaseFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type Wrappeda0gibaseFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// Wrappeda0gibaseSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type Wrappeda0gibaseSession struct { + Contract *Wrappeda0gibase // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// Wrappeda0gibaseCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type Wrappeda0gibaseCallerSession struct { + Contract *Wrappeda0gibaseCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// Wrappeda0gibaseTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type Wrappeda0gibaseTransactorSession struct { + Contract *Wrappeda0gibaseTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// Wrappeda0gibaseRaw is an auto generated low-level Go binding around an Ethereum contract. +type Wrappeda0gibaseRaw struct { + Contract *Wrappeda0gibase // Generic contract binding to access the raw methods on +} + +// Wrappeda0gibaseCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type Wrappeda0gibaseCallerRaw struct { + Contract *Wrappeda0gibaseCaller // Generic read-only contract binding to access the raw methods on +} + +// Wrappeda0gibaseTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type Wrappeda0gibaseTransactorRaw struct { + Contract *Wrappeda0gibaseTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewWrappeda0gibase creates a new instance of Wrappeda0gibase, bound to a specific deployed contract. +func NewWrappeda0gibase(address common.Address, backend bind.ContractBackend) (*Wrappeda0gibase, error) { + contract, err := bindWrappeda0gibase(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Wrappeda0gibase{Wrappeda0gibaseCaller: Wrappeda0gibaseCaller{contract: contract}, Wrappeda0gibaseTransactor: Wrappeda0gibaseTransactor{contract: contract}, Wrappeda0gibaseFilterer: Wrappeda0gibaseFilterer{contract: contract}}, nil +} + +// NewWrappeda0gibaseCaller creates a new read-only instance of Wrappeda0gibase, bound to a specific deployed contract. +func NewWrappeda0gibaseCaller(address common.Address, caller bind.ContractCaller) (*Wrappeda0gibaseCaller, error) { + contract, err := bindWrappeda0gibase(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &Wrappeda0gibaseCaller{contract: contract}, nil +} + +// NewWrappeda0gibaseTransactor creates a new write-only instance of Wrappeda0gibase, bound to a specific deployed contract. +func NewWrappeda0gibaseTransactor(address common.Address, transactor bind.ContractTransactor) (*Wrappeda0gibaseTransactor, error) { + contract, err := bindWrappeda0gibase(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &Wrappeda0gibaseTransactor{contract: contract}, nil +} + +// NewWrappeda0gibaseFilterer creates a new log filterer instance of Wrappeda0gibase, bound to a specific deployed contract. +func NewWrappeda0gibaseFilterer(address common.Address, filterer bind.ContractFilterer) (*Wrappeda0gibaseFilterer, error) { + contract, err := bindWrappeda0gibase(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &Wrappeda0gibaseFilterer{contract: contract}, nil +} + +// bindWrappeda0gibase binds a generic wrapper to an already deployed contract. +func bindWrappeda0gibase(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(Wrappeda0gibaseABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Wrappeda0gibase *Wrappeda0gibaseRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Wrappeda0gibase.Contract.Wrappeda0gibaseCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Wrappeda0gibase *Wrappeda0gibaseRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Wrappeda0gibaseTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Wrappeda0gibase *Wrappeda0gibaseRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Wrappeda0gibaseTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Wrappeda0gibase *Wrappeda0gibaseCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Wrappeda0gibase.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Wrappeda0gibase *Wrappeda0gibaseTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Wrappeda0gibase *Wrappeda0gibaseTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.contract.Transact(opts, method, params...) +} + +// MinterSupply is a free data retrieval call binding the contract method 0x95609212. +// +// Solidity: function minterSupply(address minter) view returns((uint256,uint256)) +func (_Wrappeda0gibase *Wrappeda0gibaseCaller) MinterSupply(opts *bind.CallOpts, minter common.Address) (Supply, error) { + var out []interface{} + err := _Wrappeda0gibase.contract.Call(opts, &out, "minterSupply", minter) + + if err != nil { + return *new(Supply), err + } + + out0 := *abi.ConvertType(out[0], new(Supply)).(*Supply) + + return out0, err + +} + +// MinterSupply is a free data retrieval call binding the contract method 0x95609212. +// +// Solidity: function minterSupply(address minter) view returns((uint256,uint256)) +func (_Wrappeda0gibase *Wrappeda0gibaseSession) MinterSupply(minter common.Address) (Supply, error) { + return _Wrappeda0gibase.Contract.MinterSupply(&_Wrappeda0gibase.CallOpts, minter) +} + +// MinterSupply is a free data retrieval call binding the contract method 0x95609212. +// +// Solidity: function minterSupply(address minter) view returns((uint256,uint256)) +func (_Wrappeda0gibase *Wrappeda0gibaseCallerSession) MinterSupply(minter common.Address) (Supply, error) { + return _Wrappeda0gibase.Contract.MinterSupply(&_Wrappeda0gibase.CallOpts, minter) +} + +// Burn is a paid mutator transaction binding the contract method 0x9dc29fac. +// +// Solidity: function burn(address minter, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) Burn(opts *bind.TransactOpts, minter common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.contract.Transact(opts, "burn", minter, amount) +} + +// Burn is a paid mutator transaction binding the contract method 0x9dc29fac. +// +// Solidity: function burn(address minter, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseSession) Burn(minter common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Burn(&_Wrappeda0gibase.TransactOpts, minter, amount) +} + +// Burn is a paid mutator transaction binding the contract method 0x9dc29fac. +// +// Solidity: function burn(address minter, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Burn(minter common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Burn(&_Wrappeda0gibase.TransactOpts, minter, amount) +} + +// Mint is a paid mutator transaction binding the contract method 0xc6c3bbe6. +// +// Solidity: function mint(address minter, address to, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) Mint(opts *bind.TransactOpts, minter common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.contract.Transact(opts, "mint", minter, to, amount) +} + +// Mint is a paid mutator transaction binding the contract method 0xc6c3bbe6. +// +// Solidity: function mint(address minter, address to, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseSession) Mint(minter common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, to, amount) +} + +// Mint is a paid mutator transaction binding the contract method 0xc6c3bbe6. +// +// Solidity: function mint(address minter, address to, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Mint(minter common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, to, amount) +} diff --git a/precompiles/wrapped-a0gi-base/types.go b/precompiles/wrapped-a0gi-base/types.go new file mode 100644 index 00000000..95e427bd --- /dev/null +++ b/precompiles/wrapped-a0gi-base/types.go @@ -0,0 +1,8 @@ +package wrappeda0gibase + +import "math/big" + +type Supply = struct { + Cap *big.Int "json:\"cap\"" + Total *big.Int "json:\"total\"" +} diff --git a/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go new file mode 100644 index 00000000..088ecf40 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go @@ -0,0 +1,65 @@ +package wrappeda0gibase + +import ( + "strings" + + precompiles_common "github.com/0glabs/0g-chain/precompiles/common" + wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" + "github.com/cosmos/cosmos-sdk/store/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" +) + +const ( + PrecompileAddress = "0x0000000000000000000000000000000000001002" +) + +var _ vm.PrecompiledContract = &WrappedA0giBasePrecompile{} +var _ precompiles_common.PrecompileCommon = &WrappedA0giBasePrecompile{} + +type WrappedA0giBasePrecompile struct { + abi abi.ABI + wrappeda0gibaseKeeper wrappeda0gibasekeeper.Keeper +} + +// Abi implements common.PrecompileCommon. +func (w *WrappedA0giBasePrecompile) Abi() *abi.ABI { + panic("unimplemented") +} + +// IsTx implements common.PrecompileCommon. +func (w *WrappedA0giBasePrecompile) IsTx(string) bool { + panic("unimplemented") +} + +// KVGasConfig implements common.PrecompileCommon. +func (w *WrappedA0giBasePrecompile) KVGasConfig() types.GasConfig { + panic("unimplemented") +} + +// Address implements vm.PrecompiledContract. +func (w *WrappedA0giBasePrecompile) Address() common.Address { + return common.HexToAddress(PrecompileAddress) +} + +// RequiredGas implements vm.PrecompiledContract. +func (w *WrappedA0giBasePrecompile) RequiredGas(input []byte) uint64 { + panic("unimplemented") +} + +func NewWrappedA0giBasePrecompile(wrappeda0gibaseKeeper wrappeda0gibasekeeper.Keeper) (*WrappedA0giBasePrecompile, error) { + abi, err := abi.JSON(strings.NewReader(Wrappeda0gibaseABI)) + if err != nil { + return nil, err + } + return &WrappedA0giBasePrecompile{ + abi: abi, + wrappeda0gibaseKeeper: wrappeda0gibaseKeeper, + }, nil +} + +// Run implements vm.PrecompiledContract. +func (w *WrappedA0giBasePrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error) { + panic("unimplemented") +} diff --git a/proto/zgc/dasigners/v1/dasigners.proto b/proto/zgc/dasigners/v1/dasigners.proto index ee32ed3b..c390e5f3 100644 --- a/proto/zgc/dasigners/v1/dasigners.proto +++ b/proto/zgc/dasigners/v1/dasigners.proto @@ -25,5 +25,5 @@ message Quorum { } message Quorums { - repeated Quorum quorums = 1; + repeated Quorum quorums = 1; } diff --git a/proto/zgc/wrappeda0gibase/genesis.proto b/proto/zgc/wrappeda0gibase/genesis.proto new file mode 100644 index 00000000..66fd833a --- /dev/null +++ b/proto/zgc/wrappeda0gibase/genesis.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package zgc.wrappeda0gibase; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"; + +// GenesisState defines the wrapped a0gi base module's genesis state. +message GenesisState { + // address of wrapped a0gi contract + string wrapped_a0gi_address = 1; +} diff --git a/proto/zgc/wrappeda0gibase/query.proto b/proto/zgc/wrappeda0gibase/query.proto new file mode 100644 index 00000000..97958902 --- /dev/null +++ b/proto/zgc/wrappeda0gibase/query.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +package zgc.wrappeda0gibase; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"; +option (gogoproto.goproto_getters_all) = false; + +// Query defines the gRPC querier service for the wrapped a0gi base module +service Query { + rpc MinterSupply(MinterSupplyRequest) returns (MinterSupplyResponse) { + option (google.api.http).get = "/0g/wrapped-a0gi-base/minter-supply"; + } +} + +message MinterSupplyRequest { + string address = 1; +} + +message MinterSupplyResponse { + string cap = 1; + string supply = 2; +} diff --git a/proto/zgc/wrappeda0gibase/tx.proto b/proto/zgc/wrappeda0gibase/tx.proto new file mode 100644 index 00000000..6f247d93 --- /dev/null +++ b/proto/zgc/wrappeda0gibase/tx.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package zgc.wrappeda0gibase; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"; +option (gogoproto.goproto_getters_all) = false; + +// Msg defines the wrapped a0gi base Msg service +service Msg { + rpc SetWA0GI(MsgSetWA0GI) returns (MsgSetWA0GIResponse); + rpc SetMinterCap(MsgSetMintCap) returns (MsgSetMintCapResponse); + rpc Mint(MsgMint) returns (MsgMintResponse); + rpc Burn(MsgBurn) returns (MsgBurnResponse); +} + +message MsgSetWA0GI { + string authority = 1; + string address = 2; +} + +message MsgSetWA0GIResponse {} + +message MsgSetMintCap { + string authority = 1; + string minter = 2; + string cap = 3; +} + +message MsgSetMintCapResponse {} + +message MsgMint { + string minter = 1; + string to = 2; + string amount = 3; +} + +message MsgMintResponse {} + +message MsgBurn { + string minter = 1; + string amount = 2; +} + +message MsgBurnResponse {} diff --git a/x/wrapped-a0gi-base/cli/query.go b/x/wrapped-a0gi-base/cli/query.go new file mode 100644 index 00000000..52e4eaca --- /dev/null +++ b/x/wrapped-a0gi-base/cli/query.go @@ -0,0 +1,23 @@ +package cli + +import ( + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" +) + +// GetQueryCmd returns the cli query commands for the inflation module. +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the dasigners module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand() + + return cmd +} diff --git a/x/wrapped-a0gi-base/cli/tx.go b/x/wrapped-a0gi-base/cli/tx.go new file mode 100644 index 00000000..1fd09826 --- /dev/null +++ b/x/wrapped-a0gi-base/cli/tx.go @@ -0,0 +1,22 @@ +package cli + +import ( + "fmt" + + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + cmd.AddCommand() + return cmd +} diff --git a/x/wrapped-a0gi-base/genesis.go b/x/wrapped-a0gi-base/genesis.go new file mode 100644 index 00000000..4029ed65 --- /dev/null +++ b/x/wrapped-a0gi-base/genesis.go @@ -0,0 +1,22 @@ +package wrappeda0gibase + +import ( + "fmt" + + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the store state from a genesis state. +func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) { + if err := gs.Validate(); err != nil { + panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) + } + panic("unimplemented") +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { + panic("unimplemented") +} diff --git a/x/wrapped-a0gi-base/keeper/abci.go b/x/wrapped-a0gi-base/keeper/abci.go new file mode 100644 index 00000000..4abc1524 --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/abci.go @@ -0,0 +1,8 @@ +package keeper + +import ( + abci "github.com/cometbft/cometbft/abci/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/wrapped-a0gi-base/keeper/grpc_query.go b/x/wrapped-a0gi-base/keeper/grpc_query.go new file mode 100644 index 00000000..cd144ac2 --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/grpc_query.go @@ -0,0 +1,14 @@ +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" +) + +var _ types.QueryServer = Keeper{} + +// MinterSupply implements types.QueryServer. +func (k Keeper) MinterSupply(c context.Context, request *types.MinterSupplyRequest) (*types.MinterSupplyResponse, error) { + panic("unimplemented") +} diff --git a/x/wrapped-a0gi-base/keeper/keeper.go b/x/wrapped-a0gi-base/keeper/keeper.go new file mode 100644 index 00000000..b20e7e0b --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/keeper.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/codec" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" +) + +type Keeper struct { + storeKey storetypes.StoreKey + cdc codec.BinaryCodec + authority string // the address capable of changing signers params. Should be the gov module account +} + +// NewKeeper creates a new wrapped a0gi base keeper instance +func NewKeeper( + storeKey storetypes.StoreKey, + cdc codec.BinaryCodec, + authority string, +) Keeper { + return Keeper{ + storeKey: storeKey, + cdc: cdc, + authority: authority, + } +} diff --git a/x/wrapped-a0gi-base/keeper/msg_server.go b/x/wrapped-a0gi-base/keeper/msg_server.go new file mode 100644 index 00000000..e01fa164 --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/msg_server.go @@ -0,0 +1,38 @@ +package keeper + +import ( + "context" + + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" +) + +/* + errorsmod "cosmossdk.io/errors" + "github.com/0glabs/0g-chain/crypto/bn254util" + sdk "github.com/cosmos/cosmos-sdk/types" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/ethereum/go-ethereum/common" + etherminttypes "github.com/evmos/ethermint/types" +*/ + +var _ types.MsgServer = &Keeper{} + +// Burn implements types.MsgServer. +func (k Keeper) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnResponse, error) { + panic("unimplemented") +} + +// Mint implements types.MsgServer. +func (k Keeper) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) { + panic("unimplemented") +} + +// SetMinterCap implements types.MsgServer. +func (k Keeper) SetMinterCap(goCtx context.Context, msg *types.MsgSetMintCap) (*types.MsgSetMintCapResponse, error) { + panic("unimplemented") +} + +// SetWA0GI implements types.MsgServer. +func (k Keeper) SetWA0GI(goCtx context.Context, msg *types.MsgSetWA0GI) (*types.MsgSetWA0GIResponse, error) { + panic("unimplemented") +} diff --git a/x/wrapped-a0gi-base/module.go b/x/wrapped-a0gi-base/module.go new file mode 100644 index 00000000..2055f509 --- /dev/null +++ b/x/wrapped-a0gi-base/module.go @@ -0,0 +1,168 @@ +package wrappeda0gibase + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/cli" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" +) + +// consensusVersion defines the current x/council module consensus version. +const consensusVersion = 1 + +// type check to ensure the interface is properly implemented +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// app module Basics object +type AppModuleBasic struct{} + +// Name returns the inflation module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the inflation module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// ConsensusVersion returns the consensus state-breaking version for the module. +func (AppModuleBasic) ConsensusVersion() uint64 { + return consensusVersion +} + +// RegisterInterfaces registers interfaces and implementations of the incentives +// module. +func (AppModuleBasic) RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(interfaceRegistry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the incentives +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the inflation module. +func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genesisState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genesisState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return genesisState.Validate() +} + +// RegisterRESTRoutes performs a no-op as the inflation module doesn't expose REST +// endpoints +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the inflation module. +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root tx command for the inflation module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns no root query command for the inflation module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// ___________________________________________________________________________ + +// AppModule implements an application module for the inflation module. +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule Object +func NewAppModule( + k keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + keeper: k, + } +} + +// Name returns the inflation module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// QuerierRoute returns wrapped a0gi base module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// RegisterInvariants registers the inflation module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { + am.keeper.BeginBlock(ctx, req) +} + +func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { + // am.keeper.EndBlock(ctx, req) + return []abci.ValidatorUpdate{} +} + +// InitGenesis performs genesis initialization for the inflation module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(data, &genesisState) + InitGenesis(ctx, am.keeper, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the inflation +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(gs) +} + +// ___________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the inflation module. +func (am AppModule) GenerateGenesisState(_ *module.SimulationState) { +} + +// RegisterStoreDecoder registers a decoder for inflation module's types. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) { +} + +// WeightedOperations doesn't return any inflation module operation. +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return []simtypes.WeightedOperation{} +} diff --git a/x/wrapped-a0gi-base/types/codec.go b/x/wrapped-a0gi-base/types/codec.go new file mode 100644 index 00000000..7af6a480 --- /dev/null +++ b/x/wrapped-a0gi-base/types/codec.go @@ -0,0 +1,45 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +var ( + amino = codec.NewLegacyAmino() + // ModuleCdc references the global evm module codec. Note, the codec should + // ONLY be used in certain instances of tests and for JSON encoding. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino JSON compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +const ( +// Amino names +) + +// NOTE: This is required for the GetSignBytes function +func init() { + RegisterLegacyAminoCodec(amino) + amino.Seal() +} + +// RegisterInterfaces register implementations +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgSetWA0GI{}, + &MsgSetMintCap{}, + &MsgMint{}, + &MsgBurn{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +// RegisterLegacyAminoCodec required for EIP-712 +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} diff --git a/x/wrapped-a0gi-base/types/errors.go b/x/wrapped-a0gi-base/types/errors.go new file mode 100644 index 00000000..f77409c1 --- /dev/null +++ b/x/wrapped-a0gi-base/types/errors.go @@ -0,0 +1,7 @@ +package types + +import errorsmod "cosmossdk.io/errors" + +var ( + ErrTxForbidden = errorsmod.Register(ModuleName, 1, "cosmos tx forbidden") +) diff --git a/x/wrapped-a0gi-base/types/genesis.go b/x/wrapped-a0gi-base/types/genesis.go new file mode 100644 index 00000000..75265bac --- /dev/null +++ b/x/wrapped-a0gi-base/types/genesis.go @@ -0,0 +1,18 @@ +package types + +// NewGenesisState returns a new genesis state object for the module. +func NewGenesisState(addr string) *GenesisState { + return &GenesisState{ + WrappedA0GiAddress: addr, + } +} + +// DefaultGenesisState returns the default genesis state for the module. +func DefaultGenesisState() *GenesisState { + return NewGenesisState("0000000000000000000000000000000000000000") +} + +// Validate performs basic validation of genesis data. +func (gs GenesisState) Validate() error { + return ValidateHexAddress(gs.WrappedA0GiAddress) +} diff --git a/x/wrapped-a0gi-base/types/genesis.pb.go b/x/wrapped-a0gi-base/types/genesis.pb.go new file mode 100644 index 00000000..dd6a07da --- /dev/null +++ b/x/wrapped-a0gi-base/types/genesis.pb.go @@ -0,0 +1,326 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/wrappeda0gibase/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the wrapped a0gi base module's genesis state. +type GenesisState struct { + // address of wrapped a0gi contract + WrappedA0GiAddress string `protobuf:"bytes,1,opt,name=wrapped_a0gi_address,json=wrappedA0giAddress,proto3" json:"wrapped_a0gi_address,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_7e056019f61fd820, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetWrappedA0GiAddress() string { + if m != nil { + return m.WrappedA0GiAddress + } + return "" +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "zgc.wrappeda0gibase.GenesisState") +} + +func init() { proto.RegisterFile("zgc/wrappeda0gibase/genesis.proto", fileDescriptor_7e056019f61fd820) } + +var fileDescriptor_7e056019f61fd820 = []byte{ + // 246 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xbd, 0x4e, 0xc3, 0x30, + 0x10, 0x80, 0xe3, 0x05, 0x89, 0x88, 0x29, 0x74, 0xa0, 0x1d, 0xcc, 0xcf, 0xc4, 0x92, 0xd8, 0x12, + 0x3c, 0x00, 0x65, 0x61, 0x63, 0x80, 0x8d, 0x25, 0xb2, 0x1d, 0x73, 0xb5, 0xd4, 0xe4, 0xac, 0x9c, + 0x2b, 0x68, 0x9f, 0x82, 0xc7, 0x62, 0xec, 0xc8, 0x88, 0x92, 0x17, 0x41, 0x89, 0xc3, 0x92, 0xcd, + 0x77, 0xdf, 0x27, 0xf9, 0xd3, 0xa5, 0xd7, 0x07, 0x30, 0xe2, 0xa3, 0x55, 0xde, 0xdb, 0x4a, 0x49, + 0x70, 0x5a, 0x91, 0x15, 0x60, 0x1b, 0x4b, 0x8e, 0x0a, 0xdf, 0x62, 0xc0, 0xec, 0xfc, 0x00, 0xa6, + 0x98, 0x29, 0xab, 0xa5, 0x41, 0xaa, 0x91, 0xca, 0x51, 0x11, 0x71, 0x88, 0xfe, 0x6a, 0x01, 0x08, + 0x18, 0xf7, 0xc3, 0x6b, 0xda, 0x2e, 0x01, 0x11, 0xb6, 0x56, 0x8c, 0x93, 0xde, 0xbd, 0x0b, 0xd5, + 0xec, 0x27, 0x74, 0x39, 0x47, 0xc1, 0xd5, 0x96, 0x82, 0xaa, 0x7d, 0x14, 0x6e, 0x1e, 0xd2, 0xb3, + 0xa7, 0x98, 0xf4, 0x1a, 0x54, 0xb0, 0x99, 0x4c, 0x17, 0x53, 0x4f, 0x39, 0x04, 0x95, 0xaa, 0xaa, + 0x5a, 0x4b, 0x74, 0xc1, 0xae, 0xd8, 0xed, 0xe9, 0x4b, 0x36, 0xb1, 0xb5, 0x04, 0xb7, 0x8e, 0xe4, + 0xf1, 0xf9, 0xbb, 0xe3, 0xec, 0xd8, 0x71, 0xf6, 0xdb, 0x71, 0xf6, 0xd5, 0xf3, 0xe4, 0xd8, 0xf3, + 0xe4, 0xa7, 0xe7, 0xc9, 0xdb, 0x3d, 0xb8, 0xb0, 0xd9, 0xe9, 0xc2, 0x60, 0x2d, 0x24, 0x6c, 0x95, + 0x26, 0x21, 0x21, 0x37, 0x1b, 0xe5, 0x1a, 0xf1, 0xf9, 0x7f, 0x99, 0x7c, 0xf8, 0x26, 0x1f, 0x6f, + 0x13, 0xf6, 0xde, 0x92, 0x3e, 0x19, 0xc3, 0xee, 0xfe, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe8, 0xe8, + 0x6b, 0x2a, 0x3f, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WrappedA0GiAddress) > 0 { + i -= len(m.WrappedA0GiAddress) + copy(dAtA[i:], m.WrappedA0GiAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.WrappedA0GiAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.WrappedA0GiAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WrappedA0GiAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WrappedA0GiAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/wrapped-a0gi-base/types/keys.go b/x/wrapped-a0gi-base/types/keys.go new file mode 100644 index 00000000..29578c19 --- /dev/null +++ b/x/wrapped-a0gi-base/types/keys.go @@ -0,0 +1,12 @@ +package types + +const ( + // ModuleName The name that will be used throughout the module + ModuleName = "wrapped-a0gi-base" + + // StoreKey Top level store key where all module items will be stored + StoreKey = ModuleName + + // QuerierRoute Top level query string + QuerierRoute = ModuleName +) diff --git a/x/wrapped-a0gi-base/types/msg.go b/x/wrapped-a0gi-base/types/msg.go new file mode 100644 index 00000000..cc634912 --- /dev/null +++ b/x/wrapped-a0gi-base/types/msg.go @@ -0,0 +1,92 @@ +package types + +import ( + "encoding/hex" + fmt "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _, _, _, _ sdk.Msg = &MsgSetWA0GI{}, &MsgSetMintCap{}, &MsgMint{}, &MsgBurn{} + +func ValidateHexAddress(account string) error { + addr, err := hex.DecodeString(account) + if err != nil { + return err + } + if len(addr) != 20 { + return fmt.Errorf("invalid address length") + } + return nil +} + +func (msg *MsgSetWA0GI) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} + +func (msg *MsgSetWA0GI) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } + + if err := ValidateHexAddress(msg.Address); err != nil { + return errorsmod.Wrap(err, "address") + } + + return nil +} + +func (msg MsgSetWA0GI) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + +func (msg *MsgSetMintCap) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} + +func (msg *MsgSetMintCap) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "authority") + } + + if err := ValidateHexAddress(msg.Minter); err != nil { + return errorsmod.Wrap(err, "minter") + } + + return nil +} + +func (msg MsgSetMintCap) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + +func (msg *MsgMint) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{} +} + +func (msg *MsgMint) ValidateBasic() error { + // forbid mint from cosmos tx + // it can only be called by wrapped a0gi from EVM + return ErrTxForbidden +} + +func (msg MsgMint) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + +func (msg *MsgBurn) GetSigners() []sdk.AccAddress { + return []sdk.AccAddress{} +} + +func (msg *MsgBurn) ValidateBasic() error { + // forbid burn from cosmos tx + // it can only be called by wrapped a0gi from EVM + return ErrTxForbidden +} + +func (msg MsgBurn) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} diff --git a/x/wrapped-a0gi-base/types/query.pb.go b/x/wrapped-a0gi-base/types/query.pb.go new file mode 100644 index 00000000..bcba92eb --- /dev/null +++ b/x/wrapped-a0gi-base/types/query.pb.go @@ -0,0 +1,616 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/wrappeda0gibase/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MinterSupplyRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *MinterSupplyRequest) Reset() { *m = MinterSupplyRequest{} } +func (m *MinterSupplyRequest) String() string { return proto.CompactTextString(m) } +func (*MinterSupplyRequest) ProtoMessage() {} +func (*MinterSupplyRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_19911faa2ec12c75, []int{0} +} +func (m *MinterSupplyRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MinterSupplyRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MinterSupplyRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MinterSupplyRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MinterSupplyRequest.Merge(m, src) +} +func (m *MinterSupplyRequest) XXX_Size() int { + return m.Size() +} +func (m *MinterSupplyRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MinterSupplyRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MinterSupplyRequest proto.InternalMessageInfo + +type MinterSupplyResponse struct { + Cap string `protobuf:"bytes,1,opt,name=cap,proto3" json:"cap,omitempty"` + Supply string `protobuf:"bytes,2,opt,name=supply,proto3" json:"supply,omitempty"` +} + +func (m *MinterSupplyResponse) Reset() { *m = MinterSupplyResponse{} } +func (m *MinterSupplyResponse) String() string { return proto.CompactTextString(m) } +func (*MinterSupplyResponse) ProtoMessage() {} +func (*MinterSupplyResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_19911faa2ec12c75, []int{1} +} +func (m *MinterSupplyResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MinterSupplyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MinterSupplyResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MinterSupplyResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MinterSupplyResponse.Merge(m, src) +} +func (m *MinterSupplyResponse) XXX_Size() int { + return m.Size() +} +func (m *MinterSupplyResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MinterSupplyResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MinterSupplyResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MinterSupplyRequest)(nil), "zgc.wrappeda0gibase.MinterSupplyRequest") + proto.RegisterType((*MinterSupplyResponse)(nil), "zgc.wrappeda0gibase.MinterSupplyResponse") +} + +func init() { proto.RegisterFile("zgc/wrappeda0gibase/query.proto", fileDescriptor_19911faa2ec12c75) } + +var fileDescriptor_19911faa2ec12c75 = []byte{ + // 348 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x4a, 0x2b, 0x31, + 0x14, 0x86, 0x27, 0xbd, 0xdc, 0x5e, 0x6e, 0x70, 0x21, 0x69, 0x91, 0x76, 0x90, 0x54, 0x2a, 0x42, + 0x45, 0x66, 0x32, 0xa8, 0x0f, 0x20, 0xee, 0x5d, 0x58, 0x77, 0x6e, 0x24, 0x33, 0x8d, 0x69, 0xa0, + 0x93, 0xa4, 0x93, 0x0c, 0xda, 0x2e, 0x7d, 0x82, 0x82, 0x3b, 0x9f, 0xa8, 0xcb, 0x82, 0x1b, 0x97, + 0xda, 0xfa, 0x20, 0x32, 0x99, 0x29, 0x68, 0xe9, 0xc2, 0x5d, 0xfe, 0x73, 0xbe, 0xff, 0xe4, 0xf0, + 0x1f, 0xd8, 0x99, 0xf2, 0x84, 0x3c, 0x64, 0x54, 0x6b, 0x36, 0xa0, 0x11, 0x17, 0x31, 0x35, 0x8c, + 0x8c, 0x73, 0x96, 0x4d, 0x42, 0x9d, 0x29, 0xab, 0x50, 0x63, 0xca, 0x93, 0x70, 0x03, 0xf0, 0xdb, + 0x89, 0x32, 0xa9, 0x32, 0x77, 0x0e, 0x21, 0xa5, 0x28, 0x79, 0xbf, 0xc9, 0x15, 0x57, 0x65, 0xbd, + 0x78, 0x55, 0xd5, 0x7d, 0xae, 0x14, 0x1f, 0x31, 0x42, 0xb5, 0x20, 0x54, 0x4a, 0x65, 0xa9, 0x15, + 0x4a, 0xae, 0x3d, 0xed, 0xaa, 0xeb, 0x54, 0x9c, 0xdf, 0x13, 0x2a, 0xab, 0xef, 0xfd, 0xce, 0x66, + 0xcb, 0x8a, 0x94, 0x19, 0x4b, 0x53, 0x5d, 0x02, 0x5d, 0x02, 0x1b, 0x57, 0x42, 0x5a, 0x96, 0xdd, + 0xe4, 0x5a, 0x8f, 0x26, 0x7d, 0x36, 0xce, 0x99, 0xb1, 0xa8, 0x05, 0xff, 0xd1, 0xc1, 0x20, 0x63, + 0xc6, 0xb4, 0xc0, 0x01, 0xe8, 0xfd, 0xef, 0xaf, 0x65, 0xf7, 0x02, 0x36, 0x7f, 0x1a, 0x8c, 0x56, + 0xd2, 0x30, 0xb4, 0x0b, 0xff, 0x24, 0x54, 0x57, 0x74, 0xf1, 0x44, 0x7b, 0xb0, 0x6e, 0x1c, 0xd3, + 0xaa, 0xb9, 0x62, 0xa5, 0x4e, 0x5f, 0x00, 0xfc, 0x7b, 0x5d, 0x44, 0x84, 0x66, 0x00, 0xee, 0x7c, + 0x1f, 0x86, 0x7a, 0xe1, 0x96, 0xb8, 0xc2, 0x2d, 0x0b, 0xfa, 0xc7, 0xbf, 0x20, 0xcb, 0xcd, 0xba, + 0x27, 0x4f, 0xaf, 0x9f, 0xcf, 0xb5, 0x23, 0x74, 0x48, 0x22, 0xbe, 0xbe, 0x55, 0x50, 0x58, 0x02, + 0x77, 0xad, 0xd4, 0x79, 0x82, 0x72, 0xb9, 0xcb, 0xfe, 0xfc, 0x03, 0x7b, 0xf3, 0x25, 0x06, 0x8b, + 0x25, 0x06, 0xef, 0x4b, 0x0c, 0x66, 0x2b, 0xec, 0x2d, 0x56, 0xd8, 0x7b, 0x5b, 0x61, 0xef, 0xf6, + 0x9c, 0x0b, 0x3b, 0xcc, 0xe3, 0x30, 0x51, 0x29, 0x89, 0xf8, 0x88, 0xc6, 0x86, 0x44, 0x3c, 0x48, + 0x86, 0x54, 0x48, 0xf2, 0xb8, 0x65, 0xb6, 0x9d, 0x68, 0x66, 0xe2, 0xba, 0x8b, 0xfa, 0xec, 0x2b, + 0x00, 0x00, 0xff, 0xff, 0x26, 0x34, 0x94, 0xac, 0x2d, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + MinterSupply(ctx context.Context, in *MinterSupplyRequest, opts ...grpc.CallOption) (*MinterSupplyResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) MinterSupply(ctx context.Context, in *MinterSupplyRequest, opts ...grpc.CallOption) (*MinterSupplyResponse, error) { + out := new(MinterSupplyResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Query/MinterSupply", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + MinterSupply(context.Context, *MinterSupplyRequest) (*MinterSupplyResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) MinterSupply(ctx context.Context, req *MinterSupplyRequest) (*MinterSupplyResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MinterSupply not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_MinterSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MinterSupplyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).MinterSupply(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Query/MinterSupply", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).MinterSupply(ctx, req.(*MinterSupplyRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.wrappeda0gibase.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "MinterSupply", + Handler: _Query_MinterSupply_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/wrappeda0gibase/query.proto", +} + +func (m *MinterSupplyRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MinterSupplyRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MinterSupplyRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MinterSupplyResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MinterSupplyResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MinterSupplyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Supply) > 0 { + i -= len(m.Supply) + copy(dAtA[i:], m.Supply) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Supply))) + i-- + dAtA[i] = 0x12 + } + if len(m.Cap) > 0 { + i -= len(m.Cap) + copy(dAtA[i:], m.Cap) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Cap))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MinterSupplyRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *MinterSupplyResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Cap) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Supply) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MinterSupplyRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MinterSupplyRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MinterSupplyRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MinterSupplyResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MinterSupplyResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MinterSupplyResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cap", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cap = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Supply", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Supply = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/wrapped-a0gi-base/types/query.pb.gw.go b/x/wrapped-a0gi-base/types/query.pb.gw.go new file mode 100644 index 00000000..a4bbda75 --- /dev/null +++ b/x/wrapped-a0gi-base/types/query.pb.gw.go @@ -0,0 +1,171 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: zgc/wrappeda0gibase/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +var ( + filter_Query_MinterSupply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_MinterSupply_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MinterSupplyRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MinterSupply_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.MinterSupply(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_MinterSupply_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq MinterSupplyRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MinterSupply_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.MinterSupply(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_MinterSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_MinterSupply_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_MinterSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_MinterSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_MinterSupply_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_MinterSupply_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_MinterSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"0g", "wrapped-a0gi-base", "minter-supply"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_MinterSupply_0 = runtime.ForwardResponseMessage +) diff --git a/x/wrapped-a0gi-base/types/tx.pb.go b/x/wrapped-a0gi-base/types/tx.pb.go new file mode 100644 index 00000000..78de5739 --- /dev/null +++ b/x/wrapped-a0gi-base/types/tx.pb.go @@ -0,0 +1,1750 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zgc/wrappeda0gibase/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type MsgSetWA0GI struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *MsgSetWA0GI) Reset() { *m = MsgSetWA0GI{} } +func (m *MsgSetWA0GI) String() string { return proto.CompactTextString(m) } +func (*MsgSetWA0GI) ProtoMessage() {} +func (*MsgSetWA0GI) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{0} +} +func (m *MsgSetWA0GI) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetWA0GI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetWA0GI.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetWA0GI) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetWA0GI.Merge(m, src) +} +func (m *MsgSetWA0GI) XXX_Size() int { + return m.Size() +} +func (m *MsgSetWA0GI) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetWA0GI.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetWA0GI proto.InternalMessageInfo + +type MsgSetWA0GIResponse struct { +} + +func (m *MsgSetWA0GIResponse) Reset() { *m = MsgSetWA0GIResponse{} } +func (m *MsgSetWA0GIResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetWA0GIResponse) ProtoMessage() {} +func (*MsgSetWA0GIResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{1} +} +func (m *MsgSetWA0GIResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetWA0GIResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetWA0GIResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetWA0GIResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetWA0GIResponse.Merge(m, src) +} +func (m *MsgSetWA0GIResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetWA0GIResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetWA0GIResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetWA0GIResponse proto.InternalMessageInfo + +type MsgSetMintCap struct { + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Minter string `protobuf:"bytes,2,opt,name=minter,proto3" json:"minter,omitempty"` + Cap string `protobuf:"bytes,3,opt,name=cap,proto3" json:"cap,omitempty"` +} + +func (m *MsgSetMintCap) Reset() { *m = MsgSetMintCap{} } +func (m *MsgSetMintCap) String() string { return proto.CompactTextString(m) } +func (*MsgSetMintCap) ProtoMessage() {} +func (*MsgSetMintCap) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{2} +} +func (m *MsgSetMintCap) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetMintCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetMintCap.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetMintCap) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMintCap.Merge(m, src) +} +func (m *MsgSetMintCap) XXX_Size() int { + return m.Size() +} +func (m *MsgSetMintCap) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMintCap.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetMintCap proto.InternalMessageInfo + +type MsgSetMintCapResponse struct { +} + +func (m *MsgSetMintCapResponse) Reset() { *m = MsgSetMintCapResponse{} } +func (m *MsgSetMintCapResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetMintCapResponse) ProtoMessage() {} +func (*MsgSetMintCapResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{3} +} +func (m *MsgSetMintCapResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetMintCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetMintCapResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetMintCapResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMintCapResponse.Merge(m, src) +} +func (m *MsgSetMintCapResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetMintCapResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMintCapResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetMintCapResponse proto.InternalMessageInfo + +type MsgMint struct { + Minter string `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` + To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgMint) Reset() { *m = MsgMint{} } +func (m *MsgMint) String() string { return proto.CompactTextString(m) } +func (*MsgMint) ProtoMessage() {} +func (*MsgMint) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{4} +} +func (m *MsgMint) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMint.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgMint) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMint.Merge(m, src) +} +func (m *MsgMint) XXX_Size() int { + return m.Size() +} +func (m *MsgMint) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMint.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMint proto.InternalMessageInfo + +type MsgMintResponse struct { +} + +func (m *MsgMintResponse) Reset() { *m = MsgMintResponse{} } +func (m *MsgMintResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintResponse) ProtoMessage() {} +func (*MsgMintResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{5} +} +func (m *MsgMintResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgMintResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintResponse.Merge(m, src) +} +func (m *MsgMintResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintResponse proto.InternalMessageInfo + +type MsgBurn struct { + Minter string `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgBurn) Reset() { *m = MsgBurn{} } +func (m *MsgBurn) String() string { return proto.CompactTextString(m) } +func (*MsgBurn) ProtoMessage() {} +func (*MsgBurn) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{6} +} +func (m *MsgBurn) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurn) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurn.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgBurn) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurn.Merge(m, src) +} +func (m *MsgBurn) XXX_Size() int { + return m.Size() +} +func (m *MsgBurn) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurn.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurn proto.InternalMessageInfo + +type MsgBurnResponse struct { +} + +func (m *MsgBurnResponse) Reset() { *m = MsgBurnResponse{} } +func (m *MsgBurnResponse) String() string { return proto.CompactTextString(m) } +func (*MsgBurnResponse) ProtoMessage() {} +func (*MsgBurnResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f80bf93a1fc022d3, []int{7} +} +func (m *MsgBurnResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBurnResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBurnResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgBurnResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBurnResponse.Merge(m, src) +} +func (m *MsgBurnResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgBurnResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBurnResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSetWA0GI)(nil), "zgc.wrappeda0gibase.MsgSetWA0GI") + proto.RegisterType((*MsgSetWA0GIResponse)(nil), "zgc.wrappeda0gibase.MsgSetWA0GIResponse") + proto.RegisterType((*MsgSetMintCap)(nil), "zgc.wrappeda0gibase.MsgSetMintCap") + proto.RegisterType((*MsgSetMintCapResponse)(nil), "zgc.wrappeda0gibase.MsgSetMintCapResponse") + proto.RegisterType((*MsgMint)(nil), "zgc.wrappeda0gibase.MsgMint") + proto.RegisterType((*MsgMintResponse)(nil), "zgc.wrappeda0gibase.MsgMintResponse") + proto.RegisterType((*MsgBurn)(nil), "zgc.wrappeda0gibase.MsgBurn") + proto.RegisterType((*MsgBurnResponse)(nil), "zgc.wrappeda0gibase.MsgBurnResponse") +} + +func init() { proto.RegisterFile("zgc/wrappeda0gibase/tx.proto", fileDescriptor_f80bf93a1fc022d3) } + +var fileDescriptor_f80bf93a1fc022d3 = []byte{ + // 433 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6b, 0xd4, 0x40, + 0x14, 0xc7, 0x93, 0xac, 0xb4, 0xf6, 0xf9, 0x3b, 0xb5, 0x9a, 0x86, 0x25, 0x94, 0xe0, 0xa1, 0x08, + 0x9b, 0x09, 0xea, 0xc5, 0xa3, 0x15, 0x91, 0x0a, 0xb9, 0xac, 0x60, 0xc1, 0x83, 0x32, 0xc9, 0x8e, + 0xb3, 0x81, 0x26, 0x13, 0x32, 0x13, 0xec, 0xf6, 0xaf, 0xf0, 0xcf, 0xea, 0x71, 0x2f, 0x82, 0x47, + 0xdd, 0xfd, 0x47, 0x64, 0x26, 0x93, 0x6c, 0xb6, 0x6c, 0x76, 0x6f, 0xf3, 0xbe, 0xdf, 0xf7, 0x3e, + 0x0f, 0xbe, 0xc3, 0x83, 0xe1, 0x35, 0x4d, 0xd0, 0xcf, 0x12, 0x17, 0x05, 0x99, 0xe0, 0x90, 0xa6, + 0x31, 0xe6, 0x04, 0x89, 0xab, 0xa0, 0x28, 0x99, 0x60, 0xf6, 0xe1, 0x35, 0x4d, 0x82, 0x5b, 0xae, + 0x7b, 0x9c, 0x30, 0x9e, 0x31, 0xfe, 0x5d, 0xb5, 0xa0, 0xba, 0xa8, 0xfb, 0xdd, 0xa7, 0x94, 0x51, + 0x56, 0xeb, 0xf2, 0xa5, 0xd5, 0x63, 0xca, 0x18, 0xbd, 0x24, 0x48, 0x55, 0x71, 0xf5, 0x03, 0xe1, + 0x7c, 0x56, 0x5b, 0xfe, 0x07, 0xb8, 0x17, 0x71, 0xfa, 0x99, 0x88, 0x8b, 0x77, 0xe1, 0xc7, 0x73, + 0x7b, 0x08, 0x07, 0xb8, 0x12, 0x53, 0x56, 0xa6, 0x62, 0xe6, 0x98, 0x27, 0xe6, 0xe9, 0xc1, 0x78, + 0x25, 0xd8, 0x0e, 0xec, 0xe3, 0xc9, 0xa4, 0x24, 0x9c, 0x3b, 0x96, 0xf2, 0x9a, 0xd2, 0x3f, 0x82, + 0xc3, 0x0e, 0x66, 0x4c, 0x78, 0xc1, 0x72, 0x4e, 0xfc, 0x0b, 0x78, 0x50, 0xcb, 0x51, 0x9a, 0x8b, + 0xf7, 0xb8, 0xd8, 0xc1, 0x7f, 0x06, 0x7b, 0x59, 0x9a, 0x0b, 0x52, 0x6a, 0xbc, 0xae, 0xec, 0xc7, + 0x30, 0x48, 0x70, 0xe1, 0x0c, 0x94, 0x28, 0x9f, 0xfe, 0x73, 0x38, 0x5a, 0x03, 0xb7, 0x1b, 0xcf, + 0x61, 0x3f, 0xe2, 0x54, 0xaa, 0x1d, 0x9a, 0xb9, 0x46, 0x7b, 0x08, 0x96, 0x60, 0x7a, 0x83, 0x25, + 0x98, 0xec, 0xc3, 0x19, 0xab, 0x72, 0xa1, 0x17, 0xe8, 0xca, 0x7f, 0x02, 0x8f, 0x34, 0xaa, 0xa5, + 0xbf, 0x55, 0xf4, 0xb3, 0xaa, 0xcc, 0x7b, 0xe9, 0x2b, 0x9a, 0xb5, 0x81, 0x26, 0x47, 0x1b, 0xda, + 0xab, 0xdf, 0x16, 0x0c, 0x22, 0x4e, 0xed, 0x2f, 0x70, 0xb7, 0xfd, 0x80, 0x93, 0x60, 0xc3, 0x8f, + 0x07, 0x9d, 0x6c, 0xdd, 0xd3, 0x5d, 0x1d, 0x0d, 0xdf, 0xfe, 0x06, 0xf7, 0x75, 0x42, 0xa4, 0x94, + 0xe1, 0xfb, 0x5b, 0x26, 0x75, 0x8e, 0xee, 0xcb, 0xdd, 0x3d, 0x2d, 0xff, 0x13, 0xdc, 0x51, 0x41, + 0x0f, 0xfb, 0x66, 0xa4, 0xeb, 0xbe, 0xd8, 0xe6, 0x76, 0x59, 0x2a, 0xd6, 0x5e, 0x96, 0x74, 0xfb, + 0x59, 0xdd, 0x5c, 0xcf, 0xc6, 0x37, 0xff, 0x3c, 0xe3, 0x66, 0xe1, 0x99, 0xf3, 0x85, 0x67, 0xfe, + 0x5d, 0x78, 0xe6, 0xaf, 0xa5, 0x67, 0xcc, 0x97, 0x9e, 0xf1, 0x67, 0xe9, 0x19, 0x5f, 0xdf, 0xd0, + 0x54, 0x4c, 0xab, 0x38, 0x48, 0x58, 0x86, 0x42, 0x7a, 0x89, 0x63, 0x8e, 0x42, 0x3a, 0x4a, 0xa6, + 0x38, 0xcd, 0xd1, 0x55, 0x73, 0x89, 0x23, 0x09, 0x1f, 0xd5, 0xb7, 0x38, 0x2b, 0x08, 0x8f, 0xf7, + 0xd4, 0xb9, 0xbc, 0xfe, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xeb, 0xd8, 0x1c, 0xf0, 0xaf, 0x03, 0x00, + 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + SetWA0GI(ctx context.Context, in *MsgSetWA0GI, opts ...grpc.CallOption) (*MsgSetWA0GIResponse, error) + SetMinterCap(ctx context.Context, in *MsgSetMintCap, opts ...grpc.CallOption) (*MsgSetMintCapResponse, error) + Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) + Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SetWA0GI(ctx context.Context, in *MsgSetWA0GI, opts ...grpc.CallOption) (*MsgSetWA0GIResponse, error) { + out := new(MsgSetWA0GIResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/SetWA0GI", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SetMinterCap(ctx context.Context, in *MsgSetMintCap, opts ...grpc.CallOption) (*MsgSetMintCapResponse, error) { + out := new(MsgSetMintCapResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/SetMinterCap", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) { + out := new(MsgMintResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/Mint", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) { + out := new(MsgBurnResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/Burn", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + SetWA0GI(context.Context, *MsgSetWA0GI) (*MsgSetWA0GIResponse, error) + SetMinterCap(context.Context, *MsgSetMintCap) (*MsgSetMintCapResponse, error) + Mint(context.Context, *MsgMint) (*MsgMintResponse, error) + Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SetWA0GI(ctx context.Context, req *MsgSetWA0GI) (*MsgSetWA0GIResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetWA0GI not implemented") +} +func (*UnimplementedMsgServer) SetMinterCap(ctx context.Context, req *MsgSetMintCap) (*MsgSetMintCapResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetMinterCap not implemented") +} +func (*UnimplementedMsgServer) Mint(ctx context.Context, req *MsgMint) (*MsgMintResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Mint not implemented") +} +func (*UnimplementedMsgServer) Burn(ctx context.Context, req *MsgBurn) (*MsgBurnResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Burn not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SetWA0GI_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetWA0GI) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetWA0GI(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/SetWA0GI", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetWA0GI(ctx, req.(*MsgSetWA0GI)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SetMinterCap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetMintCap) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetMinterCap(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/SetMinterCap", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetMinterCap(ctx, req.(*MsgSetMintCap)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Mint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMint) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Mint(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/Mint", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Mint(ctx, req.(*MsgMint)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Burn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBurn) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Burn(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Msg/Burn", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Burn(ctx, req.(*MsgBurn)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zgc.wrappeda0gibase.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SetWA0GI", + Handler: _Msg_SetWA0GI_Handler, + }, + { + MethodName: "SetMinterCap", + Handler: _Msg_SetMinterCap_Handler, + }, + { + MethodName: "Mint", + Handler: _Msg_Mint_Handler, + }, + { + MethodName: "Burn", + Handler: _Msg_Burn_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "zgc/wrappeda0gibase/tx.proto", +} + +func (m *MsgSetWA0GI) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetWA0GI) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetWA0GI) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetWA0GIResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetWA0GIResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetWA0GIResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgSetMintCap) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetMintCap) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetMintCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Cap) > 0 { + i -= len(m.Cap) + copy(dAtA[i:], m.Cap) + i = encodeVarintTx(dAtA, i, uint64(len(m.Cap))) + i-- + dAtA[i] = 0x1a + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetMintCapResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetMintCapResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetMintCapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMint) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgMint) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a + } + if len(m.To) > 0 { + i -= len(m.To) + copy(dAtA[i:], m.To) + i = encodeVarintTx(dAtA, i, uint64(len(m.To))) + i-- + dAtA[i] = 0x12 + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgMintResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgBurn) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgBurn) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurn) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Minter) > 0 { + i -= len(m.Minter) + copy(dAtA[i:], m.Minter) + i = encodeVarintTx(dAtA, i, uint64(len(m.Minter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgBurnResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgBurnResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBurnResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSetWA0GI) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetWA0GIResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetMintCap) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Cap) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSetMintCapResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMint) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.To) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgBurn) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Minter) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgBurnResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSetWA0GI) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetWA0GI: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetWA0GI: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetWA0GIResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetWA0GIResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetWA0GIResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetMintCap) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetMintCap: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetMintCap: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cap", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Cap = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetMintCapResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetMintCapResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetMintCapResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgMint) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgMint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.To = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgMintResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgMintResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBurn) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgBurn: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurn: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Minter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBurnResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgBurnResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBurnResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 58871957a8e63feffe7dc7fe0e48722d21ddc164 Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Wed, 8 Jan 2025 12:58:14 +0800 Subject: [PATCH 04/10] feat: wrapped-a0gi-base module --- app/app.go | 3 +- .../interfaces/contracts/IWrappedA0GIBase.sol | 7 +- .../wrapped-a0gi-base/IWrappedA0GIBase.json | 13 + precompiles/wrapped-a0gi-base/contract.go | 23 +- proto/zgc/wrappeda0gibase/genesis.proto | 2 +- proto/zgc/wrappeda0gibase/query.proto | 15 +- proto/zgc/wrappeda0gibase/tx.proto | 16 +- x/wrapped-a0gi-base/genesis.go | 7 +- x/wrapped-a0gi-base/keeper/grpc_query.go | 25 +- x/wrapped-a0gi-base/keeper/keeper.go | 47 +- x/wrapped-a0gi-base/keeper/msg_server.go | 92 +++- x/wrapped-a0gi-base/types/errors.go | 3 +- x/wrapped-a0gi-base/types/genesis.go | 14 +- x/wrapped-a0gi-base/types/genesis.pb.go | 50 ++- x/wrapped-a0gi-base/types/keys.go | 15 + x/wrapped-a0gi-base/types/msg.go | 22 - x/wrapped-a0gi-base/types/query.pb.go | 422 ++++++++++++++++-- x/wrapped-a0gi-base/types/query.pb.gw.go | 65 +++ x/wrapped-a0gi-base/types/tx.pb.go | 186 ++++---- 19 files changed, 815 insertions(+), 212 deletions(-) diff --git a/app/app.go b/app/app.go index e558b416..95eb8720 100644 --- a/app/app.go +++ b/app/app.go @@ -210,6 +210,7 @@ var ( bep3types.ModuleName: {authtypes.Burner, authtypes.Minter}, minttypes.ModuleName: {authtypes.Minter}, precisebanktypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for reserve account to back fractional amounts + wrappeda0gibasetypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } ) @@ -519,7 +520,7 @@ func NewApp( } precompiles[stakingPrecompile.Address()] = stakingPrecompile // wrapped wrapped a0gi base - app.wrappeda0gibaseKeeper = wrappeda0gibasekeeper.NewKeeper(keys[wrappeda0gibasetypes.StoreKey], appCodec, govAuthAddrStr) + app.wrappeda0gibaseKeeper = wrappeda0gibasekeeper.NewKeeper(keys[wrappeda0gibasetypes.StoreKey], appCodec, app.precisebankKeeper, govAuthAddrStr) wrappeda0gibasePrecompile, err := wrappeda0gibaseprecompile.NewWrappedA0giBasePrecompile(app.wrappeda0gibaseKeeper) if err != nil { panic(fmt.Sprintf("initialize wrapped a0gi base precompile failed: %v", err)) diff --git a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol index eaf5a246..7f22a024 100644 --- a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol +++ b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol @@ -13,10 +13,15 @@ interface IWrappedA0GIBase { /** * @dev set the wA0GI address. * It is designed to be called by governance module only so it's not implemented at EVM precompile side. - * @param + * @param addr address of wA0GI */ // function setWA0GI(address addr) external; + /** + * @dev get the wA0GI address. + */ + function getWA0GI() external returns (address); + /** * @dev set the cap for a minter. * It is designed to be called by governance module only so it's not implemented at EVM precompile side. diff --git a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json index 2d051720..89dae14b 100644 --- a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json +++ b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json @@ -17,6 +17,19 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "getWA0GI", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { diff --git a/precompiles/wrapped-a0gi-base/contract.go b/precompiles/wrapped-a0gi-base/contract.go index 9eccaf96..09cc37e0 100644 --- a/precompiles/wrapped-a0gi-base/contract.go +++ b/precompiles/wrapped-a0gi-base/contract.go @@ -30,7 +30,7 @@ var ( // Wrappeda0gibaseMetaData contains all meta data concerning the Wrappeda0gibase contract. var Wrappeda0gibaseMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWA0GI\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // Wrappeda0gibaseABI is the input ABI used to generate the binding from. @@ -231,6 +231,27 @@ func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Burn(minter common.Add return _Wrappeda0gibase.Contract.Burn(&_Wrappeda0gibase.TransactOpts, minter, amount) } +// GetWA0GI is a paid mutator transaction binding the contract method 0xa9283a7a. +// +// Solidity: function getWA0GI() returns(address) +func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) GetWA0GI(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Wrappeda0gibase.contract.Transact(opts, "getWA0GI") +} + +// GetWA0GI is a paid mutator transaction binding the contract method 0xa9283a7a. +// +// Solidity: function getWA0GI() returns(address) +func (_Wrappeda0gibase *Wrappeda0gibaseSession) GetWA0GI() (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.TransactOpts) +} + +// GetWA0GI is a paid mutator transaction binding the contract method 0xa9283a7a. +// +// Solidity: function getWA0GI() returns(address) +func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) GetWA0GI() (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.TransactOpts) +} + // Mint is a paid mutator transaction binding the contract method 0xc6c3bbe6. // // Solidity: function mint(address minter, address to, uint256 amount) returns() diff --git a/proto/zgc/wrappeda0gibase/genesis.proto b/proto/zgc/wrappeda0gibase/genesis.proto index 66fd833a..3915a898 100644 --- a/proto/zgc/wrappeda0gibase/genesis.proto +++ b/proto/zgc/wrappeda0gibase/genesis.proto @@ -11,5 +11,5 @@ option go_package = "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types"; // GenesisState defines the wrapped a0gi base module's genesis state. message GenesisState { // address of wrapped a0gi contract - string wrapped_a0gi_address = 1; + bytes wrapped_a0gi_address = 1; } diff --git a/proto/zgc/wrappeda0gibase/query.proto b/proto/zgc/wrappeda0gibase/query.proto index 97958902..a242ad39 100644 --- a/proto/zgc/wrappeda0gibase/query.proto +++ b/proto/zgc/wrappeda0gibase/query.proto @@ -12,16 +12,25 @@ option (gogoproto.goproto_getters_all) = false; // Query defines the gRPC querier service for the wrapped a0gi base module service Query { + rpc GetWA0GI(GetWA0GIRequest) returns (GetWA0GIResponse) { + option (google.api.http).get = "/0g/wrapped-a0gi-base/get-wa0gi"; + } rpc MinterSupply(MinterSupplyRequest) returns (MinterSupplyResponse) { option (google.api.http).get = "/0g/wrapped-a0gi-base/minter-supply"; } } +message GetWA0GIRequest {} + +message GetWA0GIResponse { + bytes address = 1; +} + message MinterSupplyRequest { - string address = 1; + bytes address = 1; } message MinterSupplyResponse { - string cap = 1; - string supply = 2; + bytes cap = 1; // big endian + bytes supply = 2; // big endian } diff --git a/proto/zgc/wrappeda0gibase/tx.proto b/proto/zgc/wrappeda0gibase/tx.proto index 6f247d93..61fed0f7 100644 --- a/proto/zgc/wrappeda0gibase/tx.proto +++ b/proto/zgc/wrappeda0gibase/tx.proto @@ -18,30 +18,30 @@ service Msg { message MsgSetWA0GI { string authority = 1; - string address = 2; + bytes address = 2; } message MsgSetWA0GIResponse {} message MsgSetMintCap { string authority = 1; - string minter = 2; - string cap = 3; + bytes minter = 2; + bytes cap = 3; // big endian } message MsgSetMintCapResponse {} message MsgMint { - string minter = 1; - string to = 2; - string amount = 3; + bytes minter = 1; + bytes to = 2; + bytes amount = 3; // big endian } message MsgMintResponse {} message MsgBurn { - string minter = 1; - string amount = 2; + bytes minter = 1; + bytes amount = 2; // big endian } message MsgBurnResponse {} diff --git a/x/wrapped-a0gi-base/genesis.go b/x/wrapped-a0gi-base/genesis.go index 4029ed65..56da0ad5 100644 --- a/x/wrapped-a0gi-base/genesis.go +++ b/x/wrapped-a0gi-base/genesis.go @@ -6,6 +6,7 @@ import ( "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" ) // InitGenesis initializes the store state from a genesis state. @@ -13,10 +14,12 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) { if err := gs.Validate(); err != nil { panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err)) } - panic("unimplemented") + keeper.SetWA0GIAddress(ctx, common.BytesToAddress(gs.WrappedA0GiAddress)) } // ExportGenesis returns a GenesisState for a given context and keeper. func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { - panic("unimplemented") + return &types.GenesisState{ + WrappedA0GiAddress: keeper.GetWA0GIAddress(ctx), + } } diff --git a/x/wrapped-a0gi-base/keeper/grpc_query.go b/x/wrapped-a0gi-base/keeper/grpc_query.go index cd144ac2..3164fb26 100644 --- a/x/wrapped-a0gi-base/keeper/grpc_query.go +++ b/x/wrapped-a0gi-base/keeper/grpc_query.go @@ -4,11 +4,34 @@ import ( "context" "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" ) var _ types.QueryServer = Keeper{} // MinterSupply implements types.QueryServer. func (k Keeper) MinterSupply(c context.Context, request *types.MinterSupplyRequest) (*types.MinterSupplyResponse, error) { - panic("unimplemented") + ctx := sdk.UnwrapSDKContext(c) + account := common.BytesToAddress(request.Address) + cap, err := k.getMinterCap(ctx, account) + if err != nil { + return nil, err + } + supply, err := k.getMinterSupply(ctx, account) + if err != nil { + return nil, err + } + return &types.MinterSupplyResponse{ + Cap: cap.Bytes(), + Supply: supply.Bytes(), + }, nil +} + +// GetWA0GI implements types.QueryServer. +func (k Keeper) GetWA0GI(c context.Context, request *types.GetWA0GIRequest) (*types.GetWA0GIResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + return &types.GetWA0GIResponse{ + Address: k.GetWA0GIAddress(ctx), + }, nil } diff --git a/x/wrapped-a0gi-base/keeper/keeper.go b/x/wrapped-a0gi-base/keeper/keeper.go index b20e7e0b..13a77c67 100644 --- a/x/wrapped-a0gi-base/keeper/keeper.go +++ b/x/wrapped-a0gi-base/keeper/keeper.go @@ -1,14 +1,22 @@ package keeper import ( - "github.com/cosmos/cosmos-sdk/codec" + "math/big" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/ethereum/go-ethereum/common" + + precisebankkeeper "github.com/0glabs/0g-chain/x/precisebank/keeper" + "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec + pbkeeper precisebankkeeper.Keeper authority string // the address capable of changing signers params. Should be the gov module account } @@ -16,11 +24,48 @@ type Keeper struct { func NewKeeper( storeKey storetypes.StoreKey, cdc codec.BinaryCodec, + pbkeeper precisebankkeeper.Keeper, authority string, ) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, + pbkeeper: pbkeeper, authority: authority, } } + +func (k Keeper) SetWA0GIAddress(ctx sdk.Context, addr common.Address) { + store := ctx.KVStore(k.storeKey) + store.Set(types.WA0GIKey, addr.Bytes()) +} + +func (k Keeper) GetWA0GIAddress(ctx sdk.Context) []byte { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.WA0GIKey) + return bz +} + +func (k Keeper) setMinterCap(ctx sdk.Context, account common.Address, cap *big.Int) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterCapKeyPrefix) + store.Set(account.Bytes(), cap.Bytes()) + return nil +} + +func (k Keeper) getMinterCap(ctx sdk.Context, account common.Address) (*big.Int, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterCapKeyPrefix) + bz := store.Get(account.Bytes()) + return new(big.Int).SetBytes(bz), nil +} + +func (k Keeper) setMinterSupply(ctx sdk.Context, account common.Address, supply *big.Int) error { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterSupplyKeyPrefix) + store.Set(account.Bytes(), supply.Bytes()) + return nil +} + +func (k Keeper) getMinterSupply(ctx sdk.Context, account common.Address) (*big.Int, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.MinterSupplyKeyPrefix) + bz := store.Get(account.Bytes()) + return new(big.Int).SetBytes(bz), nil +} diff --git a/x/wrapped-a0gi-base/keeper/msg_server.go b/x/wrapped-a0gi-base/keeper/msg_server.go index e01fa164..dc3759cc 100644 --- a/x/wrapped-a0gi-base/keeper/msg_server.go +++ b/x/wrapped-a0gi-base/keeper/msg_server.go @@ -2,37 +2,107 @@ package keeper import ( "context" + "math/big" - "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" -) - -/* errorsmod "cosmossdk.io/errors" - "github.com/0glabs/0g-chain/crypto/bn254util" + precisebanktypes "github.com/0glabs/0g-chain/x/precisebank/types" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" sdk "github.com/cosmos/cosmos-sdk/types" gov "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/ethereum/go-ethereum/common" - etherminttypes "github.com/evmos/ethermint/types" -*/ +) var _ types.MsgServer = &Keeper{} // Burn implements types.MsgServer. func (k Keeper) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnResponse, error) { - panic("unimplemented") + ctx := sdk.UnwrapSDKContext(goCtx) + minter := common.BytesToAddress(msg.Minter) + cap, err := k.getMinterCap(ctx, minter) + if err != nil { + return nil, err + } + supply, err := k.getMinterSupply(ctx, minter) + if err != nil { + return nil, err + } + amount := new(big.Int).SetBytes(msg.Amount) + // check & update mint supply + supply.Sub(supply, amount) + if supply.Cmp(cap) > 0 { + return nil, types.ErrInsufficientMintCap + } + if err = k.setMinterSupply(ctx, minter, supply); err != nil { + return nil, err + } + // transfer & burn + c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount)) + burner := sdk.AccAddress(minter.Bytes()) + if err = k.pbkeeper.SendCoinsFromAccountToModule(ctx, burner, types.ModuleName, sdk.NewCoins(c)); err != nil { + return nil, err + } + if err = k.pbkeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil { + return nil, err + } + return &types.MsgBurnResponse{}, nil } // Mint implements types.MsgServer. func (k Keeper) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) { - panic("unimplemented") + ctx := sdk.UnwrapSDKContext(goCtx) + minter := common.BytesToAddress(msg.Minter) + cap, err := k.getMinterCap(ctx, minter) + if err != nil { + return nil, err + } + supply, err := k.getMinterSupply(ctx, minter) + if err != nil { + return nil, err + } + amount := new(big.Int).SetBytes(msg.Amount) + // check & update mint supply + supply.Add(supply, amount) + if supply.Cmp(cap) > 0 { + return nil, types.ErrInsufficientMintCap + } + if err = k.setMinterSupply(ctx, minter, supply); err != nil { + return nil, err + } + // mint & transfer + c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount)) + if err = k.pbkeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil { + return nil, err + } + recipient := sdk.AccAddress(common.BytesToAddress(msg.To).Bytes()) + if err = k.pbkeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, recipient, sdk.NewCoins(c)); err != nil { + return nil, err + } + return &types.MsgMintResponse{}, nil } // SetMinterCap implements types.MsgServer. func (k Keeper) SetMinterCap(goCtx context.Context, msg *types.MsgSetMintCap) (*types.MsgSetMintCapResponse, error) { - panic("unimplemented") + ctx := sdk.UnwrapSDKContext(goCtx) + minter := common.BytesToAddress(msg.Minter) + // validate authority + if k.authority != msg.Authority { + return nil, errorsmod.Wrapf(gov.ErrInvalidSigner, "expected %s got %s", k.authority, msg.Authority) + } + // update minter cap + if err := k.setMinterCap(ctx, minter, new(big.Int).SetBytes(msg.Cap)); err != nil { + return nil, err + } + return &types.MsgSetMintCapResponse{}, nil } // SetWA0GI implements types.MsgServer. func (k Keeper) SetWA0GI(goCtx context.Context, msg *types.MsgSetWA0GI) (*types.MsgSetWA0GIResponse, error) { - panic("unimplemented") + ctx := sdk.UnwrapSDKContext(goCtx) + // validate authority + if k.authority != msg.Authority { + return nil, errorsmod.Wrapf(gov.ErrInvalidSigner, "expected %s got %s", k.authority, msg.Authority) + } + // save new address + k.SetWA0GIAddress(ctx, common.BytesToAddress(msg.Address)) + return &types.MsgSetWA0GIResponse{}, nil } diff --git a/x/wrapped-a0gi-base/types/errors.go b/x/wrapped-a0gi-base/types/errors.go index f77409c1..7b38b98c 100644 --- a/x/wrapped-a0gi-base/types/errors.go +++ b/x/wrapped-a0gi-base/types/errors.go @@ -3,5 +3,6 @@ package types import errorsmod "cosmossdk.io/errors" var ( - ErrTxForbidden = errorsmod.Register(ModuleName, 1, "cosmos tx forbidden") + ErrTxForbidden = errorsmod.Register(ModuleName, 1, "cosmos tx forbidden") + ErrInsufficientMintCap = errorsmod.Register(ModuleName, 2, "insufficient mint cap") ) diff --git a/x/wrapped-a0gi-base/types/genesis.go b/x/wrapped-a0gi-base/types/genesis.go index 75265bac..0b622117 100644 --- a/x/wrapped-a0gi-base/types/genesis.go +++ b/x/wrapped-a0gi-base/types/genesis.go @@ -1,18 +1,24 @@ package types +import "github.com/ethereum/go-ethereum/common" + +const ( + DEFAULT_WRAPPED_A0GI = "0000000000000000000000000000000000000000" +) + // NewGenesisState returns a new genesis state object for the module. -func NewGenesisState(addr string) *GenesisState { +func NewGenesisState(addr common.Address) *GenesisState { return &GenesisState{ - WrappedA0GiAddress: addr, + WrappedA0GiAddress: addr.Bytes(), } } // DefaultGenesisState returns the default genesis state for the module. func DefaultGenesisState() *GenesisState { - return NewGenesisState("0000000000000000000000000000000000000000") + return NewGenesisState(common.HexToAddress(DEFAULT_WRAPPED_A0GI)) } // Validate performs basic validation of genesis data. func (gs GenesisState) Validate() error { - return ValidateHexAddress(gs.WrappedA0GiAddress) + return nil } diff --git a/x/wrapped-a0gi-base/types/genesis.pb.go b/x/wrapped-a0gi-base/types/genesis.pb.go index dd6a07da..4d23ee39 100644 --- a/x/wrapped-a0gi-base/types/genesis.pb.go +++ b/x/wrapped-a0gi-base/types/genesis.pb.go @@ -29,7 +29,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the wrapped a0gi base module's genesis state. type GenesisState struct { // address of wrapped a0gi contract - WrappedA0GiAddress string `protobuf:"bytes,1,opt,name=wrapped_a0gi_address,json=wrappedA0giAddress,proto3" json:"wrapped_a0gi_address,omitempty"` + WrappedA0GiAddress []byte `protobuf:"bytes,1,opt,name=wrapped_a0gi_address,json=wrappedA0giAddress,proto3" json:"wrapped_a0gi_address,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -65,11 +65,11 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetWrappedA0GiAddress() string { +func (m *GenesisState) GetWrappedA0GiAddress() []byte { if m != nil { return m.WrappedA0GiAddress } - return "" + return nil } func init() { @@ -81,21 +81,21 @@ func init() { proto.RegisterFile("zgc/wrappeda0gibase/genesis.proto", fileDescri var fileDescriptor_7e056019f61fd820 = []byte{ // 246 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xbd, 0x4e, 0xc3, 0x30, - 0x10, 0x80, 0xe3, 0x05, 0x89, 0x88, 0x29, 0x74, 0xa0, 0x1d, 0xcc, 0xcf, 0xc4, 0x92, 0xd8, 0x12, - 0x3c, 0x00, 0x65, 0x61, 0x63, 0x80, 0x8d, 0x25, 0xb2, 0x1d, 0x73, 0xb5, 0xd4, 0xe4, 0xac, 0x9c, - 0x2b, 0x68, 0x9f, 0x82, 0xc7, 0x62, 0xec, 0xc8, 0x88, 0x92, 0x17, 0x41, 0x89, 0xc3, 0x92, 0xcd, - 0x77, 0xdf, 0x27, 0xf9, 0xd3, 0xa5, 0xd7, 0x07, 0x30, 0xe2, 0xa3, 0x55, 0xde, 0xdb, 0x4a, 0x49, - 0x70, 0x5a, 0x91, 0x15, 0x60, 0x1b, 0x4b, 0x8e, 0x0a, 0xdf, 0x62, 0xc0, 0xec, 0xfc, 0x00, 0xa6, - 0x98, 0x29, 0xab, 0xa5, 0x41, 0xaa, 0x91, 0xca, 0x51, 0x11, 0x71, 0x88, 0xfe, 0x6a, 0x01, 0x08, - 0x18, 0xf7, 0xc3, 0x6b, 0xda, 0x2e, 0x01, 0x11, 0xb6, 0x56, 0x8c, 0x93, 0xde, 0xbd, 0x0b, 0xd5, - 0xec, 0x27, 0x74, 0x39, 0x47, 0xc1, 0xd5, 0x96, 0x82, 0xaa, 0x7d, 0x14, 0x6e, 0x1e, 0xd2, 0xb3, - 0xa7, 0x98, 0xf4, 0x1a, 0x54, 0xb0, 0x99, 0x4c, 0x17, 0x53, 0x4f, 0x39, 0x04, 0x95, 0xaa, 0xaa, - 0x5a, 0x4b, 0x74, 0xc1, 0xae, 0xd8, 0xed, 0xe9, 0x4b, 0x36, 0xb1, 0xb5, 0x04, 0xb7, 0x8e, 0xe4, - 0xf1, 0xf9, 0xbb, 0xe3, 0xec, 0xd8, 0x71, 0xf6, 0xdb, 0x71, 0xf6, 0xd5, 0xf3, 0xe4, 0xd8, 0xf3, - 0xe4, 0xa7, 0xe7, 0xc9, 0xdb, 0x3d, 0xb8, 0xb0, 0xd9, 0xe9, 0xc2, 0x60, 0x2d, 0x24, 0x6c, 0x95, - 0x26, 0x21, 0x21, 0x37, 0x1b, 0xe5, 0x1a, 0xf1, 0xf9, 0x7f, 0x99, 0x7c, 0xf8, 0x26, 0x1f, 0x6f, - 0x13, 0xf6, 0xde, 0x92, 0x3e, 0x19, 0xc3, 0xee, 0xfe, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe8, 0xe8, - 0x6b, 0x2a, 0x3f, 0x01, 0x00, 0x00, + 0x10, 0x80, 0xe3, 0x85, 0x21, 0xea, 0x14, 0x3a, 0xd0, 0x0e, 0xe6, 0x67, 0x62, 0x49, 0x6c, 0x09, + 0x1e, 0x80, 0xb2, 0xb0, 0x31, 0xc0, 0xc6, 0x12, 0xd9, 0x8e, 0xb9, 0x5a, 0x6a, 0x72, 0x56, 0xce, + 0x15, 0xb4, 0x4f, 0xc1, 0x63, 0x31, 0x76, 0x64, 0x44, 0xc9, 0x8b, 0xa0, 0xc4, 0x61, 0xc9, 0xe6, + 0xbb, 0xef, 0x93, 0xfc, 0xe9, 0xd2, 0xeb, 0x23, 0x18, 0xf1, 0xd1, 0x2a, 0xef, 0x6d, 0xa5, 0x24, + 0x38, 0xad, 0xc8, 0x0a, 0xb0, 0x8d, 0x25, 0x47, 0x85, 0x6f, 0x31, 0x60, 0x76, 0x7e, 0x04, 0x53, + 0xcc, 0x94, 0xf5, 0xca, 0x20, 0xd5, 0x48, 0xe5, 0xa8, 0x88, 0x38, 0x44, 0x7f, 0xbd, 0x04, 0x04, + 0x8c, 0xfb, 0xe1, 0x35, 0x6d, 0x57, 0x80, 0x08, 0x3b, 0x2b, 0xc6, 0x49, 0xef, 0xdf, 0x85, 0x6a, + 0x0e, 0x13, 0xba, 0x9c, 0xa3, 0xe0, 0x6a, 0x4b, 0x41, 0xd5, 0x3e, 0x0a, 0x37, 0x0f, 0xe9, 0xe2, + 0x29, 0x26, 0xbd, 0x06, 0x15, 0x6c, 0x26, 0xd3, 0xe5, 0xd4, 0x53, 0x0e, 0x41, 0xa5, 0xaa, 0xaa, + 0xd6, 0x12, 0x5d, 0xb0, 0x2b, 0x76, 0xbb, 0x78, 0xc9, 0x26, 0xb6, 0x91, 0xe0, 0x36, 0x91, 0x3c, + 0x3e, 0x7f, 0x77, 0x9c, 0x9d, 0x3a, 0xce, 0x7e, 0x3b, 0xce, 0xbe, 0x7a, 0x9e, 0x9c, 0x7a, 0x9e, + 0xfc, 0xf4, 0x3c, 0x79, 0xbb, 0x07, 0x17, 0xb6, 0x7b, 0x5d, 0x18, 0xac, 0x85, 0x84, 0x9d, 0xd2, + 0x24, 0x24, 0xe4, 0x66, 0xab, 0x5c, 0x23, 0x3e, 0xff, 0x2f, 0x93, 0x0f, 0xdf, 0xe4, 0xe3, 0x6d, + 0xc2, 0xc1, 0x5b, 0xd2, 0x67, 0x63, 0xd8, 0xdd, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xec, 0x50, + 0x04, 0x4c, 0x3f, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -191,7 +191,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field WrappedA0GiAddress", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -201,23 +201,25 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - m.WrappedA0GiAddress = string(dAtA[iNdEx:postIndex]) + m.WrappedA0GiAddress = append(m.WrappedA0GiAddress[:0], dAtA[iNdEx:postIndex]...) + if m.WrappedA0GiAddress == nil { + m.WrappedA0GiAddress = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/wrapped-a0gi-base/types/keys.go b/x/wrapped-a0gi-base/types/keys.go index 29578c19..47d86e2f 100644 --- a/x/wrapped-a0gi-base/types/keys.go +++ b/x/wrapped-a0gi-base/types/keys.go @@ -1,5 +1,7 @@ package types +import "encoding/hex" + const ( // ModuleName The name that will be used throughout the module ModuleName = "wrapped-a0gi-base" @@ -10,3 +12,16 @@ const ( // QuerierRoute Top level query string QuerierRoute = ModuleName ) + +var ( + // prefix + MinterCapKeyPrefix = []byte{0x00} + MinterSupplyKeyPrefix = []byte{0x01} + + // keys + WA0GIKey = []byte{0x00} +) + +func GetMinterKeyFromAccount(account string) ([]byte, error) { + return hex.DecodeString(account) +} diff --git a/x/wrapped-a0gi-base/types/msg.go b/x/wrapped-a0gi-base/types/msg.go index cc634912..6d6b4a00 100644 --- a/x/wrapped-a0gi-base/types/msg.go +++ b/x/wrapped-a0gi-base/types/msg.go @@ -1,26 +1,12 @@ package types import ( - "encoding/hex" - fmt "fmt" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" ) var _, _, _, _ sdk.Msg = &MsgSetWA0GI{}, &MsgSetMintCap{}, &MsgMint{}, &MsgBurn{} -func ValidateHexAddress(account string) error { - addr, err := hex.DecodeString(account) - if err != nil { - return err - } - if len(addr) != 20 { - return fmt.Errorf("invalid address length") - } - return nil -} - func (msg *MsgSetWA0GI) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.Authority) return []sdk.AccAddress{addr} @@ -31,10 +17,6 @@ func (msg *MsgSetWA0GI) ValidateBasic() error { return errorsmod.Wrap(err, "authority") } - if err := ValidateHexAddress(msg.Address); err != nil { - return errorsmod.Wrap(err, "address") - } - return nil } @@ -52,10 +34,6 @@ func (msg *MsgSetMintCap) ValidateBasic() error { return errorsmod.Wrap(err, "authority") } - if err := ValidateHexAddress(msg.Minter); err != nil { - return errorsmod.Wrap(err, "minter") - } - return nil } diff --git a/x/wrapped-a0gi-base/types/query.pb.go b/x/wrapped-a0gi-base/types/query.pb.go index bcba92eb..ed2753b2 100644 --- a/x/wrapped-a0gi-base/types/query.pb.go +++ b/x/wrapped-a0gi-base/types/query.pb.go @@ -32,15 +32,88 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type GetWA0GIRequest struct { +} + +func (m *GetWA0GIRequest) Reset() { *m = GetWA0GIRequest{} } +func (m *GetWA0GIRequest) String() string { return proto.CompactTextString(m) } +func (*GetWA0GIRequest) ProtoMessage() {} +func (*GetWA0GIRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_19911faa2ec12c75, []int{0} +} +func (m *GetWA0GIRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetWA0GIRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetWA0GIRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetWA0GIRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetWA0GIRequest.Merge(m, src) +} +func (m *GetWA0GIRequest) XXX_Size() int { + return m.Size() +} +func (m *GetWA0GIRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetWA0GIRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetWA0GIRequest proto.InternalMessageInfo + +type GetWA0GIResponse struct { + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *GetWA0GIResponse) Reset() { *m = GetWA0GIResponse{} } +func (m *GetWA0GIResponse) String() string { return proto.CompactTextString(m) } +func (*GetWA0GIResponse) ProtoMessage() {} +func (*GetWA0GIResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_19911faa2ec12c75, []int{1} +} +func (m *GetWA0GIResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetWA0GIResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetWA0GIResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetWA0GIResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetWA0GIResponse.Merge(m, src) +} +func (m *GetWA0GIResponse) XXX_Size() int { + return m.Size() +} +func (m *GetWA0GIResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetWA0GIResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetWA0GIResponse proto.InternalMessageInfo + type MinterSupplyRequest struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` } func (m *MinterSupplyRequest) Reset() { *m = MinterSupplyRequest{} } func (m *MinterSupplyRequest) String() string { return proto.CompactTextString(m) } func (*MinterSupplyRequest) ProtoMessage() {} func (*MinterSupplyRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_19911faa2ec12c75, []int{0} + return fileDescriptor_19911faa2ec12c75, []int{2} } func (m *MinterSupplyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -70,15 +143,15 @@ func (m *MinterSupplyRequest) XXX_DiscardUnknown() { var xxx_messageInfo_MinterSupplyRequest proto.InternalMessageInfo type MinterSupplyResponse struct { - Cap string `protobuf:"bytes,1,opt,name=cap,proto3" json:"cap,omitempty"` - Supply string `protobuf:"bytes,2,opt,name=supply,proto3" json:"supply,omitempty"` + Cap []byte `protobuf:"bytes,1,opt,name=cap,proto3" json:"cap,omitempty"` + Supply []byte `protobuf:"bytes,2,opt,name=supply,proto3" json:"supply,omitempty"` } func (m *MinterSupplyResponse) Reset() { *m = MinterSupplyResponse{} } func (m *MinterSupplyResponse) String() string { return proto.CompactTextString(m) } func (*MinterSupplyResponse) ProtoMessage() {} func (*MinterSupplyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_19911faa2ec12c75, []int{1} + return fileDescriptor_19911faa2ec12c75, []int{3} } func (m *MinterSupplyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -108,6 +181,8 @@ func (m *MinterSupplyResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MinterSupplyResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*GetWA0GIRequest)(nil), "zgc.wrappeda0gibase.GetWA0GIRequest") + proto.RegisterType((*GetWA0GIResponse)(nil), "zgc.wrappeda0gibase.GetWA0GIResponse") proto.RegisterType((*MinterSupplyRequest)(nil), "zgc.wrappeda0gibase.MinterSupplyRequest") proto.RegisterType((*MinterSupplyResponse)(nil), "zgc.wrappeda0gibase.MinterSupplyResponse") } @@ -115,29 +190,33 @@ func init() { func init() { proto.RegisterFile("zgc/wrappeda0gibase/query.proto", fileDescriptor_19911faa2ec12c75) } var fileDescriptor_19911faa2ec12c75 = []byte{ - // 348 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x4a, 0x2b, 0x31, - 0x14, 0x86, 0x27, 0xbd, 0xdc, 0x5e, 0x6e, 0x70, 0x21, 0x69, 0x91, 0x76, 0x90, 0x54, 0x2a, 0x42, - 0x45, 0x66, 0x32, 0xa8, 0x0f, 0x20, 0xee, 0x5d, 0x58, 0x77, 0x6e, 0x24, 0x33, 0x8d, 0x69, 0xa0, - 0x93, 0xa4, 0x93, 0x0c, 0xda, 0x2e, 0x7d, 0x82, 0x82, 0x3b, 0x9f, 0xa8, 0xcb, 0x82, 0x1b, 0x97, - 0xda, 0xfa, 0x20, 0x32, 0x99, 0x29, 0x68, 0xe9, 0xc2, 0x5d, 0xfe, 0x73, 0xbe, 0xff, 0xe4, 0xf0, - 0x1f, 0xd8, 0x99, 0xf2, 0x84, 0x3c, 0x64, 0x54, 0x6b, 0x36, 0xa0, 0x11, 0x17, 0x31, 0x35, 0x8c, - 0x8c, 0x73, 0x96, 0x4d, 0x42, 0x9d, 0x29, 0xab, 0x50, 0x63, 0xca, 0x93, 0x70, 0x03, 0xf0, 0xdb, - 0x89, 0x32, 0xa9, 0x32, 0x77, 0x0e, 0x21, 0xa5, 0x28, 0x79, 0xbf, 0xc9, 0x15, 0x57, 0x65, 0xbd, - 0x78, 0x55, 0xd5, 0x7d, 0xae, 0x14, 0x1f, 0x31, 0x42, 0xb5, 0x20, 0x54, 0x4a, 0x65, 0xa9, 0x15, - 0x4a, 0xae, 0x3d, 0xed, 0xaa, 0xeb, 0x54, 0x9c, 0xdf, 0x13, 0x2a, 0xab, 0xef, 0xfd, 0xce, 0x66, - 0xcb, 0x8a, 0x94, 0x19, 0x4b, 0x53, 0x5d, 0x02, 0x5d, 0x02, 0x1b, 0x57, 0x42, 0x5a, 0x96, 0xdd, - 0xe4, 0x5a, 0x8f, 0x26, 0x7d, 0x36, 0xce, 0x99, 0xb1, 0xa8, 0x05, 0xff, 0xd1, 0xc1, 0x20, 0x63, - 0xc6, 0xb4, 0xc0, 0x01, 0xe8, 0xfd, 0xef, 0xaf, 0x65, 0xf7, 0x02, 0x36, 0x7f, 0x1a, 0x8c, 0x56, - 0xd2, 0x30, 0xb4, 0x0b, 0xff, 0x24, 0x54, 0x57, 0x74, 0xf1, 0x44, 0x7b, 0xb0, 0x6e, 0x1c, 0xd3, - 0xaa, 0xb9, 0x62, 0xa5, 0x4e, 0x5f, 0x00, 0xfc, 0x7b, 0x5d, 0x44, 0x84, 0x66, 0x00, 0xee, 0x7c, - 0x1f, 0x86, 0x7a, 0xe1, 0x96, 0xb8, 0xc2, 0x2d, 0x0b, 0xfa, 0xc7, 0xbf, 0x20, 0xcb, 0xcd, 0xba, - 0x27, 0x4f, 0xaf, 0x9f, 0xcf, 0xb5, 0x23, 0x74, 0x48, 0x22, 0xbe, 0xbe, 0x55, 0x50, 0x58, 0x02, - 0x77, 0xad, 0xd4, 0x79, 0x82, 0x72, 0xb9, 0xcb, 0xfe, 0xfc, 0x03, 0x7b, 0xf3, 0x25, 0x06, 0x8b, - 0x25, 0x06, 0xef, 0x4b, 0x0c, 0x66, 0x2b, 0xec, 0x2d, 0x56, 0xd8, 0x7b, 0x5b, 0x61, 0xef, 0xf6, - 0x9c, 0x0b, 0x3b, 0xcc, 0xe3, 0x30, 0x51, 0x29, 0x89, 0xf8, 0x88, 0xc6, 0x86, 0x44, 0x3c, 0x48, - 0x86, 0x54, 0x48, 0xf2, 0xb8, 0x65, 0xb6, 0x9d, 0x68, 0x66, 0xe2, 0xba, 0x8b, 0xfa, 0xec, 0x2b, - 0x00, 0x00, 0xff, 0xff, 0x26, 0x34, 0x94, 0xac, 0x2d, 0x02, 0x00, 0x00, + // 410 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0x93, 0x22, 0x0a, 0xb2, 0x2a, 0x51, 0xdc, 0x0a, 0xb5, 0x11, 0x4a, 0x21, 0x50, 0x51, + 0x04, 0x89, 0x23, 0xe0, 0x01, 0x80, 0x4b, 0xc5, 0x81, 0x03, 0xe5, 0x80, 0xc4, 0x05, 0x39, 0xa9, + 0x71, 0x23, 0x35, 0xb1, 0x1b, 0x3b, 0xea, 0xda, 0xd3, 0xb4, 0x27, 0xa8, 0xb4, 0xf3, 0xde, 0xa7, + 0xc7, 0x4a, 0xbb, 0xec, 0xb8, 0xb5, 0x7b, 0x90, 0x29, 0x8e, 0xa3, 0x6d, 0x55, 0xb4, 0xed, 0xe6, + 0xff, 0xe7, 0xdf, 0xe7, 0xef, 0xef, 0xbf, 0x0d, 0x7a, 0x4b, 0x1a, 0xa2, 0x79, 0x8a, 0x39, 0x27, + 0x63, 0xec, 0xd3, 0x28, 0xc0, 0x82, 0xa0, 0x59, 0x46, 0xd2, 0x85, 0xc7, 0x53, 0x26, 0x19, 0x6c, + 0x2d, 0x69, 0xe8, 0xed, 0x01, 0x56, 0x37, 0x64, 0x22, 0x66, 0xe2, 0x9f, 0x42, 0x50, 0x21, 0x0a, + 0xde, 0x6a, 0x53, 0x46, 0x59, 0x51, 0xcf, 0x57, 0xba, 0xfa, 0x92, 0x32, 0x46, 0xa7, 0x04, 0x61, + 0x1e, 0x21, 0x9c, 0x24, 0x4c, 0x62, 0x19, 0xb1, 0xa4, 0xec, 0xe9, 0xea, 0x5d, 0xa5, 0x82, 0xec, + 0x3f, 0xc2, 0x89, 0x1e, 0x6f, 0xf5, 0xf6, 0xb7, 0x64, 0x14, 0x13, 0x21, 0x71, 0xcc, 0x0b, 0xc0, + 0x79, 0x0e, 0x9e, 0x0d, 0x89, 0xfc, 0xf3, 0xcd, 0x1f, 0xfe, 0x18, 0x91, 0x59, 0x46, 0x84, 0x74, + 0x3e, 0x82, 0xe6, 0x75, 0x49, 0x70, 0x96, 0x08, 0x02, 0x3b, 0xe0, 0x09, 0x1e, 0x8f, 0x53, 0x22, + 0x44, 0xc7, 0x7c, 0x65, 0x0e, 0x1a, 0xa3, 0x52, 0x3a, 0x08, 0xb4, 0x7e, 0x46, 0x89, 0x24, 0xe9, + 0xef, 0x8c, 0xf3, 0xe9, 0x42, 0x1f, 0x72, 0x47, 0xc3, 0x57, 0xd0, 0xbe, 0xdd, 0xa0, 0x47, 0x34, + 0xc1, 0xa3, 0x10, 0x73, 0x4d, 0xe7, 0x4b, 0xf8, 0x02, 0xd4, 0x85, 0x62, 0x3a, 0x35, 0x55, 0xd4, + 0xea, 0xd3, 0x49, 0x0d, 0x3c, 0xfe, 0x95, 0x67, 0x0c, 0x0f, 0x4d, 0xf0, 0xb4, 0xf4, 0x0a, 0xdf, + 0x7a, 0x15, 0x59, 0x7b, 0x7b, 0xb7, 0xb3, 0xfa, 0xf7, 0x50, 0x85, 0x1b, 0xe7, 0xdd, 0xd1, 0xe9, + 0xe5, 0x71, 0xed, 0x35, 0xec, 0x21, 0x9f, 0x96, 0x0f, 0xec, 0xe6, 0xb8, 0xab, 0x9e, 0x98, 0x12, + 0xe9, 0xce, 0x73, 0x09, 0x57, 0x26, 0x68, 0xdc, 0xbc, 0x0f, 0x1c, 0x54, 0x0e, 0xa8, 0xc8, 0xc8, + 0x7a, 0xff, 0x00, 0x52, 0xdb, 0xf9, 0xa0, 0xec, 0xf4, 0xe1, 0x9b, 0x6a, 0x3b, 0xb1, 0xea, 0x71, + 0x8b, 0x7c, 0xbe, 0x8f, 0xd6, 0x17, 0xb6, 0xb1, 0xde, 0xda, 0xe6, 0x66, 0x6b, 0x9b, 0xe7, 0x5b, + 0xdb, 0x5c, 0xed, 0x6c, 0x63, 0xb3, 0xb3, 0x8d, 0xb3, 0x9d, 0x6d, 0xfc, 0xfd, 0x42, 0x23, 0x39, + 0xc9, 0x02, 0x2f, 0x64, 0x31, 0xf2, 0xe9, 0x14, 0x07, 0x02, 0xf9, 0xd4, 0x0d, 0x27, 0x38, 0x4a, + 0xd0, 0x41, 0xc5, 0xd9, 0x72, 0xc1, 0x89, 0x08, 0xea, 0xea, 0xbb, 0x7c, 0xbe, 0x0a, 0x00, 0x00, + 0xff, 0xff, 0x14, 0xfb, 0x91, 0x88, 0xf1, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -152,6 +231,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { + GetWA0GI(ctx context.Context, in *GetWA0GIRequest, opts ...grpc.CallOption) (*GetWA0GIResponse, error) MinterSupply(ctx context.Context, in *MinterSupplyRequest, opts ...grpc.CallOption) (*MinterSupplyResponse, error) } @@ -163,6 +243,15 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } +func (c *queryClient) GetWA0GI(ctx context.Context, in *GetWA0GIRequest, opts ...grpc.CallOption) (*GetWA0GIResponse, error) { + out := new(GetWA0GIResponse) + err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Query/GetWA0GI", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) MinterSupply(ctx context.Context, in *MinterSupplyRequest, opts ...grpc.CallOption) (*MinterSupplyResponse, error) { out := new(MinterSupplyResponse) err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Query/MinterSupply", in, out, opts...) @@ -174,6 +263,7 @@ func (c *queryClient) MinterSupply(ctx context.Context, in *MinterSupplyRequest, // QueryServer is the server API for Query service. type QueryServer interface { + GetWA0GI(context.Context, *GetWA0GIRequest) (*GetWA0GIResponse, error) MinterSupply(context.Context, *MinterSupplyRequest) (*MinterSupplyResponse, error) } @@ -181,6 +271,9 @@ type QueryServer interface { type UnimplementedQueryServer struct { } +func (*UnimplementedQueryServer) GetWA0GI(ctx context.Context, req *GetWA0GIRequest) (*GetWA0GIResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetWA0GI not implemented") +} func (*UnimplementedQueryServer) MinterSupply(ctx context.Context, req *MinterSupplyRequest) (*MinterSupplyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method MinterSupply not implemented") } @@ -189,6 +282,24 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } +func _Query_GetWA0GI_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetWA0GIRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetWA0GI(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zgc.wrappeda0gibase.Query/GetWA0GI", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetWA0GI(ctx, req.(*GetWA0GIRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_MinterSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MinterSupplyRequest) if err := dec(in); err != nil { @@ -211,6 +322,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "zgc.wrappeda0gibase.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "GetWA0GI", + Handler: _Query_GetWA0GI_Handler, + }, { MethodName: "MinterSupply", Handler: _Query_MinterSupply_Handler, @@ -220,6 +335,59 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "zgc/wrappeda0gibase/query.proto", } +func (m *GetWA0GIRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetWA0GIRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetWA0GIRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *GetWA0GIResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetWA0GIResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetWA0GIResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MinterSupplyRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -298,6 +466,28 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *GetWA0GIRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GetWA0GIResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *MinterSupplyRequest) Size() (n int) { if m == nil { return 0 @@ -334,6 +524,140 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *GetWA0GIRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetWA0GIRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetWA0GIRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetWA0GIResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetWA0GIResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetWA0GIResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *MinterSupplyRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -367,7 +691,7 @@ func (m *MinterSupplyRequest) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -377,23 +701,25 @@ func (m *MinterSupplyRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -449,7 +775,7 @@ func (m *MinterSupplyResponse) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Cap", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -459,29 +785,31 @@ func (m *MinterSupplyResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Cap = string(dAtA[iNdEx:postIndex]) + m.Cap = append(m.Cap[:0], dAtA[iNdEx:postIndex]...) + if m.Cap == nil { + m.Cap = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Supply", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -491,23 +819,25 @@ func (m *MinterSupplyResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Supply = string(dAtA[iNdEx:postIndex]) + m.Supply = append(m.Supply[:0], dAtA[iNdEx:postIndex]...) + if m.Supply == nil { + m.Supply = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/wrapped-a0gi-base/types/query.pb.gw.go b/x/wrapped-a0gi-base/types/query.pb.gw.go index a4bbda75..17f15012 100644 --- a/x/wrapped-a0gi-base/types/query.pb.gw.go +++ b/x/wrapped-a0gi-base/types/query.pb.gw.go @@ -33,6 +33,24 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join +func request_Query_GetWA0GI_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetWA0GIRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetWA0GI(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetWA0GI_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetWA0GIRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetWA0GI(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_MinterSupply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -75,6 +93,29 @@ func local_request_Query_MinterSupply_0(ctx context.Context, marshaler runtime.M // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + mux.Handle("GET", pattern_Query_GetWA0GI_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetWA0GI_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetWA0GI_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_MinterSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -139,6 +180,26 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + mux.Handle("GET", pattern_Query_GetWA0GI_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetWA0GI_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetWA0GI_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_MinterSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -163,9 +224,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( + pattern_Query_GetWA0GI_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"0g", "wrapped-a0gi-base", "get-wa0gi"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_MinterSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"0g", "wrapped-a0gi-base", "minter-supply"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( + forward_Query_GetWA0GI_0 = runtime.ForwardResponseMessage + forward_Query_MinterSupply_0 = runtime.ForwardResponseMessage ) diff --git a/x/wrapped-a0gi-base/types/tx.pb.go b/x/wrapped-a0gi-base/types/tx.pb.go index 78de5739..1760ab6d 100644 --- a/x/wrapped-a0gi-base/types/tx.pb.go +++ b/x/wrapped-a0gi-base/types/tx.pb.go @@ -32,7 +32,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgSetWA0GI struct { Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Address []byte `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` } func (m *MsgSetWA0GI) Reset() { *m = MsgSetWA0GI{} } @@ -106,8 +106,8 @@ var xxx_messageInfo_MsgSetWA0GIResponse proto.InternalMessageInfo type MsgSetMintCap struct { Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - Minter string `protobuf:"bytes,2,opt,name=minter,proto3" json:"minter,omitempty"` - Cap string `protobuf:"bytes,3,opt,name=cap,proto3" json:"cap,omitempty"` + Minter []byte `protobuf:"bytes,2,opt,name=minter,proto3" json:"minter,omitempty"` + Cap []byte `protobuf:"bytes,3,opt,name=cap,proto3" json:"cap,omitempty"` } func (m *MsgSetMintCap) Reset() { *m = MsgSetMintCap{} } @@ -180,9 +180,9 @@ func (m *MsgSetMintCapResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetMintCapResponse proto.InternalMessageInfo type MsgMint struct { - Minter string `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` - To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` - Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + Minter []byte `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` + To []byte `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` + Amount []byte `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` } func (m *MsgMint) Reset() { *m = MsgMint{} } @@ -255,8 +255,8 @@ func (m *MsgMintResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgMintResponse proto.InternalMessageInfo type MsgBurn struct { - Minter string `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` - Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` + Minter []byte `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` + Amount []byte `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` } func (m *MsgBurn) Reset() { *m = MsgBurn{} } @@ -342,35 +342,35 @@ func init() { func init() { proto.RegisterFile("zgc/wrappeda0gibase/tx.proto", fileDescriptor_f80bf93a1fc022d3) } var fileDescriptor_f80bf93a1fc022d3 = []byte{ - // 433 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6b, 0xd4, 0x40, - 0x14, 0xc7, 0x93, 0xac, 0xb4, 0xf6, 0xf9, 0x3b, 0xb5, 0x9a, 0x86, 0x25, 0x94, 0xe0, 0xa1, 0x08, - 0x9b, 0x09, 0xea, 0xc5, 0xa3, 0x15, 0x91, 0x0a, 0xb9, 0xac, 0x60, 0xc1, 0x83, 0x32, 0xc9, 0x8e, - 0xb3, 0x81, 0x26, 0x13, 0x32, 0x13, 0xec, 0xf6, 0xaf, 0xf0, 0xcf, 0xea, 0x71, 0x2f, 0x82, 0x47, - 0xdd, 0xfd, 0x47, 0x64, 0x26, 0x93, 0x6c, 0xb6, 0x6c, 0x76, 0x6f, 0xf3, 0xbe, 0xdf, 0xf7, 0x3e, - 0x0f, 0xbe, 0xc3, 0x83, 0xe1, 0x35, 0x4d, 0xd0, 0xcf, 0x12, 0x17, 0x05, 0x99, 0xe0, 0x90, 0xa6, - 0x31, 0xe6, 0x04, 0x89, 0xab, 0xa0, 0x28, 0x99, 0x60, 0xf6, 0xe1, 0x35, 0x4d, 0x82, 0x5b, 0xae, - 0x7b, 0x9c, 0x30, 0x9e, 0x31, 0xfe, 0x5d, 0xb5, 0xa0, 0xba, 0xa8, 0xfb, 0xdd, 0xa7, 0x94, 0x51, - 0x56, 0xeb, 0xf2, 0xa5, 0xd5, 0x63, 0xca, 0x18, 0xbd, 0x24, 0x48, 0x55, 0x71, 0xf5, 0x03, 0xe1, - 0x7c, 0x56, 0x5b, 0xfe, 0x07, 0xb8, 0x17, 0x71, 0xfa, 0x99, 0x88, 0x8b, 0x77, 0xe1, 0xc7, 0x73, - 0x7b, 0x08, 0x07, 0xb8, 0x12, 0x53, 0x56, 0xa6, 0x62, 0xe6, 0x98, 0x27, 0xe6, 0xe9, 0xc1, 0x78, - 0x25, 0xd8, 0x0e, 0xec, 0xe3, 0xc9, 0xa4, 0x24, 0x9c, 0x3b, 0x96, 0xf2, 0x9a, 0xd2, 0x3f, 0x82, - 0xc3, 0x0e, 0x66, 0x4c, 0x78, 0xc1, 0x72, 0x4e, 0xfc, 0x0b, 0x78, 0x50, 0xcb, 0x51, 0x9a, 0x8b, - 0xf7, 0xb8, 0xd8, 0xc1, 0x7f, 0x06, 0x7b, 0x59, 0x9a, 0x0b, 0x52, 0x6a, 0xbc, 0xae, 0xec, 0xc7, - 0x30, 0x48, 0x70, 0xe1, 0x0c, 0x94, 0x28, 0x9f, 0xfe, 0x73, 0x38, 0x5a, 0x03, 0xb7, 0x1b, 0xcf, - 0x61, 0x3f, 0xe2, 0x54, 0xaa, 0x1d, 0x9a, 0xb9, 0x46, 0x7b, 0x08, 0x96, 0x60, 0x7a, 0x83, 0x25, - 0x98, 0xec, 0xc3, 0x19, 0xab, 0x72, 0xa1, 0x17, 0xe8, 0xca, 0x7f, 0x02, 0x8f, 0x34, 0xaa, 0xa5, - 0xbf, 0x55, 0xf4, 0xb3, 0xaa, 0xcc, 0x7b, 0xe9, 0x2b, 0x9a, 0xb5, 0x81, 0x26, 0x47, 0x1b, 0xda, - 0xab, 0xdf, 0x16, 0x0c, 0x22, 0x4e, 0xed, 0x2f, 0x70, 0xb7, 0xfd, 0x80, 0x93, 0x60, 0xc3, 0x8f, - 0x07, 0x9d, 0x6c, 0xdd, 0xd3, 0x5d, 0x1d, 0x0d, 0xdf, 0xfe, 0x06, 0xf7, 0x75, 0x42, 0xa4, 0x94, - 0xe1, 0xfb, 0x5b, 0x26, 0x75, 0x8e, 0xee, 0xcb, 0xdd, 0x3d, 0x2d, 0xff, 0x13, 0xdc, 0x51, 0x41, - 0x0f, 0xfb, 0x66, 0xa4, 0xeb, 0xbe, 0xd8, 0xe6, 0x76, 0x59, 0x2a, 0xd6, 0x5e, 0x96, 0x74, 0xfb, - 0x59, 0xdd, 0x5c, 0xcf, 0xc6, 0x37, 0xff, 0x3c, 0xe3, 0x66, 0xe1, 0x99, 0xf3, 0x85, 0x67, 0xfe, - 0x5d, 0x78, 0xe6, 0xaf, 0xa5, 0x67, 0xcc, 0x97, 0x9e, 0xf1, 0x67, 0xe9, 0x19, 0x5f, 0xdf, 0xd0, - 0x54, 0x4c, 0xab, 0x38, 0x48, 0x58, 0x86, 0x42, 0x7a, 0x89, 0x63, 0x8e, 0x42, 0x3a, 0x4a, 0xa6, - 0x38, 0xcd, 0xd1, 0x55, 0x73, 0x89, 0x23, 0x09, 0x1f, 0xd5, 0xb7, 0x38, 0x2b, 0x08, 0x8f, 0xf7, - 0xd4, 0xb9, 0xbc, 0xfe, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xeb, 0xd8, 0x1c, 0xf0, 0xaf, 0x03, 0x00, - 0x00, + // 436 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0x93, 0x54, 0x76, 0xdd, 0xe7, 0xfa, 0x2b, 0xeb, 0x6a, 0x36, 0x94, 0x50, 0x82, 0x87, + 0x22, 0x34, 0x13, 0xd4, 0x8b, 0x47, 0x57, 0x44, 0x56, 0xc8, 0x25, 0x82, 0x0b, 0x1e, 0x94, 0x49, + 0x3a, 0x4e, 0x03, 0x9b, 0x4c, 0xc8, 0x4c, 0x70, 0xbb, 0x7f, 0x85, 0x7f, 0xd6, 0x1e, 0x7b, 0x11, + 0x3c, 0x6a, 0xfb, 0x8f, 0xc8, 0x24, 0x93, 0x34, 0x95, 0xa6, 0xbd, 0xcd, 0xfb, 0xbe, 0xef, 0xfb, + 0x3c, 0xf8, 0x0e, 0x0f, 0x86, 0x37, 0x34, 0x46, 0x3f, 0x0a, 0x9c, 0xe7, 0x64, 0x8a, 0x7d, 0x9a, + 0x44, 0x98, 0x13, 0x24, 0xae, 0xbd, 0xbc, 0x60, 0x82, 0x99, 0x27, 0x37, 0x34, 0xf6, 0xfe, 0xeb, + 0xda, 0x67, 0x31, 0xe3, 0x29, 0xe3, 0xdf, 0x2a, 0x0b, 0xaa, 0x8b, 0xda, 0x6f, 0x3f, 0xa1, 0x8c, + 0xb2, 0x5a, 0x97, 0x2f, 0xa5, 0x9e, 0x51, 0xc6, 0xe8, 0x15, 0x41, 0x55, 0x15, 0x95, 0xdf, 0x11, + 0xce, 0xe6, 0x75, 0xcb, 0x7d, 0x0f, 0xf7, 0x02, 0x4e, 0x3f, 0x11, 0x71, 0xf9, 0xd6, 0xff, 0x70, + 0x61, 0x0e, 0xe1, 0x08, 0x97, 0x62, 0xc6, 0x8a, 0x44, 0xcc, 0x2d, 0x7d, 0xa4, 0x8f, 0x8f, 0xc2, + 0xb5, 0x60, 0x5a, 0x70, 0x88, 0xa7, 0xd3, 0x82, 0x70, 0x6e, 0x19, 0x23, 0x7d, 0x7c, 0x1c, 0x36, + 0xa5, 0x7b, 0x0a, 0x27, 0x1d, 0x4c, 0x48, 0x78, 0xce, 0x32, 0x4e, 0xdc, 0x4b, 0xb8, 0x5f, 0xcb, + 0x41, 0x92, 0x89, 0x77, 0x38, 0xdf, 0xc3, 0x7f, 0x0a, 0x07, 0x69, 0x92, 0x09, 0x52, 0x28, 0xbc, + 0xaa, 0xcc, 0x47, 0x30, 0x88, 0x71, 0x6e, 0x0d, 0x2a, 0x51, 0x3e, 0xdd, 0x67, 0x70, 0xba, 0x01, + 0x6e, 0x37, 0x5e, 0xc0, 0x61, 0xc0, 0xa9, 0x54, 0x3b, 0x34, 0x7d, 0x83, 0xf6, 0x00, 0x0c, 0xc1, + 0xd4, 0x06, 0x43, 0x30, 0xe9, 0xc3, 0x29, 0x2b, 0x33, 0xa1, 0x16, 0xa8, 0xca, 0x7d, 0x0c, 0x0f, + 0x15, 0xaa, 0xa5, 0xbf, 0xa9, 0xe8, 0xe7, 0x65, 0x91, 0xf5, 0xd2, 0xd7, 0x34, 0x63, 0x0b, 0x4d, + 0x8e, 0x36, 0xb4, 0x97, 0xbf, 0x0c, 0x18, 0x04, 0x9c, 0x9a, 0x9f, 0xe1, 0x6e, 0xfb, 0x01, 0x23, + 0x6f, 0xcb, 0x8f, 0x7b, 0x9d, 0x6c, 0xed, 0xf1, 0x3e, 0x47, 0xc3, 0x37, 0xbf, 0xc2, 0xb1, 0x4a, + 0x88, 0x14, 0x32, 0x7c, 0x77, 0xc7, 0xa4, 0xca, 0xd1, 0x7e, 0xb1, 0xdf, 0xd3, 0xf2, 0x3f, 0xc2, + 0x9d, 0x2a, 0xe8, 0x61, 0xdf, 0x8c, 0xec, 0xda, 0xcf, 0x77, 0x75, 0xbb, 0xac, 0x2a, 0xd6, 0x5e, + 0x96, 0xec, 0xf6, 0xb3, 0xba, 0xb9, 0x9e, 0x87, 0xb7, 0x7f, 0x1d, 0xed, 0x76, 0xe9, 0xe8, 0x8b, + 0xa5, 0xa3, 0xff, 0x59, 0x3a, 0xfa, 0xcf, 0x95, 0xa3, 0x2d, 0x56, 0x8e, 0xf6, 0x7b, 0xe5, 0x68, + 0x5f, 0x5e, 0xd3, 0x44, 0xcc, 0xca, 0xc8, 0x8b, 0x59, 0x8a, 0x7c, 0x7a, 0x85, 0x23, 0x8e, 0x7c, + 0x3a, 0x89, 0x67, 0x38, 0xc9, 0xd0, 0x75, 0x73, 0x89, 0x13, 0x09, 0x9f, 0xd4, 0xb7, 0x38, 0xcf, + 0x09, 0x8f, 0x0e, 0xaa, 0x73, 0x79, 0xf5, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x19, 0x0a, 0x77, + 0xaf, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1009,7 +1009,7 @@ func (m *MsgSetWA0GI) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1019,23 +1019,25 @@ func (m *MsgSetWA0GI) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -1173,7 +1175,7 @@ func (m *MsgSetMintCap) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1183,29 +1185,31 @@ func (m *MsgSetMintCap) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Minter = string(dAtA[iNdEx:postIndex]) + m.Minter = append(m.Minter[:0], dAtA[iNdEx:postIndex]...) + if m.Minter == nil { + m.Minter = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Cap", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1215,23 +1219,25 @@ func (m *MsgSetMintCap) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Cap = string(dAtA[iNdEx:postIndex]) + m.Cap = append(m.Cap[:0], dAtA[iNdEx:postIndex]...) + if m.Cap == nil { + m.Cap = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -1337,7 +1343,7 @@ func (m *MsgMint) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1347,29 +1353,31 @@ func (m *MsgMint) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Minter = string(dAtA[iNdEx:postIndex]) + m.Minter = append(m.Minter[:0], dAtA[iNdEx:postIndex]...) + if m.Minter == nil { + m.Minter = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1379,29 +1387,31 @@ func (m *MsgMint) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.To = string(dAtA[iNdEx:postIndex]) + m.To = append(m.To[:0], dAtA[iNdEx:postIndex]...) + if m.To == nil { + m.To = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1411,23 +1421,25 @@ func (m *MsgMint) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Amount = string(dAtA[iNdEx:postIndex]) + m.Amount = append(m.Amount[:0], dAtA[iNdEx:postIndex]...) + if m.Amount == nil { + m.Amount = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -1533,7 +1545,7 @@ func (m *MsgBurn) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Minter", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1543,29 +1555,31 @@ func (m *MsgBurn) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Minter = string(dAtA[iNdEx:postIndex]) + m.Minter = append(m.Minter[:0], dAtA[iNdEx:postIndex]...) + if m.Minter == nil { + m.Minter = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1575,23 +1589,25 @@ func (m *MsgBurn) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Amount = string(dAtA[iNdEx:postIndex]) + m.Amount = append(m.Amount[:0], dAtA[iNdEx:postIndex]...) + if m.Amount == nil { + m.Amount = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex From 88304562ccf6a0eeb036a91f7d7f99bc56de7a7f Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Wed, 8 Jan 2025 13:45:12 +0800 Subject: [PATCH 05/10] refactor: mint --- .../interfaces/contracts/IWrappedA0GIBase.sol | 9 +- .../wrapped-a0gi-base/IWrappedA0GIBase.json | 5 - precompiles/wrapped-a0gi-base/contract.go | 26 ++--- proto/zgc/wrappeda0gibase/tx.proto | 3 +- x/wrapped-a0gi-base/keeper/msg_server.go | 12 +- x/wrapped-a0gi-base/types/tx.pb.go | 105 +++++------------- 6 files changed, 49 insertions(+), 111 deletions(-) diff --git a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol index 7f22a024..ba975348 100644 --- a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol +++ b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol @@ -37,18 +37,17 @@ interface IWrappedA0GIBase { function minterSupply(address minter) external view returns (Supply memory); /** - * @dev mint a0gi to given address directly, add corresponding amount to minter's mint supply. + * @dev mint a0gi to this precompile, add corresponding amount to minter's mint supply. * If sender's final mint supply exceeds its mint cap, the transaction will revert. - * Can only be called by - * + * Can only be called by WA0GI. * @param minter minter address - * @param to recipient address * @param amount amount to mint */ - function mint(address minter, address to, uint256 amount) external; + function mint(address minter, uint256 amount) external; /** * @dev burn given amount of a0gi on behalf of minter, reduce corresponding amount from sender's mint supply. + * Can only be called by WA0GI. * @param minter minter address * @param amount amount to burn */ diff --git a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json index 89dae14b..6f4d2f48 100644 --- a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json +++ b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json @@ -37,11 +37,6 @@ "name": "minter", "type": "address" }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, { "internalType": "uint256", "name": "amount", diff --git a/precompiles/wrapped-a0gi-base/contract.go b/precompiles/wrapped-a0gi-base/contract.go index 09cc37e0..99174a4f 100644 --- a/precompiles/wrapped-a0gi-base/contract.go +++ b/precompiles/wrapped-a0gi-base/contract.go @@ -30,7 +30,7 @@ var ( // Wrappeda0gibaseMetaData contains all meta data concerning the Wrappeda0gibase contract. var Wrappeda0gibaseMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWA0GI\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWA0GI\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // Wrappeda0gibaseABI is the input ABI used to generate the binding from. @@ -252,23 +252,23 @@ func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) GetWA0GI() (*types.Tra return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.TransactOpts) } -// Mint is a paid mutator transaction binding the contract method 0xc6c3bbe6. +// Mint is a paid mutator transaction binding the contract method 0x40c10f19. // -// Solidity: function mint(address minter, address to, uint256 amount) returns() -func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) Mint(opts *bind.TransactOpts, minter common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { - return _Wrappeda0gibase.contract.Transact(opts, "mint", minter, to, amount) +// Solidity: function mint(address minter, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) Mint(opts *bind.TransactOpts, minter common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.contract.Transact(opts, "mint", minter, amount) } -// Mint is a paid mutator transaction binding the contract method 0xc6c3bbe6. +// Mint is a paid mutator transaction binding the contract method 0x40c10f19. // -// Solidity: function mint(address minter, address to, uint256 amount) returns() -func (_Wrappeda0gibase *Wrappeda0gibaseSession) Mint(minter common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { - return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, to, amount) +// Solidity: function mint(address minter, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseSession) Mint(minter common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, amount) } -// Mint is a paid mutator transaction binding the contract method 0xc6c3bbe6. +// Mint is a paid mutator transaction binding the contract method 0x40c10f19. // -// Solidity: function mint(address minter, address to, uint256 amount) returns() -func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Mint(minter common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { - return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, to, amount) +// Solidity: function mint(address minter, uint256 amount) returns() +func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Mint(minter common.Address, amount *big.Int) (*types.Transaction, error) { + return _Wrappeda0gibase.Contract.Mint(&_Wrappeda0gibase.TransactOpts, minter, amount) } diff --git a/proto/zgc/wrappeda0gibase/tx.proto b/proto/zgc/wrappeda0gibase/tx.proto index 61fed0f7..4f47c32b 100644 --- a/proto/zgc/wrappeda0gibase/tx.proto +++ b/proto/zgc/wrappeda0gibase/tx.proto @@ -33,8 +33,7 @@ message MsgSetMintCapResponse {} message MsgMint { bytes minter = 1; - bytes to = 2; - bytes amount = 3; // big endian + bytes amount = 2; // big endian } message MsgMintResponse {} diff --git a/x/wrapped-a0gi-base/keeper/msg_server.go b/x/wrapped-a0gi-base/keeper/msg_server.go index dc3759cc..0d47034c 100644 --- a/x/wrapped-a0gi-base/keeper/msg_server.go +++ b/x/wrapped-a0gi-base/keeper/msg_server.go @@ -35,12 +35,8 @@ func (k Keeper) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnR if err = k.setMinterSupply(ctx, minter, supply); err != nil { return nil, err } - // transfer & burn + // burn c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount)) - burner := sdk.AccAddress(minter.Bytes()) - if err = k.pbkeeper.SendCoinsFromAccountToModule(ctx, burner, types.ModuleName, sdk.NewCoins(c)); err != nil { - return nil, err - } if err = k.pbkeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil { return nil, err } @@ -68,15 +64,11 @@ func (k Keeper) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintR if err = k.setMinterSupply(ctx, minter, supply); err != nil { return nil, err } - // mint & transfer + // mint c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount)) if err = k.pbkeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil { return nil, err } - recipient := sdk.AccAddress(common.BytesToAddress(msg.To).Bytes()) - if err = k.pbkeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, recipient, sdk.NewCoins(c)); err != nil { - return nil, err - } return &types.MsgMintResponse{}, nil } diff --git a/x/wrapped-a0gi-base/types/tx.pb.go b/x/wrapped-a0gi-base/types/tx.pb.go index 1760ab6d..122627dc 100644 --- a/x/wrapped-a0gi-base/types/tx.pb.go +++ b/x/wrapped-a0gi-base/types/tx.pb.go @@ -181,8 +181,7 @@ var xxx_messageInfo_MsgSetMintCapResponse proto.InternalMessageInfo type MsgMint struct { Minter []byte `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` - To []byte `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` - Amount []byte `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + Amount []byte `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` } func (m *MsgMint) Reset() { *m = MsgMint{} } @@ -342,35 +341,34 @@ func init() { func init() { proto.RegisterFile("zgc/wrappeda0gibase/tx.proto", fileDescriptor_f80bf93a1fc022d3) } var fileDescriptor_f80bf93a1fc022d3 = []byte{ - // 436 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x93, 0x54, 0x76, 0xdd, 0xe7, 0xfa, 0x2b, 0xeb, 0x6a, 0x36, 0x94, 0x50, 0x82, 0x87, - 0x22, 0x34, 0x13, 0xd4, 0x8b, 0x47, 0x57, 0x44, 0x56, 0xc8, 0x25, 0x82, 0x0b, 0x1e, 0x94, 0x49, - 0x3a, 0x4e, 0x03, 0x9b, 0x4c, 0xc8, 0x4c, 0x70, 0xbb, 0x7f, 0x85, 0x7f, 0xd6, 0x1e, 0x7b, 0x11, - 0x3c, 0x6a, 0xfb, 0x8f, 0xc8, 0x24, 0x93, 0x34, 0x95, 0xa6, 0xbd, 0xcd, 0xfb, 0xbe, 0xef, 0xfb, - 0x3c, 0xf8, 0x0e, 0x0f, 0x86, 0x37, 0x34, 0x46, 0x3f, 0x0a, 0x9c, 0xe7, 0x64, 0x8a, 0x7d, 0x9a, - 0x44, 0x98, 0x13, 0x24, 0xae, 0xbd, 0xbc, 0x60, 0x82, 0x99, 0x27, 0x37, 0x34, 0xf6, 0xfe, 0xeb, - 0xda, 0x67, 0x31, 0xe3, 0x29, 0xe3, 0xdf, 0x2a, 0x0b, 0xaa, 0x8b, 0xda, 0x6f, 0x3f, 0xa1, 0x8c, - 0xb2, 0x5a, 0x97, 0x2f, 0xa5, 0x9e, 0x51, 0xc6, 0xe8, 0x15, 0x41, 0x55, 0x15, 0x95, 0xdf, 0x11, - 0xce, 0xe6, 0x75, 0xcb, 0x7d, 0x0f, 0xf7, 0x02, 0x4e, 0x3f, 0x11, 0x71, 0xf9, 0xd6, 0xff, 0x70, - 0x61, 0x0e, 0xe1, 0x08, 0x97, 0x62, 0xc6, 0x8a, 0x44, 0xcc, 0x2d, 0x7d, 0xa4, 0x8f, 0x8f, 0xc2, - 0xb5, 0x60, 0x5a, 0x70, 0x88, 0xa7, 0xd3, 0x82, 0x70, 0x6e, 0x19, 0x23, 0x7d, 0x7c, 0x1c, 0x36, - 0xa5, 0x7b, 0x0a, 0x27, 0x1d, 0x4c, 0x48, 0x78, 0xce, 0x32, 0x4e, 0xdc, 0x4b, 0xb8, 0x5f, 0xcb, - 0x41, 0x92, 0x89, 0x77, 0x38, 0xdf, 0xc3, 0x7f, 0x0a, 0x07, 0x69, 0x92, 0x09, 0x52, 0x28, 0xbc, - 0xaa, 0xcc, 0x47, 0x30, 0x88, 0x71, 0x6e, 0x0d, 0x2a, 0x51, 0x3e, 0xdd, 0x67, 0x70, 0xba, 0x01, - 0x6e, 0x37, 0x5e, 0xc0, 0x61, 0xc0, 0xa9, 0x54, 0x3b, 0x34, 0x7d, 0x83, 0xf6, 0x00, 0x0c, 0xc1, - 0xd4, 0x06, 0x43, 0x30, 0xe9, 0xc3, 0x29, 0x2b, 0x33, 0xa1, 0x16, 0xa8, 0xca, 0x7d, 0x0c, 0x0f, - 0x15, 0xaa, 0xa5, 0xbf, 0xa9, 0xe8, 0xe7, 0x65, 0x91, 0xf5, 0xd2, 0xd7, 0x34, 0x63, 0x0b, 0x4d, - 0x8e, 0x36, 0xb4, 0x97, 0xbf, 0x0c, 0x18, 0x04, 0x9c, 0x9a, 0x9f, 0xe1, 0x6e, 0xfb, 0x01, 0x23, - 0x6f, 0xcb, 0x8f, 0x7b, 0x9d, 0x6c, 0xed, 0xf1, 0x3e, 0x47, 0xc3, 0x37, 0xbf, 0xc2, 0xb1, 0x4a, - 0x88, 0x14, 0x32, 0x7c, 0x77, 0xc7, 0xa4, 0xca, 0xd1, 0x7e, 0xb1, 0xdf, 0xd3, 0xf2, 0x3f, 0xc2, - 0x9d, 0x2a, 0xe8, 0x61, 0xdf, 0x8c, 0xec, 0xda, 0xcf, 0x77, 0x75, 0xbb, 0xac, 0x2a, 0xd6, 0x5e, - 0x96, 0xec, 0xf6, 0xb3, 0xba, 0xb9, 0x9e, 0x87, 0xb7, 0x7f, 0x1d, 0xed, 0x76, 0xe9, 0xe8, 0x8b, - 0xa5, 0xa3, 0xff, 0x59, 0x3a, 0xfa, 0xcf, 0x95, 0xa3, 0x2d, 0x56, 0x8e, 0xf6, 0x7b, 0xe5, 0x68, - 0x5f, 0x5e, 0xd3, 0x44, 0xcc, 0xca, 0xc8, 0x8b, 0x59, 0x8a, 0x7c, 0x7a, 0x85, 0x23, 0x8e, 0x7c, - 0x3a, 0x89, 0x67, 0x38, 0xc9, 0xd0, 0x75, 0x73, 0x89, 0x13, 0x09, 0x9f, 0xd4, 0xb7, 0x38, 0xcf, - 0x09, 0x8f, 0x0e, 0xaa, 0x73, 0x79, 0xf5, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xeb, 0x19, 0x0a, 0x77, - 0xaf, 0x03, 0x00, 0x00, + // 421 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4f, 0xab, 0xd3, 0x40, + 0x14, 0xc5, 0x93, 0x57, 0xe9, 0xf3, 0x5d, 0x2b, 0x6a, 0x6a, 0x6b, 0x1a, 0x4a, 0x28, 0xc1, 0x45, + 0x11, 0x9a, 0x09, 0xea, 0xc6, 0xa5, 0x15, 0x11, 0x85, 0x6c, 0x22, 0x58, 0x70, 0xa1, 0x4c, 0xd2, + 0x71, 0x1a, 0x68, 0x32, 0x21, 0x33, 0xc1, 0xb6, 0x9f, 0xc2, 0x8f, 0xd5, 0x65, 0x37, 0x82, 0x4b, + 0x6d, 0xbf, 0x88, 0x4c, 0xfe, 0xd4, 0xb4, 0xd8, 0x16, 0xde, 0x2e, 0xe7, 0x9c, 0x7b, 0x7f, 0x03, + 0x27, 0x5c, 0xe8, 0xaf, 0x68, 0x80, 0xbe, 0xa7, 0x38, 0x49, 0xc8, 0x14, 0x3b, 0x34, 0xf4, 0x31, + 0x27, 0x48, 0x2c, 0xec, 0x24, 0x65, 0x82, 0x69, 0xed, 0x15, 0x0d, 0xec, 0xa3, 0xd4, 0xe8, 0x05, + 0x8c, 0x47, 0x8c, 0x7f, 0xcd, 0x47, 0x50, 0x21, 0x8a, 0x79, 0xe3, 0x31, 0x65, 0x94, 0x15, 0xbe, + 0xfc, 0x2a, 0xdd, 0x1e, 0x65, 0x8c, 0xce, 0x09, 0xca, 0x95, 0x9f, 0x7d, 0x43, 0x38, 0x5e, 0x16, + 0x91, 0xf5, 0x16, 0xee, 0xb9, 0x9c, 0x7e, 0x24, 0x62, 0xf2, 0xda, 0x79, 0xf7, 0x5e, 0xeb, 0xc3, + 0x0d, 0xce, 0xc4, 0x8c, 0xa5, 0xa1, 0x58, 0xea, 0xea, 0x40, 0x1d, 0xde, 0x78, 0xff, 0x0c, 0x4d, + 0x87, 0x6b, 0x3c, 0x9d, 0xa6, 0x84, 0x73, 0xfd, 0x6a, 0xa0, 0x0e, 0x5b, 0x5e, 0x25, 0xad, 0x0e, + 0xb4, 0x6b, 0x18, 0x8f, 0xf0, 0x84, 0xc5, 0x9c, 0x58, 0x13, 0xb8, 0x5f, 0xd8, 0x6e, 0x18, 0x8b, + 0x37, 0x38, 0xb9, 0xc0, 0xef, 0x42, 0x33, 0x0a, 0x63, 0x41, 0xd2, 0x12, 0x5f, 0x2a, 0xed, 0x21, + 0x34, 0x02, 0x9c, 0xe8, 0x8d, 0xdc, 0x94, 0x9f, 0xd6, 0x13, 0xe8, 0x1c, 0x80, 0xf7, 0x2f, 0xbe, + 0x82, 0x6b, 0x97, 0x53, 0xe9, 0xd6, 0x68, 0xea, 0x01, 0xad, 0x0b, 0x4d, 0x1c, 0xb1, 0x2c, 0x16, + 0xd5, 0x2b, 0x85, 0xb2, 0x1e, 0xc1, 0x83, 0x72, 0xf5, 0x88, 0x36, 0xce, 0xd2, 0xf8, 0x96, 0x34, + 0xb9, 0x5a, 0xd1, 0x9e, 0xff, 0xbc, 0x82, 0x86, 0xcb, 0xa9, 0xf6, 0x09, 0xee, 0xee, 0x0b, 0x1f, + 0xd8, 0xff, 0xf9, 0xc3, 0x76, 0xad, 0x4b, 0x63, 0x78, 0x69, 0xa2, 0xe2, 0x6b, 0x5f, 0xa0, 0x55, + 0x36, 0x42, 0x52, 0x59, 0xb6, 0x75, 0x66, 0xb3, 0xec, 0xcd, 0x78, 0x76, 0x79, 0x66, 0xcf, 0xff, + 0x00, 0x77, 0xf2, 0x62, 0xfb, 0xa7, 0x76, 0x64, 0x6a, 0x3c, 0x3d, 0x97, 0xd6, 0x59, 0x79, 0xad, + 0x27, 0x59, 0x32, 0x3d, 0xcd, 0xaa, 0xf7, 0x3a, 0xf6, 0xd6, 0x7f, 0x4c, 0x65, 0xbd, 0x35, 0xd5, + 0xcd, 0xd6, 0x54, 0x7f, 0x6f, 0x4d, 0xf5, 0xc7, 0xce, 0x54, 0x36, 0x3b, 0x53, 0xf9, 0xb5, 0x33, + 0x95, 0xcf, 0x2f, 0x69, 0x28, 0x66, 0x99, 0x6f, 0x07, 0x2c, 0x42, 0x0e, 0x9d, 0x63, 0x9f, 0x23, + 0x87, 0x8e, 0x82, 0x19, 0x0e, 0x63, 0xb4, 0xa8, 0x2e, 0x6f, 0x24, 0xe1, 0xa3, 0xe2, 0xf6, 0x96, + 0x09, 0xe1, 0x7e, 0x33, 0x3f, 0x8f, 0x17, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x43, 0x23, + 0x4d, 0x9f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -713,13 +711,6 @@ func (m *MsgMint) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Amount) i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) i-- - dAtA[i] = 0x1a - } - if len(m.To) > 0 { - i -= len(m.To) - copy(dAtA[i:], m.To) - i = encodeVarintTx(dAtA, i, uint64(len(m.To))) - i-- dAtA[i] = 0x12 } if len(m.Minter) > 0 { @@ -892,10 +883,6 @@ func (m *MsgMint) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.To) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } l = len(m.Amount) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1374,40 +1361,6 @@ func (m *MsgMint) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field To", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.To = append(m.To[:0], dAtA[iNdEx:postIndex]...) - if m.To == nil { - m.To = []byte{} - } - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } From 2500f6cb316867d432d4b5419f1da340331b9e60 Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:08:01 +0800 Subject: [PATCH 06/10] test: wrapped-a0gi-base --- app/test_common.go | 4 + x/wrapped-a0gi-base/cli/query.go | 2 +- x/wrapped-a0gi-base/genesis_test.go | 67 +++++ x/wrapped-a0gi-base/keeper/keeper_test.go | 40 +++ x/wrapped-a0gi-base/keeper/msg_server.go | 20 +- x/wrapped-a0gi-base/keeper/msg_server_test.go | 284 ++++++++++++++++++ x/wrapped-a0gi-base/testutil/suite.go | 66 ++++ x/wrapped-a0gi-base/testutil/types.go | 25 ++ x/wrapped-a0gi-base/types/errors.go | 5 +- x/wrapped-a0gi-base/types/genesis.go | 11 +- 10 files changed, 508 insertions(+), 16 deletions(-) create mode 100644 x/wrapped-a0gi-base/genesis_test.go create mode 100644 x/wrapped-a0gi-base/keeper/keeper_test.go create mode 100644 x/wrapped-a0gi-base/keeper/msg_server_test.go create mode 100644 x/wrapped-a0gi-base/testutil/suite.go create mode 100644 x/wrapped-a0gi-base/testutil/types.go diff --git a/app/test_common.go b/app/test_common.go index b822ddd2..b4657884 100644 --- a/app/test_common.go +++ b/app/test_common.go @@ -49,6 +49,7 @@ import ( issuancekeeper "github.com/0glabs/0g-chain/x/issuance/keeper" precisebankkeeper "github.com/0glabs/0g-chain/x/precisebank/keeper" pricefeedkeeper "github.com/0glabs/0g-chain/x/pricefeed/keeper" + wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" ) var ( @@ -118,6 +119,9 @@ func (tApp TestApp) GetEvmKeeper() *evmkeeper.Keeper { return tAp func (tApp TestApp) GetFeeMarketKeeper() feemarketkeeper.Keeper { return tApp.feeMarketKeeper } func (tApp TestApp) GetDASignersKeeper() dasignerskeeper.Keeper { return tApp.dasignersKeeper } func (tApp TestApp) GetPrecisebankKeeper() precisebankkeeper.Keeper { return tApp.precisebankKeeper } +func (tApp TestApp) GetWrappedA0GIBaseKeeper() wrappeda0gibasekeeper.Keeper { + return tApp.wrappeda0gibaseKeeper +} func (tApp TestApp) GetKVStoreKey(key string) *storetypes.KVStoreKey { return tApp.keys[key] diff --git a/x/wrapped-a0gi-base/cli/query.go b/x/wrapped-a0gi-base/cli/query.go index 52e4eaca..c693ab23 100644 --- a/x/wrapped-a0gi-base/cli/query.go +++ b/x/wrapped-a0gi-base/cli/query.go @@ -11,7 +11,7 @@ import ( func GetQueryCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the dasigners module", + Short: "Querying commands for the wrapped a0gi base module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, diff --git a/x/wrapped-a0gi-base/genesis_test.go b/x/wrapped-a0gi-base/genesis_test.go new file mode 100644 index 00000000..831efd82 --- /dev/null +++ b/x/wrapped-a0gi-base/genesis_test.go @@ -0,0 +1,67 @@ +package wrappeda0gibase_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + + "github.com/0glabs/0g-chain/app" + wrappeda0gibase "github.com/0glabs/0g-chain/x/wrapped-a0gi-base" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/testutil" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" +) + +type GenesisTestSuite struct { + testutil.Suite +} + +func (suite *GenesisTestSuite) TestInitGenesis() { + // Most genesis validation tests are located in the types directory. The 'invalid' test cases are + // randomly selected subset of those tests. + testCases := []struct { + name string + genState *types.GenesisState + expectPass bool + }{ + { + name: "default genesis", + genState: types.DefaultGenesisState(), + expectPass: true, + }, + } + for _, tc := range testCases { + suite.Run(tc.name, func() { + // Setup (note: suite.SetupTest is not run before every suite.Run) + suite.App = app.NewTestApp() + suite.Keeper = suite.App.GetWrappedA0GIBaseKeeper() + suite.Ctx = suite.App.NewContext(true, tmproto.Header{}) + + // Run + var exportedGenState *types.GenesisState + run := func() { + wrappeda0gibase.InitGenesis(suite.Ctx, suite.Keeper, *tc.genState) + exportedGenState = wrappeda0gibase.ExportGenesis(suite.Ctx, suite.Keeper) + } + if tc.expectPass { + suite.Require().NotPanics(run) + } else { + suite.Require().Panics(run) + } + + // Check + if tc.expectPass { + expectedJson, err := suite.App.AppCodec().MarshalJSON(tc.genState) + suite.Require().NoError(err) + actualJson, err := suite.App.AppCodec().MarshalJSON(exportedGenState) + suite.Require().NoError(err) + suite.Equal(expectedJson, actualJson) + } + }) + } +} + +func TestGenesisTestSuite(t *testing.T) { + suite.Run(t, new(GenesisTestSuite)) +} diff --git a/x/wrapped-a0gi-base/keeper/keeper_test.go b/x/wrapped-a0gi-base/keeper/keeper_test.go new file mode 100644 index 00000000..b045109f --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/keeper_test.go @@ -0,0 +1,40 @@ +package keeper_test + +import ( + "testing" + + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/testutil" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/suite" +) + +type KeeperTestSuite struct { + testutil.Suite +} + +func (s *KeeperTestSuite) TestSetWA0GIAddress() { + testCases := []struct { + name string + wa0gi common.Address + }{ + { + name: "zero address", + wa0gi: common.HexToAddress("0x0000000000000000000000000000000000000000"), + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + s.SetupTest() + + s.Keeper.SetWA0GIAddress(s.Ctx, tc.wa0gi) + response, err := s.Keeper.GetWA0GI(s.Ctx, &types.GetWA0GIRequest{}) + s.Require().NoError(err) + s.Require().Equal(common.BytesToAddress(response.Address), tc.wa0gi) + }) + } +} + +func TestKeeperSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} diff --git a/x/wrapped-a0gi-base/keeper/msg_server.go b/x/wrapped-a0gi-base/keeper/msg_server.go index 0d47034c..f3de20dd 100644 --- a/x/wrapped-a0gi-base/keeper/msg_server.go +++ b/x/wrapped-a0gi-base/keeper/msg_server.go @@ -18,10 +18,6 @@ var _ types.MsgServer = &Keeper{} func (k Keeper) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) minter := common.BytesToAddress(msg.Minter) - cap, err := k.getMinterCap(ctx, minter) - if err != nil { - return nil, err - } supply, err := k.getMinterSupply(ctx, minter) if err != nil { return nil, err @@ -29,17 +25,17 @@ func (k Keeper) Burn(goCtx context.Context, msg *types.MsgBurn) (*types.MsgBurnR amount := new(big.Int).SetBytes(msg.Amount) // check & update mint supply supply.Sub(supply, amount) - if supply.Cmp(cap) > 0 { - return nil, types.ErrInsufficientMintCap - } - if err = k.setMinterSupply(ctx, minter, supply); err != nil { - return nil, err + if supply.Cmp(big.NewInt(0)) < 0 { + return nil, types.ErrInsufficientMintSupply } // burn c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount)) if err = k.pbkeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil { return nil, err } + if err = k.setMinterSupply(ctx, minter, supply); err != nil { + return nil, err + } return &types.MsgBurnResponse{}, nil } @@ -61,14 +57,14 @@ func (k Keeper) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintR if supply.Cmp(cap) > 0 { return nil, types.ErrInsufficientMintCap } - if err = k.setMinterSupply(ctx, minter, supply); err != nil { - return nil, err - } // mint c := sdk.NewCoin(precisebanktypes.ExtendedCoinDenom, sdk.NewIntFromBigInt(amount)) if err = k.pbkeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(c)); err != nil { return nil, err } + if err = k.setMinterSupply(ctx, minter, supply); err != nil { + return nil, err + } return &types.MsgMintResponse{}, nil } diff --git a/x/wrapped-a0gi-base/keeper/msg_server_test.go b/x/wrapped-a0gi-base/keeper/msg_server_test.go new file mode 100644 index 00000000..8c54cd3f --- /dev/null +++ b/x/wrapped-a0gi-base/keeper/msg_server_test.go @@ -0,0 +1,284 @@ +package keeper_test + +import ( + "fmt" + "math/big" + "testing" + + precisebanktypes "github.com/0glabs/0g-chain/x/precisebank/types" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/testutil" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/suite" +) + +type MsgServerTestSuite struct { + testutil.Suite +} + +func (s *MsgServerTestSuite) TestSetWA0GI() { + govAccAddr := s.GovKeeper.GetGovernanceAccount(s.Ctx).GetAddress().String() + testCases := []struct { + name string + req *types.MsgSetWA0GI + expectErr bool + errMsg string + }{ + { + name: "invalid signer", + req: &types.MsgSetWA0GI{ + Authority: s.Addresses[0].String(), + Address: common.HexToAddress("0x0000000000000000000000000000000000000001").Bytes(), + }, + expectErr: true, + errMsg: "expected gov account as only signer for proposal message", + }, + { + name: "success", + req: &types.MsgSetWA0GI{ + Authority: govAccAddr, + Address: common.HexToAddress("0x0000000000000000000000000000000000000001").Bytes(), + }, + expectErr: false, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + _, err := s.Keeper.SetWA0GI(sdk.WrapSDKContext(s.Ctx), tc.req) + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.errMsg) + } else { + s.Require().NoError(err) + response, err := s.Keeper.GetWA0GI(s.Ctx, &types.GetWA0GIRequest{}) + s.Require().NoError(err) + s.Require().Equal(response.Address, tc.req.Address) + } + }) + } +} + +func (s *MsgServerTestSuite) TestSetMinterCap() { + testCases := []struct { + name string + caps []struct { + account common.Address + cap *big.Int + } + }{ + { + name: "success", + caps: []struct { + account common.Address + cap *big.Int + }{ + { + account: common.HexToAddress("0x0000000000000000000000000000000000000000"), + cap: big.NewInt(100000), + }, + { + account: common.HexToAddress("0x0000000000000000000000000000000000000001"), + cap: big.NewInt(200000), + }, + { + account: common.HexToAddress("0x0000000000000000000000000000000000000002"), + cap: big.NewInt(300000), + }, + { + account: common.HexToAddress("0x0000000000000000000000000000000000000003"), + cap: big.NewInt(400000), + }, + { + account: common.HexToAddress("0x0000000000000000000000000000000000000002"), + cap: big.NewInt(500000), + }, + { + account: common.HexToAddress("0x0000000000000000000000000000000000000001"), + cap: big.NewInt(600000), + }, + { + account: common.HexToAddress("0x0000000000000000000000000000000000000000"), + cap: big.NewInt(700000), + }, + }, + }, + } + s.Run("invalid authority", func() { + s.SetupTest() + _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + Authority: s.Addresses[0].String(), + Minter: common.HexToAddress("0x0000000000000000000000000000000000000000").Bytes(), + Cap: big.NewInt(600000).Bytes(), + }) + s.Require().Error(err) + s.Require().Contains(err.Error(), "expected gov account as only signer for proposal message") + }) + govAccAddr := s.GovKeeper.GetGovernanceAccount(s.Ctx).GetAddress().String() + for _, tc := range testCases { + s.Run(tc.name, func() { + s.SetupTest() + + c := make(map[common.Address]*big.Int) + for _, cap := range tc.caps { + _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + Authority: govAccAddr, + Minter: cap.account.Bytes(), + Cap: cap.cap.Bytes(), + }) + s.Require().NoError(err) + response, err := s.Keeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{ + Address: cap.account.Bytes(), + }) + s.Require().NoError(err) + s.Require().Equal(new(big.Int).SetBytes(response.Cap), cap.cap) + c[cap.account] = cap.cap + } + for account, cap := range c { + response, err := s.Keeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{ + Address: account.Bytes(), + }) + s.Require().NoError(err) + s.Require().Equal(new(big.Int).SetBytes(response.Cap), cap) + } + }) + } +} + +type MintBurn struct { + IsMint bool + Minter common.Address + Amount *big.Int + Success bool +} + +func (s *MsgServerTestSuite) TestSetMintBurn() { + precisebankKeeper := s.App.GetPrecisebankKeeper() + accountKeeper := s.App.GetAccountKeeper() + moduleAcc := accountKeeper.GetModuleAccount(s.Ctx, types.ModuleName).GetAddress() + govAccAddr := s.GovKeeper.GetGovernanceAccount(s.Ctx).GetAddress().String() + + minter1 := common.HexToAddress("0x0000000000000000000000000000000000000001") + minter2 := common.HexToAddress("0x0000000000000000000000000000000000000002") + + // set mint cap of minter 1 to 8 a0gi + _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + Authority: govAccAddr, + Minter: minter1.Bytes(), + Cap: big.NewInt(8e18).Bytes(), + }) + s.Require().NoError(err) + // set mint cap of minter 2 to 5 a0gi + _, err = s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + Authority: govAccAddr, + Minter: minter2.Bytes(), + Cap: big.NewInt(5e18).Bytes(), + }) + s.Require().NoError(err) + + testCases := []MintBurn{ + // #0, failed burn + { + IsMint: false, + Minter: minter1, + Amount: big.NewInt(1e18), + Success: false, + }, + // #1, mint 5 a0gi by minter 1 + { + IsMint: true, + Minter: minter1, + Amount: big.NewInt(5e18), + Success: true, + }, + // #2, burn 0.5 a0gi by minter 1 + { + IsMint: false, + Minter: minter1, + Amount: big.NewInt(5e17), + Success: true, + }, + // #3, mint 0.7 a0gi by minter 2 + { + IsMint: true, + Minter: minter2, + Amount: big.NewInt(7e17), + Success: true, + }, + // #4, mint 2 a0gi by minter 2 + { + IsMint: true, + Minter: minter2, + Amount: big.NewInt(2e18), + Success: true, + }, + // #5, burn 0.3 a0gi by minter 2 + { + IsMint: false, + Minter: minter1, + Amount: big.NewInt(3e17), + Success: true, + }, + // #6, failed to mint 4 a0gi by minter 1 + { + IsMint: true, + Minter: minter1, + Amount: big.NewInt(4e18), + Success: false, + }, + // #7, mint 3.5 a0gi by minter 1 + { + IsMint: true, + Minter: minter1, + Amount: big.NewInt(3e18 + 5e17), + Success: true, + }, + } + minted := big.NewInt(0) + supplied := make(map[common.Address]*big.Int) + for id, c := range testCases { + fmt.Println(id) + if c.IsMint { + _, err = s.Keeper.Mint(sdk.WrapSDKContext(s.Ctx), &types.MsgMint{ + Minter: c.Minter.Bytes(), + Amount: c.Amount.Bytes(), + }) + } else { + _, err = s.Keeper.Burn(sdk.WrapSDKContext(s.Ctx), &types.MsgBurn{ + Minter: c.Minter.Bytes(), + Amount: c.Amount.Bytes(), + }) + } + if c.Success { + if c.IsMint { + minted.Add(minted, c.Amount) + if amt, ok := supplied[c.Minter]; ok { + amt.Add(amt, c.Amount) + } else { + supplied[c.Minter] = new(big.Int).Set(c.Amount) + } + } else { + minted.Sub(minted, c.Amount) + if amt, ok := supplied[c.Minter]; ok { + amt.Sub(amt, c.Amount) + } else { + supplied[c.Minter] = new(big.Int).Set(c.Amount) + } + } + s.Require().NoError(err) + response, err := s.Keeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{ + Address: c.Minter.Bytes(), + }) + s.Require().NoError(err) + s.Require().Equal(supplied[c.Minter].Bytes(), response.Supply) + } else { + s.Require().Error(err) + } + coins := precisebankKeeper.GetBalance(s.Ctx, moduleAcc, precisebanktypes.ExtendedCoinDenom) + s.Require().Equal(coins.Amount.BigInt(), minted) + } +} + +func TestMsgServerSuite(t *testing.T) { + suite.Run(t, new(MsgServerTestSuite)) +} diff --git a/x/wrapped-a0gi-base/testutil/suite.go b/x/wrapped-a0gi-base/testutil/suite.go new file mode 100644 index 00000000..071d87de --- /dev/null +++ b/x/wrapped-a0gi-base/testutil/suite.go @@ -0,0 +1,66 @@ +package testutil + +import ( + "strings" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/ethereum/go-ethereum/crypto" + "github.com/stretchr/testify/suite" + + "github.com/0glabs/0g-chain/app" + "github.com/0glabs/0g-chain/chaincfg" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/evmos/ethermint/crypto/ethsecp256k1" +) + +// Suite implements a test suite for the module integration tests +type Suite struct { + suite.Suite + + Keeper keeper.Keeper + StakingKeeper *stakingkeeper.Keeper + GovKeeper govkeeper.Keeper + App app.TestApp + Ctx sdk.Context + QueryClient types.QueryClient + Addresses []sdk.AccAddress +} + +// SetupTest instantiates a new app, keepers, and sets suite state +func (suite *Suite) SetupTest() { + chaincfg.SetSDKConfig() + suite.App = app.NewTestApp() + suite.App.InitializeFromGenesisStates() + suite.Keeper = suite.App.GetWrappedA0GIBaseKeeper() + suite.GovKeeper = suite.App.GetGovKeeper() + suite.StakingKeeper = suite.App.GetStakingKeeper() + + // make block header + privkey, _ := ethsecp256k1.GenerateKey() + consAddress := sdk.ConsAddress(privkey.PubKey().Address()) + key, err := privkey.ToECDSA() + suite.Assert().NoError(err) + hexAddr := strings.ToLower(crypto.PubkeyToAddress(key.PublicKey).Hex()[2:]) + valAddr, err := sdk.ValAddressFromHex(hexAddr) + suite.Assert().NoError(err) + suite.Ctx = suite.App.NewContext(true, tmproto.Header{Height: 1, ChainID: app.TestChainId, ProposerAddress: consAddress}) + newValidator, err := stakingtypes.NewValidator(valAddr, privkey.PubKey(), stakingtypes.Description{}) + suite.Assert().NoError(err) + err = suite.StakingKeeper.SetValidatorByConsAddr(suite.Ctx, newValidator) + suite.Assert().NoError(err) + suite.StakingKeeper.SetValidator(suite.Ctx, newValidator) + + _, accAddresses := app.GeneratePrivKeyAddressPairs(10) + suite.Addresses = accAddresses + + // Set query client + queryHelper := suite.App.NewQueryServerTestHelper(suite.Ctx) + queryHandler := suite.Keeper + types.RegisterQueryServer(queryHelper, queryHandler) + suite.QueryClient = types.NewQueryClient(queryHelper) +} diff --git a/x/wrapped-a0gi-base/testutil/types.go b/x/wrapped-a0gi-base/testutil/types.go new file mode 100644 index 00000000..1ae3828c --- /dev/null +++ b/x/wrapped-a0gi-base/testutil/types.go @@ -0,0 +1,25 @@ +package testutil + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/assert" +) + +// Avoid cluttering test cases with long function names +func I(in int64) sdkmath.Int { return sdkmath.NewInt(in) } +func D(str string) sdk.Dec { return sdk.MustNewDecFromStr(str) } +func C(denom string, amount int64) sdk.Coin { return sdk.NewInt64Coin(denom, amount) } +func Cs(coins ...sdk.Coin) sdk.Coins { return sdk.NewCoins(coins...) } + +func AssertProtoMessageJSON(t *testing.T, cdc codec.Codec, expected proto.Message, actual proto.Message) { + expectedJson, err := cdc.MarshalJSON(expected) + assert.NoError(t, err) + actualJson, err := cdc.MarshalJSON(actual) + assert.NoError(t, err) + assert.Equal(t, string(expectedJson), string(actualJson)) +} diff --git a/x/wrapped-a0gi-base/types/errors.go b/x/wrapped-a0gi-base/types/errors.go index 7b38b98c..cd8bff0d 100644 --- a/x/wrapped-a0gi-base/types/errors.go +++ b/x/wrapped-a0gi-base/types/errors.go @@ -3,6 +3,7 @@ package types import errorsmod "cosmossdk.io/errors" var ( - ErrTxForbidden = errorsmod.Register(ModuleName, 1, "cosmos tx forbidden") - ErrInsufficientMintCap = errorsmod.Register(ModuleName, 2, "insufficient mint cap") + ErrTxForbidden = errorsmod.Register(ModuleName, 1, "cosmos tx forbidden") + ErrInsufficientMintCap = errorsmod.Register(ModuleName, 2, "insufficient mint cap") + ErrInsufficientMintSupply = errorsmod.Register(ModuleName, 3, "insufficient mint supply") ) diff --git a/x/wrapped-a0gi-base/types/genesis.go b/x/wrapped-a0gi-base/types/genesis.go index 0b622117..d306dc5f 100644 --- a/x/wrapped-a0gi-base/types/genesis.go +++ b/x/wrapped-a0gi-base/types/genesis.go @@ -3,7 +3,16 @@ package types import "github.com/ethereum/go-ethereum/common" const ( - DEFAULT_WRAPPED_A0GI = "0000000000000000000000000000000000000000" + // This is a Wrapped A0GI contract deployed by a raw transaction: + // raw tx params: + // from: 0x43db6cef54678f25310c0804bc1c1c2418f68e5b + // nonce: 0 + // gasPrice: 100 Gwei + // gasLimit: 1000000 + // The sender is an ephemeral account, nobody holds its private key and this is the only transaction it signed. + // This transaction is a legacy transaction without chain ID so it can be deployed at any EVM chain which supports pre-EIP155 transactions. + // raw tx: 0xf90c378085174876e800830f42408080b90be460c0604052600c60809081526b57726170706564204130474960a01b60a05260009061002b908261011c565b50604080518082019091526005815264574130474960d81b6020820152600190610055908261011c565b50600280546001600160a81b0319166210021217905534801561007757600080fd5b506101db565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806100a757607f821691505b6020821081036100c757634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561011757600081815260208120601f850160051c810160208610156100f45750805b601f850160051c820191505b8181101561011357828155600101610100565b5050505b505050565b81516001600160401b038111156101355761013561007d565b610149816101438454610093565b846100cd565b602080601f83116001811461017e57600084156101665750858301515b600019600386901b1c1916600185901b178555610113565b600085815260208120601f198616915b828110156101ad5788860151825594840194600190910190840161018e565b50858210156101cb5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6109f980620001eb6000396000f3fe6080604052600436106100e15760003560e01c806342966c681161007f57806395d89b411161005957806395d89b4114610283578063a9059cbb14610298578063d0e30db0146102b8578063dd62ed3e146102c057600080fd5b806342966c68146101f95780635001f3b51461021957806370a082311461025657600080fd5b806323b872dd116100bb57806323b872dd1461016d5780632e1a7d4d1461018d578063313ce567146101ad57806340c10f19146101d957600080fd5b806306fdde03146100f5578063095ea7b31461012057806318160ddd1461015057600080fd5b366100f0576100ee6102f8565b005b600080fd5b34801561010157600080fd5b5061010a610353565b6040516101179190610816565b60405180910390f35b34801561012c57600080fd5b5061014061013b366004610880565b6103e1565b6040519015158152602001610117565b34801561015c57600080fd5b50475b604051908152602001610117565b34801561017957600080fd5b506101406101883660046108aa565b61044e565b34801561019957600080fd5b506100ee6101a83660046108e6565b6105d2565b3480156101b957600080fd5b506002546101c79060ff1681565b60405160ff9091168152602001610117565b3480156101e557600080fd5b506100ee6101f4366004610880565b61065d565b34801561020557600080fd5b506100ee6102143660046108e6565b610736565b34801561022557600080fd5b5060025461023e9061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610117565b34801561026257600080fd5b5061015f6102713660046108ff565b60036020526000908152604090205481565b34801561028f57600080fd5b5061010a6107f5565b3480156102a457600080fd5b506101406102b3366004610880565b610802565b6100ee6102f8565b3480156102cc57600080fd5b5061015f6102db36600461091a565b600460209081526000928352604080842090915290825290205481565b3360009081526003602052604081208054349290610317908490610963565b909155505060405134815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a2565b6000805461036090610976565b80601f016020809104026020016040519081016040528092919081815260200182805461038c90610976565b80156103d95780601f106103ae576101008083540402835291602001916103d9565b820191906000526020600020905b8154815290600101906020018083116103bc57829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061043c9086815260200190565b60405180910390a35060015b92915050565b6001600160a01b03831660009081526003602052604081205482111561047357600080fd5b6001600160a01b03841633148015906104b157506001600160a01b038416600090815260046020908152604080832033845290915290205460001914155b1561051f576001600160a01b03841660009081526004602090815260408083203384529091529020548211156104e657600080fd5b6001600160a01b0384166000908152600460209081526040808320338452909152812080548492906105199084906109b0565b90915550505b6001600160a01b038416600090815260036020526040812080548492906105479084906109b0565b90915550506001600160a01b03831660009081526003602052604081208054849290610574908490610963565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516105c091815260200190565b60405180910390a35060019392505050565b33600090815260036020526040812080548392906105f19084906109b0565b9091555050604051339082156108fc029083906000818181858888f19350505050158015610623573d6000803e3d6000fd5b5060405181815233907f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65906020015b60405180910390a250565b6002546040516340c10f1960e01b8152336004820152602481018390526101009091046001600160a01b0316906340c10f1990604401600060405180830381600087803b1580156106ad57600080fd5b505af11580156106c1573d6000803e3d6000fd5b505050506001600160a01b038216600090815260036020526040812080548392906106ed908490610963565b90915550506040518181526001600160a01b0383169033907fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f89060200160405180910390a35050565b600254604051632770a7eb60e21b8152336004820152602481018390526101009091046001600160a01b031690639dc29fac90604401600060405180830381600087803b15801561078657600080fd5b505af115801561079a573d6000803e3d6000fd5b505033600090815260036020526040812080548594509092506107be9084906109b0565b909155505060405181815233907fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca590602001610652565b6001805461036090610976565b600061080f33848461044e565b9392505050565b600060208083528351808285015260005b8181101561084357858101830151858201604001528201610827565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461087b57600080fd5b919050565b6000806040838503121561089357600080fd5b61089c83610864565b946020939093013593505050565b6000806000606084860312156108bf57600080fd5b6108c884610864565b92506108d660208501610864565b9150604084013590509250925092565b6000602082840312156108f857600080fd5b5035919050565b60006020828403121561091157600080fd5b61080f82610864565b6000806040838503121561092d57600080fd5b61093683610864565b915061094460208401610864565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b808201808211156104485761044861094d565b600181811c9082168061098a57607f821691505b6020821081036109aa57634e487b7160e01b600052602260045260246000fd5b50919050565b818103818111156104485761044861094d56fea2646970667358221220076f43aa18ca3555e080ebb6815ba9bdfa3617ec5fad0223a8d6007ea588a6f364736f6c634300081400331ba07f6fb2afc9cb39989c4e35299f44266a2f800f009fdeb24914df0b51de47c85fa02acc21d7f401e1529a4fbd0b3cf888414a07494af162ddca5670a6fa181ebe07 + DEFAULT_WRAPPED_A0GI = "0xCDf97Ac4453AD85C663d2555BF4424601e1f2A9F" ) // NewGenesisState returns a new genesis state object for the module. From 8b43aa40647a09698d7de8da4d9e9ff6ad9a7e8b Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:08:18 +0800 Subject: [PATCH 07/10] feat: wrapped-a0gi-base precompile --- .../interfaces/contracts/IWrappedA0GIBase.sol | 2 +- .../wrapped-a0gi-base/IWrappedA0GIBase.json | 2 +- precompiles/wrapped-a0gi-base/contract.go | 54 +++++++++------- precompiles/wrapped-a0gi-base/errors.go | 5 ++ precompiles/wrapped-a0gi-base/query.go | 38 ++++++++++++ precompiles/wrapped-a0gi-base/tx.go | 62 +++++++++++++++++++ precompiles/wrapped-a0gi-base/types.go | 45 +++++++++++++- .../wrapped-a0gi-base/wrapped_a0gi_base.go | 57 ++++++++++++++--- 8 files changed, 232 insertions(+), 33 deletions(-) create mode 100644 precompiles/wrapped-a0gi-base/errors.go create mode 100644 precompiles/wrapped-a0gi-base/query.go create mode 100644 precompiles/wrapped-a0gi-base/tx.go diff --git a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol index ba975348..ad7e8132 100644 --- a/precompiles/interfaces/contracts/IWrappedA0GIBase.sol +++ b/precompiles/interfaces/contracts/IWrappedA0GIBase.sol @@ -20,7 +20,7 @@ interface IWrappedA0GIBase { /** * @dev get the wA0GI address. */ - function getWA0GI() external returns (address); + function getWA0GI() external view returns (address); /** * @dev set the cap for a minter. diff --git a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json index 6f4d2f48..67a7800b 100644 --- a/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json +++ b/precompiles/wrapped-a0gi-base/IWrappedA0GIBase.json @@ -27,7 +27,7 @@ "type": "address" } ], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { diff --git a/precompiles/wrapped-a0gi-base/contract.go b/precompiles/wrapped-a0gi-base/contract.go index 99174a4f..3cadb588 100644 --- a/precompiles/wrapped-a0gi-base/contract.go +++ b/precompiles/wrapped-a0gi-base/contract.go @@ -30,7 +30,7 @@ var ( // Wrappeda0gibaseMetaData contains all meta data concerning the Wrappeda0gibase contract. var Wrappeda0gibaseMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWA0GI\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWA0GI\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"minterSupply\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"internalType\":\"structSupply\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // Wrappeda0gibaseABI is the input ABI used to generate the binding from. @@ -179,6 +179,37 @@ func (_Wrappeda0gibase *Wrappeda0gibaseTransactorRaw) Transact(opts *bind.Transa return _Wrappeda0gibase.Contract.contract.Transact(opts, method, params...) } +// GetWA0GI is a free data retrieval call binding the contract method 0xa9283a7a. +// +// Solidity: function getWA0GI() view returns(address) +func (_Wrappeda0gibase *Wrappeda0gibaseCaller) GetWA0GI(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Wrappeda0gibase.contract.Call(opts, &out, "getWA0GI") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetWA0GI is a free data retrieval call binding the contract method 0xa9283a7a. +// +// Solidity: function getWA0GI() view returns(address) +func (_Wrappeda0gibase *Wrappeda0gibaseSession) GetWA0GI() (common.Address, error) { + return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.CallOpts) +} + +// GetWA0GI is a free data retrieval call binding the contract method 0xa9283a7a. +// +// Solidity: function getWA0GI() view returns(address) +func (_Wrappeda0gibase *Wrappeda0gibaseCallerSession) GetWA0GI() (common.Address, error) { + return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.CallOpts) +} + // MinterSupply is a free data retrieval call binding the contract method 0x95609212. // // Solidity: function minterSupply(address minter) view returns((uint256,uint256)) @@ -231,27 +262,6 @@ func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) Burn(minter common.Add return _Wrappeda0gibase.Contract.Burn(&_Wrappeda0gibase.TransactOpts, minter, amount) } -// GetWA0GI is a paid mutator transaction binding the contract method 0xa9283a7a. -// -// Solidity: function getWA0GI() returns(address) -func (_Wrappeda0gibase *Wrappeda0gibaseTransactor) GetWA0GI(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Wrappeda0gibase.contract.Transact(opts, "getWA0GI") -} - -// GetWA0GI is a paid mutator transaction binding the contract method 0xa9283a7a. -// -// Solidity: function getWA0GI() returns(address) -func (_Wrappeda0gibase *Wrappeda0gibaseSession) GetWA0GI() (*types.Transaction, error) { - return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.TransactOpts) -} - -// GetWA0GI is a paid mutator transaction binding the contract method 0xa9283a7a. -// -// Solidity: function getWA0GI() returns(address) -func (_Wrappeda0gibase *Wrappeda0gibaseTransactorSession) GetWA0GI() (*types.Transaction, error) { - return _Wrappeda0gibase.Contract.GetWA0GI(&_Wrappeda0gibase.TransactOpts) -} - // Mint is a paid mutator transaction binding the contract method 0x40c10f19. // // Solidity: function mint(address minter, uint256 amount) returns() diff --git a/precompiles/wrapped-a0gi-base/errors.go b/precompiles/wrapped-a0gi-base/errors.go new file mode 100644 index 00000000..4d793692 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/errors.go @@ -0,0 +1,5 @@ +package wrappeda0gibase + +const ( + ErrSenderNotWA0GI = "sender is not WA0GI" +) diff --git a/precompiles/wrapped-a0gi-base/query.go b/precompiles/wrapped-a0gi-base/query.go new file mode 100644 index 00000000..9052dbf7 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/query.go @@ -0,0 +1,38 @@ +package wrappeda0gibase + +import ( + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" +) + +func (w *WrappedA0giBasePrecompile) GetW0GI(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) { + req, err := NewGetW0GIRequest(args) + if err != nil { + return nil, err + } + response, err := w.wrappeda0gibaseKeeper.GetWA0GI(ctx, req) + if err != nil { + return nil, err + } + return method.Outputs.Pack(common.BytesToAddress(response.Address)) +} + +func (w *WrappedA0giBasePrecompile) MinterSupply(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) { + req, err := NewMinterSupplyRequest(args) + if err != nil { + return nil, err + } + response, err := w.wrappeda0gibaseKeeper.MinterSupply(ctx, req) + if err != nil { + return nil, err + } + supply := Supply{ + Cap: new(big.Int).SetBytes(response.Cap), + Total: new(big.Int).SetBytes(response.Supply), + } + return method.Outputs.Pack(supply) +} diff --git a/precompiles/wrapped-a0gi-base/tx.go b/precompiles/wrapped-a0gi-base/tx.go new file mode 100644 index 00000000..74032d94 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/tx.go @@ -0,0 +1,62 @@ +package wrappeda0gibase + +import ( + "errors" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/evmos/ethermint/x/evm/statedb" +) + +func (w *WrappedA0giBasePrecompile) Mint( + ctx sdk.Context, + evm *vm.EVM, + stateDB *statedb.StateDB, + contract *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + msg, err := NewMsgMint(args) + if err != nil { + return nil, err + } + // validation + wa0gi := common.BytesToAddress(w.wrappeda0gibaseKeeper.GetWA0GIAddress(ctx)) + if contract.CallerAddress != wa0gi { + return nil, errors.New(ErrSenderNotWA0GI) + } + // execute + _, err = w.wrappeda0gibaseKeeper.Mint(sdk.WrapSDKContext(ctx), msg) + if err != nil { + return nil, err + } + return method.Outputs.Pack() +} + +func (w *WrappedA0giBasePrecompile) Burn( + ctx sdk.Context, + evm *vm.EVM, + stateDB *statedb.StateDB, + contract *vm.Contract, + method *abi.Method, + args []interface{}, +) ([]byte, error) { + msg, err := NewMsgBurn(args) + if err != nil { + return nil, err + } + // validation + wa0gi := common.BytesToAddress(w.wrappeda0gibaseKeeper.GetWA0GIAddress(ctx)) + if contract.CallerAddress != wa0gi { + return nil, errors.New(ErrSenderNotWA0GI) + } + // execute + _, err = w.wrappeda0gibaseKeeper.Burn(sdk.WrapSDKContext(ctx), msg) + if err != nil { + return nil, err + } + return method.Outputs.Pack() +} diff --git a/precompiles/wrapped-a0gi-base/types.go b/precompiles/wrapped-a0gi-base/types.go index 95e427bd..23c6c2c0 100644 --- a/precompiles/wrapped-a0gi-base/types.go +++ b/precompiles/wrapped-a0gi-base/types.go @@ -1,8 +1,51 @@ package wrappeda0gibase -import "math/big" +import ( + "fmt" + "math/big" + + precompiles_common "github.com/0glabs/0g-chain/precompiles/common" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + "github.com/ethereum/go-ethereum/common" +) type Supply = struct { Cap *big.Int "json:\"cap\"" Total *big.Int "json:\"total\"" } + +func NewGetW0GIRequest(args []interface{}) (*types.GetWA0GIRequest, error) { + if len(args) != 0 { + return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 0, len(args)) + } + return &types.GetWA0GIRequest{}, nil +} + +func NewMinterSupplyRequest(args []interface{}) (*types.MinterSupplyRequest, error) { + if len(args) != 1 { + return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args)) + } + return &types.MinterSupplyRequest{ + Address: args[0].(common.Address).Bytes(), + }, nil +} + +func NewMsgMint(args []interface{}) (*types.MsgMint, error) { + if len(args) != 2 { + return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args)) + } + return &types.MsgMint{ + Minter: args[0].(common.Address).Bytes(), + Amount: args[1].(*big.Int).Bytes(), + }, nil +} + +func NewMsgBurn(args []interface{}) (*types.MsgBurn, error) { + if len(args) != 2 { + return nil, fmt.Errorf(precompiles_common.ErrInvalidNumberOfArgs, 1, len(args)) + } + return &types.MsgBurn{ + Minter: args[0].(common.Address).Bytes(), + Amount: args[1].(*big.Int).Bytes(), + }, nil +} diff --git a/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go index 088ecf40..ca3176dc 100644 --- a/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go +++ b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base.go @@ -5,7 +5,7 @@ import ( precompiles_common "github.com/0glabs/0g-chain/precompiles/common" wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" - "github.com/cosmos/cosmos-sdk/store/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" @@ -13,6 +13,13 @@ import ( const ( PrecompileAddress = "0x0000000000000000000000000000000000001002" + + // txs + WrappedA0GIBaseFunctionMint = "mint" + WrappedA0GIBaseFunctionBurn = "burn" + // queries + WrappedA0GIBaseFunctionGetWA0GI = "getWA0GI" + WrappedA0GIBaseFunctionMinterSupply = "minterSupply" ) var _ vm.PrecompiledContract = &WrappedA0giBasePrecompile{} @@ -25,17 +32,23 @@ type WrappedA0giBasePrecompile struct { // Abi implements common.PrecompileCommon. func (w *WrappedA0giBasePrecompile) Abi() *abi.ABI { - panic("unimplemented") + return &w.abi } // IsTx implements common.PrecompileCommon. -func (w *WrappedA0giBasePrecompile) IsTx(string) bool { - panic("unimplemented") +func (w *WrappedA0giBasePrecompile) IsTx(method string) bool { + switch method { + case WrappedA0GIBaseFunctionMint, + WrappedA0GIBaseFunctionBurn: + return true + default: + return false + } } // KVGasConfig implements common.PrecompileCommon. -func (w *WrappedA0giBasePrecompile) KVGasConfig() types.GasConfig { - panic("unimplemented") +func (w *WrappedA0giBasePrecompile) KVGasConfig() storetypes.GasConfig { + return storetypes.KVGasConfig() } // Address implements vm.PrecompiledContract. @@ -45,7 +58,7 @@ func (w *WrappedA0giBasePrecompile) Address() common.Address { // RequiredGas implements vm.PrecompiledContract. func (w *WrappedA0giBasePrecompile) RequiredGas(input []byte) uint64 { - panic("unimplemented") + return 0 } func NewWrappedA0giBasePrecompile(wrappeda0gibaseKeeper wrappeda0gibasekeeper.Keeper) (*WrappedA0giBasePrecompile, error) { @@ -61,5 +74,33 @@ func NewWrappedA0giBasePrecompile(wrappeda0gibaseKeeper wrappeda0gibasekeeper.Ke // Run implements vm.PrecompiledContract. func (w *WrappedA0giBasePrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error) { - panic("unimplemented") + ctx, stateDB, method, initialGas, args, err := precompiles_common.InitializePrecompileCall(w, evm, contract, readonly) + if err != nil { + return nil, err + } + + var bz []byte + switch method.Name { + // queries + case WrappedA0GIBaseFunctionGetWA0GI: + bz, err = w.GetW0GI(ctx, evm, method, args) + case WrappedA0GIBaseFunctionMinterSupply: + bz, err = w.MinterSupply(ctx, evm, method, args) + // txs + case WrappedA0GIBaseFunctionMint: + bz, err = w.Mint(ctx, evm, stateDB, contract, method, args) + case WrappedA0GIBaseFunctionBurn: + bz, err = w.Burn(ctx, evm, stateDB, contract, method, args) + } + + if err != nil { + return nil, err + } + + cost := ctx.GasMeter().GasConsumed() - initialGas + + if !contract.UseGas(cost) { + return nil, vm.ErrOutOfGas + } + return bz, nil } From 6ed21ea3fba41b47dc52876f9f016b5f6c4a5757 Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:00:09 +0800 Subject: [PATCH 08/10] test: wrapped-a0gi-base precompile --- precompiles/wrapped-a0gi-base/query_test.go | 147 ++++++++++++ precompiles/wrapped-a0gi-base/tx_test.go | 218 ++++++++++++++++++ .../wrapped_a0gi_base_test.go | 80 +++++++ 3 files changed, 445 insertions(+) create mode 100644 precompiles/wrapped-a0gi-base/query_test.go create mode 100644 precompiles/wrapped-a0gi-base/tx_test.go create mode 100644 precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go diff --git a/precompiles/wrapped-a0gi-base/query_test.go b/precompiles/wrapped-a0gi-base/query_test.go new file mode 100644 index 00000000..a930f12b --- /dev/null +++ b/precompiles/wrapped-a0gi-base/query_test.go @@ -0,0 +1,147 @@ +package wrappeda0gibase_test + +import ( + "math/big" + + wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + +func (s *WrappedA0giBaseTestSuite) TestGetW0GI() { + method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionGetWA0GI + + testCases := []struct { + name string + malleate func() []byte + postCheck func(bz []byte) + gas uint64 + expErr bool + errContains string + }{ + { + "success", + func() []byte { + input, err := s.abi.Pack( + method, + ) + s.Assert().NoError(err) + return input + }, + func(data []byte) { + out, err := s.abi.Methods[method].Outputs.Unpack(data) + s.Require().NoError(err, "failed to unpack output") + wa0gi := out[0].(common.Address) + s.Require().Equal(wa0gi, common.HexToAddress(types.DEFAULT_WRAPPED_A0GI)) + // fmt.Println(wa0gi) + }, + 100000, + false, + "", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + s.SetupTest() + + bz, err := s.runTx(tc.malleate(), s.signerOne, 10000000) + + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.errContains) + } else { + s.Require().NoError(err) + s.Require().NotNil(bz) + tc.postCheck(bz) + } + }) + } +} + +func (s *WrappedA0giBaseTestSuite) TestMinterSupply() { + method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionMinterSupply + govAccAddr := s.App.GetGovKeeper().GetGovernanceAccount(s.Ctx).GetAddress().String() + + testCases := []struct { + name string + malleate func() []byte + postCheck func(bz []byte) + gas uint64 + expErr bool + errContains string + }{ + { + "non-empty", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerOne.Addr, + ) + s.Assert().NoError(err) + return input + }, + func(data []byte) { + out, err := s.abi.Methods[method].Outputs.Unpack(data) + s.Require().NoError(err, "failed to unpack output") + wa0gi := out[0].(wrappeda0gibaseprecompile.Supply) + s.Require().Equal(wa0gi.Cap, big.NewInt(8e18)) + s.Require().Equal(wa0gi.Total, big.NewInt(1e18)) + // fmt.Println(wa0gi) + }, + 100000, + false, + "", + }, { + "empty", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerTwo.Addr, + ) + s.Assert().NoError(err) + return input + }, + func(data []byte) { + out, err := s.abi.Methods[method].Outputs.Unpack(data) + s.Require().NoError(err, "failed to unpack output") + supply := out[0].(wrappeda0gibaseprecompile.Supply) + s.Require().Equal(supply.Cap.Bytes(), big.NewInt(0).Bytes()) + s.Require().Equal(supply.Total.Bytes(), big.NewInt(0).Bytes()) + // fmt.Println(wa0gi) + }, + 100000, + false, + "", + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + s.SetupTest() + + s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + Authority: govAccAddr, + Minter: s.signerOne.Addr.Bytes(), + Cap: big.NewInt(8e18).Bytes(), + }) + + s.wa0gibasekeeper.Mint(sdk.WrapSDKContext(s.Ctx), &types.MsgMint{ + Minter: s.signerOne.Addr.Bytes(), + Amount: big.NewInt(1e18).Bytes(), + }) + + bz, err := s.runTx(tc.malleate(), s.signerOne, 10000000) + + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.errContains) + } else { + s.Require().NoError(err) + s.Require().NotNil(bz) + tc.postCheck(bz) + } + }) + } +} diff --git a/precompiles/wrapped-a0gi-base/tx_test.go b/precompiles/wrapped-a0gi-base/tx_test.go new file mode 100644 index 00000000..81910379 --- /dev/null +++ b/precompiles/wrapped-a0gi-base/tx_test.go @@ -0,0 +1,218 @@ +package wrappeda0gibase_test + +import ( + "fmt" + "math/big" + + wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base" + "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (s *WrappedA0giBaseTestSuite) TestMint() { + method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionMint + govAccAddr := s.App.GetGovKeeper().GetGovernanceAccount(s.Ctx).GetAddress().String() + + testCases := []struct { + name string + malleate func() []byte + postCheck func() + gas uint64 + expErr bool + errContains string + isSignerOne bool + }{ + { + "success", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerOne.Addr, + big.NewInt(1e18), + ) + s.Assert().NoError(err) + return input + }, + func() { + supply, err := s.wa0gibasekeeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{ + Address: s.signerOne.Addr.Bytes(), + }) + s.Assert().NoError(err) + s.Require().Equal(supply.Cap, big.NewInt(8e18).Bytes()) + s.Require().Equal(supply.Supply, big.NewInt(1e18).Bytes()) + // fmt.Println(wa0gi) + }, + 100000, + false, + "", + true, + }, { + "fail", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerOne.Addr, + big.NewInt(9e18), + ) + s.Assert().NoError(err) + return input + }, + func() {}, + 100000, + true, + "insufficient mint cap", + true, + }, { + "invalid sender", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerTwo.Addr, + big.NewInt(9e18), + ) + s.Assert().NoError(err) + return input + }, + func() {}, + 100000, + true, + "sender is not WA0GI", + false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + s.SetupTest() + + fmt.Println(s.signerOne.Addr) + s.wa0gibasekeeper.SetWA0GIAddress(s.Ctx, s.signerOne.Addr) + s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + Authority: govAccAddr, + Minter: s.signerOne.Addr.Bytes(), + Cap: big.NewInt(8e18).Bytes(), + }) + + var err error + if tc.isSignerOne { + _, err = s.runTx(tc.malleate(), s.signerOne, 10000000) + } else { + _, err = s.runTx(tc.malleate(), s.signerTwo, 10000000) + } + + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.errContains) + } else { + s.Require().NoError(err) + tc.postCheck() + } + }) + } +} + +func (s *WrappedA0giBaseTestSuite) TestBurn() { + method := wrappeda0gibaseprecompile.WrappedA0GIBaseFunctionBurn + govAccAddr := s.App.GetGovKeeper().GetGovernanceAccount(s.Ctx).GetAddress().String() + + testCases := []struct { + name string + malleate func() []byte + postCheck func() + gas uint64 + expErr bool + errContains string + isSignerOne bool + }{ + { + "success", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerOne.Addr, + big.NewInt(1e18), + ) + s.Assert().NoError(err) + return input + }, + func() { + supply, err := s.wa0gibasekeeper.MinterSupply(s.Ctx, &types.MinterSupplyRequest{ + Address: s.signerOne.Addr.Bytes(), + }) + s.Assert().NoError(err) + s.Require().Equal(supply.Cap, big.NewInt(8e18).Bytes()) + s.Require().Equal(supply.Supply, big.NewInt(3e18).Bytes()) + // fmt.Println(wa0gi) + }, + 100000, + false, + "", + true, + }, { + "fail", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerOne.Addr, + big.NewInt(9e18), + ) + s.Assert().NoError(err) + return input + }, + func() {}, + 100000, + true, + "insufficient mint supply", + true, + }, { + "invalid sender", + func() []byte { + input, err := s.abi.Pack( + method, + s.signerTwo.Addr, + big.NewInt(9e18), + ) + s.Assert().NoError(err) + return input + }, + func() {}, + 100000, + true, + "sender is not WA0GI", + false, + }, + } + + for _, tc := range testCases { + s.Run(tc.name, func() { + s.SetupTest() + + fmt.Println(s.signerOne.Addr) + s.wa0gibasekeeper.SetWA0GIAddress(s.Ctx, s.signerOne.Addr) + s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + Authority: govAccAddr, + Minter: s.signerOne.Addr.Bytes(), + Cap: big.NewInt(8e18).Bytes(), + }) + s.wa0gibasekeeper.Mint(sdk.WrapSDKContext(s.Ctx), &types.MsgMint{ + Minter: s.signerOne.Addr.Bytes(), + Amount: big.NewInt(4e18).Bytes(), + }) + + var err error + if tc.isSignerOne { + _, err = s.runTx(tc.malleate(), s.signerOne, 10000000) + } else { + _, err = s.runTx(tc.malleate(), s.signerTwo, 10000000) + } + + if tc.expErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.errContains) + } else { + s.Require().NoError(err) + tc.postCheck() + } + }) + } +} diff --git a/precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go new file mode 100644 index 00000000..62bfce4b --- /dev/null +++ b/precompiles/wrapped-a0gi-base/wrapped_a0gi_base_test.go @@ -0,0 +1,80 @@ +package wrappeda0gibase_test + +import ( + "math/big" + "strings" + "testing" + + "github.com/0glabs/0g-chain/precompiles/testutil" + wrappeda0gibaseprecompile "github.com/0glabs/0g-chain/precompiles/wrapped-a0gi-base" + wrappeda0gibasekeeper "github.com/0glabs/0g-chain/x/wrapped-a0gi-base/keeper" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/vm" + "github.com/evmos/ethermint/x/evm/statedb" + evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/stretchr/testify/suite" +) + +type WrappedA0giBaseTestSuite struct { + testutil.PrecompileTestSuite + + abi abi.ABI + addr common.Address + wa0gibasekeeper wrappeda0gibasekeeper.Keeper + wa0gibase *wrappeda0gibaseprecompile.WrappedA0giBasePrecompile + signerOne *testutil.TestSigner + signerTwo *testutil.TestSigner +} + +func (suite *WrappedA0giBaseTestSuite) SetupTest() { + suite.PrecompileTestSuite.SetupTest() + + suite.wa0gibasekeeper = suite.App.GetWrappedA0GIBaseKeeper() + + suite.addr = common.HexToAddress(wrappeda0gibaseprecompile.PrecompileAddress) + + precompiles := suite.EvmKeeper.GetPrecompiles() + precompile, ok := precompiles[suite.addr] + suite.Assert().EqualValues(ok, true) + + suite.wa0gibase = precompile.(*wrappeda0gibaseprecompile.WrappedA0giBasePrecompile) + + suite.signerOne = suite.GenSigner() + suite.signerTwo = suite.GenSigner() + + abi, err := abi.JSON(strings.NewReader(wrappeda0gibaseprecompile.Wrappeda0gibaseABI)) + suite.Assert().NoError(err) + suite.abi = abi +} + +func (suite *WrappedA0giBaseTestSuite) runTx(input []byte, signer *testutil.TestSigner, gas uint64) ([]byte, error) { + contract := vm.NewPrecompile(vm.AccountRef(signer.Addr), vm.AccountRef(suite.addr), big.NewInt(0), gas) + contract.Input = input + + msgEthereumTx := evmtypes.NewTx(suite.EvmKeeper.ChainID(), 0, &suite.addr, big.NewInt(0), gas, big.NewInt(0), big.NewInt(0), big.NewInt(0), input, nil) + msgEthereumTx.From = signer.HexAddr + err := msgEthereumTx.Sign(suite.EthSigner, signer.Signer) + suite.Assert().NoError(err, "failed to sign Ethereum message") + + proposerAddress := suite.Ctx.BlockHeader().ProposerAddress + cfg, err := suite.EvmKeeper.EVMConfig(suite.Ctx, proposerAddress, suite.EvmKeeper.ChainID()) + suite.Assert().NoError(err, "failed to instantiate EVM config") + + msg, err := msgEthereumTx.AsMessage(suite.EthSigner, big.NewInt(0)) + suite.Assert().NoError(err, "failed to instantiate Ethereum message") + + evm := suite.EvmKeeper.NewEVM(suite.Ctx, msg, cfg, nil, suite.Statedb) + precompiles := suite.EvmKeeper.GetPrecompiles() + evm.WithPrecompiles(precompiles, []common.Address{suite.addr}) + + bz, err := suite.wa0gibase.Run(evm, contract, false) + if err == nil { + evm.StateDB.(*statedb.StateDB).Commit() + } + return bz, err +} + +func TestWrappedA0giBaseTestSuite(t *testing.T) { + suite.Run(t, new(WrappedA0giBaseTestSuite)) +} From 1a039a0d13941f6e8b4946d39a4e3f0c34d5d2a6 Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Tue, 14 Jan 2025 13:40:50 +0800 Subject: [PATCH 09/10] fix: proto name feat: update fix-deployed wa0gi --- precompiles/wrapped-a0gi-base/query_test.go | 2 +- precompiles/wrapped-a0gi-base/tx_test.go | 4 +- proto/zgc/wrappeda0gibase/tx.proto | 6 +- x/wrapped-a0gi-base/keeper/msg_server.go | 4 +- x/wrapped-a0gi-base/keeper/msg_server_test.go | 8 +- x/wrapped-a0gi-base/types/codec.go | 2 +- x/wrapped-a0gi-base/types/genesis.go | 6 +- x/wrapped-a0gi-base/types/msg.go | 8 +- x/wrapped-a0gi-base/types/tx.pb.go | 158 +++++++++--------- 9 files changed, 99 insertions(+), 99 deletions(-) diff --git a/precompiles/wrapped-a0gi-base/query_test.go b/precompiles/wrapped-a0gi-base/query_test.go index a930f12b..e987c4b4 100644 --- a/precompiles/wrapped-a0gi-base/query_test.go +++ b/precompiles/wrapped-a0gi-base/query_test.go @@ -121,7 +121,7 @@ func (s *WrappedA0giBaseTestSuite) TestMinterSupply() { s.Run(tc.name, func() { s.SetupTest() - s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMinterCap{ Authority: govAccAddr, Minter: s.signerOne.Addr.Bytes(), Cap: big.NewInt(8e18).Bytes(), diff --git a/precompiles/wrapped-a0gi-base/tx_test.go b/precompiles/wrapped-a0gi-base/tx_test.go index 81910379..acf3e262 100644 --- a/precompiles/wrapped-a0gi-base/tx_test.go +++ b/precompiles/wrapped-a0gi-base/tx_test.go @@ -87,7 +87,7 @@ func (s *WrappedA0giBaseTestSuite) TestMint() { fmt.Println(s.signerOne.Addr) s.wa0gibasekeeper.SetWA0GIAddress(s.Ctx, s.signerOne.Addr) - s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMinterCap{ Authority: govAccAddr, Minter: s.signerOne.Addr.Bytes(), Cap: big.NewInt(8e18).Bytes(), @@ -189,7 +189,7 @@ func (s *WrappedA0giBaseTestSuite) TestBurn() { fmt.Println(s.signerOne.Addr) s.wa0gibasekeeper.SetWA0GIAddress(s.Ctx, s.signerOne.Addr) - s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + s.wa0gibasekeeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMinterCap{ Authority: govAccAddr, Minter: s.signerOne.Addr.Bytes(), Cap: big.NewInt(8e18).Bytes(), diff --git a/proto/zgc/wrappeda0gibase/tx.proto b/proto/zgc/wrappeda0gibase/tx.proto index 4f47c32b..323dce06 100644 --- a/proto/zgc/wrappeda0gibase/tx.proto +++ b/proto/zgc/wrappeda0gibase/tx.proto @@ -11,7 +11,7 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the wrapped a0gi base Msg service service Msg { rpc SetWA0GI(MsgSetWA0GI) returns (MsgSetWA0GIResponse); - rpc SetMinterCap(MsgSetMintCap) returns (MsgSetMintCapResponse); + rpc SetMinterCap(MsgSetMinterCap) returns (MsgSetMinterCapResponse); rpc Mint(MsgMint) returns (MsgMintResponse); rpc Burn(MsgBurn) returns (MsgBurnResponse); } @@ -23,13 +23,13 @@ message MsgSetWA0GI { message MsgSetWA0GIResponse {} -message MsgSetMintCap { +message MsgSetMinterCap { string authority = 1; bytes minter = 2; bytes cap = 3; // big endian } -message MsgSetMintCapResponse {} +message MsgSetMinterCapResponse {} message MsgMint { bytes minter = 1; diff --git a/x/wrapped-a0gi-base/keeper/msg_server.go b/x/wrapped-a0gi-base/keeper/msg_server.go index f3de20dd..b626cab4 100644 --- a/x/wrapped-a0gi-base/keeper/msg_server.go +++ b/x/wrapped-a0gi-base/keeper/msg_server.go @@ -69,7 +69,7 @@ func (k Keeper) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintR } // SetMinterCap implements types.MsgServer. -func (k Keeper) SetMinterCap(goCtx context.Context, msg *types.MsgSetMintCap) (*types.MsgSetMintCapResponse, error) { +func (k Keeper) SetMinterCap(goCtx context.Context, msg *types.MsgSetMinterCap) (*types.MsgSetMinterCapResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) minter := common.BytesToAddress(msg.Minter) // validate authority @@ -80,7 +80,7 @@ func (k Keeper) SetMinterCap(goCtx context.Context, msg *types.MsgSetMintCap) (* if err := k.setMinterCap(ctx, minter, new(big.Int).SetBytes(msg.Cap)); err != nil { return nil, err } - return &types.MsgSetMintCapResponse{}, nil + return &types.MsgSetMinterCapResponse{}, nil } // SetWA0GI implements types.MsgServer. diff --git a/x/wrapped-a0gi-base/keeper/msg_server_test.go b/x/wrapped-a0gi-base/keeper/msg_server_test.go index 8c54cd3f..127d73db 100644 --- a/x/wrapped-a0gi-base/keeper/msg_server_test.go +++ b/x/wrapped-a0gi-base/keeper/msg_server_test.go @@ -106,7 +106,7 @@ func (s *MsgServerTestSuite) TestSetMinterCap() { } s.Run("invalid authority", func() { s.SetupTest() - _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMinterCap{ Authority: s.Addresses[0].String(), Minter: common.HexToAddress("0x0000000000000000000000000000000000000000").Bytes(), Cap: big.NewInt(600000).Bytes(), @@ -121,7 +121,7 @@ func (s *MsgServerTestSuite) TestSetMinterCap() { c := make(map[common.Address]*big.Int) for _, cap := range tc.caps { - _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMinterCap{ Authority: govAccAddr, Minter: cap.account.Bytes(), Cap: cap.cap.Bytes(), @@ -162,14 +162,14 @@ func (s *MsgServerTestSuite) TestSetMintBurn() { minter2 := common.HexToAddress("0x0000000000000000000000000000000000000002") // set mint cap of minter 1 to 8 a0gi - _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + _, err := s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMinterCap{ Authority: govAccAddr, Minter: minter1.Bytes(), Cap: big.NewInt(8e18).Bytes(), }) s.Require().NoError(err) // set mint cap of minter 2 to 5 a0gi - _, err = s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMintCap{ + _, err = s.Keeper.SetMinterCap(sdk.WrapSDKContext(s.Ctx), &types.MsgSetMinterCap{ Authority: govAccAddr, Minter: minter2.Bytes(), Cap: big.NewInt(5e18).Bytes(), diff --git a/x/wrapped-a0gi-base/types/codec.go b/x/wrapped-a0gi-base/types/codec.go index 7af6a480..6fdf49af 100644 --- a/x/wrapped-a0gi-base/types/codec.go +++ b/x/wrapped-a0gi-base/types/codec.go @@ -32,7 +32,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgSetWA0GI{}, - &MsgSetMintCap{}, + &MsgSetMinterCap{}, &MsgMint{}, &MsgBurn{}, ) diff --git a/x/wrapped-a0gi-base/types/genesis.go b/x/wrapped-a0gi-base/types/genesis.go index d306dc5f..1f8510bb 100644 --- a/x/wrapped-a0gi-base/types/genesis.go +++ b/x/wrapped-a0gi-base/types/genesis.go @@ -5,14 +5,14 @@ import "github.com/ethereum/go-ethereum/common" const ( // This is a Wrapped A0GI contract deployed by a raw transaction: // raw tx params: - // from: 0x43db6cef54678f25310c0804bc1c1c2418f68e5b + // from: 0x873cd27b6833e6394c34a00c37b260aca5abc0b6 // nonce: 0 // gasPrice: 100 Gwei // gasLimit: 1000000 // The sender is an ephemeral account, nobody holds its private key and this is the only transaction it signed. // This transaction is a legacy transaction without chain ID so it can be deployed at any EVM chain which supports pre-EIP155 transactions. - // raw tx: 0xf90c378085174876e800830f42408080b90be460c0604052600c60809081526b57726170706564204130474960a01b60a05260009061002b908261011c565b50604080518082019091526005815264574130474960d81b6020820152600190610055908261011c565b50600280546001600160a81b0319166210021217905534801561007757600080fd5b506101db565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806100a757607f821691505b6020821081036100c757634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561011757600081815260208120601f850160051c810160208610156100f45750805b601f850160051c820191505b8181101561011357828155600101610100565b5050505b505050565b81516001600160401b038111156101355761013561007d565b610149816101438454610093565b846100cd565b602080601f83116001811461017e57600084156101665750858301515b600019600386901b1c1916600185901b178555610113565b600085815260208120601f198616915b828110156101ad5788860151825594840194600190910190840161018e565b50858210156101cb5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6109f980620001eb6000396000f3fe6080604052600436106100e15760003560e01c806342966c681161007f57806395d89b411161005957806395d89b4114610283578063a9059cbb14610298578063d0e30db0146102b8578063dd62ed3e146102c057600080fd5b806342966c68146101f95780635001f3b51461021957806370a082311461025657600080fd5b806323b872dd116100bb57806323b872dd1461016d5780632e1a7d4d1461018d578063313ce567146101ad57806340c10f19146101d957600080fd5b806306fdde03146100f5578063095ea7b31461012057806318160ddd1461015057600080fd5b366100f0576100ee6102f8565b005b600080fd5b34801561010157600080fd5b5061010a610353565b6040516101179190610816565b60405180910390f35b34801561012c57600080fd5b5061014061013b366004610880565b6103e1565b6040519015158152602001610117565b34801561015c57600080fd5b50475b604051908152602001610117565b34801561017957600080fd5b506101406101883660046108aa565b61044e565b34801561019957600080fd5b506100ee6101a83660046108e6565b6105d2565b3480156101b957600080fd5b506002546101c79060ff1681565b60405160ff9091168152602001610117565b3480156101e557600080fd5b506100ee6101f4366004610880565b61065d565b34801561020557600080fd5b506100ee6102143660046108e6565b610736565b34801561022557600080fd5b5060025461023e9061010090046001600160a01b031681565b6040516001600160a01b039091168152602001610117565b34801561026257600080fd5b5061015f6102713660046108ff565b60036020526000908152604090205481565b34801561028f57600080fd5b5061010a6107f5565b3480156102a457600080fd5b506101406102b3366004610880565b610802565b6100ee6102f8565b3480156102cc57600080fd5b5061015f6102db36600461091a565b600460209081526000928352604080842090915290825290205481565b3360009081526003602052604081208054349290610317908490610963565b909155505060405134815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a2565b6000805461036090610976565b80601f016020809104026020016040519081016040528092919081815260200182805461038c90610976565b80156103d95780601f106103ae576101008083540402835291602001916103d9565b820191906000526020600020905b8154815290600101906020018083116103bc57829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259061043c9086815260200190565b60405180910390a35060015b92915050565b6001600160a01b03831660009081526003602052604081205482111561047357600080fd5b6001600160a01b03841633148015906104b157506001600160a01b038416600090815260046020908152604080832033845290915290205460001914155b1561051f576001600160a01b03841660009081526004602090815260408083203384529091529020548211156104e657600080fd5b6001600160a01b0384166000908152600460209081526040808320338452909152812080548492906105199084906109b0565b90915550505b6001600160a01b038416600090815260036020526040812080548492906105479084906109b0565b90915550506001600160a01b03831660009081526003602052604081208054849290610574908490610963565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516105c091815260200190565b60405180910390a35060019392505050565b33600090815260036020526040812080548392906105f19084906109b0565b9091555050604051339082156108fc029083906000818181858888f19350505050158015610623573d6000803e3d6000fd5b5060405181815233907f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65906020015b60405180910390a250565b6002546040516340c10f1960e01b8152336004820152602481018390526101009091046001600160a01b0316906340c10f1990604401600060405180830381600087803b1580156106ad57600080fd5b505af11580156106c1573d6000803e3d6000fd5b505050506001600160a01b038216600090815260036020526040812080548392906106ed908490610963565b90915550506040518181526001600160a01b0383169033907fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f89060200160405180910390a35050565b600254604051632770a7eb60e21b8152336004820152602481018390526101009091046001600160a01b031690639dc29fac90604401600060405180830381600087803b15801561078657600080fd5b505af115801561079a573d6000803e3d6000fd5b505033600090815260036020526040812080548594509092506107be9084906109b0565b909155505060405181815233907fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca590602001610652565b6001805461036090610976565b600061080f33848461044e565b9392505050565b600060208083528351808285015260005b8181101561084357858101830151858201604001528201610827565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461087b57600080fd5b919050565b6000806040838503121561089357600080fd5b61089c83610864565b946020939093013593505050565b6000806000606084860312156108bf57600080fd5b6108c884610864565b92506108d660208501610864565b9150604084013590509250925092565b6000602082840312156108f857600080fd5b5035919050565b60006020828403121561091157600080fd5b61080f82610864565b6000806040838503121561092d57600080fd5b61093683610864565b915061094460208401610864565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b808201808211156104485761044861094d565b600181811c9082168061098a57607f821691505b6020821081036109aa57634e487b7160e01b600052602260045260246000fd5b50919050565b818103818111156104485761044861094d56fea2646970667358221220076f43aa18ca3555e080ebb6815ba9bdfa3617ec5fad0223a8d6007ea588a6f364736f6c634300081400331ba07f6fb2afc9cb39989c4e35299f44266a2f800f009fdeb24914df0b51de47c85fa02acc21d7f401e1529a4fbd0b3cf888414a07494af162ddca5670a6fa181ebe07 - DEFAULT_WRAPPED_A0GI = "0xCDf97Ac4453AD85C663d2555BF4424601e1f2A9F" + // raw tx: 0xf90f568085174876e800830f42408080b90f0360c0604052600c60809081526b57726170706564204130474960a01b60a0526000906200002d908262000128565b50604080518082019091526005815264574130474960d81b602082015260019062000059908262000128565b50600280546001600160a81b031916621002121790553480156200007c57600080fd5b50620001f4565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620000ae57607f821691505b602082108103620000cf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200012357600081815260208120601f850160051c81016020861015620000fe5750805b601f850160051c820191505b818110156200011f578281556001016200010a565b5050505b505050565b81516001600160401b0381111562000144576200014462000083565b6200015c8162000155845462000099565b84620000d5565b602080601f8311600181146200019457600084156200017b5750858301515b600019600386901b1c1916600185901b1785556200011f565b600085815260208120601f198616915b82811015620001c557888601518255948401946001909101908401620001a4565b5085821015620001e45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b610cff80620002046000396000f3fe6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb14610291578063c8dd1a26146102b1578063d0e30db0146102ee578063dd62ed3e146102f657600080fd5b806370a082311461022f57806379cc67901461025c57806395d89b411461027c5780639dc29fac1461025c57600080fd5b80632e1a7d4d116100c65780632e1a7d4d146101a3578063313ce567146101c357806340c10f19146101ef57806342966c681461020f57600080fd5b806306fdde031461010b578063095ea7b31461013657806318160ddd1461016657806323b872dd1461018357600080fd5b366101065761010461032e565b005b600080fd5b34801561011757600080fd5b50610120610389565b60405161012d9190610b1b565b60405180910390f35b34801561014257600080fd5b50610156610151366004610b6a565b610417565b604051901515815260200161012d565b34801561017257600080fd5b50475b60405190815260200161012d565b34801561018f57600080fd5b5061015661019e366004610b94565b610484565b3480156101af57600080fd5b506101046101be366004610bd0565b61068c565b3480156101cf57600080fd5b506002546101dd9060ff1681565b60405160ff909116815260200161012d565b3480156101fb57600080fd5b5061010461020a366004610b6a565b610716565b34801561021b57600080fd5b5061010461022a366004610bd0565b610879565b34801561023b57600080fd5b5061017561024a366004610be9565b60036020526000908152604090205481565b34801561026857600080fd5b50610104610277366004610b6a565b610886565b34801561028857600080fd5b50610120610894565b34801561029d57600080fd5b506101566102ac366004610b6a565b6108a1565b3480156102bd57600080fd5b506002546102d69061010090046001600160a01b031681565b6040516001600160a01b03909116815260200161012d565b61010461032e565b34801561030257600080fd5b50610175610311366004610c04565b600460209081526000928352604080842090915290825290205481565b336000908152600360205260408120805434929061034d908490610c4d565b909155505060405134815233907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a2565b6000805461039690610c60565b80601f01602080910402602001604051908101604052809291908181526020018280546103c290610c60565b801561040f5780601f106103e45761010080835404028352916020019161040f565b820191906000526020600020905b8154815290600101906020018083116103f257829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906104729086815260200190565b60405180910390a35060015b92915050565b6001600160a01b0383166000908152600360205260408120548211156104f15760405162461bcd60e51b815260206004820152601860248201527f73726320696e73756666696369656e742062616c616e6365000000000000000060448201526064015b60405180910390fd5b6001600160a01b038416331480159061052f57506001600160a01b038416600090815260046020908152604080832033845290915290205460001914155b156105d9576001600160a01b03841660009081526004602090815260408083203384529091529020548211156105a05760405162461bcd60e51b8152602060048201526016602482015275696e73756666696369656e7420616c6c6f77616e636560501b60448201526064016104e8565b6001600160a01b0384166000908152600460209081526040808320338452909152812080548492906105d3908490610c9a565b90915550505b6001600160a01b03841660009081526003602052604081208054849290610601908490610c9a565b90915550506001600160a01b0383166000908152600360205260408120805484929061062e908490610c4d565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161067a91815260200190565b60405180910390a35060019392505050565b33600090815260036020526040812080548392906106ab908490610c9a565b9091555050604051339082156108fc029083906000818181858888f193505050501580156106dd573d6000803e3d6000fd5b5060405181815233907f7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b659060200160405180910390a250565b6002546040513360248201526044810183905260009161010090046001600160a01b03169060640160408051601f198184030181529181526020820180516001600160e01b03166340c10f1960e01b179052516107739190610cad565b6000604051808303816000865af19150503d80600081146107b0576040519150601f19603f3d011682016040523d82523d6000602084013e6107b5565b606091505b50509050806108065760405162461bcd60e51b815260206004820152601d60248201527f7772617070656420613067692062617365206d696e74206661696c656400000060448201526064016104e8565b6001600160a01b0383166000908152600360205260408120805484929061082e908490610c4d565b90915550506040518281526001600160a01b0384169033907fab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8906020015b60405180910390a3505050565b61088333826108b5565b50565b61089082826108b5565b5050565b6001805461039690610c60565b60006108ae338484610484565b9392505050565b6002546040513360248201526044810183905260009161010090046001600160a01b03169060640160408051601f198184030181529181526020820180516001600160e01b0316632770a7eb60e21b179052516109129190610cad565b6000604051808303816000865af19150503d806000811461094f576040519150601f19603f3d011682016040523d82523d6000602084013e610954565b606091505b50509050806109a55760405162461bcd60e51b815260206004820152601d60248201527f7772617070656420613067692062617365206275726e206661696c656400000060448201526064016104e8565b6001600160a01b03831633148015906109e357506001600160a01b038316600090815260046020908152604080832033845290915290205460001914155b15610a8d576001600160a01b0383166000908152600460209081526040808320338452909152902054821115610a545760405162461bcd60e51b8152602060048201526016602482015275696e73756666696369656e7420616c6c6f77616e636560501b60448201526064016104e8565b6001600160a01b038316600090815260046020908152604080832033845290915281208054849290610a87908490610c9a565b90915550505b6001600160a01b03831660009081526003602052604081208054849290610ab5908490610c9a565b90915550506040518281526001600160a01b0384169033907fbac40739b0d4ca32fa2d82fc91630465ba3eddd1598da6fca393b26fb63b94539060200161086c565b60005b83811015610b12578181015183820152602001610afa565b50506000910152565b6020815260008251806020840152610b3a816040850160208701610af7565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114610b6557600080fd5b919050565b60008060408385031215610b7d57600080fd5b610b8683610b4e565b946020939093013593505050565b600080600060608486031215610ba957600080fd5b610bb284610b4e565b9250610bc060208501610b4e565b9150604084013590509250925092565b600060208284031215610be257600080fd5b5035919050565b600060208284031215610bfb57600080fd5b6108ae82610b4e565b60008060408385031215610c1757600080fd5b610c2083610b4e565b9150610c2e60208401610b4e565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047e5761047e610c37565b600181811c90821680610c7457607f821691505b602082108103610c9457634e487b7160e01b600052602260045260246000fd5b50919050565b8181038181111561047e5761047e610c37565b60008251610cbf818460208701610af7565b919091019291505056fea2646970667358221220e46d4016267b105c34d4679646e09d6fb451927a4dd464e4ebe1563577af02a664736f6c634300081400331ba0fbd8c503ac7ff82ea302cdc5d6a7195281eaa99017a6a363e36fba073028ba42a037a49fedf5460e3d33776233d88dfb242ddaf9bb5d4cb6688aa290ead65a93c7 + DEFAULT_WRAPPED_A0GI = "0x1cd0690ff9a693f5ef2dd976660a8dafc81a109c" ) // NewGenesisState returns a new genesis state object for the module. diff --git a/x/wrapped-a0gi-base/types/msg.go b/x/wrapped-a0gi-base/types/msg.go index 6d6b4a00..437c1058 100644 --- a/x/wrapped-a0gi-base/types/msg.go +++ b/x/wrapped-a0gi-base/types/msg.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var _, _, _, _ sdk.Msg = &MsgSetWA0GI{}, &MsgSetMintCap{}, &MsgMint{}, &MsgBurn{} +var _, _, _, _ sdk.Msg = &MsgSetWA0GI{}, &MsgSetMinterCap{}, &MsgMint{}, &MsgBurn{} func (msg *MsgSetWA0GI) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.Authority) @@ -24,12 +24,12 @@ func (msg MsgSetWA0GI) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) } -func (msg *MsgSetMintCap) GetSigners() []sdk.AccAddress { +func (msg *MsgSetMinterCap) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(msg.Authority) return []sdk.AccAddress{addr} } -func (msg *MsgSetMintCap) ValidateBasic() error { +func (msg *MsgSetMinterCap) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { return errorsmod.Wrap(err, "authority") } @@ -37,7 +37,7 @@ func (msg *MsgSetMintCap) ValidateBasic() error { return nil } -func (msg MsgSetMintCap) GetSignBytes() []byte { +func (msg MsgSetMinterCap) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) } diff --git a/x/wrapped-a0gi-base/types/tx.pb.go b/x/wrapped-a0gi-base/types/tx.pb.go index 122627dc..87358084 100644 --- a/x/wrapped-a0gi-base/types/tx.pb.go +++ b/x/wrapped-a0gi-base/types/tx.pb.go @@ -104,24 +104,24 @@ func (m *MsgSetWA0GIResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetWA0GIResponse proto.InternalMessageInfo -type MsgSetMintCap struct { +type MsgSetMinterCap struct { Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` Minter []byte `protobuf:"bytes,2,opt,name=minter,proto3" json:"minter,omitempty"` Cap []byte `protobuf:"bytes,3,opt,name=cap,proto3" json:"cap,omitempty"` } -func (m *MsgSetMintCap) Reset() { *m = MsgSetMintCap{} } -func (m *MsgSetMintCap) String() string { return proto.CompactTextString(m) } -func (*MsgSetMintCap) ProtoMessage() {} -func (*MsgSetMintCap) Descriptor() ([]byte, []int) { +func (m *MsgSetMinterCap) Reset() { *m = MsgSetMinterCap{} } +func (m *MsgSetMinterCap) String() string { return proto.CompactTextString(m) } +func (*MsgSetMinterCap) ProtoMessage() {} +func (*MsgSetMinterCap) Descriptor() ([]byte, []int) { return fileDescriptor_f80bf93a1fc022d3, []int{2} } -func (m *MsgSetMintCap) XXX_Unmarshal(b []byte) error { +func (m *MsgSetMinterCap) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetMintCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSetMinterCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetMintCap.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSetMinterCap.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -131,33 +131,33 @@ func (m *MsgSetMintCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } -func (m *MsgSetMintCap) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetMintCap.Merge(m, src) +func (m *MsgSetMinterCap) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMinterCap.Merge(m, src) } -func (m *MsgSetMintCap) XXX_Size() int { +func (m *MsgSetMinterCap) XXX_Size() int { return m.Size() } -func (m *MsgSetMintCap) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetMintCap.DiscardUnknown(m) +func (m *MsgSetMinterCap) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMinterCap.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetMintCap proto.InternalMessageInfo +var xxx_messageInfo_MsgSetMinterCap proto.InternalMessageInfo -type MsgSetMintCapResponse struct { +type MsgSetMinterCapResponse struct { } -func (m *MsgSetMintCapResponse) Reset() { *m = MsgSetMintCapResponse{} } -func (m *MsgSetMintCapResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetMintCapResponse) ProtoMessage() {} -func (*MsgSetMintCapResponse) Descriptor() ([]byte, []int) { +func (m *MsgSetMinterCapResponse) Reset() { *m = MsgSetMinterCapResponse{} } +func (m *MsgSetMinterCapResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetMinterCapResponse) ProtoMessage() {} +func (*MsgSetMinterCapResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f80bf93a1fc022d3, []int{3} } -func (m *MsgSetMintCapResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgSetMinterCapResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetMintCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSetMinterCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetMintCapResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSetMinterCapResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -167,17 +167,17 @@ func (m *MsgSetMintCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgSetMintCapResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetMintCapResponse.Merge(m, src) +func (m *MsgSetMinterCapResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetMinterCapResponse.Merge(m, src) } -func (m *MsgSetMintCapResponse) XXX_Size() int { +func (m *MsgSetMinterCapResponse) XXX_Size() int { return m.Size() } -func (m *MsgSetMintCapResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetMintCapResponse.DiscardUnknown(m) +func (m *MsgSetMinterCapResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetMinterCapResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetMintCapResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgSetMinterCapResponse proto.InternalMessageInfo type MsgMint struct { Minter []byte `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter,omitempty"` @@ -330,8 +330,8 @@ var xxx_messageInfo_MsgBurnResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgSetWA0GI)(nil), "zgc.wrappeda0gibase.MsgSetWA0GI") proto.RegisterType((*MsgSetWA0GIResponse)(nil), "zgc.wrappeda0gibase.MsgSetWA0GIResponse") - proto.RegisterType((*MsgSetMintCap)(nil), "zgc.wrappeda0gibase.MsgSetMintCap") - proto.RegisterType((*MsgSetMintCapResponse)(nil), "zgc.wrappeda0gibase.MsgSetMintCapResponse") + proto.RegisterType((*MsgSetMinterCap)(nil), "zgc.wrappeda0gibase.MsgSetMinterCap") + proto.RegisterType((*MsgSetMinterCapResponse)(nil), "zgc.wrappeda0gibase.MsgSetMinterCapResponse") proto.RegisterType((*MsgMint)(nil), "zgc.wrappeda0gibase.MsgMint") proto.RegisterType((*MsgMintResponse)(nil), "zgc.wrappeda0gibase.MsgMintResponse") proto.RegisterType((*MsgBurn)(nil), "zgc.wrappeda0gibase.MsgBurn") @@ -341,34 +341,34 @@ func init() { func init() { proto.RegisterFile("zgc/wrappeda0gibase/tx.proto", fileDescriptor_f80bf93a1fc022d3) } var fileDescriptor_f80bf93a1fc022d3 = []byte{ - // 421 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4f, 0xab, 0xd3, 0x40, - 0x14, 0xc5, 0x93, 0x57, 0xe9, 0xf3, 0x5d, 0x2b, 0x6a, 0x6a, 0x6b, 0x1a, 0x4a, 0x28, 0xc1, 0x45, - 0x11, 0x9a, 0x09, 0xea, 0xc6, 0xa5, 0x15, 0x11, 0x85, 0x6c, 0x22, 0x58, 0x70, 0xa1, 0x4c, 0xd2, - 0x71, 0x1a, 0x68, 0x32, 0x21, 0x33, 0xc1, 0xb6, 0x9f, 0xc2, 0x8f, 0xd5, 0x65, 0x37, 0x82, 0x4b, - 0x6d, 0xbf, 0x88, 0x4c, 0xfe, 0xd4, 0xb4, 0xd8, 0x16, 0xde, 0x2e, 0xe7, 0x9c, 0x7b, 0x7f, 0x03, - 0x27, 0x5c, 0xe8, 0xaf, 0x68, 0x80, 0xbe, 0xa7, 0x38, 0x49, 0xc8, 0x14, 0x3b, 0x34, 0xf4, 0x31, - 0x27, 0x48, 0x2c, 0xec, 0x24, 0x65, 0x82, 0x69, 0xed, 0x15, 0x0d, 0xec, 0xa3, 0xd4, 0xe8, 0x05, - 0x8c, 0x47, 0x8c, 0x7f, 0xcd, 0x47, 0x50, 0x21, 0x8a, 0x79, 0xe3, 0x31, 0x65, 0x94, 0x15, 0xbe, - 0xfc, 0x2a, 0xdd, 0x1e, 0x65, 0x8c, 0xce, 0x09, 0xca, 0x95, 0x9f, 0x7d, 0x43, 0x38, 0x5e, 0x16, - 0x91, 0xf5, 0x16, 0xee, 0xb9, 0x9c, 0x7e, 0x24, 0x62, 0xf2, 0xda, 0x79, 0xf7, 0x5e, 0xeb, 0xc3, - 0x0d, 0xce, 0xc4, 0x8c, 0xa5, 0xa1, 0x58, 0xea, 0xea, 0x40, 0x1d, 0xde, 0x78, 0xff, 0x0c, 0x4d, - 0x87, 0x6b, 0x3c, 0x9d, 0xa6, 0x84, 0x73, 0xfd, 0x6a, 0xa0, 0x0e, 0x5b, 0x5e, 0x25, 0xad, 0x0e, - 0xb4, 0x6b, 0x18, 0x8f, 0xf0, 0x84, 0xc5, 0x9c, 0x58, 0x13, 0xb8, 0x5f, 0xd8, 0x6e, 0x18, 0x8b, - 0x37, 0x38, 0xb9, 0xc0, 0xef, 0x42, 0x33, 0x0a, 0x63, 0x41, 0xd2, 0x12, 0x5f, 0x2a, 0xed, 0x21, - 0x34, 0x02, 0x9c, 0xe8, 0x8d, 0xdc, 0x94, 0x9f, 0xd6, 0x13, 0xe8, 0x1c, 0x80, 0xf7, 0x2f, 0xbe, - 0x82, 0x6b, 0x97, 0x53, 0xe9, 0xd6, 0x68, 0xea, 0x01, 0xad, 0x0b, 0x4d, 0x1c, 0xb1, 0x2c, 0x16, - 0xd5, 0x2b, 0x85, 0xb2, 0x1e, 0xc1, 0x83, 0x72, 0xf5, 0x88, 0x36, 0xce, 0xd2, 0xf8, 0x96, 0x34, - 0xb9, 0x5a, 0xd1, 0x9e, 0xff, 0xbc, 0x82, 0x86, 0xcb, 0xa9, 0xf6, 0x09, 0xee, 0xee, 0x0b, 0x1f, - 0xd8, 0xff, 0xf9, 0xc3, 0x76, 0xad, 0x4b, 0x63, 0x78, 0x69, 0xa2, 0xe2, 0x6b, 0x5f, 0xa0, 0x55, - 0x36, 0x42, 0x52, 0x59, 0xb6, 0x75, 0x66, 0xb3, 0xec, 0xcd, 0x78, 0x76, 0x79, 0x66, 0xcf, 0xff, - 0x00, 0x77, 0xf2, 0x62, 0xfb, 0xa7, 0x76, 0x64, 0x6a, 0x3c, 0x3d, 0x97, 0xd6, 0x59, 0x79, 0xad, - 0x27, 0x59, 0x32, 0x3d, 0xcd, 0xaa, 0xf7, 0x3a, 0xf6, 0xd6, 0x7f, 0x4c, 0x65, 0xbd, 0x35, 0xd5, - 0xcd, 0xd6, 0x54, 0x7f, 0x6f, 0x4d, 0xf5, 0xc7, 0xce, 0x54, 0x36, 0x3b, 0x53, 0xf9, 0xb5, 0x33, - 0x95, 0xcf, 0x2f, 0x69, 0x28, 0x66, 0x99, 0x6f, 0x07, 0x2c, 0x42, 0x0e, 0x9d, 0x63, 0x9f, 0x23, - 0x87, 0x8e, 0x82, 0x19, 0x0e, 0x63, 0xb4, 0xa8, 0x2e, 0x6f, 0x24, 0xe1, 0xa3, 0xe2, 0xf6, 0x96, - 0x09, 0xe1, 0x7e, 0x33, 0x3f, 0x8f, 0x17, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x43, 0x23, - 0x4d, 0x9f, 0x03, 0x00, 0x00, + // 419 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xc1, 0xae, 0xd2, 0x40, + 0x14, 0x86, 0x5b, 0x30, 0x20, 0x23, 0x89, 0x5a, 0x14, 0x4b, 0x43, 0x1a, 0xd2, 0xb0, 0x60, 0x21, + 0x9d, 0x46, 0xdd, 0xb8, 0x14, 0x63, 0x8c, 0x26, 0xdd, 0xd4, 0x44, 0xa3, 0x1b, 0x33, 0x2d, 0xe3, + 0xd0, 0x84, 0x76, 0x9a, 0xce, 0x34, 0x02, 0x4f, 0xe1, 0x63, 0xb1, 0x64, 0xa9, 0x3b, 0x2f, 0xbc, + 0xc8, 0xcd, 0x4c, 0x69, 0x6f, 0x21, 0x17, 0xb8, 0xb9, 0xbb, 0x39, 0xff, 0xf9, 0xcf, 0x77, 0x9a, + 0xbf, 0x39, 0xa0, 0xbf, 0x22, 0x01, 0xfc, 0x9d, 0xa2, 0x24, 0xc1, 0x53, 0xe4, 0x90, 0xd0, 0x47, + 0x0c, 0x43, 0xbe, 0xb0, 0x93, 0x94, 0x72, 0xaa, 0x75, 0x56, 0x24, 0xb0, 0x8f, 0xba, 0x46, 0x2f, + 0xa0, 0x2c, 0xa2, 0xec, 0xa7, 0xb4, 0xc0, 0xbc, 0xc8, 0xfd, 0xc6, 0x33, 0x42, 0x09, 0xcd, 0x75, + 0xf1, 0xda, 0xab, 0x3d, 0x42, 0x29, 0x99, 0x63, 0x28, 0x2b, 0x3f, 0xfb, 0x05, 0x51, 0xbc, 0xcc, + 0x5b, 0xd6, 0x07, 0xf0, 0xc8, 0x65, 0xe4, 0x0b, 0xe6, 0xdf, 0xde, 0x39, 0x1f, 0x3f, 0x69, 0x7d, + 0xd0, 0x42, 0x19, 0x9f, 0xd1, 0x34, 0xe4, 0x4b, 0x5d, 0x1d, 0xa8, 0xa3, 0x96, 0x77, 0x23, 0x68, + 0x3a, 0x68, 0xa2, 0xe9, 0x34, 0xc5, 0x8c, 0xe9, 0xb5, 0x81, 0x3a, 0x6a, 0x7b, 0x45, 0x69, 0x3d, + 0x07, 0x9d, 0x0a, 0xc6, 0xc3, 0x2c, 0xa1, 0x31, 0xc3, 0xd6, 0x77, 0xf0, 0x38, 0x97, 0xdd, 0x30, + 0xe6, 0x38, 0x7d, 0x8f, 0x92, 0x0b, 0x1b, 0xba, 0xa0, 0x11, 0x49, 0xeb, 0x7e, 0xc1, 0xbe, 0xd2, + 0x9e, 0x80, 0x7a, 0x80, 0x12, 0xbd, 0x2e, 0x45, 0xf1, 0xb4, 0x7a, 0xe0, 0xc5, 0x11, 0xba, 0xdc, + 0xfa, 0x16, 0x34, 0x5d, 0x46, 0x84, 0x5e, 0xe1, 0xa9, 0x07, 0xbc, 0x2e, 0x68, 0xa0, 0x88, 0x66, + 0x31, 0x2f, 0xf6, 0xe4, 0x95, 0xf5, 0x54, 0x7e, 0xb0, 0x18, 0x3d, 0xa2, 0x4d, 0xb2, 0x34, 0xbe, + 0x27, 0x4d, 0x8c, 0x16, 0xb4, 0x57, 0xff, 0x6a, 0xa0, 0xee, 0x32, 0xa2, 0x7d, 0x05, 0x0f, 0xcb, + 0xd0, 0x07, 0xf6, 0x2d, 0x7f, 0xd9, 0xae, 0xe4, 0x69, 0x8c, 0x2e, 0x39, 0x0a, 0xbe, 0xe6, 0x83, + 0xf6, 0x41, 0xdc, 0xc3, 0x33, 0x93, 0xa5, 0xcb, 0x78, 0x79, 0x17, 0x57, 0xb9, 0xe3, 0x33, 0x78, + 0x20, 0xc3, 0xed, 0x9f, 0x9a, 0x12, 0x5d, 0x63, 0x78, 0xae, 0x5b, 0x65, 0xc9, 0x68, 0x4f, 0xb2, + 0x44, 0xf7, 0x34, 0xab, 0x9a, 0xed, 0xc4, 0x5b, 0x5f, 0x99, 0xca, 0x7a, 0x6b, 0xaa, 0x9b, 0xad, + 0xa9, 0xfe, 0xdf, 0x9a, 0xea, 0x9f, 0x9d, 0xa9, 0x6c, 0x76, 0xa6, 0xf2, 0x77, 0x67, 0x2a, 0x3f, + 0xde, 0x90, 0x90, 0xcf, 0x32, 0xdf, 0x0e, 0x68, 0x04, 0x1d, 0x32, 0x47, 0x3e, 0x83, 0x0e, 0x19, + 0x07, 0x33, 0x14, 0xc6, 0x70, 0x51, 0x5c, 0xe0, 0x58, 0xc0, 0xc7, 0xf9, 0x0d, 0x2e, 0x13, 0xcc, + 0xfc, 0x86, 0x3c, 0x93, 0xd7, 0xd7, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x07, 0x50, 0x07, 0xa7, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -384,7 +384,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { SetWA0GI(ctx context.Context, in *MsgSetWA0GI, opts ...grpc.CallOption) (*MsgSetWA0GIResponse, error) - SetMinterCap(ctx context.Context, in *MsgSetMintCap, opts ...grpc.CallOption) (*MsgSetMintCapResponse, error) + SetMinterCap(ctx context.Context, in *MsgSetMinterCap, opts ...grpc.CallOption) (*MsgSetMinterCapResponse, error) Mint(ctx context.Context, in *MsgMint, opts ...grpc.CallOption) (*MsgMintResponse, error) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOption) (*MsgBurnResponse, error) } @@ -406,8 +406,8 @@ func (c *msgClient) SetWA0GI(ctx context.Context, in *MsgSetWA0GI, opts ...grpc. return out, nil } -func (c *msgClient) SetMinterCap(ctx context.Context, in *MsgSetMintCap, opts ...grpc.CallOption) (*MsgSetMintCapResponse, error) { - out := new(MsgSetMintCapResponse) +func (c *msgClient) SetMinterCap(ctx context.Context, in *MsgSetMinterCap, opts ...grpc.CallOption) (*MsgSetMinterCapResponse, error) { + out := new(MsgSetMinterCapResponse) err := c.cc.Invoke(ctx, "/zgc.wrappeda0gibase.Msg/SetMinterCap", in, out, opts...) if err != nil { return nil, err @@ -436,7 +436,7 @@ func (c *msgClient) Burn(ctx context.Context, in *MsgBurn, opts ...grpc.CallOpti // MsgServer is the server API for Msg service. type MsgServer interface { SetWA0GI(context.Context, *MsgSetWA0GI) (*MsgSetWA0GIResponse, error) - SetMinterCap(context.Context, *MsgSetMintCap) (*MsgSetMintCapResponse, error) + SetMinterCap(context.Context, *MsgSetMinterCap) (*MsgSetMinterCapResponse, error) Mint(context.Context, *MsgMint) (*MsgMintResponse, error) Burn(context.Context, *MsgBurn) (*MsgBurnResponse, error) } @@ -448,7 +448,7 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) SetWA0GI(ctx context.Context, req *MsgSetWA0GI) (*MsgSetWA0GIResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetWA0GI not implemented") } -func (*UnimplementedMsgServer) SetMinterCap(ctx context.Context, req *MsgSetMintCap) (*MsgSetMintCapResponse, error) { +func (*UnimplementedMsgServer) SetMinterCap(ctx context.Context, req *MsgSetMinterCap) (*MsgSetMinterCapResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetMinterCap not implemented") } func (*UnimplementedMsgServer) Mint(ctx context.Context, req *MsgMint) (*MsgMintResponse, error) { @@ -481,7 +481,7 @@ func _Msg_SetWA0GI_Handler(srv interface{}, ctx context.Context, dec func(interf } func _Msg_SetMinterCap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetMintCap) + in := new(MsgSetMinterCap) if err := dec(in); err != nil { return nil, err } @@ -493,7 +493,7 @@ func _Msg_SetMinterCap_Handler(srv interface{}, ctx context.Context, dec func(in FullMethod: "/zgc.wrappeda0gibase.Msg/SetMinterCap", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetMinterCap(ctx, req.(*MsgSetMintCap)) + return srv.(MsgServer).SetMinterCap(ctx, req.(*MsgSetMinterCap)) } return interceptor(ctx, in, info, handler) } @@ -619,7 +619,7 @@ func (m *MsgSetWA0GIResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgSetMintCap) Marshal() (dAtA []byte, err error) { +func (m *MsgSetMinterCap) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -629,12 +629,12 @@ func (m *MsgSetMintCap) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetMintCap) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetMinterCap) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetMintCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetMinterCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -663,7 +663,7 @@ func (m *MsgSetMintCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgSetMintCapResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSetMinterCapResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -673,12 +673,12 @@ func (m *MsgSetMintCapResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetMintCapResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetMinterCapResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetMintCapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetMinterCapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -843,7 +843,7 @@ func (m *MsgSetWA0GIResponse) Size() (n int) { return n } -func (m *MsgSetMintCap) Size() (n int) { +func (m *MsgSetMinterCap) Size() (n int) { if m == nil { return 0 } @@ -864,7 +864,7 @@ func (m *MsgSetMintCap) Size() (n int) { return n } -func (m *MsgSetMintCapResponse) Size() (n int) { +func (m *MsgSetMinterCapResponse) Size() (n int) { if m == nil { return 0 } @@ -1097,7 +1097,7 @@ func (m *MsgSetWA0GIResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetMintCap) Unmarshal(dAtA []byte) error { +func (m *MsgSetMinterCap) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1120,10 +1120,10 @@ func (m *MsgSetMintCap) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetMintCap: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetMinterCap: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetMintCap: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetMinterCap: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1247,7 +1247,7 @@ func (m *MsgSetMintCap) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetMintCapResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSetMinterCapResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1270,10 +1270,10 @@ func (m *MsgSetMintCapResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetMintCapResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetMinterCapResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetMintCapResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetMinterCapResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From db1d6463ec4fd18de980181af041edd425d68bea Mon Sep 17 00:00:00 2001 From: MiniFrenchBread <103425574+MiniFrenchBread@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:10:54 +0800 Subject: [PATCH 10/10] revert third party protos --- .../proto/cosmos/auth/v1beta1/auth.proto | 4 +- .../proto/cosmos/bank/v1beta1/bank.proto | 2 +- .../cosmos/base/store/v1beta1/listening.proto | 22 +++--- .../cosmos/distribution/v1beta1/tx.proto | 4 +- .../cosmos/evidence/v1beta1/evidence.proto | 6 +- .../proto/cosmos/evidence/v1beta1/tx.proto | 2 +- third_party/proto/cosmos/gov/v1/gov.proto | 30 ++++---- third_party/proto/cosmos/gov/v1/tx.proto | 24 +++---- .../proto/cosmos/gov/v1beta1/gov.proto | 18 ++--- third_party/proto/cosmos/gov/v1beta1/tx.proto | 16 ++--- .../proto/cosmos/mint/v1beta1/mint.proto | 27 +------- third_party/proto/cosmos/tx/v1beta1/tx.proto | 6 +- .../cosmos/upgrade/v1beta1/upgrade.proto | 6 +- .../proto/cosmos/vesting/v1beta1/tx.proto | 4 +- .../cosmos/vesting/v1beta1/vesting.proto | 2 +- third_party/proto/ethermint/evm/v1/evm.proto | 19 ++++-- .../applications/transfer/v1/transfer.proto | 4 +- third_party/proto/tendermint/abci/types.proto | 68 +++++++++---------- .../proto/tendermint/types/evidence.proto | 2 +- .../proto/tendermint/types/params.proto | 2 +- .../proto/tendermint/types/types.proto | 28 ++++---- 21 files changed, 139 insertions(+), 157 deletions(-) diff --git a/third_party/proto/cosmos/auth/v1beta1/auth.proto b/third_party/proto/cosmos/auth/v1beta1/auth.proto index f09df382..0578453c 100644 --- a/third_party/proto/cosmos/auth/v1beta1/auth.proto +++ b/third_party/proto/cosmos/auth/v1beta1/auth.proto @@ -17,8 +17,8 @@ message BaseAccount { option (gogoproto.equal) = false; option (cosmos_proto.implements_interface) = "cosmos.auth.v1beta1.AccountI"; - string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"]; + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (amino.field_name) = "public_key"]; uint64 account_number = 3; uint64 sequence = 4; } diff --git a/third_party/proto/cosmos/bank/v1beta1/bank.proto b/third_party/proto/cosmos/bank/v1beta1/bank.proto index f81bb923..483540db 100644 --- a/third_party/proto/cosmos/bank/v1beta1/bank.proto +++ b/third_party/proto/cosmos/bank/v1beta1/bank.proto @@ -98,7 +98,7 @@ message Metadata { string description = 1; // denom_units represents the list of DenomUnit's for a given coin repeated DenomUnit denom_units = 2; - // base represents the base denom (should be the DenomUnit with exponent = 0). + // base represents the evm denom (should be the DenomUnit with exponent = 0). string base = 3; // display indicates the suggested denom that should be // displayed in clients. diff --git a/third_party/proto/cosmos/base/store/v1beta1/listening.proto b/third_party/proto/cosmos/base/store/v1beta1/listening.proto index d6f71289..753f7c16 100644 --- a/third_party/proto/cosmos/base/store/v1beta1/listening.proto +++ b/third_party/proto/cosmos/base/store/v1beta1/listening.proto @@ -20,15 +20,15 @@ message StoreKVPair { // BlockMetadata contains all the abci event data of a block // the file streamer dump them into files together with the state changes. message BlockMetadata { - // DeliverTx encapulate deliver tx request and response. - message DeliverTx { - tendermint.abci.RequestDeliverTx request = 1; - tendermint.abci.ResponseDeliverTx response = 2; - } - tendermint.abci.RequestBeginBlock request_begin_block = 1; - tendermint.abci.ResponseBeginBlock response_begin_block = 2; - repeated DeliverTx deliver_txs = 3; - tendermint.abci.RequestEndBlock request_end_block = 4; - tendermint.abci.ResponseEndBlock response_end_block = 5; - tendermint.abci.ResponseCommit response_commit = 6; + // DeliverTx encapulate deliver tx request and response. + message DeliverTx { + tendermint.abci.RequestDeliverTx request = 1; + tendermint.abci.ResponseDeliverTx response = 2; + } + tendermint.abci.RequestBeginBlock request_begin_block = 1; + tendermint.abci.ResponseBeginBlock response_begin_block = 2; + repeated DeliverTx deliver_txs = 3; + tendermint.abci.RequestEndBlock request_end_block = 4; + tendermint.abci.ResponseEndBlock response_end_block = 5; + tendermint.abci.ResponseCommit response_commit = 6; } diff --git a/third_party/proto/cosmos/distribution/v1beta1/tx.proto b/third_party/proto/cosmos/distribution/v1beta1/tx.proto index b921879a..957747cf 100644 --- a/third_party/proto/cosmos/distribution/v1beta1/tx.proto +++ b/third_party/proto/cosmos/distribution/v1beta1/tx.proto @@ -162,8 +162,8 @@ message MsgCommunityPoolSpend { option (amino.name) = "cosmos-sdk/distr/MsgCommunityPoolSpend"; // authority is the address that controls the module (defaults to x/gov unless overwritten). - string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string recipient = 2; + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string recipient = 2; repeated cosmos.base.v1beta1.Coin amount = 3 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true, diff --git a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto index 195be98b..8dca3201 100644 --- a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto +++ b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto @@ -18,14 +18,14 @@ message Equivocation { option (gogoproto.equal) = false; // height is the equivocation height. - int64 height = 1; + int64 height = 1; // time is the equivocation time. - google.protobuf.Timestamp time = 2 + google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true, (gogoproto.stdtime) = true]; // power is the equivocation validator power. - int64 power = 3; + int64 power = 3; // consensus_address is the equivocation validator consensus address. string consensus_address = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; diff --git a/third_party/proto/cosmos/evidence/v1beta1/tx.proto b/third_party/proto/cosmos/evidence/v1beta1/tx.proto index e6fe5c45..f5646e2d 100644 --- a/third_party/proto/cosmos/evidence/v1beta1/tx.proto +++ b/third_party/proto/cosmos/evidence/v1beta1/tx.proto @@ -29,7 +29,7 @@ message MsgSubmitEvidence { option (gogoproto.goproto_getters) = false; // submitter is the signer account address of evidence. - string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string submitter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // evidence defines the evidence of misbehavior. google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "cosmos.evidence.v1beta1.Evidence"]; diff --git a/third_party/proto/cosmos/gov/v1/gov.proto b/third_party/proto/cosmos/gov/v1/gov.proto index 491b0d29..49bfcc26 100644 --- a/third_party/proto/cosmos/gov/v1/gov.proto +++ b/third_party/proto/cosmos/gov/v1/gov.proto @@ -32,17 +32,17 @@ message WeightedVoteOption { VoteOption option = 1; // weight is the vote weight associated with the vote option. - string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"]; + string weight = 2 [(cosmos_proto.scalar) = "cosmos.Dec"]; } // Deposit defines an amount deposited by an account address to an active // proposal. message Deposit { // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; @@ -51,33 +51,33 @@ message Deposit { // Proposal defines the core field members of a governance proposal. message Proposal { // id defines the unique id of the proposal. - uint64 id = 1; + uint64 id = 1; // messages are the arbitrary messages to be executed if the proposal passes. repeated google.protobuf.Any messages = 2; // status defines the proposal status. - ProposalStatus status = 3; + ProposalStatus status = 3; // final_tally_result is the final tally result of the proposal. When // querying a proposal via gRPC, this field is not populated until the // proposal's voting period has ended. - TallyResult final_tally_result = 4; + TallyResult final_tally_result = 4; // submit_time is the time of proposal submission. - google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true]; // deposit_end_time is the end time for deposition. - google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp deposit_end_time = 6 [(gogoproto.stdtime) = true]; // total_deposit is the total deposit on the proposal. - repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated cosmos.base.v1beta1.Coin total_deposit = 7 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // voting_start_time is the starting time to vote on a proposal. - google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp voting_start_time = 8 [(gogoproto.stdtime) = true]; // voting_end_time is the end time of voting on a proposal. - google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true]; + google.protobuf.Timestamp voting_end_time = 9 [(gogoproto.stdtime) = true]; // metadata is any arbitrary metadata attached to the proposal. string metadata = 10; @@ -122,11 +122,11 @@ enum ProposalStatus { // TallyResult defines a standard tally for a governance proposal. message TallyResult { // yes_count is the number of yes votes on a proposal. - string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"]; + string yes_count = 1 [(cosmos_proto.scalar) = "cosmos.Int"]; // abstain_count is the number of abstain votes on a proposal. - string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"]; + string abstain_count = 2 [(cosmos_proto.scalar) = "cosmos.Int"]; // no_count is the number of no votes on a proposal. - string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"]; + string no_count = 3 [(cosmos_proto.scalar) = "cosmos.Int"]; // no_with_veto_count is the number of no with veto votes on a proposal. string no_with_veto_count = 4 [(cosmos_proto.scalar) = "cosmos.Int"]; } @@ -138,7 +138,7 @@ message Vote { uint64 proposal_id = 1; // voter is the voter address of the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; reserved 3; diff --git a/third_party/proto/cosmos/gov/v1/tx.proto b/third_party/proto/cosmos/gov/v1/tx.proto index 0cac6558..1708066c 100644 --- a/third_party/proto/cosmos/gov/v1/tx.proto +++ b/third_party/proto/cosmos/gov/v1/tx.proto @@ -46,13 +46,13 @@ message MsgSubmitProposal { option (amino.name) = "cosmos-sdk/v1/MsgSubmitProposal"; // messages are the arbitrary messages to be executed if proposal passes. - repeated google.protobuf.Any messages = 1; + repeated google.protobuf.Any messages = 1; // initial_deposit is the deposit value that must be paid at proposal submission. repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // proposer is the account address of the proposer. - string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string proposer = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // metadata is any arbitrary metadata attached to the proposal. string metadata = 4; @@ -95,16 +95,16 @@ message MsgVote { option (amino.name) = "cosmos-sdk/v1/MsgVote"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // option defines the vote option. - VoteOption option = 3; + VoteOption option = 3; // metadata is any arbitrary metadata attached to the Vote. - string metadata = 4; + string metadata = 4; } // MsgVoteResponse defines the Msg/Vote response type. @@ -116,16 +116,16 @@ message MsgVoteWeighted { option (amino.name) = "cosmos-sdk/v1/MsgVoteWeighted"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // options defines the weighted vote options. - repeated WeightedVoteOption options = 3; + repeated WeightedVoteOption options = 3; // metadata is any arbitrary metadata attached to the VoteWeighted. - string metadata = 4; + string metadata = 4; } // MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. @@ -137,10 +137,10 @@ message MsgDeposit { option (amino.name) = "cosmos-sdk/v1/MsgDeposit"; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; diff --git a/third_party/proto/cosmos/gov/v1beta1/gov.proto b/third_party/proto/cosmos/gov/v1beta1/gov.proto index b8996a4a..dc8fcfd3 100644 --- a/third_party/proto/cosmos/gov/v1beta1/gov.proto +++ b/third_party/proto/cosmos/gov/v1beta1/gov.proto @@ -39,7 +39,7 @@ message WeightedVoteOption { VoteOption option = 1; // weight is the vote weight associated with the vote option. - string weight = 2 [ + string weight = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false @@ -55,7 +55,7 @@ message TextProposal { option (gogoproto.equal) = true; // title of the proposal. - string title = 1; + string title = 1; // description associated with the proposal. string description = 2; @@ -68,10 +68,10 @@ message Deposit { option (gogoproto.equal) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [ @@ -86,20 +86,20 @@ message Proposal { option (gogoproto.equal) = true; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // content is the proposal's content. google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "cosmos.gov.v1beta1.Content"]; // status defines the proposal status. - ProposalStatus status = 3; + ProposalStatus status = 3; // final_tally_result is the final tally result of the proposal. When // querying a proposal via gRPC, this field is not populated until the // proposal's voting period has ended. - TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + TallyResult final_tally_result = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // submit_time is the time of proposal submission. - google.protobuf.Timestamp submit_time = 5 + google.protobuf.Timestamp submit_time = 5 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (amino.dont_omitempty) = true]; // deposit_end_time is the end time for deposition. @@ -188,7 +188,7 @@ message Vote { uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (amino.field_name) = "id", (amino.dont_omitempty) = true]; // voter is the voter address of the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // Deprecated: Prefer to use `options` instead. This field is set in queries // if and only if `len(options) == 1` and that option has weight 1. In all // other cases, this field will default to VOTE_OPTION_UNSPECIFIED. diff --git a/third_party/proto/cosmos/gov/v1beta1/tx.proto b/third_party/proto/cosmos/gov/v1beta1/tx.proto index a976137d..0afa1d56 100644 --- a/third_party/proto/cosmos/gov/v1beta1/tx.proto +++ b/third_party/proto/cosmos/gov/v1beta1/tx.proto @@ -71,13 +71,13 @@ message MsgVote { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1; + uint64 proposal_id = 1; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // option defines the vote option. - VoteOption option = 3; + VoteOption option = 3; } // MsgVoteResponse defines the Msg/Vote response type. @@ -96,13 +96,13 @@ message MsgVoteWeighted { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // voter is the voter address for the proposal. - string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string voter = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // options defines the weighted vote options. - repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated WeightedVoteOption options = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. @@ -121,10 +121,10 @@ message MsgDeposit { option (gogoproto.goproto_getters) = false; // proposal_id defines the unique id of the proposal. - uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (amino.dont_omitempty) = true]; // depositor defines the deposit addresses from the proposals. - string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string depositor = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // amount to be deposited by depositor. repeated cosmos.base.v1beta1.Coin amount = 3 [ diff --git a/third_party/proto/cosmos/mint/v1beta1/mint.proto b/third_party/proto/cosmos/mint/v1beta1/mint.proto index c9ea8f84..49b00a5d 100644 --- a/third_party/proto/cosmos/mint/v1beta1/mint.proto +++ b/third_party/proto/cosmos/mint/v1beta1/mint.proto @@ -55,30 +55,5 @@ message Params { (gogoproto.nullable) = false ]; // expected blocks per year - uint64 blocks_per_year = 6; - string max_staked_ratio = 7 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string apy_at_max_staked_ratio = 8 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string min_staked_ratio = 9 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string apy_at_min_staked_ratio = 10 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - string decay_rate = 11 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; + uint64 blocks_per_year = 6; } diff --git a/third_party/proto/cosmos/tx/v1beta1/tx.proto b/third_party/proto/cosmos/tx/v1beta1/tx.proto index a71a3e11..558b1da6 100644 --- a/third_party/proto/cosmos/tx/v1beta1/tx.proto +++ b/third_party/proto/cosmos/tx/v1beta1/tx.proto @@ -234,18 +234,18 @@ message Tip { string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; } -// AuxSignerData is the intermediary format that an auxiliary signer (e.g. a +// AuxSignerData is the intermediary format that an gas signer (e.g. a // tipper) builds and sends to the fee payer (who will build and broadcast the // actual tx). AuxSignerData is not a valid tx in itself, and will be rejected // by the node if sent directly as-is. // // Since: cosmos-sdk 0.46 message AuxSignerData { - // address is the bech32-encoded address of the auxiliary signer. If using + // address is the bech32-encoded address of the gas signer. If using // AuxSignerData across different chains, the bech32 prefix of the target // chain (where the final transaction is broadcasted) should be used. string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer + // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the gas signer // signs. Note: we use the same sign doc even if we're signing with // LEGACY_AMINO_JSON. SignDocDirectAux sign_doc = 2; diff --git a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto index 327ef5af..0a967168 100644 --- a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +++ b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -56,13 +56,13 @@ message SoftwareUpgradeProposal { option (gogoproto.goproto_stringer) = false; // title of the proposal - string title = 1; + string title = 1; // description of the proposal string description = 2; // plan of the proposal - Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + Plan plan = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software @@ -77,7 +77,7 @@ message CancelSoftwareUpgradeProposal { option (gogoproto.goproto_stringer) = false; // title of the proposal - string title = 1; + string title = 1; // description of the proposal string description = 2; diff --git a/third_party/proto/cosmos/vesting/v1beta1/tx.proto b/third_party/proto/cosmos/vesting/v1beta1/tx.proto index 30b726a6..42d3213f 100644 --- a/third_party/proto/cosmos/vesting/v1beta1/tx.proto +++ b/third_party/proto/cosmos/vesting/v1beta1/tx.proto @@ -86,8 +86,8 @@ message MsgCreatePeriodicVestingAccount { option (gogoproto.equal) = false; - string from_address = 1; - string to_address = 2; + string from_address = 1; + string to_address = 2; // start of vesting as unix time (in seconds). int64 start_time = 3; repeated Period vesting_periods = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; diff --git a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto index e772b186..7ab1fb79 100644 --- a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto +++ b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto @@ -44,7 +44,7 @@ message ContinuousVestingAccount { BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; // Vesting start time, as unix timestamp (in seconds). - int64 start_time = 2; + int64 start_time = 2; } // DelayedVestingAccount implements the VestingAccount interface. It vests all diff --git a/third_party/proto/ethermint/evm/v1/evm.proto b/third_party/proto/ethermint/evm/v1/evm.proto index 875619ff..43b3e7a5 100644 --- a/third_party/proto/ethermint/evm/v1/evm.proto +++ b/third_party/proto/ethermint/evm/v1/evm.proto @@ -18,12 +18,17 @@ message Params { repeated int64 extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.moretags) = "yaml:\"extra_eips\""]; // chain_config defines the EVM chain configuration parameters ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; - // list of allowed eip712 msgs and their types + // eip712_allowed_msgs contains list of allowed eip712 msgs and their types repeated EIP712AllowedMsg eip712_allowed_msgs = 6 [(gogoproto.customname) = "EIP712AllowedMsgs", (gogoproto.nullable) = false]; // allow_unprotected_txs defines if replay-protected (i.e non EIP155 // signed) transactions can be executed on the state machine. bool allow_unprotected_txs = 7; + // enabled_precompiles contains list of hex-encoded evm addresses of enabled precompiled contracts. + // Precompile must be registered before it can be enabled. + // enabled_precompiles should be sorted in ascending order and unique. + // sorting and uniqueness are checked against bytes representation of addresses + repeated string enabled_precompiles = 8; } // ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int values @@ -246,20 +251,20 @@ message TraceConfig { // EIP712AllowedMsg stores an allowed legacy msg and its eip712 type. message EIP712AllowedMsg { - // msg's proto type name. ie "/cosmos.bank.v1beta1.MsgSend" + // msg_type_url is a msg's proto type name. ie "/cosmos.bank.v1beta1.MsgSend" string msg_type_url = 1; - // name of the eip712 value type. ie "MsgValueSend" + // msg_value_type_name is a name of the eip712 value type. ie "MsgValueSend" string msg_value_type_name = 2; - // types of the msg value + // value_types is a list of msg value types repeated EIP712MsgAttrType value_types = 3 [(gogoproto.nullable) = false]; - // nested types of the msg value + // nested_types is a list of msg value nested types repeated EIP712NestedMsgType nested_types = 4 [(gogoproto.nullable) = false]; } -// EIP712MsgType is the eip712 type of a single message. +// EIP712NestedMsgType is the eip712 type of a single message. message EIP712NestedMsgType { // name of the nested type. ie "Fee", "Coin" string name = 1; @@ -270,6 +275,8 @@ message EIP712NestedMsgType { // EIP712MsgAttrType is the eip712 type of a single message attribute. message EIP712MsgAttrType { + // name string name = 1; + // type string type = 2; } diff --git a/third_party/proto/ibc/applications/transfer/v1/transfer.proto b/third_party/proto/ibc/applications/transfer/v1/transfer.proto index 21710747..cb50559c 100644 --- a/third_party/proto/ibc/applications/transfer/v1/transfer.proto +++ b/third_party/proto/ibc/applications/transfer/v1/transfer.proto @@ -6,13 +6,13 @@ option go_package = "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"; import "gogoproto/gogo.proto"; -// DenomTrace contains the base denomination for ICS20 fungible tokens and the +// DenomTrace contains the evm denomination for ICS20 fungible tokens and the // source tracing information path. message DenomTrace { // path defines the chain of port/channel identifiers used for tracing the // source of the fungible token. string path = 1; - // base denomination of the relayed fungible token. + // evm denomination of the relayed fungible token. string base_denom = 2; } diff --git a/third_party/proto/tendermint/abci/types.proto b/third_party/proto/tendermint/abci/types.proto index 0c57bf0c..cf9927d7 100644 --- a/third_party/proto/tendermint/abci/types.proto +++ b/third_party/proto/tendermint/abci/types.proto @@ -103,8 +103,8 @@ message RequestListSnapshots {} // offers a snapshot to the application message RequestOfferSnapshot { - Snapshot snapshot = 1; // snapshot offered by peers - bytes app_hash = 2; // light client-verified app hash for snapshot height + Snapshot snapshot = 1; // snapshot offered by peers + bytes app_hash = 2; // light client-verified app hash for snapshot height } // loads a snapshot chunk @@ -205,8 +205,8 @@ message ResponseInitChain { message ResponseQuery { uint32 code = 1; // bytes data = 2; // use "value" instead. - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 index = 5; bytes key = 6; bytes value = 7; @@ -223,15 +223,15 @@ message ResponseBeginBlock { message ResponseCheckTx { uint32 code = 1; bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 gas_wanted = 5 [json_name = "gas_wanted"]; int64 gas_used = 6 [json_name = "gas_used"]; repeated Event events = 7 [(gogoproto.nullable) = false, (gogoproto.jsontag) = "events,omitempty"]; - string codespace = 8; - string sender = 9; - int64 priority = 10; + string codespace = 8; + string sender = 9; + int64 priority = 10; // mempool_error is set by CometBFT. // ABCI applictions creating a ResponseCheckTX should not set mempool_error. @@ -241,8 +241,8 @@ message ResponseCheckTx { message ResponseDeliverTx { uint32 code = 1; bytes data = 2; - string log = 3; // nondeterministic - string info = 4; // nondeterministic + string log = 3; // nondeterministic + string info = 4; // nondeterministic int64 gas_wanted = 5 [json_name = "gas_wanted"]; int64 gas_used = 6 [json_name = "gas_used"]; repeated Event events = 7 [ @@ -273,12 +273,12 @@ message ResponseOfferSnapshot { Result result = 1; enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Snapshot accepted, apply chunks - ABORT = 2; // Abort all snapshot restoration - REJECT = 3; // Reject this specific snapshot, try others - REJECT_FORMAT = 4; // Reject all snapshots of this format, try others - REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Snapshot accepted, apply chunks + ABORT = 2; // Abort all snapshot restoration + REJECT = 3; // Reject this specific snapshot, try others + REJECT_FORMAT = 4; // Reject all snapshots of this format, try others + REJECT_SENDER = 5; // Reject all snapshots from the sender(s), try others } } @@ -288,16 +288,16 @@ message ResponseLoadSnapshotChunk { message ResponseApplySnapshotChunk { Result result = 1; - repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply - repeated string reject_senders = 3; // Chunk senders to reject and ban + repeated uint32 refetch_chunks = 2; // Chunks to refetch and reapply + repeated string reject_senders = 3; // Chunk senders to reject and ban enum Result { - UNKNOWN = 0; // Unknown result, abort all snapshot restoration - ACCEPT = 1; // Chunk successfully accepted - ABORT = 2; // Abort all snapshot restoration - RETRY = 3; // Retry chunk (combine with refetch and reject) - RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) - REJECT_SNAPSHOT = 5; // Reject this snapshot, try others + UNKNOWN = 0; // Unknown result, abort all snapshot restoration + ACCEPT = 1; // Chunk successfully accepted + ABORT = 2; // Abort all snapshot restoration + RETRY = 3; // Retry chunk (combine with refetch and reject) + RETRY_SNAPSHOT = 4; // Retry snapshot (combine with refetch and reject) + REJECT_SNAPSHOT = 5; // Reject this snapshot, try others } } @@ -346,7 +346,7 @@ message Event { message EventAttribute { string key = 1; string value = 2; - bool index = 3; // nondeterministic + bool index = 3; // nondeterministic } // TxResult contains results of executing the transaction. @@ -364,9 +364,9 @@ message TxResult { // Validator message Validator { - bytes address = 1; // The first 20 bytes of SHA256(public key) + bytes address = 1; // The first 20 bytes of SHA256(public key) // PubKey pub_key = 2 [(gogoproto.nullable)=false]; - int64 power = 3; // The voting power + int64 power = 3; // The voting power } // ValidatorUpdate @@ -384,7 +384,7 @@ message VoteInfo { message ExtendedVoteInfo { Validator validator = 1 [(gogoproto.nullable) = false]; bool signed_last_block = 2; - bytes vote_extension = 3; // Reserved for future use + bytes vote_extension = 3; // Reserved for future use } enum MisbehaviorType { @@ -412,11 +412,11 @@ message Misbehavior { // State Sync Types message Snapshot { - uint64 height = 1; // The height at which the snapshot was taken - uint32 format = 2; // The application-specific snapshot format - uint32 chunks = 3; // Number of chunks in the snapshot - bytes hash = 4; // Arbitrary snapshot hash, equal only if identical - bytes metadata = 5; // Arbitrary application metadata + uint64 height = 1; // The height at which the snapshot was taken + uint32 format = 2; // The application-specific snapshot format + uint32 chunks = 3; // Number of chunks in the snapshot + bytes hash = 4; // Arbitrary snapshot hash, equal only if identical + bytes metadata = 5; // Arbitrary application metadata } //---------------------------------------- diff --git a/third_party/proto/tendermint/types/evidence.proto b/third_party/proto/tendermint/types/evidence.proto index 06f30ec2..1f35049b 100644 --- a/third_party/proto/tendermint/types/evidence.proto +++ b/third_party/proto/tendermint/types/evidence.proto @@ -30,7 +30,7 @@ message LightClientAttackEvidence { int64 common_height = 2; repeated tendermint.types.Validator byzantine_validators = 3; int64 total_voting_power = 4; - google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } message EvidenceList { diff --git a/third_party/proto/tendermint/types/params.proto b/third_party/proto/tendermint/types/params.proto index e8f56c2e..66963eec 100644 --- a/third_party/proto/tendermint/types/params.proto +++ b/third_party/proto/tendermint/types/params.proto @@ -26,7 +26,7 @@ message BlockParams { // Note: must be greater or equal to -1 int64 max_gas = 2; - reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792 + reserved 3; // was TimeIotaMs see https://github.com/cometbft/cometbft/pull/5792 } // EvidenceParams determine how we handle evidence of malfeasance. diff --git a/third_party/proto/tendermint/types/types.proto b/third_party/proto/tendermint/types/types.proto index b4c31671..425f041d 100644 --- a/third_party/proto/tendermint/types/types.proto +++ b/third_party/proto/tendermint/types/types.proto @@ -66,19 +66,19 @@ message Header { BlockID last_block_id = 5 [(gogoproto.nullable) = false]; // hashes of block data - bytes last_commit_hash = 6; // commit from validators from the last block - bytes data_hash = 7; // transactions + bytes last_commit_hash = 6; // commit from validators from the last block + bytes data_hash = 7; // transactions // hashes from the app output from the prev block - bytes validators_hash = 8; // validators for the current block - bytes next_validators_hash = 9; // validators for the next block - bytes consensus_hash = 10; // consensus params for current block - bytes app_hash = 11; // state after txs from the previous block - bytes last_results_hash = 12; // root hash of all results from the txs from the previous block + bytes validators_hash = 8; // validators for the current block + bytes next_validators_hash = 9; // validators for the next block + bytes consensus_hash = 10; // consensus params for current block + bytes app_hash = 11; // state after txs from the previous block + bytes last_results_hash = 12; // root hash of all results from the txs from the previous block // consensus info - bytes evidence_hash = 13; // evidence included in the block - bytes proposer_address = 14; // original proposer of the block + bytes evidence_hash = 13; // evidence included in the block + bytes proposer_address = 14; // original proposer of the block } // Data contains the set of transactions included in the block @@ -99,9 +99,9 @@ message Vote { [(gogoproto.nullable) = false, (gogoproto.customname) = "BlockID"]; // zero if vote is nil. google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes validator_address = 6; - int32 validator_index = 7; - bytes signature = 8; + bytes validator_address = 6; + int32 validator_index = 7; + bytes signature = 8; } // Commit contains the evidence that a block was committed by a set of validators. @@ -118,7 +118,7 @@ message CommitSig { bytes validator_address = 2; google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 4; + bytes signature = 4; } message Proposal { @@ -129,7 +129,7 @@ message Proposal { BlockID block_id = 5 [(gogoproto.customname) = "BlockID", (gogoproto.nullable) = false]; google.protobuf.Timestamp timestamp = 6 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - bytes signature = 7; + bytes signature = 7; } message SignedHeader {