arc402-cli 0.9.19 → 0.10.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 +41 -2
- package/dist/abis.d.ts +1 -0
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +45 -14
- 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 +61 -27
- 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 +9 -5
- package/dist/client.js.map +1 -1
- package/dist/coinbase-smart-wallet.js +4 -1
- package/dist/coinbase-smart-wallet.js.map +1 -1
- package/dist/commands/accept.js +28 -25
- package/dist/commands/accept.js.map +1 -1
- package/dist/commands/agent-handshake.js +18 -15
- package/dist/commands/agent-handshake.js.map +1 -1
- package/dist/commands/agent.js +104 -98
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/agreements.js +98 -62
- package/dist/commands/agreements.js.map +1 -1
- package/dist/commands/arbitrator.js +81 -45
- package/dist/commands/arbitrator.js.map +1 -1
- package/dist/commands/arena-handshake.d.ts.map +1 -1
- package/dist/commands/arena-handshake.js +35 -53
- package/dist/commands/arena-handshake.js.map +1 -1
- package/dist/commands/arena.js +18 -12
- package/dist/commands/arena.js.map +1 -1
- package/dist/commands/backup.js +36 -30
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/cancel.js +18 -15
- package/dist/commands/cancel.js.map +1 -1
- package/dist/commands/channel.js +81 -45
- package/dist/commands/channel.js.map +1 -1
- package/dist/commands/coldstart.js +34 -31
- package/dist/commands/coldstart.js.map +1 -1
- package/dist/commands/compute.d.ts +14 -0
- package/dist/commands/compute.d.ts.map +1 -0
- package/dist/commands/compute.js +466 -0
- package/dist/commands/compute.js.map +1 -0
- package/dist/commands/config.js +30 -24
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/contract-interaction.js +15 -12
- package/dist/commands/contract-interaction.js.map +1 -1
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +135 -98
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/deliver.js +76 -37
- package/dist/commands/deliver.js.map +1 -1
- package/dist/commands/discover.js +27 -24
- package/dist/commands/discover.js.map +1 -1
- package/dist/commands/dispute.js +110 -104
- package/dist/commands/dispute.js.map +1 -1
- package/dist/commands/doctor.js +55 -16
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/endpoint.js +95 -56
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/feed.js +18 -11
- package/dist/commands/feed.js.map +1 -1
- package/dist/commands/hire.js +40 -37
- package/dist/commands/hire.js.map +1 -1
- package/dist/commands/migrate.js +33 -30
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/negotiate.d.ts.map +1 -1
- package/dist/commands/negotiate.js +36 -34
- package/dist/commands/negotiate.js.map +1 -1
- package/dist/commands/openshell.js +104 -68
- package/dist/commands/openshell.js.map +1 -1
- package/dist/commands/owner.js +20 -17
- package/dist/commands/owner.js.map +1 -1
- package/dist/commands/policy.js +43 -41
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/relay.d.ts.map +1 -1
- package/dist/commands/relay.js +51 -18
- package/dist/commands/relay.js.map +1 -1
- package/dist/commands/remediate.js +23 -20
- package/dist/commands/remediate.js.map +1 -1
- package/dist/commands/reputation.js +27 -25
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/setup.js +104 -65
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/trust.js +20 -17
- package/dist/commands/trust.js.map +1 -1
- package/dist/commands/verify.js +21 -18
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/wallet.d.ts.map +1 -1
- package/dist/commands/wallet.js +645 -679
- package/dist/commands/wallet.js.map +1 -1
- package/dist/commands/watch.js +36 -33
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/watchtower.js +73 -37
- package/dist/commands/watchtower.js.map +1 -1
- package/dist/commands/workroom.d.ts.map +1 -1
- package/dist/commands/workroom.js +282 -143
- package/dist/commands/workroom.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +71 -22
- package/dist/config.js.map +1 -1
- package/dist/daemon/compute-metering.d.ts +61 -0
- package/dist/daemon/compute-metering.d.ts.map +1 -0
- package/dist/daemon/compute-metering.js +299 -0
- package/dist/daemon/compute-metering.js.map +1 -0
- package/dist/daemon/compute-session.d.ts +100 -0
- package/dist/daemon/compute-session.d.ts.map +1 -0
- package/dist/daemon/compute-session.js +231 -0
- package/dist/daemon/compute-session.js.map +1 -0
- package/dist/daemon/config.d.ts +19 -1
- package/dist/daemon/config.d.ts.map +1 -1
- package/dist/daemon/config.js +90 -16
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/credentials.d.ts +24 -0
- package/dist/daemon/credentials.d.ts.map +1 -0
- package/dist/daemon/credentials.js +80 -0
- package/dist/daemon/credentials.js.map +1 -0
- package/dist/daemon/delivery-client.d.ts +35 -0
- package/dist/daemon/delivery-client.d.ts.map +1 -0
- package/dist/daemon/delivery-client.js +231 -0
- package/dist/daemon/delivery-client.js.map +1 -0
- package/dist/daemon/file-delivery.d.ts +98 -0
- package/dist/daemon/file-delivery.d.ts.map +1 -0
- package/dist/daemon/file-delivery.js +461 -0
- package/dist/daemon/file-delivery.js.map +1 -0
- 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 +47 -13
- package/dist/daemon/hire-listener.js.map +1 -1
- package/dist/daemon/index.d.ts +2 -1
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +526 -53
- 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 +51 -11
- 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 +53 -19
- package/dist/daemon/notify.js.map +1 -1
- package/dist/daemon/token-metering.js +47 -8
- 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 +27 -23
- 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 +12 -8
- package/dist/daemon/wallet-monitor.js.map +1 -1
- package/dist/daemon/worker-executor.d.ts +71 -0
- package/dist/daemon/worker-executor.d.ts.map +1 -0
- package/dist/daemon/worker-executor.js +382 -0
- package/dist/daemon/worker-executor.js.map +1 -0
- package/dist/drain-v4.js +64 -26
- package/dist/drain-v4.js.map +1 -1
- package/dist/endpoint-config.js +63 -20
- package/dist/endpoint-config.js.map +1 -1
- package/dist/endpoint-notify.d.ts.map +1 -1
- package/dist/endpoint-notify.js +49 -15
- package/dist/endpoint-notify.js.map +1 -1
- package/dist/index.js +50 -18
- package/dist/index.js.map +1 -1
- package/dist/openshell-runtime.d.ts.map +1 -1
- package/dist/openshell-runtime.js +82 -38
- package/dist/openshell-runtime.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +85 -78
- package/dist/program.js.map +1 -1
- package/dist/repl.js +31 -25
- package/dist/repl.js.map +1 -1
- package/dist/signing.js +6 -3
- package/dist/signing.js.map +1 -1
- package/dist/telegram-notify.js +40 -3
- package/dist/telegram-notify.js.map +1 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +56 -89
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/Footer.js +7 -4
- package/dist/tui/Footer.js.map +1 -1
- package/dist/tui/Header.d.ts +1 -1
- package/dist/tui/Header.d.ts.map +1 -1
- package/dist/tui/Header.js +14 -9
- package/dist/tui/Header.js.map +1 -1
- package/dist/tui/InputLine.d.ts +2 -1
- package/dist/tui/InputLine.d.ts.map +1 -1
- package/dist/tui/InputLine.js +47 -97
- package/dist/tui/InputLine.js.map +1 -1
- package/dist/tui/Viewport.d.ts +1 -2
- package/dist/tui/Viewport.d.ts.map +1 -1
- package/dist/tui/Viewport.js +26 -6
- package/dist/tui/Viewport.js.map +1 -1
- package/dist/tui/WalletConnectPairing.js +19 -16
- package/dist/tui/WalletConnectPairing.js.map +1 -1
- package/dist/tui/components/Button.js +9 -6
- package/dist/tui/components/Button.js.map +1 -1
- package/dist/tui/components/CeremonyView.js +8 -5
- package/dist/tui/components/CeremonyView.js.map +1 -1
- package/dist/tui/components/CompletionDropdown.js +9 -6
- package/dist/tui/components/CompletionDropdown.js.map +1 -1
- package/dist/tui/components/ConfirmPrompt.js +8 -5
- package/dist/tui/components/ConfirmPrompt.js.map +1 -1
- package/dist/tui/components/CustomTextInput.js +14 -11
- package/dist/tui/components/CustomTextInput.js.map +1 -1
- package/dist/tui/components/InteractiveTable.js +12 -9
- package/dist/tui/components/InteractiveTable.js.map +1 -1
- package/dist/tui/components/StepSpinner.js +13 -10
- package/dist/tui/components/StepSpinner.js.map +1 -1
- package/dist/tui/components/Toast.js +12 -8
- package/dist/tui/components/Toast.js.map +1 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +21 -28
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/useChat.js +19 -13
- package/dist/tui/useChat.js.map +1 -1
- package/dist/tui/useCommand.d.ts +2 -3
- package/dist/tui/useCommand.d.ts.map +1 -1
- package/dist/tui/useCommand.js +24 -100
- package/dist/tui/useCommand.js.map +1 -1
- package/dist/tui/useNotifications.js +8 -5
- package/dist/tui/useNotifications.js.map +1 -1
- package/dist/tui/useScroll.d.ts.map +1 -1
- package/dist/tui/useScroll.js +12 -15
- package/dist/tui/useScroll.js.map +1 -1
- package/dist/ui/banner.d.ts +0 -12
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +19 -35
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/colors.js +19 -13
- package/dist/ui/colors.js.map +1 -1
- package/dist/ui/format.js +14 -6
- package/dist/ui/format.js.map +1 -1
- package/dist/ui/qr-render.js +11 -4
- package/dist/ui/qr-render.js.map +1 -1
- package/dist/ui/rpc-fallback.js +11 -6
- package/dist/ui/rpc-fallback.js.map +1 -1
- package/dist/ui/spinner.js +12 -6
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/tree.js +6 -3
- package/dist/ui/tree.js.map +1 -1
- package/dist/utils/format.js +41 -27
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/hash.js +42 -4
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/time.js +6 -2
- 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 +19 -12
- 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 +11 -6
- package/dist/walletconnect-session.js.map +1 -1
- package/dist/walletconnect.d.ts +5 -6
- package/dist/walletconnect.d.ts.map +1 -1
- package/dist/walletconnect.js +35 -32
- package/dist/walletconnect.js.map +1 -1
- package/package.json +11 -10
- package/INK6-UX-SPEC.md +0 -446
- package/MIGRATION-SPEC.md +0 -108
- package/TUI-SPEC.md +0 -214
- package/scripts/authorize-machine-key.ts +0 -43
- package/scripts/drain-wallet.ts +0 -149
- package/scripts/execute-spend-only.ts +0 -81
- package/scripts/register-agent-userop.ts +0 -186
- package/src/abis.ts +0 -187
- package/src/bundler.ts +0 -235
- package/src/client.ts +0 -36
- package/src/coinbase-smart-wallet.ts +0 -51
- package/src/commands/accept.ts +0 -64
- package/src/commands/agent-handshake.ts +0 -72
- package/src/commands/agent.ts +0 -691
- package/src/commands/agreements.ts +0 -350
- package/src/commands/arbitrator.ts +0 -180
- package/src/commands/arena-handshake.ts +0 -274
- package/src/commands/arena.ts +0 -122
- package/src/commands/backup.ts +0 -117
- package/src/commands/cancel.ts +0 -35
- package/src/commands/channel.ts +0 -218
- package/src/commands/coldstart.ts +0 -165
- package/src/commands/config.ts +0 -68
- package/src/commands/contract-interaction.ts +0 -166
- package/src/commands/daemon.ts +0 -1054
- package/src/commands/deliver.ts +0 -148
- package/src/commands/discover.ts +0 -350
- package/src/commands/dispute.ts +0 -375
- package/src/commands/doctor.ts +0 -172
- package/src/commands/endpoint.ts +0 -620
- package/src/commands/feed.ts +0 -229
- package/src/commands/hire.ts +0 -245
- package/src/commands/migrate.ts +0 -177
- package/src/commands/negotiate.ts +0 -272
- package/src/commands/openshell.ts +0 -1055
- package/src/commands/owner.ts +0 -35
- package/src/commands/policy.ts +0 -263
- package/src/commands/relay.ts +0 -277
- package/src/commands/remediate.ts +0 -24
- package/src/commands/reputation.ts +0 -79
- package/src/commands/setup.ts +0 -343
- package/src/commands/trust.ts +0 -27
- package/src/commands/verify.ts +0 -91
- package/src/commands/wallet.ts +0 -3548
- package/src/commands/watch.ts +0 -220
- package/src/commands/watchtower.ts +0 -248
- package/src/commands/workroom.ts +0 -963
- package/src/config.ts +0 -220
- package/src/daemon/config.ts +0 -344
- package/src/daemon/hire-listener.ts +0 -226
- package/src/daemon/index.ts +0 -1089
- package/src/daemon/job-lifecycle.ts +0 -215
- package/src/daemon/notify.ts +0 -297
- package/src/daemon/token-metering.ts +0 -183
- package/src/daemon/userops.ts +0 -119
- package/src/daemon/wallet-monitor.ts +0 -90
- package/src/drain-v4.ts +0 -159
- package/src/endpoint-config.ts +0 -83
- package/src/endpoint-notify.ts +0 -134
- package/src/index.ts +0 -74
- package/src/openshell-runtime.ts +0 -281
- package/src/program.ts +0 -88
- package/src/repl.ts +0 -178
- package/src/signing.ts +0 -28
- package/src/telegram-notify.ts +0 -88
- package/src/tui/App.tsx +0 -263
- package/src/tui/Footer.tsx +0 -18
- package/src/tui/Header.tsx +0 -45
- package/src/tui/InputLine.tsx +0 -243
- package/src/tui/Viewport.tsx +0 -51
- package/src/tui/WalletConnectPairing.tsx +0 -114
- package/src/tui/components/Button.tsx +0 -38
- package/src/tui/components/CeremonyView.tsx +0 -39
- package/src/tui/components/CompletionDropdown.tsx +0 -56
- package/src/tui/components/ConfirmPrompt.tsx +0 -36
- package/src/tui/components/CustomTextInput.tsx +0 -132
- package/src/tui/components/InteractiveTable.tsx +0 -106
- package/src/tui/components/StepSpinner.tsx +0 -84
- package/src/tui/components/Toast.tsx +0 -59
- package/src/tui/index.tsx +0 -90
- package/src/tui/useChat.ts +0 -103
- package/src/tui/useCommand.ts +0 -238
- package/src/tui/useNotifications.ts +0 -28
- package/src/tui/useScroll.ts +0 -69
- package/src/ui/banner.ts +0 -78
- package/src/ui/colors.ts +0 -30
- package/src/ui/format.ts +0 -78
- package/src/ui/qr-render.ts +0 -92
- package/src/ui/rpc-fallback.ts +0 -59
- package/src/ui/spinner.ts +0 -56
- package/src/ui/tree.ts +0 -16
- package/src/utils/format.ts +0 -48
- package/src/utils/hash.ts +0 -5
- package/src/utils/time.ts +0 -15
- package/src/wallet-router.ts +0 -178
- package/src/walletconnect-session.ts +0 -27
- package/src/walletconnect.ts +0 -309
- package/test/time.test.js +0 -11
- package/tsconfig.json +0 -33
package/src/abis.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ABIs extracted from the ARC-402 contract sources.
|
|
3
|
-
* Source: /products/arc-402/reference/contracts/
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export const AGENT_REGISTRY_ABI = [
|
|
7
|
-
// Registration
|
|
8
|
-
"function register(string name, string[] capabilities, string serviceType, string endpoint, string metadataURI) external",
|
|
9
|
-
"function update(string name, string[] capabilities, string serviceType, string endpoint, string metadataURI) external",
|
|
10
|
-
"function deactivate() external",
|
|
11
|
-
"function reactivate() external",
|
|
12
|
-
// Queries
|
|
13
|
-
"function getAgent(address wallet) external view returns (tuple(address wallet, string name, string[] capabilities, string serviceType, string endpoint, string metadataURI, bool active, uint256 registeredAt))",
|
|
14
|
-
"function isRegistered(address wallet) external view returns (bool)",
|
|
15
|
-
"function isActive(address wallet) external view returns (bool)",
|
|
16
|
-
"function getCapabilities(address wallet) external view returns (string[])",
|
|
17
|
-
"function getTrustScore(address wallet) external view returns (uint256)",
|
|
18
|
-
"function agentCount() external view returns (uint256)",
|
|
19
|
-
"function getAgentAtIndex(uint256 index) external view returns (address)",
|
|
20
|
-
// Events
|
|
21
|
-
"event AgentRegistered(address indexed wallet, string name, string serviceType, uint256 timestamp)",
|
|
22
|
-
"event AgentUpdated(address indexed wallet, string name, string serviceType)",
|
|
23
|
-
"event AgentDeactivated(address indexed wallet)",
|
|
24
|
-
] as const;
|
|
25
|
-
|
|
26
|
-
export const SERVICE_AGREEMENT_ABI = [
|
|
27
|
-
"function propose(address provider, string serviceType, string description, uint256 price, address token, uint256 deadline, bytes32 deliverablesHash) external payable returns (uint256 agreementId)",
|
|
28
|
-
"function accept(uint256 agreementId) external",
|
|
29
|
-
"function fulfill(uint256 agreementId, bytes32 actualDeliverablesHash) external",
|
|
30
|
-
"function commitDeliverable(uint256 agreementId, bytes32 deliverableHash) external",
|
|
31
|
-
"function verifyDeliverable(uint256 agreementId) external",
|
|
32
|
-
"function autoRelease(uint256 agreementId) external",
|
|
33
|
-
"function dispute(uint256 agreementId, string reason) external",
|
|
34
|
-
"function directDispute(uint256 agreementId, uint8 directReason, string reason) external",
|
|
35
|
-
"function escalateToDispute(uint256 agreementId, string reason) external",
|
|
36
|
-
"function requestRevision(uint256 agreementId, bytes32 feedbackHash, string feedbackURI, bytes32 previousTranscriptHash) external",
|
|
37
|
-
"function respondToRevision(uint256 agreementId, uint8 responseType, uint256 proposedProviderPayout, bytes32 responseHash, string responseURI, bytes32 previousTranscriptHash) external",
|
|
38
|
-
"function submitDisputeEvidence(uint256 agreementId, uint8 evidenceType, bytes32 evidenceHash, string evidenceURI) external",
|
|
39
|
-
"function nominateArbitrator(uint256 agreementId, address arbitrator) external",
|
|
40
|
-
"function castArbitrationVote(uint256 agreementId, uint8 vote, uint256 providerAward, uint256 clientAward) external",
|
|
41
|
-
"function requestHumanEscalation(uint256 agreementId, string reason) external",
|
|
42
|
-
"function cancel(uint256 agreementId) external",
|
|
43
|
-
"function expiredCancel(uint256 agreementId) external",
|
|
44
|
-
"function resolveDispute(uint256 agreementId, bool favorProvider) external",
|
|
45
|
-
"function resolveDisputeDetailed(uint256 agreementId, uint8 outcome, uint256 providerAward, uint256 clientAward) external",
|
|
46
|
-
"function openDisputeWithMode(uint256 agreementId, uint8 mode, uint8 class, string reason) external payable",
|
|
47
|
-
"function ownerResolveDispute(uint256 agreementId, bool favorProvider) external",
|
|
48
|
-
"function canDirectDispute(uint256 agreementId, uint8 directReason) external view returns (bool)",
|
|
49
|
-
"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))",
|
|
50
|
-
"function getDisputeCase(uint256 agreementId) external view returns (tuple(uint256 agreementId, uint256 openedAt, uint256 responseDeadlineAt, uint8 outcome, uint256 providerAward, uint256 clientAward, bool humanReviewRequested, uint256 evidenceCount))",
|
|
51
|
-
"function getDisputeEvidence(uint256 agreementId, uint256 index) external view returns (tuple(address submitter, uint8 evidenceType, bytes32 evidenceHash, string evidenceURI, uint256 timestamp))",
|
|
52
|
-
"function getArbitrationCase(uint256 agreementId) external view returns (tuple(uint256 agreementId, address[3] arbitrators, uint8 arbitratorCount, uint8 providerVotes, uint8 clientVotes, uint8 splitVotes, uint8 humanVotes, uint256 selectionDeadlineAt, uint256 decisionDeadlineAt, uint256 splitProviderAward, uint256 splitClientAward, bool finalized, bool humanBackstopUsed))",
|
|
53
|
-
"function getAgreementsByClient(address client) external view returns (uint256[])",
|
|
54
|
-
"function getAgreementsByProvider(address provider) external view returns (uint256[])",
|
|
55
|
-
"function agreementCount() external view returns (uint256)",
|
|
56
|
-
"function openSessionChannel(address provider, address token, uint256 maxAmount, uint256 ratePerCall, uint256 deadline) external payable returns (bytes32)",
|
|
57
|
-
"function closeChannel(bytes32 channelId, bytes finalState) external",
|
|
58
|
-
"function challengeChannel(bytes32 channelId, bytes latestState) external",
|
|
59
|
-
"function finaliseChallenge(bytes32 channelId) external",
|
|
60
|
-
"function reclaimExpiredChannel(bytes32 channelId) external",
|
|
61
|
-
"function getChannel(bytes32 channelId) external view returns (tuple(address client, address provider, address token, uint256 depositAmount, uint256 settledAmount, uint256 lastSequenceNumber, uint256 deadline, uint256 challengeExpiry, uint8 status))",
|
|
62
|
-
"function getChannelsByClient(address client) external view returns (bytes32[])",
|
|
63
|
-
"function getChannelsByProvider(address provider) external view returns (bytes32[])",
|
|
64
|
-
"function resolveFromArbitration(uint256 agreementId, address recipient, uint256 amount) external",
|
|
65
|
-
"event AgreementProposed(uint256 indexed id, address indexed client, address indexed provider, string serviceType, uint256 price, address token, uint256 deadline)",
|
|
66
|
-
"event AgreementAccepted(uint256 indexed id, address indexed provider)",
|
|
67
|
-
"event AgreementFulfilled(uint256 indexed id, address indexed provider, bytes32 deliverablesHash)",
|
|
68
|
-
"event AgreementDisputed(uint256 indexed id, address indexed initiator, string reason)",
|
|
69
|
-
"event AgreementCancelled(uint256 indexed id, address indexed client)",
|
|
70
|
-
] as const;
|
|
71
|
-
|
|
72
|
-
export const TRUST_REGISTRY_ABI = [
|
|
73
|
-
"function getScore(address wallet) external view returns (uint256)",
|
|
74
|
-
"function getTrustLevel(address wallet) external view returns (string)",
|
|
75
|
-
"function initWallet(address wallet) external",
|
|
76
|
-
"function recordSuccess(address wallet) external",
|
|
77
|
-
"function recordAnomaly(address wallet) external",
|
|
78
|
-
"function owner() external view returns (address)",
|
|
79
|
-
] as const;
|
|
80
|
-
|
|
81
|
-
export const ERC20_ABI = [
|
|
82
|
-
"function approve(address spender, uint256 amount) external returns (bool)",
|
|
83
|
-
"function allowance(address owner, address spender) external view returns (uint256)",
|
|
84
|
-
"function balanceOf(address owner) external view returns (uint256)",
|
|
85
|
-
"function decimals() external view returns (uint8)",
|
|
86
|
-
"function symbol() external view returns (string)",
|
|
87
|
-
] as const;
|
|
88
|
-
|
|
89
|
-
export const WALLET_FACTORY_ABI = [
|
|
90
|
-
"function createWallet(address _entryPoint) external returns (address)",
|
|
91
|
-
"function getWallets(address owner) external view returns (address[] memory)",
|
|
92
|
-
"function totalWallets() external view returns (uint256)",
|
|
93
|
-
"event WalletCreated(address indexed owner, address indexed walletAddress)",
|
|
94
|
-
] as const;
|
|
95
|
-
|
|
96
|
-
export const POLICY_ENGINE_LIMITS_ABI = [
|
|
97
|
-
// Auto-getters from public mappings (actual on-chain function names)
|
|
98
|
-
"function categoryLimits(address wallet, string category) external view returns (uint256)",
|
|
99
|
-
"function dailyCategoryLimit(address wallet, string category) external view returns (uint256)",
|
|
100
|
-
// Owner-callable setters
|
|
101
|
-
"function setCategoryLimitFor(address wallet, string category, uint256 limitPerTx) external",
|
|
102
|
-
"function setDailyLimitFor(address wallet, string category, uint256 limit) external",
|
|
103
|
-
] as const;
|
|
104
|
-
|
|
105
|
-
// PolicyEngine governance functions — for onboarding ceremony
|
|
106
|
-
export const POLICY_ENGINE_GOVERNANCE_ABI = [
|
|
107
|
-
// registerWallet requires msg.sender == wallet — route through wallet's executeContractCall
|
|
108
|
-
"function registerWallet(address wallet, address owner) external",
|
|
109
|
-
// enableDefiAccess: onlyWalletOwnerOrWallet — owner can call directly on PolicyEngine
|
|
110
|
-
"function enableDefiAccess(address wallet) external",
|
|
111
|
-
// isRegistered check helper
|
|
112
|
-
"function walletOwners(address wallet) external view returns (address)",
|
|
113
|
-
"function defiAccessEnabled(address wallet) external view returns (bool)",
|
|
114
|
-
] as const;
|
|
115
|
-
|
|
116
|
-
export const ARC402_WALLET_EXECUTE_ABI = [
|
|
117
|
-
"function executeContractCall((address target, bytes data, uint256 value, uint256 minReturnValue, uint256 maxApprovalAmount, address approvalToken) params) external returns (bytes memory)",
|
|
118
|
-
] as const;
|
|
119
|
-
|
|
120
|
-
// Direct protocol functions — all onlyOwnerOrMachineKey, never route through executeContractCall
|
|
121
|
-
export const ARC402_WALLET_PROTOCOL_ABI = [
|
|
122
|
-
"function openContext(bytes32 contextId, string calldata taskType) external",
|
|
123
|
-
"function closeContext() external",
|
|
124
|
-
"function contextOpen() external view returns (bool)",
|
|
125
|
-
"function attest(bytes32 attestationId, string calldata action, string calldata reason, address recipient, uint256 amount, address token, uint256 expiresAt) external returns (bytes32)",
|
|
126
|
-
"function executeSpend(address payable recipient, uint256 amount, string calldata category, bytes32 attestationId) external",
|
|
127
|
-
"function executeTokenSpend(address recipient, uint256 amount, address token, string calldata category, bytes32 attestationId) external",
|
|
128
|
-
] as const;
|
|
129
|
-
|
|
130
|
-
export const ARC402_WALLET_GUARDIAN_ABI = [
|
|
131
|
-
// Guardian management (owner only)
|
|
132
|
-
"function setGuardian(address _guardian) external",
|
|
133
|
-
// Guardian freeze functions (guardian key only)
|
|
134
|
-
"function freeze() external",
|
|
135
|
-
"function freezeAndDrain() external",
|
|
136
|
-
// Owner freeze (with reason)
|
|
137
|
-
"function freeze(string reason) external",
|
|
138
|
-
// Owner unfreeze
|
|
139
|
-
"function unfreeze() external",
|
|
140
|
-
// State queries
|
|
141
|
-
"function frozen() external view returns (bool)",
|
|
142
|
-
"function frozenBy() external view returns (address)",
|
|
143
|
-
"function frozenAt() external view returns (uint256)",
|
|
144
|
-
"function guardian() external view returns (address)",
|
|
145
|
-
"function owner() external view returns (address)",
|
|
146
|
-
// Events
|
|
147
|
-
"event WalletFrozen(address indexed by, string reason, uint256 timestamp)",
|
|
148
|
-
"event WalletUnfrozen(address indexed by, uint256 timestamp)",
|
|
149
|
-
"event GuardianUpdated(address indexed newGuardian)",
|
|
150
|
-
] as const;
|
|
151
|
-
|
|
152
|
-
export const ARC402_WALLET_REGISTRY_ABI = [
|
|
153
|
-
"function proposeRegistryUpdate(address newRegistry) external",
|
|
154
|
-
"function executeRegistryUpdate() external",
|
|
155
|
-
"function cancelRegistryUpdate() external",
|
|
156
|
-
"function pendingRegistry() external view returns (address)",
|
|
157
|
-
"function registryUpdateUnlockAt() external view returns (uint256)",
|
|
158
|
-
"function registry() external view returns (address)",
|
|
159
|
-
] as const;
|
|
160
|
-
|
|
161
|
-
export const ARC402_WALLET_OWNER_ABI = [
|
|
162
|
-
// Owner-only setters
|
|
163
|
-
"function setAuthorizedInterceptor(address interceptor) external",
|
|
164
|
-
"function setVelocityLimit(uint256 limit) external",
|
|
165
|
-
"function updatePolicy(bytes32 newPolicyId) external",
|
|
166
|
-
// State queries
|
|
167
|
-
"function authorizedInterceptor() external view returns (address)",
|
|
168
|
-
"function velocityLimit() external view returns (uint256)",
|
|
169
|
-
"function velocityWindowStart() external view returns (uint256)",
|
|
170
|
-
"function cumulativeSpend() external view returns (uint256)",
|
|
171
|
-
"function activePolicyId() external view returns (bytes32)",
|
|
172
|
-
] as const;
|
|
173
|
-
|
|
174
|
-
export const ARC402_WALLET_MACHINE_KEY_ABI = [
|
|
175
|
-
"function authorizeMachineKey(address key) external",
|
|
176
|
-
"function revokeMachineKey(address key) external",
|
|
177
|
-
"function authorizedMachineKeys(address key) external view returns (bool)",
|
|
178
|
-
] as const;
|
|
179
|
-
|
|
180
|
-
export const ARC402_WALLET_PASSKEY_ABI = [
|
|
181
|
-
"function setPasskey(bytes32 pubKeyX, bytes32 pubKeyY) external",
|
|
182
|
-
"function clearPasskey() external",
|
|
183
|
-
"function emergencyOwnerOverride(bytes32 newPubKeyX, bytes32 newPubKeyY) external",
|
|
184
|
-
"function emergencyOwnerOverride() external",
|
|
185
|
-
"function ownerAuth() external view returns (uint8 signerType, bytes32 pubKeyX, bytes32 pubKeyY)",
|
|
186
|
-
"event PasskeySet(bytes32 indexed pubKeyX, bytes32 pubKeyY)",
|
|
187
|
-
] as const;
|
package/src/bundler.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
|
-
import { createPrivateKey } from "crypto";
|
|
3
|
-
import type { Arc402Config } from "./config.js";
|
|
4
|
-
|
|
5
|
-
export const DEFAULT_ENTRY_POINT = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
6
|
-
export const DEFAULT_BUNDLER_URL = "https://api.pimlico.io/v2/base/rpc";
|
|
7
|
-
|
|
8
|
-
export type UserOperation = {
|
|
9
|
-
sender: string;
|
|
10
|
-
nonce: string; // hex
|
|
11
|
-
callData: string; // hex
|
|
12
|
-
callGasLimit: string; // hex
|
|
13
|
-
verificationGasLimit: string; // hex
|
|
14
|
-
preVerificationGas: string; // hex
|
|
15
|
-
maxFeePerGas: string; // hex
|
|
16
|
-
maxPriorityFeePerGas: string; // hex
|
|
17
|
-
signature: string; // hex — empty for policy-auto-approved ops
|
|
18
|
-
factory?: string;
|
|
19
|
-
factoryData?: string;
|
|
20
|
-
paymaster?: string;
|
|
21
|
-
paymasterData?: string;
|
|
22
|
-
paymasterVerificationGasLimit?: string;
|
|
23
|
-
paymasterPostOpGasLimit?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type GasEstimate = {
|
|
27
|
-
callGasLimit: string;
|
|
28
|
-
verificationGasLimit: string;
|
|
29
|
-
preVerificationGas: string;
|
|
30
|
-
paymasterVerificationGasLimit?: string;
|
|
31
|
-
paymasterPostOpGasLimit?: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type UserOpReceipt = {
|
|
35
|
-
userOpHash: string;
|
|
36
|
-
entryPoint: string;
|
|
37
|
-
sender: string;
|
|
38
|
-
nonce: string;
|
|
39
|
-
success: boolean;
|
|
40
|
-
actualGasCost: string;
|
|
41
|
-
actualGasUsed: string;
|
|
42
|
-
logs: unknown[];
|
|
43
|
-
receipt: {
|
|
44
|
-
transactionHash: string;
|
|
45
|
-
blockNumber: string;
|
|
46
|
-
blockHash: string;
|
|
47
|
-
[key: string]: unknown;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
type RpcResponse = {
|
|
52
|
-
result?: unknown;
|
|
53
|
-
error?: { code: number; message: string };
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export class BundlerClient {
|
|
57
|
-
private bundlerUrl: string;
|
|
58
|
-
private entryPointAddress: string;
|
|
59
|
-
private chainId: number;
|
|
60
|
-
|
|
61
|
-
constructor(bundlerUrl: string, entryPointAddress: string, chainId: number) {
|
|
62
|
-
this.bundlerUrl = bundlerUrl;
|
|
63
|
-
this.entryPointAddress = entryPointAddress;
|
|
64
|
-
this.chainId = chainId;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private async rpc(method: string, params: unknown[]): Promise<unknown> {
|
|
68
|
-
const response = await fetch(this.bundlerUrl, {
|
|
69
|
-
method: "POST",
|
|
70
|
-
headers: { "Content-Type": "application/json" },
|
|
71
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
72
|
-
});
|
|
73
|
-
if (!response.ok) {
|
|
74
|
-
throw new Error(`Bundler HTTP ${response.status}: ${response.statusText}`);
|
|
75
|
-
}
|
|
76
|
-
const json = (await response.json()) as RpcResponse;
|
|
77
|
-
if (json.error) {
|
|
78
|
-
throw new Error(`Bundler RPC error [${json.error.code}]: ${json.error.message}`);
|
|
79
|
-
}
|
|
80
|
-
return json.result;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async sendUserOperation(userOp: UserOperation): Promise<string> {
|
|
84
|
-
const hash = await this.rpc("eth_sendUserOperation", [userOp, this.entryPointAddress]);
|
|
85
|
-
return hash as string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async getUserOperationReceipt(userOpHash: string): Promise<UserOpReceipt> {
|
|
89
|
-
const POLL_INTERVAL_MS = 2000;
|
|
90
|
-
const MAX_ATTEMPTS = 30;
|
|
91
|
-
for (let i = 0; i < MAX_ATTEMPTS; i++) {
|
|
92
|
-
const receipt = await this.rpc("eth_getUserOperationReceipt", [userOpHash]);
|
|
93
|
-
if (receipt !== null && receipt !== undefined) {
|
|
94
|
-
return receipt as UserOpReceipt;
|
|
95
|
-
}
|
|
96
|
-
await new Promise<void>((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
97
|
-
}
|
|
98
|
-
throw new Error(
|
|
99
|
-
`UserOperation ${userOpHash} not confirmed after ${(MAX_ATTEMPTS * POLL_INTERVAL_MS) / 1000}s`
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async estimateUserOperationGas(userOp: Partial<UserOperation>): Promise<GasEstimate> {
|
|
104
|
-
const estimate = await this.rpc("eth_estimateUserOperationGas", [
|
|
105
|
-
userOp,
|
|
106
|
-
this.entryPointAddress,
|
|
107
|
-
]);
|
|
108
|
-
return estimate as GasEstimate;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ─── PaymasterClient ──────────────────────────────────────────────────────────
|
|
113
|
-
|
|
114
|
-
export class PaymasterClient {
|
|
115
|
-
private paymasterUrl: string;
|
|
116
|
-
private cdpKeyName?: string;
|
|
117
|
-
private cdpPrivateKey?: string;
|
|
118
|
-
|
|
119
|
-
constructor(paymasterUrl: string, cdpKeyName?: string, cdpPrivateKey?: string) {
|
|
120
|
-
this.paymasterUrl = paymasterUrl;
|
|
121
|
-
this.cdpKeyName = cdpKeyName;
|
|
122
|
-
this.cdpPrivateKey = cdpPrivateKey;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private async buildJwt(): Promise<string | null> {
|
|
126
|
-
if (!this.cdpKeyName || !this.cdpPrivateKey) return null;
|
|
127
|
-
const { SignJWT, importPKCS8 } = await import("jose");
|
|
128
|
-
|
|
129
|
-
// Convert SEC1 base64 DER or SEC1 PEM → PKCS8 PEM using Node's crypto module
|
|
130
|
-
let pkcs8Pem: string;
|
|
131
|
-
if (this.cdpPrivateKey.includes("-----BEGIN")) {
|
|
132
|
-
if (this.cdpPrivateKey.includes("EC PRIVATE KEY")) {
|
|
133
|
-
const key = createPrivateKey({ key: this.cdpPrivateKey, format: "pem", type: "sec1" });
|
|
134
|
-
pkcs8Pem = key.export({ format: "pem", type: "pkcs8" }) as string;
|
|
135
|
-
} else {
|
|
136
|
-
pkcs8Pem = this.cdpPrivateKey;
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
const der = Buffer.from(this.cdpPrivateKey, "base64");
|
|
140
|
-
const key = createPrivateKey({ key: der, format: "der", type: "sec1" });
|
|
141
|
-
pkcs8Pem = key.export({ format: "pem", type: "pkcs8" }) as string;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const privateKey = await importPKCS8(pkcs8Pem, "ES256");
|
|
145
|
-
const now = Math.floor(Date.now() / 1000);
|
|
146
|
-
return new SignJWT({ sub: this.cdpKeyName })
|
|
147
|
-
.setProtectedHeader({ alg: "ES256", kid: this.cdpKeyName })
|
|
148
|
-
.setIssuer(this.cdpKeyName)
|
|
149
|
-
.setNotBefore(now)
|
|
150
|
-
.setExpirationTime(now + 120)
|
|
151
|
-
.sign(privateKey);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
private async rpc(method: string, params: unknown[]): Promise<unknown> {
|
|
155
|
-
const jwt = await this.buildJwt();
|
|
156
|
-
const headers: Record<string, string> = { "Content-Type": "application/json" };
|
|
157
|
-
if (jwt) headers["Authorization"] = `Bearer ${jwt}`;
|
|
158
|
-
const response = await fetch(this.paymasterUrl, {
|
|
159
|
-
method: "POST",
|
|
160
|
-
headers,
|
|
161
|
-
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
162
|
-
});
|
|
163
|
-
if (!response.ok) {
|
|
164
|
-
throw new Error(`Paymaster HTTP ${response.status}: ${response.statusText}`);
|
|
165
|
-
}
|
|
166
|
-
const json = (await response.json()) as { result?: unknown; error?: { code: number; message: string } };
|
|
167
|
-
if (json.error) {
|
|
168
|
-
throw new Error(`Paymaster RPC error [${json.error.code}]: ${json.error.message}`);
|
|
169
|
-
}
|
|
170
|
-
return json.result;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
async sponsorUserOperation(
|
|
174
|
-
userOp: Partial<UserOperation>,
|
|
175
|
-
entryPoint: string
|
|
176
|
-
): Promise<UserOperation> {
|
|
177
|
-
const result = (await this.rpc("pm_sponsorUserOperation", [userOp, entryPoint, {}])) as {
|
|
178
|
-
paymaster: string;
|
|
179
|
-
paymasterData: string;
|
|
180
|
-
paymasterVerificationGasLimit: string;
|
|
181
|
-
paymasterPostOpGasLimit: string;
|
|
182
|
-
callGasLimit?: string;
|
|
183
|
-
verificationGasLimit?: string;
|
|
184
|
-
preVerificationGas?: string;
|
|
185
|
-
};
|
|
186
|
-
return {
|
|
187
|
-
...(userOp as UserOperation),
|
|
188
|
-
paymaster: result.paymaster,
|
|
189
|
-
paymasterData: result.paymasterData,
|
|
190
|
-
paymasterVerificationGasLimit: result.paymasterVerificationGasLimit,
|
|
191
|
-
paymasterPostOpGasLimit: result.paymasterPostOpGasLimit,
|
|
192
|
-
...(result.callGasLimit && { callGasLimit: result.callGasLimit }),
|
|
193
|
-
...(result.verificationGasLimit && { verificationGasLimit: result.verificationGasLimit }),
|
|
194
|
-
...(result.preVerificationGas && { preVerificationGas: result.preVerificationGas }),
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// ─── buildUserOp / buildSponsoredUserOp ───────────────────────────────────────
|
|
200
|
-
|
|
201
|
-
export async function buildUserOp(
|
|
202
|
-
callData: string,
|
|
203
|
-
sender: string,
|
|
204
|
-
nonce: bigint,
|
|
205
|
-
config: Arc402Config
|
|
206
|
-
): Promise<UserOperation> {
|
|
207
|
-
const provider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
208
|
-
const feeData = await provider.getFeeData();
|
|
209
|
-
|
|
210
|
-
const maxFeePerGas = feeData.maxFeePerGas ?? BigInt(1_000_000_000);
|
|
211
|
-
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? BigInt(100_000_000);
|
|
212
|
-
|
|
213
|
-
return {
|
|
214
|
-
sender,
|
|
215
|
-
nonce: ethers.toBeHex(nonce),
|
|
216
|
-
callData,
|
|
217
|
-
callGasLimit: ethers.toBeHex(300_000),
|
|
218
|
-
verificationGasLimit: ethers.toBeHex(150_000),
|
|
219
|
-
preVerificationGas: ethers.toBeHex(50_000),
|
|
220
|
-
maxFeePerGas: ethers.toBeHex(maxFeePerGas),
|
|
221
|
-
maxPriorityFeePerGas: ethers.toBeHex(maxPriorityFeePerGas),
|
|
222
|
-
signature: "0x",
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export async function buildSponsoredUserOp(
|
|
227
|
-
callData: string,
|
|
228
|
-
sender: string,
|
|
229
|
-
nonce: bigint,
|
|
230
|
-
config: Arc402Config,
|
|
231
|
-
paymasterClient: PaymasterClient
|
|
232
|
-
): Promise<UserOperation> {
|
|
233
|
-
const userOp = await buildUserOp(callData, sender, nonce, config);
|
|
234
|
-
return paymasterClient.sponsorUserOperation(userOp, DEFAULT_ENTRY_POINT);
|
|
235
|
-
}
|
package/src/client.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
|
-
import { Arc402Config } from "./config.js";
|
|
3
|
-
|
|
4
|
-
export interface Arc402Client {
|
|
5
|
-
provider: ethers.JsonRpcProvider;
|
|
6
|
-
signer: ethers.Wallet | null;
|
|
7
|
-
address: string | null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export async function getClient(config: Arc402Config): Promise<Arc402Client> {
|
|
11
|
-
const provider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
12
|
-
|
|
13
|
-
if (config.privateKey) {
|
|
14
|
-
const signer = new ethers.Wallet(config.privateKey, provider);
|
|
15
|
-
const address = await signer.getAddress();
|
|
16
|
-
return { provider, signer, address };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// No private key — use walletContractAddress for read-only operations
|
|
20
|
-
const address = config.walletContractAddress ?? null;
|
|
21
|
-
return { provider, signer: null, address };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function requireSigner(
|
|
25
|
-
config: Arc402Config
|
|
26
|
-
): Promise<{ provider: ethers.JsonRpcProvider; signer: ethers.Wallet; address: string }> {
|
|
27
|
-
const { provider, signer } = await getClient(config);
|
|
28
|
-
if (!signer) {
|
|
29
|
-
console.error(
|
|
30
|
-
"No private key configured. Run `arc402 config init` and provide a private key."
|
|
31
|
-
);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
const address = await signer.getAddress();
|
|
35
|
-
return { provider, signer, address };
|
|
36
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* coinbase-smart-wallet.ts
|
|
3
|
-
*
|
|
4
|
-
* Base Smart Wallet connection via Coinbase Wallet SDK.
|
|
5
|
-
*
|
|
6
|
-
* IMPORTANT — Node.js limitation:
|
|
7
|
-
* @coinbase/wallet-sdk v4 is a browser-only library. It communicates with the
|
|
8
|
-
* wallet through a popup opened to keys.coinbase.com using window.postMessage.
|
|
9
|
-
* There is no scannable QR URL emitted — the popup IS the transport layer.
|
|
10
|
-
*
|
|
11
|
-
* Running the SDK in Node.js fails at the `window.open` call inside openPopup().
|
|
12
|
-
* See TODO.md at the project root for resolution paths.
|
|
13
|
-
*
|
|
14
|
-
* This module is a typed stub so that:
|
|
15
|
-
* - `arc402 wallet deploy --smart-wallet` exists and compiles cleanly.
|
|
16
|
-
* - The error shown to users is clear and actionable, not a raw stack trace.
|
|
17
|
-
* - The interface matches requestPhoneWalletSignature() so the caller in
|
|
18
|
-
* wallet.ts requires zero changes once a real implementation lands.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
-
import type { CoinbaseWalletSDK } from "@coinbase/wallet-sdk";
|
|
23
|
-
|
|
24
|
-
export async function requestCoinbaseSmartWalletSignature(
|
|
25
|
-
chainId: number,
|
|
26
|
-
buildTx: (account: string) => { to: string; data: string; value?: string },
|
|
27
|
-
prompt: string
|
|
28
|
-
): Promise<{ txHash: string; account: string }> {
|
|
29
|
-
console.log(`\n${prompt}`);
|
|
30
|
-
console.log("─────────────────────────────────────────────────────────");
|
|
31
|
-
console.log("Connect your Base Smart Wallet:\n");
|
|
32
|
-
console.log(
|
|
33
|
-
"⚠ Base Smart Wallet (Coinbase Wallet SDK v4) is not yet supported in the CLI.\n"
|
|
34
|
-
);
|
|
35
|
-
console.log(
|
|
36
|
-
" The SDK requires a browser environment — it opens a popup to\n" +
|
|
37
|
-
" keys.coinbase.com and communicates via window.postMessage.\n" +
|
|
38
|
-
" There is no scannable QR URL available outside a browser context.\n"
|
|
39
|
-
);
|
|
40
|
-
console.log(
|
|
41
|
-
" Workarounds are tracked in TODO.md at the project root.\n"
|
|
42
|
-
);
|
|
43
|
-
console.log(
|
|
44
|
-
" To sign this transaction today, omit --smart-wallet and use WalletConnect instead:\n" +
|
|
45
|
-
" arc402 wallet deploy\n"
|
|
46
|
-
);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
|
|
49
|
-
// Unreachable — satisfies the return type so the caller compiles without a cast.
|
|
50
|
-
return { txHash: "", account: "" };
|
|
51
|
-
}
|
package/src/commands/accept.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { ServiceAgreementClient } from "@arc402/sdk";
|
|
3
|
-
import { ethers } from "ethers";
|
|
4
|
-
import { loadConfig } from "../config.js";
|
|
5
|
-
import { requireSigner } from "../client.js";
|
|
6
|
-
import { printSenderInfo, executeContractWriteViaWallet } from "../wallet-router.js";
|
|
7
|
-
import { SERVICE_AGREEMENT_ABI } from "../abis.js";
|
|
8
|
-
import { resolveAgentEndpoint, notifyAgent, DEFAULT_REGISTRY_ADDRESS } from "../endpoint-notify.js";
|
|
9
|
-
import { c } from "../ui/colors.js";
|
|
10
|
-
import { startSpinner } from "../ui/spinner.js";
|
|
11
|
-
|
|
12
|
-
export function registerAcceptCommand(program: Command): void {
|
|
13
|
-
program.command("accept <id>").description("Provider accepts a proposed agreement").action(async (id) => {
|
|
14
|
-
const config = loadConfig();
|
|
15
|
-
if (!config.serviceAgreementAddress) throw new Error("serviceAgreementAddress missing in config");
|
|
16
|
-
const { signer, address: signerAddress } = await requireSigner(config);
|
|
17
|
-
printSenderInfo(config);
|
|
18
|
-
|
|
19
|
-
// Read agreement to get client address for endpoint notification
|
|
20
|
-
let clientAddress = "";
|
|
21
|
-
try {
|
|
22
|
-
const prefProvider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
23
|
-
const saContract = new ethers.Contract(
|
|
24
|
-
config.serviceAgreementAddress,
|
|
25
|
-
["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))"],
|
|
26
|
-
prefProvider
|
|
27
|
-
);
|
|
28
|
-
const ag = await saContract.getAgreement(BigInt(id));
|
|
29
|
-
clientAddress = String(ag.client ?? "");
|
|
30
|
-
} catch { /* non-fatal */ }
|
|
31
|
-
|
|
32
|
-
const spinner = startSpinner("Submitting transaction...");
|
|
33
|
-
try {
|
|
34
|
-
if (config.walletContractAddress) {
|
|
35
|
-
await executeContractWriteViaWallet(
|
|
36
|
-
config.walletContractAddress, signer, config.serviceAgreementAddress,
|
|
37
|
-
SERVICE_AGREEMENT_ABI, "accept", [BigInt(id)],
|
|
38
|
-
);
|
|
39
|
-
} else {
|
|
40
|
-
const client = new ServiceAgreementClient(config.serviceAgreementAddress, signer);
|
|
41
|
-
await client.accept(BigInt(id));
|
|
42
|
-
}
|
|
43
|
-
spinner.succeed();
|
|
44
|
-
} catch (err) {
|
|
45
|
-
spinner.fail();
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
console.log(' ' + c.success + c.white(` Accepted — agreement #${id}`));
|
|
49
|
-
|
|
50
|
-
// Notify client's HTTP endpoint (non-blocking)
|
|
51
|
-
if (clientAddress) {
|
|
52
|
-
try {
|
|
53
|
-
const notifyProvider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
54
|
-
const registryAddress = config.agentRegistryV2Address ?? config.agentRegistryAddress ?? DEFAULT_REGISTRY_ADDRESS;
|
|
55
|
-
const endpoint = await resolveAgentEndpoint(clientAddress, notifyProvider, registryAddress);
|
|
56
|
-
const payload = { agreementId: id, from: signerAddress };
|
|
57
|
-
await notifyAgent(endpoint, "/hire/accepted", payload);
|
|
58
|
-
await notifyAgent(endpoint, "/delivery/accepted", payload);
|
|
59
|
-
} catch (err) {
|
|
60
|
-
console.warn(' ' + c.warning + c.white(` Could not notify client endpoint: ${err instanceof Error ? err.message : String(err)}`));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { ethers } from "ethers";
|
|
3
|
-
import { loadConfig } from "../config.js";
|
|
4
|
-
import { requireSigner } from "../client.js";
|
|
5
|
-
import { c } from "../ui/colors.js";
|
|
6
|
-
import { renderTree } from "../ui/tree.js";
|
|
7
|
-
|
|
8
|
-
// Challenge-response: both agents sign a shared nonce with their agent key
|
|
9
|
-
// and verify each other against AgentRegistry
|
|
10
|
-
|
|
11
|
-
const AGENT_REGISTRY_ABI = [
|
|
12
|
-
"function isRegistered(address wallet) view returns (bool)",
|
|
13
|
-
"function getAgent(address wallet) view returns (tuple(address wallet, string endpoint, string serviceType, bool active, uint256 registeredAt))",
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
export function registerHandshakeCommand(program: Command): void {
|
|
17
|
-
program
|
|
18
|
-
.command("handshake <agentAddress>")
|
|
19
|
-
.description("Mutual challenge-response authentication with another ARC-402 agent. Verifies both parties are registered before any negotiation begins.")
|
|
20
|
-
.option("--json", "Output as machine-parseable JSON")
|
|
21
|
-
.action(async (agentAddress: string, opts) => {
|
|
22
|
-
const config = loadConfig();
|
|
23
|
-
const { signer, provider } = await requireSigner(config);
|
|
24
|
-
const myAddress = await signer.getAddress();
|
|
25
|
-
|
|
26
|
-
// Generate shared challenge nonce
|
|
27
|
-
const challengeNonce = ethers.hexlify(ethers.randomBytes(32));
|
|
28
|
-
const timestamp = Math.floor(Date.now() / 1000);
|
|
29
|
-
|
|
30
|
-
// Sign: keccak256(HANDSHAKE + myAddress + theirAddress + challengeNonce + timestamp)
|
|
31
|
-
const digest = ethers.solidityPackedKeccak256(
|
|
32
|
-
["string", "address", "address", "bytes32", "uint256"],
|
|
33
|
-
["HANDSHAKE", myAddress, agentAddress, challengeNonce, timestamp]
|
|
34
|
-
);
|
|
35
|
-
const mySig = await signer.signMessage(ethers.getBytes(digest));
|
|
36
|
-
|
|
37
|
-
// Fetch their endpoint from AgentRegistry to send challenge
|
|
38
|
-
if (!config.agentRegistryAddress) throw new Error("agentRegistryAddress not configured");
|
|
39
|
-
const registry = new ethers.Contract(config.agentRegistryAddress, AGENT_REGISTRY_ABI, provider);
|
|
40
|
-
|
|
41
|
-
const myRegistered = await registry.isRegistered(myAddress);
|
|
42
|
-
if (!myRegistered) throw new Error(`Your wallet ${myAddress} is not registered in AgentRegistry`);
|
|
43
|
-
|
|
44
|
-
const theirAgent = await registry.getAgent(agentAddress);
|
|
45
|
-
if (!theirAgent.active) throw new Error(`Agent ${agentAddress} is not active in AgentRegistry`);
|
|
46
|
-
|
|
47
|
-
// For v1: output the signed challenge for manual relay / SDK integration
|
|
48
|
-
// Full async exchange (HTTP POST to their endpoint) is in NegotiationSession flow
|
|
49
|
-
const challenge = {
|
|
50
|
-
type: "HANDSHAKE_CHALLENGE",
|
|
51
|
-
from: myAddress,
|
|
52
|
-
to: agentAddress,
|
|
53
|
-
nonce: challengeNonce,
|
|
54
|
-
timestamp,
|
|
55
|
-
sig: mySig,
|
|
56
|
-
theirEndpoint: theirAgent.endpoint,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (opts.json) {
|
|
60
|
-
console.log(JSON.stringify(challenge));
|
|
61
|
-
} else {
|
|
62
|
-
console.log('\n ' + c.mark + c.white(' Handshake'));
|
|
63
|
-
renderTree([
|
|
64
|
-
{ label: 'Your identity', value: `${myAddress} (registered)` },
|
|
65
|
-
{ label: 'Their identity', value: `${agentAddress} (registered, active)` },
|
|
66
|
-
{ label: 'Their endpoint', value: theirAgent.endpoint, last: true },
|
|
67
|
-
]);
|
|
68
|
-
console.log('\n ' + c.dim('Signed challenge (send to their endpoint to complete handshake):'));
|
|
69
|
-
console.log(JSON.stringify(challenge, null, 2));
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|