diff --git a/db/schema/v019.sql b/db/schema/v019.sql new file mode 100644 index 0000000..c711330 --- /dev/null +++ b/db/schema/v019.sql @@ -0,0 +1,3 @@ +ALTER TABLE nft_class + ALTER COLUMN price TYPE BIGINT +; diff --git a/extractor/marketplace.go b/extractor/marketplace.go index d3dcda6..4809c2d 100644 --- a/extractor/marketplace.go +++ b/extractor/marketplace.go @@ -3,6 +3,7 @@ package extractor import ( "encoding/json" "fmt" + "math" "strconv" "time" @@ -31,6 +32,10 @@ func parseMessage(payload *Payload) (db.NftMarketplaceItem, error) { if err != nil { return db.NftMarketplaceItem{}, fmt.Errorf("failed to parse price in marketplace related message: %w", err) } + // HACK: pg cannot store MaxUInt64 + if price > math.MaxInt64 { + price = math.MaxInt64 + } } return db.NftMarketplaceItem{ ClassId: item.ClassId, @@ -106,6 +111,10 @@ func getPriceFromEvent(event *types.StringEvent) uint64 { // TODO: should we return error? return 0 } + // HACK: pg cannot store MaxUInt64 + if price > math.MaxInt64 { + price = math.MaxInt64 + } return price }