Skip to content

Commit

Permalink
fix: change tx_count to json number (#216)
Browse files Browse the repository at this point in the history
Co-authored-by: janniks <janniks@users.noreply.github.com>
  • Loading branch information
janniks and janniks committed Sep 11, 2023
1 parent a9885d0 commit 20f9415
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/api/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export const Brc20TokenResponseSchema = Type.Object(
decimals: Type.Integer({ examples: [18] }),
deploy_timestamp: Type.Integer({ examples: [1677733170000] }),
minted_supply: Type.String({ examples: ['1000000'] }),
tx_count: Type.String({ examples: ['300000'] }),
tx_count: Type.Integer({ examples: [300000] }),
},
{ title: 'BRC-20 Token Response' }
);
Expand Down
2 changes: 1 addition & 1 deletion src/api/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function parseBrc20Tokens(items: DbBrc20Token[]): Brc20TokenResponse[] {
decimals: i.decimals,
deploy_timestamp: i.timestamp.valueOf(),
minted_supply: decimals(i.minted_supply, i.decimals),
tx_count: i.tx_count,
tx_count: parseInt(i.tx_count),
}));
}

Expand Down
26 changes: 13 additions & 13 deletions tests/brc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ describe('BRC-20', () => {
tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
deploy_timestamp: 1677811111000,
minted_supply: '0.000000000000000000',
tx_count: '1',
tx_count: 1,
},
]);
});
Expand Down Expand Up @@ -589,7 +589,7 @@ describe('BRC-20', () => {
tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
deploy_timestamp: 1677803510000,
minted_supply: '0.000000000000000000',
tx_count: '1',
tx_count: 1,
},
]);
});
Expand Down Expand Up @@ -665,7 +665,7 @@ describe('BRC-20', () => {
tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
deploy_timestamp: 1677803510000,
minted_supply: '0.000000000000000000',
tx_count: '1',
tx_count: 1,
},
]);
const response2 = await fastify.inject({
Expand All @@ -688,7 +688,7 @@ describe('BRC-20', () => {
tx_id: '38c46a8bf7ec90bc7f6b797e7dc84baa97f4e5fd4286b92fe1b50176d03b18dc',
deploy_timestamp: 1677803510000,
minted_supply: '0.000000000000000000',
tx_count: '1',
tx_count: 1,
},
]);
});
Expand Down Expand Up @@ -1752,7 +1752,7 @@ describe('BRC-20', () => {
decimals: 18,
deploy_timestamp: 1677803510000,
minted_supply: '0.000000000000000000',
tx_count: '1',
tx_count: 1,
},
supply: {
max_supply: '21000000.000000000000000000',
Expand Down Expand Up @@ -2021,11 +2021,11 @@ describe('BRC-20', () => {
// The first result is the token with the latest activity (ABCD)
expect.objectContaining({
ticker: 'ABCD',
tx_count: '4',
tx_count: 4,
} as Brc20TokenResponse),
expect.objectContaining({
ticker: 'PEPE',
tx_count: '11',
tx_count: 11,
} as Brc20TokenResponse),
]);

Expand All @@ -2042,11 +2042,11 @@ describe('BRC-20', () => {
expect(json.results).toEqual([
expect.objectContaining({
ticker: 'PEPE',
tx_count: '11',
tx_count: 11,
} as Brc20TokenResponse),
expect.objectContaining({
ticker: 'ABCD',
tx_count: '4',
tx_count: 4,
} as Brc20TokenResponse),
]);

Expand All @@ -2068,11 +2068,11 @@ describe('BRC-20', () => {
expect(json.results).toEqual([
expect.objectContaining({
ticker: 'ABCD',
tx_count: '4',
tx_count: 4,
} as Brc20TokenResponse),
expect.objectContaining({
ticker: 'PEPE',
tx_count: '1', // only the deploy remains
tx_count: 1, // only the deploy remains
} as Brc20TokenResponse),
]);

Expand All @@ -2099,11 +2099,11 @@ describe('BRC-20', () => {
expect(json.results).toEqual([
expect.objectContaining({
ticker: 'ABCD',
tx_count: '2', // only the deploy and mint remain
tx_count: 2, // only the deploy and mint remain
} as Brc20TokenResponse),
expect.objectContaining({
ticker: 'PEPE',
tx_count: '1',
tx_count: 1,
} as Brc20TokenResponse),
]);
});
Expand Down

0 comments on commit 20f9415

Please sign in to comment.