presign-guard-wallet 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,7 +52,18 @@ try {
52
52
  }
53
53
  ```
54
54
 
55
- `wallet` is the same client. `signMessage` is checked too, as a plain message: a sign-in message (Sign-In with Ethereum) for another site than `origin` is red, unreadable bytes are orange; it counts toward no limit (`checkMessages: false` turns this off). Every other method (`getAddresses`, `extend`, …) works as before, unchecked.
55
+ `wallet` is the same client. `signMessage` is checked too, as a plain message: a sign-in message (Sign-In with Ethereum) for another site than `origin` is red, unreadable bytes are orange; it counts toward no limit (`checkMessages: false` turns this off).
56
+
57
+ viem's other ways to sign or send are checked the same way, so a library that uses them can't go around the wallet:
58
+
59
+ | Method | Checked as |
60
+ |---|---|
61
+ | `sendTransactionSync`, `signTransaction` | `sendTransaction` (a signed transaction is as good as sent: anyone can broadcast it) |
62
+ | `writeContractSync` | `writeContract` |
63
+ | `sendCalls`, `sendCallsSync` (EIP-5792 batches) | every call, as a transaction from the wallet; one red or stopped call stops the whole batch. Each call counts toward `perTx` on its own and all of them toward the day's limit, booked before anything is signed |
64
+ | `deployContract` | a deployment: not checked by presign-guard, but the value it sends counts toward the limits |
65
+
66
+ Every other method (`getAddresses`, `extend`, `sendRawTransaction` for a transaction that is already signed, …) works as before, unchecked.
56
67
 
57
68
  ## Options
58
69
 
@@ -287,7 +298,9 @@ Only single payments are checked; the cumulative spend against the cap needs the
287
298
 
288
299
  ## XRP Ledger (RLUSD and XRP)
289
300
 
290
- `xrplSigner` guards an XRPL signer the same way: before a `Payment` is signed it goes to presign-guard as `{ type: "xrpl", network, tx }` (destination, issuer of the token, flags), and red or orange stops it. Spending limits apply too: RLUSD from Ripple's issuer counts toward your `USDC` limit, drops toward `XRP`, any other token is unknown (`onUnknown`). The agent keeps its own XRPL key; anything but a `Payment` is refused.
301
+ `xrplSigner` guards an XRPL signer the same way: before a `Payment` is signed it goes to presign-guard as `{ type: "xrpl", network, tx }` (destination, issuer of the token, flags), and red or orange stops it. Spending limits apply too: RLUSD from Ripple's issuer counts toward your `USDC` limit, drops toward `XRP`, any other token is unknown (`onUnknown`). The agent keeps its own XRPL key; anything but a `Payment` is refused, unless you pass `{ any: true }`.
302
+
303
+ **Other XRPL transactions.** With `xrplSigner(signer, { any: true })` the signer also signs other transactions from its own account: a trust line for RLUSD, a DEX order, an escrow, a `Batch`. Each goes to presign-guard first. presign-guard judges every transaction inside a Batch on its own, so a new regular key, signer list or account delete hidden next to a payment is red and never signed; a `DelegateSet` that lets another account send payments for you is red too. What the transaction can take out counts toward your limits: a `Payment` (SendMax or Amount), a check (SendMax), an escrow or payment channel (Amount), a DEX order (TakerGets), an AMM deposit, an NFT buy offer, and in a Batch this account's own inner transactions together (the other accounts' parts are their money). Trust lines, cancellations and other types that move nothing out add nothing; anything else (an `AccountDelete`, a `DelegateSet`, a `SetRegularKey`) counts as unknown spending and goes to `onOverLimit`.
291
304
 
292
305
  ```js
293
306
  import { Wallet } from "xrpl";
package/index.d.ts CHANGED
@@ -152,6 +152,13 @@ export interface GuardControls {
152
152
  * Tempo's escrow, in USDC.e, for this account (the deposit counts toward the USDC limits), plus its vouchers.
153
153
  */
154
154
  tempoSessionAccount<A extends LocalAccount>(account: A, opts?: { chainId?: 4217 | 42431 }): A;
155
+ /**
156
+ * A guarded XRP Ledger signer for @x402/xrpl (ExactXrplScheme): signs only Payment transactions from this account,
157
+ * each checked by presign-guard (type xrpl) and counted toward the limits (RLUSD toward USDC, drops toward XRP);
158
+ * anything else is refused, unless `any`: then every transaction (trust lines, DEX orders, a Batch, whose inner
159
+ * transactions presign-guard judges one by one) is checked first and what it can take out counts toward the limits.
160
+ */
161
+ xrplSigner<S extends { classicAddress: string; sign(tx: Record<string, unknown>): unknown }>(signer: S, opts?: { network?: "xrpl:0" | "xrpl:1"; any?: boolean }): S;
155
162
  /**
156
163
  * A guarded Algorand signer for @x402/avm (ExactAvmScheme): signs only the agent's own USDC transfer in a
157
164
  * payment group (no close-out, rekey or clawback), counted toward the USDC limits; anything else is refused.
@@ -203,7 +210,11 @@ export interface GuardOptions {
203
210
  server?: { url: string; key: string; fetch?: typeof globalThis.fetch; requestTimeoutMs?: number };
204
211
  }
205
212
 
206
- /** The same wallet client; sendTransaction, writeContract, signTypedData, signAuthorization (EIP-7702) and signMessage are checked first. */
213
+ /**
214
+ * The same wallet client. Checked first: sendTransaction, writeContract, signTypedData, signAuthorization (EIP-7702),
215
+ * signMessage, and viem's other ways to sign or send: signTransaction, sendTransactionSync, writeContractSync,
216
+ * sendCalls and sendCallsSync (every call), deployContract (its value counts toward the limits).
217
+ */
207
218
  export declare function guardWallet<W extends WalletClient>(wallet: W, options: GuardOptions): W & GuardControls;
208
219
  export declare function checkRequestFor(method: string, args: unknown, options?: { chainId?: number; origin?: string; x402?: Record<string, unknown>; from?: string }): CheckRequest | null;
209
220
  /**
package/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  // presign-guard-wallet: a viem wallet for AI agents that asks presign-guard
2
2
  // before it signs.
3
3
  //
4
- // Before every sendTransaction, writeContract and signTypedData, the wallet
4
+ // Before every sendTransaction, writeContract and signTypedData (and viem's
5
+ // other ways to sign or send: signTransaction, sendTransactionSync,
6
+ // writeContractSync, sendCalls, sendCallsSync, deployContract), the wallet
5
7
  // pays $0.01 (x402, USDC) for a presign-guard verdict on exactly what is about
6
8
  // to be signed, and acts on it:
7
9
  // green → signs
@@ -52,7 +54,9 @@
52
54
  // Payment transactions, each checked by presign-guard first (type "xrpl": fake
53
55
  // RLUSD, partial payments, missing destination tags, issuer risks) and counted
54
56
  // toward the limits (XRP toward an XRP limit, RLUSD toward USDC). Use it with
55
- // @x402/xrpl's ExactXrplScheme to pay x402 services in RLUSD.
57
+ // @x402/xrpl's ExactXrplScheme to pay x402 services in RLUSD. With { any: true }
58
+ // it also signs other transactions (a trust line, a DEX order, a Batch), each
59
+ // checked by presign-guard first; what they can take out counts toward the limits.
56
60
 
57
61
  import { bytesToHex, decodeFunctionData, encodeFunctionData, parseAbi } from "viem";
58
62
  import { recoverAuthorizationAddress } from "viem/utils";
@@ -86,7 +90,7 @@ const ESCROW_ABI = parseAbi([
86
90
  const TRANSFER_ABI = parseAbi(["function transfer(address to, uint256 amount)"]);
87
91
  const VOUCHER_DOMAIN = "TIP20 Channel Reserve";
88
92
  export const XRPL_NETWORKS = ["xrpl:0", "xrpl:1"];
89
- export const VERSION = "0.21.0";
93
+ export const VERSION = "0.23.0";
90
94
  export const CREDIT_HEADER = "x-credit-key";
91
95
  const ROUTE = "POST /v1/check";
92
96
 
@@ -139,6 +143,7 @@ function senderOf(args, client) {
139
143
  // What presign-guard should check for a wallet call, or null for calls it does not cover. With `from` (the
140
144
  // sending wallet) presign-guard simulates a transaction and reports what really leaves the wallet.
141
145
  export function checkRequestFor(method, args, { chainId, origin, x402, from } = {}) {
146
+ method = SAME_AS[method] ?? method;
142
147
  const base = { chainId, ...(origin ? { origin } : {}) };
143
148
  const sender = from ? { from } : {};
144
149
  if (method === "sendTransaction") {
@@ -207,7 +212,13 @@ export function sessionDeposit(tx, chainId, address) {
207
212
  return { token: descriptor.token.toLowerCase(), payee: descriptor.payee, deposit };
208
213
  }
209
214
 
210
- const GUARDED = new Set(["sendTransaction", "writeContract", "signTypedData", "signAuthorization"]);
215
+ // viem's other ways to sign or send, each checked like the call it stands for. A signed transaction is as good as
216
+ // sent (anyone can broadcast it), and a deployment is checked like a transaction without a recipient: not by
217
+ // presign-guard, but the value it sends counts.
218
+ const SAME_AS = { sendTransactionSync: "sendTransaction", signTransaction: "sendTransaction", deployContract: "sendTransaction", writeContractSync: "writeContract" };
219
+ // EIP-5792 batches: every call in them is checked.
220
+ const BATCHES = new Set(["sendCalls", "sendCallsSync"]);
221
+ const GUARDED = new Set(["sendTransaction", "writeContract", "signTypedData", "signAuthorization", ...Object.keys(SAME_AS), ...BATCHES]);
211
222
 
212
223
  // A signed EIP-7702 authorization, by its signature.
213
224
  const authorizationKey = (a) => (typeof a?.r === "string" && typeof a?.s === "string" ? `${a.r}:${a.s}`.toLowerCase() : null);
@@ -373,10 +384,45 @@ export function guardWallet(wallet, {
373
384
  return result;
374
385
  }
375
386
 
387
+ // Several spends signed at once (a batch): every one booked before anything is signed, so each counts toward the
388
+ // window (perTx applies to each call on its own); all given back when one doesn't fit or signing fails.
389
+ async function withinLimitsAll(method, items, run) {
390
+ const ctx = purchases.getStore();
391
+ const purchase = ctx?.info ?? null;
392
+ const booked = [];
393
+ const giveBack = (error) => Promise.all(booked.map((b) => limiter.release(b.entries, { purchaseId: b.purchaseId, error }).catch((e) => console.warn(`[presign-guard-wallet] could not give back spending: ${e.message}`))));
394
+ for (const { request, verdict } of items) {
395
+ let b;
396
+ try {
397
+ b = await limiter.reserve({ method, request, verdict, purchase });
398
+ } catch (err) {
399
+ await giveBack(err.message);
400
+ throw new PresignBlockedError(`spending limits could not be checked (${err.message}); nothing was signed`, { code: "limit_unavailable", verdict, request });
401
+ }
402
+ if (!b.ok) {
403
+ await giveBack(b.summary);
404
+ const err = new PresignBlockedError(`not signed: ${b.summary}`, { code: b.paused ? "paused" : "over_limit", verdict, request });
405
+ err.reasons = b.reasons;
406
+ throw err;
407
+ }
408
+ booked.push({ ...b, verdict });
409
+ if (b.purchaseId) ctx?.purchaseIds.push(b.purchaseId);
410
+ }
411
+ let result;
412
+ try {
413
+ result = await run();
414
+ } catch (err) {
415
+ await giveBack(err.message);
416
+ throw err;
417
+ }
418
+ for (const b of booked) limiter.spent(b.entries, result, { verdict: b.verdict, purchase, purchaseId: b.purchaseId, approval: b.approval ?? null });
419
+ return result;
420
+ }
421
+
376
422
  // Tempo: only a plain stablecoin transfer, checked here instead of by presign-guard.
377
423
  function tempoRequest(method, args, chainId) {
378
424
  const tokens = TEMPO_TOKENS[chainId];
379
- const ok = method === "writeContract" && tokens.includes(String(args?.address ?? "").toLowerCase())
425
+ const ok = (SAME_AS[method] ?? method) === "writeContract" && tokens.includes(String(args?.address ?? "").toLowerCase())
380
426
  && TEMPO_TRANSFERS.has(args?.functionName) && !(BigInt(args?.value ?? 0n) > 0n);
381
427
  let request = null;
382
428
  try { request = ok ? checkRequestFor(method, args, { chainId, origin }) : null; } catch { request = null; }
@@ -422,10 +468,32 @@ export function guardWallet(wallet, {
422
468
  }
423
469
  }
424
470
 
471
+ // EIP-5792 batches (sendCalls, sendCallsSync): every call is checked like a transaction from the same wallet and
472
+ // counts toward the limits; one red or stopped call stops the whole batch, before anything is signed.
473
+ async function sendCallsGuarded(target, method, original, args, rest, chainId) {
474
+ if (TEMPO_TOKENS[chainId]) throw new PresignBlockedError(`on Tempo (chain ${chainId}) this wallet sends no batches; nothing was signed`, { code: "unsupported_chain" });
475
+ const calls = Array.isArray(args?.calls) ? args.calls : [];
476
+ if (!calls.length) throw new PresignBlockedError("a batch without calls; nothing was signed", { code: "check_failed" });
477
+ const from = senderOf(args, target);
478
+ const checked = [];
479
+ for (const call of calls) {
480
+ // A call is { to, data, value } or { to, abi, functionName, args, value }, as viem takes them.
481
+ const request = call?.abi
482
+ ? checkRequestFor("writeContract", { address: call.to, abi: call.abi, functionName: call.functionName, args: call.args, value: call.value }, { chainId, origin, from })
483
+ : checkRequestFor("sendTransaction", call, { chainId, origin, from });
484
+ // A deployment in the batch: not checked, but the value it sends counts.
485
+ if (!request) checked.push({ request: { type: "transaction", chainId, to: null, data: call?.data ?? "0x", value: String(call?.value ?? 0n) }, verdict: null });
486
+ else checked.push({ request, verdict: await verdictFor(method, request, chainId) });
487
+ }
488
+ const run = () => original(args, ...rest);
489
+ return limiter ? withinLimitsAll(method, checked, run) : run();
490
+ }
491
+
425
492
  async function guarded(target, method, original, args, rest) {
426
493
  if (paused) throw new PresignBlockedError(`wallet is paused; nothing was signed`, { code: "paused" });
427
494
  const chainId = args?.chain?.id ?? target.chain?.id;
428
495
  const run = () => original(args, ...rest);
496
+ if (BATCHES.has(method)) return sendCallsGuarded(target, method, original, args, rest, chainId);
429
497
  if (method === "signAuthorization") {
430
498
  if (TEMPO_TOKENS[chainId]) throw new PresignBlockedError(`on Tempo (chain ${chainId}) this wallet signs no EIP-7702 authorization; nothing was signed`, { code: "unsupported_chain" });
431
499
  return signAuthorizationGuarded(target, original, args, rest, chainId);
@@ -446,7 +514,7 @@ export function guardWallet(wallet, {
446
514
  const request = checkRequestFor(method, args, { chainId, origin, x402: x402Paying.getStore(), from: senderOf(args, target) });
447
515
  if (!request) {
448
516
  // A contract deployment is not checked, but the value it sends still counts.
449
- if (limiter && method === "sendTransaction") {
517
+ if (limiter && (SAME_AS[method] ?? method) === "sendTransaction") {
450
518
  return withinLimits(method, { type: "transaction", chainId, to: null, data: args?.data ?? "0x", value: String(args?.value ?? 0n) }, null, run);
451
519
  }
452
520
  return run();
@@ -455,19 +523,21 @@ export function guardWallet(wallet, {
455
523
  return limiter ? withinLimits(method, request, verdict, run) : run();
456
524
  }
457
525
 
458
- // XRP Ledger: sign a Payment only after presign-guard's check and within the limits.
459
- async function xrplSign(signer, network, tx) {
526
+ // XRP Ledger: sign a Payment (with any, any transaction) only after presign-guard's check and within the limits.
527
+ // presign-guard judges every transaction inside a Batch, so a new key can't hide in one; red is never signed.
528
+ async function xrplSign(signer, network, tx, any) {
460
529
  if (paused) throw new PresignBlockedError(`wallet is paused; nothing was signed`, { code: "paused" });
461
- if (!tx || typeof tx !== "object" || tx.TransactionType !== "Payment") {
462
- throw new PresignBlockedError(`on the XRP Ledger this wallet only signs Payment transactions (got ${tx?.TransactionType ?? "nothing"}); nothing was signed`, { code: "unsupported_chain" });
530
+ if (!tx || typeof tx !== "object" || typeof tx.TransactionType !== "string" || (tx.TransactionType !== "Payment" && !any)) {
531
+ throw new PresignBlockedError(`on the XRP Ledger this wallet only signs Payment transactions (got ${tx?.TransactionType ?? "nothing"}; xrplSigner with { any: true } signs others after presign-guard's check); nothing was signed`, { code: "unsupported_chain" });
463
532
  }
464
533
  if (tx.Account && signer.classicAddress && tx.Account !== signer.classicAddress) {
465
534
  throw new PresignBlockedError(`the transaction's Account ${tx.Account} is not this signer (${signer.classicAddress}); nothing was signed`, { code: "unsupported_chain" });
466
535
  }
467
536
  const request = { type: "xrpl", network, tx: JSON.parse(JSON.stringify(tx)), ...(origin ? { origin } : {}) };
468
- const verdict = await verdictFor("signXrplPayment", request, network);
537
+ const method = tx.TransactionType === "Payment" ? "signXrplPayment" : "signXrplTransaction";
538
+ const verdict = await verdictFor(method, request, network);
469
539
  const run = () => signer.sign(tx);
470
- return limiter ? withinLimits("signXrplPayment", request, verdict, run) : run();
540
+ return limiter ? withinLimits(method, request, verdict, run) : run();
471
541
  }
472
542
 
473
543
  // Algorand: sign only a USDC transfer from this address, within the limits (checked here, no presign-guard
@@ -558,12 +628,13 @@ export function guardWallet(wallet, {
558
628
  /**
559
629
  * The same guard on an XRP Ledger signer ({ classicAddress, sign(tx) }, e.g. createXrplWalletSigner
560
630
  * from @x402/xrpl): only Payment transactions, each checked by presign-guard and counted toward the
561
- * limits (RLUSD toward USDC, XRP toward an XRP limit). network: "xrpl:0" (default) or "xrpl:1".
631
+ * limits (RLUSD toward USDC, XRP toward an XRP limit). network: "xrpl:0" (default) or "xrpl:1". any: also
632
+ * sign other transactions (trust lines, DEX orders, a Batch), each checked by presign-guard first.
562
633
  */
563
- xrplSigner: (signer, { network = "xrpl:0" } = {}) => {
634
+ xrplSigner: (signer, { network = "xrpl:0", any = false } = {}) => {
564
635
  if (!signer || typeof signer.sign !== "function") throw new TypeError("xrplSigner(signer): signer needs a sign(tx) function (e.g. createXrplWalletSigner from @x402/xrpl)");
565
636
  if (!XRPL_NETWORKS.includes(network)) throw new TypeError(`xrplSigner: network must be one of ${XRPL_NETWORKS.join(", ")}`);
566
- return { classicAddress: signer.classicAddress, sign: (tx) => xrplSign(signer, network, tx) };
637
+ return { classicAddress: signer.classicAddress, sign: (tx) => xrplSign(signer, network, tx, any === true) };
567
638
  },
568
639
  /**
569
640
  * A guarded viem account for MPP sessions on Tempo (e.g. mppx's sessionManager): it signs only
package/limits.js CHANGED
@@ -171,25 +171,64 @@ export function spendFor(request, verdict) {
171
171
  return out;
172
172
  }
173
173
 
174
- // An XRP Ledger Payment: what can leave the account (SendMax if set, else Amount) and who receives it.
174
+ // XRP Ledger: what can leave the account and who receives it. A Payment: SendMax if set, else Amount. With any
175
+ // (xrplSigner { any: true }), also a check (SendMax), escrow or payment channel (Amount), DEX order (TakerGets), AMM
176
+ // deposit, NFT buy offer and bridge commit, and the account's own transactions inside a Batch (the others are their
177
+ // accounts' money). Types that move nothing out by themselves add nothing; anything else is unknown.
178
+ const XRPL_MOVES_NOTHING = new Set(["TrustSet", "AccountSet", "OfferCancel", "EscrowFinish", "EscrowCancel", "CheckCash", "CheckCancel", "TicketCreate", "NFTokenMint", "NFTokenBurn", "NFTokenCancelOffer", "NFTokenModify", "AMMWithdraw", "AMMVote", "AMMDelete", "AMMClawback", "Clawback", "CredentialCreate", "CredentialAccept", "CredentialDelete", "PermissionedDomainSet", "PermissionedDomainDelete", "DepositPreauth", "DIDSet", "DIDDelete", "OracleSet", "OracleDelete", "MPTokenAuthorize", "MPTokenIssuanceCreate", "MPTokenIssuanceSet", "MPTokenIssuanceDestroy"]);
179
+ const TF_SELL_NFTOKEN = 0x00000001;
180
+
175
181
  function xrplSpend(request, out) {
176
182
  const net = request.network ?? "xrpl:0";
177
183
  const tx = request.tx ?? {};
184
+ if (tx.TransactionType === "Batch") {
185
+ const inner = Array.isArray(tx.RawTransactions) ? tx.RawTransactions.map((r) => r?.RawTransaction ?? {}) : [];
186
+ if (!inner.length) out.unknown = true;
187
+ for (const t of inner) if (!t.Account || t.Account === tx.Account) xrplTxSpend(t, net, out);
188
+ } else xrplTxSpend(tx, net, out);
189
+ return out;
190
+ }
191
+
192
+ function xrplTxSpend(tx, net, out) {
178
193
  const to = typeof tx.Destination === "string" && XRPL_ADDRESS_RE.test(tx.Destination) ? lower(tx.Destination) : null;
179
- out.counterparties.push(to);
180
- if (tx.TransactionType !== "Payment") { out.unknown = true; return out; }
181
- const amt = tx.SendMax ?? tx.Amount;
182
- if (typeof amt === "string" && /^\d+$/.test(amt)) {
183
- out.items.push({ chainId: net, token: NATIVE, amount: BigInt(amt), to });
184
- } else if (amt && typeof amt === "object" && /^\d+(\.\d+)?$/.test(String(amt.value ?? ""))) {
185
- const currency = String(amt.currency ?? "").toUpperCase();
186
- const rlusd = (currency === "RLUSD" || currency === RLUSD_HEX) && amt.issuer === XRPL_RLUSD_ISSUERS[net];
187
- const value = String(amt.value).replace(/^(\d+\.\d{18})\d+$/, "$1"); // RLUSD has at most 15 significant digits; keep 18 decimals
188
- out.items.push({ chainId: net, token: rlusd ? "rlusd" : `${currency}.${amt.issuer}`, amount: parseUnits(value, SCALE), to });
189
- } else {
190
- out.unknown = true;
194
+ const take = (amt, receiver) => {
195
+ if (typeof amt === "string" && /^\d+$/.test(amt)) {
196
+ out.items.push({ chainId: net, token: NATIVE, amount: BigInt(amt), to: receiver });
197
+ } else if (amt && typeof amt === "object" && typeof amt.mpt_issuance_id === "string" && /^\d+$/.test(String(amt.value ?? ""))) {
198
+ out.items.push({ chainId: net, token: `mpt.${amt.mpt_issuance_id}`, amount: BigInt(amt.value), to: receiver });
199
+ } else if (amt && typeof amt === "object" && /^\d+(\.\d+)?$/.test(String(amt.value ?? ""))) {
200
+ const currency = String(amt.currency ?? "").toUpperCase();
201
+ const rlusd = (currency === "RLUSD" || currency === RLUSD_HEX) && amt.issuer === XRPL_RLUSD_ISSUERS[net];
202
+ const value = String(amt.value).replace(/^(\d+\.\d{18})\d+$/, "$1"); // RLUSD has at most 15 significant digits; keep 18 decimals
203
+ out.items.push({ chainId: net, token: rlusd ? "rlusd" : `${currency}.${amt.issuer}`, amount: parseUnits(value, SCALE), to: receiver });
204
+ } else {
205
+ out.unknown = true;
206
+ }
207
+ };
208
+ switch (tx.TransactionType) {
209
+ case "Payment": out.counterparties.push(to); take(tx.SendMax ?? tx.Amount, to); break;
210
+ case "CheckCreate": out.counterparties.push(to); take(tx.SendMax, to); break;
211
+ case "EscrowCreate":
212
+ case "PaymentChannelCreate": out.counterparties.push(to); take(tx.Amount, to); break;
213
+ case "PaymentChannelFund":
214
+ case "XChainCommit": out.counterparties.push(null); take(tx.Amount, null); break;
215
+ case "OfferCreate": out.counterparties.push(null); take(tx.TakerGets, null); break;
216
+ case "AMMCreate":
217
+ case "AMMDeposit":
218
+ out.counterparties.push(null);
219
+ if (tx.Amount === undefined && tx.Amount2 === undefined) out.unknown = true;
220
+ for (const a of [tx.Amount, tx.Amount2]) if (a !== undefined) take(a, null);
221
+ break;
222
+ case "NFTokenCreateOffer":
223
+ // A buy offer pays Amount to the owner; a sell offer gives the NFT, which no limit counts.
224
+ if (Number(tx.Flags) & TF_SELL_NFTOKEN) out.counterparties.push(to);
225
+ else { const owner = typeof tx.Owner === "string" ? lower(tx.Owner) : null; out.counterparties.push(owner); take(tx.Amount, owner); }
226
+ break;
227
+ default:
228
+ if (XRPL_MOVES_NOTHING.has(tx.TransactionType)) break;
229
+ out.counterparties.push(to);
230
+ out.unknown = true;
191
231
  }
192
- return out;
193
232
  }
194
233
 
195
234
  // An Algorand asset transfer (read from the unsigned transaction by algorandSigner): the asset, amount and receiver.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presign-guard-wallet",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "A wallet for AI agents (viem on EVM chains, Solana and Algorand) that asks presign-guard ($0.01 over x402) before every transaction, contract write and signature, refuses to sign red, and keeps to per-token spending limits, with approval from your phone over the limit (Telegram, or signed in your own wallet over AC2).",
5
5
  "type": "module",
6
6
  "exports": {