@human-protocol/sdk 1.1.11 → 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.
- package/README.md +2 -0
- package/dist/error.d.ts +4 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +6 -2
- package/dist/escrow.d.ts +28 -8
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +109 -34
- package/dist/graphql/queries/escrow.d.ts +1 -0
- package/dist/graphql/queries/escrow.d.ts.map +1 -1
- package/dist/graphql/queries/escrow.js +18 -2
- package/dist/graphql/queries/index.d.ts +1 -0
- package/dist/graphql/queries/index.d.ts.map +1 -1
- package/dist/graphql/queries/index.js +1 -0
- package/dist/graphql/queries/payout.d.ts +3 -0
- package/dist/graphql/queries/payout.d.ts.map +1 -0
- package/dist/graphql/queries/payout.js +43 -0
- package/dist/graphql/queries/staking.d.ts +4 -0
- package/dist/graphql/queries/staking.d.ts.map +1 -0
- package/dist/graphql/queries/staking.js +58 -0
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +10 -2
- package/dist/graphql/types.d.ts +23 -0
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/interfaces.d.ts +34 -9
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/staking.d.ts +8 -8
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +16 -38
- package/dist/statistics.d.ts +19 -2
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +93 -13
- package/dist/storage.d.ts +3 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +3 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/error.ts +7 -0
- package/src/escrow.ts +152 -41
- package/src/graphql/queries/escrow.ts +26 -2
- package/src/graphql/queries/index.ts +1 -0
- package/src/graphql/queries/payout.ts +41 -0
- package/src/graphql/queries/staking.ts +57 -0
- package/src/graphql/queries/statistics.ts +10 -2
- package/src/graphql/types.ts +28 -0
- package/src/index.ts +2 -1
- package/src/interfaces.ts +35 -14
- package/src/staking.ts +23 -53
- package/src/statistics.ts +133 -17
- package/src/storage.ts +3 -0
- 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/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
|
*/
|
package/dist/error.d.ts.map
CHANGED
|
@@ -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;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AAO,MAAM,wCAAwC,OAEpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,OAE1C,CAAC;AAEF;;GAEG;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.
|
|
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';
|
|
@@ -174,14 +175,6 @@ export declare class EscrowClient {
|
|
|
174
175
|
* @throws {Error} - An error object if an error occurred.
|
|
175
176
|
*/
|
|
176
177
|
getStatus(escrowAddress: string): Promise<EscrowStatus>;
|
|
177
|
-
/**
|
|
178
|
-
* Returns the list of escrows for given filter
|
|
179
|
-
*
|
|
180
|
-
* @param {IEscrowsFilter} filter - Filter parameters.
|
|
181
|
-
* @returns {Promise<EscrowData[]>}
|
|
182
|
-
* @throws {Error} - An error object if an error occurred.
|
|
183
|
-
*/
|
|
184
|
-
getEscrows(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
|
package/dist/escrow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAU5D,OAAO,EAAE,SAAS,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAU5D,OAAO,EAAE,SAAS,EAAm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E,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 {
|
|
@@ -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) ||
|
|
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) {
|
|
@@ -532,44 +538,35 @@ class EscrowClient {
|
|
|
532
538
|
}
|
|
533
539
|
}
|
|
534
540
|
/**
|
|
535
|
-
* Returns the
|
|
541
|
+
* Returns the recording oracle address of given escrow
|
|
536
542
|
*
|
|
537
|
-
* @param {
|
|
538
|
-
* @returns {Promise<
|
|
543
|
+
* @param {string} escrowAddress - Address of the escrow.
|
|
544
|
+
* @returns {Promise<string>} - Address of the recording oracle.
|
|
539
545
|
* @throws {Error} - An error object if an error occurred.
|
|
540
546
|
*/
|
|
541
|
-
async
|
|
542
|
-
if (
|
|
543
|
-
throw error_1.
|
|
544
|
-
}
|
|
545
|
-
if (filter.recordingOracle &&
|
|
546
|
-
!ethers_1.ethers.utils.isAddress(filter.recordingOracle)) {
|
|
547
|
-
throw error_1.ErrorInvalidAddress;
|
|
547
|
+
async getRecordingOracleAddress(escrowAddress) {
|
|
548
|
+
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
549
|
+
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
548
550
|
}
|
|
549
|
-
if (
|
|
550
|
-
|
|
551
|
-
throw error_1.ErrorInvalidAddress;
|
|
551
|
+
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
552
|
+
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
552
553
|
}
|
|
553
554
|
try {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
from: filter.from ? +filter.from.getTime() / 1000 : undefined,
|
|
557
|
-
to: filter.to ? +filter.to.getTime() / 1000 : undefined,
|
|
558
|
-
});
|
|
559
|
-
return escrows;
|
|
555
|
+
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
556
|
+
return this.escrowContract.recordingOracle();
|
|
560
557
|
}
|
|
561
558
|
catch (e) {
|
|
562
559
|
return (0, utils_1.throwError)(e);
|
|
563
560
|
}
|
|
564
561
|
}
|
|
565
562
|
/**
|
|
566
|
-
* Returns the
|
|
563
|
+
* Returns the job launcher address of given escrow
|
|
567
564
|
*
|
|
568
565
|
* @param {string} escrowAddress - Address of the escrow.
|
|
569
|
-
* @returns {Promise<string>} - Address of the
|
|
566
|
+
* @returns {Promise<string>} - Address of the job launcher.
|
|
570
567
|
* @throws {Error} - An error object if an error occurred.
|
|
571
568
|
*/
|
|
572
|
-
async
|
|
569
|
+
async getJobLauncherAddress(escrowAddress) {
|
|
573
570
|
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
574
571
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
575
572
|
}
|
|
@@ -578,20 +575,20 @@ class EscrowClient {
|
|
|
578
575
|
}
|
|
579
576
|
try {
|
|
580
577
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
581
|
-
return this.escrowContract.
|
|
578
|
+
return this.escrowContract.launcher();
|
|
582
579
|
}
|
|
583
580
|
catch (e) {
|
|
584
581
|
return (0, utils_1.throwError)(e);
|
|
585
582
|
}
|
|
586
583
|
}
|
|
587
584
|
/**
|
|
588
|
-
* Returns the
|
|
585
|
+
* Returns the reputation oracle address of given escrow
|
|
589
586
|
*
|
|
590
587
|
* @param {string} escrowAddress - Address of the escrow.
|
|
591
|
-
* @returns {Promise<string>} - Address of the
|
|
588
|
+
* @returns {Promise<string>} - Address of the reputation oracle.
|
|
592
589
|
* @throws {Error} - An error object if an error occurred.
|
|
593
590
|
*/
|
|
594
|
-
async
|
|
591
|
+
async getReputationOracleAddress(escrowAddress) {
|
|
595
592
|
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
596
593
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
597
594
|
}
|
|
@@ -600,7 +597,7 @@ class EscrowClient {
|
|
|
600
597
|
}
|
|
601
598
|
try {
|
|
602
599
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
603
|
-
return this.escrowContract.
|
|
600
|
+
return this.escrowContract.reputationOracle();
|
|
604
601
|
}
|
|
605
602
|
catch (e) {
|
|
606
603
|
return (0, utils_1.throwError)(e);
|
|
@@ -613,7 +610,7 @@ class EscrowClient {
|
|
|
613
610
|
* @returns {Promise<string>} - Address of the reputation oracle.
|
|
614
611
|
* @throws {Error} - An error object if an error occurred.
|
|
615
612
|
*/
|
|
616
|
-
async
|
|
613
|
+
async getExchangeOracleAddress(escrowAddress) {
|
|
617
614
|
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
618
615
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
619
616
|
}
|
|
@@ -622,7 +619,7 @@ class EscrowClient {
|
|
|
622
619
|
}
|
|
623
620
|
try {
|
|
624
621
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
625
|
-
return this.escrowContract.
|
|
622
|
+
return this.escrowContract.exchangeOracle();
|
|
626
623
|
}
|
|
627
624
|
catch (e) {
|
|
628
625
|
return (0, utils_1.throwError)(e);
|
|
@@ -712,3 +709,81 @@ __decorate([
|
|
|
712
709
|
__metadata("design:returntype", Promise)
|
|
713
710
|
], EscrowClient.prototype, "addTrustedHandlers", null);
|
|
714
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
1
|
import { IEscrowsFilter } from '../../interfaces';
|
|
2
|
+
export declare const GET_ESCROW_BY_ADDRESS_QUERY: () => import("graphql").DocumentNode;
|
|
2
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":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,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"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GET_ESCROWS_QUERY = void 0;
|
|
6
|
+
exports.GET_ESCROWS_QUERY = exports.GET_ESCROW_BY_ADDRESS_QUERY = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const ESCROW_FRAGMENT = (0, graphql_tag_1.default) `
|
|
9
9
|
fragment EscrowFields on Escrow {
|
|
@@ -15,6 +15,7 @@ const ESCROW_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
15
15
|
finalResultsUrl
|
|
16
16
|
id
|
|
17
17
|
intermediateResultsUrl
|
|
18
|
+
jobRequesterId
|
|
18
19
|
launcher
|
|
19
20
|
manifestHash
|
|
20
21
|
manifestUrl
|
|
@@ -22,19 +23,32 @@ const ESCROW_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
22
23
|
recordingOracleFee
|
|
23
24
|
reputationOracle
|
|
24
25
|
reputationOracleFee
|
|
26
|
+
exchangeOracle
|
|
27
|
+
exchangeOracleFee
|
|
25
28
|
status
|
|
26
29
|
token
|
|
27
30
|
totalFundedAmount
|
|
28
31
|
createdAt
|
|
29
32
|
}
|
|
30
33
|
`;
|
|
34
|
+
const GET_ESCROW_BY_ADDRESS_QUERY = () => (0, graphql_tag_1.default) `
|
|
35
|
+
query getEscrowByAddress($escrowAddress: String!) {
|
|
36
|
+
escrow(id: $escrowAddress) {
|
|
37
|
+
...EscrowFields
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
${ESCROW_FRAGMENT}
|
|
41
|
+
`;
|
|
42
|
+
exports.GET_ESCROW_BY_ADDRESS_QUERY = GET_ESCROW_BY_ADDRESS_QUERY;
|
|
31
43
|
const GET_ESCROWS_QUERY = (filter) => {
|
|
32
|
-
const { launcher, reputationOracle, recordingOracle, status, from, to } = filter;
|
|
44
|
+
const { launcher, jobRequesterId, reputationOracle, recordingOracle, exchangeOracle, status, from, to, } = filter;
|
|
33
45
|
const WHERE_CLAUSE = `
|
|
34
46
|
where: {
|
|
35
47
|
${launcher ? `launcher: $launcher` : ''}
|
|
48
|
+
${jobRequesterId ? `jobRequesterId: $jobRequesterId` : ''}
|
|
36
49
|
${reputationOracle ? `reputationOracle: $reputationOracle` : ''}
|
|
37
50
|
${recordingOracle ? `recordingOracle: $recordingOracle` : ''}
|
|
51
|
+
${exchangeOracle ? `exchangeOracle: $exchangeOracle` : ''}
|
|
38
52
|
${status ? `status: $status` : ''}
|
|
39
53
|
${from ? `createdAt_gte: $from` : ''}
|
|
40
54
|
${to ? `createdAt_lte: $to` : ''}
|
|
@@ -43,8 +57,10 @@ const GET_ESCROWS_QUERY = (filter) => {
|
|
|
43
57
|
return (0, graphql_tag_1.default) `
|
|
44
58
|
query getEscrows(
|
|
45
59
|
$launcher: String
|
|
60
|
+
$jobRequesterId: String
|
|
46
61
|
$reputationOracle: String
|
|
47
62
|
$recordingOracle: String
|
|
63
|
+
$exchangeOracle: String
|
|
48
64
|
$status: String
|
|
49
65
|
$from: Int
|
|
50
66
|
$to: Int
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payout.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/payout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYjD,eAAO,MAAM,iBAAiB,WAAY,aAAa,mCA2BtD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GET_PAYOUTS_QUERY = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const PAYOUT_FRAGMENT = (0, graphql_tag_1.default) `
|
|
9
|
+
fragment PayoutFields on Payout {
|
|
10
|
+
id
|
|
11
|
+
escrowAddress
|
|
12
|
+
recipient
|
|
13
|
+
amount
|
|
14
|
+
createdAt
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
const GET_PAYOUTS_QUERY = (filter) => {
|
|
18
|
+
const { escrowAddress, recipient, from, to } = filter;
|
|
19
|
+
const WHERE_CLAUSE = `
|
|
20
|
+
where: {
|
|
21
|
+
${escrowAddress ? `escrowAddress: $escrowAddress` : ''}
|
|
22
|
+
${recipient ? `recipient: $recipient` : ''}
|
|
23
|
+
${from ? `createdAt_gte: $from` : ''}
|
|
24
|
+
${to ? `createdAt_lte: $to` : ''}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
return (0, graphql_tag_1.default) `
|
|
28
|
+
query getPayouts(
|
|
29
|
+
$escrowAddress: String
|
|
30
|
+
$recipient: String
|
|
31
|
+
$from: Int
|
|
32
|
+
$to: Int
|
|
33
|
+
) {
|
|
34
|
+
payouts(
|
|
35
|
+
${WHERE_CLAUSE}
|
|
36
|
+
) {
|
|
37
|
+
...PayoutFields
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
${PAYOUT_FRAGMENT}
|
|
41
|
+
`;
|
|
42
|
+
};
|
|
43
|
+
exports.GET_PAYOUTS_QUERY = GET_PAYOUTS_QUERY;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/staking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAuBhD,eAAO,MAAM,iBAAiB,WAAY,cAAc,mCAuBvD,CAAC;AAEF,eAAO,MAAM,gBAAgB,gCAO5B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GET_LEADER_QUERY = exports.GET_LEADERS_QUERY = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const LEADER_FRAGMENT = (0, graphql_tag_1.default) `
|
|
9
|
+
fragment LeaderFields on Leader {
|
|
10
|
+
id
|
|
11
|
+
address
|
|
12
|
+
amountStaked
|
|
13
|
+
amountAllocated
|
|
14
|
+
amountLocked
|
|
15
|
+
lockedUntilTimestamp
|
|
16
|
+
amountWithdrawn
|
|
17
|
+
amountSlashed
|
|
18
|
+
reputation
|
|
19
|
+
reward
|
|
20
|
+
amountJobsLaunched
|
|
21
|
+
role
|
|
22
|
+
fee
|
|
23
|
+
publicKey
|
|
24
|
+
webhookUrl
|
|
25
|
+
url
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const GET_LEADERS_QUERY = (filter) => {
|
|
29
|
+
const { role } = filter;
|
|
30
|
+
const WHERE_CLAUSE = `
|
|
31
|
+
where: {
|
|
32
|
+
${role ? `role: $role` : ''}
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
return (0, graphql_tag_1.default) `
|
|
36
|
+
query getLeaders(
|
|
37
|
+
$role: String
|
|
38
|
+
) {
|
|
39
|
+
leaders(
|
|
40
|
+
${WHERE_CLAUSE}
|
|
41
|
+
orderBy: amountStaked,
|
|
42
|
+
orderDirection: desc,
|
|
43
|
+
) {
|
|
44
|
+
...LeaderFields
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
${LEADER_FRAGMENT}
|
|
48
|
+
`;
|
|
49
|
+
};
|
|
50
|
+
exports.GET_LEADERS_QUERY = GET_LEADERS_QUERY;
|
|
51
|
+
exports.GET_LEADER_QUERY = (0, graphql_tag_1.default) `
|
|
52
|
+
query getLeader($address: String!) {
|
|
53
|
+
leader(id: $address) {
|
|
54
|
+
...LeaderFields
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
${LEADER_FRAGMENT}
|
|
58
|
+
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAmDrD,eAAO,MAAM,4BAA4B,gCAOxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,gCAOvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAAY,iBAAiB,
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAmDrD,eAAO,MAAM,4BAA4B,gCAOxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,gCAOvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAAY,iBAAiB,mCAyBjE,CAAC"}
|
|
@@ -68,16 +68,24 @@ exports.GET_ESCROW_STATISTICS_QUERY = (0, graphql_tag_1.default) `
|
|
|
68
68
|
${ESCROW_STATISTICS_FRAGMENT}
|
|
69
69
|
`;
|
|
70
70
|
const GET_EVENT_DAY_DATA_QUERY = (params) => {
|
|
71
|
-
const { from, to } = params;
|
|
71
|
+
const { from, to, limit } = params;
|
|
72
72
|
const WHERE_CLAUSE = `
|
|
73
73
|
where: {
|
|
74
74
|
${from !== undefined ? `timestamp_gte: $from` : ''}
|
|
75
75
|
${to !== undefined ? `timestamp_lte: $to` : ''}
|
|
76
76
|
}
|
|
77
|
+
`;
|
|
78
|
+
const LIMIT_CLAUSE = `
|
|
79
|
+
first: ${limit ? `$limit` : `1000`}
|
|
77
80
|
`;
|
|
78
81
|
return (0, graphql_tag_1.default) `
|
|
79
82
|
query GetEscrowDayData($from: Int, $to: Int) {
|
|
80
|
-
eventDayDatas(
|
|
83
|
+
eventDayDatas(
|
|
84
|
+
${WHERE_CLAUSE},
|
|
85
|
+
orderBy: timestamp,
|
|
86
|
+
orderDirection: desc,
|
|
87
|
+
${LIMIT_CLAUSE}
|
|
88
|
+
) {
|
|
81
89
|
...EventDayDataFields
|
|
82
90
|
}
|
|
83
91
|
}
|