Skip to content

Commit 29c0ba6

Browse files
committed
chore: cleanup transactor
1 parent efabfdc commit 29c0ba6

File tree

11 files changed

+38
-241
lines changed

11 files changed

+38
-241
lines changed

api/backend.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ type StatusBackend interface {
5353
HashTypedDataV4(typed signercore.TypedData) (types.Hash, error)
5454
SendTransaction(sendArgs wallettypes.SendTxArgs, password string) (hash types.Hash, err error)
5555
SendTransactionWithChainID(chainID uint64, sendArgs wallettypes.SendTxArgs, password string) (hash types.Hash, err error)
56-
SendTransactionWithSignature(sendArgs wallettypes.SendTxArgs, sig []byte) (hash types.Hash, err error)
5756
SignHash(hexEncodedHash string) (string, error)
5857
SignMessage(rpcParams personal.SignParams) (types.HexBytes, error)
5958
SignTypedData(typed typeddata.TypedData, address string, password string) (types.HexBytes, error)

api/geth_backend.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
"github.com/imdario/mergo"
2424

25-
"github.com/ethereum/go-ethereum/common"
2625
"github.com/ethereum/go-ethereum/common/hexutil"
2726
ethcrypto "github.com/ethereum/go-ethereum/crypto"
2827
signercore "github.com/ethereum/go-ethereum/signer/core/apitypes"
@@ -1938,8 +1937,7 @@ func (b *GethStatusBackend) startNode(config *params.NodeConfig) (err error) {
19381937
return
19391938
}
19401939

1941-
b.transactor.SetNetworkID(config.NetworkID)
1942-
b.transactor.SetRPC(b.statusNode.RPCClient(), rpc.DefaultCallTimeout)
1940+
b.transactor.SetEthClientGetter(b.statusNode.RPCClient(), rpc.DefaultCallTimeout)
19431941

19441942
signal.SendNodeStarted()
19451943

@@ -1994,15 +1992,10 @@ func (b *GethStatusBackend) CallInProcessRPC(inputJSON string) string {
19941992
return b.statusNode.CallInProcessRPC(inputJSON)
19951993
}
19961994

1995+
// @deprecated
19971996
// SendTransaction creates a new transaction and waits until it's complete.
19981997
func (b *GethStatusBackend) SendTransaction(sendArgs wallettypes.SendTxArgs, password string) (hash types.Hash, err error) {
1999-
verifiedAccount, err := b.getVerifiedWalletAccount(sendArgs.From.String(), password)
2000-
if err != nil {
2001-
return hash, err
2002-
}
2003-
2004-
hash, _, err = b.transactor.SendTransaction(sendArgs, verifiedAccount, -1)
2005-
return hash, err
1998+
return types.Hash{}, errors.New("method not supported")
20061999
}
20072000

20082001
func (b *GethStatusBackend) SendTransactionWithChainID(chainID uint64, sendArgs wallettypes.SendTxArgs, password string) (hash types.Hash, err error) {
@@ -2015,18 +2008,15 @@ func (b *GethStatusBackend) SendTransactionWithChainID(chainID uint64, sendArgs
20152008
return hash, err
20162009
}
20172010

2011+
// @deprecated
20182012
func (b *GethStatusBackend) SendTransactionWithSignature(sendArgs wallettypes.SendTxArgs, sig []byte) (hash types.Hash, err error) {
2019-
txWithSignature, err := b.transactor.BuildTransactionWithSignature(b.transactor.NetworkID(), sendArgs, sig)
2020-
if err != nil {
2021-
return hash, err
2022-
}
2023-
2024-
return b.transactor.SendTransactionWithSignature(common.Address(sendArgs.From), sendArgs.Symbol, txWithSignature)
2013+
return types.Hash{}, errors.New("method not supported")
20252014
}
20262015

2016+
// @deprecated
20272017
// HashTransaction validate the transaction and returns new sendArgs and the transaction hash.
20282018
func (b *GethStatusBackend) HashTransaction(sendArgs wallettypes.SendTxArgs) (wallettypes.SendTxArgs, types.Hash, error) {
2029-
return b.transactor.HashTransaction(sendArgs)
2019+
return wallettypes.SendTxArgs{}, types.Hash{}, errors.New("method not supported")
20302020
}
20312021

20322022
// SignMessage checks the pwd vs the selected account and passes on the signParams

node/get_status_node.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ func (n *StatusNode) createAndStartTokenManager() error {
389389

390390
func (n *StatusNode) setupRPCClient() (err error) {
391391
config := rpc.ClientConfig{
392-
UpstreamChainID: n.config.NetworkID,
393392
Networks: n.config.Networks,
394393
DB: n.appDB,
395394
AccountsPublisher: n.accountsPublisher,

rpc/client.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ type EthClientGetter interface {
6262
// Client manages RPC clients for multiple chains with
6363
// multiple providers for each chain.
6464
type Client struct {
65-
UpstreamChainID uint64
66-
6765
rpcClientsMutex sync.RWMutex
6866
rpcClients map[uint64]chain.ClientInterface
6967
rpsLimiterMutex sync.RWMutex
@@ -84,7 +82,6 @@ var verifProxyInitFn func(c *Client)
8482

8583
// ClientConfig holds the configuration for initializing a new Client.
8684
type ClientConfig struct {
87-
UpstreamChainID uint64
8885
Networks []params.Network
8986
DB *sql.DB
9087
AccountsPublisher *pubsub.Publisher
@@ -117,8 +114,6 @@ func NewClient(config ClientConfig) (*Client, error) {
117114
signalsTransmitter: NewSignalsTransmitter(networkManager.GetPublisher()),
118115
}
119116

120-
c.UpstreamChainID = config.UpstreamChainID
121-
122117
if verifProxyInitFn != nil {
123118
verifProxyInitFn(&c)
124119
}

rpc/client_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ func TestGetClientsUsingCache(t *testing.T) {
9898
security.NewSensitiveString(password))
9999

100100
config := ClientConfig{
101-
UpstreamChainID: 1,
102-
Networks: networks,
103-
DB: db,
101+
Networks: networks,
102+
DB: db,
104103
}
105104

106105
c, err := NewClient(config)

services/ens/api_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ func setupTestAPI(t *testing.T) (*API, func()) {
3535
_ = client
3636

3737
config := statusRPC.ClientConfig{
38-
UpstreamChainID: 1,
39-
Networks: nil,
40-
DB: db,
38+
Networks: nil,
39+
DB: db,
4140
}
4241
rpcClient, err := statusRPC.NewClient(config)
4342
require.NoError(t, err)

services/wallet/api.go

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -152,45 +152,12 @@ func (api *API) GetTokens(ctx context.Context, chainID uint64) ([]*tokenTypes.To
152152
return rst, err
153153
}
154154

155-
// @deprecated
156-
func (api *API) GetCustomTokens(ctx context.Context) ([]*tokenTypes.Token, error) {
157-
logutils.ZapLogger().Debug("call to get custom tokens")
158-
rst, err := api.s.tokenManager.GetCustoms(true)
159-
logutils.ZapLogger().Debug("result from database for custom tokens", zap.Int("len", len(rst)))
160-
return rst, err
161-
}
162-
163155
func (api *API) DiscoverToken(ctx context.Context, chainID uint64, address common.Address) (*tokenTypes.Token, error) {
164156
logutils.ZapLogger().Debug("call to get discover token")
165157
token, err := api.s.tokenManager.DiscoverToken(ctx, chainID, address)
166158
return token, err
167159
}
168160

169-
func (api *API) AddCustomToken(ctx context.Context, token tokenTypes.Token) error {
170-
logutils.ZapLogger().Debug("call to create or edit custom token")
171-
if token.ChainID == 0 {
172-
token.ChainID = api.s.rpcClient.UpstreamChainID
173-
}
174-
err := api.s.tokenManager.UpsertCustom(token)
175-
logutils.ZapLogger().Debug("result from database for create or edit custom token", zap.Error(err))
176-
return err
177-
}
178-
179-
// @deprecated
180-
func (api *API) DeleteCustomToken(ctx context.Context, address common.Address) error {
181-
logutils.ZapLogger().Debug("call to remove custom token")
182-
err := api.s.tokenManager.DeleteCustom(api.s.rpcClient.UpstreamChainID, address)
183-
logutils.ZapLogger().Debug("result from database for remove custom token", zap.Error(err))
184-
return err
185-
}
186-
187-
func (api *API) DeleteCustomTokenByChainID(ctx context.Context, chainID uint64, address common.Address) error {
188-
logutils.ZapLogger().Debug("call to remove custom token")
189-
err := api.s.tokenManager.DeleteCustom(chainID, address)
190-
logutils.ZapLogger().Debug("result from database for remove custom token", zap.Error(err))
191-
return err
192-
}
193-
194161
// @deprecated
195162
// Not used by status-desktop anymore
196163
func (api *API) GetPendingTransactions(ctx context.Context) ([]*transactions.PendingTransaction, error) {

services/wallet/api_impl_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ func TestAPI_GetAddressDetails(t *testing.T) {
6868
require.NotEmpty(t, networks)
6969

7070
config := rpc.ClientConfig{
71-
UpstreamChainID: chainID,
72-
Networks: networks,
73-
DB: appDB,
71+
Networks: networks,
72+
DB: appDB,
7473
}
7574
c, err := rpc.NewClient(config)
7675
require.NoError(t, err)

services/wallet/router/router_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ func setupRouter(t *testing.T) (*Router, func()) {
5252
db, cleanTmpDb := setupTestNetworkDB(t)
5353

5454
config := rpc.ClientConfig{
55-
UpstreamChainID: 1,
56-
Networks: defaultNetworks,
57-
DB: db,
55+
Networks: defaultNetworks,
56+
DB: db,
5857
}
5958
client, _ := rpc.NewClient(config)
6059

0 commit comments

Comments
 (0)