@metamask/snaps-simulation
Version:
A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment
34 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccountsHandler = void 0;
const key_tree_1 = require("@metamask/key-tree");
/**
* A mock handler for account related methods that always returns the first
* address for the selected secret recovery phrase.
*
* @param _request - Incoming JSON-RPC request. This is ignored for this
* specific handler.
* @param response - The outgoing JSON-RPC response, modified to return the
* result.
* @param _next - The `json-rpc-engine` middleware next handler.
* @param end - The `json-rpc-engine` middleware end handler.
* @param hooks - Any hooks required by this handler.
* @returns The JSON-RPC response.
*/
async function getAccountsHandler(_request, response, _next, end, hooks) {
const { getMnemonic } = hooks;
const node = await key_tree_1.BIP44Node.fromDerivationPath({
derivationPath: [
await getMnemonic(),
`bip32:44'`,
`bip32:60'`,
`bip32:0'`,
`bip32:0`,
`bip32:0`,
],
});
response.result = [node.address];
return end();
}
exports.getAccountsHandler = getAccountsHandler;
//# sourceMappingURL=accounts.cjs.map