arc402-cli 0.7.5 → 0.8.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/MIGRATION-SPEC.md +108 -0
- package/dist/abis.js +14 -17
- package/dist/abis.js.map +1 -1
- package/dist/bundler.d.ts +1 -1
- package/dist/bundler.d.ts.map +1 -1
- package/dist/bundler.js +27 -61
- package/dist/bundler.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -9
- package/dist/client.js.map +1 -1
- package/dist/coinbase-smart-wallet.js +1 -4
- package/dist/coinbase-smart-wallet.js.map +1 -1
- package/dist/commands/accept.js +25 -28
- package/dist/commands/accept.js.map +1 -1
- package/dist/commands/agent-handshake.js +15 -18
- package/dist/commands/agent-handshake.js.map +1 -1
- package/dist/commands/agent.js +98 -104
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/agreements.js +62 -98
- package/dist/commands/agreements.js.map +1 -1
- package/dist/commands/arbitrator.js +45 -81
- package/dist/commands/arbitrator.js.map +1 -1
- package/dist/commands/arena-handshake.js +27 -30
- package/dist/commands/arena-handshake.js.map +1 -1
- package/dist/commands/arena.js +12 -18
- package/dist/commands/arena.js.map +1 -1
- package/dist/commands/backup.js +30 -36
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/cancel.js +15 -18
- package/dist/commands/cancel.js.map +1 -1
- package/dist/commands/channel.js +45 -81
- package/dist/commands/channel.js.map +1 -1
- package/dist/commands/coldstart.js +31 -34
- package/dist/commands/coldstart.js.map +1 -1
- package/dist/commands/config.js +23 -29
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/contract-interaction.js +12 -15
- package/dist/commands/contract-interaction.js.map +1 -1
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +98 -135
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/deliver.js +37 -76
- package/dist/commands/deliver.js.map +1 -1
- package/dist/commands/discover.js +24 -27
- package/dist/commands/discover.js.map +1 -1
- package/dist/commands/dispute.js +104 -110
- package/dist/commands/dispute.js.map +1 -1
- package/dist/commands/doctor.js +16 -55
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/endpoint.js +56 -95
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/feed.js +11 -18
- package/dist/commands/feed.js.map +1 -1
- package/dist/commands/hire.js +37 -40
- package/dist/commands/hire.js.map +1 -1
- package/dist/commands/migrate.js +30 -33
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/negotiate.d.ts.map +1 -1
- package/dist/commands/negotiate.js +34 -36
- package/dist/commands/negotiate.js.map +1 -1
- package/dist/commands/openshell.js +68 -104
- package/dist/commands/openshell.js.map +1 -1
- package/dist/commands/owner.js +17 -20
- package/dist/commands/owner.js.map +1 -1
- package/dist/commands/policy.js +41 -43
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/relay.d.ts.map +1 -1
- package/dist/commands/relay.js +18 -51
- package/dist/commands/relay.js.map +1 -1
- package/dist/commands/remediate.js +20 -23
- package/dist/commands/remediate.js.map +1 -1
- package/dist/commands/reputation.js +25 -27
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/setup.js +65 -104
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/trust.js +17 -20
- package/dist/commands/trust.js.map +1 -1
- package/dist/commands/verify.js +18 -21
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/wallet.js +619 -625
- package/dist/commands/wallet.js.map +1 -1
- package/dist/commands/watch.js +33 -36
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/watchtower.js +37 -73
- package/dist/commands/watchtower.js.map +1 -1
- package/dist/commands/workroom.d.ts.map +1 -1
- package/dist/commands/workroom.js +138 -171
- package/dist/commands/workroom.js.map +1 -1
- package/dist/config.js +21 -65
- package/dist/config.js.map +1 -1
- package/dist/daemon/config.d.ts.map +1 -1
- package/dist/daemon/config.js +16 -53
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/hire-listener.d.ts +3 -3
- package/dist/daemon/hire-listener.d.ts.map +1 -1
- package/dist/daemon/hire-listener.js +13 -47
- package/dist/daemon/hire-listener.js.map +1 -1
- package/dist/daemon/index.d.ts +1 -1
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +50 -88
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/job-lifecycle.d.ts +1 -1
- package/dist/daemon/job-lifecycle.d.ts.map +1 -1
- package/dist/daemon/job-lifecycle.js +11 -51
- package/dist/daemon/job-lifecycle.js.map +1 -1
- package/dist/daemon/notify.d.ts +1 -1
- package/dist/daemon/notify.d.ts.map +1 -1
- package/dist/daemon/notify.js +19 -53
- package/dist/daemon/notify.js.map +1 -1
- package/dist/daemon/token-metering.js +8 -47
- package/dist/daemon/token-metering.js.map +1 -1
- package/dist/daemon/userops.d.ts +2 -2
- package/dist/daemon/userops.d.ts.map +1 -1
- package/dist/daemon/userops.js +23 -27
- package/dist/daemon/userops.js.map +1 -1
- package/dist/daemon/wallet-monitor.d.ts +1 -1
- package/dist/daemon/wallet-monitor.d.ts.map +1 -1
- package/dist/daemon/wallet-monitor.js +8 -12
- package/dist/daemon/wallet-monitor.js.map +1 -1
- package/dist/drain-v4.js +26 -64
- package/dist/drain-v4.js.map +1 -1
- package/dist/endpoint-config.js +20 -63
- package/dist/endpoint-config.js.map +1 -1
- package/dist/endpoint-notify.js +9 -48
- package/dist/endpoint-notify.js.map +1 -1
- package/dist/index.js +16 -50
- package/dist/index.js.map +1 -1
- package/dist/openshell-runtime.d.ts.map +1 -1
- package/dist/openshell-runtime.js +38 -82
- package/dist/openshell-runtime.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +77 -83
- package/dist/program.js.map +1 -1
- package/dist/repl.js +25 -31
- package/dist/repl.js.map +1 -1
- package/dist/signing.js +3 -6
- package/dist/signing.js.map +1 -1
- package/dist/telegram-notify.js +3 -40
- package/dist/telegram-notify.js.map +1 -1
- package/dist/tui/App.d.ts +1 -9
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +47 -65
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/Footer.js +4 -7
- package/dist/tui/Footer.js.map +1 -1
- package/dist/tui/Header.d.ts +1 -2
- package/dist/tui/Header.d.ts.map +1 -1
- package/dist/tui/Header.js +8 -14
- package/dist/tui/Header.js.map +1 -1
- package/dist/tui/InputLine.js +17 -23
- package/dist/tui/InputLine.js.map +1 -1
- package/dist/tui/Viewport.d.ts +5 -4
- package/dist/tui/Viewport.d.ts.map +1 -1
- package/dist/tui/Viewport.js +20 -13
- package/dist/tui/Viewport.js.map +1 -1
- package/dist/tui/WalletConnectPairing.d.ts +23 -0
- package/dist/tui/WalletConnectPairing.d.ts.map +1 -0
- package/dist/tui/WalletConnectPairing.js +75 -0
- package/dist/tui/WalletConnectPairing.js.map +1 -0
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +14 -21
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/useChat.js +13 -19
- package/dist/tui/useChat.js.map +1 -1
- package/dist/tui/useCommand.d.ts +2 -7
- package/dist/tui/useCommand.d.ts.map +1 -1
- package/dist/tui/useCommand.js +77 -165
- package/dist/tui/useCommand.js.map +1 -1
- package/dist/tui/useScroll.js +9 -12
- package/dist/tui/useScroll.js.map +1 -1
- package/dist/ui/banner.js +12 -19
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/colors.js +13 -19
- package/dist/ui/colors.js.map +1 -1
- package/dist/ui/format.js +6 -14
- package/dist/ui/format.js.map +1 -1
- package/dist/ui/spinner.js +6 -12
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/tree.js +3 -6
- package/dist/ui/tree.js.map +1 -1
- package/dist/utils/format.js +27 -41
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/hash.js +4 -42
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/time.js +2 -6
- package/dist/utils/time.js.map +1 -1
- package/dist/wallet-router.d.ts +1 -1
- package/dist/wallet-router.d.ts.map +1 -1
- package/dist/wallet-router.js +12 -19
- package/dist/wallet-router.js.map +1 -1
- package/dist/walletconnect-session.d.ts +1 -1
- package/dist/walletconnect-session.d.ts.map +1 -1
- package/dist/walletconnect-session.js +6 -11
- package/dist/walletconnect-session.js.map +1 -1
- package/dist/walletconnect.d.ts +6 -1
- package/dist/walletconnect.d.ts.map +1 -1
- package/dist/walletconnect.js +32 -35
- package/dist/walletconnect.js.map +1 -1
- package/package.json +7 -6
- package/src/bundler.ts +1 -1
- package/src/client.ts +1 -1
- package/src/commands/accept.ts +7 -7
- package/src/commands/agent-handshake.ts +4 -4
- package/src/commands/agent.ts +9 -9
- package/src/commands/agreements.ts +8 -8
- package/src/commands/arbitrator.ts +5 -5
- package/src/commands/arena-handshake.ts +6 -6
- package/src/commands/arena.ts +2 -2
- package/src/commands/backup.ts +1 -1
- package/src/commands/cancel.ts +6 -6
- package/src/commands/channel.ts +6 -6
- package/src/commands/coldstart.ts +5 -5
- package/src/commands/config.ts +2 -2
- package/src/commands/contract-interaction.ts +2 -2
- package/src/commands/daemon.ts +14 -11
- package/src/commands/deliver.ts +9 -9
- package/src/commands/discover.ts +5 -5
- package/src/commands/dispute.ts +7 -7
- package/src/commands/doctor.ts +2 -2
- package/src/commands/endpoint.ts +6 -6
- package/src/commands/feed.ts +1 -1
- package/src/commands/hire.ts +10 -10
- package/src/commands/migrate.ts +7 -7
- package/src/commands/negotiate.ts +6 -5
- package/src/commands/openshell.ts +4 -4
- package/src/commands/owner.ts +5 -5
- package/src/commands/policy.ts +5 -5
- package/src/commands/relay.ts +5 -1
- package/src/commands/remediate.ts +5 -5
- package/src/commands/reputation.ts +6 -6
- package/src/commands/setup.ts +1 -1
- package/src/commands/trust.ts +6 -6
- package/src/commands/verify.ts +6 -6
- package/src/commands/wallet.ts +15 -15
- package/src/commands/watch.ts +3 -3
- package/src/commands/watchtower.ts +6 -6
- package/src/commands/workroom.ts +14 -10
- package/src/daemon/config.ts +2 -1
- package/src/daemon/hire-listener.ts +3 -3
- package/src/daemon/index.ts +10 -9
- package/src/daemon/job-lifecycle.ts +1 -1
- package/src/daemon/notify.ts +4 -4
- package/src/daemon/userops.ts +4 -4
- package/src/daemon/wallet-monitor.ts +2 -2
- package/src/endpoint-notify.ts +1 -1
- package/src/index.ts +8 -7
- package/src/openshell-runtime.ts +5 -1
- package/src/program.ts +36 -36
- package/src/repl.ts +3 -3
- package/src/tui/App.tsx +26 -47
- package/src/tui/Header.tsx +3 -10
- package/src/tui/InputLine.tsx +1 -1
- package/src/tui/Viewport.tsx +22 -18
- package/src/tui/WalletConnectPairing.tsx +131 -0
- package/src/tui/index.tsx +7 -8
- package/src/tui/useChat.ts +1 -1
- package/src/tui/useCommand.ts +86 -183
- package/src/ui/banner.ts +2 -2
- package/src/ui/tree.ts +1 -1
- package/src/wallet-router.ts +2 -2
- package/src/walletconnect-session.ts +1 -1
- package/src/walletconnect.ts +20 -5
- package/tsconfig.json +16 -7
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Ink 6 + ESM Migration Spec
|
|
2
|
+
|
|
3
|
+
## Goal
|
|
4
|
+
Migrate ARC-402 CLI from Ink 3 (CommonJS) to Ink 6 (ESM + React 19).
|
|
5
|
+
Also build a native WalletConnect Ink component so QR codes render inside the TUI viewport.
|
|
6
|
+
|
|
7
|
+
## Current State
|
|
8
|
+
- ink@3.2.0, react@18.3.1, ink-text-input@4.0.3
|
|
9
|
+
- tsconfig: module=commonjs, target=ES2020
|
|
10
|
+
- ~33k lines of TypeScript across 53+ source files
|
|
11
|
+
- All source uses `import/export` syntax, compiled to CJS by tsc
|
|
12
|
+
- Some files use `require()` for package.json reads
|
|
13
|
+
- TUI files: src/tui/ (App.tsx, Header.tsx, Viewport.tsx, InputLine.tsx, Footer.tsx, index.tsx, useChat.ts, useCommand.ts, useScroll.ts)
|
|
14
|
+
|
|
15
|
+
## Phase 1: ESM + Ink 6 Migration
|
|
16
|
+
|
|
17
|
+
### Step 1: Update package.json
|
|
18
|
+
- Add `"type": "module"`
|
|
19
|
+
- Update deps: `ink@^6.8.0`, `react@^19.0.0`, `@types/react@^19.0.0`, `ink-text-input@^6.0.0`
|
|
20
|
+
- Add `react-devtools-core` as optional peer dep if needed
|
|
21
|
+
- Run `npm install`
|
|
22
|
+
|
|
23
|
+
### Step 2: Update tsconfig.json
|
|
24
|
+
- Change `"module": "NodeNext"` and add `"moduleResolution": "NodeNext"`
|
|
25
|
+
- Change `"target": "ES2022"` and `"lib": ["ES2022"]`
|
|
26
|
+
- Remove the `paths` entries for ink/ink-text-input (Ink 6 has proper types)
|
|
27
|
+
- Add ethers path mapping if needed: `"ethers": ["./node_modules/ethers/lib.commonjs/index.d.ts"]`
|
|
28
|
+
|
|
29
|
+
### Step 3: Fix ALL relative imports
|
|
30
|
+
Every `import ... from "./foo"` must become `import ... from "./foo.js"`.
|
|
31
|
+
Every `import ... from "../foo"` must become `import ... from "../foo.js"`.
|
|
32
|
+
TSX files: `import ... from "./App"` → `import ... from "./App.js"` (tsc compiles .tsx to .js)
|
|
33
|
+
|
|
34
|
+
### Step 4: Convert require() calls to import
|
|
35
|
+
- `require("../../package.json")` → use `createRequire(import.meta.url)` from `"node:module"`
|
|
36
|
+
- `require("ethers")` etc → already using `import`, should be fine
|
|
37
|
+
- Dynamic requires → convert to dynamic `import()`
|
|
38
|
+
|
|
39
|
+
### Step 5: Fix Ink 6 API changes
|
|
40
|
+
- Check if `useStdout`, `useInput`, `useApp` signatures changed
|
|
41
|
+
- `ink-text-input@6` may have different import path or component API
|
|
42
|
+
- `<Static>` component may have changed
|
|
43
|
+
- Verify `render()` function signature
|
|
44
|
+
|
|
45
|
+
### Step 6: Build & fix errors iteratively
|
|
46
|
+
- Run `npx tsc --noEmit` after each batch of changes
|
|
47
|
+
- Fix type errors in batches by file category (TUI files first, then commands, then daemon)
|
|
48
|
+
|
|
49
|
+
## Phase 2: TUI Design Improvements
|
|
50
|
+
|
|
51
|
+
### Step 7: Remove vertical box borders
|
|
52
|
+
The TUI should use horizontal separator lines only (no │ borders — they break on resize):
|
|
53
|
+
```
|
|
54
|
+
██████╗ ██████╗ ██████╗ ...
|
|
55
|
+
agent-to-agent arcing · v0.7.5
|
|
56
|
+
◈ ──────────────────────────────────────
|
|
57
|
+
Network Base Mainnet Wallet 0xa9e0..
|
|
58
|
+
─────────────────────────────────────────────
|
|
59
|
+
scrollable output area
|
|
60
|
+
─────────────────────────────────────────────
|
|
61
|
+
◈ arc402 > _
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Step 8: ARC402_NO_TUI env guard
|
|
65
|
+
In src/index.ts, the TTY TUI launch condition must check `!process.env.ARC402_NO_TUI`:
|
|
66
|
+
```ts
|
|
67
|
+
} else if (process.stdout.isTTY && !hasSubcommand && process.argv.length <= 2 && !process.env.ARC402_NO_TUI) {
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Phase 3: Native WalletConnect Component
|
|
71
|
+
|
|
72
|
+
### Step 9: Create WalletConnect Ink component
|
|
73
|
+
Create `src/tui/WalletConnectPairing.tsx`:
|
|
74
|
+
- Renders QR code as ASCII text inside the viewport
|
|
75
|
+
- Shows wallet deep links (MetaMask, Rainbow, Trust)
|
|
76
|
+
- Shows "Waiting for approval..." status
|
|
77
|
+
- Handles connection success/failure as React state transitions
|
|
78
|
+
|
|
79
|
+
This requires refactoring `src/walletconnect.ts`:
|
|
80
|
+
- Extract the pairing logic into an event-emitter or callback-based API
|
|
81
|
+
- The current `connectPhoneWallet()` does console.log for QR — change it to accept
|
|
82
|
+
an `onUri` callback and an `onStatus` callback instead
|
|
83
|
+
- Keep the existing console.log behavior as the default (for one-shot CLI mode)
|
|
84
|
+
|
|
85
|
+
### Step 10: Wire WalletConnect component into useCommand
|
|
86
|
+
Instead of spawning a child process for interactive commands, render the
|
|
87
|
+
WalletConnect pairing component inside the viewport when `wallet deploy` runs.
|
|
88
|
+
|
|
89
|
+
The multi-step deploy wizard becomes a state machine:
|
|
90
|
+
1. CONNECTING → show QR + links
|
|
91
|
+
2. CONNECTED → show account, deploy tx
|
|
92
|
+
3. DEPLOYING → show spinner
|
|
93
|
+
4. ONBOARDING → show each ceremony step
|
|
94
|
+
5. COMPLETE → show summary tree
|
|
95
|
+
|
|
96
|
+
## Rules
|
|
97
|
+
- Do NOT change any business logic in command handlers
|
|
98
|
+
- Do NOT change contract addresses, ABIs, or deployment logic
|
|
99
|
+
- Keep all existing CLI one-shot behavior working (`arc402 wallet deploy` outside TUI)
|
|
100
|
+
- Test with `npx tsc --noEmit` frequently
|
|
101
|
+
- After build succeeds, test `node dist/index.js --help` to verify one-shot mode works
|
|
102
|
+
|
|
103
|
+
## Build & verify
|
|
104
|
+
```bash
|
|
105
|
+
npm run build
|
|
106
|
+
node dist/index.js --help # one-shot mode
|
|
107
|
+
node dist/index.js # TUI mode (if TTY)
|
|
108
|
+
```
|
package/dist/abis.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* ABIs extracted from the ARC-402 contract sources.
|
|
4
3
|
* Source: /products/arc-402/reference/contracts/
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
exports.ARC402_WALLET_PASSKEY_ABI = exports.ARC402_WALLET_MACHINE_KEY_ABI = exports.ARC402_WALLET_OWNER_ABI = exports.ARC402_WALLET_REGISTRY_ABI = exports.ARC402_WALLET_GUARDIAN_ABI = exports.ARC402_WALLET_PROTOCOL_ABI = exports.ARC402_WALLET_EXECUTE_ABI = exports.POLICY_ENGINE_GOVERNANCE_ABI = exports.POLICY_ENGINE_LIMITS_ABI = exports.WALLET_FACTORY_ABI = exports.ERC20_ABI = exports.TRUST_REGISTRY_ABI = exports.SERVICE_AGREEMENT_ABI = exports.AGENT_REGISTRY_ABI = void 0;
|
|
8
|
-
exports.AGENT_REGISTRY_ABI = [
|
|
5
|
+
export const AGENT_REGISTRY_ABI = [
|
|
9
6
|
// Registration
|
|
10
7
|
"function register(string name, string[] capabilities, string serviceType, string endpoint, string metadataURI) external",
|
|
11
8
|
"function update(string name, string[] capabilities, string serviceType, string endpoint, string metadataURI) external",
|
|
@@ -24,7 +21,7 @@ exports.AGENT_REGISTRY_ABI = [
|
|
|
24
21
|
"event AgentUpdated(address indexed wallet, string name, string serviceType)",
|
|
25
22
|
"event AgentDeactivated(address indexed wallet)",
|
|
26
23
|
];
|
|
27
|
-
|
|
24
|
+
export const SERVICE_AGREEMENT_ABI = [
|
|
28
25
|
"function propose(address provider, string serviceType, string description, uint256 price, address token, uint256 deadline, bytes32 deliverablesHash) external payable returns (uint256 agreementId)",
|
|
29
26
|
"function accept(uint256 agreementId) external",
|
|
30
27
|
"function fulfill(uint256 agreementId, bytes32 actualDeliverablesHash) external",
|
|
@@ -69,7 +66,7 @@ exports.SERVICE_AGREEMENT_ABI = [
|
|
|
69
66
|
"event AgreementDisputed(uint256 indexed id, address indexed initiator, string reason)",
|
|
70
67
|
"event AgreementCancelled(uint256 indexed id, address indexed client)",
|
|
71
68
|
];
|
|
72
|
-
|
|
69
|
+
export const TRUST_REGISTRY_ABI = [
|
|
73
70
|
"function getScore(address wallet) external view returns (uint256)",
|
|
74
71
|
"function getTrustLevel(address wallet) external view returns (string)",
|
|
75
72
|
"function initWallet(address wallet) external",
|
|
@@ -77,20 +74,20 @@ exports.TRUST_REGISTRY_ABI = [
|
|
|
77
74
|
"function recordAnomaly(address wallet) external",
|
|
78
75
|
"function owner() external view returns (address)",
|
|
79
76
|
];
|
|
80
|
-
|
|
77
|
+
export const ERC20_ABI = [
|
|
81
78
|
"function approve(address spender, uint256 amount) external returns (bool)",
|
|
82
79
|
"function allowance(address owner, address spender) external view returns (uint256)",
|
|
83
80
|
"function balanceOf(address owner) external view returns (uint256)",
|
|
84
81
|
"function decimals() external view returns (uint8)",
|
|
85
82
|
"function symbol() external view returns (string)",
|
|
86
83
|
];
|
|
87
|
-
|
|
84
|
+
export const WALLET_FACTORY_ABI = [
|
|
88
85
|
"function createWallet(address _entryPoint) external returns (address)",
|
|
89
86
|
"function getWallets(address owner) external view returns (address[] memory)",
|
|
90
87
|
"function totalWallets() external view returns (uint256)",
|
|
91
88
|
"event WalletCreated(address indexed owner, address indexed walletAddress)",
|
|
92
89
|
];
|
|
93
|
-
|
|
90
|
+
export const POLICY_ENGINE_LIMITS_ABI = [
|
|
94
91
|
// Auto-getters from public mappings (actual on-chain function names)
|
|
95
92
|
"function categoryLimits(address wallet, string category) external view returns (uint256)",
|
|
96
93
|
"function dailyCategoryLimit(address wallet, string category) external view returns (uint256)",
|
|
@@ -99,7 +96,7 @@ exports.POLICY_ENGINE_LIMITS_ABI = [
|
|
|
99
96
|
"function setDailyLimitFor(address wallet, string category, uint256 limit) external",
|
|
100
97
|
];
|
|
101
98
|
// PolicyEngine governance functions — for onboarding ceremony
|
|
102
|
-
|
|
99
|
+
export const POLICY_ENGINE_GOVERNANCE_ABI = [
|
|
103
100
|
// registerWallet requires msg.sender == wallet — route through wallet's executeContractCall
|
|
104
101
|
"function registerWallet(address wallet, address owner) external",
|
|
105
102
|
// enableDefiAccess: onlyWalletOwnerOrWallet — owner can call directly on PolicyEngine
|
|
@@ -108,11 +105,11 @@ exports.POLICY_ENGINE_GOVERNANCE_ABI = [
|
|
|
108
105
|
"function walletOwners(address wallet) external view returns (address)",
|
|
109
106
|
"function defiAccessEnabled(address wallet) external view returns (bool)",
|
|
110
107
|
];
|
|
111
|
-
|
|
108
|
+
export const ARC402_WALLET_EXECUTE_ABI = [
|
|
112
109
|
"function executeContractCall((address target, bytes data, uint256 value, uint256 minReturnValue, uint256 maxApprovalAmount, address approvalToken) params) external returns (bytes memory)",
|
|
113
110
|
];
|
|
114
111
|
// Direct protocol functions — all onlyOwnerOrMachineKey, never route through executeContractCall
|
|
115
|
-
|
|
112
|
+
export const ARC402_WALLET_PROTOCOL_ABI = [
|
|
116
113
|
"function openContext(bytes32 contextId, string calldata taskType) external",
|
|
117
114
|
"function closeContext() external",
|
|
118
115
|
"function contextOpen() external view returns (bool)",
|
|
@@ -120,7 +117,7 @@ exports.ARC402_WALLET_PROTOCOL_ABI = [
|
|
|
120
117
|
"function executeSpend(address payable recipient, uint256 amount, string calldata category, bytes32 attestationId) external",
|
|
121
118
|
"function executeTokenSpend(address recipient, uint256 amount, address token, string calldata category, bytes32 attestationId) external",
|
|
122
119
|
];
|
|
123
|
-
|
|
120
|
+
export const ARC402_WALLET_GUARDIAN_ABI = [
|
|
124
121
|
// Guardian management (owner only)
|
|
125
122
|
"function setGuardian(address _guardian) external",
|
|
126
123
|
// Guardian freeze functions (guardian key only)
|
|
@@ -141,7 +138,7 @@ exports.ARC402_WALLET_GUARDIAN_ABI = [
|
|
|
141
138
|
"event WalletUnfrozen(address indexed by, uint256 timestamp)",
|
|
142
139
|
"event GuardianUpdated(address indexed newGuardian)",
|
|
143
140
|
];
|
|
144
|
-
|
|
141
|
+
export const ARC402_WALLET_REGISTRY_ABI = [
|
|
145
142
|
"function proposeRegistryUpdate(address newRegistry) external",
|
|
146
143
|
"function executeRegistryUpdate() external",
|
|
147
144
|
"function cancelRegistryUpdate() external",
|
|
@@ -149,7 +146,7 @@ exports.ARC402_WALLET_REGISTRY_ABI = [
|
|
|
149
146
|
"function registryUpdateUnlockAt() external view returns (uint256)",
|
|
150
147
|
"function registry() external view returns (address)",
|
|
151
148
|
];
|
|
152
|
-
|
|
149
|
+
export const ARC402_WALLET_OWNER_ABI = [
|
|
153
150
|
// Owner-only setters
|
|
154
151
|
"function setAuthorizedInterceptor(address interceptor) external",
|
|
155
152
|
"function setVelocityLimit(uint256 limit) external",
|
|
@@ -161,12 +158,12 @@ exports.ARC402_WALLET_OWNER_ABI = [
|
|
|
161
158
|
"function cumulativeSpend() external view returns (uint256)",
|
|
162
159
|
"function activePolicyId() external view returns (bytes32)",
|
|
163
160
|
];
|
|
164
|
-
|
|
161
|
+
export const ARC402_WALLET_MACHINE_KEY_ABI = [
|
|
165
162
|
"function authorizeMachineKey(address key) external",
|
|
166
163
|
"function revokeMachineKey(address key) external",
|
|
167
164
|
"function authorizedMachineKeys(address key) external view returns (bool)",
|
|
168
165
|
];
|
|
169
|
-
|
|
166
|
+
export const ARC402_WALLET_PASSKEY_ABI = [
|
|
170
167
|
"function setPasskey(bytes32 pubKeyX, bytes32 pubKeyY) external",
|
|
171
168
|
"function clearPasskey() external",
|
|
172
169
|
"function emergencyOwnerOverride(bytes32 newPubKeyX, bytes32 newPubKeyY) external",
|
package/dist/abis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abis.js","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abis.js","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,eAAe;IACf,yHAAyH;IACzH,uHAAuH;IACvH,gCAAgC;IAChC,gCAAgC;IAChC,UAAU;IACV,iNAAiN;IACjN,oEAAoE;IACpE,gEAAgE;IAChE,2EAA2E;IAC3E,wEAAwE;IACxE,uDAAuD;IACvD,yEAAyE;IACzE,SAAS;IACT,mGAAmG;IACnG,6EAA6E;IAC7E,gDAAgD;CACxC,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,qMAAqM;IACrM,+CAA+C;IAC/C,gFAAgF;IAChF,mFAAmF;IACnF,0DAA0D;IAC1D,oDAAoD;IACpD,+DAA+D;IAC/D,yFAAyF;IACzF,yEAAyE;IACzE,kIAAkI;IAClI,wLAAwL;IACxL,4HAA4H;IAC5H,+EAA+E;IAC/E,oHAAoH;IACpH,8EAA8E;IAC9E,+CAA+C;IAC/C,sDAAsD;IACtD,2EAA2E;IAC3E,0HAA0H;IAC1H,4GAA4G;IAC5G,gFAAgF;IAChF,iGAAiG;IACjG,sUAAsU;IACtU,4PAA4P;IAC5P,mMAAmM;IACnM,uXAAuX;IACvX,kFAAkF;IAClF,sFAAs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AA4B;IAC5B,oCAAoC;IACpC,6BAA6B;IAC7B,yCAAyC;IACzC,iBAAiB;IACjB,8BAA8B;IAC9B,gBAAgB;IAChB,gDAAgD;IAChD,qDAAqD;IACrD,qDAAqD;IACrD,qDAAqD;IACrD,kDAAkD;IAClD,SAAS;IACT,0EAA0E;IAC1E,6DAA6D;IAC7D,oDAAoD;CAC5C,CAAC;AAEX,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,8DAA8D;IAC9D,2CAA2C;IAC3C,0CAA0C;IAC1C,4DAA4D;IAC5D,mEAAmE;IACnE,qDAAqD;CAC7C,CAAC;AAEX,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,qBAAqB;IACrB,iEAAiE;IACjE,mDAAmD;IACnD,qDAAqD;IACrD,gBAAgB;IAChB,kEAAkE;IAClE,0DAA0D;IAC1D,gEAAgE;IAChE,4DAA4D;IAC5D,2DAA2D;CACnD,CAAC;AAEX,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,oDAAoD;IACpD,iDAAiD;IACjD,0EAA0E;CAClE,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,gEAAgE;IAChE,kCAAkC;IAClC,kFAAkF;IAClF,4CAA4C;IAC5C,iGAAiG;IACjG,4DAA4D;CACpD,CAAC"}
|
package/dist/bundler.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Arc402Config } from "./config";
|
|
1
|
+
import type { Arc402Config } from "./config.js";
|
|
2
2
|
export declare const DEFAULT_ENTRY_POINT = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
3
3
|
export declare const DEFAULT_BUNDLER_URL = "https://api.pimlico.io/v2/base/rpc";
|
|
4
4
|
export type UserOperation = {
|
package/dist/bundler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAEA,OAAO,KAA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M,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,YAAY,EACpB,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,aAAa,CAAC,CAGxB"}
|
package/dist/bundler.js
CHANGED
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.PaymasterClient = exports.BundlerClient = exports.DEFAULT_BUNDLER_URL = exports.DEFAULT_ENTRY_POINT = void 0;
|
|
37
|
-
exports.buildUserOp = buildUserOp;
|
|
38
|
-
exports.buildSponsoredUserOp = buildSponsoredUserOp;
|
|
39
|
-
const ethers_1 = require("ethers");
|
|
40
|
-
const crypto_1 = require("crypto");
|
|
41
|
-
exports.DEFAULT_ENTRY_POINT = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
42
|
-
exports.DEFAULT_BUNDLER_URL = "https://api.pimlico.io/v2/base/rpc";
|
|
43
|
-
class BundlerClient {
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { createPrivateKey } from "crypto";
|
|
3
|
+
export const DEFAULT_ENTRY_POINT = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
4
|
+
export const DEFAULT_BUNDLER_URL = "https://api.pimlico.io/v2/base/rpc";
|
|
5
|
+
export class BundlerClient {
|
|
6
|
+
bundlerUrl;
|
|
7
|
+
entryPointAddress;
|
|
8
|
+
chainId;
|
|
44
9
|
constructor(bundlerUrl, entryPointAddress, chainId) {
|
|
45
10
|
this.bundlerUrl = bundlerUrl;
|
|
46
11
|
this.entryPointAddress = entryPointAddress;
|
|
@@ -85,9 +50,11 @@ class BundlerClient {
|
|
|
85
50
|
return estimate;
|
|
86
51
|
}
|
|
87
52
|
}
|
|
88
|
-
exports.BundlerClient = BundlerClient;
|
|
89
53
|
// ─── PaymasterClient ──────────────────────────────────────────────────────────
|
|
90
|
-
class PaymasterClient {
|
|
54
|
+
export class PaymasterClient {
|
|
55
|
+
paymasterUrl;
|
|
56
|
+
cdpKeyName;
|
|
57
|
+
cdpPrivateKey;
|
|
91
58
|
constructor(paymasterUrl, cdpKeyName, cdpPrivateKey) {
|
|
92
59
|
this.paymasterUrl = paymasterUrl;
|
|
93
60
|
this.cdpKeyName = cdpKeyName;
|
|
@@ -96,12 +63,12 @@ class PaymasterClient {
|
|
|
96
63
|
async buildJwt() {
|
|
97
64
|
if (!this.cdpKeyName || !this.cdpPrivateKey)
|
|
98
65
|
return null;
|
|
99
|
-
const { SignJWT, importPKCS8 } = await
|
|
66
|
+
const { SignJWT, importPKCS8 } = await import("jose");
|
|
100
67
|
// Convert SEC1 base64 DER or SEC1 PEM → PKCS8 PEM using Node's crypto module
|
|
101
68
|
let pkcs8Pem;
|
|
102
69
|
if (this.cdpPrivateKey.includes("-----BEGIN")) {
|
|
103
70
|
if (this.cdpPrivateKey.includes("EC PRIVATE KEY")) {
|
|
104
|
-
const key =
|
|
71
|
+
const key = createPrivateKey({ key: this.cdpPrivateKey, format: "pem", type: "sec1" });
|
|
105
72
|
pkcs8Pem = key.export({ format: "pem", type: "pkcs8" });
|
|
106
73
|
}
|
|
107
74
|
else {
|
|
@@ -110,7 +77,7 @@ class PaymasterClient {
|
|
|
110
77
|
}
|
|
111
78
|
else {
|
|
112
79
|
const der = Buffer.from(this.cdpPrivateKey, "base64");
|
|
113
|
-
const key =
|
|
80
|
+
const key = createPrivateKey({ key: der, format: "der", type: "sec1" });
|
|
114
81
|
pkcs8Pem = key.export({ format: "pem", type: "pkcs8" });
|
|
115
82
|
}
|
|
116
83
|
const privateKey = await importPKCS8(pkcs8Pem, "ES256");
|
|
@@ -155,27 +122,26 @@ class PaymasterClient {
|
|
|
155
122
|
};
|
|
156
123
|
}
|
|
157
124
|
}
|
|
158
|
-
exports.PaymasterClient = PaymasterClient;
|
|
159
125
|
// ─── buildUserOp / buildSponsoredUserOp ───────────────────────────────────────
|
|
160
|
-
async function buildUserOp(callData, sender, nonce, config) {
|
|
161
|
-
const provider = new
|
|
126
|
+
export async function buildUserOp(callData, sender, nonce, config) {
|
|
127
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
162
128
|
const feeData = await provider.getFeeData();
|
|
163
|
-
const maxFeePerGas = feeData.maxFeePerGas ?? BigInt(
|
|
164
|
-
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? BigInt(
|
|
129
|
+
const maxFeePerGas = feeData.maxFeePerGas ?? BigInt(1_000_000_000);
|
|
130
|
+
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? BigInt(100_000_000);
|
|
165
131
|
return {
|
|
166
132
|
sender,
|
|
167
|
-
nonce:
|
|
133
|
+
nonce: ethers.toBeHex(nonce),
|
|
168
134
|
callData,
|
|
169
|
-
callGasLimit:
|
|
170
|
-
verificationGasLimit:
|
|
171
|
-
preVerificationGas:
|
|
172
|
-
maxFeePerGas:
|
|
173
|
-
maxPriorityFeePerGas:
|
|
135
|
+
callGasLimit: ethers.toBeHex(300_000),
|
|
136
|
+
verificationGasLimit: ethers.toBeHex(150_000),
|
|
137
|
+
preVerificationGas: ethers.toBeHex(50_000),
|
|
138
|
+
maxFeePerGas: ethers.toBeHex(maxFeePerGas),
|
|
139
|
+
maxPriorityFeePerGas: ethers.toBeHex(maxPriorityFeePerGas),
|
|
174
140
|
signature: "0x",
|
|
175
141
|
};
|
|
176
142
|
}
|
|
177
|
-
async function buildSponsoredUserOp(callData, sender, nonce, config, paymasterClient) {
|
|
143
|
+
export async function buildSponsoredUserOp(callData, sender, nonce, config, paymasterClient) {
|
|
178
144
|
const userOp = await buildUserOp(callData, sender, nonce, config);
|
|
179
|
-
return paymasterClient.sponsorUserOperation(userOp,
|
|
145
|
+
return paymasterClient.sponsorUserOperation(userOp, DEFAULT_ENTRY_POINT);
|
|
180
146
|
}
|
|
181
147
|
//# sourceMappingURL=bundler.js.map
|
package/dist/bundler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundler.js","sourceRoot":"","sources":["../src/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,4CAA4C,CAAC;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,oCAAoC,CAAC;AAkDxE,MAAM,OAAO,aAAa;IAChB,UAAU,CA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,CAAC,OAAO,CAAC;QACrC,oBAAoB,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7C,kBAAkB,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC1C,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;QAC1C,oBAAoB,EAAE,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAC1D,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,MAAc,EACd,KAAa,EACb,MAAoB,EACpB,eAAgC;IAEhC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAClE,OAAO,eAAe,CAAC,oBAAoB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;AAC3E,CAAC"}
|
package/dist/client.d.ts
CHANGED
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAY3E;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAUvF"}
|
package/dist/client.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.requireSigner = requireSigner;
|
|
5
|
-
const ethers_1 = require("ethers");
|
|
6
|
-
async function getClient(config) {
|
|
7
|
-
const provider = new ethers_1.ethers.JsonRpcProvider(config.rpcUrl);
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
export async function getClient(config) {
|
|
3
|
+
const provider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
8
4
|
if (config.privateKey) {
|
|
9
|
-
const signer = new
|
|
5
|
+
const signer = new ethers.Wallet(config.privateKey, provider);
|
|
10
6
|
const address = await signer.getAddress();
|
|
11
7
|
return { provider, signer, address };
|
|
12
8
|
}
|
|
@@ -14,7 +10,7 @@ async function getClient(config) {
|
|
|
14
10
|
const address = config.walletContractAddress ?? null;
|
|
15
11
|
return { provider, signer: null, address };
|
|
16
12
|
}
|
|
17
|
-
async function requireSigner(config) {
|
|
13
|
+
export async function requireSigner(config) {
|
|
18
14
|
const { provider, signer } = await getClient(config);
|
|
19
15
|
if (!signer) {
|
|
20
16
|
console.error("No private key configured. Run `arc402 config init` and provide a private key.");
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAShC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAoB;IAClD,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE3D,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACvC,CAAC;IAED,sEAAsE;IACtE,MAAM,OAAO,GAAG,MAAM,CAAC,qBAAqB,IAAI,IAAI,CAAC;IACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAoB;IAEpB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CACX,gFAAgF,CACjF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* coinbase-smart-wallet.ts
|
|
4
3
|
*
|
|
@@ -18,9 +17,7 @@
|
|
|
18
17
|
* - The interface matches requestPhoneWalletSignature() so the caller in
|
|
19
18
|
* wallet.ts requires zero changes once a real implementation lands.
|
|
20
19
|
*/
|
|
21
|
-
|
|
22
|
-
exports.requestCoinbaseSmartWalletSignature = requestCoinbaseSmartWalletSignature;
|
|
23
|
-
async function requestCoinbaseSmartWalletSignature(chainId, buildTx, prompt) {
|
|
20
|
+
export async function requestCoinbaseSmartWalletSignature(chainId, buildTx, prompt) {
|
|
24
21
|
console.log(`\n${prompt}`);
|
|
25
22
|
console.log("─────────────────────────────────────────────────────────");
|
|
26
23
|
console.log("Connect your Base Smart Wallet:\n");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coinbase-smart-wallet.js","sourceRoot":"","sources":["../src/coinbase-smart-wallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coinbase-smart-wallet.js","sourceRoot":"","sources":["../src/coinbase-smart-wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,OAAe,EACf,OAA0E,EAC1E,MAAc;IAEd,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;IACzE,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CACT,kFAAkF,CACnF,CAAC;IACF,OAAO,CAAC,GAAG,CACT,mEAAmE;QACjE,iEAAiE;QACjE,wEAAwE,CAC3E,CAAC;IACF,OAAO,CAAC,GAAG,CACT,8DAA8D,CAC/D,CAAC;IACF,OAAO,CAAC,GAAG,CACT,yFAAyF;QACvF,6BAA6B,CAChC,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEhB,iFAAiF;IACjF,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/commands/accept.js
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const colors_1 = require("../ui/colors");
|
|
12
|
-
const spinner_1 = require("../ui/spinner");
|
|
13
|
-
function registerAcceptCommand(program) {
|
|
1
|
+
import { ServiceAgreementClient } from "@arc402/sdk";
|
|
2
|
+
import { ethers } from "ethers";
|
|
3
|
+
import { loadConfig } from "../config.js";
|
|
4
|
+
import { requireSigner } from "../client.js";
|
|
5
|
+
import { printSenderInfo, executeContractWriteViaWallet } from "../wallet-router.js";
|
|
6
|
+
import { SERVICE_AGREEMENT_ABI } from "../abis.js";
|
|
7
|
+
import { resolveAgentEndpoint, notifyAgent, DEFAULT_REGISTRY_ADDRESS } from "../endpoint-notify.js";
|
|
8
|
+
import { c } from "../ui/colors.js";
|
|
9
|
+
import { startSpinner } from "../ui/spinner.js";
|
|
10
|
+
export function registerAcceptCommand(program) {
|
|
14
11
|
program.command("accept <id>").description("Provider accepts a proposed agreement").action(async (id) => {
|
|
15
|
-
const config =
|
|
12
|
+
const config = loadConfig();
|
|
16
13
|
if (!config.serviceAgreementAddress)
|
|
17
14
|
throw new Error("serviceAgreementAddress missing in config");
|
|
18
|
-
const { signer, address: signerAddress } = await
|
|
19
|
-
|
|
15
|
+
const { signer, address: signerAddress } = await requireSigner(config);
|
|
16
|
+
printSenderInfo(config);
|
|
20
17
|
// Read agreement to get client address for endpoint notification
|
|
21
18
|
let clientAddress = "";
|
|
22
19
|
try {
|
|
23
|
-
const prefProvider = new
|
|
24
|
-
const saContract = new
|
|
20
|
+
const prefProvider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
21
|
+
const saContract = new ethers.Contract(config.serviceAgreementAddress, ["function getAgreement(uint256 id) external view returns (tuple(uint256 id, address client, address provider, string serviceType, string description, uint256 price, address token, uint256 deadline, bytes32 deliverablesHash, uint8 status, uint256 createdAt, uint256 resolvedAt, uint256 verifyWindowEnd, bytes32 committedHash))"], prefProvider);
|
|
25
22
|
const ag = await saContract.getAgreement(BigInt(id));
|
|
26
23
|
clientAddress = String(ag.client ?? "");
|
|
27
24
|
}
|
|
28
25
|
catch { /* non-fatal */ }
|
|
29
|
-
const spinner =
|
|
26
|
+
const spinner = startSpinner("Submitting transaction...");
|
|
30
27
|
try {
|
|
31
28
|
if (config.walletContractAddress) {
|
|
32
|
-
await
|
|
29
|
+
await executeContractWriteViaWallet(config.walletContractAddress, signer, config.serviceAgreementAddress, SERVICE_AGREEMENT_ABI, "accept", [BigInt(id)]);
|
|
33
30
|
}
|
|
34
31
|
else {
|
|
35
|
-
const client = new
|
|
32
|
+
const client = new ServiceAgreementClient(config.serviceAgreementAddress, signer);
|
|
36
33
|
await client.accept(BigInt(id));
|
|
37
34
|
}
|
|
38
35
|
spinner.succeed();
|
|
@@ -41,19 +38,19 @@ function registerAcceptCommand(program) {
|
|
|
41
38
|
spinner.fail();
|
|
42
39
|
throw err;
|
|
43
40
|
}
|
|
44
|
-
console.log(' ' +
|
|
41
|
+
console.log(' ' + c.success + c.white(` Accepted — agreement #${id}`));
|
|
45
42
|
// Notify client's HTTP endpoint (non-blocking)
|
|
46
43
|
if (clientAddress) {
|
|
47
44
|
try {
|
|
48
|
-
const notifyProvider = new
|
|
49
|
-
const registryAddress = config.agentRegistryV2Address ?? config.agentRegistryAddress ??
|
|
50
|
-
const endpoint = await
|
|
45
|
+
const notifyProvider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
46
|
+
const registryAddress = config.agentRegistryV2Address ?? config.agentRegistryAddress ?? DEFAULT_REGISTRY_ADDRESS;
|
|
47
|
+
const endpoint = await resolveAgentEndpoint(clientAddress, notifyProvider, registryAddress);
|
|
51
48
|
const payload = { agreementId: id, from: signerAddress };
|
|
52
|
-
await
|
|
53
|
-
await
|
|
49
|
+
await notifyAgent(endpoint, "/hire/accepted", payload);
|
|
50
|
+
await notifyAgent(endpoint, "/delivery/accepted", payload);
|
|
54
51
|
}
|
|
55
52
|
catch (err) {
|
|
56
|
-
console.warn(' ' +
|
|
53
|
+
console.warn(' ' + c.warning + c.white(` Could not notify client endpoint: ${err instanceof Error ? err.message : String(err)}`));
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../src/commands/accept.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../src/commands/accept.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACtG,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,uBAAuB;YAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAClG,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC;QACvE,eAAe,CAAC,MAAM,CAAC,CAAC;QAExB,iEAAiE;QACjE,IAAI,aAAa,GAAG,EAAE,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