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
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { ethers } from "ethers";
|
|
3
|
-
import * as readline from "readline";
|
|
4
|
-
import { AgreementStatus, ServiceAgreementClient } from "@arc402/sdk";
|
|
5
|
-
import { loadConfig } from "../config.js";
|
|
6
|
-
import { getClient } from "../client.js";
|
|
7
|
-
import { agreementStatusLabel, formatDate, printTable, truncateAddress } from "../utils/format.js";
|
|
8
|
-
import { formatDeadline } from "../utils/time.js";
|
|
9
|
-
import { hashString } from "../utils/hash.js";
|
|
10
|
-
import { c } from "../ui/colors.js";
|
|
11
|
-
import { renderTree } from "../ui/tree.js";
|
|
12
|
-
import { formatAddress } from "../ui/format.js";
|
|
13
|
-
|
|
14
|
-
// ─── AgreementTree minimal ABI ────────────────────────────────────────────────
|
|
15
|
-
|
|
16
|
-
const AGREEMENT_TREE_ABI = [
|
|
17
|
-
"function registerSubAgreement(uint256 parentAgreementId, uint256 childAgreementId) external",
|
|
18
|
-
"function getChildren(uint256 agreementId) external view returns (uint256[])",
|
|
19
|
-
"function getRoot(uint256 agreementId) external view returns (uint256)",
|
|
20
|
-
"function getPath(uint256 agreementId) external view returns (uint256[])",
|
|
21
|
-
"function allChildrenSettled(uint256 agreementId) external view returns (bool)",
|
|
22
|
-
"function getDepth(uint256 agreementId) external view returns (uint256)",
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
export function registerAgreementsCommands(program: Command): void {
|
|
26
|
-
|
|
27
|
-
// ── arc402 agreements ────────────────────────────────────────────────────────
|
|
28
|
-
program
|
|
29
|
-
.command("agreements")
|
|
30
|
-
.description("List agreements for the configured wallet")
|
|
31
|
-
.option("--as <role>", "client or provider", "client")
|
|
32
|
-
.option("--json")
|
|
33
|
-
.action(async (opts) => {
|
|
34
|
-
const config = loadConfig();
|
|
35
|
-
if (!config.serviceAgreementAddress) throw new Error("serviceAgreementAddress missing in config");
|
|
36
|
-
const { provider, address } = await getClient(config);
|
|
37
|
-
if (!address) throw new Error("No wallet configured");
|
|
38
|
-
const client = new ServiceAgreementClient(config.serviceAgreementAddress, provider);
|
|
39
|
-
const agreements = opts.as === "provider"
|
|
40
|
-
? await client.getProviderAgreements(address)
|
|
41
|
-
: await client.getClientAgreements(address);
|
|
42
|
-
if (opts.json) return console.log(JSON.stringify(agreements, (_k, value) => typeof value === "bigint" ? value.toString() : value, 2));
|
|
43
|
-
printTable(
|
|
44
|
-
["ID", "COUNTERPARTY", "SERVICE", "DEADLINE", "STATUS"],
|
|
45
|
-
agreements.map((agreement) => [
|
|
46
|
-
agreement.id.toString(),
|
|
47
|
-
truncateAddress(opts.as === "provider" ? agreement.client : agreement.provider),
|
|
48
|
-
agreement.serviceType,
|
|
49
|
-
formatDeadline(Number(agreement.deadline)),
|
|
50
|
-
agreementStatusLabel(agreement.status),
|
|
51
|
-
])
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// ── arc402 agreement <id> ────────────────────────────────────────────────────
|
|
56
|
-
program
|
|
57
|
-
.command("agreement <id>")
|
|
58
|
-
.description("Show agreement detail, including remediation/dispute fields")
|
|
59
|
-
.option("--json")
|
|
60
|
-
.action(async (id, opts) => {
|
|
61
|
-
const config = loadConfig();
|
|
62
|
-
if (!config.serviceAgreementAddress) throw new Error("serviceAgreementAddress missing in config");
|
|
63
|
-
const { provider } = await getClient(config);
|
|
64
|
-
const client = new ServiceAgreementClient(config.serviceAgreementAddress, provider);
|
|
65
|
-
const agreement = await client.getAgreement(BigInt(id));
|
|
66
|
-
if (opts.json) return console.log(JSON.stringify(agreement, (_k, value) => typeof value === "bigint" ? value.toString() : value, 2));
|
|
67
|
-
console.log('\n ' + c.mark + c.white(` Agreement #${agreement.id}`));
|
|
68
|
-
renderTree([
|
|
69
|
-
{ label: 'Client', value: formatAddress(agreement.client) },
|
|
70
|
-
{ label: 'Provider', value: formatAddress(agreement.provider) },
|
|
71
|
-
{ label: 'Status', value: agreementStatusLabel(agreement.status) },
|
|
72
|
-
{ label: 'Created', value: formatDate(Number(agreement.createdAt)) },
|
|
73
|
-
{ label: 'Deadline', value: formatDate(Number(agreement.deadline)) },
|
|
74
|
-
{ label: 'Verify end', value: Number(agreement.verifyWindowEnd) ? formatDate(Number(agreement.verifyWindowEnd)) : 'n/a' },
|
|
75
|
-
{ label: 'Hash', value: String(agreement.committedHash), last: true },
|
|
76
|
-
]);
|
|
77
|
-
if ([AgreementStatus.REVISION_REQUESTED, AgreementStatus.REVISED, AgreementStatus.PARTIAL_SETTLEMENT, AgreementStatus.ESCALATED_TO_HUMAN, AgreementStatus.DISPUTED, AgreementStatus.ESCALATED_TO_ARBITRATION].includes(agreement.status)) {
|
|
78
|
-
const remediation = await client.getRemediationCase(agreement.id);
|
|
79
|
-
const dispute = await client.getDisputeCase(agreement.id);
|
|
80
|
-
renderTree([
|
|
81
|
-
{ label: 'Remediation', value: `active=${remediation.active} cycles=${remediation.cycleCount}` },
|
|
82
|
-
{ label: 'Dispute', value: `outcome=${dispute.outcome}`, last: true },
|
|
83
|
-
]);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// ── arc402 agreements-sub-register ──────────────────────────────────────────
|
|
88
|
-
// Spec 19: arc402 agreements sub-register --parent <id> --child <id>
|
|
89
|
-
program
|
|
90
|
-
.command("agreements-sub-register")
|
|
91
|
-
.description("Link a child agreement to its parent in the AgreementTree (Spec 19)")
|
|
92
|
-
.requiredOption("--parent <id>", "Parent agreement ID")
|
|
93
|
-
.requiredOption("--child <id>", "Child agreement ID to register under the parent")
|
|
94
|
-
.option("--json", "Machine-parseable output")
|
|
95
|
-
.action(async (opts) => {
|
|
96
|
-
const config = loadConfig();
|
|
97
|
-
if (!config.agreementTreeAddress) throw new Error("agreementTreeAddress missing in config");
|
|
98
|
-
const { signer } = await getClient(config);
|
|
99
|
-
if (!signer) { console.error("No private key configured."); process.exit(1); }
|
|
100
|
-
|
|
101
|
-
const tree = new ethers.Contract(config.agreementTreeAddress, AGREEMENT_TREE_ABI, signer);
|
|
102
|
-
const tx = await tree.registerSubAgreement(BigInt(opts.parent), BigInt(opts.child));
|
|
103
|
-
const receipt = await tx.wait();
|
|
104
|
-
|
|
105
|
-
if (opts.json) {
|
|
106
|
-
console.log(JSON.stringify({ txHash: receipt.hash, parentId: opts.parent, childId: opts.child }));
|
|
107
|
-
} else {
|
|
108
|
-
console.log('\n ' + c.mark + c.white(' Sub-agreement registered'));
|
|
109
|
-
renderTree([
|
|
110
|
-
{ label: 'Parent', value: `#${opts.parent}` },
|
|
111
|
-
{ label: 'Child', value: `#${opts.child}` },
|
|
112
|
-
{ label: 'Tx', value: receipt.hash, last: true },
|
|
113
|
-
]);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// ── arc402 agreements-tree <id> ──────────────────────────────────────────────
|
|
118
|
-
// Spec 19: arc402 agreements tree <agreementId>
|
|
119
|
-
program
|
|
120
|
-
.command("agreements-tree <agreementId>")
|
|
121
|
-
.description("View full agreement tree for an agreement (Spec 19)")
|
|
122
|
-
.option("--json", "Machine-parseable output")
|
|
123
|
-
.action(async (agreementId, opts) => {
|
|
124
|
-
const config = loadConfig();
|
|
125
|
-
if (!config.agreementTreeAddress) throw new Error("agreementTreeAddress missing in config");
|
|
126
|
-
const { provider } = await getClient(config);
|
|
127
|
-
|
|
128
|
-
const tree = new ethers.Contract(config.agreementTreeAddress, AGREEMENT_TREE_ABI, provider);
|
|
129
|
-
|
|
130
|
-
const id = BigInt(agreementId);
|
|
131
|
-
const [root, path, children, depth] = await Promise.all([
|
|
132
|
-
tree.getRoot(id),
|
|
133
|
-
tree.getPath(id),
|
|
134
|
-
tree.getChildren(id),
|
|
135
|
-
tree.getDepth(id),
|
|
136
|
-
]);
|
|
137
|
-
|
|
138
|
-
const result = {
|
|
139
|
-
agreementId: agreementId,
|
|
140
|
-
root: root.toString(),
|
|
141
|
-
path: (path as bigint[]).map(String),
|
|
142
|
-
children: (children as bigint[]).map(String),
|
|
143
|
-
depth: Number(depth),
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
if (opts.json) {
|
|
147
|
-
console.log(JSON.stringify(result));
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
console.log('\n ' + c.mark + c.white(` Agreement Tree — node #${agreementId}`));
|
|
152
|
-
renderTree([
|
|
153
|
-
{ label: 'Root', value: `#${result.root}` },
|
|
154
|
-
{ label: 'Depth', value: String(result.depth) },
|
|
155
|
-
{ label: 'Path', value: result.path.map((p) => "#" + p).join(" → ") },
|
|
156
|
-
{ label: 'Children', value: result.children.length > 0 ? result.children.map((ch) => "#" + ch).join(", ") : "(none)", last: true },
|
|
157
|
-
]);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// ── arc402 agreements-tree-status <id> ───────────────────────────────────────
|
|
161
|
-
// Spec 19: arc402 agreements tree-status <agreementId>
|
|
162
|
-
program
|
|
163
|
-
.command("agreements-tree-status <agreementId>")
|
|
164
|
-
.description("Check whether all sub-agreements are settled before delivering (Spec 19)")
|
|
165
|
-
.option("--json", "Machine-parseable output")
|
|
166
|
-
.action(async (agreementId, opts) => {
|
|
167
|
-
const config = loadConfig();
|
|
168
|
-
if (!config.agreementTreeAddress) throw new Error("agreementTreeAddress missing in config");
|
|
169
|
-
const { provider } = await getClient(config);
|
|
170
|
-
|
|
171
|
-
const tree = new ethers.Contract(config.agreementTreeAddress, AGREEMENT_TREE_ABI, provider);
|
|
172
|
-
|
|
173
|
-
const id = BigInt(agreementId);
|
|
174
|
-
const [allSettled, children] = await Promise.all([
|
|
175
|
-
tree.allChildrenSettled(id),
|
|
176
|
-
tree.getChildren(id),
|
|
177
|
-
]);
|
|
178
|
-
|
|
179
|
-
const result = {
|
|
180
|
-
agreementId: agreementId,
|
|
181
|
-
childCount: (children as bigint[]).length,
|
|
182
|
-
allChildrenSettled: Boolean(allSettled),
|
|
183
|
-
readyToDeliver: Boolean(allSettled),
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
if (opts.json) {
|
|
187
|
-
console.log(JSON.stringify(result));
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
console.log('\n ' + c.mark + c.white(` Agreement #${agreementId} — tree status`));
|
|
192
|
-
renderTree([
|
|
193
|
-
{ label: 'Sub-agrmts', value: String(result.childCount) },
|
|
194
|
-
{ label: 'All settled', value: result.allChildrenSettled ? 'YES' : 'NO' },
|
|
195
|
-
{ label: 'Ready', value: result.readyToDeliver ? 'YES — ready to deliver to parent' : 'NO', last: true },
|
|
196
|
-
]);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
// ── arc402 agreements-create-tree ────────────────────────────────────────────
|
|
200
|
-
// Spec 19: interactive multi-party agreement setup
|
|
201
|
-
// Usage: arc402 agreements-create-tree \
|
|
202
|
-
// --provider <addr> --task <desc> --service-type <type> --price <wei> --deadline <s> \
|
|
203
|
-
// --sub <addr>,<task>,<type>,<wei>,<deadline> [--sub ...]
|
|
204
|
-
program
|
|
205
|
-
.command("agreements-create-tree")
|
|
206
|
-
.description("Create a multi-party agreement tree: one root agreement plus sub-agreements (Spec 19)")
|
|
207
|
-
.requiredOption("--provider <address>", "Root provider (Agent B)")
|
|
208
|
-
.requiredOption("--task <description>", "Root task description")
|
|
209
|
-
.requiredOption("--service-type <type>", "Root service type")
|
|
210
|
-
.requiredOption("--price <wei>", "Root price in wei")
|
|
211
|
-
.requiredOption("--deadline <seconds>", "Root deadline offset in seconds from now")
|
|
212
|
-
.option(
|
|
213
|
-
"--sub <spec>",
|
|
214
|
-
"Sub-agreement in format <provider>,<task>,<serviceType>,<priceWei>,<deadlineSeconds>. Repeatable.",
|
|
215
|
-
(val: string, acc: string[]) => { acc.push(val); return acc; },
|
|
216
|
-
[] as string[],
|
|
217
|
-
)
|
|
218
|
-
.option("--interactive", "Prompt interactively for sub-agreements")
|
|
219
|
-
.option("--json", "Machine-parseable output")
|
|
220
|
-
.action(async (opts) => {
|
|
221
|
-
const config = loadConfig();
|
|
222
|
-
if (!config.serviceAgreementAddress) throw new Error("serviceAgreementAddress missing in config");
|
|
223
|
-
if (!config.agreementTreeAddress) throw new Error("agreementTreeAddress missing in config");
|
|
224
|
-
const { signer } = await getClient(config);
|
|
225
|
-
if (!signer) { console.error("No private key configured."); process.exit(1); }
|
|
226
|
-
|
|
227
|
-
type SubSpec = { provider: string; task: string; serviceType: string; price: bigint; deadline: number };
|
|
228
|
-
const subSpecs: SubSpec[] = [];
|
|
229
|
-
|
|
230
|
-
// Parse --sub flags
|
|
231
|
-
for (const raw of opts.sub as string[]) {
|
|
232
|
-
const parts = raw.split(",");
|
|
233
|
-
if (parts.length < 5) {
|
|
234
|
-
console.error(`--sub format: <provider>,<task>,<serviceType>,<priceWei>,<deadlineSeconds> got: ${raw}`);
|
|
235
|
-
process.exit(1);
|
|
236
|
-
}
|
|
237
|
-
subSpecs.push({
|
|
238
|
-
provider: parts[0],
|
|
239
|
-
task: parts.slice(1, parts.length - 3).join(",") || parts[1],
|
|
240
|
-
serviceType: parts[parts.length - 3],
|
|
241
|
-
price: BigInt(parts[parts.length - 2]),
|
|
242
|
-
deadline: Number(parts[parts.length - 1]),
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Interactive mode: prompt for sub-agreements if no --sub flags provided
|
|
247
|
-
if (opts.interactive || subSpecs.length === 0) {
|
|
248
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
249
|
-
const ask = (q: string) => new Promise<string>((res) => rl.question(q, res));
|
|
250
|
-
|
|
251
|
-
console.log("\nMulti-party agreement setup — add sub-agreements (leave provider blank to finish)");
|
|
252
|
-
while (true) {
|
|
253
|
-
const provider = await ask(" Sub-provider address (blank to finish): ");
|
|
254
|
-
if (!provider.trim()) break;
|
|
255
|
-
const task = await ask(" Task description: ");
|
|
256
|
-
const serviceType = await ask(" Service type: ");
|
|
257
|
-
const priceRaw = await ask(" Price (wei): ");
|
|
258
|
-
const deadlineRaw = await ask(" Deadline offset (seconds): ");
|
|
259
|
-
subSpecs.push({
|
|
260
|
-
provider: provider.trim(),
|
|
261
|
-
task: task.trim(),
|
|
262
|
-
serviceType: serviceType.trim(),
|
|
263
|
-
price: BigInt(priceRaw.trim()),
|
|
264
|
-
deadline: Number(deadlineRaw.trim()),
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
rl.close();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const saContract = new ethers.Contract(config.serviceAgreementAddress, [
|
|
271
|
-
"function propose(address provider, string serviceType, string description, uint256 price, address token, uint256 deadline, bytes32 deliverablesHash) external payable returns (uint256)",
|
|
272
|
-
"event AgreementProposed(uint256 indexed id, address indexed client, address indexed provider, string serviceType, uint256 price, address token, uint256 deadline)",
|
|
273
|
-
], signer);
|
|
274
|
-
const treeContract = new ethers.Contract(config.agreementTreeAddress, AGREEMENT_TREE_ABI, signer);
|
|
275
|
-
|
|
276
|
-
const rootPrice = BigInt(opts.price);
|
|
277
|
-
const rootDeadline = Number(opts.deadline);
|
|
278
|
-
const rootHash = hashString(opts.task);
|
|
279
|
-
|
|
280
|
-
if (!opts.json) console.log('\n ' + c.mark + c.white(` Proposing root agreement to ${opts.provider}...`));
|
|
281
|
-
const rootTx = await saContract.propose(
|
|
282
|
-
opts.provider, opts.serviceType, opts.task,
|
|
283
|
-
rootPrice, ethers.ZeroAddress, rootDeadline, rootHash,
|
|
284
|
-
{ value: rootPrice },
|
|
285
|
-
);
|
|
286
|
-
const rootReceipt = await rootTx.wait();
|
|
287
|
-
const iface = new ethers.Interface([
|
|
288
|
-
"event AgreementProposed(uint256 indexed id, address indexed client, address indexed provider, string serviceType, uint256 price, address token, uint256 deadline)",
|
|
289
|
-
]);
|
|
290
|
-
let rootAgreementId: bigint | undefined;
|
|
291
|
-
for (const log of rootReceipt.logs) {
|
|
292
|
-
try {
|
|
293
|
-
const parsed = iface.parseLog(log);
|
|
294
|
-
if (parsed?.name === "AgreementProposed") { rootAgreementId = BigInt(parsed.args.id); break; }
|
|
295
|
-
} catch { /* skip */ }
|
|
296
|
-
}
|
|
297
|
-
if (rootAgreementId === undefined) throw new Error("Could not parse root AgreementProposed event");
|
|
298
|
-
|
|
299
|
-
if (!opts.json) console.log(' ' + c.success + c.white(` Root agreement ID: #${rootAgreementId}`));
|
|
300
|
-
|
|
301
|
-
const childAgreementIds: bigint[] = [];
|
|
302
|
-
for (const sub of subSpecs) {
|
|
303
|
-
if (!opts.json) console.log(' ' + c.dim(` Proposing sub-agreement to ${sub.provider}...`));
|
|
304
|
-
const subHash = hashString(sub.task);
|
|
305
|
-
const subTx = await saContract.propose(
|
|
306
|
-
sub.provider, sub.serviceType, sub.task,
|
|
307
|
-
sub.price, ethers.ZeroAddress, sub.deadline, subHash,
|
|
308
|
-
{ value: sub.price },
|
|
309
|
-
);
|
|
310
|
-
const subReceipt = await subTx.wait();
|
|
311
|
-
let childId: bigint | undefined;
|
|
312
|
-
for (const log of subReceipt.logs) {
|
|
313
|
-
try {
|
|
314
|
-
const parsed = iface.parseLog(log);
|
|
315
|
-
if (parsed?.name === "AgreementProposed") { childId = BigInt(parsed.args.id); break; }
|
|
316
|
-
} catch { /* skip */ }
|
|
317
|
-
}
|
|
318
|
-
if (childId === undefined) throw new Error(`Could not parse AgreementProposed for sub-agreement to ${sub.provider}`);
|
|
319
|
-
if (!opts.json) console.log(' ' + c.success + c.white(` Sub-agreement #${childId} — registering in tree...`));
|
|
320
|
-
await (await treeContract.registerSubAgreement(rootAgreementId, childId)).wait();
|
|
321
|
-
childAgreementIds.push(childId);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const result = {
|
|
325
|
-
rootAgreementId: rootAgreementId.toString(),
|
|
326
|
-
childAgreementIds: childAgreementIds.map(String),
|
|
327
|
-
txHash: rootReceipt.hash,
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
if (opts.json) {
|
|
331
|
-
console.log(JSON.stringify(result, null, 2));
|
|
332
|
-
} else {
|
|
333
|
-
console.log('\n ' + c.mark + c.white(' Agreement tree created'));
|
|
334
|
-
renderTree([
|
|
335
|
-
{ label: 'Root', value: `#${result.rootAgreementId}` },
|
|
336
|
-
{
|
|
337
|
-
label: 'Children',
|
|
338
|
-
value: result.childAgreementIds.length > 0
|
|
339
|
-
? result.childAgreementIds.map((id) => "#" + id).join(", ")
|
|
340
|
-
: "(none — sub-agreements can be added with agreements-sub-register)",
|
|
341
|
-
last: true,
|
|
342
|
-
},
|
|
343
|
-
]);
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
// ── arc402 agreements-tree <id> (alias) already exists above ─────────────────
|
|
348
|
-
// The spec also refers to this as "arc402 agreements tree <id>" — the flat
|
|
349
|
-
// command agreements-tree <agreementId> above fulfils that requirement.
|
|
350
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { DisputeArbitrationClient } from "@arc402/sdk";
|
|
3
|
-
import { loadConfig } from "../config.js";
|
|
4
|
-
import { getClient, requireSigner } from "../client.js";
|
|
5
|
-
import { c } from "../ui/colors.js";
|
|
6
|
-
import { startSpinner } from "../ui/spinner.js";
|
|
7
|
-
import { renderTree } from "../ui/tree.js";
|
|
8
|
-
|
|
9
|
-
export function registerArbitratorCommand(program: Command): void {
|
|
10
|
-
const arbitrator = program
|
|
11
|
-
.command("arbitrator")
|
|
12
|
-
.description("Arbitrator panel operations: bonds, eligibility, status");
|
|
13
|
-
|
|
14
|
-
// Bond subcommands — nest under 'bond' to avoid duplicate registration
|
|
15
|
-
const bond = arbitrator
|
|
16
|
-
.command("bond")
|
|
17
|
-
.description("Arbitrator bond operations: status, accept, fallback");
|
|
18
|
-
|
|
19
|
-
bond
|
|
20
|
-
.command("status <arbitratorAddress> [agreementId]")
|
|
21
|
-
.description("Check arbitrator bond status for an agreement (or general eligibility)")
|
|
22
|
-
.action(async (arbitratorAddress, agreementId, _opts) => {
|
|
23
|
-
const config = loadConfig();
|
|
24
|
-
if (!config.disputeArbitrationAddress) throw new Error("disputeArbitrationAddress missing in config");
|
|
25
|
-
const { provider } = await getClient(config);
|
|
26
|
-
const client = new DisputeArbitrationClient(config.disputeArbitrationAddress, provider);
|
|
27
|
-
|
|
28
|
-
const eligible = await client.isEligibleArbitrator(arbitratorAddress);
|
|
29
|
-
console.log('\n ' + c.mark + c.white(' Arbitrator status'));
|
|
30
|
-
renderTree([
|
|
31
|
-
{ label: 'Address', value: arbitratorAddress },
|
|
32
|
-
{ label: 'Eligible', value: eligible ? 'yes' : 'no', last: !agreementId },
|
|
33
|
-
]);
|
|
34
|
-
|
|
35
|
-
if (agreementId) {
|
|
36
|
-
const bondState = await client.getArbitratorBondState(arbitratorAddress, BigInt(agreementId));
|
|
37
|
-
console.log('\n ' + c.mark + c.white(` Bond state — agreement #${agreementId}`));
|
|
38
|
-
renderTree([
|
|
39
|
-
{ label: 'Amount', value: `${bondState.bondAmount.toString()} tokens` },
|
|
40
|
-
{ label: 'Locked', value: String(bondState.locked) },
|
|
41
|
-
{ label: 'Slashed', value: String(bondState.slashed) },
|
|
42
|
-
{ label: 'Returned', value: String(bondState.returned) },
|
|
43
|
-
{ label: 'Locked at', value: new Date(Number(bondState.lockedAt) * 1000).toISOString(), last: true },
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
bond
|
|
49
|
-
.command("accept <agreementId>")
|
|
50
|
-
.description("Accept panel assignment and post bond")
|
|
51
|
-
.option("--bond <bond>", "Bond amount in wei (for ETH agreements)", "0")
|
|
52
|
-
.action(async (agreementId, opts) => {
|
|
53
|
-
const config = loadConfig();
|
|
54
|
-
if (!config.disputeArbitrationAddress) throw new Error("disputeArbitrationAddress missing in config");
|
|
55
|
-
const { signer } = await requireSigner(config);
|
|
56
|
-
const client = new DisputeArbitrationClient(config.disputeArbitrationAddress, signer);
|
|
57
|
-
|
|
58
|
-
const bondAmount = BigInt(opts.bond);
|
|
59
|
-
if (bondAmount === 0n) {
|
|
60
|
-
console.warn(' ' + c.warning + c.white(' Bond amount is 0. For ERC-20 agreements, pre-approve the DisputeArbitration contract.'));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const spinner = startSpinner("Submitting transaction...");
|
|
64
|
-
try {
|
|
65
|
-
await client.acceptAssignment(BigInt(agreementId), bondAmount);
|
|
66
|
-
spinner.succeed();
|
|
67
|
-
} catch (err) {
|
|
68
|
-
spinner.fail();
|
|
69
|
-
throw err;
|
|
70
|
-
}
|
|
71
|
-
console.log(' ' + c.success + c.white(` Assignment accepted — agreement #${agreementId}`));
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
bond
|
|
75
|
-
.command("fallback <agreementId>")
|
|
76
|
-
.description("Trigger fallback to human backstop (mutual unfunded or panel incomplete)")
|
|
77
|
-
.action(async (agreementId, _opts) => {
|
|
78
|
-
const config = loadConfig();
|
|
79
|
-
if (!config.disputeArbitrationAddress) throw new Error("disputeArbitrationAddress missing in config");
|
|
80
|
-
const { signer } = await requireSigner(config);
|
|
81
|
-
const client = new DisputeArbitrationClient(config.disputeArbitrationAddress, signer);
|
|
82
|
-
const spinner = startSpinner("Submitting transaction...");
|
|
83
|
-
try {
|
|
84
|
-
await client.triggerFallback(BigInt(agreementId));
|
|
85
|
-
spinner.succeed();
|
|
86
|
-
} catch (err) {
|
|
87
|
-
spinner.fail();
|
|
88
|
-
throw err;
|
|
89
|
-
}
|
|
90
|
-
console.log(' ' + c.success + c.white(` Fallback triggered — agreement #${agreementId}`));
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Rate subcommands — nest under 'rate'
|
|
94
|
-
const rate = arbitrator
|
|
95
|
-
.command("rate")
|
|
96
|
-
.description("Token USD rate management (owner only)");
|
|
97
|
-
|
|
98
|
-
rate
|
|
99
|
-
.command("set <tokenAddress> <usdPerToken>")
|
|
100
|
-
.description("Set USD rate for a token. Rate in USD with 18 decimals. e.g. 2000e18 for $2000")
|
|
101
|
-
.action(async (tokenAddress, usdPerToken, _opts) => {
|
|
102
|
-
const config = loadConfig();
|
|
103
|
-
if (!config.disputeArbitrationAddress) throw new Error("disputeArbitrationAddress missing in config");
|
|
104
|
-
const { signer } = await requireSigner(config);
|
|
105
|
-
const client = new DisputeArbitrationClient(config.disputeArbitrationAddress, signer);
|
|
106
|
-
|
|
107
|
-
const rateVal = BigInt(usdPerToken);
|
|
108
|
-
const spinner = startSpinner("Submitting transaction...");
|
|
109
|
-
try {
|
|
110
|
-
await client.setTokenUsdRate(tokenAddress, rateVal);
|
|
111
|
-
spinner.succeed();
|
|
112
|
-
} catch (err) {
|
|
113
|
-
spinner.fail();
|
|
114
|
-
throw err;
|
|
115
|
-
}
|
|
116
|
-
console.log(' ' + c.success + c.white(` Token rate set: ${tokenAddress} = ${rateVal.toString()} USD/token`));
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// Admin: slash arbitrator (manual rules violation)
|
|
120
|
-
arbitrator
|
|
121
|
-
.command("slash <agreementId> <arbitratorAddress> <reason>")
|
|
122
|
-
.description("Owner only: manually slash an arbitrator for rules violation")
|
|
123
|
-
.action(async (agreementId, arbitratorAddress, reason, _opts) => {
|
|
124
|
-
const config = loadConfig();
|
|
125
|
-
if (!config.disputeArbitrationAddress) throw new Error("disputeArbitrationAddress missing in config");
|
|
126
|
-
const { signer } = await requireSigner(config);
|
|
127
|
-
const client = new DisputeArbitrationClient(config.disputeArbitrationAddress, signer);
|
|
128
|
-
const spinner = startSpinner("Submitting transaction...");
|
|
129
|
-
try {
|
|
130
|
-
await client.slashArbitrator(BigInt(agreementId), arbitratorAddress, reason);
|
|
131
|
-
spinner.succeed();
|
|
132
|
-
} catch (err) {
|
|
133
|
-
spinner.fail();
|
|
134
|
-
throw err;
|
|
135
|
-
}
|
|
136
|
-
console.log(' ' + c.success + c.white(` Slashed ${arbitratorAddress}`));
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
arbitrator
|
|
140
|
-
.command("reclaim-bond <agreementId>")
|
|
141
|
-
.description("Reclaim an arbitrator bond after 45 days if dispute was never resolved via resolveDisputeFee")
|
|
142
|
-
.action(async (agreementId, _opts) => {
|
|
143
|
-
const config = loadConfig();
|
|
144
|
-
if (!config.disputeArbitrationAddress) throw new Error("disputeArbitrationAddress missing in config");
|
|
145
|
-
const { signer } = await requireSigner(config);
|
|
146
|
-
const client = new DisputeArbitrationClient(config.disputeArbitrationAddress, signer);
|
|
147
|
-
const spinner = startSpinner("Submitting transaction...");
|
|
148
|
-
try {
|
|
149
|
-
await client.reclaimExpiredBond(BigInt(agreementId));
|
|
150
|
-
spinner.succeed();
|
|
151
|
-
} catch (err) {
|
|
152
|
-
spinner.fail();
|
|
153
|
-
throw err;
|
|
154
|
-
}
|
|
155
|
-
console.log(' ' + c.success + c.white(` Bond reclaimed — agreement #${agreementId}`));
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
arbitrator
|
|
159
|
-
.command("resolve-from <agreementId>")
|
|
160
|
-
.description("Resolve a dispute from arbitration with split amounts (calls ServiceAgreement.resolveFromArbitration)")
|
|
161
|
-
.requiredOption("--recipient <address>", "Winning recipient address")
|
|
162
|
-
.requiredOption("--provider-amount <amount>", "Provider payout in wei/tokens")
|
|
163
|
-
.requiredOption("--client-amount <amount>", "Client refund in wei/tokens")
|
|
164
|
-
.action(async (agreementId, opts) => {
|
|
165
|
-
const { ServiceAgreementClient } = await import("@arc402/sdk");
|
|
166
|
-
const config = loadConfig();
|
|
167
|
-
if (!config.serviceAgreementAddress) throw new Error("serviceAgreementAddress missing in config");
|
|
168
|
-
const { signer } = await requireSigner(config);
|
|
169
|
-
const client = new ServiceAgreementClient(config.serviceAgreementAddress, signer);
|
|
170
|
-
const spinner = startSpinner("Submitting transaction...");
|
|
171
|
-
try {
|
|
172
|
-
await client.resolveFromArbitration(BigInt(agreementId), opts.recipient, BigInt(opts.providerAmount), BigInt(opts.clientAmount));
|
|
173
|
-
spinner.succeed();
|
|
174
|
-
} catch (err) {
|
|
175
|
-
spinner.fail();
|
|
176
|
-
throw err;
|
|
177
|
-
}
|
|
178
|
-
console.log(' ' + c.success + c.white(` Resolved from arbitration — agreement #${agreementId}`));
|
|
179
|
-
});
|
|
180
|
-
}
|