Skip to content

Commit

Permalink
fix: add chain type (#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
trkhoi authored Dec 5, 2023
1 parent 206fced commit 426ba32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions migrations/schemas/20231205193453-add_chain_type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

-- +migrate Up
alter table chains add column type varchar(255);
-- +migrate Down
alter table chains drop column type;
7 changes: 7 additions & 0 deletions pkg/entities/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,17 @@ func (e *Entity) GetDefaultMoniker() ([]response.MonikerConfigData, error) {

res := []response.MonikerConfigData{}
for i, config := range configs {
chainId, _ := strconv.Atoi(config.Token.ChainId)
chain, err := e.repo.Chain.GetByID(chainId)
if err != nil {
e.log.Fields(logger.Fields{"chainId": chainId}).Error(err, "[entities.GetDefaultMoniker] - failed to get chain")
}

var configData response.MonikerConfigData
configData.Moniker = config
configData.Value = config.Amount * prices[config.Token.CoinGeckoID]
configs[i].Token.TokenPrice = prices[config.Token.CoinGeckoID]
configs[i].Token.Chain = chain
res = append(res, configData)
}
return res, nil
Expand Down
1 change: 1 addition & 0 deletions pkg/model/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ type Chain struct {
APIKey string `json:"-"`
TxBaseURL string `json:"-"`
Currency string `json:"currency"`
Type string `json:"type"`
}
1 change: 1 addition & 0 deletions pkg/model/offchain_tip_bot_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type OffchainTipBotToken struct {
Address string `json:"address"`
IsNative bool `json:"is_native"`
Decimal int64 `json:"decimal"`
Chain Chain `json:"chain" gorm:"-"`
}

func (OffchainTipBotToken) TableName() string {
Expand Down

0 comments on commit 426ba32

Please sign in to comment.