From 07f26aed203de82e86313081aa6cbd5e9ca2529f Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Mon, 23 Sep 2024 09:15:24 +0200 Subject: [PATCH] feat_: send tx args type extended with new properties Added props: - `Version` used to differ old and new usage - `ValueOut` - `FromChainID` - `ToChainID` - `FromTokenID` - `ToTokenID` - `ToContractAddress` - `SlippagePercentage` --- transactions/types.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/transactions/types.go b/transactions/types.go index cab661892..12f1b300b 100644 --- a/transactions/types.go +++ b/transactions/types.go @@ -15,6 +15,13 @@ import ( wallet_common "github.com/status-im/status-go/services/wallet/common" ) +type SendTxArgsVersion uint + +const ( + SendTxArgsVersion0 SendTxArgsVersion = 0 + SendTxArgsVersion1 SendTxArgsVersion = 1 +) + var ( // ErrInvalidSendTxArgs is returned when the structure of SendTxArgs is ambigious. ErrInvalidSendTxArgs = errors.New("transaction arguments are invalid") @@ -41,6 +48,8 @@ type GasCalculator interface { // This struct is based on go-ethereum's type in internal/ethapi/api.go, but we have freedom // over the exact layout of this struct. type SendTxArgs struct { + Version SendTxArgsVersion `json:"version"` + From types.Address `json:"from"` To *types.Address `json:"to"` Gas *hexutil.Uint64 `json:"gas"` @@ -55,9 +64,17 @@ type SendTxArgs struct { Input types.HexBytes `json:"input"` Data types.HexBytes `json:"data"` - // additional data - MultiTransactionID wallet_common.MultiTransactionIDType - Symbol string + // additional data - version SendTxArgsVersion0 + MultiTransactionID wallet_common.MultiTransactionIDType `json:"multiTransactionID"` + Symbol string `json:"-"` + // additional data - version SendTxArgsVersion1 + ValueOut *hexutil.Big `json:"-"` + FromChainID uint64 `json:"-"` + ToChainID uint64 `json:"-"` + FromTokenID string `json:"-"` + ToTokenID string `json:"-"` + ToContractAddress types.Address `json:"-"` // represents address of the contract that needs to be used in order to send assets, like ERC721 or ERC1155 tx + SlippagePercentage float32 `json:"-"` } // Valid checks whether this structure is filled in correctly.