Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For beta version 2024-08-16 - import token beta #5267

Draft
wants to merge 177 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
40488ec
New const MAX_IMPORTED_TOKENS
mstrasinskis Jul 28, 2024
c79717e
New imported tokens services
mstrasinskis Jul 28, 2024
da6ad8f
Comments
mstrasinskis Jul 28, 2024
503c294
refactro: addImportedToken
mstrasinskis Jul 28, 2024
ef1593b
Test loadImportedTokens
mstrasinskis Jul 28, 2024
015346f
refactor: error messages
mstrasinskis Jul 28, 2024
3d49dee
refactor: testError
mstrasinskis Jul 28, 2024
1e36698
Test addImportedToken
mstrasinskis Jul 28, 2024
09e3c30
refactor: split addImportedToken
mstrasinskis Jul 28, 2024
2740b47
New removeImportedToken service
mstrasinskis Jul 28, 2024
91c476d
refactor: error/success messages
mstrasinskis Jul 28, 2024
c913361
test success toast
mstrasinskis Jul 28, 2024
c679bde
Test removeImportedToken
mstrasinskis Jul 28, 2024
ed0ea9d
Merge branch 'main' into mstr/imported-tokens-services
mstrasinskis Jul 28, 2024
9af3859
Fix typo
mstrasinskis Jul 28, 2024
2fa54de
Comments
mstrasinskis Jul 28, 2024
7a390f4
Merge branch 'mstr/imported-tokens-services' of https://github.com/df…
mstrasinskis Jul 28, 2024
70cece1
Todo added
mstrasinskis Jul 29, 2024
a3bc1da
Add ImportTokenWarning
mstrasinskis Jul 18, 2024
0b30654
Prop "required" for PrincipalInput
mstrasinskis Jul 18, 2024
c97d4e3
New labels
mstrasinskis Jul 18, 2024
57dce25
ImportTokenForm component base
mstrasinskis Jul 18, 2024
f8fa6c5
Dispatch nnsSubmit from ImportTokenForm
mstrasinskis Jul 18, 2024
a0c299f
New ImportTokenModal component with basic validation
mstrasinskis Jul 18, 2024
ca474b3
Add `import-token-validation` busy initiator type
mstrasinskis Jul 18, 2024
fdf850e
Busy screen text
mstrasinskis Jul 18, 2024
aa4e143
Add LinkIcon component
mstrasinskis Jul 18, 2024
594c776
Add ImportTokenCanisterId component
mstrasinskis Jul 18, 2024
f1064ea
Add ImportTokenReview component
mstrasinskis Jul 18, 2024
58941d8
Change index_label_optional label
mstrasinskis Jul 18, 2024
0cab007
Display ImportTokenReview in modal
mstrasinskis Jul 18, 2024
0d857d2
Show modal on import token click
mstrasinskis Jul 18, 2024
dc327ea
Load imported tokens on app init
mstrasinskis Jul 29, 2024
5bdbc4c
Add fetchIcrcToken service
mstrasinskis Jul 18, 2024
56d9f4a
cleanup: remove step 3
mstrasinskis Jul 29, 2024
5f7e87d
Merge branch 'main' into mstr/imported-tokens-form
mstrasinskis Jul 29, 2024
19ac08e
Add missing imported tokens api types
mstrasinskis Jul 29, 2024
9fd1e63
clean: imports
mstrasinskis Jul 29, 2024
73c9a29
Load imported tokens on dapp init
mstrasinskis Jul 29, 2024
58a3665
cleanup: remove step 3 config
mstrasinskis Jul 29, 2024
de2e2e8
feat: adding imported token on confirm
mstrasinskis Jul 29, 2024
fb7ffeb
refactor: use a single link_to_canister
mstrasinskis Jul 29, 2024
7c7a7eb
Remove where_to_find_href
mstrasinskis Jul 29, 2024
29415bf
Comments
mstrasinskis Jul 29, 2024
eff83c3
Remove unused labels
mstrasinskis Jul 29, 2024
be035e9
refactro: rename fetchIcrcTokenMetaData
mstrasinskis Jul 29, 2024
e306495
cleanup: imports
mstrasinskis Jul 29, 2024
2146d13
Add more testIds
mstrasinskis Jul 30, 2024
6d1273b
Merge branch 'main' into mstr/imported-tokens-form
mstrasinskis Jul 31, 2024
460bd3e
feat: propagate more props from PrincipalInput
mstrasinskis Jul 31, 2024
09ccd99
New component ImportTokenForm
mstrasinskis Jul 31, 2024
f793680
Update labels
mstrasinskis Jul 31, 2024
5e3f2eb
New busy store initiator
mstrasinskis Jul 31, 2024
77d3b20
feat: fetchIcrcTokenMetaData service
mstrasinskis Jul 31, 2024
73e8970
New component ImportTokenReview
mstrasinskis Jul 31, 2024
e988727
New component ImportTokenModal
mstrasinskis Jul 31, 2024
ffecb60
feat: display the modal on import token click
mstrasinskis Jul 31, 2024
4a703e4
Remove unused labels
mstrasinskis Jul 31, 2024
020fbfd
Update labels
mstrasinskis Jul 31, 2024
97e1b2f
test: fetchIcrcTokenMetaData service
mstrasinskis Jul 31, 2024
f2eb3cf
test: ImportTokenForm
mstrasinskis Jul 31, 2024
fce3f17
test: add testId prop to ImportTokenCanisterId
mstrasinskis Jul 31, 2024
85857db
test: add testId prop to ImportTokenCanisterId
mstrasinskis Jul 31, 2024
2cd4ee9
cleanup: remove redundant fn
mstrasinskis Jul 31, 2024
d1a7511
test: ImportTokenReview.spec
mstrasinskis Jul 31, 2024
466b863
test: ImportTokenModal
mstrasinskis Jul 31, 2024
8089ff1
test: error and fallback handling
mstrasinskis Jul 31, 2024
0fe010a
test: should open import token modal
mstrasinskis Jul 31, 2024
033ec97
test: should stay on step1 when error
mstrasinskis Jul 31, 2024
4439154
Comment
mstrasinskis Jul 31, 2024
ca77365
Restore missing labels
mstrasinskis Jul 31, 2024
bdccf5e
Merge branch 'mstr/imported-tokens-modal-1' into mstr/imported-tokens…
mstrasinskis Aug 1, 2024
e3b3407
Fix labels
mstrasinskis Aug 1, 2024
2276bf7
Fix labels
mstrasinskis Aug 1, 2024
3017df1
feat: save imported token after user confirmation
mstrasinskis Aug 1, 2024
1d23c65
feat: make indexCanisterId optional for IcrcCanistersStore
mstrasinskis Aug 1, 2024
fa0c66a
feat: Add imported tokens to the icrcCanistersStore
mstrasinskis Aug 1, 2024
20dd1cf
Fix importing label
mstrasinskis Aug 1, 2024
0b15e4b
feat: navigate to imported token after saving
mstrasinskis Aug 1, 2024
f318528
feat: table sort with imported tokens support
mstrasinskis Aug 1, 2024
cd0aba6
feat: display imported token tag
mstrasinskis Aug 1, 2024
18708f0
feat: isImportedToken util
mstrasinskis Aug 1, 2024
84628e2
refactor: use isImportedToken for tag
mstrasinskis Aug 1, 2024
552588e
feat: display imported token tag on wallet page
mstrasinskis Aug 1, 2024
81cf849
cleanup: remove redundant named slot
mstrasinskis Aug 1, 2024
09d4887
Revert "cleanup: remove redundant named slot"
mstrasinskis Aug 1, 2024
e6a769d
Revert "feat: display imported token tag on wallet page"
mstrasinskis Aug 1, 2024
dfb9e8a
feat: display tag in the wallet page header
mstrasinskis Aug 1, 2024
07fa9be
feat: remove imported token (basic version, separate button)
mstrasinskis Aug 1, 2024
1f57673
chore: formatting
mstrasinskis Aug 1, 2024
9d6ca11
fix: update i18n types
mstrasinskis Aug 1, 2024
4654cc0
test: fix compareTokensByImportance arguments
mstrasinskis Aug 1, 2024
234b0d4
test: adjust "should not show errors if loading accounts fails" test
mstrasinskis Aug 1, 2024
03a0b69
chore: remove log
mstrasinskis Aug 1, 2024
0179f68
! ENABLE ENABLE_IMPORT_TOKEN FLAG !
mstrasinskis Aug 1, 2024
9164fcf
Temporary suppress load imported tokens error toast
mstrasinskis Aug 1, 2024
ada4b18
Temporary suppress load imported tokens error toast
mstrasinskis Aug 1, 2024
19515ae
Temporary suppress load imported tokens error toast
mstrasinskis Aug 1, 2024
54194d1
i18n: update new account description to "Create a new account control…
mstrasinskis Aug 2, 2024
5540cb7
i18n: capitalise Ledger everywhere because it's a proper noun.
mstrasinskis Aug 2, 2024
783fcf2
Adjust unit test because of the label update
mstrasinskis Aug 2, 2024
9626542
i18n: change "Add hardware account" button title
mstrasinskis Aug 2, 2024
196589f
Update test environment warning.
mstrasinskis Aug 2, 2024
ac5947d
Revert "Temporary suppress load imported tokens error toast"
mstrasinskis Aug 4, 2024
c23a67c
Revert "Temporary suppress load imported tokens error toast"
mstrasinskis Aug 4, 2024
ce4a311
Revert "Temporary suppress load imported tokens error toast"
mstrasinskis Aug 4, 2024
4c3ba34
Revert "! ENABLE ENABLE_IMPORT_TOKEN FLAG !"
mstrasinskis Aug 4, 2024
d496799
feat: compareTokensByImportance comparator
mstrasinskis Aug 5, 2024
5c58c17
refactor: tokenWithBalance mock function to have id
mstrasinskis Aug 5, 2024
eb50ce1
test: compareTokensWithBalanceOrImportedFirst
mstrasinskis Aug 5, 2024
ee63a31
Remove compareTokensWithBalanceFirst
mstrasinskis Aug 5, 2024
ae8918a
feat: handle import token error
mstrasinskis Aug 6, 2024
201ab7a
test: createTokenWithBalance util
mstrasinskis Aug 6, 2024
7b2714b
test: should display imported tokens after important with balance
mstrasinskis Aug 6, 2024
f52928f
refactor: don't export createTokenWithBalance
mstrasinskis Aug 6, 2024
06e5be2
Expose testId and require props for PrincipaInput component
mstrasinskis Aug 8, 2024
37106ed
Update labels
mstrasinskis Aug 8, 2024
ac57c9c
New ImportTokenForm component
mstrasinskis Aug 8, 2024
de7ed16
New ImportTokenModal component
mstrasinskis Aug 8, 2024
245d914
feat: show modal on "Import token" button click
mstrasinskis Aug 8, 2024
3626af1
Change form test id
mstrasinskis Aug 8, 2024
11b2456
Move the import label
mstrasinskis Aug 8, 2024
0342a7d
test: ImportTokenForm
mstrasinskis Aug 8, 2024
4999d60
test: ImportTokenModal
mstrasinskis Aug 8, 2024
2f08c99
test: open import token modal
mstrasinskis Aug 8, 2024
a4a01be
Remove redundant label
mstrasinskis Aug 8, 2024
737fae4
refactor: rename disable
mstrasinskis Aug 9, 2024
61f00fe
Formatting
mstrasinskis Aug 9, 2024
b6b56db
upgrade ic-js
mstrasinskis Aug 9, 2024
31d7bd0
Index/Ledger canister IDs validation (getLedgerId)
mstrasinskis Aug 9, 2024
81d51fb
npm upgrade:gix to local
mstrasinskis Aug 11, 2024
aac6604
New LinkToDashboard component
mstrasinskis Aug 12, 2024
fc7b223
Add slot actions to WalletPageHeader
mstrasinskis Aug 12, 2024
e347217
Display link to dashboard popover on nns wallet page
mstrasinskis Aug 12, 2024
8a06ea9
Display link to dashboard popover on icrc wallet page
mstrasinskis Aug 12, 2024
d0bef16
Formatting
mstrasinskis Aug 12, 2024
c283cb7
Use LinkToDashboard instead of LinkIcon in ImportTokenCanisterId comp…
mstrasinskis Aug 12, 2024
ffb2312
Merge branch 'mstr/imported-tokens-modal' into mstr/imported-tokens-form
mstrasinskis Aug 13, 2024
6f092a4
reset package lock
mstrasinskis Aug 13, 2024
75cfd53
cleanup
mstrasinskis Aug 13, 2024
a49f1b2
Merge branch 'main' into mstr/imported-tokens-form
mstrasinskis Aug 13, 2024
3e5f876
cleanup
mstrasinskis Aug 13, 2024
ffb6bfa
New const IMPORTANT_CK_TOKEN_IDS
mstrasinskis Aug 14, 2024
9ce3fe6
Import token validation before review
mstrasinskis Aug 14, 2024
ad478a6
Do not show import buttons before the imported tokens are loaded
mstrasinskis Aug 14, 2024
c8917a5
Squashed commit of the following:
mstrasinskis Aug 14, 2024
4af138a
Squashed commit of the following:
mstrasinskis Aug 14, 2024
3ad601f
Restore missing label
mstrasinskis Aug 14, 2024
59f91a3
Merge remote-tracking branch 'origin/main' into mstr/imported-tokens-…
mstrasinskis Aug 15, 2024
eb4b947
Safari table fix - Squashed commit of the following:
mstrasinskis Aug 15, 2024
17da1cd
Formatting
mstrasinskis Aug 16, 2024
05f6380
cleanup: remove unused vars
mstrasinskis Aug 16, 2024
723dbc5
Add remove button to the more popup
mstrasinskis Aug 16, 2024
ae1ed05
style: "more" popup buttons
mstrasinskis Aug 16, 2024
fb9907d
style: Import button redesign
mstrasinskis Aug 16, 2024
8ac4efe
cleanup
mstrasinskis Aug 16, 2024
ced1d8b
feat: remove imported token confirmation dialog (ImportTokenRemoveCon…
mstrasinskis Aug 16, 2024
a725e71
Merge branch 'mstr/imported-tokens-form' into mstr/import-token-beta-…
mstrasinskis Aug 16, 2024
95a8765
Formatting
mstrasinskis Aug 16, 2024
6cc1360
Fix type warnings
mstrasinskis Aug 16, 2024
0d98da2
Fix type warnings
mstrasinskis Aug 16, 2024
62c2937
Enable ENABLE_IMPORT_TOKEN ff
mstrasinskis Aug 16, 2024
f8571fe
Skipt updated ImportTokenModal.spec.ts
mstrasinskis Aug 16, 2024
f086195
Comment out outdated specs
mstrasinskis Aug 16, 2024
cd1d8f2
Remove redundant lables
mstrasinskis Aug 16, 2024
17a3711
Squashed commit of the following:
mstrasinskis Aug 21, 2024
615f55d
Merge branch 'main' into mstr/import-token-beta-2024-08-02
mstrasinskis Aug 21, 2024
550bddc
Squashed commit of the following:
mstrasinskis Aug 21, 2024
e10d983
Squashed commit of the following:
mstrasinskis Aug 21, 2024
6acf15b
Fix typo
mstrasinskis Aug 21, 2024
0825b91
Temporary commend out imported modal specs
mstrasinskis Aug 21, 2024
7825222
Merge branch 'mstr/import-token-beta-2024-08-02' of github.com:dfinit…
mstrasinskis Aug 21, 2024
d177157
Temporary commend out imported modal specs
mstrasinskis Aug 21, 2024
b6f0d4e
Temporary commend out imported modal specs
mstrasinskis Aug 21, 2024
1193906
Temporary commend out imported modal specs
mstrasinskis Aug 21, 2024
588a622
Disable broken test
mstrasinskis Aug 21, 2024
640107f
Use mainnet sns-aggregator for beta
mstrasinskis Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/deploy-to-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ jobs:
timeout-minutes: 60
env:
NNS_DAPP_APP_SUBNET_CANISTER_ID: "xnjld-hqaaa-aaaal-qb56q-cai"
SNS_AGGREGATOR_APP_SUBNET_CANISTER_ID: "otgyv-wyaaa-aaaak-qcgba-cai"
# beta sns aggregator
# SNS_AGGREGATOR_APP_SUBNET_CANISTER_ID: "otgyv-wyaaa-aaaak-qcgba-cai"
# mainnet sns aggregator
SNS_AGGREGATOR_APP_SUBNET_CANISTER_ID: "3r4gx-wqaaa-aaaaq-aaaia-cai"
DFX_NETWORK: app
steps:
- name: Checkout nns-dapp
Expand Down
2 changes: 1 addition & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
"ENABLE_CKBTC": true,
"ENABLE_CKTESTBTC": false,
"ENABLE_PROJECTS_TABLE": true,
"ENABLE_IMPORT_TOKEN": false
"ENABLE_IMPORT_TOKEN": true
}
}
},
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/lib/api/icrc-index.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ export const getTransactions = async ({
};
};

export const getLedgerId = async ({
identity,
indexCanisterId,
certified,
}: {
identity: Identity;
indexCanisterId: Principal;
certified?: boolean;
}): Promise<Principal> => {
const {
canister: { ledgerId },
} = await indexCanister({ identity, canisterId: indexCanisterId });

return ledgerId({ certified });
};

const indexCanister = async ({
identity,
canisterId,
Expand Down
209 changes: 163 additions & 46 deletions frontend/src/lib/components/accounts/IcrcWalletPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@
hasAccounts,
} from "$lib/utils/accounts.utils";
import { replacePlaceholders } from "$lib/utils/i18n.utils";
import { Island, Spinner } from "@dfinity/gix-components";
import {
IconBin,
IconDots,
Island,
Popover,
Spinner,
Tag,
} from "@dfinity/gix-components";
import type { Principal } from "@dfinity/principal";
import { TokenAmountV2, isNullish, nonNullish } from "@dfinity/utils";
import type { Writable } from "svelte/store";
import { accountsPathStore } from "$lib/derived/paths.derived";
import { startBusy, stopBusy } from "$lib/stores/busy.store";
import { importedTokensStore } from "$lib/stores/imported-tokens.store";
import { removeImportedTokens } from "$lib/services/imported-tokens.services";
import TestIdWrapper from "$lib/components/common/TestIdWrapper.svelte";
import LinkToDashboardCanister from "$lib/components/common/LinkToDashboardCanister.svelte";
import { isImportedToken as checkImportedToken } from "$lib/utils/imported-tokens.utils";
import ImportTokenRemoveConfirmation from "$lib/components/accounts/ImportTokenRemoveConfirmation.svelte";

export let testId: string;
export let accountIdentifier: string | undefined | null = undefined;
Expand Down Expand Up @@ -142,58 +157,145 @@
ledgerCanisterId,
isSignedIn: $authSignedInStore,
}))();

const remove = async () => {
if (isNullish(ledgerCanisterId)) return;

startBusy({
initiator: "import-token-removing",
labelKey: "import_token.removing",
});

const importedTokens = $importedTokensStore.importedTokens ?? [];
const { success } = await removeImportedTokens({
tokensToRemove: importedTokens.filter(
({ ledgerCanisterId: id }) => id.toText() === ledgerCanisterId?.toText()
),
importedTokens,
});

stopBusy("import-token-removing");

if (success) {
goto($accountsPathStore);
}
};

let moreButton: HTMLButtonElement | undefined;
let morePopupVisible = false;

let isImportedToken = false;
$: isImportedToken = checkImportedToken({
ledgerCanisterId,
importedTokens: $importedTokensStore.importedTokens,
});

let removeImportedTokenConfirmtionVisible = false;
</script>

<Island {testId}>
<main class="legacy">
<section>
{#if loaded && nonNullish(ledgerCanisterId)}
{#if nonNullish($selectedAccountStore.account) && nonNullish(token)}
<IcrcBalancesObserver
{ledgerCanisterId}
accounts={[$selectedAccountStore.account]}
reload={reloadOnlyAccountFromStore}
/>
{/if}
<WalletPageHeader
universe={$selectedUniverseStore}
walletAddress={$selectedAccountStore.account?.identifier}
/>
<WalletPageHeading
accountName={$selectedAccountStore.account?.name ??
$i18n.accounts.main}
balance={nonNullish($selectedAccountStore.account) &&
nonNullish(token)
? TokenAmountV2.fromUlps({
amount: $selectedAccountStore.account.balanceUlps,
token,
})
: undefined}
>
<slot name="header-actions" />
<SignInGuard />
</WalletPageHeading>

{#if $$slots["info-card"]}
<div class="content-cell-island info-card">
<slot name="info-card" />
<TestIdWrapper {testId}>
<Island>
<main class="legacy">
<section>
{#if loaded && nonNullish(ledgerCanisterId)}
{#if nonNullish($selectedAccountStore.account) && nonNullish(token)}
<IcrcBalancesObserver
{ledgerCanisterId}
accounts={[$selectedAccountStore.account]}
reload={reloadOnlyAccountFromStore}
/>
{/if}
<WalletPageHeader
universe={$selectedUniverseStore}
walletAddress={$selectedAccountStore.account?.identifier}
>
<svelte:fragment slot="tags">
{#if isImportedToken}
<Tag testId="imported-token-tag"
>{$i18n.import_token.imported_token}</Tag
>
{/if}
</svelte:fragment>
<svelte:fragment slot="actions">
{#if nonNullish(ledgerCanisterId)}
<button
bind:this={moreButton}
class="icon-only"
data-tid="more-button"
on:click={() => (morePopupVisible = true)}
>
<IconDots />
</button>
{/if}
</svelte:fragment>
</WalletPageHeader>
<WalletPageHeading
accountName={$selectedAccountStore.account?.name ??
$i18n.accounts.main}
balance={nonNullish($selectedAccountStore.account) &&
nonNullish(token)
? TokenAmountV2.fromUlps({
amount: $selectedAccountStore.account.balanceUlps,
token,
})
: undefined}
>
<slot name="header-actions" />
<SignInGuard />
</WalletPageHeading>

{#if $$slots["info-card"]}
<div class="content-cell-island info-card">
<slot name="info-card" />
</div>
{/if}

<Separator spacing="none" />

<!-- Transactions and the explanation go together. -->
<div>
<slot name="page-content" />
</div>
{:else}
<Spinner />
{/if}
</section>
</main>

<Separator spacing="none" />
<slot name="footer-actions" />
</Island>

<!-- Transactions and the explanation go together. -->
<div>
<slot name="page-content" />
</div>
{:else}
<Spinner />
{/if}
</section>
</main>
{#if nonNullish(ledgerCanisterId)}
<Popover
bind:visible={morePopupVisible}
anchor={moreButton}
direction="rtl"
invisibleBackdrop
>
<div class="popover-content">
<LinkToDashboardCanister canisterId={ledgerCanisterId} />
{#if isImportedToken}
<button
class="remove-button button ghost with-icon"
data-tid="remove-imported-token-button"
on:click={() => (removeImportedTokenConfirmtionVisible = true)}
>
<IconBin />
{$i18n.core.remove}
</button>
{/if}
</div>
</Popover>
{/if}

<slot name="footer-actions" />
</Island>
{#if removeImportedTokenConfirmtionVisible && nonNullish(ledgerCanisterId)}
<ImportTokenRemoveConfirmation
{ledgerCanisterId}
on:nnsClose={() => (removeImportedTokenConfirmtionVisible = false)}
on:nnsConfirm={remove}
/>
{/if}
</TestIdWrapper>

<style lang="scss">
section {
Expand All @@ -205,4 +307,19 @@
.info-card {
background-color: var(--island-card-background);
}

.popover-content {
display: flex;
flex-direction: column;
gap: var(--padding-2x);
}

.remove-button {
padding: 0;
color: var(--negative-emphasis);

&:hover {
color: var(--negative-emphasis);
}
}
</style>
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<script lang="ts">
import { Copy } from "@dfinity/gix-components";
import { nonNullish } from "@dfinity/utils";
import LinkIcon from "$lib/components/common/LinkIcon.svelte";
import LinkToDashboardCanister from "$lib/components/common/LinkToDashboardCanister.svelte";
import type { Principal } from "@dfinity/principal";

export let label: string;
export let canisterId: string | undefined = undefined;
export let canisterLinkHref: string | undefined = undefined;
export let testId: string = "import-token-canister-id-component";
export let canisterId: Principal | undefined = undefined;
export let canisterIdFallback: string | undefined = undefined;
</script>

<div class="container" data-tid="import-token-canister-id-component">
<div class="container" data-tid={testId}>
<span data-tid="label">{label}</span>
<div class="canister-id">
{#if nonNullish(canisterId)}
<span class="value description" data-tid="canister-id">{canisterId}</span>
<Copy value={canisterId} />
{#if nonNullish(canisterLinkHref)}
<LinkIcon href={canisterLinkHref} />
{/if}
<Copy value={canisterId.toText()} />
<LinkToDashboardCanister noLabel {canisterId} />
{:else if nonNullish(canisterIdFallback)}
<span class="fallback description" data-tid="canister-id-fallback"
>{canisterIdFallback}</span
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<script lang="ts">
import { i18n } from "$lib/stores/i18n";
import { Html, Modal, Tag } from "@dfinity/gix-components";
import { createEventDispatcher } from "svelte";
import UniversePageSummary from "$lib/components/universe/UniversePageSummary.svelte";
import type { Principal } from "@dfinity/principal";
import type { Universe } from "$lib/types/universe";
import { nonNullish } from "@dfinity/utils";
import { selectableUniversesStore } from "$lib/derived/selectable-universes.derived";

export let ledgerCanisterId: Principal;

let universe: Universe | undefined;
$: universe = $selectableUniversesStore.find(
({ canisterId }) => canisterId === ledgerCanisterId.toText()
);

const dispatch = createEventDispatcher();
</script>

<Modal
role="alert"
on:nnsClose
testId="imported-token-remove-confirmation"
disablePointerEvents={true}
>
<svelte:fragment slot="title">
{$i18n.import_token.remove_confirmation_title}
</svelte:fragment>

<div class="content">
{#if nonNullish(universe)}
<UniversePageSummary {universe}>
<Tag slot="tags" testId="imported-token-tag"
>{$i18n.import_token.imported_token}</Tag
>
</UniversePageSummary>
{/if}
<p><Html text={$i18n.import_token.remove_confirmation_description} /></p>
</div>
<div class="toolbar">
<button
class="secondary"
data-tid="close-button"
on:click={() => dispatch("nnsClose")}
>
{$i18n.core.back}
</button>

<button
data-tid="confirm-button"
class="primary"
on:click={() => dispatch("nnsConfirm")}
>
{$i18n.core.remove}
</button>
</div>
</Modal>

<style lang="scss">
.content {
display: flex;
flex-direction: column;
gap: var(--padding-2x);

margin-bottom: var(--padding-4x);
}
</style>
Loading
Loading