UNPKG

@metamask/snaps-simulation

Version:

A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment

1 lines 1.37 kB
{"version":3,"file":"net-version.cjs","sourceRoot":"","sources":["../../../src/middleware/internal-methods/net-version.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,wBAAwB,CAC5C,QAAwB,EACxB,QAAgC,EAChC,KAAgC,EAChC,GAA6B;IAE7B,uEAAuE;IACvE,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC;IAEtB,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAXD,4DAWC","sourcesContent":["import type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n} from '@metamask/json-rpc-engine';\nimport type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';\n\n/**\n * A mock handler for net_version that always returns a specific\n * hardcoded result.\n *\n * @param _request - Incoming JSON-RPC request. Ignored for this specific\n * handler.\n * @param response - The outgoing JSON-RPC response, modified to return the\n * result.\n * @param _next - The `json-rpc-engine` middleware next handler.\n * @param end - The `json-rpc-engine` middleware end handler.\n * @returns The JSON-RPC response.\n */\nexport async function getNetworkVersionHandler(\n _request: JsonRpcRequest,\n response: PendingJsonRpcResponse,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n) {\n // For now this will return a mocked result, this should probably match\n // whatever network the simulation is using.\n response.result = '1';\n\n return end();\n}\n"]}