@synfin/wallet-partylayer
v0.1.7
Published
The reference Synfin WalletAdapter for PartyLayer-connected Canton wallets. Drop it into @synfin/client's executePlan so a swap executes in about five lines, non-custodially, from the user's own wallet.
Maintainers
Readme
@synfin/wallet-partylayer
The reference Synfin WalletAdapter for a PartyLayer-connected Canton
wallet. Build it once and hand it to @synfin/client's
executePlan, and a swap executes non-custodially from the user's own wallet
in about five lines. Synfin holds no keys.
This wraps the same non-custodial adapter the Synfin Launch App runs and proved on mainnet, so there is no new execution logic here, only the PartyLayer wiring.
- Docs: https://synfin.xyz/docs/support-matrix
- Status: v0, pin an exact version.
Hosted wallets: no PartyLayer needed
If YOU are the wallet (the user is already inside; you hold the party and sign
natively), skip the connector entirely: this package also exports the
underlying CIP-0103 adapter, and @partylayer/sdk is an OPTIONAL peer you do
not install on this path.
import {
createCip0103WalletAdapter,
MAINNET_REGISTRY_BASE_URL,
type Cip0103Signer,
} from '@synfin/wallet-partylayer';
const signer: Cip0103Signer = {
party: userParty, // yours already; nothing connects
async signAndSubmit(tx) {
// sign tx (exercise + disclosedContracts + actAs) with your own key
// machinery and submit through your participant
return { updateId: await myWallet.signAndExecute(tx) };
},
};
const wallet = createCip0103WalletAdapter({
ledger: { baseUrl: myParticipantJsonApi, token: myLedgerToken },
registry: { baseUrl: MAINNET_REGISTRY_BASE_URL, token: '' },
signer,
instrumentAdmin,
});
// then executePlan({ plan, wallet }) from @synfin/client, unchangedGuide: https://synfin.xyz/docs/hosted-wallets. Strict TypeScript setups
(skipLibCheck off) can import from @synfin/wallet-partylayer/cip0103, a
self-contained subpath whose types never reference the SDK.
Install
npm install @synfin/wallet-partylayer @synfin/client @partylayer/sdk@synfin/client and @partylayer/sdk are peer dependencies (you already use
both). This package bundles the rest and has no other runtime dependency.
Use
import { createClient, executePlan, track, isPartnerTerminal } from '@synfin/client';
import { createPartyLayerWalletAdapter } from '@synfin/wallet-partylayer';
// You already have a connected PartyLayer client (partyLayerClient) and a plan
// from synfin.createPlan(...). Wallet in, adapter out:
const wallet = createPartyLayerWalletAdapter(partyLayerClient, {
party: 'yourparty::1220...', // the connected taker party
});
const handle = await executePlan(plan, { wallet });
let state = await track(handle, { wallet });
while (!isPartnerTerminal(state.status)) {
await new Promise((r) => setTimeout(r, 3000));
state = await track(handle, { wallet });
}
console.log('final:', state.status, state.payoutAmount);That is the whole execute path: no CIP-56 transfer construction, no ledger reads, no Canton-specific code in your app, and no network identifiers to paste. The registry base defaults to Synfin's public mainnet proxy, and the deposit instrument's registrar admin is read from your wallet's own holdings (the same way the Launch App resolves it), so nothing that can change out from under you is hardcoded in your code.
Options
Only party is required. For devnet or a private registry, override the
network:
createPartyLayerWalletAdapter(pl, {
party: 'yourparty::1220...',
network: 'devnet', // anything but mainnet needs a base
registryBaseUrl: 'https://your-devnet-scan-proxy',
});What it does
createPartyLayerWalletAdapter returns a @synfin/client WalletAdapter:
sendDepositbuilds and submits the venue deposit as a CIP-56 token-standard transfer offer, signed by the user's wallet.withdrawDeposit/depositActivemanage the offer's lifecycle.observePayoutreads the taker's own holdings through the wallet's participant (never a third-party explorer).lockFeeEscrowis a retired no-op (the escrow was retired for the CIP-0112 batch; see the docs).
Known limitation (stated, not hidden)
observePayout reports the taker's current balance of the instrument, not
the amount received strictly since a timestamp. A holding that merges on
payout re-creates the whole balance, so the reported figure can be the balance,
not the delta. For terminal detection (did a nonzero payout arrive after the
deposit) this is sufficient; for exact received-since accounting, track the
delta yourself against a pre-swap snapshot. A precise received-since read is a
planned hardening.
Non-custodial
Every write is signed by the user's wallet through the PartyLayer bridge; every read uses the wallet's own participant view. Synfin holds no keys and drives no ledger.
License
MIT. Copyright Cayvox Labs.
