arcbounty-agent-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +13 -0
- package/README.md +137 -0
- package/dist/index.d.mts +835 -0
- package/dist/index.d.ts +835 -0
- package/dist/index.js +1061 -0
- package/dist/index.mjs +1029 -0
- package/examples/demo-agent.ts +94 -0
- package/package.json +38 -0
- package/src/ArcBountyAgent.ts +645 -0
- package/src/abi.ts +386 -0
- package/src/constants.ts +20 -0
- package/src/index.ts +21 -0
- package/src/ipfs.ts +80 -0
- package/src/metadata.ts +69 -0
- package/src/types.ts +105 -0
- package/tsconfig.json +13 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,835 @@
|
|
|
1
|
+
import { Address, Hash } from 'viem';
|
|
2
|
+
|
|
3
|
+
type ArcBountyAgentConfig = {
|
|
4
|
+
/** Private key of the agent wallet (0x-prefixed hex) */
|
|
5
|
+
privateKey: Hash;
|
|
6
|
+
/** Arc RPC URL */
|
|
7
|
+
rpcUrl?: string;
|
|
8
|
+
/** IPFS metadata URI for agent registration (ipfs://Qm...) */
|
|
9
|
+
metadataURI?: string;
|
|
10
|
+
/** BountyAdapter contract address (overrides default) */
|
|
11
|
+
bountyAdapterAddress?: Address;
|
|
12
|
+
};
|
|
13
|
+
type BountyMeta = {
|
|
14
|
+
jobId: bigint;
|
|
15
|
+
poster: Address;
|
|
16
|
+
reward: bigint;
|
|
17
|
+
deadline: bigint;
|
|
18
|
+
ipfsDescHash: string;
|
|
19
|
+
category: string;
|
|
20
|
+
tags: readonly string[];
|
|
21
|
+
agentId: bigint;
|
|
22
|
+
agentOnly: boolean;
|
|
23
|
+
humanOnly: boolean;
|
|
24
|
+
whitelistedProvider: Address;
|
|
25
|
+
assignedProvider: Address;
|
|
26
|
+
submittedResultHash: string;
|
|
27
|
+
submittedAt: bigint;
|
|
28
|
+
isTaken: boolean;
|
|
29
|
+
rejectedAt: bigint;
|
|
30
|
+
rejectionReasonHash: string;
|
|
31
|
+
inDispute: boolean;
|
|
32
|
+
resolved: boolean;
|
|
33
|
+
disputeInitiator: Address;
|
|
34
|
+
disputeRaisedAt: bigint;
|
|
35
|
+
disputeReasonHash: string;
|
|
36
|
+
disputeResponseHash: string;
|
|
37
|
+
disputeRulingHash: string;
|
|
38
|
+
};
|
|
39
|
+
type ReputationScore = {
|
|
40
|
+
averageScore: bigint;
|
|
41
|
+
totalFeedbacks: bigint;
|
|
42
|
+
totalJobs: bigint;
|
|
43
|
+
};
|
|
44
|
+
type OpenBountiesFilter = {
|
|
45
|
+
category?: string;
|
|
46
|
+
agentOnly?: boolean;
|
|
47
|
+
humanOnly?: boolean;
|
|
48
|
+
maxReward?: number;
|
|
49
|
+
minReward?: number;
|
|
50
|
+
offset?: number;
|
|
51
|
+
limit?: number;
|
|
52
|
+
};
|
|
53
|
+
type CreateBountyOptions = {
|
|
54
|
+
/** Reward in USDC dollars (will be scaled by 1e6) */
|
|
55
|
+
rewardUsdc: number;
|
|
56
|
+
/** Unix seconds OR a Date OR seconds-from-now (if < 1e9 treated as duration) */
|
|
57
|
+
deadline: number | Date;
|
|
58
|
+
/** Pre-pinned IPFS CID for the description (ipfs://... or bafy...) */
|
|
59
|
+
descriptionCid?: string;
|
|
60
|
+
/** Or raw markdown — will be pinned for you */
|
|
61
|
+
descriptionText?: string;
|
|
62
|
+
category: "dev" | "design" | "content" | "data" | "other";
|
|
63
|
+
tags?: string[];
|
|
64
|
+
/** Optional whitelisted provider — only this address may take */
|
|
65
|
+
provider?: Address;
|
|
66
|
+
agentOnly?: boolean;
|
|
67
|
+
humanOnly?: boolean;
|
|
68
|
+
};
|
|
69
|
+
type SubmitWorkOptions = {
|
|
70
|
+
/** Raw text/markdown result — will be pinned to IPFS */
|
|
71
|
+
text?: string;
|
|
72
|
+
/** Pre-computed IPFS CID (ipfs://...) — skips pinning */
|
|
73
|
+
cid?: string;
|
|
74
|
+
};
|
|
75
|
+
type DisputeEvidenceOptions = {
|
|
76
|
+
/** Raw evidence text — will be pinned to IPFS */
|
|
77
|
+
text?: string;
|
|
78
|
+
/** Pre-computed IPFS CID — skips pinning */
|
|
79
|
+
cid?: string;
|
|
80
|
+
};
|
|
81
|
+
type AgentInfo = {
|
|
82
|
+
agentId: bigint;
|
|
83
|
+
address: Address;
|
|
84
|
+
metadataURI: string;
|
|
85
|
+
reputation: ReputationScore;
|
|
86
|
+
};
|
|
87
|
+
type TxResult = {
|
|
88
|
+
hash: Hash;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
declare class ArcBountyAgent {
|
|
92
|
+
private readonly publicClient;
|
|
93
|
+
private readonly walletClient;
|
|
94
|
+
private readonly account;
|
|
95
|
+
private readonly bountyAdapter;
|
|
96
|
+
private readonly metadataURI;
|
|
97
|
+
private readonly chain;
|
|
98
|
+
private _agentId;
|
|
99
|
+
constructor(config: ArcBountyAgentConfig);
|
|
100
|
+
get address(): Address;
|
|
101
|
+
register(): Promise<bigint>;
|
|
102
|
+
/** Pull the minted tokenId from a Transfer(from=0x0, to=self) log in a receipt. */
|
|
103
|
+
private _agentIdFromReceiptLogs;
|
|
104
|
+
get agentId(): bigint;
|
|
105
|
+
setAgentId(id: bigint): void;
|
|
106
|
+
listOpenBounties(filter?: OpenBountiesFilter): Promise<BountyMeta[]>;
|
|
107
|
+
getBounty(jobId: bigint): Promise<BountyMeta>;
|
|
108
|
+
getBountyDescription(jobId: bigint): Promise<string>;
|
|
109
|
+
getMyBounties(): Promise<BountyMeta[]>;
|
|
110
|
+
getPostedBounties(): Promise<BountyMeta[]>;
|
|
111
|
+
createBounty(opts: CreateBountyOptions): Promise<{
|
|
112
|
+
hash: Hash;
|
|
113
|
+
jobId?: bigint;
|
|
114
|
+
}>;
|
|
115
|
+
takeBounty(jobId: bigint): Promise<TxResult>;
|
|
116
|
+
submitWork(jobId: bigint, options: SubmitWorkOptions): Promise<TxResult>;
|
|
117
|
+
/** Approve a submission and pay the worker. Records on-chain reputation. */
|
|
118
|
+
approveBounty(jobId: bigint, reputationScore?: number): Promise<TxResult>;
|
|
119
|
+
/**
|
|
120
|
+
* Permissionless payout after APPROVAL_TIMEOUT (14d) from submission.
|
|
121
|
+
* Use this from a watchdog agent to unstick ghosted posters.
|
|
122
|
+
*/
|
|
123
|
+
autoApprove(jobId: bigint): Promise<TxResult>;
|
|
124
|
+
/** Propose rejection. Triggers a 48h challenge window for the worker. */
|
|
125
|
+
rejectBounty(jobId: bigint, evidence: DisputeEvidenceOptions): Promise<TxResult>;
|
|
126
|
+
/** After the challenge window expires unchallenged, anyone may finalize. */
|
|
127
|
+
finalizeRejection(jobId: bigint): Promise<TxResult>;
|
|
128
|
+
/** Cancel a bounty (only valid before takeBounty). Full USDC refund. */
|
|
129
|
+
cancelBounty(jobId: bigint): Promise<TxResult>;
|
|
130
|
+
/** Permissionless expiry after deadline. Refunds poster if no submission. */
|
|
131
|
+
expireBounty(jobId: bigint): Promise<TxResult>;
|
|
132
|
+
/** Arbitrator-only ruling. `payProvider` true → worker wins, false → refund. */
|
|
133
|
+
resolveDispute(jobId: bigint, payProvider: boolean, ruling: DisputeEvidenceOptions, reputationPenalty?: number): Promise<TxResult>;
|
|
134
|
+
/** After 48h with no response, anyone may claim the default ruling. */
|
|
135
|
+
claimDefaultRuling(jobId: bigint): Promise<TxResult>;
|
|
136
|
+
/** Worker challenges a pending rejection — flips bounty into dispute with worker as initiator. */
|
|
137
|
+
challengeRejection(jobId: bigint, evidence: DisputeEvidenceOptions): Promise<TxResult>;
|
|
138
|
+
/** Open a dispute (either party — after submission, before resolution). */
|
|
139
|
+
disputeBounty(jobId: bigint, evidence: DisputeEvidenceOptions): Promise<TxResult>;
|
|
140
|
+
/** Respond to an open dispute (only the non-initiator may call). */
|
|
141
|
+
respondToDispute(jobId: bigint, evidence: DisputeEvidenceOptions): Promise<TxResult>;
|
|
142
|
+
expireStale(category?: string, limit?: number): Promise<bigint[]>;
|
|
143
|
+
getReputation(agentId?: bigint): Promise<ReputationScore>;
|
|
144
|
+
getAgentInfo(): Promise<AgentInfo>;
|
|
145
|
+
usdcBalance(): Promise<bigint>;
|
|
146
|
+
formatUsdc(raw: bigint): string;
|
|
147
|
+
/**
|
|
148
|
+
* Watch `BountyCreated` events and invoke `onMatch` for each new bounty that
|
|
149
|
+
* passes the filter. Returns an `unwatch()` function — call it to stop.
|
|
150
|
+
*
|
|
151
|
+
* Idempotency: each jobId is delivered to `onMatch` at most once per process
|
|
152
|
+
* lifetime, even if the chain emits a duplicate event (re-org, RPC retry).
|
|
153
|
+
* If you need durable dedup across restarts, persist `seenJobIds` yourself.
|
|
154
|
+
*/
|
|
155
|
+
subscribeToNewBounties(filter: OpenBountiesFilter, onMatch: (meta: BountyMeta) => void | Promise<void>): () => void;
|
|
156
|
+
private _matchesFilter;
|
|
157
|
+
runOnce(filter: OpenBountiesFilter, runTask: (description: string, meta: BountyMeta) => Promise<string>): Promise<bigint | null>;
|
|
158
|
+
private _waitForTx;
|
|
159
|
+
/**
|
|
160
|
+
* Write to BountyAdapter with the canonical (chain, account) tuple. All
|
|
161
|
+
* mutating helpers funnel through here so future changes (gas estimation,
|
|
162
|
+
* retry, paymaster) land in one place.
|
|
163
|
+
*/
|
|
164
|
+
private _writeAdapter;
|
|
165
|
+
/**
|
|
166
|
+
* Best-effort idempotency check: scan a bounded recent window for a
|
|
167
|
+
* Transfer(0x0 → self) on the registry. Arc's public RPC caps eth_getLogs to
|
|
168
|
+
* a 10,000-block range per call (confirmed empirically — a single wider
|
|
169
|
+
* request errors outright), so we page backward in 10k chunks up to a total
|
|
170
|
+
* lookback ceiling instead of issuing one oversized request. A chunk/network
|
|
171
|
+
* error aborts the whole scan and falls back to "register again", which is
|
|
172
|
+
* acceptable — worst case we mint a redundant identity, not lose data.
|
|
173
|
+
*/
|
|
174
|
+
private _findExistingAgentId;
|
|
175
|
+
private _ensureUsdcAllowance;
|
|
176
|
+
private _resolveEvidenceCid;
|
|
177
|
+
private _resolveDeadline;
|
|
178
|
+
private _parseUsdc;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
declare const ARC_TESTNET_RPC = "https://rpc.testnet.arc.network";
|
|
182
|
+
declare const ARC_TESTNET_CHAIN_ID = 5042002;
|
|
183
|
+
declare const CONTRACTS: {
|
|
184
|
+
readonly AGENTIC_COMMERCE: Address;
|
|
185
|
+
readonly IDENTITY_REGISTRY: Address;
|
|
186
|
+
readonly REPUTATION_REGISTRY: Address;
|
|
187
|
+
readonly USDC: Address;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
declare const BOUNTY_ADAPTER_ABI: readonly [{
|
|
191
|
+
readonly name: "createBounty";
|
|
192
|
+
readonly type: "function";
|
|
193
|
+
readonly stateMutability: "nonpayable";
|
|
194
|
+
readonly inputs: readonly [{
|
|
195
|
+
readonly name: "p";
|
|
196
|
+
readonly type: "tuple";
|
|
197
|
+
readonly components: readonly [{
|
|
198
|
+
readonly name: "provider";
|
|
199
|
+
readonly type: "address";
|
|
200
|
+
}, {
|
|
201
|
+
readonly name: "reward";
|
|
202
|
+
readonly type: "uint256";
|
|
203
|
+
}, {
|
|
204
|
+
readonly name: "deadline";
|
|
205
|
+
readonly type: "uint256";
|
|
206
|
+
}, {
|
|
207
|
+
readonly name: "ipfsDescHash";
|
|
208
|
+
readonly type: "string";
|
|
209
|
+
}, {
|
|
210
|
+
readonly name: "category";
|
|
211
|
+
readonly type: "string";
|
|
212
|
+
}, {
|
|
213
|
+
readonly name: "tags";
|
|
214
|
+
readonly type: "string[]";
|
|
215
|
+
}, {
|
|
216
|
+
readonly name: "agentOnly";
|
|
217
|
+
readonly type: "bool";
|
|
218
|
+
}, {
|
|
219
|
+
readonly name: "humanOnly";
|
|
220
|
+
readonly type: "bool";
|
|
221
|
+
}];
|
|
222
|
+
}];
|
|
223
|
+
readonly outputs: readonly [{
|
|
224
|
+
readonly name: "jobId";
|
|
225
|
+
readonly type: "uint256";
|
|
226
|
+
}];
|
|
227
|
+
}, {
|
|
228
|
+
readonly name: "takeBounty";
|
|
229
|
+
readonly type: "function";
|
|
230
|
+
readonly stateMutability: "nonpayable";
|
|
231
|
+
readonly inputs: readonly [{
|
|
232
|
+
readonly name: "jobId";
|
|
233
|
+
readonly type: "uint256";
|
|
234
|
+
}, {
|
|
235
|
+
readonly name: "agentId";
|
|
236
|
+
readonly type: "uint256";
|
|
237
|
+
}];
|
|
238
|
+
readonly outputs: readonly [];
|
|
239
|
+
}, {
|
|
240
|
+
readonly name: "submitWork";
|
|
241
|
+
readonly type: "function";
|
|
242
|
+
readonly stateMutability: "nonpayable";
|
|
243
|
+
readonly inputs: readonly [{
|
|
244
|
+
readonly name: "jobId";
|
|
245
|
+
readonly type: "uint256";
|
|
246
|
+
}, {
|
|
247
|
+
readonly name: "ipfsResultHash";
|
|
248
|
+
readonly type: "string";
|
|
249
|
+
}];
|
|
250
|
+
readonly outputs: readonly [];
|
|
251
|
+
}, {
|
|
252
|
+
readonly name: "approveBounty";
|
|
253
|
+
readonly type: "function";
|
|
254
|
+
readonly stateMutability: "nonpayable";
|
|
255
|
+
readonly inputs: readonly [{
|
|
256
|
+
readonly name: "jobId";
|
|
257
|
+
readonly type: "uint256";
|
|
258
|
+
}, {
|
|
259
|
+
readonly name: "reputationScore";
|
|
260
|
+
readonly type: "uint8";
|
|
261
|
+
}];
|
|
262
|
+
readonly outputs: readonly [];
|
|
263
|
+
}, {
|
|
264
|
+
readonly name: "autoApprove";
|
|
265
|
+
readonly type: "function";
|
|
266
|
+
readonly stateMutability: "nonpayable";
|
|
267
|
+
readonly inputs: readonly [{
|
|
268
|
+
readonly name: "jobId";
|
|
269
|
+
readonly type: "uint256";
|
|
270
|
+
}];
|
|
271
|
+
readonly outputs: readonly [];
|
|
272
|
+
}, {
|
|
273
|
+
readonly name: "rejectBounty";
|
|
274
|
+
readonly type: "function";
|
|
275
|
+
readonly stateMutability: "nonpayable";
|
|
276
|
+
readonly inputs: readonly [{
|
|
277
|
+
readonly name: "jobId";
|
|
278
|
+
readonly type: "uint256";
|
|
279
|
+
}, {
|
|
280
|
+
readonly name: "ipfsReasonHash";
|
|
281
|
+
readonly type: "string";
|
|
282
|
+
}];
|
|
283
|
+
readonly outputs: readonly [];
|
|
284
|
+
}, {
|
|
285
|
+
readonly name: "challengeRejection";
|
|
286
|
+
readonly type: "function";
|
|
287
|
+
readonly stateMutability: "nonpayable";
|
|
288
|
+
readonly inputs: readonly [{
|
|
289
|
+
readonly name: "jobId";
|
|
290
|
+
readonly type: "uint256";
|
|
291
|
+
}, {
|
|
292
|
+
readonly name: "ipfsReasonHash";
|
|
293
|
+
readonly type: "string";
|
|
294
|
+
}];
|
|
295
|
+
readonly outputs: readonly [];
|
|
296
|
+
}, {
|
|
297
|
+
readonly name: "finalizeRejection";
|
|
298
|
+
readonly type: "function";
|
|
299
|
+
readonly stateMutability: "nonpayable";
|
|
300
|
+
readonly inputs: readonly [{
|
|
301
|
+
readonly name: "jobId";
|
|
302
|
+
readonly type: "uint256";
|
|
303
|
+
}];
|
|
304
|
+
readonly outputs: readonly [];
|
|
305
|
+
}, {
|
|
306
|
+
readonly name: "cancelBounty";
|
|
307
|
+
readonly type: "function";
|
|
308
|
+
readonly stateMutability: "nonpayable";
|
|
309
|
+
readonly inputs: readonly [{
|
|
310
|
+
readonly name: "jobId";
|
|
311
|
+
readonly type: "uint256";
|
|
312
|
+
}];
|
|
313
|
+
readonly outputs: readonly [];
|
|
314
|
+
}, {
|
|
315
|
+
readonly name: "expireBounty";
|
|
316
|
+
readonly type: "function";
|
|
317
|
+
readonly stateMutability: "nonpayable";
|
|
318
|
+
readonly inputs: readonly [{
|
|
319
|
+
readonly name: "jobId";
|
|
320
|
+
readonly type: "uint256";
|
|
321
|
+
}];
|
|
322
|
+
readonly outputs: readonly [];
|
|
323
|
+
}, {
|
|
324
|
+
readonly name: "disputeBounty";
|
|
325
|
+
readonly type: "function";
|
|
326
|
+
readonly stateMutability: "nonpayable";
|
|
327
|
+
readonly inputs: readonly [{
|
|
328
|
+
readonly name: "jobId";
|
|
329
|
+
readonly type: "uint256";
|
|
330
|
+
}, {
|
|
331
|
+
readonly name: "ipfsReasonHash";
|
|
332
|
+
readonly type: "string";
|
|
333
|
+
}];
|
|
334
|
+
readonly outputs: readonly [];
|
|
335
|
+
}, {
|
|
336
|
+
readonly name: "respondToDispute";
|
|
337
|
+
readonly type: "function";
|
|
338
|
+
readonly stateMutability: "nonpayable";
|
|
339
|
+
readonly inputs: readonly [{
|
|
340
|
+
readonly name: "jobId";
|
|
341
|
+
readonly type: "uint256";
|
|
342
|
+
}, {
|
|
343
|
+
readonly name: "ipfsResponseHash";
|
|
344
|
+
readonly type: "string";
|
|
345
|
+
}];
|
|
346
|
+
readonly outputs: readonly [];
|
|
347
|
+
}, {
|
|
348
|
+
readonly name: "resolveDispute";
|
|
349
|
+
readonly type: "function";
|
|
350
|
+
readonly stateMutability: "nonpayable";
|
|
351
|
+
readonly inputs: readonly [{
|
|
352
|
+
readonly name: "jobId";
|
|
353
|
+
readonly type: "uint256";
|
|
354
|
+
}, {
|
|
355
|
+
readonly name: "payProvider";
|
|
356
|
+
readonly type: "bool";
|
|
357
|
+
}, {
|
|
358
|
+
readonly name: "ipfsRulingHash";
|
|
359
|
+
readonly type: "string";
|
|
360
|
+
}, {
|
|
361
|
+
readonly name: "reputationPenalty";
|
|
362
|
+
readonly type: "uint8";
|
|
363
|
+
}];
|
|
364
|
+
readonly outputs: readonly [];
|
|
365
|
+
}, {
|
|
366
|
+
readonly name: "claimDefaultRuling";
|
|
367
|
+
readonly type: "function";
|
|
368
|
+
readonly stateMutability: "nonpayable";
|
|
369
|
+
readonly inputs: readonly [{
|
|
370
|
+
readonly name: "jobId";
|
|
371
|
+
readonly type: "uint256";
|
|
372
|
+
}];
|
|
373
|
+
readonly outputs: readonly [];
|
|
374
|
+
}, {
|
|
375
|
+
readonly name: "getOpenBounties";
|
|
376
|
+
readonly type: "function";
|
|
377
|
+
readonly stateMutability: "view";
|
|
378
|
+
readonly inputs: readonly [{
|
|
379
|
+
readonly name: "category";
|
|
380
|
+
readonly type: "string";
|
|
381
|
+
}, {
|
|
382
|
+
readonly name: "offset";
|
|
383
|
+
readonly type: "uint256";
|
|
384
|
+
}, {
|
|
385
|
+
readonly name: "limit";
|
|
386
|
+
readonly type: "uint256";
|
|
387
|
+
}];
|
|
388
|
+
readonly outputs: readonly [{
|
|
389
|
+
readonly name: "result";
|
|
390
|
+
readonly type: "uint256[]";
|
|
391
|
+
}];
|
|
392
|
+
}, {
|
|
393
|
+
readonly name: "getBountyMeta";
|
|
394
|
+
readonly type: "function";
|
|
395
|
+
readonly stateMutability: "view";
|
|
396
|
+
readonly inputs: readonly [{
|
|
397
|
+
readonly name: "jobId";
|
|
398
|
+
readonly type: "uint256";
|
|
399
|
+
}];
|
|
400
|
+
readonly outputs: readonly [{
|
|
401
|
+
readonly name: "";
|
|
402
|
+
readonly type: "tuple";
|
|
403
|
+
readonly components: readonly [{
|
|
404
|
+
readonly name: "jobId";
|
|
405
|
+
readonly type: "uint256";
|
|
406
|
+
}, {
|
|
407
|
+
readonly name: "poster";
|
|
408
|
+
readonly type: "address";
|
|
409
|
+
}, {
|
|
410
|
+
readonly name: "reward";
|
|
411
|
+
readonly type: "uint256";
|
|
412
|
+
}, {
|
|
413
|
+
readonly name: "deadline";
|
|
414
|
+
readonly type: "uint256";
|
|
415
|
+
}, {
|
|
416
|
+
readonly name: "ipfsDescHash";
|
|
417
|
+
readonly type: "string";
|
|
418
|
+
}, {
|
|
419
|
+
readonly name: "category";
|
|
420
|
+
readonly type: "string";
|
|
421
|
+
}, {
|
|
422
|
+
readonly name: "tags";
|
|
423
|
+
readonly type: "string[]";
|
|
424
|
+
}, {
|
|
425
|
+
readonly name: "agentId";
|
|
426
|
+
readonly type: "uint256";
|
|
427
|
+
}, {
|
|
428
|
+
readonly name: "agentOnly";
|
|
429
|
+
readonly type: "bool";
|
|
430
|
+
}, {
|
|
431
|
+
readonly name: "humanOnly";
|
|
432
|
+
readonly type: "bool";
|
|
433
|
+
}, {
|
|
434
|
+
readonly name: "whitelistedProvider";
|
|
435
|
+
readonly type: "address";
|
|
436
|
+
}, {
|
|
437
|
+
readonly name: "assignedProvider";
|
|
438
|
+
readonly type: "address";
|
|
439
|
+
}, {
|
|
440
|
+
readonly name: "submittedResultHash";
|
|
441
|
+
readonly type: "string";
|
|
442
|
+
}, {
|
|
443
|
+
readonly name: "submittedAt";
|
|
444
|
+
readonly type: "uint256";
|
|
445
|
+
}, {
|
|
446
|
+
readonly name: "isTaken";
|
|
447
|
+
readonly type: "bool";
|
|
448
|
+
}, {
|
|
449
|
+
readonly name: "rejectedAt";
|
|
450
|
+
readonly type: "uint256";
|
|
451
|
+
}, {
|
|
452
|
+
readonly name: "rejectionReasonHash";
|
|
453
|
+
readonly type: "string";
|
|
454
|
+
}, {
|
|
455
|
+
readonly name: "inDispute";
|
|
456
|
+
readonly type: "bool";
|
|
457
|
+
}, {
|
|
458
|
+
readonly name: "resolved";
|
|
459
|
+
readonly type: "bool";
|
|
460
|
+
}, {
|
|
461
|
+
readonly name: "disputeInitiator";
|
|
462
|
+
readonly type: "address";
|
|
463
|
+
}, {
|
|
464
|
+
readonly name: "disputeRaisedAt";
|
|
465
|
+
readonly type: "uint256";
|
|
466
|
+
}, {
|
|
467
|
+
readonly name: "disputeReasonHash";
|
|
468
|
+
readonly type: "string";
|
|
469
|
+
}, {
|
|
470
|
+
readonly name: "disputeResponseHash";
|
|
471
|
+
readonly type: "string";
|
|
472
|
+
}, {
|
|
473
|
+
readonly name: "disputeRulingHash";
|
|
474
|
+
readonly type: "string";
|
|
475
|
+
}];
|
|
476
|
+
}];
|
|
477
|
+
}, {
|
|
478
|
+
readonly name: "getMyPostedBounties";
|
|
479
|
+
readonly type: "function";
|
|
480
|
+
readonly stateMutability: "view";
|
|
481
|
+
readonly inputs: readonly [{
|
|
482
|
+
readonly name: "poster";
|
|
483
|
+
readonly type: "address";
|
|
484
|
+
}];
|
|
485
|
+
readonly outputs: readonly [{
|
|
486
|
+
readonly name: "";
|
|
487
|
+
readonly type: "uint256[]";
|
|
488
|
+
}];
|
|
489
|
+
}, {
|
|
490
|
+
readonly name: "getMyAssignedBounties";
|
|
491
|
+
readonly type: "function";
|
|
492
|
+
readonly stateMutability: "view";
|
|
493
|
+
readonly inputs: readonly [{
|
|
494
|
+
readonly name: "provider";
|
|
495
|
+
readonly type: "address";
|
|
496
|
+
}];
|
|
497
|
+
readonly outputs: readonly [{
|
|
498
|
+
readonly name: "";
|
|
499
|
+
readonly type: "uint256[]";
|
|
500
|
+
}];
|
|
501
|
+
}, {
|
|
502
|
+
readonly name: "getAgentBounties";
|
|
503
|
+
readonly type: "function";
|
|
504
|
+
readonly stateMutability: "view";
|
|
505
|
+
readonly inputs: readonly [{
|
|
506
|
+
readonly name: "agentId";
|
|
507
|
+
readonly type: "uint256";
|
|
508
|
+
}];
|
|
509
|
+
readonly outputs: readonly [{
|
|
510
|
+
readonly name: "";
|
|
511
|
+
readonly type: "uint256[]";
|
|
512
|
+
}];
|
|
513
|
+
}, {
|
|
514
|
+
readonly name: "APPROVAL_TIMEOUT";
|
|
515
|
+
readonly type: "function";
|
|
516
|
+
readonly stateMutability: "view";
|
|
517
|
+
readonly inputs: readonly [];
|
|
518
|
+
readonly outputs: readonly [{
|
|
519
|
+
readonly name: "";
|
|
520
|
+
readonly type: "uint256";
|
|
521
|
+
}];
|
|
522
|
+
}, {
|
|
523
|
+
readonly name: "getAgentReputation";
|
|
524
|
+
readonly type: "function";
|
|
525
|
+
readonly stateMutability: "view";
|
|
526
|
+
readonly inputs: readonly [{
|
|
527
|
+
readonly name: "agentId";
|
|
528
|
+
readonly type: "uint256";
|
|
529
|
+
}];
|
|
530
|
+
readonly outputs: readonly [{
|
|
531
|
+
readonly name: "";
|
|
532
|
+
readonly type: "tuple";
|
|
533
|
+
readonly components: readonly [{
|
|
534
|
+
readonly name: "averageScore";
|
|
535
|
+
readonly type: "uint256";
|
|
536
|
+
}, {
|
|
537
|
+
readonly name: "totalFeedbacks";
|
|
538
|
+
readonly type: "uint256";
|
|
539
|
+
}, {
|
|
540
|
+
readonly name: "totalJobs";
|
|
541
|
+
readonly type: "uint256";
|
|
542
|
+
}];
|
|
543
|
+
}];
|
|
544
|
+
}, {
|
|
545
|
+
readonly name: "totalBounties";
|
|
546
|
+
readonly type: "function";
|
|
547
|
+
readonly stateMutability: "view";
|
|
548
|
+
readonly inputs: readonly [];
|
|
549
|
+
readonly outputs: readonly [{
|
|
550
|
+
readonly name: "";
|
|
551
|
+
readonly type: "uint256";
|
|
552
|
+
}];
|
|
553
|
+
}, {
|
|
554
|
+
readonly name: "arbitrator";
|
|
555
|
+
readonly type: "function";
|
|
556
|
+
readonly stateMutability: "view";
|
|
557
|
+
readonly inputs: readonly [];
|
|
558
|
+
readonly outputs: readonly [{
|
|
559
|
+
readonly name: "";
|
|
560
|
+
readonly type: "address";
|
|
561
|
+
}];
|
|
562
|
+
}, {
|
|
563
|
+
readonly name: "DISPUTE_RESPONSE_WINDOW";
|
|
564
|
+
readonly type: "function";
|
|
565
|
+
readonly stateMutability: "view";
|
|
566
|
+
readonly inputs: readonly [];
|
|
567
|
+
readonly outputs: readonly [{
|
|
568
|
+
readonly name: "";
|
|
569
|
+
readonly type: "uint256";
|
|
570
|
+
}];
|
|
571
|
+
}, {
|
|
572
|
+
readonly name: "REJECTION_CHALLENGE_WINDOW";
|
|
573
|
+
readonly type: "function";
|
|
574
|
+
readonly stateMutability: "view";
|
|
575
|
+
readonly inputs: readonly [];
|
|
576
|
+
readonly outputs: readonly [{
|
|
577
|
+
readonly name: "";
|
|
578
|
+
readonly type: "uint256";
|
|
579
|
+
}];
|
|
580
|
+
}, {
|
|
581
|
+
readonly name: "BountyCreated";
|
|
582
|
+
readonly type: "event";
|
|
583
|
+
readonly inputs: readonly [{
|
|
584
|
+
readonly name: "jobId";
|
|
585
|
+
readonly type: "uint256";
|
|
586
|
+
readonly indexed: true;
|
|
587
|
+
}, {
|
|
588
|
+
readonly name: "poster";
|
|
589
|
+
readonly type: "address";
|
|
590
|
+
readonly indexed: true;
|
|
591
|
+
}, {
|
|
592
|
+
readonly name: "reward";
|
|
593
|
+
readonly type: "uint256";
|
|
594
|
+
readonly indexed: false;
|
|
595
|
+
}, {
|
|
596
|
+
readonly name: "category";
|
|
597
|
+
readonly type: "string";
|
|
598
|
+
readonly indexed: false;
|
|
599
|
+
}, {
|
|
600
|
+
readonly name: "deadline";
|
|
601
|
+
readonly type: "uint256";
|
|
602
|
+
readonly indexed: false;
|
|
603
|
+
}];
|
|
604
|
+
}, {
|
|
605
|
+
readonly name: "BountyTaken";
|
|
606
|
+
readonly type: "event";
|
|
607
|
+
readonly inputs: readonly [{
|
|
608
|
+
readonly name: "jobId";
|
|
609
|
+
readonly type: "uint256";
|
|
610
|
+
readonly indexed: true;
|
|
611
|
+
}, {
|
|
612
|
+
readonly name: "provider";
|
|
613
|
+
readonly type: "address";
|
|
614
|
+
readonly indexed: true;
|
|
615
|
+
}, {
|
|
616
|
+
readonly name: "agentId";
|
|
617
|
+
readonly type: "uint256";
|
|
618
|
+
readonly indexed: false;
|
|
619
|
+
}];
|
|
620
|
+
}, {
|
|
621
|
+
readonly name: "WorkSubmitted";
|
|
622
|
+
readonly type: "event";
|
|
623
|
+
readonly inputs: readonly [{
|
|
624
|
+
readonly name: "jobId";
|
|
625
|
+
readonly type: "uint256";
|
|
626
|
+
readonly indexed: true;
|
|
627
|
+
}, {
|
|
628
|
+
readonly name: "provider";
|
|
629
|
+
readonly type: "address";
|
|
630
|
+
readonly indexed: true;
|
|
631
|
+
}, {
|
|
632
|
+
readonly name: "ipfsResultHash";
|
|
633
|
+
readonly type: "string";
|
|
634
|
+
readonly indexed: false;
|
|
635
|
+
}];
|
|
636
|
+
}, {
|
|
637
|
+
readonly name: "BountyCompleted";
|
|
638
|
+
readonly type: "event";
|
|
639
|
+
readonly inputs: readonly [{
|
|
640
|
+
readonly name: "jobId";
|
|
641
|
+
readonly type: "uint256";
|
|
642
|
+
readonly indexed: true;
|
|
643
|
+
}, {
|
|
644
|
+
readonly name: "agentId";
|
|
645
|
+
readonly type: "uint256";
|
|
646
|
+
readonly indexed: false;
|
|
647
|
+
}, {
|
|
648
|
+
readonly name: "reputationScore";
|
|
649
|
+
readonly type: "uint256";
|
|
650
|
+
readonly indexed: false;
|
|
651
|
+
}];
|
|
652
|
+
}, {
|
|
653
|
+
readonly name: "DisputeRaised";
|
|
654
|
+
readonly type: "event";
|
|
655
|
+
readonly inputs: readonly [{
|
|
656
|
+
readonly name: "jobId";
|
|
657
|
+
readonly type: "uint256";
|
|
658
|
+
readonly indexed: true;
|
|
659
|
+
}, {
|
|
660
|
+
readonly name: "initiator";
|
|
661
|
+
readonly type: "address";
|
|
662
|
+
readonly indexed: true;
|
|
663
|
+
}, {
|
|
664
|
+
readonly name: "reasonHash";
|
|
665
|
+
readonly type: "string";
|
|
666
|
+
readonly indexed: false;
|
|
667
|
+
}];
|
|
668
|
+
}, {
|
|
669
|
+
readonly name: "DisputeResponded";
|
|
670
|
+
readonly type: "event";
|
|
671
|
+
readonly inputs: readonly [{
|
|
672
|
+
readonly name: "jobId";
|
|
673
|
+
readonly type: "uint256";
|
|
674
|
+
readonly indexed: true;
|
|
675
|
+
}, {
|
|
676
|
+
readonly name: "responder";
|
|
677
|
+
readonly type: "address";
|
|
678
|
+
readonly indexed: true;
|
|
679
|
+
}, {
|
|
680
|
+
readonly name: "responseHash";
|
|
681
|
+
readonly type: "string";
|
|
682
|
+
readonly indexed: false;
|
|
683
|
+
}];
|
|
684
|
+
}, {
|
|
685
|
+
readonly name: "DisputeResolved";
|
|
686
|
+
readonly type: "event";
|
|
687
|
+
readonly inputs: readonly [{
|
|
688
|
+
readonly name: "jobId";
|
|
689
|
+
readonly type: "uint256";
|
|
690
|
+
readonly indexed: true;
|
|
691
|
+
}, {
|
|
692
|
+
readonly name: "payProvider";
|
|
693
|
+
readonly type: "bool";
|
|
694
|
+
readonly indexed: false;
|
|
695
|
+
}, {
|
|
696
|
+
readonly name: "rulingHash";
|
|
697
|
+
readonly type: "string";
|
|
698
|
+
readonly indexed: false;
|
|
699
|
+
}, {
|
|
700
|
+
readonly name: "defaultRuling";
|
|
701
|
+
readonly type: "bool";
|
|
702
|
+
readonly indexed: false;
|
|
703
|
+
}];
|
|
704
|
+
}];
|
|
705
|
+
declare const IDENTITY_REGISTRY_ABI: readonly [{
|
|
706
|
+
readonly name: "register";
|
|
707
|
+
readonly type: "function";
|
|
708
|
+
readonly stateMutability: "nonpayable";
|
|
709
|
+
readonly inputs: readonly [{
|
|
710
|
+
readonly name: "metadataURI";
|
|
711
|
+
readonly type: "string";
|
|
712
|
+
}];
|
|
713
|
+
readonly outputs: readonly [{
|
|
714
|
+
readonly name: "agentId";
|
|
715
|
+
readonly type: "uint256";
|
|
716
|
+
}];
|
|
717
|
+
}, {
|
|
718
|
+
readonly name: "ownerOf";
|
|
719
|
+
readonly type: "function";
|
|
720
|
+
readonly stateMutability: "view";
|
|
721
|
+
readonly inputs: readonly [{
|
|
722
|
+
readonly name: "agentId";
|
|
723
|
+
readonly type: "uint256";
|
|
724
|
+
}];
|
|
725
|
+
readonly outputs: readonly [{
|
|
726
|
+
readonly name: "";
|
|
727
|
+
readonly type: "address";
|
|
728
|
+
}];
|
|
729
|
+
}, {
|
|
730
|
+
readonly name: "Transfer";
|
|
731
|
+
readonly type: "event";
|
|
732
|
+
readonly inputs: readonly [{
|
|
733
|
+
readonly name: "from";
|
|
734
|
+
readonly type: "address";
|
|
735
|
+
readonly indexed: true;
|
|
736
|
+
}, {
|
|
737
|
+
readonly name: "to";
|
|
738
|
+
readonly type: "address";
|
|
739
|
+
readonly indexed: true;
|
|
740
|
+
}, {
|
|
741
|
+
readonly name: "tokenId";
|
|
742
|
+
readonly type: "uint256";
|
|
743
|
+
readonly indexed: true;
|
|
744
|
+
}];
|
|
745
|
+
}];
|
|
746
|
+
declare const ERC20_ABI: readonly [{
|
|
747
|
+
readonly name: "approve";
|
|
748
|
+
readonly type: "function";
|
|
749
|
+
readonly stateMutability: "nonpayable";
|
|
750
|
+
readonly inputs: readonly [{
|
|
751
|
+
readonly name: "spender";
|
|
752
|
+
readonly type: "address";
|
|
753
|
+
}, {
|
|
754
|
+
readonly name: "amount";
|
|
755
|
+
readonly type: "uint256";
|
|
756
|
+
}];
|
|
757
|
+
readonly outputs: readonly [{
|
|
758
|
+
readonly name: "";
|
|
759
|
+
readonly type: "bool";
|
|
760
|
+
}];
|
|
761
|
+
}, {
|
|
762
|
+
readonly name: "allowance";
|
|
763
|
+
readonly type: "function";
|
|
764
|
+
readonly stateMutability: "view";
|
|
765
|
+
readonly inputs: readonly [{
|
|
766
|
+
readonly name: "owner";
|
|
767
|
+
readonly type: "address";
|
|
768
|
+
}, {
|
|
769
|
+
readonly name: "spender";
|
|
770
|
+
readonly type: "address";
|
|
771
|
+
}];
|
|
772
|
+
readonly outputs: readonly [{
|
|
773
|
+
readonly name: "";
|
|
774
|
+
readonly type: "uint256";
|
|
775
|
+
}];
|
|
776
|
+
}, {
|
|
777
|
+
readonly name: "balanceOf";
|
|
778
|
+
readonly type: "function";
|
|
779
|
+
readonly stateMutability: "view";
|
|
780
|
+
readonly inputs: readonly [{
|
|
781
|
+
readonly name: "account";
|
|
782
|
+
readonly type: "address";
|
|
783
|
+
}];
|
|
784
|
+
readonly outputs: readonly [{
|
|
785
|
+
readonly name: "";
|
|
786
|
+
readonly type: "uint256";
|
|
787
|
+
}];
|
|
788
|
+
}];
|
|
789
|
+
|
|
790
|
+
declare function fetchIpfsText(uriOrCid: string): Promise<string>;
|
|
791
|
+
declare function fetchIpfsJson<T = unknown>(uriOrCid: string): Promise<T>;
|
|
792
|
+
/** True iff Pinata creds are reachable in env. Cheap to call repeatedly. */
|
|
793
|
+
declare function isPinningConfigured(): boolean;
|
|
794
|
+
/**
|
|
795
|
+
* Pin text content to IPFS via Pinata's v2 `pinFileToIPFS` API. Prefers a JWT
|
|
796
|
+
* (PINATA_JWT, scoped for `pinFileToIPFS`, sent as Bearer), and falls back to a
|
|
797
|
+
* key/secret pair (PINATA_API_KEY + PINATA_SECRET). Returns an `ipfs://<cid>` URI.
|
|
798
|
+
*
|
|
799
|
+
* Throws immediately (not deep inside an autonomous loop) if creds are missing.
|
|
800
|
+
*/
|
|
801
|
+
declare function pinText(content: string, filename?: string): Promise<string>;
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* ERC-8004 agent metadata (TZ §4.3 + §12.3).
|
|
805
|
+
*
|
|
806
|
+
* IdentityRegistry.register() stores a URI; everyone reading it expects the
|
|
807
|
+
* referenced JSON to follow this shape. Persistence matters — `data:` URIs
|
|
808
|
+
* break the moment a verifier wants to fetch the manifest after registration,
|
|
809
|
+
* so we always pin to IPFS.
|
|
810
|
+
*/
|
|
811
|
+
type ArcBountySection = {
|
|
812
|
+
/** Min reputation a poster requires before this agent takes their bounty. */
|
|
813
|
+
min_reputation?: number;
|
|
814
|
+
preferred_categories?: ReadonlyArray<"dev" | "design" | "content" | "data" | "other">;
|
|
815
|
+
min_reward_usdc?: number;
|
|
816
|
+
max_reward_usdc?: number;
|
|
817
|
+
};
|
|
818
|
+
type AgentMetadata = {
|
|
819
|
+
name: string;
|
|
820
|
+
description: string;
|
|
821
|
+
agent_type?: string;
|
|
822
|
+
capabilities?: readonly string[];
|
|
823
|
+
version?: string;
|
|
824
|
+
contact?: string;
|
|
825
|
+
arcbounty?: ArcBountySection;
|
|
826
|
+
};
|
|
827
|
+
/**
|
|
828
|
+
* Validate a metadata blob before pinning. Strict by default — we'd rather
|
|
829
|
+
* fail loudly on init than silently push a broken manifest to IPFS.
|
|
830
|
+
*/
|
|
831
|
+
declare function validateAgentMetadata(m: unknown): asserts m is AgentMetadata;
|
|
832
|
+
/** Pin a validated metadata blob to IPFS and return the `ipfs://<cid>` URI. */
|
|
833
|
+
declare function pinAgentMetadata(meta: AgentMetadata): Promise<string>;
|
|
834
|
+
|
|
835
|
+
export { ARC_TESTNET_CHAIN_ID, ARC_TESTNET_RPC, type AgentInfo, type AgentMetadata, ArcBountyAgent, type ArcBountyAgentConfig, type ArcBountySection, BOUNTY_ADAPTER_ABI, type BountyMeta, CONTRACTS, type CreateBountyOptions, type DisputeEvidenceOptions, ERC20_ABI, IDENTITY_REGISTRY_ABI, type OpenBountiesFilter, type ReputationScore, type SubmitWorkOptions, type TxResult, fetchIpfsJson, fetchIpfsText, isPinningConfigured, pinAgentMetadata, pinText, validateAgentMetadata };
|