@locuschain/lib 0.0.11 → 0.0.15-beta.0
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/autogen/locus-tx.d.mts +2 -2
- package/dist/autogen/rpc-api-spec.d.mts +110 -110
- package/dist/autogen/rpc.d.mts +112 -112
- package/dist/autogen/types/common/asset-object-transfer.d.mts +1 -1
- package/dist/autogen/types/common/asset-proof-objects.d.mts +1 -1
- package/dist/autogen/types/common/asset-transfer-info.d.mts +3 -3
- package/dist/autogen/types/common/contract-exec-status.d.mts +1 -1
- package/dist/autogen/types/common/index.d.mts +47 -47
- package/dist/autogen/types/common/ref-vtx.d.mts +1 -1
- package/dist/autogen/types/common/round-state-detail.d.mts +1 -1
- package/dist/autogen/types/common/rpc-data-trade-result.d.mts +1 -1
- package/dist/autogen/types/common/transaction-sender-index.d.mts +1 -1
- package/dist/autogen/types/common/transfer-info.d.mts +1 -1
- package/dist/autogen/types/common/vm-engine-block.d.mts +1 -1
- package/dist/autogen/types/common/vm-tx-state.d.mts +4 -4
- package/dist/autogen/types/consts/index.d.mts +3 -3
- package/dist/autogen/types/rpc/heights-result.d.mts +1 -1
- package/dist/autogen/types/rpc/index.d.mts +100 -100
- package/dist/autogen/types/rpc/params-account-heights.d.mts +1 -1
- package/dist/autogen/types/rpc/params-call-contract.d.mts +1 -1
- package/dist/autogen/types/rpc/params-create-contract.d.mts +1 -1
- package/dist/autogen/types/rpc/params-download-account-txs.d.mts +1 -1
- package/dist/autogen/types/rpc/params-provide-script.d.mts +1 -1
- package/dist/autogen/types/rpc/params-transfer-coin-express.d.mts +1 -1
- package/dist/autogen/types/rpc/params-transfer-tokens.d.mts +1 -1
- package/dist/autogen/types/rpc/rpc-get-account-asset-list-result.d.mts +1 -1
- package/dist/autogen/types/rpc/rpc-get-account-asset-object-result.d.mts +1 -1
- package/dist/autogen/types/rpc/rpc-get-account-token-list-result.d.mts +1 -1
- package/dist/autogen/types/rpc/rpc-get-inactive-tx-list-result.d.mts +2 -2
- package/dist/autogen/types/rpc/rpc-get-mont-info-list-result.d.mts +1 -1
- package/dist/autogen/types/rpc/rpc-get-world-round-state-result.d.mts +1 -1
- package/dist/autogen/types/rpc/upload-heights-result.d.mts +1 -1
- package/dist/autogen/types/tx/index.d.mts +49 -49
- package/dist/autogen/types/tx/tx-accept-script-after-time-lock.d.mts +4 -4
- package/dist/autogen/types/tx/tx-accept-script.d.mts +3 -3
- package/dist/autogen/types/tx/tx-activate-all-assets.d.mts +5 -5
- package/dist/autogen/types/tx/tx-activate-asset-object.d.mts +4 -4
- package/dist/autogen/types/tx/tx-activate-call-contract.d.mts +4 -4
- package/dist/autogen/types/tx/tx-activate-coin.d.mts +3 -3
- package/dist/autogen/types/tx/tx-activate-contract-result.d.mts +6 -6
- package/dist/autogen/types/tx/tx-activate-contract-reward.d.mts +3 -3
- package/dist/autogen/types/tx/tx-activate-contract-transfer.d.mts +5 -5
- package/dist/autogen/types/tx/tx-activate-data-synth-account.d.mts +3 -3
- package/dist/autogen/types/tx/tx-activate-foundation-reserve.d.mts +2 -2
- package/dist/autogen/types/tx/tx-activate-incentive.d.mts +2 -2
- package/dist/autogen/types/tx/tx-activate-lock-stake-for-vme.d.mts +4 -4
- package/dist/autogen/types/tx/tx-activate-open-contract.d.mts +4 -4
- package/dist/autogen/types/tx/tx-activate-open-synth-account.d.mts +3 -3
- package/dist/autogen/types/tx/tx-activate-open-vm-engine.d.mts +4 -4
- package/dist/autogen/types/tx/tx-activate-token.d.mts +4 -4
- package/dist/autogen/types/tx/tx-become-guest.d.mts +2 -2
- package/dist/autogen/types/tx/tx-become-host.d.mts +2 -2
- package/dist/autogen/types/tx/tx-burn-asset-object.d.mts +3 -3
- package/dist/autogen/types/tx/tx-burn-token.d.mts +3 -3
- package/dist/autogen/types/tx/tx-call-contract.d.mts +4 -4
- package/dist/autogen/types/tx/tx-change-foundation-account.d.mts +2 -2
- package/dist/autogen/types/tx/tx-change-keypair.d.mts +3 -3
- package/dist/autogen/types/tx/tx-change-vkey.d.mts +2 -2
- package/dist/autogen/types/tx/tx-close-account.d.mts +4 -4
- package/dist/autogen/types/tx/tx-contract-blank-reward.d.mts +2 -2
- package/dist/autogen/types/tx/tx-contract-transfer-reward.d.mts +2 -2
- package/dist/autogen/types/tx/tx-create-asset-object.d.mts +3 -3
- package/dist/autogen/types/tx/tx-create-contract.d.mts +4 -4
- package/dist/autogen/types/tx/tx-create-synth-account.d.mts +2 -2
- package/dist/autogen/types/tx/tx-create-token.d.mts +3 -3
- package/dist/autogen/types/tx/tx-create-vm-engine.d.mts +2 -2
- package/dist/autogen/types/tx/tx-dummy.d.mts +2 -2
- package/dist/autogen/types/tx/tx-finalize.d.mts +2 -2
- package/dist/autogen/types/tx/tx-genesis-account.d.mts +3 -3
- package/dist/autogen/types/tx/tx-lead-vtx.d.mts +3 -3
- package/dist/autogen/types/tx/tx-lock-stake-for-vme.d.mts +2 -2
- package/dist/autogen/types/tx/tx-open-account.d.mts +5 -5
- package/dist/autogen/types/tx/tx-post-data-synth-account.d.mts +2 -2
- package/dist/autogen/types/tx/tx-post-data.d.mts +2 -2
- package/dist/autogen/types/tx/tx-provide-script.d.mts +3 -3
- package/dist/autogen/types/tx/tx-revoke.d.mts +6 -6
- package/dist/autogen/types/tx/tx-transfer-asset-object.d.mts +3 -3
- package/dist/autogen/types/tx/tx-transfer-coin-express.d.mts +3 -3
- package/dist/autogen/types/tx/tx-transfer-coin.d.mts +2 -2
- package/dist/autogen/types/tx/tx-transfer-token.d.mts +3 -3
- package/dist/autogen/types/tx/tx-unlock-stake.d.mts +2 -2
- package/dist/autogen/types/tx/tx-vm-engine-block.d.mts +3 -3
- package/dist/autogen/types/wasm/index.d.mts +24 -24
- package/dist/autogen/types/wasm/param-test-core-script.d.mts +1 -1
- package/dist/autogen/wasm.d.mts +24 -24
- package/dist/constant/index.d.cts +2 -2
- package/dist/constant/index.d.mts +2 -2
- package/dist/{index-BQ0aTXY5.js → index-DG0VEpO7.js} +31 -7
- package/dist/{index-Byqx0KIO.js → index-dKo4dwic.js} +31 -7
- package/dist/{index-Cg0xnkC2.js → index-pHGVNvIY.js} +31 -7
- package/dist/index.d.mts +4 -4
- package/dist/support/erc20-helper/abi.d.mts +1 -1
- package/dist/support/erc20-helper/index.d.mts +1 -1
- package/dist/support/index.amd.js +1 -1
- package/dist/support/index.cjs.js +1 -1
- package/dist/support/index.d.cts +3 -3
- package/dist/support/index.d.mts +3 -3
- package/dist/support/index.esm.js +1 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.mts +4 -4
- package/dist/utils/index.amd.js +1 -1
- package/dist/utils/index.cjs.js +1 -1
- package/dist/utils/index.d.cts +5 -5
- package/dist/utils/index.d.mts +5 -5
- package/dist/utils/index.esm.js +1 -1
- package/dist/utils/lclib.d.mts +1 -0
- package/dist/web3/index.amd.js +25 -18
- package/dist/web3/index.cjs.js +25 -18
- package/dist/web3/index.d.cts +5 -5
- package/dist/web3/index.d.mts +5 -5
- package/dist/web3/index.esm.js +25 -18
- package/dist/web3/providers/account-provider.d.mts +2 -2
- package/dist/web3/providers/http-rpc-provider.d.mts +2 -2
- package/dist/web3/providers/index.d.mts +3 -3
- package/dist/web3/providers/rpc-provider.d.mts +4 -4
- package/dist/web3/types/account.d.mts +1 -1
- package/dist/web3/types/index.d.mts +4 -4
- package/package.json +7 -7
package/dist/web3/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var utils = require('../index-
|
|
3
|
+
var utils = require('../index-pHGVNvIY.js');
|
|
4
4
|
var txType = require('../tx-type-jR5Owltc.js');
|
|
5
5
|
require('../address-class-Cjy48Uqk.js');
|
|
6
6
|
require('lodash');
|
|
@@ -89,18 +89,25 @@ 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
|
+
NO_SELECTED_NETWORK: 1010,
|
|
108
|
+
KEY_SIGN_FAILED: 1011,
|
|
109
|
+
INVALID_NETWORK: 1012,
|
|
110
|
+
INVALID_ADDRESS: 1013,
|
|
104
111
|
});
|
|
105
112
|
class LocusError extends Error {
|
|
106
113
|
constructor(code, message) {
|
|
@@ -138,7 +145,7 @@ class RpcProvider extends utils.Rpc {
|
|
|
138
145
|
request(cmd, params, rpcOption) {
|
|
139
146
|
return utils.__awaiter(this, void 0, void 0, function* () {
|
|
140
147
|
if (this.getSignal().aborted) {
|
|
141
|
-
throw new LocusError(LocusErrorCode.
|
|
148
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
142
149
|
}
|
|
143
150
|
if (this.id === Number.MAX_SAFE_INTEGER) {
|
|
144
151
|
this.id = 0;
|
|
@@ -154,7 +161,7 @@ class RpcProvider extends utils.Rpc {
|
|
|
154
161
|
const callRpc1Signal = this.getSignal();
|
|
155
162
|
const rpc1Result = yield this.callRpc(data, { signal: callRpc1Signal, headersInit: options.headersInit });
|
|
156
163
|
if (callRpc1Signal.aborted) {
|
|
157
|
-
throw new LocusError(LocusErrorCode.
|
|
164
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
158
165
|
}
|
|
159
166
|
if (!utils.TX_CREATION_RPC_LIST.some(str => str === cmd)) {
|
|
160
167
|
return rpc1Result;
|
|
@@ -173,13 +180,13 @@ class RpcProvider extends utils.Rpc {
|
|
|
173
180
|
const callRpc2Signal = this.getSignal();
|
|
174
181
|
const rpcResul2 = yield this.callRpc(newData, { signal: callRpc2Signal, headersInit: options.headersInit });
|
|
175
182
|
if (callRpc2Signal.aborted) {
|
|
176
|
-
throw new LocusError(LocusErrorCode.
|
|
183
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
177
184
|
}
|
|
178
185
|
return rpcResul2;
|
|
179
186
|
// console.debug('rpcResul2', rpcResult2)
|
|
180
187
|
}
|
|
181
188
|
catch (err) {
|
|
182
|
-
if (err.code === LocusErrorCode.
|
|
189
|
+
if (err.code === LocusErrorCode.NETWORK_ABORTED)
|
|
183
190
|
throw err;
|
|
184
191
|
throw new LocusError(LocusErrorCode.RUNTIME_ERROR, err.message);
|
|
185
192
|
// console.trace(err)
|
|
@@ -201,7 +208,7 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
201
208
|
// console.debug('params', data)
|
|
202
209
|
var _a;
|
|
203
210
|
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
204
|
-
throw new LocusError(LocusErrorCode.
|
|
211
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
205
212
|
}
|
|
206
213
|
try {
|
|
207
214
|
const res = yield fetch(this.rpcUrl, {
|
|
@@ -211,16 +218,16 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
211
218
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
212
219
|
});
|
|
213
220
|
if (!res.ok)
|
|
214
|
-
throw new LocusError(LocusErrorCode.
|
|
221
|
+
throw new LocusError(LocusErrorCode.NETWORK_ERROR, `node response http status : ${res.status}`);
|
|
215
222
|
const response = yield res.json();
|
|
216
223
|
if (response.error) {
|
|
217
224
|
const { code, message } = response.error;
|
|
218
|
-
throw new LocusError(message === 'timeout error' ? LocusErrorCode.
|
|
225
|
+
throw new LocusError(message === 'timeout error' ? LocusErrorCode.NETWORK_TIMEOUT : code, message);
|
|
219
226
|
}
|
|
220
227
|
return response.result;
|
|
221
228
|
}
|
|
222
229
|
catch (err) {
|
|
223
|
-
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.
|
|
230
|
+
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.NETWORK_TIMEOUT : LocusErrorCode.RUNTIME_ERROR, err.message);
|
|
224
231
|
}
|
|
225
232
|
});
|
|
226
233
|
}
|
package/dist/web3/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AccountProvider } from './providers/account-provider.
|
|
2
|
-
import { HttpRpcProvider } from './providers/http-rpc-provider.
|
|
3
|
-
import { RpcProvider } from './providers/rpc-provider.
|
|
4
|
-
import { RpcOptions } from './types/index.
|
|
1
|
+
import { AccountProvider } from './providers/account-provider.mjs';
|
|
2
|
+
import { HttpRpcProvider } from './providers/http-rpc-provider.mjs';
|
|
3
|
+
import { RpcProvider } from './providers/rpc-provider.mjs';
|
|
4
|
+
import { RpcOptions } from './types/index.mjs';
|
|
5
5
|
export declare class Web3 {
|
|
6
6
|
private accountProvider?;
|
|
7
7
|
private rpcProvider?;
|
|
@@ -16,4 +16,4 @@ export declare class Web3 {
|
|
|
16
16
|
};
|
|
17
17
|
get accounts(): AccountProvider;
|
|
18
18
|
}
|
|
19
|
-
export * from './types/index.
|
|
19
|
+
export * from './types/index.mjs';
|
package/dist/web3/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AccountProvider } from './providers/account-provider.
|
|
2
|
-
import { HttpRpcProvider } from './providers/http-rpc-provider.
|
|
3
|
-
import { RpcProvider } from './providers/rpc-provider.
|
|
4
|
-
import { RpcOptions } from './types/index.
|
|
1
|
+
import { AccountProvider } from './providers/account-provider.mjs';
|
|
2
|
+
import { HttpRpcProvider } from './providers/http-rpc-provider.mjs';
|
|
3
|
+
import { RpcProvider } from './providers/rpc-provider.mjs';
|
|
4
|
+
import { RpcOptions } from './types/index.mjs';
|
|
5
5
|
export declare class Web3 {
|
|
6
6
|
private accountProvider?;
|
|
7
7
|
private rpcProvider?;
|
|
@@ -16,4 +16,4 @@ export declare class Web3 {
|
|
|
16
16
|
};
|
|
17
17
|
get accounts(): AccountProvider;
|
|
18
18
|
}
|
|
19
|
-
export * from './types/index.
|
|
19
|
+
export * from './types/index.mjs';
|
package/dist/web3/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as sign, _ as __awaiter, v as verifyTxParams, R as Rpc, T as TX_CREATION_RPC_LIST } from '../index-
|
|
1
|
+
import { s as sign, _ as __awaiter, v as verifyTxParams, R as Rpc, T as TX_CREATION_RPC_LIST } from '../index-DG0VEpO7.js';
|
|
2
2
|
import { T as TxType } from '../tx-type-nyLU5xv5.js';
|
|
3
3
|
import '../address-class-CHAZYhdZ.js';
|
|
4
4
|
import 'lodash';
|
|
@@ -87,18 +87,25 @@ 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
|
+
NO_SELECTED_NETWORK: 1010,
|
|
106
|
+
KEY_SIGN_FAILED: 1011,
|
|
107
|
+
INVALID_NETWORK: 1012,
|
|
108
|
+
INVALID_ADDRESS: 1013,
|
|
102
109
|
});
|
|
103
110
|
class LocusError extends Error {
|
|
104
111
|
constructor(code, message) {
|
|
@@ -136,7 +143,7 @@ class RpcProvider extends Rpc {
|
|
|
136
143
|
request(cmd, params, rpcOption) {
|
|
137
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
145
|
if (this.getSignal().aborted) {
|
|
139
|
-
throw new LocusError(LocusErrorCode.
|
|
146
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
140
147
|
}
|
|
141
148
|
if (this.id === Number.MAX_SAFE_INTEGER) {
|
|
142
149
|
this.id = 0;
|
|
@@ -152,7 +159,7 @@ class RpcProvider extends Rpc {
|
|
|
152
159
|
const callRpc1Signal = this.getSignal();
|
|
153
160
|
const rpc1Result = yield this.callRpc(data, { signal: callRpc1Signal, headersInit: options.headersInit });
|
|
154
161
|
if (callRpc1Signal.aborted) {
|
|
155
|
-
throw new LocusError(LocusErrorCode.
|
|
162
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
156
163
|
}
|
|
157
164
|
if (!TX_CREATION_RPC_LIST.some(str => str === cmd)) {
|
|
158
165
|
return rpc1Result;
|
|
@@ -171,13 +178,13 @@ class RpcProvider extends Rpc {
|
|
|
171
178
|
const callRpc2Signal = this.getSignal();
|
|
172
179
|
const rpcResul2 = yield this.callRpc(newData, { signal: callRpc2Signal, headersInit: options.headersInit });
|
|
173
180
|
if (callRpc2Signal.aborted) {
|
|
174
|
-
throw new LocusError(LocusErrorCode.
|
|
181
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
175
182
|
}
|
|
176
183
|
return rpcResul2;
|
|
177
184
|
// console.debug('rpcResul2', rpcResult2)
|
|
178
185
|
}
|
|
179
186
|
catch (err) {
|
|
180
|
-
if (err.code === LocusErrorCode.
|
|
187
|
+
if (err.code === LocusErrorCode.NETWORK_ABORTED)
|
|
181
188
|
throw err;
|
|
182
189
|
throw new LocusError(LocusErrorCode.RUNTIME_ERROR, err.message);
|
|
183
190
|
// console.trace(err)
|
|
@@ -199,7 +206,7 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
199
206
|
// console.debug('params', data)
|
|
200
207
|
var _a;
|
|
201
208
|
if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
202
|
-
throw new LocusError(LocusErrorCode.
|
|
209
|
+
throw new LocusError(LocusErrorCode.NETWORK_ABORTED, `rpc aborted by user`);
|
|
203
210
|
}
|
|
204
211
|
try {
|
|
205
212
|
const res = yield fetch(this.rpcUrl, {
|
|
@@ -209,16 +216,16 @@ class HttpRpcProvider extends RpcProvider {
|
|
|
209
216
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
|
210
217
|
});
|
|
211
218
|
if (!res.ok)
|
|
212
|
-
throw new LocusError(LocusErrorCode.
|
|
219
|
+
throw new LocusError(LocusErrorCode.NETWORK_ERROR, `node response http status : ${res.status}`);
|
|
213
220
|
const response = yield res.json();
|
|
214
221
|
if (response.error) {
|
|
215
222
|
const { code, message } = response.error;
|
|
216
|
-
throw new LocusError(message === 'timeout error' ? LocusErrorCode.
|
|
223
|
+
throw new LocusError(message === 'timeout error' ? LocusErrorCode.NETWORK_TIMEOUT : code, message);
|
|
217
224
|
}
|
|
218
225
|
return response.result;
|
|
219
226
|
}
|
|
220
227
|
catch (err) {
|
|
221
|
-
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.
|
|
228
|
+
throw new LocusError(err.name === 'TimeoutError' ? LocusErrorCode.NETWORK_TIMEOUT : LocusErrorCode.RUNTIME_ERROR, err.message);
|
|
222
229
|
}
|
|
223
230
|
});
|
|
224
231
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RpcCreateTxResult } from
|
|
2
|
-
import { Account } from
|
|
1
|
+
import { RpcCreateTxResult } from '../../autogen/types/rpc/rpc-create-tx-result.mjs';
|
|
2
|
+
import { Account } from '../types/account.mjs';
|
|
3
3
|
export declare class AccountProvider {
|
|
4
4
|
accounts: Account[];
|
|
5
5
|
add: (acc: Account) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CallRpcOptions, RpcOptions } from '../types/index.
|
|
2
|
-
import { RpcProvider } from './rpc-provider.
|
|
1
|
+
import { CallRpcOptions, RpcOptions } from '../types/index.mjs';
|
|
2
|
+
import { RpcProvider } from './rpc-provider.mjs';
|
|
3
3
|
export declare class HttpRpcProvider extends RpcProvider {
|
|
4
4
|
id: number;
|
|
5
5
|
rpcUrl: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './http-rpc-provider.
|
|
2
|
-
export * from './account-provider.
|
|
3
|
-
export * from './rpc-provider.
|
|
1
|
+
export * from './http-rpc-provider.mjs';
|
|
2
|
+
export * from './account-provider.mjs';
|
|
3
|
+
export * from './rpc-provider.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RpcApiSpec } from '../../autogen/rpc-api-spec.
|
|
2
|
-
import { Rpc } from '../../autogen/rpc.
|
|
3
|
-
import { CallRpcOptions, RpcOptions, Web3APIMethod, Web3APIParams } from '../types/index.
|
|
4
|
-
import { AccountProvider } from './account-provider.
|
|
1
|
+
import { RpcApiSpec } from '../../autogen/rpc-api-spec.mjs';
|
|
2
|
+
import { Rpc } from '../../autogen/rpc.mjs';
|
|
3
|
+
import { CallRpcOptions, RpcOptions, Web3APIMethod, Web3APIParams } from '../types/index.mjs';
|
|
4
|
+
import { AccountProvider } from './account-provider.mjs';
|
|
5
5
|
export declare abstract class RpcProvider extends Rpc {
|
|
6
6
|
id: number;
|
|
7
7
|
rpcOptions?: RpcOptions | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RpcApiSpec } from
|
|
1
|
+
import { RpcApiSpec } from '../../autogen/rpc-api-spec.mjs';
|
|
2
2
|
export type RpcOptions = {
|
|
3
3
|
address?: string;
|
|
4
4
|
headersInit?: HeadersInit;
|
|
@@ -8,7 +8,7 @@ export type CallRpcOptions = {
|
|
|
8
8
|
headersInit?: HeadersInit;
|
|
9
9
|
signal?: AbortSignal;
|
|
10
10
|
};
|
|
11
|
-
export type Web3APIMethod<T extends RpcApiSpec> =
|
|
11
|
+
export type Web3APIMethod<T extends RpcApiSpec> = keyof T & string;
|
|
12
12
|
export type Web3APIParams<API extends RpcApiSpec, Method extends Web3APIMethod<API>> = API[Method] extends (...args: any) => any ? Parameters<API[Method]> : any[];
|
|
13
|
-
export * from '../providers/index.
|
|
14
|
-
export * from './account.
|
|
13
|
+
export * from '../providers/index.mjs';
|
|
14
|
+
export * from './account.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@locuschain/lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "bloomtechnology",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"./utils": {
|
|
16
16
|
"types": {
|
|
17
17
|
"require": "./dist/utils/index.d.cts",
|
|
18
|
-
"import": "./dist/utils/index.d.
|
|
18
|
+
"import": "./dist/utils/index.d.mjs"
|
|
19
19
|
},
|
|
20
20
|
"require": "./dist/utils/index.cjs.js",
|
|
21
21
|
"import": "./dist/utils/index.esm.js"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"./types": {
|
|
24
24
|
"types": {
|
|
25
25
|
"require": "./dist/types/index.d.cts",
|
|
26
|
-
"import": "./dist/types/index.d.
|
|
26
|
+
"import": "./dist/types/index.d.mjs"
|
|
27
27
|
},
|
|
28
28
|
"import": "./dist/types/index.esm.js",
|
|
29
29
|
"require": "./dist/types/index.cjs.js"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"./constant": {
|
|
32
32
|
"types": {
|
|
33
33
|
"require": "./dist/constant/index.d.cts",
|
|
34
|
-
"import": "./dist/constant/index.d.
|
|
34
|
+
"import": "./dist/constant/index.d.mjs"
|
|
35
35
|
},
|
|
36
36
|
"import": "./dist/constant/index.esm.js",
|
|
37
37
|
"require": "./dist/constant/index.cjs.js"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"./web3": {
|
|
40
40
|
"types": {
|
|
41
41
|
"require": "./dist/web3/index.d.cts",
|
|
42
|
-
"import": "./dist/web3/index.d.
|
|
42
|
+
"import": "./dist/web3/index.d.mjs"
|
|
43
43
|
},
|
|
44
44
|
"import": "./dist/web3/index.esm.js",
|
|
45
45
|
"require": "./dist/web3/index.cjs.js"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"./support": {
|
|
48
48
|
"types": {
|
|
49
49
|
"require": "./dist/support/index.d.cts",
|
|
50
|
-
"import": "./dist/support/index.d.
|
|
50
|
+
"import": "./dist/support/index.d.mjs"
|
|
51
51
|
},
|
|
52
52
|
"import": "./dist/support/index.esm.js",
|
|
53
53
|
"require": "./dist/support/index.cjs.js"
|
|
@@ -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.11-beta.0"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"generate-code": "generate-code.sh",
|