@intent-engine/cli 0.1.23 → 0.1.26
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/dist/src/admin-commands.d.ts +12 -0
- package/dist/src/admin-commands.js +140 -0
- package/dist/src/admin-commands.js.map +1 -0
- package/dist/src/agent/actions.d.ts +2 -0
- package/dist/src/agent/actions.js +1 -1
- package/dist/src/agent/actions.js.map +1 -1
- package/dist/src/agent/claims.js +13 -12
- package/dist/src/agent/claims.js.map +1 -1
- package/dist/src/agent/create.d.ts +1 -0
- package/dist/src/agent/create.js +7 -3
- package/dist/src/agent/create.js.map +1 -1
- package/dist/src/agent/mandate-agent.d.ts +2 -0
- package/dist/src/agent/mandate-agent.js +136 -0
- package/dist/src/agent/mandate-agent.js.map +1 -0
- package/dist/src/agent/mandate-grant.d.ts +2 -0
- package/dist/src/agent/mandate-grant.js +192 -0
- package/dist/src/agent/mandate-grant.js.map +1 -0
- package/dist/src/agent/mandate-revoke.d.ts +1 -0
- package/dist/src/agent/mandate-revoke.js +142 -0
- package/dist/src/agent/mandate-revoke.js.map +1 -0
- package/dist/src/agent/mandate-state.d.ts +33 -0
- package/dist/src/agent/mandate-state.js +85 -0
- package/dist/src/agent/mandate-state.js.map +1 -0
- package/dist/src/agent/mandate.d.ts +4 -26
- package/dist/src/agent/mandate.js +4 -479
- package/dist/src/agent/mandate.js.map +1 -1
- package/dist/src/agent/mcp.js +7 -3
- package/dist/src/agent/mcp.js.map +1 -1
- package/dist/src/agent/prepare.js +1 -1
- package/dist/src/agent/prepare.js.map +1 -1
- package/dist/src/agent/problems.d.ts +13 -1
- package/dist/src/agent/problems.js +32 -1
- package/dist/src/agent/problems.js.map +1 -1
- package/dist/src/agent/read.d.ts +12 -0
- package/dist/src/agent/read.js +20 -6
- package/dist/src/agent/read.js.map +1 -1
- package/dist/src/agent/registry.js +6 -1
- package/dist/src/agent/registry.js.map +1 -1
- package/dist/src/agent/relay.d.ts +2 -0
- package/dist/src/agent/relay.js +11 -3
- package/dist/src/agent/relay.js.map +1 -1
- package/dist/src/agent/sales.d.ts +29 -0
- package/dist/src/agent/sales.js +248 -0
- package/dist/src/agent/sales.js.map +1 -0
- package/dist/src/agent/signed-prepare.d.ts +1 -0
- package/dist/src/agent/signed-prepare.js +141 -0
- package/dist/src/agent/signed-prepare.js.map +1 -0
- package/dist/src/agent/signed-relay.d.ts +25 -0
- package/dist/src/agent/signed-relay.js +68 -0
- package/dist/src/agent/signed-relay.js.map +1 -0
- package/dist/src/agent/signed-submit.d.ts +2 -0
- package/dist/src/agent/signed-submit.js +137 -0
- package/dist/src/agent/signed-submit.js.map +1 -0
- package/dist/src/agent/signed-terms.d.ts +85 -0
- package/dist/src/agent/signed-terms.js +84 -0
- package/dist/src/agent/signed-terms.js.map +1 -0
- package/dist/src/agent/signed.d.ts +4 -13
- package/dist/src/agent/signed.js +4 -361
- package/dist/src/agent/signed.js.map +1 -1
- package/dist/src/agent/wallet/account.d.ts +4 -0
- package/dist/src/agent/wallet/account.js +84 -0
- package/dist/src/agent/wallet/account.js.map +1 -0
- package/dist/src/agent/wallet/attest.d.ts +4 -0
- package/dist/src/agent/wallet/attest.js +178 -0
- package/dist/src/agent/wallet/attest.js.map +1 -0
- package/dist/src/agent/wallet/delivery.d.ts +13 -0
- package/dist/src/agent/wallet/delivery.js +171 -0
- package/dist/src/agent/wallet/delivery.js.map +1 -0
- package/dist/src/agent/wallet/escrow.d.ts +7 -0
- package/dist/src/agent/wallet/escrow.js +164 -0
- package/dist/src/agent/wallet/escrow.js.map +1 -0
- package/dist/src/agent/wallet/fills.d.ts +27 -0
- package/dist/src/agent/wallet/fills.js +80 -0
- package/dist/src/agent/wallet/fills.js.map +1 -0
- package/dist/src/agent/wallet/guard.d.ts +57 -0
- package/dist/src/agent/wallet/guard.js +205 -0
- package/dist/src/agent/wallet/guard.js.map +1 -0
- package/dist/src/agent/wallet/offer.d.ts +50 -0
- package/dist/src/agent/wallet/offer.js +80 -0
- package/dist/src/agent/wallet/offer.js.map +1 -0
- package/dist/src/agent/wallet/receipt.d.ts +42 -0
- package/dist/src/agent/wallet/receipt.js +102 -0
- package/dist/src/agent/wallet/receipt.js.map +1 -0
- package/dist/src/agent/wallet/record.d.ts +31 -0
- package/dist/src/agent/wallet/record.js +178 -0
- package/dist/src/agent/wallet/record.js.map +1 -0
- package/dist/src/agent/wallet/releases.d.ts +40 -0
- package/dist/src/agent/wallet/releases.js +236 -0
- package/dist/src/agent/wallet/releases.js.map +1 -0
- package/dist/src/agent/wallet/split.d.ts +10 -0
- package/dist/src/agent/wallet/split.js +271 -0
- package/dist/src/agent/wallet/split.js.map +1 -0
- package/dist/src/agent/wallet/trade.d.ts +14 -0
- package/dist/src/agent/wallet/trade.js +243 -0
- package/dist/src/agent/wallet/trade.js.map +1 -0
- package/dist/src/agent/wallet/wait.d.ts +5 -0
- package/dist/src/agent/wallet/wait.js +99 -0
- package/dist/src/agent/wallet/wait.js.map +1 -0
- package/dist/src/agent/wallet.d.ts +18 -73
- package/dist/src/agent/wallet.js +24 -1322
- package/dist/src/agent/wallet.js.map +1 -1
- package/dist/src/arg-options.d.ts +333 -0
- package/dist/src/arg-options.js +310 -0
- package/dist/src/arg-options.js.map +1 -0
- package/dist/src/arg-usage.d.ts +7 -0
- package/dist/src/arg-usage.js +53 -0
- package/dist/src/arg-usage.js.map +1 -0
- package/dist/src/arg-values.d.ts +47 -0
- package/dist/src/arg-values.js +280 -0
- package/dist/src/arg-values.js.map +1 -0
- package/dist/src/args.d.ts +7 -545
- package/dist/src/args.js +55 -923
- package/dist/src/args.js.map +1 -1
- package/dist/src/artifact.d.ts +22 -0
- package/dist/src/artifact.js +89 -0
- package/dist/src/artifact.js.map +1 -0
- package/dist/src/check-process.d.ts +39 -0
- package/dist/src/check-process.js +338 -0
- package/dist/src/check-process.js.map +1 -0
- package/dist/src/command-builders.d.ts +37 -0
- package/dist/src/command-builders.js +216 -0
- package/dist/src/command-builders.js.map +1 -0
- package/dist/src/command-types.d.ts +227 -0
- package/dist/src/command-types.js +2 -0
- package/dist/src/command-types.js.map +1 -0
- package/dist/src/commands.d.ts +7 -43
- package/dist/src/commands.js +60 -457
- package/dist/src/commands.js.map +1 -1
- package/dist/src/event-feed.d.ts +13 -0
- package/dist/src/event-feed.js +46 -0
- package/dist/src/event-feed.js.map +1 -0
- package/dist/src/flow-commands.d.ts +8 -0
- package/dist/src/flow-commands.js +116 -0
- package/dist/src/flow-commands.js.map +1 -0
- package/dist/src/flows.d.ts +6 -0
- package/dist/src/flows.js +84 -10
- package/dist/src/flows.js.map +1 -1
- package/dist/src/job-commands.d.ts +9 -0
- package/dist/src/job-commands.js +89 -0
- package/dist/src/job-commands.js.map +1 -0
- package/dist/src/judge-errors.d.ts +12 -0
- package/dist/src/judge-errors.js +16 -0
- package/dist/src/judge-errors.js.map +1 -0
- package/dist/src/judge.d.ts +11 -16
- package/dist/src/judge.js +120 -100
- package/dist/src/judge.js.map +1 -1
- package/dist/src/main.d.ts +4 -1
- package/dist/src/main.js +25 -9
- package/dist/src/main.js.map +1 -1
- package/dist/src/order-builders.d.ts +10 -0
- package/dist/src/order-builders.js +172 -0
- package/dist/src/order-builders.js.map +1 -0
- package/dist/src/render.d.ts +1 -0
- package/dist/src/render.js +9 -0
- package/dist/src/render.js.map +1 -1
- package/dist/src/runtime.d.ts +22 -0
- package/dist/src/runtime.js +2 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/solve-commands.d.ts +25 -0
- package/dist/src/solve-commands.js +171 -0
- package/dist/src/solve-commands.js.map +1 -0
- package/dist/src/tokens.js +2 -1
- package/dist/src/tokens.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/wallet.d.ts +4 -1
- package/dist/src/wallet.js +25 -5
- package/dist/src/wallet.js.map +1 -1
- package/package.json +16 -7
- package/dist/src/events.d.ts +0 -8
- package/dist/src/events.js +0 -43
- package/dist/src/events.js.map +0 -1
- package/dist/src/transport.d.ts +0 -208
- package/dist/src/transport.js +0 -441
- package/dist/src/transport.js.map +0 -1
package/dist/src/args.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
|
-
import {
|
|
3
|
-
import { MAX_EXPIRES_IN } from "./agent/create.js";
|
|
4
|
-
import { MANDATE_KIND_NAMES } from "./agent/mandate.js";
|
|
2
|
+
import { AUTO_PRICE_CAP } from "./compute.js";
|
|
5
3
|
import { MAX_SUBMIT_WITHIN } from "./agent/signed.js";
|
|
6
|
-
import { DEVNET_URL
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { DEVNET_URL } from "./tokens.js";
|
|
5
|
+
import { ACCEPTS, OPTIONS } from "./arg-options.js";
|
|
6
|
+
import { addressList, amountOf, https, key, memoUrlOf, mintList, named, noRepeats, noSub, onlyAccepted, optionalField, outputOf, parseAddress, parseBounded, parseFeeBps, parseI64, parseKindFees, parseKinds, parseLimit, parseMaxRent, parsePause, parsePriority, parseSolCost, required, sha256Of, u64, unitsOf, UsageError, } from "./arg-values.js";
|
|
7
|
+
import { agentSpec, authorityOf, configChange, JUDGE_TIMEOUT, market, MAX_JUDGE_TIMEOUT, maxPagesOf, profitFloors, relaySpec, releaseOption, runOf, solveFeeAboveCap, treasury, walletLimits, } from "./command-builders.js";
|
|
8
|
+
import { createTerms, mandate, terms } from "./order-builders.js";
|
|
9
|
+
import { USAGE } from "./arg-usage.js";
|
|
10
|
+
import { DEFAULT_MAX_RENT, DEFAULT_MAX_SOL_COST } from "@intent-engine/solver";
|
|
11
|
+
export { ACCEPTS, GLOBAL_OPTIONS, SUB_ACCEPTS, TOKEN_SIDES } from "./arg-options.js";
|
|
12
|
+
export { COMMANDS, SHAPES, USAGE, usageOf } from "./arg-usage.js";
|
|
13
|
+
export { MAX_EVENT_LIMIT, MAX_RENT_FORMAT, MAX_SOL_COST_FORMAT, outputOf, parseFeeBps, parseI64, parseKinds, parseLimit, parseMaxRent, parsePause, parsePriority, parseSolCost, parseU64, SHA256_NEEDED, UsageError, } from "./arg-values.js";
|
|
14
|
+
export { expiry, MANDATE_USE_KINDS, needsSpecHash, order, SPEC_HASH_FORMAT } from "./order-builders.js";
|
|
15
|
+
export { AGENT_DEFAULT_HOURLY_LAMPORTS, AGENT_NEEDS_OWNERS, ISSUE_ALONE, ISSUE_FORMAT, JUDGE_TIMEOUT, MAX_DELIVERY_PAGES, MAX_JUDGE_TIMEOUT, ONE_MARKET, RELAY_DEFAULT_HOURLY_LAMPORTS, RELAY_DEFAULT_TTL, RELAY_MAX_TTL, RELAY_NEEDS_FEES, RELEASE_NEEDED, RUN_NEEDED, solveFeeAboveCap, TREASURY_CREATE_NEEDS_MINTS, WALLET_LIMITS_NEED_WALLET, zeroProfit, } from "./command-builders.js";
|
|
9
16
|
export const DEFAULT_URL = "http://127.0.0.1:8899";
|
|
10
17
|
export const CLUSTERS = {
|
|
11
18
|
localnet: DEFAULT_URL,
|
|
@@ -18,923 +25,11 @@ export const ENV_KEYPAIR = "INTENT_ENGINE_KEYPAIR";
|
|
|
18
25
|
const SETUP_CLUSTER = "devnet";
|
|
19
26
|
export const WALLET_NOT_MAINNET = "mcp --wallet keeps its key in a file on this machine, so it serves devnet, testnet and localnet only";
|
|
20
27
|
const BALANCE_OF_ONE = "balance takes --keypair or --owner, not both";
|
|
21
|
-
export const GLOBAL_OPTIONS = ["output", "help"];
|
|
22
|
-
export class UsageError extends Error {
|
|
23
|
-
}
|
|
24
|
-
export const RELAY_NEEDS_FEES = "--relayer needs --relay-fee naming every input token it relays as mint=amount; amount may be 0, and other tokens are refused";
|
|
25
|
-
export const AGENT_NEEDS_OWNERS = "--agent needs --agent-owners naming every owner whose mandates this agent key may use";
|
|
26
|
-
export const RELAY_DEFAULT_TTL = 24 * 60 * 60;
|
|
27
|
-
export const RELAY_DEFAULT_HOURLY_LAMPORTS = 100000000n;
|
|
28
|
-
export const AGENT_DEFAULT_HOURLY_LAMPORTS = 50000000n;
|
|
29
|
-
export const RELAY_MAX_TTL = 365 * 24 * 60 * 60;
|
|
30
|
-
const RELAY_DEFAULT_PER_HOUR = 10;
|
|
31
|
-
const RELAY_MIN_TTL = 60;
|
|
32
|
-
export const TOKEN_SIDES = {
|
|
33
|
-
"amount-in": "input",
|
|
34
|
-
make: "input",
|
|
35
|
-
"per-intent": "input",
|
|
36
|
-
total: "input",
|
|
37
|
-
"agent-fee": "input",
|
|
38
|
-
"floor-in": "input",
|
|
39
|
-
"relayer-fee": "input",
|
|
40
|
-
amount: "input",
|
|
41
|
-
"min-out": "output",
|
|
42
|
-
take: "output",
|
|
43
|
-
"start-out": "output",
|
|
44
|
-
"end-out": "output",
|
|
45
|
-
"floor-out": "output",
|
|
46
|
-
};
|
|
47
|
-
const OPTIONS = {
|
|
48
|
-
url: { type: "string" },
|
|
49
|
-
keypair: { type: "string" },
|
|
50
|
-
relayer: { type: "string" },
|
|
51
|
-
agent: { type: "string" },
|
|
52
|
-
wallet: { type: "boolean" },
|
|
53
|
-
"wallet-per-trade": { type: "string" },
|
|
54
|
-
"wallet-per-hour": { type: "string" },
|
|
55
|
-
"relay-max-lamports": { type: "string" },
|
|
56
|
-
"relay-max-ttl": { type: "string" },
|
|
57
|
-
"relay-per-hour": { type: "string" },
|
|
58
|
-
"relay-hourly-lamports": { type: "string" },
|
|
59
|
-
"relay-fee": { type: "string" },
|
|
60
|
-
"priority-fee": { type: "string" },
|
|
61
|
-
authority: { type: "string" },
|
|
62
|
-
"fill-disabled": { type: "string" },
|
|
63
|
-
"new-admin": { type: "string" },
|
|
64
|
-
"agent-hourly-lamports": { type: "string" },
|
|
65
|
-
"agent-owners": { type: "string" },
|
|
66
|
-
owner: { type: "string" },
|
|
67
|
-
nonce: { type: "string" },
|
|
68
|
-
at: { type: "string" },
|
|
69
|
-
base: { type: "string" },
|
|
70
|
-
"input-mint": { type: "string" },
|
|
71
|
-
"output-mint": { type: "string" },
|
|
72
|
-
"expires-at": { type: "string" },
|
|
73
|
-
"amount-in": { type: "string" },
|
|
74
|
-
"min-out": { type: "string" },
|
|
75
|
-
make: { type: "string" },
|
|
76
|
-
take: { type: "string" },
|
|
77
|
-
guardian: { type: "string" },
|
|
78
|
-
"fee-recipient": { type: "string" },
|
|
79
|
-
"fee-bps": { type: "string" },
|
|
80
|
-
kinds: { type: "string" },
|
|
81
|
-
flags: { type: "string" },
|
|
82
|
-
"dry-run": { type: "boolean" },
|
|
83
|
-
yes: { type: "boolean" },
|
|
84
|
-
help: { type: "boolean" },
|
|
85
|
-
version: { type: "boolean" },
|
|
86
|
-
follow: { type: "boolean" },
|
|
87
|
-
watch: { type: "boolean" },
|
|
88
|
-
output: { type: "string" },
|
|
89
|
-
interval: { type: "string" },
|
|
90
|
-
"expires-in": { type: "string" },
|
|
91
|
-
"start-out": { type: "string" },
|
|
92
|
-
"end-out": { type: "string" },
|
|
93
|
-
"start-at": { type: "string" },
|
|
94
|
-
"end-at": { type: "string" },
|
|
95
|
-
"min-result": { type: "string" },
|
|
96
|
-
"max-result": { type: "string" },
|
|
97
|
-
attestor: { type: "string" },
|
|
98
|
-
"per-intent": { type: "string" },
|
|
99
|
-
total: { type: "string" },
|
|
100
|
-
"max-intents": { type: "string" },
|
|
101
|
-
"max-ttl": { type: "string" },
|
|
102
|
-
"valid-for": { type: "string" },
|
|
103
|
-
"floor-out": { type: "string" },
|
|
104
|
-
"floor-in": { type: "string" },
|
|
105
|
-
"agent-fee": { type: "string" },
|
|
106
|
-
id: { type: "string" },
|
|
107
|
-
mint: { type: "string" },
|
|
108
|
-
amount: { type: "string" },
|
|
109
|
-
out: { type: "string" },
|
|
110
|
-
file: { type: "string" },
|
|
111
|
-
"submit-within": { type: "string" },
|
|
112
|
-
"relayer-fee": { type: "string" },
|
|
113
|
-
units: { type: "string" },
|
|
114
|
-
"fund-accounts": { type: "boolean" },
|
|
115
|
-
limit: { type: "string" },
|
|
116
|
-
bounty: { type: "string" },
|
|
117
|
-
"create-fee": { type: "string" },
|
|
118
|
-
"kind-fees": { type: "string" },
|
|
119
|
-
"partner-cut": { type: "string" },
|
|
120
|
-
partner: { type: "string" },
|
|
121
|
-
jupiter: { type: "string" },
|
|
122
|
-
jito: { type: "string" },
|
|
123
|
-
tip: { type: "string" },
|
|
124
|
-
"min-profit": { type: "string" },
|
|
125
|
-
issue: { type: "string" },
|
|
126
|
-
"max-fee-bps": { type: "string" },
|
|
127
|
-
"slippage-bps": { type: "string" },
|
|
128
|
-
"route-program": { type: "string" },
|
|
129
|
-
"lookup-table": { type: "string" },
|
|
130
|
-
solver: { type: "string" },
|
|
131
|
-
"partner-bps": { type: "string" },
|
|
132
|
-
mints: { type: "string" },
|
|
133
|
-
create: { type: "boolean" },
|
|
134
|
-
intent: { type: "string" },
|
|
135
|
-
sha256: { type: "string" },
|
|
136
|
-
"work-url": { type: "string" },
|
|
137
|
-
spec: { type: "string" },
|
|
138
|
-
artifact: { type: "string" },
|
|
139
|
-
run: { type: "string" },
|
|
140
|
-
"pay-to": { type: "string" },
|
|
141
|
-
timeout: { type: "string" },
|
|
142
|
-
verdict: { type: "string" },
|
|
143
|
-
};
|
|
144
|
-
const KIND_NAMES = {
|
|
145
|
-
swap: Kind.SwapExactIn,
|
|
146
|
-
limit: Kind.LimitOrder,
|
|
147
|
-
dutch: Kind.DutchAuction,
|
|
148
|
-
attested: Kind.AttestedResult,
|
|
149
|
-
};
|
|
150
|
-
const PAUSE_NAMES = { none: 0, create: 1, fill: 2, all: 3 };
|
|
151
|
-
export function parseKinds(text) {
|
|
152
|
-
return parseKindSet(text, "kinds", false);
|
|
153
|
-
}
|
|
154
|
-
function parseKindSet(text, key, allowNone) {
|
|
155
|
-
if (allowNone && text === "none") {
|
|
156
|
-
return 0n;
|
|
157
|
-
}
|
|
158
|
-
let mask = 0n;
|
|
159
|
-
for (const name of text.split(",")) {
|
|
160
|
-
const kind = KIND_NAMES[name];
|
|
161
|
-
if (kind === undefined) {
|
|
162
|
-
throw new UsageError(`--${key} takes ${allowNone ? "none or " : ""}a comma list of swap, limit, dutch, attested; got ${name}`);
|
|
163
|
-
}
|
|
164
|
-
mask |= kindBit(kind);
|
|
165
|
-
}
|
|
166
|
-
return mask;
|
|
167
|
-
}
|
|
168
|
-
export function parsePause(text, key) {
|
|
169
|
-
const flags = PAUSE_NAMES[text];
|
|
170
|
-
if (flags === undefined) {
|
|
171
|
-
throw new UsageError(`--${key} must be none, create, fill or all`);
|
|
172
|
-
}
|
|
173
|
-
return flags;
|
|
174
|
-
}
|
|
175
|
-
function parseBounded(text, key, max, min = 0) {
|
|
176
|
-
if (!/^\d+$/.test(text) || BigInt(text) > BigInt(max) || BigInt(text) < BigInt(min)) {
|
|
177
|
-
throw new UsageError(`--${key} must be an integer from ${min} to ${max}`);
|
|
178
|
-
}
|
|
179
|
-
return Number(text);
|
|
180
|
-
}
|
|
181
|
-
function parseKindFees(text) {
|
|
182
|
-
const bps = [0, 0, 0, 0];
|
|
183
|
-
let mask = 0;
|
|
184
|
-
if (text === "") {
|
|
185
|
-
return { mask, bps };
|
|
186
|
-
}
|
|
187
|
-
for (const pair of text.split(",")) {
|
|
188
|
-
const [name, value] = pair.split("=");
|
|
189
|
-
const kind = name === undefined ? undefined : KIND_NAMES[name];
|
|
190
|
-
if (kind === undefined || value === undefined) {
|
|
191
|
-
throw new UsageError(`--kind-fees takes name=bps pairs for swap, limit, dutch, attested; got ${pair}`);
|
|
192
|
-
}
|
|
193
|
-
if ((mask & (1 << kind)) !== 0) {
|
|
194
|
-
throw new UsageError(`--kind-fees names ${name} twice`);
|
|
195
|
-
}
|
|
196
|
-
mask |= 1 << kind;
|
|
197
|
-
bps[kind - 1] = parseBounded(value, "kind-fees", 0xffff);
|
|
198
|
-
}
|
|
199
|
-
return { mask, bps };
|
|
200
|
-
}
|
|
201
|
-
export const MAX_EVENT_LIMIT = 1_000;
|
|
202
|
-
export function parseLimit(text) {
|
|
203
|
-
if (!/^\d+$/.test(text) || Number(text) < 1 || Number(text) > MAX_EVENT_LIMIT) {
|
|
204
|
-
throw new UsageError(`--limit must be an integer from 1 to ${MAX_EVENT_LIMIT}`);
|
|
205
|
-
}
|
|
206
|
-
return Number(text);
|
|
207
|
-
}
|
|
208
|
-
export function parseFeeBps(text) {
|
|
209
|
-
if (!/^\d+$/.test(text) || BigInt(text) > 65535n) {
|
|
210
|
-
throw new UsageError("--fee-bps must be an integer from 0 to 65535");
|
|
211
|
-
}
|
|
212
|
-
return Number(text);
|
|
213
|
-
}
|
|
214
|
-
const EXPIRY = ["expires-at", "expires-in"];
|
|
215
|
-
const ORDER = [
|
|
216
|
-
"amount-in",
|
|
217
|
-
"min-out",
|
|
218
|
-
"make",
|
|
219
|
-
"take",
|
|
220
|
-
"start-out",
|
|
221
|
-
"end-out",
|
|
222
|
-
"start-at",
|
|
223
|
-
"end-at",
|
|
224
|
-
"min-result",
|
|
225
|
-
"max-result",
|
|
226
|
-
"attestor",
|
|
227
|
-
];
|
|
228
|
-
const MANDATE_ORDER = ORDER.filter((o) => o !== "min-result" && o !== "max-result" && o !== "attestor");
|
|
229
|
-
export const MANDATE_USE_KINDS = "a mandate covers swap, limit and dutch orders; name one of those";
|
|
230
|
-
export const ACCEPTS = {
|
|
231
|
-
setup: ["url", "keypair"],
|
|
232
|
-
balance: ["url", "keypair", "owner", "mints"],
|
|
233
|
-
pda: ["owner", "nonce"],
|
|
234
|
-
hash: ["artifact"],
|
|
235
|
-
show: ["url", "owner", "nonce"],
|
|
236
|
-
domain: ["url"],
|
|
237
|
-
mcp: [
|
|
238
|
-
"url",
|
|
239
|
-
"priority-fee",
|
|
240
|
-
"relayer",
|
|
241
|
-
"relay-max-lamports",
|
|
242
|
-
"relay-max-ttl",
|
|
243
|
-
"relay-per-hour",
|
|
244
|
-
"relay-hourly-lamports",
|
|
245
|
-
"relay-fee",
|
|
246
|
-
"agent",
|
|
247
|
-
"agent-hourly-lamports",
|
|
248
|
-
"agent-owners",
|
|
249
|
-
"wallet",
|
|
250
|
-
"wallet-per-trade",
|
|
251
|
-
"wallet-per-hour",
|
|
252
|
-
],
|
|
253
|
-
quote: ["url", "owner", "nonce", "at"],
|
|
254
|
-
cancel: ["url", "priority-fee", "keypair", "nonce"],
|
|
255
|
-
expire: ["url", "priority-fee", "keypair", "owner", "nonce"],
|
|
256
|
-
close: ["url", "priority-fee", "keypair", "owner", "nonce"],
|
|
257
|
-
"advance-nonce": ["url", "priority-fee", "keypair", "base"],
|
|
258
|
-
"advance-epoch": ["url", "priority-fee", "keypair"],
|
|
259
|
-
"init-config": ["url", "priority-fee", "keypair", "authority", "yes", "guardian", "fee-recipient", "fee-bps", "kinds", "flags"],
|
|
260
|
-
"raise-pause": ["url", "priority-fee", "keypair", "authority", "yes", "flags"],
|
|
261
|
-
"set-economics": ["url", "priority-fee", "keypair", "authority", "yes", "bounty", "create-fee", "kind-fees", "partner-cut"],
|
|
262
|
-
"update-config": [
|
|
263
|
-
"url",
|
|
264
|
-
"priority-fee",
|
|
265
|
-
"keypair",
|
|
266
|
-
"authority",
|
|
267
|
-
"yes",
|
|
268
|
-
"guardian",
|
|
269
|
-
"fee-recipient",
|
|
270
|
-
"fee-bps",
|
|
271
|
-
"kinds",
|
|
272
|
-
"fill-disabled",
|
|
273
|
-
],
|
|
274
|
-
"propose-admin": ["url", "priority-fee", "keypair", "authority", "yes", "new-admin"],
|
|
275
|
-
"accept-admin": ["url", "priority-fee", "keypair", "authority", "yes"],
|
|
276
|
-
solve: ["url", "priority-fee", "keypair", "jupiter", "issue", "jito", "tip", "min-profit", "max-fee-bps", "slippage-bps", "route-program", "lookup-table", "watch", "interval"],
|
|
277
|
-
"solver-table": ["url", "solver", "mints"],
|
|
278
|
-
"lower-pause": ["url", "priority-fee", "keypair", "authority", "yes", "flags"],
|
|
279
|
-
events: ["url", "limit", "follow", "interval"],
|
|
280
|
-
jobs: ["url", "attestor"],
|
|
281
|
-
deliver: ["url", "priority-fee", "keypair", "yes", "intent", "sha256", "work-url"],
|
|
282
|
-
deliveries: ["url", "attestor", "intent"],
|
|
283
|
-
judge: ["url", "priority-fee", "keypair", "yes", "owner", "nonce", "spec", "artifact", "run", "pay-to", "timeout", "verdict"],
|
|
284
|
-
crank: ["url", "priority-fee", "keypair", "dry-run", "fund-accounts"],
|
|
285
|
-
treasury: ["url", "priority-fee", "keypair", "yes", "mints", "create"],
|
|
286
|
-
create: [
|
|
287
|
-
"url",
|
|
288
|
-
"priority-fee",
|
|
289
|
-
"keypair",
|
|
290
|
-
"yes",
|
|
291
|
-
"nonce",
|
|
292
|
-
"input-mint",
|
|
293
|
-
"output-mint",
|
|
294
|
-
...EXPIRY,
|
|
295
|
-
...ORDER,
|
|
296
|
-
"partner",
|
|
297
|
-
"partner-bps",
|
|
298
|
-
"units",
|
|
299
|
-
],
|
|
300
|
-
list: ["url", "keypair", "owner"],
|
|
301
|
-
mandate: [
|
|
302
|
-
"url",
|
|
303
|
-
"priority-fee",
|
|
304
|
-
"keypair",
|
|
305
|
-
"yes",
|
|
306
|
-
"owner",
|
|
307
|
-
"agent",
|
|
308
|
-
"id",
|
|
309
|
-
"input-mint",
|
|
310
|
-
"output-mint",
|
|
311
|
-
"kinds",
|
|
312
|
-
"per-intent",
|
|
313
|
-
"total",
|
|
314
|
-
"max-intents",
|
|
315
|
-
"max-ttl",
|
|
316
|
-
"valid-for",
|
|
317
|
-
"floor-out",
|
|
318
|
-
"floor-in",
|
|
319
|
-
"partner",
|
|
320
|
-
"partner-bps",
|
|
321
|
-
"agent-fee",
|
|
322
|
-
"nonce",
|
|
323
|
-
...EXPIRY,
|
|
324
|
-
...ORDER,
|
|
325
|
-
"units",
|
|
326
|
-
],
|
|
327
|
-
approve: ["url", "priority-fee", "keypair", "yes", "mint", "amount", "units"],
|
|
328
|
-
"revoke-approval": ["url", "priority-fee", "keypair", "yes", "mint"],
|
|
329
|
-
signed: [
|
|
330
|
-
"url",
|
|
331
|
-
"keypair",
|
|
332
|
-
"yes",
|
|
333
|
-
"out",
|
|
334
|
-
"file",
|
|
335
|
-
"nonce",
|
|
336
|
-
"input-mint",
|
|
337
|
-
"output-mint",
|
|
338
|
-
"submit-within",
|
|
339
|
-
"relayer-fee",
|
|
340
|
-
...EXPIRY,
|
|
341
|
-
...ORDER,
|
|
342
|
-
"partner",
|
|
343
|
-
"partner-bps",
|
|
344
|
-
"units",
|
|
345
|
-
],
|
|
346
|
-
};
|
|
347
|
-
export const SUB_ACCEPTS = {
|
|
348
|
-
mandate: {
|
|
349
|
-
grant: [
|
|
350
|
-
"url",
|
|
351
|
-
"priority-fee",
|
|
352
|
-
"keypair",
|
|
353
|
-
"yes",
|
|
354
|
-
"agent",
|
|
355
|
-
"id",
|
|
356
|
-
"input-mint",
|
|
357
|
-
"output-mint",
|
|
358
|
-
"kinds",
|
|
359
|
-
"per-intent",
|
|
360
|
-
"total",
|
|
361
|
-
"max-intents",
|
|
362
|
-
"max-ttl",
|
|
363
|
-
"valid-for",
|
|
364
|
-
"floor-out",
|
|
365
|
-
"floor-in",
|
|
366
|
-
"partner",
|
|
367
|
-
"partner-bps",
|
|
368
|
-
"agent-fee",
|
|
369
|
-
"units",
|
|
370
|
-
],
|
|
371
|
-
show: ["url", "keypair", "agent", "id", "owner"],
|
|
372
|
-
revoke: ["url", "priority-fee", "keypair", "yes", "agent", "id"],
|
|
373
|
-
use: ["url", "priority-fee", "keypair", "yes", "owner", "id", "nonce", ...EXPIRY, ...MANDATE_ORDER, "units"],
|
|
374
|
-
},
|
|
375
|
-
signed: {
|
|
376
|
-
prepare: [
|
|
377
|
-
"url",
|
|
378
|
-
"keypair",
|
|
379
|
-
"yes",
|
|
380
|
-
"out",
|
|
381
|
-
"nonce",
|
|
382
|
-
"input-mint",
|
|
383
|
-
"output-mint",
|
|
384
|
-
"submit-within",
|
|
385
|
-
"relayer-fee",
|
|
386
|
-
...EXPIRY,
|
|
387
|
-
...ORDER,
|
|
388
|
-
"partner",
|
|
389
|
-
"partner-bps",
|
|
390
|
-
"units",
|
|
391
|
-
],
|
|
392
|
-
submit: ["url", "keypair", "yes", "file"],
|
|
393
|
-
},
|
|
394
|
-
};
|
|
395
|
-
function noRepeats(argv) {
|
|
396
|
-
const seen = new Set();
|
|
397
|
-
for (const arg of argv) {
|
|
398
|
-
if (arg === "--") {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
if (!arg.startsWith("--")) {
|
|
402
|
-
continue;
|
|
403
|
-
}
|
|
404
|
-
const name = arg.slice(2).split("=")[0] ?? "";
|
|
405
|
-
if (seen.has(name)) {
|
|
406
|
-
throw new UsageError(`--${name} is given more than once`);
|
|
407
|
-
}
|
|
408
|
-
seen.add(name);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
function onlyAccepted(verb, sub, values) {
|
|
412
|
-
const accepted = verb === undefined ? undefined : (SUB_ACCEPTS[verb]?.[sub ?? ""] ?? ACCEPTS[verb]);
|
|
413
|
-
const named = verb !== undefined && SUB_ACCEPTS[verb]?.[sub ?? ""] !== undefined ? `${verb} ${sub}` : verb;
|
|
414
|
-
if (accepted === undefined) {
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
for (const [key, value] of Object.entries(values)) {
|
|
418
|
-
if (value !== undefined &&
|
|
419
|
-
!accepted.includes(key) &&
|
|
420
|
-
!GLOBAL_OPTIONS.includes(key)) {
|
|
421
|
-
throw new UsageError(`${named} does not take --${key}`);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
function required(values, key) {
|
|
426
|
-
const value = values[key];
|
|
427
|
-
if (value === undefined) {
|
|
428
|
-
throw new UsageError(`missing --${key}`);
|
|
429
|
-
}
|
|
430
|
-
return value;
|
|
431
|
-
}
|
|
432
|
-
export function parseU64(text, key) {
|
|
433
|
-
if (!/^\d+$/.test(text) || BigInt(text) > U64_MAX) {
|
|
434
|
-
throw new UsageError(`--${key} must be an integer from 0 to ${U64_MAX}`);
|
|
435
|
-
}
|
|
436
|
-
return BigInt(text);
|
|
437
|
-
}
|
|
438
|
-
export function parseI64(text, key) {
|
|
439
|
-
if (!/^-?\d+$/.test(text) || BigInt(text) < I64_MIN || BigInt(text) > I64_MAX) {
|
|
440
|
-
throw new UsageError(`--${key} must be an integer from ${I64_MIN} to ${I64_MAX}`);
|
|
441
|
-
}
|
|
442
|
-
return BigInt(text);
|
|
443
|
-
}
|
|
444
|
-
function parseAddress(text, key) {
|
|
445
|
-
try {
|
|
446
|
-
return address(text);
|
|
447
|
-
}
|
|
448
|
-
catch {
|
|
449
|
-
throw new UsageError(`--${key} is not a base58 address`);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
const u64 = (values, key) => parseU64(required(values, key), key);
|
|
453
|
-
const key = (values, name) => parseAddress(required(values, name), name);
|
|
454
|
-
function amountOf(values, name) {
|
|
455
|
-
const side = TOKEN_SIDES[name];
|
|
456
|
-
if (values.units === "raw" || side === undefined) {
|
|
457
|
-
return u64(values, name).toString();
|
|
458
|
-
}
|
|
459
|
-
const text = required(values, name);
|
|
460
|
-
if (!TOKEN_AMOUNT_PATTERN.test(text)) {
|
|
461
|
-
throw new UsageError(`--${name} must be a token amount like 12 or 0.5`);
|
|
462
|
-
}
|
|
463
|
-
return { tokens: text, side };
|
|
464
|
-
}
|
|
465
|
-
function unitsOf(values) {
|
|
466
|
-
if (values.units !== undefined && values.units !== "raw" && values.units !== "tokens") {
|
|
467
|
-
throw new UsageError("--units must be raw or tokens");
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
const timeOf = (values, name) => parseI64(required(values, name), name).toString();
|
|
471
|
-
const ORDER_FIELDS = {
|
|
472
|
-
swap: ["amount-in", "min-out"],
|
|
473
|
-
limit: ["make", "take"],
|
|
474
|
-
dutch: ["amount-in", "start-out", "end-out", "start-at", "end-at"],
|
|
475
|
-
attested: ["amount-in", "min-result", "max-result", "attestor"],
|
|
476
|
-
};
|
|
477
|
-
export function order(kind, values) {
|
|
478
|
-
const fields = kind === undefined ? undefined : ORDER_FIELDS[kind];
|
|
479
|
-
if (fields === undefined) {
|
|
480
|
-
throw new UsageError("name the order kind: swap, limit, dutch or attested");
|
|
481
|
-
}
|
|
482
|
-
for (const name of ORDER) {
|
|
483
|
-
if (values[name] !== undefined && !fields.includes(name)) {
|
|
484
|
-
throw new UsageError(`a ${kind} order does not take --${name}`);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
switch (kind) {
|
|
488
|
-
case "swap":
|
|
489
|
-
return { kind, amount_in: amountOf(values, "amount-in"), min_out: amountOf(values, "min-out") };
|
|
490
|
-
case "limit":
|
|
491
|
-
return { kind, make_amount: amountOf(values, "make"), take_amount: amountOf(values, "take") };
|
|
492
|
-
case "dutch":
|
|
493
|
-
return {
|
|
494
|
-
kind,
|
|
495
|
-
amount_in: amountOf(values, "amount-in"),
|
|
496
|
-
start_out: amountOf(values, "start-out"),
|
|
497
|
-
end_out: amountOf(values, "end-out"),
|
|
498
|
-
start_time: timeOf(values, "start-at"),
|
|
499
|
-
end_time: timeOf(values, "end-at"),
|
|
500
|
-
};
|
|
501
|
-
default:
|
|
502
|
-
return {
|
|
503
|
-
kind,
|
|
504
|
-
amount_in: amountOf(values, "amount-in"),
|
|
505
|
-
min_result: amountOf(values, "min-result"),
|
|
506
|
-
max_result: amountOf(values, "max-result"),
|
|
507
|
-
attestor: key(values, "attestor"),
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
export function expiry(values) {
|
|
512
|
-
if ((values["expires-at"] === undefined) === (values["expires-in"] === undefined)) {
|
|
513
|
-
throw new UsageError("give exactly one of --expires-at or --expires-in");
|
|
514
|
-
}
|
|
515
|
-
return values["expires-at"] === undefined
|
|
516
|
-
? { expires_in: parseBounded(required(values, "expires-in"), "expires-in", MAX_EXPIRES_IN) }
|
|
517
|
-
: { expires_at: timeOf(values, "expires-at") };
|
|
518
|
-
}
|
|
519
|
-
function partner(values) {
|
|
520
|
-
if (values.partner === undefined && values["partner-bps"] === undefined) {
|
|
521
|
-
return {};
|
|
522
|
-
}
|
|
523
|
-
return {
|
|
524
|
-
partner: {
|
|
525
|
-
account: key(values, "partner"),
|
|
526
|
-
bps: parseBounded(required(values, "partner-bps"), "partner-bps", MAX_PARTNER_BPS),
|
|
527
|
-
},
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
const optionalField = (values, name, field, read) => values[name] === undefined ? {} : { [field]: read(values, name) };
|
|
531
|
-
function terms(kind, values) {
|
|
532
|
-
return {
|
|
533
|
-
input_mint: key(values, "input-mint"),
|
|
534
|
-
output_mint: key(values, "output-mint"),
|
|
535
|
-
order: order(kind, values),
|
|
536
|
-
...expiry(values),
|
|
537
|
-
...optionalField(values, "nonce", "nonce", amountOf),
|
|
538
|
-
...partner(values),
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
function grant(values) {
|
|
542
|
-
const kinds = required(values, "kinds").split(",");
|
|
543
|
-
for (const name of kinds) {
|
|
544
|
-
if (!MANDATE_KIND_NAMES.includes(name)) {
|
|
545
|
-
throw new UsageError(`--kinds takes a comma list of swap, limit, dutch; got ${name}`);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return {
|
|
549
|
-
agent: key(values, "agent"),
|
|
550
|
-
input_mint: key(values, "input-mint"),
|
|
551
|
-
output_mint: key(values, "output-mint"),
|
|
552
|
-
kinds,
|
|
553
|
-
per_intent: amountOf(values, "per-intent"),
|
|
554
|
-
total: amountOf(values, "total"),
|
|
555
|
-
max_intents: parseBounded(required(values, "max-intents"), "max-intents", 0xffff_ffff),
|
|
556
|
-
max_ttl: parseBounded(required(values, "max-ttl"), "max-ttl", MAX_EXPIRES_IN),
|
|
557
|
-
valid_for: parseBounded(required(values, "valid-for"), "valid-for", MAX_EXPIRES_IN),
|
|
558
|
-
floor: { out: amountOf(values, "floor-out"), in: amountOf(values, "floor-in") },
|
|
559
|
-
...optionalField(values, "id", "id", amountOf),
|
|
560
|
-
...partner(values),
|
|
561
|
-
...optionalField(values, "agent-fee", "agent_fee", amountOf),
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
function mandate(sub, kind, remote, values) {
|
|
565
|
-
const flow = (name, input) => ({
|
|
566
|
-
name: "flow",
|
|
567
|
-
...remote,
|
|
568
|
-
flow: name,
|
|
569
|
-
keypair: required(values, "keypair"),
|
|
570
|
-
yes: values.yes === true,
|
|
571
|
-
input,
|
|
572
|
-
});
|
|
573
|
-
const ref = () => ({ agent: key(values, "agent"), ...optionalField(values, "id", "id", amountOf) });
|
|
574
|
-
if (sub !== "use") {
|
|
575
|
-
noSub(kind);
|
|
576
|
-
}
|
|
577
|
-
switch (sub) {
|
|
578
|
-
case "grant":
|
|
579
|
-
return flow("mandate-grant", grant(values));
|
|
580
|
-
case "revoke":
|
|
581
|
-
return flow("mandate-revoke", ref());
|
|
582
|
-
case "show":
|
|
583
|
-
return {
|
|
584
|
-
name: "lookup",
|
|
585
|
-
...remote,
|
|
586
|
-
lookup: "mandate-show",
|
|
587
|
-
keypair: values.keypair,
|
|
588
|
-
input: { ...ref(), ...optionalField(values, "owner", "owner", key) },
|
|
589
|
-
};
|
|
590
|
-
case "use":
|
|
591
|
-
if (kind === "attested") {
|
|
592
|
-
throw new UsageError(MANDATE_USE_KINDS);
|
|
593
|
-
}
|
|
594
|
-
return flow("mandate-use", {
|
|
595
|
-
owner: key(values, "owner"),
|
|
596
|
-
order: order(kind, values),
|
|
597
|
-
...expiry(values),
|
|
598
|
-
...optionalField(values, "id", "id", amountOf),
|
|
599
|
-
...optionalField(values, "nonce", "nonce", amountOf),
|
|
600
|
-
});
|
|
601
|
-
default:
|
|
602
|
-
throw new UsageError("mandate needs grant, show, revoke or use");
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
function https(text, key) {
|
|
606
|
-
let parsed;
|
|
607
|
-
try {
|
|
608
|
-
parsed = new URL(text);
|
|
609
|
-
}
|
|
610
|
-
catch {
|
|
611
|
-
throw new UsageError(`--${key} is not a url`);
|
|
612
|
-
}
|
|
613
|
-
if (parsed.protocol !== "https:") {
|
|
614
|
-
throw new UsageError(`--${key} must be an https url`);
|
|
615
|
-
}
|
|
616
|
-
return text.replace(/\/+$/, "");
|
|
617
|
-
}
|
|
618
|
-
function relaySpec(values) {
|
|
619
|
-
const policy = [
|
|
620
|
-
values["relay-max-lamports"],
|
|
621
|
-
values["relay-max-ttl"],
|
|
622
|
-
values["relay-per-hour"],
|
|
623
|
-
values["relay-hourly-lamports"],
|
|
624
|
-
values["relay-fee"],
|
|
625
|
-
];
|
|
626
|
-
if (values.relayer === undefined) {
|
|
627
|
-
if (policy.some((v) => v !== undefined)) {
|
|
628
|
-
throw new UsageError("the --relay-* limits need --relayer");
|
|
629
|
-
}
|
|
630
|
-
return undefined;
|
|
631
|
-
}
|
|
632
|
-
if (values["relay-fee"] === undefined) {
|
|
633
|
-
throw new UsageError(RELAY_NEEDS_FEES);
|
|
634
|
-
}
|
|
635
|
-
const maxTtl = parseBounded(values["relay-max-ttl"] ?? String(RELAY_DEFAULT_TTL), "relay-max-ttl", RELAY_MAX_TTL);
|
|
636
|
-
const perHour = parseBounded(values["relay-per-hour"] ?? String(RELAY_DEFAULT_PER_HOUR), "relay-per-hour", 3_600);
|
|
637
|
-
if (maxTtl < RELAY_MIN_TTL || perHour < 1) {
|
|
638
|
-
throw new UsageError(`--relay-max-ttl must be at least ${RELAY_MIN_TTL} and --relay-per-hour at least 1`);
|
|
639
|
-
}
|
|
640
|
-
return {
|
|
641
|
-
keypair: values.relayer,
|
|
642
|
-
maxLamports: values["relay-max-lamports"] === undefined ? 0n : u64(values, "relay-max-lamports"),
|
|
643
|
-
maxTtl: BigInt(maxTtl),
|
|
644
|
-
perHour,
|
|
645
|
-
hourlyLamports: values["relay-hourly-lamports"] === undefined
|
|
646
|
-
? RELAY_DEFAULT_HOURLY_LAMPORTS
|
|
647
|
-
: u64(values, "relay-hourly-lamports"),
|
|
648
|
-
fees: mintAmounts(values["relay-fee"], "relay-fee"),
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
function mintAmounts(text, name) {
|
|
652
|
-
const amounts = new Map();
|
|
653
|
-
for (const entry of text === undefined ? [] : text.split(",")) {
|
|
654
|
-
const [mint, amount, ...rest] = entry.split("=");
|
|
655
|
-
if (mint === undefined || amount === undefined || rest.length > 0) {
|
|
656
|
-
throw new UsageError(`--${name} takes mint=amount pairs separated by commas`);
|
|
657
|
-
}
|
|
658
|
-
const key = parseAddress(mint.trim(), name);
|
|
659
|
-
if (amounts.has(key)) {
|
|
660
|
-
throw new UsageError(`--${name} names ${key} twice`);
|
|
661
|
-
}
|
|
662
|
-
amounts.set(key, parseU64(amount.trim(), name));
|
|
663
|
-
}
|
|
664
|
-
return amounts;
|
|
665
|
-
}
|
|
666
|
-
export const WALLET_LIMITS_NEED_WALLET = "--wallet-per-trade and --wallet-per-hour need --wallet";
|
|
667
|
-
const wholeTokens = (key) => `--${key} takes token=amount pairs separated by commas, such as SOL=0.1,TEST=20`;
|
|
668
|
-
function tokenAmounts(text, key, url) {
|
|
669
|
-
const amounts = new Map();
|
|
670
|
-
for (const entry of text === undefined ? [] : text.split(",")) {
|
|
671
|
-
const [name, amount, ...rest] = entry.split("=");
|
|
672
|
-
if (name === undefined || amount === undefined || rest.length > 0 || !TOKEN_AMOUNT_PATTERN.test(amount.trim())) {
|
|
673
|
-
throw new UsageError(wholeTokens(key));
|
|
674
|
-
}
|
|
675
|
-
const mint = tokenNamed(name.trim(), url);
|
|
676
|
-
if (mint instanceof Error) {
|
|
677
|
-
throw new UsageError(`--${key}: ${mint.message}`);
|
|
678
|
-
}
|
|
679
|
-
const parsed = parseAddress(mint, key);
|
|
680
|
-
if (amounts.has(parsed)) {
|
|
681
|
-
throw new UsageError(`--${key} names ${name.trim()} twice`);
|
|
682
|
-
}
|
|
683
|
-
amounts.set(parsed, amount.trim());
|
|
684
|
-
}
|
|
685
|
-
return amounts;
|
|
686
|
-
}
|
|
687
|
-
function walletLimits(values, url) {
|
|
688
|
-
if (values.wallet !== true) {
|
|
689
|
-
if (values["wallet-per-trade"] !== undefined || values["wallet-per-hour"] !== undefined) {
|
|
690
|
-
throw new UsageError(WALLET_LIMITS_NEED_WALLET);
|
|
691
|
-
}
|
|
692
|
-
return null;
|
|
693
|
-
}
|
|
694
|
-
return {
|
|
695
|
-
perTrade: tokenAmounts(values["wallet-per-trade"], "wallet-per-trade", url),
|
|
696
|
-
perHour: tokenAmounts(values["wallet-per-hour"], "wallet-per-hour", url),
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
function agentSpec(values) {
|
|
700
|
-
if (values.agent === undefined) {
|
|
701
|
-
if (values["agent-hourly-lamports"] !== undefined || values["agent-owners"] !== undefined) {
|
|
702
|
-
throw new UsageError("the --agent-* limits need --agent");
|
|
703
|
-
}
|
|
704
|
-
return undefined;
|
|
705
|
-
}
|
|
706
|
-
const owners = values["agent-owners"];
|
|
707
|
-
if (owners === undefined) {
|
|
708
|
-
throw new UsageError(AGENT_NEEDS_OWNERS);
|
|
709
|
-
}
|
|
710
|
-
return {
|
|
711
|
-
keypair: values.agent,
|
|
712
|
-
hourlyLamports: values["agent-hourly-lamports"] === undefined
|
|
713
|
-
? AGENT_DEFAULT_HOURLY_LAMPORTS
|
|
714
|
-
: u64(values, "agent-hourly-lamports"),
|
|
715
|
-
owners: owners.split(",").map((o) => parseAddress(o.trim(), "agent-owners")),
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
export function parsePriority(text) {
|
|
719
|
-
if (text === undefined) {
|
|
720
|
-
return 0n;
|
|
721
|
-
}
|
|
722
|
-
if (text === "auto") {
|
|
723
|
-
return "auto";
|
|
724
|
-
}
|
|
725
|
-
const price = parseU64(text, "priority-fee");
|
|
726
|
-
if (price > MAX_PRIORITY_PRICE) {
|
|
727
|
-
throw new UsageError(`--priority-fee is micro-lamports per compute unit and at most ${MAX_PRIORITY_PRICE}; use auto for the recent market price`);
|
|
728
|
-
}
|
|
729
|
-
return price;
|
|
730
|
-
}
|
|
731
|
-
function authorityOf(values) {
|
|
732
|
-
if (values.keypair !== undefined && values.authority !== undefined) {
|
|
733
|
-
throw new UsageError("pass --keypair to sign and send, or --authority to print an unsigned transaction, not both");
|
|
734
|
-
}
|
|
735
|
-
if (values.authority !== undefined) {
|
|
736
|
-
if (values.yes === true) {
|
|
737
|
-
throw new UsageError("--yes signs and sends with --keypair; --authority only prints an unsigned transaction");
|
|
738
|
-
}
|
|
739
|
-
return { authority: key(values, "authority") };
|
|
740
|
-
}
|
|
741
|
-
return { keypair: required(values, "keypair"), yes: values.yes === true };
|
|
742
|
-
}
|
|
743
|
-
function configChange(values) {
|
|
744
|
-
const change = {
|
|
745
|
-
guardian: values.guardian === undefined ? undefined : key(values, "guardian"),
|
|
746
|
-
feeRecipient: values["fee-recipient"] === undefined ? undefined : key(values, "fee-recipient"),
|
|
747
|
-
feeBps: values["fee-bps"] === undefined ? undefined : parseFeeBps(values["fee-bps"]),
|
|
748
|
-
enabledKinds: values.kinds === undefined ? undefined : parseKinds(values.kinds),
|
|
749
|
-
fillDisabledKinds: values["fill-disabled"] === undefined ? undefined : parseKindSet(values["fill-disabled"], "fill-disabled", true),
|
|
750
|
-
};
|
|
751
|
-
if (Object.values(change).every((v) => v === undefined)) {
|
|
752
|
-
throw new UsageError("update-config needs at least one of --guardian, --fee-recipient, --fee-bps, --kinds, --fill-disabled");
|
|
753
|
-
}
|
|
754
|
-
return change;
|
|
755
|
-
}
|
|
756
|
-
const MINT_KEYS = ["input-mint", "output-mint", "mint"];
|
|
757
|
-
function resolved(text, url) {
|
|
758
|
-
const mint = tokenNamed(text, url);
|
|
759
|
-
if (mint instanceof Error) {
|
|
760
|
-
throw new UsageError(mint.message);
|
|
761
|
-
}
|
|
762
|
-
return mint;
|
|
763
|
-
}
|
|
764
|
-
function named(values, url) {
|
|
765
|
-
for (const name of MINT_KEYS) {
|
|
766
|
-
const text = values[name];
|
|
767
|
-
if (text !== undefined) {
|
|
768
|
-
values[name] = resolved(text, url);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
if (values.mints !== undefined) {
|
|
772
|
-
values.mints = values.mints
|
|
773
|
-
.split(",")
|
|
774
|
-
.map((m) => resolved(m.trim(), url))
|
|
775
|
-
.join(",");
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
function mintList(text) {
|
|
779
|
-
return addressList(text, "mints");
|
|
780
|
-
}
|
|
781
|
-
export const ISSUE_FORMAT = "--issue takes <input mint>:<output mint>=<out>/<in> entries separated by commas";
|
|
782
|
-
export const ONE_MARKET = "solve needs exactly one of --jupiter or --issue";
|
|
783
|
-
export const ISSUE_ALONE = "--issue mints the output itself, so --slippage-bps and --route-program do not apply";
|
|
784
|
-
function issues(text) {
|
|
785
|
-
const routes = [];
|
|
786
|
-
for (const entry of text.split(",")) {
|
|
787
|
-
const match = /^([^:=/]+):([^:=/]+)=([^:=/]+)\/([^:=/]+)$/.exec(entry.trim());
|
|
788
|
-
if (match === null) {
|
|
789
|
-
throw new UsageError(ISSUE_FORMAT);
|
|
790
|
-
}
|
|
791
|
-
const [, input = "", output = "", out = "", per = ""] = match;
|
|
792
|
-
const route = {
|
|
793
|
-
inputMint: parseAddress(input.trim(), "issue"),
|
|
794
|
-
outputMint: parseAddress(output.trim(), "issue"),
|
|
795
|
-
out: parseU64(out.trim(), "issue"),
|
|
796
|
-
in: parseU64(per.trim(), "issue"),
|
|
797
|
-
};
|
|
798
|
-
if (route.out === 0n || route.in === 0n) {
|
|
799
|
-
throw new UsageError("--issue rates must be positive on both sides");
|
|
800
|
-
}
|
|
801
|
-
if (routes.some((r) => r.inputMint === route.inputMint && r.outputMint === route.outputMint)) {
|
|
802
|
-
throw new UsageError(`--issue names ${route.inputMint}:${route.outputMint} twice`);
|
|
803
|
-
}
|
|
804
|
-
routes.push(route);
|
|
805
|
-
}
|
|
806
|
-
return routes;
|
|
807
|
-
}
|
|
808
|
-
function market(values) {
|
|
809
|
-
if ((values.jupiter === undefined) === (values.issue === undefined)) {
|
|
810
|
-
throw new UsageError(ONE_MARKET);
|
|
811
|
-
}
|
|
812
|
-
if (values.issue === undefined) {
|
|
813
|
-
return { jupiter: https(required(values, "jupiter"), "jupiter"), issue: [] };
|
|
814
|
-
}
|
|
815
|
-
if (values["slippage-bps"] !== undefined || values["route-program"] !== undefined) {
|
|
816
|
-
throw new UsageError(ISSUE_ALONE);
|
|
817
|
-
}
|
|
818
|
-
return { jupiter: undefined, issue: issues(values.issue) };
|
|
819
|
-
}
|
|
820
|
-
function addressList(text, name) {
|
|
821
|
-
const items = [...new Set(text.split(",").map((m) => m.trim()))];
|
|
822
|
-
if (items.some((m) => m === "")) {
|
|
823
|
-
throw new UsageError(`--${name} takes a comma list of addresses`);
|
|
824
|
-
}
|
|
825
|
-
return items.map((m) => parseAddress(m, name));
|
|
826
|
-
}
|
|
827
|
-
export const TREASURY_CREATE_NEEDS_MINTS = "--create needs --mints naming the tokens to open treasury accounts for; anyone can open intents in any token, so the list must be yours";
|
|
828
|
-
function treasury(remote, values) {
|
|
829
|
-
const create = values.create === true;
|
|
830
|
-
if (values.yes === true && !create) {
|
|
831
|
-
throw new UsageError("--yes only applies with --create");
|
|
832
|
-
}
|
|
833
|
-
if (create && values.mints === undefined) {
|
|
834
|
-
throw new UsageError(TREASURY_CREATE_NEEDS_MINTS);
|
|
835
|
-
}
|
|
836
|
-
return {
|
|
837
|
-
name: "treasury",
|
|
838
|
-
...remote,
|
|
839
|
-
mints: values.mints === undefined ? null : mintList(values.mints),
|
|
840
|
-
create,
|
|
841
|
-
keypair: create ? required(values, "keypair") : values.keypair,
|
|
842
|
-
yes: values.yes === true,
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
export const SHA256_NEEDED = "--sha256 must be the work's sha256 as 64 hex digits";
|
|
846
|
-
function sha256Of(text) {
|
|
847
|
-
if (!/^[0-9a-fA-F]{64}$/.test(text)) {
|
|
848
|
-
throw new UsageError(SHA256_NEEDED);
|
|
849
|
-
}
|
|
850
|
-
return text.toLowerCase();
|
|
851
|
-
}
|
|
852
|
-
function workUrlOf(text) {
|
|
853
|
-
if (!isMemoUrl(text)) {
|
|
854
|
-
throw new UsageError(`--work-url must be ${MEMO_URL_RULE}`);
|
|
855
|
-
}
|
|
856
|
-
return text;
|
|
857
|
-
}
|
|
858
|
-
export const JUDGE_TIMEOUT = 600;
|
|
859
|
-
export const MAX_JUDGE_TIMEOUT = 86_400;
|
|
860
|
-
export const RUN_NEEDED = "--run must name the command that checks the artifact";
|
|
861
|
-
function runOf(text) {
|
|
862
|
-
if (text.trim() === "") {
|
|
863
|
-
throw new UsageError(RUN_NEEDED);
|
|
864
|
-
}
|
|
865
|
-
return text;
|
|
866
|
-
}
|
|
867
|
-
function noSub(sub) {
|
|
868
|
-
if (sub !== undefined) {
|
|
869
|
-
throw new UsageError(`unexpected argument ${sub}`);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
28
|
export function clusterUrl(text) {
|
|
873
29
|
return CLUSTERS[text] ?? text;
|
|
874
30
|
}
|
|
875
|
-
export function outputOf(argv) {
|
|
876
|
-
const at = argv.lastIndexOf("--output");
|
|
877
|
-
const inline = argv.findLast((a) => a.startsWith("--output="));
|
|
878
|
-
const value = at >= 0 ? argv[at + 1] : inline?.slice("--output=".length);
|
|
879
|
-
if (value === undefined) {
|
|
880
|
-
return "json";
|
|
881
|
-
}
|
|
882
|
-
if (value !== "json" && value !== "text") {
|
|
883
|
-
throw new UsageError("--output must be json or text");
|
|
884
|
-
}
|
|
885
|
-
return value;
|
|
886
|
-
}
|
|
887
31
|
export const MAX_FOLLOW_INTERVAL = 3_600;
|
|
888
32
|
export const WATCH_INTERVAL = 5;
|
|
889
|
-
export const COMMANDS = "setup | balance | pda | domain | mcp | show config | show intent | quote | cancel | expire | close | advance-nonce | advance-epoch | create swap|limit|dutch|attested | list | mandate grant|show|revoke|use <kind> | approve | revoke-approval | signed prepare <kind>|submit | init-config | update-config | set-economics | propose-admin | accept-admin | solve | raise-pause | lower-pause | crank | treasury | solver-table | events | jobs | deliver | deliveries | judge | hash | version | help [command]";
|
|
890
|
-
export const USAGE = `usage: ${COMMANDS}`;
|
|
891
|
-
const MANDATE_ORDER_SHAPE = "(--amount-in --min-out | --make --take | --amount-in --start-out --end-out --start-at --end-at)";
|
|
892
|
-
const ORDER_SHAPE = "(--amount-in --min-out | --make --take | --amount-in --start-out --end-out --start-at --end-at | --amount-in --min-result --max-result --attestor)";
|
|
893
|
-
const PARTNER_SHAPE = "[--partner <address> --partner-bps <n>]";
|
|
894
|
-
export const SHAPES = {
|
|
895
|
-
setup: "[--url <cluster>] [--keypair <file>]",
|
|
896
|
-
balance: "[--keypair <file> | --owner <address>] [--mints <mint,...>]",
|
|
897
|
-
pda: "--owner <address> --nonce <n>",
|
|
898
|
-
hash: "--artifact <file or directory>",
|
|
899
|
-
show: "config | intent --owner <address> --nonce <n>",
|
|
900
|
-
domain: "",
|
|
901
|
-
mcp: "[--wallet [--wallet-per-trade <token=amount,...>] [--wallet-per-hour <token=amount,...>]] [--relayer <keypair> --relay-fee <mint=amount,...> [--relay-max-lamports] [--relay-max-ttl] [--relay-per-hour] [--relay-hourly-lamports]] [--agent <keypair> --agent-owners <address,...> [--agent-hourly-lamports]]",
|
|
902
|
-
quote: "--owner <address> --nonce <n> [--at <unix>]",
|
|
903
|
-
cancel: "--keypair <file> --nonce <n>",
|
|
904
|
-
expire: "--keypair <file> --owner <address> --nonce <n>",
|
|
905
|
-
close: "--keypair <file> --owner <address> --nonce <n>",
|
|
906
|
-
"advance-nonce": "--keypair <file> --base <n>",
|
|
907
|
-
"advance-epoch": "--keypair <file>",
|
|
908
|
-
"init-config": "(--keypair <file> [--yes] | --authority <address>) --guardian --fee-recipient --fee-bps --kinds [--flags create|fill|all]",
|
|
909
|
-
"update-config": "(--keypair <file> [--yes] | --authority <address>) and any of --guardian --fee-recipient --fee-bps --kinds --fill-disabled",
|
|
910
|
-
"propose-admin": "(--keypair <file> [--yes] | --authority <address>) --new-admin <address>",
|
|
911
|
-
"accept-admin": "(--keypair <file> [--yes] | --authority <address>)",
|
|
912
|
-
"raise-pause": "(--keypair <file> [--yes] | --authority <address>) --flags create|fill|all",
|
|
913
|
-
"lower-pause": "(--keypair <file> [--yes] | --authority <address>) --flags create|fill|all",
|
|
914
|
-
"set-economics": "(--keypair <file> [--yes] | --authority <address>) --bounty --create-fee [--kind-fees] [--partner-cut]",
|
|
915
|
-
solve: "--keypair <file> (--jupiter <url> | --issue <input mint>:<output mint>=<out>/<in>,...) --min-profit <output mint=raw,...> [--priority-fee <micro-lamports|auto>] [--max-fee-bps <n>] [--slippage-bps <n>] [--jito <url> [--tip <lamports>]] [--route-program <program the aggregator swaps through>] [--lookup-table <address,...>] [--watch [--interval <seconds>]]",
|
|
916
|
-
"solver-table": "--solver <address> --mints <mint,...>",
|
|
917
|
-
crank: "--keypair <file> [--dry-run] [--fund-accounts]",
|
|
918
|
-
treasury: "[--mints <mint,...>] [--create --mints <mint,...> --keypair <payer file> [--yes]]",
|
|
919
|
-
events: "[--limit <n>] [--follow [--interval <seconds>]]",
|
|
920
|
-
jobs: "[--attestor <address>]",
|
|
921
|
-
deliver: "--keypair <worker file> --intent <address> --sha256 <64 hex> --work-url <https url> [--yes]",
|
|
922
|
-
deliveries: "--attestor <address> --intent <address>",
|
|
923
|
-
judge: "--keypair <judge file> --owner <address> --nonce <n> --spec <file> --artifact <file or directory> --run <command> [--pay-to <wallet>] [--timeout <seconds>] [--verdict <file>] [--yes]",
|
|
924
|
-
create: `swap|limit|dutch|attested --keypair <file> --input-mint --output-mint (--expires-at | --expires-in) ${ORDER_SHAPE} [--nonce <n>] ${PARTNER_SHAPE} [--units tokens|raw] [--yes]`,
|
|
925
|
-
list: "--owner <address> or --keypair <file>; --owner wins when both are given",
|
|
926
|
-
mandate: `grant --keypair <file> --agent --input-mint --output-mint --kinds --per-intent --total --max-intents --max-ttl --valid-for --floor-out --floor-in [--agent-fee] ${PARTNER_SHAPE} [--id] [--units tokens|raw] [--yes] | show --agent (--owner <address> | --keypair <file>) [--id] | revoke --keypair <file> --agent [--id] [--yes] | use swap|limit|dutch --keypair <file> --owner (--expires-at | --expires-in) ${MANDATE_ORDER_SHAPE} [--id] [--nonce <n>] [--units tokens|raw] [--yes]`,
|
|
927
|
-
approve: "--keypair <file> --mint <mint> --amount <amount> [--units tokens|raw] [--yes]",
|
|
928
|
-
"revoke-approval": "--keypair <file> --mint <mint> [--yes]",
|
|
929
|
-
signed: `prepare swap|limit|dutch|attested --keypair <file> --out <file> --input-mint --output-mint (--expires-at | --expires-in) ${ORDER_SHAPE} [--nonce <n>] [--submit-within <seconds>] [--relayer-fee] ${PARTNER_SHAPE} [--units tokens|raw] [--yes] | submit --keypair <relayer file> --file <file> [--yes]`,
|
|
930
|
-
};
|
|
931
|
-
export function usageOf(verb) {
|
|
932
|
-
const known = verb !== undefined && ACCEPTS[verb] !== undefined;
|
|
933
|
-
return {
|
|
934
|
-
usage: known ? `${verb} ${SHAPES[verb] ?? ""}`.trim() : COMMANDS,
|
|
935
|
-
options: known ? [...(ACCEPTS[verb] ?? []), ...GLOBAL_OPTIONS].map((o) => `--${o}`) : [],
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
33
|
export function parse(argv, env = {}) {
|
|
939
34
|
noRepeats(argv);
|
|
940
35
|
let parsed;
|
|
@@ -1027,7 +122,14 @@ export function parse(argv, env = {}) {
|
|
|
1027
122
|
};
|
|
1028
123
|
case "cancel":
|
|
1029
124
|
noSub(sub);
|
|
1030
|
-
return {
|
|
125
|
+
return {
|
|
126
|
+
name: "cancel",
|
|
127
|
+
...remote,
|
|
128
|
+
keypair: required(values, "keypair"),
|
|
129
|
+
yes: values.yes === true,
|
|
130
|
+
nonce: u64(values, "nonce"),
|
|
131
|
+
close: values.close === true,
|
|
132
|
+
};
|
|
1031
133
|
case "expire":
|
|
1032
134
|
case "close":
|
|
1033
135
|
noSub(sub);
|
|
@@ -1035,6 +137,7 @@ export function parse(argv, env = {}) {
|
|
|
1035
137
|
name: verb,
|
|
1036
138
|
...remote,
|
|
1037
139
|
keypair: required(values, "keypair"),
|
|
140
|
+
yes: values.yes === true,
|
|
1038
141
|
owner: key(values, "owner"),
|
|
1039
142
|
nonce: u64(values, "nonce"),
|
|
1040
143
|
};
|
|
@@ -1090,6 +193,9 @@ export function parse(argv, env = {}) {
|
|
|
1090
193
|
if (values.interval !== undefined && values.watch !== true) {
|
|
1091
194
|
throw new UsageError("--interval needs --watch");
|
|
1092
195
|
}
|
|
196
|
+
if (remote.priority !== "auto" && remote.priority > AUTO_PRICE_CAP) {
|
|
197
|
+
throw new UsageError(solveFeeAboveCap);
|
|
198
|
+
}
|
|
1093
199
|
return {
|
|
1094
200
|
name: "solve",
|
|
1095
201
|
...remote,
|
|
@@ -1097,8 +203,10 @@ export function parse(argv, env = {}) {
|
|
|
1097
203
|
...market(values),
|
|
1098
204
|
jito: values.jito === undefined ? undefined : https(values.jito, "jito"),
|
|
1099
205
|
tipLamports,
|
|
1100
|
-
minProfit:
|
|
206
|
+
minProfit: profitFloors(required(values, "min-profit")),
|
|
1101
207
|
maxFeeBps: parseBounded(values["max-fee-bps"] ?? "100", "max-fee-bps", 200),
|
|
208
|
+
maxSolCost: values["max-sol-cost"] === undefined ? DEFAULT_MAX_SOL_COST : parseSolCost(values["max-sol-cost"]),
|
|
209
|
+
maxRent: values["max-rent"] === undefined ? DEFAULT_MAX_RENT : parseMaxRent(values["max-rent"]),
|
|
1102
210
|
slippageBps: parseBounded(values["slippage-bps"] ?? "50", "slippage-bps", 10_000),
|
|
1103
211
|
routeProgram: values["route-program"] === undefined ? undefined : parseAddress(values["route-program"], "route-program"),
|
|
1104
212
|
lookupTables: values["lookup-table"] === undefined ? [] : addressList(values["lookup-table"], "lookup-table"),
|
|
@@ -1143,11 +251,33 @@ export function parse(argv, env = {}) {
|
|
|
1143
251
|
yes: values.yes === true,
|
|
1144
252
|
intent: key(values, "intent"),
|
|
1145
253
|
sha256: sha256Of(required(values, "sha256")),
|
|
1146
|
-
workUrl:
|
|
254
|
+
workUrl: memoUrlOf(required(values, "work-url"), "work-url"),
|
|
1147
255
|
};
|
|
1148
256
|
case "deliveries":
|
|
1149
257
|
noSub(sub);
|
|
1150
|
-
return { name: "deliveries", ...remote, attestor: key(values, "attestor"), intent: key(values, "intent") };
|
|
258
|
+
return { name: "deliveries", ...remote, attestor: key(values, "attestor"), intent: key(values, "intent"), maxPages: maxPagesOf(values) };
|
|
259
|
+
case "receipt":
|
|
260
|
+
noSub(sub);
|
|
261
|
+
return {
|
|
262
|
+
name: "receipt",
|
|
263
|
+
...remote,
|
|
264
|
+
owner: key(values, "owner"),
|
|
265
|
+
nonce: u64(values, "nonce"),
|
|
266
|
+
sha256: values.sha256 === undefined ? undefined : sha256Of(values.sha256),
|
|
267
|
+
...releaseOption(values),
|
|
268
|
+
};
|
|
269
|
+
case "record-delivery":
|
|
270
|
+
noSub(sub);
|
|
271
|
+
return {
|
|
272
|
+
name: "record-delivery",
|
|
273
|
+
...remote,
|
|
274
|
+
keypair: required(values, "keypair"),
|
|
275
|
+
yes: values.yes === true,
|
|
276
|
+
owner: key(values, "owner"),
|
|
277
|
+
nonce: u64(values, "nonce"),
|
|
278
|
+
sha256: sha256Of(required(values, "sha256")),
|
|
279
|
+
...releaseOption(values),
|
|
280
|
+
};
|
|
1151
281
|
case "judge":
|
|
1152
282
|
noSub(sub);
|
|
1153
283
|
return {
|
|
@@ -1161,8 +291,10 @@ export function parse(argv, env = {}) {
|
|
|
1161
291
|
artifact: required(values, "artifact"),
|
|
1162
292
|
run: runOf(required(values, "run")),
|
|
1163
293
|
payTo: values["pay-to"] === undefined ? undefined : key(values, "pay-to"),
|
|
294
|
+
result: values.result === undefined ? undefined : u64(values, "result"),
|
|
1164
295
|
timeout: parseBounded(values.timeout ?? String(JUDGE_TIMEOUT), "timeout", MAX_JUDGE_TIMEOUT, 1),
|
|
1165
296
|
verdict: values.verdict,
|
|
297
|
+
maxPages: maxPagesOf(values),
|
|
1166
298
|
};
|
|
1167
299
|
case "solver-table":
|
|
1168
300
|
noSub(sub);
|
|
@@ -1183,7 +315,7 @@ export function parse(argv, env = {}) {
|
|
|
1183
315
|
flow: "create",
|
|
1184
316
|
keypair: required(values, "keypair"),
|
|
1185
317
|
yes: values.yes === true,
|
|
1186
|
-
input:
|
|
318
|
+
input: createTerms(sub, values),
|
|
1187
319
|
};
|
|
1188
320
|
case "list":
|
|
1189
321
|
noSub(sub);
|