Skip to content

Commit

Permalink
fix_: Fill chain ids for bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuteivist committed Aug 25, 2024
1 parent 5da91fe commit ca3fca4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions services/wallet/transfer/transaction_manager_multitransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ func (tm *TransactionManager) CreateMultiTransactionFromCommand(command *MultiTr

multiTransaction := multiTransactionFromCommand(command)

// Set network for single chain transactions
// Extract network from args
switch multiTransaction.Type {
case MultiTransactionSend, MultiTransactionApprove, MultiTransactionSwap:
if multiTransaction.FromNetworkID == wallet_common.UnknownChainID && len(data) == 1 {
multiTransaction.FromNetworkID = data[0].ChainID
}
case MultiTransactionBridge:
break
if len(data) == 1 && data[0].HopTx != nil {
if multiTransaction.FromNetworkID == wallet_common.UnknownChainID {
multiTransaction.FromNetworkID = data[0].HopTx.ChainID
}
if multiTransaction.ToNetworkID == wallet_common.UnknownChainID {
multiTransaction.ToNetworkID = data[0].HopTx.ChainIDTo
}
}
default:
return nil, fmt.Errorf("unsupported multi transaction type: %v", multiTransaction.Type)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func TestCreateMultiTransactionFromCommand(t *testing.T) {
var command *MultiTransactionCommand

// Test types that should get chainID from the data
mtTypes := []MultiTransactionType{MultiTransactionSend, MultiTransactionApprove, MultiTransactionSwap, MultiTransactionType(7)}
mtTypes := []MultiTransactionType{MultiTransactionSend, MultiTransactionApprove, MultiTransactionSwap, MultiTransactionBridge, MultiTransactionType(7)}

for _, mtType := range mtTypes {
fromAmount := hexutil.Big(*big.NewInt(1000000000000000000))
Expand All @@ -339,6 +339,13 @@ func TestCreateMultiTransactionFromCommand(t *testing.T) {
ChainID: 1,
})

if mtType == MultiTransactionBridge {
data[0].HopTx = &pathprocessor.HopBridgeTxArgs{
ChainID: 1,
ChainIDTo: 2,
}
}

multiTransaction, err := tm.CreateMultiTransactionFromCommand(command, data)
if mtType > MultiTransactionApprove {
// Unsupported type
Expand Down

0 comments on commit ca3fca4

Please sign in to comment.