Skip to content

Commit a8589ec

Browse files
committed
chore: remove unused methods from path processors
- Eliminated `Send` and `BuildTransaction` methods. - Updated related tests to reflect the removal of these methods. - Codebase cleaned up accordingly.
1 parent fcb9a07 commit a8589ec

25 files changed

+0
-833
lines changed

services/wallet/router/pathprocessor/multipath_processor.go

Lines changed: 0 additions & 75 deletions
This file was deleted.

services/wallet/router/pathprocessor/nft_handler.go

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
}

services/wallet/router/pathprocessor/nft_handler_cryptokitties.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"strings"
55

66
"github.com/ethereum/go-ethereum/accounts/abi"
7-
"github.com/ethereum/go-ethereum/accounts/abi/bind"
87
"github.com/ethereum/go-ethereum/common"
98
ethTypes "github.com/ethereum/go-ethereum/core/types"
109
"github.com/status-im/status-go/contracts/cryptokitties"
@@ -61,21 +60,6 @@ func (h *CryptoKittiesHandler) PackTxInputData(params ProcessorInputParams) ([]b
6160
return parsedABI.Pack(cryptoKittiesFunctionNameTransfer, params.ToAddr, tokenID)
6261
}
6362

64-
func (h *CryptoKittiesHandler) SendOrBuild(
65-
transactor transactions.TransactorIface,
66-
rpcClient rpc.ClientInterface,
67-
sendArgs *MultipathProcessorTxArgs,
68-
signerFn bind.SignerFn,
69-
lastUsedNonce int64,
70-
) (*ethTypes.Transaction, error) {
71-
return h.SendOrBuildCollectible(
72-
sendArgs,
73-
lastUsedNonce,
74-
h.PackTxInputData,
75-
&CryptoKittiesContractID, // Force use CryptoKitties address
76-
)
77-
}
78-
7963
func (h *CryptoKittiesHandler) BuildTransactionV2(
8064
transactor transactions.TransactorIface,
8165
sendArgs *wallettypes.SendTxArgs,

services/wallet/router/pathprocessor/nft_handler_cryptokitties_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,6 @@ func TestCryptoKittiesHandler_WithMocks(t *testing.T) {
8989
handler := NewCryptoKittiesHandler(mockRPCClient, mockTransactor)
9090

9191
testTx := ethTypes.NewTransaction(1, CryptoKittiesContractID.Address, big.NewInt(0), 21000, big.NewInt(1000000000), []byte{})
92-
contractAddress := types.Address(CryptoKittiesContractID.Address)
93-
94-
// Test SendOrBuild
95-
sendArgs := &MultipathProcessorTxArgs{
96-
ChainID: walletCommon.EthereumMainnet,
97-
ERC721TransferTx: &ERC721TxArgs{
98-
SendTxArgs: wallettypes.SendTxArgs{From: types.HexToAddress("0x1234567890123456789012345678901234567890"), To: &contractAddress},
99-
TokenID: (*hexutil.Big)(big.NewInt(456)),
100-
Recipient: common.HexToAddress("0x5678901234567890123456789012345678901234"),
101-
},
102-
}
103-
104-
mockTransactor.EXPECT().NextNonce(gomock.Any(), mockRPCClient, walletCommon.EthereumMainnet, gomock.Any()).Return(uint64(1), nil)
105-
mockTransactor.EXPECT().ValidateAndBuildTransaction(walletCommon.EthereumMainnet, gomock.Any(), int64(0)).Return(testTx, uint64(1), nil)
106-
mockTransactor.EXPECT().StoreAndTrackPendingTx(gomock.Any(), gomock.Any(), walletCommon.EthereumMainnet, testTx).Return(nil)
107-
108-
tx, err := handler.SendOrBuild(mockTransactor, mockRPCClient, sendArgs, nil, -1)
109-
require.NoError(t, err)
110-
assert.Equal(t, testTx, tx)
11192

11293
// Test BuildTransactionV2
11394
buildArgs := &wallettypes.SendTxArgs{

services/wallet/router/pathprocessor/nft_handler_cryptopunks.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"strings"
55

66
"github.com/ethereum/go-ethereum/accounts/abi"
7-
"github.com/ethereum/go-ethereum/accounts/abi/bind"
87
"github.com/ethereum/go-ethereum/common"
98
ethTypes "github.com/ethereum/go-ethereum/core/types"
109
"github.com/status-im/status-go/contracts/cryptopunks"
@@ -61,21 +60,6 @@ func (h *CryptoPunksHandler) PackTxInputData(params ProcessorInputParams) ([]byt
6160
return parsedABI.Pack(cryptoPunksHandlerFunctionNameTransferPunk, params.ToAddr, tokenID)
6261
}
6362

64-
func (h *CryptoPunksHandler) SendOrBuild(
65-
transactor transactions.TransactorIface,
66-
rpcClient rpc.ClientInterface,
67-
sendArgs *MultipathProcessorTxArgs,
68-
signerFn bind.SignerFn,
69-
lastUsedNonce int64,
70-
) (*ethTypes.Transaction, error) {
71-
return h.SendOrBuildCollectible(
72-
sendArgs,
73-
lastUsedNonce,
74-
h.PackTxInputData,
75-
&CryptoPunksContractID, // Force use CryptoPunks address
76-
)
77-
}
78-
7963
func (h *CryptoPunksHandler) BuildTransactionV2(
8064
transactor transactions.TransactorIface,
8165
sendArgs *wallettypes.SendTxArgs,

services/wallet/router/pathprocessor/nft_handler_cryptopunks_test.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,6 @@ func TestCryptoPunksHandler_WithMocks(t *testing.T) {
7777
handler := NewCryptoPunksHandler(mockRPCClient, mockTransactor)
7878

7979
testTx := ethTypes.NewTransaction(1, CryptoPunksContractID.Address, big.NewInt(0), 21000, big.NewInt(1000000000), []byte{})
80-
contractAddress := types.Address(CryptoPunksContractID.Address)
81-
82-
// Test SendOrBuild
83-
sendArgs := &MultipathProcessorTxArgs{
84-
ChainID: walletCommon.EthereumMainnet,
85-
ERC721TransferTx: &ERC721TxArgs{
86-
SendTxArgs: wallettypes.SendTxArgs{From: types.HexToAddress("0x1234567890123456789012345678901234567890"), To: &contractAddress},
87-
TokenID: (*hexutil.Big)(big.NewInt(123)),
88-
Recipient: common.HexToAddress("0x5678901234567890123456789012345678901234"),
89-
},
90-
}
91-
92-
mockTransactor.EXPECT().NextNonce(gomock.Any(), mockRPCClient, walletCommon.EthereumMainnet, gomock.Any()).Return(uint64(1), nil)
93-
mockTransactor.EXPECT().ValidateAndBuildTransaction(walletCommon.EthereumMainnet, gomock.Any(), int64(0)).Return(testTx, uint64(1), nil)
94-
mockTransactor.EXPECT().StoreAndTrackPendingTx(gomock.Any(), gomock.Any(), walletCommon.EthereumMainnet, testTx).Return(nil)
95-
96-
tx, err := handler.SendOrBuild(mockTransactor, mockRPCClient, sendArgs, nil, -1)
97-
require.NoError(t, err)
98-
assert.Equal(t, testTx, tx)
9980

10081
// Test BuildTransactionV2
10182
buildArgs := &wallettypes.SendTxArgs{

0 commit comments

Comments
 (0)