github.com/status-im/status-go@v1.1.0/services/wallet/router/pathprocessor/multipath_processor.go (about) 1 package pathprocessor 2 3 import ( 4 "math/big" 5 6 "github.com/status-im/status-go/eth-node/types" 7 "github.com/status-im/status-go/transactions" 8 ) 9 10 type MultipathProcessorTxArgs struct { 11 Name string `json:"bridgeName"` 12 ChainID uint64 13 TransferTx *transactions.SendTxArgs 14 HopTx *HopBridgeTxArgs 15 CbridgeTx *CelerBridgeTxArgs 16 ERC721TransferTx *ERC721TxArgs 17 ERC1155TransferTx *ERC1155TxArgs 18 SwapTx *SwapParaswapTxArgs 19 } 20 21 func (t *MultipathProcessorTxArgs) Value() *big.Int { 22 if t.TransferTx != nil && t.TransferTx.To != nil { 23 return t.TransferTx.Value.ToInt() 24 } else if t.HopTx != nil { 25 return t.HopTx.Amount.ToInt() 26 } else if t.CbridgeTx != nil { 27 return t.CbridgeTx.Amount.ToInt() 28 } else if t.ERC721TransferTx != nil { 29 return big.NewInt(1) 30 } else if t.ERC1155TransferTx != nil { 31 return t.ERC1155TransferTx.Amount.ToInt() 32 } 33 34 return ZeroBigIntValue 35 } 36 37 func (t *MultipathProcessorTxArgs) From() types.Address { 38 if t.TransferTx != nil && t.TransferTx.To != nil { 39 return t.TransferTx.From 40 } else if t.HopTx != nil { 41 return t.HopTx.From 42 } else if t.CbridgeTx != nil { 43 return t.CbridgeTx.From 44 } else if t.ERC721TransferTx != nil { 45 return t.ERC721TransferTx.From 46 } else if t.ERC1155TransferTx != nil { 47 return t.ERC1155TransferTx.From 48 } 49 50 return types.HexToAddress("0x0") 51 } 52 53 func (t *MultipathProcessorTxArgs) To() types.Address { 54 if t.TransferTx != nil && t.TransferTx.To != nil { 55 return *t.TransferTx.To 56 } else if t.HopTx != nil { 57 return types.Address(t.HopTx.Recipient) 58 } else if t.CbridgeTx != nil { 59 return types.Address(t.HopTx.Recipient) 60 } else if t.ERC721TransferTx != nil { 61 return types.Address(t.ERC721TransferTx.Recipient) 62 } else if t.ERC1155TransferTx != nil { 63 return types.Address(t.ERC1155TransferTx.Recipient) 64 } 65 66 return types.HexToAddress("0x0") 67 } 68 69 func (t *MultipathProcessorTxArgs) Data() types.HexBytes { 70 if t.TransferTx != nil && t.TransferTx.To != nil { 71 return t.TransferTx.Data 72 } else if t.HopTx != nil { 73 return types.HexBytes("") 74 } else if t.CbridgeTx != nil { 75 return types.HexBytes("") 76 } else if t.ERC721TransferTx != nil { 77 return types.HexBytes("") 78 } else if t.ERC1155TransferTx != nil { 79 return types.HexBytes("") 80 } 81 82 return types.HexBytes("") 83 }