@@ -5,18 +5,11 @@ import (
55 "math/big"
66
77 "github.com/ethereum/go-ethereum"
8- "github.com/ethereum/go-ethereum/accounts/abi/bind"
98 "github.com/ethereum/go-ethereum/common"
10- "github.com/ethereum/go-ethereum/common/hexutil"
119 ethTypes "github.com/ethereum/go-ethereum/core/types"
12- "github.com/status-im/status-go/accounts-management/generator"
13- "github.com/status-im/status-go/crypto/types"
14- "github.com/status-im/status-go/params"
1510 "github.com/status-im/status-go/rpc"
16- "github.com/status-im/status-go/services/utils"
1711 pathProcessorCommon "github.com/status-im/status-go/services/wallet/router/pathprocessor/common"
1812 "github.com/status-im/status-go/services/wallet/thirdparty"
19- tokenTypes "github.com/status-im/status-go/services/wallet/token/types"
2013 "github.com/status-im/status-go/services/wallet/wallettypes"
2114 "github.com/status-im/status-go/transactions"
2215)
@@ -33,14 +26,6 @@ type NFTHandler interface {
3326
3427 EstimateGas (params ProcessorInputParams , input []byte , handlerName string ) (uint64 , error )
3528
36- SendOrBuild (
37- transactor transactions.TransactorIface ,
38- rpcClient rpc.ClientInterface ,
39- sendArgs * MultipathProcessorTxArgs ,
40- signerFn bind.SignerFn ,
41- lastUsedNonce int64 ,
42- ) (* ethTypes.Transaction , error )
43-
4429 BuildTransactionV2 (
4530 transactor transactions.TransactorIface ,
4631 sendArgs * wallettypes.SendTxArgs ,
@@ -97,113 +82,3 @@ func (h *BaseNFTHandler) EstimateGas(params ProcessorInputParams, input []byte,
9782
9883 return uint64 (float64 (estimation ) * pathProcessorCommon .IncreaseEstimatedGasFactor ), nil
9984}
100-
101- func (h * BaseNFTHandler ) PrepareNonce (sendArgs * MultipathProcessorTxArgs , lastUsedNonce int64 ) (uint64 , error ) {
102- var nonce uint64
103- var err error
104- if lastUsedNonce < 0 {
105- nonce , err = h .transactor .NextNonce (context .Background (), h .rpcClient , sendArgs .ChainID , sendArgs .ERC721TransferTx .From )
106- if err != nil {
107- return 0 , err
108- }
109- } else {
110- nonce = uint64 (lastUsedNonce ) + 1
111- }
112-
113- argNonce := hexutil .Uint64 (nonce )
114- sendArgs .ERC721TransferTx .Nonce = & argNonce
115- return nonce , nil
116- }
117-
118- func (h * BaseNFTHandler ) SendOrBuildCollectible (
119- sendArgs * MultipathProcessorTxArgs ,
120- lastUsedNonce int64 ,
121- packDataFn func (ProcessorInputParams ) ([]byte , error ),
122- targetContractID * thirdparty.ContractID , // nil for regular ERC721, specify for special contracts
123- ) (* ethTypes.Transaction , error ) {
124- from := common .Address (sendArgs .ERC721TransferTx .From )
125-
126- inputParams := ProcessorInputParams {
127- FromChain : & params.Network {ChainID : sendArgs .ChainID },
128- FromAddr : from ,
129- ToAddr : sendArgs .ERC721TransferTx .Recipient ,
130- FromToken : & tokenTypes.Token {
131- Symbol : sendArgs .ERC721TransferTx .TokenID .String (),
132- Address : common .Address (* sendArgs .ERC721TransferTx .To ),
133- },
134- }
135-
136- nonce , err := h .PrepareNonce (sendArgs , lastUsedNonce )
137- if err != nil {
138- return nil , err
139- }
140-
141- data , err := packDataFn (inputParams )
142- if err != nil {
143- return nil , err
144- }
145-
146- var contractAddress * types.Address
147- if targetContractID != nil {
148- // For special contracts (CryptoKitties, CryptoPunks) force use their address
149- addr := types .Address (targetContractID .Address )
150- contractAddress = & addr
151- } else {
152- contractAddress = sendArgs .ERC721TransferTx .To
153- }
154-
155- tx , _ , err := h .transactor .ValidateAndBuildTransaction (sendArgs .ChainID , wallettypes.SendTxArgs {
156- From : sendArgs .ERC721TransferTx .From ,
157- To : contractAddress ,
158- Gas : sendArgs .ERC721TransferTx .Gas ,
159- GasPrice : sendArgs .ERC721TransferTx .GasPrice ,
160- Value : (* hexutil .Big )(big .NewInt (0 )),
161- Nonce : sendArgs .ERC721TransferTx .Nonce ,
162- Data : types .HexBytes (data ),
163- }, int64 (nonce - 1 ))
164-
165- if err != nil {
166- return nil , err
167- }
168-
169- err = h .transactor .StoreAndTrackPendingTx (from , sendArgs .ERC721TransferTx .Symbol , sendArgs .ChainID , tx )
170- if err != nil {
171- return nil , err
172- }
173-
174- return tx , nil
175- }
176-
177- func (h * BaseNFTHandler ) Send (
178- sendArgs * MultipathProcessorTxArgs ,
179- lastUsedNonce int64 ,
180- verifiedAccount * generator.Account ,
181- handler NFTHandler ,
182- ) (types.Hash , uint64 , error ) {
183- tx , err := handler .SendOrBuild (
184- h .transactor ,
185- h .rpcClient ,
186- sendArgs ,
187- utils .GetSigner (sendArgs .ChainID , sendArgs .ERC721TransferTx .From , verifiedAccount .PrivateKey ()),
188- lastUsedNonce ,
189- )
190- if err != nil {
191- return types.Hash {}, 0 , err
192- }
193- return types .Hash (tx .Hash ()), tx .Nonce (), nil
194- }
195-
196- func (h * BaseNFTHandler ) BuildTransaction (
197- sendArgs * MultipathProcessorTxArgs ,
198- lastUsedNonce int64 ,
199- handler NFTHandler ,
200- ) (* ethTypes.Transaction , uint64 , error ) {
201- tx , err := handler .SendOrBuild (
202- h .transactor ,
203- h .rpcClient ,
204- sendArgs ,
205- nil ,
206- lastUsedNonce ,
207- )
208- return tx , tx .Nonce (), err
209- }
0 commit comments