-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement
MsgUpdateERC20CustodyPauseStatus
to pause or unpaus…
…e ERC20 Custody (#2681) * refactor cmd cctx creation * initialize migrate funds message * implement migrate message * zetaclient implementation * fix event * fix params * add e2e test * generate * changelog * zetaclient test * fix message test * initialize cctx test * cmd cctx type tests * message test * Update zetaclient/chains/evm/signer/admin_cmd.go Co-authored-by: skosito <skostic9242@gmail.com> * tanmay comments * stefan comments * admin commands * make generate * initialize message * some message fixes * implement logic on ZetaClient * update pause status * add in authorization list * E2E test * add test in admin workflow * add event for pausing * changelogs * Update x/crosschain/types/cmd_cctxs.go Co-authored-by: skosito <skostic9242@gmail.com> * Update x/crosschain/types/cmd_cctxs.go Co-authored-by: skosito <skostic9242@gmail.com> * fix * remove rate limiter test --------- Co-authored-by: skosito <skostic9242@gmail.com>
- Loading branch information
Showing
24 changed files
with
2,032 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package e2etests | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/zeta-chain/zetacore/e2e/runner" | ||
"github.com/zeta-chain/zetacore/e2e/txserver" | ||
"github.com/zeta-chain/zetacore/e2e/utils" | ||
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" | ||
) | ||
|
||
// TestPauseERC20Custody tests the pausing and unpausing of ERC20 custody contracts on the EVM chain | ||
func TestPauseERC20Custody(r *runner.E2ERunner, _ []string) { | ||
// get EVM chain ID | ||
chainID, err := r.EVMClient.ChainID(r.Ctx) | ||
require.NoError(r, err) | ||
|
||
// check ERC20 custody contract is not paused | ||
paused, err := r.ERC20Custody.Paused(&bind.CallOpts{}) | ||
require.NoError(r, err) | ||
require.False(r, paused) | ||
|
||
// Part 1: Pause ERC20 custody contract | ||
|
||
// send command for pausing ERC20 custody contract | ||
msg := crosschaintypes.NewMsgUpdateERC20CustodyPauseStatus( | ||
r.ZetaTxServer.MustGetAccountAddressFromName(utils.AdminPolicyName), | ||
chainID.Int64(), | ||
true, | ||
) | ||
res, err := r.ZetaTxServer.BroadcastTx(utils.AdminPolicyName, msg) | ||
require.NoError(r, err) | ||
|
||
// fetch cctx index from tx response | ||
cctxIndex, err := txserver.FetchAttributeFromTxResponse(res, "cctx_index") | ||
require.NoError(r, err) | ||
|
||
cctxRes, err := r.CctxClient.Cctx(r.Ctx, &crosschaintypes.QueryGetCctxRequest{Index: cctxIndex}) | ||
require.NoError(r, err) | ||
|
||
cctx := cctxRes.CrossChainTx | ||
r.Logger.CCTX(*cctx, "pausing") | ||
|
||
// wait for the cctx to be mined | ||
r.WaitForMinedCCTXFromIndex(cctxIndex) | ||
|
||
// check ERC20 custody contract is paused | ||
paused, err = r.ERC20Custody.Paused(&bind.CallOpts{}) | ||
require.NoError(r, err) | ||
require.True(r, paused) | ||
|
||
// Part 2: Unpause ERC20 custody contract | ||
|
||
// send command for unpausing ERC20 custody contract | ||
msg = crosschaintypes.NewMsgUpdateERC20CustodyPauseStatus( | ||
r.ZetaTxServer.MustGetAccountAddressFromName(utils.AdminPolicyName), | ||
chainID.Int64(), | ||
false, | ||
) | ||
res, err = r.ZetaTxServer.BroadcastTx(utils.AdminPolicyName, msg) | ||
require.NoError(r, err) | ||
|
||
// fetch cctx index from tx response | ||
cctxIndex, err = txserver.FetchAttributeFromTxResponse(res, "cctx_index") | ||
require.NoError(r, err) | ||
|
||
cctxRes, err = r.CctxClient.Cctx(r.Ctx, &crosschaintypes.QueryGetCctxRequest{Index: cctxIndex}) | ||
require.NoError(r, err) | ||
|
||
cctx = cctxRes.CrossChainTx | ||
r.Logger.CCTX(*cctx, "unpausing") | ||
|
||
// wait for the cctx to be mined | ||
r.WaitForMinedCCTXFromIndex(cctxIndex) | ||
|
||
// check ERC20 custody contract is unpaused | ||
paused, err = r.ERC20Custody.Paused(&bind.CallOpts{}) | ||
require.NoError(r, err) | ||
require.False(r, paused) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.