Skip to content

Commit

Permalink
decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
ironoa committed Mar 6, 2024
1 parent 035275d commit 7eff8cb
Show file tree
Hide file tree
Showing 5 changed files with 1,215 additions and 962 deletions.
4 changes: 2 additions & 2 deletions charts/polkadot-watcher-transaction/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: Polkadot Watcher
name: polkadot-watcher-transaction
version: v1.3.2
appVersion: v1.3.2
version: v1.3.3
appVersion: v1.3.3
apiVersion: v2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkadot-watcher-transaction",
"version": "1.3.2",
"version": "1.3.3",
"description": "Monitor events on Polkadot networks, specifically transactions",
"repository": "git@github.com:w3f/polkadot-watcher-csv-exporter.git",
"author": "W3F Infrastructure Team <devops@web3.foundation>",
Expand Down
7 changes: 6 additions & 1 deletion src/subscriptionModules/balanceBelowThreshold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ export class BalanceBelowThreshold implements ISubscriptionModule{
}

private formatBalance(free: bigint): number {
return Number(free / BigInt(10**this.api.registry.chainDecimals[0]));
const decimalPlaces = 1
const scalingFactor = 10n ** BigInt(decimalPlaces);
const scaledNumerator = free * scalingFactor;
const denominator = BigInt(10**this.api.registry.chainDecimals[0])
const result = Number(scaledNumerator / denominator) / Number(scalingFactor);
return result
}

public subscribe = async (): Promise<void> => {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declaration": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es6",
"target": "ES2020",
"skipLibCheck": true,
"outDir": "./dist",
"experimentalDecorators": true,
Expand Down
Loading

0 comments on commit 7eff8cb

Please sign in to comment.