@metamask-previews/json-rpc-engine 10.1.1-preview-63ea58af → 10.1.1-preview-0458fe94

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 (116) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +647 -124
  3. package/dist/JsonRpcEngine.cjs +11 -13
  4. package/dist/JsonRpcEngine.cjs.map +1 -1
  5. package/dist/JsonRpcEngine.d.cts +18 -0
  6. package/dist/JsonRpcEngine.d.cts.map +1 -1
  7. package/dist/JsonRpcEngine.d.mts +18 -0
  8. package/dist/JsonRpcEngine.d.mts.map +1 -1
  9. package/dist/JsonRpcEngine.mjs +11 -13
  10. package/dist/JsonRpcEngine.mjs.map +1 -1
  11. package/dist/asV2Middleware.cjs +48 -0
  12. package/dist/asV2Middleware.cjs.map +1 -0
  13. package/dist/asV2Middleware.d.cts +11 -0
  14. package/dist/asV2Middleware.d.cts.map +1 -0
  15. package/dist/asV2Middleware.d.mts +11 -0
  16. package/dist/asV2Middleware.d.mts.map +1 -0
  17. package/dist/asV2Middleware.mjs +44 -0
  18. package/dist/asV2Middleware.mjs.map +1 -0
  19. package/dist/createAsyncMiddleware.cjs +1 -0
  20. package/dist/createAsyncMiddleware.cjs.map +1 -1
  21. package/dist/createAsyncMiddleware.d.cts +1 -0
  22. package/dist/createAsyncMiddleware.d.cts.map +1 -1
  23. package/dist/createAsyncMiddleware.d.mts +1 -0
  24. package/dist/createAsyncMiddleware.d.mts.map +1 -1
  25. package/dist/createAsyncMiddleware.mjs +1 -0
  26. package/dist/createAsyncMiddleware.mjs.map +1 -1
  27. package/dist/createScaffoldMiddleware.cjs +1 -0
  28. package/dist/createScaffoldMiddleware.cjs.map +1 -1
  29. package/dist/createScaffoldMiddleware.d.cts +1 -0
  30. package/dist/createScaffoldMiddleware.d.cts.map +1 -1
  31. package/dist/createScaffoldMiddleware.d.mts +1 -0
  32. package/dist/createScaffoldMiddleware.d.mts.map +1 -1
  33. package/dist/createScaffoldMiddleware.mjs +1 -0
  34. package/dist/createScaffoldMiddleware.mjs.map +1 -1
  35. package/dist/idRemapMiddleware.cjs +1 -0
  36. package/dist/idRemapMiddleware.cjs.map +1 -1
  37. package/dist/idRemapMiddleware.d.cts +1 -0
  38. package/dist/idRemapMiddleware.d.cts.map +1 -1
  39. package/dist/idRemapMiddleware.d.mts +1 -0
  40. package/dist/idRemapMiddleware.d.mts.map +1 -1
  41. package/dist/idRemapMiddleware.mjs +1 -0
  42. package/dist/idRemapMiddleware.mjs.map +1 -1
  43. package/dist/index.cjs +3 -1
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.cts +1 -0
  46. package/dist/index.d.cts.map +1 -1
  47. package/dist/index.d.mts +1 -0
  48. package/dist/index.d.mts.map +1 -1
  49. package/dist/index.mjs +1 -0
  50. package/dist/index.mjs.map +1 -1
  51. package/dist/mergeMiddleware.cjs +1 -0
  52. package/dist/mergeMiddleware.cjs.map +1 -1
  53. package/dist/mergeMiddleware.d.cts +1 -0
  54. package/dist/mergeMiddleware.d.cts.map +1 -1
  55. package/dist/mergeMiddleware.d.mts +1 -0
  56. package/dist/mergeMiddleware.d.mts.map +1 -1
  57. package/dist/mergeMiddleware.mjs +1 -0
  58. package/dist/mergeMiddleware.mjs.map +1 -1
  59. package/dist/v2/JsonRpcEngineV2.cjs +213 -0
  60. package/dist/v2/JsonRpcEngineV2.cjs.map +1 -0
  61. package/dist/v2/JsonRpcEngineV2.d.cts +122 -0
  62. package/dist/v2/JsonRpcEngineV2.d.cts.map +1 -0
  63. package/dist/v2/JsonRpcEngineV2.d.mts +122 -0
  64. package/dist/v2/JsonRpcEngineV2.d.mts.map +1 -0
  65. package/dist/v2/JsonRpcEngineV2.mjs +213 -0
  66. package/dist/v2/JsonRpcEngineV2.mjs.map +1 -0
  67. package/dist/v2/JsonRpcServer.cjs +162 -0
  68. package/dist/v2/JsonRpcServer.cjs.map +1 -0
  69. package/dist/v2/JsonRpcServer.d.cts +85 -0
  70. package/dist/v2/JsonRpcServer.d.cts.map +1 -0
  71. package/dist/v2/JsonRpcServer.d.mts +85 -0
  72. package/dist/v2/JsonRpcServer.d.mts.map +1 -0
  73. package/dist/v2/JsonRpcServer.mjs +158 -0
  74. package/dist/v2/JsonRpcServer.mjs.map +1 -0
  75. package/dist/v2/MiddlewareContext.cjs +66 -0
  76. package/dist/v2/MiddlewareContext.cjs.map +1 -0
  77. package/dist/v2/MiddlewareContext.d.cts +95 -0
  78. package/dist/v2/MiddlewareContext.d.cts.map +1 -0
  79. package/dist/v2/MiddlewareContext.d.mts +95 -0
  80. package/dist/v2/MiddlewareContext.d.mts.map +1 -0
  81. package/dist/v2/MiddlewareContext.mjs +62 -0
  82. package/dist/v2/MiddlewareContext.mjs.map +1 -0
  83. package/dist/v2/asLegacyMiddleware.cjs +39 -0
  84. package/dist/v2/asLegacyMiddleware.cjs.map +1 -0
  85. package/dist/v2/asLegacyMiddleware.d.cts +11 -0
  86. package/dist/v2/asLegacyMiddleware.d.cts.map +1 -0
  87. package/dist/v2/asLegacyMiddleware.d.mts +11 -0
  88. package/dist/v2/asLegacyMiddleware.d.mts.map +1 -0
  89. package/dist/v2/asLegacyMiddleware.mjs +35 -0
  90. package/dist/v2/asLegacyMiddleware.mjs.map +1 -0
  91. package/dist/v2/compatibility-utils.cjs +151 -0
  92. package/dist/v2/compatibility-utils.cjs.map +1 -0
  93. package/dist/v2/compatibility-utils.d.cts +75 -0
  94. package/dist/v2/compatibility-utils.d.cts.map +1 -0
  95. package/dist/v2/compatibility-utils.d.mts +75 -0
  96. package/dist/v2/compatibility-utils.d.mts.map +1 -0
  97. package/dist/v2/compatibility-utils.mjs +142 -0
  98. package/dist/v2/compatibility-utils.mjs.map +1 -0
  99. package/dist/v2/index.cjs +29 -0
  100. package/dist/v2/index.cjs.map +1 -0
  101. package/dist/v2/index.d.cts +8 -0
  102. package/dist/v2/index.d.cts.map +1 -0
  103. package/dist/v2/index.d.mts +8 -0
  104. package/dist/v2/index.d.mts.map +1 -0
  105. package/dist/v2/index.mjs +6 -0
  106. package/dist/v2/index.mjs.map +1 -0
  107. package/dist/v2/utils.cjs +41 -0
  108. package/dist/v2/utils.cjs.map +1 -0
  109. package/dist/v2/utils.d.cts +35 -0
  110. package/dist/v2/utils.d.cts.map +1 -0
  111. package/dist/v2/utils.d.mts +35 -0
  112. package/dist/v2/utils.d.mts.map +1 -0
  113. package/dist/v2/utils.mjs +34 -0
  114. package/dist/v2/utils.mjs.map +1 -0
  115. package/package.json +17 -3
  116. package/v2.js +3 -0
@@ -0,0 +1,11 @@
1
+ import { type JsonRpcParams, type JsonRpcRequest } from "@metamask/utils";
2
+ import type { JsonRpcEngine } from "./JsonRpcEngine.mjs";
3
+ import type { JsonRpcMiddleware } from "./v2/JsonRpcEngineV2.mjs";
4
+ /**
5
+ * Convert a legacy {@link JsonRpcEngine} into a {@link JsonRpcEngineV2} middleware.
6
+ *
7
+ * @param engine - The legacy engine to convert.
8
+ * @returns The {@link JsonRpcEngineV2} middleware.
9
+ */
10
+ export declare function asV2Middleware<Params extends JsonRpcParams, Request extends JsonRpcRequest<Params>>(engine: JsonRpcEngine): JsonRpcMiddleware<Request>;
11
+ //# sourceMappingURL=asV2Middleware.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asV2Middleware.d.mts","sourceRoot":"","sources":["../src/asV2Middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,wBAAwB;AAEzB,OAAO,KAAK,EACV,aAAa,EAGd,4BAAwB;AAQzB,OAAO,KAAK,EAIV,iBAAiB,EAElB,iCAA6B;AAE9B;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,SAAS,aAAa,EAC5B,OAAO,SAAS,cAAc,CAAC,MAAM,CAAC,EACtC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAsCnD"}
@@ -0,0 +1,44 @@
1
+ import { serializeError } from "@metamask/rpc-errors";
2
+ import { hasProperty } from "@metamask/utils";
3
+ import { deepClone, fromLegacyRequest, propagateToContext, propagateToRequest, unserializeError } from "./v2/compatibility-utils.mjs";
4
+ /**
5
+ * Convert a legacy {@link JsonRpcEngine} into a {@link JsonRpcEngineV2} middleware.
6
+ *
7
+ * @param engine - The legacy engine to convert.
8
+ * @returns The {@link JsonRpcEngineV2} middleware.
9
+ */
10
+ export function asV2Middleware(engine) {
11
+ const middleware = engine.asMiddleware();
12
+ return async ({ request, context, next }) => {
13
+ const req = deepClone(request);
14
+ propagateToRequest(req, context);
15
+ const response = await new Promise((resolve) => {
16
+ // The result or error property will be set by the legacy engine
17
+ // middleware.
18
+ const res = {
19
+ jsonrpc: '2.0',
20
+ id: req.id,
21
+ };
22
+ const end = (error) => {
23
+ if (error !== undefined) {
24
+ res.error = serializeError(error);
25
+ }
26
+ resolve(res);
27
+ };
28
+ // We know from the implementation of JsonRpcEngine.asMiddleware() that
29
+ // legacyNext will always be passed a callback, so cb can never be
30
+ // undefined.
31
+ const legacyNext = ((cb) => cb(end));
32
+ middleware(req, res, legacyNext, end);
33
+ });
34
+ propagateToContext(req, context);
35
+ if (hasProperty(response, 'error')) {
36
+ throw unserializeError(response.error);
37
+ }
38
+ else if (hasProperty(response, 'result')) {
39
+ return response.result;
40
+ }
41
+ return next(fromLegacyRequest(req));
42
+ };
43
+ }
44
+ //# sourceMappingURL=asV2Middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asV2Middleware.mjs","sourceRoot":"","sources":["../src/asV2Middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAA6B;AAEtD,OAAO,EACL,WAAW,EAGZ,wBAAwB;AAOzB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EACjB,qCAAiC;AASlC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAG5B,MAAqB;IACrB,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IACzC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAA2B,CAAC;QACzD,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAEjC,MAAM,QAAQ,GAAG,MAAM,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9D,gEAAgE;YAChE,cAAc;YACd,MAAM,GAAG,GAAG;gBACV,OAAO,EAAE,KAAc;gBACvB,EAAE,EAAE,GAAG,CAAC,EAAE;aACQ,CAAC;YAErB,MAAM,GAAG,GAA6B,CAAC,KAAK,EAAE,EAAE;gBAC9C,IAAI,KAAK,KAAK,SAAS,EAAE;oBACtB,GAAsB,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;iBACvD;gBACD,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC,CAAC;YAEF,uEAAuE;YACvE,kEAAkE;YAClE,aAAa;YACb,MAAM,UAAU,GAAG,CAAC,CAAC,EAA4B,EAAE,EAAE,CACnD,EAAE,CAAC,GAAG,CAAC,CAA8B,CAAC;YAExC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QACH,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAEjC,IAAI,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;YAClC,MAAM,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxC;aAAM,IAAI,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE;YAC1C,OAAO,QAAQ,CAAC,MAAmC,CAAC;SACrD;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAc,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { serializeError } from '@metamask/rpc-errors';\nimport type { JsonRpcFailure, JsonRpcResponse } from '@metamask/utils';\nimport {\n hasProperty,\n type JsonRpcParams,\n type JsonRpcRequest,\n} from '@metamask/utils';\n\nimport type {\n JsonRpcEngine,\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from './JsonRpcEngine';\nimport {\n deepClone,\n fromLegacyRequest,\n propagateToContext,\n propagateToRequest,\n unserializeError,\n} from './v2/compatibility-utils';\nimport type {\n // JsonRpcEngineV2 is used in docs.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n JsonRpcEngineV2,\n JsonRpcMiddleware,\n ResultConstraint,\n} from './v2/JsonRpcEngineV2';\n\n/**\n * Convert a legacy {@link JsonRpcEngine} into a {@link JsonRpcEngineV2} middleware.\n *\n * @param engine - The legacy engine to convert.\n * @returns The {@link JsonRpcEngineV2} middleware.\n */\nexport function asV2Middleware<\n Params extends JsonRpcParams,\n Request extends JsonRpcRequest<Params>,\n>(engine: JsonRpcEngine): JsonRpcMiddleware<Request> {\n const middleware = engine.asMiddleware();\n return async ({ request, context, next }) => {\n const req = deepClone(request) as JsonRpcRequest<Params>;\n propagateToRequest(req, context);\n\n const response = await new Promise<JsonRpcResponse>((resolve) => {\n // The result or error property will be set by the legacy engine\n // middleware.\n const res = {\n jsonrpc: '2.0' as const,\n id: req.id,\n } as JsonRpcResponse;\n\n const end: JsonRpcEngineEndCallback = (error) => {\n if (error !== undefined) {\n (res as JsonRpcFailure).error = serializeError(error);\n }\n resolve(res);\n };\n\n // We know from the implementation of JsonRpcEngine.asMiddleware() that\n // legacyNext will always be passed a callback, so cb can never be\n // undefined.\n const legacyNext = ((cb: JsonRpcEngineEndCallback) =>\n cb(end)) as JsonRpcEngineNextCallback;\n\n middleware(req, res, legacyNext, end);\n });\n propagateToContext(req, context);\n\n if (hasProperty(response, 'error')) {\n throw unserializeError(response.error);\n } else if (hasProperty(response, 'result')) {\n return response.result as ResultConstraint<Request>;\n }\n return next(fromLegacyRequest(req as Request));\n };\n}\n"]}
@@ -18,6 +18,7 @@ exports.createAsyncMiddleware = void 0;
18
18
  * The return handler will always be called. Its resolution of the promise
19
19
  * enables the control flow described above.
20
20
  *
21
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
21
22
  * @param asyncMiddleware - The asynchronous middleware function to wrap.
22
23
  * @returns The wrapped asynchronous middleware function, ready to be consumed
23
24
  * by JsonRpcEngine.
@@ -1 +1 @@
1
- {"version":3,"file":"createAsyncMiddleware.cjs","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":";;;AAyBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,qBAAqB,CAInC,eAAuD;IAEvD,kEAAkE;IAClE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5C,+CAA+C;QAC/C,qDAAqD;QACrD,kBAAkB;QAClB,IAAI,kBAA8B,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAChD,kBAAkB,GAAG,OAAO,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,IAAI,qBAAqB,GAAY,IAAI,CAAC;QAC1C,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,0DAA0D;QAC1D,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,aAAa,GAAG,IAAI,CAAC;YAErB,uEAAuE;YACvE,yDAAyD;YACzD,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;gBACjC,4DAA4D;gBAC5D,qBAAqB,GAAG,yBAAyB,CAAC;gBAClD,kBAAkB,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC;QAEF,IAAI;YACF,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YAEpD,IAAI,aAAa,EAAE;gBACjB,MAAM,WAAW,CAAC,CAAC,kDAAkD;gBACpE,qBAA+C,CAAC,IAAI,CAAC,CAAC;aACxD;iBAAM;gBACL,GAAG,CAAC,IAAI,CAAC,CAAC;aACX;SACF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,qBAAqB,EAAE;gBACxB,qBAA+C,CAAC,KAAK,CAAC,CAAC;aACzD;iBAAM;gBACL,GAAG,CAAC,KAAK,CAAC,CAAC;aACZ;SACF;IACH,CAAC,CAAC;AACJ,CAAC;AAlDD,sDAkDC","sourcesContent":["import type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n JsonRpcEngineReturnHandler,\n JsonRpcMiddleware,\n} from './JsonRpcEngine';\n\nexport type AsyncJsonRpcEngineNextCallback = () => Promise<void>;\n\nexport type AsyncJsonrpcMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n> = (\n request: JsonRpcRequest<Params>,\n response: PendingJsonRpcResponse<Result>,\n next: AsyncJsonRpcEngineNextCallback,\n) => Promise<void>;\n\ntype ReturnHandlerCallback = Parameters<JsonRpcEngineReturnHandler>[0];\n\n/**\n * JsonRpcEngine only accepts callback-based middleware directly.\n * createAsyncMiddleware exists to enable consumers to pass in async middleware\n * functions.\n *\n * Async middleware have no \"end\" function. Instead, they \"end\" if they return\n * without calling \"next\". Rather than passing in explicit return handlers,\n * async middleware can simply await \"next\", and perform operations on the\n * response object when execution resumes.\n *\n * To accomplish this, createAsyncMiddleware passes the async middleware a\n * wrapped \"next\" function. That function calls the internal JsonRpcEngine\n * \"next\" function with a return handler that resolves a promise when called.\n *\n * The return handler will always be called. Its resolution of the promise\n * enables the control flow described above.\n *\n * @param asyncMiddleware - The asynchronous middleware function to wrap.\n * @returns The wrapped asynchronous middleware function, ready to be consumed\n * by JsonRpcEngine.\n */\nexport function createAsyncMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n>(\n asyncMiddleware: AsyncJsonrpcMiddleware<Params, Result>,\n): JsonRpcMiddleware<Params, Result> {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async (request, response, next, end) => {\n // nextPromise is the key to the implementation\n // it is resolved by the return handler passed to the\n // \"next\" function\n let resolveNextPromise: () => void;\n const nextPromise = new Promise<void>((resolve) => {\n resolveNextPromise = resolve;\n });\n\n let returnHandlerCallback: unknown = null;\n let nextWasCalled = false;\n\n // This will be called by the consumer's async middleware.\n const asyncNext = async () => {\n nextWasCalled = true;\n\n // We pass a return handler to next(). When it is called by the engine,\n // the consumer's async middleware will resume executing.\n next((runReturnHandlersCallback) => {\n // This callback comes from JsonRpcEngine._runReturnHandlers\n returnHandlerCallback = runReturnHandlersCallback;\n resolveNextPromise();\n });\n return nextPromise;\n };\n\n try {\n await asyncMiddleware(request, response, asyncNext);\n\n if (nextWasCalled) {\n await nextPromise; // we must wait until the return handler is called\n (returnHandlerCallback as ReturnHandlerCallback)(null);\n } else {\n end(null);\n }\n } catch (error) {\n if (returnHandlerCallback) {\n (returnHandlerCallback as ReturnHandlerCallback)(error);\n } else {\n end(error);\n }\n }\n };\n}\n"]}
1
+ {"version":3,"file":"createAsyncMiddleware.cjs","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":";;;AAyBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,qBAAqB,CAInC,eAAuD;IAEvD,kEAAkE;IAClE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5C,+CAA+C;QAC/C,qDAAqD;QACrD,kBAAkB;QAClB,IAAI,kBAA8B,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAChD,kBAAkB,GAAG,OAAO,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,IAAI,qBAAqB,GAAY,IAAI,CAAC;QAC1C,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,0DAA0D;QAC1D,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,aAAa,GAAG,IAAI,CAAC;YAErB,uEAAuE;YACvE,yDAAyD;YACzD,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;gBACjC,4DAA4D;gBAC5D,qBAAqB,GAAG,yBAAyB,CAAC;gBAClD,kBAAkB,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC;QAEF,IAAI;YACF,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YAEpD,IAAI,aAAa,EAAE;gBACjB,MAAM,WAAW,CAAC,CAAC,kDAAkD;gBACpE,qBAA+C,CAAC,IAAI,CAAC,CAAC;aACxD;iBAAM;gBACL,GAAG,CAAC,IAAI,CAAC,CAAC;aACX;SACF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,qBAAqB,EAAE;gBACxB,qBAA+C,CAAC,KAAK,CAAC,CAAC;aACzD;iBAAM;gBACL,GAAG,CAAC,KAAK,CAAC,CAAC;aACZ;SACF;IACH,CAAC,CAAC;AACJ,CAAC;AAlDD,sDAkDC","sourcesContent":["import type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n JsonRpcEngineReturnHandler,\n JsonRpcMiddleware,\n} from './JsonRpcEngine';\n\nexport type AsyncJsonRpcEngineNextCallback = () => Promise<void>;\n\nexport type AsyncJsonrpcMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n> = (\n request: JsonRpcRequest<Params>,\n response: PendingJsonRpcResponse<Result>,\n next: AsyncJsonRpcEngineNextCallback,\n) => Promise<void>;\n\ntype ReturnHandlerCallback = Parameters<JsonRpcEngineReturnHandler>[0];\n\n/**\n * JsonRpcEngine only accepts callback-based middleware directly.\n * createAsyncMiddleware exists to enable consumers to pass in async middleware\n * functions.\n *\n * Async middleware have no \"end\" function. Instead, they \"end\" if they return\n * without calling \"next\". Rather than passing in explicit return handlers,\n * async middleware can simply await \"next\", and perform operations on the\n * response object when execution resumes.\n *\n * To accomplish this, createAsyncMiddleware passes the async middleware a\n * wrapped \"next\" function. That function calls the internal JsonRpcEngine\n * \"next\" function with a return handler that resolves a promise when called.\n *\n * The return handler will always be called. Its resolution of the promise\n * enables the control flow described above.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @param asyncMiddleware - The asynchronous middleware function to wrap.\n * @returns The wrapped asynchronous middleware function, ready to be consumed\n * by JsonRpcEngine.\n */\nexport function createAsyncMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n>(\n asyncMiddleware: AsyncJsonrpcMiddleware<Params, Result>,\n): JsonRpcMiddleware<Params, Result> {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async (request, response, next, end) => {\n // nextPromise is the key to the implementation\n // it is resolved by the return handler passed to the\n // \"next\" function\n let resolveNextPromise: () => void;\n const nextPromise = new Promise<void>((resolve) => {\n resolveNextPromise = resolve;\n });\n\n let returnHandlerCallback: unknown = null;\n let nextWasCalled = false;\n\n // This will be called by the consumer's async middleware.\n const asyncNext = async () => {\n nextWasCalled = true;\n\n // We pass a return handler to next(). When it is called by the engine,\n // the consumer's async middleware will resume executing.\n next((runReturnHandlersCallback) => {\n // This callback comes from JsonRpcEngine._runReturnHandlers\n returnHandlerCallback = runReturnHandlersCallback;\n resolveNextPromise();\n });\n return nextPromise;\n };\n\n try {\n await asyncMiddleware(request, response, asyncNext);\n\n if (nextWasCalled) {\n await nextPromise; // we must wait until the return handler is called\n (returnHandlerCallback as ReturnHandlerCallback)(null);\n } else {\n end(null);\n }\n } catch (error) {\n if (returnHandlerCallback) {\n (returnHandlerCallback as ReturnHandlerCallback)(error);\n } else {\n end(error);\n }\n }\n };\n}\n"]}
@@ -19,6 +19,7 @@ export type AsyncJsonrpcMiddleware<Params extends JsonRpcParams, Result extends
19
19
  * The return handler will always be called. Its resolution of the promise
20
20
  * enables the control flow described above.
21
21
  *
22
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
22
23
  * @param asyncMiddleware - The asynchronous middleware function to wrap.
23
24
  * @returns The wrapped asynchronous middleware function, ready to be consumed
24
25
  * by JsonRpcEngine.
@@ -1 +1 @@
1
- {"version":3,"file":"createAsyncMiddleware.d.cts","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,wBAAwB;AAEzB,OAAO,KAAK,EAEV,iBAAiB,EAClB,4BAAwB;AAEzB,MAAM,MAAM,8BAA8B,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,MAAM,sBAAsB,CAChC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,CACF,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAC/B,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,EACxC,IAAI,EAAE,8BAA8B,KACjC,OAAO,CAAC,IAAI,CAAC,CAAC;AAInB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,EAEnB,eAAe,EAAE,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,GACtD,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6CnC"}
1
+ {"version":3,"file":"createAsyncMiddleware.d.cts","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,wBAAwB;AAEzB,OAAO,KAAK,EAEV,iBAAiB,EAClB,4BAAwB;AAEzB,MAAM,MAAM,8BAA8B,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,MAAM,sBAAsB,CAChC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,CACF,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAC/B,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,EACxC,IAAI,EAAE,8BAA8B,KACjC,OAAO,CAAC,IAAI,CAAC,CAAC;AAInB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,EAEnB,eAAe,EAAE,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,GACtD,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6CnC"}
@@ -19,6 +19,7 @@ export type AsyncJsonrpcMiddleware<Params extends JsonRpcParams, Result extends
19
19
  * The return handler will always be called. Its resolution of the promise
20
20
  * enables the control flow described above.
21
21
  *
22
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
22
23
  * @param asyncMiddleware - The asynchronous middleware function to wrap.
23
24
  * @returns The wrapped asynchronous middleware function, ready to be consumed
24
25
  * by JsonRpcEngine.
@@ -1 +1 @@
1
- {"version":3,"file":"createAsyncMiddleware.d.mts","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,wBAAwB;AAEzB,OAAO,KAAK,EAEV,iBAAiB,EAClB,4BAAwB;AAEzB,MAAM,MAAM,8BAA8B,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,MAAM,sBAAsB,CAChC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,CACF,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAC/B,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,EACxC,IAAI,EAAE,8BAA8B,KACjC,OAAO,CAAC,IAAI,CAAC,CAAC;AAInB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,EAEnB,eAAe,EAAE,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,GACtD,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6CnC"}
1
+ {"version":3,"file":"createAsyncMiddleware.d.mts","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,wBAAwB;AAEzB,OAAO,KAAK,EAEV,iBAAiB,EAClB,4BAAwB;AAEzB,MAAM,MAAM,8BAA8B,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,MAAM,sBAAsB,CAChC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,CACF,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAC/B,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,EACxC,IAAI,EAAE,8BAA8B,KACjC,OAAO,CAAC,IAAI,CAAC,CAAC;AAInB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,EAEnB,eAAe,EAAE,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,GACtD,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6CnC"}
@@ -15,6 +15,7 @@
15
15
  * The return handler will always be called. Its resolution of the promise
16
16
  * enables the control flow described above.
17
17
  *
18
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
18
19
  * @param asyncMiddleware - The asynchronous middleware function to wrap.
19
20
  * @returns The wrapped asynchronous middleware function, ready to be consumed
20
21
  * by JsonRpcEngine.
@@ -1 +1 @@
1
- {"version":3,"file":"createAsyncMiddleware.mjs","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,qBAAqB,CAInC,eAAuD;IAEvD,kEAAkE;IAClE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5C,+CAA+C;QAC/C,qDAAqD;QACrD,kBAAkB;QAClB,IAAI,kBAA8B,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAChD,kBAAkB,GAAG,OAAO,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,IAAI,qBAAqB,GAAY,IAAI,CAAC;QAC1C,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,0DAA0D;QAC1D,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,aAAa,GAAG,IAAI,CAAC;YAErB,uEAAuE;YACvE,yDAAyD;YACzD,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;gBACjC,4DAA4D;gBAC5D,qBAAqB,GAAG,yBAAyB,CAAC;gBAClD,kBAAkB,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC;QAEF,IAAI;YACF,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YAEpD,IAAI,aAAa,EAAE;gBACjB,MAAM,WAAW,CAAC,CAAC,kDAAkD;gBACpE,qBAA+C,CAAC,IAAI,CAAC,CAAC;aACxD;iBAAM;gBACL,GAAG,CAAC,IAAI,CAAC,CAAC;aACX;SACF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,qBAAqB,EAAE;gBACxB,qBAA+C,CAAC,KAAK,CAAC,CAAC;aACzD;iBAAM;gBACL,GAAG,CAAC,KAAK,CAAC,CAAC;aACZ;SACF;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n JsonRpcEngineReturnHandler,\n JsonRpcMiddleware,\n} from './JsonRpcEngine';\n\nexport type AsyncJsonRpcEngineNextCallback = () => Promise<void>;\n\nexport type AsyncJsonrpcMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n> = (\n request: JsonRpcRequest<Params>,\n response: PendingJsonRpcResponse<Result>,\n next: AsyncJsonRpcEngineNextCallback,\n) => Promise<void>;\n\ntype ReturnHandlerCallback = Parameters<JsonRpcEngineReturnHandler>[0];\n\n/**\n * JsonRpcEngine only accepts callback-based middleware directly.\n * createAsyncMiddleware exists to enable consumers to pass in async middleware\n * functions.\n *\n * Async middleware have no \"end\" function. Instead, they \"end\" if they return\n * without calling \"next\". Rather than passing in explicit return handlers,\n * async middleware can simply await \"next\", and perform operations on the\n * response object when execution resumes.\n *\n * To accomplish this, createAsyncMiddleware passes the async middleware a\n * wrapped \"next\" function. That function calls the internal JsonRpcEngine\n * \"next\" function with a return handler that resolves a promise when called.\n *\n * The return handler will always be called. Its resolution of the promise\n * enables the control flow described above.\n *\n * @param asyncMiddleware - The asynchronous middleware function to wrap.\n * @returns The wrapped asynchronous middleware function, ready to be consumed\n * by JsonRpcEngine.\n */\nexport function createAsyncMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n>(\n asyncMiddleware: AsyncJsonrpcMiddleware<Params, Result>,\n): JsonRpcMiddleware<Params, Result> {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async (request, response, next, end) => {\n // nextPromise is the key to the implementation\n // it is resolved by the return handler passed to the\n // \"next\" function\n let resolveNextPromise: () => void;\n const nextPromise = new Promise<void>((resolve) => {\n resolveNextPromise = resolve;\n });\n\n let returnHandlerCallback: unknown = null;\n let nextWasCalled = false;\n\n // This will be called by the consumer's async middleware.\n const asyncNext = async () => {\n nextWasCalled = true;\n\n // We pass a return handler to next(). When it is called by the engine,\n // the consumer's async middleware will resume executing.\n next((runReturnHandlersCallback) => {\n // This callback comes from JsonRpcEngine._runReturnHandlers\n returnHandlerCallback = runReturnHandlersCallback;\n resolveNextPromise();\n });\n return nextPromise;\n };\n\n try {\n await asyncMiddleware(request, response, asyncNext);\n\n if (nextWasCalled) {\n await nextPromise; // we must wait until the return handler is called\n (returnHandlerCallback as ReturnHandlerCallback)(null);\n } else {\n end(null);\n }\n } catch (error) {\n if (returnHandlerCallback) {\n (returnHandlerCallback as ReturnHandlerCallback)(error);\n } else {\n end(error);\n }\n }\n };\n}\n"]}
1
+ {"version":3,"file":"createAsyncMiddleware.mjs","sourceRoot":"","sources":["../src/createAsyncMiddleware.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,qBAAqB,CAInC,eAAuD;IAEvD,kEAAkE;IAClE,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5C,+CAA+C;QAC/C,qDAAqD;QACrD,kBAAkB;QAClB,IAAI,kBAA8B,CAAC;QACnC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAChD,kBAAkB,GAAG,OAAO,CAAC;QAC/B,CAAC,CAAC,CAAC;QAEH,IAAI,qBAAqB,GAAY,IAAI,CAAC;QAC1C,IAAI,aAAa,GAAG,KAAK,CAAC;QAE1B,0DAA0D;QAC1D,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,aAAa,GAAG,IAAI,CAAC;YAErB,uEAAuE;YACvE,yDAAyD;YACzD,IAAI,CAAC,CAAC,yBAAyB,EAAE,EAAE;gBACjC,4DAA4D;gBAC5D,qBAAqB,GAAG,yBAAyB,CAAC;gBAClD,kBAAkB,EAAE,CAAC;YACvB,CAAC,CAAC,CAAC;YACH,OAAO,WAAW,CAAC;QACrB,CAAC,CAAC;QAEF,IAAI;YACF,MAAM,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;YAEpD,IAAI,aAAa,EAAE;gBACjB,MAAM,WAAW,CAAC,CAAC,kDAAkD;gBACpE,qBAA+C,CAAC,IAAI,CAAC,CAAC;aACxD;iBAAM;gBACL,GAAG,CAAC,IAAI,CAAC,CAAC;aACX;SACF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,qBAAqB,EAAE;gBACxB,qBAA+C,CAAC,KAAK,CAAC,CAAC;aACzD;iBAAM;gBACL,GAAG,CAAC,KAAK,CAAC,CAAC;aACZ;SACF;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n JsonRpcEngineReturnHandler,\n JsonRpcMiddleware,\n} from './JsonRpcEngine';\n\nexport type AsyncJsonRpcEngineNextCallback = () => Promise<void>;\n\nexport type AsyncJsonrpcMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n> = (\n request: JsonRpcRequest<Params>,\n response: PendingJsonRpcResponse<Result>,\n next: AsyncJsonRpcEngineNextCallback,\n) => Promise<void>;\n\ntype ReturnHandlerCallback = Parameters<JsonRpcEngineReturnHandler>[0];\n\n/**\n * JsonRpcEngine only accepts callback-based middleware directly.\n * createAsyncMiddleware exists to enable consumers to pass in async middleware\n * functions.\n *\n * Async middleware have no \"end\" function. Instead, they \"end\" if they return\n * without calling \"next\". Rather than passing in explicit return handlers,\n * async middleware can simply await \"next\", and perform operations on the\n * response object when execution resumes.\n *\n * To accomplish this, createAsyncMiddleware passes the async middleware a\n * wrapped \"next\" function. That function calls the internal JsonRpcEngine\n * \"next\" function with a return handler that resolves a promise when called.\n *\n * The return handler will always be called. Its resolution of the promise\n * enables the control flow described above.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @param asyncMiddleware - The asynchronous middleware function to wrap.\n * @returns The wrapped asynchronous middleware function, ready to be consumed\n * by JsonRpcEngine.\n */\nexport function createAsyncMiddleware<\n Params extends JsonRpcParams,\n Result extends Json,\n>(\n asyncMiddleware: AsyncJsonrpcMiddleware<Params, Result>,\n): JsonRpcMiddleware<Params, Result> {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async (request, response, next, end) => {\n // nextPromise is the key to the implementation\n // it is resolved by the return handler passed to the\n // \"next\" function\n let resolveNextPromise: () => void;\n const nextPromise = new Promise<void>((resolve) => {\n resolveNextPromise = resolve;\n });\n\n let returnHandlerCallback: unknown = null;\n let nextWasCalled = false;\n\n // This will be called by the consumer's async middleware.\n const asyncNext = async () => {\n nextWasCalled = true;\n\n // We pass a return handler to next(). When it is called by the engine,\n // the consumer's async middleware will resume executing.\n next((runReturnHandlersCallback) => {\n // This callback comes from JsonRpcEngine._runReturnHandlers\n returnHandlerCallback = runReturnHandlersCallback;\n resolveNextPromise();\n });\n return nextPromise;\n };\n\n try {\n await asyncMiddleware(request, response, asyncNext);\n\n if (nextWasCalled) {\n await nextPromise; // we must wait until the return handler is called\n (returnHandlerCallback as ReturnHandlerCallback)(null);\n } else {\n end(null);\n }\n } catch (error) {\n if (returnHandlerCallback) {\n (returnHandlerCallback as ReturnHandlerCallback)(error);\n } else {\n end(error);\n }\n }\n };\n}\n"]}
@@ -7,6 +7,7 @@ exports.createScaffoldMiddleware = void 0;
7
7
  * object is requested, this middleware will pass it to the corresponding
8
8
  * handler and return the result.
9
9
  *
10
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
10
11
  * @param handlers - The RPC method handler functions.
11
12
  * @returns The scaffold middleware function.
12
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createScaffoldMiddleware.cjs","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":";;;AASA;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,QAExC;IACC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,wBAAwB;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,IAAI,EAAE,CAAC;SACf;QAED,uCAAuC;QACvC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SACrC;QACD,gDAAgD;QAC/C,GAAsB,CAAC,MAAM,GAAG,OAAO,CAAC;QACzC,OAAO,GAAG,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAlBD,4DAkBC","sourcesContent":["import type { Json, JsonRpcParams, JsonRpcSuccess } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\ntype ScaffoldMiddlewareHandler<\n Params extends JsonRpcParams,\n Result extends Json,\n> = JsonRpcMiddleware<Params, Result> | Json;\n\n/**\n * Creates a middleware function from an object of RPC method handler functions,\n * keyed to particular method names. If a method corresponding to a key of this\n * object is requested, this middleware will pass it to the corresponding\n * handler and return the result.\n *\n * @param handlers - The RPC method handler functions.\n * @returns The scaffold middleware function.\n */\nexport function createScaffoldMiddleware(handlers: {\n [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;\n}): JsonRpcMiddleware<JsonRpcParams, Json> {\n return (req, res, next, end) => {\n const handler = handlers[req.method];\n // if no handler, return\n if (handler === undefined) {\n return next();\n }\n\n // if handler is fn, call as middleware\n if (typeof handler === 'function') {\n return handler(req, res, next, end);\n }\n // if handler is some other value, use as result\n (res as JsonRpcSuccess).result = handler;\n return end();\n };\n}\n"]}
1
+ {"version":3,"file":"createScaffoldMiddleware.cjs","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":";;;AASA;;;;;;;;;GASG;AACH,SAAgB,wBAAwB,CAAC,QAExC;IACC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,wBAAwB;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,IAAI,EAAE,CAAC;SACf;QAED,uCAAuC;QACvC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SACrC;QACD,gDAAgD;QAC/C,GAAsB,CAAC,MAAM,GAAG,OAAO,CAAC;QACzC,OAAO,GAAG,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAlBD,4DAkBC","sourcesContent":["import type { Json, JsonRpcParams, JsonRpcSuccess } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\ntype ScaffoldMiddlewareHandler<\n Params extends JsonRpcParams,\n Result extends Json,\n> = JsonRpcMiddleware<Params, Result> | Json;\n\n/**\n * Creates a middleware function from an object of RPC method handler functions,\n * keyed to particular method names. If a method corresponding to a key of this\n * object is requested, this middleware will pass it to the corresponding\n * handler and return the result.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @param handlers - The RPC method handler functions.\n * @returns The scaffold middleware function.\n */\nexport function createScaffoldMiddleware(handlers: {\n [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;\n}): JsonRpcMiddleware<JsonRpcParams, Json> {\n return (req, res, next, end) => {\n const handler = handlers[req.method];\n // if no handler, return\n if (handler === undefined) {\n return next();\n }\n\n // if handler is fn, call as middleware\n if (typeof handler === 'function') {\n return handler(req, res, next, end);\n }\n // if handler is some other value, use as result\n (res as JsonRpcSuccess).result = handler;\n return end();\n };\n}\n"]}
@@ -7,6 +7,7 @@ type ScaffoldMiddlewareHandler<Params extends JsonRpcParams, Result extends Json
7
7
  * object is requested, this middleware will pass it to the corresponding
8
8
  * handler and return the result.
9
9
  *
10
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
10
11
  * @param handlers - The RPC method handler functions.
11
12
  * @returns The scaffold middleware function.
12
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createScaffoldMiddleware.d.cts","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAkB,wBAAwB;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD,KAAK,yBAAyB,CAC5B,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACtE,GAAG,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,CAgBzC"}
1
+ {"version":3,"file":"createScaffoldMiddleware.d.cts","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAkB,wBAAwB;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD,KAAK,yBAAyB,CAC5B,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACtE,GAAG,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,CAgBzC"}
@@ -7,6 +7,7 @@ type ScaffoldMiddlewareHandler<Params extends JsonRpcParams, Result extends Json
7
7
  * object is requested, this middleware will pass it to the corresponding
8
8
  * handler and return the result.
9
9
  *
10
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
10
11
  * @param handlers - The RPC method handler functions.
11
12
  * @returns The scaffold middleware function.
12
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createScaffoldMiddleware.d.mts","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAkB,wBAAwB;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD,KAAK,yBAAyB,CAC5B,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACtE,GAAG,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,CAgBzC"}
1
+ {"version":3,"file":"createScaffoldMiddleware.d.mts","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAkB,wBAAwB;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD,KAAK,yBAAyB,CAC5B,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACtE,GAAG,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,CAgBzC"}
@@ -4,6 +4,7 @@
4
4
  * object is requested, this middleware will pass it to the corresponding
5
5
  * handler and return the result.
6
6
  *
7
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
7
8
  * @param handlers - The RPC method handler functions.
8
9
  * @returns The scaffold middleware function.
9
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createScaffoldMiddleware.mjs","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AASA;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAExC;IACC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,wBAAwB;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,IAAI,EAAE,CAAC;SACf;QAED,uCAAuC;QACvC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SACrC;QACD,gDAAgD;QAC/C,GAAsB,CAAC,MAAM,GAAG,OAAO,CAAC;QACzC,OAAO,GAAG,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Json, JsonRpcParams, JsonRpcSuccess } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\ntype ScaffoldMiddlewareHandler<\n Params extends JsonRpcParams,\n Result extends Json,\n> = JsonRpcMiddleware<Params, Result> | Json;\n\n/**\n * Creates a middleware function from an object of RPC method handler functions,\n * keyed to particular method names. If a method corresponding to a key of this\n * object is requested, this middleware will pass it to the corresponding\n * handler and return the result.\n *\n * @param handlers - The RPC method handler functions.\n * @returns The scaffold middleware function.\n */\nexport function createScaffoldMiddleware(handlers: {\n [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;\n}): JsonRpcMiddleware<JsonRpcParams, Json> {\n return (req, res, next, end) => {\n const handler = handlers[req.method];\n // if no handler, return\n if (handler === undefined) {\n return next();\n }\n\n // if handler is fn, call as middleware\n if (typeof handler === 'function') {\n return handler(req, res, next, end);\n }\n // if handler is some other value, use as result\n (res as JsonRpcSuccess).result = handler;\n return end();\n };\n}\n"]}
1
+ {"version":3,"file":"createScaffoldMiddleware.mjs","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAExC;IACC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,wBAAwB;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,IAAI,EAAE,CAAC;SACf;QAED,uCAAuC;QACvC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SACrC;QACD,gDAAgD;QAC/C,GAAsB,CAAC,MAAM,GAAG,OAAO,CAAC;QACzC,OAAO,GAAG,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Json, JsonRpcParams, JsonRpcSuccess } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\ntype ScaffoldMiddlewareHandler<\n Params extends JsonRpcParams,\n Result extends Json,\n> = JsonRpcMiddleware<Params, Result> | Json;\n\n/**\n * Creates a middleware function from an object of RPC method handler functions,\n * keyed to particular method names. If a method corresponding to a key of this\n * object is requested, this middleware will pass it to the corresponding\n * handler and return the result.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @param handlers - The RPC method handler functions.\n * @returns The scaffold middleware function.\n */\nexport function createScaffoldMiddleware(handlers: {\n [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;\n}): JsonRpcMiddleware<JsonRpcParams, Json> {\n return (req, res, next, end) => {\n const handler = handlers[req.method];\n // if no handler, return\n if (handler === undefined) {\n return next();\n }\n\n // if handler is fn, call as middleware\n if (typeof handler === 'function') {\n return handler(req, res, next, end);\n }\n // if handler is some other value, use as result\n (res as JsonRpcSuccess).result = handler;\n return end();\n };\n}\n"]}
@@ -9,6 +9,7 @@ const getUniqueId_1 = require("./getUniqueId.cjs");
9
9
  *
10
10
  * If used, should be the first middleware in the stack.
11
11
  *
12
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
12
13
  * @returns The ID remap middleware function.
13
14
  */
14
15
  function createIdRemapMiddleware() {
@@ -1 +1 @@
1
- {"version":3,"file":"idRemapMiddleware.cjs","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":";;;AAEA,mDAA4C;AAG5C;;;;;;;;GAQG;AACH,SAAgB,uBAAuB;IAIrC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC5B,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;QACnB,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;YACxB,QAAQ,CAAC,EAAE,GAAG,UAAU,CAAC;YACzB,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAfD,0DAeC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport { getUniqueId } from './getUniqueId';\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\n/**\n * Returns a middleware function that overwrites the `id` property of each\n * request with an ID that is guaranteed to be unique, and restores the original\n * ID in a return handler.\n *\n * If used, should be the first middleware in the stack.\n *\n * @returns The ID remap middleware function.\n */\nexport function createIdRemapMiddleware(): JsonRpcMiddleware<\n JsonRpcParams,\n Json\n> {\n return (request, response, next, _end) => {\n const originalId = request.id;\n const newId = getUniqueId();\n request.id = newId;\n response.id = newId;\n next((done) => {\n request.id = originalId;\n response.id = originalId;\n done();\n });\n };\n}\n"]}
1
+ {"version":3,"file":"idRemapMiddleware.cjs","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":";;;AAEA,mDAA4C;AAG5C;;;;;;;;;GASG;AACH,SAAgB,uBAAuB;IAIrC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC5B,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;QACnB,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;YACxB,QAAQ,CAAC,EAAE,GAAG,UAAU,CAAC;YACzB,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAfD,0DAeC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport { getUniqueId } from './getUniqueId';\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\n/**\n * Returns a middleware function that overwrites the `id` property of each\n * request with an ID that is guaranteed to be unique, and restores the original\n * ID in a return handler.\n *\n * If used, should be the first middleware in the stack.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @returns The ID remap middleware function.\n */\nexport function createIdRemapMiddleware(): JsonRpcMiddleware<\n JsonRpcParams,\n Json\n> {\n return (request, response, next, _end) => {\n const originalId = request.id;\n const newId = getUniqueId();\n request.id = newId;\n response.id = newId;\n next((done) => {\n request.id = originalId;\n response.id = originalId;\n done();\n });\n };\n}\n"]}
@@ -7,6 +7,7 @@ import type { JsonRpcMiddleware } from "./JsonRpcEngine.cjs";
7
7
  *
8
8
  * If used, should be the first middleware in the stack.
9
9
  *
10
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
10
11
  * @returns The ID remap middleware function.
11
12
  */
12
13
  export declare function createIdRemapMiddleware(): JsonRpcMiddleware<JsonRpcParams, Json>;
@@ -1 +1 @@
1
- {"version":3,"file":"idRemapMiddleware.d.cts","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAC1D,aAAa,EACb,IAAI,CACL,CAYA"}
1
+ {"version":3,"file":"idRemapMiddleware.d.cts","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAC1D,aAAa,EACb,IAAI,CACL,CAYA"}
@@ -7,6 +7,7 @@ import type { JsonRpcMiddleware } from "./JsonRpcEngine.mjs";
7
7
  *
8
8
  * If used, should be the first middleware in the stack.
9
9
  *
10
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
10
11
  * @returns The ID remap middleware function.
11
12
  */
12
13
  export declare function createIdRemapMiddleware(): JsonRpcMiddleware<JsonRpcParams, Json>;
@@ -1 +1 @@
1
- {"version":3,"file":"idRemapMiddleware.d.mts","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAC1D,aAAa,EACb,IAAI,CACL,CAYA"}
1
+ {"version":3,"file":"idRemapMiddleware.d.mts","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAC1D,aAAa,EACb,IAAI,CACL,CAYA"}
@@ -6,6 +6,7 @@ import { getUniqueId } from "./getUniqueId.mjs";
6
6
  *
7
7
  * If used, should be the first middleware in the stack.
8
8
  *
9
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
9
10
  * @returns The ID remap middleware function.
10
11
  */
11
12
  export function createIdRemapMiddleware() {
@@ -1 +1 @@
1
- {"version":3,"file":"idRemapMiddleware.mjs","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAG5C;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB;IAIrC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;QAC5B,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;QACnB,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;YACxB,QAAQ,CAAC,EAAE,GAAG,UAAU,CAAC;YACzB,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport { getUniqueId } from './getUniqueId';\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\n/**\n * Returns a middleware function that overwrites the `id` property of each\n * request with an ID that is guaranteed to be unique, and restores the original\n * ID in a return handler.\n *\n * If used, should be the first middleware in the stack.\n *\n * @returns The ID remap middleware function.\n */\nexport function createIdRemapMiddleware(): JsonRpcMiddleware<\n JsonRpcParams,\n Json\n> {\n return (request, response, next, _end) => {\n const originalId = request.id;\n const newId = getUniqueId();\n request.id = newId;\n response.id = newId;\n next((done) => {\n request.id = originalId;\n response.id = originalId;\n done();\n });\n };\n}\n"]}
1
+ {"version":3,"file":"idRemapMiddleware.mjs","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAG5C;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB;IAIrC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;QAC5B,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;QACnB,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;YACxB,QAAQ,CAAC,EAAE,GAAG,UAAU,CAAC;YACzB,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport { getUniqueId } from './getUniqueId';\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\n/**\n * Returns a middleware function that overwrites the `id` property of each\n * request with an ID that is guaranteed to be unique, and restores the original\n * ID in a return handler.\n *\n * If used, should be the first middleware in the stack.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @returns The ID remap middleware function.\n */\nexport function createIdRemapMiddleware(): JsonRpcMiddleware<\n JsonRpcParams,\n Json\n> {\n return (request, response, next, _end) => {\n const originalId = request.id;\n const newId = getUniqueId();\n request.id = newId;\n response.id = newId;\n next((done) => {\n request.id = originalId;\n response.id = originalId;\n done();\n });\n };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeMiddleware = exports.JsonRpcEngine = exports.createIdRemapMiddleware = exports.getUniqueId = exports.createScaffoldMiddleware = exports.createAsyncMiddleware = void 0;
3
+ exports.mergeMiddleware = exports.JsonRpcEngine = exports.createIdRemapMiddleware = exports.getUniqueId = exports.createScaffoldMiddleware = exports.createAsyncMiddleware = exports.asV2Middleware = void 0;
4
+ var asV2Middleware_1 = require("./asV2Middleware.cjs");
5
+ Object.defineProperty(exports, "asV2Middleware", { enumerable: true, get: function () { return asV2Middleware_1.asV2Middleware; } });
4
6
  var createAsyncMiddleware_1 = require("./createAsyncMiddleware.cjs");
5
7
  Object.defineProperty(exports, "createAsyncMiddleware", { enumerable: true, get: function () { return createAsyncMiddleware_1.createAsyncMiddleware; } });
6
8
  var createScaffoldMiddleware_1 = require("./createScaffoldMiddleware.cjs");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,qEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,iDAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,6DAA8D;AAArD,4HAAA,uBAAuB,OAAA;AAShC,qDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yDAAoD;AAA3C,kHAAA,eAAe,OAAA","sourcesContent":["export type {\n AsyncJsonRpcEngineNextCallback,\n AsyncJsonrpcMiddleware,\n} from './createAsyncMiddleware';\nexport { createAsyncMiddleware } from './createAsyncMiddleware';\nexport { createScaffoldMiddleware } from './createScaffoldMiddleware';\nexport { getUniqueId } from './getUniqueId';\nexport { createIdRemapMiddleware } from './idRemapMiddleware';\nexport type {\n JsonRpcEngineCallbackError,\n JsonRpcEngineReturnHandler,\n JsonRpcEngineNextCallback,\n JsonRpcEngineEndCallback,\n JsonRpcMiddleware,\n JsonRpcNotificationHandler,\n} from './JsonRpcEngine';\nexport { JsonRpcEngine } from './JsonRpcEngine';\nexport { mergeMiddleware } from './mergeMiddleware';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAkD;AAAzC,gHAAA,cAAc,OAAA;AAKvB,qEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,iDAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,6DAA8D;AAArD,4HAAA,uBAAuB,OAAA;AAShC,qDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yDAAoD;AAA3C,kHAAA,eAAe,OAAA","sourcesContent":["export { asV2Middleware } from './asV2Middleware';\nexport type {\n AsyncJsonRpcEngineNextCallback,\n AsyncJsonrpcMiddleware,\n} from './createAsyncMiddleware';\nexport { createAsyncMiddleware } from './createAsyncMiddleware';\nexport { createScaffoldMiddleware } from './createScaffoldMiddleware';\nexport { getUniqueId } from './getUniqueId';\nexport { createIdRemapMiddleware } from './idRemapMiddleware';\nexport type {\n JsonRpcEngineCallbackError,\n JsonRpcEngineReturnHandler,\n JsonRpcEngineNextCallback,\n JsonRpcEngineEndCallback,\n JsonRpcMiddleware,\n JsonRpcNotificationHandler,\n} from './JsonRpcEngine';\nexport { JsonRpcEngine } from './JsonRpcEngine';\nexport { mergeMiddleware } from './mergeMiddleware';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ export { asV2Middleware } from "./asV2Middleware.cjs";
1
2
  export type { AsyncJsonRpcEngineNextCallback, AsyncJsonrpcMiddleware, } from "./createAsyncMiddleware.cjs";
2
3
  export { createAsyncMiddleware } from "./createAsyncMiddleware.cjs";
3
4
  export { createScaffoldMiddleware } from "./createScaffoldMiddleware.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,GACvB,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,GAC3B,4BAAwB;AACzB,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAAyB;AAClD,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,GACvB,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,GAC3B,4BAAwB;AACzB,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B"}
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ export { asV2Middleware } from "./asV2Middleware.mjs";
1
2
  export type { AsyncJsonRpcEngineNextCallback, AsyncJsonrpcMiddleware, } from "./createAsyncMiddleware.mjs";
2
3
  export { createAsyncMiddleware } from "./createAsyncMiddleware.mjs";
3
4
  export { createScaffoldMiddleware } from "./createScaffoldMiddleware.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,GACvB,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,GAC3B,4BAAwB;AACzB,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAAyB;AAClD,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,GACvB,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,GAC3B,4BAAwB;AACzB,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ export { asV2Middleware } from "./asV2Middleware.mjs";
1
2
  export { createAsyncMiddleware } from "./createAsyncMiddleware.mjs";
2
3
  export { createScaffoldMiddleware } from "./createScaffoldMiddleware.mjs";
3
4
  export { getUniqueId } from "./getUniqueId.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAS9D,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B","sourcesContent":["export type {\n AsyncJsonRpcEngineNextCallback,\n AsyncJsonrpcMiddleware,\n} from './createAsyncMiddleware';\nexport { createAsyncMiddleware } from './createAsyncMiddleware';\nexport { createScaffoldMiddleware } from './createScaffoldMiddleware';\nexport { getUniqueId } from './getUniqueId';\nexport { createIdRemapMiddleware } from './idRemapMiddleware';\nexport type {\n JsonRpcEngineCallbackError,\n JsonRpcEngineReturnHandler,\n JsonRpcEngineNextCallback,\n JsonRpcEngineEndCallback,\n JsonRpcMiddleware,\n JsonRpcNotificationHandler,\n} from './JsonRpcEngine';\nexport { JsonRpcEngine } from './JsonRpcEngine';\nexport { mergeMiddleware } from './mergeMiddleware';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAAyB;AAKlD,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAS9D,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B","sourcesContent":["export { asV2Middleware } from './asV2Middleware';\nexport type {\n AsyncJsonRpcEngineNextCallback,\n AsyncJsonrpcMiddleware,\n} from './createAsyncMiddleware';\nexport { createAsyncMiddleware } from './createAsyncMiddleware';\nexport { createScaffoldMiddleware } from './createScaffoldMiddleware';\nexport { getUniqueId } from './getUniqueId';\nexport { createIdRemapMiddleware } from './idRemapMiddleware';\nexport type {\n JsonRpcEngineCallbackError,\n JsonRpcEngineReturnHandler,\n JsonRpcEngineNextCallback,\n JsonRpcEngineEndCallback,\n JsonRpcMiddleware,\n JsonRpcNotificationHandler,\n} from './JsonRpcEngine';\nexport { JsonRpcEngine } from './JsonRpcEngine';\nexport { mergeMiddleware } from './mergeMiddleware';\n"]}
@@ -5,6 +5,7 @@ const JsonRpcEngine_1 = require("./JsonRpcEngine.cjs");
5
5
  /**
6
6
  * Takes a stack of middleware and joins them into a single middleware function.
7
7
  *
8
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
8
9
  * @param middlewareStack - The middleware stack to merge.
9
10
  * @returns The merged middleware function.
10
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mergeMiddleware.cjs","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":";;;AAGA,uDAAgD;AAEhD;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,eAAyD;IAEzD,MAAM,MAAM,GAAG,IAAI,6BAAa,EAAE,CAAC;IACnC,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;AAC/B,CAAC;AAND,0CAMC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\nimport { JsonRpcEngine } from './JsonRpcEngine';\n\n/**\n * Takes a stack of middleware and joins them into a single middleware function.\n *\n * @param middlewareStack - The middleware stack to merge.\n * @returns The merged middleware function.\n */\nexport function mergeMiddleware(\n middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[],\n) {\n const engine = new JsonRpcEngine();\n middlewareStack.forEach((middleware) => engine.push(middleware));\n return engine.asMiddleware();\n}\n"]}
1
+ {"version":3,"file":"mergeMiddleware.cjs","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":";;;AAGA,uDAAgD;AAEhD;;;;;;GAMG;AACH,SAAgB,eAAe,CAC7B,eAAyD;IAEzD,MAAM,MAAM,GAAG,IAAI,6BAAa,EAAE,CAAC;IACnC,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;AAC/B,CAAC;AAND,0CAMC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\nimport { JsonRpcEngine } from './JsonRpcEngine';\n\n/**\n * Takes a stack of middleware and joins them into a single middleware function.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @param middlewareStack - The middleware stack to merge.\n * @returns The merged middleware function.\n */\nexport function mergeMiddleware(\n middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[],\n) {\n const engine = new JsonRpcEngine();\n middlewareStack.forEach((middleware) => engine.push(middleware));\n return engine.asMiddleware();\n}\n"]}
@@ -3,6 +3,7 @@ import type { JsonRpcMiddleware } from "./JsonRpcEngine.cjs";
3
3
  /**
4
4
  * Takes a stack of middleware and joins them into a single middleware function.
5
5
  *
6
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
6
7
  * @param middlewareStack - The middleware stack to merge.
7
8
  * @returns The merged middleware function.
8
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mergeMiddleware.d.cts","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAGzD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,0CAK1D"}
1
+ {"version":3,"file":"mergeMiddleware.d.cts","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAGzD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,0CAK1D"}
@@ -3,6 +3,7 @@ import type { JsonRpcMiddleware } from "./JsonRpcEngine.mjs";
3
3
  /**
4
4
  * Takes a stack of middleware and joins them into a single middleware function.
5
5
  *
6
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
6
7
  * @param middlewareStack - The middleware stack to merge.
7
8
  * @returns The merged middleware function.
8
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mergeMiddleware.d.mts","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAGzD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,0CAK1D"}
1
+ {"version":3,"file":"mergeMiddleware.d.mts","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAGzD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,0CAK1D"}
@@ -2,6 +2,7 @@ import { JsonRpcEngine } from "./JsonRpcEngine.mjs";
2
2
  /**
3
3
  * Takes a stack of middleware and joins them into a single middleware function.
4
4
  *
5
+ * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.
5
6
  * @param middlewareStack - The middleware stack to merge.
6
7
  * @returns The merged middleware function.
7
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mergeMiddleware.mjs","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,eAAyD;IAEzD,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;IACnC,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\nimport { JsonRpcEngine } from './JsonRpcEngine';\n\n/**\n * Takes a stack of middleware and joins them into a single middleware function.\n *\n * @param middlewareStack - The middleware stack to merge.\n * @returns The merged middleware function.\n */\nexport function mergeMiddleware(\n middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[],\n) {\n const engine = new JsonRpcEngine();\n middlewareStack.forEach((middleware) => engine.push(middleware));\n return engine.asMiddleware();\n}\n"]}
1
+ {"version":3,"file":"mergeMiddleware.mjs","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,eAAyD;IAEzD,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;IACnC,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\nimport { JsonRpcEngine } from './JsonRpcEngine';\n\n/**\n * Takes a stack of middleware and joins them into a single middleware function.\n *\n * @deprecated Use `JsonRpcEngineV2` and its corresponding types instead.\n * @param middlewareStack - The middleware stack to merge.\n * @returns The merged middleware function.\n */\nexport function mergeMiddleware(\n middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[],\n) {\n const engine = new JsonRpcEngine();\n middlewareStack.forEach((middleware) => engine.push(middleware));\n return engine.asMiddleware();\n}\n"]}