@human-protocol/sdk 1.1.17 → 1.1.18
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 +29 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +37 -0
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +9 -1
- package/dist/escrow.d.ts +13 -6
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +84 -50
- package/dist/kvstore.d.ts +60 -4
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +124 -8
- package/dist/staking.d.ts +17 -8
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +61 -54
- package/dist/statistics.d.ts +3 -3
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +10 -10
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +22 -2
- package/package.json +2 -1
- package/src/base.ts +49 -0
- package/src/error.ts +9 -0
- package/src/escrow.ts +116 -115
- package/src/kvstore.ts +141 -9
- package/src/staking.ts +74 -64
- package/src/statistics.ts +11 -11
- package/src/storage.ts +1 -0
- package/src/utils.ts +29 -1
package/dist/kvstore.js
CHANGED
|
@@ -12,9 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.KVStoreClient = void 0;
|
|
13
13
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
14
14
|
const ethers_1 = require("ethers");
|
|
15
|
+
const base_1 = require("./base");
|
|
15
16
|
const constants_1 = require("./constants");
|
|
16
17
|
const decorators_1 = require("./decorators");
|
|
17
18
|
const error_1 = require("./error");
|
|
19
|
+
const utils_1 = require("./utils");
|
|
18
20
|
/**
|
|
19
21
|
* ## Introduction
|
|
20
22
|
*
|
|
@@ -84,26 +86,29 @@ const error_1 = require("./error");
|
|
|
84
86
|
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
85
87
|
* ```
|
|
86
88
|
*/
|
|
87
|
-
class KVStoreClient {
|
|
89
|
+
class KVStoreClient extends base_1.BaseEthersClient {
|
|
88
90
|
/**
|
|
89
91
|
* **KVStoreClient constructor**
|
|
90
92
|
*
|
|
91
93
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
92
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
|
|
93
96
|
*/
|
|
94
|
-
constructor(signerOrProvider,
|
|
95
|
-
|
|
96
|
-
this.
|
|
97
|
+
constructor(signerOrProvider, networkData, gasPriceMultiplier) {
|
|
98
|
+
super(signerOrProvider, networkData, gasPriceMultiplier);
|
|
99
|
+
this.contract = typechain_types_1.KVStore__factory.connect(networkData.kvstoreAddress, signerOrProvider);
|
|
97
100
|
}
|
|
98
101
|
/**
|
|
99
102
|
* Creates an instance of KVStoreClient from a Signer or Provider.
|
|
100
103
|
*
|
|
101
104
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
105
|
+
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
106
|
+
*
|
|
102
107
|
* @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
|
|
103
108
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
104
109
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
105
110
|
*/
|
|
106
|
-
static async build(signerOrProvider) {
|
|
111
|
+
static async build(signerOrProvider, gasPriceMultiplier) {
|
|
107
112
|
let network;
|
|
108
113
|
if (ethers_1.Signer.isSigner(signerOrProvider)) {
|
|
109
114
|
if (!signerOrProvider.provider) {
|
|
@@ -119,7 +124,7 @@ class KVStoreClient {
|
|
|
119
124
|
if (!networkData) {
|
|
120
125
|
throw error_1.ErrorUnsupportedChainID;
|
|
121
126
|
}
|
|
122
|
-
return new KVStoreClient(signerOrProvider, networkData);
|
|
127
|
+
return new KVStoreClient(signerOrProvider, networkData, gasPriceMultiplier);
|
|
123
128
|
}
|
|
124
129
|
/**
|
|
125
130
|
* This function sets a key-value pair associated with the address that submits the transaction.
|
|
@@ -153,7 +158,9 @@ class KVStoreClient {
|
|
|
153
158
|
if (key === '')
|
|
154
159
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
155
160
|
try {
|
|
156
|
-
await this.contract?.set(key, value
|
|
161
|
+
await this.contract?.set(key, value, {
|
|
162
|
+
...(await this.gasPriceOptions()),
|
|
163
|
+
});
|
|
157
164
|
}
|
|
158
165
|
catch (e) {
|
|
159
166
|
if (e instanceof Error)
|
|
@@ -196,13 +203,60 @@ class KVStoreClient {
|
|
|
196
203
|
if (keys.includes(''))
|
|
197
204
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
198
205
|
try {
|
|
199
|
-
await this.contract?.setBulk(keys, values
|
|
206
|
+
await this.contract?.setBulk(keys, values, {
|
|
207
|
+
...(await this.gasPriceOptions()),
|
|
208
|
+
});
|
|
200
209
|
}
|
|
201
210
|
catch (e) {
|
|
202
211
|
if (e instanceof Error)
|
|
203
212
|
throw Error(`Failed to set bulk values: ${e.message}`);
|
|
204
213
|
}
|
|
205
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* This function sets a URL value for the address that submits the transaction.
|
|
217
|
+
*
|
|
218
|
+
* @param {string} url URL to set
|
|
219
|
+
* @param {string | undefined} urlKey Configurable URL key. `url` by default.
|
|
220
|
+
* @returns Returns void if successful. Throws error if any.
|
|
221
|
+
*
|
|
222
|
+
*
|
|
223
|
+
* **Code example**
|
|
224
|
+
*
|
|
225
|
+
* ```ts
|
|
226
|
+
* import { Wallet, providers } from 'ethers';
|
|
227
|
+
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
228
|
+
*
|
|
229
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
230
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
231
|
+
*
|
|
232
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
233
|
+
* const signer = new Wallet(privateKey, provider);
|
|
234
|
+
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
235
|
+
*
|
|
236
|
+
* await kvstoreClient.setURL('example.com');
|
|
237
|
+
* await kvstoreClient.setURL('linkedin.com/example', 'linkedinUrl);
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
async setURL(url, urlKey = 'url') {
|
|
241
|
+
if (!ethers_1.Signer.isSigner(this.signerOrProvider)) {
|
|
242
|
+
throw error_1.ErrorSigner;
|
|
243
|
+
}
|
|
244
|
+
if (!(0, utils_1.isValidUrl)(url)) {
|
|
245
|
+
throw error_1.ErrorInvalidUrl;
|
|
246
|
+
}
|
|
247
|
+
const content = await fetch(url).then((res) => res.text());
|
|
248
|
+
const contentHash = ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.toUtf8Bytes(content));
|
|
249
|
+
const hashKey = urlKey + 'Hash';
|
|
250
|
+
try {
|
|
251
|
+
await this.contract.setBulk([urlKey, hashKey], [url, contentHash], {
|
|
252
|
+
...(await this.gasPriceOptions()),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
if (e instanceof Error)
|
|
257
|
+
throw Error(`Failed to set URL and hash: ${e.message}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
206
260
|
/**
|
|
207
261
|
* This function returns the value for a specified key and address.
|
|
208
262
|
*
|
|
@@ -242,6 +296,62 @@ class KVStoreClient {
|
|
|
242
296
|
return e;
|
|
243
297
|
}
|
|
244
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* This function returns the URL value for the given entity.
|
|
301
|
+
*
|
|
302
|
+
* @param {string} address Address from which to get the URL value.
|
|
303
|
+
* @param {string} urlKey Configurable URL key. `url` by default.
|
|
304
|
+
* @returns {string} URL value for the given address if exists, and the content is valid
|
|
305
|
+
*
|
|
306
|
+
*
|
|
307
|
+
* **Code example**
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* import { providers } from 'ethers';
|
|
311
|
+
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
312
|
+
*
|
|
313
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
314
|
+
*
|
|
315
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
316
|
+
* const kvstoreClient = await KVStoreClient.build(provider);
|
|
317
|
+
*
|
|
318
|
+
* const url = await kvstoreClient.getURL('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266');
|
|
319
|
+
* const linkedinUrl = await kvstoreClient.getURL(
|
|
320
|
+
* '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
321
|
+
* 'linkedinUrl'
|
|
322
|
+
* );
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
async getURL(address, urlKey = 'url') {
|
|
326
|
+
if (!ethers_1.ethers.utils.isAddress(address))
|
|
327
|
+
throw error_1.ErrorInvalidAddress;
|
|
328
|
+
const hashKey = urlKey + 'Hash';
|
|
329
|
+
let url = '', hash = '';
|
|
330
|
+
try {
|
|
331
|
+
url = await this.contract?.get(address, urlKey);
|
|
332
|
+
}
|
|
333
|
+
catch (e) {
|
|
334
|
+
if (e instanceof Error)
|
|
335
|
+
throw Error(`Failed to get URL: ${e.message}`);
|
|
336
|
+
}
|
|
337
|
+
// Return empty string
|
|
338
|
+
if (!url?.length) {
|
|
339
|
+
return '';
|
|
340
|
+
}
|
|
341
|
+
try {
|
|
342
|
+
hash = await this.contract?.get(address, hashKey);
|
|
343
|
+
}
|
|
344
|
+
catch (e) {
|
|
345
|
+
if (e instanceof Error)
|
|
346
|
+
throw Error(`Failed to get Hash: ${e.message}`);
|
|
347
|
+
}
|
|
348
|
+
const content = await fetch(url).then((res) => res.text());
|
|
349
|
+
const contentHash = ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.toUtf8Bytes(content));
|
|
350
|
+
if (hash !== contentHash) {
|
|
351
|
+
throw error_1.ErrorInvalidHash;
|
|
352
|
+
}
|
|
353
|
+
return url;
|
|
354
|
+
}
|
|
245
355
|
}
|
|
246
356
|
__decorate([
|
|
247
357
|
decorators_1.requiresSigner,
|
|
@@ -255,4 +365,10 @@ __decorate([
|
|
|
255
365
|
__metadata("design:paramtypes", [Array, Array]),
|
|
256
366
|
__metadata("design:returntype", Promise)
|
|
257
367
|
], KVStoreClient.prototype, "setBulk", null);
|
|
368
|
+
__decorate([
|
|
369
|
+
decorators_1.requiresSigner,
|
|
370
|
+
__metadata("design:type", Function),
|
|
371
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
372
|
+
__metadata("design:returntype", Promise)
|
|
373
|
+
], KVStoreClient.prototype, "setURL", null);
|
|
258
374
|
exports.KVStoreClient = KVStoreClient;
|
package/dist/staking.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
|
-
import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-types';
|
|
2
|
+
import { EscrowFactory, HMToken, RewardPool, Staking } from '@human-protocol/core/typechain-types';
|
|
3
3
|
import { BigNumber, Signer } from 'ethers';
|
|
4
|
+
import { BaseEthersClient } from './base';
|
|
4
5
|
import { IAllocation, ILeader, ILeadersFilter, IReward } from './interfaces';
|
|
5
6
|
import { NetworkData } from './types';
|
|
6
7
|
/**
|
|
@@ -72,28 +73,36 @@ import { NetworkData } from './types';
|
|
|
72
73
|
* const stakingClient = await StakingClient.build(provider);
|
|
73
74
|
* ```
|
|
74
75
|
*/
|
|
75
|
-
export declare class StakingClient {
|
|
76
|
-
signerOrProvider: Signer | Provider;
|
|
77
|
-
network: NetworkData;
|
|
76
|
+
export declare class StakingClient extends BaseEthersClient {
|
|
78
77
|
tokenContract: HMToken;
|
|
79
78
|
stakingContract: Staking;
|
|
80
79
|
escrowFactoryContract: EscrowFactory;
|
|
80
|
+
rewardPoolContract: RewardPool;
|
|
81
81
|
/**
|
|
82
82
|
* **StakingClient constructor**
|
|
83
83
|
*
|
|
84
84
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
85
85
|
* @param {NetworkData} network - The network information required to connect to the Staking contract
|
|
86
|
+
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
86
87
|
*/
|
|
87
|
-
constructor(signerOrProvider: Signer | Provider,
|
|
88
|
+
constructor(signerOrProvider: Signer | Provider, networkData: NetworkData, gasPriceMultiplier?: number);
|
|
88
89
|
/**
|
|
89
90
|
* Creates an instance of StakingClient from a Signer or Provider.
|
|
90
91
|
*
|
|
91
92
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
93
|
+
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
94
|
+
*
|
|
92
95
|
* @returns {Promise<StakingClient>} - An instance of StakingClient
|
|
93
96
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
94
97
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
95
98
|
*/
|
|
96
|
-
static build(signerOrProvider: Signer | Provider): Promise<StakingClient>;
|
|
99
|
+
static build(signerOrProvider: Signer | Provider, gasPriceMultiplier?: number): Promise<StakingClient>;
|
|
100
|
+
/**
|
|
101
|
+
* Check if escrow exists
|
|
102
|
+
*
|
|
103
|
+
* @param escrowAddress Escrow address to check against
|
|
104
|
+
*/
|
|
105
|
+
private checkValidEscrow;
|
|
97
106
|
/**
|
|
98
107
|
* This function approves the staking contract to transfer a specified amount of tokens when the user stakes. It increases the allowance for the staking contract.
|
|
99
108
|
*
|
|
@@ -304,10 +313,10 @@ export declare class StakingClient {
|
|
|
304
313
|
* const signer = new Wallet(privateKey, provider);
|
|
305
314
|
* const stakingClient = await StakingClient.build(signer);
|
|
306
315
|
*
|
|
307
|
-
* await stakingClient.
|
|
316
|
+
* await stakingClient.distributeReward('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
308
317
|
* ```
|
|
309
318
|
*/
|
|
310
|
-
|
|
319
|
+
distributeReward(escrowAddress: string): Promise<void>;
|
|
311
320
|
/**
|
|
312
321
|
* This function returns all the leader details of the protocol.
|
|
313
322
|
*
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,EAEP,UAAU,EAEV,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAc1C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC1C,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IACrC,kBAAkB,EAAE,UAAU,CAAC;IAEtC;;;;;;OAMG;gBAED,gBAAgB,EAAE,MAAM,GAAG,QAAQ,EACnC,WAAW,EAAE,WAAW,EACxB,kBAAkB,CAAC,EAAE,MAAM;IAyB7B;;;;;;;;;OASG;WACiB,KAAK,CACvB,gBAAgB,EAAE,MAAM,GAAG,QAAQ,EACnC,kBAAkB,CAAC,EAAE,MAAM;IAuB7B;;;;OAIG;YACW,gBAAgB;IAU9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB3D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBpD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBtD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAWtC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC;IA8BhB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,QAAQ,CACnB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC;IAqBhB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAalE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IAEU,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAanE;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBzD;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,UAAU,CAAC,MAAM,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAcxE;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAWvE;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAsBpE"}
|
package/dist/staking.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.StakingClient = void 0;
|
|
|
16
16
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
17
17
|
const ethers_1 = require("ethers");
|
|
18
18
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
19
|
+
const base_1 = require("./base");
|
|
19
20
|
const constants_1 = require("./constants");
|
|
20
21
|
const decorators_1 = require("./decorators");
|
|
21
22
|
const error_1 = require("./error");
|
|
@@ -91,29 +92,32 @@ const staking_1 = require("./graphql/queries/staking");
|
|
|
91
92
|
* const stakingClient = await StakingClient.build(provider);
|
|
92
93
|
* ```
|
|
93
94
|
*/
|
|
94
|
-
class StakingClient {
|
|
95
|
+
class StakingClient extends base_1.BaseEthersClient {
|
|
95
96
|
/**
|
|
96
97
|
* **StakingClient constructor**
|
|
97
98
|
*
|
|
98
99
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
99
100
|
* @param {NetworkData} network - The network information required to connect to the Staking contract
|
|
101
|
+
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
100
102
|
*/
|
|
101
|
-
constructor(signerOrProvider,
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
106
|
-
this.
|
|
103
|
+
constructor(signerOrProvider, networkData, gasPriceMultiplier) {
|
|
104
|
+
super(signerOrProvider, networkData, gasPriceMultiplier);
|
|
105
|
+
this.stakingContract = typechain_types_1.Staking__factory.connect(networkData.stakingAddress, signerOrProvider);
|
|
106
|
+
this.escrowFactoryContract = typechain_types_1.EscrowFactory__factory.connect(networkData.factoryAddress, signerOrProvider);
|
|
107
|
+
this.tokenContract = typechain_types_1.HMToken__factory.connect(networkData.hmtAddress, signerOrProvider);
|
|
108
|
+
this.rewardPoolContract = typechain_types_1.RewardPool__factory.connect(networkData.rewardPoolAddress, this.signerOrProvider);
|
|
107
109
|
}
|
|
108
110
|
/**
|
|
109
111
|
* Creates an instance of StakingClient from a Signer or Provider.
|
|
110
112
|
*
|
|
111
113
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
114
|
+
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
115
|
+
*
|
|
112
116
|
* @returns {Promise<StakingClient>} - An instance of StakingClient
|
|
113
117
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
114
118
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
115
119
|
*/
|
|
116
|
-
static async build(signerOrProvider) {
|
|
120
|
+
static async build(signerOrProvider, gasPriceMultiplier) {
|
|
117
121
|
let network;
|
|
118
122
|
if (ethers_1.Signer.isSigner(signerOrProvider)) {
|
|
119
123
|
if (!signerOrProvider.provider) {
|
|
@@ -129,7 +133,20 @@ class StakingClient {
|
|
|
129
133
|
if (!networkData) {
|
|
130
134
|
throw error_1.ErrorUnsupportedChainID;
|
|
131
135
|
}
|
|
132
|
-
return new StakingClient(signerOrProvider, networkData);
|
|
136
|
+
return new StakingClient(signerOrProvider, networkData, gasPriceMultiplier);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Check if escrow exists
|
|
140
|
+
*
|
|
141
|
+
* @param escrowAddress Escrow address to check against
|
|
142
|
+
*/
|
|
143
|
+
async checkValidEscrow(escrowAddress) {
|
|
144
|
+
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
145
|
+
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
146
|
+
}
|
|
147
|
+
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
148
|
+
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
149
|
+
}
|
|
133
150
|
}
|
|
134
151
|
/**
|
|
135
152
|
* This function approves the staking contract to transfer a specified amount of tokens when the user stakes. It increases the allowance for the staking contract.
|
|
@@ -163,7 +180,9 @@ class StakingClient {
|
|
|
163
180
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
164
181
|
}
|
|
165
182
|
try {
|
|
166
|
-
await this.tokenContract.approve(this.stakingContract.address, amount
|
|
183
|
+
await this.tokenContract.approve(this.stakingContract.address, amount, {
|
|
184
|
+
...(await this.gasPriceOptions()),
|
|
185
|
+
});
|
|
167
186
|
return;
|
|
168
187
|
}
|
|
169
188
|
catch (e) {
|
|
@@ -205,7 +224,9 @@ class StakingClient {
|
|
|
205
224
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
206
225
|
}
|
|
207
226
|
try {
|
|
208
|
-
await this.stakingContract.stake(amount
|
|
227
|
+
await this.stakingContract.stake(amount, {
|
|
228
|
+
...(await this.gasPriceOptions()),
|
|
229
|
+
});
|
|
209
230
|
return;
|
|
210
231
|
}
|
|
211
232
|
catch (e) {
|
|
@@ -246,7 +267,9 @@ class StakingClient {
|
|
|
246
267
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
247
268
|
}
|
|
248
269
|
try {
|
|
249
|
-
await this.stakingContract.unstake(amount
|
|
270
|
+
await this.stakingContract.unstake(amount, {
|
|
271
|
+
...(await this.gasPriceOptions()),
|
|
272
|
+
});
|
|
250
273
|
return;
|
|
251
274
|
}
|
|
252
275
|
catch (e) {
|
|
@@ -279,7 +302,9 @@ class StakingClient {
|
|
|
279
302
|
*/
|
|
280
303
|
async withdraw() {
|
|
281
304
|
try {
|
|
282
|
-
await this.stakingContract.withdraw(
|
|
305
|
+
await this.stakingContract.withdraw({
|
|
306
|
+
...(await this.gasPriceOptions()),
|
|
307
|
+
});
|
|
283
308
|
return;
|
|
284
309
|
}
|
|
285
310
|
catch (e) {
|
|
@@ -326,14 +351,11 @@ class StakingClient {
|
|
|
326
351
|
if (!ethers_1.ethers.utils.isAddress(staker)) {
|
|
327
352
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
328
353
|
}
|
|
329
|
-
|
|
330
|
-
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
331
|
-
}
|
|
332
|
-
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
333
|
-
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
334
|
-
}
|
|
354
|
+
await this.checkValidEscrow(escrowAddress);
|
|
335
355
|
try {
|
|
336
|
-
await this.stakingContract.slash(slasher, staker, escrowAddress, amount
|
|
356
|
+
await this.stakingContract.slash(slasher, staker, escrowAddress, amount, {
|
|
357
|
+
...(await this.gasPriceOptions()),
|
|
358
|
+
});
|
|
337
359
|
return;
|
|
338
360
|
}
|
|
339
361
|
catch (e) {
|
|
@@ -374,14 +396,11 @@ class StakingClient {
|
|
|
374
396
|
if (amount.isNegative()) {
|
|
375
397
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
376
398
|
}
|
|
377
|
-
|
|
378
|
-
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
379
|
-
}
|
|
380
|
-
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
381
|
-
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
382
|
-
}
|
|
399
|
+
await this.checkValidEscrow(escrowAddress);
|
|
383
400
|
try {
|
|
384
|
-
await this.stakingContract.allocate(escrowAddress, amount
|
|
401
|
+
await this.stakingContract.allocate(escrowAddress, amount, {
|
|
402
|
+
...(await this.gasPriceOptions()),
|
|
403
|
+
});
|
|
385
404
|
return;
|
|
386
405
|
}
|
|
387
406
|
catch (e) {
|
|
@@ -415,14 +434,11 @@ class StakingClient {
|
|
|
415
434
|
* ```
|
|
416
435
|
*/
|
|
417
436
|
async closeAllocation(escrowAddress) {
|
|
418
|
-
|
|
419
|
-
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
420
|
-
}
|
|
421
|
-
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
422
|
-
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
423
|
-
}
|
|
437
|
+
await this.checkValidEscrow(escrowAddress);
|
|
424
438
|
try {
|
|
425
|
-
await this.stakingContract.closeAllocation(escrowAddress
|
|
439
|
+
await this.stakingContract.closeAllocation(escrowAddress, {
|
|
440
|
+
...(await this.gasPriceOptions()),
|
|
441
|
+
});
|
|
426
442
|
return;
|
|
427
443
|
}
|
|
428
444
|
catch (e) {
|
|
@@ -451,19 +467,15 @@ class StakingClient {
|
|
|
451
467
|
* const signer = new Wallet(privateKey, provider);
|
|
452
468
|
* const stakingClient = await StakingClient.build(signer);
|
|
453
469
|
*
|
|
454
|
-
* await stakingClient.
|
|
470
|
+
* await stakingClient.distributeReward('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
455
471
|
* ```
|
|
456
472
|
*/
|
|
457
|
-
async
|
|
458
|
-
|
|
459
|
-
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
460
|
-
}
|
|
461
|
-
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
462
|
-
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
463
|
-
}
|
|
473
|
+
async distributeReward(escrowAddress) {
|
|
474
|
+
await this.checkValidEscrow(escrowAddress);
|
|
464
475
|
try {
|
|
465
|
-
|
|
466
|
-
|
|
476
|
+
this.rewardPoolContract.distributeReward(escrowAddress, {
|
|
477
|
+
...(await this.gasPriceOptions()),
|
|
478
|
+
});
|
|
467
479
|
return;
|
|
468
480
|
}
|
|
469
481
|
catch (e) {
|
|
@@ -496,7 +508,7 @@ class StakingClient {
|
|
|
496
508
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
497
509
|
}
|
|
498
510
|
try {
|
|
499
|
-
const { leader } = await (0, graphql_request_1.default)(this.
|
|
511
|
+
const { leader } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, staking_1.GET_LEADER_QUERY, {
|
|
500
512
|
address: address.toLowerCase(),
|
|
501
513
|
});
|
|
502
514
|
return leader;
|
|
@@ -528,7 +540,7 @@ class StakingClient {
|
|
|
528
540
|
*/
|
|
529
541
|
async getLeaders(filter = {}) {
|
|
530
542
|
try {
|
|
531
|
-
const { leaders } = await (0, graphql_request_1.default)(this.
|
|
543
|
+
const { leaders } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, staking_1.GET_LEADERS_QUERY)(filter), {
|
|
532
544
|
role: filter.role,
|
|
533
545
|
});
|
|
534
546
|
return leaders;
|
|
@@ -559,12 +571,7 @@ class StakingClient {
|
|
|
559
571
|
* ```
|
|
560
572
|
*/
|
|
561
573
|
async getAllocation(escrowAddress) {
|
|
562
|
-
|
|
563
|
-
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
564
|
-
}
|
|
565
|
-
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
566
|
-
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
567
|
-
}
|
|
574
|
+
await this.checkValidEscrow(escrowAddress);
|
|
568
575
|
try {
|
|
569
576
|
const result = await this.stakingContract.getAllocation(escrowAddress);
|
|
570
577
|
return result;
|
|
@@ -599,7 +606,7 @@ class StakingClient {
|
|
|
599
606
|
throw error_1.ErrorInvalidSlasherAddressProvided;
|
|
600
607
|
}
|
|
601
608
|
try {
|
|
602
|
-
const { rewardAddedEvents } = await (0, graphql_request_1.default)(this.
|
|
609
|
+
const { rewardAddedEvents } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, reward_1.GET_REWARD_ADDED_EVENTS_QUERY, {
|
|
603
610
|
slasherAddress: slasherAddress.toLowerCase(),
|
|
604
611
|
});
|
|
605
612
|
return rewardAddedEvents.map((reward) => {
|
|
@@ -661,5 +668,5 @@ __decorate([
|
|
|
661
668
|
__metadata("design:type", Function),
|
|
662
669
|
__metadata("design:paramtypes", [String]),
|
|
663
670
|
__metadata("design:returntype", Promise)
|
|
664
|
-
], StakingClient.prototype, "
|
|
671
|
+
], StakingClient.prototype, "distributeReward", null);
|
|
665
672
|
exports.StakingClient = StakingClient;
|
package/dist/statistics.d.ts
CHANGED
|
@@ -39,13 +39,13 @@ import { NetworkData } from './types';
|
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
41
|
export declare class StatisticsClient {
|
|
42
|
-
|
|
42
|
+
networkData: NetworkData;
|
|
43
43
|
/**
|
|
44
44
|
* **StatisticsClient constructor**
|
|
45
45
|
*
|
|
46
|
-
* @param {NetworkData}
|
|
46
|
+
* @param {NetworkData} networkData - The network information required to connect to the Statistics contract
|
|
47
47
|
*/
|
|
48
|
-
constructor(
|
|
48
|
+
constructor(networkData: NetworkData);
|
|
49
49
|
/**
|
|
50
50
|
* This function returns the statistical data of escrows.
|
|
51
51
|
*
|
package/dist/statistics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gBAAgB;IACpB,
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gBAAgB;IACpB,WAAW,EAAE,WAAW,CAAC;IAEhC;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAIpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA6B5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAoB5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkEG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IA2B7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgFG;IACG,gBAAgB,CACpB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,aAAa,CAAC;CAuC1B"}
|
package/dist/statistics.js
CHANGED
|
@@ -50,10 +50,10 @@ class StatisticsClient {
|
|
|
50
50
|
/**
|
|
51
51
|
* **StatisticsClient constructor**
|
|
52
52
|
*
|
|
53
|
-
* @param {NetworkData}
|
|
53
|
+
* @param {NetworkData} networkData - The network information required to connect to the Statistics contract
|
|
54
54
|
*/
|
|
55
|
-
constructor(
|
|
56
|
-
this.
|
|
55
|
+
constructor(networkData) {
|
|
56
|
+
this.networkData = networkData;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* This function returns the statistical data of escrows.
|
|
@@ -106,8 +106,8 @@ class StatisticsClient {
|
|
|
106
106
|
*/
|
|
107
107
|
async getEscrowStatistics(params = {}) {
|
|
108
108
|
try {
|
|
109
|
-
const { escrowStatistics } = await (0, graphql_request_1.default)(this.
|
|
110
|
-
const { eventDayDatas } = await (0, graphql_request_1.default)(this.
|
|
109
|
+
const { escrowStatistics } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, graphql_1.GET_ESCROW_STATISTICS_QUERY);
|
|
110
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
|
|
111
111
|
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
112
112
|
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
113
113
|
});
|
|
@@ -173,7 +173,7 @@ class StatisticsClient {
|
|
|
173
173
|
*/
|
|
174
174
|
async getWorkerStatistics(params = {}) {
|
|
175
175
|
try {
|
|
176
|
-
const { eventDayDatas } = await (0, graphql_request_1.default)(this.
|
|
176
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
|
|
177
177
|
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
178
178
|
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
179
179
|
});
|
|
@@ -257,7 +257,7 @@ class StatisticsClient {
|
|
|
257
257
|
*/
|
|
258
258
|
async getPaymentStatistics(params = {}) {
|
|
259
259
|
try {
|
|
260
|
-
const { eventDayDatas } = await (0, graphql_request_1.default)(this.
|
|
260
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
|
|
261
261
|
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
262
262
|
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
263
263
|
});
|
|
@@ -359,9 +359,9 @@ class StatisticsClient {
|
|
|
359
359
|
*/
|
|
360
360
|
async getHMTStatistics(params = {}) {
|
|
361
361
|
try {
|
|
362
|
-
const { hmtokenStatistics } = await (0, graphql_request_1.default)(this.
|
|
363
|
-
const { holders } = await (0, graphql_request_1.default)(this.
|
|
364
|
-
const { eventDayDatas } = await (0, graphql_request_1.default)(this.
|
|
362
|
+
const { hmtokenStatistics } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY);
|
|
363
|
+
const { holders } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, graphql_1.GET_HOLDERS_QUERY);
|
|
364
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.networkData.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
|
|
365
365
|
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
366
366
|
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
367
367
|
});
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAgB;IAEpC;;;;;OAKG;gBACS,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,kBAAkB;IAcnE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB1E;;;;;;;;;;;;;;OAcG;WACiB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,WAAW,CACtB,KAAK,EAAE,GAAG,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAgB;IAEpC;;;;;OAKG;gBACS,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,kBAAkB;IAcnE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB1E;;;;;;;;;;;;;;OAcG;WACiB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACU,WAAW,CACtB,KAAK,EAAE,GAAG,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,EAAE,CAAC;IAmCxB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqB5D"}
|
package/dist/storage.js
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
|
+
import { BigNumber, Signer } from 'ethers';
|
|
1
3
|
/**
|
|
2
4
|
* **Get specific error text.*
|
|
3
5
|
*
|
|
@@ -19,4 +21,10 @@ export declare const throwError: (e: any) => never;
|
|
|
19
21
|
* @returns
|
|
20
22
|
*/
|
|
21
23
|
export declare const isValidUrl: (url: string) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Increase/Decrease gas price
|
|
26
|
+
*
|
|
27
|
+
* @returns {Promise<BigNumber>} Returns the adjusted gas price
|
|
28
|
+
*/
|
|
29
|
+
export declare const gasPriceAdjusted: (signerOrProvider: Signer | Provider, gasPriceMultiplier: number) => Promise<BigNumber>;
|
|
22
30
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAenD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,GAAG,KAAG,MAO5C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,MAAO,GAAG,UAqBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,YAOrC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,qBACT,MAAM,GAAG,QAAQ,sBACf,MAAM,KACzB,QAAQ,SAAS,CAgBnB,CAAC"}
|