Skip to content

Commit

Permalink
refactor: use keyringInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
montelaidev committed Apr 16, 2024
1 parent 74b32e1 commit 6ae1b7e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 6ae1b7e

Please sign in to comment.