Skip to content

Commit

Permalink
update method usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Nov 4, 2023
1 parent 1d2ab6b commit 325b4f5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions x/crosschain/client/cli/cli_cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func CmdCCTXInboundVoter() *cobra.Command {
250_000,
argsCoinType,
argsAsset,
0,
)
if err := msg.ValidateBasic(); err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions x/crosschain/client/integrationtests/cli_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func GetBallotIdentifier(message string) string {
250_000,
common.CoinType_Zeta,
"",
0,
)
return msg.Digest()
}
Expand Down
2 changes: 2 additions & 0 deletions x/crosschain/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func (k Keeper) ProcessZRC20WithdrawalEvent(ctx sdk.Context, event *zrc20.ZRC20W
gasLimit.Uint64()+uint64(event.Raw.Index),
foreignCoin.CoinType,
foreignCoin.Asset,
0,
)
sendHash := msg.Digest()

Expand Down Expand Up @@ -223,6 +224,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC
90000+uint64(event.Raw.Index),
common.CoinType_Zeta,
"",
0,
)
sendHash := msg.Digest()

Expand Down
2 changes: 2 additions & 0 deletions x/crosschain/types/message_vote_on_observed_inbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func NewMsgVoteOnObservedInboundTx(
gasLimit uint64,
coinType common.CoinType,
asset string,
eventIndex uint,
) *MsgVoteOnObservedInboundTx {
return &MsgVoteOnObservedInboundTx{
Creator: creator,
Expand All @@ -45,6 +46,7 @@ func NewMsgVoteOnObservedInboundTx(
GasLimit: gasLimit,
CoinType: coinType,
Asset: asset,
EventIndex: uint64(eventIndex),
}
}

Expand Down
12 changes: 12 additions & 0 deletions x/crosschain/types/message_vote_on_observed_inbound_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) {
GasLimit: 42,
CoinType: common.CoinType_Zeta,
Asset: sample.String(),
EventIndex: 42,
},
},
{
Expand All @@ -55,6 +56,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) {
GasLimit: 42,
CoinType: common.CoinType_Zeta,
Asset: sample.String(),
EventIndex: 42,
},
err: sdkerrors.ErrInvalidAddress,
},
Expand All @@ -74,6 +76,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) {
GasLimit: 42,
CoinType: common.CoinType_Zeta,
Asset: sample.String(),
EventIndex: 42,
},
err: types.ErrInvalidChainID,
},
Expand All @@ -93,6 +96,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) {
GasLimit: 42,
CoinType: common.CoinType_Zeta,
Asset: sample.String(),
EventIndex: 42,
},
err: types.ErrInvalidChainID,
},
Expand All @@ -112,6 +116,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) {
GasLimit: 42,
CoinType: common.CoinType_Zeta,
Asset: sample.String(),
EventIndex: 42,
},
err: sdkerrors.ErrInvalidRequest,
},
Expand Down Expand Up @@ -145,6 +150,7 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) {
GasLimit: 42,
CoinType: common.CoinType_Zeta,
Asset: sample.String(),
EventIndex: 42,
}
hash := msg.Digest()
require.NotEmpty(t, hash, "hash should not be empty")
Expand Down Expand Up @@ -226,4 +232,10 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) {
msg2.Asset = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
require.NotEqual(t, hash, hash2, "asset should change hash")

// event index used
msg2 = msg
msg2.EventIndex = 43
hash2 = msg2.Digest()
require.NotEqual(t, hash, hash2, "event index should change hash")
}
34 changes: 32 additions & 2 deletions zetaclient/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,38 @@ const (
DefaultRetryInterval = 5
)

func GetInBoundVoteMessage(sender string, senderChain int64, txOrigin string, receiver string, receiverChain int64, amount math.Uint, message string, inTxHash string, inBlockHeight uint64, gasLimit uint64, coinType common.CoinType, asset string, signerAddress string) *types.MsgVoteOnObservedInboundTx {
msg := types.NewMsgVoteOnObservedInboundTx(signerAddress, sender, senderChain, txOrigin, receiver, receiverChain, amount, message, inTxHash, inBlockHeight, gasLimit, coinType, asset)
// GetInBoundVoteMessage returns a new MsgVoteOnObservedInboundTx
func GetInBoundVoteMessage(
sender string,
senderChain int64,
txOrigin string,
receiver string,
receiverChain int64,
amount math.Uint,
message string,
inTxHash string,
inBlockHeight uint64,
gasLimit uint64,
coinType common.CoinType,
asset string,
signerAddress string,
) *types.MsgVoteOnObservedInboundTx {
msg := types.NewMsgVoteOnObservedInboundTx(
signerAddress,
sender,
senderChain,
txOrigin,
receiver,
receiverChain,
amount,
message,
inTxHash,
inBlockHeight,
gasLimit,
coinType,
asset,
0,
)
return msg
}

Expand Down

0 comments on commit 325b4f5

Please sign in to comment.