restucturization of recipients payment methods
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
This commit is contained in:
69
api/gateway/chain/internal/service/gateway/options.go
Normal file
69
api/gateway/chain/internal/service/gateway/options.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/tech/sendico/gateway/chain/internal/keymanager"
|
||||
"github.com/tech/sendico/gateway/chain/internal/service/gateway/shared"
|
||||
clockpkg "github.com/tech/sendico/pkg/clock"
|
||||
)
|
||||
|
||||
// Option configures the Service.
|
||||
type Option func(*Service)
|
||||
|
||||
// WithKeyManager configures the service key manager.
|
||||
func WithKeyManager(manager keymanager.Manager) Option {
|
||||
return func(s *Service) {
|
||||
s.keyManager = manager
|
||||
}
|
||||
}
|
||||
|
||||
// WithTransferExecutor configures the executor responsible for on-chain submissions.
|
||||
func WithTransferExecutor(executor TransferExecutor) Option {
|
||||
return func(s *Service) {
|
||||
s.executor = executor
|
||||
}
|
||||
}
|
||||
|
||||
// WithNetworks configures supported blockchain networks.
|
||||
func WithNetworks(networks []shared.Network) Option {
|
||||
return func(s *Service) {
|
||||
if len(networks) == 0 {
|
||||
return
|
||||
}
|
||||
if s.networks == nil {
|
||||
s.networks = make(map[string]shared.Network, len(networks))
|
||||
}
|
||||
for _, network := range networks {
|
||||
if network.Name == "" {
|
||||
continue
|
||||
}
|
||||
clone := network
|
||||
if clone.TokenConfigs == nil {
|
||||
clone.TokenConfigs = []shared.TokenContract{}
|
||||
}
|
||||
for i := range clone.TokenConfigs {
|
||||
clone.TokenConfigs[i].Symbol = strings.ToUpper(strings.TrimSpace(clone.TokenConfigs[i].Symbol))
|
||||
clone.TokenConfigs[i].ContractAddress = strings.ToLower(strings.TrimSpace(clone.TokenConfigs[i].ContractAddress))
|
||||
}
|
||||
clone.Name = strings.ToLower(strings.TrimSpace(clone.Name))
|
||||
s.networks[clone.Name] = clone
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithServiceWallet configures the service wallet binding.
|
||||
func WithServiceWallet(wallet shared.ServiceWallet) Option {
|
||||
return func(s *Service) {
|
||||
s.serviceWallet = wallet
|
||||
}
|
||||
}
|
||||
|
||||
// WithClock overrides the service clock.
|
||||
func WithClock(clk clockpkg.Clock) Option {
|
||||
return func(s *Service) {
|
||||
if clk != nil {
|
||||
s.clock = clk
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user