github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/stellar/remote/serverconfig.go (about) 1 package remote 2 3 import ( 4 "context" 5 6 "github.com/keybase/client/go/libkb" 7 "github.com/keybase/client/go/protocol/stellar1" 8 ) 9 10 // Getting server config - like currency definitions - from the 11 // server, using `stellar/config` API. 12 13 type configResult struct { 14 Status libkb.AppStatus `json:"status"` 15 Revision int `json:"revision"` 16 Currencies map[stellar1.OutsideCurrencyCode]stellar1.OutsideCurrencyDefinition `json:"currencies"` 17 } 18 19 func (b *configResult) GetAppStatus() *libkb.AppStatus { 20 return &b.Status 21 } 22 23 func FetchServerConfig(ctx context.Context, g *libkb.GlobalContext) (ret stellar1.StellarServerDefinitions, err error) { 24 mctx := libkb.NewMetaContext(ctx, g) 25 apiArg := libkb.APIArg{ 26 Endpoint: "stellar/config", 27 SessionType: libkb.APISessionTypeNONE, 28 } 29 30 var res configResult 31 if err := mctx.G().API.GetDecode(mctx, apiArg, &res); err != nil { 32 return ret, err 33 } 34 35 ret.Revision = res.Revision 36 ret.Currencies = res.Currencies 37 return ret, nil 38 }