smoldot 1.0.17 → 2.0.1

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.
Files changed (39) hide show
  1. package/dist/cjs/index-browser.d.ts +1 -1
  2. package/dist/cjs/index-browser.js +1 -2
  3. package/dist/cjs/index-deno.d.ts +1 -1
  4. package/dist/cjs/index-deno.js +1 -2
  5. package/dist/cjs/index-nodejs.d.ts +1 -1
  6. package/dist/cjs/index-nodejs.js +1 -2
  7. package/dist/cjs/internals/bytecode/wasm0.js +1 -1
  8. package/dist/cjs/internals/bytecode/wasm1.js +1 -1
  9. package/dist/cjs/internals/bytecode/wasm2.js +1 -1
  10. package/dist/cjs/internals/client.js +1 -6
  11. package/dist/cjs/internals/local-instance.js +1 -1
  12. package/dist/cjs/no-auto-bytecode-browser.d.ts +1 -1
  13. package/dist/cjs/no-auto-bytecode-browser.js +1 -2
  14. package/dist/cjs/no-auto-bytecode-deno.d.ts +1 -1
  15. package/dist/cjs/no-auto-bytecode-deno.js +1 -2
  16. package/dist/cjs/no-auto-bytecode-nodejs.d.ts +1 -1
  17. package/dist/cjs/no-auto-bytecode-nodejs.js +1 -2
  18. package/dist/cjs/public-types.d.ts +3 -13
  19. package/dist/cjs/public-types.js +1 -10
  20. package/dist/mjs/index-browser.d.ts +1 -1
  21. package/dist/mjs/index-browser.js +1 -1
  22. package/dist/mjs/index-deno.d.ts +1 -1
  23. package/dist/mjs/index-deno.js +1 -1
  24. package/dist/mjs/index-nodejs.d.ts +1 -1
  25. package/dist/mjs/index-nodejs.js +1 -1
  26. package/dist/mjs/internals/bytecode/wasm0.js +1 -1
  27. package/dist/mjs/internals/bytecode/wasm1.js +1 -1
  28. package/dist/mjs/internals/bytecode/wasm2.js +1 -1
  29. package/dist/mjs/internals/client.js +2 -7
  30. package/dist/mjs/internals/local-instance.js +1 -1
  31. package/dist/mjs/no-auto-bytecode-browser.d.ts +1 -1
  32. package/dist/mjs/no-auto-bytecode-browser.js +1 -1
  33. package/dist/mjs/no-auto-bytecode-deno.d.ts +1 -1
  34. package/dist/mjs/no-auto-bytecode-deno.js +1 -1
  35. package/dist/mjs/no-auto-bytecode-nodejs.d.ts +1 -1
  36. package/dist/mjs/no-auto-bytecode-nodejs.js +1 -1
  37. package/dist/mjs/public-types.d.ts +3 -13
  38. package/dist/mjs/public-types.js +0 -8
  39. package/package.json +2 -2
@@ -309,15 +309,10 @@ function start(options, wasmModule, platformBindings) {
309
309
  throw new public_types_js_1.AlreadyDestroyedError();
310
310
  if (options.disableJsonRpc)
311
311
  throw new public_types_js_1.JsonRpcDisabledError();
312
- if (request.length >= 64 * 1024 * 1024) {
313
- throw new public_types_js_1.MalformedJsonRpcError();
314
- }
315
- ;
316
312
  const retVal = state.instance.instance.request(request, chainId);
317
313
  switch (retVal) {
318
314
  case 0: break;
319
- case 1: throw new public_types_js_1.MalformedJsonRpcError();
320
- case 2: throw new public_types_js_1.QueueFullError();
315
+ case 1: throw new public_types_js_1.QueueFullError();
321
316
  default: throw new Error("Internal error: unknown json_rpc_send error code: " + retVal);
322
317
  }
323
318
  },
@@ -469,7 +469,7 @@ function startLocalInstance(config, wasmModule, eventCallback) {
469
469
  return {
470
470
  request: (request, chainId) => {
471
471
  if (!state.instance)
472
- return 2; // TODO: return a different error code? should be documented
472
+ return 1; // TODO: return a different error code? should be documented
473
473
  state.bufferIndices[0] = new TextEncoder().encode(request);
474
474
  return state.instance.exports.json_rpc_send(0, chainId) >>> 0;
475
475
  },
@@ -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, MalformedJsonRpcError, QueueFullError, LogCallback } from './public-types.js';
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
  *
@@ -12,14 +12,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  });
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.startWithBytecode = exports.QueueFullError = exports.MalformedJsonRpcError = exports.JsonRpcDisabledError = exports.CrashError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
15
+ exports.startWithBytecode = exports.QueueFullError = exports.JsonRpcDisabledError = exports.CrashError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
16
16
  const client_js_1 = require("./internals/client.js");
17
17
  var public_types_js_1 = require("./public-types.js");
18
18
  Object.defineProperty(exports, "AddChainError", { enumerable: true, get: function () { return public_types_js_1.AddChainError; } });
19
19
  Object.defineProperty(exports, "AlreadyDestroyedError", { enumerable: true, get: function () { return public_types_js_1.AlreadyDestroyedError; } });
20
20
  Object.defineProperty(exports, "CrashError", { enumerable: true, get: function () { return public_types_js_1.CrashError; } });
21
21
  Object.defineProperty(exports, "JsonRpcDisabledError", { enumerable: true, get: function () { return public_types_js_1.JsonRpcDisabledError; } });
22
- Object.defineProperty(exports, "MalformedJsonRpcError", { enumerable: true, get: function () { return public_types_js_1.MalformedJsonRpcError; } });
23
22
  Object.defineProperty(exports, "QueueFullError", { enumerable: true, get: function () { return public_types_js_1.QueueFullError; } });
24
23
  /**
25
24
  * Initializes a new client. This is a pre-requisite to connecting to a blockchain.
@@ -1,5 +1,5 @@
1
1
  import { Client, ClientOptionsWithBytecode } from './public-types.js';
2
- export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError, LogCallback } from './public-types.js';
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
  *
@@ -12,13 +12,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  });
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.startWithBytecode = exports.JsonRpcDisabledError = exports.QueueFullError = exports.MalformedJsonRpcError = exports.CrashError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
15
+ exports.startWithBytecode = exports.JsonRpcDisabledError = exports.QueueFullError = exports.CrashError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
16
16
  const client_js_1 = require("./internals/client.js");
17
17
  var public_types_js_1 = require("./public-types.js");
18
18
  Object.defineProperty(exports, "AddChainError", { enumerable: true, get: function () { return public_types_js_1.AddChainError; } });
19
19
  Object.defineProperty(exports, "AlreadyDestroyedError", { enumerable: true, get: function () { return public_types_js_1.AlreadyDestroyedError; } });
20
20
  Object.defineProperty(exports, "CrashError", { enumerable: true, get: function () { return public_types_js_1.CrashError; } });
21
- Object.defineProperty(exports, "MalformedJsonRpcError", { enumerable: true, get: function () { return public_types_js_1.MalformedJsonRpcError; } });
22
21
  Object.defineProperty(exports, "QueueFullError", { enumerable: true, get: function () { return public_types_js_1.QueueFullError; } });
23
22
  Object.defineProperty(exports, "JsonRpcDisabledError", { enumerable: true, get: function () { return public_types_js_1.JsonRpcDisabledError; } });
24
23
  /**
@@ -1,5 +1,5 @@
1
1
  import { Client, ClientOptionsWithBytecode } from './public-types.js';
2
- export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError, LogCallback } from './public-types.js';
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
  *
@@ -3,7 +3,7 @@
3
3
  // Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
4
4
  // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.startWithBytecode = exports.JsonRpcDisabledError = exports.QueueFullError = exports.MalformedJsonRpcError = exports.CrashError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
6
+ exports.startWithBytecode = exports.JsonRpcDisabledError = exports.QueueFullError = exports.CrashError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
7
7
  const client_js_1 = require("./internals/client.js");
8
8
  const ws_1 = require("ws");
9
9
  const node_perf_hooks_1 = require("node:perf_hooks");
@@ -13,7 +13,6 @@ var public_types_js_1 = require("./public-types.js");
13
13
  Object.defineProperty(exports, "AddChainError", { enumerable: true, get: function () { return public_types_js_1.AddChainError; } });
14
14
  Object.defineProperty(exports, "AlreadyDestroyedError", { enumerable: true, get: function () { return public_types_js_1.AlreadyDestroyedError; } });
15
15
  Object.defineProperty(exports, "CrashError", { enumerable: true, get: function () { return public_types_js_1.CrashError; } });
16
- Object.defineProperty(exports, "MalformedJsonRpcError", { enumerable: true, get: function () { return public_types_js_1.MalformedJsonRpcError; } });
17
16
  Object.defineProperty(exports, "QueueFullError", { enumerable: true, get: function () { return public_types_js_1.QueueFullError; } });
18
17
  Object.defineProperty(exports, "JsonRpcDisabledError", { enumerable: true, get: function () { return public_types_js_1.JsonRpcDisabledError; } });
19
18
  /**
@@ -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
- * A {@link MalformedJsonRpcError} is thrown if the request isn't a valid JSON-RPC request
107
- * (for example if it is not valid JSON) or if the request is unreasonably large (64 MiB at the
108
- * time of writing of this comment).
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.
@@ -3,7 +3,7 @@
3
3
  // Copyright (C) 2019-2022 Parity Technologies (UK) Ltd.
4
4
  // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.QueueFullError = exports.MalformedJsonRpcError = exports.CrashError = exports.JsonRpcDisabledError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
6
+ exports.QueueFullError = exports.CrashError = exports.JsonRpcDisabledError = exports.AlreadyDestroyedError = exports.AddChainError = void 0;
7
7
  // This program is free software: you can redistribute it and/or modify
8
8
  // it under the terms of the GNU General Public License as published by
9
9
  // the Free Software Foundation, either version 3 of the License, or
@@ -56,15 +56,6 @@ class CrashError extends Error {
56
56
  }
57
57
  }
58
58
  exports.CrashError = CrashError;
59
- /**
60
- * Thrown in case a malformed JSON-RPC request is sent.
61
- */
62
- class MalformedJsonRpcError extends Error {
63
- constructor() {
64
- super("JSON-RPC request is malformed");
65
- }
66
- }
67
- exports.MalformedJsonRpcError = MalformedJsonRpcError;
68
59
  /**
69
60
  * Thrown in case the buffer of JSON-RPC requests is full and cannot accept any more request.
70
61
  */
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="dom" />
2
2
  import { Client, ClientOptions } from './public-types.js';
3
- export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, JsonRpcDisabledError, MalformedJsonRpcError, QueueFullError, LogCallback } from './public-types.js';
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
  *
@@ -3,7 +3,7 @@
3
3
  // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
4
4
  import { startWithBytecode } from './no-auto-bytecode-browser.js';
5
5
  import { compileBytecode } from './bytecode-browser.js';
6
- export { AddChainError, AlreadyDestroyedError, CrashError, JsonRpcDisabledError, MalformedJsonRpcError, QueueFullError } from './public-types.js';
6
+ export { AddChainError, AlreadyDestroyedError, CrashError, JsonRpcDisabledError, QueueFullError } from './public-types.js';
7
7
  /**
8
8
  * Initializes a new client. This is a pre-requisite to connecting to a blockchain.
9
9
  *
@@ -1,5 +1,5 @@
1
1
  import { Client, ClientOptions } from './public-types.js';
2
- export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError, LogCallback } from './public-types.js';
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
  *
@@ -3,7 +3,7 @@
3
3
  // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
4
4
  import { startWithBytecode } from './no-auto-bytecode-deno.js';
5
5
  import { compileBytecode } from './bytecode-deno.js';
6
- export { AddChainError, AlreadyDestroyedError, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError } from './public-types.js';
6
+ export { AddChainError, AlreadyDestroyedError, CrashError, QueueFullError, JsonRpcDisabledError } from './public-types.js';
7
7
  /**
8
8
  * Initializes a new client. This is a pre-requisite to connecting to a blockchain.
9
9
  *
@@ -1,5 +1,5 @@
1
1
  import { Client, ClientOptions } from './public-types.js';
2
- export { AddChainError, AddChainOptions, AlreadyDestroyedError, Chain, Client, ClientOptions, ClientOptionsWithBytecode, SmoldotBytecode, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError, LogCallback } from './public-types.js';
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
  *
@@ -3,7 +3,7 @@
3
3
  // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
4
4
  import { startWithBytecode } from './no-auto-bytecode-nodejs.js';
5
5
  import { compileBytecode } from './bytecode-nodejs.js';
6
- export { AddChainError, AlreadyDestroyedError, CrashError, MalformedJsonRpcError, QueueFullError, JsonRpcDisabledError } from './public-types.js';
6
+ export { AddChainError, AlreadyDestroyedError, CrashError, QueueFullError, JsonRpcDisabledError } from './public-types.js';
7
7
  /**
8
8
  * Initializes a new client. This is a pre-requisite to connecting to a blockchain.
9
9
  *