@@ -8,11 +8,11 @@ import (
8
8
9
9
"github.com/go-chi/chi"
10
10
"github.com/sirupsen/logrus"
11
- "github.com/stellar/go/clients/horizonclient"
12
11
supporthttp "github.com/stellar/go/support/http"
13
12
"github.com/stellar/go/support/log"
14
13
"github.com/stellar/go/support/render/health"
15
14
"github.com/stellar/go/xdr"
15
+
16
16
"github.com/stellar/wallet-backend/internal/apptracker"
17
17
"github.com/stellar/wallet-backend/internal/data"
18
18
"github.com/stellar/wallet-backend/internal/db"
@@ -60,7 +60,6 @@ type Configs struct {
60
60
NetworkPassphrase string
61
61
MaxSponsoredBaseReserves int
62
62
BaseFee int
63
- HorizonClientURL string
64
63
DistributionAccountSignatureClient signing.SignatureClient
65
64
ChannelAccountSignatureClient signing.SignatureClient
66
65
// TSS
@@ -150,9 +149,10 @@ func initHandlerDeps(cfg Configs) (handlerDeps, error) {
150
149
return handlerDeps {}, fmt .Errorf ("instantiating stellar signature verifier: %w" , err )
151
150
}
152
151
153
- horizonClient := horizonclient.Client {
154
- HorizonURL : cfg .HorizonClientURL ,
155
- HTTP : & http.Client {Timeout : 40 * time .Second },
152
+ httpClient := http.Client {Timeout : time .Duration (30 * time .Second )}
153
+ rpcService , err := services .NewRPCService (cfg .RPCURL , & httpClient )
154
+ if err != nil {
155
+ return handlerDeps {}, fmt .Errorf ("instantiating rpc service: %w" , err )
156
156
}
157
157
158
158
accountService , err := services .NewAccountService (models )
@@ -163,7 +163,7 @@ func initHandlerDeps(cfg Configs) (handlerDeps, error) {
163
163
accountSponsorshipService , err := services .NewAccountSponsorshipService (services.AccountSponsorshipServiceOptions {
164
164
DistributionAccountSignatureClient : cfg .DistributionAccountSignatureClient ,
165
165
ChannelAccountSignatureClient : cfg .ChannelAccountSignatureClient ,
166
- HorizonClient : & horizonClient ,
166
+ RPCService : rpcService ,
167
167
MaxSponsoredBaseReserves : cfg .MaxSponsoredBaseReserves ,
168
168
BaseFee : int64 (cfg .BaseFee ),
169
169
Models : models ,
@@ -178,50 +178,31 @@ func initHandlerDeps(cfg Configs) (handlerDeps, error) {
178
178
return handlerDeps {}, fmt .Errorf ("instantiating payment service: %w" , err )
179
179
}
180
180
181
- channelAccountService , err := services .NewChannelAccountService (services.ChannelAccountServiceOptions {
182
- DB : dbConnectionPool ,
183
- HorizonClient : & horizonClient ,
184
- BaseFee : int64 (cfg .BaseFee ),
185
- DistributionAccountSignatureClient : cfg .DistributionAccountSignatureClient ,
186
- ChannelAccountStore : store .NewChannelAccountModel (dbConnectionPool ),
187
- PrivateKeyEncrypter : & signingutils.DefaultPrivateKeyEncrypter {},
188
- EncryptionPassphrase : cfg .EncryptionPassphrase ,
189
- })
190
- if err != nil {
191
- return handlerDeps {}, fmt .Errorf ("instantiating channel account service: %w" , err )
192
- }
193
- go ensureChannelAccounts (channelAccountService , int64 (cfg .NumberOfChannelAccounts ))
194
-
195
181
// TSS setup
196
182
tssTxService , err := tssservices .NewTransactionService (tssservices.TransactionServiceOptions {
197
183
DistributionAccountSignatureClient : cfg .DistributionAccountSignatureClient ,
198
184
ChannelAccountSignatureClient : cfg .ChannelAccountSignatureClient ,
199
- HorizonClient : & horizonClient ,
185
+ RPCService : rpcService ,
200
186
BaseFee : int64 (cfg .BaseFee ),
201
187
})
202
188
203
189
if err != nil {
204
190
return handlerDeps {}, fmt .Errorf ("instantiating tss transaction service: %w" , err )
205
191
}
206
- httpClient := http.Client {Timeout : time .Duration (30 * time .Second )}
207
- rpcService , err := services .NewRPCService (cfg .RPCURL , & httpClient )
208
- if err != nil {
209
- return handlerDeps {}, fmt .Errorf ("instantiating rpc service: %w" , err )
210
- }
211
192
212
- store , err := tssstore .NewStore (dbConnectionPool )
193
+ tssStore , err := tssstore .NewStore (dbConnectionPool )
213
194
if err != nil {
214
195
return handlerDeps {}, fmt .Errorf ("instantiating tss store: %w" , err )
215
196
}
216
197
txManager := tssservices .NewTransactionManager (tssservices.TransactionManagerConfigs {
217
198
TxService : tssTxService ,
218
199
RPCService : rpcService ,
219
- Store : store ,
200
+ Store : tssStore ,
220
201
})
221
202
222
203
rpcCallerChannel := tsschannel .NewRPCCallerChannel (tsschannel.RPCCallerChannelConfigs {
223
204
TxManager : txManager ,
224
- Store : store ,
205
+ Store : tssStore ,
225
206
MaxBufferSize : cfg .RPCCallerServiceChannelBufferSize ,
226
207
MaxWorkers : cfg .RPCCallerServiceChannelMaxWorkers ,
227
208
})
@@ -245,7 +226,7 @@ func initHandlerDeps(cfg Configs) (handlerDeps, error) {
245
226
httpClient = http.Client {Timeout : time .Duration (30 * time .Second )}
246
227
webhookChannel := tsschannel .NewWebhookChannel (tsschannel.WebhookChannelConfigs {
247
228
HTTPClient : & httpClient ,
248
- Store : store ,
229
+ Store : tssStore ,
249
230
MaxBufferSize : cfg .WebhookHandlerServiceChannelMaxBufferSize ,
250
231
MaxWorkers : cfg .WebhookHandlerServiceChannelMaxWorkers ,
251
232
MaxRetries : cfg .WebhookHandlerServiceChannelMaxRetries ,
@@ -263,11 +244,25 @@ func initHandlerDeps(cfg Configs) (handlerDeps, error) {
263
244
errorJitterChannel .SetRouter (router )
264
245
errorNonJitterChannel .SetRouter (router )
265
246
266
- poolPopulator , err := tssservices .NewPoolPopulator (router , store , rpcService )
247
+ poolPopulator , err := tssservices .NewPoolPopulator (router , tssStore , rpcService )
267
248
if err != nil {
268
249
return handlerDeps {}, fmt .Errorf ("instantiating tss pool populator" )
269
250
}
270
251
252
+ channelAccountService , err := services .NewChannelAccountService (services.ChannelAccountServiceOptions {
253
+ DB : dbConnectionPool ,
254
+ RPCService : rpcService ,
255
+ BaseFee : int64 (cfg .BaseFee ),
256
+ DistributionAccountSignatureClient : cfg .DistributionAccountSignatureClient ,
257
+ ChannelAccountStore : store .NewChannelAccountModel (dbConnectionPool ),
258
+ PrivateKeyEncrypter : & signingutils.DefaultPrivateKeyEncrypter {},
259
+ EncryptionPassphrase : cfg .EncryptionPassphrase ,
260
+ })
261
+ if err != nil {
262
+ return handlerDeps {}, fmt .Errorf ("instantiating channel account service: %w" , err )
263
+ }
264
+ go ensureChannelAccounts (channelAccountService , int64 (cfg .NumberOfChannelAccounts ))
265
+
271
266
return handlerDeps {
272
267
Models : models ,
273
268
SignatureVerifier : signatureVerifier ,
@@ -284,7 +279,7 @@ func initHandlerDeps(cfg Configs) (handlerDeps, error) {
284
279
WebhookChannel : webhookChannel ,
285
280
TSSRouter : router ,
286
281
PoolPopulator : poolPopulator ,
287
- TSSStore : store ,
282
+ TSSStore : tssStore ,
288
283
TSSTransactionService : tssTxService ,
289
284
}, nil
290
285
}
0 commit comments