From 8ad22e5f08055bcd7f00e37086aaaf2b9ffb7674 Mon Sep 17 00:00:00 2001 From: mj Date: Sun, 7 May 2023 16:55:17 +0330 Subject: [PATCH] feat: get chain by its id and symbol --- asset.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/asset.go b/asset.go index 0dfe6149..e05d8675 100644 --- a/asset.go +++ b/asset.go @@ -46,6 +46,28 @@ func (a *AssetRepo) GetMainChains(option *Option) ([]*entity.Chain, error) { return applyOptionsOnChains(chains, option) } +// GetChain return chain by its id +func (a *AssetRepo) GetChain(Id string) *entity.Chain { + for _, c := range a.Chains { + if c.ChainId == Id { + return c + } + } + + return nil +} + +// GetChainBySymbol return chain by its symbol +func (a *AssetRepo) GetChainBySymbol(symbol string) *entity.Chain { + for _, c := range a.Chains { + if c.Symbol == symbol { + return c + } + } + + return nil +} + // applyOptionsOnChains will check Options passed to requests and apply theme to result chains func applyOptionsOnChains(chains []*entity.Chain, option *Option) ([]*entity.Chain, error) {