fix_: Fill chain ids for bridge (#5751)
This commit is contained in:
parent
5da91fe215
commit
c0d1f11ac2
|
@ -39,14 +39,21 @@ func (tm *TransactionManager) CreateMultiTransactionFromCommand(command *MultiTr
|
||||||
|
|
||||||
multiTransaction := multiTransactionFromCommand(command)
|
multiTransaction := multiTransactionFromCommand(command)
|
||||||
|
|
||||||
// Set network for single chain transactions
|
// Extract network from args
|
||||||
switch multiTransaction.Type {
|
switch multiTransaction.Type {
|
||||||
case MultiTransactionSend, MultiTransactionApprove, MultiTransactionSwap:
|
case MultiTransactionSend, MultiTransactionApprove, MultiTransactionSwap:
|
||||||
if multiTransaction.FromNetworkID == wallet_common.UnknownChainID && len(data) == 1 {
|
if multiTransaction.FromNetworkID == wallet_common.UnknownChainID && len(data) == 1 {
|
||||||
multiTransaction.FromNetworkID = data[0].ChainID
|
multiTransaction.FromNetworkID = data[0].ChainID
|
||||||
}
|
}
|
||||||
case MultiTransactionBridge:
|
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:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported multi transaction type: %v", multiTransaction.Type)
|
return nil, fmt.Errorf("unsupported multi transaction type: %v", multiTransaction.Type)
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,7 @@ func TestCreateMultiTransactionFromCommand(t *testing.T) {
|
||||||
var command *MultiTransactionCommand
|
var command *MultiTransactionCommand
|
||||||
|
|
||||||
// Test types that should get chainID from the data
|
// 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 {
|
for _, mtType := range mtTypes {
|
||||||
fromAmount := hexutil.Big(*big.NewInt(1000000000000000000))
|
fromAmount := hexutil.Big(*big.NewInt(1000000000000000000))
|
||||||
|
@ -339,6 +339,13 @@ func TestCreateMultiTransactionFromCommand(t *testing.T) {
|
||||||
ChainID: 1,
|
ChainID: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if mtType == MultiTransactionBridge {
|
||||||
|
data[0].HopTx = &pathprocessor.HopBridgeTxArgs{
|
||||||
|
ChainID: 1,
|
||||||
|
ChainIDTo: 2,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
multiTransaction, err := tm.CreateMultiTransactionFromCommand(command, data)
|
multiTransaction, err := tm.CreateMultiTransactionFromCommand(command, data)
|
||||||
if mtType > MultiTransactionApprove {
|
if mtType > MultiTransactionApprove {
|
||||||
// Unsupported type
|
// Unsupported type
|
||||||
|
|
Loading…
Reference in New Issue