presign-guard-wallet 0.23.0 → 0.25.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 +2 -2
- package/index.js +4 -3
- package/limits.js +17 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ Every other method (`getAddresses`, `extend`, `sendRawTransaction` for a transac
|
|
|
85
85
|
| `onSpend` | | `(entry) => void` after each signed spend, e.g. for a log |
|
|
86
86
|
| `store` | in memory | Where spending is kept; `fileStore(path)` from `presign-guard-wallet/file-store`, or your own |
|
|
87
87
|
|
|
88
|
-
Chains: Ethereum (1), Optimism (10), BNB Chain (56), Polygon (137), Base (8453), Arbitrum (42161).
|
|
88
|
+
Chains: Ethereum (1), Optimism (10), BNB Chain (56), Polygon (137), Base (8453), Arbitrum (42161), Robinhood Chain (4663).
|
|
89
89
|
|
|
90
90
|
**Tempo** (4217, and the Moderato testnet 42431) is not covered by presign-guard. There the wallet signs exactly one thing, checked locally: a TIP-20 `transfer` or `transferWithMemo` of USDC.e (pathUSD on the testnet), with no value attached, counted toward your `USDC` limits. Anything else on Tempo is refused (`unsupported_chain`). Guard a Tempo wallet client next to your main one with `guarded.wrap(tempoWalletClient)`: both share the same limits, pause and purchase records.
|
|
91
91
|
|
|
@@ -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";
|
|
@@ -74,7 +75,7 @@ export { memoryStore };
|
|
|
74
75
|
|
|
75
76
|
export const PRESIGN_URL = "https://presign-guard.fizzl.eu";
|
|
76
77
|
export const PRESIGN_SIGNERS = ["0xf084Ea47Ca4D99BB4De3ECB0332b316bE6521EaE"];
|
|
77
|
-
export const SUPPORTED_CHAINS = [1, 10, 56, 137, 8453, 42161];
|
|
78
|
+
export const SUPPORTED_CHAINS = [1, 10, 56, 137, 8453, 42161, 4663];
|
|
78
79
|
// Tempo: the stablecoins the wallet may send there (the ones the USDC limit covers).
|
|
79
80
|
export const TEMPO_TOKENS = {
|
|
80
81
|
4217: ["0x20c000000000000000000000b9537d11c60e8b50"],
|
package/limits.js
CHANGED
|
@@ -40,11 +40,14 @@ const USDC = {
|
|
|
40
40
|
137: [["0x3c499c542cef5e3811e1192ce70d8cc03d5c3359", 6], ["0x2791bca1f2de4661ed88a30c99a7a9449aa84174", 6]],
|
|
41
41
|
8453: [["0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", 6]],
|
|
42
42
|
42161: [["0xaf88d065e77c8cc2239327c5edb3a432268e5831", 6], ["0xff970a61a04b1ca14834a43f5de4533ebddb5cc8", 6]],
|
|
43
|
+
// Robinhood Chain has no Circle USDC: its dollar is Paxos' USDG (Global Dollar), counted like RLUSD (a dollar is a
|
|
44
|
+
// dollar). A token there called "USDC" (0x11d0…991e, 18 decimals) is a copy and stays outside the budget.
|
|
45
|
+
4663: [["0x5fc5360d0400a0fd4f2af552add042d716f1d168", 6]],
|
|
43
46
|
// Tempo: USDC.e (bridged USDC, what MPP charges in), and pathUSD on the Moderato testnet.
|
|
44
47
|
4217: [["0x20c000000000000000000000b9537d11c60e8b50", 6]],
|
|
45
48
|
42431: [["0x20c0000000000000000000000000000000000000", 6]],
|
|
46
49
|
};
|
|
47
|
-
const NATIVE_SYMBOL = { 1: "ETH", 10: "ETH", 8453: "ETH", 42161: "ETH", 56: "BNB", 137: "POL", "xrpl:0": "XRP", "xrpl:1": "XRP", ...Object.fromEntries(Object.keys(SOLANA_USDC).map((n) => [n, "SOL"])), ...Object.fromEntries(Object.keys(ALGORAND_USDC).map((n) => [n, "ALGO"])) };
|
|
50
|
+
const NATIVE_SYMBOL = { 1: "ETH", 10: "ETH", 8453: "ETH", 42161: "ETH", 4663: "ETH", 56: "BNB", 137: "POL", "xrpl:0": "XRP", "xrpl:1": "XRP", ...Object.fromEntries(Object.keys(SOLANA_USDC).map((n) => [n, "SOL"])), ...Object.fromEntries(Object.keys(ALGORAND_USDC).map((n) => [n, "ALGO"])) };
|
|
48
51
|
export const KNOWN_TOKENS = ["USDC", "ETH", "BNB", "POL", "XRP", "SOL", "ALGO"];
|
|
49
52
|
|
|
50
53
|
// XRP Ledger networks and the RLUSD issuer on each (Ripple's).
|
|
@@ -173,9 +176,11 @@ export function spendFor(request, verdict) {
|
|
|
173
176
|
|
|
174
177
|
// XRP Ledger: what can leave the account and who receives it. A Payment: SendMax if set, else Amount. With any
|
|
175
178
|
// (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
|
-
|
|
179
|
+
// deposit, NFT buy offer and bridge commit, a vault deposit, first-loss cover deposit or loan payment (Amount), a vault
|
|
180
|
+
// or cover withdrawal to another account (Amount, to that account), and the account's own transactions inside a Batch
|
|
181
|
+
// (the others are their accounts' money). Types that move nothing out by themselves add nothing (a loan is paid out by
|
|
182
|
+
// the vault, and its payments count when they are made); anything else is unknown.
|
|
183
|
+
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
184
|
const TF_SELL_NFTOKEN = 0x00000001;
|
|
180
185
|
|
|
181
186
|
function xrplSpend(request, out) {
|
|
@@ -213,6 +218,14 @@ function xrplTxSpend(tx, net, out) {
|
|
|
213
218
|
case "PaymentChannelFund":
|
|
214
219
|
case "XChainCommit": out.counterparties.push(null); take(tx.Amount, null); break;
|
|
215
220
|
case "OfferCreate": out.counterparties.push(null); take(tx.TakerGets, null); break;
|
|
221
|
+
case "VaultDeposit":
|
|
222
|
+
case "LoanBrokerCoverDeposit":
|
|
223
|
+
case "LoanPay": out.counterparties.push(null); take(tx.Amount, null); break;
|
|
224
|
+
case "VaultWithdraw":
|
|
225
|
+
case "LoanBrokerCoverWithdraw":
|
|
226
|
+
// Into the account itself nothing leaves it; to another Destination, what is withdrawn goes to that account.
|
|
227
|
+
if (to && to !== lower(tx.Account)) { out.counterparties.push(to); take(tx.Amount, to); }
|
|
228
|
+
break;
|
|
216
229
|
case "AMMCreate":
|
|
217
230
|
case "AMMDeposit":
|
|
218
231
|
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.25.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": {
|