Skip to content

Commit

Permalink
refactor: temporary remove call options from argument
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Jun 18, 2024
1 parent 6ddd644 commit 0a0ec9b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion apps/example/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Reactive DOT demo</title>
</head>
<body>
<div id="root"></div>
Expand Down
22 changes: 12 additions & 10 deletions packages/core/src/QueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ type InferPapiStorageEntry<T> = T extends {
? { args: Args; response: Response }
: { args: unknown[]; response: unknown };

type InferPapiStorageEntryWithKeys<T> = T extends {
getEntries: (...args: infer Args) => infer Response;
type InferPapiStorageEntries<T> = 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> = T extends (...args: infer Args) => infer Response
? { args: Args; response: Response }
: { args: unknown[]; response: unknown };
type InferPapiRuntimeCall<T> = T extends (
...args: [...infer Args, infer Options]
) => infer Response
? { args: Args; options: Options; response: Response }
: { args: unknown[]; options: unknown; response: unknown };

type InferPapiConstantEntry<T> = T extends {
(): Promise<infer Payload>;
Expand Down Expand Up @@ -55,7 +57,7 @@ export type StorageReadInstruction<
export type StorageEntriesReadInstruction<
TPallet extends keyof TypedApi<TDescriptor>["query"],
TStorage extends keyof TypedApi<TDescriptor>["query"][TPallet],
TArguments extends InferPapiStorageEntryWithKeys<
TArguments extends InferPapiStorageEntries<
TypedApi<TDescriptor>["query"][TPallet][TStorage]
>["args"],
TDescriptor extends ChainDefinition = CommonDescriptor,
Expand Down Expand Up @@ -117,7 +119,7 @@ type StorageEntriesReadResponse<
TDescriptor
>,
TDescriptor extends ChainDefinition = CommonDescriptor,
> = InferPapiStorageEntryWithKeys<
> = InferPapiStorageEntries<
TypedApi<TDescriptor>["query"][TInstruction["pallet"]][TInstruction["storage"]]
>["response"];

Expand Down Expand Up @@ -261,7 +263,7 @@ export default class Query<
TPallet extends keyof TypedApi<TDescriptor>["query"],
TStorage extends keyof TypedApi<TDescriptor>["query"][TPallet],
TArguments extends Array<
InferPapiStorageEntryWithKeys<
InferPapiStorageEntries<
TypedApi<TDescriptor>["query"][TPallet][TStorage]
>["args"]
>,
Expand Down

0 comments on commit 0a0ec9b

Please sign in to comment.