@locuschain/lib 0.0.8 → 0.0.9
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/errors/index.amd.js +22 -0
- package/dist/errors/index.cjs.js +20 -0
- package/dist/errors/index.d.mts +1 -0
- package/dist/errors/index.esm.js +18 -0
- package/dist/errors/rpc-error.d.mts +13 -0
- package/dist/support/index.amd.js +1 -1
- package/dist/support/index.cjs.js +1 -1
- package/dist/support/index.esm.js +1 -1
- package/dist/web3/index.amd.js +12 -14
- package/dist/web3/index.cjs.js +12 -14
- package/dist/web3/index.d.cts +4 -4
- package/dist/web3/index.d.mts +4 -4
- package/dist/web3/index.esm.js +1 -3
- package/dist/web3/providers/http-rpc-provider.d.mts +2 -3
- package/dist/web3/providers/rpc-provider.d.mts +0 -1
- package/package.json +9 -1
- package/dist/rpc-error-8sxpHnEq.js +0 -18
- package/dist/rpc-error-CIW1Ier-.js +0 -22
- package/dist/rpc-error-DxFStPj8.js +0 -20
- package/dist/web3/rpc-error.d.mts +0 -13
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
define(['exports'], (function (exports) { 'use strict';
|
|
2
|
+
|
|
3
|
+
exports.RpcErrorCode = void 0;
|
|
4
|
+
(function (RpcErrorCode) {
|
|
5
|
+
RpcErrorCode["ERROR"] = "LOCUSLIB_ERROR";
|
|
6
|
+
RpcErrorCode["RUNTIME_ERROR"] = "LOCUSLIB_RUNTIME_ERROR";
|
|
7
|
+
RpcErrorCode["NET_ERROR"] = "LOCUSLIB_NET_ERROR";
|
|
8
|
+
RpcErrorCode["TIMEOUT"] = "LOCUSLIB_TIMEOUT";
|
|
9
|
+
RpcErrorCode["ABORTED"] = "LOCUSLIB_ABORTED";
|
|
10
|
+
RpcErrorCode["REQUIRE_ACCOUNT"] = "LOCUSLIB_REQUIRE_ACCOUNT";
|
|
11
|
+
})(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
|
|
12
|
+
class RpcError extends Error {
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.message = message;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.RpcError = RpcError;
|
|
21
|
+
|
|
22
|
+
}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
exports.RpcErrorCode = void 0;
|
|
4
|
+
(function (RpcErrorCode) {
|
|
5
|
+
RpcErrorCode["ERROR"] = "LOCUSLIB_ERROR";
|
|
6
|
+
RpcErrorCode["RUNTIME_ERROR"] = "LOCUSLIB_RUNTIME_ERROR";
|
|
7
|
+
RpcErrorCode["NET_ERROR"] = "LOCUSLIB_NET_ERROR";
|
|
8
|
+
RpcErrorCode["TIMEOUT"] = "LOCUSLIB_TIMEOUT";
|
|
9
|
+
RpcErrorCode["ABORTED"] = "LOCUSLIB_ABORTED";
|
|
10
|
+
RpcErrorCode["REQUIRE_ACCOUNT"] = "LOCUSLIB_REQUIRE_ACCOUNT";
|
|
11
|
+
})(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
|
|
12
|
+
class RpcError extends Error {
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.message = message;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.RpcError = RpcError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rpc-error.mts';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var RpcErrorCode;
|
|
2
|
+
(function (RpcErrorCode) {
|
|
3
|
+
RpcErrorCode["ERROR"] = "LOCUSLIB_ERROR";
|
|
4
|
+
RpcErrorCode["RUNTIME_ERROR"] = "LOCUSLIB_RUNTIME_ERROR";
|
|
5
|
+
RpcErrorCode["NET_ERROR"] = "LOCUSLIB_NET_ERROR";
|
|
6
|
+
RpcErrorCode["TIMEOUT"] = "LOCUSLIB_TIMEOUT";
|
|
7
|
+
RpcErrorCode["ABORTED"] = "LOCUSLIB_ABORTED";
|
|
8
|
+
RpcErrorCode["REQUIRE_ACCOUNT"] = "LOCUSLIB_REQUIRE_ACCOUNT";
|
|
9
|
+
})(RpcErrorCode || (RpcErrorCode = {}));
|
|
10
|
+
class RpcError extends Error {
|
|
11
|
+
constructor(code, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.message = message;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { RpcError, RpcErrorCode };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum RpcErrorCode {
|
|
2
|
+
ERROR = "LOCUSLIB_ERROR",
|
|
3
|
+
RUNTIME_ERROR = "LOCUSLIB_RUNTIME_ERROR",
|
|
4
|
+
NET_ERROR = "LOCUSLIB_NET_ERROR",
|
|
5
|
+
TIMEOUT = "LOCUSLIB_TIMEOUT",
|
|
6
|
+
ABORTED = "LOCUSLIB_ABORTED",
|
|
7
|
+
REQUIRE_ACCOUNT = "LOCUSLIB_REQUIRE_ACCOUNT"
|
|
8
|
+
}
|
|
9
|
+
export declare class RpcError extends Error {
|
|
10
|
+
code: string;
|
|
11
|
+
message: string;
|
|
12
|
+
constructor(code: string, message: string);
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(['exports', '../index-BkQ38g4T', '../
|
|
1
|
+
define(['exports', '../index-BkQ38g4T', '../errors/index.amd', 'lodash', '../address-class-Dp7aNQb2'], (function (exports, utils$2, errors, _, addressClass) { 'use strict';
|
|
2
2
|
|
|
3
3
|
function _interopNamespaceDefault(e) {
|
|
4
4
|
var n = Object.create(null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as convertHexToData, a as convertDataToHex, b as convertHexToAddress, d as convertAddressToHex, _ as __awaiter } from '../index-CB-t6xed.js';
|
|
2
|
-
import '../
|
|
2
|
+
import '../errors/index.esm.js';
|
|
3
3
|
import * as _ from 'lodash';
|
|
4
4
|
import '../address-class-CHAZYhdZ.js';
|
|
5
5
|
|
package/dist/web3/index.amd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../
|
|
1
|
+
define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../errors/index.amd', '../address-class-Dp7aNQb2', 'lodash'], (function (exports, utils, txType, errors, addressClass, _) { 'use strict';
|
|
2
2
|
|
|
3
3
|
class Account {
|
|
4
4
|
constructor({ address, nsk }) {
|
|
@@ -84,7 +84,6 @@ define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../rpc-error-CIW
|
|
|
84
84
|
constructor() {
|
|
85
85
|
super(...arguments);
|
|
86
86
|
this.id = 0;
|
|
87
|
-
this.canceledLastCallIndex = -1;
|
|
88
87
|
}
|
|
89
88
|
setAccountProvider(accountProvider) {
|
|
90
89
|
this.accountProvider = accountProvider;
|
|
@@ -109,7 +108,7 @@ define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../rpc-error-CIW
|
|
|
109
108
|
request(cmd, params, rpcOption) {
|
|
110
109
|
return utils.__awaiter(this, void 0, void 0, function* () {
|
|
111
110
|
if (this.getSignal().aborted) {
|
|
112
|
-
throw new
|
|
111
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
113
112
|
}
|
|
114
113
|
if (this.id === Number.MAX_SAFE_INTEGER) {
|
|
115
114
|
this.id = 0;
|
|
@@ -125,18 +124,18 @@ define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../rpc-error-CIW
|
|
|
125
124
|
const callRpc1Signal = this.getSignal();
|
|
126
125
|
const rpc1Result = yield this.callRpc(data, { signal: callRpc1Signal, headersInit: options.headersInit });
|
|
127
126
|
if (callRpc1Signal.aborted) {
|
|
128
|
-
throw new
|
|
127
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
129
128
|
}
|
|
130
129
|
if (!utils.TX_CREATION_RPC_LIST.includes(cmd)) {
|
|
131
130
|
return rpc1Result;
|
|
132
131
|
}
|
|
133
132
|
if (!this.accountProvider)
|
|
134
|
-
throw new
|
|
133
|
+
throw new errors.RpcError(errors.RpcErrorCode.REQUIRE_ACCOUNT, 'No accounts found. Please add an account before tx creation.');
|
|
135
134
|
// rpc1Result가 T(제네릭)이므로 'in' 연산자 사용을 위해 any로 캐스팅하여 체크합니다.
|
|
136
135
|
const txResult = rpc1Result;
|
|
137
136
|
if (!txResult || typeof txResult !== 'object' || !('hash' in txResult) || !('tx' in txResult)) {
|
|
138
137
|
// console.warn('rpcResul1>>', txResult)
|
|
139
|
-
throw new
|
|
138
|
+
throw new errors.RpcError(errors.RpcErrorCode.REQUIRE_ACCOUNT, 'Invalid transaction creation result.');
|
|
140
139
|
}
|
|
141
140
|
// console.debug('rpcResul1>>', txResult)
|
|
142
141
|
const additionalParams = yield this.accountProvider.signTx(txResult, params, options.address);
|
|
@@ -144,15 +143,15 @@ define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../rpc-error-CIW
|
|
|
144
143
|
const callRpc2Signal = this.getSignal();
|
|
145
144
|
const rpcResul2 = yield this.callRpc(newData, { signal: callRpc2Signal, headersInit: options.headersInit });
|
|
146
145
|
if (callRpc2Signal.aborted) {
|
|
147
|
-
throw new
|
|
146
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
148
147
|
}
|
|
149
148
|
return rpcResul2;
|
|
150
149
|
// console.debug('rpcResul2', rpcResult2)
|
|
151
150
|
}
|
|
152
151
|
catch (err) {
|
|
153
|
-
if (err.code ===
|
|
152
|
+
if (err.code === errors.RpcErrorCode.ABORTED)
|
|
154
153
|
throw err;
|
|
155
|
-
throw new
|
|
154
|
+
throw new errors.RpcError(errors.RpcErrorCode.RUNTIME_ERROR, err.message);
|
|
156
155
|
// console.trace(err)
|
|
157
156
|
// console.log(err.stack);
|
|
158
157
|
}
|
|
@@ -164,7 +163,6 @@ define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../rpc-error-CIW
|
|
|
164
163
|
constructor(rpcUrl, rpcOptions) {
|
|
165
164
|
super();
|
|
166
165
|
this.id = 0;
|
|
167
|
-
this.canceledLastCallIndex = -1;
|
|
168
166
|
this.rpcUrl = rpcUrl;
|
|
169
167
|
this.rpcOptions = Object.assign({ abortController: new AbortController() }, rpcOptions);
|
|
170
168
|
}
|
|
@@ -173,7 +171,7 @@ define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../rpc-error-CIW
|
|
|
173
171
|
// console.debug('params', data)
|
|
174
172
|
var _a;
|
|
175
173
|
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
176
|
-
throw new
|
|
174
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
177
175
|
}
|
|
178
176
|
try {
|
|
179
177
|
const res = yield fetch(this.rpcUrl, {
|
|
@@ -183,16 +181,16 @@ define(['exports', '../index-BkQ38g4T', '../tx-type-BeeK7Ci3', '../rpc-error-CIW
|
|
|
183
181
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
184
182
|
});
|
|
185
183
|
if (!res.ok)
|
|
186
|
-
throw new
|
|
184
|
+
throw new errors.RpcError(errors.RpcErrorCode.NET_ERROR, `node response http status : ${res.status}`);
|
|
187
185
|
const response = yield res.json();
|
|
188
186
|
if (response.error) {
|
|
189
187
|
const { code, message } = response.error;
|
|
190
|
-
throw new
|
|
188
|
+
throw new errors.RpcError(message === 'timeout error' ? errors.RpcErrorCode.TIMEOUT : code, message);
|
|
191
189
|
}
|
|
192
190
|
return response.result;
|
|
193
191
|
}
|
|
194
192
|
catch (err) {
|
|
195
|
-
throw new
|
|
193
|
+
throw new errors.RpcError(err.name === 'TimeoutError' ? errors.RpcErrorCode.TIMEOUT : errors.RpcErrorCode.RUNTIME_ERROR, err.message);
|
|
196
194
|
}
|
|
197
195
|
});
|
|
198
196
|
}
|
package/dist/web3/index.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var utils = require('../index-BJsuMvb_.js');
|
|
4
4
|
var txType = require('../tx-type-jR5Owltc.js');
|
|
5
|
-
var
|
|
5
|
+
var errors = require('../errors/index.cjs.js');
|
|
6
6
|
require('../address-class-Cjy48Uqk.js');
|
|
7
7
|
require('lodash');
|
|
8
8
|
|
|
@@ -90,7 +90,6 @@ class RpcProvider extends utils.Rpc {
|
|
|
90
90
|
constructor() {
|
|
91
91
|
super(...arguments);
|
|
92
92
|
this.id = 0;
|
|
93
|
-
this.canceledLastCallIndex = -1;
|
|
94
93
|
}
|
|
95
94
|
setAccountProvider(accountProvider) {
|
|
96
95
|
this.accountProvider = accountProvider;
|
|
@@ -115,7 +114,7 @@ class RpcProvider extends utils.Rpc {
|
|
|
115
114
|
request(cmd, params, rpcOption) {
|
|
116
115
|
return utils.__awaiter(this, void 0, void 0, function* () {
|
|
117
116
|
if (this.getSignal().aborted) {
|
|
118
|
-
throw new
|
|
117
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
119
118
|
}
|
|
120
119
|
if (this.id === Number.MAX_SAFE_INTEGER) {
|
|
121
120
|
this.id = 0;
|
|
@@ -131,18 +130,18 @@ class RpcProvider extends utils.Rpc {
|
|
|
131
130
|
const callRpc1Signal = this.getSignal();
|
|
132
131
|
const rpc1Result = yield this.callRpc(data, { signal: callRpc1Signal, headersInit: options.headersInit });
|
|
133
132
|
if (callRpc1Signal.aborted) {
|
|
134
|
-
throw new
|
|
133
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
135
134
|
}
|
|
136
135
|
if (!utils.TX_CREATION_RPC_LIST.includes(cmd)) {
|
|
137
136
|
return rpc1Result;
|
|
138
137
|
}
|
|
139
138
|
if (!this.accountProvider)
|
|
140
|
-
throw new
|
|
139
|
+
throw new errors.RpcError(errors.RpcErrorCode.REQUIRE_ACCOUNT, 'No accounts found. Please add an account before tx creation.');
|
|
141
140
|
// rpc1Result가 T(제네릭)이므로 'in' 연산자 사용을 위해 any로 캐스팅하여 체크합니다.
|
|
142
141
|
const txResult = rpc1Result;
|
|
143
142
|
if (!txResult || typeof txResult !== 'object' || !('hash' in txResult) || !('tx' in txResult)) {
|
|
144
143
|
// console.warn('rpcResul1>>', txResult)
|
|
145
|
-
throw new
|
|
144
|
+
throw new errors.RpcError(errors.RpcErrorCode.REQUIRE_ACCOUNT, 'Invalid transaction creation result.');
|
|
146
145
|
}
|
|
147
146
|
// console.debug('rpcResul1>>', txResult)
|
|
148
147
|
const additionalParams = yield this.accountProvider.signTx(txResult, params, options.address);
|
|
@@ -150,15 +149,15 @@ class RpcProvider extends utils.Rpc {
|
|
|
150
149
|
const callRpc2Signal = this.getSignal();
|
|
151
150
|
const rpcResul2 = yield this.callRpc(newData, { signal: callRpc2Signal, headersInit: options.headersInit });
|
|
152
151
|
if (callRpc2Signal.aborted) {
|
|
153
|
-
throw new
|
|
152
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
154
153
|
}
|
|
155
154
|
return rpcResul2;
|
|
156
155
|
// console.debug('rpcResul2', rpcResult2)
|
|
157
156
|
}
|
|
158
157
|
catch (err) {
|
|
159
|
-
if (err.code ===
|
|
158
|
+
if (err.code === errors.RpcErrorCode.ABORTED)
|
|
160
159
|
throw err;
|
|
161
|
-
throw new
|
|
160
|
+
throw new errors.RpcError(errors.RpcErrorCode.RUNTIME_ERROR, err.message);
|
|
162
161
|
// console.trace(err)
|
|
163
162
|
// console.log(err.stack);
|
|
164
163
|
}
|
|
@@ -170,7 +169,6 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
170
169
|
constructor(rpcUrl, rpcOptions) {
|
|
171
170
|
super();
|
|
172
171
|
this.id = 0;
|
|
173
|
-
this.canceledLastCallIndex = -1;
|
|
174
172
|
this.rpcUrl = rpcUrl;
|
|
175
173
|
this.rpcOptions = Object.assign({ abortController: new AbortController() }, rpcOptions);
|
|
176
174
|
}
|
|
@@ -179,7 +177,7 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
179
177
|
// console.debug('params', data)
|
|
180
178
|
var _a;
|
|
181
179
|
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
182
|
-
throw new
|
|
180
|
+
throw new errors.RpcError(errors.RpcErrorCode.ABORTED, `rpc aborted by user`);
|
|
183
181
|
}
|
|
184
182
|
try {
|
|
185
183
|
const res = yield fetch(this.rpcUrl, {
|
|
@@ -189,16 +187,16 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
189
187
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
190
188
|
});
|
|
191
189
|
if (!res.ok)
|
|
192
|
-
throw new
|
|
190
|
+
throw new errors.RpcError(errors.RpcErrorCode.NET_ERROR, `node response http status : ${res.status}`);
|
|
193
191
|
const response = yield res.json();
|
|
194
192
|
if (response.error) {
|
|
195
193
|
const { code, message } = response.error;
|
|
196
|
-
throw new
|
|
194
|
+
throw new errors.RpcError(message === 'timeout error' ? errors.RpcErrorCode.TIMEOUT : code, message);
|
|
197
195
|
}
|
|
198
196
|
return response.result;
|
|
199
197
|
}
|
|
200
198
|
catch (err) {
|
|
201
|
-
throw new
|
|
199
|
+
throw new errors.RpcError(err.name === 'TimeoutError' ? errors.RpcErrorCode.TIMEOUT : errors.RpcErrorCode.RUNTIME_ERROR, err.message);
|
|
202
200
|
}
|
|
203
201
|
});
|
|
204
202
|
}
|
package/dist/web3/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AccountProvider } from
|
|
2
|
-
import { HttpRpcProvider } from
|
|
3
|
-
import { RpcProvider } from
|
|
4
|
-
import { RpcOptions } from
|
|
1
|
+
import { AccountProvider } from './providers/account-provider.mts';
|
|
2
|
+
import { HttpRpcProvider } from './providers/http-rpc-provider.mts';
|
|
3
|
+
import { RpcProvider } from './providers/rpc-provider.mts';
|
|
4
|
+
import { RpcOptions } from './types/index.mts';
|
|
5
5
|
export declare class Web3 {
|
|
6
6
|
private accountProvider?;
|
|
7
7
|
private rpcProvider?;
|
package/dist/web3/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AccountProvider } from
|
|
2
|
-
import { HttpRpcProvider } from
|
|
3
|
-
import { RpcProvider } from
|
|
4
|
-
import { RpcOptions } from
|
|
1
|
+
import { AccountProvider } from './providers/account-provider.mts';
|
|
2
|
+
import { HttpRpcProvider } from './providers/http-rpc-provider.mts';
|
|
3
|
+
import { RpcProvider } from './providers/rpc-provider.mts';
|
|
4
|
+
import { RpcOptions } from './types/index.mts';
|
|
5
5
|
export declare class Web3 {
|
|
6
6
|
private accountProvider?;
|
|
7
7
|
private rpcProvider?;
|
package/dist/web3/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as sign, _ as __awaiter, v as verifyTxParams, R as Rpc, T as TX_CREATION_RPC_LIST } from '../index-CB-t6xed.js';
|
|
2
2
|
import { T as TxType } from '../tx-type-nyLU5xv5.js';
|
|
3
|
-
import {
|
|
3
|
+
import { RpcError, RpcErrorCode } from '../errors/index.esm.js';
|
|
4
4
|
import '../address-class-CHAZYhdZ.js';
|
|
5
5
|
import 'lodash';
|
|
6
6
|
|
|
@@ -88,7 +88,6 @@ class RpcProvider extends Rpc {
|
|
|
88
88
|
constructor() {
|
|
89
89
|
super(...arguments);
|
|
90
90
|
this.id = 0;
|
|
91
|
-
this.canceledLastCallIndex = -1;
|
|
92
91
|
}
|
|
93
92
|
setAccountProvider(accountProvider) {
|
|
94
93
|
this.accountProvider = accountProvider;
|
|
@@ -168,7 +167,6 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
168
167
|
constructor(rpcUrl, rpcOptions) {
|
|
169
168
|
super();
|
|
170
169
|
this.id = 0;
|
|
171
|
-
this.canceledLastCallIndex = -1;
|
|
172
170
|
this.rpcUrl = rpcUrl;
|
|
173
171
|
this.rpcOptions = Object.assign({ abortController: new AbortController() }, rpcOptions);
|
|
174
172
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { CallRpcOptions, RpcOptions } from
|
|
2
|
-
import { RpcProvider } from
|
|
1
|
+
import { CallRpcOptions, RpcOptions } from '../types/index.mts';
|
|
2
|
+
import { RpcProvider } from './rpc-provider.mts';
|
|
3
3
|
export declare class HttpRpcProvider extends RpcProvider {
|
|
4
4
|
id: number;
|
|
5
5
|
rpcUrl: string;
|
|
6
6
|
rpcOptions?: RpcOptions;
|
|
7
|
-
canceledLastCallIndex: number;
|
|
8
7
|
constructor(rpcUrl: string, rpcOptions?: RpcOptions);
|
|
9
8
|
callRpc<T>(data: any, options?: CallRpcOptions): Promise<T>;
|
|
10
9
|
}
|
|
@@ -5,7 +5,6 @@ import { AccountProvider } from './account-provider.mts';
|
|
|
5
5
|
export declare abstract class RpcProvider extends Rpc {
|
|
6
6
|
id: number;
|
|
7
7
|
rpcOptions?: RpcOptions | undefined;
|
|
8
|
-
canceledLastCallIndex: number;
|
|
9
8
|
accountProvider?: AccountProvider;
|
|
10
9
|
abstract callRpc<T>(data: any, options?: CallRpcOptions): Promise<T>;
|
|
11
10
|
abstract get rpcUrl(): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locuschain/lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"author": "bloomtechnology",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "",
|
|
@@ -52,6 +52,14 @@
|
|
|
52
52
|
},
|
|
53
53
|
"import": "./dist/support/index.esm.js",
|
|
54
54
|
"require": "./dist/support/index.cjs.js"
|
|
55
|
+
},
|
|
56
|
+
"./errors": {
|
|
57
|
+
"types": {
|
|
58
|
+
"require": "./dist/errors/index.d.cts",
|
|
59
|
+
"import": "./dist/errors/index.d.mts"
|
|
60
|
+
},
|
|
61
|
+
"import": "./dist/errors/index.esm.js",
|
|
62
|
+
"require": "./dist/errors/index.cjs.js"
|
|
55
63
|
}
|
|
56
64
|
},
|
|
57
65
|
"files": [
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var RpcErrorCode;
|
|
2
|
-
(function (RpcErrorCode) {
|
|
3
|
-
RpcErrorCode[RpcErrorCode["ERROR"] = -32000] = "ERROR";
|
|
4
|
-
RpcErrorCode[RpcErrorCode["RUNTIME_ERROR"] = -31999] = "RUNTIME_ERROR";
|
|
5
|
-
RpcErrorCode[RpcErrorCode["NET_ERROR"] = -31998] = "NET_ERROR";
|
|
6
|
-
RpcErrorCode[RpcErrorCode["TIMEOUT"] = -31997] = "TIMEOUT";
|
|
7
|
-
RpcErrorCode[RpcErrorCode["ABORTED"] = -31996] = "ABORTED";
|
|
8
|
-
RpcErrorCode[RpcErrorCode["REQUIRE_ACCOUNT"] = -31995] = "REQUIRE_ACCOUNT";
|
|
9
|
-
})(RpcErrorCode || (RpcErrorCode = {}));
|
|
10
|
-
class RpcError extends Error {
|
|
11
|
-
constructor(code, message) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.code = code;
|
|
14
|
-
this.message = message;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { RpcError as R, RpcErrorCode as a };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
define(['exports'], (function (exports) { 'use strict';
|
|
2
|
-
|
|
3
|
-
exports.RpcErrorCode = void 0;
|
|
4
|
-
(function (RpcErrorCode) {
|
|
5
|
-
RpcErrorCode[RpcErrorCode["ERROR"] = -32000] = "ERROR";
|
|
6
|
-
RpcErrorCode[RpcErrorCode["RUNTIME_ERROR"] = -31999] = "RUNTIME_ERROR";
|
|
7
|
-
RpcErrorCode[RpcErrorCode["NET_ERROR"] = -31998] = "NET_ERROR";
|
|
8
|
-
RpcErrorCode[RpcErrorCode["TIMEOUT"] = -31997] = "TIMEOUT";
|
|
9
|
-
RpcErrorCode[RpcErrorCode["ABORTED"] = -31996] = "ABORTED";
|
|
10
|
-
RpcErrorCode[RpcErrorCode["REQUIRE_ACCOUNT"] = -31995] = "REQUIRE_ACCOUNT";
|
|
11
|
-
})(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
|
|
12
|
-
class RpcError extends Error {
|
|
13
|
-
constructor(code, message) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.code = code;
|
|
16
|
-
this.message = message;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.RpcError = RpcError;
|
|
21
|
-
|
|
22
|
-
}));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
exports.RpcErrorCode = void 0;
|
|
4
|
-
(function (RpcErrorCode) {
|
|
5
|
-
RpcErrorCode[RpcErrorCode["ERROR"] = -32000] = "ERROR";
|
|
6
|
-
RpcErrorCode[RpcErrorCode["RUNTIME_ERROR"] = -31999] = "RUNTIME_ERROR";
|
|
7
|
-
RpcErrorCode[RpcErrorCode["NET_ERROR"] = -31998] = "NET_ERROR";
|
|
8
|
-
RpcErrorCode[RpcErrorCode["TIMEOUT"] = -31997] = "TIMEOUT";
|
|
9
|
-
RpcErrorCode[RpcErrorCode["ABORTED"] = -31996] = "ABORTED";
|
|
10
|
-
RpcErrorCode[RpcErrorCode["REQUIRE_ACCOUNT"] = -31995] = "REQUIRE_ACCOUNT";
|
|
11
|
-
})(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
|
|
12
|
-
class RpcError extends Error {
|
|
13
|
-
constructor(code, message) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.code = code;
|
|
16
|
-
this.message = message;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.RpcError = RpcError;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare enum RpcErrorCode {
|
|
2
|
-
ERROR = -32000,
|
|
3
|
-
RUNTIME_ERROR = -31999,
|
|
4
|
-
NET_ERROR = -31998,
|
|
5
|
-
TIMEOUT = -31997,
|
|
6
|
-
ABORTED = -31996,
|
|
7
|
-
REQUIRE_ACCOUNT = -31995
|
|
8
|
-
}
|
|
9
|
-
export declare class RpcError extends Error {
|
|
10
|
-
code: number;
|
|
11
|
-
message: string;
|
|
12
|
-
constructor(code: number, message: string);
|
|
13
|
-
}
|