@human-protocol/sdk 1.1.11 → 1.1.13
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/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -14
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +10 -2
- package/dist/escrow.d.ts +31 -11
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +133 -37
- 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 +49 -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 +24 -2
- 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.map +1 -1
- package/dist/statistics.js +2 -8
- 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 +18 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +16 -14
- package/src/error.ts +14 -0
- package/src/escrow.ts +189 -46
- package/src/graphql/queries/escrow.ts +26 -2
- package/src/graphql/queries/index.ts +1 -0
- package/src/graphql/queries/payout.ts +47 -0
- package/src/graphql/queries/staking.ts +57 -0
- package/src/graphql/queries/statistics.ts +10 -2
- package/src/graphql/types.ts +29 -2
- package/src/index.ts +2 -1
- package/src/interfaces.ts +35 -14
- package/src/staking.ts +23 -53
- package/src/statistics.ts +2 -12
- package/src/storage.ts +3 -0
- package/src/types.ts +20 -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.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;GAEG;AACH,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,gBAAgB,MAAM;IACtB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,qBAAqB,MAAM;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE;KACpB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;GAEG;AACH,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,gBAAgB,MAAM;IACtB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,qBAAqB,MAAM;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE;KACpB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW;CA4LnC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -165,27 +165,27 @@ exports.NETWORKS = {
|
|
|
165
165
|
chainId: enums_1.ChainId.AVALANCHE_TESTNET,
|
|
166
166
|
title: 'Fuji C-Chain',
|
|
167
167
|
scanUrl: 'https://testnet.snowtrace.io',
|
|
168
|
-
factoryAddress: '
|
|
168
|
+
factoryAddress: '0x56C2ba540726ED4f46E7a134b6b9Ee9C867FcF92',
|
|
169
169
|
hmtAddress: '0x9406d5c635AD22b0d76c75E52De57A2177919ca3',
|
|
170
|
-
stakingAddress: '',
|
|
171
|
-
rewardPoolAddress: '',
|
|
172
|
-
kvstoreAddress: '
|
|
173
|
-
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
|
|
174
|
-
oldSubgraphUrl: '',
|
|
175
|
-
oldFactoryAddress: '',
|
|
170
|
+
stakingAddress: '0x9890473B0b93E24d6D1a8Dfb739D577C6f25FFd3',
|
|
171
|
+
rewardPoolAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
|
|
172
|
+
kvstoreAddress: '0x707fb5A5d36BC15275Af3f73262bf9a1D8C470EB',
|
|
173
|
+
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji-v2',
|
|
174
|
+
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
|
|
175
|
+
oldFactoryAddress: '0xfb4469201951C3B9a7F1996c477cb7BDBEcE0A88',
|
|
176
176
|
},
|
|
177
177
|
[enums_1.ChainId.AVALANCHE]: {
|
|
178
178
|
chainId: enums_1.ChainId.AVALANCHE,
|
|
179
179
|
title: 'Avalanche C-Chain Mainnet',
|
|
180
180
|
scanUrl: 'https://snowtrace.io',
|
|
181
|
-
factoryAddress: '
|
|
181
|
+
factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
|
|
182
182
|
hmtAddress: '0x12365293cb6477d4fc2686e46BB97E3Fb64f1550',
|
|
183
|
-
stakingAddress: '',
|
|
184
|
-
rewardPoolAddress: '',
|
|
185
|
-
kvstoreAddress: '
|
|
186
|
-
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
|
|
187
|
-
oldSubgraphUrl: '',
|
|
188
|
-
oldFactoryAddress: '',
|
|
183
|
+
stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
|
|
184
|
+
rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
|
|
185
|
+
kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
|
|
186
|
+
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche-v2',
|
|
187
|
+
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
|
|
188
|
+
oldFactoryAddress: '0x9767a578ba7a5FA1563c8229943cB01cd8446BB4',
|
|
189
189
|
},
|
|
190
190
|
[enums_1.ChainId.SKALE]: {
|
|
191
191
|
chainId: enums_1.ChainId.SKALE,
|
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
|
*/
|
|
@@ -103,6 +107,10 @@ export declare const ErrorSigner: Error;
|
|
|
103
107
|
* @constant {Error} - Escrow address is not provided by the factory.
|
|
104
108
|
*/
|
|
105
109
|
export declare const ErrorEscrowAddressIsNotProvidedByFactory: Error;
|
|
110
|
+
/**
|
|
111
|
+
* @constant {Error} - Transfer event not found in transaction logs.
|
|
112
|
+
*/
|
|
113
|
+
export declare const ErrorTransferEventNotFoundInTransactionLogs: Error;
|
|
106
114
|
/**
|
|
107
115
|
* @constant {Error} - Manifest file does not exist.
|
|
108
116
|
*/
|
package/dist/error.d.ts.map
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,eAAO,MAAM,gCAAgC,OAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC,OAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC,OAE/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,OAE1C,CAAC;AAEF;;GAEG;AACH,eAAO,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.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.ErrorTransferEventNotFoundInTransactionLogs = 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 = exports.NonceExpired = 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
|
*/
|
|
@@ -107,6 +111,10 @@ exports.ErrorSigner = new Error('Signer required');
|
|
|
107
111
|
* @constant {Error} - Escrow address is not provided by the factory.
|
|
108
112
|
*/
|
|
109
113
|
exports.ErrorEscrowAddressIsNotProvidedByFactory = new Error('Escrow address is not provided by the factory');
|
|
114
|
+
/**
|
|
115
|
+
* @constant {Error} - Transfer event not found in transaction logs.
|
|
116
|
+
*/
|
|
117
|
+
exports.ErrorTransferEventNotFoundInTransactionLogs = new Error('Transfer event not found in transaction logs');
|
|
110
118
|
/**
|
|
111
119
|
* @constant {Error} - Manifest file does not exist.
|
|
112
120
|
*/
|
package/dist/escrow.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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
|
-
import { EscrowStatus, NetworkData } from './types';
|
|
5
|
+
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
5
6
|
import { EscrowData } from './graphql';
|
|
6
7
|
export declare class EscrowClient {
|
|
7
8
|
private escrowFactoryContract;
|
|
@@ -97,10 +98,10 @@ export declare class EscrowClient {
|
|
|
97
98
|
* Cancels the specified escrow and sends the balance to the canceler.
|
|
98
99
|
*
|
|
99
100
|
* @param {string} escrowAddress - Address of the escrow.
|
|
100
|
-
* @returns {Promise<
|
|
101
|
+
* @returns {Promise<EscrowCancel>}
|
|
101
102
|
* @throws {Error} - An error object if an error occurred.
|
|
102
103
|
*/
|
|
103
|
-
cancel(escrowAddress: string): Promise<
|
|
104
|
+
cancel(escrowAddress: string): Promise<EscrowCancel>;
|
|
104
105
|
/**
|
|
105
106
|
* Cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
|
|
106
107
|
*
|
|
@@ -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,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;AAIpE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAyBlC,OAAO,EA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,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) {
|
|
@@ -303,7 +309,7 @@ class EscrowClient {
|
|
|
303
309
|
* Cancels the specified escrow and sends the balance to the canceler.
|
|
304
310
|
*
|
|
305
311
|
* @param {string} escrowAddress - Address of the escrow.
|
|
306
|
-
* @returns {Promise<
|
|
312
|
+
* @returns {Promise<EscrowCancel>}
|
|
307
313
|
* @throws {Error} - An error object if an error occurred.
|
|
308
314
|
*/
|
|
309
315
|
async cancel(escrowAddress) {
|
|
@@ -315,8 +321,29 @@ class EscrowClient {
|
|
|
315
321
|
}
|
|
316
322
|
try {
|
|
317
323
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
318
|
-
await this.escrowContract.cancel();
|
|
319
|
-
|
|
324
|
+
const tx = await this.escrowContract.cancel();
|
|
325
|
+
const transactionReceipt = await tx.wait();
|
|
326
|
+
let amountTransferred = undefined;
|
|
327
|
+
const tokenAddress = await this.escrowContract.token();
|
|
328
|
+
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.signerOrProvider);
|
|
329
|
+
for (const log of transactionReceipt.logs) {
|
|
330
|
+
if (log.address === tokenAddress) {
|
|
331
|
+
const parsedLog = tokenContract.interface.parseLog(log);
|
|
332
|
+
const from = parsedLog.args[0];
|
|
333
|
+
if (parsedLog.name === 'Transfer' && from === escrowAddress) {
|
|
334
|
+
amountTransferred = parsedLog.args[2];
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (amountTransferred === undefined) {
|
|
340
|
+
throw error_1.ErrorTransferEventNotFoundInTransactionLogs;
|
|
341
|
+
}
|
|
342
|
+
const escrowCancelData = {
|
|
343
|
+
txHash: transactionReceipt.transactionHash,
|
|
344
|
+
amountRefunded: amountTransferred,
|
|
345
|
+
};
|
|
346
|
+
return escrowCancelData;
|
|
320
347
|
}
|
|
321
348
|
catch (e) {
|
|
322
349
|
return (0, utils_1.throwError)(e);
|
|
@@ -532,44 +559,35 @@ class EscrowClient {
|
|
|
532
559
|
}
|
|
533
560
|
}
|
|
534
561
|
/**
|
|
535
|
-
* Returns the
|
|
562
|
+
* Returns the recording oracle address of given escrow
|
|
536
563
|
*
|
|
537
|
-
* @param {
|
|
538
|
-
* @returns {Promise<
|
|
564
|
+
* @param {string} escrowAddress - Address of the escrow.
|
|
565
|
+
* @returns {Promise<string>} - Address of the recording oracle.
|
|
539
566
|
* @throws {Error} - An error object if an error occurred.
|
|
540
567
|
*/
|
|
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;
|
|
568
|
+
async getRecordingOracleAddress(escrowAddress) {
|
|
569
|
+
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
570
|
+
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
548
571
|
}
|
|
549
|
-
if (
|
|
550
|
-
|
|
551
|
-
throw error_1.ErrorInvalidAddress;
|
|
572
|
+
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
573
|
+
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
552
574
|
}
|
|
553
575
|
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;
|
|
576
|
+
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
577
|
+
return this.escrowContract.recordingOracle();
|
|
560
578
|
}
|
|
561
579
|
catch (e) {
|
|
562
580
|
return (0, utils_1.throwError)(e);
|
|
563
581
|
}
|
|
564
582
|
}
|
|
565
583
|
/**
|
|
566
|
-
* Returns the
|
|
584
|
+
* Returns the job launcher address of given escrow
|
|
567
585
|
*
|
|
568
586
|
* @param {string} escrowAddress - Address of the escrow.
|
|
569
|
-
* @returns {Promise<string>} - Address of the
|
|
587
|
+
* @returns {Promise<string>} - Address of the job launcher.
|
|
570
588
|
* @throws {Error} - An error object if an error occurred.
|
|
571
589
|
*/
|
|
572
|
-
async
|
|
590
|
+
async getJobLauncherAddress(escrowAddress) {
|
|
573
591
|
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
574
592
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
575
593
|
}
|
|
@@ -578,20 +596,20 @@ class EscrowClient {
|
|
|
578
596
|
}
|
|
579
597
|
try {
|
|
580
598
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
581
|
-
return this.escrowContract.
|
|
599
|
+
return this.escrowContract.launcher();
|
|
582
600
|
}
|
|
583
601
|
catch (e) {
|
|
584
602
|
return (0, utils_1.throwError)(e);
|
|
585
603
|
}
|
|
586
604
|
}
|
|
587
605
|
/**
|
|
588
|
-
* Returns the
|
|
606
|
+
* Returns the reputation oracle address of given escrow
|
|
589
607
|
*
|
|
590
608
|
* @param {string} escrowAddress - Address of the escrow.
|
|
591
|
-
* @returns {Promise<string>} - Address of the
|
|
609
|
+
* @returns {Promise<string>} - Address of the reputation oracle.
|
|
592
610
|
* @throws {Error} - An error object if an error occurred.
|
|
593
611
|
*/
|
|
594
|
-
async
|
|
612
|
+
async getReputationOracleAddress(escrowAddress) {
|
|
595
613
|
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
596
614
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
597
615
|
}
|
|
@@ -600,7 +618,7 @@ class EscrowClient {
|
|
|
600
618
|
}
|
|
601
619
|
try {
|
|
602
620
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
603
|
-
return this.escrowContract.
|
|
621
|
+
return this.escrowContract.reputationOracle();
|
|
604
622
|
}
|
|
605
623
|
catch (e) {
|
|
606
624
|
return (0, utils_1.throwError)(e);
|
|
@@ -613,7 +631,7 @@ class EscrowClient {
|
|
|
613
631
|
* @returns {Promise<string>} - Address of the reputation oracle.
|
|
614
632
|
* @throws {Error} - An error object if an error occurred.
|
|
615
633
|
*/
|
|
616
|
-
async
|
|
634
|
+
async getExchangeOracleAddress(escrowAddress) {
|
|
617
635
|
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
618
636
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
619
637
|
}
|
|
@@ -622,7 +640,7 @@ class EscrowClient {
|
|
|
622
640
|
}
|
|
623
641
|
try {
|
|
624
642
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
625
|
-
return this.escrowContract.
|
|
643
|
+
return this.escrowContract.exchangeOracle();
|
|
626
644
|
}
|
|
627
645
|
catch (e) {
|
|
628
646
|
return (0, utils_1.throwError)(e);
|
|
@@ -712,3 +730,81 @@ __decorate([
|
|
|
712
730
|
__metadata("design:returntype", Promise)
|
|
713
731
|
], EscrowClient.prototype, "addTrustedHandlers", null);
|
|
714
732
|
exports.EscrowClient = EscrowClient;
|
|
733
|
+
class EscrowUtils {
|
|
734
|
+
/**
|
|
735
|
+
* Returns the list of escrows for given filter
|
|
736
|
+
*
|
|
737
|
+
* @param {IEscrowsFilter} filter - Filter parameters.
|
|
738
|
+
* @returns {Promise<EscrowData[]>}
|
|
739
|
+
* @throws {Error} - An error object if an error occurred.
|
|
740
|
+
*/
|
|
741
|
+
static async getEscrows(filter) {
|
|
742
|
+
if (!filter?.networks?.length) {
|
|
743
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
744
|
+
}
|
|
745
|
+
if (filter.launcher && !ethers_1.ethers.utils.isAddress(filter.launcher)) {
|
|
746
|
+
throw error_1.ErrorInvalidAddress;
|
|
747
|
+
}
|
|
748
|
+
if (filter.recordingOracle &&
|
|
749
|
+
!ethers_1.ethers.utils.isAddress(filter.recordingOracle)) {
|
|
750
|
+
throw error_1.ErrorInvalidAddress;
|
|
751
|
+
}
|
|
752
|
+
if (filter.reputationOracle &&
|
|
753
|
+
!ethers_1.ethers.utils.isAddress(filter.reputationOracle)) {
|
|
754
|
+
throw error_1.ErrorInvalidAddress;
|
|
755
|
+
}
|
|
756
|
+
if (filter.exchangeOracle &&
|
|
757
|
+
!ethers_1.ethers.utils.isAddress(filter.exchangeOracle)) {
|
|
758
|
+
throw error_1.ErrorInvalidAddress;
|
|
759
|
+
}
|
|
760
|
+
try {
|
|
761
|
+
const escrowAddresses = [];
|
|
762
|
+
for (const chainId of filter.networks) {
|
|
763
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
764
|
+
if (!networkData) {
|
|
765
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
766
|
+
}
|
|
767
|
+
const { escrows } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, graphql_1.GET_ESCROWS_QUERY)(filter), {
|
|
768
|
+
...filter,
|
|
769
|
+
status: filter.status
|
|
770
|
+
? Object.entries(types_1.EscrowStatus).find(([, value]) => value === filter.status)?.[0]
|
|
771
|
+
: undefined,
|
|
772
|
+
from: filter.from ? +filter.from.getTime() / 1000 : undefined,
|
|
773
|
+
to: filter.to ? +filter.to.getTime() / 1000 : undefined,
|
|
774
|
+
});
|
|
775
|
+
escrows.map((escrow) => (escrow.chainId = networkData.chainId));
|
|
776
|
+
escrowAddresses.push(...escrows);
|
|
777
|
+
}
|
|
778
|
+
escrowAddresses.sort((a, b) => Number(b.createdAt) - Number(a.createdAt));
|
|
779
|
+
return escrowAddresses;
|
|
780
|
+
}
|
|
781
|
+
catch (e) {
|
|
782
|
+
return (0, utils_1.throwError)(e);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Returns the escrow for a given address
|
|
787
|
+
*
|
|
788
|
+
* @param {string} escrowAddress - Escrow address.
|
|
789
|
+
* @param {ChainId} chainId - Chain id.
|
|
790
|
+
* @returns {Promise<EscrowData>}
|
|
791
|
+
* @throws {Error} - An error object if an error occurred.
|
|
792
|
+
*/
|
|
793
|
+
static async getEscrow(chainId, escrowAddress) {
|
|
794
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
795
|
+
if (!networkData) {
|
|
796
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
797
|
+
}
|
|
798
|
+
if (escrowAddress && !ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
799
|
+
throw error_1.ErrorInvalidAddress;
|
|
800
|
+
}
|
|
801
|
+
try {
|
|
802
|
+
const { escrow } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, graphql_1.GET_ESCROW_BY_ADDRESS_QUERY)(), { escrowAddress });
|
|
803
|
+
return escrow || null;
|
|
804
|
+
}
|
|
805
|
+
catch (e) {
|
|
806
|
+
return (0, utils_1.throwError)(e);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
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,mCAiCtD,CAAC"}
|