Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/cli/cmd/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ func evmSend(
}

auth := b.EthAuth
if feeToken == b.Profile.EthEmptyAddress {
auth.Value = fee
} else {

if feeToken != b.Profile.EthEmptyAddress {
allowance := requiredAllowances[feeToken]
if allowance == nil {
allowance = big.NewInt(0)
Expand All @@ -228,11 +227,16 @@ func evmSend(
}
}

if feeToken == b.Profile.EthEmptyAddress {
auth.Value = fee
}

// Ask for confirmation
fmt.Println("About to send message:")
tw := table.NewWriter()
tw.SetStyle(table.StyleLight)
tw.AppendHeader(table.Row{"Field", "Value"})
tw.AppendRow(table.Row{"Sender", b.ETHAddress.Hex()})
tw.AppendRow(table.Row{"Receiver", "0x" + common.Bytes2Hex(msg.Receiver)})
tw.AppendRow(table.Row{"Data", "0x" + common.Bytes2Hex(msg.Data)})
tw.AppendRow(table.Row{"Finality", fin.Label})
Expand All @@ -249,6 +253,7 @@ func evmSend(
}

fmt.Println("⏳ Sending message...")
auth.GasLimit = 500_000
tx, err := router.CcipSend(auth, b.Profile.CantonSelector, msg)
if err != nil {
return fmt.Errorf("ccip send: %w", err)
Expand Down
5 changes: 5 additions & 0 deletions examples/cli/internal/evmops/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func EnsureERC20Allowance(
fmt.Println("⏳ Approving...")
opts := *b.EthAuth
opts.Context = ctx
opts.Value = big.NewInt(0)
opts.GasLimit = 0
tx, err := erc20.Approve(&opts, spender, amount)
if err != nil {
return fmt.Errorf("approve ERC20: %w", err)
Expand All @@ -66,6 +68,9 @@ func EnsureERC20Allowance(
return fmt.Errorf("wait mined: %w", err)
}
fmt.Printf("Transaction mined in block: %d\n", receipt.BlockNumber.Uint64())
if receipt.Status != 1 {
return fmt.Errorf("approve transaction reverted (status=0): %s", tx.Hash().Hex())
}

return nil
}
Loading