Skip to content

Commit

Permalink
Merge pull request #500 from DefiantLabs/patch/transfer-in-denom-csv-…
Browse files Browse the repository at this point in the history
…output

Add "transfer/{channel}/{denom}" parsing during CSV output to attempt…
  • Loading branch information
pharr117 authored Oct 17, 2023
2 parents 74ce918 + eed3d86 commit 36477a3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions db/denoms.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ func GetDenomUnitForDenom(denom Denom) (DenomUnit, error) {
}

func GetBaseDenomUnitForDenom(denom Denom) (DenomUnit, error) {
// Code hack for IBC MsgAck denoms
// MsgAcks have a denom of the form transfer/{channel/{base denom}. Attempt to use that to parse out the base denom unit first.
if strings.HasPrefix(denom.Base, "transfer/") {
splitString := strings.Split(denom.Base, "/")
base := splitString[len(splitString)-1]
searchDenom, err := GetDenomForBase(base)
if err == nil {
for _, denomUnit := range CachedDenomUnits {
if denomUnit.DenomID == searchDenom.ID && denomUnit.Exponent == 0 {
return denomUnit, nil
}
}
}
}

for _, denomUnit := range CachedDenomUnits {
if denomUnit.DenomID == denom.ID && denomUnit.Exponent == 0 {
return denomUnit, nil
Expand Down

0 comments on commit 36477a3

Please sign in to comment.