@human-protocol/sdk 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.js +1 -1
- package/dist/encryption.d.ts +5 -6
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +5 -6
- package/dist/error.d.ts +3 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +7 -1
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +4 -2
- package/dist/graphql/queries/transaction.d.ts.map +1 -1
- package/dist/graphql/queries/transaction.js +17 -9
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +5 -4
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +4 -0
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +1 -1
- package/package.json +2 -4
- package/src/constants.ts +1 -1
- package/src/encryption.ts +5 -6
- package/src/error.ts +6 -0
- package/src/graphql/queries/statistics.ts +6 -2
- package/src/graphql/queries/transaction.ts +19 -9
- package/src/kvstore.ts +7 -5
- package/src/operator.ts +4 -0
- package/src/transaction.ts +2 -1
package/dist/constants.js
CHANGED
|
@@ -159,7 +159,7 @@ exports.NETWORKS = {
|
|
|
159
159
|
[enums_1.ChainId.POLYGON_AMOY]: {
|
|
160
160
|
chainId: enums_1.ChainId.POLYGON_AMOY,
|
|
161
161
|
title: 'Polygon Amoy',
|
|
162
|
-
scanUrl: 'https://
|
|
162
|
+
scanUrl: 'https://amoy.polygonscan.com/',
|
|
163
163
|
factoryAddress: '0xAFf5a986A530ff839d49325A5dF69F96627E8D29',
|
|
164
164
|
hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
|
|
165
165
|
stakingAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
|
package/dist/encryption.d.ts
CHANGED
|
@@ -3,12 +3,11 @@ import { IKeyPair } from './interfaces';
|
|
|
3
3
|
/**
|
|
4
4
|
* ## Introduction
|
|
5
5
|
*
|
|
6
|
-
* Class for
|
|
6
|
+
* Class for signing and decrypting messages.
|
|
7
7
|
*
|
|
8
|
-
* The algorithm includes the implementation of the [PGP encryption algorithm](https://github.com/openpgpjs/openpgpjs) multi-public key encryption on typescript.
|
|
9
|
-
* Using the vanilla [ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) implementation Schnorr signatures for signature and [curve25519](https://en.wikipedia.org/wiki/Curve25519) for encryption. [Learn more](https://wiki.polkadot.network/docs/learn-cryptography).
|
|
8
|
+
* The algorithm includes the implementation of the [PGP encryption algorithm](https://github.com/openpgpjs/openpgpjs) multi-public key encryption on typescript, and uses the vanilla [ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) implementation Schnorr signature for signatures and [curve25519](https://en.wikipedia.org/wiki/Curve25519) for encryption. [Learn more](https://wiki.polkadot.network/docs/learn-cryptography).
|
|
10
9
|
*
|
|
11
|
-
* To get an instance of this class, is recommended
|
|
10
|
+
* To get an instance of this class, initialization is recommended using the static `build` method.
|
|
12
11
|
*
|
|
13
12
|
* ```ts
|
|
14
13
|
* static async build(privateKeyArmored: string, passphrase?: string): Promise<Encryption>
|
|
@@ -103,10 +102,10 @@ export declare class Encryption {
|
|
|
103
102
|
*/
|
|
104
103
|
signAndEncrypt(message: string, publicKeys: string[]): Promise<string>;
|
|
105
104
|
/**
|
|
106
|
-
* This function
|
|
105
|
+
* This function decrypts messages using the private key. In addition, the public key can be added for signature verification.
|
|
107
106
|
*
|
|
108
107
|
* @param {string} message Message to decrypt.
|
|
109
|
-
* @param {string} publicKey Public key used to verify signature if needed.
|
|
108
|
+
* @param {string} publicKey Public key used to verify signature if needed. This is optional.
|
|
110
109
|
* @returns {Promise<string>} Message decrypted.
|
|
111
110
|
*
|
|
112
111
|
* **Code example**
|
package/dist/encryption.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../src/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAqB;IAEvC;;;;OAIG;gBACS,UAAU,EAAE,OAAO,CAAC,UAAU;IAI1C;;;;;;OAMG;WACiB,KAAK,CACvB,iBAAiB,EAAE,MAAM,EACzB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC;IAkBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACU,cAAc,CACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,MAAM,CAAC;IAiBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB1E;;;;;;;;;;;;;;;;;OAiBG;IACU,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAYpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,eAAe;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;WACiB,MAAM,CACxB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,OAAO,CAAC;IAgBnB;;;;;;;;;;;;;OAaG;WACiB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACiB,eAAe,CACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,SAAK,GACd,OAAO,CAAC,QAAQ,CAAC;IAkBpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;WACiB,OAAO,CACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,MAAM,CAAC;IAgBlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;WACW,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CASpD"}
|
package/dist/encryption.js
CHANGED
|
@@ -28,12 +28,11 @@ const openpgp = __importStar(require("openpgp"));
|
|
|
28
28
|
/**
|
|
29
29
|
* ## Introduction
|
|
30
30
|
*
|
|
31
|
-
* Class for
|
|
31
|
+
* Class for signing and decrypting messages.
|
|
32
32
|
*
|
|
33
|
-
* The algorithm includes the implementation of the [PGP encryption algorithm](https://github.com/openpgpjs/openpgpjs) multi-public key encryption on typescript.
|
|
34
|
-
* Using the vanilla [ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) implementation Schnorr signatures for signature and [curve25519](https://en.wikipedia.org/wiki/Curve25519) for encryption. [Learn more](https://wiki.polkadot.network/docs/learn-cryptography).
|
|
33
|
+
* The algorithm includes the implementation of the [PGP encryption algorithm](https://github.com/openpgpjs/openpgpjs) multi-public key encryption on typescript, and uses the vanilla [ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) implementation Schnorr signature for signatures and [curve25519](https://en.wikipedia.org/wiki/Curve25519) for encryption. [Learn more](https://wiki.polkadot.network/docs/learn-cryptography).
|
|
35
34
|
*
|
|
36
|
-
* To get an instance of this class, is recommended
|
|
35
|
+
* To get an instance of this class, initialization is recommended using the static `build` method.
|
|
37
36
|
*
|
|
38
37
|
* ```ts
|
|
39
38
|
* static async build(privateKeyArmored: string, passphrase?: string): Promise<Encryption>
|
|
@@ -151,10 +150,10 @@ class Encryption {
|
|
|
151
150
|
return encrypted;
|
|
152
151
|
}
|
|
153
152
|
/**
|
|
154
|
-
* This function
|
|
153
|
+
* This function decrypts messages using the private key. In addition, the public key can be added for signature verification.
|
|
155
154
|
*
|
|
156
155
|
* @param {string} message Message to decrypt.
|
|
157
|
-
* @param {string} publicKey Public key used to verify signature if needed.
|
|
156
|
+
* @param {string} publicKey Public key used to verify signature if needed. This is optional.
|
|
158
157
|
* @returns {Promise<string>} Message decrypted.
|
|
159
158
|
*
|
|
160
159
|
* **Code example**
|
package/dist/error.d.ts
CHANGED
|
@@ -215,4 +215,7 @@ export declare const ErrorUnsupportedStatus: Error;
|
|
|
215
215
|
* @constant {Error} - The SUBGRAPH_API_KEY is not being provided
|
|
216
216
|
*/
|
|
217
217
|
export declare const WarnSubgraphApiKeyNotProvided = "\"SUBGRAPH_API_KEY\" is not being provided. It might cause issues with the subgraph.";
|
|
218
|
+
export declare class InvalidKeyError extends Error {
|
|
219
|
+
constructor(key: string, address: string);
|
|
220
|
+
}
|
|
218
221
|
//# 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,OAAiC,CAAC;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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,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;AAEvF,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAGzC"}
|
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.ErrorUnsupportedStatus = exports.ErrorInvalidHash = exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = void 0;
|
|
4
|
+
exports.InvalidKeyError = 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
|
*/
|
|
@@ -243,3 +243,9 @@ exports.ErrorUnsupportedStatus = new Error('Unsupported status for query');
|
|
|
243
243
|
* @constant {Error} - The SUBGRAPH_API_KEY is not being provided
|
|
244
244
|
*/
|
|
245
245
|
exports.WarnSubgraphApiKeyNotProvided = '"SUBGRAPH_API_KEY" is not being provided. It might cause issues with the subgraph.';
|
|
246
|
+
class InvalidKeyError extends Error {
|
|
247
|
+
constructor(key, address) {
|
|
248
|
+
super(`Key "${key}" not found for address ${address}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.InvalidKeyError = InvalidKeyError;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAuDrD,eAAO,MAAM,4BAA4B,gCAOxC,CAAC;AAIF,eAAO,MAAM,2BAA2B,gCAOvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAAY,iBAAiB,mCA6BjE,CAAC"}
|
|
@@ -53,17 +53,19 @@ const EVENT_DAY_DATA_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
53
53
|
dailyUniqueReceivers
|
|
54
54
|
}
|
|
55
55
|
`;
|
|
56
|
+
const hmtStatisticsId = Buffer.from('hmt-statistics-id').toString('hex');
|
|
56
57
|
exports.GET_HMTOKEN_STATISTICS_QUERY = (0, graphql_tag_1.default) `
|
|
57
58
|
query GetHMTokenStatistics {
|
|
58
|
-
hmtokenStatistics(id: "
|
|
59
|
+
hmtokenStatistics(id: "${hmtStatisticsId}") {
|
|
59
60
|
...HMTokenStatisticsFields
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
${HMTOKEN_STATISTICS_FRAGMENT}
|
|
63
64
|
`;
|
|
65
|
+
const escrowStatisticsId = Buffer.from('escrow-statistics-id').toString('hex');
|
|
64
66
|
exports.GET_ESCROW_STATISTICS_QUERY = (0, graphql_tag_1.default) `
|
|
65
67
|
query GetEscrowStatistics {
|
|
66
|
-
escrowStatistics(id: "
|
|
68
|
+
escrowStatistics(id: "${escrowStatisticsId}") {
|
|
67
69
|
...EscrowStatisticsFields
|
|
68
70
|
}
|
|
69
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAc9D,eAAO,MAAM,sBAAsB,WAAY,mBAAmB,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAc9D,eAAO,MAAM,sBAAsB,WAAY,mBAAmB,mCAiDjE,CAAC;AAEF,eAAO,MAAM,qBAAqB,gCAOjC,CAAC"}
|
|
@@ -18,16 +18,24 @@ const TRANSACTION_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
18
18
|
`;
|
|
19
19
|
const GET_TRANSACTIONS_QUERY = (filter) => {
|
|
20
20
|
const { startDate, endDate, startBlock, endBlock, fromAddress, toAddress } = filter;
|
|
21
|
+
const addressCondition = fromAddress === toAddress
|
|
22
|
+
? `
|
|
23
|
+
${fromAddress ? `{ from: $fromAddress }` : ''}
|
|
24
|
+
${toAddress ? `{ to: $toAddress }` : ''}
|
|
25
|
+
`
|
|
26
|
+
: `
|
|
27
|
+
${fromAddress ? `from: $fromAddress` : ''}
|
|
28
|
+
${toAddress ? `to: $toAddress` : ''}
|
|
29
|
+
`;
|
|
21
30
|
const WHERE_CLAUSE = `
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`;
|
|
31
|
+
where: {
|
|
32
|
+
${fromAddress === toAddress ? `or: [ ${addressCondition} ],` : addressCondition}
|
|
33
|
+
${startDate ? `timestamp_gte: $startDate,` : ''}
|
|
34
|
+
${endDate ? `timestamp_lte: $endDate,` : ''}
|
|
35
|
+
${startBlock ? `block_gte: $startBlock,` : ''}
|
|
36
|
+
${endBlock ? `block_lte: $endBlock,` : ''}
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
31
39
|
return (0, graphql_tag_1.default) `
|
|
32
40
|
query getTransactions(
|
|
33
41
|
$fromAddress: String
|
package/dist/kvstore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAYlC,OAAO,EAAE,WA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AmBG;WACiB,uBAAuB,CACzC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,SAAQ,GACb,OAAO,CAAC,MAAM,CAAC;IAqClB;;;;;;;;;;;;;;;;;;OAkBG;WACiB,YAAY,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;CAenB"}
|
package/dist/kvstore.js
CHANGED
|
@@ -365,10 +365,9 @@ class KVStoreUtils {
|
|
|
365
365
|
}
|
|
366
366
|
const { kvstores } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY)(), { address: address.toLowerCase(), key });
|
|
367
367
|
if (!kvstores || kvstores.length === 0) {
|
|
368
|
-
throw new
|
|
368
|
+
throw new error_1.InvalidKeyError(key, address);
|
|
369
369
|
}
|
|
370
|
-
|
|
371
|
-
return value;
|
|
370
|
+
return kvstores[0].value;
|
|
372
371
|
}
|
|
373
372
|
/**
|
|
374
373
|
* Gets the URL value of the given entity, and verifies its hash.
|
|
@@ -415,7 +414,9 @@ class KVStoreUtils {
|
|
|
415
414
|
}
|
|
416
415
|
const content = await fetch(url).then((res) => res.text());
|
|
417
416
|
const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
|
|
418
|
-
|
|
417
|
+
const formattedHash = hash?.replace(/^0x/, '');
|
|
418
|
+
const formattedContentHash = contentHash?.replace(/^0x/, '');
|
|
419
|
+
if (formattedHash !== formattedContentHash) {
|
|
419
420
|
throw error_1.ErrorInvalidHash;
|
|
420
421
|
}
|
|
421
422
|
return url;
|
package/dist/operator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,cAAc,EACd,SAAS,EAET,OAAO,EACR,MAAM,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@@ -122,6 +122,8 @@ class OperatorUtils {
|
|
|
122
122
|
address: address.toLowerCase(),
|
|
123
123
|
role: role,
|
|
124
124
|
});
|
|
125
|
+
if (!reputationNetwork)
|
|
126
|
+
return [];
|
|
125
127
|
return reputationNetwork.operators.map((operator) => {
|
|
126
128
|
let jobTypes = [];
|
|
127
129
|
if (typeof operator.jobTypes === 'string') {
|
|
@@ -162,6 +164,8 @@ class OperatorUtils {
|
|
|
162
164
|
const { rewardAddedEvents } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), reward_1.GET_REWARD_ADDED_EVENTS_QUERY, {
|
|
163
165
|
slasherAddress: slasherAddress.toLowerCase(),
|
|
164
166
|
});
|
|
167
|
+
if (!rewardAddedEvents)
|
|
168
|
+
return [];
|
|
165
169
|
return rewardAddedEvents.map((reward) => {
|
|
166
170
|
return {
|
|
167
171
|
escrowAddress: reward.escrow,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC;IAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoDG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CA0C3B"}
|
package/dist/transaction.js
CHANGED
|
@@ -39,7 +39,7 @@ class TransactionUtils {
|
|
|
39
39
|
const { transaction } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), transaction_1.GET_TRANSACTION_QUERY, {
|
|
40
40
|
hash: hash.toLowerCase(),
|
|
41
41
|
});
|
|
42
|
-
return transaction;
|
|
42
|
+
return transaction || null;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* This function returns all transaction details based on the provided filter.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.5",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
7
|
"dist"
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@human-protocol/core": "*",
|
|
43
|
-
"aws-sdk": "^2.1528.0",
|
|
44
43
|
"axios": "^1.4.0",
|
|
45
44
|
"graphql": "^16.8.1",
|
|
46
45
|
"graphql-request": "^6.1.0",
|
|
@@ -48,8 +47,7 @@
|
|
|
48
47
|
"minio": "7.1.3",
|
|
49
48
|
"openpgp": "^5.11.1",
|
|
50
49
|
"secp256k1": "^4.0.3",
|
|
51
|
-
"vitest": "^1.6.0"
|
|
52
|
-
"winston": "^3.13.0"
|
|
50
|
+
"vitest": "^1.6.0"
|
|
53
51
|
},
|
|
54
52
|
"devDependencies": {
|
|
55
53
|
"typedoc": "^0.26.5",
|
package/src/constants.ts
CHANGED
|
@@ -182,7 +182,7 @@ export const NETWORKS: {
|
|
|
182
182
|
[ChainId.POLYGON_AMOY]: {
|
|
183
183
|
chainId: ChainId.POLYGON_AMOY,
|
|
184
184
|
title: 'Polygon Amoy',
|
|
185
|
-
scanUrl: 'https://
|
|
185
|
+
scanUrl: 'https://amoy.polygonscan.com/',
|
|
186
186
|
factoryAddress: '0xAFf5a986A530ff839d49325A5dF69F96627E8D29',
|
|
187
187
|
hmtAddress: '0x792abbcC99c01dbDec49c9fa9A828a186Da45C33',
|
|
188
188
|
stakingAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
|
package/src/encryption.ts
CHANGED
|
@@ -4,12 +4,11 @@ import { IKeyPair } from './interfaces';
|
|
|
4
4
|
/**
|
|
5
5
|
* ## Introduction
|
|
6
6
|
*
|
|
7
|
-
* Class for
|
|
7
|
+
* Class for signing and decrypting messages.
|
|
8
8
|
*
|
|
9
|
-
* The algorithm includes the implementation of the [PGP encryption algorithm](https://github.com/openpgpjs/openpgpjs) multi-public key encryption on typescript.
|
|
10
|
-
* Using the vanilla [ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) implementation Schnorr signatures for signature and [curve25519](https://en.wikipedia.org/wiki/Curve25519) for encryption. [Learn more](https://wiki.polkadot.network/docs/learn-cryptography).
|
|
9
|
+
* The algorithm includes the implementation of the [PGP encryption algorithm](https://github.com/openpgpjs/openpgpjs) multi-public key encryption on typescript, and uses the vanilla [ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) implementation Schnorr signature for signatures and [curve25519](https://en.wikipedia.org/wiki/Curve25519) for encryption. [Learn more](https://wiki.polkadot.network/docs/learn-cryptography).
|
|
11
10
|
*
|
|
12
|
-
* To get an instance of this class, is recommended
|
|
11
|
+
* To get an instance of this class, initialization is recommended using the static `build` method.
|
|
13
12
|
*
|
|
14
13
|
* ```ts
|
|
15
14
|
* static async build(privateKeyArmored: string, passphrase?: string): Promise<Encryption>
|
|
@@ -147,10 +146,10 @@ export class Encryption {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
/**
|
|
150
|
-
* This function
|
|
149
|
+
* This function decrypts messages using the private key. In addition, the public key can be added for signature verification.
|
|
151
150
|
*
|
|
152
151
|
* @param {string} message Message to decrypt.
|
|
153
|
-
* @param {string} publicKey Public key used to verify signature if needed.
|
|
152
|
+
* @param {string} publicKey Public key used to verify signature if needed. This is optional.
|
|
154
153
|
* @returns {Promise<string>} Message decrypted.
|
|
155
154
|
*
|
|
156
155
|
* **Code example**
|
package/src/error.ts
CHANGED
|
@@ -345,3 +345,9 @@ export const ErrorUnsupportedStatus = new Error('Unsupported status for query');
|
|
|
345
345
|
*/
|
|
346
346
|
export const WarnSubgraphApiKeyNotProvided =
|
|
347
347
|
'"SUBGRAPH_API_KEY" is not being provided. It might cause issues with the subgraph.';
|
|
348
|
+
|
|
349
|
+
export class InvalidKeyError extends Error {
|
|
350
|
+
constructor(key: string, address: string) {
|
|
351
|
+
super(`Key "${key}" not found for address ${address}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
@@ -52,18 +52,22 @@ const EVENT_DAY_DATA_FRAGMENT = gql`
|
|
|
52
52
|
}
|
|
53
53
|
`;
|
|
54
54
|
|
|
55
|
+
const hmtStatisticsId = Buffer.from('hmt-statistics-id').toString('hex');
|
|
56
|
+
|
|
55
57
|
export const GET_HMTOKEN_STATISTICS_QUERY = gql`
|
|
56
58
|
query GetHMTokenStatistics {
|
|
57
|
-
hmtokenStatistics(id: "
|
|
59
|
+
hmtokenStatistics(id: "${hmtStatisticsId}") {
|
|
58
60
|
...HMTokenStatisticsFields
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
${HMTOKEN_STATISTICS_FRAGMENT}
|
|
62
64
|
`;
|
|
63
65
|
|
|
66
|
+
const escrowStatisticsId = Buffer.from('escrow-statistics-id').toString('hex');
|
|
67
|
+
|
|
64
68
|
export const GET_ESCROW_STATISTICS_QUERY = gql`
|
|
65
69
|
query GetEscrowStatistics {
|
|
66
|
-
escrowStatistics(id: "
|
|
70
|
+
escrowStatistics(id: "${escrowStatisticsId}") {
|
|
67
71
|
...EscrowStatisticsFields
|
|
68
72
|
}
|
|
69
73
|
}
|
|
@@ -17,16 +17,26 @@ export const GET_TRANSACTIONS_QUERY = (filter: ITransactionsFilter) => {
|
|
|
17
17
|
const { startDate, endDate, startBlock, endBlock, fromAddress, toAddress } =
|
|
18
18
|
filter;
|
|
19
19
|
|
|
20
|
+
const addressCondition =
|
|
21
|
+
fromAddress === toAddress
|
|
22
|
+
? `
|
|
23
|
+
${fromAddress ? `{ from: $fromAddress }` : ''}
|
|
24
|
+
${toAddress ? `{ to: $toAddress }` : ''}
|
|
25
|
+
`
|
|
26
|
+
: `
|
|
27
|
+
${fromAddress ? `from: $fromAddress` : ''}
|
|
28
|
+
${toAddress ? `to: $toAddress` : ''}
|
|
29
|
+
`;
|
|
30
|
+
|
|
20
31
|
const WHERE_CLAUSE = `
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`;
|
|
32
|
+
where: {
|
|
33
|
+
${fromAddress === toAddress ? `or: [ ${addressCondition} ],` : addressCondition}
|
|
34
|
+
${startDate ? `timestamp_gte: $startDate,` : ''}
|
|
35
|
+
${endDate ? `timestamp_lte: $endDate,` : ''}
|
|
36
|
+
${startBlock ? `block_gte: $startBlock,` : ''}
|
|
37
|
+
${endBlock ? `block_lte: $endBlock,` : ''}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
30
40
|
|
|
31
41
|
return gql`
|
|
32
42
|
query getTransactions(
|
package/src/kvstore.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
ErrorKVStoreEmptyKey,
|
|
16
16
|
ErrorProviderDoesNotExist,
|
|
17
17
|
ErrorUnsupportedChainID,
|
|
18
|
+
InvalidKeyError,
|
|
18
19
|
} from './error';
|
|
19
20
|
import gqlFetch from 'graphql-request';
|
|
20
21
|
import { NetworkData } from './types';
|
|
@@ -406,12 +407,10 @@ export class KVStoreUtils {
|
|
|
406
407
|
);
|
|
407
408
|
|
|
408
409
|
if (!kvstores || kvstores.length === 0) {
|
|
409
|
-
throw new
|
|
410
|
+
throw new InvalidKeyError(key, address);
|
|
410
411
|
}
|
|
411
412
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return value;
|
|
413
|
+
return kvstores[0].value;
|
|
415
414
|
}
|
|
416
415
|
|
|
417
416
|
/**
|
|
@@ -465,7 +464,10 @@ export class KVStoreUtils {
|
|
|
465
464
|
const content = await fetch(url).then((res) => res.text());
|
|
466
465
|
const contentHash = ethers.keccak256(ethers.toUtf8Bytes(content));
|
|
467
466
|
|
|
468
|
-
|
|
467
|
+
const formattedHash = hash?.replace(/^0x/, '');
|
|
468
|
+
const formattedContentHash = contentHash?.replace(/^0x/, '');
|
|
469
|
+
|
|
470
|
+
if (formattedHash !== formattedContentHash) {
|
|
469
471
|
throw ErrorInvalidHash;
|
|
470
472
|
}
|
|
471
473
|
|
package/src/operator.ts
CHANGED
|
@@ -165,6 +165,8 @@ export class OperatorUtils {
|
|
|
165
165
|
role: role,
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
+
if (!reputationNetwork) return [];
|
|
169
|
+
|
|
168
170
|
return reputationNetwork.operators.map((operator) => {
|
|
169
171
|
let jobTypes: string[] = [];
|
|
170
172
|
|
|
@@ -215,6 +217,8 @@ export class OperatorUtils {
|
|
|
215
217
|
slasherAddress: slasherAddress.toLowerCase(),
|
|
216
218
|
});
|
|
217
219
|
|
|
220
|
+
if (!rewardAddedEvents) return [];
|
|
221
|
+
|
|
218
222
|
return rewardAddedEvents.map((reward: any) => {
|
|
219
223
|
return {
|
|
220
224
|
escrowAddress: reward.escrow,
|
package/src/transaction.ts
CHANGED
|
@@ -50,7 +50,7 @@ export class TransactionUtils {
|
|
|
50
50
|
hash: hash.toLowerCase(),
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
return transaction;
|
|
53
|
+
return transaction || null;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -125,6 +125,7 @@ export class TransactionUtils {
|
|
|
125
125
|
if (!networkData) {
|
|
126
126
|
throw ErrorUnsupportedChainID;
|
|
127
127
|
}
|
|
128
|
+
|
|
128
129
|
const { transactions } = await gqlFetch<{
|
|
129
130
|
transactions: ITransaction[];
|
|
130
131
|
}>(getSubgraphUrl(networkData), GET_TRANSACTIONS_QUERY(filter), {
|