Skip to content

Commit

Permalink
Update types
Browse files Browse the repository at this point in the history
  • Loading branch information
rygine committed Sep 6, 2024
1 parent f755b01 commit a8730fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/js-sdk/src/keystore/SnapKeystore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function SnapKeystore(
return snapRPC(method, rpc, undefined, snapMeta, snapId) as any
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return snapRPC(method, rpc, req, snapMeta, snapId) as any
return snapRPC(method, rpc, req as any, snapMeta, snapId) as any
}
}

Expand Down
29 changes: 14 additions & 15 deletions packages/js-sdk/src/keystore/rpcDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ type ApiInterface = {
[key: string]: (...args: any[]) => any
}

type PrivatePreferenceKeystoreMethods = {
createPrivatePreference: (
action: privatePreferences.PrivatePreferencesAction
) => Promise<PublishParams[]>
getPrivatePreferences: () => privatePreferences.PrivatePreferencesAction[]
getPrivatePreferencesTopic: () => Promise<string>
savePrivatePreferences: (data: ActionsMap) => Promise<void>
}

type OtherKeyStoreMethods = {
/**
* Get the account address of the wallet used to create the Keystore
Expand All @@ -54,7 +63,8 @@ type ExtractInterface<T extends ApiDefs> = Flatten<
? () => Promise<Res>
: (req: Req) => Promise<Res>
: never
} & OtherKeyStoreMethods
} & OtherKeyStoreMethods &
PrivatePreferenceKeystoreMethods
>

type ExtractInterfaceRequestEncoders<T extends ApiDefs> = {
Expand Down Expand Up @@ -218,19 +228,9 @@ export const apiDefs = {
},
}

export type PrivatePreferenceKeystoreInterface = {
createPrivatePreference: (
action: privatePreferences.PrivatePreferencesAction
) => Promise<PublishParams[]>
getPrivatePreferences: () => privatePreferences.PrivatePreferencesAction[]
getPrivatePreferencesTopic: () => Promise<string>
savePrivatePreferences: (data: ActionsMap) => Promise<void>
}

export type KeystoreApiDefs = typeof apiDefs
export type KeystoreApiMethods = keyof KeystoreApiDefs
export type KeystoreInterface = ExtractInterface<KeystoreApiDefs> &
PrivatePreferenceKeystoreInterface
export type KeystoreInterface = ExtractInterface<KeystoreApiDefs>
export type KeystoreApiEntries = Entries<KeystoreApiDefs>
export type KeystoreApiRequestEncoders =
ExtractInterfaceRequestEncoders<KeystoreApiDefs>
Expand All @@ -251,10 +251,9 @@ export const snapApiDefs = {
},
}

export type SnapKeystoreApiDefs = typeof snapApiDefs
export type SnapKeystoreApiDefs = typeof snapApiDefs & KeystoreApiDefs
export type SnapKeystoreApiMethods = keyof SnapKeystoreApiDefs
export type SnapKeystoreInterface = KeystoreInterface &
ExtractInterface<SnapKeystoreApiDefs>
export type SnapKeystoreInterface = ExtractInterface<SnapKeystoreApiDefs>
export type SnapKeystoreApiEntries = Entries<SnapKeystoreApiDefs>
export type SnapKeystoreApiRequestEncoders =
ExtractInterfaceRequestEncoders<SnapKeystoreApiDefs>
Expand Down

0 comments on commit a8730fb

Please sign in to comment.