@human-protocol/sdk 1.1.3 → 1.1.6

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.
Files changed (56) hide show
  1. package/README.md +80 -1
  2. package/dist/constants.d.ts +52 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +222 -0
  5. package/dist/decorators.d.ts +2 -0
  6. package/dist/decorators.d.ts.map +1 -0
  7. package/dist/decorators.js +17 -0
  8. package/dist/encryption.d.ts +84 -0
  9. package/dist/encryption.d.ts.map +1 -0
  10. package/dist/encryption.js +202 -0
  11. package/dist/enums.d.ts +17 -0
  12. package/dist/enums.d.ts.map +1 -0
  13. package/dist/enums.js +20 -0
  14. package/dist/error.d.ts +196 -0
  15. package/dist/error.d.ts.map +1 -0
  16. package/dist/error.js +229 -0
  17. package/dist/escrow.d.ts +201 -0
  18. package/dist/escrow.d.ts.map +1 -0
  19. package/dist/escrow.js +651 -0
  20. package/dist/index.d.ts +10 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +29 -0
  23. package/dist/interfaces.d.ts +42 -0
  24. package/dist/interfaces.d.ts.map +1 -0
  25. package/dist/interfaces.js +2 -0
  26. package/dist/kvstore.d.ts +51 -0
  27. package/dist/kvstore.d.ts.map +1 -0
  28. package/dist/kvstore.js +135 -0
  29. package/dist/queries.d.ts +5 -0
  30. package/dist/queries.d.ts.map +1 -0
  31. package/dist/queries.js +19 -0
  32. package/dist/staking.d.ts +130 -0
  33. package/dist/staking.d.ts.map +1 -0
  34. package/dist/staking.js +409 -0
  35. package/dist/storage.d.ts +49 -0
  36. package/dist/storage.d.ts.map +1 -0
  37. package/dist/storage.js +171 -0
  38. package/dist/types.d.ts +131 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/types.js +35 -0
  41. package/dist/utils.d.ts +32 -0
  42. package/dist/utils.d.ts.map +1 -0
  43. package/dist/utils.js +99 -0
  44. package/package.json +4 -1
  45. package/src/constants.ts +25 -6
  46. package/src/encryption.ts +223 -0
  47. package/src/error.ts +2 -4
  48. package/src/escrow.ts +120 -74
  49. package/src/index.ts +6 -12
  50. package/src/interfaces.ts +10 -13
  51. package/src/kvstore.ts +51 -14
  52. package/src/queries.ts +15 -7
  53. package/src/staking.ts +61 -24
  54. package/src/storage.ts +15 -3
  55. package/src/types.ts +8 -0
  56. package/src/init.ts +0 -45
@@ -0,0 +1,42 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { EscrowStatus } from './types';
3
+ export interface IAllocation {
4
+ escrowAddress: string;
5
+ staker: string;
6
+ tokens: BigNumber;
7
+ createdAt: BigNumber;
8
+ closedAt: BigNumber;
9
+ }
10
+ export interface IReward {
11
+ escrowAddress: string;
12
+ amount: BigNumber;
13
+ }
14
+ export interface IStaker {
15
+ tokensStaked: BigNumber;
16
+ tokensAllocated: BigNumber;
17
+ tokensLocked: BigNumber;
18
+ tokensLockedUntil: BigNumber;
19
+ tokensAvailable: BigNumber;
20
+ }
21
+ export interface IEscrowsFilter {
22
+ address?: string;
23
+ role?: number;
24
+ status?: EscrowStatus;
25
+ from?: Date;
26
+ to?: Date;
27
+ }
28
+ export interface IEscrowConfig {
29
+ recordingOracle: string;
30
+ reputationOracle: string;
31
+ recordingOracleFee: BigNumber;
32
+ reputationOracleFee: BigNumber;
33
+ manifestUrl: string;
34
+ manifestHash: string;
35
+ }
36
+ export interface IKeyPair {
37
+ privateKey: string;
38
+ publicKey: string;
39
+ passphrase: string;
40
+ revocationCertificate?: string;
41
+ }
42
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,OAAO;IACtB,YAAY,EAAE,SAAS,CAAC;IACxB,eAAe,EAAE,SAAS,CAAC;IAC3B,YAAY,EAAE,SAAS,CAAC;IACxB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,eAAe,EAAE,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,SAAS,CAAC;IAC9B,mBAAmB,EAAE,SAAS,CAAC;IAC/B,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"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,51 @@
1
+ import { Provider } from '@ethersproject/abstract-provider';
2
+ import { Signer } from 'ethers';
3
+ import { NetworkData } from './types';
4
+ export declare class KVStoreClient {
5
+ private contract;
6
+ private signerOrProvider;
7
+ /**
8
+ * **KVStoreClient constructor**
9
+ *
10
+ * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
11
+ * @param {NetworkData} network - The network information required to connect to the KVStore contract
12
+ */
13
+ constructor(signerOrProvider: Signer | Provider, network: NetworkData);
14
+ /**
15
+ * Creates an instance of KVStoreClient from a Signer or Provider.
16
+ *
17
+ * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
18
+ * @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
19
+ * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
20
+ * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
21
+ */
22
+ static build(signerOrProvider: Signer | Provider): Promise<KVStoreClient>;
23
+ /**
24
+ * Sets a key-value pair in the contract
25
+ *
26
+ * @param {string} key - The key of the key-value pair to set
27
+ * @param {string} value - The value of the key-value pair to set
28
+ * @returns {Promise<void>}
29
+ * @throws {Error} - An error object if an error occurred
30
+ */
31
+ set(key: string, value: string): Promise<void>;
32
+ /**
33
+ * Sets multiple key-value pairs in the contract
34
+ *
35
+ * @param {string[]} keys - An array of keys to set
36
+ * @param {string[]} values - An array of values to set
37
+ * @returns {Promise<void>}
38
+ * @throws {Error} - An error object if an error occurred
39
+ */
40
+ setBulk(keys: string[], values: string[]): Promise<void>;
41
+ /**
42
+ * Gets the value of a key-value pair in the contract
43
+ *
44
+ * @param {string} address - The Ethereum address associated with the key-value pair
45
+ * @param {string} key - The key of the key-value pair to get
46
+ * @returns {Promise<string>} - The value of the key-value pair if it exists
47
+ * @throws {Error} - An error object if an error occurred
48
+ */
49
+ get(address: string, key: string): Promise<string>;
50
+ }
51
+ //# sourceMappingURL=kvstore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAM5D,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAYxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,gBAAgB,CAAoB;IAE5C;;;;;OAKG;gBACS,gBAAgB,EAAE,MAAM,GAAG,QAAQ,EAAE,OAAO,EAAE,WAAW;IAQrE;;;;;;;OAOG;WACiB,KAAK,CAAC,gBAAgB,EAAE,MAAM,GAAG,QAAQ;IAsB7D;;;;;;;OAOG;IAEU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D;;;;;;;OAOG;IAEU,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAarE;;;;;;;OAOG;IACU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAYhE"}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.KVStoreClient = void 0;
13
+ const typechain_types_1 = require("@human-protocol/core/typechain-types");
14
+ const ethers_1 = require("ethers");
15
+ const constants_1 = require("./constants");
16
+ const decorators_1 = require("./decorators");
17
+ const error_1 = require("./error");
18
+ class KVStoreClient {
19
+ /**
20
+ * **KVStoreClient constructor**
21
+ *
22
+ * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
23
+ * @param {NetworkData} network - The network information required to connect to the KVStore contract
24
+ */
25
+ constructor(signerOrProvider, network) {
26
+ this.contract = typechain_types_1.KVStore__factory.connect(network.factoryAddress, signerOrProvider);
27
+ this.signerOrProvider = signerOrProvider;
28
+ }
29
+ /**
30
+ * Creates an instance of KVStoreClient from a Signer or Provider.
31
+ *
32
+ * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
33
+ * @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
34
+ * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
35
+ * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
36
+ */
37
+ static async build(signerOrProvider) {
38
+ let network;
39
+ if (ethers_1.Signer.isSigner(signerOrProvider)) {
40
+ if (!signerOrProvider.provider) {
41
+ throw error_1.ErrorProviderDoesNotExist;
42
+ }
43
+ network = await signerOrProvider.provider.getNetwork();
44
+ }
45
+ else {
46
+ network = await signerOrProvider.getNetwork();
47
+ }
48
+ const chainId = network.chainId;
49
+ const networkData = constants_1.NETWORKS[chainId];
50
+ if (!networkData) {
51
+ throw error_1.ErrorUnsupportedChainID;
52
+ }
53
+ return new KVStoreClient(signerOrProvider, networkData);
54
+ }
55
+ /**
56
+ * Sets a key-value pair in the contract
57
+ *
58
+ * @param {string} key - The key of the key-value pair to set
59
+ * @param {string} value - The value of the key-value pair to set
60
+ * @returns {Promise<void>}
61
+ * @throws {Error} - An error object if an error occurred
62
+ */
63
+ async set(key, value) {
64
+ if (!ethers_1.Signer.isSigner(this.signerOrProvider))
65
+ throw error_1.ErrorSigner;
66
+ if (key === '')
67
+ throw error_1.ErrorKVStoreEmptyKey;
68
+ try {
69
+ await this.contract?.set(key, value);
70
+ }
71
+ catch (e) {
72
+ if (e instanceof Error)
73
+ throw Error(`Failed to set value: ${e.message}`);
74
+ }
75
+ }
76
+ /**
77
+ * Sets multiple key-value pairs in the contract
78
+ *
79
+ * @param {string[]} keys - An array of keys to set
80
+ * @param {string[]} values - An array of values to set
81
+ * @returns {Promise<void>}
82
+ * @throws {Error} - An error object if an error occurred
83
+ */
84
+ async setBulk(keys, values) {
85
+ if (!ethers_1.Signer.isSigner(this.signerOrProvider))
86
+ throw error_1.ErrorSigner;
87
+ if (keys.length !== values.length)
88
+ throw error_1.ErrorKVStoreArrayLength;
89
+ if (keys.includes(''))
90
+ throw error_1.ErrorKVStoreEmptyKey;
91
+ try {
92
+ await this.contract?.setBulk(keys, values);
93
+ }
94
+ catch (e) {
95
+ if (e instanceof Error)
96
+ throw Error(`Failed to set bulk values: ${e.message}`);
97
+ }
98
+ }
99
+ /**
100
+ * Gets the value of a key-value pair in the contract
101
+ *
102
+ * @param {string} address - The Ethereum address associated with the key-value pair
103
+ * @param {string} key - The key of the key-value pair to get
104
+ * @returns {Promise<string>} - The value of the key-value pair if it exists
105
+ * @throws {Error} - An error object if an error occurred
106
+ */
107
+ async get(address, key) {
108
+ if (key === '')
109
+ throw error_1.ErrorKVStoreEmptyKey;
110
+ if (!ethers_1.ethers.utils.isAddress(address))
111
+ throw error_1.ErrorInvalidAddress;
112
+ try {
113
+ const result = await this.contract?.get(address, key);
114
+ return result;
115
+ }
116
+ catch (e) {
117
+ if (e instanceof Error)
118
+ throw Error(`Failed to get value: ${e.message}`);
119
+ return e;
120
+ }
121
+ }
122
+ }
123
+ __decorate([
124
+ decorators_1.requiresSigner,
125
+ __metadata("design:type", Function),
126
+ __metadata("design:paramtypes", [String, String]),
127
+ __metadata("design:returntype", Promise)
128
+ ], KVStoreClient.prototype, "set", null);
129
+ __decorate([
130
+ decorators_1.requiresSigner,
131
+ __metadata("design:type", Function),
132
+ __metadata("design:paramtypes", [Array, Array]),
133
+ __metadata("design:returntype", Promise)
134
+ ], KVStoreClient.prototype, "setBulk", null);
135
+ exports.KVStoreClient = KVStoreClient;
@@ -0,0 +1,5 @@
1
+ import { EscrowStatus } from './types';
2
+ export declare const RAW_REWARDS_QUERY: (slasherAddress: string) => string;
3
+ export declare const RAW_LAUNCHED_ESCROWS_QUERY: (requesterAddress: string) => string;
4
+ export declare const RAW_LAUNCHED_ESCROWS_FILTERED_QUERY: (address?: string, status?: EscrowStatus, from?: Date, to?: Date) => string;
5
+ //# sourceMappingURL=queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,eAAO,MAAM,iBAAiB,mBAAoB,MAAM,WAKpD,CAAC;AAEL,eAAO,MAAM,0BAA0B,qBAAsB,MAAM,WAI/D,CAAC;AAEL,eAAO,MAAM,mCAAmC,aACpC,MAAM,WACP,YAAY,SACd,IAAI,OACN,IAAI,WAMG,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RAW_LAUNCHED_ESCROWS_FILTERED_QUERY = exports.RAW_LAUNCHED_ESCROWS_QUERY = exports.RAW_REWARDS_QUERY = void 0;
4
+ const types_1 = require("./types");
5
+ const RAW_REWARDS_QUERY = (slasherAddress) => `{
6
+ rewardAddedEvents(id: "${slasherAddress}") {
7
+ escrow,
8
+ amount
9
+ }
10
+ }`;
11
+ exports.RAW_REWARDS_QUERY = RAW_REWARDS_QUERY;
12
+ const RAW_LAUNCHED_ESCROWS_QUERY = (requesterAddress) => `{
13
+ launchedEscrows(where: { from: ${requesterAddress} }) {
14
+ id
15
+ }
16
+ }`;
17
+ exports.RAW_LAUNCHED_ESCROWS_QUERY = RAW_LAUNCHED_ESCROWS_QUERY;
18
+ const RAW_LAUNCHED_ESCROWS_FILTERED_QUERY = (address, status, from, to) => `{ launchedEscrows(where: { ${address ? 'from: "' + address + '", ' : ''}${status ? 'status: "' + types_1.EscrowStatus[status] + '", ' : ''}${from ? 'timestamp_gte: "' + from?.valueOf() + '", ' : ''}${to ? 'timestamp_lte: "' + to?.valueOf() + '"' : ''}}) { id }}`;
19
+ exports.RAW_LAUNCHED_ESCROWS_FILTERED_QUERY = RAW_LAUNCHED_ESCROWS_FILTERED_QUERY;
@@ -0,0 +1,130 @@
1
+ import { Provider } from '@ethersproject/abstract-provider';
2
+ import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-types';
3
+ import { BigNumber, Signer } from 'ethers';
4
+ import { IAllocation, IReward, IStaker } from './interfaces';
5
+ import { NetworkData } from './types';
6
+ export declare class StakingClient {
7
+ signerOrProvider: Signer | Provider;
8
+ network: NetworkData;
9
+ tokenContract: HMToken;
10
+ stakingContract: Staking;
11
+ escrowFactoryContract: EscrowFactory;
12
+ /**
13
+ * **StakingClient constructor**
14
+ *
15
+ * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
16
+ * @param {NetworkData} network - The network information required to connect to the Staking contract
17
+ */
18
+ constructor(signerOrProvider: Signer | Provider, network: NetworkData);
19
+ /**
20
+ * Creates an instance of StakingClient from a Signer or Provider.
21
+ *
22
+ * @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
23
+ * @returns {Promise<StakingClient>} - An instance of StakingClient
24
+ * @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
25
+ * @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
26
+ */
27
+ static build(signerOrProvider: Signer | Provider): Promise<StakingClient>;
28
+ /**
29
+ * **Approves the staking contract to transfer a specified amount of tokens when the user stakes.
30
+ * **It increases the allowance for the staking contract.*
31
+ *
32
+ * @param {BigNumber} amount - Amount of tokens to approve for stake
33
+ * @returns {Promise<void>}
34
+ * @throws {Error} - An error object if an error occurred, void otherwise
35
+ */
36
+ approveStake(amount: BigNumber): Promise<void>;
37
+ /**
38
+ * **Stakes a specified amount of tokens on a specific network.*
39
+ *
40
+ * @param {BigNumber} amount - Amount of tokens to stake
41
+ * @returns {Promise<void>}
42
+ * @throws {Error} - An error object if an error occurred, void otherwise
43
+ */
44
+ stake(amount: BigNumber): Promise<void>;
45
+ /**
46
+ * **Unstakes tokens from staking contract.
47
+ * **The unstaked tokens stay locked for a period of time.*
48
+ *
49
+ * @param {BigNumber} amount - Amount of tokens to unstake
50
+ * @returns {Promise<void>}
51
+ * @throws {Error} - An error object if an error occurred, void otherwise
52
+ */
53
+ unstake(amount: BigNumber): Promise<void>;
54
+ /**
55
+ * **Withdraws unstaked and non locked tokens form staking contract to the user wallet.*
56
+ *
57
+ * @returns {Promise<void>}
58
+ * @throws {Error} - An error object if an error occurred, void otherwise
59
+ */
60
+ withdraw(): Promise<void>;
61
+ /**
62
+ * **Slash the allocated amount by an staker in an escrow and transfers those tokens to the reward pool.
63
+ * **This allows the slasher to claim them later.*
64
+ *
65
+ * @param {string} slasher - Wallet address from who requested the slash
66
+ * @param {string} staker - Wallet address from who is going to be slashed
67
+ * @param {string} escrowAddress - Address of the escrow which allocation will be slashed
68
+ * @param {BigNumber} amount - Amount of tokens to slash
69
+ * @returns {Promise<void>}
70
+ * @throws {Error} - An error object if an error occurred, void otherwise
71
+ */
72
+ slash(slasher: string, staker: string, escrowAddress: string, amount: BigNumber): Promise<void>;
73
+ /**
74
+ * **Allocates a portion of the staked tokens to a specific escrow.*
75
+ *
76
+ * @param {string} escrowAddress - Address of the escrow contract
77
+ * @param {BigNumber} amount - Amount of tokens to allocate
78
+ * @returns {Promise<void>}
79
+ * @throws {Error} - An error object if an error occurred, void otherwise
80
+ */
81
+ allocate(escrowAddress: string, amount: BigNumber): Promise<void>;
82
+ /**
83
+ * **Drops the allocation from a specific escrow.*
84
+ *
85
+ * @param {string} escrowAddress - Address of the escrow contract.
86
+ * @returns {Promise<void>}
87
+ * @throws {Error} - An error object if an error occurred, void otherwise
88
+ */
89
+ closeAllocation(escrowAddress: string): Promise<void>;
90
+ /**
91
+ * **Pays out rewards to the slashers for the specified escrow address.*
92
+ *
93
+ * @param {string} escrowAddress - Escrow address from which rewards are distributed.
94
+ * @returns {Promise<void>}
95
+ * @throws {Error} - An error object if an error occurred, void otherwise
96
+ */
97
+ distributeRewards(escrowAddress: string): Promise<void>;
98
+ /**
99
+ * **Returns the staking information about an staker address.*
100
+ *
101
+ * @param {string} staker - Address of the staker
102
+ * @returns {Promise<IStaker>} - Return staking information of the specified address
103
+ * @throws {Error} - An error object if an error occurred, result otherwise
104
+ */
105
+ getStaker(staker: string): Promise<IStaker>;
106
+ /**
107
+ * **Returns the staking information about all stakers of the protocol.*
108
+ *
109
+ * @returns {Promise<IStakerInfo>} - Return an array with all stakers information
110
+ * @throws {Error} - An error object if an error occurred, results otherwise
111
+ */
112
+ getAllStakers(): Promise<IStaker[]>;
113
+ /**
114
+ * **Returns information about the allocation of the specified escrow.*
115
+ *
116
+ * @param {string} escrowAddress - The escrow address for the received allocation data
117
+ * @returns {Promise<IAllocation>} - Returns allocation info if exists
118
+ * @throws {Error} - An error object if an error occurred, result otherwise
119
+ */
120
+ getAllocation(escrowAddress: string): Promise<IAllocation>;
121
+ /**
122
+ * **Returns information about the rewards for a given escrow address.*
123
+ *
124
+ * @param {string} slasherAddress - Address of the slasher
125
+ * @returns {Promise<IReward[]>} - Returns rewards info if exists
126
+ * @throws {Error} - An error object if an error occurred, results otherwise
127
+ */
128
+ getRewards(slasherAddress: string): Promise<IReward[]>;
129
+ }
130
+ //# sourceMappingURL=staking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,EACL,aAAa,EAEb,OAAO,EAIP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,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