@human-protocol/sdk 3.0.0 → 3.0.1
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 +23 -80
- package/dist/enums.d.ts +4 -0
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +6 -1
- package/dist/error.d.ts +7 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +8 -1
- package/dist/escrow.d.ts +90 -5
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +153 -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 +50 -9
- package/dist/graphql/queries/hmtoken.d.ts +1 -1
- package/dist/graphql/queries/hmtoken.d.ts.map +1 -1
- package/dist/graphql/queries/hmtoken.js +23 -7
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +2 -0
- package/dist/graphql/queries/transaction.d.ts.map +1 -1
- package/dist/graphql/queries/transaction.js +12 -7
- package/dist/graphql/types.d.ts +11 -0
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/interfaces.d.ts +15 -6
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +1 -1
- package/dist/kvstore.js +1 -1
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +64 -81
- package/dist/statistics.d.ts +28 -2
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +46 -1
- package/dist/transaction.d.ts +10 -4
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +36 -27
- package/package.json +5 -4
- package/src/enums.ts +5 -0
- package/src/error.ts +8 -0
- package/src/escrow.ts +197 -48
- package/src/graphql/queries/escrow.ts +53 -8
- package/src/graphql/queries/hmtoken.ts +23 -7
- package/src/graphql/queries/statistics.ts +2 -0
- package/src/graphql/queries/transaction.ts +12 -7
- package/src/graphql/types.ts +13 -0
- package/src/index.ts +2 -0
- package/src/interfaces.ts +17 -6
- package/src/kvstore.ts +1 -1
- package/src/operator.ts +79 -91
- package/src/statistics.ts +54 -2
- package/src/transaction.ts +40 -30
package/README.md
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://www.humanprotocol.org/" target="blank"><img src="https://s2.coinmarketcap.com/static/img/coins/64x64/10347.png" width="100" alt="Human Protocol" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
|
6
|
+
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
|
7
|
+
|
|
8
|
+
<h1 align="center">Human Protocol Node.js SDK</h1>
|
|
9
|
+
<p align="center">Node.js SDK to launch/manage escrows on <a href="https://www.humanprotocol.org/">Human Protocol</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-node-sdk.yaml">
|
|
14
|
+
<img src="https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-node-sdk.yaml/badge.svg?branch=main" alt="Node SDK Check">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://github.com/humanprotocol/human-protocol/actions/workflows/cd-node-sdk.yaml">
|
|
17
|
+
<img src="https://github.com/humanprotocol/human-protocol/actions/workflows/cd-node-sdk.yaml/badge.svg?event=release" alt="Node SDK deployment">
|
|
18
|
+
</a>
|
|
19
|
+
</p>
|
|
4
20
|
|
|
5
21
|
## Installation
|
|
6
22
|
|
|
@@ -8,83 +24,10 @@ This SDK is available on [NPM](https://www.npmjs.com/package/@human-protocol/sdk
|
|
|
8
24
|
|
|
9
25
|
yarn add @human-protocol/sdk
|
|
10
26
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
- InitClient
|
|
14
|
-
|
|
15
|
-
**InitClient** has one static function that returns a `Signer` or `Provider` (depending on the passed parameter), as well as a chainId associated with this parameter in an asynchronous way. Used for further passing as a constructor parameter to Web3 dependent modules.
|
|
16
|
-
|
|
17
|
-
- StorageClient
|
|
18
|
-
|
|
19
|
-
**StorageClient** is used to upload/download files to the cloud storage with given credentials and params. If credentials are not provided, anonymous access will be used (for downloading files).
|
|
20
|
-
|
|
21
|
-
- EscrowClient
|
|
22
|
-
|
|
23
|
-
**EscrowClient** enables to perform actions on Escrow contracts and obtain information from both the contracts and subgraph. Internally, the SDK will use one network or another according to the network ID of the `signerOrProvider`.
|
|
24
|
-
|
|
25
|
-
- KVStoreClient
|
|
26
|
-
|
|
27
|
-
**KVStoreClient** enables to perform actions on KVStore contract and obtain information from both the contracts and subgraph. Internally, the SDK will use one network or another according to the network ID of the `signerOrProvider`.
|
|
28
|
-
|
|
29
|
-
- StakingClient
|
|
30
|
-
|
|
31
|
-
**StakingClient** enables to perform actions on staking contracts and obtain staking information from both the contracts and subgraph. Internally, the SDK will use one network or another according to the network ID of the `signerOrProvider`.
|
|
32
|
-
|
|
33
|
-
## Example
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
const {
|
|
37
|
-
EscrowClient,
|
|
38
|
-
StakingClient,
|
|
39
|
-
NETWORKS,
|
|
40
|
-
ChainId,
|
|
41
|
-
} = require('@human-protocol/sdk');
|
|
42
|
-
const { ethers } = require('ethers');
|
|
43
|
-
|
|
44
|
-
(async () => {
|
|
45
|
-
// Hardhat Provider
|
|
46
|
-
const provider = new ethers.providers.JsonRpcProvider(
|
|
47
|
-
'http://127.0.0.1:8545/'
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// Load localhost configuration
|
|
51
|
-
const network = NETWORKS[ChainId.LOCALHOST];
|
|
52
|
-
|
|
53
|
-
const signer = new ethers.Wallet(
|
|
54
|
-
'0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a',
|
|
55
|
-
provider
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
// Initialize StakingClient
|
|
59
|
-
const stakingClient = new StakingClient({
|
|
60
|
-
signerOrProvider: signer,
|
|
61
|
-
network,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Stake 10 HMT
|
|
65
|
-
await stakingClient.approveStake(ethers.BigNumber.from(10));
|
|
66
|
-
await stakingClient.stake(ethers.BigNumber.from(10));
|
|
27
|
+
## Documentation
|
|
67
28
|
|
|
68
|
-
|
|
69
|
-
const escrowClient = new EscrowClient({
|
|
70
|
-
signerOrProvider: signer,
|
|
71
|
-
network,
|
|
72
|
-
});
|
|
29
|
+
For detailed information about core, please refer to the [Human Protocol Docs](https://sdk.humanprotocol.org/).
|
|
73
30
|
|
|
74
|
-
|
|
75
|
-
const escrowAddress = await escrowClient.createEscrow(network.hmtAddress, [
|
|
76
|
-
signer.address,
|
|
77
|
-
]);
|
|
31
|
+
## License
|
|
78
32
|
|
|
79
|
-
|
|
80
|
-
recordingOracle: '0x90F79bf6EB2c4f870365E785982E1f101E93b906',
|
|
81
|
-
reputationOracle: '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65',
|
|
82
|
-
exchangeOracle: '0x6b7E3C31F34cF38d1DFC1D9A8A59482028395809',
|
|
83
|
-
recordingOracleFee: ethers.BigNumber.from(1),
|
|
84
|
-
reputationOracleFee: ethers.BigNumber.from(1),
|
|
85
|
-
exchangeOracleFee: ethers.BigNumber.from(1),
|
|
86
|
-
manifestUrl: 'http://example.com',
|
|
87
|
-
hash: 'test',
|
|
88
|
-
});
|
|
89
|
-
})();
|
|
90
|
-
```
|
|
33
|
+
This project is licensed under the MIT License. See the [LICENSE](https://github.com/humanprotocol/human-protocol/blob/main/LICENSE) file for details.
|
package/dist/enums.d.ts
CHANGED
package/dist/enums.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,GAAG,KAAK;IACR,OAAO,IAAI;IACX,OAAO,IAAI;IACX,MAAM,IAAI;IACV,OAAO,WAAW;IAClB,WAAW,KAAK;IAChB,WAAW,KAAK;IAChB,OAAO,MAAM;IACb,cAAc,QAAQ;IACtB,YAAY,QAAQ;IACpB,QAAQ,OAAO;IACf,cAAc,OAAO;IACrB,iBAAiB,QAAQ;IACzB,SAAS,QAAQ;IACjB,IAAI,QAAQ;IACZ,cAAc,QAAQ;IACtB,cAAc,MAAM;IACpB,SAAS,OAAO;IAChB,MAAM,MAAM;CACb"}
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,GAAG,KAAK;IACR,OAAO,IAAI;IACX,OAAO,IAAI;IACX,MAAM,IAAI;IACV,OAAO,WAAW;IAClB,WAAW,KAAK;IAChB,WAAW,KAAK;IAChB,OAAO,MAAM;IACb,cAAc,QAAQ;IACtB,YAAY,QAAQ;IACpB,QAAQ,OAAO;IACf,cAAc,OAAO;IACrB,iBAAiB,QAAQ;IACzB,SAAS,QAAQ;IACjB,IAAI,QAAQ;IACZ,cAAc,QAAQ;IACtB,cAAc,MAAM;IACpB,SAAS,OAAO;IAChB,MAAM,MAAM;CACb;AAED,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd"}
|
package/dist/enums.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChainId = void 0;
|
|
3
|
+
exports.OrderDirection = exports.ChainId = void 0;
|
|
4
4
|
var ChainId;
|
|
5
5
|
(function (ChainId) {
|
|
6
6
|
ChainId[ChainId["ALL"] = -1] = "ALL";
|
|
@@ -23,3 +23,8 @@ var ChainId;
|
|
|
23
23
|
ChainId[ChainId["LOCALHOST"] = 1338] = "LOCALHOST";
|
|
24
24
|
ChainId[ChainId["XLAYER"] = 196] = "XLAYER";
|
|
25
25
|
})(ChainId = exports.ChainId || (exports.ChainId = {}));
|
|
26
|
+
var OrderDirection;
|
|
27
|
+
(function (OrderDirection) {
|
|
28
|
+
OrderDirection["ASC"] = "asc";
|
|
29
|
+
OrderDirection["DESC"] = "desc";
|
|
30
|
+
})(OrderDirection = exports.OrderDirection || (exports.OrderDirection = {}));
|
package/dist/error.d.ts
CHANGED
|
@@ -207,5 +207,12 @@ export declare class InvalidEthereumAddressError extends Error {
|
|
|
207
207
|
* @constant {Error} - The Hash does not match
|
|
208
208
|
*/
|
|
209
209
|
export declare const ErrorInvalidHash: Error;
|
|
210
|
+
/**
|
|
211
|
+
* @constant {Error} - The Status is not supported
|
|
212
|
+
*/
|
|
213
|
+
export declare const ErrorUnsupportedStatus: Error;
|
|
214
|
+
/**
|
|
215
|
+
* @constant {Error} - The SUBGRAPH_API_KEY is not being provided
|
|
216
|
+
*/
|
|
210
217
|
export declare const WarnSubgraphApiKeyNotProvided = "\"SUBGRAPH_API_KEY\" is not being provided. It might cause issues with the subgraph.";
|
|
211
218
|
//# sourceMappingURL=error.d.ts.map
|
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;;GAEG;AACH,eAAO,MAAM,gCAAgC,OAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,OAEvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,OAE1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,OAAgC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAA8B,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,2BAA2B,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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,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;AACD;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAA4B,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,sBAAsB,OAA4C,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,6BAA6B,yFAC4C,CAAC"}
|
package/dist/error.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NumericFault = exports.ReplacementUnderpriced = 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.ErrorCannotUseDateAndBlockSimultaneously = exports.ErrorInvalidHahsProvided = 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.WarnSubgraphApiKeyNotProvided = exports.ErrorInvalidHash = exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = void 0;
|
|
4
|
+
exports.WarnSubgraphApiKeyNotProvided = exports.ErrorUnsupportedStatus = exports.ErrorInvalidHash = exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @constant {Error} - The Staking contract is missing.
|
|
7
7
|
*/
|
|
@@ -235,4 +235,11 @@ exports.InvalidEthereumAddressError = InvalidEthereumAddressError;
|
|
|
235
235
|
* @constant {Error} - The Hash does not match
|
|
236
236
|
*/
|
|
237
237
|
exports.ErrorInvalidHash = new Error('Invalid hash');
|
|
238
|
+
/**
|
|
239
|
+
* @constant {Error} - The Status is not supported
|
|
240
|
+
*/
|
|
241
|
+
exports.ErrorUnsupportedStatus = new Error('Unsupported status for query');
|
|
242
|
+
/**
|
|
243
|
+
* @constant {Error} - The SUBGRAPH_API_KEY is not being provided
|
|
244
|
+
*/
|
|
238
245
|
exports.WarnSubgraphApiKeyNotProvided = '"SUBGRAPH_API_KEY" is not being provided. It might cause issues with the subgraph.';
|
package/dist/escrow.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContractRunner, Overrides } from 'ethers';
|
|
2
2
|
import { BaseEthersClient } from './base';
|
|
3
|
-
import { ChainId } from './enums';
|
|
4
|
-
import { EscrowData } from './graphql';
|
|
3
|
+
import { ChainId, OrderDirection } from './enums';
|
|
4
|
+
import { EscrowData, StatusEvent } from './graphql';
|
|
5
5
|
import { IEscrowConfig, IEscrowsFilter } from './interfaces';
|
|
6
6
|
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
7
7
|
/**
|
|
@@ -693,7 +693,7 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
693
693
|
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
694
694
|
*
|
|
695
695
|
* const escrowAddresses = new EscrowUtils.getEscrows({
|
|
696
|
-
*
|
|
696
|
+
* network: ChainId.POLYGON_AMOY
|
|
697
697
|
* });
|
|
698
698
|
* ```
|
|
699
699
|
*/
|
|
@@ -706,7 +706,7 @@ export declare class EscrowUtils {
|
|
|
706
706
|
*
|
|
707
707
|
* ```ts
|
|
708
708
|
* interface IEscrowsFilter {
|
|
709
|
-
*
|
|
709
|
+
* chainId: ChainId;
|
|
710
710
|
* launcher?: string;
|
|
711
711
|
* reputationOracle?: string;
|
|
712
712
|
* recordingOracle?: string;
|
|
@@ -715,6 +715,9 @@ export declare class EscrowUtils {
|
|
|
715
715
|
* status?: EscrowStatus;
|
|
716
716
|
* from?: Date;
|
|
717
717
|
* to?: Date;
|
|
718
|
+
* first?: number;
|
|
719
|
+
* skip?: number;
|
|
720
|
+
* orderDirection?: OrderDirection;
|
|
718
721
|
* }
|
|
719
722
|
* ```
|
|
720
723
|
*
|
|
@@ -741,6 +744,13 @@ export declare class EscrowUtils {
|
|
|
741
744
|
* ```
|
|
742
745
|
*
|
|
743
746
|
* ```ts
|
|
747
|
+
* enum OrderDirection {
|
|
748
|
+
* ASC = 'asc',
|
|
749
|
+
* DESC = 'desc',
|
|
750
|
+
* }
|
|
751
|
+
* ```
|
|
752
|
+
*
|
|
753
|
+
* ```ts
|
|
744
754
|
* enum EscrowStatus {
|
|
745
755
|
* Launched,
|
|
746
756
|
* Pending,
|
|
@@ -791,7 +801,7 @@ export declare class EscrowUtils {
|
|
|
791
801
|
* status: EscrowStatus.Pending,
|
|
792
802
|
* from: new Date(2023, 4, 8),
|
|
793
803
|
* to: new Date(2023, 5, 8),
|
|
794
|
-
*
|
|
804
|
+
* chainId: ChainId.POLYGON_AMOY
|
|
795
805
|
* };
|
|
796
806
|
* const escrowDatas = await EscrowUtils.getEscrows(filters);
|
|
797
807
|
* ```
|
|
@@ -866,5 +876,80 @@ export declare class EscrowUtils {
|
|
|
866
876
|
* ```
|
|
867
877
|
*/
|
|
868
878
|
static getEscrow(chainId: ChainId, escrowAddress: string): Promise<EscrowData>;
|
|
879
|
+
/**
|
|
880
|
+
* This function returns the status events for a given set of networks within an optional date range.
|
|
881
|
+
*
|
|
882
|
+
* > This uses Subgraph
|
|
883
|
+
*
|
|
884
|
+
* **Input parameters**
|
|
885
|
+
*
|
|
886
|
+
* ```ts
|
|
887
|
+
* enum ChainId {
|
|
888
|
+
* ALL = -1,
|
|
889
|
+
* MAINNET = 1,
|
|
890
|
+
* RINKEBY = 4,
|
|
891
|
+
* GOERLI = 5,
|
|
892
|
+
* SEPOLIA = 11155111,
|
|
893
|
+
* BSC_MAINNET = 56,
|
|
894
|
+
* BSC_TESTNET = 97,
|
|
895
|
+
* POLYGON = 137,
|
|
896
|
+
* POLYGON_MUMBAI = 80001,
|
|
897
|
+
* POLYGON_AMOY = 80002,
|
|
898
|
+
* MOONBEAM = 1284,
|
|
899
|
+
* MOONBASE_ALPHA = 1287,
|
|
900
|
+
* AVALANCHE = 43114,
|
|
901
|
+
* AVALANCHE_TESTNET = 43113,
|
|
902
|
+
* CELO = 42220,
|
|
903
|
+
* CELO_ALFAJORES = 44787,
|
|
904
|
+
* LOCALHOST = 1338,
|
|
905
|
+
* XLAYER_TESTNET = 195,
|
|
906
|
+
* XLAYER = 196,
|
|
907
|
+
* }
|
|
908
|
+
* ```
|
|
909
|
+
*
|
|
910
|
+
* ```ts
|
|
911
|
+
* enum OrderDirection {
|
|
912
|
+
* ASC = 'asc',
|
|
913
|
+
* DESC = 'desc',
|
|
914
|
+
* }
|
|
915
|
+
* ```
|
|
916
|
+
*
|
|
917
|
+
* ```ts
|
|
918
|
+
* type Status = {
|
|
919
|
+
* escrowAddress: string;
|
|
920
|
+
* timestamp: string;
|
|
921
|
+
* status: string;
|
|
922
|
+
* };
|
|
923
|
+
* ```
|
|
924
|
+
*
|
|
925
|
+
* @param {ChainId} chainId - List of network IDs to query for status events.
|
|
926
|
+
* @param {EscrowStatus[]} [statuses] - Optional array of statuses to query for. If not provided, queries for all statuses.
|
|
927
|
+
* @param {Date} [from] - Optional start date to filter events.
|
|
928
|
+
* @param {Date} [to] - Optional end date to filter events.
|
|
929
|
+
* @param {string} [launcher] - Optional launcher address to filter events. Must be a valid Ethereum address.
|
|
930
|
+
* @param {number} [first] - Optional number of transactions per page. Default is 10.
|
|
931
|
+
* @param {number} [skip] - Optional number of transactions to skip. Default is 0.
|
|
932
|
+
* @param {OrderDirection} [orderDirection] - Optional order of the results. Default is DESC.
|
|
933
|
+
* @returns {Promise<StatusEvent[]>} - Array of status events with their corresponding statuses.
|
|
934
|
+
*
|
|
935
|
+
* **Code example**
|
|
936
|
+
*
|
|
937
|
+
* ```ts
|
|
938
|
+
* import { ChainId, EscrowUtils, EscrowStatus } from '@human-protocol/sdk';
|
|
939
|
+
*
|
|
940
|
+
* (async () => {
|
|
941
|
+
* const fromDate = new Date('2023-01-01');
|
|
942
|
+
* const toDate = new Date('2023-12-31');
|
|
943
|
+
* const statusEvents = await EscrowUtils.getStatusEvents(
|
|
944
|
+
* [ChainId.POLYGON, ChainId.MAINNET],
|
|
945
|
+
* [EscrowStatus.Pending, EscrowStatus.Complete],
|
|
946
|
+
* fromDate,
|
|
947
|
+
* toDate
|
|
948
|
+
* );
|
|
949
|
+
* console.log(statusEvents);
|
|
950
|
+
* })();
|
|
951
|
+
* ```
|
|
952
|
+
*/
|
|
953
|
+
static getStatusEvents(chainId: ChainId, statuses?: EscrowStatus[], from?: Date, to?: Date, launcher?: string, first?: number, skip?: number, orderDirection?: OrderDirection): Promise<StatusEvent[]>;
|
|
869
954
|
}
|
|
870
955
|
//# 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":"AASA,OAAO,EAAE,cAAc,EAAY,SAAS,EAAU,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAY,SAAS,EAAU,MAAM,QAAQ,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2GG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,UAAU,EAAE,CAAC;IA2DxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmEG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC;IAoBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyEG;WAEiB,eAAe,CACjC,OAAO,EAAE,OAAO,EAChB,QAAQ,CAAC,EAAE,YAAY,EAAE,EACzB,IAAI,CAAC,EAAE,IAAI,EACX,EAAE,CAAC,EAAE,IAAI,EACT,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,WAAW,EAAE,CAAC;CAuD1B"}
|
package/dist/escrow.js
CHANGED
|
@@ -20,6 +20,7 @@ const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
|
20
20
|
const base_1 = require("./base");
|
|
21
21
|
const constants_1 = require("./constants");
|
|
22
22
|
const decorators_1 = require("./decorators");
|
|
23
|
+
const enums_1 = require("./enums");
|
|
23
24
|
const error_1 = require("./error");
|
|
24
25
|
const graphql_1 = require("./graphql");
|
|
25
26
|
const types_1 = require("./types");
|
|
@@ -1215,7 +1216,7 @@ exports.EscrowClient = EscrowClient;
|
|
|
1215
1216
|
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
1216
1217
|
*
|
|
1217
1218
|
* const escrowAddresses = new EscrowUtils.getEscrows({
|
|
1218
|
-
*
|
|
1219
|
+
* network: ChainId.POLYGON_AMOY
|
|
1219
1220
|
* });
|
|
1220
1221
|
* ```
|
|
1221
1222
|
*/
|
|
@@ -1228,7 +1229,7 @@ class EscrowUtils {
|
|
|
1228
1229
|
*
|
|
1229
1230
|
* ```ts
|
|
1230
1231
|
* interface IEscrowsFilter {
|
|
1231
|
-
*
|
|
1232
|
+
* chainId: ChainId;
|
|
1232
1233
|
* launcher?: string;
|
|
1233
1234
|
* reputationOracle?: string;
|
|
1234
1235
|
* recordingOracle?: string;
|
|
@@ -1237,6 +1238,9 @@ class EscrowUtils {
|
|
|
1237
1238
|
* status?: EscrowStatus;
|
|
1238
1239
|
* from?: Date;
|
|
1239
1240
|
* to?: Date;
|
|
1241
|
+
* first?: number;
|
|
1242
|
+
* skip?: number;
|
|
1243
|
+
* orderDirection?: OrderDirection;
|
|
1240
1244
|
* }
|
|
1241
1245
|
* ```
|
|
1242
1246
|
*
|
|
@@ -1263,6 +1267,13 @@ class EscrowUtils {
|
|
|
1263
1267
|
* ```
|
|
1264
1268
|
*
|
|
1265
1269
|
* ```ts
|
|
1270
|
+
* enum OrderDirection {
|
|
1271
|
+
* ASC = 'asc',
|
|
1272
|
+
* DESC = 'desc',
|
|
1273
|
+
* }
|
|
1274
|
+
* ```
|
|
1275
|
+
*
|
|
1276
|
+
* ```ts
|
|
1266
1277
|
* enum EscrowStatus {
|
|
1267
1278
|
* Launched,
|
|
1268
1279
|
* Pending,
|
|
@@ -1313,15 +1324,12 @@ class EscrowUtils {
|
|
|
1313
1324
|
* status: EscrowStatus.Pending,
|
|
1314
1325
|
* from: new Date(2023, 4, 8),
|
|
1315
1326
|
* to: new Date(2023, 5, 8),
|
|
1316
|
-
*
|
|
1327
|
+
* chainId: ChainId.POLYGON_AMOY
|
|
1317
1328
|
* };
|
|
1318
1329
|
* const escrowDatas = await EscrowUtils.getEscrows(filters);
|
|
1319
1330
|
* ```
|
|
1320
1331
|
*/
|
|
1321
1332
|
static async getEscrows(filter) {
|
|
1322
|
-
if (!filter?.networks?.length) {
|
|
1323
|
-
throw error_1.ErrorUnsupportedChainID;
|
|
1324
|
-
}
|
|
1325
1333
|
if (filter.launcher && !ethers_1.ethers.isAddress(filter.launcher)) {
|
|
1326
1334
|
throw error_1.ErrorInvalidAddress;
|
|
1327
1335
|
}
|
|
@@ -1334,34 +1342,33 @@ class EscrowUtils {
|
|
|
1334
1342
|
if (filter.exchangeOracle && !ethers_1.ethers.isAddress(filter.exchangeOracle)) {
|
|
1335
1343
|
throw error_1.ErrorInvalidAddress;
|
|
1336
1344
|
}
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
const { escrows } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROWS_QUERY)(filter), {
|
|
1345
|
-
...filter,
|
|
1346
|
-
launcher: filter.launcher?.toLowerCase(),
|
|
1347
|
-
reputationOracle: filter.reputationOracle?.toLowerCase(),
|
|
1348
|
-
recordingOracle: filter.recordingOracle?.toLowerCase(),
|
|
1349
|
-
exchangeOracle: filter.exchangeOracle?.toLowerCase(),
|
|
1350
|
-
status: filter.status !== undefined
|
|
1351
|
-
? Object.entries(types_1.EscrowStatus).find(([, value]) => value === filter.status)?.[0]
|
|
1352
|
-
: undefined,
|
|
1353
|
-
from: filter.from ? +filter.from.getTime() / 1000 : undefined,
|
|
1354
|
-
to: filter.to ? +filter.to.getTime() / 1000 : undefined,
|
|
1355
|
-
});
|
|
1356
|
-
escrows.map((escrow) => (escrow.chainId = networkData.chainId));
|
|
1357
|
-
escrowAddresses.push(...escrows);
|
|
1358
|
-
}
|
|
1359
|
-
escrowAddresses.sort((a, b) => Number(b.createdAt) - Number(a.createdAt));
|
|
1360
|
-
return escrowAddresses;
|
|
1345
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
1346
|
+
const skip = filter.skip || 0;
|
|
1347
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
1348
|
+
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
1349
|
+
if (!networkData) {
|
|
1350
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
1361
1351
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1352
|
+
const { escrows } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROWS_QUERY)(filter), {
|
|
1353
|
+
...filter,
|
|
1354
|
+
launcher: filter.launcher?.toLowerCase(),
|
|
1355
|
+
reputationOracle: filter.reputationOracle?.toLowerCase(),
|
|
1356
|
+
recordingOracle: filter.recordingOracle?.toLowerCase(),
|
|
1357
|
+
exchangeOracle: filter.exchangeOracle?.toLowerCase(),
|
|
1358
|
+
status: filter.status !== undefined
|
|
1359
|
+
? Object.entries(types_1.EscrowStatus).find(([, value]) => value === filter.status)?.[0]
|
|
1360
|
+
: undefined,
|
|
1361
|
+
from: filter.from ? +filter.from.getTime() / 1000 : undefined,
|
|
1362
|
+
to: filter.to ? +filter.to.getTime() / 1000 : undefined,
|
|
1363
|
+
orderDirection: orderDirection,
|
|
1364
|
+
first: first,
|
|
1365
|
+
skip: skip,
|
|
1366
|
+
});
|
|
1367
|
+
escrows.map((escrow) => (escrow.chainId = networkData.chainId));
|
|
1368
|
+
if (!escrows) {
|
|
1369
|
+
return [];
|
|
1364
1370
|
}
|
|
1371
|
+
return escrows;
|
|
1365
1372
|
}
|
|
1366
1373
|
/**
|
|
1367
1374
|
* This function returns the escrow data for a given address.
|
|
@@ -1439,13 +1446,122 @@ class EscrowUtils {
|
|
|
1439
1446
|
if (escrowAddress && !ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1440
1447
|
throw error_1.ErrorInvalidAddress;
|
|
1441
1448
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1449
|
+
const { escrow } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROW_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() });
|
|
1450
|
+
return escrow || null;
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* This function returns the status events for a given set of networks within an optional date range.
|
|
1454
|
+
*
|
|
1455
|
+
* > This uses Subgraph
|
|
1456
|
+
*
|
|
1457
|
+
* **Input parameters**
|
|
1458
|
+
*
|
|
1459
|
+
* ```ts
|
|
1460
|
+
* enum ChainId {
|
|
1461
|
+
* ALL = -1,
|
|
1462
|
+
* MAINNET = 1,
|
|
1463
|
+
* RINKEBY = 4,
|
|
1464
|
+
* GOERLI = 5,
|
|
1465
|
+
* SEPOLIA = 11155111,
|
|
1466
|
+
* BSC_MAINNET = 56,
|
|
1467
|
+
* BSC_TESTNET = 97,
|
|
1468
|
+
* POLYGON = 137,
|
|
1469
|
+
* POLYGON_MUMBAI = 80001,
|
|
1470
|
+
* POLYGON_AMOY = 80002,
|
|
1471
|
+
* MOONBEAM = 1284,
|
|
1472
|
+
* MOONBASE_ALPHA = 1287,
|
|
1473
|
+
* AVALANCHE = 43114,
|
|
1474
|
+
* AVALANCHE_TESTNET = 43113,
|
|
1475
|
+
* CELO = 42220,
|
|
1476
|
+
* CELO_ALFAJORES = 44787,
|
|
1477
|
+
* LOCALHOST = 1338,
|
|
1478
|
+
* XLAYER_TESTNET = 195,
|
|
1479
|
+
* XLAYER = 196,
|
|
1480
|
+
* }
|
|
1481
|
+
* ```
|
|
1482
|
+
*
|
|
1483
|
+
* ```ts
|
|
1484
|
+
* enum OrderDirection {
|
|
1485
|
+
* ASC = 'asc',
|
|
1486
|
+
* DESC = 'desc',
|
|
1487
|
+
* }
|
|
1488
|
+
* ```
|
|
1489
|
+
*
|
|
1490
|
+
* ```ts
|
|
1491
|
+
* type Status = {
|
|
1492
|
+
* escrowAddress: string;
|
|
1493
|
+
* timestamp: string;
|
|
1494
|
+
* status: string;
|
|
1495
|
+
* };
|
|
1496
|
+
* ```
|
|
1497
|
+
*
|
|
1498
|
+
* @param {ChainId} chainId - List of network IDs to query for status events.
|
|
1499
|
+
* @param {EscrowStatus[]} [statuses] - Optional array of statuses to query for. If not provided, queries for all statuses.
|
|
1500
|
+
* @param {Date} [from] - Optional start date to filter events.
|
|
1501
|
+
* @param {Date} [to] - Optional end date to filter events.
|
|
1502
|
+
* @param {string} [launcher] - Optional launcher address to filter events. Must be a valid Ethereum address.
|
|
1503
|
+
* @param {number} [first] - Optional number of transactions per page. Default is 10.
|
|
1504
|
+
* @param {number} [skip] - Optional number of transactions to skip. Default is 0.
|
|
1505
|
+
* @param {OrderDirection} [orderDirection] - Optional order of the results. Default is DESC.
|
|
1506
|
+
* @returns {Promise<StatusEvent[]>} - Array of status events with their corresponding statuses.
|
|
1507
|
+
*
|
|
1508
|
+
* **Code example**
|
|
1509
|
+
*
|
|
1510
|
+
* ```ts
|
|
1511
|
+
* import { ChainId, EscrowUtils, EscrowStatus } from '@human-protocol/sdk';
|
|
1512
|
+
*
|
|
1513
|
+
* (async () => {
|
|
1514
|
+
* const fromDate = new Date('2023-01-01');
|
|
1515
|
+
* const toDate = new Date('2023-12-31');
|
|
1516
|
+
* const statusEvents = await EscrowUtils.getStatusEvents(
|
|
1517
|
+
* [ChainId.POLYGON, ChainId.MAINNET],
|
|
1518
|
+
* [EscrowStatus.Pending, EscrowStatus.Complete],
|
|
1519
|
+
* fromDate,
|
|
1520
|
+
* toDate
|
|
1521
|
+
* );
|
|
1522
|
+
* console.log(statusEvents);
|
|
1523
|
+
* })();
|
|
1524
|
+
* ```
|
|
1525
|
+
*/
|
|
1526
|
+
static async getStatusEvents(chainId, statuses, from, to, launcher, first, skip, orderDirection) {
|
|
1527
|
+
if (launcher && !ethers_1.ethers.isAddress(launcher)) {
|
|
1528
|
+
throw error_1.ErrorInvalidAddress;
|
|
1445
1529
|
}
|
|
1446
|
-
|
|
1447
|
-
|
|
1530
|
+
first = first !== undefined ? Math.min(first, 1000) : 10;
|
|
1531
|
+
skip = skip || 0;
|
|
1532
|
+
orderDirection = orderDirection || enums_1.OrderDirection.DESC;
|
|
1533
|
+
// If statuses are not provided, use all statuses except Launched
|
|
1534
|
+
const effectiveStatuses = statuses ?? [
|
|
1535
|
+
types_1.EscrowStatus.Launched,
|
|
1536
|
+
types_1.EscrowStatus.Pending,
|
|
1537
|
+
types_1.EscrowStatus.Partial,
|
|
1538
|
+
types_1.EscrowStatus.Paid,
|
|
1539
|
+
types_1.EscrowStatus.Complete,
|
|
1540
|
+
types_1.EscrowStatus.Cancelled,
|
|
1541
|
+
];
|
|
1542
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
1543
|
+
if (!networkData) {
|
|
1544
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
1448
1545
|
}
|
|
1546
|
+
const statusNames = effectiveStatuses.map((status) => types_1.EscrowStatus[status]);
|
|
1547
|
+
const data = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_STATUS_UPDATES_QUERY)(from, to, launcher), {
|
|
1548
|
+
status: statusNames,
|
|
1549
|
+
from: from ? Math.floor(from.getTime() / 1000) : undefined,
|
|
1550
|
+
to: to ? Math.floor(to.getTime() / 1000) : undefined,
|
|
1551
|
+
launcher: launcher || undefined,
|
|
1552
|
+
orderDirection: orderDirection,
|
|
1553
|
+
first: first,
|
|
1554
|
+
skip: skip,
|
|
1555
|
+
});
|
|
1556
|
+
if (!data || !data['escrowStatusEvents']) {
|
|
1557
|
+
return [];
|
|
1558
|
+
}
|
|
1559
|
+
const statusEvents = data['escrowStatusEvents'];
|
|
1560
|
+
const eventsWithChainId = statusEvents.map((event) => ({
|
|
1561
|
+
...event,
|
|
1562
|
+
chainId,
|
|
1563
|
+
}));
|
|
1564
|
+
return eventsWithChainId;
|
|
1449
1565
|
}
|
|
1450
1566
|
}
|
|
1451
1567
|
exports.EscrowUtils = EscrowUtils;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IEscrowsFilter } from '../../interfaces';
|
|
2
2
|
export declare const GET_ESCROW_BY_ADDRESS_QUERY: () => import("graphql").DocumentNode;
|
|
3
3
|
export declare const GET_ESCROWS_QUERY: (filter: IEscrowsFilter) => import("graphql").DocumentNode;
|
|
4
|
+
export declare const GET_STATUS_UPDATES_QUERY: (from?: Date, to?: Date, launcher?: string) => import("graphql").DocumentNode;
|
|
4
5
|
//# 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;AA6BlD,eAAO,MAAM,2BAA2B,sCAOvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,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,mCAmDvD,CAAC;AAEF,eAAO,MAAM,wBAAwB,UAC5B,IAAI,OACN,IAAI,aACE,MAAM,mCAiClB,CAAC"}
|