exchanges: shift GetDefaultConfig wrapper function to exchange.go (#1472)

* Shift wrapper function GetDefaultConfig to exchange.Base method definition, to ensure set defaults doesn't get called twice and to reduce code

* rm alphapoint bootstrap method as is defined as exchange.Base method

* add tests

* glorious: make it a function and make it IBOTEXCHANGE

---------

Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2024-04-12 16:15:43 +10:00
committed by GitHub
parent 98eae1e0ce
commit 9657a570dd
39 changed files with 234 additions and 616 deletions

View File

@@ -1943,3 +1943,35 @@ func (b *Base) Bootstrap(_ context.Context) (continueBootstrap bool, err error)
func (b *Base) IsVerbose() bool {
return b.Verbose
}
// GetDefaultConfig returns a default exchange config
func GetDefaultConfig(ctx context.Context, exch IBotExchange) (*config.Exchange, error) {
if exch == nil {
return nil, errExchangeIsNil
}
if exch.GetName() == "" {
exch.SetDefaults()
}
b := exch.GetBase()
exchCfg, err := b.GetStandardConfig()
if err != nil {
return nil, err
}
err = b.SetupDefaults(exchCfg)
if err != nil {
return nil, err
}
if b.Features.Supports.RESTCapabilities.AutoPairUpdates {
err = exch.UpdateTradablePairs(ctx, true)
if err != nil {
return nil, err
}
}
return exchCfg, nil
}