Skip to content

Commit

Permalink
Merge pull request #2233 from dusk-network/feature-2175-split-transfe…
Browse files Browse the repository at this point in the history
…r-view

web-wallet: Split transfer contract UI
  • Loading branch information
kieranhall authored Sep 1, 2024
2 parents d59475d + 50bab51 commit f2990d2
Show file tree
Hide file tree
Showing 18 changed files with 578 additions and 318 deletions.
3 changes: 3 additions & 0 deletions web-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update Buttons to match the design system [#1606]
- Update `Stepper` component to new design [#2071]
- Update dashboard to use routes instead of `Tabs` for navigation pattern [#2075]
- Update dashboard by splitting the transfer operations into send and receive operations [#2175]

### Fixed

Expand Down Expand Up @@ -238,7 +239,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2026]: https://github.com/dusk-network/rusk/issues/2026
[#2000]: https://github.com/dusk-network/rusk/issues/2000
[#2071]: https://github.com/dusk-network/rusk/issues/2071
[#2071]: https://github.com/dusk-network/rusk/issues/2075
[#2118]: https://github.com/dusk-network/rusk/issues/2118
[#2118]: https://github.com/dusk-network/rusk/issues/2175

<!-- VERSIONS -->

Expand Down
10 changes: 3 additions & 7 deletions web-wallet/src/lib/components/Receive/Receive.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<svelte:options immutable={true} />

<script>
import { createEventDispatcher } from "svelte";
import { mdiArrowLeft, mdiContentCopy } from "@mdi/js";
import { AppAnchorButton } from "$lib/components";
import { Button, QrCode } from "$lib/dusk/components";
import { toast } from "$lib/dusk/components/Toast/store";
Expand All @@ -20,8 +20,6 @@
const COLUMN_WIDTH = 16;
const BOTTOM_PADDING = 22;
const dispatch = createEventDispatcher();
$: qrWidth =
offsetHeight - buttonHeight - COLUMN_COUNT * COLUMN_WIDTH - BOTTOM_PADDING;
</script>
Expand All @@ -37,12 +35,10 @@

<div class="receive__buttons" bind:offsetHeight={buttonHeight}>
{#if !hideBackButton}
<Button
<AppAnchorButton
className="receive__button"
icon={{ path: mdiArrowLeft }}
on:click={() => {
dispatch("operationChange", "");
}}
href="/dashboard"
text="Back"
variant="tertiary"
/>
Expand Down
14 changes: 5 additions & 9 deletions web-wallet/src/lib/components/Send/Send.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

<script>
import { fade } from "svelte/transition";
import { createEventDispatcher, onMount } from "svelte";
import { onMount } from "svelte";
import { mdiArrowUpBoldBoxOutline, mdiWalletOutline } from "@mdi/js";
import { areValidGasSettings, deductLuxFeeFrom } from "$lib/contracts";
import { duskToLux, luxToDusk } from "$lib/dusk/currency";
import { validateAddress } from "$lib/dusk/string";
Expand Down Expand Up @@ -61,15 +60,14 @@
/** @type {boolean} */
let isNextButtonDisabled = false;
/** @type {boolean} */
let isGasValid = false;
let { gasLimit, gasPrice } = gasSettings;
const minAmount = 0.000000001;
const dispatch = createEventDispatcher();
const resetOperation = () => dispatch("operationChange", "");
onMount(() => {
amountInput = document.querySelector(".operation__input-field");
isGasValid = areValidGasSettings(gasPrice, gasLimit);
Expand All @@ -82,7 +80,6 @@
$: totalLuxFee = luxFee + duskToLux(amount);
$: isFeeWithinLimit = totalLuxFee <= duskToLux(spendable);
$: isNextButtonDisabled = !(isAmountValid && isGasValid && isFeeWithinLimit);
$: addressValidationResult = validateAddress(address);
</script>

Expand All @@ -92,8 +89,9 @@
step={0}
{key}
backButton={{
action: resetOperation,
disabled: false,
href: "/dashboard",
isAnchor: true,
}}
nextButton={{ disabled: isNextButtonDisabled }}
>
Expand Down Expand Up @@ -237,7 +235,6 @@
<WizardStep step={3} {key} showNavigation={false}>
<OperationResult
errorMessage="Transaction failed"
onBeforeLeave={resetOperation}
operation={execute(address, amount, gasPrice, gasLimit)}
pendingMessage="Processing transaction"
successMessage="Transaction completed"
Expand All @@ -246,7 +243,6 @@
{#if hash}
<AppAnchorButton
href={`https://explorer.dusk.network/transactions/transaction?id=${hash}`}
on:click={resetOperation}
text="VIEW ON BLOCK EXPLORER"
rel="noopener noreferrer"
target="_blank"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,13 @@ exports[`Send > Amount step > should render the Send component Amount step 1`] =
<div
class="dusk-wizard__step-navigation"
>
<button
class="dusk-button dusk-button--type--button dusk-button--variant--tertiary dusk-button--size--default dusk-icon-button--labeled"
type="button"
<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"
href="/some-base-path/dashboard"
>
<svg
class="dusk-icon dusk-icon--size--default dusk-button__icon"
class="dusk-icon dusk-icon--size--default dusk-anchor-button__icon"
role="graphics-symbol"
viewBox="0 0 24 24"
>
Expand All @@ -333,12 +334,13 @@ exports[`Send > Amount step > should render the Send component Amount step 1`] =
<span
class="dusk-button__text"
class="dusk-anchor-button__text"
>
Back
</span>
</button>
</a>
<button
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion web-wallet/src/lib/containers/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as AllocateContract } from "./AllocateContract/AllocateContract.svelte";
export { default as MigrateContract } from "./MigrateContract/MigrateContract.svelte";
export { default as StakeContract } from "./StakeContract/StakeContract.svelte";
export { default as TransferContract } from "./TransferContract/TransferContract.svelte";
27 changes: 11 additions & 16 deletions web-wallet/src/lib/contracts/contract-descriptors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ export default [
disabled:
import.meta.env.VITE_CONTRACT_TRANSFER_DISABLED &&
import.meta.env.VITE_CONTRACT_TRANSFER_DISABLED === "true",
id: "transfer",
label: "Transact",
operations: [
{
disabled: false,
id: "send",
label: "Send",
primary: true,
},
{
disabled: false,
id: "receive",
label: "Receive",
primary: false,
},
],
id: "send",
label: "Send",
operations: [],
},
{
disabled:
import.meta.env.VITE_CONTRACT_TRANSFER_DISABLED &&
import.meta.env.VITE_CONTRACT_TRANSFER_DISABLED === "true",
id: "receive",
label: "Receive",
operations: [],
},
{
disabled:
Expand Down
8 changes: 8 additions & 0 deletions web-wallet/src/routes/(app)/dashboard/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<script>
import { filterWith, hasKeyValue } from "lamb";
import {
mdiArrowBottomLeft,
mdiArrowTopRight,
mdiContain,
mdiDatabaseOutline,
mdiSwapVertical,
Expand All @@ -26,6 +28,12 @@
case "allocate":
icons = [{ path: mdiSync }];
break;
case "receive":
icons = [{ path: mdiArrowBottomLeft }];
break;
case "send":
icons = [{ path: mdiArrowTopRight }];
break;
case "staking":
icons = [{ path: mdiDatabaseOutline }];
break;
Expand Down
Loading

0 comments on commit f2990d2

Please sign in to comment.