From 0a0ec9bc522a553123b3d2854ac8549e4fe1fb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ti=E1=BA=BFn=20Nguy=E1=BB=85n=20Kh=E1=BA=AFc?= Date: Tue, 18 Jun 2024 23:45:44 +1200 Subject: [PATCH] refactor: temporary remove call options from argument --- apps/example/index.html | 3 ++- packages/core/src/QueryBuilder.ts | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/example/index.html b/apps/example/index.html index 2947b559..48821cc3 100644 --- a/apps/example/index.html +++ b/apps/example/index.html @@ -1,8 +1,9 @@ - + + Reactive DOT demo
diff --git a/packages/core/src/QueryBuilder.ts b/packages/core/src/QueryBuilder.ts index 0a4517e9..beec1e79 100644 --- a/packages/core/src/QueryBuilder.ts +++ b/packages/core/src/QueryBuilder.ts @@ -9,15 +9,17 @@ type InferPapiStorageEntry = T extends { ? { args: Args; response: Response } : { args: unknown[]; response: unknown }; -type InferPapiStorageEntryWithKeys = T extends { - getEntries: (...args: infer Args) => infer Response; +type InferPapiStorageEntries = T extends { + getEntries: (...args: [...infer Args, infer Options]) => infer Response; } - ? { args: Args; response: Response } - : { args: unknown[]; response: unknown }; + ? { args: Args; options: Options; response: Response } + : { args: unknown[]; options: unknown; response: unknown }; -type InferPapiRuntimeCall = T extends (...args: infer Args) => infer Response - ? { args: Args; response: Response } - : { args: unknown[]; response: unknown }; +type InferPapiRuntimeCall = T extends ( + ...args: [...infer Args, infer Options] +) => infer Response + ? { args: Args; options: Options; response: Response } + : { args: unknown[]; options: unknown; response: unknown }; type InferPapiConstantEntry = T extends { (): Promise; @@ -55,7 +57,7 @@ export type StorageReadInstruction< export type StorageEntriesReadInstruction< TPallet extends keyof TypedApi["query"], TStorage extends keyof TypedApi["query"][TPallet], - TArguments extends InferPapiStorageEntryWithKeys< + TArguments extends InferPapiStorageEntries< TypedApi["query"][TPallet][TStorage] >["args"], TDescriptor extends ChainDefinition = CommonDescriptor, @@ -117,7 +119,7 @@ type StorageEntriesReadResponse< TDescriptor >, TDescriptor extends ChainDefinition = CommonDescriptor, -> = InferPapiStorageEntryWithKeys< +> = InferPapiStorageEntries< TypedApi["query"][TInstruction["pallet"]][TInstruction["storage"]] >["response"]; @@ -261,7 +263,7 @@ export default class Query< TPallet extends keyof TypedApi["query"], TStorage extends keyof TypedApi["query"][TPallet], TArguments extends Array< - InferPapiStorageEntryWithKeys< + InferPapiStorageEntries< TypedApi["query"][TPallet][TStorage] >["args"] >,