diff --git a/packages/desktop/components/AccountSwitcher.svelte b/packages/desktop/components/AccountSwitcher.svelte
index d3ad16cc95..30307137d0 100644
--- a/packages/desktop/components/AccountSwitcher.svelte
+++ b/packages/desktop/components/AccountSwitcher.svelte
@@ -9,7 +9,6 @@
import { PopupId, openPopup } from '@desktop/auxiliary/popup'
export let breadcrumb: boolean = false
- export let compact: boolean = false
export let hasCreateAccount: boolean = false
export let placement: 'bottom-start' | 'bottom-end' = 'bottom-start'
@@ -30,7 +29,19 @@
onClick: () => onAccountClick(account.index),
}
})
+
+ const totalBalance = Object.values($allAccountFiatBalances)
+ .reduce((acc, balance) => Number(acc) + Number(balance), 0)
+ .toString()
+
+ items = items.concat({
+ title: localize('general.totalBalance'),
+ subtitle: formatCurrency(totalBalance),
+ selected: false,
+ hidden: accounts.length < 2,
+ })
}
+
$: setItems($visibleActiveAccounts, $selectedAccount?.index)
function onCreateAccountClick(): void {
@@ -41,7 +52,7 @@
{/if}
-
-
+
+
{$selectedAccount?.name}
{#if !breadcrumb}
-
+
{/if}
diff --git a/packages/desktop/views/dashboard/components/Breadcrumbs.svelte b/packages/desktop/views/dashboard/components/Breadcrumbs.svelte
index ca23898239..7c40b45567 100644
--- a/packages/desktop/views/dashboard/components/Breadcrumbs.svelte
+++ b/packages/desktop/views/dashboard/components/Breadcrumbs.svelte
@@ -66,7 +66,7 @@
/>
",
"license": "PolyForm Strict License 1.0.0",
"dependencies": {
- "@bloomwalletio/ui": "0.21.1",
+ "@bloomwalletio/ui": "0.21.3",
"@ethereumjs/common": "4.3.0",
"@ethereumjs/rlp": "5.0.2",
"@ethereumjs/tx": "5.3.0",
@@ -16,7 +16,7 @@
"@metamask/eth-sig-util": "7.0.1",
"@spruceid/siwe-parser": "2.0.2",
"@sveltejs/svelte-virtual-list": "3.0.1",
- "@walletconnect/jsonrpc-types": "1.0.3",
+ "@walletconnect/jsonrpc-types": "1.0.4",
"@walletconnect/types": "2.11.3",
"@walletconnect/web3wallet": "1.11.2",
"http-status-codes": "2.3.0",
diff --git a/packages/shared/src/lib/core/utils/convert.ts b/packages/shared/src/lib/core/utils/convert.ts
index f25d1b90e4..685d3bacb2 100644
--- a/packages/shared/src/lib/core/utils/convert.ts
+++ b/packages/shared/src/lib/core/utils/convert.ts
@@ -273,12 +273,28 @@ export class Converter {
* @returns The bytes.
*/
public static bigIntLikeToBigInt(number: BigIntLike | undefined): bigint {
+ if (number === undefined || number === null || Number.isNaN(number)) {
+ return BigInt(0)
+ }
+
if (ArrayBuffer.isView(number)) {
return bytesToBigInt(number)
- } else {
- number = number === '0x' ? '0x0' : number
- return BigInt(String(number ?? '0'))
}
+
+ if (typeof number === 'string') {
+ if (number === '0x') {
+ return BigInt('0x0')
+ }
+ if (/\d+\.?\d*e[+-]?\d+/i.test(number)) {
+ number = Number(number)
+ }
+ }
+
+ if (typeof number === 'number' && !Number.isInteger(number)) {
+ number = Math.floor(number)
+ }
+
+ return BigInt(number)
}
/**
diff --git a/packages/shared/src/lib/core/utils/tests/convert.test.ts b/packages/shared/src/lib/core/utils/tests/convert.test.ts
index c789f75102..75eeda5d33 100644
--- a/packages/shared/src/lib/core/utils/tests/convert.test.ts
+++ b/packages/shared/src/lib/core/utils/tests/convert.test.ts
@@ -61,7 +61,30 @@ describe('File: convert.ts', () => {
expect(Converter.bigIntLikeToBigInt('0')).toEqual(BigInt(0))
expect(Converter.bigIntLikeToBigInt(100)).toEqual(BigInt(100))
expect(Converter.bigIntLikeToBigInt('123330')).toEqual(BigInt(123330))
+ })
+ it('should handle floats by truncating', () => {
+ expect(Converter.bigIntLikeToBigInt(123.456)).toEqual(BigInt(123))
+ })
+ it('should handle scientific notation', () => {
+ expect(Converter.bigIntLikeToBigInt('1e6')).toEqual(BigInt(1000000))
+ expect(Converter.bigIntLikeToBigInt('1.23e3')).toEqual(BigInt(1230))
+ expect(Converter.bigIntLikeToBigInt('-1e6')).toEqual(BigInt(-1000000))
+ expect(Converter.bigIntLikeToBigInt('1.23e-3')).toEqual(BigInt(0))
+ })
+ it('should handle string representations of numbers', () => {
+ expect(Converter.bigIntLikeToBigInt('123456789012345678901234567890')).toEqual(
+ BigInt('123456789012345678901234567890')
+ )
+ expect(Converter.bigIntLikeToBigInt('-123456789012345678901234567890')).toEqual(
+ BigInt('-123456789012345678901234567890')
+ )
+ })
+ it('should handle edge cases', () => {
+ expect(Converter.bigIntLikeToBigInt('')).toEqual(BigInt(0))
expect(Converter.bigIntLikeToBigInt(undefined)).toEqual(BigInt(0))
+ expect(Converter.bigIntLikeToBigInt(null)).toEqual(BigInt(0))
+ expect(Converter.bigIntLikeToBigInt(NaN)).toEqual(BigInt(0))
+ expect(Converter.bigIntLikeToBigInt(false)).toEqual(BigInt(0))
})
})
})
diff --git a/packages/shared/src/locales/en.json b/packages/shared/src/locales/en.json
index 4008a99610..88dee42bac 100644
--- a/packages/shared/src/locales/en.json
+++ b/packages/shared/src/locales/en.json
@@ -1738,7 +1738,8 @@
"average": "Average",
"fast": "Fast",
"spender": "Spender",
- "status": "Status"
+ "status": "Status",
+ "totalBalance": "Total balance"
},
"filters":{
"title": "Filters",
diff --git a/yarn.lock b/yarn.lock
index f93a43fbce..0290cd502a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -343,10 +343,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
-"@bloomwalletio/ui@0.21.1":
- version "0.21.1"
- resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.21.1/ce60ed69ad083f7ebc27164cc2fa69c8bf1a041f#ce60ed69ad083f7ebc27164cc2fa69c8bf1a041f"
- integrity sha512-1//FX06CFUvv2SXUHQGZwQ9Y8FbO/Irj8cYO3cVXNbQHiM93UCtxgb/jYmryaOSHBrhH7OtrzDt+/0Hg88BA1w==
+"@bloomwalletio/ui@0.21.3":
+ version "0.21.3"
+ resolved "https://npm.pkg.github.com/download/@bloomwalletio/ui/0.21.3/2bf5587205e01b89f67cd6b990495d3a1175b5de#2bf5587205e01b89f67cd6b990495d3a1175b5de"
+ integrity sha512-McwM3nbGmGkkq8zJAWBfriMvSDXXurTrqL26vHrTbNP1LNJJSujRo4o2Oep0sjf1xeQRoHy7HZSPVml/EKwF/g==
dependencies:
"@floating-ui/dom" "1.4.3"
"@popperjs/core" "2.11.8"
@@ -2840,6 +2840,14 @@
keyvaluestorage-interface "^1.0.0"
tslib "1.14.1"
+"@walletconnect/jsonrpc-types@1.0.4":
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/@walletconnect/jsonrpc-types/-/jsonrpc-types-1.0.4.tgz#ce1a667d79eadf2a2d9d002c152ceb68739c230c"
+ integrity sha512-P6679fG/M+wuWg9TY8mh6xFSdYnFyFjwFelxyISxMDrlbXokorEVXYOxiqEbrU3x1BmBoCAJJ+vtEaEoMlpCBQ==
+ dependencies:
+ events "^3.3.0"
+ keyvaluestorage-interface "^1.0.0"
+
"@walletconnect/jsonrpc-utils@1.0.8", "@walletconnect/jsonrpc-utils@^1.0.6", "@walletconnect/jsonrpc-utils@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@walletconnect/jsonrpc-utils/-/jsonrpc-utils-1.0.8.tgz#82d0cc6a5d6ff0ecc277cb35f71402c91ad48d72"
@@ -9903,7 +9911,16 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"
-"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
+"string-width-cjs@npm:string-width@^4.2.0":
+ version "4.2.3"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
+ integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
+ dependencies:
+ emoji-regex "^8.0.0"
+ is-fullwidth-code-point "^3.0.0"
+ strip-ansi "^6.0.1"
+
+string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -9980,7 +9997,14 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"
-"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
+"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
+ integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
+ dependencies:
+ ansi-regex "^5.0.1"
+
+strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -11347,7 +11371,16 @@ word-wrap@^1.2.5:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
-"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
+"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
+ version "7.0.0"
+ resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
+ integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
+ dependencies:
+ ansi-styles "^4.0.0"
+ string-width "^4.1.0"
+ strip-ansi "^6.0.0"
+
+wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==