@locuschain/lib 0.0.11 → 0.0.12
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/web3/index.amd.js +21 -13
- package/dist/web3/index.cjs.js +21 -13
- package/dist/web3/index.esm.js +21 -13
- package/package.json +2 -2
package/dist/web3/index.amd.js
CHANGED
|
@@ -84,18 +84,26 @@ define(['exports', '../index-Byqx0KIO', '../tx-type-BeeK7Ci3', '../address-class
|
|
|
84
84
|
// RPC
|
|
85
85
|
RPC_ERROR: -32e3,
|
|
86
86
|
// LIB
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
NETWORK_ABORTED: 'NETWORK_ABORTED',
|
|
88
|
+
NETWORK_TIMEOUT: 'NETWORK_TIMEOUT',
|
|
89
|
+
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
89
90
|
REQUIRE_ACCOUNT: 'REQUIRE_ACCOUNT',
|
|
90
91
|
RUNTIME_ERROR: 'RUNTIME_ERROR',
|
|
91
92
|
// WALLET
|
|
92
|
-
|
|
93
|
-
BY_USER:
|
|
94
|
-
REQUIRE_OPENACCOUNT:
|
|
95
|
-
DUPLICATED:
|
|
96
|
-
NOTFOUND:
|
|
97
|
-
INVALID_PARAM:
|
|
98
|
-
|
|
93
|
+
INTERNAL_ERROR: 1000,
|
|
94
|
+
BY_USER: 1001,
|
|
95
|
+
REQUIRE_OPENACCOUNT: 1002,
|
|
96
|
+
DUPLICATED: 1003,
|
|
97
|
+
NOTFOUND: 1004,
|
|
98
|
+
INVALID_PARAM: 1005,
|
|
99
|
+
REQUIRE_LOGIN: 1006,
|
|
100
|
+
REQUIRE_CONNECT: 1007,
|
|
101
|
+
INVALID_RPC_URL: 1008,
|
|
102
|
+
CALL_RPC_ERROR: 1009,
|
|
103
|
+
NO_SELECTED_NETWORK: 1010,
|
|
104
|
+
KEY_SIGN_FAILED: 1011,
|
|
105
|
+
INVALID_NETWORK: 1012,
|
|
106
|
+
INVALID_ADDRESS: 1013,
|
|
99
107
|
});
|
|
100
108
|
class LocusError extends Error {
|
|
101
109
|
constructor(code, message) {
|
|
@@ -196,7 +204,7 @@ define(['exports', '../index-Byqx0KIO', '../tx-type-BeeK7Ci3', '../address-class
|
|
|
196
204
|
// console.debug('params', data)
|
|
197
205
|
var _a;
|
|
198
206
|
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
199
|
-
throw new LocusError(LocusErrorCode.
|
|
207
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
200
208
|
}
|
|
201
209
|
try {
|
|
202
210
|
const res = yield fetch(this.rpcUrl, {
|
|
@@ -206,16 +214,16 @@ define(['exports', '../index-Byqx0KIO', '../tx-type-BeeK7Ci3', '../address-class
|
|
|
206
214
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
207
215
|
});
|
|
208
216
|
if (!res.ok)
|
|
209
|
-
throw new LocusError(LocusErrorCode.
|
|
217
|
+
throw new LocusError(LocusErrorCode.NETWORK_ERROR, `node response http status : ${res.status}`);
|
|
210
218
|
const response = yield res.json();
|
|
211
219
|
if (response.error) {
|
|
212
220
|
const { code, message } = response.error;
|
|
213
|
-
throw new LocusError(message === 'timeout error' ? LocusErrorCode.
|
|
221
|
+
throw new LocusError(message === 'timeout error' ? LocusErrorCode.NETWORK_TIMEOUT : code, message);
|
|
214
222
|
}
|
|
215
223
|
return response.result;
|
|
216
224
|
}
|
|
217
225
|
catch (err) {
|
|
218
|
-
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.
|
|
226
|
+
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.NETWORK_TIMEOUT : LocusErrorCode.RUNTIME_ERROR, err.message);
|
|
219
227
|
}
|
|
220
228
|
});
|
|
221
229
|
}
|
package/dist/web3/index.cjs.js
CHANGED
|
@@ -89,18 +89,26 @@ const LocusErrorCode = Object.freeze({
|
|
|
89
89
|
// RPC
|
|
90
90
|
RPC_ERROR: -32e3,
|
|
91
91
|
// LIB
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
NETWORK_ABORTED: 'NETWORK_ABORTED',
|
|
93
|
+
NETWORK_TIMEOUT: 'NETWORK_TIMEOUT',
|
|
94
|
+
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
94
95
|
REQUIRE_ACCOUNT: 'REQUIRE_ACCOUNT',
|
|
95
96
|
RUNTIME_ERROR: 'RUNTIME_ERROR',
|
|
96
97
|
// WALLET
|
|
97
|
-
|
|
98
|
-
BY_USER:
|
|
99
|
-
REQUIRE_OPENACCOUNT:
|
|
100
|
-
DUPLICATED:
|
|
101
|
-
NOTFOUND:
|
|
102
|
-
INVALID_PARAM:
|
|
103
|
-
|
|
98
|
+
INTERNAL_ERROR: 1000,
|
|
99
|
+
BY_USER: 1001,
|
|
100
|
+
REQUIRE_OPENACCOUNT: 1002,
|
|
101
|
+
DUPLICATED: 1003,
|
|
102
|
+
NOTFOUND: 1004,
|
|
103
|
+
INVALID_PARAM: 1005,
|
|
104
|
+
REQUIRE_LOGIN: 1006,
|
|
105
|
+
REQUIRE_CONNECT: 1007,
|
|
106
|
+
INVALID_RPC_URL: 1008,
|
|
107
|
+
CALL_RPC_ERROR: 1009,
|
|
108
|
+
NO_SELECTED_NETWORK: 1010,
|
|
109
|
+
KEY_SIGN_FAILED: 1011,
|
|
110
|
+
INVALID_NETWORK: 1012,
|
|
111
|
+
INVALID_ADDRESS: 1013,
|
|
104
112
|
});
|
|
105
113
|
class LocusError extends Error {
|
|
106
114
|
constructor(code, message) {
|
|
@@ -201,7 +209,7 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
201
209
|
// console.debug('params', data)
|
|
202
210
|
var _a;
|
|
203
211
|
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
204
|
-
throw new LocusError(LocusErrorCode.
|
|
212
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
205
213
|
}
|
|
206
214
|
try {
|
|
207
215
|
const res = yield fetch(this.rpcUrl, {
|
|
@@ -211,16 +219,16 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
211
219
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
212
220
|
});
|
|
213
221
|
if (!res.ok)
|
|
214
|
-
throw new LocusError(LocusErrorCode.
|
|
222
|
+
throw new LocusError(LocusErrorCode.NETWORK_ERROR, `node response http status : ${res.status}`);
|
|
215
223
|
const response = yield res.json();
|
|
216
224
|
if (response.error) {
|
|
217
225
|
const { code, message } = response.error;
|
|
218
|
-
throw new LocusError(message === 'timeout error' ? LocusErrorCode.
|
|
226
|
+
throw new LocusError(message === 'timeout error' ? LocusErrorCode.NETWORK_TIMEOUT : code, message);
|
|
219
227
|
}
|
|
220
228
|
return response.result;
|
|
221
229
|
}
|
|
222
230
|
catch (err) {
|
|
223
|
-
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.
|
|
231
|
+
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.NETWORK_TIMEOUT : LocusErrorCode.RUNTIME_ERROR, err.message);
|
|
224
232
|
}
|
|
225
233
|
});
|
|
226
234
|
}
|
package/dist/web3/index.esm.js
CHANGED
|
@@ -87,18 +87,26 @@ const LocusErrorCode = Object.freeze({
|
|
|
87
87
|
// RPC
|
|
88
88
|
RPC_ERROR: -32e3,
|
|
89
89
|
// LIB
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
NETWORK_ABORTED: 'NETWORK_ABORTED',
|
|
91
|
+
NETWORK_TIMEOUT: 'NETWORK_TIMEOUT',
|
|
92
|
+
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
92
93
|
REQUIRE_ACCOUNT: 'REQUIRE_ACCOUNT',
|
|
93
94
|
RUNTIME_ERROR: 'RUNTIME_ERROR',
|
|
94
95
|
// WALLET
|
|
95
|
-
|
|
96
|
-
BY_USER:
|
|
97
|
-
REQUIRE_OPENACCOUNT:
|
|
98
|
-
DUPLICATED:
|
|
99
|
-
NOTFOUND:
|
|
100
|
-
INVALID_PARAM:
|
|
101
|
-
|
|
96
|
+
INTERNAL_ERROR: 1000,
|
|
97
|
+
BY_USER: 1001,
|
|
98
|
+
REQUIRE_OPENACCOUNT: 1002,
|
|
99
|
+
DUPLICATED: 1003,
|
|
100
|
+
NOTFOUND: 1004,
|
|
101
|
+
INVALID_PARAM: 1005,
|
|
102
|
+
REQUIRE_LOGIN: 1006,
|
|
103
|
+
REQUIRE_CONNECT: 1007,
|
|
104
|
+
INVALID_RPC_URL: 1008,
|
|
105
|
+
CALL_RPC_ERROR: 1009,
|
|
106
|
+
NO_SELECTED_NETWORK: 1010,
|
|
107
|
+
KEY_SIGN_FAILED: 1011,
|
|
108
|
+
INVALID_NETWORK: 1012,
|
|
109
|
+
INVALID_ADDRESS: 1013,
|
|
102
110
|
});
|
|
103
111
|
class LocusError extends Error {
|
|
104
112
|
constructor(code, message) {
|
|
@@ -199,7 +207,7 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
199
207
|
// console.debug('params', data)
|
|
200
208
|
var _a;
|
|
201
209
|
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
202
|
-
throw new LocusError(LocusErrorCode.
|
|
210
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
203
211
|
}
|
|
204
212
|
try {
|
|
205
213
|
const res = yield fetch(this.rpcUrl, {
|
|
@@ -209,16 +217,16 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
209
217
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
210
218
|
});
|
|
211
219
|
if (!res.ok)
|
|
212
|
-
throw new LocusError(LocusErrorCode.
|
|
220
|
+
throw new LocusError(LocusErrorCode.NETWORK_ERROR, `node response http status : ${res.status}`);
|
|
213
221
|
const response = yield res.json();
|
|
214
222
|
if (response.error) {
|
|
215
223
|
const { code, message } = response.error;
|
|
216
|
-
throw new LocusError(message === 'timeout error' ? LocusErrorCode.
|
|
224
|
+
throw new LocusError(message === 'timeout error' ? LocusErrorCode.NETWORK_TIMEOUT : code, message);
|
|
217
225
|
}
|
|
218
226
|
return response.result;
|
|
219
227
|
}
|
|
220
228
|
catch (err) {
|
|
221
|
-
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.
|
|
229
|
+
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.NETWORK_TIMEOUT : LocusErrorCode.RUNTIME_ERROR, err.message);
|
|
222
230
|
}
|
|
223
231
|
});
|
|
224
232
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locuschain/lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "bloomtechnology",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"lodash": "^4.17.21",
|
|
72
72
|
"wasm-opt": "^1.4.0",
|
|
73
|
-
"@locuschain/errors": "1.0.
|
|
73
|
+
"@locuschain/errors": "1.0.7"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"generate-code": "generate-code.sh",
|