mirror of
https://github.com/alexgo-io/stacks-blockchain-api.git
synced 2026-01-12 16:53:19 +08:00
fix: expand namespace discount column types to numeric (#1591)
This commit is contained in:
21
migrations/1679508966141_namespace-discount-bigint.js
Normal file
21
migrations/1679508966141_namespace-discount-bigint.js
Normal 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'
|
||||
})
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user