vapi-network 0.16.0 → 0.16.2
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 +22 -14
- package/SKILL.md +1 -1
- package/dist/cli.js +1681 -1170
- package/dist/cli.js.map +3 -3
- package/dist/index.js +1696 -1174
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10120,7 +10120,7 @@ var init_call = __esm({
|
|
|
10120
10120
|
});
|
|
10121
10121
|
|
|
10122
10122
|
// ../cli/src/cli.ts
|
|
10123
|
-
import { join as
|
|
10123
|
+
import { join as join35 } from "node:path";
|
|
10124
10124
|
|
|
10125
10125
|
// ../../node_modules/.pnpm/zod@4.5.4/node_modules/zod/v4/classic/external.js
|
|
10126
10126
|
var external_exports = {};
|
|
@@ -47433,6 +47433,10 @@ var DEFAULT_SPEND_CAPS = {
|
|
|
47433
47433
|
};
|
|
47434
47434
|
var DEFAULT_MAX_PER_TASK_USD = 100;
|
|
47435
47435
|
var DEFAULT_AUTO_RELEASE_BELOW_USD = 25;
|
|
47436
|
+
var walletTaskPolicySchema = external_exports.object({
|
|
47437
|
+
maxPerTaskUsd: external_exports.number().min(0).optional(),
|
|
47438
|
+
approveAboveUsd: external_exports.number().min(0).optional()
|
|
47439
|
+
});
|
|
47436
47440
|
var DEFAULT_CEILING_ATOMIC = 5000000n;
|
|
47437
47441
|
var atomicString = external_exports.string().regex(/^\d+$/, "Expected non-negative atomic units.");
|
|
47438
47442
|
var spendCapsSchema = external_exports.object({
|
|
@@ -71450,10 +71454,21 @@ function readSecretBackend(home = getVapiPaths().directory) {
|
|
|
71450
71454
|
}
|
|
71451
71455
|
async function chooseSecretBackend(options) {
|
|
71452
71456
|
const env = options.env ?? process.env;
|
|
71453
|
-
const osWorks =
|
|
71457
|
+
const osWorks = await osStoreUsable(options.os);
|
|
71454
71458
|
const path = secretBackendPath(options.home);
|
|
71455
71459
|
return await withVaultLock(path, async () => {
|
|
71456
|
-
if (await fileExists(path))
|
|
71460
|
+
if (await fileExists(path)) {
|
|
71461
|
+
const pinned = readSecretBackend(options.home);
|
|
71462
|
+
if (pinned === "os" && !hasOsStore(options.os.platform)) {
|
|
71463
|
+
throw new KeystoreError(
|
|
71464
|
+
[
|
|
71465
|
+
`This vAPI home is set to use the OS secret store, which ${options.os.platform} does not have.`,
|
|
71466
|
+
`If vapi setup never finished here, delete ${path}, set ${FILE_SECRET_STORE_PASSWORD_ENV} (at least ${FILE_SECRET_STORE_MIN_PASSWORD} characters) and run vapi setup again.`
|
|
71467
|
+
].join(" ")
|
|
71468
|
+
);
|
|
71469
|
+
}
|
|
71470
|
+
return pinned;
|
|
71471
|
+
}
|
|
71457
71472
|
if (await fileExists(join6(options.home, "vault.json"))) return "os";
|
|
71458
71473
|
let backend;
|
|
71459
71474
|
if (osWorks) {
|
|
@@ -71483,6 +71498,13 @@ async function fileExists(path) {
|
|
|
71483
71498
|
throw error61;
|
|
71484
71499
|
}
|
|
71485
71500
|
}
|
|
71501
|
+
function hasOsStore(platform2) {
|
|
71502
|
+
return platform2 === "darwin" || platform2 === "win32" || platform2 === "linux";
|
|
71503
|
+
}
|
|
71504
|
+
async function osStoreUsable(store) {
|
|
71505
|
+
if (store.platform === "linux") return await osStoreWorks(store);
|
|
71506
|
+
return hasOsStore(store.platform);
|
|
71507
|
+
}
|
|
71486
71508
|
async function osStoreWorks(store) {
|
|
71487
71509
|
if (!store.available) return false;
|
|
71488
71510
|
try {
|
|
@@ -72777,6 +72799,8 @@ var walletEntrySchema = external_exports.object({
|
|
|
72777
72799
|
ceilingAtomic: external_exports.string().regex(/^\d+$/).nullable().optional(),
|
|
72778
72800
|
ceilingSweepAttemptedAt: external_exports.iso.datetime().optional(),
|
|
72779
72801
|
ceilingSweepPending: ceilingSweepPendingSchema.optional(),
|
|
72802
|
+
// Task limits for an account without an agent profile; absent means the defaults.
|
|
72803
|
+
taskPolicy: walletTaskPolicySchema.optional(),
|
|
72780
72804
|
routerRefill: routerRefillSchema.optional(),
|
|
72781
72805
|
routerPendingPurchase: routerPendingPurchaseSchema.optional(),
|
|
72782
72806
|
link: agentLinkSchema.optional()
|
|
@@ -73125,6 +73149,30 @@ var WalletStore = class _WalletStore {
|
|
|
73125
73149
|
return structuredClone(entry);
|
|
73126
73150
|
});
|
|
73127
73151
|
}
|
|
73152
|
+
/**
|
|
73153
|
+
* Stores task limits for an account without an agent profile, from the latest registry value
|
|
73154
|
+
* while holding its write lock. Returning undefined removes them, so the defaults apply.
|
|
73155
|
+
*/
|
|
73156
|
+
async updateTaskPolicy(name, update) {
|
|
73157
|
+
const walletName = assertWalletName(name);
|
|
73158
|
+
return await withRegistryLock(this.registryPath, async () => {
|
|
73159
|
+
const registry2 = await this.readRegistry();
|
|
73160
|
+
const entry = ownWalletEntry(registry2.wallets, walletName);
|
|
73161
|
+
if (!entry) {
|
|
73162
|
+
throw new KeystoreError(unknownWalletMessage(walletName, Object.keys(registry2.wallets)));
|
|
73163
|
+
}
|
|
73164
|
+
const next = update(entry.taskPolicy === void 0 ? void 0 : { ...entry.taskPolicy });
|
|
73165
|
+
const parsed = next === void 0 ? void 0 : walletTaskPolicySchema.parse(next);
|
|
73166
|
+
if (JSON.stringify(parsed) !== JSON.stringify(entry.taskPolicy)) {
|
|
73167
|
+
if (parsed === void 0) delete entry.taskPolicy;
|
|
73168
|
+
else entry.taskPolicy = parsed;
|
|
73169
|
+
await this.writeRegistry(registry2);
|
|
73170
|
+
} else {
|
|
73171
|
+
this.registry = registry2;
|
|
73172
|
+
}
|
|
73173
|
+
return structuredClone(entry);
|
|
73174
|
+
});
|
|
73175
|
+
}
|
|
73128
73176
|
/** Reads the configured ceiling and the per-day-cap floor for one wallet. */
|
|
73129
73177
|
ceilingCaps(name) {
|
|
73130
73178
|
const entry = this.resolve({ name }).entry;
|
|
@@ -74532,6 +74580,14 @@ function secretsAllowed(env, streams) {
|
|
|
74532
74580
|
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
74533
74581
|
import { mkdir as mkdir11, readFile as readFile13, readdir as readdir4, rename as rename8, unlink as unlink8, writeFile as writeFile5 } from "node:fs/promises";
|
|
74534
74582
|
import { join as join11 } from "node:path";
|
|
74583
|
+
var DEFAULT_APPROVE_ABOVE_USD = 0.5;
|
|
74584
|
+
function accountTaskLimitsUnderProfile(current) {
|
|
74585
|
+
const kept = {
|
|
74586
|
+
...current?.maxPerTaskUsd !== void 0 && current.maxPerTaskUsd < DEFAULT_MAX_PER_TASK_USD ? { maxPerTaskUsd: current.maxPerTaskUsd } : {},
|
|
74587
|
+
...current?.approveAboveUsd !== void 0 && current.approveAboveUsd < DEFAULT_APPROVE_ABOVE_USD ? { approveAboveUsd: current.approveAboveUsd } : {}
|
|
74588
|
+
};
|
|
74589
|
+
return Object.keys(kept).length === 0 ? void 0 : kept;
|
|
74590
|
+
}
|
|
74535
74591
|
var DEFAULT_AGENT_TOOLS = ["call.search", "call.inspect", "call.pay"];
|
|
74536
74592
|
var AGENT_GRANTS = ["read", "delegate", "allocate"];
|
|
74537
74593
|
var agentProfileShape = {
|
|
@@ -74541,7 +74597,7 @@ var agentProfileShape = {
|
|
|
74541
74597
|
model: external_exports.string().min(1),
|
|
74542
74598
|
instructions: external_exports.string().max(2e4),
|
|
74543
74599
|
verifiedOnly: external_exports.boolean().default(true),
|
|
74544
|
-
approveAboveUsd: external_exports.number().min(0).default(
|
|
74600
|
+
approveAboveUsd: external_exports.number().min(0).default(DEFAULT_APPROVE_ABOVE_USD),
|
|
74545
74601
|
maxPerTaskUsd: external_exports.number().min(0).default(DEFAULT_MAX_PER_TASK_USD),
|
|
74546
74602
|
autoReleaseBelowUsd: external_exports.number().min(0).default(DEFAULT_AUTO_RELEASE_BELOW_USD),
|
|
74547
74603
|
maxSteps: external_exports.number().int().min(1).max(50).default(12),
|
|
@@ -78322,6 +78378,7 @@ async function provisionSwarm(opts, home, swarm, accounts) {
|
|
|
78322
78378
|
}
|
|
78323
78379
|
if (member !== void 0) {
|
|
78324
78380
|
if (!await profileExists(home, member.account)) {
|
|
78381
|
+
const stricter = (await opts.store.updateTaskPolicy(member.account, accountTaskLimitsUnderProfile)).taskPolicy;
|
|
78325
78382
|
await writeAgentProfile(home, {
|
|
78326
78383
|
version: 1,
|
|
78327
78384
|
name: member.account,
|
|
@@ -78331,7 +78388,8 @@ async function provisionSwarm(opts, home, swarm, accounts) {
|
|
|
78331
78388
|
tools: [...DEFAULT_AGENT_TOOLS],
|
|
78332
78389
|
grants: roleGrants(member.role),
|
|
78333
78390
|
verifiedOnly: true,
|
|
78334
|
-
approveAboveUsd: 0.5,
|
|
78391
|
+
approveAboveUsd: stricter?.approveAboveUsd ?? 0.5,
|
|
78392
|
+
...stricter?.maxPerTaskUsd === void 0 ? {} : { maxPerTaskUsd: stricter.maxPerTaskUsd },
|
|
78335
78393
|
maxSteps: 12,
|
|
78336
78394
|
paused: false,
|
|
78337
78395
|
createdAt: (opts.now?.() ?? /* @__PURE__ */ new Date()).toISOString()
|
|
@@ -78667,7 +78725,7 @@ function createRunBudget(args) {
|
|
|
78667
78725
|
import { mkdir as mkdir15, writeFile as writeFile7 } from "node:fs/promises";
|
|
78668
78726
|
import { arch, platform, release } from "node:os";
|
|
78669
78727
|
import { join as join14 } from "node:path";
|
|
78670
|
-
var VAPI_CLIENT_VERSION = "0.16.
|
|
78728
|
+
var VAPI_CLIENT_VERSION = "0.16.2";
|
|
78671
78729
|
async function createSupportReport(options) {
|
|
78672
78730
|
const message = options.message.trim();
|
|
78673
78731
|
if (!message) throw new Error("Support report message must not be empty.");
|
|
@@ -82210,9 +82268,11 @@ var taskV2OperationSchema = external_exports.object({
|
|
|
82210
82268
|
step: taskV2StepSchema,
|
|
82211
82269
|
expectedActor: address2,
|
|
82212
82270
|
transactionHash: hash4.nullable(),
|
|
82213
|
-
plan
|
|
82271
|
+
// The API returns the plan only while the step is prepared and re-validated; once the
|
|
82272
|
+
// transaction is submitted or confirmed, and while a recovery scan runs, it sends null.
|
|
82273
|
+
plan: taskV2PlanSchema.nullable()
|
|
82214
82274
|
}).refine(
|
|
82215
|
-
(v) => v.plan.operationId === v.id && v.plan.step === v.step && v.plan.from === v.expectedActor,
|
|
82275
|
+
(v) => v.plan === null || v.plan.operationId === v.id && v.plan.step === v.step && v.plan.from === v.expectedActor,
|
|
82216
82276
|
"Operation plan binding mismatch"
|
|
82217
82277
|
).refine(
|
|
82218
82278
|
(v) => !["submitted", "confirmed"].includes(v.state) || v.transactionHash !== null,
|
|
@@ -83110,934 +83170,383 @@ function taskFundingIntentNonce(intent, expected) {
|
|
|
83110
83170
|
return message.nonce.toLowerCase();
|
|
83111
83171
|
}
|
|
83112
83172
|
|
|
83113
|
-
// ../core/src/tasks/
|
|
83114
|
-
import {
|
|
83115
|
-
|
|
83116
|
-
if (amount4 < 0n) throw new Error("Dispute amount must be nonnegative.");
|
|
83117
|
-
const fee = amount4 * 1000n / 10000n;
|
|
83118
|
-
return fee < 20000000n ? 20000000n : fee > 500000000n ? 500000000n : fee;
|
|
83119
|
-
}
|
|
83120
|
-
function taskFeeReservationKey(milestoneId2, action) {
|
|
83121
|
-
const bytes = createHash3("sha256").update(JSON.stringify([milestoneId2, action])).digest().subarray(0, 16);
|
|
83122
|
-
bytes[6] = bytes[6] & 15 | 80;
|
|
83123
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
83124
|
-
const hex5 = bytes.toString("hex");
|
|
83125
|
-
return `${hex5.slice(0, 8)}-${hex5.slice(8, 12)}-${hex5.slice(12, 16)}-${hex5.slice(16, 20)}-${hex5.slice(20)}`;
|
|
83126
|
-
}
|
|
83127
|
-
|
|
83128
|
-
// ../core/src/tasks/money.ts
|
|
83129
|
-
function formatBaseUnitsUsd(baseUnits2) {
|
|
83130
|
-
const [whole, fraction = ""] = formatUsdc(parseBaseUnits(baseUnits2)).split(".");
|
|
83131
|
-
return `${whole}.${fraction.padEnd(2, "0")}`;
|
|
83132
|
-
}
|
|
83133
|
-
function parseUsdToBaseUnits(text) {
|
|
83134
|
-
if (!/^\d+(?:\.\d{1,6})?$/u.test(text)) {
|
|
83135
|
-
throw new Error(
|
|
83136
|
-
"Task USD amount must be a non-negative decimal with at most six decimal places."
|
|
83137
|
-
);
|
|
83138
|
-
}
|
|
83139
|
-
const [whole = "0", fraction = ""] = text.split(".");
|
|
83140
|
-
return BigInt(whole) * 1000000n + BigInt(fraction.padEnd(6, "0"));
|
|
83141
|
-
}
|
|
83142
|
-
function parseFeeBp(deploymentOrReadiness) {
|
|
83143
|
-
if (typeof deploymentOrReadiness !== "object" || deploymentOrReadiness === null || !("feeBp" in deploymentOrReadiness)) {
|
|
83144
|
-
return null;
|
|
83145
|
-
}
|
|
83146
|
-
const feeBp = deploymentOrReadiness.feeBp;
|
|
83147
|
-
if (feeBp === void 0 || feeBp === null) return null;
|
|
83148
|
-
validateFeeBp(feeBp);
|
|
83149
|
-
return feeBp;
|
|
83150
|
-
}
|
|
83151
|
-
function taskMoney(grossBaseUnits, feeBp) {
|
|
83152
|
-
const atomic = parseBaseUnits(grossBaseUnits);
|
|
83153
|
-
const gross = amount3(atomic);
|
|
83154
|
-
if (feeBp === null) {
|
|
83155
|
-
return { gross, fee: null, net: null, feeBp, line: `$${gross.usd} gross \xB7 fee unavailable` };
|
|
83156
|
-
}
|
|
83157
|
-
validateFeeBp(feeBp);
|
|
83158
|
-
const feeAtomic = atomic * BigInt(feeBp) / 10000n;
|
|
83159
|
-
const fee = amount3(feeAtomic);
|
|
83160
|
-
const net = amount3(atomic - feeAtomic);
|
|
83161
|
-
return {
|
|
83162
|
-
gross,
|
|
83163
|
-
fee,
|
|
83164
|
-
net,
|
|
83165
|
-
feeBp,
|
|
83166
|
-
line: `$${gross.usd} gross \xB7 $${fee.usd} fee \xB7 $${net.usd} net`
|
|
83167
|
-
};
|
|
83168
|
-
}
|
|
83169
|
-
function amount3(atomic) {
|
|
83170
|
-
return { usd: formatBaseUnitsUsd(atomic), baseUnits: atomic.toString() };
|
|
83171
|
-
}
|
|
83172
|
-
function validateFeeBp(value) {
|
|
83173
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 1e4) {
|
|
83174
|
-
throw new Error("Task fee basis points must be an integer from 0 to 10000.");
|
|
83175
|
-
}
|
|
83176
|
-
}
|
|
83177
|
-
function parseBaseUnits(value) {
|
|
83178
|
-
if (typeof value === "string" && !/^\d+$/u.test(value) || typeof value !== "bigint" && typeof value !== "string") {
|
|
83179
|
-
throw new Error("Task base units must be a non-negative integer.");
|
|
83180
|
-
}
|
|
83181
|
-
const atomic = BigInt(value);
|
|
83182
|
-
if (atomic < 0n) throw new Error("Task base units must be a non-negative integer.");
|
|
83183
|
-
return atomic;
|
|
83184
|
-
}
|
|
83185
|
-
function taskPolicyAtomic(value) {
|
|
83186
|
-
if (!Number.isFinite(value) || value < 0)
|
|
83187
|
-
throw new Error("Task policy USD amounts must be finite and non-negative.");
|
|
83188
|
-
const [mantissa = "0", exponent = "0"] = value.toString().split("e");
|
|
83189
|
-
const [whole = "0", fraction = ""] = mantissa.split(".");
|
|
83190
|
-
const digits = BigInt(whole + fraction);
|
|
83191
|
-
const scale = 6 + Number(exponent) - fraction.length;
|
|
83192
|
-
return scale >= 0 ? digits * 10n ** BigInt(scale) : digits / 10n ** BigInt(-scale);
|
|
83193
|
-
}
|
|
83173
|
+
// ../core/src/tasks/operation-support.ts
|
|
83174
|
+
import { readFile as readFile18, stat as stat15 } from "node:fs/promises";
|
|
83175
|
+
import { basename as basename2, extname, join as join16 } from "node:path";
|
|
83194
83176
|
|
|
83195
|
-
// ../core/src/tasks/
|
|
83196
|
-
var
|
|
83177
|
+
// ../core/src/tasks/v2-abi.generated.ts
|
|
83178
|
+
var escrowFactoryV2Abi = [
|
|
83197
83179
|
{
|
|
83198
|
-
type: "
|
|
83199
|
-
name: "createEscrow",
|
|
83200
|
-
stateMutability: "nonpayable",
|
|
83180
|
+
type: "constructor",
|
|
83201
83181
|
inputs: [
|
|
83202
|
-
{ name: "
|
|
83203
|
-
{ name: "
|
|
83204
|
-
{ name: "
|
|
83205
|
-
{ name: "
|
|
83206
|
-
{ name: "
|
|
83207
|
-
{ name: "
|
|
83208
|
-
{ name: "
|
|
83182
|
+
{ name: "initialOwner", type: "address", internalType: "address" },
|
|
83183
|
+
{ name: "feeRouter", type: "address", internalType: "address" },
|
|
83184
|
+
{ name: "disputeResolver", type: "address", internalType: "address" },
|
|
83185
|
+
{ name: "outcomeRegistry", type: "address", internalType: "address" },
|
|
83186
|
+
{ name: "usdc", type: "address", internalType: "address" },
|
|
83187
|
+
{ name: "initialFeeBp", type: "uint16", internalType: "uint16" },
|
|
83188
|
+
{ name: "maxFeeBp_", type: "uint16", internalType: "uint16" },
|
|
83189
|
+
{ name: "maxEscrowAmount_", type: "uint256", internalType: "uint256" },
|
|
83190
|
+
{ name: "cancelGrace", type: "uint64", internalType: "uint64" },
|
|
83191
|
+
{ name: "lateWindow", type: "uint64", internalType: "uint64" },
|
|
83192
|
+
{ name: "minWorkTime", type: "uint64", internalType: "uint64" }
|
|
83209
83193
|
],
|
|
83210
|
-
|
|
83194
|
+
stateMutability: "nonpayable"
|
|
83211
83195
|
},
|
|
83212
83196
|
{
|
|
83213
83197
|
type: "function",
|
|
83214
|
-
name: "
|
|
83215
|
-
|
|
83198
|
+
name: "bountyImplementation",
|
|
83199
|
+
inputs: [],
|
|
83200
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83201
|
+
stateMutability: "view"
|
|
83202
|
+
},
|
|
83203
|
+
{
|
|
83204
|
+
type: "function",
|
|
83205
|
+
name: "createAndFundWithAuthorization",
|
|
83216
83206
|
inputs: [
|
|
83217
|
-
{
|
|
83218
|
-
|
|
83219
|
-
|
|
83220
|
-
|
|
83207
|
+
{
|
|
83208
|
+
name: "terms_",
|
|
83209
|
+
type: "tuple",
|
|
83210
|
+
internalType: "struct IEscrowV2.Terms",
|
|
83211
|
+
components: [
|
|
83212
|
+
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83213
|
+
{ name: "poster", type: "address", internalType: "address" },
|
|
83214
|
+
{ name: "worker", type: "address", internalType: "address" },
|
|
83215
|
+
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83216
|
+
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83217
|
+
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83218
|
+
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83219
|
+
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83220
|
+
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83221
|
+
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83222
|
+
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83223
|
+
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83224
|
+
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83225
|
+
]
|
|
83226
|
+
},
|
|
83227
|
+
{
|
|
83228
|
+
name: "milestones",
|
|
83229
|
+
type: "tuple[]",
|
|
83230
|
+
internalType: "struct IEscrowV2.Milestone[]",
|
|
83231
|
+
components: [
|
|
83232
|
+
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83233
|
+
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83234
|
+
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83235
|
+
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83236
|
+
]
|
|
83237
|
+
},
|
|
83238
|
+
{ name: "salt", type: "bytes32", internalType: "bytes32" },
|
|
83239
|
+
{ name: "from", type: "address", internalType: "address" },
|
|
83240
|
+
{ name: "validAfter", type: "uint256", internalType: "uint256" },
|
|
83241
|
+
{ name: "validBefore", type: "uint256", internalType: "uint256" },
|
|
83242
|
+
{ name: "nonce", type: "bytes32", internalType: "bytes32" },
|
|
83243
|
+
{ name: "signature", type: "bytes", internalType: "bytes" }
|
|
83221
83244
|
],
|
|
83222
|
-
outputs: []
|
|
83245
|
+
outputs: [{ name: "escrow", type: "address", internalType: "address" }],
|
|
83246
|
+
stateMutability: "nonpayable"
|
|
83223
83247
|
},
|
|
83224
83248
|
{
|
|
83225
83249
|
type: "function",
|
|
83226
|
-
name: "
|
|
83227
|
-
stateMutability: "nonpayable",
|
|
83250
|
+
name: "createEscrow",
|
|
83228
83251
|
inputs: [
|
|
83229
|
-
{
|
|
83230
|
-
|
|
83252
|
+
{
|
|
83253
|
+
name: "terms_",
|
|
83254
|
+
type: "tuple",
|
|
83255
|
+
internalType: "struct IEscrowV2.Terms",
|
|
83256
|
+
components: [
|
|
83257
|
+
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83258
|
+
{ name: "poster", type: "address", internalType: "address" },
|
|
83259
|
+
{ name: "worker", type: "address", internalType: "address" },
|
|
83260
|
+
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83261
|
+
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83262
|
+
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83263
|
+
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83264
|
+
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83265
|
+
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83266
|
+
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83267
|
+
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83268
|
+
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83269
|
+
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83270
|
+
]
|
|
83271
|
+
},
|
|
83272
|
+
{
|
|
83273
|
+
name: "milestones",
|
|
83274
|
+
type: "tuple[]",
|
|
83275
|
+
internalType: "struct IEscrowV2.Milestone[]",
|
|
83276
|
+
components: [
|
|
83277
|
+
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83278
|
+
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83279
|
+
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83280
|
+
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83281
|
+
]
|
|
83282
|
+
},
|
|
83283
|
+
{ name: "salt", type: "bytes32", internalType: "bytes32" }
|
|
83231
83284
|
],
|
|
83232
|
-
outputs: [{ name: "
|
|
83285
|
+
outputs: [{ name: "escrow", type: "address", internalType: "address" }],
|
|
83286
|
+
stateMutability: "nonpayable"
|
|
83233
83287
|
},
|
|
83234
83288
|
{
|
|
83235
83289
|
type: "function",
|
|
83236
|
-
name: "
|
|
83237
|
-
stateMutability: "nonpayable",
|
|
83290
|
+
name: "feeBp",
|
|
83238
83291
|
inputs: [],
|
|
83239
|
-
outputs: []
|
|
83292
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
83293
|
+
stateMutability: "view"
|
|
83240
83294
|
},
|
|
83241
83295
|
{
|
|
83242
83296
|
type: "function",
|
|
83243
|
-
name: "
|
|
83244
|
-
|
|
83245
|
-
|
|
83246
|
-
|
|
83297
|
+
name: "implementation",
|
|
83298
|
+
inputs: [],
|
|
83299
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83300
|
+
stateMutability: "view"
|
|
83247
83301
|
},
|
|
83248
83302
|
{
|
|
83249
83303
|
type: "function",
|
|
83250
|
-
name: "
|
|
83251
|
-
|
|
83304
|
+
name: "isEscrow",
|
|
83305
|
+
inputs: [{ name: "escrow", type: "address", internalType: "address" }],
|
|
83306
|
+
outputs: [{ name: "registered", type: "bool", internalType: "bool" }],
|
|
83307
|
+
stateMutability: "view"
|
|
83308
|
+
},
|
|
83309
|
+
{
|
|
83310
|
+
type: "function",
|
|
83311
|
+
name: "maxEscrowAmount",
|
|
83252
83312
|
inputs: [],
|
|
83253
|
-
outputs: []
|
|
83313
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
83314
|
+
stateMutability: "view"
|
|
83254
83315
|
},
|
|
83255
|
-
{ type: "function", name: "refundBuyer", stateMutability: "nonpayable", inputs: [], outputs: [] },
|
|
83256
83316
|
{
|
|
83257
83317
|
type: "function",
|
|
83258
|
-
name: "
|
|
83259
|
-
|
|
83260
|
-
|
|
83261
|
-
|
|
83318
|
+
name: "maxFeeBp",
|
|
83319
|
+
inputs: [],
|
|
83320
|
+
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
83321
|
+
stateMutability: "view"
|
|
83262
83322
|
},
|
|
83263
83323
|
{
|
|
83264
83324
|
type: "function",
|
|
83265
|
-
name: "
|
|
83266
|
-
|
|
83267
|
-
|
|
83268
|
-
|
|
83325
|
+
name: "owner",
|
|
83326
|
+
inputs: [],
|
|
83327
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83328
|
+
stateMutability: "view"
|
|
83269
83329
|
},
|
|
83330
|
+
{ type: "function", name: "pause", inputs: [], outputs: [], stateMutability: "nonpayable" },
|
|
83270
83331
|
{
|
|
83271
83332
|
type: "function",
|
|
83272
|
-
name: "
|
|
83273
|
-
stateMutability: "nonpayable",
|
|
83333
|
+
name: "paused",
|
|
83274
83334
|
inputs: [],
|
|
83275
|
-
outputs: []
|
|
83335
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
83336
|
+
stateMutability: "view"
|
|
83276
83337
|
},
|
|
83277
83338
|
{
|
|
83278
83339
|
type: "function",
|
|
83279
|
-
name: "
|
|
83280
|
-
stateMutability: "nonpayable",
|
|
83340
|
+
name: "paymentToken",
|
|
83281
83341
|
inputs: [],
|
|
83282
|
-
outputs: []
|
|
83342
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83343
|
+
stateMutability: "view"
|
|
83283
83344
|
},
|
|
83284
|
-
{ type: "function", name: "finalize", stateMutability: "nonpayable", inputs: [], outputs: [] },
|
|
83285
83345
|
{
|
|
83286
83346
|
type: "function",
|
|
83287
|
-
name: "
|
|
83288
|
-
|
|
83347
|
+
name: "predictBountyEscrow",
|
|
83348
|
+
inputs: [
|
|
83349
|
+
{
|
|
83350
|
+
name: "terms_",
|
|
83351
|
+
type: "tuple",
|
|
83352
|
+
internalType: "struct IEscrowV2.Terms",
|
|
83353
|
+
components: [
|
|
83354
|
+
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83355
|
+
{ name: "poster", type: "address", internalType: "address" },
|
|
83356
|
+
{ name: "worker", type: "address", internalType: "address" },
|
|
83357
|
+
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83358
|
+
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83359
|
+
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83360
|
+
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83361
|
+
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83362
|
+
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83363
|
+
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83364
|
+
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83365
|
+
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83366
|
+
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83367
|
+
]
|
|
83368
|
+
},
|
|
83369
|
+
{
|
|
83370
|
+
name: "milestones",
|
|
83371
|
+
type: "tuple[]",
|
|
83372
|
+
internalType: "struct IEscrowV2.Milestone[]",
|
|
83373
|
+
components: [
|
|
83374
|
+
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83375
|
+
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83376
|
+
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83377
|
+
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83378
|
+
]
|
|
83379
|
+
},
|
|
83380
|
+
{ name: "salt", type: "bytes32", internalType: "bytes32" }
|
|
83381
|
+
],
|
|
83382
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83383
|
+
stateMutability: "view"
|
|
83384
|
+
},
|
|
83385
|
+
{
|
|
83386
|
+
type: "function",
|
|
83387
|
+
name: "predictEscrow",
|
|
83388
|
+
inputs: [
|
|
83389
|
+
{
|
|
83390
|
+
name: "terms_",
|
|
83391
|
+
type: "tuple",
|
|
83392
|
+
internalType: "struct IEscrowV2.Terms",
|
|
83393
|
+
components: [
|
|
83394
|
+
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83395
|
+
{ name: "poster", type: "address", internalType: "address" },
|
|
83396
|
+
{ name: "worker", type: "address", internalType: "address" },
|
|
83397
|
+
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83398
|
+
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83399
|
+
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83400
|
+
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83401
|
+
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83402
|
+
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83403
|
+
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83404
|
+
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83405
|
+
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83406
|
+
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83407
|
+
]
|
|
83408
|
+
},
|
|
83409
|
+
{
|
|
83410
|
+
name: "milestones",
|
|
83411
|
+
type: "tuple[]",
|
|
83412
|
+
internalType: "struct IEscrowV2.Milestone[]",
|
|
83413
|
+
components: [
|
|
83414
|
+
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83415
|
+
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83416
|
+
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83417
|
+
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83418
|
+
]
|
|
83419
|
+
},
|
|
83420
|
+
{ name: "salt", type: "bytes32", internalType: "bytes32" }
|
|
83421
|
+
],
|
|
83422
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83423
|
+
stateMutability: "view"
|
|
83424
|
+
},
|
|
83425
|
+
{
|
|
83426
|
+
type: "function",
|
|
83427
|
+
name: "renounceOwnership",
|
|
83289
83428
|
inputs: [],
|
|
83290
|
-
outputs: [
|
|
83429
|
+
outputs: [],
|
|
83430
|
+
stateMutability: "nonpayable"
|
|
83291
83431
|
},
|
|
83292
83432
|
{
|
|
83293
83433
|
type: "function",
|
|
83294
|
-
name: "
|
|
83295
|
-
|
|
83434
|
+
name: "setFeeBp",
|
|
83435
|
+
inputs: [{ name: "newFeeBp", type: "uint16", internalType: "uint16" }],
|
|
83436
|
+
outputs: [],
|
|
83437
|
+
stateMutability: "nonpayable"
|
|
83438
|
+
},
|
|
83439
|
+
{
|
|
83440
|
+
type: "function",
|
|
83441
|
+
name: "setMaxEscrowAmount",
|
|
83442
|
+
inputs: [{ name: "newAmount", type: "uint256", internalType: "uint256" }],
|
|
83443
|
+
outputs: [],
|
|
83444
|
+
stateMutability: "nonpayable"
|
|
83445
|
+
},
|
|
83446
|
+
{
|
|
83447
|
+
type: "function",
|
|
83448
|
+
name: "transferOwnership",
|
|
83449
|
+
inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
|
|
83450
|
+
outputs: [],
|
|
83451
|
+
stateMutability: "nonpayable"
|
|
83452
|
+
},
|
|
83453
|
+
{ type: "function", name: "unpause", inputs: [], outputs: [], stateMutability: "nonpayable" },
|
|
83454
|
+
{
|
|
83455
|
+
type: "event",
|
|
83456
|
+
name: "EscrowCreated",
|
|
83296
83457
|
inputs: [
|
|
83297
|
-
{ name: "
|
|
83298
|
-
{ name: "
|
|
83458
|
+
{ name: "escrow", type: "address", indexed: true, internalType: "address" },
|
|
83459
|
+
{ name: "poster", type: "address", indexed: true, internalType: "address" },
|
|
83460
|
+
{ name: "termsHash", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
83461
|
+
{ name: "salt", type: "bytes32", indexed: false, internalType: "bytes32" },
|
|
83462
|
+
{ name: "feeBp", type: "uint16", indexed: false, internalType: "uint16" }
|
|
83299
83463
|
],
|
|
83300
|
-
|
|
83301
|
-
}
|
|
83302
|
-
|
|
83303
|
-
|
|
83304
|
-
|
|
83305
|
-
|
|
83306
|
-
|
|
83307
|
-
|
|
83308
|
-
|
|
83309
|
-
|
|
83310
|
-
|
|
83311
|
-
|
|
83312
|
-
|
|
83313
|
-
|
|
83314
|
-
|
|
83315
|
-
|
|
83316
|
-
|
|
83317
|
-
|
|
83318
|
-
|
|
83319
|
-
|
|
83320
|
-
|
|
83321
|
-
|
|
83322
|
-
|
|
83323
|
-
|
|
83324
|
-
|
|
83325
|
-
|
|
83326
|
-
|
|
83327
|
-
|
|
83328
|
-
|
|
83329
|
-
|
|
83330
|
-
|
|
83331
|
-
|
|
83332
|
-
|
|
83333
|
-
|
|
83334
|
-
|
|
83335
|
-
|
|
83336
|
-
|
|
83337
|
-
|
|
83338
|
-
|
|
83339
|
-
|
|
83340
|
-
|
|
83341
|
-
|
|
83342
|
-
|
|
83343
|
-
|
|
83344
|
-
|
|
83345
|
-
|
|
83346
|
-
|
|
83347
|
-
|
|
83348
|
-
|
|
83349
|
-
|
|
83350
|
-
|
|
83351
|
-
|
|
83352
|
-
|
|
83353
|
-
|
|
83354
|
-
|
|
83355
|
-
|
|
83356
|
-
|
|
83357
|
-
|
|
83358
|
-
|
|
83359
|
-
}
|
|
83360
|
-
|
|
83361
|
-
|
|
83362
|
-
|
|
83363
|
-
|
|
83364
|
-
|
|
83365
|
-
|
|
83366
|
-
|
|
83367
|
-
|
|
83368
|
-
|
|
83369
|
-
|
|
83370
|
-
|
|
83371
|
-
|
|
83372
|
-
|
|
83373
|
-
|
|
83374
|
-
|
|
83375
|
-
|
|
83376
|
-
|
|
83377
|
-
|
|
83378
|
-
|
|
83379
|
-
|
|
83380
|
-
|
|
83381
|
-
|
|
83382
|
-
|
|
83383
|
-
|
|
83384
|
-
|
|
83385
|
-
|
|
83386
|
-
throw new TasksChainError("Unsafe transaction plan: missing local authorization", false);
|
|
83387
|
-
requireArgs([BigInt(a.validAfter), BigInt(a.validBefore), a.nonce, a.signature]);
|
|
83388
|
-
} else if (plan.step === "approve-usdc") {
|
|
83389
|
-
if (expectation.approveAmount === void 0) fail2("missing verified approval amount");
|
|
83390
|
-
requireArgs([expectation.milestone.escrowContract, expectation.approveAmount]);
|
|
83391
|
-
} else if (plan.step === "submit-delivery") {
|
|
83392
|
-
if (!expectation.manifestHash) fail2("missing manifest hash");
|
|
83393
|
-
requireArgs([expectation.manifestHash]);
|
|
83394
|
-
} else if (plan.step === "raise-dispute" || plan.step === "submit-counter-evidence") {
|
|
83395
|
-
if (!expectation.evidenceHash) fail2("missing evidence hash");
|
|
83396
|
-
requireArgs([expectation.evidenceHash]);
|
|
83397
|
-
} else requireArgs([]);
|
|
83398
|
-
}
|
|
83399
|
-
|
|
83400
|
-
// ../core/src/tasks/chain-verification.ts
|
|
83401
|
-
var TasksPartiesNotBoundError = class extends TasksValidationError {
|
|
83402
|
-
constructor() {
|
|
83403
|
-
super(
|
|
83404
|
-
"The task parties are not bound on this machine. Sign the scope with `vapi task sign` on this machine first; an explicit --counterparty only confirms an existing binding."
|
|
83405
|
-
);
|
|
83406
|
-
this.name = "TasksPartiesNotBoundError";
|
|
83407
|
-
}
|
|
83408
|
-
};
|
|
83409
|
-
async function verifyDeployment(ready, rpc, overrides) {
|
|
83410
|
-
const factory = getTrustedTasksFactory(ready.chainId, overrides);
|
|
83411
|
-
if (!factory)
|
|
83412
|
-
throw new TasksChainError(
|
|
83413
|
-
`No trusted Tasks escrow factory is configured for chain ${ready.chainId}. Set VAPI_TASKS_ESCROW_FACTORY_${ready.chainId}.`,
|
|
83414
|
-
false,
|
|
83415
|
-
{ authorizationExposed: false }
|
|
83416
|
-
);
|
|
83417
|
-
if (!isAddressEqual(factory, ready.escrowContract))
|
|
83418
|
-
throw new TasksValidationError(
|
|
83419
|
-
"The Tasks readiness factory does not match the trusted factory."
|
|
83420
|
-
);
|
|
83421
|
-
if (await rpc.getChainId() !== ready.chainId)
|
|
83422
|
-
throw new TasksValidationError("The RPC chain ID does not match the task deployment.");
|
|
83423
|
-
const token = await rpc.readContract({
|
|
83424
|
-
address: factory,
|
|
83425
|
-
abi: TASKS_READ_ABI,
|
|
83426
|
-
functionName: "paymentToken"
|
|
83427
|
-
});
|
|
83428
|
-
if (!isAddressEqual(token, ready.usdc))
|
|
83429
|
-
throw new TasksValidationError(
|
|
83430
|
-
"The Tasks readiness token does not match the trusted factory payment token."
|
|
83431
|
-
);
|
|
83432
|
-
const [name, version5] = await Promise.all([
|
|
83433
|
-
rpc.readContract({ address: token, abi: TASKS_READ_ABI, functionName: "name" }),
|
|
83434
|
-
rpc.readContract({ address: token, abi: TASKS_READ_ABI, functionName: "version" })
|
|
83435
|
-
]);
|
|
83436
|
-
const domain2 = { name, version: version5, chainId: ready.chainId, verifyingContract: getAddress(token) };
|
|
83437
|
-
if (ready.eip3009Domain && (ready.eip3009Domain.name !== name || ready.eip3009Domain.version !== version5 || ready.eip3009Domain.chainId !== ready.chainId || !isAddressEqual(ready.eip3009Domain.verifyingContract, token)))
|
|
83438
|
-
throw new TasksValidationError(
|
|
83439
|
-
"The funding authorization domain does not match the onchain token domain."
|
|
83440
|
-
);
|
|
83441
|
-
return {
|
|
83442
|
-
...ready,
|
|
83443
|
-
escrowContract: getAddress(factory),
|
|
83444
|
-
usdc: getAddress(token),
|
|
83445
|
-
eip3009Domain: domain2
|
|
83446
|
-
};
|
|
83447
|
-
}
|
|
83448
|
-
async function verifyScope(client, signer, selected, ready, verb, steps, options = {}) {
|
|
83449
|
-
const { scopes } = await client.getScopes(selected.workOrderId);
|
|
83450
|
-
const matches = scopes.filter(
|
|
83451
|
-
(scope2) => scope2.state === "accepted" && scope2.milestoneId === selected.id
|
|
83452
|
-
);
|
|
83453
|
-
if (matches.length !== 1)
|
|
83454
|
-
throw new TasksValidationError("The task milestone requires one accepted signed scope.");
|
|
83455
|
-
const scope = matches[0];
|
|
83456
|
-
const payload = scope.signingPayload;
|
|
83457
|
-
const frozen = freezeScopeTerms(scope.structuredTerms, scope.brief);
|
|
83458
|
-
if (scope.workOrderId !== selected.workOrderId || payload.workOrderId !== selected.workOrderId || payload.trancheOrdinal !== selected.ordinal || scope.trancheOrdinal !== selected.ordinal || payload.scopeVersion !== scope.version || frozen.termsHash !== scope.termsHash || frozen.termsHash !== payload.termsHash || frozen.termsHash !== selected.termsHash)
|
|
83459
|
-
throw new TasksValidationError(
|
|
83460
|
-
"The accepted task scope does not match its locally verified terms hash and milestone."
|
|
83461
|
-
);
|
|
83462
|
-
if (!scope.counterpartyAddress || !scope.counterpartySignature || isAddressEqual(scope.proposerAddress, scope.counterpartyAddress) || !(isAddressEqual(signer, scope.proposerAddress) || isAddressEqual(signer, scope.counterpartyAddress)))
|
|
83463
|
-
throw new TasksValidationError(
|
|
83464
|
-
"The local signer is not one of the two accepted scope parties."
|
|
83465
|
-
);
|
|
83466
|
-
const message = canonicalJson(payload);
|
|
83467
|
-
const signatures = await Promise.all([
|
|
83468
|
-
verifyMessage({
|
|
83469
|
-
address: scope.proposerAddress,
|
|
83470
|
-
message,
|
|
83471
|
-
signature: scope.proposerSignature
|
|
83472
|
-
}),
|
|
83473
|
-
verifyMessage({
|
|
83474
|
-
address: scope.counterpartyAddress,
|
|
83475
|
-
message,
|
|
83476
|
-
signature: scope.counterpartySignature
|
|
83477
|
-
})
|
|
83478
|
-
]);
|
|
83479
|
-
if (signatures.some((valid) => !valid))
|
|
83480
|
-
throw new TasksValidationError("Both accepted task scope signatures must verify.");
|
|
83481
|
-
const terms = frozen.structured;
|
|
83482
|
-
if (terms.budget.network !== ready.network || terms.budget.asset.toLowerCase() !== `${ready.network}/erc20:${ready.usdc}`.toLowerCase() || !isAddressEqual(terms.escrow.contract, ready.escrowContract) || selected.network !== terms.budget.network || selected.asset.toLowerCase() !== terms.budget.asset.toLowerCase() || selected.amountBaseUnits !== terms.budget.amountBaseUnits)
|
|
83483
|
-
throw new TasksValidationError(
|
|
83484
|
-
"The signed task scope asset, factory or amount does not match the deployment and milestone."
|
|
83485
|
-
);
|
|
83486
|
-
const identity = {
|
|
83487
|
-
orderId: selected.workOrderId,
|
|
83488
|
-
trancheOrdinal: selected.ordinal,
|
|
83489
|
-
scopeVersion: scope.version,
|
|
83490
|
-
termsHash: frozen.termsHash,
|
|
83491
|
-
self: getAddress(signer)
|
|
83492
|
-
};
|
|
83493
|
-
const binding = await options.bindings?.get(identity);
|
|
83494
|
-
if (!binding) throw new TasksPartiesNotBoundError();
|
|
83495
|
-
if (options.counterparty && !isAddressEqual(binding.counterparty, options.counterparty))
|
|
83496
|
-
throw new TasksValidationError(
|
|
83497
|
-
"The confirmed counterparty differs from the locally bound parties."
|
|
83498
|
-
);
|
|
83499
|
-
if (!isAddressEqual(binding.self, signer) || binding.orderId !== identity.orderId || binding.trancheOrdinal !== identity.trancheOrdinal || binding.scopeVersion !== identity.scopeVersion || binding.termsHash.toLowerCase() !== identity.termsHash.toLowerCase() || ![scope.proposerAddress, scope.counterpartyAddress].every(
|
|
83500
|
-
(address10) => isAddressEqual(address10, binding.self) || isAddressEqual(address10, binding.counterparty)
|
|
83501
|
-
))
|
|
83502
|
-
throw new TasksValidationError(
|
|
83503
|
-
"The accepted scope parties do not match the locally bound parties."
|
|
83504
|
-
);
|
|
83505
|
-
const buyer = getAddress(binding.role === "client" ? binding.self : binding.counterparty);
|
|
83506
|
-
const seller = getAddress(binding.role === "provider" ? binding.self : binding.counterparty);
|
|
83507
|
-
if (verb === "createEscrow" && !isAddressEqual(signer, seller))
|
|
83508
|
-
throw new TasksValidationError("Task createEscrow requires the locally bound seller's wallet.");
|
|
83509
|
-
const workDurationSeconds = terms.workDurationSeconds ?? getTrustedTasksDurations(ready.chainId, options.trustedDurations).workDurationSeconds;
|
|
83510
|
-
if (workDurationSeconds === void 0)
|
|
83511
|
-
throw new TasksValidationError(
|
|
83512
|
-
"The signed task scope has no work duration and no trusted default is configured."
|
|
83513
|
-
);
|
|
83514
|
-
return {
|
|
83515
|
-
signer,
|
|
83516
|
-
buyer,
|
|
83517
|
-
seller,
|
|
83518
|
-
parties: [buyer, seller],
|
|
83519
|
-
workDurationSeconds,
|
|
83520
|
-
...verb === "fund" ? { approveAmount: BigInt(terms.budget.amountBaseUnits) } : {},
|
|
83521
|
-
reviewWindowSeconds: terms.acceptanceWindowSeconds,
|
|
83522
|
-
nowSeconds: BigInt(Math.floor((options.now ?? (() => /* @__PURE__ */ new Date()))().getTime() / 1e3)),
|
|
83523
|
-
verb,
|
|
83524
|
-
deployment: ready,
|
|
83525
|
-
milestone: {
|
|
83526
|
-
...selected,
|
|
83527
|
-
terms,
|
|
83528
|
-
termsHash: frozen.termsHash,
|
|
83529
|
-
amountBaseUnits: terms.budget.amountBaseUnits
|
|
83530
|
-
},
|
|
83531
|
-
steps
|
|
83532
|
-
};
|
|
83533
|
-
}
|
|
83534
|
-
async function verifyClone(rpc, expected, checkState) {
|
|
83535
|
-
if (expected.verb === "createEscrow") return;
|
|
83536
|
-
const clone2 = expected.milestone.escrowContract;
|
|
83537
|
-
const registered = await rpc.readContract({
|
|
83538
|
-
address: expected.deployment.escrowContract,
|
|
83539
|
-
abi: TASKS_READ_ABI,
|
|
83540
|
-
functionName: "isEscrow",
|
|
83541
|
-
args: [clone2]
|
|
83542
|
-
});
|
|
83543
|
-
if (!registered)
|
|
83544
|
-
throw new TasksValidationError(
|
|
83545
|
-
"The task escrow clone is not registered by the trusted factory."
|
|
83546
|
-
);
|
|
83547
|
-
const predicted = await rpc.readContract({
|
|
83548
|
-
address: expected.deployment.escrowContract,
|
|
83549
|
-
abi: TASKS_READ_ABI,
|
|
83550
|
-
functionName: "predictEscrow",
|
|
83551
|
-
args: [expected.seller, keccak256(stringToHex(expected.milestone.id))]
|
|
83552
|
-
});
|
|
83553
|
-
if (!isAddressEqual(predicted, clone2))
|
|
83554
|
-
throw new TasksValidationError(
|
|
83555
|
-
"The escrow clone does not match the signed milestone salt and bound seller."
|
|
83556
|
-
);
|
|
83557
|
-
const read = (functionName) => rpc.readContract({ address: clone2, abi: TASKS_READ_ABI, functionName });
|
|
83558
|
-
const [
|
|
83559
|
-
buyer,
|
|
83560
|
-
seller,
|
|
83561
|
-
token,
|
|
83562
|
-
amount4,
|
|
83563
|
-
termsHash,
|
|
83564
|
-
state,
|
|
83565
|
-
resolution,
|
|
83566
|
-
offerDeadline,
|
|
83567
|
-
workDeadline,
|
|
83568
|
-
reviewDeadline,
|
|
83569
|
-
disputedAt,
|
|
83570
|
-
counterEvidenceDeadline,
|
|
83571
|
-
slot0,
|
|
83572
|
-
slot6,
|
|
83573
|
-
slot7
|
|
83574
|
-
] = await Promise.all([
|
|
83575
|
-
read("buyer"),
|
|
83576
|
-
read("seller"),
|
|
83577
|
-
read("token"),
|
|
83578
|
-
read("amount"),
|
|
83579
|
-
read("termsHash"),
|
|
83580
|
-
read("state"),
|
|
83581
|
-
read("resolution"),
|
|
83582
|
-
read("offerDeadline"),
|
|
83583
|
-
read("workDeadline"),
|
|
83584
|
-
read("reviewDeadline"),
|
|
83585
|
-
read("disputedAt"),
|
|
83586
|
-
read("counterEvidenceDeadline"),
|
|
83587
|
-
rpc.getStorageAt({ address: clone2, slot: "0x0" }),
|
|
83588
|
-
rpc.getStorageAt({ address: clone2, slot: "0x6" }),
|
|
83589
|
-
rpc.getStorageAt({ address: clone2, slot: "0x7" })
|
|
83590
|
-
]);
|
|
83591
|
-
if (isAddressEqual(buyer, seller) || !isAddressEqual(buyer, expected.buyer) || !isAddressEqual(seller, expected.seller) || !isAddressEqual(token, expected.deployment.usdc) || amount4 !== BigInt(expected.milestone.amountBaseUnits) || termsHash.toLowerCase() !== expected.milestone.termsHash.toLowerCase())
|
|
83592
|
-
throw new TasksValidationError(
|
|
83593
|
-
"The onchain escrow parties, token, amount or terms hash do not match the signed scope."
|
|
83594
|
-
);
|
|
83595
|
-
const s0 = storageWord(slot0);
|
|
83596
|
-
const s6 = storageWord(slot6);
|
|
83597
|
-
const s7 = storageWord(slot7);
|
|
83598
|
-
if (field(s0, 0, 1) !== BigInt(state) || field(s0, 1, 1) !== BigInt(resolution) || !isAddressEqual(storageAddress(s0, 2), buyer) || field(s6, 0, 8) !== offerDeadline || field(s6, 8, 8) !== workDeadline || field(s6, 16, 8) !== reviewDeadline || field(s6, 24, 8) !== disputedAt || field(s7, 0, 8) !== counterEvidenceDeadline)
|
|
83599
|
-
throw new TasksValidationError("unsupported escrow layout");
|
|
83600
|
-
if (field(s7, 8, 8) !== BigInt(expected.workDurationSeconds) || field(s7, 16, 8) !== BigInt(expected.reviewWindowSeconds))
|
|
83601
|
-
throw new TasksValidationError(
|
|
83602
|
-
"The onchain escrow durations do not match the signed terms and trusted defaults."
|
|
83603
|
-
);
|
|
83604
|
-
const actor = expected.verb === "fund" || expected.verb === "release" ? buyer : expected.verb === "deliver" || expected.verb === "refund" ? seller : expected.signer;
|
|
83605
|
-
if (!isAddressEqual(actor, expected.signer))
|
|
83606
|
-
throw new TasksValidationError(
|
|
83607
|
-
`Task ${expected.verb} requires the onchain escrow party's local wallet.`
|
|
83608
|
-
);
|
|
83609
|
-
const states = {
|
|
83610
|
-
fund: [1],
|
|
83611
|
-
deliver: [2],
|
|
83612
|
-
release: [3],
|
|
83613
|
-
refund: [2, 3],
|
|
83614
|
-
dispute: [2, 3],
|
|
83615
|
-
"counter-evidence": [4],
|
|
83616
|
-
"resolve-unmatched": [4]
|
|
83617
|
-
};
|
|
83618
|
-
if (checkState && !states[expected.verb]?.includes(state))
|
|
83619
|
-
throw new TasksValidationError(
|
|
83620
|
-
`The onchain escrow state is not eligible for task ${expected.verb}.`
|
|
83621
|
-
);
|
|
83622
|
-
if (["dispute", "counter-evidence"].includes(expected.verb)) {
|
|
83623
|
-
const fee = disputeFeeBaseUnits(amount4);
|
|
83624
|
-
if (await read("disputeFee") !== fee)
|
|
83625
|
-
throw new TasksValidationError(
|
|
83626
|
-
"The onchain dispute fee does not match the verified amount fee rule."
|
|
83627
|
-
);
|
|
83628
|
-
expected.disputeFee = fee;
|
|
83629
|
-
expected.approveAmount = fee;
|
|
83630
|
-
}
|
|
83631
|
-
if (checkState && ["counter-evidence", "resolve-unmatched"].includes(expected.verb)) {
|
|
83632
|
-
const slot8 = storageWord(await rpc.getStorageAt({ address: clone2, slot: "0x8" }));
|
|
83633
|
-
const opener = storageAddress(slot8, 0);
|
|
83634
|
-
const submitted = field(slot8, 20, 1);
|
|
83635
|
-
if (!isAddressEqual(opener, buyer) && !isAddressEqual(opener, seller) || submitted > 1n || field(slot8, 21, 11) !== 0n)
|
|
83636
|
-
throw new TasksValidationError("unsupported escrow layout");
|
|
83637
|
-
const now = expected.nowSeconds;
|
|
83638
|
-
if (now === void 0)
|
|
83639
|
-
throw new TasksValidationError("A trusted clock is required for dispute eligibility.");
|
|
83640
|
-
if (submitted === 1n)
|
|
83641
|
-
throw new TasksValidationError(
|
|
83642
|
-
"Counter-evidence has already been submitted for this dispute."
|
|
83643
|
-
);
|
|
83644
|
-
if (expected.verb === "counter-evidence") {
|
|
83645
|
-
if (isAddressEqual(opener, expected.signer))
|
|
83646
|
-
throw new TasksValidationError("Only the non-opener party can submit counter-evidence.");
|
|
83647
|
-
if (now >= counterEvidenceDeadline)
|
|
83648
|
-
throw new TasksValidationError("The counter-evidence deadline has passed.");
|
|
83649
|
-
} else if (now <= counterEvidenceDeadline)
|
|
83650
|
-
throw new TasksValidationError(
|
|
83651
|
-
"The counter-evidence deadline has not passed; unmatched resolution is unavailable."
|
|
83652
|
-
);
|
|
83653
|
-
}
|
|
83654
|
-
expected.offerDeadline = offerDeadline;
|
|
83655
|
-
}
|
|
83656
|
-
function storageWord(value) {
|
|
83657
|
-
if (!value || !/^0x[0-9a-fA-F]{64}$/.test(value))
|
|
83658
|
-
throw new TasksValidationError("unsupported escrow layout");
|
|
83659
|
-
return BigInt(value);
|
|
83660
|
-
}
|
|
83661
|
-
function field(word, offset, bytes) {
|
|
83662
|
-
return word >> BigInt(offset * 8) & (1n << BigInt(bytes * 8)) - 1n;
|
|
83663
|
-
}
|
|
83664
|
-
function storageAddress(word, offset) {
|
|
83665
|
-
return getAddress(`0x${field(word, offset, 20).toString(16).padStart(40, "0")}`);
|
|
83666
|
-
}
|
|
83667
|
-
|
|
83668
|
-
// ../core/src/tasks/v2-abi.generated.ts
|
|
83669
|
-
var escrowFactoryV2Abi = [
|
|
83670
|
-
{
|
|
83671
|
-
type: "constructor",
|
|
83672
|
-
inputs: [
|
|
83673
|
-
{ name: "initialOwner", type: "address", internalType: "address" },
|
|
83674
|
-
{ name: "feeRouter", type: "address", internalType: "address" },
|
|
83675
|
-
{ name: "disputeResolver", type: "address", internalType: "address" },
|
|
83676
|
-
{ name: "outcomeRegistry", type: "address", internalType: "address" },
|
|
83677
|
-
{ name: "usdc", type: "address", internalType: "address" },
|
|
83678
|
-
{ name: "initialFeeBp", type: "uint16", internalType: "uint16" },
|
|
83679
|
-
{ name: "maxFeeBp_", type: "uint16", internalType: "uint16" },
|
|
83680
|
-
{ name: "maxEscrowAmount_", type: "uint256", internalType: "uint256" },
|
|
83681
|
-
{ name: "cancelGrace", type: "uint64", internalType: "uint64" },
|
|
83682
|
-
{ name: "lateWindow", type: "uint64", internalType: "uint64" },
|
|
83683
|
-
{ name: "minWorkTime", type: "uint64", internalType: "uint64" }
|
|
83684
|
-
],
|
|
83685
|
-
stateMutability: "nonpayable"
|
|
83686
|
-
},
|
|
83687
|
-
{
|
|
83688
|
-
type: "function",
|
|
83689
|
-
name: "bountyImplementation",
|
|
83690
|
-
inputs: [],
|
|
83691
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83692
|
-
stateMutability: "view"
|
|
83693
|
-
},
|
|
83694
|
-
{
|
|
83695
|
-
type: "function",
|
|
83696
|
-
name: "createAndFundWithAuthorization",
|
|
83697
|
-
inputs: [
|
|
83698
|
-
{
|
|
83699
|
-
name: "terms_",
|
|
83700
|
-
type: "tuple",
|
|
83701
|
-
internalType: "struct IEscrowV2.Terms",
|
|
83702
|
-
components: [
|
|
83703
|
-
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83704
|
-
{ name: "poster", type: "address", internalType: "address" },
|
|
83705
|
-
{ name: "worker", type: "address", internalType: "address" },
|
|
83706
|
-
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83707
|
-
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83708
|
-
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83709
|
-
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83710
|
-
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83711
|
-
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83712
|
-
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83713
|
-
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83714
|
-
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83715
|
-
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83716
|
-
]
|
|
83717
|
-
},
|
|
83718
|
-
{
|
|
83719
|
-
name: "milestones",
|
|
83720
|
-
type: "tuple[]",
|
|
83721
|
-
internalType: "struct IEscrowV2.Milestone[]",
|
|
83722
|
-
components: [
|
|
83723
|
-
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83724
|
-
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83725
|
-
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83726
|
-
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83727
|
-
]
|
|
83728
|
-
},
|
|
83729
|
-
{ name: "salt", type: "bytes32", internalType: "bytes32" },
|
|
83730
|
-
{ name: "from", type: "address", internalType: "address" },
|
|
83731
|
-
{ name: "validAfter", type: "uint256", internalType: "uint256" },
|
|
83732
|
-
{ name: "validBefore", type: "uint256", internalType: "uint256" },
|
|
83733
|
-
{ name: "nonce", type: "bytes32", internalType: "bytes32" },
|
|
83734
|
-
{ name: "signature", type: "bytes", internalType: "bytes" }
|
|
83735
|
-
],
|
|
83736
|
-
outputs: [{ name: "escrow", type: "address", internalType: "address" }],
|
|
83737
|
-
stateMutability: "nonpayable"
|
|
83738
|
-
},
|
|
83739
|
-
{
|
|
83740
|
-
type: "function",
|
|
83741
|
-
name: "createEscrow",
|
|
83742
|
-
inputs: [
|
|
83743
|
-
{
|
|
83744
|
-
name: "terms_",
|
|
83745
|
-
type: "tuple",
|
|
83746
|
-
internalType: "struct IEscrowV2.Terms",
|
|
83747
|
-
components: [
|
|
83748
|
-
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83749
|
-
{ name: "poster", type: "address", internalType: "address" },
|
|
83750
|
-
{ name: "worker", type: "address", internalType: "address" },
|
|
83751
|
-
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83752
|
-
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83753
|
-
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83754
|
-
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83755
|
-
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83756
|
-
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83757
|
-
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83758
|
-
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83759
|
-
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83760
|
-
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83761
|
-
]
|
|
83762
|
-
},
|
|
83763
|
-
{
|
|
83764
|
-
name: "milestones",
|
|
83765
|
-
type: "tuple[]",
|
|
83766
|
-
internalType: "struct IEscrowV2.Milestone[]",
|
|
83767
|
-
components: [
|
|
83768
|
-
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83769
|
-
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83770
|
-
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83771
|
-
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83772
|
-
]
|
|
83773
|
-
},
|
|
83774
|
-
{ name: "salt", type: "bytes32", internalType: "bytes32" }
|
|
83775
|
-
],
|
|
83776
|
-
outputs: [{ name: "escrow", type: "address", internalType: "address" }],
|
|
83777
|
-
stateMutability: "nonpayable"
|
|
83778
|
-
},
|
|
83779
|
-
{
|
|
83780
|
-
type: "function",
|
|
83781
|
-
name: "feeBp",
|
|
83782
|
-
inputs: [],
|
|
83783
|
-
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
83784
|
-
stateMutability: "view"
|
|
83785
|
-
},
|
|
83786
|
-
{
|
|
83787
|
-
type: "function",
|
|
83788
|
-
name: "implementation",
|
|
83789
|
-
inputs: [],
|
|
83790
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83791
|
-
stateMutability: "view"
|
|
83792
|
-
},
|
|
83793
|
-
{
|
|
83794
|
-
type: "function",
|
|
83795
|
-
name: "isEscrow",
|
|
83796
|
-
inputs: [{ name: "escrow", type: "address", internalType: "address" }],
|
|
83797
|
-
outputs: [{ name: "registered", type: "bool", internalType: "bool" }],
|
|
83798
|
-
stateMutability: "view"
|
|
83799
|
-
},
|
|
83800
|
-
{
|
|
83801
|
-
type: "function",
|
|
83802
|
-
name: "maxEscrowAmount",
|
|
83803
|
-
inputs: [],
|
|
83804
|
-
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
83805
|
-
stateMutability: "view"
|
|
83806
|
-
},
|
|
83807
|
-
{
|
|
83808
|
-
type: "function",
|
|
83809
|
-
name: "maxFeeBp",
|
|
83810
|
-
inputs: [],
|
|
83811
|
-
outputs: [{ name: "", type: "uint16", internalType: "uint16" }],
|
|
83812
|
-
stateMutability: "view"
|
|
83813
|
-
},
|
|
83814
|
-
{
|
|
83815
|
-
type: "function",
|
|
83816
|
-
name: "owner",
|
|
83817
|
-
inputs: [],
|
|
83818
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83819
|
-
stateMutability: "view"
|
|
83820
|
-
},
|
|
83821
|
-
{ type: "function", name: "pause", inputs: [], outputs: [], stateMutability: "nonpayable" },
|
|
83822
|
-
{
|
|
83823
|
-
type: "function",
|
|
83824
|
-
name: "paused",
|
|
83825
|
-
inputs: [],
|
|
83826
|
-
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
83827
|
-
stateMutability: "view"
|
|
83828
|
-
},
|
|
83829
|
-
{
|
|
83830
|
-
type: "function",
|
|
83831
|
-
name: "paymentToken",
|
|
83832
|
-
inputs: [],
|
|
83833
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83834
|
-
stateMutability: "view"
|
|
83835
|
-
},
|
|
83836
|
-
{
|
|
83837
|
-
type: "function",
|
|
83838
|
-
name: "predictBountyEscrow",
|
|
83839
|
-
inputs: [
|
|
83840
|
-
{
|
|
83841
|
-
name: "terms_",
|
|
83842
|
-
type: "tuple",
|
|
83843
|
-
internalType: "struct IEscrowV2.Terms",
|
|
83844
|
-
components: [
|
|
83845
|
-
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83846
|
-
{ name: "poster", type: "address", internalType: "address" },
|
|
83847
|
-
{ name: "worker", type: "address", internalType: "address" },
|
|
83848
|
-
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83849
|
-
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83850
|
-
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83851
|
-
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83852
|
-
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83853
|
-
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83854
|
-
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83855
|
-
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83856
|
-
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83857
|
-
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83858
|
-
]
|
|
83859
|
-
},
|
|
83860
|
-
{
|
|
83861
|
-
name: "milestones",
|
|
83862
|
-
type: "tuple[]",
|
|
83863
|
-
internalType: "struct IEscrowV2.Milestone[]",
|
|
83864
|
-
components: [
|
|
83865
|
-
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83866
|
-
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83867
|
-
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83868
|
-
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83869
|
-
]
|
|
83870
|
-
},
|
|
83871
|
-
{ name: "salt", type: "bytes32", internalType: "bytes32" }
|
|
83872
|
-
],
|
|
83873
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83874
|
-
stateMutability: "view"
|
|
83875
|
-
},
|
|
83876
|
-
{
|
|
83877
|
-
type: "function",
|
|
83878
|
-
name: "predictEscrow",
|
|
83879
|
-
inputs: [
|
|
83880
|
-
{
|
|
83881
|
-
name: "terms_",
|
|
83882
|
-
type: "tuple",
|
|
83883
|
-
internalType: "struct IEscrowV2.Terms",
|
|
83884
|
-
components: [
|
|
83885
|
-
{ name: "shape", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83886
|
-
{ name: "poster", type: "address", internalType: "address" },
|
|
83887
|
-
{ name: "worker", type: "address", internalType: "address" },
|
|
83888
|
-
{ name: "termsHash", type: "bytes32", internalType: "bytes32" },
|
|
83889
|
-
{ name: "offerTtl", type: "uint64", internalType: "uint64" },
|
|
83890
|
-
{ name: "reviewWindow", type: "uint64", internalType: "uint64" },
|
|
83891
|
-
{ name: "choiceWindow", type: "uint64", internalType: "uint64" },
|
|
83892
|
-
{ name: "bountyDeadline", type: "uint64", internalType: "uint64" },
|
|
83893
|
-
{ name: "objectionWindow", type: "uint64", internalType: "uint64" },
|
|
83894
|
-
{ name: "workerBondBp", type: "uint16", internalType: "uint16" },
|
|
83895
|
-
{ name: "feeBp", type: "uint16", internalType: "uint16" },
|
|
83896
|
-
{ name: "winners", type: "uint8", internalType: "uint8" },
|
|
83897
|
-
{ name: "rewardPerWinner", type: "uint96", internalType: "uint96" }
|
|
83898
|
-
]
|
|
83899
|
-
},
|
|
83900
|
-
{
|
|
83901
|
-
name: "milestones",
|
|
83902
|
-
type: "tuple[]",
|
|
83903
|
-
internalType: "struct IEscrowV2.Milestone[]",
|
|
83904
|
-
components: [
|
|
83905
|
-
{ name: "amount", type: "uint96", internalType: "uint96" },
|
|
83906
|
-
{ name: "deadline", type: "uint64", internalType: "uint64" },
|
|
83907
|
-
{ name: "status", type: "uint8", internalType: "uint8" },
|
|
83908
|
-
{ name: "deliveryHash", type: "bytes32", internalType: "bytes32" }
|
|
83909
|
-
]
|
|
83910
|
-
},
|
|
83911
|
-
{ name: "salt", type: "bytes32", internalType: "bytes32" }
|
|
83912
|
-
],
|
|
83913
|
-
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
83914
|
-
stateMutability: "view"
|
|
83915
|
-
},
|
|
83916
|
-
{
|
|
83917
|
-
type: "function",
|
|
83918
|
-
name: "renounceOwnership",
|
|
83919
|
-
inputs: [],
|
|
83920
|
-
outputs: [],
|
|
83921
|
-
stateMutability: "nonpayable"
|
|
83922
|
-
},
|
|
83923
|
-
{
|
|
83924
|
-
type: "function",
|
|
83925
|
-
name: "setFeeBp",
|
|
83926
|
-
inputs: [{ name: "newFeeBp", type: "uint16", internalType: "uint16" }],
|
|
83927
|
-
outputs: [],
|
|
83928
|
-
stateMutability: "nonpayable"
|
|
83929
|
-
},
|
|
83930
|
-
{
|
|
83931
|
-
type: "function",
|
|
83932
|
-
name: "setMaxEscrowAmount",
|
|
83933
|
-
inputs: [{ name: "newAmount", type: "uint256", internalType: "uint256" }],
|
|
83934
|
-
outputs: [],
|
|
83935
|
-
stateMutability: "nonpayable"
|
|
83936
|
-
},
|
|
83937
|
-
{
|
|
83938
|
-
type: "function",
|
|
83939
|
-
name: "transferOwnership",
|
|
83940
|
-
inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
|
|
83941
|
-
outputs: [],
|
|
83942
|
-
stateMutability: "nonpayable"
|
|
83943
|
-
},
|
|
83944
|
-
{ type: "function", name: "unpause", inputs: [], outputs: [], stateMutability: "nonpayable" },
|
|
83945
|
-
{
|
|
83946
|
-
type: "event",
|
|
83947
|
-
name: "EscrowCreated",
|
|
83948
|
-
inputs: [
|
|
83949
|
-
{ name: "escrow", type: "address", indexed: true, internalType: "address" },
|
|
83950
|
-
{ name: "poster", type: "address", indexed: true, internalType: "address" },
|
|
83951
|
-
{ name: "termsHash", type: "bytes32", indexed: true, internalType: "bytes32" },
|
|
83952
|
-
{ name: "salt", type: "bytes32", indexed: false, internalType: "bytes32" },
|
|
83953
|
-
{ name: "feeBp", type: "uint16", indexed: false, internalType: "uint16" }
|
|
83954
|
-
],
|
|
83955
|
-
anonymous: false
|
|
83956
|
-
},
|
|
83957
|
-
{
|
|
83958
|
-
type: "event",
|
|
83959
|
-
name: "FeeBpSet",
|
|
83960
|
-
inputs: [
|
|
83961
|
-
{ name: "previousFeeBp", type: "uint16", indexed: false, internalType: "uint16" },
|
|
83962
|
-
{ name: "newFeeBp", type: "uint16", indexed: false, internalType: "uint16" }
|
|
83963
|
-
],
|
|
83964
|
-
anonymous: false
|
|
83965
|
-
},
|
|
83966
|
-
{
|
|
83967
|
-
type: "event",
|
|
83968
|
-
name: "MaxEscrowAmountSet",
|
|
83969
|
-
inputs: [
|
|
83970
|
-
{ name: "previousAmount", type: "uint256", indexed: false, internalType: "uint256" },
|
|
83971
|
-
{ name: "newAmount", type: "uint256", indexed: false, internalType: "uint256" }
|
|
83972
|
-
],
|
|
83973
|
-
anonymous: false
|
|
83974
|
-
},
|
|
83975
|
-
{
|
|
83976
|
-
type: "event",
|
|
83977
|
-
name: "OwnershipTransferred",
|
|
83978
|
-
inputs: [
|
|
83979
|
-
{ name: "previousOwner", type: "address", indexed: true, internalType: "address" },
|
|
83980
|
-
{ name: "newOwner", type: "address", indexed: true, internalType: "address" }
|
|
83981
|
-
],
|
|
83982
|
-
anonymous: false
|
|
83983
|
-
},
|
|
83984
|
-
{
|
|
83985
|
-
type: "event",
|
|
83986
|
-
name: "PauseSet",
|
|
83987
|
-
inputs: [{ name: "paused", type: "bool", indexed: false, internalType: "bool" }],
|
|
83988
|
-
anonymous: false
|
|
83989
|
-
},
|
|
83990
|
-
{
|
|
83991
|
-
type: "error",
|
|
83992
|
-
name: "EscrowAlreadyExists",
|
|
83993
|
-
inputs: [{ name: "escrow", type: "address", internalType: "address" }]
|
|
83994
|
-
},
|
|
83995
|
-
{
|
|
83996
|
-
type: "error",
|
|
83997
|
-
name: "EscrowAmountAboveCap",
|
|
83998
|
-
inputs: [
|
|
83999
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
84000
|
-
{ name: "cap", type: "uint256", internalType: "uint256" }
|
|
84001
|
-
]
|
|
84002
|
-
},
|
|
84003
|
-
{ type: "error", name: "FactoryPaused", inputs: [] },
|
|
84004
|
-
{ type: "error", name: "FailedDeployment", inputs: [] },
|
|
84005
|
-
{
|
|
84006
|
-
type: "error",
|
|
84007
|
-
name: "InsufficientBalance",
|
|
84008
|
-
inputs: [
|
|
84009
|
-
{ name: "balance", type: "uint256", internalType: "uint256" },
|
|
84010
|
-
{ name: "needed", type: "uint256", internalType: "uint256" }
|
|
84011
|
-
]
|
|
84012
|
-
},
|
|
84013
|
-
{ type: "error", name: "InvalidAddress", inputs: [] },
|
|
84014
|
-
{ type: "error", name: "InvalidFee", inputs: [] },
|
|
84015
|
-
{ type: "error", name: "InvalidToken", inputs: [] },
|
|
84016
|
-
{
|
|
84017
|
-
type: "error",
|
|
84018
|
-
name: "OwnableInvalidOwner",
|
|
84019
|
-
inputs: [{ name: "owner", type: "address", internalType: "address" }]
|
|
84020
|
-
},
|
|
84021
|
-
{
|
|
84022
|
-
type: "error",
|
|
84023
|
-
name: "OwnableUnauthorizedAccount",
|
|
84024
|
-
inputs: [{ name: "account", type: "address", internalType: "address" }]
|
|
84025
|
-
},
|
|
84026
|
-
{
|
|
84027
|
-
type: "error",
|
|
84028
|
-
name: "ShapeMismatch",
|
|
84029
|
-
inputs: [
|
|
84030
|
-
{ name: "expected", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
84031
|
-
{ name: "supplied", type: "uint8", internalType: "enum IEscrowV2.Shape" }
|
|
84032
|
-
]
|
|
84033
|
-
},
|
|
84034
|
-
{
|
|
84035
|
-
type: "error",
|
|
84036
|
-
name: "TermsFeeMismatch",
|
|
84037
|
-
inputs: [
|
|
84038
|
-
{ name: "expected", type: "uint16", internalType: "uint16" },
|
|
84039
|
-
{ name: "supplied", type: "uint16", internalType: "uint16" }
|
|
84040
|
-
]
|
|
83464
|
+
anonymous: false
|
|
83465
|
+
},
|
|
83466
|
+
{
|
|
83467
|
+
type: "event",
|
|
83468
|
+
name: "FeeBpSet",
|
|
83469
|
+
inputs: [
|
|
83470
|
+
{ name: "previousFeeBp", type: "uint16", indexed: false, internalType: "uint16" },
|
|
83471
|
+
{ name: "newFeeBp", type: "uint16", indexed: false, internalType: "uint16" }
|
|
83472
|
+
],
|
|
83473
|
+
anonymous: false
|
|
83474
|
+
},
|
|
83475
|
+
{
|
|
83476
|
+
type: "event",
|
|
83477
|
+
name: "MaxEscrowAmountSet",
|
|
83478
|
+
inputs: [
|
|
83479
|
+
{ name: "previousAmount", type: "uint256", indexed: false, internalType: "uint256" },
|
|
83480
|
+
{ name: "newAmount", type: "uint256", indexed: false, internalType: "uint256" }
|
|
83481
|
+
],
|
|
83482
|
+
anonymous: false
|
|
83483
|
+
},
|
|
83484
|
+
{
|
|
83485
|
+
type: "event",
|
|
83486
|
+
name: "OwnershipTransferred",
|
|
83487
|
+
inputs: [
|
|
83488
|
+
{ name: "previousOwner", type: "address", indexed: true, internalType: "address" },
|
|
83489
|
+
{ name: "newOwner", type: "address", indexed: true, internalType: "address" }
|
|
83490
|
+
],
|
|
83491
|
+
anonymous: false
|
|
83492
|
+
},
|
|
83493
|
+
{
|
|
83494
|
+
type: "event",
|
|
83495
|
+
name: "PauseSet",
|
|
83496
|
+
inputs: [{ name: "paused", type: "bool", indexed: false, internalType: "bool" }],
|
|
83497
|
+
anonymous: false
|
|
83498
|
+
},
|
|
83499
|
+
{
|
|
83500
|
+
type: "error",
|
|
83501
|
+
name: "EscrowAlreadyExists",
|
|
83502
|
+
inputs: [{ name: "escrow", type: "address", internalType: "address" }]
|
|
83503
|
+
},
|
|
83504
|
+
{
|
|
83505
|
+
type: "error",
|
|
83506
|
+
name: "EscrowAmountAboveCap",
|
|
83507
|
+
inputs: [
|
|
83508
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
83509
|
+
{ name: "cap", type: "uint256", internalType: "uint256" }
|
|
83510
|
+
]
|
|
83511
|
+
},
|
|
83512
|
+
{ type: "error", name: "FactoryPaused", inputs: [] },
|
|
83513
|
+
{ type: "error", name: "FailedDeployment", inputs: [] },
|
|
83514
|
+
{
|
|
83515
|
+
type: "error",
|
|
83516
|
+
name: "InsufficientBalance",
|
|
83517
|
+
inputs: [
|
|
83518
|
+
{ name: "balance", type: "uint256", internalType: "uint256" },
|
|
83519
|
+
{ name: "needed", type: "uint256", internalType: "uint256" }
|
|
83520
|
+
]
|
|
83521
|
+
},
|
|
83522
|
+
{ type: "error", name: "InvalidAddress", inputs: [] },
|
|
83523
|
+
{ type: "error", name: "InvalidFee", inputs: [] },
|
|
83524
|
+
{ type: "error", name: "InvalidToken", inputs: [] },
|
|
83525
|
+
{
|
|
83526
|
+
type: "error",
|
|
83527
|
+
name: "OwnableInvalidOwner",
|
|
83528
|
+
inputs: [{ name: "owner", type: "address", internalType: "address" }]
|
|
83529
|
+
},
|
|
83530
|
+
{
|
|
83531
|
+
type: "error",
|
|
83532
|
+
name: "OwnableUnauthorizedAccount",
|
|
83533
|
+
inputs: [{ name: "account", type: "address", internalType: "address" }]
|
|
83534
|
+
},
|
|
83535
|
+
{
|
|
83536
|
+
type: "error",
|
|
83537
|
+
name: "ShapeMismatch",
|
|
83538
|
+
inputs: [
|
|
83539
|
+
{ name: "expected", type: "uint8", internalType: "enum IEscrowV2.Shape" },
|
|
83540
|
+
{ name: "supplied", type: "uint8", internalType: "enum IEscrowV2.Shape" }
|
|
83541
|
+
]
|
|
83542
|
+
},
|
|
83543
|
+
{
|
|
83544
|
+
type: "error",
|
|
83545
|
+
name: "TermsFeeMismatch",
|
|
83546
|
+
inputs: [
|
|
83547
|
+
{ name: "expected", type: "uint16", internalType: "uint16" },
|
|
83548
|
+
{ name: "supplied", type: "uint16", internalType: "uint16" }
|
|
83549
|
+
]
|
|
84041
83550
|
}
|
|
84042
83551
|
];
|
|
84043
83552
|
var escrowV2Abi = [
|
|
@@ -86658,10 +86167,6 @@ var TASK_V2_CASE_STATE = {
|
|
|
86658
86167
|
Snapshotting: 6
|
|
86659
86168
|
};
|
|
86660
86169
|
|
|
86661
|
-
// ../core/src/tasks/operation-support.ts
|
|
86662
|
-
import { readFile as readFile18, stat as stat15 } from "node:fs/promises";
|
|
86663
|
-
import { basename as basename2, extname } from "node:path";
|
|
86664
|
-
|
|
86665
86170
|
// ../core/src/tasks/v2-events.ts
|
|
86666
86171
|
var TASK_V2_NO_VERDICT_SUMMARY = "Disputed: status quo final after round 2 without a verdict; no dispute winner.";
|
|
86667
86172
|
var TASK_V2_REVIEWER_GUIDANCE = "mayVote reports jury membership only. Do not touch your stake until you have revealed; even a cancelled unstake can cost the vote.";
|
|
@@ -86696,6 +86201,73 @@ function taskV2OutcomeLines(value) {
|
|
|
86696
86201
|
return [...new Set(Object.values(source).flatMap(taskV2OutcomeLines))];
|
|
86697
86202
|
}
|
|
86698
86203
|
|
|
86204
|
+
// ../core/src/tasks/money.ts
|
|
86205
|
+
function formatBaseUnitsUsd(baseUnits2) {
|
|
86206
|
+
const [whole, fraction = ""] = formatUsdc(parseBaseUnits(baseUnits2)).split(".");
|
|
86207
|
+
return `${whole}.${fraction.padEnd(2, "0")}`;
|
|
86208
|
+
}
|
|
86209
|
+
function parseUsdToBaseUnits(text) {
|
|
86210
|
+
if (!/^\d+(?:\.\d{1,6})?$/u.test(text)) {
|
|
86211
|
+
throw new Error(
|
|
86212
|
+
"Task USD amount must be a non-negative decimal with at most six decimal places."
|
|
86213
|
+
);
|
|
86214
|
+
}
|
|
86215
|
+
const [whole = "0", fraction = ""] = text.split(".");
|
|
86216
|
+
return BigInt(whole) * 1000000n + BigInt(fraction.padEnd(6, "0"));
|
|
86217
|
+
}
|
|
86218
|
+
function parseFeeBp(deploymentOrReadiness) {
|
|
86219
|
+
if (typeof deploymentOrReadiness !== "object" || deploymentOrReadiness === null || !("feeBp" in deploymentOrReadiness)) {
|
|
86220
|
+
return null;
|
|
86221
|
+
}
|
|
86222
|
+
const feeBp = deploymentOrReadiness.feeBp;
|
|
86223
|
+
if (feeBp === void 0 || feeBp === null) return null;
|
|
86224
|
+
validateFeeBp(feeBp);
|
|
86225
|
+
return feeBp;
|
|
86226
|
+
}
|
|
86227
|
+
function taskMoney(grossBaseUnits, feeBp) {
|
|
86228
|
+
const atomic = parseBaseUnits(grossBaseUnits);
|
|
86229
|
+
const gross = amount3(atomic);
|
|
86230
|
+
if (feeBp === null) {
|
|
86231
|
+
return { gross, fee: null, net: null, feeBp, line: `$${gross.usd} gross \xB7 fee unavailable` };
|
|
86232
|
+
}
|
|
86233
|
+
validateFeeBp(feeBp);
|
|
86234
|
+
const feeAtomic = atomic * BigInt(feeBp) / 10000n;
|
|
86235
|
+
const fee = amount3(feeAtomic);
|
|
86236
|
+
const net = amount3(atomic - feeAtomic);
|
|
86237
|
+
return {
|
|
86238
|
+
gross,
|
|
86239
|
+
fee,
|
|
86240
|
+
net,
|
|
86241
|
+
feeBp,
|
|
86242
|
+
line: `$${gross.usd} gross \xB7 $${fee.usd} fee \xB7 $${net.usd} net`
|
|
86243
|
+
};
|
|
86244
|
+
}
|
|
86245
|
+
function amount3(atomic) {
|
|
86246
|
+
return { usd: formatBaseUnitsUsd(atomic), baseUnits: atomic.toString() };
|
|
86247
|
+
}
|
|
86248
|
+
function validateFeeBp(value) {
|
|
86249
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 1e4) {
|
|
86250
|
+
throw new Error("Task fee basis points must be an integer from 0 to 10000.");
|
|
86251
|
+
}
|
|
86252
|
+
}
|
|
86253
|
+
function parseBaseUnits(value) {
|
|
86254
|
+
if (typeof value === "string" && !/^\d+$/u.test(value) || typeof value !== "bigint" && typeof value !== "string") {
|
|
86255
|
+
throw new Error("Task base units must be a non-negative integer.");
|
|
86256
|
+
}
|
|
86257
|
+
const atomic = BigInt(value);
|
|
86258
|
+
if (atomic < 0n) throw new Error("Task base units must be a non-negative integer.");
|
|
86259
|
+
return atomic;
|
|
86260
|
+
}
|
|
86261
|
+
function taskPolicyAtomic(value) {
|
|
86262
|
+
if (!Number.isFinite(value) || value < 0)
|
|
86263
|
+
throw new Error("Task policy USD amounts must be finite and non-negative.");
|
|
86264
|
+
const [mantissa = "0", exponent = "0"] = value.toString().split("e");
|
|
86265
|
+
const [whole = "0", fraction = ""] = mantissa.split(".");
|
|
86266
|
+
const digits = BigInt(whole + fraction);
|
|
86267
|
+
const scale = 6 + Number(exponent) - fraction.length;
|
|
86268
|
+
return scale >= 0 ? digits * 10n ** BigInt(scale) : digits / 10n ** BigInt(-scale);
|
|
86269
|
+
}
|
|
86270
|
+
|
|
86699
86271
|
// ../core/src/tasks/operation-support.ts
|
|
86700
86272
|
var TaskOperationError = class extends Error {
|
|
86701
86273
|
constructor(code, message, manifestHash, details) {
|
|
@@ -86972,121 +86544,667 @@ function nextTaskEvents(page, cursor2) {
|
|
|
86972
86544
|
"invalid_response",
|
|
86973
86545
|
"The task event cursor regressed or is malformed."
|
|
86974
86546
|
);
|
|
86975
|
-
for (const event of page.events)
|
|
86976
|
-
if (!Number.isSafeInteger(event.sequence) || event.sequence < 0)
|
|
86977
|
-
throw new TaskOperationError("invalid_response", "A task event sequence is malformed.");
|
|
86978
|
-
const seen = /* @__PURE__ */ new Set();
|
|
86979
|
-
const events = [...page.events].sort((a, b) => a.sequence - b.sequence).filter((event) => {
|
|
86980
|
-
if (event.sequence <= cursor2 || seen.has(event.sequence)) return false;
|
|
86981
|
-
seen.add(event.sequence);
|
|
86982
|
-
return true;
|
|
86547
|
+
for (const event of page.events)
|
|
86548
|
+
if (!Number.isSafeInteger(event.sequence) || event.sequence < 0)
|
|
86549
|
+
throw new TaskOperationError("invalid_response", "A task event sequence is malformed.");
|
|
86550
|
+
const seen = /* @__PURE__ */ new Set();
|
|
86551
|
+
const events = [...page.events].sort((a, b) => a.sequence - b.sequence).filter((event) => {
|
|
86552
|
+
if (event.sequence <= cursor2 || seen.has(event.sequence)) return false;
|
|
86553
|
+
seen.add(event.sequence);
|
|
86554
|
+
return true;
|
|
86555
|
+
});
|
|
86556
|
+
return {
|
|
86557
|
+
events,
|
|
86558
|
+
nextCursor: Math.max(cursor2, page.nextAfter, ...page.events.map((e3) => e3.sequence))
|
|
86559
|
+
};
|
|
86560
|
+
}
|
|
86561
|
+
async function accountTaskPolicy(directory, wallet, warn) {
|
|
86562
|
+
let raw;
|
|
86563
|
+
try {
|
|
86564
|
+
raw = await readFile18(join16(directory, "wallets.json"), "utf8");
|
|
86565
|
+
} catch {
|
|
86566
|
+
return void 0;
|
|
86567
|
+
}
|
|
86568
|
+
try {
|
|
86569
|
+
const wallets = JSON.parse(raw).wallets;
|
|
86570
|
+
const stored = wallets && Object.hasOwn(wallets, wallet) ? wallets[wallet]?.taskPolicy : void 0;
|
|
86571
|
+
return stored === void 0 ? void 0 : walletTaskPolicySchema.parse(stored);
|
|
86572
|
+
} catch {
|
|
86573
|
+
warn?.(`The task limits stored for account ${wallet} are unreadable; using the defaults.`);
|
|
86574
|
+
return void 0;
|
|
86575
|
+
}
|
|
86576
|
+
}
|
|
86577
|
+
async function taskPolicyForWallet(args) {
|
|
86578
|
+
let invalid = false;
|
|
86579
|
+
const profiles = await listAgentProfiles(args.directory, {
|
|
86580
|
+
schema: args.schema,
|
|
86581
|
+
...args.warn ? { warn: args.warn } : {},
|
|
86582
|
+
onInvalid: () => {
|
|
86583
|
+
invalid = true;
|
|
86584
|
+
}
|
|
86585
|
+
});
|
|
86586
|
+
if (invalid) throw new TaskInputError("An invalid agent profile prevents task policy selection.");
|
|
86587
|
+
const matches = profiles.filter((profile2) => profile2.wallet === args.wallet);
|
|
86588
|
+
if (matches.length > 1)
|
|
86589
|
+
throw new TaskInputError(
|
|
86590
|
+
`More than one agent profile uses wallet ${args.wallet}; task policy is ambiguous.`
|
|
86591
|
+
);
|
|
86592
|
+
const profile = matches[0];
|
|
86593
|
+
if (profile)
|
|
86594
|
+
return {
|
|
86595
|
+
maxPerTaskUsd: profile.maxPerTaskUsd,
|
|
86596
|
+
approveAboveUsd: profile.approveAboveUsd,
|
|
86597
|
+
autoReleaseBelowUsd: profile.autoReleaseBelowUsd,
|
|
86598
|
+
source: "agent-profile"
|
|
86599
|
+
};
|
|
86600
|
+
const account = await accountTaskPolicy(args.directory, args.wallet, args.warn);
|
|
86601
|
+
const stored = account?.maxPerTaskUsd !== void 0 || account?.approveAboveUsd !== void 0;
|
|
86602
|
+
return {
|
|
86603
|
+
maxPerTaskUsd: account?.maxPerTaskUsd ?? DEFAULT_MAX_PER_TASK_USD,
|
|
86604
|
+
approveAboveUsd: account?.approveAboveUsd ?? agentProfileSchema.shape.approveAboveUsd.parse(void 0),
|
|
86605
|
+
autoReleaseBelowUsd: DEFAULT_AUTO_RELEASE_BELOW_USD,
|
|
86606
|
+
source: stored ? "account" : "defaults"
|
|
86607
|
+
};
|
|
86608
|
+
}
|
|
86609
|
+
async function taskMoneySnapshot(client, orderId, escrowId, options = { signInHint: "" }) {
|
|
86610
|
+
const order = await taskRequest(
|
|
86611
|
+
"task money",
|
|
86612
|
+
"getOrder",
|
|
86613
|
+
() => client.getOrder(orderId),
|
|
86614
|
+
options
|
|
86615
|
+
), workOrder = order.workOrder;
|
|
86616
|
+
if (workOrder.id !== orderId || workOrder.version !== "work-order-view-v1")
|
|
86617
|
+
throw new TaskOperationError(
|
|
86618
|
+
"invalid_response",
|
|
86619
|
+
"A private task order matching the requested ID is required."
|
|
86620
|
+
);
|
|
86621
|
+
const matches = escrowId ? workOrder.milestones.filter((m) => m.id === escrowId) : workOrder.milestones;
|
|
86622
|
+
if (matches.length !== 1)
|
|
86623
|
+
throw new TaskOperationError("invalid_response", "Select one task milestone by escrow ID.");
|
|
86624
|
+
const milestone = matches[0];
|
|
86625
|
+
if (milestone.workOrderId !== orderId)
|
|
86626
|
+
throw new TaskOperationError("invalid_response", "The milestone belongs to a different task.");
|
|
86627
|
+
let readiness;
|
|
86628
|
+
try {
|
|
86629
|
+
readiness = { ok: true, value: await client.deployment() };
|
|
86630
|
+
} catch (error61) {
|
|
86631
|
+
readiness = { ok: false, error: error61 };
|
|
86632
|
+
}
|
|
86633
|
+
return {
|
|
86634
|
+
order,
|
|
86635
|
+
escrowId: milestone.id,
|
|
86636
|
+
money: taskMoney(milestone.amountBaseUnits, readiness.ok ? parseFeeBp(readiness.value) : null),
|
|
86637
|
+
readiness
|
|
86638
|
+
};
|
|
86639
|
+
}
|
|
86640
|
+
function cachedMoneyClient(client, snapshot) {
|
|
86641
|
+
return new Proxy(client, {
|
|
86642
|
+
get(target, property) {
|
|
86643
|
+
if (property === "getOrder")
|
|
86644
|
+
return async (id2) => {
|
|
86645
|
+
if (id2 !== snapshot.order.workOrder.id)
|
|
86646
|
+
throw new Error("The cached task order does not match the requested ID.");
|
|
86647
|
+
return snapshot.order;
|
|
86648
|
+
};
|
|
86649
|
+
if (property === "deployment")
|
|
86650
|
+
return async () => {
|
|
86651
|
+
if (snapshot.readiness.ok) return snapshot.readiness.value;
|
|
86652
|
+
throw snapshot.readiness.error;
|
|
86653
|
+
};
|
|
86654
|
+
const value = Reflect.get(target, property, target);
|
|
86655
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
86656
|
+
}
|
|
86657
|
+
});
|
|
86658
|
+
}
|
|
86659
|
+
function fundingRefusalReason(error61) {
|
|
86660
|
+
if (error61 instanceof Error && error61.name === "SpendCapExceededError") {
|
|
86661
|
+
const fromCause = fundingRefusalReason(error61.cause);
|
|
86662
|
+
if (fromCause) return fromCause;
|
|
86663
|
+
return "cap" in error61 && error61.cap === "per_day" ? "policy.perDay" : void 0;
|
|
86664
|
+
}
|
|
86665
|
+
if (!(error61 instanceof SpendCapError || error61 instanceof Error && error61.name === "SpendCapError"))
|
|
86666
|
+
return void 0;
|
|
86667
|
+
const code = "code" in error61 ? error61.code : void 0;
|
|
86668
|
+
return code === "per_task_cap_exceeded" ? "policy.perTask" : code === "per_day_cap_exceeded" ? "policy.perDay" : void 0;
|
|
86669
|
+
}
|
|
86670
|
+
function taskEventLine(event) {
|
|
86671
|
+
const label2 = event.type === "task.judging" ? `deadline passed, ${event.payload.submissionCount} submissions, pick winners` : event.type === "task.claimed" ? "first submission received" : event.type === "task.checkin" ? `check-in: ${event.payload.status ?? "received"}` : event.type === "task.stalled" ? "task stalled" : event.type === "task.milestone" ? "milestone updated" : event.type === "task.released" ? "escrow released" : event.type;
|
|
86672
|
+
return `${event.sequence}: ${[label2, ...taskV2OutcomeLines(event.payload)].join(" \xB7 ")}`;
|
|
86673
|
+
}
|
|
86674
|
+
function requireTaskMethod(client, name) {
|
|
86675
|
+
const method = client[name];
|
|
86676
|
+
if (typeof method !== "function")
|
|
86677
|
+
throw new TaskOperationError(
|
|
86678
|
+
"not_supported",
|
|
86679
|
+
`Task method ${name} is not supported by this SDK adapter.`
|
|
86680
|
+
);
|
|
86681
|
+
return method.bind(client);
|
|
86682
|
+
}
|
|
86683
|
+
|
|
86684
|
+
// ../core/src/tasks/availability.ts
|
|
86685
|
+
var TASK_V2_NEW_WORK_ACTIONS = [
|
|
86686
|
+
"fund",
|
|
86687
|
+
"approve-bond",
|
|
86688
|
+
"award",
|
|
86689
|
+
"award-consent"
|
|
86690
|
+
];
|
|
86691
|
+
var NETWORK_NAMES = {
|
|
86692
|
+
8453: "Base",
|
|
86693
|
+
84532: "Base Sepolia",
|
|
86694
|
+
5042002: "Arc testnet"
|
|
86695
|
+
};
|
|
86696
|
+
function taskNetworkName(chainId) {
|
|
86697
|
+
return NETWORK_NAMES[chainId] ?? `chain ${chainId}`;
|
|
86698
|
+
}
|
|
86699
|
+
function tasksUnavailableError(chainId, untouched = "Nothing was signed and no money moved.", code = "tasks_unavailable") {
|
|
86700
|
+
return new TaskOperationError(
|
|
86701
|
+
code,
|
|
86702
|
+
`vAPI reports Tasks as unavailable on ${taskNetworkName(chainId)} right now. ${untouched} Try again later.`
|
|
86703
|
+
);
|
|
86704
|
+
}
|
|
86705
|
+
async function readTasksReadiness(client) {
|
|
86706
|
+
try {
|
|
86707
|
+
return await client.deployment();
|
|
86708
|
+
} catch {
|
|
86709
|
+
return void 0;
|
|
86710
|
+
}
|
|
86711
|
+
}
|
|
86712
|
+
function requireTasksAvailable(action, readiness, untouched) {
|
|
86713
|
+
if (!TASK_V2_NEW_WORK_ACTIONS.includes(action)) return;
|
|
86714
|
+
if (!readiness)
|
|
86715
|
+
throw new TaskOperationError(
|
|
86716
|
+
"tasks_unavailable",
|
|
86717
|
+
`vAPI's Tasks status could not be read. ${untouched ?? "Nothing was signed and no money moved."} Try again later.`
|
|
86718
|
+
);
|
|
86719
|
+
if (!readiness.configured) throw tasksUnavailableError(readiness.chainId, untouched);
|
|
86720
|
+
}
|
|
86721
|
+
|
|
86722
|
+
// ../core/src/tasks/dispute-fee.ts
|
|
86723
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
86724
|
+
function disputeFeeBaseUnits(amount4) {
|
|
86725
|
+
if (amount4 < 0n) throw new Error("Dispute amount must be nonnegative.");
|
|
86726
|
+
const fee = amount4 * 1000n / 10000n;
|
|
86727
|
+
return fee < 20000000n ? 20000000n : fee > 500000000n ? 500000000n : fee;
|
|
86728
|
+
}
|
|
86729
|
+
function taskFeeReservationKey(milestoneId2, action) {
|
|
86730
|
+
const bytes = createHash3("sha256").update(JSON.stringify([milestoneId2, action])).digest().subarray(0, 16);
|
|
86731
|
+
bytes[6] = bytes[6] & 15 | 80;
|
|
86732
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
86733
|
+
const hex5 = bytes.toString("hex");
|
|
86734
|
+
return `${hex5.slice(0, 8)}-${hex5.slice(8, 12)}-${hex5.slice(12, 16)}-${hex5.slice(16, 20)}-${hex5.slice(20)}`;
|
|
86735
|
+
}
|
|
86736
|
+
|
|
86737
|
+
// ../core/src/tasks/plan-guard.ts
|
|
86738
|
+
var TASKS_CHAIN_ABI = [
|
|
86739
|
+
{
|
|
86740
|
+
type: "function",
|
|
86741
|
+
name: "createEscrow",
|
|
86742
|
+
stateMutability: "nonpayable",
|
|
86743
|
+
inputs: [
|
|
86744
|
+
{ name: "buyer", type: "address" },
|
|
86745
|
+
{ name: "token", type: "address" },
|
|
86746
|
+
{ name: "amount", type: "uint256" },
|
|
86747
|
+
{ name: "workDuration", type: "uint64" },
|
|
86748
|
+
{ name: "acceptanceWindow", type: "uint64" },
|
|
86749
|
+
{ name: "termsHash", type: "bytes32" },
|
|
86750
|
+
{ name: "salt", type: "bytes32" }
|
|
86751
|
+
],
|
|
86752
|
+
outputs: [{ name: "escrow", type: "address" }]
|
|
86753
|
+
},
|
|
86754
|
+
{
|
|
86755
|
+
type: "function",
|
|
86756
|
+
name: "fundWithAuthorization",
|
|
86757
|
+
stateMutability: "nonpayable",
|
|
86758
|
+
inputs: [
|
|
86759
|
+
{ name: "validAfter", type: "uint256" },
|
|
86760
|
+
{ name: "validBefore", type: "uint256" },
|
|
86761
|
+
{ name: "nonce", type: "bytes32" },
|
|
86762
|
+
{ name: "signature", type: "bytes" }
|
|
86763
|
+
],
|
|
86764
|
+
outputs: []
|
|
86765
|
+
},
|
|
86766
|
+
{
|
|
86767
|
+
type: "function",
|
|
86768
|
+
name: "approve",
|
|
86769
|
+
stateMutability: "nonpayable",
|
|
86770
|
+
inputs: [
|
|
86771
|
+
{ name: "spender", type: "address" },
|
|
86772
|
+
{ name: "amount", type: "uint256" }
|
|
86773
|
+
],
|
|
86774
|
+
outputs: [{ name: "ok", type: "bool" }]
|
|
86775
|
+
},
|
|
86776
|
+
{
|
|
86777
|
+
type: "function",
|
|
86778
|
+
name: "depositFunds",
|
|
86779
|
+
stateMutability: "nonpayable",
|
|
86780
|
+
inputs: [],
|
|
86781
|
+
outputs: []
|
|
86782
|
+
},
|
|
86783
|
+
{
|
|
86784
|
+
type: "function",
|
|
86785
|
+
name: "submitDelivery",
|
|
86786
|
+
stateMutability: "nonpayable",
|
|
86787
|
+
inputs: [{ name: "manifestHash", type: "bytes32" }],
|
|
86788
|
+
outputs: []
|
|
86789
|
+
},
|
|
86790
|
+
{
|
|
86791
|
+
type: "function",
|
|
86792
|
+
name: "releaseFunds",
|
|
86793
|
+
stateMutability: "nonpayable",
|
|
86794
|
+
inputs: [],
|
|
86795
|
+
outputs: []
|
|
86796
|
+
},
|
|
86797
|
+
{ type: "function", name: "refundBuyer", stateMutability: "nonpayable", inputs: [], outputs: [] },
|
|
86798
|
+
{
|
|
86799
|
+
type: "function",
|
|
86800
|
+
name: "raiseDispute",
|
|
86801
|
+
stateMutability: "nonpayable",
|
|
86802
|
+
inputs: [{ name: "evidenceHash", type: "bytes32" }],
|
|
86803
|
+
outputs: []
|
|
86804
|
+
},
|
|
86805
|
+
{
|
|
86806
|
+
type: "function",
|
|
86807
|
+
name: "submitCounterEvidence",
|
|
86808
|
+
stateMutability: "nonpayable",
|
|
86809
|
+
inputs: [{ name: "evidenceHash", type: "bytes32" }],
|
|
86810
|
+
outputs: []
|
|
86811
|
+
},
|
|
86812
|
+
{
|
|
86813
|
+
type: "function",
|
|
86814
|
+
name: "resolveUnmatchedDispute",
|
|
86815
|
+
stateMutability: "nonpayable",
|
|
86816
|
+
inputs: [],
|
|
86817
|
+
outputs: []
|
|
86818
|
+
},
|
|
86819
|
+
{
|
|
86820
|
+
type: "function",
|
|
86821
|
+
name: "timeoutRefund",
|
|
86822
|
+
stateMutability: "nonpayable",
|
|
86823
|
+
inputs: [],
|
|
86824
|
+
outputs: []
|
|
86825
|
+
},
|
|
86826
|
+
{ type: "function", name: "finalize", stateMutability: "nonpayable", inputs: [], outputs: [] },
|
|
86827
|
+
{
|
|
86828
|
+
type: "function",
|
|
86829
|
+
name: "disputeFee",
|
|
86830
|
+
stateMutability: "view",
|
|
86831
|
+
inputs: [],
|
|
86832
|
+
outputs: [{ name: "fee", type: "uint256" }]
|
|
86833
|
+
},
|
|
86834
|
+
{
|
|
86835
|
+
type: "function",
|
|
86836
|
+
name: "allowance",
|
|
86837
|
+
stateMutability: "view",
|
|
86838
|
+
inputs: [
|
|
86839
|
+
{ name: "owner", type: "address" },
|
|
86840
|
+
{ name: "spender", type: "address" }
|
|
86841
|
+
],
|
|
86842
|
+
outputs: [{ name: "amount", type: "uint256" }]
|
|
86843
|
+
}
|
|
86844
|
+
];
|
|
86845
|
+
var TASKS_READ_ABI = parseAbi([
|
|
86846
|
+
"function paymentToken() view returns (address)",
|
|
86847
|
+
"function isEscrow(address escrow) view returns (bool)",
|
|
86848
|
+
"function name() view returns (string)",
|
|
86849
|
+
"function version() view returns (string)",
|
|
86850
|
+
"function buyer() view returns (address)",
|
|
86851
|
+
"function seller() view returns (address)",
|
|
86852
|
+
"function token() view returns (address)",
|
|
86853
|
+
"function amount() view returns (uint256)",
|
|
86854
|
+
"function termsHash() view returns (bytes32)",
|
|
86855
|
+
"function state() view returns (uint8)",
|
|
86856
|
+
"function offerDeadline() view returns (uint64)",
|
|
86857
|
+
"function workDeadline() view returns (uint64)",
|
|
86858
|
+
"function reviewDeadline() view returns (uint64)",
|
|
86859
|
+
"function disputedAt() view returns (uint64)",
|
|
86860
|
+
"function counterEvidenceDeadline() view returns (uint64)",
|
|
86861
|
+
"function resolution() view returns (uint8)",
|
|
86862
|
+
"function disputeFee() view returns (uint256)",
|
|
86863
|
+
"function predictEscrow(address seller, bytes32 salt) view returns (address)"
|
|
86864
|
+
]);
|
|
86865
|
+
function verifyPlan(operation, expectation) {
|
|
86866
|
+
const fail2 = (message) => {
|
|
86867
|
+
throw new TasksChainError(`Unsafe transaction plan: ${message}`, false);
|
|
86868
|
+
};
|
|
86869
|
+
const plan = operation.plan;
|
|
86870
|
+
if (!plan) throw new TasksChainError("Unsafe transaction plan: missing plan", false);
|
|
86871
|
+
if (plan.operationId !== operation.id || plan.step !== operation.step) fail2("operation mismatch");
|
|
86872
|
+
if (!expectation.steps.includes(plan.step)) fail2("unexpected step");
|
|
86873
|
+
if (!operation.expectedActor || getAddress(operation.expectedActor) !== getAddress(expectation.signer) || getAddress(plan.from) !== getAddress(expectation.signer))
|
|
86874
|
+
fail2("unexpected signer");
|
|
86875
|
+
if (plan.chainId !== expectation.deployment.chainId || plan.network !== expectation.deployment.network || plan.network !== `eip155:${plan.chainId}` || plan.value !== "0")
|
|
86876
|
+
fail2("unexpected network or value");
|
|
86877
|
+
if (expectation.milestone.network !== plan.network || expectation.milestone.asset.toLowerCase() !== `${plan.network}/erc20:${expectation.deployment.usdc}`.toLowerCase())
|
|
86878
|
+
fail2("milestone asset mismatch");
|
|
86879
|
+
const target = plan.step === "create-escrow" ? expectation.deployment.escrowContract : plan.step === "approve-usdc" ? expectation.deployment.usdc : expectation.milestone.escrowContract;
|
|
86880
|
+
if (getAddress(plan.to) !== getAddress(target)) fail2("unexpected target");
|
|
86881
|
+
const decoded = (() => {
|
|
86882
|
+
try {
|
|
86883
|
+
return decodeFunctionData({ abi: TASKS_CHAIN_ABI, data: plan.data });
|
|
86884
|
+
} catch {
|
|
86885
|
+
return fail2("invalid calldata");
|
|
86886
|
+
}
|
|
86887
|
+
})();
|
|
86888
|
+
const expectedName = {
|
|
86889
|
+
"create-escrow": "createEscrow",
|
|
86890
|
+
"fund-with-authorization": "fundWithAuthorization",
|
|
86891
|
+
"approve-usdc": "approve",
|
|
86892
|
+
"deposit-funds": "depositFunds",
|
|
86893
|
+
"submit-delivery": "submitDelivery",
|
|
86894
|
+
"release-funds": "releaseFunds",
|
|
86895
|
+
"refund-buyer": "refundBuyer",
|
|
86896
|
+
"raise-dispute": "raiseDispute",
|
|
86897
|
+
"submit-counter-evidence": "submitCounterEvidence",
|
|
86898
|
+
"resolve-unmatched-dispute": "resolveUnmatchedDispute",
|
|
86899
|
+
"timeout-refund": "timeoutRefund",
|
|
86900
|
+
finalize: "finalize"
|
|
86901
|
+
};
|
|
86902
|
+
if (decoded.functionName !== expectedName[plan.step]) fail2("unexpected selector");
|
|
86903
|
+
const args = [...decoded.args ?? []];
|
|
86904
|
+
const eq = (a, b) => typeof a === "string" && typeof b === "string" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
86905
|
+
const requireArgs = (values) => {
|
|
86906
|
+
if (args.length !== values.length || args.some((v, i2) => !eq(v, values[i2])))
|
|
86907
|
+
fail2("unexpected arguments");
|
|
86908
|
+
};
|
|
86909
|
+
if (plan.step === "create-escrow") {
|
|
86910
|
+
if (!expectation.seller || getAddress(expectation.signer) !== getAddress(expectation.seller))
|
|
86911
|
+
fail2("createEscrow requires the locally bound seller");
|
|
86912
|
+
const workDuration = expectation.workDurationSeconds ?? expectation.milestone.terms.workDurationSeconds ?? getTrustedTasksDurations(expectation.deployment.chainId).workDurationSeconds;
|
|
86913
|
+
if (workDuration === void 0) fail2("missing trusted work duration");
|
|
86914
|
+
requireArgs([
|
|
86915
|
+
expectation.buyer,
|
|
86916
|
+
expectation.deployment.usdc,
|
|
86917
|
+
BigInt(expectation.milestone.amountBaseUnits),
|
|
86918
|
+
BigInt(workDuration),
|
|
86919
|
+
BigInt(
|
|
86920
|
+
expectation.reviewWindowSeconds ?? expectation.milestone.terms.acceptanceWindowSeconds
|
|
86921
|
+
),
|
|
86922
|
+
expectation.milestone.termsHash,
|
|
86923
|
+
keccak256(stringToHex(expectation.milestone.id))
|
|
86924
|
+
]);
|
|
86925
|
+
} else if (plan.step === "fund-with-authorization") {
|
|
86926
|
+
const a = expectation.authorization;
|
|
86927
|
+
if (!a)
|
|
86928
|
+
throw new TasksChainError("Unsafe transaction plan: missing local authorization", false);
|
|
86929
|
+
requireArgs([BigInt(a.validAfter), BigInt(a.validBefore), a.nonce, a.signature]);
|
|
86930
|
+
} else if (plan.step === "approve-usdc") {
|
|
86931
|
+
if (expectation.approveAmount === void 0) fail2("missing verified approval amount");
|
|
86932
|
+
requireArgs([expectation.milestone.escrowContract, expectation.approveAmount]);
|
|
86933
|
+
} else if (plan.step === "submit-delivery") {
|
|
86934
|
+
if (!expectation.manifestHash) fail2("missing manifest hash");
|
|
86935
|
+
requireArgs([expectation.manifestHash]);
|
|
86936
|
+
} else if (plan.step === "raise-dispute" || plan.step === "submit-counter-evidence") {
|
|
86937
|
+
if (!expectation.evidenceHash) fail2("missing evidence hash");
|
|
86938
|
+
requireArgs([expectation.evidenceHash]);
|
|
86939
|
+
} else requireArgs([]);
|
|
86940
|
+
}
|
|
86941
|
+
|
|
86942
|
+
// ../core/src/tasks/chain-verification.ts
|
|
86943
|
+
var TasksPartiesNotBoundError = class extends TasksValidationError {
|
|
86944
|
+
constructor() {
|
|
86945
|
+
super(
|
|
86946
|
+
"The task parties are not bound on this machine. Sign the scope with `vapi task sign` on this machine first; an explicit --counterparty only confirms an existing binding."
|
|
86947
|
+
);
|
|
86948
|
+
this.name = "TasksPartiesNotBoundError";
|
|
86949
|
+
}
|
|
86950
|
+
};
|
|
86951
|
+
async function verifyDeployment(ready, rpc, overrides) {
|
|
86952
|
+
const factory = getTrustedTasksFactory(ready.chainId, overrides);
|
|
86953
|
+
if (!factory)
|
|
86954
|
+
throw new TasksChainError(
|
|
86955
|
+
`No trusted Tasks escrow factory is configured for chain ${ready.chainId}. Set VAPI_TASKS_ESCROW_FACTORY_${ready.chainId}.`,
|
|
86956
|
+
false,
|
|
86957
|
+
{ authorizationExposed: false }
|
|
86958
|
+
);
|
|
86959
|
+
if (!isAddressEqual(factory, ready.escrowContract))
|
|
86960
|
+
throw new TasksValidationError(
|
|
86961
|
+
"The Tasks readiness factory does not match the trusted factory."
|
|
86962
|
+
);
|
|
86963
|
+
if (await rpc.getChainId() !== ready.chainId)
|
|
86964
|
+
throw new TasksValidationError("The RPC chain ID does not match the task deployment.");
|
|
86965
|
+
const token = await rpc.readContract({
|
|
86966
|
+
address: factory,
|
|
86967
|
+
abi: TASKS_READ_ABI,
|
|
86968
|
+
functionName: "paymentToken"
|
|
86983
86969
|
});
|
|
86970
|
+
if (!isAddressEqual(token, ready.usdc))
|
|
86971
|
+
throw new TasksValidationError(
|
|
86972
|
+
"The Tasks readiness token does not match the trusted factory payment token."
|
|
86973
|
+
);
|
|
86974
|
+
const [name, version5] = await Promise.all([
|
|
86975
|
+
rpc.readContract({ address: token, abi: TASKS_READ_ABI, functionName: "name" }),
|
|
86976
|
+
rpc.readContract({ address: token, abi: TASKS_READ_ABI, functionName: "version" })
|
|
86977
|
+
]);
|
|
86978
|
+
const domain2 = { name, version: version5, chainId: ready.chainId, verifyingContract: getAddress(token) };
|
|
86979
|
+
if (ready.eip3009Domain && (ready.eip3009Domain.name !== name || ready.eip3009Domain.version !== version5 || ready.eip3009Domain.chainId !== ready.chainId || !isAddressEqual(ready.eip3009Domain.verifyingContract, token)))
|
|
86980
|
+
throw new TasksValidationError(
|
|
86981
|
+
"The funding authorization domain does not match the onchain token domain."
|
|
86982
|
+
);
|
|
86984
86983
|
return {
|
|
86985
|
-
|
|
86986
|
-
|
|
86984
|
+
...ready,
|
|
86985
|
+
escrowContract: getAddress(factory),
|
|
86986
|
+
usdc: getAddress(token),
|
|
86987
|
+
eip3009Domain: domain2
|
|
86987
86988
|
};
|
|
86988
86989
|
}
|
|
86989
|
-
async function
|
|
86990
|
-
|
|
86991
|
-
const
|
|
86992
|
-
|
|
86993
|
-
|
|
86994
|
-
|
|
86995
|
-
|
|
86996
|
-
|
|
86997
|
-
|
|
86998
|
-
|
|
86999
|
-
|
|
87000
|
-
|
|
87001
|
-
|
|
87002
|
-
`More than one agent profile uses wallet ${args.wallet}; task policy is ambiguous.`
|
|
86990
|
+
async function verifyScope(client, signer, selected, ready, verb, steps, options = {}) {
|
|
86991
|
+
const { scopes } = await client.getScopes(selected.workOrderId);
|
|
86992
|
+
const matches = scopes.filter(
|
|
86993
|
+
(scope2) => scope2.state === "accepted" && scope2.milestoneId === selected.id
|
|
86994
|
+
);
|
|
86995
|
+
if (matches.length !== 1)
|
|
86996
|
+
throw new TasksValidationError("The task milestone requires one accepted signed scope.");
|
|
86997
|
+
const scope = matches[0];
|
|
86998
|
+
const payload = scope.signingPayload;
|
|
86999
|
+
const frozen = freezeScopeTerms(scope.structuredTerms, scope.brief);
|
|
87000
|
+
if (scope.workOrderId !== selected.workOrderId || payload.workOrderId !== selected.workOrderId || payload.trancheOrdinal !== selected.ordinal || scope.trancheOrdinal !== selected.ordinal || payload.scopeVersion !== scope.version || frozen.termsHash !== scope.termsHash || frozen.termsHash !== payload.termsHash || frozen.termsHash !== selected.termsHash)
|
|
87001
|
+
throw new TasksValidationError(
|
|
87002
|
+
"The accepted task scope does not match its locally verified terms hash and milestone."
|
|
87003
87003
|
);
|
|
87004
|
-
|
|
87005
|
-
|
|
87006
|
-
|
|
87007
|
-
|
|
87008
|
-
|
|
87009
|
-
|
|
87010
|
-
|
|
87011
|
-
|
|
87012
|
-
|
|
87013
|
-
|
|
87014
|
-
|
|
87004
|
+
if (!scope.counterpartyAddress || !scope.counterpartySignature || isAddressEqual(scope.proposerAddress, scope.counterpartyAddress) || !(isAddressEqual(signer, scope.proposerAddress) || isAddressEqual(signer, scope.counterpartyAddress)))
|
|
87005
|
+
throw new TasksValidationError(
|
|
87006
|
+
"The local signer is not one of the two accepted scope parties."
|
|
87007
|
+
);
|
|
87008
|
+
const message = canonicalJson(payload);
|
|
87009
|
+
const signatures = await Promise.all([
|
|
87010
|
+
verifyMessage({
|
|
87011
|
+
address: scope.proposerAddress,
|
|
87012
|
+
message,
|
|
87013
|
+
signature: scope.proposerSignature
|
|
87014
|
+
}),
|
|
87015
|
+
verifyMessage({
|
|
87016
|
+
address: scope.counterpartyAddress,
|
|
87017
|
+
message,
|
|
87018
|
+
signature: scope.counterpartySignature
|
|
87019
|
+
})
|
|
87020
|
+
]);
|
|
87021
|
+
if (signatures.some((valid) => !valid))
|
|
87022
|
+
throw new TasksValidationError("Both accepted task scope signatures must verify.");
|
|
87023
|
+
const terms = frozen.structured;
|
|
87024
|
+
if (terms.budget.network !== ready.network || terms.budget.asset.toLowerCase() !== `${ready.network}/erc20:${ready.usdc}`.toLowerCase() || !isAddressEqual(terms.escrow.contract, ready.escrowContract) || selected.network !== terms.budget.network || selected.asset.toLowerCase() !== terms.budget.asset.toLowerCase() || selected.amountBaseUnits !== terms.budget.amountBaseUnits)
|
|
87025
|
+
throw new TasksValidationError(
|
|
87026
|
+
"The signed task scope asset, factory or amount does not match the deployment and milestone."
|
|
87027
|
+
);
|
|
87028
|
+
const identity = {
|
|
87029
|
+
orderId: selected.workOrderId,
|
|
87030
|
+
trancheOrdinal: selected.ordinal,
|
|
87031
|
+
scopeVersion: scope.version,
|
|
87032
|
+
termsHash: frozen.termsHash,
|
|
87033
|
+
self: getAddress(signer)
|
|
87015
87034
|
};
|
|
87016
|
-
|
|
87017
|
-
|
|
87018
|
-
|
|
87019
|
-
|
|
87020
|
-
|
|
87021
|
-
|
|
87022
|
-
|
|
87023
|
-
|
|
87024
|
-
|
|
87025
|
-
throw new
|
|
87026
|
-
"
|
|
87027
|
-
|
|
87035
|
+
const binding = await options.bindings?.get(identity);
|
|
87036
|
+
if (!binding) throw new TasksPartiesNotBoundError();
|
|
87037
|
+
if (options.counterparty && !isAddressEqual(binding.counterparty, options.counterparty))
|
|
87038
|
+
throw new TasksValidationError(
|
|
87039
|
+
"The confirmed counterparty differs from the locally bound parties."
|
|
87040
|
+
);
|
|
87041
|
+
if (!isAddressEqual(binding.self, signer) || binding.orderId !== identity.orderId || binding.trancheOrdinal !== identity.trancheOrdinal || binding.scopeVersion !== identity.scopeVersion || binding.termsHash.toLowerCase() !== identity.termsHash.toLowerCase() || ![scope.proposerAddress, scope.counterpartyAddress].every(
|
|
87042
|
+
(address10) => isAddressEqual(address10, binding.self) || isAddressEqual(address10, binding.counterparty)
|
|
87043
|
+
))
|
|
87044
|
+
throw new TasksValidationError(
|
|
87045
|
+
"The accepted scope parties do not match the locally bound parties."
|
|
87046
|
+
);
|
|
87047
|
+
const buyer = getAddress(binding.role === "client" ? binding.self : binding.counterparty);
|
|
87048
|
+
const seller = getAddress(binding.role === "provider" ? binding.self : binding.counterparty);
|
|
87049
|
+
if (verb === "createEscrow" && !isAddressEqual(signer, seller))
|
|
87050
|
+
throw new TasksValidationError("Task createEscrow requires the locally bound seller's wallet.");
|
|
87051
|
+
const workDurationSeconds = terms.workDurationSeconds ?? getTrustedTasksDurations(ready.chainId, options.trustedDurations).workDurationSeconds;
|
|
87052
|
+
if (workDurationSeconds === void 0)
|
|
87053
|
+
throw new TasksValidationError(
|
|
87054
|
+
"The signed task scope has no work duration and no trusted default is configured."
|
|
87028
87055
|
);
|
|
87029
|
-
const matches = escrowId ? workOrder.milestones.filter((m) => m.id === escrowId) : workOrder.milestones;
|
|
87030
|
-
if (matches.length !== 1)
|
|
87031
|
-
throw new TaskOperationError("invalid_response", "Select one task milestone by escrow ID.");
|
|
87032
|
-
const milestone = matches[0];
|
|
87033
|
-
if (milestone.workOrderId !== orderId)
|
|
87034
|
-
throw new TaskOperationError("invalid_response", "The milestone belongs to a different task.");
|
|
87035
|
-
let readiness;
|
|
87036
|
-
try {
|
|
87037
|
-
readiness = { ok: true, value: await client.deployment() };
|
|
87038
|
-
} catch (error61) {
|
|
87039
|
-
readiness = { ok: false, error: error61 };
|
|
87040
|
-
}
|
|
87041
87056
|
return {
|
|
87042
|
-
|
|
87043
|
-
|
|
87044
|
-
|
|
87045
|
-
|
|
87057
|
+
signer,
|
|
87058
|
+
buyer,
|
|
87059
|
+
seller,
|
|
87060
|
+
parties: [buyer, seller],
|
|
87061
|
+
workDurationSeconds,
|
|
87062
|
+
...verb === "fund" ? { approveAmount: BigInt(terms.budget.amountBaseUnits) } : {},
|
|
87063
|
+
reviewWindowSeconds: terms.acceptanceWindowSeconds,
|
|
87064
|
+
nowSeconds: BigInt(Math.floor((options.now ?? (() => /* @__PURE__ */ new Date()))().getTime() / 1e3)),
|
|
87065
|
+
verb,
|
|
87066
|
+
deployment: ready,
|
|
87067
|
+
milestone: {
|
|
87068
|
+
...selected,
|
|
87069
|
+
terms,
|
|
87070
|
+
termsHash: frozen.termsHash,
|
|
87071
|
+
amountBaseUnits: terms.budget.amountBaseUnits
|
|
87072
|
+
},
|
|
87073
|
+
steps
|
|
87046
87074
|
};
|
|
87047
87075
|
}
|
|
87048
|
-
function
|
|
87049
|
-
|
|
87050
|
-
|
|
87051
|
-
|
|
87052
|
-
|
|
87053
|
-
|
|
87054
|
-
|
|
87055
|
-
|
|
87056
|
-
};
|
|
87057
|
-
if (property === "deployment")
|
|
87058
|
-
return async () => {
|
|
87059
|
-
if (snapshot.readiness.ok) return snapshot.readiness.value;
|
|
87060
|
-
throw snapshot.readiness.error;
|
|
87061
|
-
};
|
|
87062
|
-
const value = Reflect.get(target, property, target);
|
|
87063
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
87064
|
-
}
|
|
87076
|
+
async function verifyClone(rpc, expected, checkState) {
|
|
87077
|
+
if (expected.verb === "createEscrow") return;
|
|
87078
|
+
const clone2 = expected.milestone.escrowContract;
|
|
87079
|
+
const registered = await rpc.readContract({
|
|
87080
|
+
address: expected.deployment.escrowContract,
|
|
87081
|
+
abi: TASKS_READ_ABI,
|
|
87082
|
+
functionName: "isEscrow",
|
|
87083
|
+
args: [clone2]
|
|
87065
87084
|
});
|
|
87066
|
-
|
|
87067
|
-
|
|
87068
|
-
|
|
87069
|
-
|
|
87070
|
-
|
|
87071
|
-
|
|
87085
|
+
if (!registered)
|
|
87086
|
+
throw new TasksValidationError(
|
|
87087
|
+
"The task escrow clone is not registered by the trusted factory."
|
|
87088
|
+
);
|
|
87089
|
+
const predicted = await rpc.readContract({
|
|
87090
|
+
address: expected.deployment.escrowContract,
|
|
87091
|
+
abi: TASKS_READ_ABI,
|
|
87092
|
+
functionName: "predictEscrow",
|
|
87093
|
+
args: [expected.seller, keccak256(stringToHex(expected.milestone.id))]
|
|
87094
|
+
});
|
|
87095
|
+
if (!isAddressEqual(predicted, clone2))
|
|
87096
|
+
throw new TasksValidationError(
|
|
87097
|
+
"The escrow clone does not match the signed milestone salt and bound seller."
|
|
87098
|
+
);
|
|
87099
|
+
const read = (functionName) => rpc.readContract({ address: clone2, abi: TASKS_READ_ABI, functionName });
|
|
87100
|
+
const [
|
|
87101
|
+
buyer,
|
|
87102
|
+
seller,
|
|
87103
|
+
token,
|
|
87104
|
+
amount4,
|
|
87105
|
+
termsHash,
|
|
87106
|
+
state,
|
|
87107
|
+
resolution,
|
|
87108
|
+
offerDeadline,
|
|
87109
|
+
workDeadline,
|
|
87110
|
+
reviewDeadline,
|
|
87111
|
+
disputedAt,
|
|
87112
|
+
counterEvidenceDeadline,
|
|
87113
|
+
slot0,
|
|
87114
|
+
slot6,
|
|
87115
|
+
slot7
|
|
87116
|
+
] = await Promise.all([
|
|
87117
|
+
read("buyer"),
|
|
87118
|
+
read("seller"),
|
|
87119
|
+
read("token"),
|
|
87120
|
+
read("amount"),
|
|
87121
|
+
read("termsHash"),
|
|
87122
|
+
read("state"),
|
|
87123
|
+
read("resolution"),
|
|
87124
|
+
read("offerDeadline"),
|
|
87125
|
+
read("workDeadline"),
|
|
87126
|
+
read("reviewDeadline"),
|
|
87127
|
+
read("disputedAt"),
|
|
87128
|
+
read("counterEvidenceDeadline"),
|
|
87129
|
+
rpc.getStorageAt({ address: clone2, slot: "0x0" }),
|
|
87130
|
+
rpc.getStorageAt({ address: clone2, slot: "0x6" }),
|
|
87131
|
+
rpc.getStorageAt({ address: clone2, slot: "0x7" })
|
|
87132
|
+
]);
|
|
87133
|
+
if (isAddressEqual(buyer, seller) || !isAddressEqual(buyer, expected.buyer) || !isAddressEqual(seller, expected.seller) || !isAddressEqual(token, expected.deployment.usdc) || amount4 !== BigInt(expected.milestone.amountBaseUnits) || termsHash.toLowerCase() !== expected.milestone.termsHash.toLowerCase())
|
|
87134
|
+
throw new TasksValidationError(
|
|
87135
|
+
"The onchain escrow parties, token, amount or terms hash do not match the signed scope."
|
|
87136
|
+
);
|
|
87137
|
+
const s0 = storageWord(slot0);
|
|
87138
|
+
const s6 = storageWord(slot6);
|
|
87139
|
+
const s7 = storageWord(slot7);
|
|
87140
|
+
if (field(s0, 0, 1) !== BigInt(state) || field(s0, 1, 1) !== BigInt(resolution) || !isAddressEqual(storageAddress(s0, 2), buyer) || field(s6, 0, 8) !== offerDeadline || field(s6, 8, 8) !== workDeadline || field(s6, 16, 8) !== reviewDeadline || field(s6, 24, 8) !== disputedAt || field(s7, 0, 8) !== counterEvidenceDeadline)
|
|
87141
|
+
throw new TasksValidationError("unsupported escrow layout");
|
|
87142
|
+
if (field(s7, 8, 8) !== BigInt(expected.workDurationSeconds) || field(s7, 16, 8) !== BigInt(expected.reviewWindowSeconds))
|
|
87143
|
+
throw new TasksValidationError(
|
|
87144
|
+
"The onchain escrow durations do not match the signed terms and trusted defaults."
|
|
87145
|
+
);
|
|
87146
|
+
const actor = expected.verb === "fund" || expected.verb === "release" ? buyer : expected.verb === "deliver" || expected.verb === "refund" ? seller : expected.signer;
|
|
87147
|
+
if (!isAddressEqual(actor, expected.signer))
|
|
87148
|
+
throw new TasksValidationError(
|
|
87149
|
+
`Task ${expected.verb} requires the onchain escrow party's local wallet.`
|
|
87150
|
+
);
|
|
87151
|
+
const states = {
|
|
87152
|
+
fund: [1],
|
|
87153
|
+
deliver: [2],
|
|
87154
|
+
release: [3],
|
|
87155
|
+
refund: [2, 3],
|
|
87156
|
+
dispute: [2, 3],
|
|
87157
|
+
"counter-evidence": [4],
|
|
87158
|
+
"resolve-unmatched": [4]
|
|
87159
|
+
};
|
|
87160
|
+
if (checkState && !states[expected.verb]?.includes(state))
|
|
87161
|
+
throw new TasksValidationError(
|
|
87162
|
+
`The onchain escrow state is not eligible for task ${expected.verb}.`
|
|
87163
|
+
);
|
|
87164
|
+
if (["dispute", "counter-evidence"].includes(expected.verb)) {
|
|
87165
|
+
const fee = disputeFeeBaseUnits(amount4);
|
|
87166
|
+
if (await read("disputeFee") !== fee)
|
|
87167
|
+
throw new TasksValidationError(
|
|
87168
|
+
"The onchain dispute fee does not match the verified amount fee rule."
|
|
87169
|
+
);
|
|
87170
|
+
expected.disputeFee = fee;
|
|
87171
|
+
expected.approveAmount = fee;
|
|
87072
87172
|
}
|
|
87073
|
-
if (
|
|
87074
|
-
|
|
87075
|
-
|
|
87076
|
-
|
|
87173
|
+
if (checkState && ["counter-evidence", "resolve-unmatched"].includes(expected.verb)) {
|
|
87174
|
+
const slot8 = storageWord(await rpc.getStorageAt({ address: clone2, slot: "0x8" }));
|
|
87175
|
+
const opener = storageAddress(slot8, 0);
|
|
87176
|
+
const submitted = field(slot8, 20, 1);
|
|
87177
|
+
if (!isAddressEqual(opener, buyer) && !isAddressEqual(opener, seller) || submitted > 1n || field(slot8, 21, 11) !== 0n)
|
|
87178
|
+
throw new TasksValidationError("unsupported escrow layout");
|
|
87179
|
+
const now = expected.nowSeconds;
|
|
87180
|
+
if (now === void 0)
|
|
87181
|
+
throw new TasksValidationError("A trusted clock is required for dispute eligibility.");
|
|
87182
|
+
if (submitted === 1n)
|
|
87183
|
+
throw new TasksValidationError(
|
|
87184
|
+
"Counter-evidence has already been submitted for this dispute."
|
|
87185
|
+
);
|
|
87186
|
+
if (expected.verb === "counter-evidence") {
|
|
87187
|
+
if (isAddressEqual(opener, expected.signer))
|
|
87188
|
+
throw new TasksValidationError("Only the non-opener party can submit counter-evidence.");
|
|
87189
|
+
if (now >= counterEvidenceDeadline)
|
|
87190
|
+
throw new TasksValidationError("The counter-evidence deadline has passed.");
|
|
87191
|
+
} else if (now <= counterEvidenceDeadline)
|
|
87192
|
+
throw new TasksValidationError(
|
|
87193
|
+
"The counter-evidence deadline has not passed; unmatched resolution is unavailable."
|
|
87194
|
+
);
|
|
87195
|
+
}
|
|
87196
|
+
expected.offerDeadline = offerDeadline;
|
|
87077
87197
|
}
|
|
87078
|
-
function
|
|
87079
|
-
|
|
87080
|
-
|
|
87198
|
+
function storageWord(value) {
|
|
87199
|
+
if (!value || !/^0x[0-9a-fA-F]{64}$/.test(value))
|
|
87200
|
+
throw new TasksValidationError("unsupported escrow layout");
|
|
87201
|
+
return BigInt(value);
|
|
87081
87202
|
}
|
|
87082
|
-
function
|
|
87083
|
-
|
|
87084
|
-
|
|
87085
|
-
|
|
87086
|
-
|
|
87087
|
-
`Task method ${name} is not supported by this SDK adapter.`
|
|
87088
|
-
);
|
|
87089
|
-
return method.bind(client);
|
|
87203
|
+
function field(word, offset, bytes) {
|
|
87204
|
+
return word >> BigInt(offset * 8) & (1n << BigInt(bytes * 8)) - 1n;
|
|
87205
|
+
}
|
|
87206
|
+
function storageAddress(word, offset) {
|
|
87207
|
+
return getAddress(`0x${field(word, offset, 20).toString(16).padStart(40, "0")}`);
|
|
87090
87208
|
}
|
|
87091
87209
|
|
|
87092
87210
|
// ../core/src/tasks/v2-trust.ts
|
|
@@ -87179,12 +87297,65 @@ function getTrustedTasksV2Deployment(chainId, options = {}) {
|
|
|
87179
87297
|
return normalized2;
|
|
87180
87298
|
}
|
|
87181
87299
|
|
|
87300
|
+
// ../core/src/tasks/v2-limits.ts
|
|
87301
|
+
var feeBpSchema = external_exports.union([external_exports.number(), external_exports.bigint()]).transform(Number).pipe(external_exports.number().int().min(0).max(2e3));
|
|
87302
|
+
var capSchema = external_exports.bigint().positive();
|
|
87303
|
+
async function readTaskV2Limits(input2) {
|
|
87304
|
+
const read = async () => {
|
|
87305
|
+
const pin = getTrustedTasksV2Deployment(input2.chainId, {
|
|
87306
|
+
...input2.trustedV2Deployments ? { overrides: input2.trustedV2Deployments } : {},
|
|
87307
|
+
...input2.env ? { env: input2.env } : {},
|
|
87308
|
+
// Display and pre-check only; the signing path prints the override notice.
|
|
87309
|
+
notice: input2.onV2UntrustedOverride ?? (() => {
|
|
87310
|
+
})
|
|
87311
|
+
});
|
|
87312
|
+
const rpc = input2.rpcFor(input2.chainId);
|
|
87313
|
+
if (await rpc.getChainId() !== input2.chainId) throw new Error("RPC chain mismatch");
|
|
87314
|
+
const pool = input2.shape === "pool";
|
|
87315
|
+
const address10 = pool ? pin.bountyPoolFactoryV1 : pin.escrowFactoryV2;
|
|
87316
|
+
const abi2 = pool ? bountyPoolFactoryV1Abi : escrowFactoryV2Abi;
|
|
87317
|
+
const [feeBp, cap] = await Promise.all([
|
|
87318
|
+
rpc.readContract({ address: address10, abi: abi2, functionName: "feeBp" }),
|
|
87319
|
+
rpc.readContract({
|
|
87320
|
+
address: address10,
|
|
87321
|
+
abi: abi2,
|
|
87322
|
+
functionName: pool ? "maxPoolBudget" : "maxEscrowAmount"
|
|
87323
|
+
})
|
|
87324
|
+
]);
|
|
87325
|
+
return {
|
|
87326
|
+
chainId: input2.chainId,
|
|
87327
|
+
shape: input2.shape,
|
|
87328
|
+
feeBp: feeBpSchema.parse(feeBp),
|
|
87329
|
+
maxBaseUnits: capSchema.parse(cap)
|
|
87330
|
+
};
|
|
87331
|
+
};
|
|
87332
|
+
let timer;
|
|
87333
|
+
try {
|
|
87334
|
+
return await Promise.race([
|
|
87335
|
+
read(),
|
|
87336
|
+
new Promise((resolve3) => {
|
|
87337
|
+
timer = setTimeout(() => resolve3(void 0), input2.timeoutMs ?? 5e3);
|
|
87338
|
+
})
|
|
87339
|
+
]);
|
|
87340
|
+
} catch {
|
|
87341
|
+
return void 0;
|
|
87342
|
+
} finally {
|
|
87343
|
+
if (timer) clearTimeout(timer);
|
|
87344
|
+
}
|
|
87345
|
+
}
|
|
87346
|
+
function assertWithinTaskV2Limit(totalBaseUnits, limits, untouched = "Nothing was signed and no money moved.") {
|
|
87347
|
+
if (totalBaseUnits <= limits.maxBaseUnits) return;
|
|
87348
|
+
throw new TaskInputError(
|
|
87349
|
+
`The total of $${formatBaseUnitsUsd(totalBaseUnits)} USDC is above the live limit of $${formatBaseUnitsUsd(limits.maxBaseUnits)} USDC per ${limits.shape} on ${taskNetworkName(limits.chainId)}. ${untouched}`
|
|
87350
|
+
);
|
|
87351
|
+
}
|
|
87352
|
+
|
|
87182
87353
|
// ../core/src/tasks/v2-plan-guard.ts
|
|
87183
87354
|
var address5 = external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/u).transform((v) => getAddress(v));
|
|
87184
87355
|
var hash5 = external_exports.string().regex(/^0x[0-9a-fA-F]{64}$/u).transform((v) => v.toLowerCase());
|
|
87185
87356
|
var uint2 = external_exports.union([external_exports.bigint(), external_exports.number().int().nonnegative(), external_exports.string().regex(/^\d+$/u)]).transform(BigInt);
|
|
87186
87357
|
var small = (max) => external_exports.union([external_exports.number(), external_exports.bigint()]).transform(Number).pipe(external_exports.number().int().min(0).max(max));
|
|
87187
|
-
var
|
|
87358
|
+
var feeBpSchema2 = small(2e3);
|
|
87188
87359
|
var escrowTermsSchema = external_exports.object({
|
|
87189
87360
|
shape: small(1),
|
|
87190
87361
|
poster: address5,
|
|
@@ -87196,7 +87367,7 @@ var escrowTermsSchema = external_exports.object({
|
|
|
87196
87367
|
bountyDeadline: uint2,
|
|
87197
87368
|
objectionWindow: uint2,
|
|
87198
87369
|
workerBondBp: small(2e3),
|
|
87199
|
-
feeBp:
|
|
87370
|
+
feeBp: feeBpSchema2,
|
|
87200
87371
|
winners: small(255),
|
|
87201
87372
|
rewardPerWinner: uint2
|
|
87202
87373
|
});
|
|
@@ -87460,7 +87631,7 @@ function verifyActor(action, signer, poster, worker, verifier) {
|
|
|
87460
87631
|
);
|
|
87461
87632
|
}
|
|
87462
87633
|
async function creationPolicy(rpc, pin, pool) {
|
|
87463
|
-
const feeBp =
|
|
87634
|
+
const feeBp = feeBpSchema2.parse(
|
|
87464
87635
|
await v2Read(
|
|
87465
87636
|
rpc,
|
|
87466
87637
|
pool ? pin.bountyPoolFactoryV1 : pin.escrowFactoryV2,
|
|
@@ -87479,10 +87650,13 @@ async function verifyFundingDeadlines(rpc, contract, deadlines, timestamp) {
|
|
|
87479
87650
|
`Every milestone deadline must leave at least MIN_WORK_TIME (${minimum} seconds) from the trusted chain clock before creation or funding so the task can be awarded.`
|
|
87480
87651
|
);
|
|
87481
87652
|
}
|
|
87482
|
-
async function verifyV2Target(options, current, view, action, knownTarget) {
|
|
87653
|
+
async function verifyV2Target(options, current, view, action, knownTarget, fundingMined = false) {
|
|
87483
87654
|
const operation = taskV2OperationResponseSchema.safeParse(current);
|
|
87484
87655
|
const intent = taskV2IntentSchema.safeParse(current);
|
|
87485
|
-
const
|
|
87656
|
+
const plan = operation.success ? operation.data.operation.plan : null;
|
|
87657
|
+
if (operation.success && !plan)
|
|
87658
|
+
return v2GuardFailure("The hosted operation carries no plan to verify.");
|
|
87659
|
+
const chainId = plan ? plan.chainId : intent.success ? intent.data.typedData.domain.chainId : external_exports.object({ chainId: external_exports.number().int().positive() }).parse(current).chainId;
|
|
87486
87660
|
const binding = await options.pending.v2Target?.(view.workOrder.id);
|
|
87487
87661
|
if (action.action === "bump-consent-nonce" && !binding)
|
|
87488
87662
|
return v2GuardFailure("Revocation requires a locally accepted consent target binding.");
|
|
@@ -87514,11 +87688,8 @@ async function verifyV2Target(options, current, view, action, knownTarget) {
|
|
|
87514
87688
|
let candidate = knownTarget ?? external_exports.object({ escrow: address5 }).safeParse(order.v2State).data?.escrow ?? (intent.success ? external_exports.object({ escrow: address5 }).safeParse(intent.data).data?.escrow : void 0);
|
|
87515
87689
|
let creationArgs;
|
|
87516
87690
|
let fresh;
|
|
87517
|
-
if (action.action === "fund" &&
|
|
87518
|
-
const decoded = decodeFunctionData({
|
|
87519
|
-
abi: factoryAbi,
|
|
87520
|
-
data: operation.data.operation.plan.data
|
|
87521
|
-
});
|
|
87691
|
+
if (action.action === "fund" && plan && same(plan.to, factory)) {
|
|
87692
|
+
const decoded = decodeFunctionData({ abi: factoryAbi, data: plan.data });
|
|
87522
87693
|
const names = pool ? ["createPool"] : ["createEscrow", "createAndFundWithAuthorization"];
|
|
87523
87694
|
if (!names.includes(decoded.functionName))
|
|
87524
87695
|
return v2GuardFailure("Unexpected V2 factory funding selector.");
|
|
@@ -87528,7 +87699,7 @@ async function verifyV2Target(options, current, view, action, knownTarget) {
|
|
|
87528
87699
|
verifyAcceptedCreation(options, view, pin, creationArgs, pool, chainId, fresh);
|
|
87529
87700
|
candidate = await predict(creationArgs);
|
|
87530
87701
|
}
|
|
87531
|
-
if (action.action === "fund" &&
|
|
87702
|
+
if (action.action === "fund" && plan?.step === "v2-approve-usdc" && (!candidate || !await isRegistered(candidate))) {
|
|
87532
87703
|
fresh = await creationPolicy(rpc, pin, pool);
|
|
87533
87704
|
creationArgs = acceptedCreationArgs(options, view, pin, chainId, fresh);
|
|
87534
87705
|
verifyAcceptedCreation(options, view, pin, creationArgs, pool, chainId, fresh);
|
|
@@ -87544,7 +87715,7 @@ async function verifyV2Target(options, current, view, action, knownTarget) {
|
|
|
87544
87715
|
"The V2 target cannot be independently verified from this response. A registered target or verifiable funding creation terms are required."
|
|
87545
87716
|
);
|
|
87546
87717
|
if (!await isRegistered(candidate)) {
|
|
87547
|
-
if (action.action !== "fund" || !
|
|
87718
|
+
if (action.action !== "fund" || !plan || !creationArgs || !fresh)
|
|
87548
87719
|
return v2GuardFailure("The V2 target is not registered by the locally pinned factory.");
|
|
87549
87720
|
const expectedCreation = acceptedCreationArgs(options, view, pin, chainId, fresh);
|
|
87550
87721
|
if (canon(creationArgs) !== canon(expectedCreation))
|
|
@@ -87596,7 +87767,7 @@ async function verifyV2Target(options, current, view, action, knownTarget) {
|
|
|
87596
87767
|
poster = address5.parse(await read("poster"));
|
|
87597
87768
|
verifier = address5.parse(await read("verifier"));
|
|
87598
87769
|
total = uint2.parse(await read("budget"));
|
|
87599
|
-
feeBp =
|
|
87770
|
+
feeBp = feeBpSchema2.parse(await read("feeBp"));
|
|
87600
87771
|
termsHash = hash5.parse(await read("termsHash"));
|
|
87601
87772
|
creationArgs = [
|
|
87602
87773
|
poster,
|
|
@@ -87660,7 +87831,7 @@ async function verifyV2Target(options, current, view, action, knownTarget) {
|
|
|
87660
87831
|
"The V2 target differs from the pinned factory's prediction for the requested order."
|
|
87661
87832
|
);
|
|
87662
87833
|
verifyBinding(candidate, termsHash);
|
|
87663
|
-
if (action.action === "fund" && !pool && !bounty)
|
|
87834
|
+
if (action.action === "fund" && !pool && !bounty && !fundingMined)
|
|
87664
87835
|
await verifyFundingDeadlines(
|
|
87665
87836
|
rpc,
|
|
87666
87837
|
candidate,
|
|
@@ -87764,6 +87935,7 @@ function acceptedV2WorkerBond(target, view) {
|
|
|
87764
87935
|
}
|
|
87765
87936
|
async function verifyV2Plan(target, op, action, pays, fundingAuthorization) {
|
|
87766
87937
|
const plan = op.plan;
|
|
87938
|
+
if (!plan) return v2GuardFailure("The hosted operation carries no plan to verify.");
|
|
87767
87939
|
if (plan.value !== "0" || plan.chainId !== target.chainId)
|
|
87768
87940
|
return v2GuardFailure("V2 plan value or chain mismatch.");
|
|
87769
87941
|
const authorizationArgs = fundingAuthorization ? [
|
|
@@ -88030,7 +88202,8 @@ function isTaskV2SecretAction(action) {
|
|
|
88030
88202
|
return action.action === "commit-vote" || action.action === "reveal-vote";
|
|
88031
88203
|
}
|
|
88032
88204
|
function publicTaskV2Operation(op, secret = false) {
|
|
88033
|
-
const
|
|
88205
|
+
const plan = op.plan;
|
|
88206
|
+
const reveal = secret || op.step === "v2-reveal-vote" || plan?.step === "v2-reveal-vote" || plan?.data.toLowerCase().startsWith(REVEAL_SELECTOR) === true;
|
|
88034
88207
|
return {
|
|
88035
88208
|
id: op.id,
|
|
88036
88209
|
kind: op.kind,
|
|
@@ -88038,16 +88211,17 @@ function publicTaskV2Operation(op, secret = false) {
|
|
|
88038
88211
|
step: op.step,
|
|
88039
88212
|
expectedActor: op.expectedActor,
|
|
88040
88213
|
transactionHash: op.transactionHash,
|
|
88041
|
-
|
|
88042
|
-
|
|
88043
|
-
|
|
88044
|
-
|
|
88045
|
-
|
|
88046
|
-
|
|
88047
|
-
|
|
88048
|
-
|
|
88049
|
-
|
|
88050
|
-
|
|
88214
|
+
// Null once the transaction is submitted or confirmed: the API no longer returns the plan.
|
|
88215
|
+
plan: plan && {
|
|
88216
|
+
version: plan.version,
|
|
88217
|
+
operationId: plan.operationId,
|
|
88218
|
+
step: plan.step,
|
|
88219
|
+
chainId: plan.chainId,
|
|
88220
|
+
network: plan.network,
|
|
88221
|
+
from: plan.from,
|
|
88222
|
+
to: plan.to,
|
|
88223
|
+
data: reveal ? TASK_V2_REDACTED_CALLDATA : plan.data,
|
|
88224
|
+
value: plan.value
|
|
88051
88225
|
}
|
|
88052
88226
|
};
|
|
88053
88227
|
}
|
|
@@ -88068,7 +88242,7 @@ var shownOperationSchema = external_exports.object({
|
|
|
88068
88242
|
to: external_exports.string(),
|
|
88069
88243
|
data: external_exports.string(),
|
|
88070
88244
|
value: external_exports.literal("0")
|
|
88071
|
-
})
|
|
88245
|
+
}).nullable()
|
|
88072
88246
|
});
|
|
88073
88247
|
function publicTaskV2OperationOf(value, secret = false) {
|
|
88074
88248
|
const parsed = shownOperationSchema.safeParse(value);
|
|
@@ -88288,6 +88462,9 @@ function bufferedV2Gas(estimate) {
|
|
|
88288
88462
|
var fail = (message) => {
|
|
88289
88463
|
throw new TaskOperationError("invalid_response", message);
|
|
88290
88464
|
};
|
|
88465
|
+
var balanceAbi = parseAbi(["function balanceOf(address account) view returns (uint256)"]);
|
|
88466
|
+
var PAID_NOW_ACTIONS = ["fund", "raise-dispute", "counter-evidence"];
|
|
88467
|
+
var RESERVING_ACTIONS = [...PAID_NOW_ACTIONS, "approve-bond"];
|
|
88291
88468
|
async function taskUsesV2(context, id2) {
|
|
88292
88469
|
if (!context.client.prepareV2) return false;
|
|
88293
88470
|
const { workOrder } = await context.client.getOrder(id2);
|
|
@@ -88315,6 +88492,7 @@ async function executeTaskV2(context, input2) {
|
|
|
88315
88492
|
}
|
|
88316
88493
|
const saved = journal.preparedV2;
|
|
88317
88494
|
if (saved) return saved;
|
|
88495
|
+
requireTasksAvailable(action.action, await readTasksReadiness(context.client));
|
|
88318
88496
|
const result = await (input2.consent ? context.client.signV2(input2.id, input2.consent, journal) : context.client.prepareV2(input2.id, input2.write, journal));
|
|
88319
88497
|
await context.pending?.bindPreparedV2?.(input2.id, verb, result);
|
|
88320
88498
|
return result;
|
|
@@ -88348,17 +88526,76 @@ function createTaskV2Executor(options) {
|
|
|
88348
88526
|
journal = { idempotencyKey: input2.preparationKey ?? randomUUID4(), inputs: action };
|
|
88349
88527
|
await pending.putPreparation(input2.id, verb, journal);
|
|
88350
88528
|
}
|
|
88351
|
-
let current = taskV2PreparedSchema.parse(
|
|
88352
|
-
input2.prepared ?? journal.preparedV2 ?? await (input2.consent ? sign2(input2.id, input2.consent, journal) : prepare(input2.id, input2.write, journal))
|
|
88353
|
-
);
|
|
88354
88529
|
if (!pending.bindPreparedV2) fail("Durable V2 preparation storage is unavailable.");
|
|
88355
|
-
|
|
88530
|
+
const supplied = input2.prepared ?? journal.preparedV2;
|
|
88531
|
+
let current = supplied === void 0 ? void 0 : taskV2PreparedSchema.parse(supplied);
|
|
88532
|
+
if (current) await pending.bindPreparedV2(input2.id, verb, current);
|
|
88533
|
+
const finalStep = action.action === "approve-bond" ? "v2-approve-usdc" : `v2-${action.action}`;
|
|
88534
|
+
const allowedSteps = action.action === "fund" ? ["v2-create-escrow", "v2-create-pool", "v2-approve-usdc", "v2-fund"] : action.action === "raise-dispute" || action.action === "counter-evidence" ? ["v2-approve-usdc", finalStep] : [finalStep];
|
|
88535
|
+
const reservedForTask = (excludeReservationId) => taskReservedAtomic({
|
|
88536
|
+
ledgerPath: input2.ledgerPath,
|
|
88537
|
+
wallet: input2.wallet,
|
|
88538
|
+
taskKey: input2.id,
|
|
88539
|
+
now: now(),
|
|
88540
|
+
...excludeReservationId === void 0 ? {} : { excludeReservationId }
|
|
88541
|
+
});
|
|
88542
|
+
const savedOperation = journal.operationId;
|
|
88543
|
+
const savedTransaction = savedOperation !== void 0 && (await Promise.all(allowedSteps.map((step2) => pending.get(savedOperation, step2)))).some(
|
|
88544
|
+
(entry) => entry !== void 0
|
|
88545
|
+
);
|
|
88546
|
+
const signedBefore = journal.signed === true;
|
|
88547
|
+
const started = savedTransaction || RESERVING_ACTIONS.includes(action.action) && (signedBefore || await reservedForTask() !== await reservedForTask(journal.idempotencyKey));
|
|
88548
|
+
const savedFinal = savedOperation === void 0 ? void 0 : await pending.get(savedOperation, finalStep);
|
|
88549
|
+
const mined = savedFinal && isAddressEqual(savedFinal.signer, account.address) && (await Promise.resolve().then(
|
|
88550
|
+
() => rpcFor(savedFinal.chainId).getTransactionReceipt({ hash: savedFinal.txHash })
|
|
88551
|
+
).catch(() => void 0))?.status === "success" ? savedFinal : void 0;
|
|
88552
|
+
if (current && !started && action.action === "fund" && "kind" in current && current.kind === "eip712") {
|
|
88553
|
+
const end = external_exports.object({ validBefore: uint3 }).safeParse(taskV2IntentSchema.parse(current).typedData.message);
|
|
88554
|
+
if (end.success && BigInt(end.data.validBefore) * 1000n <= BigInt(now().getTime())) {
|
|
88555
|
+
await pending.completePreparation(input2.id, verb);
|
|
88556
|
+
journal = { idempotencyKey: randomUUID4(), inputs: action };
|
|
88557
|
+
await pending.putPreparation(input2.id, verb, journal);
|
|
88558
|
+
current = void 0;
|
|
88559
|
+
}
|
|
88560
|
+
}
|
|
88561
|
+
const readiness = await readTasksReadiness(client);
|
|
88562
|
+
if (!started)
|
|
88563
|
+
requireTasksAvailable(
|
|
88564
|
+
action.action,
|
|
88565
|
+
readiness,
|
|
88566
|
+
input2.consent && journal.preparedV2 ? `This run signed nothing and moved no money. A consent this wallet signed earlier for this task may still be valid until it expires; vapi task bump-consent-nonce ${input2.id} --new-nonce <n> revokes it.` : void 0
|
|
88567
|
+
);
|
|
88568
|
+
if (!current) {
|
|
88569
|
+
current = taskV2PreparedSchema.parse(
|
|
88570
|
+
await (input2.consent ? sign2(input2.id, input2.consent, journal) : prepare(input2.id, input2.write, journal))
|
|
88571
|
+
);
|
|
88572
|
+
await pending.bindPreparedV2(input2.id, verb, current);
|
|
88573
|
+
}
|
|
88356
88574
|
const view = await client.getOrder(input2.id);
|
|
88357
88575
|
if (view.workOrder.id !== input2.id) fail("The money view belongs to another task.");
|
|
88358
88576
|
const terms = view.workOrder.terms;
|
|
88359
88577
|
const state = stateSchema.safeParse(view.workOrder.v2State);
|
|
88360
|
-
const
|
|
88361
|
-
|
|
88578
|
+
const resumed = taskV2OperationResponseSchema.safeParse(current);
|
|
88579
|
+
let resumedChainId;
|
|
88580
|
+
if (resumed.success && !resumed.data.operation.plan) {
|
|
88581
|
+
resumedChainId = (await pending.v2Target?.(input2.id))?.chainId ?? readiness?.chainId;
|
|
88582
|
+
if (resumedChainId === void 0)
|
|
88583
|
+
fail("The hosted operation carries no plan and its chain cannot be read.");
|
|
88584
|
+
}
|
|
88585
|
+
const target = await verifyV2Target(
|
|
88586
|
+
options,
|
|
88587
|
+
resumedChainId === void 0 ? current : { chainId: resumedChainId },
|
|
88588
|
+
view,
|
|
88589
|
+
action,
|
|
88590
|
+
void 0,
|
|
88591
|
+
mined !== void 0
|
|
88592
|
+
);
|
|
88593
|
+
if (mined && mined.chainId !== target.chainId)
|
|
88594
|
+
fail("The saved transaction is for another chain than the verified task.");
|
|
88595
|
+
if (readiness && target.chainId !== readiness.chainId)
|
|
88596
|
+
fail(
|
|
88597
|
+
`The prepared step is for ${taskNetworkName(target.chainId)}, but vAPI serves Tasks on ${taskNetworkName(readiness.chainId)}. ${started ? "No new step was signed." : "Nothing was signed."}`
|
|
88598
|
+
);
|
|
88362
88599
|
if (state.success && (BigInt(state.data.totalBaseUnits) !== target.total || state.data.feeBp !== target.feeBp))
|
|
88363
88600
|
v2GuardFailure("Hosted money snapshot differs from the verified V2 target.");
|
|
88364
88601
|
let gross = 0n, pays = 0n;
|
|
@@ -88402,8 +88639,7 @@ function createTaskV2Executor(options) {
|
|
|
88402
88639
|
else gross = total ?? 0n;
|
|
88403
88640
|
feeBp = 0;
|
|
88404
88641
|
} else if (action.action === "raise-dispute" || action.action === "counter-evidence") {
|
|
88405
|
-
if (!state.success
|
|
88406
|
-
fail("Hosted dispute binding is unavailable.");
|
|
88642
|
+
if (!state.success) fail("Hosted dispute binding is unavailable.");
|
|
88407
88643
|
pays = gross = await target.rpc.readContract({
|
|
88408
88644
|
address: target.escrow,
|
|
88409
88645
|
abi: escrowV2Abi,
|
|
@@ -88461,6 +88697,44 @@ function createTaskV2Executor(options) {
|
|
|
88461
88697
|
}
|
|
88462
88698
|
};
|
|
88463
88699
|
await input2.onMoney?.(money2);
|
|
88700
|
+
if (action.action === "fund" && !started) {
|
|
88701
|
+
const cap = await v2Read(
|
|
88702
|
+
target.rpc,
|
|
88703
|
+
target.factory,
|
|
88704
|
+
target.pool ? bountyPoolFactoryV1Abi : escrowFactoryV2Abi,
|
|
88705
|
+
target.pool ? "maxPoolBudget" : "maxEscrowAmount"
|
|
88706
|
+
).catch(() => void 0);
|
|
88707
|
+
if (typeof cap === "bigint" && cap > 0n)
|
|
88708
|
+
assertWithinTaskV2Limit(gross, {
|
|
88709
|
+
chainId: target.chainId,
|
|
88710
|
+
shape: target.pool ? "pool" : target.bounty ? "bounty" : "task",
|
|
88711
|
+
feeBp: target.feeBp,
|
|
88712
|
+
maxBaseUnits: cap
|
|
88713
|
+
});
|
|
88714
|
+
}
|
|
88715
|
+
if (pays > 0n && PAID_NOW_ACTIONS.includes(action.action) && !started) {
|
|
88716
|
+
const balance = await target.rpc.readContract({
|
|
88717
|
+
address: target.pin.usdc,
|
|
88718
|
+
abi: balanceAbi,
|
|
88719
|
+
functionName: "balanceOf",
|
|
88720
|
+
args: [account.address]
|
|
88721
|
+
}).catch(() => void 0);
|
|
88722
|
+
if (typeof balance === "bigint" && balance < pays)
|
|
88723
|
+
throw new TaskOperationError(
|
|
88724
|
+
"insufficient_usdc",
|
|
88725
|
+
`This step pays $${formatBaseUnitsUsd(pays)} USDC, but the wallet holds $${formatBaseUnitsUsd(balance)} on ${taskNetworkName(target.chainId)}. Nothing was signed and no money moved.`,
|
|
88726
|
+
void 0,
|
|
88727
|
+
progress
|
|
88728
|
+
);
|
|
88729
|
+
const gas = await Promise.resolve().then(() => target.rpc.getBalance({ address: account.address })).catch(() => void 0);
|
|
88730
|
+
if (gas === 0n)
|
|
88731
|
+
throw new TaskOperationError(
|
|
88732
|
+
"insufficient_gas",
|
|
88733
|
+
`The wallet holds no ETH on ${taskNetworkName(target.chainId)} to pay for the transaction. Nothing was signed and no money moved.`,
|
|
88734
|
+
void 0,
|
|
88735
|
+
progress
|
|
88736
|
+
);
|
|
88737
|
+
}
|
|
88464
88738
|
const reservationKey = journal.idempotencyKey;
|
|
88465
88739
|
const remaining2 = pays > 0n ? await escrowFundingDayRemainingAtomic({
|
|
88466
88740
|
caps: input2.caps,
|
|
@@ -88476,11 +88750,11 @@ function createTaskV2Executor(options) {
|
|
|
88476
88750
|
now: now(),
|
|
88477
88751
|
excludeReservationId: reservationKey
|
|
88478
88752
|
}) : 0n;
|
|
88479
|
-
if (pays + alreadyReserved > taskPolicyAtomic(input2.policy.maxPerTaskUsd))
|
|
88753
|
+
if (!mined && pays + alreadyReserved > taskPolicyAtomic(input2.policy.maxPerTaskUsd))
|
|
88480
88754
|
return { ok: false, reason: "policy.perTask", money: money2, ...progress };
|
|
88481
|
-
if (pays > remaining2)
|
|
88755
|
+
if (!mined && pays > remaining2)
|
|
88482
88756
|
return { ok: false, reason: "policy.perDay", money: money2, ...progress };
|
|
88483
|
-
if (pays > taskPolicyAtomic(input2.policy.approveAboveUsd)) {
|
|
88757
|
+
if (!mined && pays > taskPolicyAtomic(input2.policy.approveAboveUsd)) {
|
|
88484
88758
|
if (input2.approval && "ask" in input2.approval) {
|
|
88485
88759
|
if (!await input2.approval.ask({
|
|
88486
88760
|
money: taskMoney(pays, 0),
|
|
@@ -88516,13 +88790,24 @@ function createTaskV2Executor(options) {
|
|
|
88516
88790
|
};
|
|
88517
88791
|
let fundingAuthorization;
|
|
88518
88792
|
try {
|
|
88793
|
+
if (mined && "kind" in current)
|
|
88794
|
+
current = taskV2OperationResponseSchema.parse(
|
|
88795
|
+
await operationCall(savedOperation, "recover", { step: finalStep }, key2())
|
|
88796
|
+
);
|
|
88519
88797
|
if ("kind" in current && current.kind === "eip712") {
|
|
88520
88798
|
const intent = taskV2IntentSchema.parse(current);
|
|
88521
88799
|
const typed = intent.typedData;
|
|
88800
|
+
if (started && !savedTransaction && !signedBefore)
|
|
88801
|
+
requireTasksAvailable(
|
|
88802
|
+
action.action,
|
|
88803
|
+
readiness,
|
|
88804
|
+
"No new signature was made. An authorization signed earlier stays valid until it expires."
|
|
88805
|
+
);
|
|
88522
88806
|
await verifyV2TypedData(target, intent, action, account.address, pays);
|
|
88523
88807
|
await bindTarget();
|
|
88524
88808
|
await beforeSign();
|
|
88525
88809
|
const signature = await account.signTypedData(typed);
|
|
88810
|
+
await pending.markPreparationSigned?.(input2.id, verb);
|
|
88526
88811
|
if (action.action === "fund")
|
|
88527
88812
|
fundingAuthorization = { message: typed.message, signature };
|
|
88528
88813
|
const response = await confirmSignature(input2.id, intent.operationId, signature, key2());
|
|
@@ -88548,8 +88833,6 @@ function createTaskV2Executor(options) {
|
|
|
88548
88833
|
}
|
|
88549
88834
|
let result = taskV2OperationResponseSchema.parse(current);
|
|
88550
88835
|
const operationId = result.operation.id;
|
|
88551
|
-
const finalStep = action.action === "approve-bond" ? "v2-approve-usdc" : `v2-${action.action}`;
|
|
88552
|
-
const allowedSteps = action.action === "fund" ? ["v2-create-escrow", "v2-create-pool", "v2-approve-usdc", "v2-fund"] : action.action === "raise-dispute" || action.action === "counter-evidence" ? ["v2-approve-usdc", finalStep] : [finalStep];
|
|
88553
88836
|
const validate7 = (value) => {
|
|
88554
88837
|
if (value.orderId !== input2.id || value.operation.id !== operationId || !isAddressEqual(value.operation.expectedActor, account.address) || !allowedSteps.includes(value.operation.step))
|
|
88555
88838
|
fail("Hosted operation does not match the requested task, wallet or action.");
|
|
@@ -88568,10 +88851,17 @@ function createTaskV2Executor(options) {
|
|
|
88568
88851
|
fail("Hosted sequence moved backwards.");
|
|
88569
88852
|
return { parsed, complete: !("scanComplete" in response) || response.scanComplete };
|
|
88570
88853
|
};
|
|
88854
|
+
let waiting;
|
|
88571
88855
|
for (let poll2 = 0; poll2 < 256; poll2++) {
|
|
88572
88856
|
validate7(result);
|
|
88573
88857
|
progress = { ...progress, operation: publicTaskV2Operation(result.operation, secret) };
|
|
88574
88858
|
const op = result.operation;
|
|
88859
|
+
if (op.state !== "prepared" || waiting?.step !== op.step) waiting = void 0;
|
|
88860
|
+
if (op.state === "prepared" && op.plan) {
|
|
88861
|
+
const shown = canonicalJson(op.plan);
|
|
88862
|
+
if (waiting && waiting.plan !== shown) fail("Recovery changed the prepared plan.");
|
|
88863
|
+
waiting = { step: op.step, plan: shown };
|
|
88864
|
+
}
|
|
88575
88865
|
if (op.state === "confirmed") {
|
|
88576
88866
|
if (op.step !== finalStep)
|
|
88577
88867
|
fail("An approval alone cannot complete the requested action.");
|
|
@@ -88601,14 +88891,26 @@ function createTaskV2Executor(options) {
|
|
|
88601
88891
|
result = recovered.parsed;
|
|
88602
88892
|
continue;
|
|
88603
88893
|
}
|
|
88604
|
-
if (
|
|
88894
|
+
if (mined) {
|
|
88895
|
+
if (op.step !== finalStep)
|
|
88896
|
+
fail(
|
|
88897
|
+
"vAPI asks for an earlier step although the last step of this operation is mined. Nothing was signed."
|
|
88898
|
+
);
|
|
88899
|
+
result = (await call2("transaction", op.step, mined.txHash)).parsed;
|
|
88900
|
+
if (result.operation.state === "prepared") await sleep(1e3);
|
|
88901
|
+
continue;
|
|
88902
|
+
}
|
|
88903
|
+
const plan = recovered.parsed.operation.plan;
|
|
88904
|
+
if (!plan) return fail("The hosted operation is prepared but carries no plan to sign.");
|
|
88905
|
+
if (waiting && waiting.plan !== canonicalJson(plan))
|
|
88605
88906
|
fail("Recovery changed the prepared plan.");
|
|
88606
|
-
|
|
88607
|
-
|
|
88608
|
-
|
|
88907
|
+
waiting = void 0;
|
|
88908
|
+
const step2 = { ...op, plan };
|
|
88909
|
+
if (plan.chainId !== target.chainId)
|
|
88910
|
+
fail("The hosted plan names another chain than the verified task.");
|
|
88609
88911
|
const refreshed = await verifyV2Target(
|
|
88610
88912
|
options,
|
|
88611
|
-
{ orderId: input2.id, operation:
|
|
88913
|
+
{ orderId: input2.id, operation: step2 },
|
|
88612
88914
|
view,
|
|
88613
88915
|
action,
|
|
88614
88916
|
target.escrow
|
|
@@ -88616,7 +88918,7 @@ function createTaskV2Executor(options) {
|
|
|
88616
88918
|
if (!isAddressEqual(refreshed.escrow, target.escrow))
|
|
88617
88919
|
v2GuardFailure("The continuation changed the verified V2 target.");
|
|
88618
88920
|
try {
|
|
88619
|
-
await verifyV2Plan(refreshed,
|
|
88921
|
+
await verifyV2Plan(refreshed, step2, action, pays, fundingAuthorization);
|
|
88620
88922
|
} catch (error61) {
|
|
88621
88923
|
if (error61 instanceof TaskOperationError) throw error61;
|
|
88622
88924
|
v2GuardFailure("Unknown V2 selector or malformed ABI arguments.");
|
|
@@ -88625,7 +88927,6 @@ function createTaskV2Executor(options) {
|
|
|
88625
88927
|
if (await rpc.getChainId() !== plan.chainId) fail("Transaction chain mismatch.");
|
|
88626
88928
|
await input2.beforeSigning?.();
|
|
88627
88929
|
await bindTarget();
|
|
88628
|
-
await beforeSign();
|
|
88629
88930
|
const saved = await pending.withStepLock(
|
|
88630
88931
|
op.id,
|
|
88631
88932
|
op.step,
|
|
@@ -88640,8 +88941,15 @@ function createTaskV2Executor(options) {
|
|
|
88640
88941
|
account.address
|
|
88641
88942
|
))
|
|
88642
88943
|
fail("Saved transaction differs from the hosted plan.");
|
|
88944
|
+
await beforeSign();
|
|
88643
88945
|
return existing;
|
|
88644
88946
|
}
|
|
88947
|
+
if (started)
|
|
88948
|
+
requireTasksAvailable(
|
|
88949
|
+
action.action,
|
|
88950
|
+
readiness,
|
|
88951
|
+
"This step was not signed. Anything this operation signed earlier stands."
|
|
88952
|
+
);
|
|
88645
88953
|
const nonce = Math.max(
|
|
88646
88954
|
await rpc.getTransactionCount({ address: account.address, blockTag: "pending" }),
|
|
88647
88955
|
await pending.nextNonce(plan.chainId, account.address)
|
|
@@ -88656,6 +88964,7 @@ function createTaskV2Executor(options) {
|
|
|
88656
88964
|
nonce
|
|
88657
88965
|
});
|
|
88658
88966
|
if (request.gas === void 0) fail("The V2 transaction has no gas estimate.");
|
|
88967
|
+
await beforeSign();
|
|
88659
88968
|
const raw = await account.signTransaction({
|
|
88660
88969
|
...request,
|
|
88661
88970
|
gas: bufferedV2Gas(request.gas)
|
|
@@ -88760,7 +89069,7 @@ import { randomBytes as nodeRandomBytes } from "node:crypto";
|
|
|
88760
89069
|
|
|
88761
89070
|
// ../core/src/tasks/ballots.ts
|
|
88762
89071
|
import { readdir as readdir7, readFile as readFile19 } from "node:fs/promises";
|
|
88763
|
-
import { join as
|
|
89072
|
+
import { join as join17 } from "node:path";
|
|
88764
89073
|
var address6 = external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/u).transform((v) => v.toLowerCase());
|
|
88765
89074
|
var hash6 = external_exports.string().regex(/^0x[0-9a-fA-F]{64}$/u).transform((v) => v.toLowerCase());
|
|
88766
89075
|
var TASK_V2_VOTE_OUTCOMES = ["worker", "poster", "split"];
|
|
@@ -88780,7 +89089,7 @@ var taskV2BallotSchema = external_exports.strictObject({
|
|
|
88780
89089
|
createdAt: external_exports.iso.datetime()
|
|
88781
89090
|
});
|
|
88782
89091
|
function taskV2BallotDirectory(home, key2) {
|
|
88783
|
-
return
|
|
89092
|
+
return join17(
|
|
88784
89093
|
home,
|
|
88785
89094
|
"tasks",
|
|
88786
89095
|
"ballots",
|
|
@@ -88790,7 +89099,7 @@ function taskV2BallotDirectory(home, key2) {
|
|
|
88790
89099
|
);
|
|
88791
89100
|
}
|
|
88792
89101
|
function taskV2BallotPath(home, key2) {
|
|
88793
|
-
return
|
|
89102
|
+
return join17(taskV2BallotDirectory(home, key2), `${hash6.parse(key2.commitment)}.json`);
|
|
88794
89103
|
}
|
|
88795
89104
|
async function writeTaskV2Ballot(home, ballot) {
|
|
88796
89105
|
const parsed = taskV2BallotSchema.parse(ballot);
|
|
@@ -88826,7 +89135,7 @@ async function listTaskV2Ballots(home, key2) {
|
|
|
88826
89135
|
}
|
|
88827
89136
|
const ballots = [];
|
|
88828
89137
|
for (const name of names.filter((n) => /^0x[0-9a-f]{64}\.json$/u.test(n)).sort()) {
|
|
88829
|
-
const ballot = await readBallotFile(
|
|
89138
|
+
const ballot = await readBallotFile(join17(directory, name));
|
|
88830
89139
|
if (ballot && `${ballot.commitment}.json` === name) ballots.push(ballot);
|
|
88831
89140
|
}
|
|
88832
89141
|
return ballots.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
@@ -88893,13 +89202,16 @@ function createTaskV2Jury(options) {
|
|
|
88893
89202
|
};
|
|
88894
89203
|
async function voteCase(id2, i2) {
|
|
88895
89204
|
taskV2IndexSchema.parse(i2);
|
|
88896
|
-
const
|
|
88897
|
-
if (
|
|
88898
|
-
throw new TaskOperationError(
|
|
89205
|
+
const chainId = (await readTasksReadiness(client))?.chainId ?? (await options.pending.v2Target?.(id2))?.chainId;
|
|
89206
|
+
if (chainId === void 0)
|
|
89207
|
+
throw new TaskOperationError(
|
|
89208
|
+
"v2_resolver_unavailable",
|
|
89209
|
+
"vAPI's Tasks status could not be read, so the chain of this dispute is unknown. Nothing was signed. Try again later."
|
|
89210
|
+
);
|
|
88899
89211
|
const view = await client.getOrder(id2);
|
|
88900
89212
|
if (view.workOrder.id !== id2)
|
|
88901
89213
|
throw new TaskOperationError("invalid_response", "The order view belongs to another task.");
|
|
88902
|
-
const target = await verifyV2Target(options, { chainId
|
|
89214
|
+
const target = await verifyV2Target(options, { chainId }, view, {
|
|
88903
89215
|
action: "open-jury",
|
|
88904
89216
|
i: i2
|
|
88905
89217
|
});
|
|
@@ -89310,7 +89622,9 @@ function createTasksChain(options) {
|
|
|
89310
89622
|
});
|
|
89311
89623
|
async function deployment() {
|
|
89312
89624
|
const value = await client.deployment();
|
|
89313
|
-
if (!value.configured
|
|
89625
|
+
if (!value.configured)
|
|
89626
|
+
throw new TasksValidationError(tasksUnavailableError(value.chainId).message);
|
|
89627
|
+
if (value.network !== `eip155:${value.chainId}`)
|
|
89314
89628
|
throw new TasksValidationError("The Tasks chain deployment is unavailable.");
|
|
89315
89629
|
if (!getTrustedTasksFactory(value.chainId, options.trustedFactories))
|
|
89316
89630
|
throw new TasksChainError(
|
|
@@ -90265,7 +90579,7 @@ function createTasksRpcFor(config2, options = {}) {
|
|
|
90265
90579
|
|
|
90266
90580
|
// ../core/src/tasks/pending-transactions.ts
|
|
90267
90581
|
import { readFile as readFile20 } from "node:fs/promises";
|
|
90268
|
-
import { join as
|
|
90582
|
+
import { join as join18 } from "node:path";
|
|
90269
90583
|
var hex4 = external_exports.string().regex(/^0x(?:[0-9a-fA-F]{2})+$/).transform((v) => v);
|
|
90270
90584
|
var hash8 = external_exports.string().regex(/^0x[0-9a-fA-F]{64}$/).transform((v) => v);
|
|
90271
90585
|
var step = external_exports.union([
|
|
@@ -90330,7 +90644,8 @@ var stateSchema2 = external_exports.object({
|
|
|
90330
90644
|
idempotencyKey: external_exports.uuid(),
|
|
90331
90645
|
inputs: external_exports.unknown(),
|
|
90332
90646
|
operationId: external_exports.uuid().optional(),
|
|
90333
|
-
preparedV2: taskV2PreparedSchema.optional()
|
|
90647
|
+
preparedV2: taskV2PreparedSchema.optional(),
|
|
90648
|
+
signed: external_exports.boolean().optional()
|
|
90334
90649
|
}).strict()
|
|
90335
90650
|
).default({})
|
|
90336
90651
|
}).strict();
|
|
@@ -90354,7 +90669,7 @@ function validCheckpointStep(storedStep, response) {
|
|
|
90354
90669
|
}[response.operation.kind];
|
|
90355
90670
|
}
|
|
90356
90671
|
function createPendingTransactions(home) {
|
|
90357
|
-
const path =
|
|
90672
|
+
const path = join18(home, "tasks", "pending.json");
|
|
90358
90673
|
const lockPath = `${path}.lock`;
|
|
90359
90674
|
const read = async () => {
|
|
90360
90675
|
try {
|
|
@@ -90441,7 +90756,7 @@ function createPendingTransactions(home) {
|
|
|
90441
90756
|
},
|
|
90442
90757
|
withStepLock(operationId, step2, fn) {
|
|
90443
90758
|
return withFileLock(
|
|
90444
|
-
|
|
90759
|
+
join18(
|
|
90445
90760
|
home,
|
|
90446
90761
|
"tasks",
|
|
90447
90762
|
`step-${encodeURIComponent(operationId)}-${encodeURIComponent(step2)}.lock`
|
|
@@ -90453,13 +90768,13 @@ function createPendingTransactions(home) {
|
|
|
90453
90768
|
external_exports.number().int().positive().parse(chainId);
|
|
90454
90769
|
address8.parse(signer);
|
|
90455
90770
|
return withFileLock(
|
|
90456
|
-
|
|
90771
|
+
join18(home, "tasks", `signer-${chainId}-${signer.toLowerCase()}.lock`),
|
|
90457
90772
|
fn
|
|
90458
90773
|
);
|
|
90459
90774
|
},
|
|
90460
90775
|
withFundingLock(milestoneId2, fn) {
|
|
90461
90776
|
milestoneKey(milestoneId2);
|
|
90462
|
-
return withFileLock(
|
|
90777
|
+
return withFileLock(join18(home, "tasks", `fund-${milestoneId2}.lock`), fn);
|
|
90463
90778
|
},
|
|
90464
90779
|
async nextNonce(chainId, signer) {
|
|
90465
90780
|
external_exports.number().int().positive().parse(chainId);
|
|
@@ -90520,7 +90835,8 @@ function createPendingTransactions(home) {
|
|
|
90520
90835
|
idempotencyKey: external_exports.uuid(),
|
|
90521
90836
|
inputs: external_exports.unknown(),
|
|
90522
90837
|
operationId: external_exports.uuid().optional(),
|
|
90523
|
-
preparedV2: taskV2PreparedSchema.optional()
|
|
90838
|
+
preparedV2: taskV2PreparedSchema.optional(),
|
|
90839
|
+
signed: external_exports.boolean().optional()
|
|
90524
90840
|
}).strict().parse(preparation);
|
|
90525
90841
|
const existing = state.preparations[key2];
|
|
90526
90842
|
if (existing && (existing.idempotencyKey !== parsed.idempotencyKey || canonicalJson(existing.inputs) !== canonicalJson(parsed.inputs)))
|
|
@@ -90562,6 +90878,14 @@ function createPendingTransactions(home) {
|
|
|
90562
90878
|
}
|
|
90563
90879
|
});
|
|
90564
90880
|
},
|
|
90881
|
+
async markPreparationSigned(milestoneId2, verb) {
|
|
90882
|
+
await locked(async (state) => {
|
|
90883
|
+
const existing = state.preparations[preparationKey(milestoneId2, verb)];
|
|
90884
|
+
if (!existing || existing.signed) return;
|
|
90885
|
+
existing.signed = true;
|
|
90886
|
+
await save(state);
|
|
90887
|
+
});
|
|
90888
|
+
},
|
|
90565
90889
|
async completePreparation(milestoneId2, verb) {
|
|
90566
90890
|
await locked(async (state) => {
|
|
90567
90891
|
const key2 = preparationKey(milestoneId2, verb);
|
|
@@ -90701,7 +91025,7 @@ function validateAmount(amountUsd) {
|
|
|
90701
91025
|
// ../core/src/tasks/funding-attempts.ts
|
|
90702
91026
|
import { createHash as createHash5 } from "node:crypto";
|
|
90703
91027
|
import { readFile as readFile21, unlink as unlink13 } from "node:fs/promises";
|
|
90704
|
-
import { dirname as dirname10, join as
|
|
91028
|
+
import { dirname as dirname10, join as join19 } from "node:path";
|
|
90705
91029
|
var coordinates = external_exports.object({
|
|
90706
91030
|
network: external_exports.string().regex(/^eip155:[1-9][0-9]*$/u),
|
|
90707
91031
|
asset: external_exports.string().regex(/^0x[0-9a-fA-F]{40}$/u),
|
|
@@ -90729,7 +91053,7 @@ var attemptSchema = external_exports.object({
|
|
|
90729
91053
|
);
|
|
90730
91054
|
async function withFundingAttempt(input2, operation) {
|
|
90731
91055
|
const key2 = createHash5("sha256").update(`${input2.taskId}:${input2.milestoneId}`).digest("hex");
|
|
90732
|
-
const path =
|
|
91056
|
+
const path = join19(dirname10(input2.ledgerPath), "tasks", `funding-${key2}.json`);
|
|
90733
91057
|
return withFileLock(
|
|
90734
91058
|
`${path}.lock`,
|
|
90735
91059
|
async () => {
|
|
@@ -91493,7 +91817,14 @@ async function postTask(context, input2) {
|
|
|
91493
91817
|
"The Tasks deployment is unavailable, so the market network cannot be selected."
|
|
91494
91818
|
);
|
|
91495
91819
|
}
|
|
91496
|
-
|
|
91820
|
+
if (input2.fund)
|
|
91821
|
+
requireTasksAvailable("fund", deployment, "Nothing was posted or signed and no money moved.");
|
|
91822
|
+
const declared = input2.order;
|
|
91823
|
+
const shape = declared.shape ?? (input2.intake === "submissions" ? "bounty" : "task");
|
|
91824
|
+
const total = input2.amount * BigInt(shape === "bounty" ? declared.bounty?.winners ?? input2.maxAwards ?? 1 : 1);
|
|
91825
|
+
const limits = typeof deployment.chainId === "number" ? await context.limitsV2?.(deployment.chainId, shape).catch(() => void 0) : void 0;
|
|
91826
|
+
if (limits) assertWithinTaskV2Limit(total, limits, "Nothing was posted and no money moved.");
|
|
91827
|
+
const feeBp = limits?.feeBp ?? parseFeeBp(deployment);
|
|
91497
91828
|
const feeUnavailable = feeBp === null;
|
|
91498
91829
|
if (feeUnavailable) input2.onFeeUnavailable?.();
|
|
91499
91830
|
const money2 = taskMoney(input2.amount, feeBp);
|
|
@@ -91572,7 +91903,11 @@ async function proposeTask(context, input2) {
|
|
|
91572
91903
|
context
|
|
91573
91904
|
);
|
|
91574
91905
|
if (!deployment.configured)
|
|
91575
|
-
throw
|
|
91906
|
+
throw tasksUnavailableError(
|
|
91907
|
+
deployment.chainId,
|
|
91908
|
+
"No proposal was signed or sent.",
|
|
91909
|
+
"not_available"
|
|
91910
|
+
);
|
|
91576
91911
|
const account = await input2.unlock();
|
|
91577
91912
|
const terms = {
|
|
91578
91913
|
title: workOrder.title,
|
|
@@ -91653,7 +91988,11 @@ async function submitTask(context, input2) {
|
|
|
91653
91988
|
context
|
|
91654
91989
|
);
|
|
91655
91990
|
if (!deployment.configured)
|
|
91656
|
-
throw
|
|
91991
|
+
throw tasksUnavailableError(
|
|
91992
|
+
deployment.chainId,
|
|
91993
|
+
"No entry was signed or sent.",
|
|
91994
|
+
"not_available"
|
|
91995
|
+
);
|
|
91657
91996
|
if (task.amount === null) {
|
|
91658
91997
|
throw new TaskInputError("Task amount is unavailable.");
|
|
91659
91998
|
}
|
|
@@ -92153,6 +92492,9 @@ async function resolveUnmatchedTaskOperation(context, input2) {
|
|
|
92153
92492
|
}
|
|
92154
92493
|
|
|
92155
92494
|
// ../core/src/tasks/post-options.ts
|
|
92495
|
+
var TASK_POST_DEADLINE_LEAD_MS = 3 * 36e5;
|
|
92496
|
+
var TASK_POST_DEADLINE_MARGIN_MS = 6e4;
|
|
92497
|
+
var TASK_DEADLINE_TOO_SOON = "must be at least 3 hours from now when vAPI receives the post, so the task can still be funded and awarded. Use 181m or more.";
|
|
92156
92498
|
function positive(text, name) {
|
|
92157
92499
|
if (text === void 0) throw new TaskInputError(`${name} is required.`);
|
|
92158
92500
|
try {
|
|
@@ -92250,17 +92592,16 @@ function prepareTaskPost(input2, now) {
|
|
|
92250
92592
|
"An open pool requires --open-check allowlist|invite (configure participants separately)."
|
|
92251
92593
|
);
|
|
92252
92594
|
} else {
|
|
92253
|
-
|
|
92254
|
-
|
|
92255
|
-
|
|
92256
|
-
);
|
|
92595
|
+
const lead = input2.shape === void 0 && input2.intake === "submissions" && !input2.milestones && !input2.proofSpec && !input2.checkin ? TASK_LIMITS.postDeadlineMinMs : TASK_POST_DEADLINE_LEAD_MS + TASK_POST_DEADLINE_MARGIN_MS;
|
|
92596
|
+
if (!input2.milestones?.length && duration3 < lead)
|
|
92597
|
+
throw new TaskInputError(`Task deadlines ${TASK_DEADLINE_TOO_SOON}`);
|
|
92257
92598
|
const sum = input2.milestones?.reduce((total, item) => total + BigInt(item.amountBaseUnits), 0n);
|
|
92258
92599
|
amount4 = input2.amountUsd === void 0 && sum !== void 0 ? sum : positive(input2.amountUsd, "--amount");
|
|
92259
92600
|
if (sum !== void 0 && sum !== amount4)
|
|
92260
92601
|
throw new TaskInputError("Milestone amounts must sum to --amount.");
|
|
92261
|
-
if (input2.milestones?.some((item) => Date.parse(item.deadlineAt) - now.getTime() <
|
|
92602
|
+
if (input2.milestones?.some((item) => Date.parse(item.deadlineAt) - now.getTime() < lead))
|
|
92262
92603
|
throw new TaskInputError(
|
|
92263
|
-
|
|
92604
|
+
`Milestone deadlines ${TASK_DEADLINE_TOO_SOON} Creation and funding also check the contract's MIN_WORK_TIME against the chain clock.`
|
|
92264
92605
|
);
|
|
92265
92606
|
}
|
|
92266
92607
|
if (input2.amountUsd !== void 0 && positive(input2.amountUsd, "--amount") !== amount4)
|
|
@@ -93471,7 +93812,7 @@ function csvCell(value) {
|
|
|
93471
93812
|
// ../core/src/swarm-capital.ts
|
|
93472
93813
|
import { createHash as createHash6, randomBytes as randomBytes16 } from "node:crypto";
|
|
93473
93814
|
import { readFile as readFile24, unlink as unlink14 } from "node:fs/promises";
|
|
93474
|
-
import { join as
|
|
93815
|
+
import { join as join21 } from "node:path";
|
|
93475
93816
|
|
|
93476
93817
|
// ../core/src/payment-warning.ts
|
|
93477
93818
|
var PAYMENT_WARNING_CODES = [
|
|
@@ -93488,7 +93829,7 @@ var PAYMENT_WARNING_CODES = [
|
|
|
93488
93829
|
|
|
93489
93830
|
// ../core/src/swarm-workers.ts
|
|
93490
93831
|
import { readFile as readFile23, readdir as readdir8 } from "node:fs/promises";
|
|
93491
|
-
import { join as
|
|
93832
|
+
import { join as join20 } from "node:path";
|
|
93492
93833
|
var runSchema = external_exports.object({
|
|
93493
93834
|
v: external_exports.literal(1),
|
|
93494
93835
|
runId: external_exports.string(),
|
|
@@ -93518,7 +93859,7 @@ var sidecarSchema = external_exports.object({
|
|
|
93518
93859
|
state: external_exports.string().optional()
|
|
93519
93860
|
});
|
|
93520
93861
|
async function assertSwarmWorkersStopped(home, swarm) {
|
|
93521
|
-
const directory =
|
|
93862
|
+
const directory = join20(home, "runs");
|
|
93522
93863
|
let files;
|
|
93523
93864
|
try {
|
|
93524
93865
|
files = await readdir8(directory);
|
|
@@ -93534,7 +93875,7 @@ async function assertSwarmWorkersStopped(home, swarm) {
|
|
|
93534
93875
|
for (const file2 of files.sort()) {
|
|
93535
93876
|
const match = /^(run_[0-9a-f]{24})\.json$/u.exec(file2);
|
|
93536
93877
|
if (match === null) continue;
|
|
93537
|
-
const value = await readWorkerFile(
|
|
93878
|
+
const value = await readWorkerFile(join20(directory, file2));
|
|
93538
93879
|
if (value === void 0) continue;
|
|
93539
93880
|
const parsed = runSchema.safeParse(value);
|
|
93540
93881
|
if (!parsed.success || parsed.data.runId !== match[1]) {
|
|
@@ -93556,7 +93897,7 @@ async function assertSwarmWorkersStopped(home, swarm) {
|
|
|
93556
93897
|
for (const file2 of files) {
|
|
93557
93898
|
const match = /^(run_[0-9a-f]{24})\.railway\.json$/u.exec(file2);
|
|
93558
93899
|
if (match === null) continue;
|
|
93559
|
-
const value = await readWorkerFile(
|
|
93900
|
+
const value = await readWorkerFile(join20(directory, file2));
|
|
93560
93901
|
if (value === void 0) continue;
|
|
93561
93902
|
const parsed = sidecarSchema.safeParse(value);
|
|
93562
93903
|
if (!parsed.success) {
|
|
@@ -94553,13 +94894,13 @@ function runRecordMovementId(value) {
|
|
|
94553
94894
|
return parsed.data;
|
|
94554
94895
|
}
|
|
94555
94896
|
function treasuryRequestRecordPath(home, movementId) {
|
|
94556
|
-
return
|
|
94897
|
+
return join21(home, "runs", "requests", `${movementId}.json`);
|
|
94557
94898
|
}
|
|
94558
94899
|
function delegationRecordPath(home, movementId) {
|
|
94559
|
-
return
|
|
94900
|
+
return join21(home, "runs", "delegations", `${movementId}.json`);
|
|
94560
94901
|
}
|
|
94561
94902
|
function legacyFundingProgressPath(home, name) {
|
|
94562
|
-
return
|
|
94903
|
+
return join21(home, "swarms", `.${name}.funding`);
|
|
94563
94904
|
}
|
|
94564
94905
|
async function readLegacyFundingProgress(home, name) {
|
|
94565
94906
|
try {
|
|
@@ -95209,7 +95550,7 @@ async function removeMemberLocked(home, swarm, account) {
|
|
|
95209
95550
|
}
|
|
95210
95551
|
|
|
95211
95552
|
// ../core/src/status.ts
|
|
95212
|
-
import { join as
|
|
95553
|
+
import { join as join22 } from "node:path";
|
|
95213
95554
|
var STATUS_TIMEOUT_MS = 2e3;
|
|
95214
95555
|
async function buildStatus(deps) {
|
|
95215
95556
|
const timers = deps.timers ?? { setTimeout, clearTimeout };
|
|
@@ -95265,7 +95606,7 @@ function formatUsdAmount(value) {
|
|
|
95265
95606
|
}
|
|
95266
95607
|
async function readVaultStatus(deps) {
|
|
95267
95608
|
const store = deps.secrets.description.replace(/^the /u, "");
|
|
95268
|
-
const path =
|
|
95609
|
+
const path = join22(deps.home, "vault.json");
|
|
95269
95610
|
let file2;
|
|
95270
95611
|
try {
|
|
95271
95612
|
file2 = await readVaultFileUnlocked(path);
|
|
@@ -95755,7 +96096,7 @@ function output2(io, json2, value, human) {
|
|
|
95755
96096
|
}
|
|
95756
96097
|
|
|
95757
96098
|
// ../cli/src/wallet-session.ts
|
|
95758
|
-
import { join as
|
|
96099
|
+
import { join as join23 } from "node:path";
|
|
95759
96100
|
|
|
95760
96101
|
// ../cli/src/args.ts
|
|
95761
96102
|
var UsageError = class extends Error {
|
|
@@ -96004,7 +96345,7 @@ async function confirmWalletName(name, prompt, refusal, dependencies) {
|
|
|
96004
96345
|
if (typed.trim() !== name) throw new KeystoreError(refusal);
|
|
96005
96346
|
}
|
|
96006
96347
|
async function deviceVaultKey(store, dependencies) {
|
|
96007
|
-
const path =
|
|
96348
|
+
const path = join23(store.home, "vault.json");
|
|
96008
96349
|
const metadata = await readVaultFileUnlocked(path);
|
|
96009
96350
|
const secrets = getSecretStore(dependencies);
|
|
96010
96351
|
const key2 = metadata.protected ? await unlockProtectedVault({
|
|
@@ -98692,7 +99033,7 @@ function exactPriceFact(value) {
|
|
|
98692
99033
|
|
|
98693
99034
|
// ../mcp/src/agent/runtime.ts
|
|
98694
99035
|
import { mkdir as mkdir17, readFile as readFile25, readdir as readdir9, rm as rm2 } from "node:fs/promises";
|
|
98695
|
-
import { join as
|
|
99036
|
+
import { join as join24 } from "node:path";
|
|
98696
99037
|
|
|
98697
99038
|
// ../mcp/src/agent/run.ts
|
|
98698
99039
|
var loopSearchResultSchema = external_exports.array(
|
|
@@ -100031,19 +100372,19 @@ var runRecordSchema = external_exports.strictObject({
|
|
|
100031
100372
|
}
|
|
100032
100373
|
);
|
|
100033
100374
|
function runsDirectory(home) {
|
|
100034
|
-
return
|
|
100375
|
+
return join24(home, "runs");
|
|
100035
100376
|
}
|
|
100036
100377
|
function runRecordPath(home, runId) {
|
|
100037
100378
|
assertRunId(runId);
|
|
100038
|
-
return
|
|
100379
|
+
return join24(runsDirectory(home), `${runId}.json`);
|
|
100039
100380
|
}
|
|
100040
100381
|
function runLogPath(home, runId) {
|
|
100041
100382
|
assertRunId(runId);
|
|
100042
|
-
return
|
|
100383
|
+
return join24(runsDirectory(home), `${runId}.log`);
|
|
100043
100384
|
}
|
|
100044
100385
|
function runResultPath(home, runId) {
|
|
100045
100386
|
assertRunId(runId);
|
|
100046
|
-
return
|
|
100387
|
+
return join24(runsDirectory(home), `${runId}.result.json`);
|
|
100047
100388
|
}
|
|
100048
100389
|
async function writeRunRecord(home, record3) {
|
|
100049
100390
|
const path = runRecordPath(home, record3.runId);
|
|
@@ -100074,7 +100415,7 @@ async function listRunRecords(home, filter = {}) {
|
|
|
100074
100415
|
if (match === null) continue;
|
|
100075
100416
|
try {
|
|
100076
100417
|
const record3 = runRecordSchema.parse(
|
|
100077
|
-
JSON.parse(await readFile25(
|
|
100418
|
+
JSON.parse(await readFile25(join24(runsDirectory(home), file2), "utf8"))
|
|
100078
100419
|
);
|
|
100079
100420
|
if (record3.runId !== match[1]) continue;
|
|
100080
100421
|
if (filter.swarm !== void 0 && record3.member.swarm !== filter.swarm) continue;
|
|
@@ -100453,7 +100794,7 @@ async function stopRun(args) {
|
|
|
100453
100794
|
}
|
|
100454
100795
|
}
|
|
100455
100796
|
function memberRunLockPath(home, account) {
|
|
100456
|
-
return
|
|
100797
|
+
return join24(runsDirectory(home), `.member-${account}.lock`);
|
|
100457
100798
|
}
|
|
100458
100799
|
async function withMemberRunLock(home, account, operation) {
|
|
100459
100800
|
if (!WALLET_NAME_PATTERN.test(account))
|
|
@@ -101872,6 +102213,11 @@ function createTasksTools(options) {
|
|
|
101872
102213
|
const client = typeof injected === "function" ? injected(clientOptions) : injected ?? createHostedTasksClient(clientOptions);
|
|
101873
102214
|
return {
|
|
101874
102215
|
client,
|
|
102216
|
+
limitsV2: (async (chainId, shape) => readTaskV2Limits({
|
|
102217
|
+
chainId,
|
|
102218
|
+
shape,
|
|
102219
|
+
rpcFor: options.rpcFor ?? createTasksRpcFor(await loadConfig(getVapiPaths(home).config), { fetch: guardedFetch2 })
|
|
102220
|
+
})),
|
|
101875
102221
|
chain: options.chain ?? (selected === void 0 ? missingTasksChain : lazyTasksChain(async () => {
|
|
101876
102222
|
const { account } = await options.session.payment(selected.name);
|
|
101877
102223
|
const config2 = await loadConfig(getVapiPaths(home).config);
|
|
@@ -104933,7 +105279,7 @@ function assertKeyMatchesAddress(bundle) {
|
|
|
104933
105279
|
}
|
|
104934
105280
|
|
|
104935
105281
|
// ../cli/src/vault.ts
|
|
104936
|
-
import { join as
|
|
105282
|
+
import { join as join29 } from "node:path";
|
|
104937
105283
|
|
|
104938
105284
|
// ../cli/src/balance-reader.ts
|
|
104939
105285
|
function baseUsdcBalanceReader(config2, dependencies) {
|
|
@@ -104957,10 +105303,10 @@ function baseUsdcBalanceReader(config2, dependencies) {
|
|
|
104957
105303
|
}
|
|
104958
105304
|
|
|
104959
105305
|
// ../cli/src/cloud-backup.ts
|
|
104960
|
-
import { join as
|
|
105306
|
+
import { join as join27 } from "node:path";
|
|
104961
105307
|
|
|
104962
105308
|
// ../core/src/cloud-backup.ts
|
|
104963
|
-
import { join as
|
|
105309
|
+
import { join as join26 } from "node:path";
|
|
104964
105310
|
|
|
104965
105311
|
// ../core/src/backup.ts
|
|
104966
105312
|
import {
|
|
@@ -104987,7 +105333,7 @@ import {
|
|
|
104987
105333
|
readdir as readdir10,
|
|
104988
105334
|
rm as rm3
|
|
104989
105335
|
} from "node:fs/promises";
|
|
104990
|
-
import { dirname as dirname12, join as
|
|
105336
|
+
import { dirname as dirname12, join as join25 } from "node:path";
|
|
104991
105337
|
var ERROR_MESSAGES = {
|
|
104992
105338
|
backup_too_large: "Backup envelope exceeds 65,536 bytes.",
|
|
104993
105339
|
backup_open_failed: "Unable to open backup.",
|
|
@@ -105465,7 +105811,7 @@ async function exportBackupSource(options) {
|
|
|
105465
105811
|
var BackupSnapshotChangedError = class extends Error {
|
|
105466
105812
|
};
|
|
105467
105813
|
async function exportBackupSourceAttempt(options, networks) {
|
|
105468
|
-
const path =
|
|
105814
|
+
const path = join25(options.store.home, "vault.json");
|
|
105469
105815
|
const { phrase, file: file2, accounts } = await withVaultLock(path, async () => {
|
|
105470
105816
|
const [phrase2, vault, file3] = await Promise.all([
|
|
105471
105817
|
exportVaultPhrase({ path, key: options.vaultKey }),
|
|
@@ -105601,16 +105947,16 @@ async function restoreBackupPlaintext(options) {
|
|
|
105601
105947
|
} catch {
|
|
105602
105948
|
throw new BackupError("backup_invalid_input");
|
|
105603
105949
|
}
|
|
105604
|
-
const vaultPath2 =
|
|
105605
|
-
const registryPath =
|
|
105950
|
+
const vaultPath2 = join25(options.home, "vault.json");
|
|
105951
|
+
const registryPath = join25(options.home, "wallets.json");
|
|
105606
105952
|
let stagingHome;
|
|
105607
105953
|
let beforePublishError;
|
|
105608
105954
|
let afterPublishError;
|
|
105609
105955
|
try {
|
|
105610
105956
|
await mkdir18(options.home, { recursive: true, mode: 448 });
|
|
105611
|
-
stagingHome = await mkdtemp(
|
|
105612
|
-
const stagedVaultPath =
|
|
105613
|
-
const stagedRegistryPath =
|
|
105957
|
+
stagingHome = await mkdtemp(join25(options.home, ".backup-restore-"));
|
|
105958
|
+
const stagedVaultPath = join25(stagingHome, "vault.json");
|
|
105959
|
+
const stagedRegistryPath = join25(stagingHome, "wallets.json");
|
|
105614
105960
|
await createVault({
|
|
105615
105961
|
path: stagedVaultPath,
|
|
105616
105962
|
key: options.vaultKey,
|
|
@@ -105669,7 +106015,7 @@ async function restoreBackupPlaintext(options) {
|
|
|
105669
106015
|
protected: plaintext.protected,
|
|
105670
106016
|
networks: [...plaintext.registry.networks]
|
|
105671
106017
|
};
|
|
105672
|
-
const markerPath =
|
|
106018
|
+
const markerPath = join25(options.home, RESTORE_MARKER_FILE);
|
|
105673
106019
|
const fingerprint = restoreFingerprint(
|
|
105674
106020
|
plaintext,
|
|
105675
106021
|
stagedV2?.restoreDevice ?? options.device,
|
|
@@ -105880,13 +106226,13 @@ async function stageV2Restore(options) {
|
|
|
105880
106226
|
}
|
|
105881
106227
|
const agents = [];
|
|
105882
106228
|
for (const profile of validAgents) {
|
|
105883
|
-
const stagedPath =
|
|
106229
|
+
const stagedPath = join25(options.stagingHome, "agents", `${profile.name}.json`);
|
|
105884
106230
|
if (await stageRestoreBytes(stagedPath, prettyJson(profile))) {
|
|
105885
106231
|
agents.push({
|
|
105886
106232
|
kind: "agent",
|
|
105887
106233
|
name: profile.name,
|
|
105888
106234
|
stagedPath,
|
|
105889
|
-
targetPath:
|
|
106235
|
+
targetPath: join25(options.home, "agents", `${profile.name}.json`)
|
|
105890
106236
|
});
|
|
105891
106237
|
} else {
|
|
105892
106238
|
skipped2.push({ kind: "agent", name: profile.name, reason: "write_failed" });
|
|
@@ -105906,13 +106252,13 @@ async function stageV2Restore(options) {
|
|
|
105906
106252
|
if (restoreDevice !== void 0) {
|
|
105907
106253
|
for (const value of validSwarms) {
|
|
105908
106254
|
const swarm = swarmFileSchema.parse({ ...value, device: restoreDevice });
|
|
105909
|
-
const stagedPath =
|
|
106255
|
+
const stagedPath = join25(options.stagingHome, "swarms", `${swarm.name}.json`);
|
|
105910
106256
|
if (await stageRestoreBytes(stagedPath, prettyJson(swarm))) {
|
|
105911
106257
|
swarms.push({
|
|
105912
106258
|
kind: "swarm",
|
|
105913
106259
|
name: swarm.name,
|
|
105914
106260
|
stagedPath,
|
|
105915
|
-
targetPath:
|
|
106261
|
+
targetPath: join25(options.home, "swarms", `${swarm.name}.json`)
|
|
105916
106262
|
});
|
|
105917
106263
|
} else {
|
|
105918
106264
|
skipped2.push({ kind: "swarm", name: swarm.name, reason: "write_failed" });
|
|
@@ -105922,13 +106268,13 @@ async function stageV2Restore(options) {
|
|
|
105922
106268
|
const movements = [];
|
|
105923
106269
|
for (const movement of validMovements) {
|
|
105924
106270
|
const restored = reconcileRestoredMovement(movement, assumedReceiptKeys);
|
|
105925
|
-
const stagedPath =
|
|
106271
|
+
const stagedPath = join25(options.stagingHome, "movements", `${restored.id}.json`);
|
|
105926
106272
|
if (await stageRestoreBytes(stagedPath, serializeMovement(restored))) {
|
|
105927
106273
|
movements.push({
|
|
105928
106274
|
kind: "movement",
|
|
105929
106275
|
name: restored.id,
|
|
105930
106276
|
stagedPath,
|
|
105931
|
-
targetPath:
|
|
106277
|
+
targetPath: join25(options.home, "movements", `${restored.id}.json`),
|
|
105932
106278
|
movement: restored
|
|
105933
106279
|
});
|
|
105934
106280
|
} else {
|
|
@@ -106087,7 +106433,7 @@ async function reconcilePublishedMovements(staged, home, requireDurableSafety =
|
|
|
106087
106433
|
const unjournaledKeys = new Set([...signedKeys].filter((key2) => !journaledKeys.has(key2)));
|
|
106088
106434
|
let files;
|
|
106089
106435
|
try {
|
|
106090
|
-
files = await readdir10(
|
|
106436
|
+
files = await readdir10(join25(home, "movements"));
|
|
106091
106437
|
} catch (error61) {
|
|
106092
106438
|
if (isMissingFile4(error61)) return;
|
|
106093
106439
|
if (requireDurableSafety && unjournaledKeys.size > 0) throw error61;
|
|
@@ -106996,7 +107342,7 @@ async function uploadBackupLocked(options, signal) {
|
|
|
106996
107342
|
try {
|
|
106997
107343
|
let vaultFile;
|
|
106998
107344
|
try {
|
|
106999
|
-
vaultFile = await readVaultFileUnlocked(
|
|
107345
|
+
vaultFile = await readVaultFileUnlocked(join26(options.store.home, "vault.json"));
|
|
107000
107346
|
} catch (error61) {
|
|
107001
107347
|
if (error61 instanceof VaultError && error61.code === "not_found") {
|
|
107002
107348
|
return { status: "skipped", reason: "no_vault" };
|
|
@@ -107005,7 +107351,7 @@ async function uploadBackupLocked(options, signal) {
|
|
|
107005
107351
|
}
|
|
107006
107352
|
try {
|
|
107007
107353
|
vaultKey = vaultFile.protected ? await unlockProtectedVault({
|
|
107008
|
-
path:
|
|
107354
|
+
path: join26(options.store.home, "vault.json"),
|
|
107009
107355
|
secrets: options.secrets,
|
|
107010
107356
|
env: options.env,
|
|
107011
107357
|
...options.now === void 0 ? {} : { now: options.now }
|
|
@@ -108526,7 +108872,7 @@ async function cloudBackupCommand(argv, json2, io, dependencies) {
|
|
|
108526
108872
|
}
|
|
108527
108873
|
async function enrollCloudBackup(json2, io, dependencies) {
|
|
108528
108874
|
const paths = getVapiPaths();
|
|
108529
|
-
if (!await fileExists3(
|
|
108875
|
+
if (!await fileExists3(join27(paths.directory, "vault.json"))) {
|
|
108530
108876
|
throw new Error("No vault on this device. Run vapi setup first.");
|
|
108531
108877
|
}
|
|
108532
108878
|
const context = await cloudContext(io, dependencies);
|
|
@@ -108638,7 +108984,7 @@ async function restoreFromOwnerCommand(argv, json2, io, dependencies) {
|
|
|
108638
108984
|
}
|
|
108639
108985
|
const expectedOwner = ownerValue?.toLowerCase();
|
|
108640
108986
|
const paths = getVapiPaths();
|
|
108641
|
-
if (await fileExists3(
|
|
108987
|
+
if (await fileExists3(join27(paths.directory, "vault.json")) && !await fileExists3(join27(paths.directory, ".backup-restore.json"))) {
|
|
108642
108988
|
throw new Error(
|
|
108643
108989
|
`A vault already exists in ${paths.directory}. Move it aside before restoring.`
|
|
108644
108990
|
);
|
|
@@ -109029,7 +109375,7 @@ function writeSkippedWarnings(io, skipped2) {
|
|
|
109029
109375
|
|
|
109030
109376
|
// ../cli/src/setup.ts
|
|
109031
109377
|
import { rm as rm4 } from "node:fs/promises";
|
|
109032
|
-
import { join as
|
|
109378
|
+
import { join as join28 } from "node:path";
|
|
109033
109379
|
|
|
109034
109380
|
// ../cli/src/identity.ts
|
|
109035
109381
|
async function fetchWalletIdentity(options) {
|
|
@@ -109809,7 +110155,7 @@ async function readProcessStdin() {
|
|
|
109809
110155
|
}
|
|
109810
110156
|
|
|
109811
110157
|
// ../cli/src/version.ts
|
|
109812
|
-
var CLI_VERSION = "0.16.
|
|
110158
|
+
var CLI_VERSION = "0.16.2";
|
|
109813
110159
|
|
|
109814
110160
|
// ../cli/src/status.ts
|
|
109815
110161
|
async function statusCommand(argv, json2, io, dependencies) {
|
|
@@ -110024,7 +110370,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
110024
110370
|
steps.push("config");
|
|
110025
110371
|
}
|
|
110026
110372
|
const config2 = await readConfig(paths.config, humanIo);
|
|
110027
|
-
if (!await fileExists3(
|
|
110373
|
+
if (!await fileExists3(join28(paths.directory, "vault.json"))) {
|
|
110028
110374
|
const os = dependencies.secretBackendProbe ?? (dependencies.secretStore === void 0 ? osSecretStore() : void 0);
|
|
110029
110375
|
if (os !== void 0) {
|
|
110030
110376
|
await chooseSecretBackend({ home: paths.directory, os, env: getEnvironment(dependencies) });
|
|
@@ -110036,7 +110382,7 @@ async function setupCommand(argv, json2, io, dependencies) {
|
|
|
110036
110382
|
let changedAccount = false;
|
|
110037
110383
|
let changedLink = false;
|
|
110038
110384
|
let scannedAddresses;
|
|
110039
|
-
if (!await fileExists3(
|
|
110385
|
+
if (!await fileExists3(join28(paths.directory, "vault.json"))) {
|
|
110040
110386
|
const choice = await vaultChoice(dependencies);
|
|
110041
110387
|
if (choice === "restore") {
|
|
110042
110388
|
if (!isInteractive(dependencies)) {
|
|
@@ -110124,7 +110470,7 @@ async function restoreVaultFromPhrase(phrase, config2, io, dependencies, account
|
|
|
110124
110470
|
let scannedAddresses = 0;
|
|
110125
110471
|
try {
|
|
110126
110472
|
const restored = await restoreVault({
|
|
110127
|
-
path:
|
|
110473
|
+
path: join28(paths.directory, "vault.json"),
|
|
110128
110474
|
key: key2,
|
|
110129
110475
|
phrase: validatedPhrase,
|
|
110130
110476
|
probe: async (address10) => await readBalance3(address10) > 0n,
|
|
@@ -110135,7 +110481,7 @@ async function restoreVaultFromPhrase(phrase, config2, io, dependencies, account
|
|
|
110135
110481
|
...dependencies.now === void 0 ? {} : { now: dependencies.now }
|
|
110136
110482
|
});
|
|
110137
110483
|
names = restored.accounts().map((account) => account.name);
|
|
110138
|
-
await rm4(
|
|
110484
|
+
await rm4(join28(paths.directory, "wallets.json"), { force: true });
|
|
110139
110485
|
} finally {
|
|
110140
110486
|
key2.fill(0);
|
|
110141
110487
|
}
|
|
@@ -110218,7 +110564,7 @@ async function restoreCommand(argv, json2, io, dependencies) {
|
|
|
110218
110564
|
}
|
|
110219
110565
|
const accountCount = parseRestoreAccountCount(parsed.one("--accounts"));
|
|
110220
110566
|
const paths = getVapiPaths();
|
|
110221
|
-
const path =
|
|
110567
|
+
const path = join29(paths.directory, "vault.json");
|
|
110222
110568
|
if (await fileExists3(path)) {
|
|
110223
110569
|
throw new Error(
|
|
110224
110570
|
`A vault already exists in ${paths.directory}. Move it aside before restoring.`
|
|
@@ -110375,7 +110721,7 @@ function requireNoArguments2(argv) {
|
|
|
110375
110721
|
parseArguments(argv, { valueOptions: /* @__PURE__ */ new Set(), maximumPositionals: 0 });
|
|
110376
110722
|
}
|
|
110377
110723
|
function vaultPath() {
|
|
110378
|
-
return
|
|
110724
|
+
return join29(getVapiPaths().directory, "vault.json");
|
|
110379
110725
|
}
|
|
110380
110726
|
function quietIo(io) {
|
|
110381
110727
|
return { stdout: () => void 0, stderr: io.stderr };
|
|
@@ -110469,7 +110815,7 @@ async function backupCommand(argv, json2, io, dependencies) {
|
|
|
110469
110815
|
const target = await targetWallet(parsed, dependencies);
|
|
110470
110816
|
const vaultAccount = await target.store.hasVaultAccount(target.name);
|
|
110471
110817
|
if (vaultAccount) {
|
|
110472
|
-
const vault = await readVaultFileUnlocked(
|
|
110818
|
+
const vault = await readVaultFileUnlocked(join29(target.store.home, "vault.json"));
|
|
110473
110819
|
if (vault.accounts.some((account) => account.name === target.name && account.kind === "imported")) {
|
|
110474
110820
|
throw new KeystoreError(
|
|
110475
110821
|
`Account ${target.name} was imported and is not recoverable from the vault phrase. Back it up with vapi export-key --account ${target.name}.`
|
|
@@ -110546,7 +110892,7 @@ async function importCommand(argv, json2, io, dependencies) {
|
|
|
110546
110892
|
const existed = store.has(name);
|
|
110547
110893
|
if (existed && !parsed.has("--replace")) {
|
|
110548
110894
|
const address10 = await store.readAddress(name);
|
|
110549
|
-
const location = await store.hasVaultAccount(name) ?
|
|
110895
|
+
const location = await store.hasVaultAccount(name) ? join29(store.home, "vault.json") : store.pathFor(name);
|
|
110550
110896
|
throw new Error(
|
|
110551
110897
|
[
|
|
110552
110898
|
`Wallet ${name} already exists at ${location}.`,
|
|
@@ -110582,7 +110928,7 @@ async function importCommand(argv, json2, io, dependencies) {
|
|
|
110582
110928
|
const result = {
|
|
110583
110929
|
address: account.address,
|
|
110584
110930
|
...account.solana ? { solanaAddress: account.solana.address } : {},
|
|
110585
|
-
vault:
|
|
110931
|
+
vault: join29(paths.directory, "vault.json"),
|
|
110586
110932
|
...previousKeystore ? { previousKeystore } : {},
|
|
110587
110933
|
message: "Wallet imported. Its encrypted key stays on this machine."
|
|
110588
110934
|
};
|
|
@@ -110783,7 +111129,8 @@ async function retireStoredPassphrase(target, dependencies, io) {
|
|
|
110783
111129
|
|
|
110784
111130
|
// ../cli/src/accounts.ts
|
|
110785
111131
|
import { readFile as readFile28, stat as stat18 } from "node:fs/promises";
|
|
110786
|
-
import { join as
|
|
111132
|
+
import { join as join30 } from "node:path";
|
|
111133
|
+
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
110787
111134
|
|
|
110788
111135
|
// ../cli/src/dashboard.ts
|
|
110789
111136
|
import { resolve as resolve2 } from "node:path";
|
|
@@ -111178,10 +111525,10 @@ async function accountsRenameCommand(argv, json2, io, dependencies) {
|
|
|
111178
111525
|
{
|
|
111179
111526
|
previous: from16,
|
|
111180
111527
|
...address10 === void 0 ? {} : { address: address10 },
|
|
111181
|
-
vault:
|
|
111528
|
+
vault: join30(store.home, "vault.json"),
|
|
111182
111529
|
message: `Wallet ${from16} is now ${renamed.name}.`
|
|
111183
111530
|
},
|
|
111184
|
-
[`Wallet ${from16} is now ${renamed.name}.`, `Vault: ${
|
|
111531
|
+
[`Wallet ${from16} is now ${renamed.name}.`, `Vault: ${join30(store.home, "vault.json")}`].join(
|
|
111185
111532
|
"\n"
|
|
111186
111533
|
)
|
|
111187
111534
|
);
|
|
@@ -111290,33 +111637,44 @@ async function accountsRestoreCommand(argv, json2, io, dependencies) {
|
|
|
111290
111637
|
{ name: restored.name, ...address10 === void 0 ? {} : { address: address10 } },
|
|
111291
111638
|
{
|
|
111292
111639
|
...address10 === void 0 ? {} : { address: address10 },
|
|
111293
|
-
vault:
|
|
111640
|
+
vault: join30(store.home, "vault.json"),
|
|
111294
111641
|
spendCaps: restored.entry.spendCaps,
|
|
111295
111642
|
message: `Wallet ${restored.name} restored to the device vault.`
|
|
111296
111643
|
},
|
|
111297
111644
|
[
|
|
111298
111645
|
`Wallet ${restored.name} restored to the device vault.`,
|
|
111299
|
-
`Vault: ${
|
|
111646
|
+
`Vault: ${join30(store.home, "vault.json")}`
|
|
111300
111647
|
].join("\n")
|
|
111301
111648
|
);
|
|
111302
111649
|
}
|
|
111303
111650
|
async function accountsCapsCommand(argv, json2, io, dependencies) {
|
|
111304
111651
|
const parsed = parseArguments(argv, {
|
|
111305
|
-
valueOptions: /* @__PURE__ */ new Set([
|
|
111652
|
+
valueOptions: /* @__PURE__ */ new Set([
|
|
111653
|
+
"--per-call",
|
|
111654
|
+
"--per-day",
|
|
111655
|
+
"--ceiling",
|
|
111656
|
+
"--max-per-task",
|
|
111657
|
+
"--approve-above"
|
|
111658
|
+
]),
|
|
111659
|
+
booleanOptions: /* @__PURE__ */ new Set(["--yes"]),
|
|
111306
111660
|
maximumPositionals: 1
|
|
111307
111661
|
});
|
|
111308
|
-
const name = requiredPositional(
|
|
111309
|
-
parsed.positionals[0],
|
|
111310
|
-
"<name>",
|
|
111311
|
-
"Usage: vapi accounts caps <name> [--per-call <usd>] [--per-day <usd>] [--ceiling <usd|off>] [--json]"
|
|
111312
|
-
);
|
|
111662
|
+
const name = requiredPositional(parsed.positionals[0], "<name>", CAPS_USAGE);
|
|
111313
111663
|
const perCall = parsed.one("--per-call");
|
|
111314
111664
|
const perDay = parsed.one("--per-day");
|
|
111315
111665
|
const ceiling = parsed.one("--ceiling");
|
|
111666
|
+
const maxPerTask = parsed.one("--max-per-task");
|
|
111667
|
+
const approveAbove = parsed.one("--approve-above");
|
|
111316
111668
|
const store = await openWalletStore(dependencies);
|
|
111317
111669
|
const account = store.resolve({ name, env: {} });
|
|
111318
111670
|
const address10 = await store.readAddress(account.name);
|
|
111319
|
-
|
|
111671
|
+
let taskPolicy = await taskPolicyForWallet({
|
|
111672
|
+
directory: store.home,
|
|
111673
|
+
wallet: account.name,
|
|
111674
|
+
schema: registeredAgentProfileSchema,
|
|
111675
|
+
warn: io.stderr
|
|
111676
|
+
});
|
|
111677
|
+
if (perCall === void 0 && perDay === void 0 && ceiling === void 0 && maxPerTask === void 0 && approveAbove === void 0) {
|
|
111320
111678
|
const caps2 = capsOutput(account.entry.spendCaps, store.ceilingCaps(account.name));
|
|
111321
111679
|
outputForWallet2(
|
|
111322
111680
|
io,
|
|
@@ -111325,13 +111683,15 @@ async function accountsCapsCommand(argv, json2, io, dependencies) {
|
|
|
111325
111683
|
{
|
|
111326
111684
|
...address10 === void 0 ? {} : { address: address10 },
|
|
111327
111685
|
spendCaps: account.entry.spendCaps,
|
|
111328
|
-
...caps2
|
|
111686
|
+
...caps2,
|
|
111687
|
+
taskLimits: taskLimitsJson(taskPolicy)
|
|
111329
111688
|
},
|
|
111330
111689
|
[
|
|
111331
111690
|
walletHeader2({ name: account.name, ...address10 === void 0 ? {} : { address: address10 } }),
|
|
111332
111691
|
`Spend caps: ${formatCaps(account.entry.spendCaps)}`,
|
|
111333
111692
|
`Ceiling: ${caps2.ceilingUsd === "off" ? "off" : `${caps2.ceilingUsd} USDC`}`,
|
|
111334
|
-
|
|
111693
|
+
`Task limits: ${formatTaskLimits(taskPolicy)}`,
|
|
111694
|
+
"Change them with --per-call <usd>, --per-day <usd>, --ceiling <usd|off>, --max-per-task <usd>, or --approve-above <usd>."
|
|
111335
111695
|
].join("\n")
|
|
111336
111696
|
);
|
|
111337
111697
|
return;
|
|
@@ -111344,17 +111704,72 @@ async function accountsCapsCommand(argv, json2, io, dependencies) {
|
|
|
111344
111704
|
throw new UsageError("The per-call cap cannot be larger than the per-day cap.");
|
|
111345
111705
|
}
|
|
111346
111706
|
const ceilingAtomic = ceiling === void 0 ? void 0 : ceiling === "off" ? null : BigInt(capAtomic(ceiling, "--ceiling"));
|
|
111707
|
+
const taskLimits = maxPerTask === void 0 && approveAbove === void 0 ? void 0 : {
|
|
111708
|
+
maxPerTaskUsd: maxPerTask === void 0 ? taskPolicy.maxPerTaskUsd : taskLimitUsd(maxPerTask, "--max-per-task"),
|
|
111709
|
+
approveAboveUsd: approveAbove === void 0 ? taskPolicy.approveAboveUsd : taskLimitUsd(approveAbove, "--approve-above")
|
|
111710
|
+
};
|
|
111711
|
+
const profile = taskLimits === void 0 || taskPolicy.source !== "agent-profile" ? void 0 : (await listAgentProfiles(store.home, {
|
|
111712
|
+
schema: registeredAgentProfileSchema,
|
|
111713
|
+
warn: () => {
|
|
111714
|
+
}
|
|
111715
|
+
})).find((candidate) => candidate.wallet === account.name);
|
|
111716
|
+
if (taskLimits !== void 0 && taskPolicy.source === "agent-profile" && !profile)
|
|
111717
|
+
throw new Error(`The agent profile of ${account.name} is unreadable.`);
|
|
111718
|
+
if (taskLimits !== void 0 && (taskLimits.maxPerTaskUsd > taskPolicy.maxPerTaskUsd || taskLimits.approveAboveUsd > taskPolicy.approveAboveUsd)) {
|
|
111719
|
+
const command = `vapi accounts caps ${account.name}${maxPerTask === void 0 ? "" : ` --max-per-task ${maxPerTask}`}${approveAbove === void 0 ? "" : ` --approve-above ${approveAbove}`}`;
|
|
111720
|
+
const marker = activeAgentMarker(getEnvironment(dependencies));
|
|
111721
|
+
if (marker !== void 0 || !isStdinInteractive(dependencies))
|
|
111722
|
+
throw new UsageError(
|
|
111723
|
+
`Raising a task limit is a decision for a person. Nothing was changed. ${marker === void 0 ? "Standard input is not a terminal." : `${marker} is set, so this is an agent session.`} Run it yourself in a terminal: ${command}`
|
|
111724
|
+
);
|
|
111725
|
+
if (maxPerTask !== void 0 && taskLimits.maxPerTaskUsd > taskPolicy.maxPerTaskUsd) {
|
|
111726
|
+
const liveUsd = await liveTaskLimitUsd(dependencies);
|
|
111727
|
+
if (liveUsd !== void 0 && taskLimits.maxPerTaskUsd > liveUsd)
|
|
111728
|
+
io.stderr(
|
|
111729
|
+
`Note: one task on Base holds at most ${liveUsd} USDC today, so a per-task limit above that changes nothing until the contract's limit is raised.`
|
|
111730
|
+
);
|
|
111731
|
+
}
|
|
111732
|
+
if (!parsed.has("--yes")) {
|
|
111733
|
+
const question = `Raise the task limits of ${account.name} from ${formatTaskLimits(taskPolicy, false)} to ${formatTaskLimits(taskLimits, false)}? Type yes to confirm: `;
|
|
111734
|
+
if (json2 || !isInteractive(dependencies))
|
|
111735
|
+
throw new UsageError(
|
|
111736
|
+
`Raising a task limit needs your confirmation. Nothing was changed. Run it again with --yes: ${command} --yes`
|
|
111737
|
+
);
|
|
111738
|
+
if ((await visibleLine(question, dependencies)).trim().toLowerCase() !== "yes")
|
|
111739
|
+
throw new UsageError("Not confirmed. Nothing was changed.");
|
|
111740
|
+
}
|
|
111741
|
+
}
|
|
111347
111742
|
let entry = account.entry;
|
|
111348
111743
|
if (perCall !== void 0 || perDay !== void 0) {
|
|
111349
111744
|
entry = await store.setSpendCaps(account.name, spendCaps);
|
|
111350
111745
|
}
|
|
111351
111746
|
if (ceilingAtomic !== void 0) entry = await store.setCeiling(account.name, ceilingAtomic);
|
|
111747
|
+
if (taskLimits !== void 0) {
|
|
111748
|
+
if (profile) {
|
|
111749
|
+
await writeAgentProfile(
|
|
111750
|
+
store.home,
|
|
111751
|
+
{ ...profile, ...taskLimits },
|
|
111752
|
+
{ schema: registeredAgentProfileSchema }
|
|
111753
|
+
);
|
|
111754
|
+
taskPolicy = { ...taskPolicy, ...taskLimits };
|
|
111755
|
+
} else {
|
|
111756
|
+
entry = await store.updateTaskPolicy(account.name, (current) => ({
|
|
111757
|
+
...current,
|
|
111758
|
+
...maxPerTask === void 0 ? {} : { maxPerTaskUsd: taskLimits.maxPerTaskUsd },
|
|
111759
|
+
...approveAbove === void 0 ? {} : { approveAboveUsd: taskLimits.approveAboveUsd }
|
|
111760
|
+
}));
|
|
111761
|
+
taskPolicy = { ...taskPolicy, ...taskLimits, source: "account" };
|
|
111762
|
+
}
|
|
111763
|
+
}
|
|
111764
|
+
const taskLimitsChanged = taskLimits !== void 0;
|
|
111352
111765
|
const caps = capsOutput(entry.spendCaps, store.ceilingCaps(account.name));
|
|
111353
111766
|
await recordAudit(dependencies, "wallet.caps", {
|
|
111354
111767
|
wallet: account.name,
|
|
111355
|
-
detail: `${formatCaps(entry.spendCaps)}, ceiling ${caps.ceilingUsd === "off" ? "off" : `${caps.ceilingUsd} USDC`}`
|
|
111768
|
+
detail: `${formatCaps(entry.spendCaps)}, ceiling ${caps.ceilingUsd === "off" ? "off" : `${caps.ceilingUsd} USDC`}${taskLimitsChanged ? `, task limits ${formatTaskLimits(taskPolicy, false)}` : ""}`
|
|
111356
111769
|
});
|
|
111357
|
-
const message = perCall !== void 0 || perDay !== void 0 ? `Spend caps updated for ${account.name}.` : `Ceiling updated for ${account.name}.`;
|
|
111770
|
+
const message = perCall !== void 0 || perDay !== void 0 ? `Spend caps updated for ${account.name}.` : ceilingAtomic !== void 0 ? `Ceiling updated for ${account.name}.` : `Task limits updated for ${account.name}.`;
|
|
111771
|
+
const perDayUsd = Number(formatUsdc(BigInt(entry.spendCaps.perDayAtomic)));
|
|
111772
|
+
const perDayHint = taskLimitsChanged && taskPolicy.maxPerTaskUsd > perDayUsd ? `The per-day cap of ${formatUsdc(BigInt(entry.spendCaps.perDayAtomic))} USD still applies to task funding. Raise it with: vapi accounts caps ${account.name} --per-day <usd>` : void 0;
|
|
111358
111773
|
outputForWallet2(
|
|
111359
111774
|
io,
|
|
111360
111775
|
json2,
|
|
@@ -111363,15 +111778,67 @@ async function accountsCapsCommand(argv, json2, io, dependencies) {
|
|
|
111363
111778
|
...address10 === void 0 ? {} : { address: address10 },
|
|
111364
111779
|
spendCaps: entry.spendCaps,
|
|
111365
111780
|
...caps,
|
|
111366
|
-
|
|
111781
|
+
taskLimits: taskLimitsJson(taskPolicy),
|
|
111782
|
+
message,
|
|
111783
|
+
...perDayHint === void 0 ? {} : { hint: perDayHint }
|
|
111367
111784
|
},
|
|
111368
111785
|
[
|
|
111369
111786
|
message,
|
|
111370
111787
|
`Spend caps: ${formatCaps(entry.spendCaps)}`,
|
|
111371
|
-
`Ceiling: ${caps.ceilingUsd === "off" ? "off" : `${caps.ceilingUsd} USDC`}
|
|
111788
|
+
`Ceiling: ${caps.ceilingUsd === "off" ? "off" : `${caps.ceilingUsd} USDC`}`,
|
|
111789
|
+
`Task limits: ${formatTaskLimits(taskPolicy)}`,
|
|
111790
|
+
...perDayHint === void 0 ? [] : [perDayHint]
|
|
111372
111791
|
].join("\n")
|
|
111373
111792
|
);
|
|
111374
111793
|
}
|
|
111794
|
+
var CAPS_USAGE = "Usage: vapi accounts caps <name> [--per-call <usd>] [--per-day <usd>] [--ceiling <usd|off>] [--max-per-task <usd>] [--approve-above <usd>] [--yes] [--json]";
|
|
111795
|
+
function taskLimitsJson(policy) {
|
|
111796
|
+
return {
|
|
111797
|
+
maxPerTaskUsd: policy.maxPerTaskUsd,
|
|
111798
|
+
approveAboveUsd: policy.approveAboveUsd,
|
|
111799
|
+
source: policy.source
|
|
111800
|
+
};
|
|
111801
|
+
}
|
|
111802
|
+
function formatTaskLimits(policy, withSource = true) {
|
|
111803
|
+
const source = policy.source === "agent-profile" ? "agent profile" : policy.source === "account" ? "set for this account" : "defaults";
|
|
111804
|
+
return `${policy.maxPerTaskUsd} USD per task, approval above ${policy.approveAboveUsd} USD${withSource && policy.source ? ` (${source})` : ""}`;
|
|
111805
|
+
}
|
|
111806
|
+
async function visibleLine(prompt, dependencies) {
|
|
111807
|
+
const line = getPrompts(dependencies).line;
|
|
111808
|
+
if (line) return await line(prompt);
|
|
111809
|
+
const reader = createInterface3({ input: process.stdin, output: process.stderr });
|
|
111810
|
+
try {
|
|
111811
|
+
return await reader.question(prompt);
|
|
111812
|
+
} finally {
|
|
111813
|
+
reader.close();
|
|
111814
|
+
}
|
|
111815
|
+
}
|
|
111816
|
+
var MAX_TASK_LIMIT_USD = 1e6;
|
|
111817
|
+
function taskLimitUsd(value, option) {
|
|
111818
|
+
const usd3 = Number(formatUsdc(BigInt(capAtomic(value, option))));
|
|
111819
|
+
if (!Number.isFinite(usd3) || usd3 > MAX_TASK_LIMIT_USD)
|
|
111820
|
+
throw new UsageError(`${option} must be at most ${MAX_TASK_LIMIT_USD} USD.`);
|
|
111821
|
+
return usd3;
|
|
111822
|
+
}
|
|
111823
|
+
async function liveTaskLimitUsd(dependencies) {
|
|
111824
|
+
try {
|
|
111825
|
+
const env = getEnvironment(dependencies);
|
|
111826
|
+
const rpcFor = dependencies.tasks?.rpcFor ?? createTasksRpcFor(await accountsConfig(dependencies), {
|
|
111827
|
+
env,
|
|
111828
|
+
...dependencies.fetchImpl === void 0 ? {} : { fetch: dependencies.fetchImpl }
|
|
111829
|
+
});
|
|
111830
|
+
const limits = await readTaskV2Limits({
|
|
111831
|
+
chainId: 8453,
|
|
111832
|
+
shape: "task",
|
|
111833
|
+
rpcFor,
|
|
111834
|
+
env,
|
|
111835
|
+
timeoutMs: 2e3
|
|
111836
|
+
});
|
|
111837
|
+
return limits === void 0 ? void 0 : Number(formatUsdc(limits.maxBaseUnits));
|
|
111838
|
+
} catch {
|
|
111839
|
+
return void 0;
|
|
111840
|
+
}
|
|
111841
|
+
}
|
|
111375
111842
|
var DISTRIBUTE_USAGE = "Usage: vapi accounts distribute <amount> --from <account> [--to <a,b,c>] [--network base|arc] [--json]\n vapi accounts distribute --resume <id> [--replace-expired-restored] [--bind-legacy-addresses] [--json]\n vapi accounts distribute --cancel <id> [--replace-expired-restored] [--json]";
|
|
111376
111843
|
async function accountsDistributeCommand(argv, json2, io, dependencies) {
|
|
111377
111844
|
const parsed = parseArguments(argv, {
|
|
@@ -111627,19 +112094,19 @@ function formatNetworkAccounts(accounts) {
|
|
|
111627
112094
|
|
|
111628
112095
|
// ../cli/src/agent.ts
|
|
111629
112096
|
import { readFile as readFile30, stat as stat19 } from "node:fs/promises";
|
|
111630
|
-
import { join as
|
|
111631
|
-
import { createInterface as
|
|
112097
|
+
import { join as join33 } from "node:path";
|
|
112098
|
+
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
111632
112099
|
|
|
111633
112100
|
// ../cli/src/headless.ts
|
|
111634
112101
|
import { rmSync } from "node:fs";
|
|
111635
112102
|
import { chmod as chmod7, mkdtemp as mkdtemp2, rm as rm5, writeFile as writeFile9 } from "node:fs/promises";
|
|
111636
112103
|
import { tmpdir as osTmpdir } from "node:os";
|
|
111637
|
-
import { join as
|
|
112104
|
+
import { join as join31 } from "node:path";
|
|
111638
112105
|
var BUNDLE_VARIABLE_PATTERN = /^[A-Z_][A-Z0-9_]*$/u;
|
|
111639
112106
|
var REMOTE_BLOCKED_GRANTS2 = /* @__PURE__ */ new Set(["delegate", "allocate"]);
|
|
111640
112107
|
var agentProfileOptions = { schema: registeredAgentProfileSchema };
|
|
111641
112108
|
async function createHeadlessHome(bundle, options = {}) {
|
|
111642
|
-
const home = await mkdtemp2(
|
|
112109
|
+
const home = await mkdtemp2(join31(options.tmpdir ?? osTmpdir(), "vapi-headless-"));
|
|
111643
112110
|
const cleanup = async () => {
|
|
111644
112111
|
await rm5(home, { recursive: true, force: true });
|
|
111645
112112
|
};
|
|
@@ -111851,7 +112318,7 @@ import {
|
|
|
111851
112318
|
writeFile as nodeWriteFile
|
|
111852
112319
|
} from "node:fs/promises";
|
|
111853
112320
|
import { tmpdir as osTmpdir2 } from "node:os";
|
|
111854
|
-
import { basename as basename4, dirname as dirname14, join as
|
|
112321
|
+
import { basename as basename4, dirname as dirname14, join as join32 } from "node:path";
|
|
111855
112322
|
var RAILWAY_CLI = {
|
|
111856
112323
|
binary: "railway",
|
|
111857
112324
|
create: (options) => [
|
|
@@ -112042,7 +112509,7 @@ async function assertRemoteSafeMember(args) {
|
|
|
112042
112509
|
}
|
|
112043
112510
|
function railwaySidecarPath(home, runId) {
|
|
112044
112511
|
if (!isRunId(runId)) throw new RuntimeError("invalid_run_id", `Invalid run id: ${runId}.`);
|
|
112045
|
-
return
|
|
112512
|
+
return join32(runsDirectory(home), `${runId}.railway.json`);
|
|
112046
112513
|
}
|
|
112047
112514
|
function createRailwayRuntime(options) {
|
|
112048
112515
|
const { home } = options;
|
|
@@ -112403,10 +112870,10 @@ ${destroyedInstruction}
|
|
|
112403
112870
|
let createError;
|
|
112404
112871
|
let cleanupError;
|
|
112405
112872
|
try {
|
|
112406
|
-
directory = await fs.mkdtemp(
|
|
112873
|
+
directory = await fs.mkdtemp(join32(options.tmpdir ?? osTmpdir2(), "vapi-railway-"));
|
|
112407
112874
|
assertNotInterrupted();
|
|
112408
112875
|
await assertMode(fs, directory, 448, "env-file directory");
|
|
112409
|
-
envFile =
|
|
112876
|
+
envFile = join32(directory, "member.env");
|
|
112410
112877
|
await fs.writeFile(envFile, `${RAILWAY_CLI.bundleVariable}=${bundle}
|
|
112411
112878
|
`, {
|
|
112412
112879
|
encoding: "utf8",
|
|
@@ -112767,7 +113234,7 @@ Destroy it yourself with: railway sandbox destroy ${id2}`
|
|
|
112767
113234
|
return { runId, sandboxId: id2, destroyed: true };
|
|
112768
113235
|
};
|
|
112769
113236
|
if (account !== void 0) return await withMemberRunLock(home, account, destroy);
|
|
112770
|
-
return await withFileLock(
|
|
113237
|
+
return await withFileLock(join32(runsDirectory(home), `.sidecar-${runId}.lock`), destroy, {
|
|
112771
113238
|
timeoutMs: 5e3,
|
|
112772
113239
|
lockedMessage: `Run ${runId} is changing sidecar state.`
|
|
112773
113240
|
});
|
|
@@ -112989,7 +113456,7 @@ async function writeSidecar(home, runId, sidecar) {
|
|
|
112989
113456
|
function writeSidecarSync(path, sidecar) {
|
|
112990
113457
|
const directory = dirname14(path);
|
|
112991
113458
|
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
112992
|
-
const temporary =
|
|
113459
|
+
const temporary = join32(
|
|
112993
113460
|
directory,
|
|
112994
113461
|
`.${basename4(path)}.${process.pid}.${randomBytes17(6).toString("hex")}.tmp`
|
|
112995
113462
|
);
|
|
@@ -113087,7 +113554,7 @@ async function assertMode(fs, path, mode, what) {
|
|
|
113087
113554
|
}
|
|
113088
113555
|
}
|
|
113089
113556
|
async function deviceVaultKey2(home, secrets, now) {
|
|
113090
|
-
const path =
|
|
113557
|
+
const path = join32(home, "vault.json");
|
|
113091
113558
|
const metadata = await readVaultFileUnlocked(path);
|
|
113092
113559
|
const key2 = metadata.protected ? await unlockProtectedVault({
|
|
113093
113560
|
path,
|
|
@@ -113458,24 +113925,42 @@ async function createCommand(argv, json2, io, dependencies) {
|
|
|
113458
113925
|
const callBudget = usdOption(parsed.one("--call-budget") ?? "1", "--call-budget", true);
|
|
113459
113926
|
const maxPerCall = usdOption(parsed.one("--max-per-call") ?? "0.05", "--max-per-call");
|
|
113460
113927
|
const routerBudget = usdOption(parsed.one("--router-budget") ?? "1", "--router-budget", true);
|
|
113461
|
-
const
|
|
113928
|
+
const initialStore = await openWalletStore(dependencies);
|
|
113929
|
+
const owned = initialStore.entry(name);
|
|
113930
|
+
const stricter = accountTaskLimitsUnderProfile(owned?.taskPolicy);
|
|
113931
|
+
const defaultMaxPerTask = stricter?.maxPerTaskUsd ?? DEFAULT_MAX_PER_TASK_USD;
|
|
113932
|
+
const approveAbove = usdOption(
|
|
113933
|
+
parsed.one("--approve-above") ?? String(stricter?.approveAboveUsd ?? 0.5),
|
|
113934
|
+
"--approve-above"
|
|
113935
|
+
);
|
|
113462
113936
|
const maxSteps = boundedInteger(parsed.one("--max-steps") ?? "12", "--max-steps", 1, 50);
|
|
113463
113937
|
const interactive = !json2 && (dependencies.interactive ?? Boolean(process.stdin.isTTY && process.stdout.isTTY));
|
|
113464
113938
|
const promptForTaskPolicy = interactive && !parsed.has("--yes");
|
|
113465
113939
|
const maxPerTask = usdOption(
|
|
113466
|
-
parsed.one("--max-per-task") ?? ((promptForTaskPolicy ? await
|
|
113940
|
+
parsed.one("--max-per-task") ?? ((promptForTaskPolicy ? await visibleLine2(`Max per task in USD [${defaultMaxPerTask}]: `, dependencies) : "") || String(defaultMaxPerTask)),
|
|
113467
113941
|
"--max-per-task"
|
|
113468
113942
|
);
|
|
113469
113943
|
const autoReleaseBelow = usdOption(
|
|
113470
|
-
parsed.one("--auto-release-below") ?? ((promptForTaskPolicy ? await
|
|
113944
|
+
parsed.one("--auto-release-below") ?? ((promptForTaskPolicy ? await visibleLine2(
|
|
113471
113945
|
`Auto-release below in USD [${DEFAULT_AUTO_RELEASE_BELOW_USD}]: `,
|
|
113472
113946
|
dependencies
|
|
113473
113947
|
) : "") || String(DEFAULT_AUTO_RELEASE_BELOW_USD)),
|
|
113474
113948
|
"--auto-release-below"
|
|
113475
113949
|
);
|
|
113950
|
+
if (owned !== void 0) {
|
|
113951
|
+
const raised = [
|
|
113952
|
+
...maxPerTask.number > (owned.taskPolicy?.maxPerTaskUsd ?? DEFAULT_MAX_PER_TASK_USD) ? [`--max-per-task ${maxPerTask.text}`] : [],
|
|
113953
|
+
...approveAbove.number > (owned.taskPolicy?.approveAboveUsd ?? 0.5) ? [`--approve-above ${approveAbove.text}`] : [],
|
|
113954
|
+
...BigInt(callBudget.atomic) > BigInt(owned.spendCaps.perDayAtomic) ? [`--call-budget ${callBudget.text}`] : []
|
|
113955
|
+
];
|
|
113956
|
+
const marker = activeAgentMarker(getEnvironment(dependencies));
|
|
113957
|
+
if (raised.length > 0 && (marker !== void 0 || !isStdinInteractive(dependencies)))
|
|
113958
|
+
throw new UsageError(
|
|
113959
|
+
`Account ${name} already exists, and ${raised.join(", ")} would raise what it has now: ${owned.taskPolicy?.maxPerTaskUsd ?? DEFAULT_MAX_PER_TASK_USD} USD per task, approval above ${owned.taskPolicy?.approveAboveUsd ?? 0.5} USD, ${formatUsdc(BigInt(owned.spendCaps.perDayAtomic))} USD per day. Raising a limit is a decision for a person. Nothing was changed. ${marker === void 0 ? "Standard input is not a terminal." : `${marker} is set, so this is an agent session.`} Run the command yourself in a terminal, or leave these values at or below the account's.`
|
|
113960
|
+
);
|
|
113961
|
+
}
|
|
113476
113962
|
const commandIo = json2 ? { stdout: () => void 0, stderr: io.stderr } : io;
|
|
113477
|
-
|
|
113478
|
-
if (!initialStore.has(name)) {
|
|
113963
|
+
if (owned === void 0) {
|
|
113479
113964
|
await walletCreateCommand([name, "--label", name], json2, commandIo, dependencies);
|
|
113480
113965
|
}
|
|
113481
113966
|
await walletCapsCommand(
|
|
@@ -113500,6 +113985,20 @@ async function createCommand(argv, json2, io, dependencies) {
|
|
|
113500
113985
|
paused: false,
|
|
113501
113986
|
createdAt: (dependencies.now?.() ?? /* @__PURE__ */ new Date()).toISOString()
|
|
113502
113987
|
};
|
|
113988
|
+
let clearedAccountTaskLimits = false;
|
|
113989
|
+
const keptAccountTaskLimits = (await initialStore.updateTaskPolicy(name, (current) => {
|
|
113990
|
+
const kept = accountTaskLimitsUnderProfile(current);
|
|
113991
|
+
clearedAccountTaskLimits = JSON.stringify(kept) !== JSON.stringify(current);
|
|
113992
|
+
return kept;
|
|
113993
|
+
})).taskPolicy;
|
|
113994
|
+
if (keptAccountTaskLimits)
|
|
113995
|
+
io.stderr(
|
|
113996
|
+
`Account ${name} keeps the task limits its owner set below the defaults. When the agent profile is removed it returns to ${keptAccountTaskLimits.maxPerTaskUsd ?? DEFAULT_MAX_PER_TASK_USD} USD per task and approval above ${keptAccountTaskLimits.approveAboveUsd ?? 0.5} USD. The agent profile holds the limits now: ${profile.maxPerTaskUsd} USD per task, approval above ${profile.approveAboveUsd} USD.`
|
|
113997
|
+
);
|
|
113998
|
+
else if (clearedAccountTaskLimits)
|
|
113999
|
+
io.stderr(
|
|
114000
|
+
`The task limits set for account ${name} with vapi accounts caps were cleared. The agent profile holds them now: ${profile.maxPerTaskUsd} USD per task, approval above ${profile.approveAboveUsd} USD.`
|
|
114001
|
+
);
|
|
113503
114002
|
const writeProfile = dependencies.agent?.writeAgentProfile ?? writeAgentProfile;
|
|
113504
114003
|
await writeProfile(paths.directory, profile, agentProfileOptions2);
|
|
113505
114004
|
await runLoginFlow(["--account", name, "--label", name], json2, commandIo, dependencies, {
|
|
@@ -113527,6 +114026,7 @@ async function createCommand(argv, json2, io, dependencies) {
|
|
|
113527
114026
|
perDayAtomic: callBudget.atomic
|
|
113528
114027
|
},
|
|
113529
114028
|
routerAllowanceUsd: routerBudget.number,
|
|
114029
|
+
...clearedAccountTaskLimits ? { clearedAccountTaskLimits: true } : {},
|
|
113530
114030
|
fundingHint
|
|
113531
114031
|
})
|
|
113532
114032
|
);
|
|
@@ -113779,7 +114279,7 @@ async function buildAgentRunDeps(input2) {
|
|
|
113779
114279
|
};
|
|
113780
114280
|
const approve2 = async ({ ref, priceUsd, reason }) => {
|
|
113781
114281
|
if (approvals === "decline" || !tty) return false;
|
|
113782
|
-
const answer = await
|
|
114282
|
+
const answer = await visibleLine2(
|
|
113783
114283
|
`Pay ${usd(priceUsd)} to ${ref}? ${reason} [y/N] `,
|
|
113784
114284
|
dependencies
|
|
113785
114285
|
);
|
|
@@ -114052,10 +114552,10 @@ function searchQuery(argumentsJson) {
|
|
|
114052
114552
|
return void 0;
|
|
114053
114553
|
}
|
|
114054
114554
|
}
|
|
114055
|
-
async function
|
|
114555
|
+
async function visibleLine2(prompt, dependencies) {
|
|
114056
114556
|
if (dependencies.prompts?.line)
|
|
114057
114557
|
return (await dependencies.prompts.line(prompt)).trim().toLowerCase();
|
|
114058
|
-
const reader =
|
|
114558
|
+
const reader = createInterface4({ input: process.stdin, output: process.stderr });
|
|
114059
114559
|
try {
|
|
114060
114560
|
return (await reader.question(prompt)).trim().toLowerCase();
|
|
114061
114561
|
} finally {
|
|
@@ -114067,7 +114567,7 @@ function explicitWallet(name) {
|
|
|
114067
114567
|
}
|
|
114068
114568
|
async function profileFileExists(directory, name) {
|
|
114069
114569
|
try {
|
|
114070
|
-
await stat19(
|
|
114570
|
+
await stat19(join33(directory, `${name}.json`));
|
|
114071
114571
|
return true;
|
|
114072
114572
|
} catch (error61) {
|
|
114073
114573
|
if (isMissingFile(error61)) return false;
|
|
@@ -114784,7 +115284,7 @@ import { constants as constants3, homedir as homedir4 } from "node:os";
|
|
|
114784
115284
|
import { constants as constants2 } from "node:fs";
|
|
114785
115285
|
import { access, mkdir as mkdir20, readFile as readFile31, realpath, unlink as unlink15, writeFile as writeFile10 } from "node:fs/promises";
|
|
114786
115286
|
import { homedir as homedir3 } from "node:os";
|
|
114787
|
-
import { basename as basename5, dirname as dirname15, join as
|
|
115287
|
+
import { basename as basename5, dirname as dirname15, join as join34, posix, win32 as win322 } from "node:path";
|
|
114788
115288
|
|
|
114789
115289
|
// ../cli/src/toml-config.ts
|
|
114790
115290
|
function removeTomlTables(contents, isTarget) {
|
|
@@ -114864,7 +115364,7 @@ var VAPI_CODEX_PROFILE = "vapi";
|
|
|
114864
115364
|
var VAPI_CODEX_DEFAULT_MODEL = "venice/openai-gpt-61-sol";
|
|
114865
115365
|
var VAPI_ROUTER_KEY_ENV = "VAPI_ROUTER_KEY";
|
|
114866
115366
|
function codexConfigPath(env, home) {
|
|
114867
|
-
return
|
|
115367
|
+
return join34(env.CODEX_HOME || join34(home, ".codex"), "config.toml");
|
|
114868
115368
|
}
|
|
114869
115369
|
function hasVapiCodexProfile(contents) {
|
|
114870
115370
|
const roots = new Set(
|
|
@@ -114980,7 +115480,7 @@ async function codeCommand(argv, json2, io, dependencies) {
|
|
|
114980
115480
|
const env = getEnvironment(dependencies);
|
|
114981
115481
|
const home = dependencies.code?.homedir ?? homedir3();
|
|
114982
115482
|
const config2 = codexConfigPath(env, home);
|
|
114983
|
-
const rcPaths = [
|
|
115483
|
+
const rcPaths = [join34(home, ".zshrc"), join34(home, ".bashrc")];
|
|
114984
115484
|
if (command === "uninstall") {
|
|
114985
115485
|
const removed = [];
|
|
114986
115486
|
const previous = await readOptional(config2);
|
|
@@ -117226,7 +117726,8 @@ async function taskV2Command(verb, id2, parsed, json2, io, dependencies) {
|
|
|
117226
117726
|
const policy = await taskPolicyForWallet({
|
|
117227
117727
|
directory: getVapiPaths().directory,
|
|
117228
117728
|
wallet: target.name,
|
|
117229
|
-
schema: registeredAgentProfileSchema
|
|
117729
|
+
schema: registeredAgentProfileSchema,
|
|
117730
|
+
warn: io.stderr
|
|
117230
117731
|
});
|
|
117231
117732
|
try {
|
|
117232
117733
|
const result = await executeTaskV2(context, {
|
|
@@ -117328,7 +117829,8 @@ async function taskJuryCommand(verb, id2, parsed, json2, io, dependencies) {
|
|
|
117328
117829
|
policy: await taskPolicyForWallet({
|
|
117329
117830
|
directory: getVapiPaths().directory,
|
|
117330
117831
|
wallet: target.name,
|
|
117331
|
-
schema: registeredAgentProfileSchema
|
|
117832
|
+
schema: registeredAgentProfileSchema,
|
|
117833
|
+
warn: io.stderr
|
|
117332
117834
|
}),
|
|
117333
117835
|
caps: await spendCapsForWallet(target.store, target.name),
|
|
117334
117836
|
wallet: target.name,
|
|
@@ -117427,12 +117929,13 @@ var TASK_HELP = `Usage:
|
|
|
117427
117929
|
vapi task watch <id> [--until <state>] [--auto-release] [--timeout 7d] [--interval 5s] [--counterparty <0x\u2026>] [--account <name>] [--json]
|
|
117428
117930
|
vapi task status <id> [--operation <uuid> --step <v2-step> --recover|--abandon] [--account <name>] [--json]
|
|
117429
117931
|
|
|
117430
|
-
Durations: 5s, 10m, 48h, 7d, or an ISO-8601 timestamp.
|
|
117932
|
+
Durations: 5s, 10m, 48h, 7d, or an ISO-8601 timestamp. A task deadline and every task milestone deadline must be at least 3 hours ahead when vAPI receives the post (one hour of work time, one to award, one to fund); use 181m or more. Bounty and pool posting and proposal terms require at least 10 minutes.
|
|
117431
117933
|
V1 dispute accepts a precomputed evidence hash. V2 dispute accepts --index with --evidence text. Milestone action indices are zero-based; declared milestone indices remain one-based.
|
|
117432
117934
|
Jury: ${TASK_V2_JURY_RULES} ${TASK_V2_REVIEWER_GUIDANCE} Jury open repeats while the case is Snapshotting.
|
|
117433
117935
|
Vote --commit seals the salt in a local ballot under VAPI_HOME before vAPI sees the commitment; --reveal reads that ballot back by the onchain commitment, so reveal from the machine that committed. --to-worker is USDC base units and only for split.
|
|
117434
117936
|
Watch requires an interval of at least 1s and a positive timeout. Auto-release uses the acting wallet's agent profile, or defaults, and releases only amounts strictly below the threshold.
|
|
117435
|
-
Posting without --fund moves no money. --fund applies task and daily caps before signing.
|
|
117937
|
+
Posting without --fund moves no money. --fund applies task and daily caps before signing. Fund, post --fund, approve-bond, sign --action award-consent and award --worker need vAPI to report Tasks as available and stop before signing when it does not; a rerun of an operation that already signed something is resumed instead. Show or raise task limits with vapi accounts caps <name> [--max-per-task <usd>] [--approve-above <usd>].
|
|
117938
|
+
Base mainnet runs V2 only: the worker runs sign --action award-consent, then the poster runs award --worker <addr>. propose sends an offer the poster can read. award <proposalId> and sign without --action are V1 only. Task reads require tasks:read and writes require tasks:write; write access includes reads.
|
|
117436
117939
|
The thread cursor is the previous page's nextBeforeSeq; --after reads older messages using beforeSeq.
|
|
117437
117940
|
Every command accepts --json. Watch and a partially completed sign may write more than one JSON value. Human diagnostics go to stderr.
|
|
117438
117941
|
|
|
@@ -117615,6 +118118,10 @@ async function taskContext(parsed, io, dependencies, publicOnly = false) {
|
|
|
117615
118118
|
const injected = dependencies.tasks?.client;
|
|
117616
118119
|
const client = typeof injected === "function" ? injected(options) : injected ?? createHostedTasksClient(options);
|
|
117617
118120
|
const pending = createPendingTransactions(getVapiPaths().directory);
|
|
118121
|
+
const readRpcFor = dependencies.tasks?.rpcFor ?? createTasksRpcFor(config2, {
|
|
118122
|
+
env,
|
|
118123
|
+
...dependencies.fetchImpl === void 0 ? {} : { fetch: dependencies.fetchImpl }
|
|
118124
|
+
});
|
|
117618
118125
|
const chain2 = dependencies.tasks?.chain ?? (publicOnly || target === void 0 ? missingTasksChain : lazyTasksChain2(
|
|
117619
118126
|
async () => {
|
|
117620
118127
|
const { account } = await unlockTarget(target, dependencies);
|
|
@@ -117641,6 +118148,7 @@ async function taskContext(parsed, io, dependencies, publicOnly = false) {
|
|
|
117641
118148
|
));
|
|
117642
118149
|
return {
|
|
117643
118150
|
client,
|
|
118151
|
+
limitsV2: (chainId, shape) => readTaskV2Limits({ chainId, shape, rpcFor: readRpcFor, env }),
|
|
117644
118152
|
baseUrl,
|
|
117645
118153
|
...target === void 0 ? {} : { target },
|
|
117646
118154
|
...token === void 0 ? {} : { token },
|
|
@@ -117854,7 +118362,8 @@ async function taskCommandInner(argv, json2, io, dependencies) {
|
|
|
117854
118362
|
budget: parsed.one("--budget"),
|
|
117855
118363
|
gate: enumOption(parsed.one("--gate"), ["open", "proven"], "--gate"),
|
|
117856
118364
|
verifier: enumOption(parsed.one("--verifier"), ["poster", "vapi"], "--verifier"),
|
|
117857
|
-
openCheck: enumOption(parsed.one("--open-check"), ["allowlist", "invite"], "--open-check")
|
|
118365
|
+
openCheck: enumOption(parsed.one("--open-check"), ["allowlist", "invite"], "--open-check"),
|
|
118366
|
+
intake: enumOption(parsed.one("--intake"), ["proposals", "submissions"], "--intake")
|
|
117858
118367
|
},
|
|
117859
118368
|
now
|
|
117860
118369
|
);
|
|
@@ -117887,7 +118396,9 @@ async function taskCommandInner(argv, json2, io, dependencies) {
|
|
|
117887
118396
|
...intake === void 0 ? {} : { intake },
|
|
117888
118397
|
...maxAwards === void 0 ? {} : { maxAwards },
|
|
117889
118398
|
...parsed.one("--webhook") === void 0 ? {} : { webhook: parsed.one("--webhook") },
|
|
117890
|
-
onFeeUnavailable: () => io.stderr(
|
|
118399
|
+
onFeeUnavailable: () => io.stderr(
|
|
118400
|
+
"The fee could not be read from the Tasks contract or from vAPI. Funding shows it before anything is signed."
|
|
118401
|
+
)
|
|
117891
118402
|
});
|
|
117892
118403
|
if (parsed.has("--fund")) {
|
|
117893
118404
|
if (outcome.funding?.error) {
|
|
@@ -118754,7 +119265,7 @@ Usage:
|
|
|
118754
119265
|
vapi accounts use <name> [--json]
|
|
118755
119266
|
vapi accounts remove <name> [--force] [--json]
|
|
118756
119267
|
vapi accounts restore <name> [--json]
|
|
118757
|
-
vapi accounts caps <name> [--per-call <usd>] [--per-day <usd>] [--ceiling <usd|off>] [--json]
|
|
119268
|
+
vapi accounts caps <name> [--per-call <usd>] [--per-day <usd>] [--ceiling <usd|off>] [--max-per-task <usd>] [--approve-above <usd>] [--yes] [--json]
|
|
118758
119269
|
vapi accounts distribute <amount> --from <account> [--to <a,b,c>] [--network base|arc] [--json]
|
|
118759
119270
|
vapi accounts distribute --resume <id> [--replace-expired-restored] [--bind-legacy-addresses] [--json]
|
|
118760
119271
|
vapi accounts distribute --cancel <id> [--replace-expired-restored] [--json]
|
|
@@ -119070,7 +119581,7 @@ async function runCli(argv = process.argv.slice(2), io = processIo, dependencies
|
|
|
119070
119581
|
break;
|
|
119071
119582
|
case "unlock":
|
|
119072
119583
|
io.stderr("vapi unlock is now vapi vault unlock; the old name works for one release.");
|
|
119073
|
-
if (await fileExists3(
|
|
119584
|
+
if (await fileExists3(join35(getVapiPaths().directory, "vault.json"))) {
|
|
119074
119585
|
parseArguments(args.slice(1), {
|
|
119075
119586
|
valueOptions: /* @__PURE__ */ new Set([WALLET_OPTION]),
|
|
119076
119587
|
maximumPositionals: 0
|
|
@@ -119270,7 +119781,7 @@ async function initCommand(argv, json2, io, dependencies) {
|
|
|
119270
119781
|
address: account.address,
|
|
119271
119782
|
accounts,
|
|
119272
119783
|
config: paths.config,
|
|
119273
|
-
vault:
|
|
119784
|
+
vault: join35(paths.directory, "vault.json"),
|
|
119274
119785
|
...configRewrites.length > 0 ? { configRewrites } : {},
|
|
119275
119786
|
custody: "self",
|
|
119276
119787
|
warning: CUSTODY_NOTICE,
|
|
@@ -119409,7 +119920,7 @@ async function walletCreateCommand(argv, json2, io, dependencies) {
|
|
|
119409
119920
|
const result = {
|
|
119410
119921
|
address: account.address,
|
|
119411
119922
|
...account.solana ? { solanaAddress: account.solana.address } : {},
|
|
119412
|
-
vault:
|
|
119923
|
+
vault: join35(paths.directory, "vault.json"),
|
|
119413
119924
|
...label2 === void 0 ? {} : { label: label2 },
|
|
119414
119925
|
spendCaps: created.entry.spendCaps,
|
|
119415
119926
|
isDefault,
|
|
@@ -119449,7 +119960,7 @@ function formatCaps2(caps) {
|
|
|
119449
119960
|
function walletListResult(store, wallets, unlocked) {
|
|
119450
119961
|
return {
|
|
119451
119962
|
default: store.defaultName ?? null,
|
|
119452
|
-
vault:
|
|
119963
|
+
vault: join35(store.home, "vault.json"),
|
|
119453
119964
|
wallets: wallets.map((wallet) => ({
|
|
119454
119965
|
name: wallet.name,
|
|
119455
119966
|
...wallet.address === void 0 ? {} : { address: wallet.address },
|