From e42236f030449485e9410c3c9046be619a52f700 Mon Sep 17 00:00:00 2001 From: Norton Andreev Date: Fri, 20 Dec 2024 14:53:33 +0200 Subject: [PATCH] web-wallet: Refactor "Unshielded" occurrences to "Public" Resolves #3242 --- web-wallet/CHANGELOG.md | 2 + web-wallet/src/__mocks__/mockedWalletStore.js | 9 ++-- .../lib/components/Allocate/Allocate.svelte | 18 +++---- .../src/lib/components/Balance/Balance.svelte | 24 ++++----- .../UsageIndicator/UsageIndicator.svelte | 10 ++-- .../lib/components/__tests__/Balance.spec.js | 12 ++--- .../__snapshots__/Balance.spec.js.snap | 8 +-- .../__snapshots__/UsageIndicator.spec.js.snap | 4 +- .../AllocateContract/AllocateContract.svelte | 10 ++-- .../StakeContract/StakeContract.svelte | 2 +- .../src/lib/mock-data/cache-balances.js | 20 +++---- .../lib/stores/__tests__/walletStore.spec.js | 53 ++++++++++--------- web-wallet/src/lib/stores/stores.d.ts | 4 +- web-wallet/src/lib/stores/walletStore.js | 16 +++--- .../lib/wallet-cache/__tests__/index.spec.js | 14 ++--- web-wallet/src/lib/wallet-cache/index.js | 4 +- .../src/lib/wallet-cache/wallet-cache.d.ts | 4 +- .../src/routes/(app)/dashboard/+layout.svelte | 4 +- .../__snapshots__/layout.spec.js.snap | 10 ++-- .../(app)/dashboard/__tests__/layout.spec.js | 4 +- .../__tests__/__snapshots__/page.spec.js.snap | 4 +- .../(app)/dashboard/receive/+page.svelte | 2 +- .../__tests__/__snapshots__/page.spec.js.snap | 22 ++++---- .../dashboard/receive/__tests__/page.spec.js | 6 +-- .../routes/(app)/dashboard/send/+page.svelte | 10 ++-- .../dashboard/send/__tests__/page.spec.js | 8 +-- .../routes/(app)/dashboard/stake/+page.svelte | 2 +- .../components-showcase/Balances.svelte | 24 ++++----- 28 files changed, 159 insertions(+), 151 deletions(-) diff --git a/web-wallet/CHANGELOG.md b/web-wallet/CHANGELOG.md index 3b99844675..9a62a0466e 100644 --- a/web-wallet/CHANGELOG.md +++ b/web-wallet/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix wrong error shown in the login screen [#3226] [#3097] +- Refactor "Unshielded" occurrences to "Public" [#3242] ## [0.10.1] - 2024-12-18 @@ -466,6 +467,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#3203]: https://github.com/dusk-network/rusk/issues/3203 [#3212]: https://github.com/dusk-network/rusk/issues/3212 [#3226]: https://github.com/dusk-network/rusk/issues/3226 +[#3242]: https://github.com/dusk-network/rusk/issues/3242 diff --git a/web-wallet/src/__mocks__/mockedWalletStore.js b/web-wallet/src/__mocks__/mockedWalletStore.js index 5463953502..55f42238b7 100644 --- a/web-wallet/src/__mocks__/mockedWalletStore.js +++ b/web-wallet/src/__mocks__/mockedWalletStore.js @@ -13,12 +13,15 @@ const profiles = [ await profileGenerator.next(), ]; const currentProfile = profiles[0]; -const shielded = { spendable: 50_000_000_000_000n, value: 2_345_000_000_000n }; -const unshielded = { nonce: 1234n, value: shielded.value / 2n }; +const shieldedBalance = { + spendable: 50_000_000_000_000n, + value: 2_345_000_000_000n, +}; +const publicBalance = { nonce: 1234n, value: shieldedBalance.value / 2n }; /** @type {WalletStoreContent} */ const content = { - balance: { shielded, unshielded }, + balance: { publicBalance, shieldedBalance }, currentProfile, initialized: true, minimumStake: 1_000_000_000_000n, diff --git a/web-wallet/src/lib/components/Allocate/Allocate.svelte b/web-wallet/src/lib/components/Allocate/Allocate.svelte index bc675af24a..7041af322c 100644 --- a/web-wallet/src/lib/components/Allocate/Allocate.svelte +++ b/web-wallet/src/lib/components/Allocate/Allocate.svelte @@ -39,13 +39,13 @@ export let shieldedAddress; /** @type {string} */ - export let unshieldedAddress; + export let publicAddress; /** @type {bigint} */ export let shieldedBalance; /** @type {bigint} */ - export let unshieldedBalance; + export let publicBalance; // @ts-ignore function handleBalanceChange(event) { @@ -109,7 +109,7 @@ let hasEnoughFunds = true; // Constant total - const totalBalance = shieldedBalance + unshieldedBalance; + const totalBalance = shieldedBalance + publicBalance; // Used to keep the difference between the initial shielded balance and the current one const initialShielded = shieldedBalance; @@ -130,7 +130,7 @@ $: hasEnoughFunds = isUnshielding ? shieldedBalance - difference - fee >= 0n - : unshieldedBalance + difference - fee >= 0n; + : publicBalance + difference - fee >= 0n; $: isNextButtonDisabled = !hasEnoughFunds || @@ -197,7 +197,7 @@
{middleEllipsis( - unshieldedAddress, + publicAddress, calculateAdaptiveCharCount(screenWidth, 320, 640, 5, 20) )}
@@ -211,9 +211,9 @@ max={luxToDusk(totalBalance)} min="0" step="0.000000001" - id="unshielded-amount" + id="public-amount" on:input={handleBalanceChange} - name="unshielded-amount" + name="public-amount" />
- {isShielding ? unshieldedAddress : shieldedAddress} + {isShielding ? publicAddress : shieldedAddress}
@@ -308,7 +308,7 @@
- {isUnshielding ? unshieldedAddress : shieldedAddress} + {isUnshielding ? publicAddress : shieldedAddress}
diff --git a/web-wallet/src/lib/components/Balance/Balance.svelte b/web-wallet/src/lib/components/Balance/Balance.svelte index 4d60d374c4..c18f522375 100644 --- a/web-wallet/src/lib/components/Balance/Balance.svelte +++ b/web-wallet/src/lib/components/Balance/Balance.svelte @@ -29,19 +29,19 @@ export let tokenCurrency; /** @type {bigint} */ - export let shieldedAmount; + export let shieldedBalance; /** @type {bigint} */ - export let unshieldedAmount; + export let publicBalance; - $: totalBalance = luxToDusk(shieldedAmount + unshieldedAmount); + $: totalBalance = luxToDusk(shieldedBalance + publicBalance); - $: shieldedPercentage = totalBalance - ? (luxToDusk(shieldedAmount) / totalBalance) * 100 + $: shieldedBalancePercentage = totalBalance + ? (luxToDusk(shieldedBalance) / totalBalance) * 100 : 0; - $: unshieldedPercentage = totalBalance - ? (luxToDusk(unshieldedAmount) / totalBalance) * 100 + $: publicBalancePercentage = totalBalance + ? (luxToDusk(publicBalance) / totalBalance) * 100 : 0; $: classes = makeClassName(["dusk-balance", className]); @@ -75,10 +75,10 @@ path={mdiShieldLock} data-tooltip-id="main-tooltip" data-tooltip-text="Shielded" - />{numberFormatter(shieldedPercentage)}%{numberFormatter(shieldedBalancePercentage)}% {duskFormatter(luxToDusk(shieldedAmount))}{duskFormatter(luxToDusk(shieldedBalance))}{numberFormatter(unshieldedPercentage)}%{numberFormatter(publicBalancePercentage)}% {duskFormatter(luxToDusk(unshieldedAmount))}{duskFormatter(luxToDusk(publicBalance))}
@@ -45,7 +45,7 @@
diff --git a/web-wallet/src/lib/components/__tests__/Balance.spec.js b/web-wallet/src/lib/components/__tests__/Balance.spec.js index 84b6393df6..50ab938b3f 100644 --- a/web-wallet/src/lib/components/__tests__/Balance.spec.js +++ b/web-wallet/src/lib/components/__tests__/Balance.spec.js @@ -8,9 +8,9 @@ describe("Balance", () => { fiatCurrency: "USD", fiatPrice: 10, locale: "en", - shieldedAmount: 1_000_000n, + publicBalance: 2_000_000n, + shieldedBalance: 1_000_000n, tokenCurrency: "DUSK", - unshieldedAmount: 2_000_000n, }; const baseOptions = { @@ -38,9 +38,9 @@ describe("Balance", () => { fiatCurrency: "EUR", fiatPrice: 20, locale: "it", - shieldedAmount: 500_000n, + publicBalance: 2_500_000n, + shieldedBalance: 500_000n, tokenCurrency: "DUSK", - unshieldedAmount: 2_500_000n, }); expect(container.firstChild).toMatchSnapshot(); @@ -56,7 +56,7 @@ describe("Balance", () => { )?.textContent ).toContain("33.33%"); - // Check if unshielded percentage displays as 66.67% + // Check if public percentage displays as 66.67% expect( container.querySelector( ".dusk-balance__account:last-child .dusk-balance__percentage" @@ -67,7 +67,7 @@ describe("Balance", () => { it("should display the right percentage values when balance is zero", async () => { const options = { ...baseOptions, - props: { ...baseProps, shieldedAmount: 0n, unshieldedAmount: 0n }, + props: { ...baseProps, publicBalance: 0n, shieldedBalance: 0n }, }; const { container } = render(Balance, options); diff --git a/web-wallet/src/lib/components/__tests__/__snapshots__/Balance.spec.js.snap b/web-wallet/src/lib/components/__tests__/__snapshots__/Balance.spec.js.snap index d1621be11d..87067b0d33 100644 --- a/web-wallet/src/lib/components/__tests__/__snapshots__/Balance.spec.js.snap +++ b/web-wallet/src/lib/components/__tests__/__snapshots__/Balance.spec.js.snap @@ -91,7 +91,7 @@ exports[`Balance > renders the Balance component 1`] = ` @@ -220,7 +220,7 @@ exports[`Balance > should not display the fiat value if the fiat price is \`unde @@ -349,7 +349,7 @@ exports[`Balance > should update the Balance component when the props change 1`] @@ -478,7 +478,7 @@ exports[`Balance > should update the Balance component when the props change 2`] diff --git a/web-wallet/src/lib/components/__tests__/__snapshots__/UsageIndicator.spec.js.snap b/web-wallet/src/lib/components/__tests__/__snapshots__/UsageIndicator.spec.js.snap index 414a59a9b8..8f27c9dbe3 100644 --- a/web-wallet/src/lib/components/__tests__/__snapshots__/UsageIndicator.spec.js.snap +++ b/web-wallet/src/lib/components/__tests__/__snapshots__/UsageIndicator.spec.js.snap @@ -35,7 +35,7 @@ exports[`UsageIndicator > should render the \`UsageIndicator\` component and rea @@ -82,7 +82,7 @@ exports[`UsageIndicator > should render the \`UsageIndicator\` component and rea diff --git a/web-wallet/src/lib/containers/AllocateContract/AllocateContract.svelte b/web-wallet/src/lib/containers/AllocateContract/AllocateContract.svelte index ede8d60eb7..73cd2ebb24 100644 --- a/web-wallet/src/lib/containers/AllocateContract/AllocateContract.svelte +++ b/web-wallet/src/lib/containers/AllocateContract/AllocateContract.svelte @@ -15,17 +15,15 @@ $: [gasSettings, language] = collectSettings($settingsStore); $: ({ balance, currentProfile } = $walletStore); $: shieldedAddress = currentProfile ? currentProfile.address.toString() : ""; - $: unshieldedAddress = currentProfile - ? currentProfile.account.toString() - : ""; + $: publicAddress = currentProfile ? currentProfile.account.toString() : ""; $: duskFormatter = createCurrencyFormatter(language, "DUSK", 9); {:else if currentOperation === "unstake" || currentOperation === "claim-rewards"} diff --git a/web-wallet/src/lib/mock-data/cache-balances.js b/web-wallet/src/lib/mock-data/cache-balances.js index cedd83219e..bd33d1437e 100644 --- a/web-wallet/src/lib/mock-data/cache-balances.js +++ b/web-wallet/src/lib/mock-data/cache-balances.js @@ -5,28 +5,28 @@ export default [ address: "c3d4e5f6g7h8i9j0A1B2C3D4E5F6G7H8I9J0a1b2c3d4e5f6g7h8i9j0A1B2C3D4E5F6G7H8", balance: { - shielded: { - spendable: 400n * factor, - value: 1234n * factor, - }, - unshielded: { + publicBalance: { nonce: 1n, value: 567n * factor, }, + shieldedBalance: { + spendable: 400n * factor, + value: 1234n * factor, + }, }, }, { address: "B2C3D4E5F6G7H8I9J0a1b2c3d4e5f6g7h8i9j0A1B2C3D4E5F6G7H8I9J0a1b2c3d4e5f6g", balance: { - shielded: { - spendable: 123n * factor, - value: 456n * factor, - }, - unshielded: { + publicPublic: { nonce: 5n, value: 123n * factor, }, + shieldedBalance: { + spendable: 123n * factor, + value: 456n * factor, + }, }, }, ]; diff --git a/web-wallet/src/lib/stores/__tests__/walletStore.spec.js b/web-wallet/src/lib/stores/__tests__/walletStore.spec.js index 7feb161258..514bb4b348 100644 --- a/web-wallet/src/lib/stores/__tests__/walletStore.spec.js +++ b/web-wallet/src/lib/stores/__tests__/walletStore.spec.js @@ -29,14 +29,14 @@ describe("Wallet store", async () => { const AUTO_SYNC_INTERVAL = 5 * 60 * 1000; const cachedBalance = { - shielded: { - spendable: 10n, - value: 5n, - }, - unshielded: { + publicBalance: { nonce: 3n, value: 4n, }, + shieldedBalance: { + spendable: 10n, + value: 5n, + }, }; const cachedStakeInfo = { amount: { @@ -52,14 +52,17 @@ describe("Wallet store", async () => { nonce: 5n, reward: 56789n, }; - const shielded = { + + const shieldedBalance = { spendable: 400000000000000n, value: 1026179647718621n, }; - const unshielded = { + + const publicBalance = { nonce: 1234n, - value: shielded.value / 2n, + value: shieldedBalance.value / 2n, }; + const minimumStake = 1_000_000_000_000n; vi.spyOn(Bookkeeper.prototype, "minimumStake", "get").mockResolvedValue( @@ -74,8 +77,8 @@ describe("Wallet store", async () => { .spyOn(Bookkeeper.prototype, "balance") .mockImplementation(async (identifier) => { return ProfileGenerator.typeOf(identifier.toString()) === "address" - ? shielded - : unshielded; + ? shieldedBalance + : publicBalance; }); const stakeInfoSpy = vi @@ -109,12 +112,12 @@ describe("Wallet store", async () => { const initialState = { balance: { - shielded: { - spendable: 0n, + publicBalance: { + nonce: 0n, value: 0n, }, - unshielded: { - nonce: 0n, + shieldedBalance: { + spendable: 0n, value: 0n, }, }, @@ -139,7 +142,7 @@ describe("Wallet store", async () => { const initializedStore = { ...initialState, - balance: { shielded, unshielded }, + balance: { publicBalance, shieldedBalance }, currentProfile: defaultProfile, initialized: true, minimumStake, @@ -212,8 +215,8 @@ describe("Wallet store", async () => { expect(setCachedBalanceSpy).toHaveBeenCalledWith( defaultProfile.address.toString(), { - shielded: await balanceSpy.mock.results[0].value, - unshielded: await balanceSpy.mock.results[1].value, + publicBalance: await balanceSpy.mock.results[1].value, + shieldedBalance: await balanceSpy.mock.results[0].value, } ); expect(setCachedStakeInfoSpy).toHaveBeenCalledTimes(1); @@ -344,7 +347,7 @@ describe("Wallet store", async () => { const currentlyCachedBalance = await walletCache.getBalanceInfo( defaultProfile.address.toString() ); - const newNonce = currentlyCachedBalance.unshielded.nonce + 1n; + const newNonce = currentlyCachedBalance.publicBalance.nonce + 1n; let expectedTx; @@ -407,8 +410,8 @@ describe("Wallet store", async () => { defaultProfile.address.toString(), { ...currentlyCachedBalance, - unshielded: { - ...currentlyCachedBalance.unshielded, + publicBalance: { + ...currentlyCachedBalance.publicBalance, nonce: newNonce, }, } @@ -461,8 +464,8 @@ describe("Wallet store", async () => { expect(setCachedBalanceSpy).toHaveBeenCalledWith( defaultProfile.address.toString(), { - shielded: await balanceSpy.mock.results[0].value, - unshielded: await balanceSpy.mock.results[1].value, + publicBalance: await balanceSpy.mock.results[1].value, + shieldedBalance: await balanceSpy.mock.results[0].value, } ); expect(setCachedStakeInfoSpy).toHaveBeenCalledTimes(1); @@ -518,7 +521,7 @@ describe("Wallet store", async () => { await walletStoreTransferCheck("claimRewards", [amount, gas]); }); - it("should expose a method to shield a given amount from the unshielded account", async () => { + it("should expose a method to shield a given amount from the public account", async () => { await walletStoreTransferCheck("shield", [amount, gas]); }); @@ -648,8 +651,8 @@ describe("Wallet store", async () => { expect(setCachedBalanceSpy).toHaveBeenCalledWith( fakeExtraProfile.address.toString(), { - shielded: await balanceSpy.mock.results[0].value, - unshielded: await balanceSpy.mock.results[1].value, + publicBalance: await balanceSpy.mock.results[1].value, + shieldedBalance: await balanceSpy.mock.results[0].value, } ); expect(setCachedStakeInfoSpy).toHaveBeenCalledTimes(1); diff --git a/web-wallet/src/lib/stores/stores.d.ts b/web-wallet/src/lib/stores/stores.d.ts index e325990b69..e6c10f292e 100644 --- a/web-wallet/src/lib/stores/stores.d.ts +++ b/web-wallet/src/lib/stores/stores.d.ts @@ -80,8 +80,8 @@ type NodeInfo = { }; type WalletStoreBalance = { - shielded: AddressBalance; - unshielded: AccountBalance; + shieldedBalance: AddressBalance; + publicBalance: AccountBalance; }; type WalletStoreContent = { diff --git a/web-wallet/src/lib/stores/walletStore.js b/web-wallet/src/lib/stores/walletStore.js index 52d2c01970..72d78a6109 100644 --- a/web-wallet/src/lib/stores/walletStore.js +++ b/web-wallet/src/lib/stores/walletStore.js @@ -27,12 +27,12 @@ let syncPromise = null; /** @type {WalletStoreContent} */ const initialState = { balance: { - shielded: { - spendable: 0n, + publicBalance: { + nonce: 0n, value: 0n, }, - unshielded: { - nonce: 0n, + shieldedBalance: { + spendable: 0n, value: 0n, }, }, @@ -104,7 +104,7 @@ const updateCacheAfterTransaction = async (txInfo) => { */ await walletCache.setBalanceInfo( address, - setPathIn(currentBalance, "unshielded.nonce", txInfo.nonce) + setPathIn(currentBalance, "public.nonce", txInfo.nonce) ); } @@ -119,9 +119,9 @@ const updateBalance = async () => { return; } - const shielded = await bookkeeper.balance(currentProfile.address); - const unshielded = await bookkeeper.balance(currentProfile.account); - const balance = { shielded, unshielded }; + const shieldedBalance = await bookkeeper.balance(currentProfile.address); + const publicBalance = await bookkeeper.balance(currentProfile.account); + const balance = { publicBalance, shieldedBalance }; /** * We ignore the error as the cached balance is only diff --git a/web-wallet/src/lib/wallet-cache/__tests__/index.spec.js b/web-wallet/src/lib/wallet-cache/__tests__/index.spec.js index a778576189..7c8ec2e9ad 100644 --- a/web-wallet/src/lib/wallet-cache/__tests__/index.spec.js +++ b/web-wallet/src/lib/wallet-cache/__tests__/index.spec.js @@ -94,8 +94,8 @@ describe("Wallet cache", () => { await expect( walletCache.getBalanceInfo("fake-address") ).resolves.toStrictEqual({ - shielded: { spendable: 0n, value: 0n }, - unshielded: { nonce: 0n, value: 0n }, + publicBalance: { nonce: 0n, value: 0n }, + shieldedBalance: { spendable: 0n, value: 0n }, }); }); @@ -596,14 +596,14 @@ describe("Wallet cache", () => { const newBalance = { address: "fake-address", balance: { - shielded: { - spendable: 123n, - value: 456n, - }, - unshielded: { + publicBalance: { nonce: 7n, value: 345n, }, + shieldedBalance: { + spendable: 123n, + value: 456n, + }, }, }; diff --git a/web-wallet/src/lib/wallet-cache/index.js b/web-wallet/src/lib/wallet-cache/index.js index 3d0093d64d..f54f361d32 100644 --- a/web-wallet/src/lib/wallet-cache/index.js +++ b/web-wallet/src/lib/wallet-cache/index.js @@ -61,8 +61,8 @@ class WalletCache { /** @type {WalletCacheBalanceInfo["balance"]} */ #emptyBalanceInfo = Object.freeze({ - shielded: { spendable: 0n, value: 0n }, - unshielded: { nonce: 0n, value: 0n }, + publicBalance: { nonce: 0n, value: 0n }, + shieldedBalance: { spendable: 0n, value: 0n }, }); /** @type {StakeInfo} */ diff --git a/web-wallet/src/lib/wallet-cache/wallet-cache.d.ts b/web-wallet/src/lib/wallet-cache/wallet-cache.d.ts index 067f9e341a..5bf5b25122 100644 --- a/web-wallet/src/lib/wallet-cache/wallet-cache.d.ts +++ b/web-wallet/src/lib/wallet-cache/wallet-cache.d.ts @@ -14,8 +14,8 @@ type NotesSyncInfo = { type WalletCacheBalanceInfo = { address: string; balance: { - shielded: AddressBalance; - unshielded: AccountBalance; + publicBalance: AccountBalance; + shieldedBalance: AddressBalance; }; }; diff --git a/web-wallet/src/routes/(app)/dashboard/+layout.svelte b/web-wallet/src/routes/(app)/dashboard/+layout.svelte index ac9c5fe0a4..534fb980db 100644 --- a/web-wallet/src/routes/(app)/dashboard/+layout.svelte +++ b/web-wallet/src/routes/(app)/dashboard/+layout.svelte @@ -84,8 +84,8 @@ {fiatPrice} locale={language} tokenCurrency="DUSK" - shieldedAmount={balance.shielded.value} - unshieldedAmount={balance.unshielded.value} + shieldedBalance={balance.shieldedBalance.value} + publicBalance={balance.publicBalance.value} /> diff --git a/web-wallet/src/routes/(app)/dashboard/__tests__/__snapshots__/layout.spec.js.snap b/web-wallet/src/routes/(app)/dashboard/__tests__/__snapshots__/layout.spec.js.snap index 0d8d626a0a..08524af650 100644 --- a/web-wallet/src/routes/(app)/dashboard/__tests__/__snapshots__/layout.spec.js.snap +++ b/web-wallet/src/routes/(app)/dashboard/__tests__/__snapshots__/layout.spec.js.snap @@ -122,7 +122,7 @@ exports[`Dashboard Layout > should render the dashboard layout 1`] = ` @@ -348,7 +348,7 @@ exports[`Dashboard Layout > should render the dashboard layout and show a throbb @@ -574,7 +574,7 @@ exports[`Dashboard Layout > should render the dashboard layout in the error stat @@ -821,7 +821,7 @@ exports[`Dashboard Layout > should render the dashboard layout in the sync state @@ -1055,7 +1055,7 @@ exports[`Dashboard Layout > should render the dashboard layout in the sync state diff --git a/web-wallet/src/routes/(app)/dashboard/__tests__/layout.spec.js b/web-wallet/src/routes/(app)/dashboard/__tests__/layout.spec.js index 92b024b7c5..7cafebdb89 100644 --- a/web-wallet/src/routes/(app)/dashboard/__tests__/layout.spec.js +++ b/web-wallet/src/routes/(app)/dashboard/__tests__/layout.spec.js @@ -143,8 +143,8 @@ describe("Dashboard Layout", () => { const usdPrice = 0.5; const expectedFiat = - (luxToDusk(get(mockedWalletStore).balance.shielded.value) + - luxToDusk(get(mockedWalletStore).balance.unshielded.value)) * + (luxToDusk(get(mockedWalletStore).balance.shieldedBalance.value) + + luxToDusk(get(mockedWalletStore).balance.publicBalance.value)) * usdPrice; const formatter = createCurrencyFormatter("en", "usd", 2); const baseProps = { diff --git a/web-wallet/src/routes/(app)/dashboard/allocate/__tests__/__snapshots__/page.spec.js.snap b/web-wallet/src/routes/(app)/dashboard/allocate/__tests__/__snapshots__/page.spec.js.snap index 7e1b291405..d40f110974 100644 --- a/web-wallet/src/routes/(app)/dashboard/allocate/__tests__/__snapshots__/page.spec.js.snap +++ b/web-wallet/src/routes/(app)/dashboard/allocate/__tests__/__snapshots__/page.spec.js.snap @@ -145,10 +145,10 @@ exports[`Allocate > should render the allocation page 1`] = ` >
@@ -73,17 +73,17 @@ exports[`Receive > should change the icon to "unshielded" and show the unshielde
@@ -168,7 +168,7 @@ exports[`Receive > should change the icon to "unshielded" and show the unshielde
`; -exports[`Receive > should render the receive page with a double icon and a choice to switch from shielded to unshielded address 1`] = ` +exports[`Receive > should render the receive page with a double icon and a choice to switch from shielded to public address 1`] = `
@@ -241,17 +241,17 @@ exports[`Receive > should render the receive page with a double icon and a choic
@@ -336,7 +336,7 @@ exports[`Receive > should render the receive page with a double icon and a choic `; -exports[`Receive > should render the receive page with a single icon and no choice for shielded / unshielded if the feature flag is not true 1`] = ` +exports[`Receive > should render the receive page with a single icon and no choice for shielded / public if the feature flag is not true 1`] = `
diff --git a/web-wallet/src/routes/(app)/dashboard/receive/__tests__/page.spec.js b/web-wallet/src/routes/(app)/dashboard/receive/__tests__/page.spec.js index d8d582bb6f..ccf5edabfe 100644 --- a/web-wallet/src/routes/(app)/dashboard/receive/__tests__/page.spec.js +++ b/web-wallet/src/routes/(app)/dashboard/receive/__tests__/page.spec.js @@ -48,7 +48,7 @@ describe("Receive", () => { vi.useRealTimers(); }); - it("should render the receive page with a single icon and no choice for shielded / unshielded if the feature flag is not true", async () => { + it("should render the receive page with a single icon and no choice for shielded / public if the feature flag is not true", async () => { vi.stubEnv("VITE_FEATURE_ALLOCATE", "false"); const { container, getByRole, getByText } = render(Receive); @@ -63,7 +63,7 @@ describe("Receive", () => { vi.unstubAllEnvs(); }); - it("should render the receive page with a double icon and a choice to switch from shielded to unshielded address", async () => { + it("should render the receive page with a double icon and a choice to switch from shielded to public address", async () => { const { container, getByRole, getByText } = render(Receive); await vi.runAllTimersAsync(); @@ -74,7 +74,7 @@ describe("Receive", () => { expect(container.firstChild).toMatchSnapshot(); }); - it('should change the icon to "unshielded" and show the unshielded address when the user makes such choice', async () => { + it('should change the icon to "public" and show the public address when the user makes such choice', async () => { const { container, getByRole, getByText } = render(Receive); await vi.runAllTimersAsync(); diff --git a/web-wallet/src/routes/(app)/dashboard/send/+page.svelte b/web-wallet/src/routes/(app)/dashboard/send/+page.svelte index 825ccfc268..098738536d 100644 --- a/web-wallet/src/routes/(app)/dashboard/send/+page.svelte +++ b/web-wallet/src/routes/(app)/dashboard/send/+page.svelte @@ -9,12 +9,12 @@ import { createCurrencyFormatter, luxToDusk } from "$lib/dusk/currency"; import { gasStore, settingsStore, walletStore } from "$lib/stores"; - /** @type {(source: "shielded" | "unshielded", balanceInfo: WalletStoreBalance) => [bigint, ContractStatus[]]}*/ + /** @type {(source: "shielded" | "public", balanceInfo: WalletStoreBalance) => [bigint, ContractStatus[]]}*/ function getContractInfo(source, balanceInfo) { const spendable = source === "shielded" - ? balanceInfo.shielded.spendable - : balanceInfo.unshielded.value; + ? balanceInfo.shieldedBalance.spendable + : balanceInfo.publicBalance.value; const statuses = [ { label: "Spendable", @@ -31,7 +31,7 @@ ]); const gasLimits = $gasStore; - /** @type {"shielded" | "unshielded"} */ + /** @type {"shielded" | "public"} */ let spendableSource = "shielded"; /** @@ -39,7 +39,7 @@ */ function keyChangeHandler(event) { if (event.detail.type === "account") { - spendableSource = "unshielded"; + spendableSource = "public"; } else { spendableSource = "shielded"; } diff --git a/web-wallet/src/routes/(app)/dashboard/send/__tests__/page.spec.js b/web-wallet/src/routes/(app)/dashboard/send/__tests__/page.spec.js index dfb6e8d441..9bb1653637 100644 --- a/web-wallet/src/routes/(app)/dashboard/send/__tests__/page.spec.js +++ b/web-wallet/src/routes/(app)/dashboard/send/__tests__/page.spec.js @@ -28,8 +28,10 @@ vi.mock("$lib/stores", async (importOriginal) => { const formatter = createCurrencyFormatter("en", "DUSK", 9); const { balance, currentProfile } = mockedWalletStore.getMockedStoreValue(); -const formattedShielded = formatter(luxToDusk(balance.shielded.spendable)); -const formattedUnshielded = formatter(luxToDusk(balance.unshielded.value)); +const formattedShielded = formatter( + luxToDusk(balance.shieldedBalance.spendable) +); +const formattedPublic = formatter(luxToDusk(balance.publicBalance.value)); describe("Send page", () => { afterEach(cleanup); @@ -59,7 +61,7 @@ describe("Send page", () => { expect( container.querySelector(".contract-statuses__value") - ).toHaveTextContent(formattedUnshielded); + ).toHaveTextContent(formattedPublic); await fireEvent.input(addressTextbox, { target: { value: currentProfile.address.toString() }, diff --git a/web-wallet/src/routes/(app)/dashboard/stake/+page.svelte b/web-wallet/src/routes/(app)/dashboard/stake/+page.svelte index 68180db2aa..e93a912e40 100644 --- a/web-wallet/src/routes/(app)/dashboard/stake/+page.svelte +++ b/web-wallet/src/routes/(app)/dashboard/stake/+page.svelte @@ -55,7 +55,7 @@ $: statuses = [ { label: "Spendable", - value: duskFormatter(luxToDusk(balance.unshielded.value)), + value: duskFormatter(luxToDusk(balance.publicBalance.value)), }, { label: "Active Stake", diff --git a/web-wallet/src/routes/components-showcase/Balances.svelte b/web-wallet/src/routes/components-showcase/Balances.svelte index f3bff0a1cd..543af6f22d 100644 --- a/web-wallet/src/routes/components-showcase/Balances.svelte +++ b/web-wallet/src/routes/components-showcase/Balances.svelte @@ -1,11 +1,11 @@
@@ -14,8 +14,8 @@ fiatPrice={10} locale="en" tokenCurrency="DUSK" - {shieldedAmount} - {unshieldedAmount} + {shieldedBalance} + {publicBalance} />