Skip to content

Commit b07606f

Browse files
committed
fix: push core client
1 parent 70c6a27 commit b07606f

File tree

2 files changed

+3
-102
lines changed

2 files changed

+3
-102
lines changed

universalClient/core/client.go

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
sdk "github.com/cosmos/cosmos-sdk/types"
99
"github.com/pushchain/push-chain-node/universalClient/api"
1010
"github.com/pushchain/push-chain-node/universalClient/chains"
11-
"github.com/pushchain/push-chain-node/universalClient/chains/common"
1211
"github.com/pushchain/push-chain-node/universalClient/config"
1312
"github.com/pushchain/push-chain-node/universalClient/constant"
1413
"github.com/pushchain/push-chain-node/universalClient/db"
@@ -95,9 +94,6 @@ func NewUniversalClient(ctx context.Context, cfg *config.Config) (*UniversalClie
9594
return nil, fmt.Errorf("failed to create Push database: %w", err)
9695
}
9796

98-
// Create TxBuilderFactory that uses chains manager
99-
txBuilderFactory := newChainsTxBuilderFactory(chainsManager)
100-
10197
tssCfg := tss.Config{
10298
ValidatorAddress: cfg.PushValoperAddress,
10399
P2PPrivateKeyHex: cfg.TSSP2PPrivateKeyHex,
@@ -107,7 +103,7 @@ func NewUniversalClient(ctx context.Context, cfg *config.Config) (*UniversalClie
107103
Database: pushDB,
108104
PushCore: pushCore,
109105
Logger: log,
110-
TxBuilderFactory: txBuilderFactory,
106+
Chains: chainsManager,
111107
PushSigner: pushSigner,
112108
}
113109

@@ -207,29 +203,3 @@ func (uc *UniversalClient) Start() error {
207203

208204
return nil
209205
}
210-
211-
// chainsTxBuilderFactory implements OutboundTxBuilderFactory using the chains manager
212-
type chainsTxBuilderFactory struct {
213-
chains *chains.Chains
214-
}
215-
216-
// newChainsTxBuilderFactory creates a new factory that uses the chains manager
217-
func newChainsTxBuilderFactory(chainsManager *chains.Chains) common.OutboundTxBuilderFactory {
218-
return &chainsTxBuilderFactory{
219-
chains: chainsManager,
220-
}
221-
}
222-
223-
// CreateBuilder creates an OutboundTxBuilder for the specified chain
224-
// TODO: Implement actual builder creation using chain clients
225-
func (f *chainsTxBuilderFactory) CreateBuilder(chainID string) (common.OutboundTxBuilder, error) {
226-
// For now, return an error - this needs to be implemented
227-
// The factory should get the chain client from chains manager and create a builder
228-
return nil, fmt.Errorf("outbound tx builder creation not yet implemented for chain %s", chainID)
229-
}
230-
231-
// SupportsChain returns true if this factory can create a builder for the chain
232-
func (f *chainsTxBuilderFactory) SupportsChain(chainID string) bool {
233-
// TODO: Check if chain is available in chains manager
234-
return false
235-
}

universalClient/core/client_test.go

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/pushchain/push-chain-node/universalClient/chains"
87
"github.com/pushchain/push-chain-node/universalClient/config"
98
"github.com/stretchr/testify/assert"
109
"github.com/stretchr/testify/require"
@@ -82,73 +81,5 @@ func TestUniversalClientStruct(t *testing.T) {
8281
})
8382
}
8483

85-
func TestChainsTxBuilderFactory(t *testing.T) {
86-
t.Run("CreateBuilder returns not implemented error", func(t *testing.T) {
87-
factory := newChainsTxBuilderFactory(nil)
88-
89-
builder, err := factory.CreateBuilder("eip155:1")
90-
require.Error(t, err)
91-
assert.Nil(t, builder)
92-
assert.Contains(t, err.Error(), "not yet implemented")
93-
assert.Contains(t, err.Error(), "eip155:1")
94-
})
95-
96-
t.Run("CreateBuilder with different chain IDs", func(t *testing.T) {
97-
factory := newChainsTxBuilderFactory(nil)
98-
99-
testCases := []string{
100-
"eip155:1",
101-
"eip155:97",
102-
"eip155:137",
103-
"solana:mainnet",
104-
}
105-
106-
for _, chainID := range testCases {
107-
builder, err := factory.CreateBuilder(chainID)
108-
require.Error(t, err, "expected error for chain %s", chainID)
109-
assert.Nil(t, builder)
110-
assert.Contains(t, err.Error(), chainID)
111-
}
112-
})
113-
114-
t.Run("SupportsChain returns false", func(t *testing.T) {
115-
factory := newChainsTxBuilderFactory(nil)
116-
117-
testCases := []string{
118-
"eip155:1",
119-
"eip155:97",
120-
"solana:mainnet",
121-
"unknown-chain",
122-
}
123-
124-
for _, chainID := range testCases {
125-
supported := factory.SupportsChain(chainID)
126-
assert.False(t, supported, "expected SupportsChain to return false for %s", chainID)
127-
}
128-
})
129-
130-
t.Run("factory with chains manager", func(t *testing.T) {
131-
// Create a factory with a non-nil chains manager
132-
// Even with a chains manager, the implementation returns not implemented
133-
chainsManager := &chains.Chains{}
134-
factory := newChainsTxBuilderFactory(chainsManager)
135-
136-
builder, err := factory.CreateBuilder("eip155:1")
137-
require.Error(t, err)
138-
assert.Nil(t, builder)
139-
assert.Contains(t, err.Error(), "not yet implemented")
140-
})
141-
}
142-
143-
func TestNewChainsTxBuilderFactory(t *testing.T) {
144-
t.Run("creates factory with nil chains", func(t *testing.T) {
145-
factory := newChainsTxBuilderFactory(nil)
146-
assert.NotNil(t, factory)
147-
})
148-
149-
t.Run("creates factory with chains manager", func(t *testing.T) {
150-
chainsManager := &chains.Chains{}
151-
factory := newChainsTxBuilderFactory(chainsManager)
152-
assert.NotNil(t, factory)
153-
})
154-
}
84+
// Note: Factory tests removed as OutboundTxBuilderFactory has been replaced
85+
// with direct chain client access via Chains.GetClient() and ChainClient.GetTxBuilder()

0 commit comments

Comments
 (0)