fix: expand namespace discount column types to numeric (#1591)

This commit is contained in:
Rafael Cárdenas
2023-03-22 12:39:48 -06:00
committed by GitHub
parent a75da5368a
commit 276b5d20f9
9 changed files with 49 additions and 28 deletions

View File

@@ -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'
})
};

View File

@@ -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;

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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',

View File

@@ -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',

View File

@@ -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',