From b73fbcf93d8412e7358a15b8ac873bcf2df32e5a Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 28 May 2024 11:36:40 -0400 Subject: [PATCH 1/3] refactor: MsgUpdateZRC20 into MsgPauseZrc20 and MsgUnPauseZRC20 (#2262) * refactor MsgUpdateZRC20 into MsgPauseZrc20 and MsgUnPauseZRC20 * refactor MsgUpdateZRC20 into MsgPauseZrc20 and MsgUnPauseZRC20 * add changelog entry * add breaking changes * generate files * add todo for skipping missed coins * generate 2 * fix proto files * Update x/fungible/keeper/msg_server_pause_zrc20.go Co-authored-by: Lucas Bertrand * remove validate basic checks * generate files 3 * remove action from tx Unpause and Pause --------- Co-authored-by: Lucas Bertrand --- changelog.md | 1 + docs/cli/zetacored/zetacored_tx_fungible.md | 3 +- ...d => zetacored_tx_fungible_pause-zrc20.md} | 10 +- .../zetacored_tx_fungible_unpause-zrc20.md | 59 ++ docs/openapi/openapi.swagger.yaml | 12 +- docs/releases/v17_breaking_changes.md | 4 + docs/spec/fungible/messages.md | 35 +- e2e/e2etests/test_pause_zrc20.go | 10 +- .../zetachain/zetacore/fungible/events.proto | 11 +- proto/zetachain/zetacore/fungible/tx.proto | 31 +- .../zetacore/fungible/events_pb.d.ts | 52 +- .../zetachain/zetacore/fungible/tx_pb.d.ts | 138 +-- x/fungible/client/cli/tx.go | 3 +- .../cli/tx_update_zrc20_paused_status.go | 47 +- x/fungible/keeper/msg_server_pause_zrc20.go | 55 ++ ...test.go => msg_server_pause_zrc20_test.go} | 95 +- x/fungible/keeper/msg_server_unpause_zrc20.go | 55 ++ .../keeper/msg_server_unpause_zrc20_test.go | 142 +++ .../msg_server_update_zrc20_paused_status.go | 74 -- x/fungible/types/codec.go | 6 +- x/fungible/types/events.pb.go | 430 +++++++-- ...aused_status.go => message_pause_zrc20.go} | 29 +- ...us_test.go => message_pause_zrc20_test.go} | 54 +- x/fungible/types/message_unpause_zrc20.go | 59 ++ .../types/message_unpause_zrc20_test.go | 147 +++ x/fungible/types/tx.pb.go | 838 ++++++++++++------ 26 files changed, 1690 insertions(+), 710 deletions(-) rename docs/cli/zetacored/{zetacored_tx_fungible_update-zrc20-paused-status.md => zetacored_tx_fungible_pause-zrc20.md} (89%) create mode 100644 docs/cli/zetacored/zetacored_tx_fungible_unpause-zrc20.md create mode 100644 x/fungible/keeper/msg_server_pause_zrc20.go rename x/fungible/keeper/{msg_server_update_zrc20_paused_status_test.go => msg_server_pause_zrc20_test.go} (53%) create mode 100644 x/fungible/keeper/msg_server_unpause_zrc20.go create mode 100644 x/fungible/keeper/msg_server_unpause_zrc20_test.go delete mode 100644 x/fungible/keeper/msg_server_update_zrc20_paused_status.go rename x/fungible/types/{message_update_zrc20_paused_status.go => message_pause_zrc20.go} (54%) rename x/fungible/types/{message_update_zrc20_paused_status_test.go => message_pause_zrc20_test.go} (61%) create mode 100644 x/fungible/types/message_unpause_zrc20.go create mode 100644 x/fungible/types/message_unpause_zrc20_test.go diff --git a/changelog.md b/changelog.md index fcbfee4d18..1414740d47 100644 --- a/changelog.md +++ b/changelog.md @@ -30,6 +30,7 @@ * [2210](https://github.com/zeta-chain/node/pull/2210) - removed uncessary panics in the zetaclientd process * [2205](https://github.com/zeta-chain/node/pull/2205) - remove deprecated variables pre-v17 * [2226](https://github.com/zeta-chain/node/pull/2226) - improve Go formatting with imports standardization and max line length to 120 +* [2262](https://github.com/zeta-chain/node/pull/2262) - refactor MsgUpdateZRC20 into MsgPauseZrc20 and MsgUnPauseZRC20 ### Tests diff --git a/docs/cli/zetacored/zetacored_tx_fungible.md b/docs/cli/zetacored/zetacored_tx_fungible.md index 37fc724871..3a54cf4315 100644 --- a/docs/cli/zetacored/zetacored_tx_fungible.md +++ b/docs/cli/zetacored/zetacored_tx_fungible.md @@ -28,10 +28,11 @@ zetacored tx fungible [flags] * [zetacored tx](zetacored_tx.md) - Transactions subcommands * [zetacored tx fungible deploy-fungible-coin-zrc-4](zetacored_tx_fungible_deploy-fungible-coin-zrc-4.md) - Broadcast message DeployFungibleCoinZRC20 * [zetacored tx fungible deploy-system-contracts](zetacored_tx_fungible_deploy-system-contracts.md) - Broadcast message SystemContracts +* [zetacored tx fungible pause-zrc20](zetacored_tx_fungible_pause-zrc20.md) - Broadcast message PauseZRC20 * [zetacored tx fungible remove-foreign-coin](zetacored_tx_fungible_remove-foreign-coin.md) - Broadcast message RemoveForeignCoin +* [zetacored tx fungible unpause-zrc20](zetacored_tx_fungible_unpause-zrc20.md) - Broadcast message UnpauseZRC20 * [zetacored tx fungible update-contract-bytecode](zetacored_tx_fungible_update-contract-bytecode.md) - Broadcast message UpdateContractBytecode * [zetacored tx fungible update-system-contract](zetacored_tx_fungible_update-system-contract.md) - Broadcast message UpdateSystemContract * [zetacored tx fungible update-zrc20-liquidity-cap](zetacored_tx_fungible_update-zrc20-liquidity-cap.md) - Broadcast message UpdateZRC20LiquidityCap -* [zetacored tx fungible update-zrc20-paused-status](zetacored_tx_fungible_update-zrc20-paused-status.md) - Broadcast message UpdateZRC20PausedStatus * [zetacored tx fungible update-zrc20-withdraw-fee](zetacored_tx_fungible_update-zrc20-withdraw-fee.md) - Broadcast message UpdateZRC20WithdrawFee diff --git a/docs/cli/zetacored/zetacored_tx_fungible_update-zrc20-paused-status.md b/docs/cli/zetacored/zetacored_tx_fungible_pause-zrc20.md similarity index 89% rename from docs/cli/zetacored/zetacored_tx_fungible_update-zrc20-paused-status.md rename to docs/cli/zetacored/zetacored_tx_fungible_pause-zrc20.md index c25b2afeb1..6f2e587551 100644 --- a/docs/cli/zetacored/zetacored_tx_fungible_update-zrc20-paused-status.md +++ b/docs/cli/zetacored/zetacored_tx_fungible_pause-zrc20.md @@ -1,15 +1,15 @@ -# tx fungible update-zrc20-paused-status +# tx fungible pause-zrc20 -Broadcast message UpdateZRC20PausedStatus +Broadcast message PauseZRC20 ``` -zetacored tx fungible update-zrc20-paused-status [contractAddress1, contractAddress2, ...] [pausedStatus] [flags] +zetacored tx fungible pause-zrc20 [contractAddress1, contractAddress2, ...] [flags] ``` ### Examples ``` -zetacored tx fungible update-zrc20-paused-status "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" 0 +zetacored tx fungible pause-zrc20 "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" ``` ### Options @@ -28,7 +28,7 @@ zetacored tx fungible update-zrc20-paused-status "0xece40cbB54d65282c4623f141c4a --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) - -h, --help help for update-zrc20-paused-status + -h, --help help for pause-zrc20 --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used --ledger Use a connected Ledger device diff --git a/docs/cli/zetacored/zetacored_tx_fungible_unpause-zrc20.md b/docs/cli/zetacored/zetacored_tx_fungible_unpause-zrc20.md new file mode 100644 index 0000000000..3063faee84 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_fungible_unpause-zrc20.md @@ -0,0 +1,59 @@ +# tx fungible unpause-zrc20 + +Broadcast message UnpauseZRC20 + +``` +zetacored tx fungible unpause-zrc20 [contractAddress1, contractAddress2, ...] [flags] +``` + +### Examples + +``` +zetacored tx fungible unpause-zrc20 "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" +``` + +### Options + +``` + -a, --account-number uint The account number of the signing account (offline mode only) + --aux Generate aux signer data instead of sending a tx + -b, --broadcast-mode string Transaction broadcasting mode (sync|async) + --chain-id string The network chain ID + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) + -h, --help help for unpause-zrc20 + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string [host]:[port] to tendermint rpc interface for this chain + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) + -s, --sequence uint The sequence number of the signing account (offline mode only) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator + -y, --yes Skip tx broadcasting prompt confirmation +``` + +### Options inherited from parent commands + +``` + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --log_no_color Disable colored logs + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx fungible](zetacored_tx_fungible.md) - fungible transactions subcommands + diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 92c7ac28c8..9067eccc6d 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -57422,16 +57422,18 @@ definitions: type: string systemContract: type: string + fungibleMsgPauseZRC20Response: + type: object fungibleMsgRemoveForeignCoinResponse: type: object + fungibleMsgUnpauseZRC20Response: + type: object fungibleMsgUpdateContractBytecodeResponse: type: object fungibleMsgUpdateSystemContractResponse: type: object fungibleMsgUpdateZRC20LiquidityCapResponse: type: object - fungibleMsgUpdateZRC20PausedStatusResponse: - type: object fungibleMsgUpdateZRC20WithdrawFeeResponse: type: object fungibleQueryAllForeignCoinsResponse: @@ -57486,12 +57488,6 @@ definitions: type: string connector_zevm: type: string - fungibleUpdatePausedStatusAction: - type: string - enum: - - PAUSE - - UNPAUSE - default: PAUSE googlerpcStatus: type: object properties: diff --git a/docs/releases/v17_breaking_changes.md b/docs/releases/v17_breaking_changes.md index b1598cbf9b..13dc5df873 100644 --- a/docs/releases/v17_breaking_changes.md +++ b/docs/releases/v17_breaking_changes.md @@ -47,3 +47,7 @@ * `/zeta-chain/crosschain/inTxHashToCctxData/{hash}` endpoint is now `/zeta-chain/crosschain/inboundHashToCctxData/{hash}` * `InTxHashToCctxAll` has been renamed to `InboundHashToCctxAll` * `/zeta-chain/crosschain/inTxHashToCctx` endpoint is now `/zeta-chain/crosschain/inboundHashToCctx` + +* `MsgUpdateZRC20` has been removed, and replaced with `MsgPauseZRC20` and `MsgUnpauseZRC20` messages. + * `MsgPauseZRC20` message pauses a ZRC20 token and can be triggered via `PolicyType_groupEmergency` + * `MsgUnpauseZRC20` message unpauses a ZRC20 token and can be triggered via `PolicyType_groupOperational` diff --git a/docs/spec/fungible/messages.md b/docs/spec/fungible/messages.md index 2e3aceb19e..93c7864aef 100644 --- a/docs/spec/fungible/messages.md +++ b/docs/spec/fungible/messages.md @@ -102,32 +102,41 @@ message MsgUpdateZRC20WithdrawFee { } ``` -## MsgUpdateZRC20PausedStatus +## MsgUpdateZRC20LiquidityCap -UpdateZRC20PausedStatus updates the paused status of a ZRC20 -The list of ZRC20s are either paused or unpaused +UpdateZRC20LiquidityCap updates the liquidity cap for a ZRC20 token. -Authorized: admin policy group 1 (pausing), group 2 (pausing & unpausing) +Authorized: admin policy group 2. ```proto -message MsgUpdateZRC20PausedStatus { +message MsgUpdateZRC20LiquidityCap { string creator = 1; - string zrc20_addresses = 2; - UpdatePausedStatusAction action = 3; + string zrc20_address = 2; + string liquidity_cap = 3; } ``` -## MsgUpdateZRC20LiquidityCap +## MsgPauseZRC20 -UpdateZRC20LiquidityCap updates the liquidity cap for a ZRC20 token. +PauseZRC20 pauses a list of ZRC20 tokens +Authorized: admin policy group groupEmergency. -Authorized: admin policy group 2. +```proto +message MsgPauseZRC20 { + string creator = 1; + string zrc20_addresses = 2; +} +``` + +## MsgUnpauseZRC20 + +UnpauseZRC20 unpauses the ZRC20 token +Authorized: admin policy group groupOperational. ```proto -message MsgUpdateZRC20LiquidityCap { +message MsgUnpauseZRC20 { string creator = 1; - string zrc20_address = 2; - string liquidity_cap = 3; + string zrc20_addresses = 2; } ``` diff --git a/e2e/e2etests/test_pause_zrc20.go b/e2e/e2etests/test_pause_zrc20.go index 07505d4b2a..dbe5182e80 100644 --- a/e2e/e2etests/test_pause_zrc20.go +++ b/e2e/e2etests/test_pause_zrc20.go @@ -39,12 +39,11 @@ func TestPauseZRC20(r *runner.E2ERunner, _ []string) { // Pause ETH ZRC20 r.Logger.Info("Pausing ETH") - msg := fungibletypes.NewMsgUpdateZRC20PausedStatus( + msgPause := fungibletypes.NewMsgPauseZRC20( r.ZetaTxServer.GetAccountAddress(0), []string{r.ETHZRC20Addr.Hex()}, - fungibletypes.UpdatePausedStatusAction_PAUSE, ) - res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) + res, err := r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msgPause) if err != nil { panic(err) } @@ -129,12 +128,11 @@ func TestPauseZRC20(r *runner.E2ERunner, _ []string) { // Unpause ETH ZRC20 r.Logger.Info("Unpausing ETH") - msg = fungibletypes.NewMsgUpdateZRC20PausedStatus( + msgUnpause := fungibletypes.NewMsgUnpauseZRC20( r.ZetaTxServer.GetAccountAddress(0), []string{r.ETHZRC20Addr.Hex()}, - fungibletypes.UpdatePausedStatusAction_UNPAUSE, ) - res, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msg) + res, err = r.ZetaTxServer.BroadcastTx(utils.FungibleAdminName, msgUnpause) if err != nil { panic(err) } diff --git a/proto/zetachain/zetacore/fungible/events.proto b/proto/zetachain/zetacore/fungible/events.proto index 406da2c94d..41b78c635e 100644 --- a/proto/zetachain/zetacore/fungible/events.proto +++ b/proto/zetachain/zetacore/fungible/events.proto @@ -38,11 +38,16 @@ message EventZRC20WithdrawFeeUpdated { string new_gas_limit = 9; } -message EventZRC20PausedStatusUpdated { +message EventZRC20Paused { string msg_type_url = 1; repeated string zrc20_addresses = 2; - UpdatePausedStatusAction action = 3; - string signer = 4; + string signer = 3; +} + +message EventZRC20Unpaused { + string msg_type_url = 1; + repeated string zrc20_addresses = 2; + string signer = 3; } message EventSystemContractsDeployed { diff --git a/proto/zetachain/zetacore/fungible/tx.proto b/proto/zetachain/zetacore/fungible/tx.proto index 3090591e2d..bdb9ee8939 100644 --- a/proto/zetachain/zetacore/fungible/tx.proto +++ b/proto/zetachain/zetacore/fungible/tx.proto @@ -20,10 +20,10 @@ service Msg { returns (MsgUpdateContractBytecodeResponse); rpc UpdateZRC20WithdrawFee(MsgUpdateZRC20WithdrawFee) returns (MsgUpdateZRC20WithdrawFeeResponse); - rpc UpdateZRC20PausedStatus(MsgUpdateZRC20PausedStatus) - returns (MsgUpdateZRC20PausedStatusResponse); rpc UpdateZRC20LiquidityCap(MsgUpdateZRC20LiquidityCap) returns (MsgUpdateZRC20LiquidityCapResponse); + rpc PauseZRC20(MsgPauseZRC20) returns (MsgPauseZRC20Response); + rpc UnpauseZRC20(MsgUnpauseZRC20) returns (MsgUnpauseZRC20Response); } message MsgDeploySystemContracts { string creator = 1; } @@ -86,19 +86,6 @@ message MsgUpdateContractBytecode { message MsgUpdateContractBytecodeResponse {} -enum UpdatePausedStatusAction { - PAUSE = 0; - UNPAUSE = 1; -} - -message MsgUpdateZRC20PausedStatus { - string creator = 1; - repeated string zrc20_addresses = 2; - UpdatePausedStatusAction action = 3; -} - -message MsgUpdateZRC20PausedStatusResponse {} - message MsgUpdateZRC20LiquidityCap { string creator = 1; string zrc20_address = 2; @@ -109,3 +96,17 @@ message MsgUpdateZRC20LiquidityCap { } message MsgUpdateZRC20LiquidityCapResponse {} + +message MsgPauseZRC20 { + string creator = 1; + repeated string zrc20_addresses = 2; +} + +message MsgPauseZRC20Response {} + +message MsgUnpauseZRC20 { + string creator = 1; + repeated string zrc20_addresses = 2; +} + +message MsgUnpauseZRC20Response {} \ No newline at end of file diff --git a/typescript/zetachain/zetacore/fungible/events_pb.d.ts b/typescript/zetachain/zetacore/fungible/events_pb.d.ts index 111f48bac8..2cfb7f648b 100644 --- a/typescript/zetachain/zetacore/fungible/events_pb.d.ts +++ b/typescript/zetachain/zetacore/fungible/events_pb.d.ts @@ -6,7 +6,6 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; import type { CoinType } from "../pkg/coin/coin_pb.js"; -import type { UpdatePausedStatusAction } from "./tx_pb.js"; /** * @generated from message zetachain.zetacore.fungible.EventSystemContractUpdated @@ -176,9 +175,9 @@ export declare class EventZRC20WithdrawFeeUpdated extends Message { +export declare class EventZRC20Paused extends Message { /** * @generated from field: string msg_type_url = 1; */ @@ -190,28 +189,57 @@ export declare class EventZRC20PausedStatusUpdated extends Message); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.EventZRC20Paused"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): EventZRC20Paused; + static fromJson(jsonValue: JsonValue, options?: Partial): EventZRC20Paused; + + static fromJsonString(jsonString: string, options?: Partial): EventZRC20Paused; + + static equals(a: EventZRC20Paused | PlainMessage | undefined, b: EventZRC20Paused | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.fungible.EventZRC20Unpaused + */ +export declare class EventZRC20Unpaused extends Message { /** - * @generated from field: string signer = 4; + * @generated from field: string msg_type_url = 1; + */ + msgTypeUrl: string; + + /** + * @generated from field: repeated string zrc20_addresses = 2; + */ + zrc20Addresses: string[]; + + /** + * @generated from field: string signer = 3; */ signer: string; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.EventZRC20PausedStatusUpdated"; + static readonly typeName = "zetachain.zetacore.fungible.EventZRC20Unpaused"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): EventZRC20PausedStatusUpdated; + static fromBinary(bytes: Uint8Array, options?: Partial): EventZRC20Unpaused; - static fromJson(jsonValue: JsonValue, options?: Partial): EventZRC20PausedStatusUpdated; + static fromJson(jsonValue: JsonValue, options?: Partial): EventZRC20Unpaused; - static fromJsonString(jsonString: string, options?: Partial): EventZRC20PausedStatusUpdated; + static fromJsonString(jsonString: string, options?: Partial): EventZRC20Unpaused; - static equals(a: EventZRC20PausedStatusUpdated | PlainMessage | undefined, b: EventZRC20PausedStatusUpdated | PlainMessage | undefined): boolean; + static equals(a: EventZRC20Unpaused | PlainMessage | undefined, b: EventZRC20Unpaused | PlainMessage | undefined): boolean; } /** diff --git a/typescript/zetachain/zetacore/fungible/tx_pb.d.ts b/typescript/zetachain/zetacore/fungible/tx_pb.d.ts index de3c7df658..a1038d4bfd 100644 --- a/typescript/zetachain/zetacore/fungible/tx_pb.d.ts +++ b/typescript/zetachain/zetacore/fungible/tx_pb.d.ts @@ -7,21 +7,6 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialM import { Message, proto3 } from "@bufbuild/protobuf"; import type { CoinType } from "../pkg/coin/coin_pb.js"; -/** - * @generated from enum zetachain.zetacore.fungible.UpdatePausedStatusAction - */ -export declare enum UpdatePausedStatusAction { - /** - * @generated from enum value: PAUSE = 0; - */ - PAUSE = 0, - - /** - * @generated from enum value: UNPAUSE = 1; - */ - UNPAUSE = 1, -} - /** * @generated from message zetachain.zetacore.fungible.MsgDeploySystemContracts */ @@ -383,108 +368,151 @@ export declare class MsgUpdateContractBytecodeResponse extends Message { +export declare class MsgUpdateZRC20LiquidityCap extends Message { /** * @generated from field: string creator = 1; */ creator: string; /** - * @generated from field: repeated string zrc20_addresses = 2; + * @generated from field: string zrc20_address = 2; */ - zrc20Addresses: string[]; + zrc20Address: string; /** - * @generated from field: zetachain.zetacore.fungible.UpdatePausedStatusAction action = 3; + * @generated from field: string liquidity_cap = 3; */ - action: UpdatePausedStatusAction; + liquidityCap: string; - constructor(data?: PartialMessage); + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.MsgUpdateZRC20PausedStatus"; + static readonly typeName = "zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCap"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateZRC20PausedStatus; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateZRC20LiquidityCap; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateZRC20PausedStatus; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateZRC20LiquidityCap; - static fromJsonString(jsonString: string, options?: Partial): MsgUpdateZRC20PausedStatus; + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateZRC20LiquidityCap; - static equals(a: MsgUpdateZRC20PausedStatus | PlainMessage | undefined, b: MsgUpdateZRC20PausedStatus | PlainMessage | undefined): boolean; + static equals(a: MsgUpdateZRC20LiquidityCap | PlainMessage | undefined, b: MsgUpdateZRC20LiquidityCap | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.fungible.MsgUpdateZRC20PausedStatusResponse + * @generated from message zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCapResponse */ -export declare class MsgUpdateZRC20PausedStatusResponse extends Message { - constructor(data?: PartialMessage); +export declare class MsgUpdateZRC20LiquidityCapResponse extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.MsgUpdateZRC20PausedStatusResponse"; + static readonly typeName = "zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCapResponse"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateZRC20PausedStatusResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateZRC20LiquidityCapResponse; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateZRC20PausedStatusResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateZRC20LiquidityCapResponse; - static fromJsonString(jsonString: string, options?: Partial): MsgUpdateZRC20PausedStatusResponse; + static fromJsonString(jsonString: string, options?: Partial): MsgUpdateZRC20LiquidityCapResponse; - static equals(a: MsgUpdateZRC20PausedStatusResponse | PlainMessage | undefined, b: MsgUpdateZRC20PausedStatusResponse | PlainMessage | undefined): boolean; + static equals(a: MsgUpdateZRC20LiquidityCapResponse | PlainMessage | undefined, b: MsgUpdateZRC20LiquidityCapResponse | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCap + * @generated from message zetachain.zetacore.fungible.MsgPauseZRC20 */ -export declare class MsgUpdateZRC20LiquidityCap extends Message { +export declare class MsgPauseZRC20 extends Message { /** * @generated from field: string creator = 1; */ creator: string; /** - * @generated from field: string zrc20_address = 2; + * @generated from field: repeated string zrc20_addresses = 2; */ - zrc20Address: string; + zrc20Addresses: string[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.MsgPauseZRC20"; + static readonly fields: FieldList; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgPauseZRC20; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgPauseZRC20; + + static fromJsonString(jsonString: string, options?: Partial): MsgPauseZRC20; + + static equals(a: MsgPauseZRC20 | PlainMessage | undefined, b: MsgPauseZRC20 | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.fungible.MsgPauseZRC20Response + */ +export declare class MsgPauseZRC20Response extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.fungible.MsgPauseZRC20Response"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): MsgPauseZRC20Response; + + static fromJson(jsonValue: JsonValue, options?: Partial): MsgPauseZRC20Response; + + static fromJsonString(jsonString: string, options?: Partial): MsgPauseZRC20Response; + + static equals(a: MsgPauseZRC20Response | PlainMessage | undefined, b: MsgPauseZRC20Response | PlainMessage | undefined): boolean; +} + +/** + * @generated from message zetachain.zetacore.fungible.MsgUnpauseZRC20 + */ +export declare class MsgUnpauseZRC20 extends Message { /** - * @generated from field: string liquidity_cap = 3; + * @generated from field: string creator = 1; */ - liquidityCap: string; + creator: string; - constructor(data?: PartialMessage); + /** + * @generated from field: repeated string zrc20_addresses = 2; + */ + zrc20Addresses: string[]; + + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCap"; + static readonly typeName = "zetachain.zetacore.fungible.MsgUnpauseZRC20"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateZRC20LiquidityCap; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUnpauseZRC20; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateZRC20LiquidityCap; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUnpauseZRC20; - static fromJsonString(jsonString: string, options?: Partial): MsgUpdateZRC20LiquidityCap; + static fromJsonString(jsonString: string, options?: Partial): MsgUnpauseZRC20; - static equals(a: MsgUpdateZRC20LiquidityCap | PlainMessage | undefined, b: MsgUpdateZRC20LiquidityCap | PlainMessage | undefined): boolean; + static equals(a: MsgUnpauseZRC20 | PlainMessage | undefined, b: MsgUnpauseZRC20 | PlainMessage | undefined): boolean; } /** - * @generated from message zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCapResponse + * @generated from message zetachain.zetacore.fungible.MsgUnpauseZRC20Response */ -export declare class MsgUpdateZRC20LiquidityCapResponse extends Message { - constructor(data?: PartialMessage); +export declare class MsgUnpauseZRC20Response extends Message { + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCapResponse"; + static readonly typeName = "zetachain.zetacore.fungible.MsgUnpauseZRC20Response"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): MsgUpdateZRC20LiquidityCapResponse; + static fromBinary(bytes: Uint8Array, options?: Partial): MsgUnpauseZRC20Response; - static fromJson(jsonValue: JsonValue, options?: Partial): MsgUpdateZRC20LiquidityCapResponse; + static fromJson(jsonValue: JsonValue, options?: Partial): MsgUnpauseZRC20Response; - static fromJsonString(jsonString: string, options?: Partial): MsgUpdateZRC20LiquidityCapResponse; + static fromJsonString(jsonString: string, options?: Partial): MsgUnpauseZRC20Response; - static equals(a: MsgUpdateZRC20LiquidityCapResponse | PlainMessage | undefined, b: MsgUpdateZRC20LiquidityCapResponse | PlainMessage | undefined): boolean; + static equals(a: MsgUnpauseZRC20Response | PlainMessage | undefined, b: MsgUnpauseZRC20Response | PlainMessage | undefined): boolean; } diff --git a/x/fungible/client/cli/tx.go b/x/fungible/client/cli/tx.go index 5830233c37..8d81382cc8 100644 --- a/x/fungible/client/cli/tx.go +++ b/x/fungible/client/cli/tx.go @@ -26,7 +26,8 @@ func GetTxCmd() *cobra.Command { CmdUpdateZRC20LiquidityCap(), CmdUpdateContractBytecode(), CmdUpdateSystemContract(), - CmdUpdateZRC20PausedStatus(), + CmdPauseZRC20(), + CmdUnpauseZRC20(), CmdUpdateZRC20WithdrawFee(), ) diff --git a/x/fungible/client/cli/tx_update_zrc20_paused_status.go b/x/fungible/client/cli/tx_update_zrc20_paused_status.go index 3c0b498d5a..553cf68545 100644 --- a/x/fungible/client/cli/tx_update_zrc20_paused_status.go +++ b/x/fungible/client/cli/tx_update_zrc20_paused_status.go @@ -1,25 +1,22 @@ package cli import ( - "strconv" "strings" - cosmoserrors "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/x/fungible/types" ) -func CmdUpdateZRC20PausedStatus() *cobra.Command { +func CmdPauseZRC20() *cobra.Command { cmd := &cobra.Command{ - Use: "update-zrc20-paused-status [contractAddress1, contractAddress2, ...] [pausedStatus]", - Short: "Broadcast message UpdateZRC20PausedStatus", - Example: `zetacored tx fungible update-zrc20-paused-status "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" 0 `, - Args: cobra.ExactArgs(2), + Use: "pause-zrc20 [contractAddress1, contractAddress2, ...]", + Short: "Broadcast message PauseZRC20", + Example: `zetacored tx fungible pause-zrc20 "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" `, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -28,23 +25,37 @@ func CmdUpdateZRC20PausedStatus() *cobra.Command { contractAddressList := strings.Split(strings.TrimSpace(args[0]), ",") - action, err := strconv.ParseUint(args[1], 10, 32) + msg := types.NewMsgPauseZRC20( + clientCtx.GetFromAddress().String(), + contractAddressList, + ) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdUnpauseZRC20() *cobra.Command { + cmd := &cobra.Command{ + Use: "unpause-zrc20 [contractAddress1, contractAddress2, ...]", + Short: "Broadcast message UnpauseZRC20", + Example: `zetacored tx fungible unpause-zrc20 "0xece40cbB54d65282c4623f141c4a8a0bE7D6AdEc, 0xece40cbB54d65282c4623f141c4a8a0bEjgksncf" `, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - if (action != 0) && (action != 1) { - return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid action (%d)", action) - } - pausedStatus := types.UpdatePausedStatusAction_PAUSE - if action == 1 { - pausedStatus = types.UpdatePausedStatusAction_UNPAUSE - } + contractAddressList := strings.Split(strings.TrimSpace(args[0]), ",") - msg := types.NewMsgUpdateZRC20PausedStatus( + msg := types.NewMsgUnpauseZRC20( clientCtx.GetFromAddress().String(), contractAddressList, - pausedStatus, ) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) diff --git a/x/fungible/keeper/msg_server_pause_zrc20.go b/x/fungible/keeper/msg_server_pause_zrc20.go new file mode 100644 index 0000000000..536da472a1 --- /dev/null +++ b/x/fungible/keeper/msg_server_pause_zrc20.go @@ -0,0 +1,55 @@ +package keeper + +import ( + "context" + + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +// PauseZRC20 pauses a list of ZRC20 tokens +// Authorized: admin policy group groupEmergency. +func (k msgServer) PauseZRC20( + goCtx context.Context, + msg *types.MsgPauseZRC20, +) (*types.MsgPauseZRC20Response, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupEmergency) { + return nil, cosmoserrors.Wrap( + authoritytypes.ErrUnauthorized, + "PauseZRC20 can only be executed by the correct policy account", + ) + } + + // iterate all foreign coins and set paused status + for _, zrc20 := range msg.Zrc20Addresses { + fc, found := k.GetForeignCoins(ctx, zrc20) + if !found { + return nil, cosmoserrors.Wrapf(types.ErrForeignCoinNotFound, "foreign coin not found %s", zrc20) + } + // Set status to paused + fc.Paused = true + k.SetForeignCoins(ctx, fc) + } + + err := ctx.EventManager().EmitTypedEvent( + &types.EventZRC20Paused{ + MsgTypeUrl: sdk.MsgTypeURL(&types.MsgPauseZRC20{}), + Zrc20Addresses: msg.Zrc20Addresses, + Signer: msg.Creator, + }, + ) + if err != nil { + k.Logger(ctx).Error("failed to emit event", + "event", "EventZRC20Paused", + "error", err.Error(), + ) + return nil, cosmoserrors.Wrapf(types.ErrEmitEvent, "failed to emit event (%s)", err.Error()) + } + + return &types.MsgPauseZRC20Response{}, nil +} diff --git a/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go b/x/fungible/keeper/msg_server_pause_zrc20_test.go similarity index 53% rename from x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go rename to x/fungible/keeper/msg_server_pause_zrc20_test.go index 588361ce5a..9f9edc68fe 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_paused_status_test.go +++ b/x/fungible/keeper/msg_server_pause_zrc20_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" @@ -13,8 +12,8 @@ import ( "github.com/zeta-chain/zetacore/x/fungible/types" ) -func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { - t.Run("can update the paused status of zrc20", func(t *testing.T) { +func TestKeeper_PauseZRC20(t *testing.T) { + t.Run("can pause zrc20", func(t *testing.T) { k, ctx, _, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ UseAuthorityMock: true, }) @@ -51,113 +50,47 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) // can pause zrc20 - _, err := msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( + _, err := msgServer.PauseZRC20(ctx, types.NewMsgPauseZRC20( admin, []string{ zrc20A, zrc20B, }, - types.UpdatePausedStatusAction_PAUSE, )) require.NoError(t, err) assertPaused(zrc20A) assertPaused(zrc20B) assertUnpaused(zrc20C) - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - - // can unpause zrc20 - _, err = msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( - admin, - []string{ - zrc20A, - }, - types.UpdatePausedStatusAction_UNPAUSE, - )) - require.NoError(t, err) - assertUnpaused(zrc20A) - assertPaused(zrc20B) - assertUnpaused(zrc20C) - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) // can pause already paused zrc20 - _, err = msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( + _, err = msgServer.PauseZRC20(ctx, types.NewMsgPauseZRC20( admin, []string{ zrc20B, }, - types.UpdatePausedStatusAction_PAUSE, - )) - require.NoError(t, err) - assertUnpaused(zrc20A) - assertPaused(zrc20B) - assertUnpaused(zrc20C) - - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - - // can unpause already unpaused zrc20 - _, err = msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( - admin, - []string{ - zrc20C, - }, - types.UpdatePausedStatusAction_UNPAUSE, )) require.NoError(t, err) - assertUnpaused(zrc20A) + assertPaused(zrc20A) assertPaused(zrc20B) assertUnpaused(zrc20C) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) // can pause all zrc20 - _, err = msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( + _, err = msgServer.PauseZRC20(ctx, types.NewMsgPauseZRC20( admin, []string{ zrc20A, zrc20B, zrc20C, }, - types.UpdatePausedStatusAction_PAUSE, )) require.NoError(t, err) assertPaused(zrc20A) assertPaused(zrc20B) assertPaused(zrc20C) - - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) - - // can unpause all zrc20 - _, err = msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( - admin, - []string{ - zrc20A, - zrc20B, - zrc20C, - }, - types.UpdatePausedStatusAction_UNPAUSE, - )) - require.NoError(t, err) - assertUnpaused(zrc20A) - assertUnpaused(zrc20B) - assertUnpaused(zrc20C) - }) - - t.Run("should fail if invalid message", func(t *testing.T) { - k, ctx, _, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ - UseAuthorityMock: true, - }) - - msgServer := keeper.NewMsgServerImpl(*k) - - admin := sample.AccAddress() - - invalidMsg := types.NewMsgUpdateZRC20PausedStatus(admin, []string{}, types.UpdatePausedStatusAction_PAUSE) - require.ErrorIs(t, invalidMsg.ValidateBasic(), sdkerrors.ErrInvalidRequest) - - _, err := msgServer.UpdateZRC20PausedStatus(ctx, invalidMsg) - require.ErrorIs(t, err, sdkerrors.ErrInvalidRequest) }) t.Run("should fail if not authorized", func(t *testing.T) { @@ -171,22 +104,11 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { authorityMock := keepertest.GetFungibleAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, false) - _, err := msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( + _, err := msgServer.PauseZRC20(ctx, types.NewMsgPauseZRC20( admin, []string{sample.EthAddress().String()}, - types.UpdatePausedStatusAction_PAUSE, )) require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) - - keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) - - _, err = msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( - admin, - []string{sample.EthAddress().String()}, - types.UpdatePausedStatusAction_UNPAUSE, - )) - - require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) }) t.Run("should fail if zrc20 does not exist", func(t *testing.T) { @@ -204,14 +126,13 @@ func TestKeeper_UpdateZRC20PausedStatus(t *testing.T) { k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20A)) k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20B)) - _, err := msgServer.UpdateZRC20PausedStatus(ctx, types.NewMsgUpdateZRC20PausedStatus( + _, err := msgServer.PauseZRC20(ctx, types.NewMsgPauseZRC20( admin, []string{ zrc20A, sample.EthAddress().String(), zrc20B, }, - types.UpdatePausedStatusAction_PAUSE, )) require.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) diff --git a/x/fungible/keeper/msg_server_unpause_zrc20.go b/x/fungible/keeper/msg_server_unpause_zrc20.go new file mode 100644 index 0000000000..f00afd6909 --- /dev/null +++ b/x/fungible/keeper/msg_server_unpause_zrc20.go @@ -0,0 +1,55 @@ +package keeper + +import ( + "context" + + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +// UnpauseZRC20 unpauses the ZRC20 token +// Authorized: admin policy group groupOperational. +func (k msgServer) UnpauseZRC20( + goCtx context.Context, + msg *types.MsgUnpauseZRC20, +) (*types.MsgUnpauseZRC20Response, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, authoritytypes.PolicyType_groupOperational) { + return nil, cosmoserrors.Wrap( + authoritytypes.ErrUnauthorized, + "UnPauseZRC20 can only be executed by the correct policy account", + ) + } + + // iterate all foreign coins and set unpaused status + for _, zrc20 := range msg.Zrc20Addresses { + fc, found := k.GetForeignCoins(ctx, zrc20) + if !found { + return nil, cosmoserrors.Wrapf(types.ErrForeignCoinNotFound, "foreign coin not found %s", zrc20) + } + // Set status to unpaused + fc.Paused = false + k.SetForeignCoins(ctx, fc) + } + + err := ctx.EventManager().EmitTypedEvent( + &types.EventZRC20Unpaused{ + MsgTypeUrl: sdk.MsgTypeURL(&types.MsgUnpauseZRC20{}), + Zrc20Addresses: msg.Zrc20Addresses, + Signer: msg.Creator, + }, + ) + if err != nil { + k.Logger(ctx).Error("failed to emit event", + "event", "EventZRC20Unpaused", + "error", err.Error(), + ) + return nil, cosmoserrors.Wrapf(types.ErrEmitEvent, "failed to emit event (%s)", err.Error()) + } + + return &types.MsgUnpauseZRC20Response{}, nil +} diff --git a/x/fungible/keeper/msg_server_unpause_zrc20_test.go b/x/fungible/keeper/msg_server_unpause_zrc20_test.go new file mode 100644 index 0000000000..ea90f01e85 --- /dev/null +++ b/x/fungible/keeper/msg_server_unpause_zrc20_test.go @@ -0,0 +1,142 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" + "github.com/zeta-chain/zetacore/x/fungible/keeper" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func TestKeeper_UnpauseZRC20(t *testing.T) { + t.Run("can unpause status of zrc20", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ + UseAuthorityMock: true, + }) + + msgServer := keeper.NewMsgServerImpl(*k) + admin := sample.AccAddress() + authorityMock := keepertest.GetFungibleAuthorityMock(t, k) + + assertUnpaused := func(zrc20 string) { + fc, found := k.GetForeignCoins(ctx, zrc20) + require.True(t, found) + require.False(t, fc.Paused) + } + assertPaused := func(zrc20 string) { + fc, found := k.GetForeignCoins(ctx, zrc20) + require.True(t, found) + require.True(t, fc.Paused) + } + + // setup zrc20 + zrc20A, zrc20B, zrc20C := sample.EthAddress(). + String(), + sample.EthAddress(). + String(), + sample.EthAddress(). + String() + k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20A)) + fcB := sample.ForeignCoins(t, zrc20B) + fcB.Paused = true + k.SetForeignCoins(ctx, fcB) + k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20C)) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + + // can unpause zrc20 + _, err := msgServer.UnpauseZRC20(ctx, types.NewMsgUnpauseZRC20( + admin, + []string{ + zrc20A, + }, + )) + require.NoError(t, err) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + + // can unpause already unpaused zrc20 + _, err = msgServer.UnpauseZRC20(ctx, types.NewMsgUnpauseZRC20( + admin, + []string{ + zrc20C, + }, + )) + require.NoError(t, err) + assertUnpaused(zrc20A) + assertPaused(zrc20B) + assertUnpaused(zrc20C) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + + // can unpause all zrc20 + _, err = msgServer.UnpauseZRC20(ctx, types.NewMsgUnpauseZRC20( + admin, + []string{ + zrc20A, + zrc20B, + zrc20C, + }, + )) + require.NoError(t, err) + assertUnpaused(zrc20A) + assertUnpaused(zrc20B) + assertUnpaused(zrc20C) + }) + + t.Run("should fail if not authorized", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ + UseAuthorityMock: true, + }) + + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + authorityMock := keepertest.GetFungibleAuthorityMock(t, k) + + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, false) + + _, err := msgServer.UnpauseZRC20(ctx, types.NewMsgUnpauseZRC20( + admin, + []string{sample.EthAddress().String()}, + )) + + require.ErrorIs(t, err, authoritytypes.ErrUnauthorized) + }) + + t.Run("should fail if zrc20 does not exist", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{ + UseAuthorityMock: true, + }) + + msgServer := keeper.NewMsgServerImpl(*k) + + admin := sample.AccAddress() + authorityMock := keepertest.GetFungibleAuthorityMock(t, k) + keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupOperational, true) + + zrc20A, zrc20B := sample.EthAddress().String(), sample.EthAddress().String() + k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20A)) + k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20B)) + + _, err := msgServer.UnpauseZRC20(ctx, types.NewMsgUnpauseZRC20( + admin, + []string{ + zrc20A, + sample.EthAddress().String(), + zrc20B, + }, + )) + require.ErrorIs(t, err, types.ErrForeignCoinNotFound) + }) +} diff --git a/x/fungible/keeper/msg_server_update_zrc20_paused_status.go b/x/fungible/keeper/msg_server_update_zrc20_paused_status.go deleted file mode 100644 index a8a17fe585..0000000000 --- a/x/fungible/keeper/msg_server_update_zrc20_paused_status.go +++ /dev/null @@ -1,74 +0,0 @@ -package keeper - -import ( - "context" - - cosmoserrors "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - - authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" - "github.com/zeta-chain/zetacore/x/fungible/types" -) - -// UpdateZRC20PausedStatus updates the paused status of a ZRC20 -// The list of ZRC20s are either paused or unpaused -// -// Authorized: admin policy group 1 (pausing), group 2 (pausing & unpausing) -func (k msgServer) UpdateZRC20PausedStatus( - goCtx context.Context, - msg *types.MsgUpdateZRC20PausedStatus, -) (*types.MsgUpdateZRC20PausedStatusResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // check message validity - if err := msg.ValidateBasic(); err != nil { - return nil, err - } - - // check if the sender is the admin - // unpausing requires operational policy - requiredPolicyAccount := authoritytypes.PolicyType_groupEmergency - if msg.Action == types.UpdatePausedStatusAction_UNPAUSE { - requiredPolicyAccount = authoritytypes.PolicyType_groupOperational - } - if !k.GetAuthorityKeeper().IsAuthorized(ctx, msg.Creator, requiredPolicyAccount) { - return nil, cosmoserrors.Wrap( - authoritytypes.ErrUnauthorized, - "Update can only be executed by the correct policy account", - ) - } - - pausedStatus := true - if msg.Action == types.UpdatePausedStatusAction_UNPAUSE { - pausedStatus = false - } - - // iterate all foreign coins and set paused status - for _, zrc20 := range msg.Zrc20Addresses { - fc, found := k.GetForeignCoins(ctx, zrc20) - if !found { - return nil, cosmoserrors.Wrapf(types.ErrForeignCoinNotFound, "foreign coin not found %s", zrc20) - } - - fc.Paused = pausedStatus - k.SetForeignCoins(ctx, fc) - } - - err := ctx.EventManager().EmitTypedEvent( - &types.EventZRC20PausedStatusUpdated{ - MsgTypeUrl: sdk.MsgTypeURL(&types.MsgUpdateZRC20PausedStatus{}), - Action: msg.Action, - Zrc20Addresses: msg.Zrc20Addresses, - Signer: msg.Creator, - }, - ) - if err != nil { - k.Logger(ctx).Error("failed to emit event", - "event", "EventZRC20PausedStatusUpdated", - "error", err.Error(), - ) - return nil, cosmoserrors.Wrapf(types.ErrEmitEvent, "failed to emit event (%s)", err.Error()) - } - - return &types.MsgUpdateZRC20PausedStatusResponse{}, nil -} diff --git a/x/fungible/types/codec.go b/x/fungible/types/codec.go index ac7fc91429..fd31724336 100644 --- a/x/fungible/types/codec.go +++ b/x/fungible/types/codec.go @@ -14,8 +14,9 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateSystemContract{}, "fungible/UpdateSystemContract", nil) cdc.RegisterConcrete(&MsgUpdateZRC20WithdrawFee{}, "fungible/UpdateZRC20WithdrawFee", nil) cdc.RegisterConcrete(&MsgUpdateContractBytecode{}, "fungible/UpdateContractBytecode", nil) - cdc.RegisterConcrete(&MsgUpdateZRC20PausedStatus{}, "fungible/UpdateZRC20PausedStatus", nil) cdc.RegisterConcrete(&MsgUpdateZRC20LiquidityCap{}, "fungible/UpdateZRC20LiquidityCap", nil) + cdc.RegisterConcrete(&MsgPauseZRC20{}, "fungible/PauseZRC20", nil) + cdc.RegisterConcrete(&MsgUnpauseZRC20{}, "fungible/UnpauseZRC20", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -26,8 +27,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgUpdateSystemContract{}, &MsgUpdateZRC20WithdrawFee{}, &MsgUpdateContractBytecode{}, - &MsgUpdateZRC20PausedStatus{}, &MsgUpdateZRC20LiquidityCap{}, + &MsgPauseZRC20{}, + &MsgUnpauseZRC20{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/fungible/types/events.pb.go b/x/fungible/types/events.pb.go index ba43982bc1..41795a24b7 100644 --- a/x/fungible/types/events.pb.go +++ b/x/fungible/types/events.pb.go @@ -308,25 +308,24 @@ func (m *EventZRC20WithdrawFeeUpdated) GetNewGasLimit() string { return "" } -type EventZRC20PausedStatusUpdated struct { - MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` - Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` - Action UpdatePausedStatusAction `protobuf:"varint,3,opt,name=action,proto3,enum=zetachain.zetacore.fungible.UpdatePausedStatusAction" json:"action,omitempty"` - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` +type EventZRC20Paused struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` } -func (m *EventZRC20PausedStatusUpdated) Reset() { *m = EventZRC20PausedStatusUpdated{} } -func (m *EventZRC20PausedStatusUpdated) String() string { return proto.CompactTextString(m) } -func (*EventZRC20PausedStatusUpdated) ProtoMessage() {} -func (*EventZRC20PausedStatusUpdated) Descriptor() ([]byte, []int) { +func (m *EventZRC20Paused) Reset() { *m = EventZRC20Paused{} } +func (m *EventZRC20Paused) String() string { return proto.CompactTextString(m) } +func (*EventZRC20Paused) ProtoMessage() {} +func (*EventZRC20Paused) Descriptor() ([]byte, []int) { return fileDescriptor_1e6611815bc2713b, []int{3} } -func (m *EventZRC20PausedStatusUpdated) XXX_Unmarshal(b []byte) error { +func (m *EventZRC20Paused) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EventZRC20PausedStatusUpdated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *EventZRC20Paused) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EventZRC20PausedStatusUpdated.Marshal(b, m, deterministic) + return xxx_messageInfo_EventZRC20Paused.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -336,40 +335,93 @@ func (m *EventZRC20PausedStatusUpdated) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *EventZRC20PausedStatusUpdated) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventZRC20PausedStatusUpdated.Merge(m, src) +func (m *EventZRC20Paused) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventZRC20Paused.Merge(m, src) } -func (m *EventZRC20PausedStatusUpdated) XXX_Size() int { +func (m *EventZRC20Paused) XXX_Size() int { return m.Size() } -func (m *EventZRC20PausedStatusUpdated) XXX_DiscardUnknown() { - xxx_messageInfo_EventZRC20PausedStatusUpdated.DiscardUnknown(m) +func (m *EventZRC20Paused) XXX_DiscardUnknown() { + xxx_messageInfo_EventZRC20Paused.DiscardUnknown(m) } -var xxx_messageInfo_EventZRC20PausedStatusUpdated proto.InternalMessageInfo +var xxx_messageInfo_EventZRC20Paused proto.InternalMessageInfo -func (m *EventZRC20PausedStatusUpdated) GetMsgTypeUrl() string { +func (m *EventZRC20Paused) GetMsgTypeUrl() string { if m != nil { return m.MsgTypeUrl } return "" } -func (m *EventZRC20PausedStatusUpdated) GetZrc20Addresses() []string { +func (m *EventZRC20Paused) GetZrc20Addresses() []string { if m != nil { return m.Zrc20Addresses } return nil } -func (m *EventZRC20PausedStatusUpdated) GetAction() UpdatePausedStatusAction { +func (m *EventZRC20Paused) GetSigner() string { if m != nil { - return m.Action + return m.Signer + } + return "" +} + +type EventZRC20Unpaused struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *EventZRC20Unpaused) Reset() { *m = EventZRC20Unpaused{} } +func (m *EventZRC20Unpaused) String() string { return proto.CompactTextString(m) } +func (*EventZRC20Unpaused) ProtoMessage() {} +func (*EventZRC20Unpaused) Descriptor() ([]byte, []int) { + return fileDescriptor_1e6611815bc2713b, []int{4} +} +func (m *EventZRC20Unpaused) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventZRC20Unpaused) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventZRC20Unpaused.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } - return UpdatePausedStatusAction_PAUSE +} +func (m *EventZRC20Unpaused) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventZRC20Unpaused.Merge(m, src) +} +func (m *EventZRC20Unpaused) XXX_Size() int { + return m.Size() +} +func (m *EventZRC20Unpaused) XXX_DiscardUnknown() { + xxx_messageInfo_EventZRC20Unpaused.DiscardUnknown(m) +} + +var xxx_messageInfo_EventZRC20Unpaused proto.InternalMessageInfo + +func (m *EventZRC20Unpaused) GetMsgTypeUrl() string { + if m != nil { + return m.MsgTypeUrl + } + return "" } -func (m *EventZRC20PausedStatusUpdated) GetSigner() string { +func (m *EventZRC20Unpaused) GetZrc20Addresses() []string { + if m != nil { + return m.Zrc20Addresses + } + return nil +} + +func (m *EventZRC20Unpaused) GetSigner() string { if m != nil { return m.Signer } @@ -390,7 +442,7 @@ func (m *EventSystemContractsDeployed) Reset() { *m = EventSystemContrac func (m *EventSystemContractsDeployed) String() string { return proto.CompactTextString(m) } func (*EventSystemContractsDeployed) ProtoMessage() {} func (*EventSystemContractsDeployed) Descriptor() ([]byte, []int) { - return fileDescriptor_1e6611815bc2713b, []int{4} + return fileDescriptor_1e6611815bc2713b, []int{5} } func (m *EventSystemContractsDeployed) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -480,7 +532,7 @@ func (m *EventBytecodeUpdated) Reset() { *m = EventBytecodeUpdated{} } func (m *EventBytecodeUpdated) String() string { return proto.CompactTextString(m) } func (*EventBytecodeUpdated) ProtoMessage() {} func (*EventBytecodeUpdated) Descriptor() ([]byte, []int) { - return fileDescriptor_1e6611815bc2713b, []int{5} + return fileDescriptor_1e6611815bc2713b, []int{6} } func (m *EventBytecodeUpdated) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -548,7 +600,8 @@ func init() { proto.RegisterType((*EventSystemContractUpdated)(nil), "zetachain.zetacore.fungible.EventSystemContractUpdated") proto.RegisterType((*EventZRC20Deployed)(nil), "zetachain.zetacore.fungible.EventZRC20Deployed") proto.RegisterType((*EventZRC20WithdrawFeeUpdated)(nil), "zetachain.zetacore.fungible.EventZRC20WithdrawFeeUpdated") - proto.RegisterType((*EventZRC20PausedStatusUpdated)(nil), "zetachain.zetacore.fungible.EventZRC20PausedStatusUpdated") + proto.RegisterType((*EventZRC20Paused)(nil), "zetachain.zetacore.fungible.EventZRC20Paused") + proto.RegisterType((*EventZRC20Unpaused)(nil), "zetachain.zetacore.fungible.EventZRC20Unpaused") proto.RegisterType((*EventSystemContractsDeployed)(nil), "zetachain.zetacore.fungible.EventSystemContractsDeployed") proto.RegisterType((*EventBytecodeUpdated)(nil), "zetachain.zetacore.fungible.EventBytecodeUpdated") } @@ -558,56 +611,55 @@ func init() { } var fileDescriptor_1e6611815bc2713b = []byte{ - // 775 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xdd, 0x4e, 0xe3, 0x46, - 0x14, 0xc6, 0x04, 0x02, 0x19, 0x7e, 0x02, 0xa3, 0xa8, 0x72, 0x43, 0x1b, 0xa1, 0xb4, 0xb4, 0x29, - 0x6a, 0x1d, 0x94, 0xaa, 0x0f, 0x00, 0xb4, 0xb4, 0x48, 0xad, 0x54, 0x85, 0xd2, 0x4a, 0xdc, 0x58, - 0x13, 0xfb, 0xe0, 0x58, 0xd8, 0x33, 0x96, 0x67, 0x12, 0x63, 0x9e, 0xa2, 0x97, 0xfb, 0x10, 0xfb, - 0x04, 0xfb, 0x04, 0x7b, 0xc9, 0x6a, 0x6f, 0xf6, 0x72, 0x05, 0x2f, 0xb1, 0x97, 0xab, 0x19, 0x8f, - 0x1d, 0x9b, 0x05, 0x04, 0x7b, 0x13, 0xcd, 0x99, 0x7c, 0xe7, 0x9c, 0xef, 0x7c, 0xfe, 0x66, 0x06, - 0xf5, 0xae, 0x40, 0x10, 0x67, 0x4c, 0x7c, 0xda, 0x57, 0x2b, 0x16, 0x43, 0xff, 0x7c, 0x42, 0x3d, - 0x7f, 0x14, 0x40, 0x1f, 0xa6, 0x40, 0x05, 0xb7, 0xa2, 0x98, 0x09, 0x86, 0xb7, 0x0a, 0xa4, 0x95, - 0x23, 0xad, 0x1c, 0xd9, 0xfe, 0xf6, 0xb1, 0x32, 0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63, 0xc2, 0xc7, 0x5a, 0x9b, 0x26, 0x85, 0x24, 0xef, - 0xfd, 0x07, 0xe1, 0x63, 0x89, 0x95, 0x46, 0xae, 0x62, 0xb5, 0x4a, 0x2c, 0x70, 0x2b, 0xd8, 0xd9, - 0x54, 0x8b, 0xe5, 0xa9, 0x0e, 0x8e, 0x5f, 0xdf, 0x74, 0x8c, 0xeb, 0x9b, 0x8e, 0xf1, 0xfe, 0xa6, - 0x63, 0xfc, 0x7f, 0xdb, 0x99, 0xbb, 0xbe, 0xed, 0xcc, 0xbd, 0xbb, 0xed, 0xcc, 0x9d, 0xf5, 0x3d, - 0x5f, 0x8c, 0x27, 0x23, 0xcb, 0x61, 0xa1, 0x7a, 0x6e, 0x7e, 0xba, 0xf3, 0xf2, 0x5c, 0x96, 0xde, - 0xad, 0x34, 0x02, 0x3e, 0xaa, 0xab, 0xd7, 0xe7, 0xe7, 0x8f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, - 0x23, 0x3a, 0xee, 0x2a, 0x07, 0x00, 0x00, + // 754 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xdd, 0x4e, 0xdb, 0x48, + 0x14, 0xc6, 0x04, 0x02, 0x19, 0x7e, 0x12, 0x46, 0xd1, 0xca, 0x1b, 0x56, 0x11, 0xca, 0x2e, 0xbb, + 0x59, 0xb4, 0x9b, 0xa0, 0xf4, 0x09, 0x0a, 0x2d, 0x2d, 0x52, 0x2f, 0xaa, 0xb4, 0xb4, 0x12, 0x37, + 0xd6, 0xc4, 0x3e, 0x38, 0x16, 0xf6, 0x8c, 0xe5, 0x99, 0xc4, 0x98, 0xa7, 0xe8, 0x65, 0x1f, 0xa2, + 0x4f, 0xd0, 0x27, 0xe8, 0x25, 0x52, 0x6f, 0x7a, 0x59, 0xc1, 0x4b, 0xf4, 0xb2, 0x9a, 0xf1, 0xd8, + 0xb1, 0x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, 0xa6, 0x92, 0x66, 0x2f, 0x11, 0x60, 0x33, 0xe7, 0x01, 0xd3, + 0xf7, 0x2f, 0x6a, 0xdc, 0x72, 0xcf, 0xd6, 0xed, 0x6b, 0x57, 0xe6, 0x0e, 0xda, 0x90, 0xa6, 0x1c, + 0xe9, 0x1a, 0xd6, 0x98, 0xf0, 0xb1, 0xd6, 0xa6, 0x4e, 0x21, 0xce, 0x6a, 0x3f, 0x27, 0x7c, 0x2c, + 0xb1, 0xd2, 0xe4, 0x65, 0xac, 0x56, 0x89, 0xf9, 0x4e, 0x09, 0x3b, 0xeb, 0x6a, 0xb1, 0xd8, 0xd5, + 0xde, 0xe1, 0xa7, 0xcb, 0xb6, 0x71, 0x71, 0xd9, 0x36, 0xbe, 0x5e, 0xb6, 0x8d, 0x77, 0x57, 0xed, + 0xb9, 0x8b, 0xab, 0xf6, 0xdc, 0x97, 0xab, 0xf6, 0xdc, 0x71, 0xdf, 0xf5, 0xc4, 0x78, 0x32, 0xea, + 0xd9, 0x2c, 0x50, 0x4f, 0xd1, 0xff, 0xd7, 0x5e, 0xa5, 0xb3, 0xc2, 0x9b, 0x96, 0x84, 0xc0, 0x47, + 0x55, 0xf5, 0x32, 0x3d, 0xfa, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x55, 0x3b, 0x93, 0x8b, 0x46, 0x07, + 0x00, 0x00, } func (m *EventSystemContractUpdated) Marshal() (dAtA []byte, err error) { @@ -821,7 +873,7 @@ func (m *EventZRC20WithdrawFeeUpdated) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *EventZRC20PausedStatusUpdated) Marshal() (dAtA []byte, err error) { +func (m *EventZRC20Paused) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -831,12 +883,12 @@ func (m *EventZRC20PausedStatusUpdated) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EventZRC20PausedStatusUpdated) MarshalTo(dAtA []byte) (int, error) { +func (m *EventZRC20Paused) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EventZRC20PausedStatusUpdated) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *EventZRC20Paused) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -846,12 +898,53 @@ func (m *EventZRC20PausedStatusUpdated) MarshalToSizedBuffer(dAtA []byte) (int, copy(dAtA[i:], m.Signer) i = encodeVarintEvents(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } - if m.Action != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Action)) + if len(m.Zrc20Addresses) > 0 { + for iNdEx := len(m.Zrc20Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Zrc20Addresses[iNdEx]) + copy(dAtA[i:], m.Zrc20Addresses[iNdEx]) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Zrc20Addresses[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.MsgTypeUrl) > 0 { + i -= len(m.MsgTypeUrl) + copy(dAtA[i:], m.MsgTypeUrl) + i = encodeVarintEvents(dAtA, i, uint64(len(m.MsgTypeUrl))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventZRC20Unpaused) 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 *EventZRC20Unpaused) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventZRC20Unpaused) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x1a } if len(m.Zrc20Addresses) > 0 { for iNdEx := len(m.Zrc20Addresses) - 1; iNdEx >= 0; iNdEx-- { @@ -1122,7 +1215,7 @@ func (m *EventZRC20WithdrawFeeUpdated) Size() (n int) { return n } -func (m *EventZRC20PausedStatusUpdated) Size() (n int) { +func (m *EventZRC20Paused) Size() (n int) { if m == nil { return 0 } @@ -1138,8 +1231,28 @@ func (m *EventZRC20PausedStatusUpdated) Size() (n int) { n += 1 + l + sovEvents(uint64(l)) } } - if m.Action != 0 { - n += 1 + sovEvents(uint64(m.Action)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventZRC20Unpaused) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MsgTypeUrl) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if len(m.Zrc20Addresses) > 0 { + for _, s := range m.Zrc20Addresses { + l = len(s) + n += 1 + l + sovEvents(uint64(l)) + } } l = len(m.Signer) if l > 0 { @@ -1996,7 +2109,7 @@ func (m *EventZRC20WithdrawFeeUpdated) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventZRC20PausedStatusUpdated) Unmarshal(dAtA []byte) error { +func (m *EventZRC20Paused) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2019,10 +2132,10 @@ func (m *EventZRC20PausedStatusUpdated) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EventZRC20PausedStatusUpdated: wiretype end group for non-group") + return fmt.Errorf("proto: EventZRC20Paused: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EventZRC20PausedStatusUpdated: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EventZRC20Paused: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2090,10 +2203,10 @@ func (m *EventZRC20PausedStatusUpdated) Unmarshal(dAtA []byte) error { m.Zrc20Addresses = append(m.Zrc20Addresses, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } - m.Action = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEvents @@ -2103,12 +2216,139 @@ func (m *EventZRC20PausedStatusUpdated) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Action |= UpdatePausedStatusAction(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 4: + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EventZRC20Unpaused) 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 ErrIntOverflowEvents + } + 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: EventZRC20Unpaused: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventZRC20Unpaused: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Addresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Zrc20Addresses = append(m.Zrc20Addresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) } diff --git a/x/fungible/types/message_update_zrc20_paused_status.go b/x/fungible/types/message_pause_zrc20.go similarity index 54% rename from x/fungible/types/message_update_zrc20_paused_status.go rename to x/fungible/types/message_pause_zrc20.go index cbffdf0324..48adefdd06 100644 --- a/x/fungible/types/message_update_zrc20_paused_status.go +++ b/x/fungible/types/message_pause_zrc20.go @@ -7,31 +7,26 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" ) -const TypeMsgUpdateZRC20PausedStatus = "update_zrc20_withdraw_fee" +const TypeMsgPauseZrc20 = "pause_zrc20" -var _ sdk.Msg = &MsgUpdateZRC20PausedStatus{} +var _ sdk.Msg = &MsgPauseZRC20{} -func NewMsgUpdateZRC20PausedStatus( - creator string, - zrc20 []string, - action UpdatePausedStatusAction, -) *MsgUpdateZRC20PausedStatus { - return &MsgUpdateZRC20PausedStatus{ +func NewMsgPauseZRC20(creator string, zrc20 []string) *MsgPauseZRC20 { + return &MsgPauseZRC20{ Creator: creator, Zrc20Addresses: zrc20, - Action: action, } } -func (msg *MsgUpdateZRC20PausedStatus) Route() string { +func (msg *MsgPauseZRC20) Route() string { return RouterKey } -func (msg *MsgUpdateZRC20PausedStatus) Type() string { - return TypeMsgUpdateZRC20PausedStatus +func (msg *MsgPauseZRC20) Type() string { + return TypeMsgPauseZrc20 } -func (msg *MsgUpdateZRC20PausedStatus) GetSigners() []sdk.AccAddress { +func (msg *MsgPauseZRC20) GetSigners() []sdk.AccAddress { creator, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { panic(err) @@ -39,21 +34,17 @@ func (msg *MsgUpdateZRC20PausedStatus) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{creator} } -func (msg *MsgUpdateZRC20PausedStatus) GetSignBytes() []byte { +func (msg *MsgPauseZRC20) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgUpdateZRC20PausedStatus) ValidateBasic() error { +func (msg *MsgPauseZRC20) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if msg.Action != UpdatePausedStatusAction_PAUSE && msg.Action != UpdatePausedStatusAction_UNPAUSE { - return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid action (%d)", msg.Action) - } - if len(msg.Zrc20Addresses) == 0 { return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, "no zrc20 to update") } diff --git a/x/fungible/types/message_update_zrc20_paused_status_test.go b/x/fungible/types/message_pause_zrc20_test.go similarity index 61% rename from x/fungible/types/message_update_zrc20_paused_status_test.go rename to x/fungible/types/message_pause_zrc20_test.go index 691585711f..a6b6e1fda8 100644 --- a/x/fungible/types/message_update_zrc20_paused_status_test.go +++ b/x/fungible/types/message_pause_zrc20_test.go @@ -10,83 +10,65 @@ import ( "github.com/zeta-chain/zetacore/x/fungible/types" ) -func TestMMsgUpdateZRC20PausedStatus_ValidateBasic(t *testing.T) { +func TestMsgPauseZRC20_ValidateBasic(t *testing.T) { tt := []struct { name string - msg *types.MsgUpdateZRC20PausedStatus + msg *types.MsgPauseZRC20 wantErr bool }{ { name: "valid pause message", - msg: types.NewMsgUpdateZRC20PausedStatus( + msg: types.NewMsgPauseZRC20( sample.AccAddress(), []string{ sample.EthAddress().String(), sample.EthAddress().String(), sample.EthAddress().String(), }, - types.UpdatePausedStatusAction_PAUSE, ), wantErr: false, }, { name: "valid unpause message", - msg: types.NewMsgUpdateZRC20PausedStatus( + msg: types.NewMsgPauseZRC20( sample.AccAddress(), []string{ sample.EthAddress().String(), sample.EthAddress().String(), sample.EthAddress().String(), }, - types.UpdatePausedStatusAction_UNPAUSE, ), wantErr: false, }, { name: "invalid creator address", - msg: types.NewMsgUpdateZRC20PausedStatus( + msg: types.NewMsgPauseZRC20( "invalid", []string{ sample.EthAddress().String(), sample.EthAddress().String(), sample.EthAddress().String(), }, - types.UpdatePausedStatusAction_PAUSE, ), wantErr: true, }, { name: "invalid empty zrc20 address", - msg: types.NewMsgUpdateZRC20PausedStatus( + msg: types.NewMsgPauseZRC20( sample.AccAddress(), []string{}, - types.UpdatePausedStatusAction_PAUSE, ), wantErr: true, }, { name: "invalid zrc20 address", - msg: types.NewMsgUpdateZRC20PausedStatus( + msg: types.NewMsgPauseZRC20( sample.AccAddress(), []string{ sample.EthAddress().String(), "invalid", sample.EthAddress().String(), }, - types.UpdatePausedStatusAction_PAUSE, - ), - wantErr: true, - }, - { - name: "invalid action", - msg: types.NewMsgUpdateZRC20PausedStatus( - sample.AccAddress(), - []string{ - sample.EthAddress().String(), - sample.EthAddress().String(), - sample.EthAddress().String(), - }, - 3, ), wantErr: true, }, @@ -104,23 +86,23 @@ func TestMMsgUpdateZRC20PausedStatus_ValidateBasic(t *testing.T) { } } -func TestMMsgUpdateZRC20PausedStatus_GetSigners(t *testing.T) { +func TestMsgPauseZRC20_GetSigners(t *testing.T) { signer := sample.AccAddress() tests := []struct { name string - msg types.MsgUpdateZRC20PausedStatus + msg types.MsgPauseZRC20 panics bool }{ { name: "valid signer", - msg: types.MsgUpdateZRC20PausedStatus{ + msg: types.MsgPauseZRC20{ Creator: signer, }, panics: false, }, { name: "invalid signer", - msg: types.MsgUpdateZRC20PausedStatus{ + msg: types.MsgPauseZRC20{ Creator: "invalid", }, panics: true, @@ -141,22 +123,22 @@ func TestMMsgUpdateZRC20PausedStatus_GetSigners(t *testing.T) { } } -func TestMMsgUpdateZRC20PausedStatus_Type(t *testing.T) { - msg := types.MsgUpdateZRC20PausedStatus{ +func TestMsgPauseZRC20_Type(t *testing.T) { + msg := types.MsgPauseZRC20{ Creator: sample.AccAddress(), } - require.Equal(t, types.TypeMsgUpdateZRC20PausedStatus, msg.Type()) + require.Equal(t, types.TypeMsgPauseZrc20, msg.Type()) } -func TestMMsgUpdateZRC20PausedStatus_Route(t *testing.T) { - msg := types.MsgUpdateZRC20PausedStatus{ +func TestMsgPauseZRC20_Route(t *testing.T) { + msg := types.MsgPauseZRC20{ Creator: sample.AccAddress(), } require.Equal(t, types.RouterKey, msg.Route()) } -func TestMMsgUpdateZRC20PausedStatus_GetSignBytes(t *testing.T) { - msg := types.MsgUpdateZRC20PausedStatus{ +func TestMsgPauseZRC20_GetSignBytes(t *testing.T) { + msg := types.MsgPauseZRC20{ Creator: sample.AccAddress(), } require.NotPanics(t, func() { diff --git a/x/fungible/types/message_unpause_zrc20.go b/x/fungible/types/message_unpause_zrc20.go new file mode 100644 index 0000000000..560b0c04b3 --- /dev/null +++ b/x/fungible/types/message_unpause_zrc20.go @@ -0,0 +1,59 @@ +package types + +import ( + cosmoserrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcommon "github.com/ethereum/go-ethereum/common" +) + +const TypeMsgUnpauseZRC20 = "unpause_zrc20" + +var _ sdk.Msg = &MsgUnpauseZRC20{} + +func NewMsgUnpauseZRC20(creator string, zrc20 []string) *MsgUnpauseZRC20 { + return &MsgUnpauseZRC20{ + Creator: creator, + Zrc20Addresses: zrc20, + } +} + +func (msg *MsgUnpauseZRC20) Route() string { + return RouterKey +} + +func (msg *MsgUnpauseZRC20) Type() string { + return TypeMsgUnpauseZRC20 +} + +func (msg *MsgUnpauseZRC20) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUnpauseZRC20) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUnpauseZRC20) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if len(msg.Zrc20Addresses) == 0 { + return cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, "no zrc20 to update") + } + + // check if all zrc20 addresses are valid + for _, zrc20 := range msg.Zrc20Addresses { + if !ethcommon.IsHexAddress(zrc20) { + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid zrc20 contract address (%s)", zrc20) + } + } + return nil +} diff --git a/x/fungible/types/message_unpause_zrc20_test.go b/x/fungible/types/message_unpause_zrc20_test.go new file mode 100644 index 0000000000..3a959ab459 --- /dev/null +++ b/x/fungible/types/message_unpause_zrc20_test.go @@ -0,0 +1,147 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/fungible/types" +) + +func TestMsgUnpauseZRC20_ValidateBasic(t *testing.T) { + tt := []struct { + name string + msg *types.MsgUnpauseZRC20 + wantErr bool + }{ + { + name: "valid unpause message", + msg: types.NewMsgUnpauseZRC20( + sample.AccAddress(), + []string{ + sample.EthAddress().String(), + sample.EthAddress().String(), + sample.EthAddress().String(), + }, + ), + wantErr: false, + }, + { + name: "valid unpause message", + msg: types.NewMsgUnpauseZRC20( + sample.AccAddress(), + []string{ + sample.EthAddress().String(), + sample.EthAddress().String(), + sample.EthAddress().String(), + }, + ), + wantErr: false, + }, + { + name: "invalid creator address", + msg: types.NewMsgUnpauseZRC20( + "invalid", + []string{ + sample.EthAddress().String(), + sample.EthAddress().String(), + sample.EthAddress().String(), + }, + ), + wantErr: true, + }, + { + name: "invalid empty zrc20 address", + msg: types.NewMsgUnpauseZRC20( + sample.AccAddress(), + []string{}, + ), + wantErr: true, + }, + { + name: "invalid zrc20 address", + msg: types.NewMsgUnpauseZRC20( + sample.AccAddress(), + []string{ + sample.EthAddress().String(), + "invalid", + sample.EthAddress().String(), + }, + ), + wantErr: true, + }, + } + for _, tc := range tt { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + if tc.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestMsgUnpauseZRC20_GetSigners(t *testing.T) { + signer := sample.AccAddress() + tests := []struct { + name string + msg types.MsgUnpauseZRC20 + panics bool + }{ + { + name: "valid signer", + msg: types.MsgUnpauseZRC20{ + Creator: signer, + }, + panics: false, + }, + { + name: "invalid signer", + msg: types.MsgUnpauseZRC20{ + Creator: "invalid", + }, + panics: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if !tt.panics { + signers := tt.msg.GetSigners() + require.Equal(t, []sdk.AccAddress{sdk.MustAccAddressFromBech32(signer)}, signers) + } else { + require.Panics(t, func() { + tt.msg.GetSigners() + }) + } + }) + } +} + +func TestMsgUnpauseZRC20_Type(t *testing.T) { + msg := types.MsgUnpauseZRC20{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.TypeMsgUnpauseZRC20, msg.Type()) +} + +func TestMsgUnpauseZRC20_Route(t *testing.T) { + msg := types.MsgUnpauseZRC20{ + Creator: sample.AccAddress(), + } + require.Equal(t, types.RouterKey, msg.Route()) +} + +func TestMsgUnpauseZRC20_GetSignBytes(t *testing.T) { + msg := types.MsgUnpauseZRC20{ + Creator: sample.AccAddress(), + } + require.NotPanics(t, func() { + msg.GetSignBytes() + }) +} diff --git a/x/fungible/types/tx.pb.go b/x/fungible/types/tx.pb.go index be4e46fbd0..f72a00bc24 100644 --- a/x/fungible/types/tx.pb.go +++ b/x/fungible/types/tx.pb.go @@ -30,31 +30,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type UpdatePausedStatusAction int32 - -const ( - UpdatePausedStatusAction_PAUSE UpdatePausedStatusAction = 0 - UpdatePausedStatusAction_UNPAUSE UpdatePausedStatusAction = 1 -) - -var UpdatePausedStatusAction_name = map[int32]string{ - 0: "PAUSE", - 1: "UNPAUSE", -} - -var UpdatePausedStatusAction_value = map[string]int32{ - "PAUSE": 0, - "UNPAUSE": 1, -} - -func (x UpdatePausedStatusAction) String() string { - return proto.EnumName(UpdatePausedStatusAction_name, int32(x)) -} - -func (UpdatePausedStatusAction) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_7bea9688d1d01113, []int{0} -} - type MsgDeploySystemContracts struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` } @@ -681,24 +656,24 @@ func (m *MsgUpdateContractBytecodeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateContractBytecodeResponse proto.InternalMessageInfo -type MsgUpdateZRC20PausedStatus struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` - Action UpdatePausedStatusAction `protobuf:"varint,3,opt,name=action,proto3,enum=zetachain.zetacore.fungible.UpdatePausedStatusAction" json:"action,omitempty"` +type MsgUpdateZRC20LiquidityCap struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Zrc20Address string `protobuf:"bytes,2,opt,name=zrc20_address,json=zrc20Address,proto3" json:"zrc20_address,omitempty"` + LiquidityCap github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,3,opt,name=liquidity_cap,json=liquidityCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"liquidity_cap"` } -func (m *MsgUpdateZRC20PausedStatus) Reset() { *m = MsgUpdateZRC20PausedStatus{} } -func (m *MsgUpdateZRC20PausedStatus) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateZRC20PausedStatus) ProtoMessage() {} -func (*MsgUpdateZRC20PausedStatus) Descriptor() ([]byte, []int) { +func (m *MsgUpdateZRC20LiquidityCap) Reset() { *m = MsgUpdateZRC20LiquidityCap{} } +func (m *MsgUpdateZRC20LiquidityCap) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateZRC20LiquidityCap) ProtoMessage() {} +func (*MsgUpdateZRC20LiquidityCap) Descriptor() ([]byte, []int) { return fileDescriptor_7bea9688d1d01113, []int{12} } -func (m *MsgUpdateZRC20PausedStatus) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateZRC20LiquidityCap) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateZRC20PausedStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateZRC20LiquidityCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateZRC20PausedStatus.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateZRC20LiquidityCap.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -708,54 +683,135 @@ func (m *MsgUpdateZRC20PausedStatus) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgUpdateZRC20PausedStatus) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateZRC20PausedStatus.Merge(m, src) +func (m *MsgUpdateZRC20LiquidityCap) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateZRC20LiquidityCap.Merge(m, src) } -func (m *MsgUpdateZRC20PausedStatus) XXX_Size() int { +func (m *MsgUpdateZRC20LiquidityCap) XXX_Size() int { return m.Size() } -func (m *MsgUpdateZRC20PausedStatus) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateZRC20PausedStatus.DiscardUnknown(m) +func (m *MsgUpdateZRC20LiquidityCap) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateZRC20LiquidityCap.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateZRC20PausedStatus proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateZRC20LiquidityCap proto.InternalMessageInfo -func (m *MsgUpdateZRC20PausedStatus) GetCreator() string { +func (m *MsgUpdateZRC20LiquidityCap) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgUpdateZRC20PausedStatus) GetZrc20Addresses() []string { +func (m *MsgUpdateZRC20LiquidityCap) GetZrc20Address() string { if m != nil { - return m.Zrc20Addresses + return m.Zrc20Address } - return nil + return "" +} + +type MsgUpdateZRC20LiquidityCapResponse struct { +} + +func (m *MsgUpdateZRC20LiquidityCapResponse) Reset() { *m = MsgUpdateZRC20LiquidityCapResponse{} } +func (m *MsgUpdateZRC20LiquidityCapResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateZRC20LiquidityCapResponse) ProtoMessage() {} +func (*MsgUpdateZRC20LiquidityCapResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7bea9688d1d01113, []int{13} +} +func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse.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 *MsgUpdateZRC20LiquidityCapResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse.Merge(m, src) +} +func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse proto.InternalMessageInfo + +type MsgPauseZRC20 struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` +} + +func (m *MsgPauseZRC20) Reset() { *m = MsgPauseZRC20{} } +func (m *MsgPauseZRC20) String() string { return proto.CompactTextString(m) } +func (*MsgPauseZRC20) ProtoMessage() {} +func (*MsgPauseZRC20) Descriptor() ([]byte, []int) { + return fileDescriptor_7bea9688d1d01113, []int{14} +} +func (m *MsgPauseZRC20) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPauseZRC20) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPauseZRC20.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 *MsgPauseZRC20) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPauseZRC20.Merge(m, src) +} +func (m *MsgPauseZRC20) XXX_Size() int { + return m.Size() +} +func (m *MsgPauseZRC20) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPauseZRC20.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPauseZRC20 proto.InternalMessageInfo + +func (m *MsgPauseZRC20) GetCreator() string { + if m != nil { + return m.Creator + } + return "" } -func (m *MsgUpdateZRC20PausedStatus) GetAction() UpdatePausedStatusAction { +func (m *MsgPauseZRC20) GetZrc20Addresses() []string { if m != nil { - return m.Action + return m.Zrc20Addresses } - return UpdatePausedStatusAction_PAUSE + return nil } -type MsgUpdateZRC20PausedStatusResponse struct { +type MsgPauseZRC20Response struct { } -func (m *MsgUpdateZRC20PausedStatusResponse) Reset() { *m = MsgUpdateZRC20PausedStatusResponse{} } -func (m *MsgUpdateZRC20PausedStatusResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateZRC20PausedStatusResponse) ProtoMessage() {} -func (*MsgUpdateZRC20PausedStatusResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7bea9688d1d01113, []int{13} +func (m *MsgPauseZRC20Response) Reset() { *m = MsgPauseZRC20Response{} } +func (m *MsgPauseZRC20Response) String() string { return proto.CompactTextString(m) } +func (*MsgPauseZRC20Response) ProtoMessage() {} +func (*MsgPauseZRC20Response) Descriptor() ([]byte, []int) { + return fileDescriptor_7bea9688d1d01113, []int{15} } -func (m *MsgUpdateZRC20PausedStatusResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgPauseZRC20Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateZRC20PausedStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgPauseZRC20Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateZRC20PausedStatusResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgPauseZRC20Response.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -765,36 +821,35 @@ func (m *MsgUpdateZRC20PausedStatusResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *MsgUpdateZRC20PausedStatusResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateZRC20PausedStatusResponse.Merge(m, src) +func (m *MsgPauseZRC20Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPauseZRC20Response.Merge(m, src) } -func (m *MsgUpdateZRC20PausedStatusResponse) XXX_Size() int { +func (m *MsgPauseZRC20Response) XXX_Size() int { return m.Size() } -func (m *MsgUpdateZRC20PausedStatusResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateZRC20PausedStatusResponse.DiscardUnknown(m) +func (m *MsgPauseZRC20Response) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPauseZRC20Response.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateZRC20PausedStatusResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgPauseZRC20Response proto.InternalMessageInfo -type MsgUpdateZRC20LiquidityCap struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - Zrc20Address string `protobuf:"bytes,2,opt,name=zrc20_address,json=zrc20Address,proto3" json:"zrc20_address,omitempty"` - LiquidityCap github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,3,opt,name=liquidity_cap,json=liquidityCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"liquidity_cap"` +type MsgUnpauseZRC20 struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` } -func (m *MsgUpdateZRC20LiquidityCap) Reset() { *m = MsgUpdateZRC20LiquidityCap{} } -func (m *MsgUpdateZRC20LiquidityCap) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateZRC20LiquidityCap) ProtoMessage() {} -func (*MsgUpdateZRC20LiquidityCap) Descriptor() ([]byte, []int) { - return fileDescriptor_7bea9688d1d01113, []int{14} +func (m *MsgUnpauseZRC20) Reset() { *m = MsgUnpauseZRC20{} } +func (m *MsgUnpauseZRC20) String() string { return proto.CompactTextString(m) } +func (*MsgUnpauseZRC20) ProtoMessage() {} +func (*MsgUnpauseZRC20) Descriptor() ([]byte, []int) { + return fileDescriptor_7bea9688d1d01113, []int{16} } -func (m *MsgUpdateZRC20LiquidityCap) XXX_Unmarshal(b []byte) error { +func (m *MsgUnpauseZRC20) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateZRC20LiquidityCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUnpauseZRC20) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateZRC20LiquidityCap.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUnpauseZRC20.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -804,47 +859,47 @@ func (m *MsgUpdateZRC20LiquidityCap) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgUpdateZRC20LiquidityCap) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateZRC20LiquidityCap.Merge(m, src) +func (m *MsgUnpauseZRC20) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnpauseZRC20.Merge(m, src) } -func (m *MsgUpdateZRC20LiquidityCap) XXX_Size() int { +func (m *MsgUnpauseZRC20) XXX_Size() int { return m.Size() } -func (m *MsgUpdateZRC20LiquidityCap) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateZRC20LiquidityCap.DiscardUnknown(m) +func (m *MsgUnpauseZRC20) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnpauseZRC20.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateZRC20LiquidityCap proto.InternalMessageInfo +var xxx_messageInfo_MsgUnpauseZRC20 proto.InternalMessageInfo -func (m *MsgUpdateZRC20LiquidityCap) GetCreator() string { +func (m *MsgUnpauseZRC20) GetCreator() string { if m != nil { return m.Creator } return "" } -func (m *MsgUpdateZRC20LiquidityCap) GetZrc20Address() string { +func (m *MsgUnpauseZRC20) GetZrc20Addresses() []string { if m != nil { - return m.Zrc20Address + return m.Zrc20Addresses } - return "" + return nil } -type MsgUpdateZRC20LiquidityCapResponse struct { +type MsgUnpauseZRC20Response struct { } -func (m *MsgUpdateZRC20LiquidityCapResponse) Reset() { *m = MsgUpdateZRC20LiquidityCapResponse{} } -func (m *MsgUpdateZRC20LiquidityCapResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateZRC20LiquidityCapResponse) ProtoMessage() {} -func (*MsgUpdateZRC20LiquidityCapResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7bea9688d1d01113, []int{15} +func (m *MsgUnpauseZRC20Response) Reset() { *m = MsgUnpauseZRC20Response{} } +func (m *MsgUnpauseZRC20Response) String() string { return proto.CompactTextString(m) } +func (*MsgUnpauseZRC20Response) ProtoMessage() {} +func (*MsgUnpauseZRC20Response) Descriptor() ([]byte, []int) { + return fileDescriptor_7bea9688d1d01113, []int{17} } -func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUnpauseZRC20Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUnpauseZRC20Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUnpauseZRC20Response.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -854,20 +909,19 @@ func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse.Merge(m, src) +func (m *MsgUnpauseZRC20Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUnpauseZRC20Response.Merge(m, src) } -func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_Size() int { +func (m *MsgUnpauseZRC20Response) XXX_Size() int { return m.Size() } -func (m *MsgUpdateZRC20LiquidityCapResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse.DiscardUnknown(m) +func (m *MsgUnpauseZRC20Response) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUnpauseZRC20Response.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateZRC20LiquidityCapResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUnpauseZRC20Response proto.InternalMessageInfo func init() { - proto.RegisterEnum("zetachain.zetacore.fungible.UpdatePausedStatusAction", UpdatePausedStatusAction_name, UpdatePausedStatusAction_value) proto.RegisterType((*MsgDeploySystemContracts)(nil), "zetachain.zetacore.fungible.MsgDeploySystemContracts") proto.RegisterType((*MsgDeploySystemContractsResponse)(nil), "zetachain.zetacore.fungible.MsgDeploySystemContractsResponse") proto.RegisterType((*MsgUpdateZRC20WithdrawFee)(nil), "zetachain.zetacore.fungible.MsgUpdateZRC20WithdrawFee") @@ -880,10 +934,12 @@ func init() { proto.RegisterType((*MsgRemoveForeignCoinResponse)(nil), "zetachain.zetacore.fungible.MsgRemoveForeignCoinResponse") proto.RegisterType((*MsgUpdateContractBytecode)(nil), "zetachain.zetacore.fungible.MsgUpdateContractBytecode") proto.RegisterType((*MsgUpdateContractBytecodeResponse)(nil), "zetachain.zetacore.fungible.MsgUpdateContractBytecodeResponse") - proto.RegisterType((*MsgUpdateZRC20PausedStatus)(nil), "zetachain.zetacore.fungible.MsgUpdateZRC20PausedStatus") - proto.RegisterType((*MsgUpdateZRC20PausedStatusResponse)(nil), "zetachain.zetacore.fungible.MsgUpdateZRC20PausedStatusResponse") proto.RegisterType((*MsgUpdateZRC20LiquidityCap)(nil), "zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCap") proto.RegisterType((*MsgUpdateZRC20LiquidityCapResponse)(nil), "zetachain.zetacore.fungible.MsgUpdateZRC20LiquidityCapResponse") + proto.RegisterType((*MsgPauseZRC20)(nil), "zetachain.zetacore.fungible.MsgPauseZRC20") + proto.RegisterType((*MsgPauseZRC20Response)(nil), "zetachain.zetacore.fungible.MsgPauseZRC20Response") + proto.RegisterType((*MsgUnpauseZRC20)(nil), "zetachain.zetacore.fungible.MsgUnpauseZRC20") + proto.RegisterType((*MsgUnpauseZRC20Response)(nil), "zetachain.zetacore.fungible.MsgUnpauseZRC20Response") } func init() { @@ -891,71 +947,70 @@ func init() { } var fileDescriptor_7bea9688d1d01113 = []byte{ - // 1013 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xdd, 0x6e, 0x1b, 0x45, - 0x14, 0xce, 0x26, 0xcd, 0x8f, 0x4f, 0x6b, 0xc7, 0x8c, 0x4c, 0xbb, 0x38, 0xc8, 0x69, 0xb7, 0xa1, - 0x0d, 0x95, 0x6a, 0x17, 0x53, 0xa8, 0x90, 0x68, 0x51, 0xe2, 0x26, 0x50, 0xa9, 0x46, 0xd5, 0xa6, - 0x29, 0x22, 0x37, 0xab, 0xc9, 0xee, 0x64, 0xbd, 0x8a, 0x3d, 0xb3, 0xec, 0x8c, 0x71,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0x34, 0xd8, 0x0f, 0x13, 0xca, 0x75, - 0x1f, 0xd6, 0xa4, 0xdc, 0xb0, 0xf8, 0x96, 0x1d, 0x01, 0x86, 0x8a, 0xa7, 0x53, 0xd2, 0x1b, 0x64, - 0x8c, 0x0a, 0x69, 0x5c, 0x83, 0xf5, 0x8c, 0xff, 0x99, 0xc8, 0xfa, 0x7d, 0x1e, 0xca, 0x49, 0x9f, - 0xee, 0x46, 0x13, 0xd3, 0x60, 0x1e, 0x55, 0x89, 0x4c, 0x90, 0x56, 0x82, 0xc5, 0x1d, 0x19, 0x12, - 0xf7, 0xa3, 0x5a, 0xa0, 0x4d, 0x28, 0x1e, 0xb1, 0x80, 0x78, 0x2e, 0xb5, 0xd4, 0x68, 0x59, 0x9e, - 0xa3, 0x1a, 0x72, 0xc1, 0x2c, 0x44, 0xfb, 0x0d, 0xb9, 0xfd, 0xc8, 0x41, 0x65, 0x58, 0x71, 0x88, - 0xed, 0x75, 0x70, 0x9b, 0xab, 0x56, 0xcc, 0x9b, 0xc9, 0x1a, 0x21, 0xb8, 0x40, 0x71, 0x87, 0x44, - 0xbd, 0xa7, 0x9e, 0xd1, 0x65, 0x58, 0xe2, 0xfd, 0xce, 0x21, 0x6b, 0x87, 0xad, 0x60, 0x46, 0x2b, - 0xb4, 0x0d, 0x39, 0x39, 0xac, 0x96, 0x3c, 0x1c, 0x75, 0x9a, 0x85, 0xfa, 0x47, 0xd5, 0x31, 0x6e, - 0xe0, 0x1f, 0xbb, 0x55, 0x35, 0xd5, 0x32, 0xb9, 0xa7, 0x7d, 0x9f, 0x98, 0x2b, 0x76, 0xf4, 0x84, - 0xd6, 0x20, 0xf7, 0xae, 0x23, 0x56, 0x94, 0xdc, 0x15, 0x37, 0x3e, 0xdd, 0x07, 0x60, 0x64, 0x17, - 0x28, 0x19, 0x65, 0x1d, 0x96, 0xe3, 0x53, 0x89, 0x0a, 0x15, 0x2d, 0x8d, 0x87, 0x50, 0x6a, 0x72, - 0xd7, 0x24, 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, 0x9d, 0x56, - 0xe6, 0x0e, 0x6a, 0x29, 0xef, 0x94, 0xd4, 0xb7, 0x87, 0xbe, 0x0a, 0x9e, 0xa7, 0x3e, 0x38, 0xa4, - 0x91, 0x1e, 0x2e, 0xa9, 0x2f, 0x83, 0x4f, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x1c, 0x83, - 0x64, 0x9c, 0x0c, 0x00, 0x00, + // 998 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xdd, 0x6e, 0xdb, 0x46, + 0x13, 0x35, 0xed, 0xf8, 0x6f, 0x3e, 0xcb, 0xf6, 0xb7, 0x50, 0x62, 0x86, 0x2e, 0xe4, 0x84, 0x71, + 0x13, 0x37, 0x68, 0xc4, 0x54, 0x75, 0x1b, 0x14, 0x68, 0x52, 0xd4, 0x4a, 0xdc, 0x06, 0x88, 0x80, + 0x82, 0x71, 0x52, 0xd4, 0x37, 0xc4, 0x9a, 0x5c, 0x53, 0x84, 0xa5, 0x5d, 0x96, 0x4b, 0x55, 0x51, + 0xee, 0x0a, 0xf4, 0x2a, 0x40, 0x81, 0x00, 0x7d, 0x80, 0x3e, 0x43, 0xdf, 0x22, 0x97, 0xb9, 0x2c, + 0x82, 0x22, 0x28, 0xec, 0x17, 0x29, 0x76, 0xf9, 0x63, 0x52, 0x12, 0x25, 0x59, 0xed, 0x8d, 0xcd, + 0x1d, 0x9d, 0x39, 0x7b, 0x66, 0x76, 0x66, 0x96, 0x84, 0xed, 0x97, 0x24, 0xc4, 0x76, 0x13, 0x7b, + 0xd4, 0x90, 0x4f, 0x2c, 0x20, 0xc6, 0x71, 0x87, 0xba, 0xde, 0x51, 0x8b, 0x18, 0xe1, 0x8b, 0xaa, + 0x1f, 0xb0, 0x90, 0xa1, 0xcd, 0x14, 0x55, 0x4d, 0x50, 0xd5, 0x04, 0xa5, 0x95, 0x5d, 0xe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60, 0x3a, 0xbf, 0x21, 0x92, 0x06, 0xde, 0x61, 0x26, + 0x94, 0xd4, 0xef, 0x37, 0xa9, 0xa4, 0xa2, 0xf7, 0x04, 0x59, 0xcc, 0x45, 0x93, 0xf1, 0xde, 0x05, + 0xb8, 0xb3, 0x8e, 0xe3, 0x8b, 0x79, 0xcc, 0x60, 0x43, 0x2d, 0x80, 0xcc, 0x54, 0xbb, 0x3d, 0x8e, + 0xee, 0x1c, 0xab, 0xd5, 0x26, 0xc7, 0xa6, 0xbb, 0x05, 0xb0, 0x92, 0x1b, 0x6b, 0x1f, 0x8f, 0x95, + 0x9f, 0x41, 0x6b, 0xbb, 0x17, 0x41, 0x27, 0x7b, 0xee, 0x3d, 0x7e, 0x73, 0x5a, 0x51, 0xde, 0x9e, + 0x56, 0x94, 0xbf, 0x4f, 0x2b, 0xca, 0xeb, 0xb3, 0xca, 0xcc, 0xdb, 0xb3, 0xca, 0xcc, 0x9f, 0x67, + 0x95, 0x99, 0x43, 0x23, 0x73, 0x63, 0x08, 0xbe, 0x3b, 0x7d, 0x1f, 0x0d, 0x2f, 0x32, 0xdf, 0x23, + 0xe2, 0xfa, 0x38, 0x5a, 0x90, 0x1f, 0x0e, 0x9f, 0xfe, 0x13, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x35, + 0xf0, 0xc9, 0xbb, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -976,8 +1031,9 @@ type MsgClient interface { UpdateSystemContract(ctx context.Context, in *MsgUpdateSystemContract, opts ...grpc.CallOption) (*MsgUpdateSystemContractResponse, error) UpdateContractBytecode(ctx context.Context, in *MsgUpdateContractBytecode, opts ...grpc.CallOption) (*MsgUpdateContractBytecodeResponse, error) UpdateZRC20WithdrawFee(ctx context.Context, in *MsgUpdateZRC20WithdrawFee, opts ...grpc.CallOption) (*MsgUpdateZRC20WithdrawFeeResponse, error) - UpdateZRC20PausedStatus(ctx context.Context, in *MsgUpdateZRC20PausedStatus, opts ...grpc.CallOption) (*MsgUpdateZRC20PausedStatusResponse, error) UpdateZRC20LiquidityCap(ctx context.Context, in *MsgUpdateZRC20LiquidityCap, opts ...grpc.CallOption) (*MsgUpdateZRC20LiquidityCapResponse, error) + PauseZRC20(ctx context.Context, in *MsgPauseZRC20, opts ...grpc.CallOption) (*MsgPauseZRC20Response, error) + UnpauseZRC20(ctx context.Context, in *MsgUnpauseZRC20, opts ...grpc.CallOption) (*MsgUnpauseZRC20Response, error) } type msgClient struct { @@ -1042,18 +1098,27 @@ func (c *msgClient) UpdateZRC20WithdrawFee(ctx context.Context, in *MsgUpdateZRC return out, nil } -func (c *msgClient) UpdateZRC20PausedStatus(ctx context.Context, in *MsgUpdateZRC20PausedStatus, opts ...grpc.CallOption) (*MsgUpdateZRC20PausedStatusResponse, error) { - out := new(MsgUpdateZRC20PausedStatusResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/UpdateZRC20PausedStatus", in, out, opts...) +func (c *msgClient) UpdateZRC20LiquidityCap(ctx context.Context, in *MsgUpdateZRC20LiquidityCap, opts ...grpc.CallOption) (*MsgUpdateZRC20LiquidityCapResponse, error) { + out := new(MsgUpdateZRC20LiquidityCapResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/UpdateZRC20LiquidityCap", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) UpdateZRC20LiquidityCap(ctx context.Context, in *MsgUpdateZRC20LiquidityCap, opts ...grpc.CallOption) (*MsgUpdateZRC20LiquidityCapResponse, error) { - out := new(MsgUpdateZRC20LiquidityCapResponse) - err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/UpdateZRC20LiquidityCap", in, out, opts...) +func (c *msgClient) PauseZRC20(ctx context.Context, in *MsgPauseZRC20, opts ...grpc.CallOption) (*MsgPauseZRC20Response, error) { + out := new(MsgPauseZRC20Response) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/PauseZRC20", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UnpauseZRC20(ctx context.Context, in *MsgUnpauseZRC20, opts ...grpc.CallOption) (*MsgUnpauseZRC20Response, error) { + out := new(MsgUnpauseZRC20Response) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/UnpauseZRC20", in, out, opts...) if err != nil { return nil, err } @@ -1068,8 +1133,9 @@ type MsgServer interface { UpdateSystemContract(context.Context, *MsgUpdateSystemContract) (*MsgUpdateSystemContractResponse, error) UpdateContractBytecode(context.Context, *MsgUpdateContractBytecode) (*MsgUpdateContractBytecodeResponse, error) UpdateZRC20WithdrawFee(context.Context, *MsgUpdateZRC20WithdrawFee) (*MsgUpdateZRC20WithdrawFeeResponse, error) - UpdateZRC20PausedStatus(context.Context, *MsgUpdateZRC20PausedStatus) (*MsgUpdateZRC20PausedStatusResponse, error) UpdateZRC20LiquidityCap(context.Context, *MsgUpdateZRC20LiquidityCap) (*MsgUpdateZRC20LiquidityCapResponse, error) + PauseZRC20(context.Context, *MsgPauseZRC20) (*MsgPauseZRC20Response, error) + UnpauseZRC20(context.Context, *MsgUnpauseZRC20) (*MsgUnpauseZRC20Response, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1094,12 +1160,15 @@ func (*UnimplementedMsgServer) UpdateContractBytecode(ctx context.Context, req * func (*UnimplementedMsgServer) UpdateZRC20WithdrawFee(ctx context.Context, req *MsgUpdateZRC20WithdrawFee) (*MsgUpdateZRC20WithdrawFeeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateZRC20WithdrawFee not implemented") } -func (*UnimplementedMsgServer) UpdateZRC20PausedStatus(ctx context.Context, req *MsgUpdateZRC20PausedStatus) (*MsgUpdateZRC20PausedStatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateZRC20PausedStatus not implemented") -} func (*UnimplementedMsgServer) UpdateZRC20LiquidityCap(ctx context.Context, req *MsgUpdateZRC20LiquidityCap) (*MsgUpdateZRC20LiquidityCapResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateZRC20LiquidityCap not implemented") } +func (*UnimplementedMsgServer) PauseZRC20(ctx context.Context, req *MsgPauseZRC20) (*MsgPauseZRC20Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method PauseZRC20 not implemented") +} +func (*UnimplementedMsgServer) UnpauseZRC20(ctx context.Context, req *MsgUnpauseZRC20) (*MsgUnpauseZRC20Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnpauseZRC20 not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -1213,38 +1282,56 @@ func _Msg_UpdateZRC20WithdrawFee_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } -func _Msg_UpdateZRC20PausedStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateZRC20PausedStatus) +func _Msg_UpdateZRC20LiquidityCap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateZRC20LiquidityCap) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).UpdateZRC20PausedStatus(ctx, in) + return srv.(MsgServer).UpdateZRC20LiquidityCap(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.fungible.Msg/UpdateZRC20PausedStatus", + FullMethod: "/zetachain.zetacore.fungible.Msg/UpdateZRC20LiquidityCap", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateZRC20PausedStatus(ctx, req.(*MsgUpdateZRC20PausedStatus)) + return srv.(MsgServer).UpdateZRC20LiquidityCap(ctx, req.(*MsgUpdateZRC20LiquidityCap)) } return interceptor(ctx, in, info, handler) } -func _Msg_UpdateZRC20LiquidityCap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateZRC20LiquidityCap) +func _Msg_PauseZRC20_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPauseZRC20) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).UpdateZRC20LiquidityCap(ctx, in) + return srv.(MsgServer).PauseZRC20(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/zetachain.zetacore.fungible.Msg/UpdateZRC20LiquidityCap", + FullMethod: "/zetachain.zetacore.fungible.Msg/PauseZRC20", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateZRC20LiquidityCap(ctx, req.(*MsgUpdateZRC20LiquidityCap)) + return srv.(MsgServer).PauseZRC20(ctx, req.(*MsgPauseZRC20)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UnpauseZRC20_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUnpauseZRC20) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UnpauseZRC20(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.fungible.Msg/UnpauseZRC20", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UnpauseZRC20(ctx, req.(*MsgUnpauseZRC20)) } return interceptor(ctx, in, info, handler) } @@ -1277,14 +1364,18 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateZRC20WithdrawFee", Handler: _Msg_UpdateZRC20WithdrawFee_Handler, }, - { - MethodName: "UpdateZRC20PausedStatus", - Handler: _Msg_UpdateZRC20PausedStatus_Handler, - }, { MethodName: "UpdateZRC20LiquidityCap", Handler: _Msg_UpdateZRC20LiquidityCap_Handler, }, + { + MethodName: "PauseZRC20", + Handler: _Msg_PauseZRC20_Handler, + }, + { + MethodName: "UnpauseZRC20", + Handler: _Msg_UnpauseZRC20_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "zetachain/zetacore/fungible/tx.proto", @@ -1746,7 +1837,7 @@ func (m *MsgUpdateContractBytecodeResponse) MarshalToSizedBuffer(dAtA []byte) (i return len(dAtA) - i, nil } -func (m *MsgUpdateZRC20PausedStatus) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateZRC20LiquidityCap) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1756,21 +1847,86 @@ func (m *MsgUpdateZRC20PausedStatus) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateZRC20PausedStatus) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateZRC20LiquidityCap) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateZRC20PausedStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateZRC20LiquidityCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Action != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Action)) + { + size := m.LiquidityCap.Size() + i -= size + if _, err := m.LiquidityCap.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Zrc20Address) > 0 { + i -= len(m.Zrc20Address) + copy(dAtA[i:], m.Zrc20Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Zrc20Address))) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateZRC20LiquidityCapResponse) 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 *MsgUpdateZRC20LiquidityCapResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateZRC20LiquidityCapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgPauseZRC20) 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 *MsgPauseZRC20) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPauseZRC20) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l if len(m.Zrc20Addresses) > 0 { for iNdEx := len(m.Zrc20Addresses) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Zrc20Addresses[iNdEx]) @@ -1790,7 +1946,7 @@ func (m *MsgUpdateZRC20PausedStatus) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgUpdateZRC20PausedStatusResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgPauseZRC20Response) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1800,12 +1956,12 @@ func (m *MsgUpdateZRC20PausedStatusResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *MsgUpdateZRC20PausedStatusResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgPauseZRC20Response) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateZRC20PausedStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgPauseZRC20Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1813,7 +1969,7 @@ func (m *MsgUpdateZRC20PausedStatusResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } -func (m *MsgUpdateZRC20LiquidityCap) Marshal() (dAtA []byte, err error) { +func (m *MsgUnpauseZRC20) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1823,32 +1979,24 @@ func (m *MsgUpdateZRC20LiquidityCap) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateZRC20LiquidityCap) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUnpauseZRC20) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateZRC20LiquidityCap) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUnpauseZRC20) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size := m.LiquidityCap.Size() - i -= size - if _, err := m.LiquidityCap.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.Zrc20Addresses) > 0 { + for iNdEx := len(m.Zrc20Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Zrc20Addresses[iNdEx]) + copy(dAtA[i:], m.Zrc20Addresses[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Zrc20Addresses[iNdEx]))) + i-- + dAtA[i] = 0x12 } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Zrc20Address) > 0 { - i -= len(m.Zrc20Address) - copy(dAtA[i:], m.Zrc20Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Zrc20Address))) - i-- - dAtA[i] = 0x12 } if len(m.Creator) > 0 { i -= len(m.Creator) @@ -1860,7 +2008,7 @@ func (m *MsgUpdateZRC20LiquidityCap) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgUpdateZRC20LiquidityCapResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUnpauseZRC20Response) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1870,12 +2018,12 @@ func (m *MsgUpdateZRC20LiquidityCapResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *MsgUpdateZRC20LiquidityCapResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUnpauseZRC20Response) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateZRC20LiquidityCapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUnpauseZRC20Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2098,7 +2246,35 @@ func (m *MsgUpdateContractBytecodeResponse) Size() (n int) { return n } -func (m *MsgUpdateZRC20PausedStatus) Size() (n int) { +func (m *MsgUpdateZRC20LiquidityCap) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Zrc20Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.LiquidityCap.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateZRC20LiquidityCapResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgPauseZRC20) Size() (n int) { if m == nil { return 0 } @@ -2114,13 +2290,10 @@ func (m *MsgUpdateZRC20PausedStatus) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } } - if m.Action != 0 { - n += 1 + sovTx(uint64(m.Action)) - } return n } -func (m *MsgUpdateZRC20PausedStatusResponse) Size() (n int) { +func (m *MsgPauseZRC20Response) Size() (n int) { if m == nil { return 0 } @@ -2129,7 +2302,7 @@ func (m *MsgUpdateZRC20PausedStatusResponse) Size() (n int) { return n } -func (m *MsgUpdateZRC20LiquidityCap) Size() (n int) { +func (m *MsgUnpauseZRC20) Size() (n int) { if m == nil { return 0 } @@ -2139,16 +2312,16 @@ func (m *MsgUpdateZRC20LiquidityCap) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Zrc20Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Zrc20Addresses) > 0 { + for _, s := range m.Zrc20Addresses { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } } - l = m.LiquidityCap.Size() - n += 1 + l + sovTx(uint64(l)) return n } -func (m *MsgUpdateZRC20LiquidityCapResponse) Size() (n int) { +func (m *MsgUnpauseZRC20Response) Size() (n int) { if m == nil { return 0 } @@ -3547,7 +3720,7 @@ func (m *MsgUpdateContractBytecodeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateZRC20PausedStatus) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateZRC20LiquidityCap) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3570,10 +3743,10 @@ func (m *MsgUpdateZRC20PausedStatus) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateZRC20PausedStatus: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCap: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateZRC20PausedStatus: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCap: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3610,7 +3783,7 @@ func (m *MsgUpdateZRC20PausedStatus) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Addresses", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3638,13 +3811,13 @@ func (m *MsgUpdateZRC20PausedStatus) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Zrc20Addresses = append(m.Zrc20Addresses, string(dAtA[iNdEx:postIndex])) + m.Zrc20Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Action", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidityCap", wireType) } - m.Action = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -3654,11 +3827,26 @@ func (m *MsgUpdateZRC20PausedStatus) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Action |= UpdatePausedStatusAction(b&0x7F) << shift + 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 + } + if err := m.LiquidityCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3680,7 +3868,7 @@ func (m *MsgUpdateZRC20PausedStatus) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateZRC20PausedStatusResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateZRC20LiquidityCapResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3703,10 +3891,10 @@ func (m *MsgUpdateZRC20PausedStatusResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateZRC20PausedStatusResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCapResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateZRC20PausedStatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCapResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -3730,7 +3918,7 @@ func (m *MsgUpdateZRC20PausedStatusResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateZRC20LiquidityCap) Unmarshal(dAtA []byte) error { +func (m *MsgPauseZRC20) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3753,10 +3941,10 @@ func (m *MsgUpdateZRC20LiquidityCap) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCap: wiretype end group for non-group") + return fmt.Errorf("proto: MsgPauseZRC20: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCap: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgPauseZRC20: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3793,7 +3981,7 @@ func (m *MsgUpdateZRC20LiquidityCap) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Addresses", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3821,11 +4009,111 @@ func (m *MsgUpdateZRC20LiquidityCap) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Zrc20Address = string(dAtA[iNdEx:postIndex]) + m.Zrc20Addresses = append(m.Zrc20Addresses, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 3: + 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 *MsgPauseZRC20Response) 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: MsgPauseZRC20Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPauseZRC20Response: 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 *MsgUnpauseZRC20) 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: MsgUnpauseZRC20: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUnpauseZRC20: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidityCap", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3853,9 +4141,39 @@ func (m *MsgUpdateZRC20LiquidityCap) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.LiquidityCap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Zrc20Addresses", 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.Zrc20Addresses = append(m.Zrc20Addresses, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -3878,7 +4196,7 @@ func (m *MsgUpdateZRC20LiquidityCap) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateZRC20LiquidityCapResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUnpauseZRC20Response) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3901,10 +4219,10 @@ func (m *MsgUpdateZRC20LiquidityCapResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCapResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUnpauseZRC20Response: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateZRC20LiquidityCapResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUnpauseZRC20Response: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 89ca461c7b15a339dd31be4dffb7f9e42ba8709e Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 29 May 2024 02:19:34 -0700 Subject: [PATCH 2/3] fix: remove quotes from e2e args (#2284) --- contrib/localnet/orchestrator/start-zetae2e.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index ead84ee4d1..a297be595b 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -136,9 +136,9 @@ if [ "$OPTION" == "upgrade" ]; then # When the upgrade height is greater than 100 for upgrade test, the Bitcoin tests have been run once, therefore the Bitcoin wallet is already set up # Use light flag to skip advanced tests if [ "$UPGRADE_HEIGHT" -lt 100 ]; then - zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --light --skip-header-proof + zetae2e $ZETAE2E_CMD --skip-setup --config deployed.yml --light --skip-header-proof else - zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof + zetae2e $ZETAE2E_CMD --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof fi ZETAE2E_EXIT_CODE=$? @@ -156,7 +156,7 @@ else echo "running e2e setup..." if [[ ! -f deployed.yml ]]; then - zetae2e "$ZETAE2E_CMD" --setup-only --config-out deployed.yml + zetae2e $ZETAE2E_CMD --setup-only --config-out deployed.yml if [ $? -ne 0 ]; then echo "e2e setup failed" exit 1 @@ -167,7 +167,7 @@ else echo "running e2e tests..." - zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml + zetae2e $ZETAE2E_CMD --skip-setup --config deployed.yml ZETAE2E_EXIT_CODE=$? # if e2e passed, exit with 0, otherwise exit with 1 From 42fe69cd9186aee8995d6a9f5e341fd9b2f32186 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Wed, 29 May 2024 16:22:15 +0200 Subject: [PATCH 3/3] feat: add `ChainInfo` singleton state variable in `authority` (#2275) * add chain validate method * add chain info type * add chain info type proto * add chain info in genesis * generate * changelog * Update x/authority/types/chain_info.go Co-authored-by: Tanmay * revert is ZetaChain logic * fix name --------- Co-authored-by: Tanmay --- changelog.md | 1 + pkg/chains/chain.go | 33 ++ pkg/chains/chain_test.go | 127 +++++++ .../zetacore/authority/chain_info.proto | 14 + .../zetacore/authority/genesis.proto | 6 +- testutil/sample/authority.go | 19 +- testutil/sample/sample.go | 15 +- .../zetacore/authority/chain_info_pb.d.ts | 37 ++ .../zetacore/authority/genesis_pb.d.ts | 6 + .../zetachain/zetacore/authority/index.d.ts | 1 + x/authority/genesis.go | 6 + x/authority/genesis_test.go | 8 +- x/authority/keeper/chain_info.go | 26 ++ x/authority/keeper/chain_info_test.go | 33 ++ x/authority/types/chain_info.go | 30 ++ x/authority/types/chain_info.pb.go | 335 ++++++++++++++++++ x/authority/types/chain_info_test.go | 79 +++++ x/authority/types/genesis.go | 9 +- x/authority/types/genesis.pb.go | 78 +++- x/authority/types/genesis_test.go | 25 +- x/authority/types/keys.go | 3 + 21 files changed, 872 insertions(+), 19 deletions(-) create mode 100644 proto/zetachain/zetacore/authority/chain_info.proto create mode 100644 typescript/zetachain/zetacore/authority/chain_info_pb.d.ts create mode 100644 x/authority/keeper/chain_info.go create mode 100644 x/authority/keeper/chain_info_test.go create mode 100644 x/authority/types/chain_info.go create mode 100644 x/authority/types/chain_info.pb.go create mode 100644 x/authority/types/chain_info_test.go diff --git a/changelog.md b/changelog.md index 1414740d47..27b8257de4 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,7 @@ * [2113](https://github.com/zeta-chain/node/pull/2113) - add zetaclientd-supervisor process * [2154](https://github.com/zeta-chain/node/pull/2154) - add `ibccrosschain` module * [2258](https://github.com/zeta-chain/node/pull/2258) - add Optimism and Base in static chain information +* [2275](https://github.com/zeta-chain/node/pull/2275) - add ChainInfo singleton state variable in authority ### Refactor diff --git a/pkg/chains/chain.go b/pkg/chains/chain.go index 0b1c9edcc8..681e13a5ae 100644 --- a/pkg/chains/chain.go +++ b/pkg/chains/chain.go @@ -14,14 +14,47 @@ type SigninAlgo string // Chains represent a slice of Chain type Chains []Chain +// Validate checks whether the chain is valid +// The function check the chain ID is positive and all enum fields have a defined value +func (chain Chain) Validate() error { + if chain.ChainId <= 0 { + return fmt.Errorf("chain ID must be positive") + } + + if _, ok := ChainName_name[int32(chain.ChainName)]; !ok { + return fmt.Errorf("invalid chain name %d", int32(chain.ChainName)) + } + + if _, ok := Network_name[int32(chain.Network)]; !ok { + return fmt.Errorf("invalid network %d", int32(chain.Network)) + } + + if _, ok := NetworkType_name[int32(chain.NetworkType)]; !ok { + return fmt.Errorf("invalid network type %d", int32(chain.NetworkType)) + } + + if _, ok := Vm_name[int32(chain.Vm)]; !ok { + return fmt.Errorf("invalid vm %d", int32(chain.Vm)) + } + + if _, ok := Consensus_name[int32(chain.Consensus)]; !ok { + return fmt.Errorf("invalid consensus %d", int32(chain.Consensus)) + } + + return nil +} + // IsEqual compare two chain to see whether they represent the same chain func (chain Chain) IsEqual(c Chain) bool { return chain.ChainId == c.ChainId } +// IsZetaChain returns true if the chain is a ZetaChain chain func (chain Chain) IsZetaChain() bool { return chain.Network == Network_zeta } + +// IsExternalChain returns true if the chain is an ExternalChain chain, not ZetaChain func (chain Chain) IsExternalChain() bool { return chain.IsExternal } diff --git a/pkg/chains/chain_test.go b/pkg/chains/chain_test.go index 7bbb9de679..d14fd39a37 100644 --- a/pkg/chains/chain_test.go +++ b/pkg/chains/chain_test.go @@ -11,6 +11,133 @@ import ( "github.com/stretchr/testify/require" ) +func TestChain_Validate(t *testing.T) { + tests := []struct { + name string + chain Chain + errStr string + }{ + { + name: "should pass if chain is valid", + chain: Chain{ + ChainId: 42, + ChainName: ChainName_empty, + Network: Network_optimism, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + }, + }, + { + name: "should error if chain ID is zero", + chain: Chain{ + ChainId: 0, + ChainName: ChainName_empty, + Network: Network_optimism, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + }, + errStr: "chain ID must be positive", + }, + { + name: "should error if chain ID is negative", + chain: Chain{ + ChainId: 0, + ChainName: ChainName_empty, + Network: Network_optimism, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + }, + errStr: "chain ID must be positive", + }, + { + name: "should error if chain name invalid", + chain: Chain{ + ChainId: 42, + ChainName: ChainName_base_sepolia + 1, + Network: Network_optimism, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + }, + errStr: "invalid chain name", + }, + { + name: "should error if network invalid", + chain: Chain{ + ChainId: 42, + ChainName: ChainName_empty, + Network: Network_base + 1, + NetworkType: NetworkType_testnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + }, + errStr: "invalid network", + }, + { + name: "should error if network type invalid", + chain: Chain{ + ChainId: 42, + ChainName: ChainName_empty, + Network: Network_base, + NetworkType: NetworkType_devnet + 1, + Vm: Vm_evm, + Consensus: Consensus_op_stack, + IsExternal: true, + }, + errStr: "invalid network type", + }, + { + name: "should error if vm invalid", + chain: Chain{ + ChainId: 42, + ChainName: ChainName_empty, + Network: Network_base, + NetworkType: NetworkType_devnet, + Vm: Vm_evm + 1, + Consensus: Consensus_op_stack, + IsExternal: true, + }, + errStr: "invalid vm", + }, + { + name: "should error if consensus invalid", + chain: Chain{ + ChainId: 42, + ChainName: ChainName_empty, + Network: Network_base, + NetworkType: NetworkType_devnet, + Vm: Vm_evm, + Consensus: Consensus_op_stack + 1, + IsExternal: true, + }, + errStr: "invalid consensus", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.errStr != "" { + require.ErrorContains(t, tt.chain.Validate(), tt.errStr) + } else { + require.NoError(t, tt.chain.Validate()) + } + }) + } + + t.Run("all default chains are valid", func(t *testing.T) { + for _, chain := range DefaultChainsList() { + require.NoError(t, chain.Validate()) + } + }) +} + func TestChain_EncodeAddress(t *testing.T) { tests := []struct { name string diff --git a/proto/zetachain/zetacore/authority/chain_info.proto b/proto/zetachain/zetacore/authority/chain_info.proto new file mode 100644 index 0000000000..f417184b06 --- /dev/null +++ b/proto/zetachain/zetacore/authority/chain_info.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package zetachain.zetacore.authority; + +import "zetachain/zetacore/pkg/chains/chains.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/authority/types"; + +// ChainInfo contains static information about the chains +// This structure is used to dynamically update these info on a live network +// before hardcoding the values in a upgrade +message ChainInfo { + repeated pkg.chains.Chain chains = 1 [ (gogoproto.nullable) = false ]; +} \ No newline at end of file diff --git a/proto/zetachain/zetacore/authority/genesis.proto b/proto/zetachain/zetacore/authority/genesis.proto index 93eee1e9fc..a23416161f 100644 --- a/proto/zetachain/zetacore/authority/genesis.proto +++ b/proto/zetachain/zetacore/authority/genesis.proto @@ -2,9 +2,13 @@ syntax = "proto3"; package zetachain.zetacore.authority; import "zetachain/zetacore/authority/policies.proto"; +import "zetachain/zetacore/authority/chain_info.proto"; import "gogoproto/gogo.proto"; option go_package = "github.com/zeta-chain/zetacore/x/authority/types"; // GenesisState defines the authority module's genesis state. -message GenesisState { Policies policies = 1 [ (gogoproto.nullable) = false ]; } +message GenesisState { + Policies policies = 1 [ (gogoproto.nullable) = false ]; + ChainInfo chain_info = 2 [ (gogoproto.nullable) = false ]; +} diff --git a/testutil/sample/authority.go b/testutil/sample/authority.go index 9f2535d2b3..f24542c7fc 100644 --- a/testutil/sample/authority.go +++ b/testutil/sample/authority.go @@ -1,6 +1,9 @@ package sample -import authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" +import ( + "github.com/zeta-chain/zetacore/pkg/chains" + authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" +) func Policies() authoritytypes.Policies { return authoritytypes.Policies{ @@ -20,3 +23,17 @@ func Policies() authoritytypes.Policies { }, } } + +func ChainInfo(startChainID int64) authoritytypes.ChainInfo { + chain1 := Chain(startChainID) + chain2 := Chain(startChainID + 1) + chain3 := Chain(startChainID + 2) + + return authoritytypes.ChainInfo{ + Chains: []chains.Chain{ + *chain1, + *chain2, + *chain3, + }, + } +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 411c6dd7c9..431d93337d 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -121,9 +121,20 @@ func GenDoc(t *testing.T) *types.GenesisDoc { func Chain(chainID int64) *chains.Chain { r := newRandFromSeed(chainID) + chainNameLen := len(chains.ChainName_name) + networkLen := len(chains.Network_name) + networkTypeLen := len(chains.NetworkType_name) + vmLen := len(chains.Vm_name) + consensusLen := len(chains.Consensus_name) + return &chains.Chain{ - ChainName: chains.ChainName(r.Intn(4)), - ChainId: chainID, + ChainId: chainID, + ChainName: chains.ChainName(r.Intn(chainNameLen)), + Network: chains.Network(r.Intn(networkLen)), + NetworkType: chains.NetworkType(r.Intn(networkTypeLen)), + Vm: chains.Vm(r.Intn(vmLen)), + Consensus: chains.Consensus(r.Intn(consensusLen)), + IsExternal: true, } } diff --git a/typescript/zetachain/zetacore/authority/chain_info_pb.d.ts b/typescript/zetachain/zetacore/authority/chain_info_pb.d.ts new file mode 100644 index 0000000000..49437eb7e2 --- /dev/null +++ b/typescript/zetachain/zetacore/authority/chain_info_pb.d.ts @@ -0,0 +1,37 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file zetachain/zetacore/authority/chain_info.proto (package zetachain.zetacore.authority, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; +import type { Chain } from "../pkg/chains/chains_pb.js"; + +/** + * ChainInfo contains static information about the chains + * This structure is used to dynamically update these info on a live network + * before hardcoding the values in a upgrade + * + * @generated from message zetachain.zetacore.authority.ChainInfo + */ +export declare class ChainInfo extends Message { + /** + * @generated from field: repeated zetachain.zetacore.pkg.chains.Chain chains = 1; + */ + chains: Chain[]; + + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.authority.ChainInfo"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): ChainInfo; + + static fromJson(jsonValue: JsonValue, options?: Partial): ChainInfo; + + static fromJsonString(jsonString: string, options?: Partial): ChainInfo; + + static equals(a: ChainInfo | PlainMessage | undefined, b: ChainInfo | PlainMessage | undefined): boolean; +} + diff --git a/typescript/zetachain/zetacore/authority/genesis_pb.d.ts b/typescript/zetachain/zetacore/authority/genesis_pb.d.ts index a20371004b..381048e226 100644 --- a/typescript/zetachain/zetacore/authority/genesis_pb.d.ts +++ b/typescript/zetachain/zetacore/authority/genesis_pb.d.ts @@ -6,6 +6,7 @@ import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; import { Message, proto3 } from "@bufbuild/protobuf"; import type { Policies } from "./policies_pb.js"; +import type { ChainInfo } from "./chain_info_pb.js"; /** * GenesisState defines the authority module's genesis state. @@ -18,6 +19,11 @@ export declare class GenesisState extends Message { */ policies?: Policies; + /** + * @generated from field: zetachain.zetacore.authority.ChainInfo chain_info = 2; + */ + chainInfo?: ChainInfo; + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; diff --git a/typescript/zetachain/zetacore/authority/index.d.ts b/typescript/zetachain/zetacore/authority/index.d.ts index d363dc44f4..e27cc8abc4 100644 --- a/typescript/zetachain/zetacore/authority/index.d.ts +++ b/typescript/zetachain/zetacore/authority/index.d.ts @@ -1,3 +1,4 @@ +export * from "./chain_info_pb"; export * from "./genesis_pb"; export * from "./policies_pb"; export * from "./query_pb"; diff --git a/x/authority/genesis.go b/x/authority/genesis.go index 1391b5954d..56528a5935 100644 --- a/x/authority/genesis.go +++ b/x/authority/genesis.go @@ -10,6 +10,7 @@ import ( // InitGenesis initializes the authority module's state from a provided genesis state func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { k.SetPolicies(ctx, genState.Policies) + k.SetChainInfo(ctx, genState.ChainInfo) } // ExportGenesis returns the authority module's exported genesis. @@ -21,5 +22,10 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.Policies = policies } + chainInfo, found := k.GetChainInfo(ctx) + if found { + genesis.ChainInfo = chainInfo + } + return &genesis } diff --git a/x/authority/genesis_test.go b/x/authority/genesis_test.go index ac9c8d2e43..f14f4f37c6 100644 --- a/x/authority/genesis_test.go +++ b/x/authority/genesis_test.go @@ -14,7 +14,8 @@ import ( func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ - Policies: sample.Policies(), + Policies: sample.Policies(), + ChainInfo: sample.ChainInfo(42), } // Init @@ -26,6 +27,11 @@ func TestGenesis(t *testing.T) { require.True(t, found) require.Equal(t, genesisState.Policies, policies) + // Check chain info is set + chainInfo, found := k.GetChainInfo(ctx) + require.True(t, found) + require.Equal(t, genesisState.ChainInfo, chainInfo) + // Export got := authority.ExportGenesis(ctx, *k) require.NotNil(t, got) diff --git a/x/authority/keeper/chain_info.go b/x/authority/keeper/chain_info.go new file mode 100644 index 0000000000..5c9056fe0c --- /dev/null +++ b/x/authority/keeper/chain_info.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/zeta-chain/zetacore/x/authority/types" +) + +// SetChainInfo sets the chain info to the store +func (k Keeper) SetChainInfo(ctx sdk.Context, chainInfo types.ChainInfo) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainInfoKey)) + b := k.cdc.MustMarshal(&chainInfo) + store.Set([]byte{0}, b) +} + +// GetChainInfo returns the policies from the store +func (k Keeper) GetChainInfo(ctx sdk.Context) (val types.ChainInfo, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ChainInfoKey)) + b := store.Get([]byte{0}) + if b == nil { + return val, false + } + k.cdc.MustUnmarshal(b, &val) + return val, true +} diff --git a/x/authority/keeper/chain_info_test.go b/x/authority/keeper/chain_info_test.go new file mode 100644 index 0000000000..87424cb4dd --- /dev/null +++ b/x/authority/keeper/chain_info_test.go @@ -0,0 +1,33 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + keepertest "github.com/zeta-chain/zetacore/testutil/keeper" + "github.com/zeta-chain/zetacore/testutil/sample" +) + +func TestKeeper_SetChainInfo(t *testing.T) { + k, ctx := keepertest.AuthorityKeeper(t) + chainInfo := sample.ChainInfo(42) + + _, found := k.GetChainInfo(ctx) + require.False(t, found) + + k.SetChainInfo(ctx, chainInfo) + + // Check policy is set + got, found := k.GetChainInfo(ctx) + require.True(t, found) + require.Equal(t, chainInfo, got) + + // Can set policies again + newChainInfo := sample.ChainInfo(84) + require.NotEqual(t, chainInfo, newChainInfo) + k.SetChainInfo(ctx, newChainInfo) + got, found = k.GetChainInfo(ctx) + require.True(t, found) + require.Equal(t, newChainInfo, got) +} diff --git a/x/authority/types/chain_info.go b/x/authority/types/chain_info.go new file mode 100644 index 0000000000..cff10235c4 --- /dev/null +++ b/x/authority/types/chain_info.go @@ -0,0 +1,30 @@ +package types + +import ( + "fmt" + + "github.com/zeta-chain/zetacore/pkg/chains" +) + +// DefaultChainInfo returns the structure with an empty list of chains +func DefaultChainInfo() ChainInfo { + return ChainInfo{ + Chains: []chains.Chain{}, + } +} + +// Validate performs basic validation of chain info +// It checks all chains are valid and they're all of external type +// The structure is used to store external chain information +func (ci ChainInfo) Validate() error { + for _, chain := range ci.Chains { + if err := chain.Validate(); err != nil { + return err + } + if !chain.IsExternal { + return fmt.Errorf("chain %d is not external", chain.ChainId) + } + } + + return nil +} diff --git a/x/authority/types/chain_info.pb.go b/x/authority/types/chain_info.pb.go new file mode 100644 index 0000000000..9dd945040e --- /dev/null +++ b/x/authority/types/chain_info.pb.go @@ -0,0 +1,335 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zetachain/zetacore/authority/chain_info.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + chains "github.com/zeta-chain/zetacore/pkg/chains" + 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 + +// ChainInfo contains static information about the chains +// This structure is used to dynamically update these info on a live network +// before hardcoding the values in a upgrade +type ChainInfo struct { + Chains []chains.Chain `protobuf:"bytes,1,rep,name=chains,proto3" json:"chains"` +} + +func (m *ChainInfo) Reset() { *m = ChainInfo{} } +func (m *ChainInfo) String() string { return proto.CompactTextString(m) } +func (*ChainInfo) ProtoMessage() {} +func (*ChainInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_88c7b2261e38c0a9, []int{0} +} +func (m *ChainInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ChainInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ChainInfo.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 *ChainInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChainInfo.Merge(m, src) +} +func (m *ChainInfo) XXX_Size() int { + return m.Size() +} +func (m *ChainInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ChainInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ChainInfo proto.InternalMessageInfo + +func (m *ChainInfo) GetChains() []chains.Chain { + if m != nil { + return m.Chains + } + return nil +} + +func init() { + proto.RegisterType((*ChainInfo)(nil), "zetachain.zetacore.authority.ChainInfo") +} + +func init() { + proto.RegisterFile("zetachain/zetacore/authority/chain_info.proto", fileDescriptor_88c7b2261e38c0a9) +} + +var fileDescriptor_88c7b2261e38c0a9 = []byte{ + // 206 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xad, 0x4a, 0x2d, 0x49, + 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x07, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x13, 0x4b, 0x4b, 0x32, + 0xf2, 0x8b, 0x32, 0x4b, 0x2a, 0xf5, 0xc1, 0x12, 0xf1, 0x99, 0x79, 0x69, 0xf9, 0x7a, 0x05, 0x45, + 0xf9, 0x25, 0xf9, 0x42, 0x32, 0x70, 0xe5, 0x7a, 0x30, 0xe5, 0x7a, 0x70, 0xe5, 0x52, 0x5a, 0x58, + 0x0c, 0x2b, 0xc8, 0x4e, 0x87, 0x18, 0x53, 0x0c, 0xa5, 0x20, 0x26, 0x49, 0x89, 0xa4, 0xe7, 0xa7, + 0xe7, 0x83, 0x99, 0xfa, 0x20, 0x16, 0x44, 0x54, 0xc9, 0x9f, 0x8b, 0xd3, 0x19, 0xa4, 0xca, 0x33, + 0x2f, 0x2d, 0x5f, 0xc8, 0x89, 0x8b, 0x0d, 0xa2, 0x45, 0x82, 0x51, 0x81, 0x59, 0x83, 0xdb, 0x48, + 0x45, 0x0f, 0x8b, 0xed, 0x05, 0xd9, 0xe9, 0x7a, 0x50, 0x83, 0xc1, 0x3a, 0x9d, 0x58, 0x4e, 0xdc, + 0x93, 0x67, 0x08, 0x82, 0xea, 0x74, 0xf2, 0x3a, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, + 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, + 0x86, 0x28, 0x83, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xb0, 0x6b, 0x75, + 0xd1, 0x1c, 0x5e, 0x81, 0x14, 0x0e, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x37, 0x1a, + 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x9c, 0x16, 0x2c, 0xe3, 0x34, 0x01, 0x00, 0x00, +} + +func (m *ChainInfo) 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 *ChainInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ChainInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Chains) > 0 { + for iNdEx := len(m.Chains) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Chains[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintChainInfo(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintChainInfo(dAtA []byte, offset int, v uint64) int { + offset -= sovChainInfo(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ChainInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Chains) > 0 { + for _, e := range m.Chains { + l = e.Size() + n += 1 + l + sovChainInfo(uint64(l)) + } + } + return n +} + +func sovChainInfo(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozChainInfo(x uint64) (n int) { + return sovChainInfo(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ChainInfo) 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 ErrIntOverflowChainInfo + } + 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: ChainInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ChainInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Chains", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChainInfo + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthChainInfo + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthChainInfo + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Chains = append(m.Chains, chains.Chain{}) + if err := m.Chains[len(m.Chains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipChainInfo(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChainInfo + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipChainInfo(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, ErrIntOverflowChainInfo + } + 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, ErrIntOverflowChainInfo + } + 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, ErrIntOverflowChainInfo + } + 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, ErrInvalidLengthChainInfo + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupChainInfo + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthChainInfo + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthChainInfo = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowChainInfo = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupChainInfo = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/authority/types/chain_info_test.go b/x/authority/types/chain_info_test.go new file mode 100644 index 0000000000..dd43b4064f --- /dev/null +++ b/x/authority/types/chain_info_test.go @@ -0,0 +1,79 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/testutil/sample" + "github.com/zeta-chain/zetacore/x/authority/types" +) + +func TestDefaultChainInfo(t *testing.T) { + t.Run("default is empty", func(t *testing.T) { + chainInfo := types.DefaultChainInfo() + require.Empty(t, chainInfo.Chains) + }) +} + +func TestChainInfo_Validate(t *testing.T) { + tests := []struct { + name string + chainInfo types.ChainInfo + errContains string + }{ + { + name: "empty is valid", + chainInfo: types.ChainInfo{}, + }, + { + name: "valid chain info", + chainInfo: sample.ChainInfo(42), + }, + { + name: "invalid if chain is invalid", + chainInfo: types.ChainInfo{ + Chains: []chains.Chain{ + { + ChainId: 0, + ChainName: chains.ChainName_empty, + Network: chains.Network_optimism, + NetworkType: chains.NetworkType_testnet, + Vm: chains.Vm_evm, + Consensus: chains.Consensus_op_stack, + IsExternal: true, + }, + }, + }, + errContains: "chain ID must be positive", + }, + { + name: "invalid if chain is not external", + chainInfo: types.ChainInfo{ + Chains: []chains.Chain{ + { + ChainId: 42, + ChainName: chains.ChainName_empty, + Network: chains.Network_optimism, + NetworkType: chains.NetworkType_testnet, + Vm: chains.Vm_evm, + Consensus: chains.Consensus_op_stack, + IsExternal: false, + }, + }, + }, + errContains: "not external", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.chainInfo.Validate() + if tt.errContains != "" { + require.ErrorContains(t, err, tt.errContains) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/authority/types/genesis.go b/x/authority/types/genesis.go index bed0e04a41..13a01030bf 100644 --- a/x/authority/types/genesis.go +++ b/x/authority/types/genesis.go @@ -3,11 +3,16 @@ package types // DefaultGenesis returns the default authority genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - Policies: DefaultPolicies(), + Policies: DefaultPolicies(), + ChainInfo: DefaultChainInfo(), } } // Validate performs basic genesis state validation returning an error upon any failure func (gs GenesisState) Validate() error { - return gs.Policies.Validate() + if err := gs.Policies.Validate(); err != nil { + return err + } + + return gs.ChainInfo.Validate() } diff --git a/x/authority/types/genesis.pb.go b/x/authority/types/genesis.pb.go index 77857e5b67..aca80bfed4 100644 --- a/x/authority/types/genesis.pb.go +++ b/x/authority/types/genesis.pb.go @@ -25,7 +25,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the authority module's genesis state. type GenesisState struct { - Policies Policies `protobuf:"bytes,1,opt,name=policies,proto3" json:"policies"` + Policies Policies `protobuf:"bytes,1,opt,name=policies,proto3" json:"policies"` + ChainInfo ChainInfo `protobuf:"bytes,2,opt,name=chain_info,json=chainInfo,proto3" json:"chain_info"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,6 +69,13 @@ func (m *GenesisState) GetPolicies() Policies { return Policies{} } +func (m *GenesisState) GetChainInfo() ChainInfo { + if m != nil { + return m.ChainInfo + } + return ChainInfo{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "zetachain.zetacore.authority.GenesisState") } @@ -77,20 +85,23 @@ func init() { } var fileDescriptor_633475075491b169 = []byte{ - // 202 bytes of a gzipped FileDescriptorProto + // 242 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xaa, 0x4a, 0x2d, 0x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aa, 0x3b, 0x01, 0x00, 0x00, + 0x9a, 0x54, 0x90, 0x9f, 0x93, 0x99, 0x9c, 0x99, 0x0a, 0x35, 0x4a, 0x4a, 0x17, 0xaf, 0x62, 0xb0, + 0x44, 0x7c, 0x66, 0x5e, 0x5a, 0x3e, 0x54, 0xb9, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x98, 0xa9, 0x0f, + 0x62, 0x41, 0x44, 0x95, 0x96, 0x31, 0x72, 0xf1, 0xb8, 0x43, 0x5c, 0x18, 0x5c, 0x92, 0x58, 0x92, + 0x2a, 0xe4, 0xc1, 0xc5, 0x01, 0xb3, 0x47, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4d, 0x0f, + 0x9f, 0x9b, 0xf5, 0x02, 0xa0, 0xaa, 0x9d, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0xeb, 0x16, + 0xf2, 0xe1, 0xe2, 0x42, 0x38, 0x42, 0x82, 0x09, 0x6c, 0x96, 0x3a, 0x7e, 0xb3, 0x9c, 0x41, 0x12, + 0x9e, 0x79, 0x69, 0xf9, 0x50, 0xc3, 0x38, 0x93, 0xe1, 0x02, 0x5e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, + 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, + 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, + 0x0b, 0x0e, 0x08, 0x5d, 0xb4, 0x30, 0xa9, 0x40, 0x0a, 0x95, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, + 0x36, 0xb0, 0xdf, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x5f, 0x4d, 0x13, 0xb9, 0x01, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -113,6 +124,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.ChainInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 { size, err := m.Policies.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -145,6 +166,8 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Policies.Size() n += 1 + l + sovGenesis(uint64(l)) + l = m.ChainInfo.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -216,6 +239,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ChainInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/authority/types/genesis_test.go b/x/authority/types/genesis_test.go index 46f4ad9bcb..90aee92509 100644 --- a/x/authority/types/genesis_test.go +++ b/x/authority/types/genesis_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/authority/types" ) @@ -25,7 +26,8 @@ func TestGenesisState_Validate(t *testing.T) { { name: "valid genesis", gs: &types.GenesisState{ - Policies: sample.Policies(), + Policies: sample.Policies(), + ChainInfo: sample.ChainInfo(42), }, errContains: "", }, @@ -40,9 +42,30 @@ func TestGenesisState_Validate(t *testing.T) { }, }, }, + ChainInfo: sample.ChainInfo(42), }, errContains: "invalid address", }, + { + name: "invalid if policies is invalid", + gs: &types.GenesisState{ + Policies: sample.Policies(), + ChainInfo: types.ChainInfo{ + Chains: []chains.Chain{ + { + ChainId: 0, + ChainName: chains.ChainName_empty, + Network: chains.Network_optimism, + NetworkType: chains.NetworkType_testnet, + Vm: chains.Vm_evm, + Consensus: chains.Consensus_op_stack, + IsExternal: true, + }, + }, + }, + }, + errContains: "chain ID must be positive", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/x/authority/types/keys.go b/x/authority/types/keys.go index 5b86ca9711..7593feed3a 100644 --- a/x/authority/types/keys.go +++ b/x/authority/types/keys.go @@ -25,4 +25,7 @@ func KeyPrefix(p string) []byte { const ( // PoliciesKey is the key for the policies store PoliciesKey = "Policies-value-" + + // ChainInfoKey is the key for the chain info store + ChainInfoKey = "ChainInfo-value-" )