@human-protocol/sdk 1.1.10 → 1.1.12

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.
Files changed (61) hide show
  1. package/README.md +2 -0
  2. package/dist/constants.js +8 -8
  3. package/dist/error.d.ts +4 -0
  4. package/dist/error.d.ts.map +1 -1
  5. package/dist/error.js +6 -2
  6. package/dist/escrow.d.ts +38 -18
  7. package/dist/escrow.d.ts.map +1 -1
  8. package/dist/escrow.js +138 -51
  9. package/dist/graphql/queries/escrow.d.ts +3 -2
  10. package/dist/graphql/queries/escrow.d.ts.map +1 -1
  11. package/dist/graphql/queries/escrow.js +42 -22
  12. package/dist/graphql/queries/hmtoken.d.ts +2 -0
  13. package/dist/graphql/queries/hmtoken.d.ts.map +1 -0
  14. package/dist/graphql/queries/hmtoken.js +21 -0
  15. package/dist/graphql/queries/index.d.ts +3 -0
  16. package/dist/graphql/queries/index.d.ts.map +1 -1
  17. package/dist/graphql/queries/index.js +3 -0
  18. package/dist/graphql/queries/payout.d.ts +3 -0
  19. package/dist/graphql/queries/payout.d.ts.map +1 -0
  20. package/dist/graphql/queries/payout.js +43 -0
  21. package/dist/graphql/queries/staking.d.ts +4 -0
  22. package/dist/graphql/queries/staking.d.ts.map +1 -0
  23. package/dist/graphql/queries/staking.js +58 -0
  24. package/dist/graphql/queries/statistics.d.ts +5 -0
  25. package/dist/graphql/queries/statistics.d.ts.map +1 -0
  26. package/dist/graphql/queries/statistics.js +95 -0
  27. package/dist/graphql/types.d.ts +114 -0
  28. package/dist/graphql/types.d.ts.map +1 -1
  29. package/dist/index.d.ts +3 -2
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +4 -1
  32. package/dist/interfaces.d.ts +40 -9
  33. package/dist/interfaces.d.ts.map +1 -1
  34. package/dist/staking.d.ts +8 -8
  35. package/dist/staking.d.ts.map +1 -1
  36. package/dist/staking.js +16 -38
  37. package/dist/statistics.d.ts +62 -0
  38. package/dist/statistics.d.ts.map +1 -0
  39. package/dist/statistics.js +224 -0
  40. package/dist/storage.d.ts +5 -2
  41. package/dist/storage.d.ts.map +1 -1
  42. package/dist/storage.js +7 -4
  43. package/dist/types.d.ts +4 -0
  44. package/dist/types.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/constants.ts +8 -8
  47. package/src/error.ts +7 -0
  48. package/src/escrow.ts +184 -58
  49. package/src/graphql/queries/escrow.ts +51 -21
  50. package/src/graphql/queries/hmtoken.ts +17 -0
  51. package/src/graphql/queries/index.ts +3 -0
  52. package/src/graphql/queries/payout.ts +41 -0
  53. package/src/graphql/queries/staking.ts +57 -0
  54. package/src/graphql/queries/statistics.ts +96 -0
  55. package/src/graphql/types.ts +133 -0
  56. package/src/index.ts +10 -2
  57. package/src/interfaces.ts +43 -9
  58. package/src/staking.ts +23 -53
  59. package/src/statistics.ts +312 -0
  60. package/src/storage.ts +7 -4
  61. package/src/types.ts +4 -0
package/README.md CHANGED
@@ -79,8 +79,10 @@ const { ethers } = require('ethers');
79
79
  await escrowClient.setup(escrowAddress, {
80
80
  recordingOracle: '0x90F79bf6EB2c4f870365E785982E1f101E93b906',
81
81
  reputationOracle: '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65',
82
+ exchangeOracle: '0x6b7E3C31F34cF38d1DFC1D9A8A59482028395809',
82
83
  recordingOracleFee: ethers.BigNumber.from(1),
83
84
  reputationOracleFee: ethers.BigNumber.from(1),
85
+ exchangeOracleFee: ethers.BigNumber.from(1),
84
86
  manifestUrl: 'http://example.com',
85
87
  hash: 'test',
86
88
  });
package/dist/constants.js CHANGED
@@ -53,7 +53,7 @@ exports.NETWORKS = {
53
53
  stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
54
54
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
55
55
  kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
56
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/mainnet-v1',
56
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/mainnet-v2',
57
57
  oldSubgraphUrl: '',
58
58
  oldFactoryAddress: '',
59
59
  },
@@ -79,7 +79,7 @@ exports.NETWORKS = {
79
79
  stakingAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
80
80
  rewardPoolAddress: '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4',
81
81
  kvstoreAddress: '0xc9Fe39c4b6e1d7A2991355Af159956982DADf842',
82
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli-v1',
82
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli-v2',
83
83
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli',
84
84
  oldFactoryAddress: '0xaAe6a2646C1F88763E62e0cD08aD050Ea66AC46F',
85
85
  },
@@ -92,7 +92,7 @@ exports.NETWORKS = {
92
92
  stakingAddress: '0xdFbB79dC35a3A53741be54a2C9b587d6BafAbd1C',
93
93
  rewardPoolAddress: '0xf376443BCc6d4d4D63eeC086bc4A9E4a83878e0e',
94
94
  kvstoreAddress: '0x2B95bEcb6EBC4589f64CB000dFCF716b4aeF8aA6',
95
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc-v1',
95
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc-v2',
96
96
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
97
97
  oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
98
98
  },
@@ -105,7 +105,7 @@ exports.NETWORKS = {
105
105
  stakingAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
106
106
  rewardPoolAddress: '0xB0A0500103eCEc431b73F6BAd923F0a2774E6e29',
107
107
  kvstoreAddress: '0x3aD4B091E054f192a822D1406f4535eAd38580e4',
108
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest-v1',
108
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest-v2',
109
109
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
110
110
  oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
111
111
  },
@@ -118,7 +118,7 @@ exports.NETWORKS = {
118
118
  stakingAddress: '0xcbAd56bE3f504E98bd70875823d3CC0242B7bB29',
119
119
  rewardPoolAddress: '0xa8e32d777a3839440cc7c24D591A64B9481753B3',
120
120
  kvstoreAddress: '0x35Cf4beBD58F9C8D75B9eA2599479b6C173d406F',
121
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon-v1',
121
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon-v2',
122
122
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
123
123
  oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
124
124
  },
@@ -131,7 +131,7 @@ exports.NETWORKS = {
131
131
  stakingAddress: '0x7Fd3dF914E7b6Bd96B4c744Df32183b51368Bfac',
132
132
  rewardPoolAddress: '0xf0145eD99AC3c4f877aDa7dA4D1E059ec9116BAE',
133
133
  kvstoreAddress: '0xD7F61E812e139a5a02eDae9Dfec146E1b8eA3807',
134
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai-v1',
134
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai-v2',
135
135
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai',
136
136
  oldFactoryAddress: '0x558cd800f9F0B02f3B149667bDe003284c867E94',
137
137
  },
@@ -144,7 +144,7 @@ exports.NETWORKS = {
144
144
  stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
145
145
  rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
146
146
  kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
147
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam-v1',
147
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam-v2',
148
148
  oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam',
149
149
  oldFactoryAddress: '0x98108c28B7767a52BE38B4860832dd4e11A7ecad',
150
150
  },
@@ -157,7 +157,7 @@ exports.NETWORKS = {
157
157
  stakingAddress: '0xBFC7009F3371F93F3B54DdC8caCd02914a37495c',
158
158
  rewardPoolAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
159
159
  kvstoreAddress: '0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d',
160
- subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbase-alpha-v1',
160
+ subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbase-alpha-v2',
161
161
  oldSubgraphUrl: '',
162
162
  oldFactoryAddress: '',
163
163
  },
package/dist/error.d.ts CHANGED
@@ -50,6 +50,10 @@ export declare const ErrorInvalidRecordingOracleAddressProvided: Error;
50
50
  * @constant {Error} - Invalid reputation oracle address provided.
51
51
  */
52
52
  export declare const ErrorInvalidReputationOracleAddressProvided: Error;
53
+ /**
54
+ * @constant {Error} - Invalid reputation oracle address provided.
55
+ */
56
+ export declare const ErrorInvalidExchangeOracleAddressProvided: Error;
53
57
  /**
54
58
  * @constant {Error} - The Staking value must be positive.
55
59
  */
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAA2C,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,gCAAgC,OAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,O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AEG;AACH,eAAO,MAAM,sBAAsB,OAAuC,CAAC;AAE3E,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,oBAAqB,SAAQ,aAAa;gBACzC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,aAAc,SAAQ,aAAa;gBAClC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,sBAAuB,SAAQ,aAAa;gBAC3C,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,YAAa,SAAQ,aAAa;gBACjC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,YAAa,SAAQ,aAAa;gBACjC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,sBAAuB,SAAQ,aAAa;gBAC3C,MAAM,EAAE,MAAM;CAG3B;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAG5B"}
package/dist/error.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransactionReplaced = exports.NonceExpired = exports.NumericFault = exports.ReplacementUnderpriced = exports.UnpredictableGasLimit = exports.OutOfGasError = exports.InvalidArgumentError = exports.EthereumError = exports.ErrorHashIsEmptyString = exports.ErrorLaunchedEventIsNotEmitted = exports.ErrorRecipientAndAmountsMustBeSameLength = exports.ErrorAmountsCannotBeEmptyArray = exports.ErrorEscrowDoesNotHaveEnoughBalance = exports.ErrorAmountMustBeGreaterThanZero = exports.ErrorRecipientCannotBeEmptyArray = exports.ErrorTotalFeeMustBeLessThanHundred = exports.ErrorFeeMustBeBetweenZeroAndHundred = exports.ErrorNoURLprovided = exports.ErrorListOfHandlersCannotBeEmpty = exports.ErrorUrlIsEmptyString = exports.ErrorInvalidUrl = exports.ErrorStorageClientDoesNotExist = exports.ErrorManifestFileDoesNotExist = exports.ErrorEscrowAddressIsNotProvidedByFactory = exports.ErrorSigner = exports.ErrorUnsupportedChainID = exports.ErrorProviderDoesNotExist = exports.ErrorHMTokenAmountNotApproved = exports.ErrorFailedToCheckAllowance = exports.ErrorFailedToApproveStakingAmountSignerDoesNotExist = exports.ErrorStakingGetStakers = exports.ErrorInvalidEscrowAddressProvided = exports.ErrorInvalidStakerAddressProvided = exports.ErrorInvalidSlasherAddressProvided = exports.ErrorInvalidStakingValueSign = exports.ErrorInvalidStakingValueType = exports.ErrorStakingValueMustBePositive = exports.ErrorInvalidReputationOracleAddressProvided = exports.ErrorInvalidRecordingOracleAddressProvided = exports.ErrorInvalidTokenAddress = exports.ErrorInvalidAddress = exports.ErrorKVStoreArrayLength = exports.ErrorKVStoreEmptyKey = exports.ErrorStorageFileNotUploaded = exports.ErrorStorageFileNotFound = exports.ErrorStorageBucketNotFound = exports.ErrorStorageCredentialsMissing = exports.ErrorStorageClientNotExists = exports.ErrorStorageClientNotInitialized = exports.ErrorStakingMissing = void 0;
4
- exports.InvalidEthereumAddressError = exports.ContractExecutionError = void 0;
3
+ exports.NonceExpired = exports.NumericFault = exports.ReplacementUnderpriced = exports.UnpredictableGasLimit = exports.OutOfGasError = exports.InvalidArgumentError = exports.EthereumError = exports.ErrorHashIsEmptyString = exports.ErrorLaunchedEventIsNotEmitted = exports.ErrorRecipientAndAmountsMustBeSameLength = exports.ErrorAmountsCannotBeEmptyArray = exports.ErrorEscrowDoesNotHaveEnoughBalance = exports.ErrorAmountMustBeGreaterThanZero = exports.ErrorRecipientCannotBeEmptyArray = exports.ErrorTotalFeeMustBeLessThanHundred = exports.ErrorFeeMustBeBetweenZeroAndHundred = exports.ErrorNoURLprovided = exports.ErrorListOfHandlersCannotBeEmpty = exports.ErrorUrlIsEmptyString = exports.ErrorInvalidUrl = exports.ErrorStorageClientDoesNotExist = exports.ErrorManifestFileDoesNotExist = exports.ErrorEscrowAddressIsNotProvidedByFactory = exports.ErrorSigner = exports.ErrorUnsupportedChainID = exports.ErrorProviderDoesNotExist = exports.ErrorHMTokenAmountNotApproved = exports.ErrorFailedToCheckAllowance = exports.ErrorFailedToApproveStakingAmountSignerDoesNotExist = exports.ErrorStakingGetStakers = exports.ErrorInvalidEscrowAddressProvided = exports.ErrorInvalidStakerAddressProvided = exports.ErrorInvalidSlasherAddressProvided = exports.ErrorInvalidStakingValueSign = exports.ErrorInvalidStakingValueType = exports.ErrorStakingValueMustBePositive = exports.ErrorInvalidExchangeOracleAddressProvided = exports.ErrorInvalidReputationOracleAddressProvided = exports.ErrorInvalidRecordingOracleAddressProvided = exports.ErrorInvalidTokenAddress = exports.ErrorInvalidAddress = exports.ErrorKVStoreArrayLength = exports.ErrorKVStoreEmptyKey = exports.ErrorStorageFileNotUploaded = exports.ErrorStorageFileNotFound = exports.ErrorStorageBucketNotFound = exports.ErrorStorageCredentialsMissing = exports.ErrorStorageClientNotExists = exports.ErrorStorageClientNotInitialized = exports.ErrorStakingMissing = void 0;
4
+ exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = void 0;
5
5
  /**
6
6
  * @constant {Error} - The Staking contract is missing.
7
7
  */
@@ -54,6 +54,10 @@ exports.ErrorInvalidRecordingOracleAddressProvided = new Error('Invalid recordin
54
54
  * @constant {Error} - Invalid reputation oracle address provided.
55
55
  */
56
56
  exports.ErrorInvalidReputationOracleAddressProvided = new Error('Invalid reputation oracle address provided');
57
+ /**
58
+ * @constant {Error} - Invalid reputation oracle address provided.
59
+ */
60
+ exports.ErrorInvalidExchangeOracleAddressProvided = new Error('Invalid exchange oracle address provided');
57
61
  /**
58
62
  * @constant {Error} - The Staking value must be positive.
59
63
  */
package/dist/escrow.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Provider } from '@ethersproject/abstract-provider';
2
2
  import { BigNumber, Signer } from 'ethers';
3
+ import { ChainId } from './enums';
3
4
  import { IEscrowConfig, IEscrowsFilter } from './interfaces';
4
5
  import { EscrowStatus, NetworkData } from './types';
5
6
  import { EscrowData } from './graphql';
@@ -32,7 +33,7 @@ export declare class EscrowClient {
32
33
  * @returns {Promise<string>} - Return the address of the escrow created.
33
34
  * @throws {Error} - An error object if an error occurred.
34
35
  */
35
- createEscrow(tokenAddress: string, trustedHandlers: string[]): Promise<string>;
36
+ createEscrow(tokenAddress: string, trustedHandlers: string[], jobRequesterId: string): Promise<string>;
36
37
  /**
37
38
  * Sets up the parameters of the escrow.
38
39
  *
@@ -52,7 +53,7 @@ export declare class EscrowClient {
52
53
  * @returns {Promise<string>}
53
54
  * @throws {Error} - An error object if an error occurred.
54
55
  */
55
- createAndSetupEscrow(tokenAddress: string, trustedHandlers: string[], escrowConfig: IEscrowConfig): Promise<string>;
56
+ createAndSetupEscrow(tokenAddress: string, trustedHandlers: string[], jobRequesterId: string, escrowConfig: IEscrowConfig): Promise<string>;
56
57
  /**
57
58
  * **Adds funds of the chosen token to the escrow.*
58
59
  *
@@ -126,6 +127,14 @@ export declare class EscrowClient {
126
127
  * @throws {Error} - An error object if an error occurred.
127
128
  */
128
129
  getBalance(escrowAddress: string): Promise<BigNumber>;
130
+ /**
131
+ * Returns the manifest file hash.
132
+ *
133
+ * @param {string} escrowAddress - Address of the escrow.
134
+ * @returns {Promise<void>}
135
+ * @throws {Error} - An error object if an error occurred.
136
+ */
137
+ getManifestHash(escrowAddress: string): Promise<string>;
129
138
  /**
130
139
  * Returns the manifest file URL.
131
140
  *
@@ -166,22 +175,6 @@ export declare class EscrowClient {
166
175
  * @throws {Error} - An error object if an error occurred.
167
176
  */
168
177
  getStatus(escrowAddress: string): Promise<EscrowStatus>;
169
- /**
170
- * Returns the escrow addresses created by a job requester.
171
- *
172
- * @param {IEscrowsFilter} requesterAddress - Address of the requester.
173
- * @returns {Promise<string[]>}
174
- * @throws {Error} - An error object if an error occurred.
175
- */
176
- getLaunchedEscrows(launcherAddress: string): Promise<EscrowData[]>;
177
- /**
178
- * Returns the escrow addresses based on a specified filter.
179
- *
180
- * @param {IEscrowsFilter} filter - Filter parameters.
181
- * @returns {Promise<EscrowData[]>}
182
- * @throws {Error} - An error object if an error occurred.
183
- */
184
- getEscrowsFiltered(filter: IEscrowsFilter): Promise<EscrowData[]>;
185
178
  /**
186
179
  * Returns the recording oracle address of given escrow
187
180
  *
@@ -206,6 +199,14 @@ export declare class EscrowClient {
206
199
  * @throws {Error} - An error object if an error occurred.
207
200
  */
208
201
  getReputationOracleAddress(escrowAddress: string): Promise<string>;
202
+ /**
203
+ * Returns the reputation oracle address of given escrow
204
+ *
205
+ * @param {string} escrowAddress - Address of the escrow.
206
+ * @returns {Promise<string>} - Address of the reputation oracle.
207
+ * @throws {Error} - An error object if an error occurred.
208
+ */
209
+ getExchangeOracleAddress(escrowAddress: string): Promise<string>;
209
210
  /**
210
211
  * Returns the escrow factory address of given escrow
211
212
  *
@@ -215,4 +216,23 @@ export declare class EscrowClient {
215
216
  */
216
217
  getFactoryAddress(escrowAddress: string): Promise<string>;
217
218
  }
219
+ export declare class EscrowUtils {
220
+ /**
221
+ * Returns the list of escrows for given filter
222
+ *
223
+ * @param {IEscrowsFilter} filter - Filter parameters.
224
+ * @returns {Promise<EscrowData[]>}
225
+ * @throws {Error} - An error object if an error occurred.
226
+ */
227
+ static getEscrows(filter: IEscrowsFilter): Promise<EscrowData[]>;
228
+ /**
229
+ * Returns the escrow for a given address
230
+ *
231
+ * @param {string} escrowAddress - Escrow address.
232
+ * @param {ChainId} chainId - Chain id.
233
+ * @returns {Promise<EscrowData>}
234
+ * @throws {Error} - An error object if an error occurred.
235
+ */
236
+ static getEscrow(chainId: ChainId, escrowAddress: string): Promise<EscrowData>;
237
+ }
218
238
  //# sourceMappingURL=escrow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kC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AAG,OAAO,CAAC,MAAM,CAAC;IAoB7D;;;;;;OAMG;IACG,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB5D;;;;;;OAMG;IACG,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB3D;;;;;;OAMG;IACG,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBvE;;;;;;OAMG;IACG,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoB7D;;;;;;OAMG;IACG,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAoB7D;;;;;;OAMG;IACG,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBvE;;;;;;OAMG;IACG,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBnE;;;;;;OAMG;IACG,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxE;;;;;;OAMG;IACG,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBtE;;;;;;OAMG;IACG,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAmBhE;AAED,qBAAa,WAAW;IACtB;;;;;;OAMG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,UAAU,EAAE,CAAC;IA8DxB;;;;;;;OAOG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC;CAuBvB"}
package/dist/escrow.js CHANGED
@@ -12,13 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.EscrowClient = void 0;
15
+ exports.EscrowUtils = exports.EscrowClient = void 0;
16
16
  const typechain_types_1 = require("@human-protocol/core/typechain-types");
17
17
  const ethers_1 = require("ethers");
18
18
  const graphql_request_1 = __importDefault(require("graphql-request"));
19
19
  const constants_1 = require("./constants");
20
20
  const decorators_1 = require("./decorators");
21
21
  const error_1 = require("./error");
22
+ const types_1 = require("./types");
22
23
  const utils_1 = require("./utils");
23
24
  const graphql_1 = require("./graphql");
24
25
  class EscrowClient {
@@ -67,7 +68,7 @@ class EscrowClient {
67
68
  * @returns {Promise<string>} - Return the address of the escrow created.
68
69
  * @throws {Error} - An error object if an error occurred.
69
70
  */
70
- async createEscrow(tokenAddress, trustedHandlers) {
71
+ async createEscrow(tokenAddress, trustedHandlers, jobRequesterId) {
71
72
  if (!ethers_1.ethers.utils.isAddress(tokenAddress)) {
72
73
  throw error_1.ErrorInvalidTokenAddress;
73
74
  }
@@ -77,8 +78,8 @@ class EscrowClient {
77
78
  }
78
79
  });
79
80
  try {
80
- const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers)).wait();
81
- const event = result.events?.find(({ topics }) => topics.includes(ethers_1.ethers.utils.id('Launched(address,address)')))?.args;
81
+ const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers, jobRequesterId)).wait();
82
+ const event = result.events?.find(({ topics }) => topics.includes(ethers_1.ethers.utils.id('LaunchedV2(address,address,string)')))?.args;
82
83
  if (!event) {
83
84
  throw error_1.ErrorLaunchedEventIsNotEmitted;
84
85
  }
@@ -97,20 +98,25 @@ class EscrowClient {
97
98
  * @throws {Error} - An error object if an error occurred.
98
99
  */
99
100
  async setup(escrowAddress, escrowConfig) {
100
- const { recordingOracle, reputationOracle, recordingOracleFee, reputationOracleFee, manifestUrl, manifestHash, } = escrowConfig;
101
+ const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifestUrl, manifestHash, } = escrowConfig;
101
102
  if (!ethers_1.ethers.utils.isAddress(recordingOracle)) {
102
103
  throw error_1.ErrorInvalidRecordingOracleAddressProvided;
103
104
  }
104
105
  if (!ethers_1.ethers.utils.isAddress(reputationOracle)) {
105
106
  throw error_1.ErrorInvalidReputationOracleAddressProvided;
106
107
  }
108
+ if (!ethers_1.ethers.utils.isAddress(exchangeOracle)) {
109
+ throw error_1.ErrorInvalidExchangeOracleAddressProvided;
110
+ }
107
111
  if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
108
112
  throw error_1.ErrorInvalidEscrowAddressProvided;
109
113
  }
110
- if (recordingOracleFee.lte(0) || reputationOracleFee.lte(0)) {
114
+ if (recordingOracleFee.lte(0) ||
115
+ reputationOracleFee.lte(0) ||
116
+ exchangeOracleFee.lte(0)) {
111
117
  throw error_1.ErrorAmountMustBeGreaterThanZero;
112
118
  }
113
- if (recordingOracleFee.add(reputationOracleFee).gt(100)) {
119
+ if (recordingOracleFee.add(reputationOracleFee).add(exchangeOracleFee).gt(100)) {
114
120
  throw error_1.ErrorTotalFeeMustBeLessThanHundred;
115
121
  }
116
122
  if (!manifestUrl) {
@@ -127,7 +133,7 @@ class EscrowClient {
127
133
  }
128
134
  try {
129
135
  this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
130
- await this.escrowContract.setup(reputationOracle, recordingOracle, reputationOracleFee, recordingOracleFee, manifestUrl, manifestHash);
136
+ await this.escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifestUrl, manifestHash);
131
137
  return;
132
138
  }
133
139
  catch (e) {
@@ -144,9 +150,9 @@ class EscrowClient {
144
150
  * @returns {Promise<string>}
145
151
  * @throws {Error} - An error object if an error occurred.
146
152
  */
147
- async createAndSetupEscrow(tokenAddress, trustedHandlers, escrowConfig) {
153
+ async createAndSetupEscrow(tokenAddress, trustedHandlers, jobRequesterId, escrowConfig) {
148
154
  try {
149
- const escrowAddress = await this.createEscrow(tokenAddress, trustedHandlers);
155
+ const escrowAddress = await this.createEscrow(tokenAddress, trustedHandlers, jobRequesterId);
150
156
  await this.setup(escrowAddress, escrowConfig);
151
157
  return escrowAddress;
152
158
  }
@@ -399,6 +405,28 @@ class EscrowClient {
399
405
  return (0, utils_1.throwError)(e);
400
406
  }
401
407
  }
408
+ /**
409
+ * Returns the manifest file hash.
410
+ *
411
+ * @param {string} escrowAddress - Address of the escrow.
412
+ * @returns {Promise<void>}
413
+ * @throws {Error} - An error object if an error occurred.
414
+ */
415
+ async getManifestHash(escrowAddress) {
416
+ if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
417
+ throw error_1.ErrorInvalidEscrowAddressProvided;
418
+ }
419
+ if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
420
+ throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
421
+ }
422
+ try {
423
+ this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
424
+ return this.escrowContract.manifestHash();
425
+ }
426
+ catch (e) {
427
+ return (0, utils_1.throwError)(e);
428
+ }
429
+ }
402
430
  /**
403
431
  * Returns the manifest file URL.
404
432
  *
@@ -510,54 +538,35 @@ class EscrowClient {
510
538
  }
511
539
  }
512
540
  /**
513
- * Returns the escrow addresses created by a job requester.
541
+ * Returns the recording oracle address of given escrow
514
542
  *
515
- * @param {IEscrowsFilter} requesterAddress - Address of the requester.
516
- * @returns {Promise<string[]>}
543
+ * @param {string} escrowAddress - Address of the escrow.
544
+ * @returns {Promise<string>} - Address of the recording oracle.
517
545
  * @throws {Error} - An error object if an error occurred.
518
546
  */
519
- async getLaunchedEscrows(launcherAddress) {
520
- if (!ethers_1.ethers.utils.isAddress(launcherAddress)) {
521
- throw error_1.ErrorInvalidAddress;
522
- }
523
- try {
524
- const { escrows } = await (0, graphql_request_1.default)(this.network.subgraphUrl, graphql_1.GET_ESCROWS_BY_LAUNCHER_QUERY, { launcherAddress });
525
- return escrows;
526
- }
527
- catch (e) {
528
- return (0, utils_1.throwError)(e);
547
+ async getRecordingOracleAddress(escrowAddress) {
548
+ if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
549
+ throw error_1.ErrorInvalidEscrowAddressProvided;
529
550
  }
530
- }
531
- /**
532
- * Returns the escrow addresses based on a specified filter.
533
- *
534
- * @param {IEscrowsFilter} filter - Filter parameters.
535
- * @returns {Promise<EscrowData[]>}
536
- * @throws {Error} - An error object if an error occurred.
537
- */
538
- async getEscrowsFiltered(filter) {
539
- if (filter?.launcherAddress &&
540
- !ethers_1.ethers.utils.isAddress(filter?.launcherAddress)) {
541
- throw error_1.ErrorInvalidAddress;
551
+ if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
552
+ throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
542
553
  }
543
554
  try {
544
- const { escrows } = await (0, graphql_request_1.default)(this.network.subgraphUrl, graphql_1.GET_FILTERED_ESCROWS_QUERY, {
545
- ...filter,
546
- });
547
- return escrows;
555
+ this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
556
+ return this.escrowContract.recordingOracle();
548
557
  }
549
558
  catch (e) {
550
559
  return (0, utils_1.throwError)(e);
551
560
  }
552
561
  }
553
562
  /**
554
- * Returns the recording oracle address of given escrow
563
+ * Returns the job launcher address of given escrow
555
564
  *
556
565
  * @param {string} escrowAddress - Address of the escrow.
557
- * @returns {Promise<string>} - Address of the recording oracle.
566
+ * @returns {Promise<string>} - Address of the job launcher.
558
567
  * @throws {Error} - An error object if an error occurred.
559
568
  */
560
- async getRecordingOracleAddress(escrowAddress) {
569
+ async getJobLauncherAddress(escrowAddress) {
561
570
  if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
562
571
  throw error_1.ErrorInvalidEscrowAddressProvided;
563
572
  }
@@ -566,20 +575,20 @@ class EscrowClient {
566
575
  }
567
576
  try {
568
577
  this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
569
- return this.escrowContract.recordingOracle();
578
+ return this.escrowContract.launcher();
570
579
  }
571
580
  catch (e) {
572
581
  return (0, utils_1.throwError)(e);
573
582
  }
574
583
  }
575
584
  /**
576
- * Returns the job launcher address of given escrow
585
+ * Returns the reputation oracle address of given escrow
577
586
  *
578
587
  * @param {string} escrowAddress - Address of the escrow.
579
- * @returns {Promise<string>} - Address of the job launcher.
588
+ * @returns {Promise<string>} - Address of the reputation oracle.
580
589
  * @throws {Error} - An error object if an error occurred.
581
590
  */
582
- async getJobLauncherAddress(escrowAddress) {
591
+ async getReputationOracleAddress(escrowAddress) {
583
592
  if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
584
593
  throw error_1.ErrorInvalidEscrowAddressProvided;
585
594
  }
@@ -588,7 +597,7 @@ class EscrowClient {
588
597
  }
589
598
  try {
590
599
  this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
591
- return this.escrowContract.launcher();
600
+ return this.escrowContract.reputationOracle();
592
601
  }
593
602
  catch (e) {
594
603
  return (0, utils_1.throwError)(e);
@@ -601,7 +610,7 @@ class EscrowClient {
601
610
  * @returns {Promise<string>} - Address of the reputation oracle.
602
611
  * @throws {Error} - An error object if an error occurred.
603
612
  */
604
- async getReputationOracleAddress(escrowAddress) {
613
+ async getExchangeOracleAddress(escrowAddress) {
605
614
  if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
606
615
  throw error_1.ErrorInvalidEscrowAddressProvided;
607
616
  }
@@ -610,7 +619,7 @@ class EscrowClient {
610
619
  }
611
620
  try {
612
621
  this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
613
- return this.escrowContract.reputationOracle();
622
+ return this.escrowContract.exchangeOracle();
614
623
  }
615
624
  catch (e) {
616
625
  return (0, utils_1.throwError)(e);
@@ -642,7 +651,7 @@ class EscrowClient {
642
651
  __decorate([
643
652
  decorators_1.requiresSigner,
644
653
  __metadata("design:type", Function),
645
- __metadata("design:paramtypes", [String, Array]),
654
+ __metadata("design:paramtypes", [String, Array, String]),
646
655
  __metadata("design:returntype", Promise)
647
656
  ], EscrowClient.prototype, "createEscrow", null);
648
657
  __decorate([
@@ -654,7 +663,7 @@ __decorate([
654
663
  __decorate([
655
664
  decorators_1.requiresSigner,
656
665
  __metadata("design:type", Function),
657
- __metadata("design:paramtypes", [String, Array, Object]),
666
+ __metadata("design:paramtypes", [String, Array, String, Object]),
658
667
  __metadata("design:returntype", Promise)
659
668
  ], EscrowClient.prototype, "createAndSetupEscrow", null);
660
669
  __decorate([
@@ -700,3 +709,81 @@ __decorate([
700
709
  __metadata("design:returntype", Promise)
701
710
  ], EscrowClient.prototype, "addTrustedHandlers", null);
702
711
  exports.EscrowClient = EscrowClient;
712
+ class EscrowUtils {
713
+ /**
714
+ * Returns the list of escrows for given filter
715
+ *
716
+ * @param {IEscrowsFilter} filter - Filter parameters.
717
+ * @returns {Promise<EscrowData[]>}
718
+ * @throws {Error} - An error object if an error occurred.
719
+ */
720
+ static async getEscrows(filter) {
721
+ if (!filter?.networks?.length) {
722
+ throw error_1.ErrorUnsupportedChainID;
723
+ }
724
+ if (filter.launcher && !ethers_1.ethers.utils.isAddress(filter.launcher)) {
725
+ throw error_1.ErrorInvalidAddress;
726
+ }
727
+ if (filter.recordingOracle &&
728
+ !ethers_1.ethers.utils.isAddress(filter.recordingOracle)) {
729
+ throw error_1.ErrorInvalidAddress;
730
+ }
731
+ if (filter.reputationOracle &&
732
+ !ethers_1.ethers.utils.isAddress(filter.reputationOracle)) {
733
+ throw error_1.ErrorInvalidAddress;
734
+ }
735
+ if (filter.exchangeOracle &&
736
+ !ethers_1.ethers.utils.isAddress(filter.exchangeOracle)) {
737
+ throw error_1.ErrorInvalidAddress;
738
+ }
739
+ try {
740
+ const escrowAddresses = [];
741
+ for (const chainId of filter.networks) {
742
+ const networkData = constants_1.NETWORKS[chainId];
743
+ if (!networkData) {
744
+ throw error_1.ErrorUnsupportedChainID;
745
+ }
746
+ const { escrows } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, graphql_1.GET_ESCROWS_QUERY)(filter), {
747
+ ...filter,
748
+ status: filter.status
749
+ ? Object.entries(types_1.EscrowStatus).find(([, value]) => value === filter.status)?.[0]
750
+ : undefined,
751
+ from: filter.from ? +filter.from.getTime() / 1000 : undefined,
752
+ to: filter.to ? +filter.to.getTime() / 1000 : undefined,
753
+ });
754
+ escrows.map((escrow) => (escrow.chainId = networkData.chainId));
755
+ escrowAddresses.push(...escrows);
756
+ }
757
+ escrowAddresses.sort((a, b) => Number(b.createdAt) - Number(a.createdAt));
758
+ return escrowAddresses;
759
+ }
760
+ catch (e) {
761
+ return (0, utils_1.throwError)(e);
762
+ }
763
+ }
764
+ /**
765
+ * Returns the escrow for a given address
766
+ *
767
+ * @param {string} escrowAddress - Escrow address.
768
+ * @param {ChainId} chainId - Chain id.
769
+ * @returns {Promise<EscrowData>}
770
+ * @throws {Error} - An error object if an error occurred.
771
+ */
772
+ static async getEscrow(chainId, escrowAddress) {
773
+ const networkData = constants_1.NETWORKS[chainId];
774
+ if (!networkData) {
775
+ throw error_1.ErrorUnsupportedChainID;
776
+ }
777
+ if (escrowAddress && !ethers_1.ethers.utils.isAddress(escrowAddress)) {
778
+ throw error_1.ErrorInvalidAddress;
779
+ }
780
+ try {
781
+ const { escrow } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, graphql_1.GET_ESCROW_BY_ADDRESS_QUERY)(), { escrowAddress });
782
+ return escrow || null;
783
+ }
784
+ catch (e) {
785
+ return (0, utils_1.throwError)(e);
786
+ }
787
+ }
788
+ }
789
+ exports.EscrowUtils = EscrowUtils;
@@ -1,3 +1,4 @@
1
- export declare const GET_ESCROWS_BY_LAUNCHER_QUERY: import("graphql").DocumentNode;
2
- export declare const GET_FILTERED_ESCROWS_QUERY: import("graphql").DocumentNode;
1
+ import { IEscrowsFilter } from '../../interfaces';
2
+ export declare const GET_ESCROW_BY_ADDRESS_QUERY: () => import("graphql").DocumentNode;
3
+ export declare const GET_ESCROWS_QUERY: (filter: IEscrowsFilter) => import("graphql").DocumentNode;
3
4
  //# sourceMappingURL=escrow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/escrow.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,6BAA6B,gCAOzC,CAAC;AAEF,eAAO,MAAM,0BAA0B,gCAmBtC,CAAC"}
1
+ {"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA6BlD,eAAO,MAAM,2BAA2B,sCAOvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,cAAc,mCA4CvD,CAAC"}