Skip to content

Commit

Permalink
use event index
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Nov 4, 2023
1 parent 325b4f5 commit d838793
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Broadcast message sendVoter

```
zetacored tx crosschain inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inTxHash] [inBlockHeight] [coinType] [asset] [flags]
zetacored tx crosschain inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inTxHash] [inBlockHeight] [coinType] [asset] [eventIndex] [flags]
```

### Options
Expand Down
12 changes: 9 additions & 3 deletions x/crosschain/client/cli/cli_cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ func CmdShowSend() *cobra.Command {

func CmdCCTXInboundVoter() *cobra.Command {
cmd := &cobra.Command{
Use: "inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inTxHash] [inBlockHeight] [coinType] [asset]",
Use: "inbound-voter [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message" +
"] [inTxHash] [inBlockHeight] [coinType] [asset] [eventIndex]",
Short: "Broadcast message sendVoter",
Args: cobra.ExactArgs(11),
Args: cobra.ExactArgs(12),
RunE: func(cmd *cobra.Command, args []string) error {
argsSender := args[0]
argsSenderChain, err := strconv.ParseInt(args[1], 10, 64)
Expand Down Expand Up @@ -147,6 +148,11 @@ func CmdCCTXInboundVoter() *cobra.Command {

argsAsset := args[10]

argsEventIndex, err := strconv.ParseInt(args[11], 10, 64)
if err != nil {
return err
}

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
Expand All @@ -166,7 +172,7 @@ func CmdCCTXInboundVoter() *cobra.Command {
250_000,
argsCoinType,
argsAsset,
0,
uint(argsEventIndex),

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of an unsigned 64-bit integer from
strconv.ParseUint
to a lower bit size type uint without an upper bound check.
)
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 @@ -169,6 +169,7 @@ func BuildSignedInboundVote(t testing.TB, val *network.Validator, denom string,
"100",
"Zeta",
"",
"0",
}
txArgs := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address),
Expand Down
8 changes: 4 additions & 4 deletions x/crosschain/keeper/evm_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ func (k Keeper) ProcessZRC20WithdrawalEvent(ctx sdk.Context, event *zrc20.ZRC20W
"",
event.Raw.TxHash.String(),
event.Raw.BlockNumber,
gasLimit.Uint64()+uint64(event.Raw.Index),
gasLimit.Uint64(),
foreignCoin.CoinType,
foreignCoin.Asset,
0,
event.Raw.Index,
)
sendHash := msg.Digest()

Expand Down Expand Up @@ -221,10 +221,10 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC
"",
event.Raw.TxHash.String(),
event.Raw.BlockNumber,
90000+uint64(event.Raw.Index),
90000,
common.CoinType_Zeta,
"",
0,
event.Raw.Index,
)
sendHash := msg.Digest()

Expand Down
1 change: 1 addition & 0 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ func (ob *BitcoinChainClient) GetInboundVoteMessageFromBtcEvent(inTx *BTCInTxEvn
common.CoinType_Gas,
"",
ob.zetaClient.GetKeys().GetOperatorAddress().String(),
0,
)
}

Expand Down
3 changes: 2 additions & 1 deletion zetaclient/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func GetInBoundVoteMessage(
coinType common.CoinType,
asset string,
signerAddress string,
eventIndex uint,
) *types.MsgVoteOnObservedInboundTx {
msg := types.NewMsgVoteOnObservedInboundTx(
signerAddress,
Expand All @@ -61,7 +62,7 @@ func GetInBoundVoteMessage(
gasLimit,
coinType,
asset,
0,
eventIndex,
)
return msg
}
Expand Down
3 changes: 3 additions & 0 deletions zetaclient/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (ob *EVMChainClient) GetInboundVoteMsgForDepositedEvent(event *erc20custody
common.CoinType_ERC20,
event.Asset.String(),
ob.zetaClient.GetKeys().GetOperatorAddress().String(),
event.Raw.Index,
), nil
}

Expand Down Expand Up @@ -160,6 +161,7 @@ func (ob *EVMChainClient) GetInboundVoteMsgForZetaSentEvent(event *zetaconnector
common.CoinType_Zeta,
"",
ob.zetaClient.GetKeys().GetOperatorAddress().String(),
event.Raw.Index,
), nil
}

Expand All @@ -185,5 +187,6 @@ func (ob *EVMChainClient) GetInboundVoteMsgForTokenSentToTSS(txhash ethcommon.Ha
common.CoinType_Gas,
"",
ob.zetaClient.GetKeys().GetOperatorAddress().String(),
0, // not a smart contract call
)
}

0 comments on commit d838793

Please sign in to comment.