@blindmarket/sdk 0.1.7 → 0.4.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/dist/chain/BlindEscrowClient.d.ts +2 -0
- package/dist/chain/BlindEscrowClient.js +14 -6
- package/dist/chain/BlindReputationClient.d.ts +3 -0
- package/dist/chain/BlindReputationClient.js +3 -1
- package/dist/chain/ChainClient.d.ts +5 -2
- package/dist/chain/ChainClient.js +5 -0
- package/dist/chain/IBlindMarketChain.d.ts +74 -0
- package/dist/chain/TaskRegistryClient.d.ts +2 -1
- package/dist/chain/TaskRegistryClient.js +15 -7
- package/dist/chain/createChainAdapter.d.ts +25 -0
- package/dist/chain/createChainAdapter.js +24 -0
- package/dist/chain/domain-types.d.ts +77 -0
- package/dist/chain/evm/EVMChainAdapter.d.ts +56 -0
- package/dist/chain/evm/EVMChainAdapter.js +161 -0
- package/dist/chain/evm/index.d.ts +1 -0
- package/dist/chain/evm/index.js +1 -0
- package/dist/chain/index.d.ts +4 -0
- package/dist/chain/index.js +5 -0
- package/dist/executor/WorkerRuntime.d.ts +134 -0
- package/dist/executor/WorkerRuntime.js +277 -0
- package/dist/executor/index.d.ts +1 -0
- package/dist/executor/index.js +1 -0
- package/dist/index.d.ts +82 -9
- package/dist/index.js +60 -6
- package/dist/network/presets.d.ts +33 -5
- package/dist/network/presets.js +35 -8
- package/dist/network/resolve.d.ts +12 -3
- package/dist/network/resolve.js +15 -7
- package/dist/network/types.d.ts +3 -16
- package/dist/types.d.ts +1 -1
- package/package.json +8 -1
- package/biome.json +0 -19
- package/dist/BlindEscrowClient-CyPuKMge.d.cts +0 -54
- package/dist/BlindEscrowClient-R7iGpE-n.d.ts +0 -54
- package/dist/KeyStore-Be_SSpCt.d.cts +0 -21
- package/dist/KeyStore-k1JgYPJY.d.ts +0 -21
- package/dist/Signer-BnqH_qew.d.cts +0 -38
- package/dist/Signer-LColE0Uo.d.ts +0 -38
- package/dist/Storage-4QOrh7rm.d.ts +0 -17
- package/dist/Storage-Cf4IJRMk.d.cts +0 -17
- package/dist/TaskRegistryClient-Ch6lYqM_.d.ts +0 -24
- package/dist/TaskRegistryClient-CrQjddDc.d.cts +0 -24
- package/dist/aes-J-7HrHze.d.cts +0 -17
- package/dist/aes-J-7HrHze.d.ts +0 -17
- package/dist/agent/index.cjs +0 -425
- package/dist/agent/index.cjs.map +0 -1
- package/dist/agent/index.d.cts +0 -63
- package/dist/agent/index.js.map +0 -1
- package/dist/api/index.cjs +0 -4
- package/dist/api/index.cjs.map +0 -1
- package/dist/api/index.d.cts +0 -2
- package/dist/api/index.js.map +0 -1
- package/dist/chain/index.cjs +0 -2484
- package/dist/chain/index.cjs.map +0 -1
- package/dist/chain/index.d.cts +0 -2305
- package/dist/chain/index.js.map +0 -1
- package/dist/compute/index.cjs +0 -4
- package/dist/compute/index.cjs.map +0 -1
- package/dist/compute/index.d.cts +0 -2
- package/dist/compute/index.js.map +0 -1
- package/dist/crypto/index.cjs +0 -424
- package/dist/crypto/index.cjs.map +0 -1
- package/dist/crypto/index.d.cts +0 -74
- package/dist/crypto/index.js.map +0 -1
- package/dist/errors/BlindBountyError.d.ts +0 -14
- package/dist/errors/BlindBountyError.js +0 -30
- package/dist/errors/index.cjs +0 -136
- package/dist/errors/index.cjs.map +0 -1
- package/dist/errors/index.d.cts +0 -60
- package/dist/errors/index.js.map +0 -1
- package/dist/events/index.cjs +0 -41
- package/dist/events/index.cjs.map +0 -1
- package/dist/events/index.d.cts +0 -61
- package/dist/events/index.js.map +0 -1
- package/dist/index.cjs +0 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/keystore/index.cjs +0 -335
- package/dist/keystore/index.cjs.map +0 -1
- package/dist/keystore/index.d.cts +0 -23
- package/dist/keystore/index.js.map +0 -1
- package/dist/mcp.d.ts +0 -23
- package/dist/mcp.js +0 -101
- package/dist/network/index.cjs +0 -74
- package/dist/network/index.cjs.map +0 -1
- package/dist/network/index.d.cts +0 -36
- package/dist/network/index.js.map +0 -1
- package/dist/signer/index.cjs +0 -121
- package/dist/signer/index.cjs.map +0 -1
- package/dist/signer/index.d.cts +0 -40
- package/dist/signer/index.js.map +0 -1
- package/dist/storage/ZgStorage.d.ts +0 -24
- package/dist/storage/ZgStorage.js +0 -102
- package/dist/storage/index.cjs +0 -221
- package/dist/storage/index.cjs.map +0 -1
- package/dist/storage/index.d.cts +0 -44
- package/dist/storage/index.js.map +0 -1
- package/dist/testing/index.cjs +0 -4
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.d.cts +0 -2
- package/dist/testing/index.js.map +0 -1
- package/dist/types-BOG5Ub1z.d.cts +0 -31
- package/dist/types-BOG5Ub1z.d.ts +0 -31
- package/dist/types-V7_ZmUb-.d.cts +0 -19
- package/dist/types-hAsITUQ7.d.ts +0 -19
- package/dist/verifier/index.cjs +0 -4
- package/dist/verifier/index.cjs.map +0 -1
- package/dist/verifier/index.d.cts +0 -2
- package/dist/verifier/index.js.map +0 -1
- package/dist/worker/index.cjs +0 -382
- package/dist/worker/index.cjs.map +0 -1
- package/dist/worker/index.d.cts +0 -58
- package/dist/worker/index.js.map +0 -1
- package/examples/agent-demo.ts +0 -121
- package/scripts/gen-crypto-fixtures.mjs +0 -72
- package/src/agent/Agent.ts +0 -122
- package/src/agent/index.ts +0 -1
- package/src/chain/BlindEscrowClient.ts +0 -187
- package/src/chain/BlindReputationClient.ts +0 -55
- package/src/chain/ChainClient.ts +0 -59
- package/src/chain/TaskRegistryClient.ts +0 -82
- package/src/chain/abi/BlindEscrow.json +0 -1113
- package/src/chain/abi/BlindReputation.json +0 -447
- package/src/chain/abi/TaskRegistry.json +0 -586
- package/src/chain/abi/index.ts +0 -5
- package/src/chain/errors.ts +0 -43
- package/src/chain/index.ts +0 -6
- package/src/crypto/aes.ts +0 -104
- package/src/crypto/constants.ts +0 -7
- package/src/crypto/ecies.ts +0 -60
- package/src/crypto/envelope.ts +0 -131
- package/src/crypto/hkdf.ts +0 -45
- package/src/crypto/index.ts +0 -6
- package/src/crypto/keys.ts +0 -56
- package/src/errors/BlindMarketError.ts +0 -38
- package/src/errors/codes.ts +0 -67
- package/src/errors/index.ts +0 -3
- package/src/errors/subclasses.ts +0 -59
- package/src/events/EventBus.ts +0 -45
- package/src/events/index.ts +0 -2
- package/src/events/types.ts +0 -13
- package/src/index.ts +0 -617
- package/src/keystore/InMemoryKeyStore.ts +0 -146
- package/src/keystore/KeyStore.ts +0 -19
- package/src/keystore/index.ts +0 -2
- package/src/network/index.ts +0 -3
- package/src/network/presets.ts +0 -27
- package/src/network/resolve.ts +0 -19
- package/src/network/types.ts +0 -18
- package/src/signer/EthersSigner.ts +0 -82
- package/src/signer/PrivateKeySigner.ts +0 -19
- package/src/signer/Signer.ts +0 -40
- package/src/signer/index.ts +0 -3
- package/src/storage/MemoryStorage.ts +0 -49
- package/src/storage/Storage.ts +0 -15
- package/src/storage/ZgStorage.ts +0 -124
- package/src/storage/index.ts +0 -3
- package/src/testing/index.ts +0 -1
- package/src/tools/adapters.ts +0 -177
- package/src/tools/helpers.ts +0 -199
- package/src/tools/index.ts +0 -59
- package/src/tools/types.ts +0 -47
- package/src/types.ts +0 -296
- package/src/verifier/index.ts +0 -1
- package/src/worker/Worker.ts +0 -98
- package/src/worker/index.ts +0 -1
- package/test/agent.test.ts +0 -193
- package/test/chain.test.ts +0 -145
- package/test/crypto.aes.test.ts +0 -81
- package/test/crypto.compat.test.ts +0 -33
- package/test/crypto.ecies.test.ts +0 -64
- package/test/envelope.test.ts +0 -82
- package/test/errors.test.ts +0 -64
- package/test/events.test.ts +0 -59
- package/test/fixtures/crypto.json +0 -16
- package/test/keystore.test.ts +0 -103
- package/test/network.test.ts +0 -53
- package/test/signer.test.ts +0 -66
- package/test/smoke.test.ts +0 -7
- package/test/storage.test.ts +0 -55
- package/test/worker.test.ts +0 -181
- package/tsconfig.build.json +0 -1
- package/tsconfig.json +0 -14
- package/tsup.config.ts +0 -32
- package/vitest.config.ts +0 -17
- /package/{src/api/index.ts → dist/chain/IBlindMarketChain.js} +0 -0
- /package/{src/compute/index.ts → dist/chain/domain-types.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -130,7 +130,7 @@ export class BlindMarket {
|
|
|
130
130
|
async submitEvidence(params) {
|
|
131
131
|
return this.req('POST', '/api/v1/submissions/submit', params);
|
|
132
132
|
}
|
|
133
|
-
// ── Agent deployment & management
|
|
133
|
+
// ── Agent deployment & management ─────────────────────────────────────────
|
|
134
134
|
/**
|
|
135
135
|
* Deploy a new agent. The backend generates a wallet, mints an INFT,
|
|
136
136
|
* and returns the agent descriptor.
|
|
@@ -252,14 +252,36 @@ export class BlindMarket {
|
|
|
252
252
|
async bidOnTask(taskId) {
|
|
253
253
|
return this.req('POST', `/api/v1/a2a/tasks/${taskId}/bid`);
|
|
254
254
|
}
|
|
255
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* Accept a task and get the rootHash + ECIES-wrapped AES key for the
|
|
257
|
+
* caller's address. Requires executor auth.
|
|
258
|
+
*
|
|
259
|
+
* Note the shape here matches `backend/src/routes/a2a.ts`'s `/accept`
|
|
260
|
+
* handler exactly — there is no `task` field, and `wrappedKey` is a single
|
|
261
|
+
* hex string (this executor's slice), not a `Record`.
|
|
262
|
+
*/
|
|
256
263
|
async acceptTask(taskId) {
|
|
257
264
|
return this.req('POST', `/api/v1/a2a/tasks/${taskId}/accept`);
|
|
258
265
|
}
|
|
259
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Submit result for an accepted task. Returns an unsigned `submitEvidence`
|
|
268
|
+
* transaction — the contract requires the assigned worker to sign it
|
|
269
|
+
* personally (`onlyWorker`), so the caller must sign + broadcast
|
|
270
|
+
* `unsignedSubmitEvidence` and then call `finalize()`.
|
|
271
|
+
*/
|
|
260
272
|
async submitResult(taskId, resultData) {
|
|
261
273
|
return this.req('POST', `/api/v1/a2a/tasks/${taskId}/submit`, { resultData });
|
|
262
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Tell the backend your `submitEvidence` tx has confirmed on-chain so it
|
|
277
|
+
* can proceed with verification — auto-verify, or hand off to the poster
|
|
278
|
+
* / a designated verifier agent depending on the task's verificationMode.
|
|
279
|
+
* Call this after signing and broadcasting `unsignedSubmitEvidence` from
|
|
280
|
+
* `submitResult()`. Without this the escrow never settles.
|
|
281
|
+
*/
|
|
282
|
+
async finalize(taskId) {
|
|
283
|
+
return this.req('POST', `/api/v1/a2a/tasks/${taskId}/finalize`);
|
|
284
|
+
}
|
|
263
285
|
/** Get tasks posted by the authenticated user. */
|
|
264
286
|
async getPostedTasks() {
|
|
265
287
|
return this.req('GET', '/api/v1/a2a/tasks/posted');
|
|
@@ -274,7 +296,7 @@ export class BlindMarket {
|
|
|
274
296
|
* Trigger TEE / AI verification for a task.
|
|
275
297
|
*/
|
|
276
298
|
async verify(params) {
|
|
277
|
-
return this.req('POST', '/api/v1/verification/
|
|
299
|
+
return this.req('POST', '/api/v1/verification/verify', {
|
|
278
300
|
taskId: params.taskId,
|
|
279
301
|
taskCategory: params.taskCategory,
|
|
280
302
|
taskRequirements: params.taskRequirements,
|
|
@@ -303,11 +325,16 @@ export class BlindMarket {
|
|
|
303
325
|
async uploadBlob(data) {
|
|
304
326
|
return this.req('POST', '/api/v1/storage/upload', { data });
|
|
305
327
|
}
|
|
306
|
-
/**
|
|
328
|
+
/**
|
|
329
|
+
* Download a blob by root hash. `blob` is base64-encoded raw bytes — the
|
|
330
|
+
* caller decodes (and, for encrypted tasks, decrypts) it client-side.
|
|
331
|
+
* Matches `backend/src/routes/storage.ts`'s `GET /:rootHash` handler,
|
|
332
|
+
* which returns `{ rootHash, blob }`, not `{ data }`.
|
|
333
|
+
*/
|
|
307
334
|
async downloadBlob(rootHash) {
|
|
308
335
|
return this.req('GET', `/api/v1/storage/${rootHash}`);
|
|
309
336
|
}
|
|
310
|
-
// ── Messages
|
|
337
|
+
// ── Messages ─────────────────────────────────────────────────────────────
|
|
311
338
|
/** Send a message to another user or agent. */
|
|
312
339
|
async sendMessage(params) {
|
|
313
340
|
return this.req('POST', '/api/v1/messages/send', params);
|
|
@@ -391,6 +418,16 @@ export class BlindMarket {
|
|
|
391
418
|
return () => clearInterval(id);
|
|
392
419
|
}
|
|
393
420
|
// ── Device-flow registration (static) ─────────────────────────────────────
|
|
421
|
+
/**
|
|
422
|
+
* Canonical registration challenge signed by the agent wallet, proving
|
|
423
|
+
* control of `agentWallet`. Must stay byte-identical to
|
|
424
|
+
* `agentRegistrationMessage` in `backend/src/routes/registration.ts` — the
|
|
425
|
+
* SDK cannot import from the backend, so this is duplicated. A mismatch
|
|
426
|
+
* here silently breaks registration.
|
|
427
|
+
*/
|
|
428
|
+
static agentRegistrationMessage(agentName, agentWallet, agentPublicKey) {
|
|
429
|
+
return `BlindMarket agent registration\nname: ${agentName}\nwallet: ${agentWallet.toLowerCase()}\npubkey: ${agentPublicKey.toLowerCase()}`;
|
|
430
|
+
}
|
|
394
431
|
/**
|
|
395
432
|
* Start a device-flow registration session. Generates a magic-link URL
|
|
396
433
|
* that the user opens in a browser to sign with their wallet.
|
|
@@ -398,6 +435,11 @@ export class BlindMarket {
|
|
|
398
435
|
* After registering, call `BlindMarket.pollSession(token)` to wait for
|
|
399
436
|
* the user to confirm and receive the API key.
|
|
400
437
|
*
|
|
438
|
+
* Requires proof of control of `agentWallet`: pass either `agentSigner`
|
|
439
|
+
* (anything with a `signMessage`, e.g. an ethers `Wallet`) so the SDK signs
|
|
440
|
+
* the challenge itself, or a pre-computed `agentSignature` for callers
|
|
441
|
+
* holding a remote signer. Exactly one of the two is required.
|
|
442
|
+
*
|
|
401
443
|
* @example
|
|
402
444
|
* ```ts
|
|
403
445
|
* const wallet = ethers.Wallet.createRandom();
|
|
@@ -405,6 +447,7 @@ export class BlindMarket {
|
|
|
405
447
|
* agentName: 'my-agent',
|
|
406
448
|
* agentWallet: wallet.address,
|
|
407
449
|
* agentPublicKey: wallet.publicKey,
|
|
450
|
+
* agentSigner: wallet,
|
|
408
451
|
* });
|
|
409
452
|
* console.log('Open', url, 'to confirm');
|
|
410
453
|
* const apiKey = await BlindMarket.pollSession(token);
|
|
@@ -412,6 +455,11 @@ export class BlindMarket {
|
|
|
412
455
|
* ```
|
|
413
456
|
*/
|
|
414
457
|
static async register(params) {
|
|
458
|
+
if (!params.agentSigner === !params.agentSignature) {
|
|
459
|
+
throw new ApiError(400, 'Exactly one of agentSigner or agentSignature is required to prove control of agentWallet');
|
|
460
|
+
}
|
|
461
|
+
const message = BlindMarket.agentRegistrationMessage(params.agentName, params.agentWallet, params.agentPublicKey);
|
|
462
|
+
const agentSignature = params.agentSignature ?? await params.agentSigner.signMessage(message);
|
|
415
463
|
const base = params.apiBase ?? 'https://api.blindmarket.xyz';
|
|
416
464
|
const res = await fetch(`${base}/api/v1/registration/session`, {
|
|
417
465
|
method: 'POST',
|
|
@@ -420,6 +468,7 @@ export class BlindMarket {
|
|
|
420
468
|
agentName: params.agentName,
|
|
421
469
|
agentWallet: params.agentWallet,
|
|
422
470
|
agentPublicKey: params.agentPublicKey,
|
|
471
|
+
agentSignature,
|
|
423
472
|
}),
|
|
424
473
|
});
|
|
425
474
|
const json = await res.json();
|
|
@@ -458,4 +507,9 @@ export class BlindMarket {
|
|
|
458
507
|
export { ethers };
|
|
459
508
|
export { ApiError };
|
|
460
509
|
export { tools, createBlindMarketTools, createTaskTools, createAgentManagementTools, createA2ATools, toLangChainTools, toVercelTools, toOpenAITools, toClaudeTools, } from './tools/index.js';
|
|
510
|
+
export * from './executor/index.js';
|
|
461
511
|
export * from './types.js';
|
|
512
|
+
// Chain abstraction layer
|
|
513
|
+
export { EVMChainAdapter } from './chain/evm/index.js';
|
|
514
|
+
export { createChainAdapter } from './chain/createChainAdapter.js';
|
|
515
|
+
export { isEVMNetwork } from './network/resolve.js';
|
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Known-good network presets. Addresses pinned per SDK version so upgrading
|
|
3
3
|
* the SDK cannot silently move contracts under a consumer.
|
|
4
|
-
*
|
|
5
|
-
* testnet = 0G Galileo (chainId 16602) — addresses from
|
|
6
|
-
* contracts/deployments/0g-testnet.json (deployed 2026-04-15).
|
|
7
4
|
*/
|
|
5
|
+
export type NetworkName = 'testnet' | 'og-testnet' | 'og-mainnet';
|
|
8
6
|
export declare const networks: {
|
|
7
|
+
readonly 'og-testnet': {
|
|
8
|
+
readonly name: "0g-galileo-testnet";
|
|
9
|
+
readonly chainType: "evm";
|
|
10
|
+
readonly chainId: 16602;
|
|
11
|
+
readonly rpc: ["https://evmrpc-testnet.0g.ai"];
|
|
12
|
+
readonly contracts: {
|
|
13
|
+
readonly escrow: "0xFd4F93F5A7BE144c405D1D8fbEC63Fb776207681";
|
|
14
|
+
readonly registry: "0xeE52d780A47F77E8a4a1cEb236e3C65A48FbD828";
|
|
15
|
+
readonly reputation: "0x4A6374Fae37E19E69ba43E7cf6994AC15F63256e";
|
|
16
|
+
readonly usdc: "0x317227efcA18D004E12CA8046AEf7E1597458F25";
|
|
17
|
+
};
|
|
18
|
+
readonly indexer: "https://indexer-storage-testnet-turbo.0g.ai";
|
|
19
|
+
readonly broker: "https://broker.testnet.0g.ai";
|
|
20
|
+
readonly explorer: "https://chainscan-galileo.0g.ai";
|
|
21
|
+
};
|
|
22
|
+
readonly 'og-mainnet': {
|
|
23
|
+
readonly name: "0g-mainnet";
|
|
24
|
+
readonly chainType: "evm";
|
|
25
|
+
readonly chainId: 16661;
|
|
26
|
+
readonly rpc: ["https://evmrpc.0g.ai"];
|
|
27
|
+
readonly contracts: {
|
|
28
|
+
readonly escrow: "0x3d0374963DaaD43e31d42373eb11156A8e8ce2Ff";
|
|
29
|
+
readonly registry: "0x9CCF9c196006B573FaA9C9c9CebDd1296dbd5cE0";
|
|
30
|
+
readonly reputation: "0x3af9232009C5da30AdA366B6E09849A040162A1a";
|
|
31
|
+
readonly usdc: "0x0000000000000000000000000000000000000000";
|
|
32
|
+
};
|
|
33
|
+
readonly indexer: "https://indexer-storage-turbo.0g.ai";
|
|
34
|
+
readonly broker: "https://broker.0g.ai";
|
|
35
|
+
readonly explorer: "https://chainscan.0g.ai";
|
|
36
|
+
};
|
|
9
37
|
readonly testnet: {
|
|
10
38
|
readonly name: "0g-galileo-testnet";
|
|
11
|
-
readonly
|
|
39
|
+
readonly chainType: "evm";
|
|
40
|
+
readonly chainId: 16602;
|
|
12
41
|
readonly rpc: ["https://evmrpc-testnet.0g.ai"];
|
|
13
42
|
readonly contracts: {
|
|
14
43
|
readonly escrow: "0xFd4F93F5A7BE144c405D1D8fbEC63Fb776207681";
|
|
@@ -21,4 +50,3 @@ export declare const networks: {
|
|
|
21
50
|
readonly explorer: "https://chainscan-galileo.0g.ai";
|
|
22
51
|
};
|
|
23
52
|
};
|
|
24
|
-
export type NetworkName = keyof typeof networks;
|
package/dist/network/presets.js
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Known-good network presets. Addresses pinned per SDK version so upgrading
|
|
3
|
-
* the SDK cannot silently move contracts under a consumer.
|
|
4
|
-
*
|
|
5
|
-
* testnet = 0G Galileo (chainId 16602) — addresses from
|
|
6
|
-
* contracts/deployments/0g-testnet.json (deployed 2026-04-15).
|
|
7
|
-
*/
|
|
8
1
|
export const networks = {
|
|
2
|
+
// ── 0G EVM chains ─────────────────────────────────────────────────────
|
|
3
|
+
'og-testnet': {
|
|
4
|
+
name: '0g-galileo-testnet',
|
|
5
|
+
chainType: 'evm',
|
|
6
|
+
chainId: 16602,
|
|
7
|
+
rpc: ['https://evmrpc-testnet.0g.ai'],
|
|
8
|
+
contracts: {
|
|
9
|
+
escrow: '0xFd4F93F5A7BE144c405D1D8fbEC63Fb776207681',
|
|
10
|
+
registry: '0xeE52d780A47F77E8a4a1cEb236e3C65A48FbD828',
|
|
11
|
+
reputation: '0x4A6374Fae37E19E69ba43E7cf6994AC15F63256e',
|
|
12
|
+
usdc: '0x317227efcA18D004E12CA8046AEf7E1597458F25',
|
|
13
|
+
},
|
|
14
|
+
indexer: 'https://indexer-storage-testnet-turbo.0g.ai',
|
|
15
|
+
broker: 'https://broker.testnet.0g.ai',
|
|
16
|
+
explorer: 'https://chainscan-galileo.0g.ai',
|
|
17
|
+
},
|
|
18
|
+
'og-mainnet': {
|
|
19
|
+
name: '0g-mainnet',
|
|
20
|
+
chainType: 'evm',
|
|
21
|
+
chainId: 16661,
|
|
22
|
+
rpc: ['https://evmrpc.0g.ai'],
|
|
23
|
+
contracts: {
|
|
24
|
+
escrow: '0x3d0374963DaaD43e31d42373eb11156A8e8ce2Ff',
|
|
25
|
+
registry: '0x9CCF9c196006B573FaA9C9c9CebDd1296dbd5cE0',
|
|
26
|
+
reputation: '0x3af9232009C5da30AdA366B6E09849A040162A1a',
|
|
27
|
+
usdc: '0x0000000000000000000000000000000000000000',
|
|
28
|
+
},
|
|
29
|
+
indexer: 'https://indexer-storage-turbo.0g.ai',
|
|
30
|
+
broker: 'https://broker.0g.ai',
|
|
31
|
+
explorer: 'https://chainscan.0g.ai',
|
|
32
|
+
},
|
|
33
|
+
// ── Backward-compat alias ──────────────────────────────────────────────
|
|
34
|
+
// Kept so existing code referencing 'testnet' doesn't break.
|
|
9
35
|
testnet: {
|
|
10
36
|
name: '0g-galileo-testnet',
|
|
11
|
-
|
|
37
|
+
chainType: 'evm',
|
|
38
|
+
chainId: 16602,
|
|
12
39
|
rpc: ['https://evmrpc-testnet.0g.ai'],
|
|
13
40
|
contracts: {
|
|
14
41
|
escrow: '0xFd4F93F5A7BE144c405D1D8fbEC63Fb776207681',
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { type NetworkName } from './presets.js';
|
|
2
|
-
import type { Network } from '
|
|
2
|
+
import type { Network } from '../chain/domain-types.js';
|
|
3
3
|
/**
|
|
4
|
-
* Resolve a preset name or a
|
|
5
|
-
*
|
|
4
|
+
* Resolve a network preset name or a Network object to a canonical Network.
|
|
5
|
+
*
|
|
6
|
+
* When given a string, looks up the preset. When given a Network object,
|
|
7
|
+
* returns it as-is (pass-through for callers that already have a resolved
|
|
8
|
+
* network config).
|
|
6
9
|
*/
|
|
7
10
|
export declare function resolveNetwork(arg: NetworkName | Network): Network;
|
|
11
|
+
/**
|
|
12
|
+
* Type guard: check if a Network is an EVM network.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isEVMNetwork(network: Network): network is Network & {
|
|
15
|
+
chainType: 'evm';
|
|
16
|
+
};
|
package/dist/network/resolve.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { ConfigError } from '../errors/index.js';
|
|
2
2
|
import { networks } from './presets.js';
|
|
3
3
|
/**
|
|
4
|
-
* Resolve a preset name or a
|
|
5
|
-
*
|
|
4
|
+
* Resolve a network preset name or a Network object to a canonical Network.
|
|
5
|
+
*
|
|
6
|
+
* When given a string, looks up the preset. When given a Network object,
|
|
7
|
+
* returns it as-is (pass-through for callers that already have a resolved
|
|
8
|
+
* network config).
|
|
6
9
|
*/
|
|
7
10
|
export function resolveNetwork(arg) {
|
|
8
11
|
if (typeof arg === 'string') {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
|
|
12
|
-
throw new ConfigError('CONFIG/INVALID_NETWORK', `unknown network '${arg}' (known: ${known})`);
|
|
12
|
+
const net = networks[arg];
|
|
13
|
+
if (!net) {
|
|
14
|
+
throw new ConfigError('CONFIG/INVALID_NETWORK', `Unknown network: "${arg}". Known presets: ${Object.keys(networks).join(', ')}`);
|
|
13
15
|
}
|
|
14
|
-
return
|
|
16
|
+
return net;
|
|
15
17
|
}
|
|
16
18
|
return arg;
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Type guard: check if a Network is an EVM network.
|
|
22
|
+
*/
|
|
23
|
+
export function isEVMNetwork(network) {
|
|
24
|
+
return network.chainType === 'evm';
|
|
25
|
+
}
|
package/dist/network/types.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
registry: Address;
|
|
5
|
-
reputation: Address;
|
|
6
|
-
usdc: Address;
|
|
7
|
-
}
|
|
8
|
-
export interface Network {
|
|
9
|
-
name: string;
|
|
10
|
-
chainId: bigint;
|
|
11
|
-
rpc: string[];
|
|
12
|
-
contracts: NetworkContracts;
|
|
13
|
-
indexer: string;
|
|
14
|
-
broker: string;
|
|
15
|
-
explorer?: string;
|
|
16
|
-
}
|
|
1
|
+
import type { NetworkName } from './presets.js';
|
|
2
|
+
export type { Network, EVMNetwork, NetworkBase, BlockchainType, CreateTaskParams, DomainTask, DomainTaskMeta, DomainReputation, DomainTxReceipt, ChainSigner, } from '../chain/domain-types.js';
|
|
3
|
+
export type { NetworkName };
|
package/dist/types.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface Reward {
|
|
|
12
12
|
token: Address | TokenSymbol;
|
|
13
13
|
amount: bigint;
|
|
14
14
|
}
|
|
15
|
-
export type TaskStatus = 'funded' | 'assigned' | 'submitted' | 'verified' | 'completed' | 'cancelled';
|
|
15
|
+
export type TaskStatus = 'funded' | 'assigned' | 'submitted' | 'verified' | 'completed' | 'cancelled' | 'disputed';
|
|
16
16
|
export interface TaskMetadata {
|
|
17
17
|
category: string;
|
|
18
18
|
locationZone: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blindmarket/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "BlindMarket SDK — deploy agents, assign workers, verify evidence",
|
|
5
5
|
"author": "BlindMarket Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"vercel-ai-sdk"
|
|
32
32
|
],
|
|
33
33
|
"type": "module",
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
34
37
|
"main": "./dist/index.js",
|
|
35
38
|
"types": "./dist/index.d.ts",
|
|
36
39
|
"exports": {
|
|
@@ -41,6 +44,10 @@
|
|
|
41
44
|
"./tools": {
|
|
42
45
|
"import": "./dist/tools/index.js",
|
|
43
46
|
"types": "./dist/tools/index.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./crypto": {
|
|
49
|
+
"import": "./dist/crypto/index.js",
|
|
50
|
+
"types": "./dist/crypto/index.d.ts"
|
|
44
51
|
}
|
|
45
52
|
},
|
|
46
53
|
"scripts": {
|
package/biome.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
-
"organizeImports": { "enabled": true },
|
|
4
|
-
"linter": {
|
|
5
|
-
"enabled": true,
|
|
6
|
-
"rules": {
|
|
7
|
-
"recommended": true,
|
|
8
|
-
"suspicious": { "noExplicitAny": "error" },
|
|
9
|
-
"style": { "useImportType": "error" }
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"formatter": {
|
|
13
|
-
"enabled": true,
|
|
14
|
-
"indentStyle": "space",
|
|
15
|
-
"indentWidth": 2,
|
|
16
|
-
"lineWidth": 120,
|
|
17
|
-
"lineEnding": "lf"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
import { A as Address, H as Hex, T as TaskId, b as TxReceiptLike, e as TaskStatus } from './types-BOG5Ub1z.cjs';
|
|
3
|
-
|
|
4
|
-
interface CreateTaskArgs {
|
|
5
|
-
taskHash: Hex;
|
|
6
|
-
token: Address;
|
|
7
|
-
amount: bigint;
|
|
8
|
-
category: string;
|
|
9
|
-
locationZone: string;
|
|
10
|
-
deadline: bigint;
|
|
11
|
-
}
|
|
12
|
-
interface OnChainTask {
|
|
13
|
-
taskId: TaskId;
|
|
14
|
-
agent: Address;
|
|
15
|
-
worker: Address;
|
|
16
|
-
token: Address;
|
|
17
|
-
amount: bigint;
|
|
18
|
-
taskHash: Hex;
|
|
19
|
-
evidenceHash: Hex;
|
|
20
|
-
status: TaskStatus;
|
|
21
|
-
createdAt: Date;
|
|
22
|
-
deadline: Date;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Typed ethers v6 wrapper for the BlindEscrow contract. Every state-changing
|
|
26
|
-
* method awaits one confirmation and returns a TxReceiptLike; every read
|
|
27
|
-
* returns decoded values. Ethers errors are mapped to ChainError via
|
|
28
|
-
* wrapChainError().
|
|
29
|
-
*/
|
|
30
|
-
declare class BlindEscrowClient {
|
|
31
|
-
readonly contract: ethers.Contract;
|
|
32
|
-
readonly address: Address;
|
|
33
|
-
constructor(address: Address, runner: ethers.ContractRunner);
|
|
34
|
-
/** Create a task and return its id + receipt. Reads the TaskCreated event for the id. */
|
|
35
|
-
createTask(args: CreateTaskArgs): Promise<{
|
|
36
|
-
taskId: TaskId;
|
|
37
|
-
receipt: TxReceiptLike;
|
|
38
|
-
}>;
|
|
39
|
-
assignWorker(taskId: TaskId, worker: Address): Promise<TxReceiptLike>;
|
|
40
|
-
submitEvidence(taskId: TaskId, evidenceHash: Hex): Promise<TxReceiptLike>;
|
|
41
|
-
completeVerification(taskId: TaskId, passed: boolean): Promise<TxReceiptLike>;
|
|
42
|
-
cancelTask(taskId: TaskId): Promise<TxReceiptLike>;
|
|
43
|
-
raiseDispute(taskId: TaskId): Promise<TxReceiptLike>;
|
|
44
|
-
resolveDispute(taskId: TaskId, workerFavored: boolean): Promise<TxReceiptLike>;
|
|
45
|
-
claimTimeout(taskId: TaskId): Promise<TxReceiptLike>;
|
|
46
|
-
getTask(taskId: TaskId): Promise<OnChainTask>;
|
|
47
|
-
isTaskExpired(taskId: TaskId): Promise<boolean>;
|
|
48
|
-
nextTaskId(): Promise<TaskId>;
|
|
49
|
-
feeBps(): Promise<bigint>;
|
|
50
|
-
private sendTx;
|
|
51
|
-
private extractTaskIdFromReceipt;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { BlindEscrowClient as B, type CreateTaskArgs as C, type OnChainTask as O };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
import { A as Address, H as Hex, T as TaskId, b as TxReceiptLike, e as TaskStatus } from './types-BOG5Ub1z.js';
|
|
3
|
-
|
|
4
|
-
interface CreateTaskArgs {
|
|
5
|
-
taskHash: Hex;
|
|
6
|
-
token: Address;
|
|
7
|
-
amount: bigint;
|
|
8
|
-
category: string;
|
|
9
|
-
locationZone: string;
|
|
10
|
-
deadline: bigint;
|
|
11
|
-
}
|
|
12
|
-
interface OnChainTask {
|
|
13
|
-
taskId: TaskId;
|
|
14
|
-
agent: Address;
|
|
15
|
-
worker: Address;
|
|
16
|
-
token: Address;
|
|
17
|
-
amount: bigint;
|
|
18
|
-
taskHash: Hex;
|
|
19
|
-
evidenceHash: Hex;
|
|
20
|
-
status: TaskStatus;
|
|
21
|
-
createdAt: Date;
|
|
22
|
-
deadline: Date;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Typed ethers v6 wrapper for the BlindEscrow contract. Every state-changing
|
|
26
|
-
* method awaits one confirmation and returns a TxReceiptLike; every read
|
|
27
|
-
* returns decoded values. Ethers errors are mapped to ChainError via
|
|
28
|
-
* wrapChainError().
|
|
29
|
-
*/
|
|
30
|
-
declare class BlindEscrowClient {
|
|
31
|
-
readonly contract: ethers.Contract;
|
|
32
|
-
readonly address: Address;
|
|
33
|
-
constructor(address: Address, runner: ethers.ContractRunner);
|
|
34
|
-
/** Create a task and return its id + receipt. Reads the TaskCreated event for the id. */
|
|
35
|
-
createTask(args: CreateTaskArgs): Promise<{
|
|
36
|
-
taskId: TaskId;
|
|
37
|
-
receipt: TxReceiptLike;
|
|
38
|
-
}>;
|
|
39
|
-
assignWorker(taskId: TaskId, worker: Address): Promise<TxReceiptLike>;
|
|
40
|
-
submitEvidence(taskId: TaskId, evidenceHash: Hex): Promise<TxReceiptLike>;
|
|
41
|
-
completeVerification(taskId: TaskId, passed: boolean): Promise<TxReceiptLike>;
|
|
42
|
-
cancelTask(taskId: TaskId): Promise<TxReceiptLike>;
|
|
43
|
-
raiseDispute(taskId: TaskId): Promise<TxReceiptLike>;
|
|
44
|
-
resolveDispute(taskId: TaskId, workerFavored: boolean): Promise<TxReceiptLike>;
|
|
45
|
-
claimTimeout(taskId: TaskId): Promise<TxReceiptLike>;
|
|
46
|
-
getTask(taskId: TaskId): Promise<OnChainTask>;
|
|
47
|
-
isTaskExpired(taskId: TaskId): Promise<boolean>;
|
|
48
|
-
nextTaskId(): Promise<TaskId>;
|
|
49
|
-
feeBps(): Promise<bigint>;
|
|
50
|
-
private sendTx;
|
|
51
|
-
private extractTaskIdFromReceipt;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { BlindEscrowClient as B, type CreateTaskArgs as C, type OnChainTask as O };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { T as TaskId, a as TaskKey, A as Address, H as Hex, c as TaskKeyRef } from './types-BOG5Ub1z.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Per-session storage for task AES keys and cached peer public keys. The SDK
|
|
5
|
-
* never logs or serializes anything from here — this is the one place at-rest
|
|
6
|
-
* secrets live. Implementations MUST treat passphrase-protected exports as the
|
|
7
|
-
* only portable format.
|
|
8
|
-
*/
|
|
9
|
-
interface KeyStore {
|
|
10
|
-
putTaskKey(taskId: TaskId, key: TaskKey): Promise<void>;
|
|
11
|
-
getTaskKey(taskId: TaskId): Promise<TaskKey | null>;
|
|
12
|
-
putPeerPubKey(addr: Address, pubkey: Hex): Promise<void>;
|
|
13
|
-
getPeerPubKey(addr: Address): Promise<Hex | null>;
|
|
14
|
-
list(): Promise<TaskKeyRef[]>;
|
|
15
|
-
delete(taskId: TaskId): Promise<void>;
|
|
16
|
-
/** Portable, encrypted-at-rest JSON export for backup/migration. */
|
|
17
|
-
export(passphrase: string): Promise<string>;
|
|
18
|
-
import(data: string, passphrase: string): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type { KeyStore as K };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { T as TaskId, a as TaskKey, A as Address, H as Hex, c as TaskKeyRef } from './types-BOG5Ub1z.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Per-session storage for task AES keys and cached peer public keys. The SDK
|
|
5
|
-
* never logs or serializes anything from here — this is the one place at-rest
|
|
6
|
-
* secrets live. Implementations MUST treat passphrase-protected exports as the
|
|
7
|
-
* only portable format.
|
|
8
|
-
*/
|
|
9
|
-
interface KeyStore {
|
|
10
|
-
putTaskKey(taskId: TaskId, key: TaskKey): Promise<void>;
|
|
11
|
-
getTaskKey(taskId: TaskId): Promise<TaskKey | null>;
|
|
12
|
-
putPeerPubKey(addr: Address, pubkey: Hex): Promise<void>;
|
|
13
|
-
getPeerPubKey(addr: Address): Promise<Hex | null>;
|
|
14
|
-
list(): Promise<TaskKeyRef[]>;
|
|
15
|
-
delete(taskId: TaskId): Promise<void>;
|
|
16
|
-
/** Portable, encrypted-at-rest JSON export for backup/migration. */
|
|
17
|
-
export(passphrase: string): Promise<string>;
|
|
18
|
-
import(data: string, passphrase: string): Promise<void>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type { KeyStore as K };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { A as Address, H as Hex } from './types-BOG5Ub1z.cjs';
|
|
2
|
-
|
|
3
|
-
interface TxRequest {
|
|
4
|
-
to: Address;
|
|
5
|
-
from?: Address;
|
|
6
|
-
data?: Hex;
|
|
7
|
-
value?: bigint;
|
|
8
|
-
gasLimit?: bigint;
|
|
9
|
-
nonce?: number;
|
|
10
|
-
chainId?: bigint;
|
|
11
|
-
}
|
|
12
|
-
interface TypedDataDomain {
|
|
13
|
-
name?: string;
|
|
14
|
-
version?: string;
|
|
15
|
-
chainId?: bigint | number;
|
|
16
|
-
verifyingContract?: Address;
|
|
17
|
-
salt?: Hex;
|
|
18
|
-
}
|
|
19
|
-
type TypedDataField = {
|
|
20
|
-
name: string;
|
|
21
|
-
type: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Uniform signing interface used across the SDK. Adapters wrap ethers Signer,
|
|
25
|
-
* raw private keys, EIP-1193 providers, or KMS. Implementations MUST return
|
|
26
|
-
* hex-encoded signatures (0x-prefixed) and addresses (0x-prefixed, 20 bytes).
|
|
27
|
-
*/
|
|
28
|
-
interface Signer {
|
|
29
|
-
getAddress(): Promise<Address>;
|
|
30
|
-
chainId(): Promise<bigint>;
|
|
31
|
-
signMessage(msg: string | Uint8Array): Promise<Hex>;
|
|
32
|
-
signTypedData(domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, unknown>): Promise<Hex>;
|
|
33
|
-
signTransaction(tx: TxRequest): Promise<Hex>;
|
|
34
|
-
/** Uncompressed secp256k1 public key, 0x04-prefixed (hex). */
|
|
35
|
-
getPublicKey(): Promise<Hex>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type { Signer as S, TypedDataDomain as T, TypedDataField as a, TxRequest as b };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { A as Address, H as Hex } from './types-BOG5Ub1z.js';
|
|
2
|
-
|
|
3
|
-
interface TxRequest {
|
|
4
|
-
to: Address;
|
|
5
|
-
from?: Address;
|
|
6
|
-
data?: Hex;
|
|
7
|
-
value?: bigint;
|
|
8
|
-
gasLimit?: bigint;
|
|
9
|
-
nonce?: number;
|
|
10
|
-
chainId?: bigint;
|
|
11
|
-
}
|
|
12
|
-
interface TypedDataDomain {
|
|
13
|
-
name?: string;
|
|
14
|
-
version?: string;
|
|
15
|
-
chainId?: bigint | number;
|
|
16
|
-
verifyingContract?: Address;
|
|
17
|
-
salt?: Hex;
|
|
18
|
-
}
|
|
19
|
-
type TypedDataField = {
|
|
20
|
-
name: string;
|
|
21
|
-
type: string;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Uniform signing interface used across the SDK. Adapters wrap ethers Signer,
|
|
25
|
-
* raw private keys, EIP-1193 providers, or KMS. Implementations MUST return
|
|
26
|
-
* hex-encoded signatures (0x-prefixed) and addresses (0x-prefixed, 20 bytes).
|
|
27
|
-
*/
|
|
28
|
-
interface Signer {
|
|
29
|
-
getAddress(): Promise<Address>;
|
|
30
|
-
chainId(): Promise<bigint>;
|
|
31
|
-
signMessage(msg: string | Uint8Array): Promise<Hex>;
|
|
32
|
-
signTypedData(domain: TypedDataDomain, types: Record<string, TypedDataField[]>, value: Record<string, unknown>): Promise<Hex>;
|
|
33
|
-
signTransaction(tx: TxRequest): Promise<Hex>;
|
|
34
|
-
/** Uncompressed secp256k1 public key, 0x04-prefixed (hex). */
|
|
35
|
-
getPublicKey(): Promise<Hex>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type { Signer as S, TypedDataDomain as T, TypedDataField as a, TxRequest as b };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { U as UploadResult, d as RootHash } from './types-BOG5Ub1z.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Abstraction over blob storage. Default implementation (ZgStorage) uses
|
|
5
|
-
* 0G Storage; MemoryStorage is for tests and local fallback. Consumers can
|
|
6
|
-
* provide their own adapter for IPFS, S3, etc.
|
|
7
|
-
*/
|
|
8
|
-
interface Storage {
|
|
9
|
-
/** Upload bytes, return root hash + optional tx hash + size. */
|
|
10
|
-
upload(bytes: Uint8Array): Promise<UploadResult>;
|
|
11
|
-
/** Download bytes by root hash. Throws StorageError('STORAGE/NOT_FOUND') if absent. */
|
|
12
|
-
download(rootHash: RootHash): Promise<Uint8Array>;
|
|
13
|
-
/** Compute the canonical root hash without uploading. */
|
|
14
|
-
hash(bytes: Uint8Array): Promise<RootHash>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type { Storage as S };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { U as UploadResult, d as RootHash } from './types-BOG5Ub1z.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Abstraction over blob storage. Default implementation (ZgStorage) uses
|
|
5
|
-
* 0G Storage; MemoryStorage is for tests and local fallback. Consumers can
|
|
6
|
-
* provide their own adapter for IPFS, S3, etc.
|
|
7
|
-
*/
|
|
8
|
-
interface Storage {
|
|
9
|
-
/** Upload bytes, return root hash + optional tx hash + size. */
|
|
10
|
-
upload(bytes: Uint8Array): Promise<UploadResult>;
|
|
11
|
-
/** Download bytes by root hash. Throws StorageError('STORAGE/NOT_FOUND') if absent. */
|
|
12
|
-
download(rootHash: RootHash): Promise<Uint8Array>;
|
|
13
|
-
/** Compute the canonical root hash without uploading. */
|
|
14
|
-
hash(bytes: Uint8Array): Promise<RootHash>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type { Storage as S };
|