import * as _partylayer_core from '@partylayer/core'; import { WalletAdapter, CapabilityKey, AdapterDetectResult, AdapterContext, PartyId, AdapterConnectResult, Session, PersistedSession, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult } from '@partylayer/core'; /** * Loop Wallet adapter * * Implements WalletAdapter interface for 5N Loop Wallet using the official * Loop SDK. The SDK handles QR code display, WebSocket communication, and * popup/tab-based signing flows. * * Note: Loop sessions use WebSocket + localStorage for persistence. * The SDK's autoConnect() can restore sessions if the auth token is still valid. */ declare class LoopAdapter implements WalletAdapter { readonly walletId: _partylayer_core.WalletId; readonly name = "5N Loop"; private currentProvider; getCapabilities(): CapabilityKey[]; /** * Detect if Loop SDK is available. * * Loop uses QR code / popup flow — no browser extension needed. * Always returns true in browser environments since the SDK is * bundled as a dependency. */ detectInstalled(): Promise; /** * Connect to Loop Wallet. * * Flow: * 1. Initialize Loop SDK with app name and network * 2. Call connect() which first tries autoConnect (session restore) * 3. If no cached session, opens QR code overlay for user to scan * 4. User scans QR with Loop mobile app or approves in popup * 5. onAccept callback receives provider with party_id */ connect(ctx: AdapterContext, opts?: { timeoutMs?: number; partyId?: PartyId; }): Promise; /** * Read the wallet's payout-preapproval signal via the SDK's getAccount(), * mapping the SDK's snake_case fields to our camelCase session fields. Purely * a passthrough of what the wallet reports; nothing is inferred. Best-effort: * any failure is logged and yields an empty object so connect still succeeds. */ private readPreapproval; /** * Disconnect from Loop Wallet. * * Calls the SDK's logout() which clears the session, closes * the WebSocket, and removes the QR overlay if visible. */ disconnect(_ctx: AdapterContext, _session: Session): Promise; /** * Restore session. * * Loop SDK persists sessions in localStorage. We can attempt * autoConnect() to restore a valid session without showing the QR code. */ restore(ctx: AdapterContext, persisted: PersistedSession): Promise; /** * Sign a message. */ signMessage(ctx: AdapterContext, session: Session, params: SignMessageParams): Promise; /** * Sign a transaction. * * Loop SDK combines signing and submission. For sign-only, * throw CapabilityNotSupportedError. */ signTransaction(_ctx: AdapterContext, _session: Session, _params: SignTransactionParams): Promise; /** * Submit a transaction. * * Loop SDK's submitTransaction signs and submits the DAML command. * Returns command_id and submission_id. */ submitTransaction(ctx: AdapterContext, session: Session, params: SubmitTransactionParams): Promise; /** * Ledger API endpoints that Loop SDK can fulfill via native methods. * * Loop SDK does not expose a generic Ledger API proxy. Instead, it * provides purpose-built methods (getActiveContracts, getHolding, * submitTransaction, etc.) that we map to Canton Ledger API endpoints. * * Supported endpoints: * - POST /v2/state/acs — via getActiveContracts() * - POST /v2/state/active-contracts — alias for /v2/state/acs * - GET /v2/state/acs/active-contracts — unfiltered, via getActiveContracts() * - POST /v2/commands/submit — via submitTransaction() * - POST /v2/commands/submit-and-wait — via submitAndWaitForTransaction() * - POST /v2/commands/submit-and-wait-for-transaction — alias * * Unsupported endpoints throw CapabilityNotSupportedError with a * message listing the supported routes. */ ledgerApi(ctx: AdapterContext, session: Session, params: LedgerApiParams): Promise; /** Check if the request targets the ACS query endpoint */ private isAcsRoute; /** Check if the request targets a command submission endpoint */ private isSubmitRoute; /** * Handle POST /v2/state/acs via Loop SDK's getActiveContracts(). * * The Canton Ledger API ACS request body contains a filter with template IDs. * We extract the first templateId from the filter and pass it to the Loop SDK. * The response is wrapped to match the Canton Ledger API shape. * * Important: Loop SDK expects fully-qualified Daml template IDs that include * the package name prefix (e.g., '#splice-amulet:Splice.Amulet:Amulet'), * not the short Canton Ledger API format ('Splice.Amulet:Amulet'). */ private handleAcsQuery; /** * Handle POST /v2/commands/submit[-and-wait] via Loop SDK's * submitTransaction() or submitAndWaitForTransaction(). */ private handleSubmitCommand; /** * Build a hint string if the developer passed a short-form Canton * template ID OR used the legacy pre-Token-Standard Amulet_Transfer * choice. Both patterns produce "Execute Unknown on Unknown" in Loop's * UI because Canton moved transfers to CIP-56 TransferFactory in 2025/2026. */ private templateIdHint; /** * Map a PartyLayer network ID to the Loop SDK network format. * * Loop serves only local / devnet / mainnet. Unsupported networks (e.g. * testnet — Loop has none) throw a clear error at connect (via the adapter's * existing error path) instead of being silently substituted to the wrong * network. */ private mapNetworkToLoop; } export { LoopAdapter };