diff options
author | Florian Dold <florian@dold.me> | 2022-10-16 23:11:34 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-10-16 23:11:34 +0200 |
commit | e4f2587cabdcea92d2096114393aa1daca610671 (patch) | |
tree | e019962e332a1b8d6dbf702e72568e10b609294a /packages/taler-wallet-core/src/wallet-api-types.ts | |
parent | ea1aff81df642000a1c458a91fc8aee239d3bd3a (diff) | |
download | wallet-core-e4f2587cabdcea92d2096114393aa1daca610671.tar.xz |
webextension: introduce typesafe wallet-core API client
Diffstat (limited to 'packages/taler-wallet-core/src/wallet-api-types.ts')
-rw-r--r-- | packages/taler-wallet-core/src/wallet-api-types.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts index 88e66ff9e..354681734 100644 --- a/packages/taler-wallet-core/src/wallet-api-types.ts +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -707,17 +707,19 @@ export type WalletOperations = { [WalletApiOperation.SetDevMode]: SetDevModeOp; }; -export type RequestType< +export type WalletCoreRequestType< Op extends WalletApiOperation & keyof WalletOperations, > = WalletOperations[Op] extends { request: infer T } ? T : never; -export type ResponseType< +export type WalletCoreResponseType< Op extends WalletApiOperation & keyof WalletOperations, > = WalletOperations[Op] extends { response: infer T } ? T : never; +export type WalletCoreOpKeys = WalletApiOperation & keyof WalletOperations; + export interface WalletCoreApiClient { - call<Op extends WalletApiOperation & keyof WalletOperations>( + call<Op extends WalletCoreOpKeys>( operation: Op, - payload: RequestType<Op>, - ): Promise<ResponseType<Op>>; + payload: WalletCoreRequestType<Op>, + ): Promise<WalletCoreResponseType<Op>>; } |