diff --git a/migrations/1679508966141_namespace-discount-bigint.js b/migrations/1679508966141_namespace-discount-bigint.js new file mode 100644 index 00000000..6b33b282 --- /dev/null +++ b/migrations/1679508966141_namespace-discount-bigint.js @@ -0,0 +1,21 @@ +/* eslint-disable camelcase */ + +exports.shorthands = undefined; + +exports.up = pgm => { + pgm.alterColumn('namespaces', 'nonalpha_discount', { + type: 'numeric' + }) + pgm.alterColumn('namespaces', 'no_vowel_discount', { + type: 'numeric' + }) +}; + +exports.down = pgm => { + pgm.alterColumn('namespaces', 'nonalpha_discount', { + type: 'numeric' + }) + pgm.alterColumn('namespaces', 'no_vowel_discount', { + type: 'numeric' + }) +}; diff --git a/src/datastore/common.ts b/src/datastore/common.ts index 251c1730..463318a4 100644 --- a/src/datastore/common.ts +++ b/src/datastore/common.ts @@ -646,8 +646,8 @@ export interface DbBnsNamespace { buckets: string; base: bigint; coeff: bigint; - nonalpha_discount: number; - no_vowel_discount: number; + nonalpha_discount: bigint; + no_vowel_discount: bigint; lifetime: number; status?: string; tx_id: string; @@ -1431,8 +1431,8 @@ export interface BnsNamespaceInsertValues { buckets: string; base: PgNumeric; coeff: PgNumeric; - nonalpha_discount: number; - no_vowel_discount: number; + nonalpha_discount: PgNumeric; + no_vowel_discount: PgNumeric; lifetime: number; status: string | null; tx_index: number; diff --git a/src/datastore/pg-write-store.ts b/src/datastore/pg-write-store.ts index 6b486546..b0d9fe9e 100644 --- a/src/datastore/pg-write-store.ts +++ b/src/datastore/pg-write-store.ts @@ -1806,8 +1806,8 @@ export class PgWriteStore extends PgStore { buckets: bnsNamespace.buckets, base: bnsNamespace.base.toString(), coeff: bnsNamespace.coeff.toString(), - nonalpha_discount: bnsNamespace.nonalpha_discount, - no_vowel_discount: bnsNamespace.no_vowel_discount, + nonalpha_discount: bnsNamespace.nonalpha_discount.toString(), + no_vowel_discount: bnsNamespace.no_vowel_discount.toString(), lifetime: bnsNamespace.lifetime, status: bnsNamespace.status ?? null, tx_index: bnsNamespace.tx_index, diff --git a/src/event-stream/bns/bns-helpers.ts b/src/event-stream/bns/bns-helpers.ts index db93c9e7..a344c29a 100644 --- a/src/event-stream/bns/bns-helpers.ts +++ b/src/event-stream/bns/bns-helpers.ts @@ -165,8 +165,8 @@ export function parseNamespaceRawValue( coeff: coeff, launched_at: launched_at, lifetime: Number(lifetime), - no_vowel_discount: Number(no_vowel_discount), - nonalpha_discount: Number(nonalpha_discount), + no_vowel_discount: no_vowel_discount, + nonalpha_discount: nonalpha_discount, ready_block: readyBlock, reveal_block: Number(revealed_at), status: status, diff --git a/src/import-v1/index.ts b/src/import-v1/index.ts index f579c349..507636a9 100644 --- a/src/import-v1/index.ts +++ b/src/import-v1/index.ts @@ -179,8 +179,8 @@ class ChainProcessor extends stream.Writable { buckets: parts[2], base: BigInt(parts[3]), coeff: BigInt(parts[4]), - nonalpha_discount: parseInt(parts[5], 10), - no_vowel_discount: parseInt(parts[6], 10), + nonalpha_discount: BigInt(parts[5]), + no_vowel_discount: BigInt(parts[6]), lifetime: parseInt(parts[7], 10), tx_id: this.genesisBlock.tx_id, tx_index: this.genesisBlock.tx_index, diff --git a/src/test-utils/test-builders.ts b/src/test-utils/test-builders.ts index cd0dafc1..67f04dbf 100644 --- a/src/test-utils/test-builders.ts +++ b/src/test-utils/test-builders.ts @@ -532,8 +532,8 @@ interface TestBnsNamespaceArgs { buckets?: string; base?: bigint; coeff?: bigint; - nonalpha_discount?: number; - no_vowel_discount?: number; + nonalpha_discount?: bigint; + no_vowel_discount?: bigint; lifetime?: number; status?: string; tx_id?: string; @@ -556,8 +556,8 @@ function testBnsNamespace(args?: TestBnsNamespaceArgs): DbBnsNamespace { buckets: args?.buckets ?? '1,1,1', base: args?.base ?? 1n, coeff: args?.coeff ?? 1n, - nonalpha_discount: args?.nonalpha_discount ?? 0, - no_vowel_discount: args?.no_vowel_discount ?? 0, + nonalpha_discount: args?.nonalpha_discount ?? 0n, + no_vowel_discount: args?.no_vowel_discount ?? 0n, lifetime: args?.lifetime ?? 0, status: args?.status ?? 'ready', tx_id: args?.tx_id ?? TX_ID, diff --git a/src/tests-bns/api.ts b/src/tests-bns/api.ts index 1a5311d5..bf71639d 100644 --- a/src/tests-bns/api.ts +++ b/src/tests-bns/api.ts @@ -112,8 +112,8 @@ describe('BNS API tests', () => { coeff: 1n, launched_at: 14, lifetime: 1, - no_vowel_discount: 1, - nonalpha_discount: 1, + no_vowel_discount: 1n, + nonalpha_discount: 1n, ready_block: dbBlock.block_height, reveal_block: 6, status: 'ready', @@ -140,8 +140,8 @@ describe('BNS API tests', () => { coeff: 1n, launched_at: 14, lifetime: 1, - no_vowel_discount: 1, - nonalpha_discount: 1, + no_vowel_discount: 200000000000000n, + nonalpha_discount: 200000000000000n, ready_block: dbBlock.block_height, reveal_block: 6, status: 'ready', diff --git a/src/tests-bns/bns-helpers-tests.ts b/src/tests-bns/bns-helpers-tests.ts index 02c077f1..58481de6 100644 --- a/src/tests-bns/bns-helpers-tests.ts +++ b/src/tests-bns/bns-helpers-tests.ts @@ -14,8 +14,8 @@ describe('BNS helper tests', () => { coeff: 1n, launched_at: 14, lifetime: 1, - no_vowel_discount: 1, - nonalpha_discount: 1, + no_vowel_discount: 1n, + nonalpha_discount: 1n, ready_block: 4, reveal_block: 6, status: 'ready', diff --git a/src/tests/datastore-tests.ts b/src/tests/datastore-tests.ts index 19b8b17e..b0b2104b 100644 --- a/src/tests/datastore-tests.ts +++ b/src/tests/datastore-tests.ts @@ -3048,8 +3048,8 @@ describe('postgres datastore', () => { coeff: 1n, launched_at: 14, lifetime: 1, - no_vowel_discount: 1, - nonalpha_discount: 1, + no_vowel_discount: 1n, + nonalpha_discount: 1n, ready_block: block1.block_height, reveal_block: 6, status: 'ready', @@ -4060,8 +4060,8 @@ describe('postgres datastore', () => { coeff: 1n, launched_at: 14, lifetime: 1, - no_vowel_discount: 1, - nonalpha_discount: 1, + no_vowel_discount: 1n, + nonalpha_discount: 1n, ready_block: 2, reveal_block: 6, status: 'ready', @@ -4261,8 +4261,8 @@ describe('postgres datastore', () => { coeff: 1n, launched_at: 14, lifetime: 1, - no_vowel_discount: 1, - nonalpha_discount: 1, + no_vowel_discount: 1n, + nonalpha_discount: 1n, ready_block: 2, reveal_block: 6, status: 'ready', @@ -4807,8 +4807,8 @@ describe('postgres datastore', () => { coeff: 1n, launched_at: dbBlock.block_height, lifetime: 1, - no_vowel_discount: 1, - nonalpha_discount: 1, + no_vowel_discount: 1n, + nonalpha_discount: 1n, ready_block: dbBlock.block_height, reveal_block: 6, status: 'ready',