@human-protocol/sdk 5.2.0 → 6.0.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/base.d.ts +4 -5
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +4 -5
- package/dist/constants.js +6 -6
- package/dist/encryption.d.ts +68 -203
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +66 -202
- package/dist/error.d.ts +0 -24
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -26
- package/dist/escrow.d.ts +427 -780
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +314 -684
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +3 -1
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/kvstore.d.ts +119 -181
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +119 -182
- package/dist/operator.d.ts +59 -30
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +59 -30
- package/dist/staking.d.ts +135 -134
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +135 -134
- package/dist/statistics.d.ts +104 -134
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +119 -144
- package/dist/transaction.d.ts +36 -15
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +36 -15
- package/dist/types.d.ts +0 -54
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +31 -17
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +31 -17
- package/dist/worker.d.ts +35 -14
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +35 -14
- package/package.json +7 -24
- package/src/base.ts +4 -5
- package/src/constants.ts +6 -6
- package/src/encryption.ts +69 -203
- package/src/error.ts +0 -36
- package/src/escrow.ts +425 -780
- package/src/graphql/queries/operator.ts +3 -1
- package/src/graphql/types.ts +4 -2
- package/src/index.ts +4 -5
- package/src/kvstore.ts +120 -183
- package/src/operator.ts +59 -30
- package/src/staking.ts +135 -134
- package/src/statistics.ts +125 -146
- package/src/transaction.ts +36 -15
- package/src/types.ts +0 -57
- package/src/utils.ts +31 -17
- package/src/worker.ts +35 -14
- package/dist/storage.d.ts +0 -186
- package/dist/storage.d.ts.map +0 -1
- package/dist/storage.js +0 -319
- package/src/storage.ts +0 -313
package/dist/escrow.d.ts
CHANGED
|
@@ -1,94 +1,76 @@
|
|
|
1
|
+
import { EscrowFactory } from '@human-protocol/core/typechain-types';
|
|
1
2
|
import { ContractRunner, Overrides } from 'ethers';
|
|
2
3
|
import { BaseEthersClient } from './base';
|
|
3
4
|
import { ChainId } from './enums';
|
|
4
5
|
import { IEscrow, IEscrowConfig, IEscrowsFilter, IPayoutFilter, IStatusEventFilter, IStatusEvent, ICancellationRefund, ICancellationRefundFilter, IPayout, IEscrowWithdraw, SubgraphOptions } from './interfaces';
|
|
5
6
|
import { EscrowStatus, NetworkData, TransactionLikeWithNonce } from './types';
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* This client enables performing actions on Escrow contracts and obtaining information from both the contracts and subgraph.
|
|
8
|
+
* Client to perform actions on Escrow contracts and obtain information from the contracts.
|
|
10
9
|
*
|
|
11
10
|
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
12
|
-
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* static async build(runner: ContractRunner): Promise<EscrowClient>;
|
|
16
|
-
* ```
|
|
11
|
+
* To use this client, it is recommended to initialize it using the static [`build`](/ts/classes/EscrowClient/#build) method.
|
|
17
12
|
*
|
|
18
13
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
19
14
|
*
|
|
20
15
|
* - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
|
|
21
16
|
* - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
|
|
22
17
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* ### npm
|
|
26
|
-
* ```bash
|
|
27
|
-
* npm install @human-protocol/sdk
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* ### yarn
|
|
31
|
-
* ```bash
|
|
32
|
-
* yarn install @human-protocol/sdk
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* ## Code example
|
|
18
|
+
* @example
|
|
36
19
|
*
|
|
37
|
-
* ### Signer
|
|
20
|
+
* ###Using Signer
|
|
38
21
|
*
|
|
39
|
-
*
|
|
22
|
+
* ####Using private key (backend)
|
|
40
23
|
*
|
|
41
24
|
* ```ts
|
|
42
25
|
* import { EscrowClient } from '@human-protocol/sdk';
|
|
43
|
-
* import { Wallet,
|
|
26
|
+
* import { Wallet, JsonRpcProvider } from 'ethers';
|
|
44
27
|
*
|
|
45
28
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
46
29
|
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
47
30
|
*
|
|
48
|
-
* const provider = new
|
|
31
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
49
32
|
* const signer = new Wallet(privateKey, provider);
|
|
50
33
|
* const escrowClient = await EscrowClient.build(signer);
|
|
51
34
|
* ```
|
|
52
35
|
*
|
|
53
|
-
*
|
|
36
|
+
* ####Using Wagmi (frontend)
|
|
54
37
|
*
|
|
55
38
|
* ```ts
|
|
56
|
-
* import { useSigner
|
|
39
|
+
* import { useSigner } from 'wagmi';
|
|
57
40
|
* import { EscrowClient } from '@human-protocol/sdk';
|
|
58
41
|
*
|
|
59
42
|
* const { data: signer } = useSigner();
|
|
60
43
|
* const escrowClient = await EscrowClient.build(signer);
|
|
61
44
|
* ```
|
|
62
45
|
*
|
|
63
|
-
* ### Provider
|
|
46
|
+
* ###Using Provider
|
|
64
47
|
*
|
|
65
48
|
* ```ts
|
|
66
49
|
* import { EscrowClient } from '@human-protocol/sdk';
|
|
67
|
-
* import {
|
|
50
|
+
* import { JsonRpcProvider } from 'ethers';
|
|
68
51
|
*
|
|
69
52
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
70
|
-
*
|
|
71
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
53
|
+
* const provider = new JsonRpcProvider(rpcUrl);
|
|
72
54
|
* const escrowClient = await EscrowClient.build(provider);
|
|
73
55
|
* ```
|
|
74
56
|
*/
|
|
75
57
|
export declare class EscrowClient extends BaseEthersClient {
|
|
76
|
-
|
|
58
|
+
escrowFactoryContract: EscrowFactory;
|
|
77
59
|
/**
|
|
78
60
|
* **EscrowClient constructor**
|
|
79
61
|
*
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
62
|
+
* @param runner - The Runner object to interact with the Ethereum network
|
|
63
|
+
* @param networkData - The network information required to connect to the Escrow contract
|
|
64
|
+
* @returns An instance of EscrowClient
|
|
82
65
|
*/
|
|
83
66
|
constructor(runner: ContractRunner, networkData: NetworkData);
|
|
84
67
|
/**
|
|
85
68
|
* Creates an instance of EscrowClient from a Runner.
|
|
86
69
|
*
|
|
87
|
-
* @param
|
|
88
|
-
*
|
|
89
|
-
* @
|
|
90
|
-
* @throws
|
|
91
|
-
* @throws {ErrorUnsupportedChainID} Thrown if the network's chainId is not supported
|
|
70
|
+
* @param runner - The Runner object to interact with the Ethereum network
|
|
71
|
+
* @returns An instance of EscrowClient
|
|
72
|
+
* @throws ErrorProviderDoesNotExist If the provider does not exist for the provided Signer
|
|
73
|
+
* @throws ErrorUnsupportedChainID If the network's chainId is not supported
|
|
92
74
|
*/
|
|
93
75
|
static build(runner: ContractRunner): Promise<EscrowClient>;
|
|
94
76
|
/**
|
|
@@ -99,28 +81,17 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
99
81
|
private getEscrowContract;
|
|
100
82
|
/**
|
|
101
83
|
* This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
|
|
84
|
+
* @remarks Need to have available stake.
|
|
85
|
+
* @param tokenAddress - The address of the token to use for escrow funding.
|
|
86
|
+
* @param jobRequesterId - Identifier for the job requester.
|
|
87
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
88
|
+
* @returns Returns the address of the escrow created.
|
|
89
|
+
* @throws ErrorInvalidTokenAddress If the token address is invalid
|
|
90
|
+
* @throws ErrorLaunchedEventIsNotEmitted If the LaunchedV2 event is not emitted
|
|
102
91
|
*
|
|
103
|
-
* @
|
|
104
|
-
* @param {string} jobRequesterId - Identifier for the job requester.
|
|
105
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
106
|
-
* @returns {Promise<string>} Returns the address of the escrow created.
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* **Code example**
|
|
110
|
-
*
|
|
111
|
-
* > Need to have available stake.
|
|
92
|
+
* @example
|
|
112
93
|
*
|
|
113
94
|
* ```ts
|
|
114
|
-
* import { Wallet, providers } from 'ethers';
|
|
115
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
116
|
-
*
|
|
117
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
118
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
119
|
-
*
|
|
120
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
121
|
-
* const signer = new Wallet(privateKey, provider);
|
|
122
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
123
|
-
*
|
|
124
95
|
* const tokenAddress = '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4';
|
|
125
96
|
* const jobRequesterId = "job-requester-id";
|
|
126
97
|
* const escrowAddress = await escrowClient.createEscrow(tokenAddress, jobRequesterId);
|
|
@@ -131,50 +102,45 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
131
102
|
/**
|
|
132
103
|
* Creates, funds, and sets up a new escrow contract in a single transaction.
|
|
133
104
|
*
|
|
134
|
-
* @
|
|
135
|
-
* @param
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* @
|
|
147
|
-
*
|
|
148
|
-
* @
|
|
105
|
+
* @remarks Need to have available stake and approve allowance in the token contract before calling this method.
|
|
106
|
+
* @param tokenAddress - The ERC-20 token address used to fund the escrow.
|
|
107
|
+
* @param amount - The token amount to fund the escrow with.
|
|
108
|
+
* @param jobRequesterId - An off-chain identifier for the job requester.
|
|
109
|
+
* @param escrowConfig - Configuration parameters for escrow setup.
|
|
110
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
111
|
+
* @returns Returns the address of the escrow created.
|
|
112
|
+
* @throws ErrorInvalidTokenAddress If the token address is invalid
|
|
113
|
+
* @throws ErrorInvalidRecordingOracleAddressProvided If the recording oracle address is invalid
|
|
114
|
+
* @throws ErrorInvalidReputationOracleAddressProvided If the reputation oracle address is invalid
|
|
115
|
+
* @throws ErrorInvalidExchangeOracleAddressProvided If the exchange oracle address is invalid
|
|
116
|
+
* @throws ErrorAmountMustBeGreaterThanZero If any oracle fee is less than or equal to zero
|
|
117
|
+
* @throws ErrorTotalFeeMustBeLessThanHundred If the total oracle fees exceed 100
|
|
118
|
+
* @throws ErrorInvalidManifest If the manifest is not a valid URL or JSON string
|
|
119
|
+
* @throws ErrorHashIsEmptyString If the manifest hash is empty
|
|
120
|
+
* @throws ErrorLaunchedEventIsNotEmitted If the LaunchedV2 event is not emitted
|
|
149
121
|
*
|
|
150
122
|
* @example
|
|
151
|
-
*
|
|
152
|
-
* import {
|
|
153
|
-
*
|
|
154
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
155
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
156
|
-
* const provider = new ethers.JsonRpcProvider(rpcUrl);
|
|
157
|
-
* const signer = new Wallet(privateKey, provider);
|
|
158
|
-
*
|
|
159
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { ethers } from 'ethers';
|
|
125
|
+
* import { ERC20__factory } from '@human-protocol/sdk';
|
|
160
126
|
*
|
|
161
|
-
* const tokenAddress = '
|
|
127
|
+
* const tokenAddress = '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4';
|
|
162
128
|
* const amount = ethers.parseUnits('1000', 18);
|
|
163
129
|
* const jobRequesterId = 'requester-123';
|
|
164
130
|
*
|
|
165
|
-
* const token =
|
|
131
|
+
* const token = ERC20__factory.connect(tokenAddress, signer);
|
|
166
132
|
* await token.approve(escrowClient.escrowFactoryContract.target, amount);
|
|
167
133
|
*
|
|
168
134
|
* const escrowConfig = {
|
|
169
|
-
* recordingOracle: '
|
|
170
|
-
* reputationOracle: '
|
|
171
|
-
* exchangeOracle: '
|
|
135
|
+
* recordingOracle: '0xRecordingOracleAddress',
|
|
136
|
+
* reputationOracle: '0xReputationOracleAddress',
|
|
137
|
+
* exchangeOracle: '0xExchangeOracleAddress',
|
|
172
138
|
* recordingOracleFee: 5n,
|
|
173
139
|
* reputationOracleFee: 5n,
|
|
174
140
|
* exchangeOracleFee: 5n,
|
|
175
141
|
* manifest: 'https://example.com/manifest.json',
|
|
176
142
|
* manifestHash: 'manifestHash-123',
|
|
177
|
-
* }
|
|
143
|
+
* };
|
|
178
144
|
*
|
|
179
145
|
* const escrowAddress = await escrowClient.createFundAndSetupEscrow(
|
|
180
146
|
* tokenAddress,
|
|
@@ -182,42 +148,40 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
182
148
|
* jobRequesterId,
|
|
183
149
|
* escrowConfig
|
|
184
150
|
* );
|
|
185
|
-
*
|
|
186
151
|
* console.log('Escrow created at:', escrowAddress);
|
|
152
|
+
* ```
|
|
187
153
|
*/
|
|
188
154
|
createFundAndSetupEscrow(tokenAddress: string, amount: bigint, jobRequesterId: string, escrowConfig: IEscrowConfig, txOptions?: Overrides): Promise<string>;
|
|
189
155
|
/**
|
|
190
156
|
* This function sets up the parameters of the escrow.
|
|
191
157
|
*
|
|
192
|
-
* @
|
|
193
|
-
*
|
|
194
|
-
* @param
|
|
195
|
-
* @
|
|
158
|
+
* @remarks Only Job Launcher or admin can call it.
|
|
159
|
+
*
|
|
160
|
+
* @param escrowAddress - Address of the escrow to set up.
|
|
161
|
+
* @param escrowConfig - Escrow configuration parameters.
|
|
162
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
163
|
+
* @returns -
|
|
164
|
+
* @throws ErrorInvalidRecordingOracleAddressProvided If the recording oracle address is invalid
|
|
165
|
+
* @throws ErrorInvalidReputationOracleAddressProvided If the reputation oracle address is invalid
|
|
166
|
+
* @throws ErrorInvalidExchangeOracleAddressProvided If the exchange oracle address is invalid
|
|
167
|
+
* @throws ErrorAmountMustBeGreaterThanZero If any oracle fee is less than or equal to zero
|
|
168
|
+
* @throws ErrorTotalFeeMustBeLessThanHundred If the total oracle fees exceed 100
|
|
169
|
+
* @throws ErrorInvalidManifest If the manifest is not a valid URL or JSON string
|
|
170
|
+
* @throws ErrorHashIsEmptyString If the manifest hash is empty
|
|
171
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
172
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
196
173
|
*
|
|
197
|
-
*
|
|
198
|
-
* **Code example**
|
|
199
|
-
*
|
|
200
|
-
* > Only Job Launcher or admin can call it.
|
|
174
|
+
* @example
|
|
201
175
|
*
|
|
202
176
|
* ```ts
|
|
203
|
-
* import { Wallet, providers } from 'ethers';
|
|
204
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
205
|
-
*
|
|
206
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
207
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
208
|
-
*
|
|
209
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
210
|
-
* const signer = new Wallet(privateKey, provider);
|
|
211
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
212
|
-
*
|
|
213
177
|
* const escrowAddress = '0x62dD51230A30401C455c8398d06F85e4EaB6309f';
|
|
214
178
|
* const escrowConfig = {
|
|
215
179
|
* recordingOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
216
180
|
* reputationOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
217
181
|
* exchangeOracle: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
218
|
-
* recordingOracleFee:
|
|
219
|
-
* reputationOracleFee:
|
|
220
|
-
* exchangeOracleFee:
|
|
182
|
+
* recordingOracleFee: 10n,
|
|
183
|
+
* reputationOracleFee: 10n,
|
|
184
|
+
* exchangeOracleFee: 10n,
|
|
221
185
|
* manifest: 'http://localhost/manifest.json',
|
|
222
186
|
* manifestHash: 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079',
|
|
223
187
|
* };
|
|
@@ -228,748 +192,549 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
228
192
|
/**
|
|
229
193
|
* This function adds funds of the chosen token to the escrow.
|
|
230
194
|
*
|
|
231
|
-
* @param
|
|
232
|
-
* @param
|
|
233
|
-
* @param
|
|
234
|
-
* @returns
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
195
|
+
* @param escrowAddress - Address of the escrow to fund.
|
|
196
|
+
* @param amount - Amount to be added as funds.
|
|
197
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
198
|
+
* @returns -
|
|
199
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
200
|
+
* @throws ErrorAmountMustBeGreaterThanZero If the amount is less than or equal to zero
|
|
201
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
238
202
|
*
|
|
203
|
+
* @example
|
|
239
204
|
* ```ts
|
|
240
|
-
* import { ethers
|
|
241
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
242
|
-
*
|
|
243
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
244
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
245
|
-
*
|
|
246
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
247
|
-
* const signer = new Wallet(privateKey, provider);
|
|
248
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
205
|
+
* import { ethers } from 'ethers';
|
|
249
206
|
*
|
|
250
|
-
* const amount = ethers.parseUnits(5, 'ether');
|
|
207
|
+
* const amount = ethers.parseUnits('5', 'ether');
|
|
251
208
|
* await escrowClient.fund('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
252
209
|
* ```
|
|
253
210
|
*/
|
|
254
211
|
fund(escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
255
212
|
/**
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* @param {string} escrowAddress Address of the escrow.
|
|
259
|
-
* @param {string} url Results file URL.
|
|
260
|
-
* @param {string} hash Results file hash.
|
|
261
|
-
* @param {bigint} fundsToReserve Funds to reserve for payouts
|
|
262
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
263
|
-
* @returns Returns void if successful. Throws error if any.
|
|
264
|
-
*
|
|
213
|
+
* Stores the result URL and result hash for an escrow.
|
|
265
214
|
*
|
|
266
|
-
*
|
|
215
|
+
* @remarks Only Recording Oracle or admin can call it.
|
|
267
216
|
*
|
|
268
|
-
*
|
|
217
|
+
* @param escrowAddress - The escrow address.
|
|
218
|
+
* @param url - The URL containing the final results. May be empty only when `fundsToReserve` is `0n`.
|
|
219
|
+
* @param hash - The hash of the results payload.
|
|
220
|
+
* @param txOptions - Optional transaction overrides.
|
|
221
|
+
* @returns -
|
|
222
|
+
* @throws ErrorInvalidEscrowAddressProvided If the provided escrow address is invalid.
|
|
223
|
+
* @throws ErrorInvalidUrl If the URL format is invalid.
|
|
224
|
+
* @throws ErrorHashIsEmptyString If the hash is empty and empty values are not allowed.
|
|
225
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow does not exist in the factory.
|
|
226
|
+
* @throws ErrorStoreResultsVersion If the contract supports only the deprecated signature.
|
|
269
227
|
*
|
|
228
|
+
* @example
|
|
270
229
|
* ```ts
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
278
|
-
* const signer = new Wallet(privateKey, provider);
|
|
279
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
280
|
-
*
|
|
281
|
-
* await escrowClient.storeResults('0x62dD51230A30401C455c8398d06F85e4EaB6309f', 'http://localhost/results.json', 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079', ethers.parseEther('10'));
|
|
230
|
+
* await escrowClient.storeResults(
|
|
231
|
+
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
232
|
+
* 'https://example.com/results.json',
|
|
233
|
+
* '0xHASH123'
|
|
234
|
+
* );
|
|
282
235
|
* ```
|
|
283
236
|
*/
|
|
284
|
-
storeResults(escrowAddress: string, url: string, hash: string,
|
|
237
|
+
storeResults(escrowAddress: string, url: string, hash: string, txOptions?: Overrides): Promise<void>;
|
|
285
238
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* @param {string} escrowAddress Address of the escrow.
|
|
289
|
-
* @param {string} url Results file URL.
|
|
290
|
-
* @param {string} hash Results file hash.
|
|
291
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
292
|
-
* @returns Returns void if successful. Throws error if any.
|
|
239
|
+
* Stores the result URL and result hash for an escrow.
|
|
293
240
|
*
|
|
241
|
+
* @remarks Only Recording Oracle or admin can call it.
|
|
294
242
|
*
|
|
295
|
-
*
|
|
243
|
+
* If `fundsToReserve` is provided, the escrow reserves the specified funds.
|
|
244
|
+
* When `fundsToReserve` is `0n`, an empty URL is allowed (for cases where no solutions were provided).
|
|
296
245
|
*
|
|
297
|
-
*
|
|
246
|
+
* @param escrowAddress - The escrow address.
|
|
247
|
+
* @param url - The URL containing the final results. May be empty only when `fundsToReserve` is `0n`.
|
|
248
|
+
* @param hash - The hash of the results payload.
|
|
249
|
+
* @param fundsToReserve - Optional amount of funds to reserve (when using second overload).
|
|
250
|
+
* @param txOptions - Optional transaction overrides.
|
|
251
|
+
* @returns -
|
|
252
|
+
* @throws ErrorInvalidEscrowAddressProvided If the provided escrow address is invalid.
|
|
253
|
+
* @throws ErrorInvalidUrl If the URL format is invalid.
|
|
254
|
+
* @throws ErrorHashIsEmptyString If the hash is empty and empty values are not allowed.
|
|
255
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow does not exist in the factory.
|
|
256
|
+
* @throws ErrorStoreResultsVersion If the contract supports only the deprecated signature.
|
|
298
257
|
*
|
|
258
|
+
* @example
|
|
299
259
|
* ```ts
|
|
300
|
-
* import { ethers
|
|
301
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
302
|
-
*
|
|
303
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
304
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
260
|
+
* import { ethers } from 'ethers';
|
|
305
261
|
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
262
|
+
* await escrowClient.storeResults(
|
|
263
|
+
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
264
|
+
* 'https://example.com/results.json',
|
|
265
|
+
* '0xHASH123',
|
|
266
|
+
* ethers.parseEther('5')
|
|
267
|
+
* );
|
|
311
268
|
* ```
|
|
312
269
|
*/
|
|
313
|
-
storeResults(escrowAddress: string, url: string, hash: string, txOptions?: Overrides): Promise<void>;
|
|
270
|
+
storeResults(escrowAddress: string, url: string, hash: string, fundsToReserve: bigint, txOptions?: Overrides): Promise<void>;
|
|
314
271
|
/**
|
|
315
272
|
* This function sets the status of an escrow to completed.
|
|
273
|
+
* @remarks Only Recording Oracle or admin can call it.
|
|
274
|
+
* @param escrowAddress - Address of the escrow.
|
|
275
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
276
|
+
* @returns -
|
|
277
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid.
|
|
278
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory.
|
|
316
279
|
*
|
|
317
|
-
* @
|
|
318
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
319
|
-
* @returns Returns void if successful. Throws error if any.
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
* **Code example**
|
|
323
|
-
*
|
|
324
|
-
* > Only Recording Oracle or admin can call it.
|
|
325
|
-
*
|
|
280
|
+
* @example
|
|
326
281
|
* ```ts
|
|
327
|
-
* import { Wallet, providers } from 'ethers';
|
|
328
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
329
|
-
*
|
|
330
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
331
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
332
|
-
*
|
|
333
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
334
|
-
* const signer = new Wallet(privateKey, provider);
|
|
335
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
336
|
-
*
|
|
337
282
|
* await escrowClient.complete('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
338
283
|
* ```
|
|
339
284
|
*/
|
|
340
285
|
complete(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
341
286
|
/**
|
|
342
287
|
* This function pays out the amounts specified to the workers and sets the URL of the final results file.
|
|
288
|
+
* @remarks Only Reputation Oracle or admin can call it.
|
|
289
|
+
*
|
|
290
|
+
* @param escrowAddress - Escrow address to payout.
|
|
291
|
+
* @param recipients - Array of recipient addresses.
|
|
292
|
+
* @param amounts - Array of amounts the recipients will receive.
|
|
293
|
+
* @param finalResultsUrl - Final results file URL.
|
|
294
|
+
* @param finalResultsHash - Final results file hash.
|
|
295
|
+
* @param txId - Transaction ID.
|
|
296
|
+
* @param forceComplete - Indicates if remaining balance should be transferred to the escrow creator (optional, defaults to false).
|
|
297
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
298
|
+
* @returns -
|
|
299
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
300
|
+
* @throws ErrorRecipientCannotBeEmptyArray If the recipients array is empty
|
|
301
|
+
* @throws ErrorTooManyRecipients If there are too many recipients
|
|
302
|
+
* @throws ErrorAmountsCannotBeEmptyArray If the amounts array is empty
|
|
303
|
+
* @throws ErrorRecipientAndAmountsMustBeSameLength If recipients and amounts arrays have different lengths
|
|
304
|
+
* @throws InvalidEthereumAddressError If any recipient address is invalid
|
|
305
|
+
* @throws ErrorInvalidUrl If the final results URL is invalid
|
|
306
|
+
* @throws ErrorHashIsEmptyString If the final results hash is empty
|
|
307
|
+
* @throws ErrorEscrowDoesNotHaveEnoughBalance If the escrow doesn't have enough balance
|
|
308
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
309
|
+
* @throws ErrorBulkPayOutVersion If using deprecated signature
|
|
343
310
|
*
|
|
344
|
-
* @
|
|
345
|
-
* @param {string[]} recipients Array of recipient addresses.
|
|
346
|
-
* @param {bigint[]} amounts Array of amounts the recipients will receive.
|
|
347
|
-
* @param {string} finalResultsUrl Final results file URL.
|
|
348
|
-
* @param {string} finalResultsHash Final results file hash.
|
|
349
|
-
* @param {number} txId Transaction ID.
|
|
350
|
-
* @param {boolean} forceComplete Indicates if remaining balance should be transferred to the escrow creator (optional, defaults to false).
|
|
351
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
352
|
-
* @returns Returns void if successful. Throws error if any.
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* **Code example**
|
|
356
|
-
*
|
|
357
|
-
* > Only Reputation Oracle or admin can call it.
|
|
358
|
-
*
|
|
311
|
+
* @example
|
|
359
312
|
* ```ts
|
|
360
|
-
* import { ethers
|
|
361
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
362
|
-
*
|
|
363
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
364
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
313
|
+
* import { ethers } from 'ethers';
|
|
365
314
|
*
|
|
366
|
-
* const
|
|
367
|
-
* const
|
|
368
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
369
|
-
*
|
|
370
|
-
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
|
|
371
|
-
* const amounts = [ethers.parseUnits(5, 'ether'), ethers.parseUnits(10, 'ether')];
|
|
315
|
+
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x70997970C51812dc3A010C7d01b50e0d17dc79C8'];
|
|
316
|
+
* const amounts = [ethers.parseUnits('5', 'ether'), ethers.parseUnits('10', 'ether')];
|
|
372
317
|
* const resultsUrl = 'http://localhost/results.json';
|
|
373
318
|
* const resultsHash = 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079';
|
|
374
319
|
* const txId = 1;
|
|
375
320
|
*
|
|
376
|
-
* await escrowClient.bulkPayOut(
|
|
321
|
+
* await escrowClient.bulkPayOut(
|
|
322
|
+
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
323
|
+
* recipients,
|
|
324
|
+
* amounts,
|
|
325
|
+
* resultsUrl,
|
|
326
|
+
* resultsHash,
|
|
327
|
+
* txId,
|
|
328
|
+
* true
|
|
329
|
+
* );
|
|
377
330
|
* ```
|
|
378
331
|
*/
|
|
379
332
|
bulkPayOut(escrowAddress: string, recipients: string[], amounts: bigint[], finalResultsUrl: string, finalResultsHash: string, txId: number, forceComplete: boolean, txOptions: Overrides): Promise<void>;
|
|
380
333
|
/**
|
|
381
334
|
* This function pays out the amounts specified to the workers and sets the URL of the final results file.
|
|
335
|
+
* @remarks Only Reputation Oracle or admin can call it.
|
|
336
|
+
* @param escrowAddress - Escrow address to payout.
|
|
337
|
+
* @param recipients - Array of recipient addresses.
|
|
338
|
+
* @param amounts - Array of amounts the recipients will receive.
|
|
339
|
+
* @param finalResultsUrl - Final results file URL.
|
|
340
|
+
* @param finalResultsHash - Final results file hash.
|
|
341
|
+
* @param payoutId - Payout ID.
|
|
342
|
+
* @param forceComplete - Indicates if remaining balance should be transferred to the escrow creator (optional, defaults to false).
|
|
343
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
344
|
+
* @returns -
|
|
345
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
346
|
+
* @throws ErrorRecipientCannotBeEmptyArray If the recipients array is empty
|
|
347
|
+
* @throws ErrorTooManyRecipients If there are too many recipients
|
|
348
|
+
* @throws ErrorAmountsCannotBeEmptyArray If the amounts array is empty
|
|
349
|
+
* @throws ErrorRecipientAndAmountsMustBeSameLength If recipients and amounts arrays have different lengths
|
|
350
|
+
* @throws InvalidEthereumAddressError If any recipient address is invalid
|
|
351
|
+
* @throws ErrorInvalidUrl If the final results URL is invalid
|
|
352
|
+
* @throws ErrorHashIsEmptyString If the final results hash is empty
|
|
353
|
+
* @throws ErrorEscrowDoesNotHaveEnoughBalance If the escrow doesn't have enough balance
|
|
354
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
355
|
+
* @throws ErrorBulkPayOutVersion If using deprecated signature
|
|
382
356
|
*
|
|
383
|
-
* @
|
|
384
|
-
* @param {string[]} recipients Array of recipient addresses.
|
|
385
|
-
* @param {bigint[]} amounts Array of amounts the recipients will receive.
|
|
386
|
-
* @param {string} finalResultsUrl Final results file URL.
|
|
387
|
-
* @param {string} finalResultsHash Final results file hash.
|
|
388
|
-
* @param {string} payoutId Payout ID.
|
|
389
|
-
* @param {boolean} forceComplete Indicates if remaining balance should be transferred to the escrow creator (optional, defaults to false).
|
|
390
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
391
|
-
* @returns Returns void if successful. Throws error if any.
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
* **Code example**
|
|
395
|
-
*
|
|
396
|
-
* > Only Reputation Oracle or admin can call it.
|
|
357
|
+
* @example
|
|
397
358
|
*
|
|
398
359
|
* ```ts
|
|
399
|
-
* import { ethers
|
|
400
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
360
|
+
* import { ethers } from 'ethers';
|
|
401
361
|
* import { v4 as uuidV4 } from 'uuid';
|
|
402
362
|
*
|
|
403
|
-
* const
|
|
404
|
-
* const
|
|
405
|
-
*
|
|
406
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
407
|
-
* const signer = new Wallet(privateKey, provider);
|
|
408
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
409
|
-
*
|
|
410
|
-
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'];
|
|
411
|
-
* const amounts = [ethers.parseUnits(5, 'ether'), ethers.parseUnits(10, 'ether')];
|
|
363
|
+
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x70997970C51812dc3A010C7d01b50e0d17dc79C8'];
|
|
364
|
+
* const amounts = [ethers.parseUnits('5', 'ether'), ethers.parseUnits('10', 'ether')];
|
|
412
365
|
* const resultsUrl = 'http://localhost/results.json';
|
|
413
366
|
* const resultsHash = 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079';
|
|
414
367
|
* const payoutId = uuidV4();
|
|
415
368
|
*
|
|
416
|
-
* await escrowClient.bulkPayOut(
|
|
369
|
+
* await escrowClient.bulkPayOut(
|
|
370
|
+
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
371
|
+
* recipients,
|
|
372
|
+
* amounts,
|
|
373
|
+
* resultsUrl,
|
|
374
|
+
* resultsHash,
|
|
375
|
+
* payoutId,
|
|
376
|
+
* true
|
|
377
|
+
* );
|
|
417
378
|
* ```
|
|
418
379
|
*/
|
|
419
380
|
bulkPayOut(escrowAddress: string, recipients: string[], amounts: bigint[], finalResultsUrl: string, finalResultsHash: string, payoutId: string, forceComplete: boolean, txOptions: Overrides): Promise<void>;
|
|
420
381
|
/**
|
|
421
382
|
* This function cancels the specified escrow and sends the balance to the canceler.
|
|
383
|
+
* @remarks Only Job Launcher or admin can call it.
|
|
384
|
+
* @param escrowAddress - Address of the escrow to cancel.
|
|
385
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
386
|
+
* @returns -
|
|
387
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
388
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
422
389
|
*
|
|
423
|
-
* @
|
|
424
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* **Code example**
|
|
428
|
-
*
|
|
429
|
-
* > Only Job Launcher or admin can call it.
|
|
390
|
+
* @example
|
|
430
391
|
*
|
|
431
392
|
* ```ts
|
|
432
|
-
* import { ethers, Wallet, providers } from 'ethers';
|
|
433
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
434
|
-
*
|
|
435
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
436
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
437
|
-
*
|
|
438
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
439
|
-
* const signer = new Wallet(privateKey, provider);
|
|
440
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
441
|
-
*
|
|
442
393
|
* await escrowClient.cancel('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
443
394
|
* ```
|
|
444
395
|
*/
|
|
445
396
|
cancel(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
446
397
|
/**
|
|
447
398
|
* This function requests the cancellation of the specified escrow (moves status to ToCancel or finalizes if expired).
|
|
399
|
+
* @remarks Only Job Launcher or admin can call it.
|
|
400
|
+
* @param escrowAddress - Address of the escrow to request cancellation.
|
|
401
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
402
|
+
* @returns -
|
|
403
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
404
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
448
405
|
*
|
|
449
|
-
* @
|
|
450
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
451
|
-
* @returns Returns void if successful. Throws error if any.
|
|
452
|
-
*
|
|
453
|
-
* **Code example**
|
|
454
|
-
*
|
|
455
|
-
* > Only Job Launcher or admin can call it.
|
|
406
|
+
* @example
|
|
456
407
|
*
|
|
457
408
|
* ```ts
|
|
458
|
-
* import { Wallet, providers } from 'ethers';
|
|
459
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
460
|
-
*
|
|
461
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
462
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
463
|
-
*
|
|
464
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
465
|
-
* const signer = new Wallet(privateKey, provider);
|
|
466
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
467
|
-
*
|
|
468
409
|
* await escrowClient.requestCancellation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
469
410
|
* ```
|
|
470
411
|
*/
|
|
471
412
|
requestCancellation(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
472
413
|
/**
|
|
473
414
|
* This function withdraws additional tokens in the escrow to the canceler.
|
|
415
|
+
* @remarks Only Job Launcher or admin can call it.
|
|
474
416
|
*
|
|
475
|
-
* @param
|
|
476
|
-
* @param
|
|
477
|
-
* @param
|
|
478
|
-
* @returns
|
|
479
|
-
*
|
|
417
|
+
* @param escrowAddress - Address of the escrow to withdraw.
|
|
418
|
+
* @param tokenAddress - Address of the token to withdraw.
|
|
419
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
420
|
+
* @returns Returns the escrow withdrawal data including transaction hash and withdrawal amount.
|
|
421
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
422
|
+
* @throws ErrorInvalidTokenAddress If the token address is invalid
|
|
423
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
424
|
+
* @throws ErrorTransferEventNotFoundInTransactionLogs If the Transfer event is not found in transaction logs
|
|
480
425
|
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
* > Only Job Launcher or admin can call it.
|
|
426
|
+
* @example
|
|
484
427
|
*
|
|
485
428
|
* ```ts
|
|
486
|
-
*
|
|
487
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
488
|
-
*
|
|
489
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
490
|
-
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
491
|
-
*
|
|
492
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
493
|
-
* const signer = new Wallet(privateKey, provider);
|
|
494
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
495
|
-
*
|
|
496
|
-
* await escrowClient.withdraw(
|
|
429
|
+
* const withdrawData = await escrowClient.withdraw(
|
|
497
430
|
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
498
431
|
* '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4'
|
|
499
432
|
* );
|
|
433
|
+
* console.log('Withdrawn amount:', withdrawData.withdrawnAmount);
|
|
500
434
|
* ```
|
|
501
435
|
*/
|
|
502
436
|
withdraw(escrowAddress: string, tokenAddress: string, txOptions?: Overrides): Promise<IEscrowWithdraw>;
|
|
503
437
|
/**
|
|
504
438
|
* Creates a prepared transaction for bulk payout without immediately sending it.
|
|
505
|
-
* @
|
|
506
|
-
*
|
|
507
|
-
* @param
|
|
508
|
-
* @param
|
|
509
|
-
* @param
|
|
510
|
-
* @param
|
|
511
|
-
* @param
|
|
512
|
-
* @param
|
|
513
|
-
* @
|
|
514
|
-
*
|
|
515
|
-
*
|
|
439
|
+
* @remarks Only Reputation Oracle or admin can call it.
|
|
440
|
+
*
|
|
441
|
+
* @param escrowAddress - Escrow address to payout.
|
|
442
|
+
* @param recipients - Array of recipient addresses.
|
|
443
|
+
* @param amounts - Array of amounts the recipients will receive.
|
|
444
|
+
* @param finalResultsUrl - Final results file URL.
|
|
445
|
+
* @param finalResultsHash - Final results file hash.
|
|
446
|
+
* @param payoutId - Payout ID to identify the payout.
|
|
447
|
+
* @param forceComplete - Indicates if remaining balance should be transferred to the escrow creator (optional, defaults to false).
|
|
448
|
+
* @param txOptions - Additional transaction parameters (optional, defaults to an empty object).
|
|
449
|
+
* @returns Returns object with raw transaction and nonce
|
|
450
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
451
|
+
* @throws ErrorRecipientCannotBeEmptyArray If the recipients array is empty
|
|
452
|
+
* @throws ErrorTooManyRecipients If there are too many recipients
|
|
453
|
+
* @throws ErrorAmountsCannotBeEmptyArray If the amounts array is empty
|
|
454
|
+
* @throws ErrorRecipientAndAmountsMustBeSameLength If recipients and amounts arrays have different lengths
|
|
455
|
+
* @throws InvalidEthereumAddressError If any recipient address is invalid
|
|
456
|
+
* @throws ErrorInvalidUrl If the final results URL is invalid
|
|
457
|
+
* @throws ErrorHashIsEmptyString If the final results hash is empty
|
|
458
|
+
* @throws ErrorEscrowDoesNotHaveEnoughBalance If the escrow doesn't have enough balance
|
|
459
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
516
460
|
*
|
|
517
|
-
*
|
|
461
|
+
* @example
|
|
518
462
|
*
|
|
519
463
|
* ```ts
|
|
520
|
-
* import { ethers
|
|
521
|
-
* import {
|
|
522
|
-
*
|
|
523
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
524
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
525
|
-
*
|
|
526
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
527
|
-
* const signer = new Wallet(privateKey, provider);
|
|
528
|
-
* const escrowClient = await EscrowClient.build(signer);
|
|
464
|
+
* import { ethers } from 'ethers';
|
|
465
|
+
* import { v4 as uuidV4 } from 'uuid';
|
|
529
466
|
*
|
|
530
|
-
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '
|
|
531
|
-
* const amounts = [ethers.parseUnits(5, 'ether'), ethers.parseUnits(10, 'ether')];
|
|
467
|
+
* const recipients = ['0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x70997970C51812dc3A010C7d01b50e0d17dc79C8'];
|
|
468
|
+
* const amounts = [ethers.parseUnits('5', 'ether'), ethers.parseUnits('10', 'ether')];
|
|
532
469
|
* const resultsUrl = 'http://localhost/results.json';
|
|
533
470
|
* const resultsHash = 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079';
|
|
534
|
-
* const payoutId =
|
|
471
|
+
* const payoutId = uuidV4();
|
|
535
472
|
*
|
|
536
|
-
* const rawTransaction = await escrowClient.createBulkPayoutTransaction(
|
|
473
|
+
* const rawTransaction = await escrowClient.createBulkPayoutTransaction(
|
|
474
|
+
* '0x62dD51230A30401C455c8398d06F85e4EaB6309f',
|
|
475
|
+
* recipients,
|
|
476
|
+
* amounts,
|
|
477
|
+
* resultsUrl,
|
|
478
|
+
* resultsHash,
|
|
479
|
+
* payoutId
|
|
480
|
+
* );
|
|
537
481
|
* console.log('Raw transaction:', rawTransaction);
|
|
538
482
|
*
|
|
539
483
|
* const signedTransaction = await signer.signTransaction(rawTransaction);
|
|
540
484
|
* console.log('Tx hash:', ethers.keccak256(signedTransaction));
|
|
541
|
-
*
|
|
485
|
+
* await signer.sendTransaction(rawTransaction);
|
|
486
|
+
* ```
|
|
542
487
|
*/
|
|
543
488
|
createBulkPayoutTransaction(escrowAddress: string, recipients: string[], amounts: bigint[], finalResultsUrl: string, finalResultsHash: string, payoutId: string, forceComplete?: boolean, txOptions?: Overrides): Promise<TransactionLikeWithNonce>;
|
|
544
489
|
private ensureCorrectBulkPayoutInput;
|
|
545
490
|
/**
|
|
546
491
|
* This function returns the balance for a specified escrow address.
|
|
547
492
|
*
|
|
548
|
-
* @param
|
|
549
|
-
* @returns
|
|
550
|
-
*
|
|
551
|
-
*
|
|
493
|
+
* @param escrowAddress - Address of the escrow.
|
|
494
|
+
* @returns Balance of the escrow in the token used to fund it.
|
|
495
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
496
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
552
497
|
*
|
|
498
|
+
* @example
|
|
553
499
|
* ```ts
|
|
554
|
-
* import { providers } from 'ethers';
|
|
555
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
556
|
-
*
|
|
557
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
558
|
-
*
|
|
559
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
560
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
561
|
-
*
|
|
562
500
|
* const balance = await escrowClient.getBalance('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
501
|
+
* console.log('Balance:', balance);
|
|
563
502
|
* ```
|
|
564
503
|
*/
|
|
565
504
|
getBalance(escrowAddress: string): Promise<bigint>;
|
|
566
505
|
/**
|
|
567
506
|
* This function returns the reserved funds for a specified escrow address.
|
|
568
507
|
*
|
|
569
|
-
* @param
|
|
570
|
-
* @returns
|
|
571
|
-
*
|
|
572
|
-
*
|
|
508
|
+
* @param escrowAddress - Address of the escrow.
|
|
509
|
+
* @returns Reserved funds of the escrow in the token used to fund it.
|
|
510
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
511
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
573
512
|
*
|
|
513
|
+
* @example
|
|
574
514
|
* ```ts
|
|
575
|
-
* import { providers } from 'ethers';
|
|
576
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
577
|
-
*
|
|
578
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
579
|
-
*
|
|
580
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
581
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
582
|
-
*
|
|
583
515
|
* const reservedFunds = await escrowClient.getReservedFunds('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
516
|
+
* console.log('Reserved funds:', reservedFunds);
|
|
584
517
|
* ```
|
|
585
518
|
*/
|
|
586
519
|
getReservedFunds(escrowAddress: string): Promise<bigint>;
|
|
587
520
|
/**
|
|
588
521
|
* This function returns the manifest file hash.
|
|
589
522
|
*
|
|
590
|
-
* @param
|
|
591
|
-
* @returns
|
|
592
|
-
*
|
|
593
|
-
*
|
|
523
|
+
* @param escrowAddress - Address of the escrow.
|
|
524
|
+
* @returns Hash of the manifest file content.
|
|
525
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
526
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
594
527
|
*
|
|
528
|
+
* @example
|
|
595
529
|
* ```ts
|
|
596
|
-
* import { providers } from 'ethers';
|
|
597
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
598
|
-
*
|
|
599
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
600
|
-
*
|
|
601
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
602
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
603
|
-
*
|
|
604
530
|
* const manifestHash = await escrowClient.getManifestHash('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
531
|
+
* console.log('Manifest hash:', manifestHash);
|
|
605
532
|
* ```
|
|
606
533
|
*/
|
|
607
534
|
getManifestHash(escrowAddress: string): Promise<string>;
|
|
608
535
|
/**
|
|
609
536
|
* This function returns the manifest. Could be a URL or a JSON string.
|
|
610
537
|
*
|
|
611
|
-
* @param
|
|
612
|
-
* @returns
|
|
613
|
-
*
|
|
614
|
-
*
|
|
538
|
+
* @param escrowAddress - Address of the escrow.
|
|
539
|
+
* @returns Manifest URL or JSON string.
|
|
540
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
541
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
615
542
|
*
|
|
543
|
+
* @example
|
|
616
544
|
* ```ts
|
|
617
|
-
* import { providers } from 'ethers';
|
|
618
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
619
|
-
*
|
|
620
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
621
|
-
*
|
|
622
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
623
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
624
|
-
*
|
|
625
545
|
* const manifest = await escrowClient.getManifest('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
546
|
+
* console.log('Manifest:', manifest);
|
|
626
547
|
* ```
|
|
627
548
|
*/
|
|
628
549
|
getManifest(escrowAddress: string): Promise<string>;
|
|
629
550
|
/**
|
|
630
551
|
* This function returns the results file URL.
|
|
631
552
|
*
|
|
632
|
-
* @param
|
|
633
|
-
* @returns
|
|
634
|
-
*
|
|
635
|
-
*
|
|
553
|
+
* @param escrowAddress - Address of the escrow.
|
|
554
|
+
* @returns Results file URL.
|
|
555
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
556
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
636
557
|
*
|
|
558
|
+
* @example
|
|
637
559
|
* ```ts
|
|
638
|
-
* import { providers } from 'ethers';
|
|
639
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
640
|
-
*
|
|
641
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
642
|
-
*
|
|
643
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
644
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
645
|
-
*
|
|
646
560
|
* const resultsUrl = await escrowClient.getResultsUrl('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
561
|
+
* console.log('Results URL:', resultsUrl);
|
|
647
562
|
* ```
|
|
648
563
|
*/
|
|
649
564
|
getResultsUrl(escrowAddress: string): Promise<string>;
|
|
650
565
|
/**
|
|
651
566
|
* This function returns the intermediate results file URL.
|
|
652
567
|
*
|
|
653
|
-
* @param
|
|
654
|
-
* @returns
|
|
655
|
-
*
|
|
656
|
-
*
|
|
568
|
+
* @param escrowAddress - Address of the escrow.
|
|
569
|
+
* @returns URL of the file that stores results from Recording Oracle.
|
|
570
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
571
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
657
572
|
*
|
|
573
|
+
* @example
|
|
658
574
|
* ```ts
|
|
659
|
-
* import { providers } from 'ethers';
|
|
660
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
661
|
-
*
|
|
662
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
663
|
-
*
|
|
664
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
665
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
666
|
-
*
|
|
667
575
|
* const intermediateResultsUrl = await escrowClient.getIntermediateResultsUrl('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
576
|
+
* console.log('Intermediate results URL:', intermediateResultsUrl);
|
|
668
577
|
* ```
|
|
669
578
|
*/
|
|
670
579
|
getIntermediateResultsUrl(escrowAddress: string): Promise<string>;
|
|
671
580
|
/**
|
|
672
581
|
* This function returns the intermediate results hash.
|
|
673
582
|
*
|
|
674
|
-
* @param
|
|
675
|
-
* @returns
|
|
676
|
-
*
|
|
677
|
-
*
|
|
583
|
+
* @param escrowAddress - Address of the escrow.
|
|
584
|
+
* @returns Hash of the intermediate results file content.
|
|
585
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
586
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
678
587
|
*
|
|
588
|
+
* @example
|
|
679
589
|
* ```ts
|
|
680
|
-
* import { providers } from 'ethers';
|
|
681
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
682
|
-
*
|
|
683
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
684
|
-
*
|
|
685
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
686
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
687
|
-
*
|
|
688
590
|
* const intermediateResultsHash = await escrowClient.getIntermediateResultsHash('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
591
|
+
* console.log('Intermediate results hash:', intermediateResultsHash);
|
|
689
592
|
* ```
|
|
690
593
|
*/
|
|
691
594
|
getIntermediateResultsHash(escrowAddress: string): Promise<string>;
|
|
692
595
|
/**
|
|
693
596
|
* This function returns the token address used for funding the escrow.
|
|
694
597
|
*
|
|
695
|
-
* @param
|
|
696
|
-
* @returns
|
|
697
|
-
*
|
|
698
|
-
*
|
|
598
|
+
* @param escrowAddress - Address of the escrow.
|
|
599
|
+
* @returns Address of the token used to fund the escrow.
|
|
600
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
601
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
699
602
|
*
|
|
603
|
+
* @example
|
|
700
604
|
* ```ts
|
|
701
|
-
* import { providers } from 'ethers';
|
|
702
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
703
|
-
*
|
|
704
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
705
|
-
*
|
|
706
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
707
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
708
|
-
*
|
|
709
605
|
* const tokenAddress = await escrowClient.getTokenAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
606
|
+
* console.log('Token address:', tokenAddress);
|
|
710
607
|
* ```
|
|
711
608
|
*/
|
|
712
609
|
getTokenAddress(escrowAddress: string): Promise<string>;
|
|
713
610
|
/**
|
|
714
611
|
* This function returns the current status of the escrow.
|
|
715
612
|
*
|
|
716
|
-
* @param
|
|
717
|
-
* @returns
|
|
718
|
-
*
|
|
719
|
-
*
|
|
613
|
+
* @param escrowAddress - Address of the escrow.
|
|
614
|
+
* @returns Current status of the escrow.
|
|
615
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
616
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
720
617
|
*
|
|
618
|
+
* @example
|
|
721
619
|
* ```ts
|
|
722
|
-
* import {
|
|
723
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
724
|
-
*
|
|
725
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
726
|
-
*
|
|
727
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
728
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
620
|
+
* import { EscrowStatus } from '@human-protocol/sdk';
|
|
729
621
|
*
|
|
730
622
|
* const status = await escrowClient.getStatus('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
623
|
+
* console.log('Status:', EscrowStatus[status]);
|
|
731
624
|
* ```
|
|
732
625
|
*/
|
|
733
626
|
getStatus(escrowAddress: string): Promise<EscrowStatus>;
|
|
734
627
|
/**
|
|
735
628
|
* This function returns the recording oracle address for a given escrow.
|
|
736
629
|
*
|
|
737
|
-
* @param
|
|
738
|
-
* @returns
|
|
739
|
-
*
|
|
740
|
-
*
|
|
630
|
+
* @param escrowAddress - Address of the escrow.
|
|
631
|
+
* @returns Address of the Recording Oracle.
|
|
632
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
633
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
741
634
|
*
|
|
635
|
+
* @example
|
|
742
636
|
* ```ts
|
|
743
|
-
* import { providers } from 'ethers';
|
|
744
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
745
|
-
*
|
|
746
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
747
|
-
*
|
|
748
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
749
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
750
|
-
*
|
|
751
637
|
* const oracleAddress = await escrowClient.getRecordingOracleAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
638
|
+
* console.log('Recording Oracle address:', oracleAddress);
|
|
752
639
|
* ```
|
|
753
640
|
*/
|
|
754
641
|
getRecordingOracleAddress(escrowAddress: string): Promise<string>;
|
|
755
642
|
/**
|
|
756
643
|
* This function returns the job launcher address for a given escrow.
|
|
757
644
|
*
|
|
758
|
-
* @param
|
|
759
|
-
* @returns
|
|
760
|
-
*
|
|
761
|
-
*
|
|
645
|
+
* @param escrowAddress - Address of the escrow.
|
|
646
|
+
* @returns Address of the Job Launcher.
|
|
647
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
648
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
762
649
|
*
|
|
650
|
+
* @example
|
|
763
651
|
* ```ts
|
|
764
|
-
* import { providers } from 'ethers';
|
|
765
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
766
|
-
*
|
|
767
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
768
|
-
*
|
|
769
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
770
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
771
|
-
*
|
|
772
652
|
* const jobLauncherAddress = await escrowClient.getJobLauncherAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
653
|
+
* console.log('Job Launcher address:', jobLauncherAddress);
|
|
773
654
|
* ```
|
|
774
655
|
*/
|
|
775
656
|
getJobLauncherAddress(escrowAddress: string): Promise<string>;
|
|
776
657
|
/**
|
|
777
658
|
* This function returns the reputation oracle address for a given escrow.
|
|
778
659
|
*
|
|
779
|
-
* @param
|
|
780
|
-
* @returns
|
|
781
|
-
*
|
|
782
|
-
*
|
|
660
|
+
* @param escrowAddress - Address of the escrow.
|
|
661
|
+
* @returns Address of the Reputation Oracle.
|
|
662
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
663
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
783
664
|
*
|
|
665
|
+
* @example
|
|
784
666
|
* ```ts
|
|
785
|
-
* import { providers } from 'ethers';
|
|
786
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
787
|
-
*
|
|
788
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
789
|
-
*
|
|
790
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
791
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
792
|
-
*
|
|
793
667
|
* const oracleAddress = await escrowClient.getReputationOracleAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
668
|
+
* console.log('Reputation Oracle address:', oracleAddress);
|
|
794
669
|
* ```
|
|
795
670
|
*/
|
|
796
671
|
getReputationOracleAddress(escrowAddress: string): Promise<string>;
|
|
797
672
|
/**
|
|
798
673
|
* This function returns the exchange oracle address for a given escrow.
|
|
799
674
|
*
|
|
800
|
-
* @param
|
|
801
|
-
* @returns
|
|
802
|
-
*
|
|
803
|
-
*
|
|
675
|
+
* @param escrowAddress - Address of the escrow.
|
|
676
|
+
* @returns Address of the Exchange Oracle.
|
|
677
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
678
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
804
679
|
*
|
|
680
|
+
* @example
|
|
805
681
|
* ```ts
|
|
806
|
-
* import { providers } from 'ethers';
|
|
807
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
808
|
-
*
|
|
809
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
810
|
-
*
|
|
811
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
812
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
813
|
-
*
|
|
814
682
|
* const oracleAddress = await escrowClient.getExchangeOracleAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
683
|
+
* console.log('Exchange Oracle address:', oracleAddress);
|
|
815
684
|
* ```
|
|
816
685
|
*/
|
|
817
686
|
getExchangeOracleAddress(escrowAddress: string): Promise<string>;
|
|
818
687
|
/**
|
|
819
688
|
* This function returns the escrow factory address for a given escrow.
|
|
820
689
|
*
|
|
821
|
-
* @param
|
|
822
|
-
* @returns
|
|
823
|
-
*
|
|
824
|
-
*
|
|
690
|
+
* @param escrowAddress - Address of the escrow.
|
|
691
|
+
* @returns Address of the escrow factory.
|
|
692
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
693
|
+
* @throws ErrorEscrowAddressIsNotProvidedByFactory If the escrow is not provided by the factory
|
|
825
694
|
*
|
|
695
|
+
* @example
|
|
826
696
|
* ```ts
|
|
827
|
-
* import { providers } from 'ethers';
|
|
828
|
-
* import { EscrowClient } from '@human-protocol/sdk';
|
|
829
|
-
*
|
|
830
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
831
|
-
*
|
|
832
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
833
|
-
* const escrowClient = await EscrowClient.build(provider);
|
|
834
|
-
*
|
|
835
697
|
* const factoryAddress = await escrowClient.getFactoryAddress('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
698
|
+
* console.log('Factory address:', factoryAddress);
|
|
836
699
|
* ```
|
|
837
700
|
*/
|
|
838
701
|
getFactoryAddress(escrowAddress: string): Promise<string>;
|
|
839
702
|
}
|
|
840
703
|
/**
|
|
841
|
-
*
|
|
842
|
-
*
|
|
843
|
-
* Utility class for escrow-related operations.
|
|
844
|
-
*
|
|
845
|
-
* ## Installation
|
|
846
|
-
*
|
|
847
|
-
* ### npm
|
|
848
|
-
* ```bash
|
|
849
|
-
* npm install @human-protocol/sdk
|
|
850
|
-
* ```
|
|
851
|
-
*
|
|
852
|
-
* ### yarn
|
|
853
|
-
* ```bash
|
|
854
|
-
* yarn install @human-protocol/sdk
|
|
855
|
-
* ```
|
|
856
|
-
*
|
|
857
|
-
* ## Code example
|
|
858
|
-
*
|
|
859
|
-
* ### Signer
|
|
860
|
-
*
|
|
861
|
-
* **Using private key(backend)**
|
|
704
|
+
* Utility helpers for escrow-related queries.
|
|
862
705
|
*
|
|
706
|
+
* @example
|
|
863
707
|
* ```ts
|
|
864
708
|
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
865
709
|
*
|
|
866
|
-
* const
|
|
710
|
+
* const escrows = await EscrowUtils.getEscrows({
|
|
867
711
|
* chainId: ChainId.POLYGON_AMOY
|
|
868
712
|
* });
|
|
713
|
+
* console.log('Escrows:', escrows);
|
|
869
714
|
* ```
|
|
870
715
|
*/
|
|
871
716
|
export declare class EscrowUtils {
|
|
872
717
|
/**
|
|
873
718
|
* This function returns an array of escrows based on the specified filter parameters.
|
|
874
719
|
*
|
|
720
|
+
* @param filter - Filter parameters.
|
|
721
|
+
* @param options - Optional configuration for subgraph requests.
|
|
722
|
+
* @returns List of escrows that match the filter.
|
|
723
|
+
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
724
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
875
725
|
*
|
|
876
|
-
*
|
|
877
|
-
*
|
|
878
|
-
* ```ts
|
|
879
|
-
* interface IEscrowsFilter {
|
|
880
|
-
* chainId: ChainId;
|
|
881
|
-
* launcher?: string;
|
|
882
|
-
* reputationOracle?: string;
|
|
883
|
-
* recordingOracle?: string;
|
|
884
|
-
* exchangeOracle?: string;
|
|
885
|
-
* jobRequesterId?: string;
|
|
886
|
-
* status?: EscrowStatus;
|
|
887
|
-
* from?: Date;
|
|
888
|
-
* to?: Date;
|
|
889
|
-
* first?: number;
|
|
890
|
-
* skip?: number;
|
|
891
|
-
* orderDirection?: OrderDirection;
|
|
892
|
-
* }
|
|
893
|
-
* ```
|
|
894
|
-
*
|
|
895
|
-
* ```ts
|
|
896
|
-
* enum ChainId {
|
|
897
|
-
* ALL = -1,
|
|
898
|
-
* MAINNET = 1,
|
|
899
|
-
* SEPOLIA = 11155111,
|
|
900
|
-
* BSC_MAINNET = 56,
|
|
901
|
-
* BSC_TESTNET = 97,
|
|
902
|
-
* POLYGON = 137,
|
|
903
|
-
* POLYGON_AMOY=80002,
|
|
904
|
-
* LOCALHOST = 1338,
|
|
905
|
-
* }
|
|
906
|
-
* ```
|
|
907
|
-
*
|
|
908
|
-
* ```ts
|
|
909
|
-
* enum OrderDirection {
|
|
910
|
-
* ASC = 'asc',
|
|
911
|
-
* DESC = 'desc',
|
|
912
|
-
* }
|
|
913
|
-
* ```
|
|
914
|
-
*
|
|
915
|
-
* ```ts
|
|
916
|
-
* enum EscrowStatus {
|
|
917
|
-
* Launched,
|
|
918
|
-
* Pending,
|
|
919
|
-
* Partial,
|
|
920
|
-
* Paid,
|
|
921
|
-
* Complete,
|
|
922
|
-
* Cancelled,
|
|
923
|
-
* }
|
|
924
|
-
* ```
|
|
925
|
-
*
|
|
926
|
-
* ```ts
|
|
927
|
-
* interface IEscrow {
|
|
928
|
-
* id: string;
|
|
929
|
-
* address: string;
|
|
930
|
-
* amountPaid: bigint;
|
|
931
|
-
* balance: bigint;
|
|
932
|
-
* count: bigint;
|
|
933
|
-
* factoryAddress: string;
|
|
934
|
-
* finalResultsUrl: string | null;
|
|
935
|
-
* finalResultsHash: string | null;
|
|
936
|
-
* intermediateResultsUrl: string | null;
|
|
937
|
-
* intermediateResultsHash: string | null;
|
|
938
|
-
* launcher: string;
|
|
939
|
-
* jobRequesterId: string | null;
|
|
940
|
-
* manifestHash: string | null;
|
|
941
|
-
* manifest: string | null;
|
|
942
|
-
* recordingOracle: string | null;
|
|
943
|
-
* reputationOracle: string | null;
|
|
944
|
-
* exchangeOracle: string | null;
|
|
945
|
-
* recordingOracleFee: number | null;
|
|
946
|
-
* reputationOracleFee: number | null;
|
|
947
|
-
* exchangeOracleFee: number | null;
|
|
948
|
-
* status: string;
|
|
949
|
-
* token: string;
|
|
950
|
-
* totalFundedAmount: bigint;
|
|
951
|
-
* createdAt: number;
|
|
952
|
-
* chainId: number;
|
|
953
|
-
* };
|
|
954
|
-
* ```
|
|
955
|
-
*
|
|
956
|
-
*
|
|
957
|
-
* @param {IEscrowsFilter} filter Filter parameters.
|
|
958
|
-
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
959
|
-
* @returns {IEscrow[]} List of escrows that match the filter.
|
|
960
|
-
*
|
|
961
|
-
* **Code example**
|
|
962
|
-
*
|
|
726
|
+
* @example
|
|
963
727
|
* ```ts
|
|
964
|
-
* import { ChainId,
|
|
728
|
+
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
965
729
|
*
|
|
966
|
-
* const filters
|
|
730
|
+
* const filters = {
|
|
967
731
|
* status: EscrowStatus.Pending,
|
|
968
732
|
* from: new Date(2023, 4, 8),
|
|
969
733
|
* to: new Date(2023, 5, 8),
|
|
970
734
|
* chainId: ChainId.POLYGON_AMOY
|
|
971
735
|
* };
|
|
972
736
|
* const escrows = await EscrowUtils.getEscrows(filters);
|
|
737
|
+
* console.log('Found escrows:', escrows.length);
|
|
973
738
|
* ```
|
|
974
739
|
*/
|
|
975
740
|
static getEscrows(filter: IEscrowsFilter, options?: SubgraphOptions): Promise<IEscrow[]>;
|
|
@@ -978,63 +743,24 @@ export declare class EscrowUtils {
|
|
|
978
743
|
*
|
|
979
744
|
* > This uses Subgraph
|
|
980
745
|
*
|
|
981
|
-
*
|
|
982
|
-
*
|
|
983
|
-
*
|
|
984
|
-
*
|
|
985
|
-
*
|
|
986
|
-
*
|
|
987
|
-
* SEPOLIA = 11155111,
|
|
988
|
-
* BSC_MAINNET = 56,
|
|
989
|
-
* BSC_TESTNET = 97,
|
|
990
|
-
* POLYGON = 137,
|
|
991
|
-
* POLYGON_AMOY = 80002,
|
|
992
|
-
* LOCALHOST = 1338,
|
|
993
|
-
* }
|
|
994
|
-
* ```
|
|
995
|
-
*
|
|
996
|
-
* ```ts
|
|
997
|
-
* interface IEscrow {
|
|
998
|
-
* id: string;
|
|
999
|
-
* address: string;
|
|
1000
|
-
* amountPaid: bigint;
|
|
1001
|
-
* balance: bigint;
|
|
1002
|
-
* count: bigint;
|
|
1003
|
-
* factoryAddress: string;
|
|
1004
|
-
* finalResultsUrl: string | null;
|
|
1005
|
-
* finalResultsHash: string | null;
|
|
1006
|
-
* intermediateResultsUrl: string | null;
|
|
1007
|
-
* intermediateResultsHash: string | null;
|
|
1008
|
-
* launcher: string;
|
|
1009
|
-
* jobRequesterId: string | null;
|
|
1010
|
-
* manifestHash: string | null;
|
|
1011
|
-
* manifest: string | null;
|
|
1012
|
-
* recordingOracle: string | null;
|
|
1013
|
-
* reputationOracle: string | null;
|
|
1014
|
-
* exchangeOracle: string | null;
|
|
1015
|
-
* recordingOracleFee: number | null;
|
|
1016
|
-
* reputationOracleFee: number | null;
|
|
1017
|
-
* exchangeOracleFee: number | null;
|
|
1018
|
-
* status: string;
|
|
1019
|
-
* token: string;
|
|
1020
|
-
* totalFundedAmount: bigint;
|
|
1021
|
-
* createdAt: number;
|
|
1022
|
-
* chainId: number;
|
|
1023
|
-
* };
|
|
1024
|
-
* ```
|
|
1025
|
-
*
|
|
1026
|
-
*
|
|
1027
|
-
* @param {ChainId} chainId Network in which the escrow has been deployed
|
|
1028
|
-
* @param {string} escrowAddress Address of the escrow
|
|
1029
|
-
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1030
|
-
* @returns {Promise<IEscrow | null>} - Escrow data or null if not found.
|
|
1031
|
-
*
|
|
1032
|
-
* **Code example**
|
|
746
|
+
* @param chainId - Network in which the escrow has been deployed
|
|
747
|
+
* @param escrowAddress - Address of the escrow
|
|
748
|
+
* @param options - Optional configuration for subgraph requests.
|
|
749
|
+
* @returns Escrow data or null if not found.
|
|
750
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
751
|
+
* @throws ErrorInvalidAddress If the escrow address is invalid
|
|
1033
752
|
*
|
|
753
|
+
* @example
|
|
1034
754
|
* ```ts
|
|
1035
|
-
* import { ChainId
|
|
755
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
1036
756
|
*
|
|
1037
|
-
* const escrow =
|
|
757
|
+
* const escrow = await EscrowUtils.getEscrow(
|
|
758
|
+
* ChainId.POLYGON_AMOY,
|
|
759
|
+
* "0x1234567890123456789012345678901234567890"
|
|
760
|
+
* );
|
|
761
|
+
* if (escrow) {
|
|
762
|
+
* console.log('Escrow status:', escrow.status);
|
|
763
|
+
* }
|
|
1038
764
|
* ```
|
|
1039
765
|
*/
|
|
1040
766
|
static getEscrow(chainId: ChainId, escrowAddress: string, options?: SubgraphOptions): Promise<IEscrow | null>;
|
|
@@ -1043,56 +769,25 @@ export declare class EscrowUtils {
|
|
|
1043
769
|
*
|
|
1044
770
|
* > This uses Subgraph
|
|
1045
771
|
*
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
* MAINNET = 1,
|
|
1052
|
-
* SEPOLIA = 11155111,
|
|
1053
|
-
* BSC_MAINNET = 56,
|
|
1054
|
-
* BSC_TESTNET = 97,
|
|
1055
|
-
* POLYGON = 137,
|
|
1056
|
-
* POLYGON_AMOY = 80002,
|
|
1057
|
-
* LOCALHOST = 1338,
|
|
1058
|
-
* }
|
|
1059
|
-
* ```
|
|
1060
|
-
*
|
|
1061
|
-
* ```ts
|
|
1062
|
-
* enum OrderDirection {
|
|
1063
|
-
* ASC = 'asc',
|
|
1064
|
-
* DESC = 'desc',
|
|
1065
|
-
* }
|
|
1066
|
-
* ```
|
|
772
|
+
* @param filter - Filter parameters.
|
|
773
|
+
* @param options - Optional configuration for subgraph requests.
|
|
774
|
+
* @returns Array of status events with their corresponding statuses.
|
|
775
|
+
* @throws ErrorInvalidAddress If the launcher address is invalid
|
|
776
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
1067
777
|
*
|
|
778
|
+
* @example
|
|
1068
779
|
* ```ts
|
|
1069
|
-
*
|
|
1070
|
-
* escrowAddress: string;
|
|
1071
|
-
* timestamp: string;
|
|
1072
|
-
* status: string;
|
|
1073
|
-
* };
|
|
1074
|
-
* ```
|
|
1075
|
-
*
|
|
1076
|
-
* @param {IStatusEventFilter} filter Filter parameters.
|
|
1077
|
-
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1078
|
-
* @returns {Promise<StatusEvent[]>} - Array of status events with their corresponding statuses.
|
|
780
|
+
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
1079
781
|
*
|
|
1080
|
-
*
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1084
|
-
*
|
|
1085
|
-
*
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1089
|
-
* chainId: ChainId.POLYGON,
|
|
1090
|
-
* statuses: [EscrowStatus.Pending, EscrowStatus.Complete],
|
|
1091
|
-
* from: fromDate,
|
|
1092
|
-
* to: toDate
|
|
1093
|
-
* });
|
|
1094
|
-
* console.log(statusEvents);
|
|
1095
|
-
* })();
|
|
782
|
+
* const fromDate = new Date('2023-01-01');
|
|
783
|
+
* const toDate = new Date('2023-12-31');
|
|
784
|
+
* const statusEvents = await EscrowUtils.getStatusEvents({
|
|
785
|
+
* chainId: ChainId.POLYGON,
|
|
786
|
+
* statuses: [EscrowStatus.Pending, EscrowStatus.Complete],
|
|
787
|
+
* from: fromDate,
|
|
788
|
+
* to: toDate
|
|
789
|
+
* });
|
|
790
|
+
* console.log('Status events:', statusEvents.length);
|
|
1096
791
|
* ```
|
|
1097
792
|
*/
|
|
1098
793
|
static getStatusEvents(filter: IStatusEventFilter, options?: SubgraphOptions): Promise<IStatusEvent[]>;
|
|
@@ -1101,17 +796,15 @@ export declare class EscrowUtils {
|
|
|
1101
796
|
*
|
|
1102
797
|
* > This uses Subgraph
|
|
1103
798
|
*
|
|
1104
|
-
*
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1107
|
-
* @
|
|
1108
|
-
* @
|
|
1109
|
-
* @returns {Promise<IPayout[]>} List of payouts matching the filters.
|
|
1110
|
-
*
|
|
1111
|
-
* **Code example**
|
|
799
|
+
* @param filter - Filter parameters.
|
|
800
|
+
* @param options - Optional configuration for subgraph requests.
|
|
801
|
+
* @returns List of payouts matching the filters.
|
|
802
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
803
|
+
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
1112
804
|
*
|
|
805
|
+
* @example
|
|
1113
806
|
* ```ts
|
|
1114
|
-
* import { ChainId
|
|
807
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
1115
808
|
*
|
|
1116
809
|
* const payouts = await EscrowUtils.getPayouts({
|
|
1117
810
|
* chainId: ChainId.POLYGON,
|
|
@@ -1120,7 +813,7 @@ export declare class EscrowUtils {
|
|
|
1120
813
|
* from: new Date('2023-01-01'),
|
|
1121
814
|
* to: new Date('2023-12-31')
|
|
1122
815
|
* });
|
|
1123
|
-
* console.log(payouts);
|
|
816
|
+
* console.log('Payouts:', payouts.length);
|
|
1124
817
|
* ```
|
|
1125
818
|
*/
|
|
1126
819
|
static getPayouts(filter: IPayoutFilter, options?: SubgraphOptions): Promise<IPayout[]>;
|
|
@@ -1129,48 +822,22 @@ export declare class EscrowUtils {
|
|
|
1129
822
|
*
|
|
1130
823
|
* > This uses Subgraph
|
|
1131
824
|
*
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
* SEPOLIA = 11155111,
|
|
1139
|
-
* BSC_MAINNET = 56,
|
|
1140
|
-
* BSC_TESTNET = 97,
|
|
1141
|
-
* POLYGON = 137,
|
|
1142
|
-
* POLYGON_AMOY = 80002,
|
|
1143
|
-
* LOCALHOST = 1338,
|
|
1144
|
-
* }
|
|
1145
|
-
* ```
|
|
1146
|
-
*
|
|
1147
|
-
* ```ts
|
|
1148
|
-
* interface ICancellationRefund {
|
|
1149
|
-
* id: string;
|
|
1150
|
-
* escrowAddress: string;
|
|
1151
|
-
* receiver: string;
|
|
1152
|
-
* amount: bigint;
|
|
1153
|
-
* block: number;
|
|
1154
|
-
* timestamp: number;
|
|
1155
|
-
* txHash: string;
|
|
1156
|
-
* };
|
|
1157
|
-
* ```
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
* @param {Object} filter Filter parameters.
|
|
1161
|
-
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1162
|
-
* @returns {Promise<ICancellationRefund[]>} List of cancellation refunds matching the filters.
|
|
1163
|
-
*
|
|
1164
|
-
* **Code example**
|
|
825
|
+
* @param filter - Filter parameters.
|
|
826
|
+
* @param options - Optional configuration for subgraph requests.
|
|
827
|
+
* @returns List of cancellation refunds matching the filters.
|
|
828
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
829
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
830
|
+
* @throws ErrorInvalidAddress If the receiver address is invalid
|
|
1165
831
|
*
|
|
832
|
+
* @example
|
|
1166
833
|
* ```ts
|
|
1167
|
-
* import { ChainId
|
|
834
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
1168
835
|
*
|
|
1169
836
|
* const cancellationRefunds = await EscrowUtils.getCancellationRefunds({
|
|
1170
837
|
* chainId: ChainId.POLYGON_AMOY,
|
|
1171
838
|
* escrowAddress: '0x1234567890123456789012345678901234567890',
|
|
1172
839
|
* });
|
|
1173
|
-
* console.log(cancellationRefunds);
|
|
840
|
+
* console.log('Cancellation refunds:', cancellationRefunds.length);
|
|
1174
841
|
* ```
|
|
1175
842
|
*/
|
|
1176
843
|
static getCancellationRefunds(filter: ICancellationRefundFilter, options?: SubgraphOptions): Promise<ICancellationRefund[]>;
|
|
@@ -1179,45 +846,25 @@ export declare class EscrowUtils {
|
|
|
1179
846
|
*
|
|
1180
847
|
* > This uses Subgraph
|
|
1181
848
|
*
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
*
|
|
1188
|
-
* SEPOLIA = 11155111,
|
|
1189
|
-
* BSC_MAINNET = 56,
|
|
1190
|
-
* BSC_TESTNET = 97,
|
|
1191
|
-
* POLYGON = 137,
|
|
1192
|
-
* POLYGON_AMOY = 80002,
|
|
1193
|
-
* LOCALHOST = 1338,
|
|
1194
|
-
* }
|
|
1195
|
-
* ```
|
|
849
|
+
* @param chainId - Network in which the escrow has been deployed
|
|
850
|
+
* @param escrowAddress - Address of the escrow
|
|
851
|
+
* @param options - Optional configuration for subgraph requests.
|
|
852
|
+
* @returns Cancellation refund data or null if not found.
|
|
853
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
854
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
1196
855
|
*
|
|
856
|
+
* @example
|
|
1197
857
|
* ```ts
|
|
1198
|
-
*
|
|
1199
|
-
* id: string;
|
|
1200
|
-
* escrowAddress: string;
|
|
1201
|
-
* receiver: string;
|
|
1202
|
-
* amount: bigint;
|
|
1203
|
-
* block: number;
|
|
1204
|
-
* timestamp: number;
|
|
1205
|
-
* txHash: string;
|
|
1206
|
-
* };
|
|
1207
|
-
* ```
|
|
1208
|
-
*
|
|
1209
|
-
*
|
|
1210
|
-
* @param {ChainId} chainId Network in which the escrow has been deployed
|
|
1211
|
-
* @param {string} escrowAddress Address of the escrow
|
|
1212
|
-
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1213
|
-
* @returns {Promise<ICancellationRefund>} Cancellation refund data
|
|
858
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
1214
859
|
*
|
|
1215
|
-
* **Code example**
|
|
1216
860
|
*
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
861
|
+
* const cancellationRefund = await EscrowUtils.getCancellationRefund(
|
|
862
|
+
* ChainId.POLYGON_AMOY,
|
|
863
|
+
* "0x1234567890123456789012345678901234567890"
|
|
864
|
+
* );
|
|
865
|
+
* if (cancellationRefund) {
|
|
866
|
+
* console.log('Refund amount:', cancellationRefund.amount);
|
|
867
|
+
* }
|
|
1221
868
|
* ```
|
|
1222
869
|
*/
|
|
1223
870
|
static getCancellationRefund(chainId: ChainId, escrowAddress: string, options?: SubgraphOptions): Promise<ICancellationRefund | null>;
|