Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: typed batch function #81

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ensjs/src/functions/getSpecificRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const _getText = {
if (!response) {
return
}
return response
return response as string
},
}

Expand Down
16 changes: 15 additions & 1 deletion packages/ensjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ export interface GenericGeneratedRawFunction
extends Function,
RawFunctionWithBatch {}

interface GeneratedBatchFunction<F extends RawFunction>
extends Function,
RawFunction {
<I extends BatchFunctionResult<RawFunction>[]>(...args: I): Promise<
| {
[N in keyof I]: I[N] extends BatchFunctionResult<infer U>
? Awaited<ReturnType<U['decode']>>
: never
}
| undefined
>
batch: BatchFunction<F>
}

export class ENS {
[x: string]: any

Expand Down Expand Up @@ -418,7 +432,7 @@ export class ENS {
'initialGetters',
['multicallWrapper'],
'batch',
)
) as GeneratedBatchFunction<typeof batch>

public getProfile = this.generateFunction<typeof getProfile>(
'initialGetters',
Expand Down