@blindmarket/sdk 0.1.4 → 0.1.5
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/index.d.ts +0 -36
- package/dist/index.js +0 -51
- package/package.json +2 -2
- package/src/index.ts +0 -74
package/dist/index.d.ts
CHANGED
|
@@ -15,14 +15,6 @@ export interface DeployAgentParams {
|
|
|
15
15
|
capabilities?: string[];
|
|
16
16
|
tools?: object[];
|
|
17
17
|
}
|
|
18
|
-
export interface PostTaskParams {
|
|
19
|
-
instructions: string;
|
|
20
|
-
category: string;
|
|
21
|
-
amount: string;
|
|
22
|
-
token: string;
|
|
23
|
-
locationZone?: string;
|
|
24
|
-
duration?: string;
|
|
25
|
-
}
|
|
26
18
|
export interface DeployedAgent {
|
|
27
19
|
id: string;
|
|
28
20
|
name: string;
|
|
@@ -31,11 +23,6 @@ export interface DeployedAgent {
|
|
|
31
23
|
inftTokenId?: number;
|
|
32
24
|
status: string;
|
|
33
25
|
}
|
|
34
|
-
export interface PostedTask {
|
|
35
|
-
unsignedTx: object;
|
|
36
|
-
taskHash: string;
|
|
37
|
-
storageRoot: string;
|
|
38
|
-
}
|
|
39
26
|
export declare class BlindMarket {
|
|
40
27
|
private apiBase;
|
|
41
28
|
private apiKey;
|
|
@@ -60,20 +47,6 @@ export declare class BlindMarket {
|
|
|
60
47
|
* List all agents owned by an address.
|
|
61
48
|
*/
|
|
62
49
|
listAgents(ownerAddress: string): Promise<DeployedAgent[]>;
|
|
63
|
-
/**
|
|
64
|
-
* Encrypt instructions and post a task. Returns an unsigned tx to sign + broadcast.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* const { unsignedTx, taskHash } = await bb.postTask({
|
|
68
|
-
* instructions: 'Photograph the exterior of 42 Oak Street, NYC.',
|
|
69
|
-
* category: 'photography',
|
|
70
|
-
* amount: ethers.parseEther('30').toString(),
|
|
71
|
-
* token: '0x317227efcA18D004E12CA8046AEf7E1597458F25',
|
|
72
|
-
* locationZone: 'US-NY',
|
|
73
|
-
* });
|
|
74
|
-
* const receipt = await wallet.sendTransaction(unsignedTx);
|
|
75
|
-
*/
|
|
76
|
-
postTask(params: PostTaskParams): Promise<PostedTask>;
|
|
77
50
|
/**
|
|
78
51
|
* Assign a worker to a task. Returns an unsigned tx.
|
|
79
52
|
*/
|
|
@@ -93,15 +66,6 @@ export declare class BlindMarket {
|
|
|
93
66
|
confidence: number;
|
|
94
67
|
reasoning: string;
|
|
95
68
|
}>;
|
|
96
|
-
/**
|
|
97
|
-
* Submit evidence for an assigned task.
|
|
98
|
-
*/
|
|
99
|
-
submitEvidence(params: {
|
|
100
|
-
taskId: number;
|
|
101
|
-
evidence: string;
|
|
102
|
-
}): Promise<{
|
|
103
|
-
unsignedTx: object;
|
|
104
|
-
}>;
|
|
105
69
|
/**
|
|
106
70
|
* Get task status.
|
|
107
71
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
-
import { createCipheriv, randomBytes, createHash } from 'crypto';
|
|
3
2
|
export class BlindMarket {
|
|
4
3
|
apiBase;
|
|
5
4
|
apiKey;
|
|
@@ -43,42 +42,6 @@ export class BlindMarket {
|
|
|
43
42
|
return this.req('GET', `/api/v1/agents?owner=${ownerAddress}`);
|
|
44
43
|
}
|
|
45
44
|
// ── Task lifecycle ────────────────────────────────────────────────────────
|
|
46
|
-
/**
|
|
47
|
-
* Encrypt instructions and post a task. Returns an unsigned tx to sign + broadcast.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* const { unsignedTx, taskHash } = await bb.postTask({
|
|
51
|
-
* instructions: 'Photograph the exterior of 42 Oak Street, NYC.',
|
|
52
|
-
* category: 'photography',
|
|
53
|
-
* amount: ethers.parseEther('30').toString(),
|
|
54
|
-
* token: '0x317227efcA18D004E12CA8046AEf7E1597458F25',
|
|
55
|
-
* locationZone: 'US-NY',
|
|
56
|
-
* });
|
|
57
|
-
* const receipt = await wallet.sendTransaction(unsignedTx);
|
|
58
|
-
*/
|
|
59
|
-
async postTask(params) {
|
|
60
|
-
// Encrypt instructions
|
|
61
|
-
const key = randomBytes(32);
|
|
62
|
-
const iv = randomBytes(12);
|
|
63
|
-
const cipher = createCipheriv('aes-256-gcm', key, iv);
|
|
64
|
-
const encrypted = Buffer.concat([cipher.update(params.instructions, 'utf8'), cipher.final()]);
|
|
65
|
-
const tag = cipher.getAuthTag();
|
|
66
|
-
const blob = Buffer.concat([iv, tag, encrypted]).toString('base64');
|
|
67
|
-
// Upload to storage
|
|
68
|
-
const { rootHash } = await this.req('POST', '/api/v1/storage/upload', { data: blob });
|
|
69
|
-
// taskHash = SHA-256 of ciphertext
|
|
70
|
-
const taskHash = '0x' + createHash('sha256').update(Buffer.concat([iv, tag, encrypted])).digest('hex');
|
|
71
|
-
// Build unsigned tx
|
|
72
|
-
const { unsignedTx } = await this.req('POST', '/api/v1/tasks', {
|
|
73
|
-
taskHash,
|
|
74
|
-
token: params.token,
|
|
75
|
-
amount: params.amount,
|
|
76
|
-
category: params.category,
|
|
77
|
-
locationZone: params.locationZone ?? 'global',
|
|
78
|
-
duration: params.duration ?? '86400',
|
|
79
|
-
});
|
|
80
|
-
return { unsignedTx, taskHash, storageRoot: rootHash };
|
|
81
|
-
}
|
|
82
45
|
/**
|
|
83
46
|
* Assign a worker to a task. Returns an unsigned tx.
|
|
84
47
|
*/
|
|
@@ -96,20 +59,6 @@ export class BlindMarket {
|
|
|
96
59
|
evidenceSummary: params.evidenceSummary,
|
|
97
60
|
});
|
|
98
61
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Submit evidence for an assigned task.
|
|
101
|
-
*/
|
|
102
|
-
async submitEvidence(params) {
|
|
103
|
-
const key = randomBytes(32);
|
|
104
|
-
const iv = randomBytes(12);
|
|
105
|
-
const cipher = createCipheriv('aes-256-gcm', key, iv);
|
|
106
|
-
const encrypted = Buffer.concat([cipher.update(params.evidence, 'utf8'), cipher.final()]);
|
|
107
|
-
const tag = cipher.getAuthTag();
|
|
108
|
-
const blob = Buffer.concat([iv, tag, encrypted]).toString('base64');
|
|
109
|
-
await this.req('POST', '/api/v1/storage/upload', { data: blob });
|
|
110
|
-
const evidenceHash = '0x' + createHash('sha256').update(Buffer.concat([iv, tag, encrypted])).digest('hex');
|
|
111
|
-
return this.req('POST', '/api/v1/submissions/submit', { taskId: params.taskId, evidenceHash });
|
|
112
|
-
}
|
|
113
62
|
/**
|
|
114
63
|
* Get task status.
|
|
115
64
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blindmarket/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "BlindMarket SDK — deploy agents,
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "BlindMarket SDK — deploy agents, assign workers, verify evidence",
|
|
5
5
|
"author": "BlindMarket Team",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/JemIIahh/BlindMarket#readme",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Wallet, ethers } from 'ethers';
|
|
2
|
-
import { createCipheriv, randomBytes, createHash } from 'crypto';
|
|
3
2
|
|
|
4
3
|
export interface BlindMarketConfig {
|
|
5
4
|
apiBase?: string;
|
|
@@ -19,15 +18,6 @@ export interface DeployAgentParams {
|
|
|
19
18
|
tools?: object[];
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
export interface PostTaskParams {
|
|
23
|
-
instructions: string;
|
|
24
|
-
category: string;
|
|
25
|
-
amount: string; // wei as string
|
|
26
|
-
token: string; // ERC-20 address
|
|
27
|
-
locationZone?: string;
|
|
28
|
-
duration?: string; // seconds
|
|
29
|
-
}
|
|
30
|
-
|
|
31
21
|
export interface DeployedAgent {
|
|
32
22
|
id: string;
|
|
33
23
|
name: string;
|
|
@@ -37,12 +27,6 @@ export interface DeployedAgent {
|
|
|
37
27
|
status: string;
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
export interface PostedTask {
|
|
41
|
-
unsignedTx: object;
|
|
42
|
-
taskHash: string;
|
|
43
|
-
storageRoot: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
30
|
export class BlindMarket {
|
|
47
31
|
private apiBase: string;
|
|
48
32
|
private apiKey: string;
|
|
@@ -92,47 +76,6 @@ export class BlindMarket {
|
|
|
92
76
|
|
|
93
77
|
// ── Task lifecycle ────────────────────────────────────────────────────────
|
|
94
78
|
|
|
95
|
-
/**
|
|
96
|
-
* Encrypt instructions and post a task. Returns an unsigned tx to sign + broadcast.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* const { unsignedTx, taskHash } = await bb.postTask({
|
|
100
|
-
* instructions: 'Photograph the exterior of 42 Oak Street, NYC.',
|
|
101
|
-
* category: 'photography',
|
|
102
|
-
* amount: ethers.parseEther('30').toString(),
|
|
103
|
-
* token: '0x317227efcA18D004E12CA8046AEf7E1597458F25',
|
|
104
|
-
* locationZone: 'US-NY',
|
|
105
|
-
* });
|
|
106
|
-
* const receipt = await wallet.sendTransaction(unsignedTx);
|
|
107
|
-
*/
|
|
108
|
-
async postTask(params: PostTaskParams): Promise<PostedTask> {
|
|
109
|
-
// Encrypt instructions
|
|
110
|
-
const key = randomBytes(32);
|
|
111
|
-
const iv = randomBytes(12);
|
|
112
|
-
const cipher = createCipheriv('aes-256-gcm', key, iv);
|
|
113
|
-
const encrypted = Buffer.concat([cipher.update(params.instructions, 'utf8'), cipher.final()]);
|
|
114
|
-
const tag = (cipher as any).getAuthTag() as Buffer;
|
|
115
|
-
const blob = Buffer.concat([iv, tag, encrypted]).toString('base64');
|
|
116
|
-
|
|
117
|
-
// Upload to storage
|
|
118
|
-
const { rootHash } = await this.req<{ rootHash: string }>('POST', '/api/v1/storage/upload', { data: blob });
|
|
119
|
-
|
|
120
|
-
// taskHash = SHA-256 of ciphertext
|
|
121
|
-
const taskHash = '0x' + createHash('sha256').update(Buffer.concat([iv, tag, encrypted])).digest('hex');
|
|
122
|
-
|
|
123
|
-
// Build unsigned tx
|
|
124
|
-
const { unsignedTx } = await this.req<{ unsignedTx: object }>('POST', '/api/v1/tasks', {
|
|
125
|
-
taskHash,
|
|
126
|
-
token: params.token,
|
|
127
|
-
amount: params.amount,
|
|
128
|
-
category: params.category,
|
|
129
|
-
locationZone: params.locationZone ?? 'global',
|
|
130
|
-
duration: params.duration ?? '86400',
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return { unsignedTx, taskHash, storageRoot: rootHash };
|
|
134
|
-
}
|
|
135
|
-
|
|
136
79
|
/**
|
|
137
80
|
* Assign a worker to a task. Returns an unsigned tx.
|
|
138
81
|
*/
|
|
@@ -157,23 +100,6 @@ export class BlindMarket {
|
|
|
157
100
|
});
|
|
158
101
|
}
|
|
159
102
|
|
|
160
|
-
/**
|
|
161
|
-
* Submit evidence for an assigned task.
|
|
162
|
-
*/
|
|
163
|
-
async submitEvidence(params: { taskId: number; evidence: string }): Promise<{ unsignedTx: object }> {
|
|
164
|
-
const key = randomBytes(32);
|
|
165
|
-
const iv = randomBytes(12);
|
|
166
|
-
const cipher = createCipheriv('aes-256-gcm', key, iv);
|
|
167
|
-
const encrypted = Buffer.concat([cipher.update(params.evidence, 'utf8'), cipher.final()]);
|
|
168
|
-
const tag = (cipher as any).getAuthTag() as Buffer;
|
|
169
|
-
const blob = Buffer.concat([iv, tag, encrypted]).toString('base64');
|
|
170
|
-
|
|
171
|
-
await this.req('POST', '/api/v1/storage/upload', { data: blob });
|
|
172
|
-
const evidenceHash = '0x' + createHash('sha256').update(Buffer.concat([iv, tag, encrypted])).digest('hex');
|
|
173
|
-
|
|
174
|
-
return this.req('POST', '/api/v1/submissions/submit', { taskId: params.taskId, evidenceHash });
|
|
175
|
-
}
|
|
176
|
-
|
|
177
103
|
/**
|
|
178
104
|
* Get task status.
|
|
179
105
|
*/
|