From d549393ab8c463b18e9895177ae8962542291ede Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Wed, 9 Aug 2023 07:49:23 +0200 Subject: [PATCH 1/4] refactor(`app.go`): remove `capability` module (#914) * remove capability * new lines end blocker * remove comment * remove from localnet genesis --- app/app.go | 98 ++++++++----------- .../zetacored_zetacore0/config/genesis.json | 4 - .../zetacored_zetacore1/config/genesis.json | 4 - 3 files changed, 41 insertions(+), 65 deletions(-) diff --git a/app/app.go b/app/app.go index 6940a09798..152703dc65 100644 --- a/app/app.go +++ b/app/app.go @@ -37,9 +37,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/capability" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" @@ -167,7 +164,6 @@ var ( auth.AppModuleBasic{}, genutil.AppModuleBasic{}, bank.AppModuleBasic{}, - capability.AppModuleBasic{}, staking.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic(getGovProposalHandlers()), @@ -222,30 +218,27 @@ type App struct { memKeys map[string]*storetypes.MemoryStoreKey // keepers - AccountKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - CapabilityKeeper *capabilitykeeper.Keeper - StakingKeeper stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - DistrKeeper distrkeeper.Keeper - GovKeeper govkeeper.Keeper - CrisisKeeper crisiskeeper.Keeper - UpgradeKeeper upgradekeeper.Keeper - ParamsKeeper paramskeeper.Keeper - EvidenceKeeper evidencekeeper.Keeper - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ZetaCoreKeeper zetaCoreModuleKeeper.Keeper - ZetaObserverKeeper *zetaObserverModuleKeeper.Keeper - mm *module.Manager - sm *module.SimulationManager - configurator module.Configurator - EvmKeeper *evmkeeper.Keeper - FeeMarketKeeper feemarketkeeper.Keeper - FungibleKeeper fungibleModuleKeeper.Keeper - EmissionsKeeper emissionsModuleKeeper.Keeper - GroupKeeper groupkeeper.Keeper - AuthzKeeper authzkeeper.Keeper + AccountKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + DistrKeeper distrkeeper.Keeper + GovKeeper govkeeper.Keeper + CrisisKeeper crisiskeeper.Keeper + UpgradeKeeper upgradekeeper.Keeper + ParamsKeeper paramskeeper.Keeper + EvidenceKeeper evidencekeeper.Keeper + ZetaCoreKeeper zetaCoreModuleKeeper.Keeper + ZetaObserverKeeper *zetaObserverModuleKeeper.Keeper + mm *module.Manager + sm *module.SimulationManager + configurator module.Configurator + EvmKeeper *evmkeeper.Keeper + FeeMarketKeeper feemarketkeeper.Keeper + FungibleKeeper fungibleModuleKeeper.Keeper + EmissionsKeeper emissionsModuleKeeper.Keeper + GroupKeeper groupkeeper.Keeper + AuthzKeeper authzkeeper.Keeper } // New returns a reference to an initialized ZetaApp. @@ -277,7 +270,6 @@ func New( group.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, - capabilitytypes.StoreKey, zetaCoreModuleTypes.StoreKey, zetaObserverModuleTypes.StoreKey, evmtypes.StoreKey, feemarkettypes.StoreKey, @@ -286,7 +278,7 @@ func New( authzkeeper.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) - memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + memKeys := sdk.NewMemoryStoreKeys() app := &App{ BaseApp: bApp, @@ -306,11 +298,6 @@ func New( // set the BaseApp's parameter store bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())) - // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) - - app.CapabilityKeeper.Seal() - // add keepers // use custom Ethermint account for contracts app.AccountKeeper = authkeeper.NewAccountKeeper( @@ -460,7 +447,6 @@ func New( auth.NewAppModule(appCodec, app.AccountKeeper, nil), vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), - capability.NewAppModule(appCodec, *app.CapabilityKeeper), crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), @@ -486,7 +472,6 @@ func New( app.mm.SetOrderBeginBlockers( upgradetypes.ModuleName, - capabilitytypes.ModuleName, evmtypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, @@ -508,16 +493,26 @@ func New( authz.ModuleName, ) app.mm.SetOrderEndBlockers( - banktypes.ModuleName, authtypes.ModuleName, - upgradetypes.ModuleName, capabilitytypes.ModuleName, distrtypes.ModuleName, - slashingtypes.ModuleName, evidencetypes.ModuleName, + banktypes.ModuleName, + authtypes.ModuleName, + upgradetypes.ModuleName, + distrtypes.ModuleName, + slashingtypes.ModuleName, + evidencetypes.ModuleName, stakingtypes.ModuleName, - vestingtypes.ModuleName, govtypes.ModuleName, - paramstypes.ModuleName, genutiltypes.ModuleName, group.ModuleName, + vestingtypes.ModuleName, + govtypes.ModuleName, + paramstypes.ModuleName, + genutiltypes.ModuleName, + group.ModuleName, crisistypes.ModuleName, - evmtypes.ModuleName, feemarkettypes.ModuleName, - zetaCoreModuleTypes.ModuleName, zetaObserverModuleTypes.ModuleName, - fungibleModuleTypes.ModuleName, emissionsModuleTypes.ModuleName, authz.ModuleName, + evmtypes.ModuleName, + feemarkettypes.ModuleName, + zetaCoreModuleTypes.ModuleName, + zetaObserverModuleTypes.ModuleName, + fungibleModuleTypes.ModuleName, + emissionsModuleTypes.ModuleName, + authz.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -526,7 +521,6 @@ func New( // so that other modules that want to create or claim capabilities afterwards in InitChain // can do so safely. app.mm.SetOrderInitGenesis( - capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, @@ -586,16 +580,6 @@ func New( if err := app.LoadLatestVersion(); err != nil { tmos.Exit(err.Error()) } - - // Initialize and seal the capability keeper so all persistent capabilities - // are loaded in-memory and prevent any further modules from creating scoped - // sub-keepers. - // This must be done during creation of baseapp rather than in InitChain so - // that in-memory capabilities get regenerated on app restart. - // Note that since this reads from the store, we can only perform it when - // `loadLatest` is set to true. - //ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{}) - //app.CapabilityKeeper.InitializeAndSeal(ctx) } return app @@ -764,7 +748,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino return paramsKeeper } -// VerifyAddressFormat verifis the address is compatible with ethereum +// VerifyAddressFormat verifies the address is compatible with ethereum func VerifyAddressFormat(bz []byte) error { if len(bz) == 0 { return sdkerrors.Wrap(sdkerrors.ErrUnknownAddress, "invalid address; cannot be empty") diff --git a/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json b/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json index 5b30c3478e..114d07daf5 100644 --- a/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json +++ b/contrib/localnet/zetacored/zetacored_zetacore0/config/genesis.json @@ -149,10 +149,6 @@ ], "denom_metadata": [] }, - "capability": { - "index": "1", - "owners": [] - }, "crisis": { "constant_fee": { "denom": "azeta", diff --git a/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json b/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json index 5b30c3478e..114d07daf5 100644 --- a/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json +++ b/contrib/localnet/zetacored/zetacored_zetacore1/config/genesis.json @@ -149,10 +149,6 @@ ], "denom_metadata": [] }, - "capability": { - "index": "1", - "owners": [] - }, "crisis": { "constant_fee": { "denom": "azeta", From 5889b06d566c4ddec2f157ea8ff0d0e7325cad40 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 9 Aug 2023 18:31:14 +0400 Subject: [PATCH 2/4] docs: state transition diagrams for cctx status (#755) * docs: state transition diagrams for cctx status * Update docs/spec/crosschain/messages.md Co-authored-by: Lucas Bertrand * replace Uniswap pool with contract instance * replace was with is * replace was with is * remove dot at the end * make specs * added EVM refund * make specs * overview: sidebar_position: 1 * make generate --------- Co-authored-by: Lucas Bertrand --- docs/spec/crosschain/messages.md | 86 ++++++++++++++----- docs/spec/crosschain/overview.md | 4 + docs/spec/emissions/overview.md | 4 + docs/spec/fungible/overview.md | 4 + docs/spec/observer/overview.md | 4 + .../keeper_cross_chain_tx_vote_inbound_tx.go | 39 +++++++-- .../keeper_cross_chain_tx_vote_outbound_tx.go | 45 ++++++---- 7 files changed, 143 insertions(+), 43 deletions(-) diff --git a/docs/spec/crosschain/messages.md b/docs/spec/crosschain/messages.md index ced6c54042..e02d171736 100644 --- a/docs/spec/crosschain/messages.md +++ b/docs/spec/crosschain/messages.md @@ -87,27 +87,42 @@ message MsgNonceVoter { Casts a vote on an outbound transaction observed on a connected chain (after it has been broadcasted to and finalized on a connected chain). If this is the first vote, a new ballot is created. When a threshold of votes is -reached, the ballot is finalized. When a ballot is finalized, if the amount -of zeta minted does not match the outbound transaction amount an error is -thrown. If the amounts match, the outbound transaction hash and the "last -updated" timestamp are updated. +reached, the ballot is finalized. When a ballot is finalized, the outbound +transaction is processed. -The transaction is proceeded to be finalized: - -If the observation was successful, the status is changed from "pending -revert/outbound" to "reverted/mined". The difference between zeta burned +If the observation is successful, the difference between zeta burned and minted is minted by the bank module and deposited into the module account. -If the observation was unsuccessful, and if the status is "pending outbound", -prices and nonce are updated and the status is changed to "pending revert". -If the status was "pending revert", the status is changed to "aborted". - -If there's an error in the finalization process, the CCTX status is set to -'aborted'. +If the observation is unsuccessful, the logic depends on the previous +status. + +If the previous status was `PendingOutbound`, a new revert transaction is +created. To cover the revert transaction fee, the required amount of tokens +submitted with the CCTX are swapped using a Uniswap V2 contract instance on +ZetaChain for the ZRC20 of the gas token of the receiver chain. The ZRC20 +tokens are then +burned. The nonce is updated. If everything is successful, the CCTX status is +changed to `PendingRevert`. + +If the previous status was `PendingRevert`, the CCTX is aborted. + +```mermaid +stateDiagram-v2 + + state observation <> + state success_old_status <> + state fail_old_status <> + PendingOutbound --> observation: Finalize outbound + observation --> success_old_status: Observation succeeded + success_old_status --> Reverted: Old status is PendingRevert + success_old_status --> OutboundMined: Old status is PendingOutbound + observation --> fail_old_status: Observation failed + fail_old_status --> PendingRevert: Old status is PendingOutbound + fail_old_status --> Aborted: Old status is PendingRevert + PendingOutbound --> Aborted: Finalize outbound error -After finalization the outbound transaction tracker and pending nonces are -removed, and the CCTX is updated in the store. +``` Only observer validators are authorized to broadcast this message. @@ -132,13 +147,40 @@ is the first vote, a new ballot is created. When a threshold of votes is reached, the ballot is finalized. When a ballot is finalized, a new CCTX is created. -If the receiver chain is a ZetaChain, the EVM deposit is handled and the -status of CCTX is changed to "outbound mined". If EVM deposit handling fails, -the status of CCTX is chagned to 'aborted'. +If the receiver chain is ZetaChain, `HandleEVMDeposit` is called. If the +tokens being deposited are ZETA, `MintZetaToEVMAccount` is called and the +tokens are minted to the receiver account on ZetaChain. If the tokens being +deposited are gas tokens or ERC20 of a connected chain, ZRC20's `deposit` +method is called and the tokens are deposited to the receiver account on +ZetaChain. If the message is not empty, system contract's `depositAndCall` +method is also called and an omnichain contract on ZetaChain is executed. +Omnichain contract address and arguments are passed as part of the message. +If everything is successful, the CCTX status is changed to `OutboundMined`. + +If the receiver chain is a connected chain, the `FinalizeInbound` method is +called to prepare the CCTX to be processed as an outbound transaction. To +cover the outbound transaction fee, the required amount of tokens submitted +with the CCTX are swapped using a Uniswap V2 contract instance on ZetaChain +for the ZRC20 of the gas token of the receiver chain. The ZRC20 tokens are +then burned. The nonce is updated. If everything is successful, the CCTX +status is changed to `PendingOutbound`. + +```mermaid +stateDiagram-v2 + + state evm_deposit_success <> + state finalize_inbound <> + state evm_deposit_error <> + PendingInbound --> evm_deposit_success: Receiver is ZetaChain + evm_deposit_success --> OutboundMined: EVM deposit success + evm_deposit_success --> evm_deposit_error: EVM deposit error + evm_deposit_error --> PendingRevert: Contract error + evm_deposit_error --> Aborted: Internal error, invalid chain, gas, nonce + PendingInbound --> finalize_inbound: Receiver is connected chain + finalize_inbound --> Aborted: Finalize inbound error + finalize_inbound --> PendingOutbound: Finalize inbound success -If the receiver chain is a connected chain, the inbound CCTX is finalized -(prices and nonce are updated) and status changes to "pending outbound". If -the finalization fails, the status of CCTX is changed to 'aborted'. +``` Only observer validators are authorized to broadcast this message. diff --git a/docs/spec/crosschain/overview.md b/docs/spec/crosschain/overview.md index 3f371d5274..32e1035e41 100644 --- a/docs/spec/crosschain/overview.md +++ b/docs/spec/crosschain/overview.md @@ -1,3 +1,7 @@ +--- +sidebar_position: 1 +--- + # Overview The `crosschain` module tracks inbound and outbound cross-chain transactions diff --git a/docs/spec/emissions/overview.md b/docs/spec/emissions/overview.md index 84593191ba..7a503d8895 100644 --- a/docs/spec/emissions/overview.md +++ b/docs/spec/emissions/overview.md @@ -1,3 +1,7 @@ +--- +sidebar_position: 1 +--- + # Overview The `emissions` module is responsible for orchestrating rewards distribution for diff --git a/docs/spec/fungible/overview.md b/docs/spec/fungible/overview.md index f7c477f2f3..1420c79e1b 100644 --- a/docs/spec/fungible/overview.md +++ b/docs/spec/fungible/overview.md @@ -1,3 +1,7 @@ +--- +sidebar_position: 1 +--- + # Overview The `fungible` module facilitates the deployment of fungible tokens of connected diff --git a/docs/spec/observer/overview.md b/docs/spec/observer/overview.md index 40f2893356..94a118da46 100644 --- a/docs/spec/observer/overview.md +++ b/docs/spec/observer/overview.md @@ -1,3 +1,7 @@ +--- +sidebar_position: 1 +--- + # Overview The `observer` module keeps track of ballots for voting, a mapping between diff --git a/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go b/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go index c0eef13893..0b3efe6d9e 100644 --- a/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go +++ b/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go @@ -19,13 +19,40 @@ import ( // reached, the ballot is finalized. When a ballot is finalized, a new CCTX is // created. // -// If the receiver chain is a ZetaChain, the EVM deposit is handled and the -// status of CCTX is changed to "outbound mined". If EVM deposit handling fails, -// the status of CCTX is chagned to 'aborted'. +// If the receiver chain is ZetaChain, `HandleEVMDeposit` is called. If the +// tokens being deposited are ZETA, `MintZetaToEVMAccount` is called and the +// tokens are minted to the receiver account on ZetaChain. If the tokens being +// deposited are gas tokens or ERC20 of a connected chain, ZRC20's `deposit` +// method is called and the tokens are deposited to the receiver account on +// ZetaChain. If the message is not empty, system contract's `depositAndCall` +// method is also called and an omnichain contract on ZetaChain is executed. +// Omnichain contract address and arguments are passed as part of the message. +// If everything is successful, the CCTX status is changed to `OutboundMined`. // -// If the receiver chain is a connected chain, the inbound CCTX is finalized -// (prices and nonce are updated) and status changes to "pending outbound". If -// the finalization fails, the status of CCTX is changed to 'aborted'. +// If the receiver chain is a connected chain, the `FinalizeInbound` method is +// called to prepare the CCTX to be processed as an outbound transaction. To +// cover the outbound transaction fee, the required amount of tokens submitted +// with the CCTX are swapped using a Uniswap V2 contract instance on ZetaChain +// for the ZRC20 of the gas token of the receiver chain. The ZRC20 tokens are +// then burned. The nonce is updated. If everything is successful, the CCTX +// status is changed to `PendingOutbound`. +// +// ```mermaid +// stateDiagram-v2 +// +// state evm_deposit_success <> +// state finalize_inbound <> +// state evm_deposit_error <> +// PendingInbound --> evm_deposit_success: Receiver is ZetaChain +// evm_deposit_success --> OutboundMined: EVM deposit success +// evm_deposit_success --> evm_deposit_error: EVM deposit error +// evm_deposit_error --> PendingRevert: Contract error +// evm_deposit_error --> Aborted: Internal error, invalid chain, gas, nonce +// PendingInbound --> finalize_inbound: Receiver is connected chain +// finalize_inbound --> Aborted: Finalize inbound error +// finalize_inbound --> PendingOutbound: Finalize inbound success +// +// ``` // // Only observer validators are authorized to broadcast this message. func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.MsgVoteOnObservedInboundTx) (*types.MsgVoteOnObservedInboundTxResponse, error) { diff --git a/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go b/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go index be469262f9..76875922a6 100644 --- a/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go +++ b/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go @@ -15,27 +15,42 @@ import ( // Casts a vote on an outbound transaction observed on a connected chain (after // it has been broadcasted to and finalized on a connected chain). If this is // the first vote, a new ballot is created. When a threshold of votes is -// reached, the ballot is finalized. When a ballot is finalized, if the amount -// of zeta minted does not match the outbound transaction amount an error is -// thrown. If the amounts match, the outbound transaction hash and the "last -// updated" timestamp are updated. +// reached, the ballot is finalized. When a ballot is finalized, the outbound +// transaction is processed. // -// The transaction is proceeded to be finalized: -// -// If the observation was successful, the status is changed from "pending -// revert/outbound" to "reverted/mined". The difference between zeta burned +// If the observation is successful, the difference between zeta burned // and minted is minted by the bank module and deposited into the module // account. // -// If the observation was unsuccessful, and if the status is "pending outbound", -// prices and nonce are updated and the status is changed to "pending revert". -// If the status was "pending revert", the status is changed to "aborted". +// If the observation is unsuccessful, the logic depends on the previous +// status. +// +// If the previous status was `PendingOutbound`, a new revert transaction is +// created. To cover the revert transaction fee, the required amount of tokens +// submitted with the CCTX are swapped using a Uniswap V2 contract instance on +// ZetaChain for the ZRC20 of the gas token of the receiver chain. The ZRC20 +// tokens are then +// burned. The nonce is updated. If everything is successful, the CCTX status is +// changed to `PendingRevert`. +// +// If the previous status was `PendingRevert`, the CCTX is aborted. +// +// ```mermaid +// stateDiagram-v2 // -// If there's an error in the finalization process, the CCTX status is set to -// 'aborted'. +// state observation <> +// state success_old_status <> +// state fail_old_status <> +// PendingOutbound --> observation: Finalize outbound +// observation --> success_old_status: Observation succeeded +// success_old_status --> Reverted: Old status is PendingRevert +// success_old_status --> OutboundMined: Old status is PendingOutbound +// observation --> fail_old_status: Observation failed +// fail_old_status --> PendingRevert: Old status is PendingOutbound +// fail_old_status --> Aborted: Old status is PendingRevert +// PendingOutbound --> Aborted: Finalize outbound error // -// After finalization the outbound transaction tracker and pending nonces are -// removed, and the CCTX is updated in the store. +// ``` // // Only observer validators are authorized to broadcast this message. func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.MsgVoteOnObservedOutboundTx) (*types.MsgVoteOnObservedOutboundTxResponse, error) { From b7dfadfb2e50db7fb158c33c78dde8585f545b57 Mon Sep 17 00:00:00 2001 From: Charlie <31941002+CharlieMc0@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:00:38 -0400 Subject: [PATCH 3/4] ci: removed unnecessary credentials from ci (#936) * removed unnecessary credentials from ci --- .github/workflows/build.yml | 51 +++++--------------------- .github/workflows/chain-operations.yml | 5 --- .github/workflows/deploy.yml | 8 ++-- .github/workflows/gosec.yml | 6 --- .github/workflows/linter.yml | 8 ++-- 5 files changed, 17 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d363e083d..6c095021f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,11 +58,6 @@ jobs: skip_python: "true" skip_aws_cli: "true" skip_docker_compose: "true" - - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - name: Test uses: nick-fields/retry@v2 @@ -128,11 +123,6 @@ jobs: skip_aws_cli: "true" skip_docker_compose: "true" - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - # - uses: buildjet/cache # timeout-minutes: 5 # with: @@ -235,28 +225,15 @@ jobs: git shell-name: alpine.sh - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - - # - name: Test - # shell: alpine.sh --root {0} - # run: | - # echo "Running Build Tests" - # apk add --no-cache --update - # make clean - # make test - - name: Test - uses: nick-fields/retry@v2 - with: - timeout_minutes: 20 - max_attempts: 2 - retry_on: error - shell: alpine.sh --root {0} - command: | + env: + CGO_ENABLED: 1 + GOOS: linux + GOARCH: ${{ env.CPU_ARCH }} + shell: alpine.sh --root {0} + run: | echo "Running Build Tests" + apk add --no-cache --update make clean make test @@ -371,11 +348,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - - name: Install Pipeline Dependencies uses: ./.github/actions/install-dependencies timeout-minutes: 8 @@ -519,11 +491,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - - name: Install Pipeline Dependencies uses: ./.github/actions/install-dependencies timeout-minutes: 8 @@ -584,10 +551,10 @@ jobs: discord_token: "${{ secrets.DISCORD_TOKEN }}" discord_channel_id: "${{ secrets.DISCORD_CHANNEL_ID }}" discord_message: | - Hey <@&1122981184255840306>! A new version of the zetachain node has been released. + Hey <@&1122981184255840306>! A new version of the ZetaChain software has been released. Major Version Upgrade (e.g. v5.x.x to V6.x.x) must be completed through a governance proposal. - We will submit a governance proposal in the next few days with a 12-hour voting period. + We will submit a governance proposal in the next few days. More specific information including block height will be shared as part of the governance proposal. See the release notes for more details. https://github.com/zeta-chain/node/releases/tag/${{ env.BINARY_VERSION }} diff --git a/.github/workflows/chain-operations.yml b/.github/workflows/chain-operations.yml index 2c9e360698..88bd4c06c6 100644 --- a/.github/workflows/chain-operations.yml +++ b/.github/workflows/chain-operations.yml @@ -35,11 +35,6 @@ jobs: - name: Install Pipeline Dependencies uses: ./.github/actions/install-dependencies - - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 40816a122d..e5f234ca6e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,10 +32,10 @@ jobs: - name: Install Pipeline Dependencies uses: ./.github/actions/install-dependencies - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} + # - name: setup-git-credentials + # uses: de-vri-es/setup-git-credentials@v2.0.8 + # with: + # credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index 8195f53a5d..dd4791f507 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -20,12 +20,6 @@ jobs: with: fetch-depth: 0 - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - - - name: Set up Go uses: actions/setup-go@v2 with: diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 6e79fea33a..87781cd21e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -26,10 +26,10 @@ jobs: # - name: Install Pipeline Dependencies # uses: ./.github/actions/install-dependencies - - name: setup-git-credentials - uses: de-vri-es/setup-git-credentials@v2.0.8 - with: - credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} + # - name: setup-git-credentials + # uses: de-vri-es/setup-git-credentials@v2.0.8 + # with: + # credentials: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }} - name: Set up Go uses: actions/setup-go@v3 From 50fa378be15c0467a33af1b8dce20ac6ed1a5a91 Mon Sep 17 00:00:00 2001 From: brewmaster012 <88689859+brewmaster012@users.noreply.github.com> Date: Wed, 9 Aug 2023 12:33:49 -0500 Subject: [PATCH 4/4] feat: remote omni-chain call context: sender and chainID (#912) * make smoketest work * smoketest: add test for context in depositAndCall * add missing files * add Update System Contract Address msg and smoketest * fix linter complaints * fix openapi * fix gosec complaint and CI config * fix linter config * fix generated file check fail * try fix CI config * address PR comments * add typed events * migrate one more event to typed event * cleanup fixme * update protocol-contract package to latest main branch * Update x/fungible/keeper/evm.go Co-authored-by: Lucas Bertrand * PR comments address: error types * re-generate go.sum * use protocol-contract commit 5dfbe4f which renames Context => zContext --------- Co-authored-by: brewmaster012 <> Co-authored-by: Lucas Bertrand --- .github/workflows/gosec.yml | 6 +- .github/workflows/linter.yml | 5 +- cmd/zetacore_utils/main.go | 1 + common/chain.go | 10 + .../contracts/contextapp/ContextApp.abi | 83 ++ .../contracts/contextapp/ContextApp.bin | 1 + .../contracts/contextapp/ContextApp.go | 368 ++++++ .../contracts/contextapp/ContextApp.json | 86 ++ .../contracts/contextapp/ContextApp.sol | 29 + .../contracts/contextapp/bindings.go | 39 + .../contracts/zevmswap/ZEVMSwapApp.abi | 22 + .../contracts/zevmswap/ZEVMSwapApp.bin | 2 +- .../contracts/zevmswap/ZEVMSwapApp.go | 40 +- .../contracts/zevmswap/ZEVMSwapApp.json | 24 +- .../contracts/zevmswap/ZEVMSwapApp.sol | 9 +- .../smoketest/contracts/zevmswap/bindings.go | 3 +- .../localnet/orchestrator/smoketest/main.go | 22 + .../orchestrator/smoketest/test_bitcoin.go | 123 +- .../orchestrator/smoketest/test_context.go | 88 ++ .../smoketest/test_crosschain_swap.go | 2 +- .../orchestrator/smoketest/test_setup.go | 2 +- contrib/rpctest/main.go | 2 +- docs/openapi/openapi.swagger.yaml | 2 + docs/spec/fungible/messages.md | 9 + go.mod | 2 +- go.sum | 4 +- proto/fungible/events.proto | 26 + proto/fungible/tx.proto | 8 + scripts/gen-spec.go | 2 + x/crosschain/keeper/evm_deposit.go | 7 +- x/crosschain/types/expected_keepers.go | 1 + .../begin_blocker_deploy_system_contracts.go | 3 + ...blocker_deploy_system_contracts_privnet.go | 28 + ...blocker_deploy_system_contracts_testnet.go | 4 + x/fungible/keeper/deposits.go | 17 +- x/fungible/keeper/evm.go | 13 +- x/fungible/keeper/foreign_coins.go | 2 +- .../msg_server_deploy_fungible_coin_zrc20.go | 30 +- .../msg_server_update_system_contract.go | 81 ++ x/fungible/module.go | 8 + x/fungible/types/errors.go | 1 + x/fungible/types/events.pb.go | 1016 +++++++++++++++++ .../types/message_update_system_contract.go | 52 + x/fungible/types/tx.pb.go | 442 ++++++- zetaclient/bitcoin_client.go | 8 +- 45 files changed, 2537 insertions(+), 196 deletions(-) create mode 100644 contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.abi create mode 100644 contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.bin create mode 100644 contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.go create mode 100644 contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.json create mode 100644 contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.sol create mode 100644 contrib/localnet/orchestrator/smoketest/contracts/contextapp/bindings.go create mode 100644 contrib/localnet/orchestrator/smoketest/test_context.go create mode 100644 proto/fungible/events.proto create mode 100644 x/fungible/keeper/msg_server_update_system_contract.go create mode 100644 x/fungible/types/events.pb.go create mode 100644 x/fungible/types/message_update_system_contract.go diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index dd4791f507..23352a1e5a 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -5,9 +5,7 @@ on: - '*' pull_request: -env: - GOPRIVATE: github.com/zeta-chain/* - + jobs: gosec: runs-on: ubuntu-latest @@ -23,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 # - name: Install Pipeline Dependencies # uses: ./.github/actions/install-dependencies diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 87781cd21e..16325f08b7 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -5,9 +5,6 @@ on: - '*' pull_request: -env: - GOPRIVATE: github.com/zeta-chain/* - concurrency: group: linters-${{ github.head_ref || github.run_id }} cancel-in-progress: true @@ -15,7 +12,7 @@ concurrency: jobs: lint: runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 7 env: GO111MODULE: on diff --git a/cmd/zetacore_utils/main.go b/cmd/zetacore_utils/main.go index 42a593fa5a..bcc9bf2302 100644 --- a/cmd/zetacore_utils/main.go +++ b/cmd/zetacore_utils/main.go @@ -123,6 +123,7 @@ func readLines(path string) ([]string, error) { if err != nil { return nil, err } + /* #nosec G307 */ defer file.Close() var lines []string diff --git a/common/chain.go b/common/chain.go index 59c2ceb30e..9eeb9f63d3 100644 --- a/common/chain.go +++ b/common/chain.go @@ -74,6 +74,16 @@ func (chain Chain) EncodeAddress(b []byte) (string, error) { return "", fmt.Errorf("chain (%d) not supported", chain.ChainId) } +// DecodeAddress decode the address string to bytes +func (chain Chain) DecodeAddress(addr string) ([]byte, error) { + if IsEVMChain(chain.ChainId) { + return ethcommon.HexToAddress(addr).Bytes(), nil + } else if IsBitcoinChain(chain.ChainId) { + return []byte(addr), nil + } + return nil, fmt.Errorf("chain (%d) not supported", chain.ChainId) +} + func IsEVMChain(chainID int64) bool { return chainID == 5 || // Goerli chainID == 80001 || // Polygon mumbai diff --git a/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.abi b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.abi new file mode 100644 index 0000000000..228e151af1 --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.abi @@ -0,0 +1,83 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "msgSender", + "type": "address" + } + ], + "name": "ContextData", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + } + ], + "internalType": "struct Context", + "name": "context", + "type": "tuple" + }, + { + "internalType": "address", + "name": "zrc20", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "onCrossChainCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.bin b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.bin new file mode 100644 index 0000000000..128149841e --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b50610420806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a60048036038101906100459190610182565b61004c565b005b7fcde88c82509f7dbeaae2782de64879ac731556f65d4474e9afc4ea01cca4498885806000019061007d91906102bf565b8760200160208101906100909190610155565b8860400135336040516100a7959493929190610271565b60405180910390a15050505050565b6000813590506100c5816103bc565b92915050565b60008083601f8401126100e1576100e0610383565b5b8235905067ffffffffffffffff8111156100fe576100fd61037e565b5b60208301915083600182028301111561011a57610119610397565b5b9250929050565b6000606082840312156101375761013661038d565b5b81905092915050565b60008135905061014f816103d3565b92915050565b60006020828403121561016b5761016a6103a6565b5b6000610179848285016100b6565b91505092915050565b60008060008060006080868803121561019e5761019d6103a6565b5b600086013567ffffffffffffffff8111156101bc576101bb6103a1565b5b6101c888828901610121565b95505060206101d9888289016100b6565b94505060406101ea88828901610140565b935050606086013567ffffffffffffffff81111561020b5761020a6103a1565b5b610217888289016100cb565b92509250509295509295909350565b61022f81610333565b82525050565b60006102418385610322565b935061024e83858461036f565b610257836103ab565b840190509392505050565b61026b81610365565b82525050565b6000608082019050818103600083015261028c818789610235565b905061029b6020830186610226565b6102a86040830185610262565b6102b56060830184610226565b9695505050505050565b600080833560016020038436030381126102dc576102db610392565b5b80840192508235915067ffffffffffffffff8211156102fe576102fd610388565b5b60208301925060018202360383131561031a5761031961039c565b5b509250929050565b600082825260208201905092915050565b600061033e82610345565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6103c581610333565b81146103d057600080fd5b50565b6103dc81610365565b81146103e757600080fd5b5056fea26469706673582212203bf8ff0cc81cde452b74dd59e10fc546b8344cb0b268971059b45bc40191115d64736f6c63430008070033 diff --git a/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.go b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.go new file mode 100644 index 0000000000..6423071a86 --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.go @@ -0,0 +1,368 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package contextapp + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// Context is an auto generated low-level Go binding around an user-defined struct. +type Context struct { + Origin []byte + Sender common.Address + ChainID *big.Int +} + +// ContextAppMetaData contains all meta data concerning the ContextApp contract. +var ContextAppMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"msgSender\",\"type\":\"address\"}],\"name\":\"ContextData\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structContext\",\"name\":\"context\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50610420806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a60048036038101906100459190610182565b61004c565b005b7fcde88c82509f7dbeaae2782de64879ac731556f65d4474e9afc4ea01cca4498885806000019061007d91906102bf565b8760200160208101906100909190610155565b8860400135336040516100a7959493929190610271565b60405180910390a15050505050565b6000813590506100c5816103bc565b92915050565b60008083601f8401126100e1576100e0610383565b5b8235905067ffffffffffffffff8111156100fe576100fd61037e565b5b60208301915083600182028301111561011a57610119610397565b5b9250929050565b6000606082840312156101375761013661038d565b5b81905092915050565b60008135905061014f816103d3565b92915050565b60006020828403121561016b5761016a6103a6565b5b6000610179848285016100b6565b91505092915050565b60008060008060006080868803121561019e5761019d6103a6565b5b600086013567ffffffffffffffff8111156101bc576101bb6103a1565b5b6101c888828901610121565b95505060206101d9888289016100b6565b94505060406101ea88828901610140565b935050606086013567ffffffffffffffff81111561020b5761020a6103a1565b5b610217888289016100cb565b92509250509295509295909350565b61022f81610333565b82525050565b60006102418385610322565b935061024e83858461036f565b610257836103ab565b840190509392505050565b61026b81610365565b82525050565b6000608082019050818103600083015261028c818789610235565b905061029b6020830186610226565b6102a86040830185610262565b6102b56060830184610226565b9695505050505050565b600080833560016020038436030381126102dc576102db610392565b5b80840192508235915067ffffffffffffffff8211156102fe576102fd610388565b5b60208301925060018202360383131561031a5761031961039c565b5b509250929050565b600082825260208201905092915050565b600061033e82610345565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6103c581610333565b81146103d057600080fd5b50565b6103dc81610365565b81146103e757600080fd5b5056fea26469706673582212203bf8ff0cc81cde452b74dd59e10fc546b8344cb0b268971059b45bc40191115d64736f6c63430008070033", +} + +// ContextAppABI is the input ABI used to generate the binding from. +// Deprecated: Use ContextAppMetaData.ABI instead. +var ContextAppABI = ContextAppMetaData.ABI + +// ContextAppBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use ContextAppMetaData.Bin instead. +var ContextAppBin = ContextAppMetaData.Bin + +// DeployContextApp deploys a new Ethereum contract, binding an instance of ContextApp to it. +func DeployContextApp(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ContextApp, error) { + parsed, err := ContextAppMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ContextAppBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &ContextApp{ContextAppCaller: ContextAppCaller{contract: contract}, ContextAppTransactor: ContextAppTransactor{contract: contract}, ContextAppFilterer: ContextAppFilterer{contract: contract}}, nil +} + +// ContextApp is an auto generated Go binding around an Ethereum contract. +type ContextApp struct { + ContextAppCaller // Read-only binding to the contract + ContextAppTransactor // Write-only binding to the contract + ContextAppFilterer // Log filterer for contract events +} + +// ContextAppCaller is an auto generated read-only Go binding around an Ethereum contract. +type ContextAppCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ContextAppTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ContextAppTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ContextAppFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ContextAppFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ContextAppSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ContextAppSession struct { + Contract *ContextApp // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ContextAppCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ContextAppCallerSession struct { + Contract *ContextAppCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ContextAppTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ContextAppTransactorSession struct { + Contract *ContextAppTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ContextAppRaw is an auto generated low-level Go binding around an Ethereum contract. +type ContextAppRaw struct { + Contract *ContextApp // Generic contract binding to access the raw methods on +} + +// ContextAppCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ContextAppCallerRaw struct { + Contract *ContextAppCaller // Generic read-only contract binding to access the raw methods on +} + +// ContextAppTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ContextAppTransactorRaw struct { + Contract *ContextAppTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewContextApp creates a new instance of ContextApp, bound to a specific deployed contract. +func NewContextApp(address common.Address, backend bind.ContractBackend) (*ContextApp, error) { + contract, err := bindContextApp(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ContextApp{ContextAppCaller: ContextAppCaller{contract: contract}, ContextAppTransactor: ContextAppTransactor{contract: contract}, ContextAppFilterer: ContextAppFilterer{contract: contract}}, nil +} + +// NewContextAppCaller creates a new read-only instance of ContextApp, bound to a specific deployed contract. +func NewContextAppCaller(address common.Address, caller bind.ContractCaller) (*ContextAppCaller, error) { + contract, err := bindContextApp(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ContextAppCaller{contract: contract}, nil +} + +// NewContextAppTransactor creates a new write-only instance of ContextApp, bound to a specific deployed contract. +func NewContextAppTransactor(address common.Address, transactor bind.ContractTransactor) (*ContextAppTransactor, error) { + contract, err := bindContextApp(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ContextAppTransactor{contract: contract}, nil +} + +// NewContextAppFilterer creates a new log filterer instance of ContextApp, bound to a specific deployed contract. +func NewContextAppFilterer(address common.Address, filterer bind.ContractFilterer) (*ContextAppFilterer, error) { + contract, err := bindContextApp(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ContextAppFilterer{contract: contract}, nil +} + +// bindContextApp binds a generic wrapper to an already deployed contract. +func bindContextApp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ContextAppMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ContextApp *ContextAppRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ContextApp.Contract.ContextAppCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ContextApp *ContextAppRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ContextApp.Contract.ContextAppTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ContextApp *ContextAppRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ContextApp.Contract.ContextAppTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ContextApp *ContextAppCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ContextApp.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ContextApp *ContextAppTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ContextApp.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ContextApp *ContextAppTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ContextApp.Contract.contract.Transact(opts, method, params...) +} + +// OnCrossChainCall is a paid mutator transaction binding the contract method 0xde43156e. +// +// Solidity: function onCrossChainCall((bytes,address,uint256) context, address zrc20, uint256 amount, bytes message) returns() +func (_ContextApp *ContextAppTransactor) OnCrossChainCall(opts *bind.TransactOpts, context Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ContextApp.contract.Transact(opts, "onCrossChainCall", context, zrc20, amount, message) +} + +// OnCrossChainCall is a paid mutator transaction binding the contract method 0xde43156e. +// +// Solidity: function onCrossChainCall((bytes,address,uint256) context, address zrc20, uint256 amount, bytes message) returns() +func (_ContextApp *ContextAppSession) OnCrossChainCall(context Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ContextApp.Contract.OnCrossChainCall(&_ContextApp.TransactOpts, context, zrc20, amount, message) +} + +// OnCrossChainCall is a paid mutator transaction binding the contract method 0xde43156e. +// +// Solidity: function onCrossChainCall((bytes,address,uint256) context, address zrc20, uint256 amount, bytes message) returns() +func (_ContextApp *ContextAppTransactorSession) OnCrossChainCall(context Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ContextApp.Contract.OnCrossChainCall(&_ContextApp.TransactOpts, context, zrc20, amount, message) +} + +// ContextAppContextDataIterator is returned from FilterContextData and is used to iterate over the raw logs and unpacked data for ContextData events raised by the ContextApp contract. +type ContextAppContextDataIterator struct { + Event *ContextAppContextData // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ContextAppContextDataIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ContextAppContextData) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ContextAppContextData) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ContextAppContextDataIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ContextAppContextDataIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ContextAppContextData represents a ContextData event raised by the ContextApp contract. +type ContextAppContextData struct { + Origin []byte + Sender common.Address + ChainID *big.Int + MsgSender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterContextData is a free log retrieval operation binding the contract event 0xcde88c82509f7dbeaae2782de64879ac731556f65d4474e9afc4ea01cca44988. +// +// Solidity: event ContextData(bytes origin, address sender, uint256 chainID, address msgSender) +func (_ContextApp *ContextAppFilterer) FilterContextData(opts *bind.FilterOpts) (*ContextAppContextDataIterator, error) { + + logs, sub, err := _ContextApp.contract.FilterLogs(opts, "ContextData") + if err != nil { + return nil, err + } + return &ContextAppContextDataIterator{contract: _ContextApp.contract, event: "ContextData", logs: logs, sub: sub}, nil +} + +// WatchContextData is a free log subscription operation binding the contract event 0xcde88c82509f7dbeaae2782de64879ac731556f65d4474e9afc4ea01cca44988. +// +// Solidity: event ContextData(bytes origin, address sender, uint256 chainID, address msgSender) +func (_ContextApp *ContextAppFilterer) WatchContextData(opts *bind.WatchOpts, sink chan<- *ContextAppContextData) (event.Subscription, error) { + + logs, sub, err := _ContextApp.contract.WatchLogs(opts, "ContextData") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ContextAppContextData) + if err := _ContextApp.contract.UnpackLog(event, "ContextData", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseContextData is a log parse operation binding the contract event 0xcde88c82509f7dbeaae2782de64879ac731556f65d4474e9afc4ea01cca44988. +// +// Solidity: event ContextData(bytes origin, address sender, uint256 chainID, address msgSender) +func (_ContextApp *ContextAppFilterer) ParseContextData(log types.Log) (*ContextAppContextData, error) { + event := new(ContextAppContextData) + if err := _ContextApp.contract.UnpackLog(event, "ContextData", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.json b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.json new file mode 100644 index 0000000000..a17edab2b9 --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.json @@ -0,0 +1,86 @@ +{ + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "msgSender", + "type": "address" + } + ], + "name": "ContextData", + "type": "event" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + } + ], + "internalType": "struct Context", + "name": "context", + "type": "tuple" + }, + { + "internalType": "address", + "name": "zrc20", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "message", + "type": "bytes" + } + ], + "name": "onCrossChainCall", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bin": "608060405234801561001057600080fd5b50610420806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063de43156e14610030575b600080fd5b61004a60048036038101906100459190610182565b61004c565b005b7fcde88c82509f7dbeaae2782de64879ac731556f65d4474e9afc4ea01cca4498885806000019061007d91906102bf565b8760200160208101906100909190610155565b8860400135336040516100a7959493929190610271565b60405180910390a15050505050565b6000813590506100c5816103bc565b92915050565b60008083601f8401126100e1576100e0610383565b5b8235905067ffffffffffffffff8111156100fe576100fd61037e565b5b60208301915083600182028301111561011a57610119610397565b5b9250929050565b6000606082840312156101375761013661038d565b5b81905092915050565b60008135905061014f816103d3565b92915050565b60006020828403121561016b5761016a6103a6565b5b6000610179848285016100b6565b91505092915050565b60008060008060006080868803121561019e5761019d6103a6565b5b600086013567ffffffffffffffff8111156101bc576101bb6103a1565b5b6101c888828901610121565b95505060206101d9888289016100b6565b94505060406101ea88828901610140565b935050606086013567ffffffffffffffff81111561020b5761020a6103a1565b5b610217888289016100cb565b92509250509295509295909350565b61022f81610333565b82525050565b60006102418385610322565b935061024e83858461036f565b610257836103ab565b840190509392505050565b61026b81610365565b82525050565b6000608082019050818103600083015261028c818789610235565b905061029b6020830186610226565b6102a86040830185610262565b6102b56060830184610226565b9695505050505050565b600080833560016020038436030381126102dc576102db610392565b5b80840192508235915067ffffffffffffffff8211156102fe576102fd610388565b5b60208301925060018202360383131561031a5761031961039c565b5b509250929050565b600082825260208201905092915050565b600061033e82610345565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b6103c581610333565b81146103d057600080fd5b50565b6103dc81610365565b81146103e757600080fd5b5056fea26469706673582212203bf8ff0cc81cde452b74dd59e10fc546b8344cb0b268971059b45bc40191115d64736f6c63430008070033" +} diff --git a/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.sol b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.sol new file mode 100644 index 0000000000..ddd5ef0f5a --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/ContextApp.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.7; + +struct Context { + bytes origin; + address sender; + uint256 chainID; +} + +interface zContract { + function onCrossChainCall( + Context calldata context, + address zrc20, + uint256 amount, + bytes calldata message + ) external; +} + +contract ContextApp is zContract { + + constructor() {} + event ContextData(bytes origin, address sender, uint256 chainID, address msgSender); + + // Call this function to perform a cross-chain swap + function onCrossChainCall(Context calldata context, address zrc20, uint256 amount, bytes calldata message) external override { + + emit ContextData(context.origin, context.sender, context.chainID, msg.sender); + } +} \ No newline at end of file diff --git a/contrib/localnet/orchestrator/smoketest/contracts/contextapp/bindings.go b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/bindings.go new file mode 100644 index 0000000000..e3246d6be5 --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/contracts/contextapp/bindings.go @@ -0,0 +1,39 @@ +// solc use version 0.8.7 +//go:generate sh -c " solc --evm-version london --allow-paths .., --combined-json abi,bin --base-path .. ContextApp.sol | jq '.contracts.\"ContextApp.sol:ContextApp\"' > ContextApp.json" +//go:generate sh -c "cat ContextApp.json | jq .abi > ContextApp.abi" +//go:generate sh -c "cat ContextApp.json | jq .bin | tr -d '\"' > ContextApp.bin" + +//go:generate sh -c "abigen --abi ContextApp.abi --bin ContextApp.bin --pkg contextapp --type ContextApp --out ContextApp.go" + +package contextapp + +import ( + _ "embed" + "encoding/json" + + "github.com/ethereum/go-ethereum/accounts/abi" + evmtypes "github.com/evmos/ethermint/x/evm/types" +) + +type CompiledContract struct { + ABI abi.ABI + Bin evmtypes.HexString +} + +var ( + //go:embed ContextApp.json + ContextAppJSON []byte // nolint: golint + + ContextAppContract CompiledContract +) + +func init() { + err := json.Unmarshal(ContextAppJSON, &ContextAppContract) + if err != nil { + panic(err) + } + + if len(ContextAppContract.Bin) == 0 { + panic("load contract failed") + } +} diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.abi b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.abi index 6a0b9f3313..50bf177b93 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.abi +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.abi @@ -75,6 +75,28 @@ }, { "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + } + ], + "internalType": "struct Context", + "name": "", + "type": "tuple" + }, { "internalType": "address", "name": "zrc20", diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin index b9ac03ca6f..9b241a147f 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.bin @@ -1 +1 @@ -60c06040523480156200001157600080fd5b506040516200121e3803806200121e833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161108b62000193600039600081816101b201526101fa0152600081816101d60152818161039d0152610422015261108b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063c8522691146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107b1565b610115565b6040516100849291906108cf565b60405180910390f35b6100956101b0565b6040516100a291906108ff565b60405180910390f35b6100b36101d4565b6040516100c091906108ff565b60405180910390f35b6100e360048036038101906100de919061097c565b6101f8565b005b6100ff60048036038101906100fa91906109f0565b610709565b60405161010c9190610a50565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610a7c565b906101439190610afb565b60601c90508686601490809261015b93929190610a7c565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af610b5a565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5610b89565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344610b89565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610bc7565b6020604051808303816000875af11580156103f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041d9190610c28565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161048b959493929190610d58565b6000604051808303816000875af11580156104aa573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d39190610ed6565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610522573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105469190610f34565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610585929190610bc7565b6020604051808303816000875af11580156105a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c89190610c28565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387856001815181106105fa576105f9610b89565b5b60200260200101516040518363ffffffff1660e01b815260040161061f929190610bc7565b6020604051808303816000875af115801561063e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106629190610c28565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069457610693610b89565b5b60200260200101516040518363ffffffff1660e01b81526004016106b9929190610f74565b6020604051808303816000875af11580156106d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106fc9190610c28565b5050505050505050505050565b60608383836040516020016107209392919061102b565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126107715761077061074c565b5b8235905067ffffffffffffffff81111561078e5761078d610751565b5b6020830191508360018202830111156107aa576107a9610756565b5b9250929050565b600080602083850312156107c8576107c7610742565b5b600083013567ffffffffffffffff8111156107e6576107e5610747565b5b6107f28582860161075b565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610829826107fe565b9050919050565b6108398161081e565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561087957808201518184015260208101905061085e565b60008484015250505050565b6000601f19601f8301169050919050565b60006108a18261083f565b6108ab818561084a565b93506108bb81856020860161085b565b6108c481610885565b840191505092915050565b60006040820190506108e46000830185610830565b81810360208301526108f68184610896565b90509392505050565b60006020820190506109146000830184610830565b92915050565b6109238161081e565b811461092e57600080fd5b50565b6000813590506109408161091a565b92915050565b6000819050919050565b61095981610946565b811461096457600080fd5b50565b60008135905061097681610950565b92915050565b6000806000806060858703121561099657610995610742565b5b60006109a487828801610931565b94505060206109b587828801610967565b935050604085013567ffffffffffffffff8111156109d6576109d5610747565b5b6109e28782880161075b565b925092505092959194509250565b600080600060408486031215610a0957610a08610742565b5b6000610a1786828701610931565b935050602084013567ffffffffffffffff811115610a3857610a37610747565b5b610a448682870161075b565b92509250509250925092565b60006020820190508181036000830152610a6a8184610896565b905092915050565b600080fd5b600080fd5b60008085851115610a9057610a8f610a72565b5b83861115610aa157610aa0610a77565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b078383610ab7565b82610b128135610ac2565b92506014821015610b5257610b4d7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610aee565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610bc181610946565b82525050565b6000604082019050610bdc6000830185610830565b610be96020830184610bb8565b9392505050565b60008115159050919050565b610c0581610bf0565b8114610c1057600080fd5b50565b600081519050610c2281610bfc565b92915050565b600060208284031215610c3e57610c3d610742565b5b6000610c4c84828501610c13565b91505092915050565b6000819050919050565b6000819050919050565b6000610c84610c7f610c7a84610c55565b610c5f565b610946565b9050919050565b610c9481610c69565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610ccf8161081e565b82525050565b6000610ce18383610cc6565b60208301905092915050565b6000602082019050919050565b6000610d0582610c9a565b610d0f8185610ca5565b9350610d1a83610cb6565b8060005b83811015610d4b578151610d328882610cd5565b9750610d3d83610ced565b925050600181019050610d1e565b5085935050505092915050565b600060a082019050610d6d6000830188610bb8565b610d7a6020830187610c8b565b8181036040830152610d8c8186610cfa565b9050610d9b6060830185610830565b610da86080830184610bb8565b9695505050505050565b610dbb82610885565b810181811067ffffffffffffffff82111715610dda57610dd9610b5a565b5b80604052505050565b6000610ded610738565b9050610df98282610db2565b919050565b600067ffffffffffffffff821115610e1957610e18610b5a565b5b602082029050602081019050919050565b600081519050610e3981610950565b92915050565b6000610e52610e4d84610dfe565b610de3565b90508083825260208201905060208402830185811115610e7557610e74610756565b5b835b81811015610e9e5780610e8a8882610e2a565b845260208401935050602081019050610e77565b5050509392505050565b600082601f830112610ebd57610ebc61074c565b5b8151610ecd848260208601610e3f565b91505092915050565b600060208284031215610eec57610eeb610742565b5b600082015167ffffffffffffffff811115610f0a57610f09610747565b5b610f1684828501610ea8565b91505092915050565b600081519050610f2e8161091a565b92915050565b60008060408385031215610f4b57610f4a610742565b5b6000610f5985828601610f1f565b9250506020610f6a85828601610e2a565b9150509250929050565b60006040820190508181036000830152610f8e8185610896565b9050610f9d6020830184610bb8565b9392505050565b60008160601b9050919050565b6000610fbc82610fa4565b9050919050565b6000610fce82610fb1565b9050919050565b610fe6610fe18261081e565b610fc3565b82525050565b600081905092915050565b82818337600083830152505050565b60006110128385610fec565b935061101f838584610ff7565b82840190509392505050565b60006110378286610fd5565b601482019150611048828486611006565b915081905094935050505056fea2646970667358221220d849874c97d6127643ba0363fe1dec561e63a7a801178715667509df9a3dcef364736f6c63430008120033 +60c06040523480156200001157600080fd5b5060405162001333380380620013338339818101604052810190620000379190620000c4565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b8152505050506200015e565b600081519050620000be8162000144565b92915050565b60008060408385031215620000de57620000dd6200013f565b5b6000620000ee85828601620000ad565b92505060206200010185828601620000ad565b9150509250929050565b600062000118826200011f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200014f816200010b565b81146200015b57600080fd5b50565b60805160601c60a05160601c6111946200019f600039600081816101b201526101fa0152600081816101d60152818161039d015261043101526111946000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b61007660048036038101906100719190610a30565b610115565b604051610084929190610c8d565b60405180910390f35b6100956101b0565b6040516100a29190610c72565b60405180910390f35b6100b36101d4565b6040516100c09190610c72565b60405180910390f35b6100e360048036038101906100de9190610a7d565b6101f8565b005b6100ff60048036038101906100fa919061091a565b61076f565b60405161010c9190610ce6565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610e4e565b906101439190610f31565b60601c90508686601490809261015b93929190610e4e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af611097565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610cbd565b602060405180830381600087803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042c9190610a03565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161049a959493929190610d38565b600060405180830381600087803b1580156104b457600080fd5b505af11580156104c8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104f191906109ba565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b15801561053b57600080fd5b505afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610573919061097a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b81526004016105b2929190610cbd565b602060405180830381600087803b1580156105cc57600080fd5b505af11580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3878560018151811061063657610635611068565b5b60200260200101516040518363ffffffff1660e01b815260040161065b929190610cbd565b602060405180830381600087803b15801561067557600080fd5b505af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268683866001815181106106e0576106df611068565b5b60200260200101516106f29190610e89565b6040518363ffffffff1660e01b815260040161070f929190610d08565b602060405180830381600087803b15801561072957600080fd5b505af115801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610a03565b505050505050505050505050565b606083838360405160200161078693929190610c48565b60405160208183030381529060405290509392505050565b60006107b16107ac84610db7565b610d92565b905080838252602082019050828560208602820111156107d4576107d36110df565b5b60005b8581101561080457816107ea8882610905565b8452602084019350602083019250506001810190506107d7565b5050509392505050565b60008135905061081d81611119565b92915050565b60008151905061083281611119565b92915050565b600082601f83011261084d5761084c6110cb565b5b815161085d84826020860161079e565b91505092915050565b60008151905061087581611130565b92915050565b60008083601f840112610891576108906110cb565b5b8235905067ffffffffffffffff8111156108ae576108ad6110c6565b5b6020830191508360018202830111156108ca576108c96110df565b5b9250929050565b6000606082840312156108e7576108e66110d0565b5b81905092915050565b6000813590506108ff81611147565b92915050565b60008151905061091481611147565b92915050565b600080600060408486031215610933576109326110e9565b5b60006109418682870161080e565b935050602084013567ffffffffffffffff811115610962576109616110e4565b5b61096e8682870161087b565b92509250509250925092565b60008060408385031215610991576109906110e9565b5b600061099f85828601610823565b92505060206109b085828601610905565b9150509250929050565b6000602082840312156109d0576109cf6110e9565b5b600082015167ffffffffffffffff8111156109ee576109ed6110e4565b5b6109fa84828501610838565b91505092915050565b600060208284031215610a1957610a186110e9565b5b6000610a2784828501610866565b91505092915050565b60008060208385031215610a4757610a466110e9565b5b600083013567ffffffffffffffff811115610a6557610a646110e4565b5b610a718582860161087b565b92509250509250929050565b600080600080600060808688031215610a9957610a986110e9565b5b600086013567ffffffffffffffff811115610ab757610ab66110e4565b5b610ac3888289016108d1565b9550506020610ad48882890161080e565b9450506040610ae5888289016108f0565b935050606086013567ffffffffffffffff811115610b0657610b056110e4565b5b610b128882890161087b565b92509250509295509295909350565b6000610b2d8383610b39565b60208301905092915050565b610b4281610ebd565b82525050565b610b5181610ebd565b82525050565b610b68610b6382610ebd565b611015565b82525050565b6000610b7982610df3565b610b838185610e21565b9350610b8e83610de3565b8060005b83811015610bbf578151610ba68882610b21565b9750610bb183610e14565b925050600181019050610b92565b5085935050505092915050565b6000610bd88385610e43565b9350610be5838584610fa2565b82840190509392505050565b6000610bfc82610e09565b610c068185610e32565b9350610c16818560208601610fb1565b610c1f816110ee565b840191505092915050565b610c3381610f90565b82525050565b610c4281610f27565b82525050565b6000610c548286610b57565b601482019150610c65828486610bcc565b9150819050949350505050565b6000602082019050610c876000830184610b48565b92915050565b6000604082019050610ca26000830185610b48565b8181036020830152610cb48184610bf1565b90509392505050565b6000604082019050610cd26000830185610b48565b610cdf6020830184610c39565b9392505050565b60006020820190508181036000830152610d008184610bf1565b905092915050565b60006040820190508181036000830152610d228185610bf1565b9050610d316020830184610c39565b9392505050565b600060a082019050610d4d6000830188610c39565b610d5a6020830187610c2a565b8181036040830152610d6c8186610b6e565b9050610d7b6060830185610b48565b610d886080830184610c39565b9695505050505050565b6000610d9c610dad565b9050610da88282610fe4565b919050565b6000604051905090565b600067ffffffffffffffff821115610dd257610dd1611097565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600082905092915050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60008085851115610e6257610e616110da565b5b83861115610e7357610e726110d5565b5b6001850283019150848603905094509492505050565b6000610e9482610f27565b9150610e9f83610f27565b925082821015610eb257610eb1611039565b5b828203905092915050565b6000610ec882610f07565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610f3d8383610dfe565b82610f488135610edb565b92506014821015610f8857610f837fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008360140360080261110c565b831692505b505092915050565b6000610f9b82610f27565b9050919050565b82818337600083830152505050565b60005b83811015610fcf578082015181840152602081019050610fb4565b83811115610fde576000848401525b50505050565b610fed826110ee565b810181811067ffffffffffffffff8211171561100c5761100b611097565b5b80604052505050565b600061102082611027565b9050919050565b6000611032826110ff565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b61112281610ebd565b811461112d57600080fd5b50565b61113981610ecf565b811461114457600080fd5b50565b61115081610f27565b811461115b57600080fd5b5056fea264697066735822122077546c2f4741f7d79b7a2e01a3100f966ababfb11046c7872e4f310304d04ce564736f6c63430008070033 diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go index 5390302c92..2aa91eb530 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.go @@ -26,13 +26,19 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) +// Context is an auto generated low-level Go binding around an user-defined struct. +type Context struct { + Origin []byte + Sender common.Address + ChainID *big.Int +} + // ZEVMSwapAppMetaData contains all meta data concerning the ZEVMSwapApp contract. var ZEVMSwapAppMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"router02_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"systemContract_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSender\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LowAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeMemo\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"targetZRC20\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"}],\"name\":\"encodeMemo\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"router02\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"systemContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x60c06040523480156200001157600080fd5b506040516200121e3803806200121e833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161108b62000193600039600081816101b201526101fa0152600081816101d60152818161039d0152610422015261108b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063c8522691146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107b1565b610115565b6040516100849291906108cf565b60405180910390f35b6100956101b0565b6040516100a291906108ff565b60405180910390f35b6100b36101d4565b6040516100c091906108ff565b60405180910390f35b6100e360048036038101906100de919061097c565b6101f8565b005b6100ff60048036038101906100fa91906109f0565b610709565b60405161010c9190610a50565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610a7c565b906101439190610afb565b60601c90508686601490809261015b93929190610a7c565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af610b5a565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5610b89565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344610b89565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610bc7565b6020604051808303816000875af11580156103f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041d9190610c28565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161048b959493929190610d58565b6000604051808303816000875af11580156104aa573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d39190610ed6565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610522573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105469190610f34565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610585929190610bc7565b6020604051808303816000875af11580156105a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c89190610c28565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387856001815181106105fa576105f9610b89565b5b60200260200101516040518363ffffffff1660e01b815260040161061f929190610bc7565b6020604051808303816000875af115801561063e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106629190610c28565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069457610693610b89565b5b60200260200101516040518363ffffffff1660e01b81526004016106b9929190610f74565b6020604051808303816000875af11580156106d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106fc9190610c28565b5050505050505050505050565b60608383836040516020016107209392919061102b565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126107715761077061074c565b5b8235905067ffffffffffffffff81111561078e5761078d610751565b5b6020830191508360018202830111156107aa576107a9610756565b5b9250929050565b600080602083850312156107c8576107c7610742565b5b600083013567ffffffffffffffff8111156107e6576107e5610747565b5b6107f28582860161075b565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610829826107fe565b9050919050565b6108398161081e565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561087957808201518184015260208101905061085e565b60008484015250505050565b6000601f19601f8301169050919050565b60006108a18261083f565b6108ab818561084a565b93506108bb81856020860161085b565b6108c481610885565b840191505092915050565b60006040820190506108e46000830185610830565b81810360208301526108f68184610896565b90509392505050565b60006020820190506109146000830184610830565b92915050565b6109238161081e565b811461092e57600080fd5b50565b6000813590506109408161091a565b92915050565b6000819050919050565b61095981610946565b811461096457600080fd5b50565b60008135905061097681610950565b92915050565b6000806000806060858703121561099657610995610742565b5b60006109a487828801610931565b94505060206109b587828801610967565b935050604085013567ffffffffffffffff8111156109d6576109d5610747565b5b6109e28782880161075b565b925092505092959194509250565b600080600060408486031215610a0957610a08610742565b5b6000610a1786828701610931565b935050602084013567ffffffffffffffff811115610a3857610a37610747565b5b610a448682870161075b565b92509250509250925092565b60006020820190508181036000830152610a6a8184610896565b905092915050565b600080fd5b600080fd5b60008085851115610a9057610a8f610a72565b5b83861115610aa157610aa0610a77565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b078383610ab7565b82610b128135610ac2565b92506014821015610b5257610b4d7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610aee565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610bc181610946565b82525050565b6000604082019050610bdc6000830185610830565b610be96020830184610bb8565b9392505050565b60008115159050919050565b610c0581610bf0565b8114610c1057600080fd5b50565b600081519050610c2281610bfc565b92915050565b600060208284031215610c3e57610c3d610742565b5b6000610c4c84828501610c13565b91505092915050565b6000819050919050565b6000819050919050565b6000610c84610c7f610c7a84610c55565b610c5f565b610946565b9050919050565b610c9481610c69565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610ccf8161081e565b82525050565b6000610ce18383610cc6565b60208301905092915050565b6000602082019050919050565b6000610d0582610c9a565b610d0f8185610ca5565b9350610d1a83610cb6565b8060005b83811015610d4b578151610d328882610cd5565b9750610d3d83610ced565b925050600181019050610d1e565b5085935050505092915050565b600060a082019050610d6d6000830188610bb8565b610d7a6020830187610c8b565b8181036040830152610d8c8186610cfa565b9050610d9b6060830185610830565b610da86080830184610bb8565b9695505050505050565b610dbb82610885565b810181811067ffffffffffffffff82111715610dda57610dd9610b5a565b5b80604052505050565b6000610ded610738565b9050610df98282610db2565b919050565b600067ffffffffffffffff821115610e1957610e18610b5a565b5b602082029050602081019050919050565b600081519050610e3981610950565b92915050565b6000610e52610e4d84610dfe565b610de3565b90508083825260208201905060208402830185811115610e7557610e74610756565b5b835b81811015610e9e5780610e8a8882610e2a565b845260208401935050602081019050610e77565b5050509392505050565b600082601f830112610ebd57610ebc61074c565b5b8151610ecd848260208601610e3f565b91505092915050565b600060208284031215610eec57610eeb610742565b5b600082015167ffffffffffffffff811115610f0a57610f09610747565b5b610f1684828501610ea8565b91505092915050565b600081519050610f2e8161091a565b92915050565b60008060408385031215610f4b57610f4a610742565b5b6000610f5985828601610f1f565b9250506020610f6a85828601610e2a565b9150509250929050565b60006040820190508181036000830152610f8e8185610896565b9050610f9d6020830184610bb8565b9392505050565b60008160601b9050919050565b6000610fbc82610fa4565b9050919050565b6000610fce82610fb1565b9050919050565b610fe6610fe18261081e565b610fc3565b82525050565b600081905092915050565b82818337600083830152505050565b60006110128385610fec565b935061101f838584610ff7565b82840190509392505050565b60006110378286610fd5565b601482019150611048828486611006565b915081905094935050505056fea2646970667358221220d849874c97d6127643ba0363fe1dec561e63a7a801178715667509df9a3dcef364736f6c63430008120033", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"router02_\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"systemContract_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"InvalidSender\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LowAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeMemo\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"targetZRC20\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"recipient\",\"type\":\"bytes\"}],\"name\":\"encodeMemo\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"origin\",\"type\":\"bytes\"},{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"chainID\",\"type\":\"uint256\"}],\"internalType\":\"structContext\",\"name\":\"\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"zrc20\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"onCrossChainCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"router02\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"systemContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x60c06040523480156200001157600080fd5b5060405162001333380380620013338339818101604052810190620000379190620000c4565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b8152505050506200015e565b600081519050620000be8162000144565b92915050565b60008060408385031215620000de57620000dd6200013f565b5b6000620000ee85828601620000ad565b92505060206200010185828601620000ad565b9150509250929050565b600062000118826200011f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200014f816200010b565b81146200015b57600080fd5b50565b60805160601c60a05160601c6111946200019f600039600081816101b201526101fa0152600081816101d60152818161039d015261043101526111946000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b61007660048036038101906100719190610a30565b610115565b604051610084929190610c8d565b60405180910390f35b6100956101b0565b6040516100a29190610c72565b60405180910390f35b6100b36101d4565b6040516100c09190610c72565b60405180910390f35b6100e360048036038101906100de9190610a7d565b6101f8565b005b6100ff60048036038101906100fa919061091a565b61076f565b60405161010c9190610ce6565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610e4e565b906101439190610f31565b60601c90508686601490809261015b93929190610e4e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af611097565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610cbd565b602060405180830381600087803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042c9190610a03565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161049a959493929190610d38565b600060405180830381600087803b1580156104b457600080fd5b505af11580156104c8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104f191906109ba565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b15801561053b57600080fd5b505afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610573919061097a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b81526004016105b2929190610cbd565b602060405180830381600087803b1580156105cc57600080fd5b505af11580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3878560018151811061063657610635611068565b5b60200260200101516040518363ffffffff1660e01b815260040161065b929190610cbd565b602060405180830381600087803b15801561067557600080fd5b505af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268683866001815181106106e0576106df611068565b5b60200260200101516106f29190610e89565b6040518363ffffffff1660e01b815260040161070f929190610d08565b602060405180830381600087803b15801561072957600080fd5b505af115801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610a03565b505050505050505050505050565b606083838360405160200161078693929190610c48565b60405160208183030381529060405290509392505050565b60006107b16107ac84610db7565b610d92565b905080838252602082019050828560208602820111156107d4576107d36110df565b5b60005b8581101561080457816107ea8882610905565b8452602084019350602083019250506001810190506107d7565b5050509392505050565b60008135905061081d81611119565b92915050565b60008151905061083281611119565b92915050565b600082601f83011261084d5761084c6110cb565b5b815161085d84826020860161079e565b91505092915050565b60008151905061087581611130565b92915050565b60008083601f840112610891576108906110cb565b5b8235905067ffffffffffffffff8111156108ae576108ad6110c6565b5b6020830191508360018202830111156108ca576108c96110df565b5b9250929050565b6000606082840312156108e7576108e66110d0565b5b81905092915050565b6000813590506108ff81611147565b92915050565b60008151905061091481611147565b92915050565b600080600060408486031215610933576109326110e9565b5b60006109418682870161080e565b935050602084013567ffffffffffffffff811115610962576109616110e4565b5b61096e8682870161087b565b92509250509250925092565b60008060408385031215610991576109906110e9565b5b600061099f85828601610823565b92505060206109b085828601610905565b9150509250929050565b6000602082840312156109d0576109cf6110e9565b5b600082015167ffffffffffffffff8111156109ee576109ed6110e4565b5b6109fa84828501610838565b91505092915050565b600060208284031215610a1957610a186110e9565b5b6000610a2784828501610866565b91505092915050565b60008060208385031215610a4757610a466110e9565b5b600083013567ffffffffffffffff811115610a6557610a646110e4565b5b610a718582860161087b565b92509250509250929050565b600080600080600060808688031215610a9957610a986110e9565b5b600086013567ffffffffffffffff811115610ab757610ab66110e4565b5b610ac3888289016108d1565b9550506020610ad48882890161080e565b9450506040610ae5888289016108f0565b935050606086013567ffffffffffffffff811115610b0657610b056110e4565b5b610b128882890161087b565b92509250509295509295909350565b6000610b2d8383610b39565b60208301905092915050565b610b4281610ebd565b82525050565b610b5181610ebd565b82525050565b610b68610b6382610ebd565b611015565b82525050565b6000610b7982610df3565b610b838185610e21565b9350610b8e83610de3565b8060005b83811015610bbf578151610ba68882610b21565b9750610bb183610e14565b925050600181019050610b92565b5085935050505092915050565b6000610bd88385610e43565b9350610be5838584610fa2565b82840190509392505050565b6000610bfc82610e09565b610c068185610e32565b9350610c16818560208601610fb1565b610c1f816110ee565b840191505092915050565b610c3381610f90565b82525050565b610c4281610f27565b82525050565b6000610c548286610b57565b601482019150610c65828486610bcc565b9150819050949350505050565b6000602082019050610c876000830184610b48565b92915050565b6000604082019050610ca26000830185610b48565b8181036020830152610cb48184610bf1565b90509392505050565b6000604082019050610cd26000830185610b48565b610cdf6020830184610c39565b9392505050565b60006020820190508181036000830152610d008184610bf1565b905092915050565b60006040820190508181036000830152610d228185610bf1565b9050610d316020830184610c39565b9392505050565b600060a082019050610d4d6000830188610c39565b610d5a6020830187610c2a565b8181036040830152610d6c8186610b6e565b9050610d7b6060830185610b48565b610d886080830184610c39565b9695505050505050565b6000610d9c610dad565b9050610da88282610fe4565b919050565b6000604051905090565b600067ffffffffffffffff821115610dd257610dd1611097565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600082905092915050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60008085851115610e6257610e616110da565b5b83861115610e7357610e726110d5565b5b6001850283019150848603905094509492505050565b6000610e9482610f27565b9150610e9f83610f27565b925082821015610eb257610eb1611039565b5b828203905092915050565b6000610ec882610f07565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610f3d8383610dfe565b82610f488135610edb565b92506014821015610f8857610f837fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008360140360080261110c565b831692505b505092915050565b6000610f9b82610f27565b9050919050565b82818337600083830152505050565b60005b83811015610fcf578082015181840152602081019050610fb4565b83811115610fde576000848401525b50505050565b610fed826110ee565b810181811067ffffffffffffffff8211171561100c5761100b611097565b5b80604052505050565b600061102082611027565b9050919050565b6000611032826110ff565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b61112281610ebd565b811461112d57600080fd5b50565b61113981610ecf565b811461114457600080fd5b50565b61115081610f27565b811461115b57600080fd5b5056fea264697066735822122077546c2f4741f7d79b7a2e01a3100f966ababfb11046c7872e4f310304d04ce564736f6c63430008070033", } // ZEVMSwapAppABI is the input ABI used to generate the binding from. @@ -157,11 +163,11 @@ func NewZEVMSwapAppFilterer(address common.Address, filterer bind.ContractFilter // bindZEVMSwapApp binds a generic wrapper to an already deployed contract. func bindZEVMSwapApp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ZEVMSwapAppMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(ZEVMSwapAppABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and @@ -327,23 +333,23 @@ func (_ZEVMSwapApp *ZEVMSwapAppCallerSession) SystemContract() (common.Address, return _ZEVMSwapApp.Contract.SystemContract(&_ZEVMSwapApp.CallOpts) } -// OnCrossChainCall is a paid mutator transaction binding the contract method 0xc8522691. +// OnCrossChainCall is a paid mutator transaction binding the contract method 0xde43156e. // -// Solidity: function onCrossChainCall(address zrc20, uint256 amount, bytes message) returns() -func (_ZEVMSwapApp *ZEVMSwapAppTransactor) OnCrossChainCall(opts *bind.TransactOpts, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { - return _ZEVMSwapApp.contract.Transact(opts, "onCrossChainCall", zrc20, amount, message) +// Solidity: function onCrossChainCall((bytes,address,uint256) , address zrc20, uint256 amount, bytes message) returns() +func (_ZEVMSwapApp *ZEVMSwapAppTransactor) OnCrossChainCall(opts *bind.TransactOpts, arg0 Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ZEVMSwapApp.contract.Transact(opts, "onCrossChainCall", arg0, zrc20, amount, message) } -// OnCrossChainCall is a paid mutator transaction binding the contract method 0xc8522691. +// OnCrossChainCall is a paid mutator transaction binding the contract method 0xde43156e. // -// Solidity: function onCrossChainCall(address zrc20, uint256 amount, bytes message) returns() -func (_ZEVMSwapApp *ZEVMSwapAppSession) OnCrossChainCall(zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { - return _ZEVMSwapApp.Contract.OnCrossChainCall(&_ZEVMSwapApp.TransactOpts, zrc20, amount, message) +// Solidity: function onCrossChainCall((bytes,address,uint256) , address zrc20, uint256 amount, bytes message) returns() +func (_ZEVMSwapApp *ZEVMSwapAppSession) OnCrossChainCall(arg0 Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ZEVMSwapApp.Contract.OnCrossChainCall(&_ZEVMSwapApp.TransactOpts, arg0, zrc20, amount, message) } -// OnCrossChainCall is a paid mutator transaction binding the contract method 0xc8522691. +// OnCrossChainCall is a paid mutator transaction binding the contract method 0xde43156e. // -// Solidity: function onCrossChainCall(address zrc20, uint256 amount, bytes message) returns() -func (_ZEVMSwapApp *ZEVMSwapAppTransactorSession) OnCrossChainCall(zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { - return _ZEVMSwapApp.Contract.OnCrossChainCall(&_ZEVMSwapApp.TransactOpts, zrc20, amount, message) +// Solidity: function onCrossChainCall((bytes,address,uint256) , address zrc20, uint256 amount, bytes message) returns() +func (_ZEVMSwapApp *ZEVMSwapAppTransactorSession) OnCrossChainCall(arg0 Context, zrc20 common.Address, amount *big.Int, message []byte) (*types.Transaction, error) { + return _ZEVMSwapApp.Contract.OnCrossChainCall(&_ZEVMSwapApp.TransactOpts, arg0, zrc20, amount, message) } diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json index b989b00ca7..ff164359a6 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.json @@ -76,6 +76,28 @@ }, { "inputs": [ + { + "components": [ + { + "internalType": "bytes", + "name": "origin", + "type": "bytes" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "chainID", + "type": "uint256" + } + ], + "internalType": "struct Context", + "name": "", + "type": "tuple" + }, { "internalType": "address", "name": "zrc20", @@ -124,5 +146,5 @@ "type": "function" } ], - "bin": "60c06040523480156200001157600080fd5b506040516200121e3803806200121e833981810160405281019062000037919062000111565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1681525050505062000158565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000d982620000ac565b9050919050565b620000eb81620000cc565b8114620000f757600080fd5b50565b6000815190506200010b81620000e0565b92915050565b600080604083850312156200012b576200012a620000a7565b5b60006200013b85828601620000fa565b92505060206200014e85828601620000fa565b9150509250929050565b60805160a05161108b62000193600039600081816101b201526101fa0152600081816101d60152818161039d0152610422015261108b6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063c8522691146100c9578063df73044e146100e5575b600080fd5b610076600480360381019061007191906107b1565b610115565b6040516100849291906108cf565b60405180910390f35b6100956101b0565b6040516100a291906108ff565b60405180910390f35b6100b36101d4565b6040516100c091906108ff565b60405180910390f35b6100e360048036038101906100de919061097c565b6101f8565b005b6100ff60048036038101906100fa91906109f0565b610709565b60405161010c9190610a50565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610a7c565b906101439190610afb565b60601c90508686601490809261015b93929190610a7c565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af610b5a565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5610b89565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344610b89565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610bc7565b6020604051808303816000875af11580156103f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041d9190610c28565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161048b959493929190610d58565b6000604051808303816000875af11580156104aa573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104d39190610ed6565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b81526004016040805180830381865afa158015610522573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105469190610f34565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b8152600401610585929190610bc7565b6020604051808303816000875af11580156105a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c89190610c28565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b387856001815181106105fa576105f9610b89565b5b60200260200101516040518363ffffffff1660e01b815260040161061f929190610bc7565b6020604051808303816000875af115801561063e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106629190610c28565b508573ffffffffffffffffffffffffffffffffffffffff1663c7012626868560018151811061069457610693610b89565b5b60200260200101516040518363ffffffff1660e01b81526004016106b9929190610f74565b6020604051808303816000875af11580156106d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106fc9190610c28565b5050505050505050505050565b60608383836040516020016107209392919061102b565b60405160208183030381529060405290509392505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f8401126107715761077061074c565b5b8235905067ffffffffffffffff81111561078e5761078d610751565b5b6020830191508360018202830111156107aa576107a9610756565b5b9250929050565b600080602083850312156107c8576107c7610742565b5b600083013567ffffffffffffffff8111156107e6576107e5610747565b5b6107f28582860161075b565b92509250509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610829826107fe565b9050919050565b6108398161081e565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561087957808201518184015260208101905061085e565b60008484015250505050565b6000601f19601f8301169050919050565b60006108a18261083f565b6108ab818561084a565b93506108bb81856020860161085b565b6108c481610885565b840191505092915050565b60006040820190506108e46000830185610830565b81810360208301526108f68184610896565b90509392505050565b60006020820190506109146000830184610830565b92915050565b6109238161081e565b811461092e57600080fd5b50565b6000813590506109408161091a565b92915050565b6000819050919050565b61095981610946565b811461096457600080fd5b50565b60008135905061097681610950565b92915050565b6000806000806060858703121561099657610995610742565b5b60006109a487828801610931565b94505060206109b587828801610967565b935050604085013567ffffffffffffffff8111156109d6576109d5610747565b5b6109e28782880161075b565b925092505092959194509250565b600080600060408486031215610a0957610a08610742565b5b6000610a1786828701610931565b935050602084013567ffffffffffffffff811115610a3857610a37610747565b5b610a448682870161075b565b92509250509250925092565b60006020820190508181036000830152610a6a8184610896565b905092915050565b600080fd5b600080fd5b60008085851115610a9057610a8f610a72565b5b83861115610aa157610aa0610a77565b5b6001850283019150848603905094509492505050565b600082905092915050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600082821b905092915050565b6000610b078383610ab7565b82610b128135610ac2565b92506014821015610b5257610b4d7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802610aee565b831692505b505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b610bc181610946565b82525050565b6000604082019050610bdc6000830185610830565b610be96020830184610bb8565b9392505050565b60008115159050919050565b610c0581610bf0565b8114610c1057600080fd5b50565b600081519050610c2281610bfc565b92915050565b600060208284031215610c3e57610c3d610742565b5b6000610c4c84828501610c13565b91505092915050565b6000819050919050565b6000819050919050565b6000610c84610c7f610c7a84610c55565b610c5f565b610946565b9050919050565b610c9481610c69565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b610ccf8161081e565b82525050565b6000610ce18383610cc6565b60208301905092915050565b6000602082019050919050565b6000610d0582610c9a565b610d0f8185610ca5565b9350610d1a83610cb6565b8060005b83811015610d4b578151610d328882610cd5565b9750610d3d83610ced565b925050600181019050610d1e565b5085935050505092915050565b600060a082019050610d6d6000830188610bb8565b610d7a6020830187610c8b565b8181036040830152610d8c8186610cfa565b9050610d9b6060830185610830565b610da86080830184610bb8565b9695505050505050565b610dbb82610885565b810181811067ffffffffffffffff82111715610dda57610dd9610b5a565b5b80604052505050565b6000610ded610738565b9050610df98282610db2565b919050565b600067ffffffffffffffff821115610e1957610e18610b5a565b5b602082029050602081019050919050565b600081519050610e3981610950565b92915050565b6000610e52610e4d84610dfe565b610de3565b90508083825260208201905060208402830185811115610e7557610e74610756565b5b835b81811015610e9e5780610e8a8882610e2a565b845260208401935050602081019050610e77565b5050509392505050565b600082601f830112610ebd57610ebc61074c565b5b8151610ecd848260208601610e3f565b91505092915050565b600060208284031215610eec57610eeb610742565b5b600082015167ffffffffffffffff811115610f0a57610f09610747565b5b610f1684828501610ea8565b91505092915050565b600081519050610f2e8161091a565b92915050565b60008060408385031215610f4b57610f4a610742565b5b6000610f5985828601610f1f565b9250506020610f6a85828601610e2a565b9150509250929050565b60006040820190508181036000830152610f8e8185610896565b9050610f9d6020830184610bb8565b9392505050565b60008160601b9050919050565b6000610fbc82610fa4565b9050919050565b6000610fce82610fb1565b9050919050565b610fe6610fe18261081e565b610fc3565b82525050565b600081905092915050565b82818337600083830152505050565b60006110128385610fec565b935061101f838584610ff7565b82840190509392505050565b60006110378286610fd5565b601482019150611048828486611006565b915081905094935050505056fea2646970667358221220d849874c97d6127643ba0363fe1dec561e63a7a801178715667509df9a3dcef364736f6c63430008120033" + "bin": "60c06040523480156200001157600080fd5b5060405162001333380380620013338339818101604052810190620000379190620000c4565b8173ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1660601b815250508073ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff1660601b8152505050506200015e565b600081519050620000be8162000144565b92915050565b60008060408385031215620000de57620000dd6200013f565b5b6000620000ee85828601620000ad565b92505060206200010185828601620000ad565b9150509250929050565b600062000118826200011f565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600080fd5b6200014f816200010b565b81146200015b57600080fd5b50565b60805160601c60a05160601c6111946200019f600039600081816101b201526101fa0152600081816101d60152818161039d015261043101526111946000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063a06ea8bc1461005c578063bb88b7691461008d578063bd00c9c4146100ab578063de43156e146100c9578063df73044e146100e5575b600080fd5b61007660048036038101906100719190610a30565b610115565b604051610084929190610c8d565b60405180910390f35b6100956101b0565b6040516100a29190610c72565b60405180910390f35b6100b36101d4565b6040516100c09190610c72565b60405180910390f35b6100e360048036038101906100de9190610a7d565b6101f8565b005b6100ff60048036038101906100fa919061091a565b61076f565b60405161010c9190610ce6565b60405180910390f35b600060608060008585905090506000868660009060149261013893929190610e4e565b906101439190610f31565b60601c90508686601490809261015b93929190610e4e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505092508083945094505050509250929050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461027d576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000606061028b8484610115565b80925081935050506060600267ffffffffffffffff8111156102b0576102af611097565b5b6040519080825280602002602001820160405280156102de5781602001602082028036833780820191505090505b50905086816000815181106102f6576102f5611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050828160018151811061034557610344611068565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508673ffffffffffffffffffffffffffffffffffffffff1663095ea7b37f0000000000000000000000000000000000000000000000000000000000000000886040518363ffffffff1660e01b81526004016103da929190610cbd565b602060405180830381600087803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061042c9190610a03565b5060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166338ed17398860008530680100000000000000006040518663ffffffff1660e01b815260040161049a959493929190610d38565b600060405180830381600087803b1580156104b457600080fd5b505af11580156104c8573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906104f191906109ba565b90506000808573ffffffffffffffffffffffffffffffffffffffff1663d9eeebed6040518163ffffffff1660e01b8152600401604080518083038186803b15801561053b57600080fd5b505afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610573919061097a565b915091508173ffffffffffffffffffffffffffffffffffffffff1663095ea7b387836040518363ffffffff1660e01b81526004016105b2929190610cbd565b602060405180830381600087803b1580156105cc57600080fd5b505af11580156105e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106049190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3878560018151811061063657610635611068565b5b60200260200101516040518363ffffffff1660e01b815260040161065b929190610cbd565b602060405180830381600087803b15801561067557600080fd5b505af1158015610689573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ad9190610a03565b508573ffffffffffffffffffffffffffffffffffffffff1663c70126268683866001815181106106e0576106df611068565b5b60200260200101516106f29190610e89565b6040518363ffffffff1660e01b815260040161070f929190610d08565b602060405180830381600087803b15801561072957600080fd5b505af115801561073d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107619190610a03565b505050505050505050505050565b606083838360405160200161078693929190610c48565b60405160208183030381529060405290509392505050565b60006107b16107ac84610db7565b610d92565b905080838252602082019050828560208602820111156107d4576107d36110df565b5b60005b8581101561080457816107ea8882610905565b8452602084019350602083019250506001810190506107d7565b5050509392505050565b60008135905061081d81611119565b92915050565b60008151905061083281611119565b92915050565b600082601f83011261084d5761084c6110cb565b5b815161085d84826020860161079e565b91505092915050565b60008151905061087581611130565b92915050565b60008083601f840112610891576108906110cb565b5b8235905067ffffffffffffffff8111156108ae576108ad6110c6565b5b6020830191508360018202830111156108ca576108c96110df565b5b9250929050565b6000606082840312156108e7576108e66110d0565b5b81905092915050565b6000813590506108ff81611147565b92915050565b60008151905061091481611147565b92915050565b600080600060408486031215610933576109326110e9565b5b60006109418682870161080e565b935050602084013567ffffffffffffffff811115610962576109616110e4565b5b61096e8682870161087b565b92509250509250925092565b60008060408385031215610991576109906110e9565b5b600061099f85828601610823565b92505060206109b085828601610905565b9150509250929050565b6000602082840312156109d0576109cf6110e9565b5b600082015167ffffffffffffffff8111156109ee576109ed6110e4565b5b6109fa84828501610838565b91505092915050565b600060208284031215610a1957610a186110e9565b5b6000610a2784828501610866565b91505092915050565b60008060208385031215610a4757610a466110e9565b5b600083013567ffffffffffffffff811115610a6557610a646110e4565b5b610a718582860161087b565b92509250509250929050565b600080600080600060808688031215610a9957610a986110e9565b5b600086013567ffffffffffffffff811115610ab757610ab66110e4565b5b610ac3888289016108d1565b9550506020610ad48882890161080e565b9450506040610ae5888289016108f0565b935050606086013567ffffffffffffffff811115610b0657610b056110e4565b5b610b128882890161087b565b92509250509295509295909350565b6000610b2d8383610b39565b60208301905092915050565b610b4281610ebd565b82525050565b610b5181610ebd565b82525050565b610b68610b6382610ebd565b611015565b82525050565b6000610b7982610df3565b610b838185610e21565b9350610b8e83610de3565b8060005b83811015610bbf578151610ba68882610b21565b9750610bb183610e14565b925050600181019050610b92565b5085935050505092915050565b6000610bd88385610e43565b9350610be5838584610fa2565b82840190509392505050565b6000610bfc82610e09565b610c068185610e32565b9350610c16818560208601610fb1565b610c1f816110ee565b840191505092915050565b610c3381610f90565b82525050565b610c4281610f27565b82525050565b6000610c548286610b57565b601482019150610c65828486610bcc565b9150819050949350505050565b6000602082019050610c876000830184610b48565b92915050565b6000604082019050610ca26000830185610b48565b8181036020830152610cb48184610bf1565b90509392505050565b6000604082019050610cd26000830185610b48565b610cdf6020830184610c39565b9392505050565b60006020820190508181036000830152610d008184610bf1565b905092915050565b60006040820190508181036000830152610d228185610bf1565b9050610d316020830184610c39565b9392505050565b600060a082019050610d4d6000830188610c39565b610d5a6020830187610c2a565b8181036040830152610d6c8186610b6e565b9050610d7b6060830185610b48565b610d886080830184610c39565b9695505050505050565b6000610d9c610dad565b9050610da88282610fe4565b919050565b6000604051905090565b600067ffffffffffffffff821115610dd257610dd1611097565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600082905092915050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60008085851115610e6257610e616110da565b5b83861115610e7357610e726110d5565b5b6001850283019150848603905094509492505050565b6000610e9482610f27565b9150610e9f83610f27565b925082821015610eb257610eb1611039565b5b828203905092915050565b6000610ec882610f07565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6000610f3d8383610dfe565b82610f488135610edb565b92506014821015610f8857610f837fffffffffffffffffffffffffffffffffffffffff0000000000000000000000008360140360080261110c565b831692505b505092915050565b6000610f9b82610f27565b9050919050565b82818337600083830152505050565b60005b83811015610fcf578082015181840152602081019050610fb4565b83811115610fde576000848401525b50505050565b610fed826110ee565b810181811067ffffffffffffffff8211171561100c5761100b611097565b5b80604052505050565b600061102082611027565b9050919050565b6000611032826110ff565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b600082821b905092915050565b61112281610ebd565b811461112d57600080fd5b50565b61113981610ecf565b811461114457600080fd5b50565b61115081610f27565b811461115b57600080fd5b5056fea264697066735822122077546c2f4741f7d79b7a2e01a3100f966ababfb11046c7872e4f310304d04ce564736f6c63430008070033" } diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol index 02a25c295e..21be9ab61f 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/ZEVMSwapApp.sol @@ -3,8 +3,15 @@ pragma solidity ^0.8.7; import "interfaces/IUniswapV2Router02.sol"; +struct Context { + bytes origin; + address sender; + uint256 chainID; +} + interface zContract { function onCrossChainCall( + Context calldata context, address zrc20, uint256 amount, bytes calldata message @@ -78,7 +85,7 @@ contract ZEVMSwapApp is zContract { // Call this function to perform a cross-chain swap - function onCrossChainCall(address zrc20, uint256 amount, bytes calldata message) external override { + function onCrossChainCall(Context calldata, address zrc20, uint256 amount, bytes calldata message) external override { if (msg.sender != systemContract) { revert InvalidSender(); } diff --git a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go index 9f814d41b2..f87b3878ad 100644 --- a/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go +++ b/contrib/localnet/orchestrator/smoketest/contracts/zevmswap/bindings.go @@ -1,4 +1,5 @@ -//go:generate sh -c " solc --evm-version paris --allow-paths .., --combined-json abi,bin --base-path .. ZEVMSwapApp.sol | jq '.contracts.\"zevmswap/ZEVMSwapApp.sol:ZEVMSwapApp\"' > ZEVMSwapApp.json" +// solc/abigen use version 0.8.7 +//go:generate sh -c " solc --evm-version london --allow-paths .., --combined-json abi,bin --base-path .. ZEVMSwapApp.sol | jq '.contracts.\"ZEVMSwapApp.sol:ZEVMSwapApp\"' > ZEVMSwapApp.json" //go:generate sh -c "cat ZEVMSwapApp.json | jq .abi > ZEVMSwapApp.abi" //go:generate sh -c "cat ZEVMSwapApp.json | jq .bin | tr -d '\"' > ZEVMSwapApp.bin" diff --git a/contrib/localnet/orchestrator/smoketest/main.go b/contrib/localnet/orchestrator/smoketest/main.go index 082334b995..809074aa07 100644 --- a/contrib/localnet/orchestrator/smoketest/main.go +++ b/contrib/localnet/orchestrator/smoketest/main.go @@ -15,6 +15,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/contextapp" "github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/zevmswap" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -89,6 +90,8 @@ type SmokeTest struct { TestDAppAddr ethcommon.Address ZEVMSwapAppAddr ethcommon.Address ZEVMSwapApp *zevmswap.ZEVMSwapApp + ContextAppAddr ethcommon.Address + ContextApp *contextapp.ContextApp SystemContract *systemcontract.SystemContract SystemContractAddr ethcommon.Address @@ -275,6 +278,23 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { smokeTest.ZEVMSwapAppAddr = zevmSwapAppAddr smokeTest.ZEVMSwapApp = zevmSwapApp + // test system contract context upgrade + contextAppAddr, tx, _, err := contextapp.DeployContextApp(smokeTest.zevmAuth, smokeTest.zevmClient) + if err != nil { + panic(err) + } + receipt = MustWaitForTxReceipt(zevmClient, tx) + if receipt.Status != 1 { + panic("ContextApp deployment failed") + } + contextApp, err := contextapp.NewContextApp(contextAppAddr, zevmClient) + if err != nil { + panic(err) + } + fmt.Printf("ContextApp contract address: %s, tx hash: %s\n", contextAppAddr.Hex(), tx.Hash().Hex()) + smokeTest.ContextAppAddr = contextAppAddr + smokeTest.ContextApp = contextApp + fmt.Printf("## Essential tests takes %s\n", time.Since(startTime)) fmt.Printf("## The DeployerAddress %s is funded on the following networks:\n", DeployerAddress.Hex()) fmt.Printf("## Ether on Ethereum private net\n") @@ -284,6 +304,8 @@ func LocalSmokeTest(_ *cobra.Command, _ []string) { // temporarily to reduce dev/test cycle turnaround time smokeTest.CheckZRC20ReserveAndSupply() + smokeTest.TestContextUpgrade() + smokeTest.TestDepositAndCallRefund() smokeTest.CheckZRC20ReserveAndSupply() diff --git a/contrib/localnet/orchestrator/smoketest/test_bitcoin.go b/contrib/localnet/orchestrator/smoketest/test_bitcoin.go index 6f55775f07..bab484ec4a 100644 --- a/contrib/localnet/orchestrator/smoketest/test_bitcoin.go +++ b/contrib/localnet/orchestrator/smoketest/test_bitcoin.go @@ -114,11 +114,11 @@ func (sm *SmokeTest) DepositBTC() { fmt.Printf(" spendableAmount: %f\n", spendableAmount) fmt.Printf(" spendableUTXOs: %d\n", spendableUTXOs) fmt.Printf("Now sending two txs to TSS address...\n") - err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 1.1, utxos[:2], btc) + _, err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 1.1, utxos[:2], btc) if err != nil { panic(err) } - err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 0.05, utxos[2:4], btc) + _, err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 0.05, utxos[2:4], btc) if err != nil { panic(err) } @@ -181,11 +181,11 @@ func (sm *SmokeTest) DepositBTCRefund() { fmt.Printf(" spendableAmount: %f\n", spendableAmount) fmt.Printf(" spendableUTXOs: %d\n", spendableUTXOs) fmt.Printf("Now sending two txs to TSS address...\n") - err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 1.1, utxos[:2], btc) + _, err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 1.1, utxos[:2], btc) if err != nil { panic(err) } - err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 0.05, utxos[2:4], btc) + _, err = SendToTSSFromDeployerToDeposit(BTCTSSAddress, 0.05, utxos[2:4], btc) if err != nil { panic(err) } @@ -413,99 +413,8 @@ func (sm *SmokeTest) WithdrawBitcoinMultipleTimes(repeat int64) { } } -func SendToTSSFromDeployerToDeposit(to btcutil.Address, amount float64, inputUTXOs []btcjson.ListUnspentResult, btc *rpcclient.Client) error { - utxos := inputUTXOs - - inputs := make([]btcjson.TransactionInput, len(utxos)) - inputSats := btcutil.Amount(0) - for i, utxo := range utxos { - inputs[i] = btcjson.TransactionInput{utxo.TxID, utxo.Vout} - inputSats += btcutil.Amount(utxo.Amount * btcutil.SatoshiPerBitcoin) - } - feeSats := btcutil.Amount(0.0001 * btcutil.SatoshiPerBitcoin) - amountSats := btcutil.Amount(amount * btcutil.SatoshiPerBitcoin) - change := inputSats - feeSats - amountSats - if change < 0 { - return fmt.Errorf("not enough input amount in sats; wanted %d, got %d", amountSats+feeSats, inputSats) - } - amounts := map[btcutil.Address]btcutil.Amount{ - to: amountSats, - BTCDeployerAddress: change, - } - tx, err := btc.CreateRawTransaction(inputs, amounts, nil) - if err != nil { - panic(err) - } - // construct memo just to deposit BTC into deployer address - // the bytes in the memo (following OP_RETURN) is of format: - // [ OP_RETURN(6a) ] - // where is ASCII encoding of the base64 bytes (!we do this because popular bitcoin wallet - // only input ASCII characters, and we need to encode binary data. We pick base64 StdEncoding). - - //addrB64Str := base64.StdEncoding.EncodeToString(DeployerAddress.Bytes()) - - //addrB64StrLen := len(addrB64Str) - //fmt.Printf("addrB64StrLen: %d\naddrB64Str: %s\naddrB64StrASCII: %x\n", addrB64StrLen, addrB64Str, []byte(addrB64Str)) - nulldata, err := txscript.NullDataScript(DeployerAddress.Bytes()) // this adds a OP_RETURN + single BYTE len prefix to the data - if err != nil { - panic(err) - } - fmt.Printf("nulldata (len %d): %x\n", len(nulldata), nulldata) - if err != nil { - panic(err) - } - memoOutput := wire.TxOut{Value: 0, PkScript: nulldata} - tx.TxOut = append(tx.TxOut, &memoOutput) - tx.TxOut[1], tx.TxOut[2] = tx.TxOut[2], tx.TxOut[1] - - // make sure that TxOut[0] is sent to "to" address; TxOut[2] is change to oneself. TxOut[1] is memo. - if bytes.Compare(tx.TxOut[0].PkScript[2:], to.ScriptAddress()) != 0 { - fmt.Printf("tx.TxOut[0].PkScript: %x\n", tx.TxOut[0].PkScript) - fmt.Printf("to.ScriptAddress(): %x\n", to.ScriptAddress()) - fmt.Printf("swapping txout[0] with txout[2]\n") - tx.TxOut[0], tx.TxOut[2] = tx.TxOut[2], tx.TxOut[0] - } - - fmt.Printf("raw transaction: \n") - for idx, txout := range tx.TxOut { - fmt.Printf(" txout %d", idx) - fmt.Printf(" value: %d", txout.Value) - fmt.Printf(" PkScript: %x\n", txout.PkScript) - } - stx, signed, err := btc.SignRawTransactionWithWallet(tx) - if err != nil { - panic(err) - } - fmt.Printf("signed tx: all inputs signed?: %+v\n", signed) - txid, err := btc.SendRawTransaction(stx, true) - if err != nil { - panic(err) - } - fmt.Printf("txid: %+v\n", txid) - _, err = btc.GenerateToAddress(6, BTCDeployerAddress, nil) - if err != nil { - panic(err) - } - gtx, err := btc.GetTransaction(txid) - if err != nil { - panic(err) - } - fmt.Printf("rawtx confirmation: %d\n", gtx.BlockIndex) - rawtx, err := btc.GetRawTransactionVerbose(txid) - if err != nil { - panic(err) - } - - events := zetaclient.FilterAndParseIncomingTx([]btcjson.TxRawResult{*rawtx}, 0, BTCTSSAddress.EncodeAddress(), &log.Logger) - fmt.Printf("bitcoin intx events:\n") - for _, event := range events { - fmt.Printf(" TxHash: %s\n", event.TxHash) - fmt.Printf(" From: %s\n", event.FromAddress) - fmt.Printf(" To: %s\n", event.ToAddress) - fmt.Printf(" Amount: %f\n", event.Value) - fmt.Printf(" Memo: %x\n", event.MemoBytes) - } - return nil +func SendToTSSFromDeployerToDeposit(to btcutil.Address, amount float64, inputUTXOs []btcjson.ListUnspentResult, btc *rpcclient.Client) (*chainhash.Hash, error) { + return SendToTSSFromDeployerWithMemo(to, amount, inputUTXOs, btc, DeployerAddress.Bytes()) } func SendToTSSFromDeployerWithMemo(to btcutil.Address, amount float64, inputUTXOs []btcjson.ListUnspentResult, btc *rpcclient.Client, memo []byte) (*chainhash.Hash, error) { @@ -513,9 +422,13 @@ func SendToTSSFromDeployerWithMemo(to btcutil.Address, amount float64, inputUTXO inputs := make([]btcjson.TransactionInput, len(utxos)) inputSats := btcutil.Amount(0) + amounts := make([]float64, len(utxos)) + scriptPubkeys := make([]string, len(utxos)) for i, utxo := range utxos { inputs[i] = btcjson.TransactionInput{utxo.TxID, utxo.Vout} inputSats += btcutil.Amount(utxo.Amount * btcutil.SatoshiPerBitcoin) + amounts[i] = utxo.Amount + scriptPubkeys[i] = utxo.ScriptPubKey } feeSats := btcutil.Amount(0.0001 * btcutil.SatoshiPerBitcoin) amountSats := btcutil.Amount(amount * btcutil.SatoshiPerBitcoin) @@ -523,11 +436,11 @@ func SendToTSSFromDeployerWithMemo(to btcutil.Address, amount float64, inputUTXO if change < 0 { return nil, fmt.Errorf("not enough input amount in sats; wanted %d, got %d", amountSats+feeSats, inputSats) } - amounts := map[btcutil.Address]btcutil.Amount{ + amountMap := map[btcutil.Address]btcutil.Amount{ to: amountSats, BTCDeployerAddress: change, } - tx, err := btc.CreateRawTransaction(inputs, amounts, nil) + tx, err := btc.CreateRawTransaction(inputs, amountMap, nil) if err != nil { panic(err) } @@ -558,11 +471,19 @@ func SendToTSSFromDeployerWithMemo(to btcutil.Address, amount float64, inputUTXO fmt.Printf(" value: %d\n", txout.Value) fmt.Printf(" PkScript: %x\n", txout.PkScript) } - stx, signed, err := btc.SignRawTransactionWithWallet(tx) + var inputsForSign []btcjson.RawTxWitnessInput + for i, input := range inputs { + inputsForSign = append(inputsForSign, btcjson.RawTxWitnessInput{ + Txid: input.Txid, Vout: input.Vout, Amount: &amounts[i], ScriptPubKey: scriptPubkeys[i]}) + } + //stx, signed, err := btc.SignRawTransactionWithWallet(tx) + stx, signed, err := btc.SignRawTransactionWithWallet2(tx, inputsForSign) if err != nil { panic(err) } - fmt.Printf("signed tx: all inputs signed?: %+v\n", signed) + if !signed { + panic("btc transaction not signed") + } txid, err := btc.SendRawTransaction(stx, true) if err != nil { panic(err) diff --git a/contrib/localnet/orchestrator/smoketest/test_context.go b/contrib/localnet/orchestrator/smoketest/test_context.go new file mode 100644 index 0000000000..091336daa5 --- /dev/null +++ b/contrib/localnet/orchestrator/smoketest/test_context.go @@ -0,0 +1,88 @@ +//go:build PRIVNET +// +build PRIVNET + +package main + +import ( + "bytes" + "context" + "fmt" + "math/big" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" +) + +// this tests sending ZETA out of ZetaChain to Ethereum +func (sm *SmokeTest) TestContextUpgrade() { + startTime := time.Now() + defer func() { + fmt.Printf("test finishes in %s\n", time.Since(startTime)) + }() + goerliClient := sm.goerliClient + LoudPrintf("Test ContextApp\n") + bn, err := goerliClient.BlockNumber(context.Background()) + if err != nil { + panic(err) + } + fmt.Printf("GOERLI block number: %d\n", bn) + + value := big.NewInt(1000000000000000) // in wei (1 eth) + data := make([]byte, 0, 32) + data = append(data, sm.ContextAppAddr.Bytes()...) + data = append(data, []byte("filler")...) // just to make sure that this is a contract call; + + signedTx, err := sm.SendEther(TSSAddress, value, data) + if err != nil { + panic(err) + } + + fmt.Printf("GOERLI tx sent: %s; to %s, nonce %d\n", signedTx.Hash().String(), signedTx.To().Hex(), signedTx.Nonce()) + receipt := MustWaitForTxReceipt(sm.goerliClient, signedTx) + fmt.Printf("GOERLI tx receipt: %d\n", receipt.Status) + fmt.Printf(" tx hash: %s\n", receipt.TxHash.String()) + fmt.Printf(" to: %s\n", signedTx.To().String()) + fmt.Printf(" value: %d\n", signedTx.Value()) + fmt.Printf(" block num: %d\n", receipt.BlockNumber) + fmt.Printf(" data: %x\n", signedTx.Data()) + + found := false + for i := 0; i < 10; i++ { + eventIter, err := sm.ContextApp.FilterContextData(&bind.FilterOpts{ + Start: 0, + End: nil, + }) + if err != nil { + fmt.Printf("filter error: %s\n", err.Error()) + continue + } + for eventIter.Next() { + fmt.Printf("event: ContextData\n") + fmt.Printf(" origin: %x\n", eventIter.Event.Origin) + fmt.Printf(" sender: %s\n", eventIter.Event.Sender.Hex()) + fmt.Printf(" chainid: %d\n", eventIter.Event.ChainID) + fmt.Printf(" msgsender: %s\n", eventIter.Event.MsgSender.Hex()) + found = true + if bytes.Compare(eventIter.Event.Origin, DeployerAddress.Bytes()) != 0 { + panic("origin mismatch") + } + chainID, err := sm.goerliClient.ChainID(context.Background()) + if err != nil { + panic(err) + } + if eventIter.Event.ChainID.Cmp(chainID) != 0 { + panic("chainID mismatch") + } + + } + if found { + break + } + time.Sleep(2 * time.Second) + } + + if !found { + panic("event not found") + } + +} diff --git a/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go b/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go index 0dd382efc3..8c51b71d09 100644 --- a/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go +++ b/contrib/localnet/orchestrator/smoketest/test_crosschain_swap.go @@ -132,7 +132,7 @@ func (sm *SmokeTest) TestCrosschainSwap() { memo = append(sm.ZEVMSwapAppAddr.Bytes(), memo...) fmt.Printf("memo length %d\n", len(memo)) - txid, err := SendToTSSFromDeployerWithMemo(BTCTSSAddress, 0.001, utxos[0:2], sm.btcRPCClient, memo) + txid, err := SendToTSSFromDeployerWithMemo(BTCTSSAddress, 0.01, utxos[0:2], sm.btcRPCClient, memo) fmt.Printf("Sent BTC to TSS txid %s; now mining 10 blocks for confirmation\n", txid) _, err = sm.btcRPCClient.GenerateToAddress(10, BTCDeployerAddress, nil) if err != nil { diff --git a/contrib/localnet/orchestrator/smoketest/test_setup.go b/contrib/localnet/orchestrator/smoketest/test_setup.go index 72221c8a2c..e09e254030 100644 --- a/contrib/localnet/orchestrator/smoketest/test_setup.go +++ b/contrib/localnet/orchestrator/smoketest/test_setup.go @@ -48,7 +48,7 @@ func (sm *SmokeTest) TestSetupZetaTokenAndConnectorAndZEVMContracts() { if err := CheckNonce(goerliClient, DeployerAddress, 0); err != nil { panic(err) } - zetaEthAddr, tx, ZetaEth, err := zetaeth.DeployZetaEth(auth, goerliClient, big.NewInt(21_000_000_000)) + zetaEthAddr, tx, ZetaEth, err := zetaeth.DeployZetaEth(auth, goerliClient, DeployerAddress, big.NewInt(21_000_000_000)) if err != nil { panic(err) } diff --git a/contrib/rpctest/main.go b/contrib/rpctest/main.go index 30553c86dc..5a74a7f874 100644 --- a/contrib/rpctest/main.go +++ b/contrib/rpctest/main.go @@ -135,7 +135,7 @@ func main() { if err != nil { panic(err) } - zetaContractAddress, tx2, zetaContract, err := zetaeth.DeployZetaEth(zevmAuth, zevmClient, big.NewInt(2_100_000_000)) + zetaContractAddress, tx2, zetaContract, err := zetaeth.DeployZetaEth(zevmAuth, zevmClient, zevmAuth.From, big.NewInt(2_100_000_000)) _, _ = zetaContractAddress, zetaContract if err != nil { panic(err) diff --git a/docs/openapi/openapi.swagger.yaml b/docs/openapi/openapi.swagger.yaml index 0b86208264..3d0420ddd5 100644 --- a/docs/openapi/openapi.swagger.yaml +++ b/docs/openapi/openapi.swagger.yaml @@ -50407,6 +50407,8 @@ definitions: type: object fungibleMsgRemoveForeignCoinResponse: type: object + fungibleMsgUpdateSystemContractResponse: + type: object fungibleQueryAllForeignCoinsResponse: type: object properties: diff --git a/docs/spec/fungible/messages.md b/docs/spec/fungible/messages.md index fbbb586ff9..a826ee951b 100644 --- a/docs/spec/fungible/messages.md +++ b/docs/spec/fungible/messages.md @@ -47,3 +47,12 @@ message MsgRemoveForeignCoin { } ``` +## MsgUpdateSystemContract + +```proto +message MsgUpdateSystemContract { + string creator = 1; + string newSystemContractAddress = 2; +} +``` + diff --git a/go.mod b/go.mod index c3fd988e14..5b10f221f5 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/evmos/ethermint v0.22.0 github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 - github.com/zeta-chain/protocol-contracts v0.0.0-20230511074447-d04544b98b05 + github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230808221250-5dfbe4f962f3 gitlab.com/thorchain/tss/go-tss v0.0.0-00010101000000-000000000000 google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index ec0257aea4..9923b9ce29 100644 --- a/go.sum +++ b/go.sum @@ -2937,8 +2937,8 @@ github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQ github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= -github.com/zeta-chain/protocol-contracts v0.0.0-20230511074447-d04544b98b05 h1:+E0O/WaGpx2hnhKeQtpDyuglrqFGZGlabd85WLbVleg= -github.com/zeta-chain/protocol-contracts v0.0.0-20230511074447-d04544b98b05/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230808221250-5dfbe4f962f3 h1:Twz44ggr7FClj6NUh987XvJ9dzmjb7yqO/0ofu2KtRw= +github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20230808221250-5dfbe4f962f3/go.mod h1:v79f+eY6PMpmLv188FAubst4XV2Mm8mUmx1OgmdFG3c= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= diff --git a/proto/fungible/events.proto b/proto/fungible/events.proto new file mode 100644 index 0000000000..d823e1a42b --- /dev/null +++ b/proto/fungible/events.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package zetachain.zetacore.fungible; + +import "common/common.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; + +message EventSystemContractUpdated { + string msg_type_url = 1; + string new_contract_address = 2; + string old_contract_address = 3; + string signer = 4; +} + +message EventZRC20Deployed { + string msg_type_url = 1; + string chain = 2; + string contract = 3; + string name = 4; + string symbol = 5; + int64 decimals = 6; + common.CoinType coin_type = 7; + string erc20 = 8; + int64 gasLimit = 9; +} \ No newline at end of file diff --git a/proto/fungible/tx.proto b/proto/fungible/tx.proto index 64eb1cfc86..8752a3019b 100644 --- a/proto/fungible/tx.proto +++ b/proto/fungible/tx.proto @@ -9,8 +9,16 @@ option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; service Msg { rpc DeployFungibleCoinZRC20(MsgDeployFungibleCoinZRC20) returns (MsgDeployFungibleCoinZRC20Response); rpc RemoveForeignCoin(MsgRemoveForeignCoin) returns (MsgRemoveForeignCoinResponse); + rpc UpdateSystemContract(MsgUpdateSystemContract) returns (MsgUpdateSystemContractResponse); } +message MsgUpdateSystemContract { + string creator = 1; + string newSystemContractAddress = 2; +} + +message MsgUpdateSystemContractResponse {} + message MsgDeployFungibleCoinZRC20 { string creator = 1; string ERC20 = 2; diff --git a/scripts/gen-spec.go b/scripts/gen-spec.go index 4527354224..ddd61e647e 100644 --- a/scripts/gen-spec.go +++ b/scripts/gen-spec.go @@ -57,6 +57,7 @@ func processProtoFile(path string, outputBaseDir string) error { fmt.Printf("Error opening proto file %q: %v\n", path, err) return err } + /* #nosec G307 */ defer reader.Close() parser := proto.NewParser(reader) @@ -104,6 +105,7 @@ func processProtoFile(path string, outputBaseDir string) error { fmt.Printf("Error creating file %q: %v\n", safeOutputFile, err) return err } + /* #nosec G307 */ defer file.Close() _, err = file.WriteString("# Messages\n\n") diff --git a/x/crosschain/keeper/evm_deposit.go b/x/crosschain/keeper/evm_deposit.go index 13ec456799..8ab83c6f22 100644 --- a/x/crosschain/keeper/evm_deposit.go +++ b/x/crosschain/keeper/evm_deposit.go @@ -39,7 +39,12 @@ func (k msgServer) HandleEVMDeposit(ctx sdk.Context, cctx *types.CrossChainTx, m if err != nil { return false, errors.Wrap(types.ErrUnableToParseContract, err.Error()) } - evmTxResponse, err := k.fungibleKeeper.ZRC20DepositAndCallContract(ctx, to, msg.Amount.BigInt(), senderChain, msg.Message, contract, data, msg.CoinType, msg.Asset) + from, err := senderChain.DecodeAddress(msg.Sender) + if err != nil { + return false, fmt.Errorf("HandleEVMDeposit: unable to decode address: %s", err.Error()) + } + + evmTxResponse, err := k.fungibleKeeper.ZRC20DepositAndCallContract(ctx, from, to, msg.Amount.BigInt(), senderChain, msg.Message, contract, data, msg.CoinType, msg.Asset) if err != nil { isContractReverted := false if evmTxResponse != nil && evmTxResponse.Failed() { diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index 319c76bd36..ff07f6f1d5 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -86,6 +86,7 @@ type FungibleKeeper interface { DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int) error ZRC20DepositAndCallContract( ctx sdk.Context, + from []byte, to eth.Address, amount *big.Int, senderChain *common.Chain, diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts.go index bca2f9c099..0d51b62b7d 100644 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts.go +++ b/x/fungible/keeper/begin_blocker_deploy_system_contracts.go @@ -10,3 +10,6 @@ import ( func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { return nil } +func (k Keeper) UpdateSystemContractAddress(goCtx context.Context) error { + return nil +} diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go index 78e962dfdc..06902c3a0f 100644 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go +++ b/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go @@ -10,6 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/fungible/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) // This is for privnet/testnet only @@ -107,3 +109,29 @@ func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { fmt.Println("Successfully deployed contracts") return nil } + +func (k Keeper) UpdateSystemContractAddress(goCtx context.Context) error { + ctx := sdk.UnwrapSDKContext(goCtx) + + wzeta, err := k.GetWZetaContractAddress(ctx) + if err != nil { + return sdkerrors.Wrap(err, "failed to GetWZetaContractAddress") + } + uniswapV2Factory, err := k.GetUniswapv2FacotryAddress(ctx) + if err != nil { + return sdkerrors.Wrap(err, "failed to GetUniswapv2FacotryAddress") + } + router, err := k.GetUniswapV2Router02Address(ctx) + if err != nil { + return sdkerrors.Wrap(err, "failed to GetUniswapV2Router02Address") + } + + SystemContractAddress, err := k.DeploySystemContract(ctx, wzeta, uniswapV2Factory, router) + if err != nil { + return sdkerrors.Wrapf(err, "failed to DeploySystemContract") + } + creator := k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_deploy_fungible_coin) + msg := types.NewMessageUpdateSystemContract(creator, SystemContractAddress.Hex()) + _, err = k.UpdateSystemContract(ctx, msg) + return err +} diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_testnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_testnet.go index aa75f4875d..7ee8a152fd 100644 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_testnet.go +++ b/x/fungible/keeper/begin_blocker_deploy_system_contracts_testnet.go @@ -96,3 +96,7 @@ func (k Keeper) BlockOneDeploySystemContracts(goCtx context.Context) error { return nil } + +func (k Keeper) UpdateSystemContractAddress(goCtx context.Context) error { + return nil +} diff --git a/x/fungible/keeper/deposits.go b/x/fungible/keeper/deposits.go index fb47468fe7..c95f6ed48f 100644 --- a/x/fungible/keeper/deposits.go +++ b/x/fungible/keeper/deposits.go @@ -3,13 +3,13 @@ package keeper import ( "math/big" - "github.com/zeta-chain/zetacore/common" - "github.com/zeta-chain/zetacore/x/crosschain/types" - fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" - sdk "github.com/cosmos/cosmos-sdk/types" eth "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/crosschain/types" + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" ) func (k Keeper) DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int) error { @@ -17,7 +17,7 @@ func (k Keeper) DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int return k.MintZetaToEVMAccount(ctx, zetaToAddress, amount) } -func (k Keeper) ZRC20DepositAndCallContract(ctx sdk.Context, to eth.Address, amount *big.Int, senderChain *common.Chain, +func (k Keeper) ZRC20DepositAndCallContract(ctx sdk.Context, from []byte, to eth.Address, amount *big.Int, senderChain *common.Chain, message string, contract eth.Address, data []byte, coinType common.CoinType, asset string) (*evmtypes.MsgEthereumTxResponse, error) { var Zrc20Contract eth.Address var coin fungibletypes.ForeignCoins @@ -49,6 +49,11 @@ func (k Keeper) ZRC20DepositAndCallContract(ctx sdk.Context, to eth.Address, amo if len(data) == 0 { return k.DepositZRC20(ctx, Zrc20Contract, contract, amount) } - return k.DepositZRC20AndCallContract(ctx, Zrc20Contract, contract, amount, data) + context := systemcontract.ZContext{ + Origin: from, + Sender: eth.Address{}, + ChainID: big.NewInt(senderChain.ChainId), + } + return k.DepositZRC20AndCallContract(ctx, context, Zrc20Contract, contract, amount, data) } diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 443880bf4d..fbc7cf1636 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -205,7 +205,8 @@ func (k Keeper) DepositZRC20( // callable from fungible module // Returns directly results from CallEVM func (k Keeper) DepositZRC20AndCallContract(ctx sdk.Context, - zrc4Contract common.Address, + context systemcontract.ZContext, + zrc20Addr common.Address, targetContract common.Address, amount *big.Int, message []byte) (*evmtypes.MsgEthereumTxResponse, error) { @@ -215,17 +216,17 @@ func (k Keeper) DepositZRC20AndCallContract(ctx sdk.Context, } systemAddress := common.HexToAddress(system.SystemContract) - abi, err := systemcontract.SystemContractMetaData.GetAbi() + sysConABI, err := systemcontract.SystemContractMetaData.GetAbi() if err != nil { return nil, err } - return k.CallEVM(ctx, *abi, types.ModuleAddressEVM, systemAddress, BigIntZero, ZEVMGasLimitDepositAndCall, true, - "depositAndCall", zrc4Contract, amount, targetContract, message) + return k.CallEVM(ctx, *sysConABI, types.ModuleAddressEVM, systemAddress, BigIntZero, ZEVMGasLimitDepositAndCall, true, + "depositAndCall", context, zrc20Addr, amount, targetContract, message) } -// QueryZRC4Data returns the data of a deployed ZRC4 contract -func (k Keeper) QueryZRC4Data( +// QueryZRC20Data returns the data of a deployed ZRC20 contract +func (k Keeper) QueryZRC20Data( ctx sdk.Context, contract common.Address, ) (types.ZRC20Data, error) { diff --git a/x/fungible/keeper/foreign_coins.go b/x/fungible/keeper/foreign_coins.go index 258f4593d8..7e51a90be6 100644 --- a/x/fungible/keeper/foreign_coins.go +++ b/x/fungible/keeper/foreign_coins.go @@ -66,7 +66,7 @@ func (k Keeper) GetAllForeignCoinsForChain(ctx sdk.Context, foreignChainID int64 } // GetAllForeignCoins returns all foreignCoins -func (k Keeper) GetAllForeignCoins(ctx sdk.Context, foreignChainID int64) (list []types.ForeignCoins) { +func (k Keeper) GetAllForeignCoins(ctx sdk.Context) (list []types.ForeignCoins) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(fmt.Sprintf("%s", types.ForeignCoinsKeyPrefix))) iterator := sdk.KVStorePrefixIterator(store, []byte{}) diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go index 36857c8884..fcf5c5a1f8 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "math/big" sdk "github.com/cosmos/cosmos-sdk/types" @@ -49,20 +48,23 @@ func (k msgServer) DeployFungibleCoinZRC20(goCtx context.Context, msg *types.Msg return nil, err } - //FIXME : declare the attributes as constants , in x/fungible/types - ctx.EventManager().EmitEvent( - sdk.NewEvent(sdk.EventTypeMessage, - sdk.NewAttribute("action", "DeployFungibleCoinZRC20"), - sdk.NewAttribute("chain", msg.ForeignChain), - sdk.NewAttribute("contract", addr.String()), - sdk.NewAttribute("name", msg.Name), - sdk.NewAttribute("symbol", msg.Symbol), - sdk.NewAttribute("decimals", fmt.Sprintf("%d", msg.Decimals)), - sdk.NewAttribute("coinType", msg.CoinType.String()), - sdk.NewAttribute("erc20", msg.ERC20), - sdk.NewAttribute("gasLimit", fmt.Sprintf("%d", msg.GasLimit)), - ), + err = ctx.EventManager().EmitTypedEvent( + &types.EventZRC20Deployed{ + MsgTypeUrl: sdk.MsgTypeURL(&types.MsgDeployFungibleCoinZRC20{}), + Chain: msg.ForeignChain, + Contract: addr.String(), + Name: msg.Name, + Symbol: msg.Symbol, + Decimals: int64(msg.Decimals), + CoinType: msg.CoinType, + Erc20: msg.ERC20, + GasLimit: msg.GasLimit, + }, ) + if err != nil { + return nil, sdkerrors.Wrapf(err, "failed to emit event") + } + } return &types.MsgDeployFungibleCoinZRC20Response{}, nil diff --git a/x/fungible/keeper/msg_server_update_system_contract.go b/x/fungible/keeper/msg_server_update_system_contract.go new file mode 100644 index 0000000000..8ae6a7352d --- /dev/null +++ b/x/fungible/keeper/msg_server_update_system_contract.go @@ -0,0 +1,81 @@ +package keeper + +import ( + "context" + "math/big" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" + "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" + "github.com/zeta-chain/zetacore/common" + "github.com/zeta-chain/zetacore/x/fungible/types" + zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" +) + +func (k Keeper) UpdateSystemContract(goCtx context.Context, msg *types.MsgUpdateSystemContract) (*types.MsgUpdateSystemContractResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if msg.Creator != k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { + return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Deploy can only be executed by the correct policy account") + } + newSystemContractAddr := ethcommon.HexToAddress(msg.NewSystemContractAddress) + if newSystemContractAddr == (ethcommon.Address{}) { + return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid system contract address (%s)", msg.NewSystemContractAddress) + } + + // update contracts + zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrABIGet, "failed to get zrc20 abi") + } + sysABI, err := systemcontract.SystemContractMetaData.GetAbi() + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrABIGet, "failed to get system contract abi") + } + foreignCoins := k.GetAllForeignCoins(ctx) + tmpCtx, commit := ctx.CacheContext() + for _, fcoin := range foreignCoins { + zrc20Addr := ethcommon.HexToAddress(fcoin.Zrc20ContractAddress) + if zrc20Addr == (ethcommon.Address{}) { + k.Logger(ctx).Error("invalid zrc20 contract address", "address", fcoin.Zrc20ContractAddress) + continue + } + _, err = k.CallEVM(tmpCtx, *zrc20ABI, types.ModuleAddressEVM, zrc20Addr, BigIntZero, nil, true, "updateSystemContractAddress", newSystemContractAddr) + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrContractCall, "failed to call zrc20 contract method updateSystemContractAddress (%s)", err.Error()) + } + if fcoin.CoinType == common.CoinType_Gas { + _, err = k.CallEVM(tmpCtx, *sysABI, types.ModuleAddressEVM, newSystemContractAddr, BigIntZero, nil, true, "setGasCoinZRC20", big.NewInt(fcoin.ForeignChainId), zrc20Addr) + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrContractCall, "failed to call system contract method setGasCoinZRC20 (%s)", err.Error()) + } + _, err = k.CallEVM(tmpCtx, *sysABI, types.ModuleAddressEVM, newSystemContractAddr, BigIntZero, nil, true, "setGasZetaPool", big.NewInt(fcoin.ForeignChainId), zrc20Addr) + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrContractCall, "failed to call system contract method setGasZetaPool (%s)", err.Error()) + } + } + } + + sys, found := k.GetSystemContract(ctx) + if !found { + k.Logger(ctx).Error("system contract not found") + } + oldSystemContractAddress := sys.SystemContract + sys.SystemContract = newSystemContractAddr.Hex() + k.SetSystemContract(ctx, sys) + commit() + err = ctx.EventManager().EmitTypedEvent( + &types.EventSystemContractUpdated{ + MsgTypeUrl: sdk.MsgTypeURL(&types.MsgUpdateSystemContract{}), + NewContractAddress: msg.NewSystemContractAddress, + OldContractAddress: oldSystemContractAddress, + Signer: msg.Creator, + }, + ) + if err != nil { + k.Logger(ctx).Error("failed to emit event", "error", err.Error()) + return nil, sdkerrors.Wrapf(types.ErrEmitEvent, "failed to emit event (%s)", err.Error()) + } + return &types.MsgUpdateSystemContractResponse{}, nil +} diff --git a/x/fungible/module.go b/x/fungible/module.go index 8c4402f768..55734638c6 100644 --- a/x/fungible/module.go +++ b/x/fungible/module.go @@ -178,6 +178,14 @@ func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { ctx.Logger().Error("Unable To deploy contracts", "err", err.Error()) } } + if ctx.BlockHeight() == 20 { + err := am.keeper.UpdateSystemContractAddress(sdk.WrapSDKContext(ctx)) + if err != nil { + ctx.Logger().Error("Unable To update system contracts", "err", err.Error()) + } else { + ctx.Logger().Info("System contract updated") + } + } } // EndBlock executes all ABCI EndBlock logic respective to the fungible module. It diff --git a/x/fungible/types/errors.go b/x/fungible/types/errors.go index eecf1761a9..742afbc342 100644 --- a/x/fungible/types/errors.go +++ b/x/fungible/types/errors.go @@ -22,4 +22,5 @@ var ( ErrInvalidAddress = sdkerrors.Register(ModuleName, 1111, "invalid address") ErrStateVaraibleNotFound = sdkerrors.Register(ModuleName, 1112, "state variable not found") ErrDeployContract = sdkerrors.Register(ModuleName, 1113, "deploy contract error") + ErrEmitEvent = sdkerrors.Register(ModuleName, 1114, "emit event error") ) diff --git a/x/fungible/types/events.pb.go b/x/fungible/types/events.pb.go new file mode 100644 index 0000000000..30ef20b4ac --- /dev/null +++ b/x/fungible/types/events.pb.go @@ -0,0 +1,1016 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: fungible/events.proto + +package types + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + common "github.com/zeta-chain/zetacore/common" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type EventSystemContractUpdated struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + NewContractAddress string `protobuf:"bytes,2,opt,name=new_contract_address,json=newContractAddress,proto3" json:"new_contract_address,omitempty"` + OldContractAddress string `protobuf:"bytes,3,opt,name=old_contract_address,json=oldContractAddress,proto3" json:"old_contract_address,omitempty"` + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *EventSystemContractUpdated) Reset() { *m = EventSystemContractUpdated{} } +func (m *EventSystemContractUpdated) String() string { return proto.CompactTextString(m) } +func (*EventSystemContractUpdated) ProtoMessage() {} +func (*EventSystemContractUpdated) Descriptor() ([]byte, []int) { + return fileDescriptor_858e6494730deffd, []int{0} +} +func (m *EventSystemContractUpdated) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventSystemContractUpdated) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventSystemContractUpdated.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 *EventSystemContractUpdated) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventSystemContractUpdated.Merge(m, src) +} +func (m *EventSystemContractUpdated) XXX_Size() int { + return m.Size() +} +func (m *EventSystemContractUpdated) XXX_DiscardUnknown() { + xxx_messageInfo_EventSystemContractUpdated.DiscardUnknown(m) +} + +var xxx_messageInfo_EventSystemContractUpdated proto.InternalMessageInfo + +func (m *EventSystemContractUpdated) GetMsgTypeUrl() string { + if m != nil { + return m.MsgTypeUrl + } + return "" +} + +func (m *EventSystemContractUpdated) GetNewContractAddress() string { + if m != nil { + return m.NewContractAddress + } + return "" +} + +func (m *EventSystemContractUpdated) GetOldContractAddress() string { + if m != nil { + return m.OldContractAddress + } + return "" +} + +func (m *EventSystemContractUpdated) GetSigner() string { + if m != nil { + return m.Signer + } + return "" +} + +type EventZRC20Deployed struct { + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + Chain string `protobuf:"bytes,2,opt,name=chain,proto3" json:"chain,omitempty"` + Contract string `protobuf:"bytes,3,opt,name=contract,proto3" json:"contract,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Symbol string `protobuf:"bytes,5,opt,name=symbol,proto3" json:"symbol,omitempty"` + Decimals int64 `protobuf:"varint,6,opt,name=decimals,proto3" json:"decimals,omitempty"` + CoinType common.CoinType `protobuf:"varint,7,opt,name=coin_type,json=coinType,proto3,enum=common.CoinType" json:"coin_type,omitempty"` + Erc20 string `protobuf:"bytes,8,opt,name=erc20,proto3" json:"erc20,omitempty"` + GasLimit int64 `protobuf:"varint,9,opt,name=gasLimit,proto3" json:"gasLimit,omitempty"` +} + +func (m *EventZRC20Deployed) Reset() { *m = EventZRC20Deployed{} } +func (m *EventZRC20Deployed) String() string { return proto.CompactTextString(m) } +func (*EventZRC20Deployed) ProtoMessage() {} +func (*EventZRC20Deployed) Descriptor() ([]byte, []int) { + return fileDescriptor_858e6494730deffd, []int{1} +} +func (m *EventZRC20Deployed) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EventZRC20Deployed) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EventZRC20Deployed.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 *EventZRC20Deployed) XXX_Merge(src proto.Message) { + xxx_messageInfo_EventZRC20Deployed.Merge(m, src) +} +func (m *EventZRC20Deployed) XXX_Size() int { + return m.Size() +} +func (m *EventZRC20Deployed) XXX_DiscardUnknown() { + xxx_messageInfo_EventZRC20Deployed.DiscardUnknown(m) +} + +var xxx_messageInfo_EventZRC20Deployed proto.InternalMessageInfo + +func (m *EventZRC20Deployed) GetMsgTypeUrl() string { + if m != nil { + return m.MsgTypeUrl + } + return "" +} + +func (m *EventZRC20Deployed) GetChain() string { + if m != nil { + return m.Chain + } + return "" +} + +func (m *EventZRC20Deployed) GetContract() string { + if m != nil { + return m.Contract + } + return "" +} + +func (m *EventZRC20Deployed) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *EventZRC20Deployed) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *EventZRC20Deployed) GetDecimals() int64 { + if m != nil { + return m.Decimals + } + return 0 +} + +func (m *EventZRC20Deployed) GetCoinType() common.CoinType { + if m != nil { + return m.CoinType + } + return common.CoinType_Zeta +} + +func (m *EventZRC20Deployed) GetErc20() string { + if m != nil { + return m.Erc20 + } + return "" +} + +func (m *EventZRC20Deployed) GetGasLimit() int64 { + if m != nil { + return m.GasLimit + } + return 0 +} + +func init() { + proto.RegisterType((*EventSystemContractUpdated)(nil), "zetachain.zetacore.fungible.EventSystemContractUpdated") + proto.RegisterType((*EventZRC20Deployed)(nil), "zetachain.zetacore.fungible.EventZRC20Deployed") +} + +func init() { proto.RegisterFile("fungible/events.proto", fileDescriptor_858e6494730deffd) } + +var fileDescriptor_858e6494730deffd = []byte{ + // 401 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcd, 0x8e, 0xd3, 0x30, + 0x14, 0x85, 0xeb, 0xf9, 0x29, 0x53, 0x0b, 0x21, 0x64, 0x0a, 0xb2, 0x8a, 0x14, 0x55, 0xb3, 0xea, + 0x66, 0xea, 0xaa, 0x3c, 0x01, 0x14, 0x16, 0x48, 0xac, 0x0a, 0xb3, 0x99, 0x4d, 0xe4, 0x24, 0x17, + 0x8f, 0x25, 0xff, 0x44, 0xb6, 0xcb, 0x10, 0x9e, 0x02, 0x5e, 0x87, 0x27, 0x60, 0x39, 0x4b, 0x96, + 0xa8, 0x7d, 0x11, 0x64, 0x3b, 0xe9, 0x02, 0x36, 0xb3, 0xca, 0x39, 0xc9, 0x3d, 0xf7, 0x7e, 0xb1, + 0x2f, 0x7e, 0xfe, 0x79, 0x67, 0x84, 0xac, 0x14, 0x30, 0xf8, 0x02, 0x26, 0xf8, 0x65, 0xeb, 0x6c, + 0xb0, 0xe4, 0xe5, 0x37, 0x08, 0xbc, 0xbe, 0xe5, 0xd2, 0x2c, 0x93, 0xb2, 0x0e, 0x96, 0x43, 0xe5, + 0xec, 0x59, 0x6d, 0xb5, 0xb6, 0x86, 0xe5, 0x47, 0x4e, 0xcc, 0xa6, 0xc2, 0x0a, 0x9b, 0x24, 0x8b, + 0x2a, 0xbf, 0xbd, 0xfc, 0x89, 0xf0, 0xec, 0x5d, 0x6c, 0xfc, 0xb1, 0xf3, 0x01, 0xf4, 0xc6, 0x9a, + 0xe0, 0x78, 0x1d, 0xae, 0xdb, 0x86, 0x07, 0x68, 0xc8, 0x1c, 0x3f, 0xd6, 0x5e, 0x94, 0xa1, 0x6b, + 0xa1, 0xdc, 0x39, 0x45, 0xd1, 0x1c, 0x2d, 0x26, 0x5b, 0xac, 0xbd, 0xf8, 0xd4, 0xb5, 0x70, 0xed, + 0x14, 0x59, 0xe1, 0xa9, 0x81, 0xbb, 0xb2, 0xee, 0x83, 0x25, 0x6f, 0x1a, 0x07, 0xde, 0xd3, 0x93, + 0x54, 0x49, 0x0c, 0xdc, 0x0d, 0x3d, 0x5f, 0xe7, 0x2f, 0x31, 0x61, 0x55, 0xf3, 0x7f, 0xe2, 0x34, + 0x27, 0xac, 0x6a, 0xfe, 0x4d, 0xbc, 0xc0, 0x63, 0x2f, 0x85, 0x01, 0x47, 0xcf, 0x52, 0x4d, 0xef, + 0x2e, 0x7f, 0x9c, 0x60, 0x92, 0xe0, 0x6f, 0xb6, 0x9b, 0xf5, 0xea, 0x2d, 0xb4, 0xca, 0x76, 0x0f, + 0x82, 0x9e, 0xe2, 0xf3, 0x74, 0x76, 0x3d, 0x65, 0x36, 0x64, 0x86, 0x2f, 0x06, 0xa8, 0x1e, 0xe6, + 0xe8, 0x09, 0xc1, 0x67, 0x86, 0x6b, 0xe8, 0x01, 0x92, 0x4e, 0x58, 0x9d, 0xae, 0xac, 0xa2, 0xe7, + 0x3d, 0x56, 0x72, 0xb1, 0x4f, 0x03, 0xb5, 0xd4, 0x5c, 0x79, 0x3a, 0x9e, 0xa3, 0xc5, 0xe9, 0xf6, + 0xe8, 0xc9, 0x15, 0x9e, 0xd4, 0x56, 0x9a, 0x04, 0x47, 0x1f, 0xcd, 0xd1, 0xe2, 0xc9, 0xfa, 0xe9, + 0xb2, 0xbf, 0xa7, 0x8d, 0x95, 0x26, 0x12, 0xc6, 0xb1, 0x59, 0x45, 0x50, 0x70, 0xf5, 0x7a, 0x45, + 0x2f, 0x32, 0x68, 0x32, 0x71, 0x80, 0xe0, 0xfe, 0x83, 0xd4, 0x32, 0xd0, 0x49, 0x1e, 0x30, 0xf8, + 0x37, 0xef, 0x7f, 0xed, 0x0b, 0x74, 0xbf, 0x2f, 0xd0, 0x9f, 0x7d, 0x81, 0xbe, 0x1f, 0x8a, 0xd1, + 0xfd, 0xa1, 0x18, 0xfd, 0x3e, 0x14, 0xa3, 0x1b, 0x26, 0x64, 0xb8, 0xdd, 0x55, 0x71, 0x1a, 0x8b, + 0x3b, 0x73, 0x95, 0xfe, 0x9a, 0x0d, 0xeb, 0xc3, 0xbe, 0xb2, 0xe3, 0xaa, 0x45, 0x3a, 0x5f, 0x8d, + 0xd3, 0x8a, 0xbc, 0xfa, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x76, 0x5f, 0x9d, 0x91, 0x83, 0x02, 0x00, + 0x00, +} + +func (m *EventSystemContractUpdated) 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 *EventSystemContractUpdated) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventSystemContractUpdated) 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] = 0x22 + } + if len(m.OldContractAddress) > 0 { + i -= len(m.OldContractAddress) + copy(dAtA[i:], m.OldContractAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.OldContractAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.NewContractAddress) > 0 { + i -= len(m.NewContractAddress) + copy(dAtA[i:], m.NewContractAddress) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewContractAddress))) + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *EventZRC20Deployed) 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 *EventZRC20Deployed) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EventZRC20Deployed) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GasLimit != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.GasLimit)) + i-- + dAtA[i] = 0x48 + } + if len(m.Erc20) > 0 { + i -= len(m.Erc20) + copy(dAtA[i:], m.Erc20) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Erc20))) + i-- + dAtA[i] = 0x42 + } + if m.CoinType != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.CoinType)) + i-- + dAtA[i] = 0x38 + } + if m.Decimals != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Decimals)) + i-- + dAtA[i] = 0x30 + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0x2a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x22 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0x1a + } + if len(m.Chain) > 0 { + i -= len(m.Chain) + copy(dAtA[i:], m.Chain) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Chain))) + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *EventSystemContractUpdated) 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)) + } + l = len(m.NewContractAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.OldContractAddress) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *EventZRC20Deployed) 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)) + } + l = len(m.Chain) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Decimals != 0 { + n += 1 + sovEvents(uint64(m.Decimals)) + } + if m.CoinType != 0 { + n += 1 + sovEvents(uint64(m.CoinType)) + } + l = len(m.Erc20) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.GasLimit != 0 { + n += 1 + sovEvents(uint64(m.GasLimit)) + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *EventSystemContractUpdated) 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: EventSystemContractUpdated: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventSystemContractUpdated: 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 NewContractAddress", 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.NewContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldContractAddress", 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.OldContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", 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.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 *EventZRC20Deployed) 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: EventZRC20Deployed: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EventZRC20Deployed: 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 Chain", 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.Chain = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", 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.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", 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.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", 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.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) + } + m.Decimals = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Decimals |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CoinType", wireType) + } + m.CoinType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CoinType |= common.CoinType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Erc20", 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.Erc20 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) + } + m.GasLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasLimit |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 skipEvents(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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/fungible/types/message_update_system_contract.go b/x/fungible/types/message_update_system_contract.go new file mode 100644 index 0000000000..201aad573f --- /dev/null +++ b/x/fungible/types/message_update_system_contract.go @@ -0,0 +1,52 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcommon "github.com/ethereum/go-ethereum/common" +) + +const TypeMsgUpdateSystemContract = "update_system_contract" + +var _ sdk.Msg = &MsgUpdateSystemContract{} + +func NewMessageUpdateSystemContract(creator string, systemContractAddr string) *MsgUpdateSystemContract { + return &MsgUpdateSystemContract{ + Creator: creator, + NewSystemContractAddress: systemContractAddr, + } +} + +func (msg *MsgUpdateSystemContract) Route() string { + return RouterKey +} + +func (msg *MsgUpdateSystemContract) Type() string { + return TypeMsgUpdateSystemContract +} + +func (msg *MsgUpdateSystemContract) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateSystemContract) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateSystemContract) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + // check if the system contract address is valid + if ethcommon.HexToAddress(msg.NewSystemContractAddress) == (ethcommon.Address{}) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid system contract address (%s)", msg.NewSystemContractAddress) + } + + return nil +} diff --git a/x/fungible/types/tx.pb.go b/x/fungible/types/tx.pb.go index eaa683529e..16669e7968 100644 --- a/x/fungible/types/tx.pb.go +++ b/x/fungible/types/tx.pb.go @@ -29,6 +29,94 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgUpdateSystemContract struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + NewSystemContractAddress string `protobuf:"bytes,2,opt,name=newSystemContractAddress,proto3" json:"newSystemContractAddress,omitempty"` +} + +func (m *MsgUpdateSystemContract) Reset() { *m = MsgUpdateSystemContract{} } +func (m *MsgUpdateSystemContract) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSystemContract) ProtoMessage() {} +func (*MsgUpdateSystemContract) Descriptor() ([]byte, []int) { + return fileDescriptor_197fdedece277fa0, []int{0} +} +func (m *MsgUpdateSystemContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSystemContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSystemContract.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 *MsgUpdateSystemContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSystemContract.Merge(m, src) +} +func (m *MsgUpdateSystemContract) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSystemContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSystemContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSystemContract proto.InternalMessageInfo + +func (m *MsgUpdateSystemContract) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateSystemContract) GetNewSystemContractAddress() string { + if m != nil { + return m.NewSystemContractAddress + } + return "" +} + +type MsgUpdateSystemContractResponse struct { +} + +func (m *MsgUpdateSystemContractResponse) Reset() { *m = MsgUpdateSystemContractResponse{} } +func (m *MsgUpdateSystemContractResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSystemContractResponse) ProtoMessage() {} +func (*MsgUpdateSystemContractResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_197fdedece277fa0, []int{1} +} +func (m *MsgUpdateSystemContractResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSystemContractResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSystemContractResponse.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 *MsgUpdateSystemContractResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSystemContractResponse.Merge(m, src) +} +func (m *MsgUpdateSystemContractResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSystemContractResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSystemContractResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSystemContractResponse proto.InternalMessageInfo + type MsgDeployFungibleCoinZRC20 struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` ERC20 string `protobuf:"bytes,2,opt,name=ERC20,proto3" json:"ERC20,omitempty"` @@ -44,7 +132,7 @@ func (m *MsgDeployFungibleCoinZRC20) Reset() { *m = MsgDeployFungibleCoi func (m *MsgDeployFungibleCoinZRC20) String() string { return proto.CompactTextString(m) } func (*MsgDeployFungibleCoinZRC20) ProtoMessage() {} func (*MsgDeployFungibleCoinZRC20) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{0} + return fileDescriptor_197fdedece277fa0, []int{2} } func (m *MsgDeployFungibleCoinZRC20) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -136,7 +224,7 @@ func (m *MsgDeployFungibleCoinZRC20Response) Reset() { *m = MsgDeployFun func (m *MsgDeployFungibleCoinZRC20Response) String() string { return proto.CompactTextString(m) } func (*MsgDeployFungibleCoinZRC20Response) ProtoMessage() {} func (*MsgDeployFungibleCoinZRC20Response) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{1} + return fileDescriptor_197fdedece277fa0, []int{3} } func (m *MsgDeployFungibleCoinZRC20Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -174,7 +262,7 @@ func (m *MsgRemoveForeignCoin) Reset() { *m = MsgRemoveForeignCoin{} } func (m *MsgRemoveForeignCoin) String() string { return proto.CompactTextString(m) } func (*MsgRemoveForeignCoin) ProtoMessage() {} func (*MsgRemoveForeignCoin) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{2} + return fileDescriptor_197fdedece277fa0, []int{4} } func (m *MsgRemoveForeignCoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -224,7 +312,7 @@ func (m *MsgRemoveForeignCoinResponse) Reset() { *m = MsgRemoveForeignCo func (m *MsgRemoveForeignCoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveForeignCoinResponse) ProtoMessage() {} func (*MsgRemoveForeignCoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_197fdedece277fa0, []int{3} + return fileDescriptor_197fdedece277fa0, []int{5} } func (m *MsgRemoveForeignCoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -254,6 +342,8 @@ func (m *MsgRemoveForeignCoinResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveForeignCoinResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgUpdateSystemContract)(nil), "zetachain.zetacore.fungible.MsgUpdateSystemContract") + proto.RegisterType((*MsgUpdateSystemContractResponse)(nil), "zetachain.zetacore.fungible.MsgUpdateSystemContractResponse") proto.RegisterType((*MsgDeployFungibleCoinZRC20)(nil), "zetachain.zetacore.fungible.MsgDeployFungibleCoinZRC20") proto.RegisterType((*MsgDeployFungibleCoinZRC20Response)(nil), "zetachain.zetacore.fungible.MsgDeployFungibleCoinZRC20Response") proto.RegisterType((*MsgRemoveForeignCoin)(nil), "zetachain.zetacore.fungible.MsgRemoveForeignCoin") @@ -263,33 +353,37 @@ func init() { func init() { proto.RegisterFile("fungible/tx.proto", fileDescriptor_197fdedece277fa0) } var fileDescriptor_197fdedece277fa0 = []byte{ - // 411 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4f, 0x6b, 0xdb, 0x30, - 0x1c, 0x8d, 0x9c, 0xbf, 0x13, 0xdb, 0x58, 0xb4, 0xb0, 0x09, 0x6f, 0x18, 0x63, 0x76, 0xf0, 0x61, - 0xb3, 0xb7, 0xec, 0x30, 0x76, 0x1a, 0xcc, 0x59, 0x60, 0xd0, 0x5c, 0x4c, 0x4f, 0xb9, 0xd9, 0xae, - 0xe2, 0x08, 0x6c, 0xc9, 0x58, 0x4e, 0x89, 0x7b, 0x6b, 0x3f, 0x41, 0xa1, 0x1f, 0xa0, 0x5f, 0xa7, - 0xc7, 0x1c, 0x7b, 0x2c, 0xc9, 0x17, 0x29, 0x56, 0xec, 0x84, 0x92, 0x26, 0xa5, 0x3d, 0x59, 0xef, - 0xe7, 0xf7, 0x9e, 0x7e, 0xef, 0x27, 0x09, 0x76, 0x27, 0x33, 0x16, 0x52, 0x3f, 0x22, 0x76, 0x36, - 0xb7, 0x92, 0x94, 0x67, 0x1c, 0x7d, 0x3a, 0x23, 0x99, 0x17, 0x4c, 0x3d, 0xca, 0x2c, 0xb9, 0xe2, - 0x29, 0xb1, 0x2a, 0x96, 0xfa, 0x3e, 0xe0, 0x71, 0xcc, 0x99, 0xbd, 0xfe, 0xac, 0x15, 0xc6, 0x85, - 0x02, 0xd5, 0x91, 0x08, 0x07, 0x24, 0x89, 0x78, 0x3e, 0x2c, 0xa9, 0x0e, 0xa7, 0x6c, 0xec, 0x3a, - 0xfd, 0xef, 0x08, 0xc3, 0x76, 0x90, 0x12, 0x2f, 0xe3, 0x29, 0x06, 0x3a, 0x30, 0x5f, 0xb9, 0x15, - 0x44, 0x3d, 0xd8, 0xfc, 0x57, 0x50, 0xb0, 0x22, 0xeb, 0x6b, 0x80, 0x0c, 0xf8, 0x7a, 0xc2, 0x53, - 0x42, 0x43, 0xe6, 0x14, 0x5d, 0xe0, 0xba, 0xfc, 0xf9, 0xa0, 0x86, 0x54, 0xd8, 0x39, 0x21, 0x01, - 0x8d, 0xbd, 0x48, 0xe0, 0x86, 0x0e, 0xcc, 0x37, 0xee, 0x06, 0x23, 0x04, 0x1b, 0xcc, 0x8b, 0x09, - 0x6e, 0x4a, 0x9d, 0x5c, 0xa3, 0x0f, 0xb0, 0x25, 0xf2, 0xd8, 0xe7, 0x11, 0x6e, 0xc9, 0x6a, 0x89, - 0xd0, 0x57, 0xd8, 0x09, 0x38, 0x65, 0xc7, 0x79, 0x42, 0x70, 0x5b, 0x07, 0xe6, 0xdb, 0xfe, 0x3b, - 0xab, 0xcc, 0xe6, 0x94, 0x75, 0x77, 0xc3, 0x28, 0x76, 0x0d, 0x3d, 0x71, 0x44, 0x63, 0x9a, 0xe1, - 0x8e, 0x0e, 0xcc, 0xba, 0xbb, 0xc1, 0xc6, 0x17, 0x68, 0xec, 0x9f, 0x81, 0x4b, 0x44, 0xc2, 0x99, - 0x20, 0xc6, 0x00, 0xf6, 0x46, 0x22, 0x74, 0x49, 0xcc, 0x4f, 0xc9, 0xb0, 0x0c, 0xc4, 0x29, 0x3b, - 0x30, 0xa3, 0x2a, 0x8d, 0xb2, 0x4d, 0x63, 0x68, 0xf0, 0xf3, 0x63, 0x2e, 0xd5, 0x2e, 0xfd, 0x6b, - 0x05, 0xd6, 0x47, 0x22, 0x44, 0x57, 0x00, 0x7e, 0xdc, 0x77, 0x2a, 0xbf, 0xac, 0x03, 0xe7, 0x6c, - 0xed, 0x8f, 0xa2, 0xfe, 0x79, 0xa1, 0xb0, 0xea, 0x0e, 0x9d, 0x03, 0xd8, 0xdd, 0x9d, 0xc0, 0x8f, - 0xa7, 0x6c, 0x77, 0x24, 0xea, 0xef, 0x67, 0x4b, 0xaa, 0x1e, 0xfe, 0xfe, 0xbf, 0x59, 0x6a, 0x60, - 0xb1, 0xd4, 0xc0, 0xdd, 0x52, 0x03, 0x97, 0x2b, 0xad, 0xb6, 0x58, 0x69, 0xb5, 0xdb, 0x95, 0x56, - 0x1b, 0xdb, 0x21, 0xcd, 0xa6, 0x33, 0xbf, 0xb8, 0x05, 0x76, 0x61, 0xfa, 0x4d, 0xfa, 0xdb, 0x95, - 0xbf, 0x3d, 0xb7, 0xb7, 0x4f, 0x26, 0x4f, 0x88, 0xf0, 0x5b, 0xf2, 0x11, 0xfc, 0xbc, 0x0f, 0x00, - 0x00, 0xff, 0xff, 0xc3, 0x49, 0x7e, 0x0c, 0x4b, 0x03, 0x00, 0x00, + // 479 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xcd, 0x26, 0x6d, 0x1a, 0x46, 0x80, 0xe8, 0x12, 0xd1, 0x95, 0x41, 0x26, 0x58, 0x1c, 0x72, + 0x00, 0x1b, 0x02, 0x12, 0x02, 0x21, 0x21, 0x70, 0xa9, 0x84, 0x44, 0x2e, 0x06, 0x2e, 0xbd, 0x39, + 0xce, 0xd4, 0x5d, 0xc9, 0xde, 0xb5, 0xbc, 0x5b, 0xa8, 0xb9, 0xc1, 0x91, 0x13, 0x12, 0xbf, 0xc1, + 0x87, 0x70, 0xec, 0x91, 0x23, 0x4a, 0x7e, 0x04, 0xd9, 0xb1, 0x5d, 0x55, 0x8d, 0x53, 0x35, 0x27, + 0xef, 0xcc, 0xce, 0x9b, 0xf7, 0xe6, 0x79, 0x77, 0x61, 0xfb, 0xe0, 0x48, 0x84, 0x7c, 0x12, 0xa1, + 0xa3, 0x8f, 0xed, 0x24, 0x95, 0x5a, 0xd2, 0xdb, 0x5f, 0x51, 0xfb, 0xc1, 0xa1, 0xcf, 0x85, 0x5d, + 0xac, 0x64, 0x8a, 0x76, 0x55, 0x65, 0xdc, 0x0c, 0x64, 0x1c, 0x4b, 0xe1, 0x2c, 0x3e, 0x0b, 0x84, + 0x25, 0x61, 0x67, 0xac, 0xc2, 0x4f, 0xc9, 0xd4, 0xd7, 0xf8, 0x21, 0x53, 0x1a, 0x63, 0x57, 0x0a, + 0x9d, 0xfa, 0x81, 0xa6, 0x0c, 0xb6, 0x82, 0x14, 0x7d, 0x2d, 0x53, 0x46, 0x06, 0x64, 0x78, 0xc5, + 0xab, 0x42, 0xfa, 0x02, 0x98, 0xc0, 0x2f, 0x67, 0xcb, 0x5f, 0x4f, 0xa7, 0x29, 0x2a, 0xc5, 0xda, + 0x45, 0x69, 0xe3, 0xbe, 0x75, 0x0f, 0xee, 0x36, 0x10, 0x7a, 0xa8, 0x12, 0x29, 0x14, 0x5a, 0xdf, + 0xdb, 0x60, 0x8c, 0x55, 0xb8, 0x8b, 0x49, 0x24, 0xb3, 0xbd, 0x52, 0xbe, 0x2b, 0xb9, 0xd8, 0xf7, + 0xdc, 0xd1, 0xa3, 0x15, 0xba, 0xfa, 0xb0, 0xf9, 0x36, 0x2f, 0x29, 0x45, 0x2c, 0x02, 0x6a, 0xc1, + 0xd5, 0x03, 0x99, 0x22, 0x0f, 0x85, 0x9b, 0x3b, 0xc3, 0x3a, 0xc5, 0xe6, 0x99, 0x1c, 0x35, 0xa0, + 0x37, 0xc5, 0x80, 0xc7, 0x7e, 0xa4, 0xd8, 0xc6, 0x80, 0x0c, 0xaf, 0x79, 0x75, 0x4c, 0x29, 0x6c, + 0x08, 0x3f, 0x46, 0xb6, 0x59, 0xe0, 0x8a, 0x35, 0xbd, 0x05, 0x5d, 0x95, 0xc5, 0x13, 0x19, 0xb1, + 0x6e, 0x91, 0x2d, 0x23, 0xfa, 0x00, 0x7a, 0x81, 0xe4, 0xe2, 0x63, 0x96, 0x20, 0xdb, 0x1a, 0x90, + 0xe1, 0xf5, 0xd1, 0x0d, 0xbb, 0xf4, 0xdb, 0x2d, 0xf3, 0x5e, 0x5d, 0x91, 0xb3, 0x86, 0xbe, 0x7a, + 0xcf, 0x63, 0xae, 0x59, 0x6f, 0x40, 0x86, 0x1d, 0xaf, 0x8e, 0xad, 0xfb, 0x60, 0x35, 0x7b, 0x50, + 0x5b, 0xb5, 0x0b, 0xfd, 0xb1, 0x0a, 0x3d, 0x8c, 0xe5, 0x67, 0xdc, 0x2b, 0x07, 0x92, 0x5c, 0xac, + 0xf0, 0xa8, 0x9a, 0xa6, 0x7d, 0x3a, 0x8d, 0x65, 0xc2, 0x9d, 0x65, 0x5d, 0x2a, 0x96, 0xd1, 0xef, + 0x0e, 0x74, 0xc6, 0x2a, 0xa4, 0xbf, 0x08, 0xec, 0x34, 0xfd, 0x95, 0x67, 0xf6, 0x8a, 0xb3, 0x67, + 0x37, 0x8f, 0x62, 0xbc, 0x5a, 0x13, 0x58, 0xa9, 0xa3, 0xdf, 0x08, 0x6c, 0x9f, 0x77, 0xe0, 0xf1, + 0x45, 0x6d, 0xcf, 0x41, 0x8c, 0xe7, 0x97, 0x86, 0xd4, 0x1a, 0x7e, 0x10, 0xe8, 0x2f, 0xbd, 0x44, + 0x4f, 0x2f, 0xea, 0xb9, 0x0c, 0x65, 0xbc, 0x5c, 0x07, 0x55, 0x89, 0x79, 0xf3, 0xee, 0xcf, 0xcc, + 0x24, 0x27, 0x33, 0x93, 0xfc, 0x9b, 0x99, 0xe4, 0xe7, 0xdc, 0x6c, 0x9d, 0xcc, 0xcd, 0xd6, 0xdf, + 0xb9, 0xd9, 0xda, 0x77, 0x42, 0xae, 0x0f, 0x8f, 0x26, 0xf9, 0x91, 0x74, 0xf2, 0xbe, 0x0f, 0x0b, + 0x0a, 0xa7, 0xa2, 0x70, 0x8e, 0x9d, 0xd3, 0x37, 0x25, 0x4b, 0x50, 0x4d, 0xba, 0xc5, 0x2b, 0xf1, + 0xe4, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x92, 0x4c, 0x3f, 0x6c, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -306,6 +400,7 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { DeployFungibleCoinZRC20(ctx context.Context, in *MsgDeployFungibleCoinZRC20, opts ...grpc.CallOption) (*MsgDeployFungibleCoinZRC20Response, error) RemoveForeignCoin(ctx context.Context, in *MsgRemoveForeignCoin, opts ...grpc.CallOption) (*MsgRemoveForeignCoinResponse, error) + UpdateSystemContract(ctx context.Context, in *MsgUpdateSystemContract, opts ...grpc.CallOption) (*MsgUpdateSystemContractResponse, error) } type msgClient struct { @@ -334,10 +429,20 @@ func (c *msgClient) RemoveForeignCoin(ctx context.Context, in *MsgRemoveForeignC return out, nil } +func (c *msgClient) UpdateSystemContract(ctx context.Context, in *MsgUpdateSystemContract, opts ...grpc.CallOption) (*MsgUpdateSystemContractResponse, error) { + out := new(MsgUpdateSystemContractResponse) + err := c.cc.Invoke(ctx, "/zetachain.zetacore.fungible.Msg/UpdateSystemContract", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { DeployFungibleCoinZRC20(context.Context, *MsgDeployFungibleCoinZRC20) (*MsgDeployFungibleCoinZRC20Response, error) RemoveForeignCoin(context.Context, *MsgRemoveForeignCoin) (*MsgRemoveForeignCoinResponse, error) + UpdateSystemContract(context.Context, *MsgUpdateSystemContract) (*MsgUpdateSystemContractResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -350,6 +455,9 @@ func (*UnimplementedMsgServer) DeployFungibleCoinZRC20(ctx context.Context, req func (*UnimplementedMsgServer) RemoveForeignCoin(ctx context.Context, req *MsgRemoveForeignCoin) (*MsgRemoveForeignCoinResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RemoveForeignCoin not implemented") } +func (*UnimplementedMsgServer) UpdateSystemContract(ctx context.Context, req *MsgUpdateSystemContract) (*MsgUpdateSystemContractResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateSystemContract not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -391,6 +499,24 @@ func _Msg_RemoveForeignCoin_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Msg_UpdateSystemContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateSystemContract) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateSystemContract(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/zetachain.zetacore.fungible.Msg/UpdateSystemContract", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateSystemContract(ctx, req.(*MsgUpdateSystemContract)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "zetachain.zetacore.fungible.Msg", HandlerType: (*MsgServer)(nil), @@ -403,11 +529,75 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "RemoveForeignCoin", Handler: _Msg_RemoveForeignCoin_Handler, }, + { + MethodName: "UpdateSystemContract", + Handler: _Msg_UpdateSystemContract_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "fungible/tx.proto", } +func (m *MsgUpdateSystemContract) 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 *MsgUpdateSystemContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSystemContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewSystemContractAddress) > 0 { + i -= len(m.NewSystemContractAddress) + copy(dAtA[i:], m.NewSystemContractAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewSystemContractAddress))) + i-- + 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 *MsgUpdateSystemContractResponse) 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 *MsgUpdateSystemContractResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSystemContractResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgDeployFungibleCoinZRC20) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -575,6 +765,32 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgUpdateSystemContract) 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.NewSystemContractAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateSystemContractResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgDeployFungibleCoinZRC20) Size() (n int) { if m == nil { return 0 @@ -654,6 +870,170 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgUpdateSystemContract) 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: MsgUpdateSystemContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSystemContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewSystemContractAddress", 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.NewSystemContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateSystemContractResponse) 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: MsgUpdateSystemContractResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSystemContractResponse: 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 *MsgDeployFungibleCoinZRC20) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/zetaclient/bitcoin_client.go b/zetaclient/bitcoin_client.go index c36a8343bd..80f46dbd9b 100644 --- a/zetaclient/bitcoin_client.go +++ b/zetaclient/bitcoin_client.go @@ -321,18 +321,24 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce int, _ ob.includedTx[outTxID] = res ob.mu.Unlock() } + var amount float64 if res.Amount > 0 { - ob.logger.ObserveOutTx.Error().Msg("IsSendOutTxProcessed: res.Amount > 0") + ob.logger.ObserveOutTx.Warn().Msg("IsSendOutTxProcessed: res.Amount > 0") amount = res.Amount + } else if res.Amount == 0 { + ob.logger.ObserveOutTx.Error().Msg("IsSendOutTxProcessed: res.Amount == 0") + return false, false, nil } else { amount = -res.Amount } + amountInSat, _ := big.NewFloat(amount * 1e8).Int(nil) if res.Confirmations < ob.ConfirmationsThreshold(amountInSat) { return true, false, nil } + logger.Debug().Msgf("Bitcoin outTx confirmed: txid %s, amount %f\n", res.TxID, res.Amount) zetaHash, err := ob.zetaClient.PostReceiveConfirmation( sendHash, res.TxID,