From 6ae1b7ebba527eef66999ed46347011617c7ef76 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Tue, 16 Apr 2024 18:48:55 +0800 Subject: [PATCH] refactor: use keyringInstance --- packages/snap/src/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index 3000392..aa94bb6 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -56,28 +56,29 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ ); } + const keyringInstance = await getKeyring(); // Handle custom methods. switch (request.method) { case InternalMethod.SetConfig: { if (!request.params) { throw new Error('Missing config'); } - return (await ( - await getKeyring() - ).setConfig(request.params as ChainConfig)) as Json; + return (await keyringInstance.setConfig( + request.params as ChainConfig, + )) as Json; } case InternalMethod.GetConfigs: { - return (await (await getKeyring()).getConfigs()) as Json; + return (await keyringInstance.getConfigs()) as Json; } case InternalMethod.TogglePaymasterUsage: { - await (await getKeyring()).togglePaymasterUsage(); + await keyringInstance.togglePaymasterUsage(); return null; } case InternalMethod.IsUsingPaymaster: { - return (await getKeyring()).isUsingPaymaster(); + return keyringInstance.isUsingPaymaster(); } default: {