@human-protocol/sdk 1.1.18 → 2.0.0
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/base.d.ts +4 -13
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +3 -18
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +18 -11
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +4 -2
- package/dist/encryption.d.ts +31 -0
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +37 -0
- package/dist/error.d.ts +0 -10
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -18
- package/dist/escrow.d.ts +39 -33
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +121 -137
- package/dist/graphql/queries/{staking.d.ts → operator.d.ts} +2 -1
- package/dist/graphql/queries/operator.d.ts.map +1 -0
- package/dist/graphql/queries/{staking.js → operator.js} +24 -1
- package/dist/graphql/types.d.ts +5 -6
- 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 +28 -18
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +14 -14
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +30 -48
- package/dist/operator.d.ts +68 -0
- package/dist/operator.d.ts.map +1 -0
- package/dist/operator.js +153 -0
- package/dist/staking.d.ts +35 -95
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +73 -201
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +7 -6
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -15
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -49
- package/package.json +4 -4
- package/src/base.ts +5 -30
- package/src/constants.ts +18 -10
- package/src/decorators.ts +3 -2
- package/src/encryption.ts +40 -0
- package/src/error.ts +0 -17
- package/src/escrow.ts +169 -178
- package/src/graphql/queries/{staking.ts → operator.ts} +24 -0
- package/src/graphql/types.ts +5 -7
- package/src/index.ts +2 -0
- package/src/interfaces.ts +30 -18
- package/src/kvstore.ts +47 -59
- package/src/operator.ts +192 -0
- package/src/staking.ts +101 -213
- package/src/statistics.ts +8 -9
- package/src/types.ts +1 -3
- package/src/utils.ts +8 -58
- package/dist/graphql/queries/staking.d.ts.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ILeadersFilter } from 'src/interfaces';
|
|
2
2
|
export declare const GET_LEADERS_QUERY: (filter: ILeadersFilter) => import("graphql").DocumentNode;
|
|
3
|
+
export declare const GET_REPUTATION_NETWORK_QUERY: (role?: string) => import("graphql").DocumentNode;
|
|
3
4
|
export declare const GET_LEADER_QUERY: import("graphql").DocumentNode;
|
|
4
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=operator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/operator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAuBhD,eAAO,MAAM,iBAAiB,WAAY,cAAc,mCAuBvD,CAAC;AAEF,eAAO,MAAM,4BAA4B,UAAW,MAAM,mCAsBzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,gCAO5B,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_LEADER_QUERY = exports.GET_LEADERS_QUERY = void 0;
|
|
6
|
+
exports.GET_LEADER_QUERY = exports.GET_REPUTATION_NETWORK_QUERY = exports.GET_LEADERS_QUERY = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const LEADER_FRAGMENT = (0, graphql_tag_1.default) `
|
|
9
9
|
fragment LeaderFields on Leader {
|
|
@@ -48,6 +48,29 @@ const GET_LEADERS_QUERY = (filter) => {
|
|
|
48
48
|
`;
|
|
49
49
|
};
|
|
50
50
|
exports.GET_LEADERS_QUERY = GET_LEADERS_QUERY;
|
|
51
|
+
const GET_REPUTATION_NETWORK_QUERY = (role) => {
|
|
52
|
+
const WHERE_CLAUSE = `
|
|
53
|
+
where: {
|
|
54
|
+
${role ? `role: $role` : ''}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
return (0, graphql_tag_1.default) `
|
|
58
|
+
query getReputationNetwork(
|
|
59
|
+
$address: String,
|
|
60
|
+
$role: String
|
|
61
|
+
) {
|
|
62
|
+
reputationNetwork(id: $address) {
|
|
63
|
+
operators(
|
|
64
|
+
${WHERE_CLAUSE}
|
|
65
|
+
) {
|
|
66
|
+
address,
|
|
67
|
+
role
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
};
|
|
73
|
+
exports.GET_REPUTATION_NETWORK_QUERY = GET_REPUTATION_NETWORK_QUERY;
|
|
51
74
|
exports.GET_LEADER_QUERY = (0, graphql_tag_1.default) `
|
|
52
75
|
query getLeader($address: String!) {
|
|
53
76
|
leader(id: $address) {
|
package/dist/graphql/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BigNumber } from 'ethers';
|
|
2
1
|
export type EscrowData = {
|
|
3
2
|
id: string;
|
|
4
3
|
address: string;
|
|
@@ -97,9 +96,9 @@ export type WorkerStatistics = {
|
|
|
97
96
|
};
|
|
98
97
|
export type DailyPaymentData = {
|
|
99
98
|
timestamp: Date;
|
|
100
|
-
totalAmountPaid:
|
|
99
|
+
totalAmountPaid: bigint;
|
|
101
100
|
totalCount: number;
|
|
102
|
-
averageAmountPerWorker:
|
|
101
|
+
averageAmountPerWorker: bigint;
|
|
103
102
|
};
|
|
104
103
|
export type PaymentStatistics = {
|
|
105
104
|
dailyPaymentsData: DailyPaymentData[];
|
|
@@ -110,15 +109,15 @@ export type HMTHolderData = {
|
|
|
110
109
|
};
|
|
111
110
|
export type HMTHolder = {
|
|
112
111
|
address: string;
|
|
113
|
-
balance:
|
|
112
|
+
balance: bigint;
|
|
114
113
|
};
|
|
115
114
|
export type DailyHMTData = {
|
|
116
115
|
timestamp: Date;
|
|
117
|
-
totalTransactionAmount:
|
|
116
|
+
totalTransactionAmount: bigint;
|
|
118
117
|
totalTransactionCount: number;
|
|
119
118
|
};
|
|
120
119
|
export type HMTStatistics = {
|
|
121
|
-
totalTransferAmount:
|
|
120
|
+
totalTransferAmount: bigint;
|
|
122
121
|
totalTransferCount: number;
|
|
123
122
|
totalHolders: number;
|
|
124
123
|
holders: HMTHolder[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/graphql/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/graphql/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EA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4
|
import { EscrowClient, EscrowUtils } from './escrow';
|
|
5
5
|
import { StatisticsClient } from './statistics';
|
|
6
6
|
import { Encryption, EncryptionUtils } from './encryption';
|
|
7
|
+
import { OperatorUtils } from './operator';
|
|
7
8
|
export * from './constants';
|
|
8
9
|
export * from './types';
|
|
9
10
|
export * from './enums';
|
|
10
11
|
export * from './interfaces';
|
|
11
|
-
export { StakingClient, StorageClient, KVStoreClient, EscrowClient, EscrowUtils, StatisticsClient, Encryption, EncryptionUtils, };
|
|
12
|
+
export { StakingClient, StorageClient, KVStoreClient, EscrowClient, EscrowUtils, StatisticsClient, Encryption, EncryptionUtils, OperatorUtils, };
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,aAAa,GACd,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
|
|
17
|
+
exports.OperatorUtils = exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
|
|
18
18
|
const staking_1 = require("./staking");
|
|
19
19
|
Object.defineProperty(exports, "StakingClient", { enumerable: true, get: function () { return staking_1.StakingClient; } });
|
|
20
20
|
const storage_1 = require("./storage");
|
|
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "StatisticsClient", { enumerable: true, get: func
|
|
|
29
29
|
const encryption_1 = require("./encryption");
|
|
30
30
|
Object.defineProperty(exports, "Encryption", { enumerable: true, get: function () { return encryption_1.Encryption; } });
|
|
31
31
|
Object.defineProperty(exports, "EncryptionUtils", { enumerable: true, get: function () { return encryption_1.EncryptionUtils; } });
|
|
32
|
+
const operator_1 = require("./operator");
|
|
33
|
+
Object.defineProperty(exports, "OperatorUtils", { enumerable: true, get: function () { return operator_1.OperatorUtils; } });
|
|
32
34
|
__exportStar(require("./constants"), exports);
|
|
33
35
|
__exportStar(require("./types"), exports);
|
|
34
36
|
__exportStar(require("./enums"), exports);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,36 +1,46 @@
|
|
|
1
|
-
import { BigNumber } from 'ethers';
|
|
2
1
|
import { EscrowStatus } from './types';
|
|
3
2
|
import { ChainId } from './enums';
|
|
4
3
|
export interface IAllocation {
|
|
5
4
|
escrowAddress: string;
|
|
6
5
|
staker: string;
|
|
7
|
-
tokens:
|
|
8
|
-
createdAt:
|
|
9
|
-
closedAt:
|
|
6
|
+
tokens: bigint;
|
|
7
|
+
createdAt: bigint;
|
|
8
|
+
closedAt: bigint;
|
|
10
9
|
}
|
|
11
10
|
export interface IReward {
|
|
12
11
|
escrowAddress: string;
|
|
13
|
-
amount:
|
|
12
|
+
amount: bigint;
|
|
14
13
|
}
|
|
15
14
|
export interface ILeader {
|
|
16
15
|
id: string;
|
|
16
|
+
chainId: ChainId;
|
|
17
17
|
address: string;
|
|
18
|
-
amountStaked:
|
|
19
|
-
amountAllocated:
|
|
20
|
-
amountLocked:
|
|
21
|
-
lockedUntilTimestamp:
|
|
22
|
-
amountWithdrawn:
|
|
23
|
-
amountSlashed:
|
|
24
|
-
reputation:
|
|
25
|
-
reward:
|
|
26
|
-
amountJobsLaunched:
|
|
18
|
+
amountStaked: bigint;
|
|
19
|
+
amountAllocated: bigint;
|
|
20
|
+
amountLocked: bigint;
|
|
21
|
+
lockedUntilTimestamp: bigint;
|
|
22
|
+
amountWithdrawn: bigint;
|
|
23
|
+
amountSlashed: bigint;
|
|
24
|
+
reputation: bigint;
|
|
25
|
+
reward: bigint;
|
|
26
|
+
amountJobsLaunched: bigint;
|
|
27
27
|
role?: string;
|
|
28
|
-
fee?:
|
|
28
|
+
fee?: bigint;
|
|
29
29
|
publicKey?: string;
|
|
30
30
|
webhookUrl?: string;
|
|
31
31
|
url?: string;
|
|
32
32
|
}
|
|
33
33
|
export interface ILeadersFilter {
|
|
34
|
+
networks: ChainId[];
|
|
35
|
+
role?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface IReputationNetwork {
|
|
38
|
+
id: string;
|
|
39
|
+
address: string;
|
|
40
|
+
operators: IOperator[];
|
|
41
|
+
}
|
|
42
|
+
export interface IOperator {
|
|
43
|
+
address: string;
|
|
34
44
|
role?: string;
|
|
35
45
|
}
|
|
36
46
|
export interface IEscrowsFilter {
|
|
@@ -48,9 +58,9 @@ export interface IEscrowConfig {
|
|
|
48
58
|
recordingOracle: string;
|
|
49
59
|
reputationOracle: string;
|
|
50
60
|
exchangeOracle: string;
|
|
51
|
-
recordingOracleFee:
|
|
52
|
-
reputationOracleFee:
|
|
53
|
-
exchangeOracleFee:
|
|
61
|
+
recordingOracleFee: bigint;
|
|
62
|
+
reputationOracleFee: bigint;
|
|
63
|
+
exchangeOracleFee: bigint;
|
|
54
64
|
manifestUrl: string;
|
|
55
65
|
manifestHash: string;
|
|
56
66
|
}
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACt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MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;CACX"}
|
package/dist/kvstore.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Signer } from 'ethers';
|
|
1
|
+
import { ContractRunner, Overrides } from 'ethers';
|
|
3
2
|
import { BaseEthersClient } from './base';
|
|
4
3
|
import { NetworkData } from './types';
|
|
5
4
|
/**
|
|
@@ -7,11 +6,11 @@ import { NetworkData } from './types';
|
|
|
7
6
|
*
|
|
8
7
|
* This client enables to perform actions on KVStore contract and obtain information from both the contracts and subgraph.
|
|
9
8
|
*
|
|
10
|
-
* Internally, the SDK will use one network or another according to the network ID of the `
|
|
9
|
+
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
11
10
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
12
11
|
*
|
|
13
12
|
* ```ts
|
|
14
|
-
* static async build(
|
|
13
|
+
* static async build(runner: ContractRunner);
|
|
15
14
|
* ```
|
|
16
15
|
*
|
|
17
16
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
@@ -76,27 +75,26 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
76
75
|
/**
|
|
77
76
|
* **KVStoreClient constructor**
|
|
78
77
|
*
|
|
79
|
-
* @param {
|
|
78
|
+
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
80
79
|
* @param {NetworkData} network - The network information required to connect to the KVStore contract
|
|
81
|
-
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
82
80
|
*/
|
|
83
|
-
constructor(
|
|
81
|
+
constructor(runner: ContractRunner, networkData: NetworkData);
|
|
84
82
|
/**
|
|
85
|
-
* Creates an instance of KVStoreClient from a
|
|
83
|
+
* Creates an instance of KVStoreClient from a runner.
|
|
86
84
|
*
|
|
87
|
-
* @param {
|
|
88
|
-
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
85
|
+
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
89
86
|
*
|
|
90
87
|
* @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
|
|
91
88
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
92
89
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
93
90
|
*/
|
|
94
|
-
static build(
|
|
91
|
+
static build(runner: ContractRunner): Promise<KVStoreClient>;
|
|
95
92
|
/**
|
|
96
93
|
* This function sets a key-value pair associated with the address that submits the transaction.
|
|
97
94
|
*
|
|
98
95
|
* @param {string} key Key of the key-value pair
|
|
99
96
|
* @param {string} value Value of the key-value pair
|
|
97
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
100
98
|
* @returns Returns void if successful. Throws error if any.
|
|
101
99
|
*
|
|
102
100
|
*
|
|
@@ -118,12 +116,13 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
118
116
|
* await kvstoreClient.set('Role', 'RecordingOracle');
|
|
119
117
|
* ```
|
|
120
118
|
*/
|
|
121
|
-
set(key: string, value: string): Promise<void>;
|
|
119
|
+
set(key: string, value: string, txOptions?: Overrides): Promise<void>;
|
|
122
120
|
/**
|
|
123
121
|
* This function sets key-value pairs in bulk associated with the address that submits the transaction.
|
|
124
122
|
*
|
|
125
123
|
* @param {string[]} keys Array of keys (keys and value must have the same order)
|
|
126
124
|
* @param {string[]} values Array of values
|
|
125
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
127
126
|
* @returns Returns void if successful. Throws error if any.
|
|
128
127
|
*
|
|
129
128
|
*
|
|
@@ -147,12 +146,13 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
147
146
|
* await kvstoreClient.set(keys, values);
|
|
148
147
|
* ```
|
|
149
148
|
*/
|
|
150
|
-
setBulk(keys: string[], values: string[]): Promise<void>;
|
|
149
|
+
setBulk(keys: string[], values: string[], txOptions?: Overrides): Promise<void>;
|
|
151
150
|
/**
|
|
152
151
|
* This function sets a URL value for the address that submits the transaction.
|
|
153
152
|
*
|
|
154
153
|
* @param {string} url URL to set
|
|
155
154
|
* @param {string | undefined} urlKey Configurable URL key. `url` by default.
|
|
155
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
156
156
|
* @returns Returns void if successful. Throws error if any.
|
|
157
157
|
*
|
|
158
158
|
*
|
|
@@ -173,7 +173,7 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
173
173
|
* await kvstoreClient.setURL('linkedin.com/example', 'linkedinUrl);
|
|
174
174
|
* ```
|
|
175
175
|
*/
|
|
176
|
-
setURL(url: string, urlKey?: string): Promise<void>;
|
|
176
|
+
setURL(url: string, urlKey?: string, txOptions?: Overrides): Promise<void>;
|
|
177
177
|
/**
|
|
178
178
|
* This function returns the value for a specified key and address.
|
|
179
179
|
*
|
package/dist/kvstore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"
|
|
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;AAa1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAS5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc;IAiBhD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,GAAG,CACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAShB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IAEU,OAAO,CAClB,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,MAAM,CACjB,GAAG,EAAE,MAAM,EACX,MAAM,SAAQ,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAwBhB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAa/D;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;CAiCtE"}
|
package/dist/kvstore.js
CHANGED
|
@@ -22,11 +22,11 @@ const utils_1 = require("./utils");
|
|
|
22
22
|
*
|
|
23
23
|
* This client enables to perform actions on KVStore contract and obtain information from both the contracts and subgraph.
|
|
24
24
|
*
|
|
25
|
-
* Internally, the SDK will use one network or another according to the network ID of the `
|
|
25
|
+
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
26
26
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
27
27
|
*
|
|
28
28
|
* ```ts
|
|
29
|
-
* static async build(
|
|
29
|
+
* static async build(runner: ContractRunner);
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
32
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
@@ -90,47 +90,40 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
90
90
|
/**
|
|
91
91
|
* **KVStoreClient constructor**
|
|
92
92
|
*
|
|
93
|
-
* @param {
|
|
93
|
+
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
94
94
|
* @param {NetworkData} network - The network information required to connect to the KVStore contract
|
|
95
|
-
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
96
95
|
*/
|
|
97
|
-
constructor(
|
|
98
|
-
super(
|
|
99
|
-
this.contract = typechain_types_1.KVStore__factory.connect(networkData.kvstoreAddress,
|
|
96
|
+
constructor(runner, networkData) {
|
|
97
|
+
super(runner, networkData);
|
|
98
|
+
this.contract = typechain_types_1.KVStore__factory.connect(networkData.kvstoreAddress, runner);
|
|
100
99
|
}
|
|
101
100
|
/**
|
|
102
|
-
* Creates an instance of KVStoreClient from a
|
|
101
|
+
* Creates an instance of KVStoreClient from a runner.
|
|
103
102
|
*
|
|
104
|
-
* @param {
|
|
105
|
-
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
103
|
+
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
106
104
|
*
|
|
107
105
|
* @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
|
|
108
106
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
109
107
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
110
108
|
*/
|
|
111
|
-
static async build(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (!signerOrProvider.provider) {
|
|
115
|
-
throw error_1.ErrorProviderDoesNotExist;
|
|
116
|
-
}
|
|
117
|
-
network = await signerOrProvider.provider.getNetwork();
|
|
109
|
+
static async build(runner) {
|
|
110
|
+
if (!runner.provider) {
|
|
111
|
+
throw error_1.ErrorProviderDoesNotExist;
|
|
118
112
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
const chainId = network.chainId;
|
|
113
|
+
const network = await runner.provider?.getNetwork();
|
|
114
|
+
const chainId = Number(network?.chainId);
|
|
123
115
|
const networkData = constants_1.NETWORKS[chainId];
|
|
124
116
|
if (!networkData) {
|
|
125
117
|
throw error_1.ErrorUnsupportedChainID;
|
|
126
118
|
}
|
|
127
|
-
return new KVStoreClient(
|
|
119
|
+
return new KVStoreClient(runner, networkData);
|
|
128
120
|
}
|
|
129
121
|
/**
|
|
130
122
|
* This function sets a key-value pair associated with the address that submits the transaction.
|
|
131
123
|
*
|
|
132
124
|
* @param {string} key Key of the key-value pair
|
|
133
125
|
* @param {string} value Value of the key-value pair
|
|
126
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
134
127
|
* @returns Returns void if successful. Throws error if any.
|
|
135
128
|
*
|
|
136
129
|
*
|
|
@@ -152,15 +145,11 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
152
145
|
* await kvstoreClient.set('Role', 'RecordingOracle');
|
|
153
146
|
* ```
|
|
154
147
|
*/
|
|
155
|
-
async set(key, value) {
|
|
156
|
-
if (!ethers_1.Signer.isSigner(this.signerOrProvider))
|
|
157
|
-
throw error_1.ErrorSigner;
|
|
148
|
+
async set(key, value, txOptions = {}) {
|
|
158
149
|
if (key === '')
|
|
159
150
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
160
151
|
try {
|
|
161
|
-
await this.contract
|
|
162
|
-
...(await this.gasPriceOptions()),
|
|
163
|
-
});
|
|
152
|
+
await (await this.contract.set(key, value, txOptions)).wait();
|
|
164
153
|
}
|
|
165
154
|
catch (e) {
|
|
166
155
|
if (e instanceof Error)
|
|
@@ -172,6 +161,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
172
161
|
*
|
|
173
162
|
* @param {string[]} keys Array of keys (keys and value must have the same order)
|
|
174
163
|
* @param {string[]} values Array of values
|
|
164
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
175
165
|
* @returns Returns void if successful. Throws error if any.
|
|
176
166
|
*
|
|
177
167
|
*
|
|
@@ -195,17 +185,13 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
195
185
|
* await kvstoreClient.set(keys, values);
|
|
196
186
|
* ```
|
|
197
187
|
*/
|
|
198
|
-
async setBulk(keys, values) {
|
|
199
|
-
if (!ethers_1.Signer.isSigner(this.signerOrProvider))
|
|
200
|
-
throw error_1.ErrorSigner;
|
|
188
|
+
async setBulk(keys, values, txOptions = {}) {
|
|
201
189
|
if (keys.length !== values.length)
|
|
202
190
|
throw error_1.ErrorKVStoreArrayLength;
|
|
203
191
|
if (keys.includes(''))
|
|
204
192
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
205
193
|
try {
|
|
206
|
-
await this.contract
|
|
207
|
-
...(await this.gasPriceOptions()),
|
|
208
|
-
});
|
|
194
|
+
await (await this.contract.setBulk(keys, values, txOptions)).wait();
|
|
209
195
|
}
|
|
210
196
|
catch (e) {
|
|
211
197
|
if (e instanceof Error)
|
|
@@ -217,6 +203,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
217
203
|
*
|
|
218
204
|
* @param {string} url URL to set
|
|
219
205
|
* @param {string | undefined} urlKey Configurable URL key. `url` by default.
|
|
206
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
220
207
|
* @returns Returns void if successful. Throws error if any.
|
|
221
208
|
*
|
|
222
209
|
*
|
|
@@ -237,20 +224,15 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
237
224
|
* await kvstoreClient.setURL('linkedin.com/example', 'linkedinUrl);
|
|
238
225
|
* ```
|
|
239
226
|
*/
|
|
240
|
-
async setURL(url, urlKey = 'url') {
|
|
241
|
-
if (!ethers_1.Signer.isSigner(this.signerOrProvider)) {
|
|
242
|
-
throw error_1.ErrorSigner;
|
|
243
|
-
}
|
|
227
|
+
async setURL(url, urlKey = 'url', txOptions = {}) {
|
|
244
228
|
if (!(0, utils_1.isValidUrl)(url)) {
|
|
245
229
|
throw error_1.ErrorInvalidUrl;
|
|
246
230
|
}
|
|
247
231
|
const content = await fetch(url).then((res) => res.text());
|
|
248
|
-
const contentHash = ethers_1.ethers.
|
|
232
|
+
const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
|
|
249
233
|
const hashKey = urlKey + 'Hash';
|
|
250
234
|
try {
|
|
251
|
-
await this.contract.setBulk([urlKey, hashKey], [url, contentHash],
|
|
252
|
-
...(await this.gasPriceOptions()),
|
|
253
|
-
});
|
|
235
|
+
await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash], txOptions)).wait();
|
|
254
236
|
}
|
|
255
237
|
catch (e) {
|
|
256
238
|
if (e instanceof Error)
|
|
@@ -284,7 +266,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
284
266
|
async get(address, key) {
|
|
285
267
|
if (key === '')
|
|
286
268
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
287
|
-
if (!ethers_1.ethers.
|
|
269
|
+
if (!ethers_1.ethers.isAddress(address))
|
|
288
270
|
throw error_1.ErrorInvalidAddress;
|
|
289
271
|
try {
|
|
290
272
|
const result = await this.contract?.get(address, key);
|
|
@@ -323,7 +305,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
323
305
|
* ```
|
|
324
306
|
*/
|
|
325
307
|
async getURL(address, urlKey = 'url') {
|
|
326
|
-
if (!ethers_1.ethers.
|
|
308
|
+
if (!ethers_1.ethers.isAddress(address))
|
|
327
309
|
throw error_1.ErrorInvalidAddress;
|
|
328
310
|
const hashKey = urlKey + 'Hash';
|
|
329
311
|
let url = '', hash = '';
|
|
@@ -346,7 +328,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
346
328
|
throw Error(`Failed to get Hash: ${e.message}`);
|
|
347
329
|
}
|
|
348
330
|
const content = await fetch(url).then((res) => res.text());
|
|
349
|
-
const contentHash = ethers_1.ethers.
|
|
331
|
+
const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
|
|
350
332
|
if (hash !== contentHash) {
|
|
351
333
|
throw error_1.ErrorInvalidHash;
|
|
352
334
|
}
|
|
@@ -356,19 +338,19 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
356
338
|
__decorate([
|
|
357
339
|
decorators_1.requiresSigner,
|
|
358
340
|
__metadata("design:type", Function),
|
|
359
|
-
__metadata("design:paramtypes", [String, String]),
|
|
341
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
360
342
|
__metadata("design:returntype", Promise)
|
|
361
343
|
], KVStoreClient.prototype, "set", null);
|
|
362
344
|
__decorate([
|
|
363
345
|
decorators_1.requiresSigner,
|
|
364
346
|
__metadata("design:type", Function),
|
|
365
|
-
__metadata("design:paramtypes", [Array, Array]),
|
|
347
|
+
__metadata("design:paramtypes", [Array, Array, Object]),
|
|
366
348
|
__metadata("design:returntype", Promise)
|
|
367
349
|
], KVStoreClient.prototype, "setBulk", null);
|
|
368
350
|
__decorate([
|
|
369
351
|
decorators_1.requiresSigner,
|
|
370
352
|
__metadata("design:type", Function),
|
|
371
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
353
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
372
354
|
__metadata("design:returntype", Promise)
|
|
373
355
|
], KVStoreClient.prototype, "setURL", null);
|
|
374
356
|
exports.KVStoreClient = KVStoreClient;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ILeader, ILeadersFilter, IOperator, IReward } from './interfaces';
|
|
2
|
+
import { ChainId } from './enums';
|
|
3
|
+
export declare class OperatorUtils {
|
|
4
|
+
/**
|
|
5
|
+
* This function returns the leader data for the given address.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} address Leader address.
|
|
8
|
+
* @returns {ILeader} Returns the leader details.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* **Code example**
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
15
|
+
*
|
|
16
|
+
* const leader = await OperatorUtils.getLeader(ChainId.POLYGON_MUMBAI, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
static getLeader(chainId: ChainId, address: string): Promise<ILeader>;
|
|
20
|
+
/**
|
|
21
|
+
* This function returns all the leader details of the protocol.
|
|
22
|
+
*
|
|
23
|
+
* @param {ILeadersFilter} filter Filter for the leaders.
|
|
24
|
+
* @returns {ILeader[]} Returns an array with all the leader details.
|
|
25
|
+
*
|
|
26
|
+
*
|
|
27
|
+
* **Code example**
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { OperatorUtils } from '@human-protocol/sdk';
|
|
31
|
+
*
|
|
32
|
+
* const leaders = await OperatorUtils.getLeaders();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
static getLeaders(filter?: ILeadersFilter): Promise<ILeader[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves the reputation network operators of the specified address.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} address - Address of the reputation oracle.
|
|
40
|
+
* @param {string} [role] - (Optional) Role of the operator.
|
|
41
|
+
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
46
|
+
*
|
|
47
|
+
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_MUMBAI, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
static getReputationNetworkOperators(chainId: ChainId, address: string, role?: string): Promise<IOperator[]>;
|
|
51
|
+
/**
|
|
52
|
+
* This function returns information about the rewards for a given slasher address.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} slasherAddress Slasher address.
|
|
55
|
+
* @returns {IReward[]} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
* **Code example**
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
62
|
+
*
|
|
63
|
+
* const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_MUMBAI, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
static getRewards(chainId: ChainId, slasherAddress: string): Promise<IReward[]>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=operator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EACP,cAAc,EACd,SAAS,EAET,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;IAuBnB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,MAAM,GAAE,cAAuD,GAC9D,OAAO,CAAC,OAAO,EAAE,CAAC;IAuBrB;;;;;;;;;;;;;OAaG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IAoBvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CA2BtB"}
|