@metamask/snaps-simulation
Version:
A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment
1 lines • 1.57 kB
Source Map (JSON)
{"version":3,"file":"provider-state.cjs","sourceRoot":"","sources":["../../../src/middleware/internal-methods/provider-state.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,uBAAuB,CAC3C,QAAwB,EACxB,QAAgC,EAChC,KAAgC,EAChC,GAA6B;IAE7B,uEAAuE;IACvE,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,GAAG;QAChB,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,MAAM;QACf,cAAc,EAAE,MAAM;QACtB,QAAQ,EAAE,EAAE;KACb,CAAC;IAEF,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAhBD,0DAgBC","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 metamask_getProviderState 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 getProviderStateHandler(\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 = {\n isUnlocked: true,\n chainId: '0x01',\n networkVersion: '0x01',\n accounts: [],\n };\n\n return end();\n}\n"]}