Skip to content

Commit

Permalink
feat: get chain by its id and symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
mj committed May 7, 2023
1 parent 217b03a commit 8ad22e5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down

0 comments on commit 8ad22e5

Please sign in to comment.