Skip to content

Commit

Permalink
Merge pull request #3254 from dusk-network/feature-3246
Browse files Browse the repository at this point in the history
web-wallet: Remove VITE_FEATURE_MOONLIGHT_TRANSACTIONS flag
  • Loading branch information
nortonandreev authored Dec 20, 2024
2 parents d6a3752 + f5ff92d commit 60d4280
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 202 deletions.
1 change: 1 addition & 0 deletions web-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Remove Beta ribbon [#3164]
- Remove "UsageIndicator" component [#3245]
- Remove "VITE_FEATURE_MOONLIGHT_TRANSACTIONS" flag [#3246]

### Fixed

Expand Down
1 change: 0 additions & 1 deletion web-wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ N.B. the current `0.1.2` version of the library has no option to pick the networ
VITE_BASE_PATH=""
VITE_FEATURE_ALLOCATE=true
VITE_FEATURE_MIGRATE=true
VITE_FEATURE_MOONLIGHT_TRANSACTIONS=true
VITE_FEATURE_STAKE=true
VITE_FEATURE_TRANSFER=true
VITE_FEATURE_TRANSACTION_HISTORY=true
Expand Down
41 changes: 7 additions & 34 deletions web-wallet/src/lib/components/Send/Send.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
/** @type {GasStoreContent} */
export let gasLimits;
/** @type {boolean} */
export let enableMoonlightTransactions = false;
/** @type {string} */
export let shieldedAddress;
Expand Down Expand Up @@ -110,21 +107,6 @@
let activeStep = 0;
/**
* Validates an address/account depending on moonlight transactions being enabled.
*
* Note. This function can be removed when the VITE_FEATURE_MOONLIGHT_TRANSACTIONS flag is removed.
*
* @param {{isValid: boolean, type?: "address" | "account", isSelfReferential? : boolean}} addressInfo
*/
function isValid(addressInfo) {
return !addressInfo.isValid
? true
: isMoonlightTransaction
? !enableMoonlightTransactions
: false;
}
$: sendAmountInLux = sendAmount ? duskToLux(sendAmount) : 0n;
// Calculate the maximum gas fee based on the gas limit and gas price.
Expand Down Expand Up @@ -166,8 +148,6 @@
publicAddress
);
$: isMoonlightTransaction = addressInfo.type === "account";
$: if (addressInfo.type) {
dispatch("keyChange", {
type: addressInfo.type,
Expand All @@ -191,7 +171,7 @@
}}
nextButton={{
action: () => activeStep++,
disabled: isValid(addressInfo),
disabled: !addressInfo.isValid,
}}
>
<div in:fade|global class="operation__send">
Expand All @@ -213,19 +193,12 @@
bind:value={sendToAddress}
/>
{#if addressInfo.type === "account"}
<Banner
title="Public account detected"
variant={enableMoonlightTransactions ? "info" : "warning"}
>
{#if enableMoonlightTransactions}
<p>
This transaction will be public and sent from your <strong
>public</strong
> account.
</p>
{:else}
<p>Public transactions are currently unavailable.</p>
{/if}
<Banner title="Public account detected" variant="info">
<p>
This transaction will be public and sent from your <strong
>public</strong
> account.
</p>
</Banner>
{/if}
<ScanQR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ exports[`Send > Address step > should display a warning if the address input is
<div
class="banner banner--warning"
class="banner banner--info"
>
<svg
class="dusk-icon dusk-icon--size--large banner__icon banner__icon--warning"
class="dusk-icon dusk-icon--size--large banner__icon banner__icon--info"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16"
d="M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z"
/>
</svg>
Expand All @@ -129,9 +129,12 @@ exports[`Send > Address step > should display a warning if the address input is
</strong>
<p>
Public transactions are currently unavailable.
This transaction will be public and sent from your
<strong>
public
</strong>
account.
</p>
</div>
</div>
Expand Down Expand Up @@ -195,7 +198,6 @@ exports[`Send > Address step > should display a warning if the address input is
<button
class="dusk-button dusk-button--type--button dusk-button--variant--tertiary dusk-button--size--default dusk-icon-button--labeled"
disabled=""
type="button"
>
<span
Expand Down Expand Up @@ -336,15 +338,15 @@ exports[`Send > Address step > should display a warning if the address input is
<div
class="banner banner--warning"
class="banner banner--info"
>
<svg
class="dusk-icon dusk-icon--size--large banner__icon banner__icon--warning"
class="dusk-icon dusk-icon--size--large banner__icon banner__icon--info"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16"
d="M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z"
/>
</svg>
Expand All @@ -357,9 +359,12 @@ exports[`Send > Address step > should display a warning if the address input is
</strong>
<p>
Public transactions are currently unavailable.
This transaction will be public and sent from your
<strong>
public
</strong>
account.
</p>
</div>
</div>
Expand Down Expand Up @@ -452,7 +457,6 @@ exports[`Send > Address step > should display a warning if the address input is
<button
class="dusk-button dusk-button--type--button dusk-button--variant--tertiary dusk-button--size--default dusk-icon-button--labeled"
disabled=""
type="button"
>
<span
Expand Down
16 changes: 5 additions & 11 deletions web-wallet/src/routes/(app)/dashboard/receive/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@
$: currentAddress = currentProfile
? currentProfile[addressProp].toString()
: "";
$: icons =
import.meta.env.VITE_FEATURE_ALLOCATE === "true"
? [
mdiArrowBottomLeftThin,
addressToShow === "shielded" ? mdiShieldLock : mdiShieldLockOpen,
]
: [mdiArrowBottomLeftThin];
$: icons = [
mdiArrowBottomLeftThin,
addressToShow === "shielded" ? mdiShieldLock : mdiShieldLockOpen,
];
</script>

<IconHeadingCard gap="medium" heading="Receive" {icons}>
{#if import.meta.env.VITE_FEATURE_ALLOCATE === "true"}
<ExclusiveChoice {options} bind:value={addressToShow} />
{/if}

<ExclusiveChoice {options} bind:value={addressToShow} />
<Receive address={currentAddress} />
</IconHeadingCard>
Original file line number Diff line number Diff line change
Expand Up @@ -335,127 +335,3 @@ exports[`Receive > should render the receive page with a double icon and a choic
</div>
`;

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`] = `
<div
class="dusk-card dusk-card--gap-medium"
>
<div
class="dusk-card__header-container"
>
<header
class="dusk-card__header"
slot="header"
>
<div
class="dusk-card__heading-container"
>
<h3
class="h4"
>
Receive
</h3>
<div
class="dusk-card__heading-icons"
>
<svg
class="dusk-icon dusk-icon--size--default"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M12.07 19L9.24 16.18L19 6.42L17.58 5L7.82 14.76L5 11.94V19Z"
/>
</svg>
</div>
</div>
</header>
</div>
<div
class="dusk-card__body-container"
>
<div
class="receive svelte-14g7par"
>
<figure
class="receive__address-qr-figure svelte-14g7par"
>
<img
alt="Key QR code"
class="dusk-qr-code receive__qr"
height="0"
src="data:image/png;base64,00"
width="0"
/>
<figcaption
class="receive__address svelte-14g7par"
>
<samp>
2zFZwXf4JEvD2Vmd4kqx5tHDv73LkRr2Ydb84Knr2gmFJJoEEpZPtTbuQCrojM85QDHAvosxoZdnpLPSNRqzqmai
</samp>
</figcaption>
</figure>
<div
class="receive__buttons svelte-14g7par"
>
<a
aria-disabled="false"
class="dusk-anchor dusk-anchor--on-surface dusk-anchor-button dusk-anchor-button--variant--tertiary dusk-anchor-button--size--default dusk-icon-button--labeled receive__button"
href="/some-base-path/dashboard"
>
<svg
class="dusk-icon dusk-icon--size--default dusk-anchor-button__icon"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"
/>
</svg>
<span
class="dusk-anchor-button__text"
>
Back
</span>
</a>
<button
class="dusk-button dusk-button--type--button dusk-button--variant--primary dusk-button--size--default dusk-icon-button--labeled receive__button"
type="button"
>
<svg
class="dusk-icon dusk-icon--size--default dusk-button__icon"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"
/>
</svg>
<span
class="dusk-button__text"
>
Copy
</span>
</button>
</div>
</div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@ 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 () => {
vi.stubEnv("VITE_FEATURE_ALLOCATE", "false");

const { container, getByRole, getByText } = render(Receive);

await vi.runAllTimersAsync();

expect(() => getByRole("radiogroup")).toThrow();
expect(getByText(expectedAddress)).toBeInTheDocument();
expect(() => getByText(expectedAccount)).toThrow();
expect(container.firstChild).toMatchSnapshot();

vi.unstubAllEnvs();
});

it("should render the receive page with a double icon and a choice to switch from shielded to unshielded address", async () => {
const { container, getByRole, getByText } = render(Receive);

Expand Down
2 changes: 0 additions & 2 deletions web-wallet/src/routes/(app)/dashboard/send/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@
{gasLimits}
{gasSettings}
availableBalance={spendable}
enableMoonlightTransactions={import.meta.env
.VITE_FEATURE_MOONLIGHT_TRANSACTIONS === "true"}
on:keyChange={keyChangeHandler}
/>
</IconHeadingCard>
3 changes: 0 additions & 3 deletions web-wallet/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export default defineConfig(({ mode }) => {
MODE_MAINTENANCE: env.VITE_MODE_MAINTENANCE,
VITE_FEATURE_ALLOCATE: env.VITE_FEATURE_ALLOCATE,
VITE_FEATURE_MIGRATE: env.VITE_FEATURE_MIGRATE,
VITE_FEATURE_MOONLIGHT_TRANSACTIONS:
env.VITE_FEATURE_MOONLIGHT_TRANSACTIONS,
VITE_FEATURE_STAKE: env.VITE_FEATURE_STAKE,
VITE_FEATURE_TRANSACTION_HISTORY: env.VITE_FEATURE_TRANSACTION_HISTORY,
VITE_FEATURE_TRANSFER: env.VITE_FEATURE_TRANSFER,
Expand Down Expand Up @@ -89,7 +87,6 @@ export default defineConfig(({ mode }) => {
APP_VERSION: "0.1.5",
VITE_FEATURE_ALLOCATE: "true",
VITE_FEATURE_MIGRATE: "true",
VITE_FEATURE_MOONLIGHT_TRANSACTIONS: "true",
VITE_FEATURE_STAKE: "true",
VITE_FEATURE_TRANSACTION_HISTORY: "true",
VITE_FEATURE_TRANSFER: "true",
Expand Down

0 comments on commit 60d4280

Please sign in to comment.