From 7072dfce76cbb6e7a1983c3953f1cc81de593c02 Mon Sep 17 00:00:00 2001 From: Ry Racherbaumer Date: Tue, 23 Jan 2024 18:32:03 -0600 Subject: [PATCH] fix: update snapRPC types and fix snapRequest --- src/keystore/SnapKeystore.ts | 6 ++++-- src/keystore/snapHelpers.ts | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/keystore/SnapKeystore.ts b/src/keystore/SnapKeystore.ts index 26564ab81..3713c75a9 100644 --- a/src/keystore/SnapKeystore.ts +++ b/src/keystore/SnapKeystore.ts @@ -24,9 +24,11 @@ export function SnapKeystore( ) as SnapKeystoreApiEntries) { generatedMethods[method] = async (req?: SnapKeystoreApiRequestValues) => { if (!rpc.req) { - return snapRPC(method, rpc, undefined, snapMeta, snapId) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return snapRPC(method, rpc, undefined, snapMeta, snapId) as any } - return snapRPC(method, rpc, req, snapMeta, snapId) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return snapRPC(method, rpc, req, snapMeta, snapId) as any } } diff --git a/src/keystore/snapHelpers.ts b/src/keystore/snapHelpers.ts index 292d0ee6e..65ac92f8c 100644 --- a/src/keystore/snapHelpers.ts +++ b/src/keystore/snapHelpers.ts @@ -53,8 +53,9 @@ export async function snapRPC( throw new Error('Unexpected array response') } - const decoder = rpc.res.decode as SnapKeystoreApiResponseDecoders[T] - return decoder(b64Decode(responseString)) + return rpc.res.decode(b64Decode(responseString)) as ReturnType< + SnapKeystoreApiResponseDecoders[T] + > } export async function snapRequest( @@ -78,11 +79,11 @@ export async function snapRequest( }, }) - if (!response || !response.res) { + if (!response || typeof response !== 'object') { throw new Error('No response value') } - return response.res + return (response as SnapResponse).res } export type Snap = {