@human-protocol/sdk 1.1.1 → 1.1.3
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/package.json +5 -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 +781 -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 -143
- 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 -1067
- package/src/logger.ts +0 -29
- package/test/job.test.ts +0 -817
- package/test/utils/constants.ts +0 -30
- package/test/utils/manifest.ts +0 -33
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
|
-
"dist"
|
|
8
|
-
"example",
|
|
9
|
-
"test"
|
|
7
|
+
"dist"
|
|
10
8
|
],
|
|
11
9
|
"main": "dist/index.js",
|
|
12
10
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +12,7 @@
|
|
|
14
12
|
"clean": "rm -rf ./dist",
|
|
15
13
|
"build": "npm run clean && tsc",
|
|
16
14
|
"prepublish": "npm run build",
|
|
17
|
-
"test": "
|
|
15
|
+
"test": "vitest -u",
|
|
18
16
|
"lint": "eslint .",
|
|
19
17
|
"lint:fix": "eslint . --fix",
|
|
20
18
|
"format": "prettier --write '**/*.{ts,json}'"
|
|
@@ -38,12 +36,12 @@
|
|
|
38
36
|
]
|
|
39
37
|
},
|
|
40
38
|
"dependencies": {
|
|
41
|
-
"@human-protocol/core": "
|
|
39
|
+
"@human-protocol/core": "*",
|
|
42
40
|
"aws-sdk": "^2.1255.0",
|
|
43
41
|
"crypto": "^1.0.1",
|
|
44
|
-
"dotenv": "^16.0.3",
|
|
45
42
|
"ethers": "^5.7.2",
|
|
46
43
|
"secp256k1": "^4.0.3",
|
|
44
|
+
"vitest": "^0.30.1",
|
|
47
45
|
"winston": "^3.8.2"
|
|
48
46
|
}
|
|
49
47
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,9 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export const DEFAULT_BUCKET = 'escrow-results';
|
|
1
|
+
import { ChainId } from './enums';
|
|
2
|
+
import { NetworkData } from './types';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* @constant Default public bucket name
|
|
8
6
|
*/
|
|
9
7
|
export const DEFAULT_PUBLIC_BUCKET = 'escrow-public-results';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @constant Default storage endpoint
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_ENDPOINT = 'localhost';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @constant Default storage region
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_REGION = 'eu';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @constant Default storage port
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_PORT = 9000;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @constant Default storage port
|
|
26
|
+
*/
|
|
27
|
+
export const DEFAULT_USE_SSL = false;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @constant Default tx Id
|
|
31
|
+
*/
|
|
32
|
+
export const DEFAULT_TX_ID = 1;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @constant Default Enum for escrow statuses.
|
|
36
|
+
*/
|
|
37
|
+
export enum HttpStatus {
|
|
38
|
+
OK = 200,
|
|
39
|
+
CREATED = 201,
|
|
40
|
+
BAD_REQUEST = 400,
|
|
41
|
+
UNAUTHORIZED = 401,
|
|
42
|
+
PAYMENT_REQUIRED = 402,
|
|
43
|
+
FORBIDDEN = 403,
|
|
44
|
+
NOT_FOUND = 404,
|
|
45
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @constant Default network parameters
|
|
50
|
+
*/
|
|
51
|
+
export const NETWORKS: {
|
|
52
|
+
[chainId in ChainId]?: NetworkData;
|
|
53
|
+
} = {
|
|
54
|
+
[ChainId.MAINNET]: {
|
|
55
|
+
chainId: ChainId.MAINNET,
|
|
56
|
+
title: 'Ethereum',
|
|
57
|
+
scanUrl: 'https://etherscan.io',
|
|
58
|
+
factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
|
|
59
|
+
hmtAddress: '0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867',
|
|
60
|
+
stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
|
|
61
|
+
kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
|
|
62
|
+
subgraphUrl:
|
|
63
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/mainnet-v1',
|
|
64
|
+
oldSubgraphUrl: '',
|
|
65
|
+
oldFactoryAddress: '',
|
|
66
|
+
},
|
|
67
|
+
[ChainId.RINKEBY]: {
|
|
68
|
+
chainId: ChainId.RINKEBY,
|
|
69
|
+
title: 'Ethereum Rinkeby',
|
|
70
|
+
scanUrl: 'https://rinkeby.etherscan.io',
|
|
71
|
+
factoryAddress: '0x925B24444511c86F4d4E63141D8Be0A025E2dca4',
|
|
72
|
+
hmtAddress: '0x4dCf5ac4509888714dd43A5cCc46d7ab389D9c23',
|
|
73
|
+
stakingAddress: '',
|
|
74
|
+
kvstoreAddress: '',
|
|
75
|
+
subgraphUrl: '',
|
|
76
|
+
oldSubgraphUrl: '',
|
|
77
|
+
oldFactoryAddress: '',
|
|
78
|
+
},
|
|
79
|
+
[ChainId.GOERLI]: {
|
|
80
|
+
chainId: ChainId.GOERLI,
|
|
81
|
+
title: 'Ethereum Goerli',
|
|
82
|
+
scanUrl: 'https://goerli.etherscan.io',
|
|
83
|
+
factoryAddress: '0x87469B4f2Fcf37cBd34E54244c0BD4Fa0603664c',
|
|
84
|
+
hmtAddress: '0xd3A31D57FDD790725d0F6B78095F62E8CD4ab317',
|
|
85
|
+
stakingAddress: '0xf46B45Df3d956369726d8Bd93Ba33963Ab692920',
|
|
86
|
+
kvstoreAddress: '0xc9Fe39c4b6e1d7A2991355Af159956982DADf842',
|
|
87
|
+
subgraphUrl:
|
|
88
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli-v1',
|
|
89
|
+
oldSubgraphUrl:
|
|
90
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/goerli',
|
|
91
|
+
oldFactoryAddress: '0xaAe6a2646C1F88763E62e0cD08aD050Ea66AC46F',
|
|
92
|
+
},
|
|
93
|
+
[ChainId.BSC_MAINNET]: {
|
|
94
|
+
chainId: ChainId.BSC_MAINNET,
|
|
95
|
+
title: 'Binance Smart Chain',
|
|
96
|
+
scanUrl: 'https://bscscan.com',
|
|
97
|
+
factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
|
|
98
|
+
hmtAddress: '0x0d501B743F22b641B8C8dfe00F1AAb881D57DDC7',
|
|
99
|
+
stakingAddress: '0xC2163A0928034e020f0d31e1171Ba0D6d9AfFB6c',
|
|
100
|
+
kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
|
|
101
|
+
|
|
102
|
+
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc-v1',
|
|
103
|
+
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
|
|
104
|
+
oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
|
|
105
|
+
},
|
|
106
|
+
[ChainId.BSC_TESTNET]: {
|
|
107
|
+
chainId: ChainId.BSC_TESTNET,
|
|
108
|
+
title: 'Binance Smart Chain (Testnet)',
|
|
109
|
+
scanUrl: 'https://testnet.bscscan.com',
|
|
110
|
+
factoryAddress: '0x2bfA592DBDaF434DDcbb893B1916120d181DAD18',
|
|
111
|
+
hmtAddress: '0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d',
|
|
112
|
+
stakingAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
|
|
113
|
+
kvstoreAddress: '0x3aD4B091E054f192a822D1406f4535eAd38580e4',
|
|
114
|
+
subgraphUrl:
|
|
115
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest-v1',
|
|
116
|
+
oldSubgraphUrl:
|
|
117
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
|
|
118
|
+
oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
|
|
119
|
+
},
|
|
120
|
+
[ChainId.POLYGON]: {
|
|
121
|
+
chainId: ChainId.POLYGON,
|
|
122
|
+
title: 'Polygon',
|
|
123
|
+
scanUrl: 'https://polygonscan.com',
|
|
124
|
+
factoryAddress: '0xBDBfD2cC708199C5640C6ECdf3B0F4A4C67AdfcB',
|
|
125
|
+
hmtAddress: '0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571BF',
|
|
126
|
+
stakingAddress: '0xcbAd56bE3f504E98bd70875823d3CC0242B7bB29',
|
|
127
|
+
kvstoreAddress: '0x35Cf4beBD58F9C8D75B9eA2599479b6C173d406F',
|
|
128
|
+
subgraphUrl:
|
|
129
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon-v1',
|
|
130
|
+
oldSubgraphUrl:
|
|
131
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
|
|
132
|
+
oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
|
|
133
|
+
},
|
|
134
|
+
[ChainId.POLYGON_MUMBAI]: {
|
|
135
|
+
chainId: ChainId.POLYGON_MUMBAI,
|
|
136
|
+
title: 'Polygon Mumbai',
|
|
137
|
+
scanUrl: 'https://mumbai.polygonscan.com',
|
|
138
|
+
factoryAddress: '0xA8D927C4DA17A6b71675d2D49dFda4E9eBE58f2d',
|
|
139
|
+
hmtAddress: '0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4',
|
|
140
|
+
stakingAddress: '0x7Fd3dF914E7b6Bd96B4c744Df32183b51368Bfac',
|
|
141
|
+
kvstoreAddress: '0xD7F61E812e139a5a02eDae9Dfec146E1b8eA3807',
|
|
142
|
+
subgraphUrl:
|
|
143
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai-v1',
|
|
144
|
+
oldSubgraphUrl:
|
|
145
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/mumbai',
|
|
146
|
+
oldFactoryAddress: '0x558cd800f9F0B02f3B149667bDe003284c867E94',
|
|
147
|
+
},
|
|
148
|
+
[ChainId.MOONBEAM]: {
|
|
149
|
+
chainId: ChainId.MOONBEAM,
|
|
150
|
+
title: 'Moonbeam',
|
|
151
|
+
scanUrl: 'https://moonbeam.moonscan.io',
|
|
152
|
+
factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
|
|
153
|
+
hmtAddress: '0x3b25BC1dC591D24d60560d0135D6750A561D4764',
|
|
154
|
+
stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
|
|
155
|
+
kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
|
|
156
|
+
subgraphUrl:
|
|
157
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam-v1',
|
|
158
|
+
oldSubgraphUrl:
|
|
159
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbeam',
|
|
160
|
+
oldFactoryAddress: '0x98108c28B7767a52BE38B4860832dd4e11A7ecad',
|
|
161
|
+
},
|
|
162
|
+
[ChainId.MOONBASE_ALPHA]: {
|
|
163
|
+
chainId: ChainId.MOONBASE_ALPHA,
|
|
164
|
+
title: 'Moonbase Alpha',
|
|
165
|
+
scanUrl: 'https://moonbase.moonscan.io/',
|
|
166
|
+
factoryAddress: '0x5e622FF522D81aa426f082bDD95210BC25fCA7Ed',
|
|
167
|
+
hmtAddress: '0x2dd72db2bBA65cE663e476bA8b84A1aAF802A8e3',
|
|
168
|
+
stakingAddress: '0xBFC7009F3371F93F3B54DdC8caCd02914a37495c',
|
|
169
|
+
kvstoreAddress: '0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d',
|
|
170
|
+
subgraphUrl:
|
|
171
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/moonbase-alpha-v1',
|
|
172
|
+
oldSubgraphUrl: '',
|
|
173
|
+
oldFactoryAddress: '',
|
|
174
|
+
},
|
|
175
|
+
[ChainId.AVALANCHE_TESTNET]: {
|
|
176
|
+
chainId: ChainId.AVALANCHE_TESTNET,
|
|
177
|
+
title: 'Fuji C-Chain',
|
|
178
|
+
scanUrl: 'https://testnet.snowtrace.io',
|
|
179
|
+
factoryAddress: '0xfb4469201951C3B9a7F1996c477cb7BDBEcE0A88',
|
|
180
|
+
hmtAddress: '0x9406d5c635AD22b0d76c75E52De57A2177919ca3',
|
|
181
|
+
stakingAddress: '',
|
|
182
|
+
kvstoreAddress: '0xd232c1426CF0653cE8a71DC98bCfDf10c471c114',
|
|
183
|
+
|
|
184
|
+
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
|
|
185
|
+
oldSubgraphUrl: '',
|
|
186
|
+
oldFactoryAddress: '',
|
|
187
|
+
},
|
|
188
|
+
[ChainId.AVALANCHE]: {
|
|
189
|
+
chainId: ChainId.AVALANCHE,
|
|
190
|
+
title: 'Avalanche C-Chain Mainnet',
|
|
191
|
+
scanUrl: 'https://snowtrace.io',
|
|
192
|
+
factoryAddress: '0x9767a578ba7a5FA1563c8229943cB01cd8446BB4',
|
|
193
|
+
hmtAddress: '0x12365293cb6477d4fc2686e46BB97E3Fb64f1550',
|
|
194
|
+
stakingAddress: '',
|
|
195
|
+
kvstoreAddress: '0x4B79eaD28F52eD5686bf0e379717e85fc7aD10Df',
|
|
196
|
+
subgraphUrl:
|
|
197
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
|
|
198
|
+
oldSubgraphUrl: '',
|
|
199
|
+
oldFactoryAddress: '',
|
|
200
|
+
},
|
|
201
|
+
[ChainId.SKALE]: {
|
|
202
|
+
chainId: ChainId.SKALE,
|
|
203
|
+
title: 'SKALE Human Protocol Chain',
|
|
204
|
+
scanUrl: 'https://wan-red-ain.explorer.mainnet.skalenodes.com/',
|
|
205
|
+
factoryAddress: '0x319070b49C8d1cC015915D1E7Eb5fd8e22833885',
|
|
206
|
+
hmtAddress: '0x6E5FF61Ea88270F6142E0E0eC8cbe9d67476CbCd',
|
|
207
|
+
stakingAddress: '0x79F37FB9C210910733c16228AC4D14a8e32C11BD',
|
|
208
|
+
kvstoreAddress: '0xE1055607327b1be2080D31211dCDC4D9338CaF4A',
|
|
209
|
+
subgraphUrl:
|
|
210
|
+
'https://graph-skale.humanprotocol.org/subgraphs/name/skale-human',
|
|
211
|
+
oldSubgraphUrl: '',
|
|
212
|
+
oldFactoryAddress: '0x27B423cE73d1dBdB48d2dd351398b5Ce8223117c',
|
|
213
|
+
},
|
|
214
|
+
[ChainId.LOCALHOST]: {
|
|
215
|
+
chainId: ChainId.LOCALHOST,
|
|
216
|
+
title: 'Localhost',
|
|
217
|
+
scanUrl: '',
|
|
218
|
+
factoryAddress: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
|
|
219
|
+
hmtAddress: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
|
|
220
|
+
stakingAddress: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
|
|
221
|
+
kvstoreAddress: '0x5FC8d32690cc91D4c39d9d3abcBD16989F875707',
|
|
222
|
+
subgraphUrl: '',
|
|
223
|
+
oldSubgraphUrl: '',
|
|
224
|
+
oldFactoryAddress: '',
|
|
225
|
+
},
|
|
226
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Signer } from 'ethers';
|
|
3
|
+
import { ErrorSigner } from './error';
|
|
4
|
+
|
|
5
|
+
export function requiresSigner(
|
|
6
|
+
target: any,
|
|
7
|
+
propertyKey: string,
|
|
8
|
+
descriptor: PropertyDescriptor
|
|
9
|
+
) {
|
|
10
|
+
const originalMethod = descriptor.value;
|
|
11
|
+
|
|
12
|
+
descriptor.value = async function (this: any, ...args: any[]) {
|
|
13
|
+
if (!Signer.isSigner(this.signerOrProvider)) {
|
|
14
|
+
throw ErrorSigner;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return originalMethod.apply(this, args);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return descriptor;
|
|
21
|
+
}
|
package/src/enums.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export enum ChainId {
|
|
2
|
+
ALL = -1,
|
|
3
|
+
MAINNET = 1,
|
|
4
|
+
RINKEBY = 4,
|
|
5
|
+
GOERLI = 5,
|
|
6
|
+
BSC_MAINNET = 56,
|
|
7
|
+
BSC_TESTNET = 97,
|
|
8
|
+
POLYGON = 137,
|
|
9
|
+
POLYGON_MUMBAI = 80001,
|
|
10
|
+
MOONBEAM = 1284,
|
|
11
|
+
MOONBASE_ALPHA = 1287,
|
|
12
|
+
AVALANCHE_TESTNET = 43113,
|
|
13
|
+
AVALANCHE = 43114,
|
|
14
|
+
SKALE = 1273227453,
|
|
15
|
+
LOCALHOST = 1338,
|
|
16
|
+
}
|
package/src/error.ts
CHANGED
|
@@ -1,43 +1,320 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @constant {Error} - The
|
|
2
|
+
* @constant {Error} - The Staking contract is missing.
|
|
3
3
|
*/
|
|
4
|
-
export const
|
|
4
|
+
export const ErrorStakingMissing = new Error('Staking contract is missing');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @constant {Error} - The
|
|
7
|
+
* @constant {Error} - The Storage client not initialised.
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
9
|
+
export const ErrorStorageClientNotInitialized = new Error(
|
|
10
|
+
'Storage client not initialized'
|
|
11
|
+
);
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* @constant {Error} - The
|
|
14
|
+
* @constant {Error} - The Storage does not exists.
|
|
13
15
|
*/
|
|
14
|
-
export const
|
|
16
|
+
export const ErrorStorageClientNotExists = new Error(
|
|
17
|
+
'Storage client does not exists'
|
|
18
|
+
);
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
|
-
* @constant {Error} - The
|
|
21
|
+
* @constant {Error} - The Storage credentials is missing.
|
|
18
22
|
*/
|
|
19
|
-
export const
|
|
20
|
-
'
|
|
23
|
+
export const ErrorStorageCredentialsMissing = new Error(
|
|
24
|
+
'Storage credentials is missing'
|
|
21
25
|
);
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
|
-
* @constant {Error} - The
|
|
28
|
+
* @constant {Error} - The Storage bucket not found.
|
|
29
|
+
*/
|
|
30
|
+
export const ErrorStorageBucketNotFound = new Error('Bucket not found');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @constant {Error} - The Storage file not found.
|
|
34
|
+
*/
|
|
35
|
+
export const ErrorStorageFileNotFound = new Error('File not found');
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @constant {Error} - The Storage file not uploaded.
|
|
25
39
|
*/
|
|
26
|
-
export const
|
|
40
|
+
export const ErrorStorageFileNotUploaded = new Error('File not uploaded');
|
|
27
41
|
|
|
28
42
|
/**
|
|
29
|
-
* @constant {Error} - The
|
|
43
|
+
* @constant {Error} - The KVStore key can not be empty.
|
|
30
44
|
*/
|
|
31
|
-
export const
|
|
45
|
+
export const ErrorKVStoreEmptyKey = new Error('Key can not be empty');
|
|
32
46
|
|
|
33
47
|
/**
|
|
34
|
-
* @constant {Error} - The
|
|
48
|
+
* @constant {Error} - The KVStore arrays must have the same length.
|
|
35
49
|
*/
|
|
36
|
-
export const
|
|
37
|
-
'
|
|
50
|
+
export const ErrorKVStoreArrayLength = new Error(
|
|
51
|
+
'Arrays must have the same length'
|
|
38
52
|
);
|
|
39
53
|
|
|
40
54
|
/**
|
|
41
|
-
* @constant {Error} - The
|
|
55
|
+
* @constant {Error} - The Address sent is invalid.
|
|
42
56
|
*/
|
|
43
|
-
export const
|
|
57
|
+
export const ErrorInvalidAddress = new Error('Invalid address');
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @constant {Error} - The token address sent is invalid.
|
|
61
|
+
*/
|
|
62
|
+
export const ErrorInvalidTokenAddress = new Error('Invalid token address');
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @constant {Error} - Invalid recording oracle address provided.
|
|
66
|
+
*/
|
|
67
|
+
export const ErrorInvalidRecordingOracleAddressProvided = new Error(
|
|
68
|
+
'Invalid recording oracle address provided'
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @constant {Error} - Invalid reputation oracle address provided.
|
|
73
|
+
*/
|
|
74
|
+
export const ErrorInvalidReputationOracleAddressProvided = new Error(
|
|
75
|
+
'Invalid reputation oracle address provided'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @constant {Error} - The Staking value must be positive.
|
|
80
|
+
*/
|
|
81
|
+
export const ErrorStakingValueMustBePositive = new Error(
|
|
82
|
+
'Value must be positive'
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @constant {Error} - Invalid staking value: amount must be a BigNumber.
|
|
87
|
+
*/
|
|
88
|
+
export const ErrorInvalidStakingValueType = new Error(
|
|
89
|
+
'Invalid staking value: amount must be a BigNumber'
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @constant {Error} - Invalid staking value: amount must be positive.
|
|
94
|
+
*/
|
|
95
|
+
export const ErrorInvalidStakingValueSign = new Error(
|
|
96
|
+
'Invalid staking value: amount must be positive'
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @constant {Error} - Invalid slasher address provided.
|
|
101
|
+
*/
|
|
102
|
+
export const ErrorInvalidSlasherAddressProvided = new Error(
|
|
103
|
+
'Invalid slasher address provided'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @constant {Error} - Invalid staker address provided.
|
|
108
|
+
*/
|
|
109
|
+
export const ErrorInvalidStakerAddressProvided = new Error(
|
|
110
|
+
'Invalid staker address provided'
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @constant {Error} - Invalid escrow address provided.
|
|
115
|
+
*/
|
|
116
|
+
export const ErrorInvalidEscrowAddressProvided = new Error(
|
|
117
|
+
'Invalid escrow address provided'
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @constant {Error} - Error getting stakers data.
|
|
122
|
+
*/
|
|
123
|
+
export const ErrorStakingGetStakers = new Error('Error getting stakers data');
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @constant {Error} - Failed to approve staking amount: signerOrProvider is not a Signer instance.
|
|
127
|
+
*/
|
|
128
|
+
export const ErrorFailedToApproveStakingAmountSignerDoesNotExist = new Error(
|
|
129
|
+
'Failed to approve staking amount: signerOrProvider is not a Signer instance'
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
export const ErrorFailedToCheckAllowance = new Error(
|
|
133
|
+
'Failed to check allowance'
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @constant {Error} - The HMToken amount not approved.
|
|
138
|
+
*/
|
|
139
|
+
export const ErrorHMTokenAmountNotApproved = new Error('Amount not approved');
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @constant {Error} - Init provider does not exists.
|
|
143
|
+
*/
|
|
144
|
+
export const ErrorInitProviderDoesNotExist = new Error(
|
|
145
|
+
'Provider does not exist'
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @constant {Error} - Init with unsupported chain ID.
|
|
150
|
+
*/
|
|
151
|
+
export const ErrorInitUnsupportedChainID = new Error('Unsupported chain ID');
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @constant {Error} - Sending a transaction requires a signer.
|
|
155
|
+
*/
|
|
156
|
+
export const ErrorSigner = new Error('Signer required');
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @constant {Error} - Escrow address is not provided by the factory.
|
|
160
|
+
*/
|
|
161
|
+
export const ErrorEscrowAddressIsNotProvidedByFactory = new Error(
|
|
162
|
+
'Escrow address is not provided by the factory'
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @constant {Error} - Manifest file does not exist.
|
|
167
|
+
*/
|
|
168
|
+
export const ErrorManifestFileDoesNotExist = new Error(
|
|
169
|
+
'Manifest file does not exist'
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @constant {Error} - Storage client does not exist.
|
|
174
|
+
*/
|
|
175
|
+
export const ErrorStorageClientDoesNotExist = new Error(
|
|
176
|
+
'Storage client does not exist'
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @constant {Error} - Invalid URL string.
|
|
181
|
+
*/
|
|
182
|
+
export const ErrorInvalidUrl = new Error('Invalid URL string');
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @constant {Error} - URL is an empty string.
|
|
186
|
+
*/
|
|
187
|
+
export const ErrorUrlIsEmptyString = new Error('URL is an empty string');
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @constant {Error} - List of handlers cannot be empty.
|
|
191
|
+
*/
|
|
192
|
+
export const ErrorListOfHandlersCannotBeEmpty = new Error(
|
|
193
|
+
'List of handlers cannot be empty'
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @constant {Error} - No URL provided.
|
|
198
|
+
*/
|
|
199
|
+
export const ErrorNoURLprovided = new Error('No URL provided');
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @constant {Error} - Fee must be between 0 and 100.
|
|
203
|
+
*/
|
|
204
|
+
export const ErrorFeeMustBeBetweenZeroAndHundred = new Error(
|
|
205
|
+
'Fee must be between 0 and 100'
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @constant {Error} - Total fee must be less than 100.
|
|
210
|
+
*/
|
|
211
|
+
export const ErrorTotalFeeMustBeLessThanHundred = new Error(
|
|
212
|
+
'Total fee must be less than 100'
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @constant {Error} - Recipient cannot be an empty array.
|
|
217
|
+
*/
|
|
218
|
+
export const ErrorRecipientCannotBeEmptyArray = new Error(
|
|
219
|
+
'Recipient cannot be an empty array'
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @constant {Error} - Amount must be greater than zero..
|
|
224
|
+
*/
|
|
225
|
+
export const ErrorAmountMustBeGreaterThanZero = new Error(
|
|
226
|
+
'Amount must be greater than zero'
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @constant {Error} - Escrow does not have enough balance.
|
|
231
|
+
*/
|
|
232
|
+
export const ErrorEscrowDoesNotHaveEnoughBalance = new Error(
|
|
233
|
+
'Escrow does not have enough balance'
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* @constant {Error} - Amounts cannot be an empty array.
|
|
238
|
+
*/
|
|
239
|
+
export const ErrorAmountsCannotBeEmptyArray = new Error(
|
|
240
|
+
'Amounts cannot be an empty array'
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @constant {Error} - Recipient and amounts must be the same length.
|
|
245
|
+
*/
|
|
246
|
+
export const ErrorRecipientAndAmountsMustBeSameLength = new Error(
|
|
247
|
+
'Recipient and amounts must be the same length'
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @constant {Error} - Launched event is not emitted.
|
|
252
|
+
*/
|
|
253
|
+
export const ErrorLaunchedEventIsNotEmitted = new Error(
|
|
254
|
+
'Launched event is not emitted'
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @constant {Error} - Hash is an empty string.
|
|
259
|
+
*/
|
|
260
|
+
export const ErrorHashIsEmptyString = new Error('Hash is an empty string');
|
|
261
|
+
|
|
262
|
+
export class EthereumError extends Error {
|
|
263
|
+
constructor(message: string) {
|
|
264
|
+
super(`An error occurred while interacting with Ethereum: ${message}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export class InvalidArgumentError extends EthereumError {
|
|
269
|
+
constructor(message: string) {
|
|
270
|
+
super(`Invalid argument: ${message}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export class OutOfGasError extends EthereumError {
|
|
275
|
+
constructor(message: string) {
|
|
276
|
+
super(`Out of gas: ${message}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export class UnpredictableGasLimit extends EthereumError {
|
|
281
|
+
constructor(message: string) {
|
|
282
|
+
super(`Unpredictable gas limit: ${message}`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export class ReplacementUnderpriced extends EthereumError {
|
|
287
|
+
constructor(message: string) {
|
|
288
|
+
super(`Replacement underpriced: ${message}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export class NumericFault extends EthereumError {
|
|
293
|
+
constructor(message: string) {
|
|
294
|
+
super(`Numeric fault: ${message}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export class NonceExpired extends EthereumError {
|
|
299
|
+
constructor(message: string) {
|
|
300
|
+
super(`Nonce expired: ${message}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export class TransactionReplaced extends EthereumError {
|
|
305
|
+
constructor(message: string) {
|
|
306
|
+
super(`Transaction replaced: ${message}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export class ContractExecutionError extends EthereumError {
|
|
311
|
+
constructor(reason: string) {
|
|
312
|
+
super(`Contract execution error: ${reason}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export class InvalidEthereumAddressError extends Error {
|
|
317
|
+
constructor(address: string) {
|
|
318
|
+
super(`Invalid ethereum address error: ${address}`);
|
|
319
|
+
}
|
|
320
|
+
}
|