Skip to content

fix(wallet): lock the ledger canister id once an asset has one - #667

Open
MRmarioruci wants to merge 2 commits into
mainfrom
fix/wallet-readonly-asset-ledger-id
Open

MRmarioruci wants to merge 2 commits into
mainfrom
fix/wallet-readonly-asset-ledger-id

Conversation

@MRmarioruci

@MRmarioruci MRmarioruci commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Change

An asset's ledger_canister_id identifies the token that asset represents, and the station rejects an edit that repoints or drops it once set. The asset form still rendered it as a free text field, so the only feedback a user got was a rejected request.

The field is now read only when the asset already has a ledger, with a persistent hint saying a different ledger needs a new asset. Two cases are deliberately unaffected: creating an asset, and filling in a ledger id on an asset that does not have one yet, which the station still allows. The index canister id stays editable.

Changes

InternetComputerNativeStandardForm derives isLedgerIdLocked from the currentMetadata prop it already receives, so the lock keys off whether the stored asset has a ledger rather than on form mode. That drives the field's readonly, its variant, and the hint. Three locale files gain the hint string.

Tests

  • the field is editable when the asset has no ledger canister id yet
  • the field is read only when it already has one, and the index canister id is not

vitest run src/components/assets passes (11). Lint, typecheck and prettier clean.

Note

Pairs with #648

The station rejects an edit that repoints or drops a ledger canister id that
is already set, but the asset form still offered it as a free text field, so
the only feedback was a rejected request. The field is now read only when the
asset already has a ledger, with a hint explaining that a different ledger
needs a new asset. Creating an asset and filling in a missing ledger id are
unaffected, and the index canister id stays editable.
@MRmarioruci
MRmarioruci requested a review from a team as a code owner September 18, 2026 09:50
@zeropath-ai

zeropath-ai Bot commented Sep 18, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 2a055c0.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► apps/wallet/src/components/assets/AssetDialog.spec.ts
    - it('locks the ledger canister id when editing an asset that already has one', async () => { … }
Enhancement ► apps/wallet/src/components/assets/AssetDialog.vue
    - @loaded="onAssetLoaded"
► apps/wallet/src/components/assets/AssetForm.vue
    - :lock-ledger-canister-id="props.lockLedgerCanisterId.value"
Enhancement ► apps/wallet/src/components/assets/standards/InternetComputerNativeStandardForm.spec.ts
    - it('allows setting the ledger canister id while the asset does not have one', async () => { … }
    - it('locks the ledger canister id once the asset already has one', async () => { … }
Enhancement ► apps/wallet/src/components/assets/standards/InternetComputerNativeStandardForm.vue
    - :variant="props.readonly
Enhancement ► apps/wallet/src/locales/en.locale.ts
    - forms.ledger_canister_id_immutable: 'The ledger canister cannot be changed once the asset has one. Create a new asset to use a different ledger.'
Enhancement ► apps/wallet/src/locales/fr.locale.ts
    - forms.ledger_canister_id_immutable: 'Le canister ledger ne peut plus être modifié une fois défini. Créez un nouvel actif pour utiliser un autre ledger.'
Enhancement ► apps/wallet/src/locales/pt.locale.ts
    - forms.ledger_canister_id_immutable: 'O canister de contabilidade não pode ser alterado depois de definido. Crie um novo ativo para usar outro canister.'

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The production edit dialog does not supply the stored metadata needed to activate the ledger lock.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Aligns the wallet UI with the station-side ledger immutability guard from #648.

Changes:

  • Makes existing ledger IDs read-only while leaving index IDs editable.
  • Adds localized guidance and component tests.
File summaries
File Description
apps/wallet/src/locales/pt.locale.ts Adds Portuguese guidance.
apps/wallet/src/locales/fr.locale.ts Adds French guidance.
apps/wallet/src/locales/en.locale.ts Adds English guidance.
apps/wallet/src/components/assets/standards/InternetComputerNativeStandardForm.vue Implements the ledger lock and hint.
apps/wallet/src/components/assets/standards/InternetComputerNativeStandardForm.spec.ts Tests ledger field editability.
Review details

Suppressed comments (1)

apps/wallet/src/components/assets/standards/InternetComputerNativeStandardForm.spec.ts:49

  • This setup omits currentMetadata, so it exercises the creation path rather than the stated existing-asset-without-a-ledger case. Populate currentMetadata with another metadata key (and mirror it in modelValue) to prove an existing asset remains editable when only the ledger key is absent.
      props: {
        modelValue: [],
        readonly: false,
      },
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The lock derived from currentMetadata, which the dialog never passes, so it
only ever engaged in the request review that is already read only. The dialog
now snapshots whether the loaded asset has a ledger and passes that down.
Taking a snapshot rather than reading the editable model matters, since the
model gains a ledger id as soon as the first character is typed, which would
lock the field mid entry on an asset that does not have one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants