Skip to content

[LWDM] feat(coin-concordium): add PLT errors and mapping (LIVE-36748) - #21429

Open
amaslakov wants to merge 2 commits into
developfrom
LIVE-36748-concordium-add-plt-error-classes-and-error-mapping
Open

[LWDM] feat(coin-concordium): add PLT errors and mapping (LIVE-36748)#21429
amaslakov wants to merge 2 commits into
developfrom
LIVE-36748-concordium-add-plt-error-classes-and-error-mapping

Conversation

@amaslakov

@amaslakov amaslakov commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

📝 Description

Groundwork for PLT send: adds the 8 error classes a PLT transfer needs and maps chain reject reasons onto them. Nothing calls it yet — the pre-send checks (LIVE-28334) and the signer (LIVE-28337) are the consumers.

import { mapPltRejectReason } from "@ledgerhq/coin-concordium/logic";

const error = mapPltRejectReason(tx.details.rawRejectReason);
// undefined when the reason is absent, non-PLT, or its payload does not match its tag
  • Only addressNotFound and tokenBalanceInsufficient are narrowed. operationNotPermitted covers paused, allow-list and deny-list alike, and the reason that would separate them sits in details as hex CBOR that concordium-core has no decoder for — so those three conditions are reachable only from the pre-send checks, never from this mapping. Confirmed against CIS-7 and concordium-grpc-api.
  • ConcordiumInsufficientCcdForFee is a new class rather than the existing generic NotEnoughBalanceInParentAccount — deliberate, so the copy can name CCD.

🔗 Context

Copilot AI lite review requested due to automatic review settings September 2, 2026 08:29
@amaslakov
amaslakov requested review from a team as code owners September 2, 2026 08:29
@live-github-bot live-github-bot Bot changed the title feat(coin-concordium): add PLT errors and mapping (LIVE-36748) [LWDM] feat(coin-concordium): add PLT errors and mapping (LIVE-36748) Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ E2E tests are required

Changes detected require e2e testing before merge (even before asking for any review).

🖥️ Desktop

-> Run Desktop E2E

  • Select "Run workflow"
  • Branch: LIVE-36748-concordium-add-plt-error-classes-and-error-mapping
  • Device: nanoSP or stax

📱 Mobile

-> Run Mobile E2E

  • Select "Run workflow"
  • Branch: LIVE-36748-concordium-add-plt-error-classes-and-error-mapping
  • Device: nanoX

Affected coins modules: concordium

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.

🟢 Approval recommended

Changes are self-contained, consistent with existing error patterns in the module, include focused tests, and add a correctly scoped changeset for the new exported API.

Pull request overview

Adds Protocol-Level Token (PLT) groundwork to the Concordium coin module by introducing dedicated error classes and a safe mapper from on-chain PLT reject reasons to typed errors, exposed via the module’s logic entrypoint.

Changes:

  • Added 11 PLT-focused error classes (plus tests) ensuring stable name contracts across serialization boundaries.
  • Implemented mapPltRejectReason to narrow selected PLT reject reasons (and safely degrade unknown/malformed inputs).
  • Exported the mapper from libs/coin-modules/coin-concordium/src/logic/index.ts and added a changeset for the API addition.
File summaries
File Description
libs/coin-modules/coin-concordium/src/types/errors.ts Adds PLT-specific Error subclasses used by upcoming PLT send flows.
libs/coin-modules/coin-concordium/src/types/errors.test.ts Verifies PLT error name/message defaults and field assignment behavior.
libs/coin-modules/coin-concordium/src/logic/transaction/pltRejectReason.ts Adds mapping from validated PLT reject reasons to typed errors with safe fallback behavior.
libs/coin-modules/coin-concordium/src/logic/transaction/pltRejectReason.test.ts Covers mapping outcomes, fallback behavior, and prototype-pollution-safe lookup.
libs/coin-modules/coin-concordium/src/logic/index.ts Re-exports mapPltRejectReason as part of the logic public surface.
.changeset/quiet-lantern-drifts.md Declares a minor bump for @ledgerhq/coin-concordium due to new exported API/errors.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Web Tools Build Status

Build Status Deployment
Web Tools Build ✅ Deployed https://web-tools-82ojqmdd5-ledger-hq-prd.vercel.app

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

⚠️ Note: The latest commit (e33572da550ed8d8ef768853209427c2a3f0e014) does not have baseline artifacts. Using commit 4597f6ed03a1dd0b6805c61ec63ddd47ec584c2a for baseline comparison instead. If this seems incorrect, please wait a few minutes and try rerunning the workflow.

Found 7 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
desktop-main 2.5 MB - 0 -
desktop-preloader 7.1 KB - 0 -
desktop-renderer 82.4 MB - +302.0 B (0.0%) -
desktop-webviewDappPreloader 36.9 KB - 0 -
desktop-webviewPreloader 200.0 B - 0 -
desktop-workers 36.8 KB - 0 -
mobile 129.5 MB - +8.8 KB (0.0%) -
📋 Detailed Reports (Click to expand)

📁 desktop-renderer

Path: rsdoctor/desktop-renderer/rsdoctor-data.json

📌 Baseline Commit: 4597f6ed03a1dd0b6805c61ec63ddd47ec584c2a | PR: #21463

Metric Current Baseline Change
📊 Total Size 82.4 MB 82.4 MB +302.0 B (0.0%)
🗜️ Gzip Size - - -
📄 JavaScript 30.6 MB 30.6 MB +302.0 B (0.0%)
🎨 CSS 188.4 KB 188.4 KB 0
🌐 HTML 1.8 KB 1.8 KB 0
📁 Other Assets 51.7 MB 51.7 MB 0

📦 Download Diff Report: desktop-renderer Bundle Diff

📁 mobile

Path: rsdoctor/mobile/rsdoctor-data.json

📌 Baseline Commit: 4597f6ed03a1dd0b6805c61ec63ddd47ec584c2a | PR: #21463

Metric Current Baseline Change
📊 Total Size 129.5 MB 129.5 MB +8.8 KB (0.0%)
🗜️ Gzip Size - - -
📄 JavaScript 114.0 MB 114.0 MB +8.8 KB (0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 15.5 MB 15.5 MB 0

📦 Download Diff Report: mobile Bundle Diff

Generated by Rsdoctor GitHub Action

lysyi3m
lysyi3m previously approved these changes Sep 2, 2026
Adds the token-state, broadcast and signer-surface errors a PLT transfer
needs, so they land once instead of per-ticket.

The three signer-surface classes are included even though the device
status-word mapping is out of scope: LIVE-36748 was written assuming they
already existed, but they were never implemented, and LIVE-28337 needs
them to map anything in DmkSignerConcordium.

ConcordiumInsufficientCcdForFee is deliberately separate from the generic
NotEnoughBalanceInParentAccount: the failing balance is the parent
account's, not the token sub-account's, and it wants its own copy.
Only addressNotFound and tokenBalanceInsufficient are narrowed. Of the
remaining four CIS-7 types, mintWouldOverflow cannot arise from a
transfer, and deserializationFailure and unsupportedOperation mean the
wallet built a bad payload rather than describing a user-facing state.

operationNotPermitted is the notable gap: the chain reports paused,
allow-list and deny-list failures under that single type, and the only
discriminator is a reason string inside details, which arrives as
hex-encoded CBOR that concordium-core has no decoder for. Those
conditions are therefore reachable only from the pre-send checks in
LIVE-28334, never from this mapping.

The lookup is a Map rather than an object literal because the key comes
off the wire, where a Record would resolve constructor and toString off
Object.prototype and return a non-Error.
@amaslakov
amaslakov force-pushed the LIVE-36748-concordium-add-plt-error-classes-and-error-mapping branch from 9173b2f to 30619aa Compare September 2, 2026 17:08
Copilot AI review requested due to automatic review settings September 2, 2026 17:08

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.

🟢 Approval recommended

The changes are self-contained, follow existing error conventions in the module, and include thorough unit tests for both the new error classes and the reject-reason mapper.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants