@human-protocol/sdk 1.1.13 → 1.1.15
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/encryption.d.ts +245 -29
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +245 -29
- package/dist/escrow.d.ts +731 -117
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +734 -120
- package/dist/kvstore.d.ts +138 -15
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +138 -15
- package/dist/staking.d.ts +324 -54
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +324 -54
- package/dist/statistics.d.ts +266 -16
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +266 -16
- package/dist/storage.d.ts +155 -16
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +155 -16
- package/package.json +17 -1
- package/src/encryption.ts +246 -29
- package/src/escrow.ts +734 -120
- package/src/kvstore.ts +138 -15
- package/src/staking.ts +324 -54
- package/src/statistics.ts +266 -16
- package/src/storage.ts +156 -17
package/dist/escrow.d.ts
CHANGED
|
@@ -4,6 +4,75 @@ import { ChainId } from './enums';
|
|
|
4
4
|
import { IEscrowConfig, IEscrowsFilter } from './interfaces';
|
|
5
5
|
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
6
6
|
import { EscrowData } from './graphql';
|
|
7
|
+
/**
|
|
8
|
+
* ## Introduction
|
|
9
|
+
*
|
|
10
|
+
* This client enables to perform actions on Escrow contracts and obtain information from both the contracts and subgraph.
|
|
11
|
+
*
|
|
12
|
+
* Internally, the SDK will use one network or another according to the network ID of the `signerOrProvider`.
|
|
13
|
+
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* static async build(signerOrProvider: Signer | Provider);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
20
|
+
*
|
|
21
|
+
* - **Signer**: when the user wants to use this model in order to send transactions caling the contract functions.
|
|
22
|
+
* - **Provider**: when the user wants to use this model in order to get information from the contracts or subgraph.
|
|
23
|
+
*
|
|
24
|
+
* ## Installation
|
|
25
|
+
*
|
|
26
|
+
* ### npm
|
|
27
|
+
* ```bash
|
|
28
|
+
* npm install @human-protocol/sdk
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ### yarn
|
|
32
|
+
* ```bash
|
|
33
|
+
* yarn install @human-protocol/sdk
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ## Code example
|
|
37
|
+
*
|
|
38
|
+
* ### Signer
|
|
39
|
+
*
|
|
40
|
+
* **Using private key(backend)**
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
44
|
+
* import { Wallet, providers } from 'ethers';
|
|
45
|
+
*
|
|
46
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
47
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
48
|
+
*
|
|
49
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
50
|
+
* const signer = new Wallet(privateKey, provider);
|
|
51
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* **Using Wagmi(frontend)**
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { useSigner, useChainId } from 'wagmi';
|
|
58
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
59
|
+
*
|
|
60
|
+
* const { data: signer } = useSigner();
|
|
61
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* ### Provider
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
68
|
+
* import { providers } from 'ethers';
|
|
69
|
+
*
|
|
70
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
71
|
+
*
|
|
72
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
73
|
+
* const escrowClient = await EscrowClient.build(provider);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
7
76
|
export declare class EscrowClient {
|
|
8
77
|
private escrowFactoryContract;
|
|
9
78
|
private escrowContract?;
|
|
@@ -12,226 +81,771 @@ export declare class EscrowClient {
|
|
|
12
81
|
/**
|
|
13
82
|
* **EscrowClient constructor**
|
|
14
83
|
*
|
|
15
|
-
* @param {Signer | Provider} signerOrProvider
|
|
16
|
-
* @param {NetworkData} network
|
|
84
|
+
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
85
|
+
* @param {NetworkData} network The network information required to connect to the Escrow contract
|
|
17
86
|
*/
|
|
18
87
|
constructor(signerOrProvider: Signer | Provider, network: NetworkData);
|
|
19
88
|
/**
|
|
20
89
|
* Creates an instance of EscrowClient from a Signer or Provider.
|
|
21
90
|
*
|
|
22
|
-
* @param {Signer | Provider} signerOrProvider
|
|
23
|
-
* @returns {Promise<EscrowClient>}
|
|
24
|
-
* @throws {ErrorProviderDoesNotExist}
|
|
25
|
-
* @throws {ErrorUnsupportedChainID}
|
|
91
|
+
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
92
|
+
* @returns {Promise<EscrowClient>} An instance of EscrowClient
|
|
93
|
+
* @throws {ErrorProviderDoesNotExist} Thrown if the provider does not exist for the provided Signer
|
|
94
|
+
* @throws {ErrorUnsupportedChainID} Thrown if the network's chainId is not supported
|
|
26
95
|
*/
|
|
27
96
|
static build(signerOrProvider: Signer | Provider): Promise<EscrowClient>;
|
|
28
97
|
/**
|
|
29
|
-
*
|
|
98
|
+
* This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
|
|
30
99
|
*
|
|
31
|
-
* @param {string} tokenAddress
|
|
32
|
-
* @param {string[]} trustedHandlers
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
100
|
+
* @param {string} tokenAddress Token address to use for pay outs.
|
|
101
|
+
* @param {string[]} trustedHandlers Array of addresses that can perform actions on the contract.
|
|
102
|
+
* @param {string} jobRequesterId Job Requester Id
|
|
103
|
+
* @returns {Promise<string>} Return the address of the escrow created.
|
|
104
|
+
*
|
|
105
|
+
*
|
|
106
|
+
* **Code example**
|
|
107
|
+
*
|
|
108
|
+
* > Need to have available stake.
|
|
109
|
+
*
|
|
110
|
+
* ```ts
|
|
111
|
+
* import { Wallet, providers } from 'ethers';
|
|
112
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
113
|
+
*
|
|
114
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
115
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
116
|
+
*
|
|
117
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
118
|
+
* const signer = new Wallet(privateKey, provider);
|
|
119
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
120
|
+
*
|
|
121
|
+
* const tokenAddress = '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4';
|
|
122
|
+
* const trustedHandlers = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
|
|
123
|
+
* const jobRequesterId = "job-requester-id";
|
|
124
|
+
* const escrowAddress = await escrowClient.createEscrow(tokenAddress, trustedHandlers, jobRequesterId);
|
|
125
|
+
* ```
|
|
35
126
|
*/
|
|
36
127
|
createEscrow(tokenAddress: string, trustedHandlers: string[], jobRequesterId: string): Promise<string>;
|
|
37
128
|
/**
|
|
38
|
-
*
|
|
129
|
+
* This function sets up the parameters of the escrow.
|
|
130
|
+
*
|
|
131
|
+
* @param {string} escrowAddress Address of the escrow to set up.
|
|
132
|
+
* @param {IEscrowConfig} escrowConfig Escrow configuration parameters.
|
|
133
|
+
* @returns Returns void if successful. Throws error if any.
|
|
134
|
+
*
|
|
135
|
+
*
|
|
136
|
+
* **Code example**
|
|
39
137
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
138
|
+
* > Only Job Launcher or a trusted handler can call it.
|
|
139
|
+
*
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { Wallet, providers } from 'ethers';
|
|
142
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
143
|
+
*
|
|
144
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
145
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
146
|
+
*
|
|
147
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
148
|
+
* const signer = new Wallet(privateKey, provider);
|
|
149
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
150
|
+
*
|
|
151
|
+
* const escrowAddress = '0x62dD51230A30401C455c8398d06F85e4EaB6309f';
|
|
152
|
+
* const escrowConfig = {
|
|
153
|
+
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
154
|
+
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
155
|
+
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
156
|
+
* recordingOracleFee: BigNumber.from('10'),
|
|
157
|
+
* reputationOracleFee: BigNumber.from('10'),
|
|
158
|
+
* exchangeOracleFee: BigNumber.from('10'),
|
|
159
|
+
* manifestUrl: 'htttp://localhost/manifest.json',
|
|
160
|
+
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
161
|
+
* };
|
|
162
|
+
* await escrowClient.setup(escrowAddress, escrowConfig);
|
|
163
|
+
* ```
|
|
44
164
|
*/
|
|
45
165
|
setup(escrowAddress: string, escrowConfig: IEscrowConfig): Promise<void>;
|
|
46
166
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
167
|
+
* This function creates and sets up an escrow.
|
|
168
|
+
*
|
|
169
|
+
* @param {string} tokenAddress Token address to use for pay outs.
|
|
170
|
+
* @param {string[]} trustedHandlers Array of addresses that can perform actions on the contract.
|
|
171
|
+
* @param {string} jobRequesterId Job Requester Id
|
|
172
|
+
* @param {IEscrowConfig} escrowConfig Configuration object with escrow settings.
|
|
173
|
+
* @returns {Promise<string>} Returns the address of the escrow created.
|
|
174
|
+
*
|
|
175
|
+
*
|
|
176
|
+
* **Code example**
|
|
177
|
+
*
|
|
178
|
+
* ```ts
|
|
179
|
+
* import { ethers, Wallet, providers } from 'ethers';
|
|
180
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
181
|
+
*
|
|
182
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
183
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
49
184
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
185
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
186
|
+
* const signer = new Wallet(privateKey, provider);
|
|
187
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
188
|
+
*
|
|
189
|
+
* const tokenAddress = '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4';
|
|
190
|
+
* const trustedHandlers = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
|
|
191
|
+
* const jobRequesterId = "job-requester-id";
|
|
192
|
+
*
|
|
193
|
+
* const escrowConfig = {
|
|
194
|
+
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
195
|
+
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
196
|
+
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
197
|
+
* recordingOracleFee: BigNumber.from('10'),
|
|
198
|
+
* reputationOracleFee: BigNumber.from('10'),
|
|
199
|
+
* exchangeOracleFee: BigNumber.from('10'),
|
|
200
|
+
* manifestUrl: 'htttp://localhost/manifest.json',
|
|
201
|
+
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
202
|
+
* };
|
|
203
|
+
*
|
|
204
|
+
* const escrowAddress = await escrowClient.createAndSetupEscrow(tokenAddress, trustedHandlers, jobRequesterId, escrowConfig);
|
|
205
|
+
* ```
|
|
55
206
|
*/
|
|
56
207
|
createAndSetupEscrow(tokenAddress: string, trustedHandlers: string[], jobRequesterId: string, escrowConfig: IEscrowConfig): Promise<string>;
|
|
57
208
|
/**
|
|
58
|
-
*
|
|
209
|
+
* This function adds funds of the chosen token to the escrow.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} escrowAddress Address of the escrow to fund.
|
|
212
|
+
* @param {BigNumber} amount Amount to be added as funds.
|
|
213
|
+
* @returns Returns void if successful. Throws error if any.
|
|
214
|
+
*
|
|
59
215
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
216
|
+
* **Code example**
|
|
217
|
+
*
|
|
218
|
+
* ```ts
|
|
219
|
+
* import { ethers, Wallet, providers } from 'ethers';
|
|
220
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
221
|
+
*
|
|
222
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
223
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
224
|
+
*
|
|
225
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
226
|
+
* const signer = new Wallet(privateKey, provider);
|
|
227
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
228
|
+
*
|
|
229
|
+
* const amount = ethers.utils.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
230
|
+
* await escrowClient.fund('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
231
|
+
* ```
|
|
64
232
|
*/
|
|
65
233
|
fund(escrowAddress: string, amount: BigNumber): Promise<void>;
|
|
66
234
|
/**
|
|
67
|
-
*
|
|
235
|
+
* This function stores the results url and hash.
|
|
236
|
+
*
|
|
237
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
238
|
+
* @param {string} url Results file url.
|
|
239
|
+
* @param {string} hash Results file hash.
|
|
240
|
+
* @returns Returns void if successful. Throws error if any.
|
|
68
241
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
242
|
+
*
|
|
243
|
+
* **Code example**
|
|
244
|
+
*
|
|
245
|
+
* > Only Recording Oracle or a trusted handler can call it.
|
|
246
|
+
*
|
|
247
|
+
* ```ts
|
|
248
|
+
* import { ethers, Wallet, providers } from 'ethers';
|
|
249
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
250
|
+
*
|
|
251
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
252
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
253
|
+
*
|
|
254
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
255
|
+
* const signer = new Wallet(privateKey, provider);
|
|
256
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
257
|
+
*
|
|
258
|
+
* await storeResults.storeResults('0x62dD51230A30401C455c8398d06F85e4EaB6309f', 'http://localhost/results.json', 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079');
|
|
259
|
+
* ```
|
|
75
260
|
*/
|
|
76
261
|
storeResults(escrowAddress: string, url: string, hash: string): Promise<void>;
|
|
77
262
|
/**
|
|
78
|
-
*
|
|
263
|
+
* This function sets the status of an escrow to completed.
|
|
264
|
+
*
|
|
265
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
266
|
+
* @returns Returns void if successful. Throws error if any.
|
|
267
|
+
*
|
|
268
|
+
*
|
|
269
|
+
* **Code example**
|
|
79
270
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
271
|
+
* > Only Recording Oracle or a trusted handler can call it.
|
|
272
|
+
*
|
|
273
|
+
* ```ts
|
|
274
|
+
* import { Wallet, providers } from 'ethers';
|
|
275
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
276
|
+
*
|
|
277
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
278
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
279
|
+
*
|
|
280
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
281
|
+
* const signer = new Wallet(privateKey, provider);
|
|
282
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
283
|
+
*
|
|
284
|
+
* await escrowClient.complete('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
285
|
+
* ```
|
|
83
286
|
*/
|
|
84
287
|
complete(escrowAddress: string): Promise<void>;
|
|
85
288
|
/**
|
|
86
|
-
*
|
|
289
|
+
* This function pays out the amounts specified to the workers and sets the URL of the final results file.
|
|
290
|
+
*
|
|
291
|
+
* @param {string} escrowAddress Escrow address to payout.
|
|
292
|
+
* @param {string[]} recipients Array of recipient addresses.
|
|
293
|
+
* @param {BigNumber[]} amounts Array of amounts the recipients will receive.
|
|
294
|
+
* @param {string} finalResultsUrl Final results file url.
|
|
295
|
+
* @param {string} finalResultsHash Final results file hash.
|
|
296
|
+
* @returns Returns void if successful. Throws error if any.
|
|
297
|
+
*
|
|
298
|
+
*
|
|
299
|
+
* **Code example**
|
|
300
|
+
*
|
|
301
|
+
* > Only Reputation Oracle or a trusted handler can call it.
|
|
302
|
+
*
|
|
303
|
+
* ```ts
|
|
304
|
+
* import { ethers, Wallet, providers } from 'ethers';
|
|
305
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
306
|
+
*
|
|
307
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
308
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
87
309
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
310
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
311
|
+
* const signer = new Wallet(privateKey, provider);
|
|
312
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
313
|
+
*
|
|
314
|
+
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
|
|
315
|
+
* const amounts = [ethers.utils.parseUnits(5, 'ether'), ethers.utils.parseUnits(10, 'ether')];
|
|
316
|
+
* const resultsUrl = 'http://localhost/results.json';
|
|
317
|
+
* const resultsHash'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079';
|
|
318
|
+
*
|
|
319
|
+
* await escrowClient.bulkPayOut('0x62dD51230A30401C455c8398d06F85e4EaB6309f', recipients, amounts, resultsUrl, resultsHash);
|
|
320
|
+
* ```
|
|
95
321
|
*/
|
|
96
322
|
bulkPayOut(escrowAddress: string, recipients: string[], amounts: BigNumber[], finalResultsUrl: string, finalResultsHash: string): Promise<void>;
|
|
97
323
|
/**
|
|
98
|
-
*
|
|
324
|
+
* This function cancels the specified escrow and sends the balance to the canceler.
|
|
325
|
+
*
|
|
326
|
+
* @param {string} escrowAddress Address of the escrow to cancel.
|
|
327
|
+
* @returns {EscrowCancel} Returns the escrow cancellation data including transaction hash and refunded amount. Throws error if any.
|
|
328
|
+
*
|
|
329
|
+
*
|
|
330
|
+
* **Code example**
|
|
331
|
+
*
|
|
332
|
+
* > Only Job Launcher or a trusted handler can call it.
|
|
333
|
+
*
|
|
334
|
+
* ```ts
|
|
335
|
+
* import { ethers, Wallet, providers } from 'ethers';
|
|
336
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
337
|
+
*
|
|
338
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
339
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
340
|
+
*
|
|
341
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
342
|
+
* const signer = new Wallet(privateKey, provider);
|
|
343
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
99
344
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* @throws {Error} - An error object if an error occurred.
|
|
345
|
+
* await escrowClient.cancel('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
346
|
+
* ```
|
|
103
347
|
*/
|
|
104
348
|
cancel(escrowAddress: string): Promise<EscrowCancel>;
|
|
105
349
|
/**
|
|
106
|
-
*
|
|
350
|
+
* This function cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
|
|
107
351
|
*
|
|
108
|
-
* @param {string} escrowAddress
|
|
109
|
-
* @returns
|
|
110
|
-
*
|
|
352
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
353
|
+
* @returns Returns void if successful. Throws error if any.
|
|
354
|
+
*
|
|
355
|
+
*
|
|
356
|
+
* **Code example**
|
|
357
|
+
*
|
|
358
|
+
* > Only Job Launcher or trusted handler can call it.
|
|
359
|
+
*
|
|
360
|
+
* ```ts
|
|
361
|
+
* import { Wallet, providers } from 'ethers';
|
|
362
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
363
|
+
*
|
|
364
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
365
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
366
|
+
*
|
|
367
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
368
|
+
* const signer = new Wallet(privateKey, provider);
|
|
369
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
370
|
+
*
|
|
371
|
+
* await escrowClient.abort('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
372
|
+
* ```
|
|
111
373
|
*/
|
|
112
374
|
abort(escrowAddress: string): Promise<void>;
|
|
113
375
|
/**
|
|
114
|
-
*
|
|
376
|
+
* This function sets the status of an escrow to completed.
|
|
377
|
+
*
|
|
378
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
379
|
+
* @param {string[]} trustedHandlers Array of addresses of trusted handlers to add.
|
|
380
|
+
* @returns Returns void if successful. Throws error if any.
|
|
381
|
+
*
|
|
115
382
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
383
|
+
* **Code example**
|
|
384
|
+
*
|
|
385
|
+
* > Only Job Launcher or trusted handler can call it.
|
|
386
|
+
*
|
|
387
|
+
* ```ts
|
|
388
|
+
* import { Wallet, providers } from 'ethers';
|
|
389
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
390
|
+
*
|
|
391
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
392
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
393
|
+
*
|
|
394
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
395
|
+
* const signer = new Wallet(privateKey, provider);
|
|
396
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
397
|
+
*
|
|
398
|
+
* const trustedHandlers = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266']
|
|
399
|
+
* await escrowClient.addTrustedHandlers('0x62dD51230A30401C455c8398d06F85e4EaB6309f', trustedHandlers);
|
|
400
|
+
* ```
|
|
120
401
|
*/
|
|
121
402
|
addTrustedHandlers(escrowAddress: string, trustedHandlers: string[]): Promise<void>;
|
|
122
403
|
/**
|
|
123
|
-
*
|
|
404
|
+
* This function returns the balance for a specified escrow address.
|
|
405
|
+
*
|
|
406
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
407
|
+
* @returns {BigNumber} Balance of the escrow in the token used to fund it.
|
|
408
|
+
*
|
|
409
|
+
* **Code example**
|
|
410
|
+
*
|
|
411
|
+
* ```ts
|
|
412
|
+
* import { providers } from 'ethers';
|
|
413
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
414
|
+
*
|
|
415
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
124
416
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
417
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
418
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
419
|
+
*
|
|
420
|
+
* const balance = await escrowClient.getBalance('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
421
|
+
* ```
|
|
128
422
|
*/
|
|
129
423
|
getBalance(escrowAddress: string): Promise<BigNumber>;
|
|
130
424
|
/**
|
|
131
|
-
*
|
|
425
|
+
* This function returns the manifest file hash.
|
|
426
|
+
*
|
|
427
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
428
|
+
* @returns {string} Hash of the manifest file content.
|
|
429
|
+
*
|
|
430
|
+
* **Code example**
|
|
431
|
+
*
|
|
432
|
+
* ```ts
|
|
433
|
+
* import { providers } from 'ethers';
|
|
434
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
435
|
+
*
|
|
436
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
132
437
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
438
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
439
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
440
|
+
*
|
|
441
|
+
* const manifestHash = await escrowClient.getManifestHash('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
442
|
+
* ```
|
|
136
443
|
*/
|
|
137
444
|
getManifestHash(escrowAddress: string): Promise<string>;
|
|
138
445
|
/**
|
|
139
|
-
*
|
|
446
|
+
* This function returns the manifest file URL.
|
|
447
|
+
*
|
|
448
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
449
|
+
* @returns {string} Url of the manifest.
|
|
450
|
+
*
|
|
451
|
+
* **Code example**
|
|
452
|
+
*
|
|
453
|
+
* ```ts
|
|
454
|
+
* import { providers } from 'ethers';
|
|
455
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
456
|
+
*
|
|
457
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
140
458
|
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
459
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
460
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
461
|
+
*
|
|
462
|
+
* const manifestUrl = await escrowClient.getManifestUrl('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
463
|
+
* ```
|
|
144
464
|
*/
|
|
145
465
|
getManifestUrl(escrowAddress: string): Promise<string>;
|
|
146
466
|
/**
|
|
147
|
-
*
|
|
467
|
+
* This function returns the results file URL.
|
|
468
|
+
*
|
|
469
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
470
|
+
* @returns {string} Results file url.
|
|
471
|
+
*
|
|
472
|
+
* **Code example**
|
|
473
|
+
*
|
|
474
|
+
* ```ts
|
|
475
|
+
* import { providers } from 'ethers';
|
|
476
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
477
|
+
*
|
|
478
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
148
479
|
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
480
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
481
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
482
|
+
*
|
|
483
|
+
* const resultsUrl = await escrowClient.getResultsUrl('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
484
|
+
* ```
|
|
152
485
|
*/
|
|
153
486
|
getResultsUrl(escrowAddress: string): Promise<string>;
|
|
154
487
|
/**
|
|
155
|
-
*
|
|
488
|
+
* This function returns the intermediate results file URL.
|
|
489
|
+
*
|
|
490
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
491
|
+
* @returns {string} Url of the file that store results from Recording Oracle.
|
|
492
|
+
*
|
|
493
|
+
* **Code example**
|
|
494
|
+
*
|
|
495
|
+
* ```ts
|
|
496
|
+
* import { providers } from 'ethers';
|
|
497
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
156
498
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
499
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
500
|
+
*
|
|
501
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
502
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
503
|
+
*
|
|
504
|
+
* const intemediateResultsUrl = await escrowClient.getIntermediateResultsUrl('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
505
|
+
* ```
|
|
160
506
|
*/
|
|
161
507
|
getIntermediateResultsUrl(escrowAddress: string): Promise<string>;
|
|
162
508
|
/**
|
|
163
|
-
*
|
|
509
|
+
* This function returns the token address used for funding the escrow.
|
|
510
|
+
*
|
|
511
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
512
|
+
* @returns {string} Address of the token used to fund the escrow.
|
|
513
|
+
*
|
|
514
|
+
* **Code example**
|
|
515
|
+
*
|
|
516
|
+
* ```ts
|
|
517
|
+
* import { providers } from 'ethers';
|
|
518
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
164
519
|
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
520
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
521
|
+
*
|
|
522
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
523
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
524
|
+
*
|
|
525
|
+
* const tokenAddress = await escrowClient.getTokenAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
526
|
+
* ```
|
|
168
527
|
*/
|
|
169
528
|
getTokenAddress(escrowAddress: string): Promise<string>;
|
|
170
529
|
/**
|
|
171
|
-
*
|
|
530
|
+
* This function returns the current status of the escrow.
|
|
531
|
+
*
|
|
532
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
533
|
+
* @returns {EscrowStatus} Current status of the escrow.
|
|
534
|
+
*
|
|
535
|
+
* **Code example**
|
|
172
536
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
537
|
+
* ```ts
|
|
538
|
+
* import { providers } from 'ethers';
|
|
539
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
540
|
+
*
|
|
541
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
542
|
+
*
|
|
543
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
544
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
545
|
+
*
|
|
546
|
+
* const status = await escrowClient.getStatus('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
547
|
+
* ```
|
|
176
548
|
*/
|
|
177
549
|
getStatus(escrowAddress: string): Promise<EscrowStatus>;
|
|
178
550
|
/**
|
|
179
|
-
*
|
|
551
|
+
* This function returns the recording oracle address for a given escrow.
|
|
552
|
+
*
|
|
553
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
554
|
+
* @returns {string} Address of the Recording Oracle.
|
|
555
|
+
*
|
|
556
|
+
* **Code example**
|
|
180
557
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
558
|
+
* ```ts
|
|
559
|
+
* import { providers } from 'ethers';
|
|
560
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
561
|
+
*
|
|
562
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
563
|
+
*
|
|
564
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
565
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
566
|
+
*
|
|
567
|
+
* const oracleAddress = await escrowClient.getRecordingOracleAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
568
|
+
* ```
|
|
184
569
|
*/
|
|
185
570
|
getRecordingOracleAddress(escrowAddress: string): Promise<string>;
|
|
186
571
|
/**
|
|
187
|
-
*
|
|
572
|
+
* This function returns the job launcher address for a given escrow.
|
|
573
|
+
*
|
|
574
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
575
|
+
* @returns {string} Address of the Job Launcher.
|
|
188
576
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
577
|
+
* **Code example**
|
|
578
|
+
*
|
|
579
|
+
* ```ts
|
|
580
|
+
* import { providers } from 'ethers';
|
|
581
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
582
|
+
*
|
|
583
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
584
|
+
*
|
|
585
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
586
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
587
|
+
*
|
|
588
|
+
* const jobLauncherAddress = await escrowClient.getJobLauncherAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
589
|
+
* ```
|
|
192
590
|
*/
|
|
193
591
|
getJobLauncherAddress(escrowAddress: string): Promise<string>;
|
|
194
592
|
/**
|
|
195
|
-
*
|
|
593
|
+
* This function returns the reputation oracle address for a given escrow.
|
|
594
|
+
*
|
|
595
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
596
|
+
* @returns {EscrowStatus} Address of the Reputation Oracle.
|
|
196
597
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
598
|
+
* **Code example**
|
|
599
|
+
*
|
|
600
|
+
* ```ts
|
|
601
|
+
* import { providers } from 'ethers';
|
|
602
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
603
|
+
*
|
|
604
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
605
|
+
*
|
|
606
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
607
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
608
|
+
*
|
|
609
|
+
* const oracleAddress = await escrowClient.getReputationOracleAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
610
|
+
* ```
|
|
200
611
|
*/
|
|
201
612
|
getReputationOracleAddress(escrowAddress: string): Promise<string>;
|
|
202
613
|
/**
|
|
203
|
-
*
|
|
614
|
+
* This function returns the exchange oracle address for a given escrow.
|
|
615
|
+
*
|
|
616
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
617
|
+
* @returns {EscrowStatus} Address of the Exchange Oracle.
|
|
204
618
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
619
|
+
* **Code example**
|
|
620
|
+
*
|
|
621
|
+
* ```ts
|
|
622
|
+
* import { providers } from 'ethers';
|
|
623
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
624
|
+
*
|
|
625
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
626
|
+
*
|
|
627
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
628
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
629
|
+
*
|
|
630
|
+
* const oracleAddress = await escrowClient.getExchangeOracleAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
631
|
+
* ```
|
|
208
632
|
*/
|
|
209
633
|
getExchangeOracleAddress(escrowAddress: string): Promise<string>;
|
|
210
634
|
/**
|
|
211
|
-
*
|
|
635
|
+
* This function returns the escrow factory address for a given escrow.
|
|
636
|
+
*
|
|
637
|
+
* @param {string} escrowAddress Address of the escrow.
|
|
638
|
+
* @returns {EscrowStatus} Address of the escrow factory.
|
|
639
|
+
*
|
|
640
|
+
* **Code example**
|
|
641
|
+
*
|
|
642
|
+
* ```ts
|
|
643
|
+
* import { providers } from 'ethers';
|
|
644
|
+
* import { EscrowClient } from '@human-protocol/sdk';
|
|
645
|
+
*
|
|
646
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
647
|
+
*
|
|
648
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
649
|
+
* const escrowClient = await EscrowClient.build(signer);
|
|
212
650
|
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* @throws {Error} - An error object if an error occurred.
|
|
651
|
+
* const factoryAddress = await escrowClient.getFactoryAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
652
|
+
* ```
|
|
216
653
|
*/
|
|
217
654
|
getFactoryAddress(escrowAddress: string): Promise<string>;
|
|
218
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* ## Introduction
|
|
658
|
+
*
|
|
659
|
+
* Utility class for escrow-related operations.
|
|
660
|
+
*
|
|
661
|
+
* ## Installation
|
|
662
|
+
*
|
|
663
|
+
* ### npm
|
|
664
|
+
* ```bash
|
|
665
|
+
* npm install @human-protocol/sdk
|
|
666
|
+
* ```
|
|
667
|
+
*
|
|
668
|
+
* ### yarn
|
|
669
|
+
* ```bash
|
|
670
|
+
* yarn install @human-protocol/sdk
|
|
671
|
+
* ```
|
|
672
|
+
*
|
|
673
|
+
* ## Code example
|
|
674
|
+
*
|
|
675
|
+
* ### Signer
|
|
676
|
+
*
|
|
677
|
+
* **Using private key(backend)**
|
|
678
|
+
*
|
|
679
|
+
* ```ts
|
|
680
|
+
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
681
|
+
*
|
|
682
|
+
* const escrowAddresses = new EscrowUtils.getEscrows({
|
|
683
|
+
* networks: [ChainId.POLYGON_MUMBAI]
|
|
684
|
+
* });
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
219
687
|
export declare class EscrowUtils {
|
|
220
688
|
/**
|
|
221
|
-
*
|
|
689
|
+
* This function returns an array of escrows based on the specified filter parameters.
|
|
222
690
|
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
691
|
+
*
|
|
692
|
+
* **Input parameters**
|
|
693
|
+
*
|
|
694
|
+
* ```ts
|
|
695
|
+
* interface IEscrowsFilter {
|
|
696
|
+
* networks: ChainId[];
|
|
697
|
+
* launcher?: string;
|
|
698
|
+
* reputationOracle?: string;
|
|
699
|
+
* recordingOracle?: string;
|
|
700
|
+
* exchangeOracle?: string;
|
|
701
|
+
* jobRequesterId?: string;
|
|
702
|
+
* status?: EscrowStatus;
|
|
703
|
+
* from?: Date;
|
|
704
|
+
* to?: Date;
|
|
705
|
+
* }
|
|
706
|
+
* ```
|
|
707
|
+
*
|
|
708
|
+
* ```ts
|
|
709
|
+
* enum ChainId {
|
|
710
|
+
* ALL = -1,
|
|
711
|
+
* MAINNET = 1,
|
|
712
|
+
* RINKEBY = 4,
|
|
713
|
+
* GOERLI = 5,
|
|
714
|
+
* BSC_MAINNET = 56,
|
|
715
|
+
* BSC_TESTNET = 97,
|
|
716
|
+
* POLYGON = 137,
|
|
717
|
+
* POLYGON_MUMBAI = 80001,
|
|
718
|
+
* MOONBEAM = 1284,
|
|
719
|
+
* MOONBASE_ALPHA = 1287,
|
|
720
|
+
* AVALANCHE = 43114,
|
|
721
|
+
* AVALANCHE_TESTNET = 43113,
|
|
722
|
+
* SKALE = 1273227453,
|
|
723
|
+
* LOCALHOST = 1338,
|
|
724
|
+
* }
|
|
725
|
+
* ```
|
|
726
|
+
*
|
|
727
|
+
* ```ts
|
|
728
|
+
* enum EscrowStatus {
|
|
729
|
+
* Launched,
|
|
730
|
+
* Pending,
|
|
731
|
+
* Partial,
|
|
732
|
+
* Paid,
|
|
733
|
+
* Complete,
|
|
734
|
+
* Cancelled,
|
|
735
|
+
* }
|
|
736
|
+
* ```
|
|
737
|
+
*
|
|
738
|
+
* ```ts
|
|
739
|
+
* type EscrowData = {
|
|
740
|
+
* id: string;
|
|
741
|
+
* address: string;
|
|
742
|
+
* amountPaid: string;
|
|
743
|
+
* balance: string;
|
|
744
|
+
* count: string;
|
|
745
|
+
* jobRequesterId: string;
|
|
746
|
+
* factoryAddress: string;
|
|
747
|
+
* finalResultsUrl?: string;
|
|
748
|
+
* intermediateResultsUrl?: string;
|
|
749
|
+
* launcher: string;
|
|
750
|
+
* manifestHash?: string;
|
|
751
|
+
* manifestUrl?: string;
|
|
752
|
+
* recordingOracle?: string;
|
|
753
|
+
* recordingOracleFee?: string;
|
|
754
|
+
* reputationOracle?: string;
|
|
755
|
+
* reputationOracleFee?: string;
|
|
756
|
+
* exchangeOracle?: string;
|
|
757
|
+
* exchangeOracleFee?: string;
|
|
758
|
+
* status: EscrowStatus;
|
|
759
|
+
* token: string;
|
|
760
|
+
* totalFundedAmount: string;
|
|
761
|
+
* createdAt: string;
|
|
762
|
+
* };
|
|
763
|
+
* ```
|
|
764
|
+
*
|
|
765
|
+
*
|
|
766
|
+
* @param {IEscrowsFilter} filter Filter parameters.
|
|
767
|
+
* @returns {EscrowData[]} List of escrows that match the filter.
|
|
768
|
+
*
|
|
769
|
+
* **Code example**
|
|
770
|
+
*
|
|
771
|
+
* ```ts
|
|
772
|
+
* import { ChainId, EscrowUtils, EscrowStatus } from '@human-protocol/sdk';
|
|
773
|
+
*
|
|
774
|
+
* const filters: IEscrowsFilter = {
|
|
775
|
+
* status: EscrowStatus.Pending,
|
|
776
|
+
* from: new Date(2023, 4, 8),
|
|
777
|
+
* to: new Date(2023, 5, 8),
|
|
778
|
+
* networks: [ChainId.POLYGON_MUMBAI]
|
|
779
|
+
* };
|
|
780
|
+
* const escrowDatas = await EscrowUtils.getEscrows(filters);
|
|
781
|
+
* ```
|
|
226
782
|
*/
|
|
227
783
|
static getEscrows(filter: IEscrowsFilter): Promise<EscrowData[]>;
|
|
228
784
|
/**
|
|
229
|
-
*
|
|
785
|
+
* This function returns the escrow data for a given address.
|
|
786
|
+
*
|
|
787
|
+
* > This uses Subgraph
|
|
788
|
+
*
|
|
789
|
+
* **Input parameters**
|
|
790
|
+
*
|
|
791
|
+
* ```ts
|
|
792
|
+
* enum ChainId {
|
|
793
|
+
* ALL = -1,
|
|
794
|
+
* MAINNET = 1,
|
|
795
|
+
* RINKEBY = 4,
|
|
796
|
+
* GOERLI = 5,
|
|
797
|
+
* BSC_MAINNET = 56,
|
|
798
|
+
* BSC_TESTNET = 97,
|
|
799
|
+
* POLYGON = 137,
|
|
800
|
+
* POLYGON_MUMBAI = 80001,
|
|
801
|
+
* MOONBEAM = 1284,
|
|
802
|
+
* MOONBASE_ALPHA = 1287,
|
|
803
|
+
* AVALANCHE = 43114,
|
|
804
|
+
* AVALANCHE_TESTNET = 43113,
|
|
805
|
+
* SKALE = 1273227453,
|
|
806
|
+
* LOCALHOST = 1338,
|
|
807
|
+
* }
|
|
808
|
+
* ```
|
|
809
|
+
*
|
|
810
|
+
* ```ts
|
|
811
|
+
* type EscrowData = {
|
|
812
|
+
* id: string;
|
|
813
|
+
* address: string;
|
|
814
|
+
* amountPaid: string;
|
|
815
|
+
* balance: string;
|
|
816
|
+
* count: string;
|
|
817
|
+
* jobRequesterId: string;
|
|
818
|
+
* factoryAddress: string;
|
|
819
|
+
* finalResultsUrl?: string;
|
|
820
|
+
* intermediateResultsUrl?: string;
|
|
821
|
+
* launcher: string;
|
|
822
|
+
* manifestHash?: string;
|
|
823
|
+
* manifestUrl?: string;
|
|
824
|
+
* recordingOracle?: string;
|
|
825
|
+
* recordingOracleFee?: string;
|
|
826
|
+
* reputationOracle?: string;
|
|
827
|
+
* reputationOracleFee?: string;
|
|
828
|
+
* exchangeOracle?: string;
|
|
829
|
+
* exchangeOracleFee?: string;
|
|
830
|
+
* status: EscrowStatus;
|
|
831
|
+
* token: string;
|
|
832
|
+
* totalFundedAmount: string;
|
|
833
|
+
* createdAt: string;
|
|
834
|
+
* };
|
|
835
|
+
* ```
|
|
836
|
+
*
|
|
837
|
+
*
|
|
838
|
+
* @param {ChainId} chainId Network in which the escrow has been deployed
|
|
839
|
+
* @param {string} escrowAddress Address of the escrow
|
|
840
|
+
* @returns {EscrowData} Escrow data
|
|
841
|
+
*
|
|
842
|
+
* **Code example**
|
|
843
|
+
*
|
|
844
|
+
* ```ts
|
|
845
|
+
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
230
846
|
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
* @returns {Promise<EscrowData>}
|
|
234
|
-
* @throws {Error} - An error object if an error occurred.
|
|
847
|
+
* const escrowData = new EscrowUtils.getEscrow(ChainId.POLYGON_MUMBAI, "0x1234567890123456789012345678901234567890");
|
|
848
|
+
* ```
|
|
235
849
|
*/
|
|
236
850
|
static getEscrow(chainId: ChainId, escrowAddress: string): Promise<EscrowData>;
|
|
237
851
|
}
|