smoldot 1.0.17 → 2.0.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/cjs/index-browser.d.ts +1 -1
- package/dist/cjs/index-browser.js +1 -2
- package/dist/cjs/index-deno.d.ts +1 -1
- package/dist/cjs/index-deno.js +1 -2
- package/dist/cjs/index-nodejs.d.ts +1 -1
- package/dist/cjs/index-nodejs.js +1 -2
- package/dist/cjs/internals/bytecode/wasm0.js +1 -1
- package/dist/cjs/internals/bytecode/wasm1.js +1 -1
- package/dist/cjs/internals/bytecode/wasm2.js +1 -1
- package/dist/cjs/internals/client.js +1 -6
- package/dist/cjs/internals/local-instance.js +1 -1
- package/dist/cjs/no-auto-bytecode-browser.d.ts +1 -1
- package/dist/cjs/no-auto-bytecode-browser.js +1 -2
- package/dist/cjs/no-auto-bytecode-deno.d.ts +1 -1
- package/dist/cjs/no-auto-bytecode-deno.js +1 -2
- package/dist/cjs/no-auto-bytecode-nodejs.d.ts +1 -1
- package/dist/cjs/no-auto-bytecode-nodejs.js +1 -2
- package/dist/cjs/public-types.d.ts +3 -13
- package/dist/cjs/public-types.js +1 -10
- package/dist/mjs/index-browser.d.ts +1 -1
- package/dist/mjs/index-browser.js +1 -1
- package/dist/mjs/index-deno.d.ts +1 -1
- package/dist/mjs/index-deno.js +1 -1
- package/dist/mjs/index-nodejs.d.ts +1 -1
- package/dist/mjs/index-nodejs.js +1 -1
- package/dist/mjs/internals/bytecode/wasm0.js +1 -1
- package/dist/mjs/internals/bytecode/wasm1.js +1 -1
- package/dist/mjs/internals/bytecode/wasm2.js +1 -1
- package/dist/mjs/internals/client.js +2 -7
- package/dist/mjs/internals/local-instance.js +1 -1
- package/dist/mjs/no-auto-bytecode-browser.d.ts +1 -1
- package/dist/mjs/no-auto-bytecode-browser.js +1 -1
- package/dist/mjs/no-auto-bytecode-deno.d.ts +1 -1
- package/dist/mjs/no-auto-bytecode-deno.js +1 -1
- package/dist/mjs/no-auto-bytecode-nodejs.d.ts +1 -1
- package/dist/mjs/no-auto-bytecode-nodejs.js +1 -1
- package/dist/mjs/public-types.d.ts +3 -13
- package/dist/mjs/public-types.js +0 -8
- package/package.json +2 -2
|
@@ -20,7 +20,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
// GNU General Public License for more details.
|
|
21
21
|
// You should have received a copy of the GNU General Public License
|
|
22
22
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
-
import { QueueFullError, AlreadyDestroyedError, AddChainError, JsonRpcDisabledError,
|
|
23
|
+
import { QueueFullError, AlreadyDestroyedError, AddChainError, JsonRpcDisabledError, CrashError } from '../public-types.js';
|
|
24
24
|
import * as instance from './local-instance.js';
|
|
25
25
|
import * as remote from './remote-instance.js';
|
|
26
26
|
// This function is similar to the `start` function found in `index.ts`, except with an extra
|
|
@@ -306,15 +306,10 @@ export function start(options, wasmModule, platformBindings) {
|
|
|
306
306
|
throw new AlreadyDestroyedError();
|
|
307
307
|
if (options.disableJsonRpc)
|
|
308
308
|
throw new JsonRpcDisabledError();
|
|
309
|
-
if (request.length >= 64 * 1024 * 1024) {
|
|
310
|
-
throw new MalformedJsonRpcError();
|
|
311
|
-
}
|
|
312
|
-
;
|
|
313
309
|
const retVal = state.instance.instance.request(request, chainId);
|
|
314
310
|
switch (retVal) {
|
|
315
311
|
case 0: break;
|
|
316
|
-
case 1: throw new
|
|
317
|
-
case 2: throw new QueueFullError();
|
|
312
|
+
case 1: throw new QueueFullError();
|
|
318
313
|
default: throw new Error("Internal error: unknown json_rpc_send error code: " + retVal);
|
|
319
314
|
}
|
|
320
315
|
},
|
|
@@ -466,7 +466,7 @@ export function startLocalInstance(config, wasmModule, eventCallback) {
|
|
|
466
466
|
return {
|
|
467
467
|
request: (request, chainId) => {
|
|
468
468
|
if (!state.instance)
|
|
469
|
-
return
|
|
469
|
+
return 1; // TODO: return a different error code? should be documented
|
|
470
470
|
state.bufferIndices[0] = new TextEncoder().encode(request);
|
|
471
471
|
return state.instance.exports.json_rpc_send(0, chainId) >>> 0;
|
|
472
472
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
import { Client, ClientOptionsWithBytecode } from './public-types.js';
|
|
3
|
-
export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, JsonRpcDisabledError,
|
|
3
|
+
export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, JsonRpcDisabledError, QueueFullError, LogCallback } from './public-types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Initializes a new client. This is a pre-requisite to connecting to a blockchain.
|
|
6
6
|
*
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
import { start as innerStart } from './internals/client.js';
|
|
14
|
-
export { AddChainError, AlreadyDestroyedError, CrashError, JsonRpcDisabledError,
|
|
14
|
+
export { AddChainError, AlreadyDestroyedError, CrashError, JsonRpcDisabledError, QueueFullError } from './public-types.js';
|
|
15
15
|
/**
|
|
16
16
|
* Initializes a new client. This is a pre-requisite to connecting to a blockchain.
|
|
17
17
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client, ClientOptionsWithBytecode } from './public-types.js';
|
|
2
|
-
export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError,
|
|
2
|
+
export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, QueueFullError, JsonRpcDisabledError, LogCallback } from './public-types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes a new client. This is a pre-requisite to connecting to a blockchain.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
import { start as innerStart } from './internals/client.js';
|
|
14
|
-
export { AddChainError, AlreadyDestroyedError, CrashError,
|
|
14
|
+
export { AddChainError, AlreadyDestroyedError, CrashError, QueueFullError, JsonRpcDisabledError } from './public-types.js';
|
|
15
15
|
/**
|
|
16
16
|
* Initializes a new client. This is a pre-requisite to connecting to a blockchain.
|
|
17
17
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client, ClientOptionsWithBytecode } from './public-types.js';
|
|
2
|
-
export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError,
|
|
2
|
+
export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, QueueFullError, JsonRpcDisabledError, LogCallback } from './public-types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Initializes a new client. This is a pre-requisite to connecting to a blockchain.
|
|
5
5
|
*
|
|
@@ -6,7 +6,7 @@ import { WebSocket } from 'ws';
|
|
|
6
6
|
import { performance } from 'node:perf_hooks';
|
|
7
7
|
import { createConnection as nodeCreateConnection } from 'node:net';
|
|
8
8
|
import { randomFillSync } from 'node:crypto';
|
|
9
|
-
export { AddChainError, AlreadyDestroyedError, CrashError,
|
|
9
|
+
export { AddChainError, AlreadyDestroyedError, CrashError, QueueFullError, JsonRpcDisabledError } from './public-types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Initializes a new client. This is a pre-requisite to connecting to a blockchain.
|
|
12
12
|
*
|
|
@@ -25,12 +25,6 @@ export declare class JsonRpcDisabledError extends Error {
|
|
|
25
25
|
export declare class CrashError extends Error {
|
|
26
26
|
constructor(message: string);
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Thrown in case a malformed JSON-RPC request is sent.
|
|
30
|
-
*/
|
|
31
|
-
export declare class MalformedJsonRpcError extends Error {
|
|
32
|
-
constructor();
|
|
33
|
-
}
|
|
34
28
|
/**
|
|
35
29
|
* Thrown in case the buffer of JSON-RPC requests is full and cannot accept any more request.
|
|
36
30
|
*/
|
|
@@ -103,15 +97,12 @@ export interface Chain {
|
|
|
103
97
|
* Be aware that some requests will cause notifications to be sent back using the same callback
|
|
104
98
|
* as the responses.
|
|
105
99
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
100
|
+
* If the request is not a valid JSON-RPC request, then a JSON-RPC error response is later
|
|
101
|
+
* generated with an `id` equal to `null`, in accordance with the JSON-RPC 2.0 specification.
|
|
102
|
+
*
|
|
109
103
|
* If, however, the request is a valid JSON-RPC request but that concerns an unknown method, or
|
|
110
104
|
* if for example some parameters are missing, an error response is properly generated and
|
|
111
105
|
* yielded through the JSON-RPC callback.
|
|
112
|
-
* In other words, a {@link MalformedJsonRpcError} is thrown in situations where something
|
|
113
|
-
* is *so wrong* with the request that it is not possible for smoldot to send back an error
|
|
114
|
-
* through the JSON-RPC callback.
|
|
115
106
|
*
|
|
116
107
|
* Two JSON-RPC APIs are supported by smoldot:
|
|
117
108
|
*
|
|
@@ -120,7 +111,6 @@ export interface Chain {
|
|
|
120
111
|
*
|
|
121
112
|
* @param rpc JSON-encoded RPC request.
|
|
122
113
|
*
|
|
123
|
-
* @throws {@link MalformedJsonRpcError} If the payload isn't valid JSON-RPC.
|
|
124
114
|
* @throws {@link QueueFullError} If the queue of JSON-RPC requests of the chain is full.
|
|
125
115
|
* @throws {@link AlreadyDestroyedError} If the chain has been removed or the client has been terminated.
|
|
126
116
|
* @throws {@link JsonRpcDisabledError} If the JSON-RPC system was disabled in the options of the chain.
|
package/dist/mjs/public-types.js
CHANGED
|
@@ -49,14 +49,6 @@ export class CrashError extends Error {
|
|
|
49
49
|
super(message);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Thrown in case a malformed JSON-RPC request is sent.
|
|
54
|
-
*/
|
|
55
|
-
export class MalformedJsonRpcError extends Error {
|
|
56
|
-
constructor() {
|
|
57
|
-
super("JSON-RPC request is malformed");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
52
|
/**
|
|
61
53
|
* Thrown in case the buffer of JSON-RPC requests is full and cannot accept any more request.
|
|
62
54
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smoldot",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Light client that connects to Polkadot and Substrate-based blockchains",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Parity Technologies <admin@parity.io>",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@types/ws": "^8.5.3",
|
|
81
81
|
"ava": "^5.0.1",
|
|
82
82
|
"dtslint": "^4.0.6",
|
|
83
|
-
"typedoc": "^0.
|
|
83
|
+
"typedoc": "^0.25.0",
|
|
84
84
|
"typescript": "^5.1.3"
|
|
85
85
|
}
|
|
86
86
|
}
|