Repository navigation
Support external-wallet trading with Token Standard V2 - #138
Merged
Merged
Conversation
An Unfunded pool has zero reserves, so matching the pool ratio derived the paired amount as NaN and left the button disabled. Detect the first deposit, keep both amounts as independent inputs so the LP sets the opening price, estimate LP as sqrt(base*quote), and require both sides before enabling add.
Let a connected wallet prove control of its party on-ledger and receive a scoped, short-lived caller token that authorizes its own trader-flow writes, so a public user swaps or adds liquidity without ever holding the venue operator secret. - Daml SessionAttestation: the party self-authors a single-use proof only it can create (sole signatory); the operator observes and consumes it. - Session service (POST /v1/session/challenge, /v1/session/verify) mints an HS256 caller token (sub=party) from the on-ledger proof; enabled by DEX_CALLER_JWT_SECRET, a 501 no-op otherwise. - A valid caller token authorizes the seven caller-bound trader routes in place of the operator token; the per-caller binding still restricts the subject to the caller's own party, and the backend performs the operator/lpRegistrar ledger steps with its own server-side credential. - Frontend establishes a session on connect (the wallet authors the attestation) and attaches X-Caller-Token to trader writes.
An env file that parses VITE_CANTON_DEX_PACKAGE_ID=#canton-dex-trading-v2 as a comment yields an empty string, which the nullish (`??`) default let through unchanged. Every wallet-authored create then submitted an empty Daml-LF package id. Use `||` so an empty value also falls back to the package-name reference.
…Message) Matches the testnet-deployed tree: the wallet authors only Token-Standard allocations (acceptRequest=false; operator settles via the live-request arm), SessionAttestation removed, off-ledger signMessage session with a capability fallback for keyless wallets. Includes a temporary [session:account-debug] log used to diagnose Loop's empty publicKey (removed in the progressive-auth work).
…ustody
Wallet connect is sign-in; the Token-Standard allocation validated on-ledger is
the authorization boundary. A one-time operator-signed bootstrap token carries a
nonceHash that the operator stamps into the request's allocation specs; the
settle Daml choices validate the allocations against the live request and return
{authenticatedParty, authBinding}. The backend mints a party JWT only when the
presented bootstrap's nonceHash equals the settle result's authBinding, subject
is the ledger-proven party (never the HTTP body), one-time. signMessage stays a
capability-gated fast path; keyless wallets (Loop) take the ledger path. Request
and settle routes leave the operator-token/caller-binding gates; a rate limiter
covers the new public surface. canton-dex-trading-v2 1.1.0 -> 1.2.0 (additive,
upgrade-check clean). Orders remain on the operator path (still trader-signed).
…1.3.0 SwapAllocationRequest/LiquidityAllocationRequest named the trader as observer, making the trader's participant a stakeholder on canton-dex-trading-v2 and forcing it to vet our package (INVALID_PRESCRIBED_SYNCHRONIZER_ID). With acceptRequest=false the wallet authors from HTTP-returned specs and never observes the on-ledger request, so the observer is unnecessary. Removing it keeps the trader off every canton-dex-trading-v2 contract. Additive SCU upgrade (observer-expression change is a warning, not a break).
…tilityV2 External wallets (Loop) reject the BatchingUtilityV2 CreateAndExercise as an unsupported command. Emit one direct AllocationFactory_Allocate ExerciseCommand per leg in a single atomic commands[] instead (composeAllocationCommands), with real per-leg inputHoldingCids. Removes the splice-util-token-standard-wallet dependency from the external-wallet path. Invariant test asserts no external command references canton-dex-trading-v2 / splice-util / CantonDex.*.
PartyLayer/Loop's tx UI refuses a multi-command request (Confirm disabled). The canonical external-wallet flow is now one AllocationFactory_Allocate per wallet prompt: capability supportsMultiCommandTransaction (default false) drives a shared sequential-submit helper that authors each allocation as its own request, recovers each created cid by updateId, and aggregates them in canonical order — the operator settle stays the sole atomic point. settleAt ~5min gives locked funds a liveness escape; partial failure surfaces which leg failed. Backend: recover-dvp-allocations made public (connected) + rate-limited so the browser can recover cids before settle. No wallet-name branching.
…), not synthetic The @partylayer/adapter-loop patch intercepted HoldingV2 ACS queries, called aggregate getHolding(), and fabricated synthetic loop-holding:* contract ids — which Canton rejects as unparseable when passed to AllocationFactory_Allocate. Removed that shim so Holding ACS queries flow through provider.getActiveContracts (real per-holding cids); getHolding stays display-only. Regenerated the patch. Added assertRealContractId guard in composeAllocationCommands so a synthetic id can never reach the wallet again; temporary funding-cid console probe.
…isplay via getHolding Loop's getActiveContracts(HoldingV2 interface) returns [] despite real CC, so funding gets a concrete-template fallback: try the HoldingV2 interface first, then a per-asset concrete Holding template (CC -> #splice-amulet:Splice.Amulet:Amulet) from an asset-compat descriptor in the wallet layer (never DEX/pool code). USDCx left unconfigured until its template is known. Balance DISPLAY now uses the wallet's aggregate getHolding() — a separate path from spendable-holding resolution (balance != spendable ledger contract). Temporary probe logs on the concrete-template response. No synthetic cids.
…+ retry on ingestion lag Recover created allocation cids from each AllocationFactory_Allocate exercise result rather than matching a fixed template name, so deposits minted on external registries (Amulet, USDCx) are recovered. Forward treeAllocationCids through the idempotent ledger wrapper, and retry DvP recovery briefly to absorb cross-participant ingestion lag.
… resolver, committed updateId) Back off and pace active-contracts reads when a wallet rate-limits them. Resolve spendable holdings via the mapped concrete asset template first, falling back to interface discovery. Submit through submit-and-wait so the receipt carries the real ledger updateId the operator recovers by. Show the aggregate available balance in the pool form.
Remove the [funding]/[holdings] active-contracts probes and the adapter waited-submit diagnostic. The loop-sdk 429 error detail is kept: it surfaces the real status when a wallet rate-limits reads.
… Daml tests Drop the unused CantonDex.Session.Attestation template and its stale guide (the deployed auth uses the bootstrap-bound session flow, not this proof-of-control contract), and bump canton-dex-trading-v2 to 1.4.0. The Daml test suite was pinned to the 1.0.0 DAR and had drifted: point trading-tests at the current DAR, add the authBinding field (introduced in 1.2.0) to the request-choice constructions, and read the operator-only request contracts via readAs (the trader observer was removed in 1.3.0). 118 tests pass.
srikanth-bitdynamics
force-pushed
the
registry-0.14
branch
from
September 10, 2026 18:27
005793b to
d5920f4
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add external-wallet funding and atomic settlement across token admins in package version 1.3.0. Update allocation recovery, holding selection and wallet approvals for these flows.
Checked package upgrade compatibility, backend typechecking, 346 backend tests, 145 frontend tests and the frontend build.