From 5b904b39da8311982553b955cdea1b431caf9433 Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Mon, 4 Dec 2023 12:13:32 +0000
Subject: [PATCH 01/10] 1134 refactor
---
main/core.js | 6 +++++-
main/index.js | 10 +++++++---
main/ipc.js | 2 +-
main/typings.ts | 3 ++-
main/wallet.js | 20 +++++++++++---------
renderer/src/pages/Dashboard.tsx | 3 ++-
renderer/src/utils/number-ops.ts | 5 +++++
7 files changed, 33 insertions(+), 16 deletions(-)
create mode 100644 renderer/src/utils/number-ops.ts
diff --git a/main/core.js b/main/core.js
index 5fe78cceb..bf4d8331a 100644
--- a/main/core.js
+++ b/main/core.js
@@ -25,6 +25,7 @@ console.log('Core binary: %s', corePath)
const logs = new Logs()
const activities = new Activities()
let totalJobsCompleted = 0
+let scheduledRewardsForAddress = ""
/**
* @param {Context} ctx
@@ -83,7 +84,9 @@ async function start (ctx) {
switch (event.type) {
case 'jobs-completed':
totalJobsCompleted = event.total
+ scheduledRewardsForAddress = event.rewardsScheduledForAddress
ctx.setTotalJobsCompleted(event.total)
+ ctx.setScheduledRewardsForAddress(event.rewardsScheduledForAddress)
break
case 'activity:info':
case 'activity:error': {
@@ -164,5 +167,6 @@ module.exports = {
setup,
isOnline: () => activities.isOnline(),
getActivities: () => activities.get(),
- getTotalJobsCompleted: () => totalJobsCompleted
+ getTotalJobsCompleted: () => totalJobsCompleted,
+ getScheduledRewardsForAddress: () => scheduledRewardsForAddress
}
diff --git a/main/index.js b/main/index.js
index b4a4be71e..c0fe797a1 100644
--- a/main/index.js
+++ b/main/index.js
@@ -110,6 +110,13 @@ const ctx = {
count
)
},
+ getScheduledRewardsForAddress: () => core.getScheduledRewardsForAddress(),
+ setScheduledRewardsForAddress: (balance) => {
+ ipcMain.emit(
+ ipcMainEvents.SCHEDULED_REWARDS_UPDATE,
+ balance
+ )
+ },
manualCheckForUpdates: () => { throw new Error('never get here') },
saveModuleLogsAs: () => { throw new Error('never get here') },
@@ -129,9 +136,6 @@ const ctx = {
},
balanceUpdate: (balance) => {
ipcMain.emit(ipcMainEvents.BALANCE_UPDATE, balance)
- },
- scheduledRewardsUpdate: (balance) => {
- ipcMain.emit(ipcMainEvents.SCHEDULED_REWARDS_UPDATE, balance)
}
}
diff --git a/main/ipc.js b/main/ipc.js
index 4708032d5..8e79564a1 100644
--- a/main/ipc.js
+++ b/main/ipc.js
@@ -41,7 +41,7 @@ function setupIpcMain (/** @type {Context} */ ctx) {
(_event, address) => stationConfig.setDestinationWalletAddress(address)
)
ipcMain.handle('station:getStationWalletBalance', wallet.getBalance)
- ipcMain.handle('station:getScheduledRewards', wallet.getScheduledRewards)
+ ipcMain.handle('station:getScheduledRewards', ctx.getScheduledRewardsForAddress)
ipcMain.handle(
'station:getStationWalletTransactionsHistory',
wallet.listTransactions
diff --git a/main/typings.ts b/main/typings.ts
index e8506bb76..cd7897177 100644
--- a/main/typings.ts
+++ b/main/typings.ts
@@ -21,6 +21,8 @@ export interface Context {
getActivities(): Activity[];
setTotalJobsCompleted(count: number): void;
getTotalJobsCompleted(): number;
+ setScheduledRewardsForAddress(balance: string): void;
+ getScheduledRewardsForAddress(): string;
showUI: () => void;
isShowingUI: boolean;
@@ -37,7 +39,6 @@ export interface Context {
transactionUpdate: (transactions: (FILTransaction|FILTransactionProcessing)[]) => void;
balanceUpdate: (balance:string) => void;
- scheduledRewardsUpdate: (balance: string) => void;
}
export interface WalletSeed {
diff --git a/main/wallet.js b/main/wallet.js
index ae08f0986..9b32290ab 100644
--- a/main/wallet.js
+++ b/main/wallet.js
@@ -15,8 +15,15 @@ const { ethers } = require('ethers')
} FILTransactionProcessing */
const log = electronLog.scope('wallet')
+
+/** @type {Store<{
+ scheduled_rewards: string
+}>} */
const walletStore = new Store({
- name: 'wallet'
+ name: 'wallet',
+ defaults: {
+ scheduled_rewards: ""
+ }
})
const backend = new WalletBackend({
@@ -84,7 +91,7 @@ function getBalance () {
* @returns {string}
*/
function getScheduledRewards () {
- return formatWithSixDecimalDigits(scheduledRewards)
+ return scheduledRewards
}
/**
@@ -147,9 +154,7 @@ async function updateScheduledRewards () {
async function _updateScheduledRewards () {
assert(ctx)
- scheduledRewards = await backend.fetchScheduledRewards()
- walletStore.set('scheduled_rewards', scheduledRewards.toHexString())
- ctx.scheduledRewardsUpdate(getScheduledRewards())
+ walletStore.set('scheduled_rewards', ctx.getScheduledRewardsForAddress())
}
function listTransactions () {
@@ -245,10 +250,7 @@ function loadBalance () {
}
function loadScheduledRewards () {
- return ethers.BigNumber.from(
- // A workaround to fix false TypeScript errors
- /** @type {string} */ (walletStore.get('scheduled_rewards', '0x0'))
- )
+ return walletStore.get('scheduled_rewards')
}
module.exports = {
diff --git a/renderer/src/pages/Dashboard.tsx b/renderer/src/pages/Dashboard.tsx
index 848269eca..fe2038c96 100644
--- a/renderer/src/pages/Dashboard.tsx
+++ b/renderer/src/pages/Dashboard.tsx
@@ -5,6 +5,7 @@ import ActivityLog from '../components/ActivityLog'
import UpdateBanner from '../components/UpdateBanner'
import WalletWidget from '../components/WalletWidget'
import useStationActivity from '../hooks/StationActivity'
+import { roundToSixDecimalPlaces } from '../utils/number-ops'
const scheduledRewardsTooltip = `
This is the reward total you have accrued since your last payout.
@@ -50,7 +51,7 @@ const Dashboard = (): JSX.Element => {
className="w-fit text-header-m font-bold font-number total-earnings"
title={scheduledRewardsTooltip}
>
- {scheduledRewards} FIL
+ {roundToSixDecimalPlaces(scheduledRewards)} FIL
diff --git a/renderer/src/utils/number-ops.ts b/renderer/src/utils/number-ops.ts
new file mode 100644
index 000000000..3433a215f
--- /dev/null
+++ b/renderer/src/utils/number-ops.ts
@@ -0,0 +1,5 @@
+export function roundToSixDecimalPlaces(number: string | number | undefined) {
+ if (!number) return 0
+ const roundedNumber = Number(number).toFixed(6); // Round to 6 decimal places
+ return roundedNumber.toString();
+}
\ No newline at end of file
From cb87bf570be5dd4757b321a6bfc966654db410de Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Mon, 4 Dec 2023 12:59:36 +0000
Subject: [PATCH 02/10] lint fix
---
main/core.js | 2 +-
main/ipc.js | 5 ++++-
main/wallet.js | 4 ++--
renderer/src/utils/number-ops.ts | 10 +++++-----
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/main/core.js b/main/core.js
index bf4d8331a..8b1fa7c59 100644
--- a/main/core.js
+++ b/main/core.js
@@ -25,7 +25,7 @@ console.log('Core binary: %s', corePath)
const logs = new Logs()
const activities = new Activities()
let totalJobsCompleted = 0
-let scheduledRewardsForAddress = ""
+let scheduledRewardsForAddress = ''
/**
* @param {Context} ctx
diff --git a/main/ipc.js b/main/ipc.js
index 8e79564a1..66d8b0009 100644
--- a/main/ipc.js
+++ b/main/ipc.js
@@ -41,7 +41,10 @@ function setupIpcMain (/** @type {Context} */ ctx) {
(_event, address) => stationConfig.setDestinationWalletAddress(address)
)
ipcMain.handle('station:getStationWalletBalance', wallet.getBalance)
- ipcMain.handle('station:getScheduledRewards', ctx.getScheduledRewardsForAddress)
+ ipcMain.handle(
+ 'station:getScheduledRewards',
+ ctx.getScheduledRewardsForAddress
+ )
ipcMain.handle(
'station:getStationWalletTransactionsHistory',
wallet.listTransactions
diff --git a/main/wallet.js b/main/wallet.js
index 9b32290ab..c139be0a4 100644
--- a/main/wallet.js
+++ b/main/wallet.js
@@ -22,7 +22,7 @@ const log = electronLog.scope('wallet')
const walletStore = new Store({
name: 'wallet',
defaults: {
- scheduled_rewards: ""
+ scheduled_rewards: ''
}
})
@@ -37,7 +37,7 @@ backend.transactions = loadStoredEntries()
/** @type {Context | null} */
let ctx = null
let balance = loadBalance()
-let scheduledRewards = loadScheduledRewards()
+const scheduledRewards = loadScheduledRewards()
/**
* @param {Context} _ctx
diff --git a/renderer/src/utils/number-ops.ts b/renderer/src/utils/number-ops.ts
index 3433a215f..4104bca47 100644
--- a/renderer/src/utils/number-ops.ts
+++ b/renderer/src/utils/number-ops.ts
@@ -1,5 +1,5 @@
-export function roundToSixDecimalPlaces(number: string | number | undefined) {
- if (!number) return 0
- const roundedNumber = Number(number).toFixed(6); // Round to 6 decimal places
- return roundedNumber.toString();
-}
\ No newline at end of file
+export function roundToSixDecimalPlaces (number: string | number | undefined) {
+ if (!number) return 0
+ const roundedNumber = Number(number).toFixed(6) // Round to 6 decimal places
+ return roundedNumber.toString()
+}
From 0614d3d7cbee8e9476597ccc3a50128e25ea7c82 Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Mon, 4 Dec 2023 19:59:35 +0000
Subject: [PATCH 03/10] no change to wallet store API
---
main/wallet.js | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/main/wallet.js b/main/wallet.js
index c139be0a4..d3ac2238b 100644
--- a/main/wallet.js
+++ b/main/wallet.js
@@ -7,6 +7,7 @@ const timers = require('node:timers/promises')
const Store = require('electron-store')
const { WalletBackend } = require('./wallet-backend')
const { ethers } = require('ethers')
+const { parseEther, formatEther } = require('ethers/lib/utils')
/** @typedef {import('./typings').Context} Context */
/** @typedef {import('./typings').FILTransaction} FILTransaction */
@@ -91,7 +92,7 @@ function getBalance () {
* @returns {string}
*/
function getScheduledRewards () {
- return scheduledRewards
+ return formatEther(scheduledRewards)
}
/**
@@ -154,7 +155,11 @@ async function updateScheduledRewards () {
async function _updateScheduledRewards () {
assert(ctx)
- walletStore.set('scheduled_rewards', ctx.getScheduledRewardsForAddress())
+ if (!ctx.getScheduledRewardsForAddress()) return
+ const storeValue = parseEther(
+ ctx.getScheduledRewardsForAddress()
+ ).toHexString()
+ walletStore.set('scheduled_rewards', storeValue)
}
function listTransactions () {
@@ -250,7 +255,10 @@ function loadBalance () {
}
function loadScheduledRewards () {
- return walletStore.get('scheduled_rewards')
+ return ethers.BigNumber.from(
+ // A workaround to fix false TypeScript errors
+ /** @type {string} */ (walletStore.get('scheduled_rewards', '0x0'))
+ )
}
module.exports = {
From 92d4a5c50d3606cfeaed1b61c7dcd32493e9ad83 Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Mon, 4 Dec 2023 20:01:36 +0000
Subject: [PATCH 04/10] revert wallet store setup to original
---
main/wallet.js | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/main/wallet.js b/main/wallet.js
index d3ac2238b..b99a3be1f 100644
--- a/main/wallet.js
+++ b/main/wallet.js
@@ -16,15 +16,8 @@ const { parseEther, formatEther } = require('ethers/lib/utils')
} FILTransactionProcessing */
const log = electronLog.scope('wallet')
-
-/** @type {Store<{
- scheduled_rewards: string
-}>} */
const walletStore = new Store({
- name: 'wallet',
- defaults: {
- scheduled_rewards: ''
- }
+ name: 'wallet'
})
const backend = new WalletBackend({
From bb0285d9dce6ff539f8a9186e2b810cdd40d55cb Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Tue, 5 Dec 2023 12:36:56 +0000
Subject: [PATCH 05/10] use only the wallet store as the state for scheduld
rewards
---
main/core.js | 10 ++++++----
main/index.js | 2 +-
main/wallet.js | 16 ++++++++++------
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/main/core.js b/main/core.js
index 8b1fa7c59..b85862020 100644
--- a/main/core.js
+++ b/main/core.js
@@ -12,6 +12,7 @@ const { randomUUID } = require('node:crypto')
const { Activities } = require('./activities')
const { Logs } = require('./logs')
const split2 = require('split2')
+const { parseEther } = require('ethers/lib/utils')
/** @typedef {import('./typings').Context} Context */
@@ -25,7 +26,6 @@ console.log('Core binary: %s', corePath)
const logs = new Logs()
const activities = new Activities()
let totalJobsCompleted = 0
-let scheduledRewardsForAddress = ''
/**
* @param {Context} ctx
@@ -81,11 +81,14 @@ async function start (ctx) {
console.error(err)
return
}
+ console.log('event', event)
switch (event.type) {
case 'jobs-completed':
totalJobsCompleted = event.total
- scheduledRewardsForAddress = event.rewardsScheduledForAddress
ctx.setTotalJobsCompleted(event.total)
+ wallet.setScheduledRewards(
+ parseEther(event.rewardsScheduledForAddress || 0)
+ )
ctx.setScheduledRewardsForAddress(event.rewardsScheduledForAddress)
break
case 'activity:info':
@@ -167,6 +170,5 @@ module.exports = {
setup,
isOnline: () => activities.isOnline(),
getActivities: () => activities.get(),
- getTotalJobsCompleted: () => totalJobsCompleted,
- getScheduledRewardsForAddress: () => scheduledRewardsForAddress
+ getTotalJobsCompleted: () => totalJobsCompleted
}
diff --git a/main/index.js b/main/index.js
index c0fe797a1..a6a2e972b 100644
--- a/main/index.js
+++ b/main/index.js
@@ -110,7 +110,7 @@ const ctx = {
count
)
},
- getScheduledRewardsForAddress: () => core.getScheduledRewardsForAddress(),
+ getScheduledRewardsForAddress: () => wallet.getScheduledRewards(),
setScheduledRewardsForAddress: (balance) => {
ipcMain.emit(
ipcMainEvents.SCHEDULED_REWARDS_UPDATE,
diff --git a/main/wallet.js b/main/wallet.js
index b99a3be1f..da06e92d9 100644
--- a/main/wallet.js
+++ b/main/wallet.js
@@ -7,7 +7,7 @@ const timers = require('node:timers/promises')
const Store = require('electron-store')
const { WalletBackend } = require('./wallet-backend')
const { ethers } = require('ethers')
-const { parseEther, formatEther } = require('ethers/lib/utils')
+const { formatEther } = require('ethers/lib/utils')
/** @typedef {import('./typings').Context} Context */
/** @typedef {import('./typings').FILTransaction} FILTransaction */
@@ -148,11 +148,14 @@ async function updateScheduledRewards () {
async function _updateScheduledRewards () {
assert(ctx)
- if (!ctx.getScheduledRewardsForAddress()) return
- const storeValue = parseEther(
- ctx.getScheduledRewardsForAddress()
- ).toHexString()
- walletStore.set('scheduled_rewards', storeValue)
+ ctx.setScheduledRewardsForAddress(getScheduledRewards())
+}
+
+/**
+ * @param {ethers.BigNumber} scheduledRewards
+ */
+async function setScheduledRewards (scheduledRewards) {
+ walletStore.set('scheduled_rewards', scheduledRewards.toHexString())
}
function listTransactions () {
@@ -259,6 +262,7 @@ module.exports = {
getAddress,
getBalance,
getScheduledRewards,
+ setScheduledRewards,
formatWithSixDecimalDigits,
listTransactions,
transferAllFundsToDestinationWallet,
From be7b078d8e58ace5ba86dd2cee78b5c6217bc03c Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Tue, 5 Dec 2023 12:37:50 +0000
Subject: [PATCH 06/10] remove console.log
---
main/core.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/main/core.js b/main/core.js
index b85862020..57c9f8d29 100644
--- a/main/core.js
+++ b/main/core.js
@@ -81,7 +81,6 @@ async function start (ctx) {
console.error(err)
return
}
- console.log('event', event)
switch (event.type) {
case 'jobs-completed':
totalJobsCompleted = event.total
From 542532b902416e9c690b454ca8054843f229a0f6 Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Thu, 7 Dec 2023 12:54:08 +0000
Subject: [PATCH 07/10] updated core version and added test cases
---
main/core.js | 2 +-
main/test/utils.test.js | 59 +++++++++
main/test/wallet.test.js | 42 +-----
main/tray.js | 6 +-
main/utils.js | 19 ++-
main/wallet.js | 18 ---
package-lock.json | 211 ++++++++++++++++++++-----------
package.json | 2 +-
renderer/src/pages/Dashboard.tsx | 4 +-
renderer/src/utils/number-ops.ts | 10 +-
10 files changed, 222 insertions(+), 151 deletions(-)
create mode 100644 main/test/utils.test.js
diff --git a/main/core.js b/main/core.js
index 57c9f8d29..c8e82dd83 100644
--- a/main/core.js
+++ b/main/core.js
@@ -86,7 +86,7 @@ async function start (ctx) {
totalJobsCompleted = event.total
ctx.setTotalJobsCompleted(event.total)
wallet.setScheduledRewards(
- parseEther(event.rewardsScheduledForAddress || 0)
+ parseEther(event.rewardsScheduledForAddress)
)
ctx.setScheduledRewardsForAddress(event.rewardsScheduledForAddress)
break
diff --git a/main/test/utils.test.js b/main/test/utils.test.js
new file mode 100644
index 000000000..44f3ad61a
--- /dev/null
+++ b/main/test/utils.test.js
@@ -0,0 +1,59 @@
+'use strict'
+
+const { formatTokenValue } = require('../utils')
+const assert = require('assert').strict
+
+describe('formatTokenValue', function () {
+ it('should correctly round a typical value', function () {
+ const input = 0.004567687
+ const expectedOutput = 0.004568
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+ it('should reduce a big number to 6 decimal places',
+ function () {
+ const input = 123.45678923456
+ const expectedOutput = 123.456789
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+ it('should reduce a very small number to 6 decimal places',
+ function () {
+ const input = 0.000123456789
+ const expectedOutput = 0.000123
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+ it('should round up', function () {
+ const input = 0.0001289
+ const expectedOutput = 0.000129
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+ it('should map 0 to 0', function () {
+ const input = 0
+ const expectedOutput = 0
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+ it('should leave a big integer alone', function () {
+ const input = 123456789
+ const expectedOutput = 123456789
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+ it('should show 6 decimal places for numbers smaller than 0.000001',
+ function () {
+ const input = 0.000000000123456789
+ const expectedOutput = 0.000000
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+ it('should not add zeroes to a number that is has no trailing zeroes',
+ function () {
+ const input = 123.4
+ const expectedOutput = 123.4
+ const result = formatTokenValue(input)
+ assert.equal(result, expectedOutput)
+ })
+})
diff --git a/main/test/wallet.test.js b/main/test/wallet.test.js
index 83ca0856a..66ede7507 100644
--- a/main/test/wallet.test.js
+++ b/main/test/wallet.test.js
@@ -1,11 +1,7 @@
'use strict'
-const {
- getTransactionsForUI,
- formatWithSixDecimalDigits
-} = require('../wallet')
+const { getTransactionsForUI } = require('../wallet')
const assert = require('assert').strict
-const ethers = require('ethers')
/** @typedef {import('../typings').FILTransactionStatus} FILTransactionStatus */
@@ -103,39 +99,3 @@ describe('Wallet', function () {
})
})
})
-
-describe('formatWithSixDecimalDigits', function () {
- it('keeps six decimal digits only', function () {
- assert.strictEqual(
- formatWithSixDecimalDigits(ethers.BigNumber.from('1654759687033008')),
- '0.001654'
- )
- })
-
- it('rounds down', function () {
- assert.strictEqual(
- formatWithSixDecimalDigits(ethers.BigNumber.from('1999999999999999')),
- '0.001999'
- )
- })
-
- it('strips trailing zeroes after rounding down', function () {
- assert.strictEqual(
- formatWithSixDecimalDigits(ethers.BigNumber.from('1000000000000001')),
- '0.001'
- )
- })
- it('strips trailing zeroes when no rounding is needed', function () {
- assert.strictEqual(
- formatWithSixDecimalDigits(ethers.BigNumber.from('1000000000000000')),
- '0.001'
- )
- })
-
- it('preserves .0 at the end', function () {
- assert.strictEqual(
- formatWithSixDecimalDigits(ethers.BigNumber.from('1000000000000000000')),
- '1.0'
- )
- })
-})
diff --git a/main/tray.js b/main/tray.js
index 257f069f5..55cfb2a25 100644
--- a/main/tray.js
+++ b/main/tray.js
@@ -6,7 +6,7 @@ const { ipcMainEvents } = require('./ipc')
const path = require('path')
const assert = require('node:assert')
const core = require('./core')
-const { roundToSixDecimalPlaces } = require('./utils')
+const { formatTokenValue } = require('./utils')
/** @typedef {import('./typings').Context} Context */
@@ -61,13 +61,13 @@ const createContextMenu = (/** @type {Context} */ ctx) => {
{
label:
`Wallet Balance: ${
- roundToSixDecimalPlaces(ctx.getWalletBalance())
+ formatTokenValue(ctx.getWalletBalance())
} FIL`,
enabled: false
},
{
label: `Scheduled Rewards: ${
- roundToSixDecimalPlaces(ctx.getScheduledRewards())
+ formatTokenValue(ctx.getScheduledRewards())
} FIL`,
enabled: false
},
diff --git a/main/utils.js b/main/utils.js
index 5f885d8ae..e1ffff59f 100644
--- a/main/utils.js
+++ b/main/utils.js
@@ -1,12 +1,17 @@
'use strict'
/**
- * @param { number | string | undefined } amount
- * @returns { string }
- */
+ * @param {string | number | undefined} input
+ * @returns {number}
+*/
+function formatTokenValue (input) {
+ const number = Number(input)
+ if (!input) return 0
+ if (Number.isInteger(number)) return number
+ // decimal cases below
+ return Number(number.toFixed(6))
+}
-exports.roundToSixDecimalPlaces = (amount) => {
- if (!amount) return '0'
- const roundedNumber = Number(amount).toFixed(6) // Round to 6 decimal places
- return roundedNumber.toString()
+module.exports = {
+ formatTokenValue
}
diff --git a/main/wallet.js b/main/wallet.js
index da06e92d9..1fcd342b7 100644
--- a/main/wallet.js
+++ b/main/wallet.js
@@ -88,23 +88,6 @@ function getScheduledRewards () {
return formatEther(scheduledRewards)
}
-/**
- * @param {ethers.BigNumber} amount
- * @returns {string}
- */
-function formatWithSixDecimalDigits (amount) {
- const fullPrecision = ethers.utils.formatUnits(amount, 18)
- const [whole, fraction] = fullPrecision.split('.')
- if (fraction === undefined) return fullPrecision
- const truncated = fraction
- // keep the first 6 digits, discard the rest
- .slice(0, 6)
- // remove trailing zeroes as long as there are some leading digits
- // (we want to preserve .0 if there is no fraction)
- .replace(/(\d)0+$/, '$1')
- return [whole, truncated].join('.')
-}
-
// Inline `p-debounce.promise` from
// https://github.com/sindresorhus/p-debounce/blob/1ba9d31dd81eee55b93ef67e38b8fa24781df63b/index.js#L38-L53
// since v5 is ESM only.
@@ -263,7 +246,6 @@ module.exports = {
getBalance,
getScheduledRewards,
setScheduledRewards,
- formatWithSixDecimalDigits,
listTransactions,
transferAllFundsToDestinationWallet,
getTransactionsForUI
diff --git a/package-lock.json b/package-lock.json
index 43a0680f9..39bd9c77b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,7 @@
"hasInstallScript": true,
"license": "(Apache-2.0 AND MIT)",
"dependencies": {
- "@filecoin-station/core": "^16.0.2",
+ "@filecoin-station/core": "^16.2.0",
"@glif/filecoin-address": "2.0.43",
"@glif/filecoin-message": "^2.0.44",
"@glif/filecoin-number": "^2.0.72",
@@ -3403,17 +3403,17 @@
}
},
"node_modules/@fastify/busboy": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
- "integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
+ "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
"engines": {
"node": ">=14"
}
},
"node_modules/@filecoin-station/core": {
- "version": "16.0.2",
- "resolved": "https://registry.npmjs.org/@filecoin-station/core/-/core-16.0.2.tgz",
- "integrity": "sha512-DadZ6XSOomoapGil/WBY1VWa7o34NMnA+jB+S5etzIpU//VkPBfaEOW9g775tth+eEqBSSTPRlIAX9pcmxbPOw==",
+ "version": "16.2.0",
+ "resolved": "https://registry.npmjs.org/@filecoin-station/core/-/core-16.2.0.tgz",
+ "integrity": "sha512-dx0bobLc44qQrF0mHeLkFGuEZiEpTLegFkBWprhCdMHUxzEYIqOTE5Twrpra1gW4M8THM+aQHM6bF6qNtvzCVw==",
"hasInstallScript": true,
"dependencies": {
"@glif/filecoin-address": "^2.0.43",
@@ -3441,9 +3441,9 @@
"integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q=="
},
"node_modules/@filecoin-station/core/node_modules/ethers": {
- "version": "6.8.1",
- "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.1.tgz",
- "integrity": "sha512-iEKm6zox5h1lDn6scuRWdIdFJUCGg3+/aQWu0F4K0GVyEZiktFkqrJbRjTn1FlYEPz7RKA707D6g5Kdk6j7Ljg==",
+ "version": "6.9.0",
+ "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.9.0.tgz",
+ "integrity": "sha512-pmfNyQzc2mseLe91FnT2vmNaTt8dDzhxZ/xItAV7uGsF4dI4ek2ufMu3rAkgQETL/TIs0GS5A+U05g9QyWnv3Q==",
"funding": [
{
"type": "individual",
@@ -3477,21 +3477,22 @@
}
},
"node_modules/@filecoin-station/core/node_modules/tar-fs": {
- "version": "3.0.3",
- "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.3.tgz",
- "integrity": "sha512-ZK36riGYnFI6LujIBfBRoDfeaaWUkStIFKwtPjnDWCKnsDE9kuQthG09aQjLjpzoRtVElEMZ/AIAURNb7N9mkA==",
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.4.tgz",
+ "integrity": "sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==",
"dependencies": {
"mkdirp-classic": "^0.5.2",
"pump": "^3.0.0",
- "tar-stream": "^3.1.0"
+ "tar-stream": "^3.1.5"
}
},
"node_modules/@filecoin-station/core/node_modules/tar-stream": {
- "version": "3.1.3",
- "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.3.tgz",
- "integrity": "sha512-oX1ywwb1FyBeLDOV/c9oHPT5y9RcjYkWmmYL5wxcPtKqraL9V0IaeHaX5cRmk5WPVX5z9kmxfsUwiHamIs5CvA==",
+ "version": "3.1.6",
+ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.6.tgz",
+ "integrity": "sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==",
"dependencies": {
"b4a": "^1.6.4",
+ "fast-fifo": "^1.2.0",
"streamx": "^2.15.0"
}
},
@@ -6479,10 +6480,14 @@
},
"node_modules/binary": {
"version": "0.3.0",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz",
+ "integrity": "sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==",
"dependencies": {
"buffers": "~0.1.1",
"chainsaw": "~0.1.0"
+ },
+ "engines": {
+ "node": "*"
}
},
"node_modules/binary-extensions": {
@@ -6664,7 +6669,8 @@
},
"node_modules/browserify-zlib": {
"version": "0.1.4",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz",
+ "integrity": "sha512-19OEpq7vWgsH6WkvkBJQDFvJS1uPcbFOQ4v9CU839dO+ZZXUZO6XpE6hNCqvlIIj+4fZvRiJ6DsAQ382GwiyTQ==",
"dependencies": {
"pako": "~0.2.0"
}
@@ -6771,6 +6777,8 @@
},
"node_modules/buffers": {
"version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz",
+ "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==",
"engines": {
"node": ">=0.2.0"
}
@@ -7121,9 +7129,13 @@
},
"node_modules/chainsaw": {
"version": "0.1.0",
- "license": "MIT/X11",
+ "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz",
+ "integrity": "sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==",
"dependencies": {
"traverse": ">=0.3.0 <0.4"
+ },
+ "engines": {
+ "node": "*"
}
},
"node_modules/chalk": {
@@ -7973,7 +7985,8 @@
},
"node_modules/duplexify": {
"version": "3.7.1",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz",
+ "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==",
"dependencies": {
"end-of-stream": "^1.0.0",
"inherits": "^2.0.1",
@@ -9617,9 +9630,9 @@
"license": "Apache-2.0"
},
"node_modules/fast-fifo": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.2.0.tgz",
- "integrity": "sha512-NcvQXt7Cky1cNau15FWy64IjuO8X0JijhTBBrJj1YlxlDfRkJXNaK9RFUjwpfDPzMdv7wB38jr53l9tkNLxnWg=="
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
+ "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ=="
},
"node_modules/fast-glob": {
"version": "3.3.0",
@@ -10156,7 +10169,8 @@
},
"node_modules/gunzip-maybe": {
"version": "1.4.2",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/gunzip-maybe/-/gunzip-maybe-1.4.2.tgz",
+ "integrity": "sha512-4haO1M4mLO91PW57BMsDFf75UmwoRX0GkdD+Faw+Lr+r/OZrOCS0pIBwOL1xCKQqnQzbNFGgK2V2CpBUPeFNTw==",
"dependencies": {
"browserify-zlib": "^0.1.4",
"is-deflate": "^1.0.0",
@@ -10694,7 +10708,8 @@
},
"node_modules/is-deflate": {
"version": "1.0.0",
- "license": "MIT"
+ "resolved": "https://registry.npmjs.org/is-deflate/-/is-deflate-1.0.0.tgz",
+ "integrity": "sha512-YDoFpuZWu1VRXlsnlYMzKyVRITXj7Ej/V9gXQ2/pAe7X1J7M/RNOqaIYi6qUn+B7nGyB9pDXrv02dsB58d2ZAQ=="
},
"node_modules/is-extglob": {
"version": "2.1.1",
@@ -10751,7 +10766,8 @@
},
"node_modules/is-gzip": {
"version": "1.0.0",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/is-gzip/-/is-gzip-1.0.0.tgz",
+ "integrity": "sha512-rcfALRIb1YewtnksfRIHGcIY93QnK8BIQ/2c9yDYcG/Y6+vRoJuTWBmmSEbyLLYtXm7q35pHOHbZFQBaLrhlWQ==",
"engines": {
"node": ">=0.10.0"
}
@@ -13382,7 +13398,8 @@
},
"node_modules/pako": {
"version": "0.2.9",
- "license": "MIT"
+ "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
+ "integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA=="
},
"node_modules/parent-module": {
"version": "1.0.1",
@@ -13510,7 +13527,8 @@
},
"node_modules/peek-stream": {
"version": "1.1.3",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/peek-stream/-/peek-stream-1.1.3.tgz",
+ "integrity": "sha512-FhJ+YbOSBb9/rIl2ZeE/QHEsWn7PqNYt8ARAY3kIgNGOk13g9FGyIY6JIl/xB/3TFRVoTv5as0l11weORrTekA==",
"dependencies": {
"buffer-from": "^1.0.0",
"duplexify": "^3.5.0",
@@ -13981,7 +13999,8 @@
},
"node_modules/pump": {
"version": "2.0.1",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz",
+ "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==",
"dependencies": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
@@ -13989,7 +14008,8 @@
},
"node_modules/pumpify": {
"version": "1.5.1",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz",
+ "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==",
"dependencies": {
"duplexify": "^3.6.0",
"inherits": "^2.0.3",
@@ -15141,12 +15161,13 @@
},
"node_modules/stream-shift": {
"version": "1.0.1",
- "license": "MIT"
+ "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz",
+ "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ=="
},
"node_modules/streamx": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.0.tgz",
- "integrity": "sha512-HcxY6ncGjjklGs1xsP1aR71INYcsXFJet5CU1CHqihQ2J5nOsbd4OjgjHO42w/4QNv9gZb3BueV+Vxok5pLEXg==",
+ "version": "2.15.5",
+ "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.5.tgz",
+ "integrity": "sha512-9thPGMkKC2GctCzyCUjME3yR03x2xNo0GPKGkRw2UMYN+gqWa9uqpyNWhmsNCutU5zHmkUum0LsCRQTXUgUCAg==",
"dependencies": {
"fast-fifo": "^1.1.0",
"queue-tick": "^1.0.1"
@@ -15697,7 +15718,8 @@
},
"node_modules/through2": {
"version": "2.0.5",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
+ "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
"dependencies": {
"readable-stream": "~2.3.6",
"xtend": "~4.0.1"
@@ -15821,7 +15843,11 @@
},
"node_modules/traverse": {
"version": "0.3.9",
- "license": "MIT/X11"
+ "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz",
+ "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==",
+ "engines": {
+ "node": "*"
+ }
},
"node_modules/truncate-utf8-bytes": {
"version": "1.0.2",
@@ -16096,9 +16122,9 @@
}
},
"node_modules/undici": {
- "version": "5.26.3",
- "resolved": "https://registry.npmjs.org/undici/-/undici-5.26.3.tgz",
- "integrity": "sha512-H7n2zmKEWgOllKkIUkLvFmsJQj062lSm3uA4EYApG8gLuiOM0/go9bIoC3HVaSnfg4xunowDE2i9p8drkXuvDw==",
+ "version": "5.28.2",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz",
+ "integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
@@ -16186,7 +16212,8 @@
},
"node_modules/unzip-stream": {
"version": "0.3.1",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.1.tgz",
+ "integrity": "sha512-RzaGXLNt+CW+T41h1zl6pGz3EaeVhYlK+rdAap+7DxW5kqsqePO8kRtWPaCiVqdhZc86EctSPVYNix30YOMzmw==",
"dependencies": {
"binary": "^0.3.0",
"mkdirp": "^0.5.1"
@@ -16865,7 +16892,8 @@
},
"node_modules/xtend": {
"version": "4.0.2",
- "license": "MIT",
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
+ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
"engines": {
"node": ">=0.4"
}
@@ -18989,14 +19017,14 @@
}
},
"@fastify/busboy": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
- "integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ=="
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
+ "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA=="
},
"@filecoin-station/core": {
- "version": "16.0.2",
- "resolved": "https://registry.npmjs.org/@filecoin-station/core/-/core-16.0.2.tgz",
- "integrity": "sha512-DadZ6XSOomoapGil/WBY1VWa7o34NMnA+jB+S5etzIpU//VkPBfaEOW9g775tth+eEqBSSTPRlIAX9pcmxbPOw==",
+ "version": "16.2.0",
+ "resolved": "https://registry.npmjs.org/@filecoin-station/core/-/core-16.2.0.tgz",
+ "integrity": "sha512-dx0bobLc44qQrF0mHeLkFGuEZiEpTLegFkBWprhCdMHUxzEYIqOTE5Twrpra1gW4M8THM+aQHM6bF6qNtvzCVw==",
"requires": {
"@glif/filecoin-address": "^2.0.43",
"@influxdata/influxdb-client": "^1.33.2",
@@ -19017,9 +19045,9 @@
"integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q=="
},
"ethers": {
- "version": "6.8.1",
- "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.8.1.tgz",
- "integrity": "sha512-iEKm6zox5h1lDn6scuRWdIdFJUCGg3+/aQWu0F4K0GVyEZiktFkqrJbRjTn1FlYEPz7RKA707D6g5Kdk6j7Ljg==",
+ "version": "6.9.0",
+ "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.9.0.tgz",
+ "integrity": "sha512-pmfNyQzc2mseLe91FnT2vmNaTt8dDzhxZ/xItAV7uGsF4dI4ek2ufMu3rAkgQETL/TIs0GS5A+U05g9QyWnv3Q==",
"requires": {
"@adraffy/ens-normalize": "1.10.0",
"@noble/curves": "1.2.0",
@@ -19040,21 +19068,22 @@
}
},
"tar-fs": {
- "version": "3.0.3",
- "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.3.tgz",
- "integrity": "sha512-ZK36riGYnFI6LujIBfBRoDfeaaWUkStIFKwtPjnDWCKnsDE9kuQthG09aQjLjpzoRtVElEMZ/AIAURNb7N9mkA==",
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.4.tgz",
+ "integrity": "sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==",
"requires": {
"mkdirp-classic": "^0.5.2",
"pump": "^3.0.0",
- "tar-stream": "^3.1.0"
+ "tar-stream": "^3.1.5"
}
},
"tar-stream": {
- "version": "3.1.3",
- "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.3.tgz",
- "integrity": "sha512-oX1ywwb1FyBeLDOV/c9oHPT5y9RcjYkWmmYL5wxcPtKqraL9V0IaeHaX5cRmk5WPVX5z9kmxfsUwiHamIs5CvA==",
+ "version": "3.1.6",
+ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.6.tgz",
+ "integrity": "sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==",
"requires": {
"b4a": "^1.6.4",
+ "fast-fifo": "^1.2.0",
"streamx": "^2.15.0"
}
},
@@ -21245,6 +21274,8 @@
},
"binary": {
"version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz",
+ "integrity": "sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==",
"requires": {
"buffers": "~0.1.1",
"chainsaw": "~0.1.0"
@@ -21387,6 +21418,8 @@
},
"browserify-zlib": {
"version": "0.1.4",
+ "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz",
+ "integrity": "sha512-19OEpq7vWgsH6WkvkBJQDFvJS1uPcbFOQ4v9CU839dO+ZZXUZO6XpE6hNCqvlIIj+4fZvRiJ6DsAQ382GwiyTQ==",
"requires": {
"pako": "~0.2.0"
}
@@ -21443,7 +21476,9 @@
}
},
"buffers": {
- "version": "0.1.1"
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz",
+ "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ=="
},
"builder-util": {
"version": "24.4.0",
@@ -21694,6 +21729,8 @@
},
"chainsaw": {
"version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz",
+ "integrity": "sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==",
"requires": {
"traverse": ">=0.3.0 <0.4"
}
@@ -22288,6 +22325,8 @@
},
"duplexify": {
"version": "3.7.1",
+ "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz",
+ "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==",
"requires": {
"end-of-stream": "^1.0.0",
"inherits": "^2.0.1",
@@ -23392,9 +23431,9 @@
"dev": true
},
"fast-fifo": {
- "version": "1.2.0",
- "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.2.0.tgz",
- "integrity": "sha512-NcvQXt7Cky1cNau15FWy64IjuO8X0JijhTBBrJj1YlxlDfRkJXNaK9RFUjwpfDPzMdv7wB38jr53l9tkNLxnWg=="
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
+ "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ=="
},
"fast-glob": {
"version": "3.3.0",
@@ -23759,6 +23798,8 @@
},
"gunzip-maybe": {
"version": "1.4.2",
+ "resolved": "https://registry.npmjs.org/gunzip-maybe/-/gunzip-maybe-1.4.2.tgz",
+ "integrity": "sha512-4haO1M4mLO91PW57BMsDFf75UmwoRX0GkdD+Faw+Lr+r/OZrOCS0pIBwOL1xCKQqnQzbNFGgK2V2CpBUPeFNTw==",
"requires": {
"browserify-zlib": "^0.1.4",
"is-deflate": "^1.0.0",
@@ -24095,7 +24136,9 @@
}
},
"is-deflate": {
- "version": "1.0.0"
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-deflate/-/is-deflate-1.0.0.tgz",
+ "integrity": "sha512-YDoFpuZWu1VRXlsnlYMzKyVRITXj7Ej/V9gXQ2/pAe7X1J7M/RNOqaIYi6qUn+B7nGyB9pDXrv02dsB58d2ZAQ=="
},
"is-extglob": {
"version": "2.1.1",
@@ -24130,7 +24173,9 @@
}
},
"is-gzip": {
- "version": "1.0.0"
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-gzip/-/is-gzip-1.0.0.tgz",
+ "integrity": "sha512-rcfALRIb1YewtnksfRIHGcIY93QnK8BIQ/2c9yDYcG/Y6+vRoJuTWBmmSEbyLLYtXm7q35pHOHbZFQBaLrhlWQ=="
},
"is-interactive": {
"version": "1.0.0",
@@ -25887,7 +25932,9 @@
}
},
"pako": {
- "version": "0.2.9"
+ "version": "0.2.9",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
+ "integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA=="
},
"parent-module": {
"version": "1.0.1",
@@ -25968,6 +26015,8 @@
},
"peek-stream": {
"version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/peek-stream/-/peek-stream-1.1.3.tgz",
+ "integrity": "sha512-FhJ+YbOSBb9/rIl2ZeE/QHEsWn7PqNYt8ARAY3kIgNGOk13g9FGyIY6JIl/xB/3TFRVoTv5as0l11weORrTekA==",
"requires": {
"buffer-from": "^1.0.0",
"duplexify": "^3.5.0",
@@ -26251,6 +26300,8 @@
},
"pump": {
"version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz",
+ "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==",
"requires": {
"end-of-stream": "^1.1.0",
"once": "^1.3.1"
@@ -26258,6 +26309,8 @@
},
"pumpify": {
"version": "1.5.1",
+ "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz",
+ "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==",
"requires": {
"duplexify": "^3.6.0",
"inherits": "^2.0.3",
@@ -27035,12 +27088,14 @@
}
},
"stream-shift": {
- "version": "1.0.1"
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz",
+ "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ=="
},
"streamx": {
- "version": "2.15.0",
- "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.0.tgz",
- "integrity": "sha512-HcxY6ncGjjklGs1xsP1aR71INYcsXFJet5CU1CHqihQ2J5nOsbd4OjgjHO42w/4QNv9gZb3BueV+Vxok5pLEXg==",
+ "version": "2.15.5",
+ "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.5.tgz",
+ "integrity": "sha512-9thPGMkKC2GctCzyCUjME3yR03x2xNo0GPKGkRw2UMYN+gqWa9uqpyNWhmsNCutU5zHmkUum0LsCRQTXUgUCAg==",
"requires": {
"fast-fifo": "^1.1.0",
"queue-tick": "^1.0.1"
@@ -27426,6 +27481,8 @@
},
"through2": {
"version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz",
+ "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==",
"requires": {
"readable-stream": "~2.3.6",
"xtend": "~4.0.1"
@@ -27512,7 +27569,9 @@
}
},
"traverse": {
- "version": "0.3.9"
+ "version": "0.3.9",
+ "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz",
+ "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ=="
},
"truncate-utf8-bytes": {
"version": "1.0.2",
@@ -27703,9 +27762,9 @@
}
},
"undici": {
- "version": "5.26.3",
- "resolved": "https://registry.npmjs.org/undici/-/undici-5.26.3.tgz",
- "integrity": "sha512-H7n2zmKEWgOllKkIUkLvFmsJQj062lSm3uA4EYApG8gLuiOM0/go9bIoC3HVaSnfg4xunowDE2i9p8drkXuvDw==",
+ "version": "5.28.2",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz",
+ "integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==",
"requires": {
"@fastify/busboy": "^2.0.0"
}
@@ -27764,6 +27823,8 @@
},
"unzip-stream": {
"version": "0.3.1",
+ "resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.1.tgz",
+ "integrity": "sha512-RzaGXLNt+CW+T41h1zl6pGz3EaeVhYlK+rdAap+7DxW5kqsqePO8kRtWPaCiVqdhZc86EctSPVYNix30YOMzmw==",
"requires": {
"binary": "^0.3.0",
"mkdirp": "^0.5.1"
@@ -28183,7 +28244,9 @@
"dev": true
},
"xtend": {
- "version": "4.0.2"
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
+ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
},
"xvfb-maybe": {
"version": "0.2.1",
diff --git a/package.json b/package.json
index 247b4bc5b..d934fde38 100644
--- a/package.json
+++ b/package.json
@@ -39,7 +39,7 @@
},
"homepage": "https://github.com/filecoin-station/desktop#readme",
"dependencies": {
- "@filecoin-station/core": "^16.0.2",
+ "@filecoin-station/core": "^16.2.0",
"@glif/filecoin-address": "2.0.43",
"@glif/filecoin-message": "^2.0.44",
"@glif/filecoin-number": "^2.0.72",
diff --git a/renderer/src/pages/Dashboard.tsx b/renderer/src/pages/Dashboard.tsx
index fe2038c96..9e8f9190a 100644
--- a/renderer/src/pages/Dashboard.tsx
+++ b/renderer/src/pages/Dashboard.tsx
@@ -5,7 +5,7 @@ import ActivityLog from '../components/ActivityLog'
import UpdateBanner from '../components/UpdateBanner'
import WalletWidget from '../components/WalletWidget'
import useStationActivity from '../hooks/StationActivity'
-import { roundToSixDecimalPlaces } from '../utils/number-ops'
+import { formatTokenValue } from '../utils/number-ops'
const scheduledRewardsTooltip = `
This is the reward total you have accrued since your last payout.
@@ -51,7 +51,7 @@ const Dashboard = (): JSX.Element => {
className="w-fit text-header-m font-bold font-number total-earnings"
title={scheduledRewardsTooltip}
>
- {roundToSixDecimalPlaces(scheduledRewards)} FIL
+ {formatTokenValue(scheduledRewards)} FIL
diff --git a/renderer/src/utils/number-ops.ts b/renderer/src/utils/number-ops.ts
index 4104bca47..90ac48313 100644
--- a/renderer/src/utils/number-ops.ts
+++ b/renderer/src/utils/number-ops.ts
@@ -1,5 +1,7 @@
-export function roundToSixDecimalPlaces (number: string | number | undefined) {
- if (!number) return 0
- const roundedNumber = Number(number).toFixed(6) // Round to 6 decimal places
- return roundedNumber.toString()
+export function formatTokenValue (input: string | number | undefined): number {
+ const number = Number(input)
+ if (!input) return 0
+ if (Number.isInteger(number)) return number
+ // decimal cases below
+ return Number(number.toFixed(6))
}
From 9e21efc5127cd206be17ec5e1ae5a3103128dbb5 Mon Sep 17 00:00:00 2001
From: patrickwoodhead <91056047+patrickwoodhead@users.noreply.github.com>
Date: Thu, 7 Dec 2023 13:40:18 +0000
Subject: [PATCH 08/10] Update renderer/src/utils/number-ops.ts
Co-authored-by: Julian Gruber
---
renderer/src/utils/number-ops.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/renderer/src/utils/number-ops.ts b/renderer/src/utils/number-ops.ts
index 90ac48313..1c5cd7a26 100644
--- a/renderer/src/utils/number-ops.ts
+++ b/renderer/src/utils/number-ops.ts
@@ -1,3 +1,4 @@
+// Keep in sync with main/utils.js
export function formatTokenValue (input: string | number | undefined): number {
const number = Number(input)
if (!input) return 0
From ea572156513a8c5636fc245bcac08aade087e467 Mon Sep 17 00:00:00 2001
From: patrickwoodhead
Date: Thu, 7 Dec 2023 14:58:47 +0000
Subject: [PATCH 09/10] make sure value is constantly updated
---
main/wallet.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/main/wallet.js b/main/wallet.js
index 1fcd342b7..1bbcd6546 100644
--- a/main/wallet.js
+++ b/main/wallet.js
@@ -31,7 +31,6 @@ backend.transactions = loadStoredEntries()
/** @type {Context | null} */
let ctx = null
let balance = loadBalance()
-const scheduledRewards = loadScheduledRewards()
/**
* @param {Context} _ctx
@@ -85,7 +84,7 @@ function getBalance () {
* @returns {string}
*/
function getScheduledRewards () {
- return formatEther(scheduledRewards)
+ return formatEther(loadScheduledRewards())
}
// Inline `p-debounce.promise` from
From 16e7da35c9499a3d8786d0d1aa8d833b974e5e11 Mon Sep 17 00:00:00 2001
From: patrickwoodhead <91056047+patrickwoodhead@users.noreply.github.com>
Date: Thu, 7 Dec 2023 15:00:31 +0000
Subject: [PATCH 10/10] Update main/utils.js
Co-authored-by: Julian Gruber
---
main/utils.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/main/utils.js b/main/utils.js
index e1ffff59f..15f0ee7ce 100644
--- a/main/utils.js
+++ b/main/utils.js
@@ -4,6 +4,7 @@
* @param {string | number | undefined} input
* @returns {number}
*/
+// Keep in sync with renderer/src/number-ops.ts
function formatTokenValue (input) {
const number = Number(input)
if (!input) return 0