@human-protocol/sdk 1.0.2 → 1.0.4
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 +1 -1
- package/dist/constants.d.ts +46 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +203 -0
- package/dist/decorators.d.ts +2 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +17 -0
- package/dist/enums.d.ts +17 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +20 -0
- package/dist/error.d.ts +196 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +229 -0
- package/dist/escrow.d.ts +176 -0
- package/dist/escrow.d.ts.map +1 -0
- package/dist/escrow.js +590 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/init.d.ts +13 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +35 -0
- package/dist/interfaces.d.ts +44 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +2 -0
- package/dist/kvstore.d.ts +40 -0
- package/dist/kvstore.d.ts.map +1 -0
- package/dist/kvstore.js +106 -0
- package/dist/queries.d.ts +4 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +22 -0
- package/dist/staking.d.ts +121 -0
- package/dist/staking.d.ts.map +1 -0
- package/dist/staking.js +381 -0
- package/dist/storage.d.ts +48 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +164 -0
- package/dist/types.d.ts +123 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +35 -0
- package/dist/utils.d.ts +32 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +99 -0
- package/package.json +4 -7
- package/src/constants.ts +221 -4
- package/src/decorators.ts +21 -0
- package/src/enums.ts +16 -0
- package/src/error.ts +295 -18
- package/src/escrow.ts +754 -0
- package/src/index.ts +14 -1
- package/src/init.ts +45 -0
- package/src/interfaces.ts +50 -0
- package/src/kvstore.ts +93 -0
- package/src/queries.ts +18 -0
- package/src/staking.ts +421 -0
- package/src/storage.ts +159 -131
- package/src/types.ts +36 -586
- package/src/utils.ts +80 -142
- package/test/escrow.test.ts +1339 -0
- package/test/init.test.ts +88 -0
- package/test/kvstore.test.ts +208 -0
- package/test/staking.test.ts +640 -0
- package/test/storage.test.ts +422 -0
- package/test/utils/constants.ts +38 -1
- package/example/simple-existing-job.ts +0 -86
- package/example/simple-new-job-public.ts +0 -74
- package/example/simple-new-job.ts +0 -72
- package/src/job.ts +0 -977
- package/src/logger.ts +0 -29
- package/test/job.test.ts +0 -716
- package/test/utils/manifest.ts +0 -33
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BigNumber, Signer } from 'ethers';
|
|
2
|
+
import { Provider } from '@ethersproject/abstract-provider';
|
|
3
|
+
import { NetworkData } from './types';
|
|
4
|
+
export interface IClientParams {
|
|
5
|
+
signerOrProvider: Signer | Provider;
|
|
6
|
+
network: NetworkData;
|
|
7
|
+
}
|
|
8
|
+
export interface IAllocation {
|
|
9
|
+
escrowAddress: string;
|
|
10
|
+
staker: string;
|
|
11
|
+
tokens: BigNumber;
|
|
12
|
+
createdAt: BigNumber;
|
|
13
|
+
closedAt: BigNumber;
|
|
14
|
+
}
|
|
15
|
+
export interface IReward {
|
|
16
|
+
escrowAddress: string;
|
|
17
|
+
amount: BigNumber;
|
|
18
|
+
}
|
|
19
|
+
export interface IStaker {
|
|
20
|
+
tokensStaked: BigNumber;
|
|
21
|
+
tokensAllocated: BigNumber;
|
|
22
|
+
tokensLocked: BigNumber;
|
|
23
|
+
tokensLockedUntil: BigNumber;
|
|
24
|
+
tokensAvailable: BigNumber;
|
|
25
|
+
}
|
|
26
|
+
export interface IEscrowsFilter {
|
|
27
|
+
address: string;
|
|
28
|
+
role?: number;
|
|
29
|
+
status?: number;
|
|
30
|
+
from?: Date;
|
|
31
|
+
to?: Date;
|
|
32
|
+
}
|
|
33
|
+
export interface IEscrowConfig {
|
|
34
|
+
recordingOracle: string;
|
|
35
|
+
reputationOracle: string;
|
|
36
|
+
recordingOracleFee: BigNumber;
|
|
37
|
+
reputationOracleFee: BigNumber;
|
|
38
|
+
manifestUrl: string;
|
|
39
|
+
hash: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ILauncherEscrowsResult {
|
|
42
|
+
id: string;
|
|
43
|
+
}
|
|
44
|
+
//# 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,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,GAAG,QAAQ,CAAC;IACpC,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,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,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;CACZ"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IClientParams } from './interfaces';
|
|
2
|
+
export default class KVStoreClient {
|
|
3
|
+
readonly clientParams: IClientParams;
|
|
4
|
+
private contract;
|
|
5
|
+
private signerOrProvider;
|
|
6
|
+
/**
|
|
7
|
+
* **KVStore constructor**
|
|
8
|
+
*
|
|
9
|
+
* * @param {IClientParams} clientParams - Init client parameters
|
|
10
|
+
*/
|
|
11
|
+
constructor(clientParams: IClientParams);
|
|
12
|
+
/**
|
|
13
|
+
* Sets a key-value pair in the contract
|
|
14
|
+
*
|
|
15
|
+
* @param {string} key - The key of the key-value pair to set
|
|
16
|
+
* @param {string} value - The value of the key-value pair to set
|
|
17
|
+
* @returns {Promise<void>}
|
|
18
|
+
* @throws {Error} - An error object if an error occurred
|
|
19
|
+
*/
|
|
20
|
+
set(key: string, value: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Sets multiple key-value pairs in the contract
|
|
23
|
+
*
|
|
24
|
+
* @param {string[]} keys - An array of keys to set
|
|
25
|
+
* @param {string[]} values - An array of values to set
|
|
26
|
+
* @returns {Promise<void>}
|
|
27
|
+
* @throws {Error} - An error object if an error occurred
|
|
28
|
+
*/
|
|
29
|
+
setBulk(keys: string[], values: string[]): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the value of a key-value pair in the contract
|
|
32
|
+
*
|
|
33
|
+
* @param {string} address - The Ethereum address associated with the key-value pair
|
|
34
|
+
* @param {string} key - The key of the key-value pair to get
|
|
35
|
+
* @returns {string} - The value of the key-value pair if it exists
|
|
36
|
+
* @throws {Error} - An error object if an error occurred
|
|
37
|
+
*/
|
|
38
|
+
get(address: string, key: string): Promise<string | undefined>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=kvstore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,CAAC,OAAO,OAAO,aAAa;IASpB,QAAQ,CAAC,YAAY,EAAE,aAAa;IARhD,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,gBAAgB,CAAoB;IAE5C;;;;OAIG;gBACkB,YAAY,EAAE,aAAa;IAQhD;;;;;;;OAOG;IAEU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAU3C;;;;;;;OAOG;IAEU,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IAarD;;;;;;;OAOG;IACU,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAW9C"}
|
package/dist/kvstore.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
13
|
+
const ethers_1 = require("ethers");
|
|
14
|
+
const error_1 = require("./error");
|
|
15
|
+
const decorators_1 = require("./decorators");
|
|
16
|
+
class KVStoreClient {
|
|
17
|
+
/**
|
|
18
|
+
* **KVStore constructor**
|
|
19
|
+
*
|
|
20
|
+
* * @param {IClientParams} clientParams - Init client parameters
|
|
21
|
+
*/
|
|
22
|
+
constructor(clientParams) {
|
|
23
|
+
this.clientParams = clientParams;
|
|
24
|
+
this.contract = typechain_types_1.KVStore__factory.connect(clientParams.network.kvstoreAddress, clientParams.signerOrProvider);
|
|
25
|
+
this.signerOrProvider = clientParams.signerOrProvider;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sets a key-value pair in the contract
|
|
29
|
+
*
|
|
30
|
+
* @param {string} key - The key of the key-value pair to set
|
|
31
|
+
* @param {string} value - The value of the key-value pair to set
|
|
32
|
+
* @returns {Promise<void>}
|
|
33
|
+
* @throws {Error} - An error object if an error occurred
|
|
34
|
+
*/
|
|
35
|
+
async set(key, value) {
|
|
36
|
+
if (!ethers_1.Signer.isSigner(this.signerOrProvider))
|
|
37
|
+
throw error_1.ErrorSigner;
|
|
38
|
+
if (key === '')
|
|
39
|
+
throw error_1.ErrorKVStoreEmptyKey;
|
|
40
|
+
try {
|
|
41
|
+
await this.contract?.set(key, value);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (e instanceof Error)
|
|
45
|
+
throw Error(`Failed to set value: ${e.message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets multiple key-value pairs in the contract
|
|
50
|
+
*
|
|
51
|
+
* @param {string[]} keys - An array of keys to set
|
|
52
|
+
* @param {string[]} values - An array of values to set
|
|
53
|
+
* @returns {Promise<void>}
|
|
54
|
+
* @throws {Error} - An error object if an error occurred
|
|
55
|
+
*/
|
|
56
|
+
async setBulk(keys, values) {
|
|
57
|
+
if (!ethers_1.Signer.isSigner(this.signerOrProvider))
|
|
58
|
+
throw error_1.ErrorSigner;
|
|
59
|
+
if (keys.length !== values.length)
|
|
60
|
+
throw error_1.ErrorKVStoreArrayLength;
|
|
61
|
+
if (keys.includes(''))
|
|
62
|
+
throw error_1.ErrorKVStoreEmptyKey;
|
|
63
|
+
try {
|
|
64
|
+
await this.contract?.setBulk(keys, values);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
if (e instanceof Error)
|
|
68
|
+
throw Error(`Failed to set bulk values: ${e.message}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Gets the value of a key-value pair in the contract
|
|
73
|
+
*
|
|
74
|
+
* @param {string} address - The Ethereum address associated with the key-value pair
|
|
75
|
+
* @param {string} key - The key of the key-value pair to get
|
|
76
|
+
* @returns {string} - The value of the key-value pair if it exists
|
|
77
|
+
* @throws {Error} - An error object if an error occurred
|
|
78
|
+
*/
|
|
79
|
+
async get(address, key) {
|
|
80
|
+
if (key === '')
|
|
81
|
+
throw error_1.ErrorKVStoreEmptyKey;
|
|
82
|
+
if (!ethers_1.ethers.utils.isAddress(address))
|
|
83
|
+
throw error_1.ErrorInvalidAddress;
|
|
84
|
+
try {
|
|
85
|
+
const result = await this.contract?.get(address, key);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
if (e instanceof Error)
|
|
90
|
+
throw Error(`Failed to get value: ${e.message}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
__decorate([
|
|
95
|
+
decorators_1.requiresSigner,
|
|
96
|
+
__metadata("design:type", Function),
|
|
97
|
+
__metadata("design:paramtypes", [String, String]),
|
|
98
|
+
__metadata("design:returntype", Promise)
|
|
99
|
+
], KVStoreClient.prototype, "set", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
decorators_1.requiresSigner,
|
|
102
|
+
__metadata("design:type", Function),
|
|
103
|
+
__metadata("design:paramtypes", [Array, Array]),
|
|
104
|
+
__metadata("design:returntype", Promise)
|
|
105
|
+
], KVStoreClient.prototype, "setBulk", null);
|
|
106
|
+
exports.default = KVStoreClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,mBAAoB,MAAM,WAKpD,CAAC;AAEL,eAAO,MAAM,0BAA0B,cAInC,CAAC;AAEL,eAAO,MAAM,mCAAmC,cAI5C,CAAC"}
|
package/dist/queries.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 RAW_REWARDS_QUERY = (slasherAddress) => `{
|
|
5
|
+
rewardAddedEvents(id: "${slasherAddress}") {
|
|
6
|
+
escrow,
|
|
7
|
+
amount
|
|
8
|
+
}
|
|
9
|
+
}`;
|
|
10
|
+
exports.RAW_REWARDS_QUERY = RAW_REWARDS_QUERY;
|
|
11
|
+
const RAW_LAUNCHED_ESCROWS_QUERY = () => `{
|
|
12
|
+
launchedEscrows(where: { from: $address }) {
|
|
13
|
+
id
|
|
14
|
+
}
|
|
15
|
+
}`;
|
|
16
|
+
exports.RAW_LAUNCHED_ESCROWS_QUERY = RAW_LAUNCHED_ESCROWS_QUERY;
|
|
17
|
+
const RAW_LAUNCHED_ESCROWS_FILTERED_QUERY = () => `{
|
|
18
|
+
launchedEscrows(where: { from: $address, status: $status, timestamp_gte: $from, timestamp_lte: $to }) {
|
|
19
|
+
id
|
|
20
|
+
}
|
|
21
|
+
}`;
|
|
22
|
+
exports.RAW_LAUNCHED_ESCROWS_FILTERED_QUERY = RAW_LAUNCHED_ESCROWS_FILTERED_QUERY;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
|
+
import { HMToken, Staking, EscrowFactory } from '@human-protocol/core/typechain-types';
|
|
3
|
+
import { BigNumber, Signer } from 'ethers';
|
|
4
|
+
import { NetworkData } from './types';
|
|
5
|
+
import { IAllocation, IClientParams, IReward, IStaker } from './interfaces';
|
|
6
|
+
export default class StakingClient {
|
|
7
|
+
readonly clientParams: IClientParams;
|
|
8
|
+
signerOrProvider: Signer | Provider;
|
|
9
|
+
network: NetworkData;
|
|
10
|
+
tokenContract: HMToken;
|
|
11
|
+
stakingContract: Staking;
|
|
12
|
+
escrowFactoryContract: EscrowFactory;
|
|
13
|
+
/**
|
|
14
|
+
* **Staking constructor**
|
|
15
|
+
*
|
|
16
|
+
* @param {IClientParams} clientParams - Init client parameters
|
|
17
|
+
*/
|
|
18
|
+
constructor(clientParams: IClientParams);
|
|
19
|
+
/**
|
|
20
|
+
* **Approves the staking contract to transfer a specified amount of tokens when the user stakes.
|
|
21
|
+
* **It increases the allowance for the staking contract.*
|
|
22
|
+
*
|
|
23
|
+
* @param {BigNumber} amount - Amount of tokens to approve for stake
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
26
|
+
*/
|
|
27
|
+
approveStake(amount: BigNumber): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* **Stakes a specified amount of tokens on a specific network.*
|
|
30
|
+
*
|
|
31
|
+
* @param {BigNumber} amount - Amount of tokens to stake
|
|
32
|
+
* @returns {Promise<void>}
|
|
33
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
34
|
+
*/
|
|
35
|
+
stake(amount: BigNumber): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* **Unstakes tokens from staking contract.
|
|
38
|
+
* **The unstaked tokens stay locked for a period of time.*
|
|
39
|
+
*
|
|
40
|
+
* @param {BigNumber} amount - Amount of tokens to unstake
|
|
41
|
+
* @returns {Promise<void>}
|
|
42
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
43
|
+
*/
|
|
44
|
+
unstake(amount: BigNumber): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* **Withdraws unstaked and non locked tokens form staking contract to the user wallet.*
|
|
47
|
+
*
|
|
48
|
+
* @returns {Promise<void>}
|
|
49
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
50
|
+
*/
|
|
51
|
+
withdraw(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* **Slash the allocated amount by an staker in an escrow and transfers those tokens to the reward pool.
|
|
54
|
+
* **This allows the slasher to claim them later.*
|
|
55
|
+
*
|
|
56
|
+
* @param {string} slasher - Wallet address from who requested the slash
|
|
57
|
+
* @param {string} staker - Wallet address from who is going to be slashed
|
|
58
|
+
* @param {string} escrowAddress - Address of the escrow which allocation will be slashed
|
|
59
|
+
* @param {BigNumber} amount - Amount of tokens to slash
|
|
60
|
+
* @returns {Promise<void>}
|
|
61
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
62
|
+
*/
|
|
63
|
+
slash(slasher: string, staker: string, escrowAddress: string, amount: BigNumber): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* **Allocates a portion of the staked tokens to a specific escrow.*
|
|
66
|
+
*
|
|
67
|
+
* @param {string} escrowAddress - Address of the escrow contract
|
|
68
|
+
* @param {BigNumber} amount - Amount of tokens to allocate
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
71
|
+
*/
|
|
72
|
+
allocate(escrowAddress: string, amount: BigNumber): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* **Drops the allocation from a specific escrow.*
|
|
75
|
+
*
|
|
76
|
+
* @param {string} escrowAddress - Address of the escrow contract.
|
|
77
|
+
* @returns {Promise<void>}
|
|
78
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
79
|
+
*/
|
|
80
|
+
closeAllocation(escrowAddress: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* **Pays out rewards to the slashers for the specified escrow address.*
|
|
83
|
+
*
|
|
84
|
+
* @param {string} escrowAddress - Escrow address from which rewards are distributed.
|
|
85
|
+
* @returns {Promise<void>}
|
|
86
|
+
* @throws {Error} - An error object if an error occurred, void otherwise
|
|
87
|
+
*/
|
|
88
|
+
distributeRewards(escrowAddress: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* **Returns the staking information about an staker address.*
|
|
91
|
+
*
|
|
92
|
+
* @param {string} staker - Address of the staker
|
|
93
|
+
* @returns {Promise<IStaker>} - Return staking information of the specified address
|
|
94
|
+
* @throws {Error} - An error object if an error occurred, result otherwise
|
|
95
|
+
*/
|
|
96
|
+
getStaker(staker: string): Promise<IStaker>;
|
|
97
|
+
/**
|
|
98
|
+
* **Returns the staking information about all stakers of the protocol.*
|
|
99
|
+
*
|
|
100
|
+
* @returns {Promise<IStakerInfo>} - Return an array with all stakers information
|
|
101
|
+
* @throws {Error} - An error object if an error occurred, results otherwise
|
|
102
|
+
*/
|
|
103
|
+
getAllStakers(): Promise<IStaker[]>;
|
|
104
|
+
/**
|
|
105
|
+
* **Returns information about the allocation of the specified escrow.*
|
|
106
|
+
*
|
|
107
|
+
* @param {string} escrowAddress - The escrow address for the received allocation data
|
|
108
|
+
* @returns {Promise<IAllocation>} - Returns allocation info if exists
|
|
109
|
+
* @throws {Error} - An error object if an error occurred, result otherwise
|
|
110
|
+
*/
|
|
111
|
+
getAllocation(escrowAddress: string): Promise<IAllocation>;
|
|
112
|
+
/**
|
|
113
|
+
* **Returns information about the rewards for a given escrow address.*
|
|
114
|
+
*
|
|
115
|
+
* @param {string} slasherAddress - Address of the slasher
|
|
116
|
+
* @returns {Promise<IReward[]>} - Returns rewards info if exists
|
|
117
|
+
* @throws {Error} - An error object if an error occurred, results otherwise
|
|
118
|
+
*/
|
|
119
|
+
getRewards(slasherAddress: string): Promise<IReward[]>;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=staking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAGL,OAAO,EACP,OAAO,EAGP,aAAa,EAEd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAc5E,MAAM,CAAC,OAAO,OAAO,aAAa;IAYpB,QAAQ,CAAC,YAAY,EAAE,aAAa;IAXzC,gBAAgB,EAAE,MAAM,GAAG,QAAQ,CAAC;IACpC,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IAE5C;;;;OAIG;gBACkB,YAAY,EAAE,aAAa;IAoBhD;;;;;;;OAOG;IAEU,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB3D;;;;;;OAMG;IAEU,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpD;;;;;;;OAOG;IAEU,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBtD;;;;;OAKG;IAEU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAStC;;;;;;;;;;OAUG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC;IAkChB;;;;;;;OAOG;IAEU,QAAQ,CACnB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC;IAyBhB;;;;;;OAMG;IAEU,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlE;;;;;;OAMG;IAEU,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBpE;;;;;;OAMG;IACU,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA6BxD;;;;;OAKG;IACU,aAAa,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IA+BhD;;;;;;OAMG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAiBvE;;;;;;OAMG;IACU,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAqBpE"}
|