-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Motivation Users can import a custom token without providing an index canister ID. It should be possible to add the canister afterwards, and this PR addresses that. **Note:** the transactions are loaded automatically by the transaction sync mechanism. **Demo:** https://qsgjb-riaaa-aaaaa-aaaga-cai.mstr-ingress.devenv.dfinity.network ckRED token for testing: - ledger canister ID: `mrfq3-7eaaa-aaaaa-qabja-cai` - index canister ID: `mwewp-s4aaa-aaaaa-qabjq-cai` # Changes - Display "Add index canister" button and description. - Add `AddIndexCanisterModal` component. - Add index canister logic. - New mode `addIndexCanisterMode` to import token form. - Expose `disabled` prop of PrincipalInput. # Tests - Added. - Tested manually. | 1 | 2 | 3 | 4 | |--------|--------|--------|--------| | <img width="804" alt="image" src="https://github.com/user-attachments/assets/6a232089-8886-46a9-a30a-5df36720dca1"> | <img width="618" alt="image" src="https://github.com/user-attachments/assets/dabb0703-e22c-413c-952e-eb0908a48645"> | <img width="624" alt="image" src="https://github.com/user-attachments/assets/f45f7a6a-d7c9-4c14-bace-c6d8b980cf0a"> | <img width="782" alt="image" src="https://github.com/user-attachments/assets/d7fd6dff-95fe-48c7-b030-a18602d1d516"> | # Todos - [ ] Add entry to changelog (if necessary). Not necessary.
- Loading branch information
1 parent
32403a6
commit b9701e5
Showing
14 changed files
with
484 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
frontend/src/lib/modals/accounts/AddIndexCanisterModal.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script lang="ts"> | ||
import ImportTokenForm from "$lib/components/accounts/ImportTokenForm.svelte"; | ||
import { matchLedgerIndexPair } from "$lib/services/icrc-index.services"; | ||
import { startBusy, stopBusy } from "$lib/stores/busy.store"; | ||
import { i18n } from "$lib/stores/i18n"; | ||
import { importedTokensStore } from "$lib/stores/imported-tokens.store"; | ||
import { Modal } from "@dfinity/gix-components"; | ||
import type { Principal } from "@dfinity/principal"; | ||
import { isNullish } from "@dfinity/utils"; | ||
import { createEventDispatcher } from "svelte"; | ||
import { addIndexCanister } from "../../services/imported-tokens.services"; | ||
export let ledgerCanisterId: Principal; | ||
const dispatch = createEventDispatcher(); | ||
let indexCanisterId: Principal | undefined; | ||
const nnsSubmit = async () => { | ||
// Just for type safety. This should never happen. | ||
if ( | ||
isNullish(ledgerCanisterId) || | ||
isNullish(indexCanisterId) || | ||
isNullish($importedTokensStore.importedTokens) | ||
) { | ||
return; | ||
} | ||
try { | ||
startBusy({ | ||
initiator: "import-token-updating", | ||
labelKey: "import_token.updating", | ||
}); | ||
if ( | ||
!(await matchLedgerIndexPair({ | ||
ledgerCanisterId, | ||
indexCanisterId, | ||
})) | ||
) { | ||
return; | ||
} | ||
const { success } = await addIndexCanister({ | ||
ledgerCanisterId, | ||
indexCanisterId, | ||
importedTokens: $importedTokensStore.importedTokens, | ||
}); | ||
if (success) { | ||
dispatch("nnsClose"); | ||
} | ||
} finally { | ||
stopBusy("import-token-updating"); | ||
} | ||
}; | ||
</script> | ||
|
||
<Modal testId="add-index-canister-modal-component" on:nnsClose> | ||
<svelte:fragment slot="title" | ||
>{$i18n.import_token.add_index_canister}</svelte:fragment | ||
> | ||
<ImportTokenForm | ||
addIndexCanisterMode | ||
bind:ledgerCanisterId | ||
bind:indexCanisterId | ||
on:nnsClose | ||
on:nnsSubmit={nnsSubmit} | ||
/> | ||
</Modal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.