presign-guard-wallet 0.23.0 → 0.24.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 +1 -1
- package/index.js +3 -2
- package/limits.js +13 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -300,7 +300,7 @@ Only single payments are checked; the cumulative spend against the cap needs the
|
|
|
300
300
|
|
|
301
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
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`.
|
|
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, a vault deposit, a first-loss cover deposit or a loan payment (Amount), a vault or cover withdrawal to another account (Amount, to that account), and in a Batch this account's own inner transactions together (the other accounts' parts are their money). Trust lines, cancellations, a withdrawal into your own account, a loan (the vault pays it out; its payments count when made) 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`.
|
|
304
304
|
|
|
305
305
|
```js
|
|
306
306
|
import { Wallet } from "xrpl";
|
package/index.js
CHANGED
|
@@ -55,8 +55,9 @@
|
|
|
55
55
|
// RLUSD, partial payments, missing destination tags, issuer risks) and counted
|
|
56
56
|
// toward the limits (XRP toward an XRP limit, RLUSD toward USDC). Use it with
|
|
57
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
|
|
59
|
-
// checked by presign-guard first; what they can
|
|
58
|
+
// it also signs other transactions (a trust line, a DEX order, a Batch, a vault
|
|
59
|
+
// deposit or loan payment), each checked by presign-guard first; what they can
|
|
60
|
+
// take out counts toward the limits.
|
|
60
61
|
|
|
61
62
|
import { bytesToHex, decodeFunctionData, encodeFunctionData, parseAbi } from "viem";
|
|
62
63
|
import { recoverAuthorizationAddress } from "viem/utils";
|
package/limits.js
CHANGED
|
@@ -173,9 +173,11 @@ export function spendFor(request, verdict) {
|
|
|
173
173
|
|
|
174
174
|
// XRP Ledger: what can leave the account and who receives it. A Payment: SendMax if set, else Amount. With any
|
|
175
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,
|
|
177
|
-
//
|
|
178
|
-
|
|
176
|
+
// deposit, NFT buy offer and bridge commit, a vault deposit, first-loss cover deposit or loan payment (Amount), a vault
|
|
177
|
+
// or cover withdrawal to another account (Amount, to that account), and the account's own transactions inside a Batch
|
|
178
|
+
// (the others are their accounts' money). Types that move nothing out by themselves add nothing (a loan is paid out by
|
|
179
|
+
// the vault, and its payments count when they are made); anything else is unknown.
|
|
180
|
+
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", "VaultCreate", "VaultSet", "VaultDelete", "VaultClawback", "LoanBrokerSet", "LoanBrokerDelete", "LoanBrokerCoverClawback", "LoanSet", "LoanDelete", "LoanManage"]);
|
|
179
181
|
const TF_SELL_NFTOKEN = 0x00000001;
|
|
180
182
|
|
|
181
183
|
function xrplSpend(request, out) {
|
|
@@ -213,6 +215,14 @@ function xrplTxSpend(tx, net, out) {
|
|
|
213
215
|
case "PaymentChannelFund":
|
|
214
216
|
case "XChainCommit": out.counterparties.push(null); take(tx.Amount, null); break;
|
|
215
217
|
case "OfferCreate": out.counterparties.push(null); take(tx.TakerGets, null); break;
|
|
218
|
+
case "VaultDeposit":
|
|
219
|
+
case "LoanBrokerCoverDeposit":
|
|
220
|
+
case "LoanPay": out.counterparties.push(null); take(tx.Amount, null); break;
|
|
221
|
+
case "VaultWithdraw":
|
|
222
|
+
case "LoanBrokerCoverWithdraw":
|
|
223
|
+
// Into the account itself nothing leaves it; to another Destination, what is withdrawn goes to that account.
|
|
224
|
+
if (to && to !== lower(tx.Account)) { out.counterparties.push(to); take(tx.Amount, to); }
|
|
225
|
+
break;
|
|
216
226
|
case "AMMCreate":
|
|
217
227
|
case "AMMDeposit":
|
|
218
228
|
out.counterparties.push(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "presign-guard-wallet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.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": {
|