mirror of
https://github.com/alexgo-io/gaze-brc20-indexer.git
synced 2026-01-12 14:34:54 +08:00
feat(decimals): support pgtype.Numeric
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/gaze-network/indexer-network/pkg/logger/slogx"
|
||||
"github.com/gaze-network/uint128"
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/shopspring/decimal"
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
@@ -89,6 +90,8 @@ func ToBigInt(iamount any, decimals uint16) *big.Int {
|
||||
amount, _ = decimal.NewFromString(v.String())
|
||||
case *big.Float:
|
||||
amount, _ = decimal.NewFromString(v.String())
|
||||
case pgtype.Numeric:
|
||||
amount = decimal.NewFromBigInt(v.Int, v.Exp)
|
||||
}
|
||||
return amount.Mul(PowerOfTen(decimals)).BigInt()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user