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

refactor: add explicit annotations to SimulateContractReturnType #2557

Merged
merged 6 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.3",
"@arktype/attest": "0.8.0",
"@ark/attest": "^0.10.2",
"@biomejs/biome": "^1.8.0",
"@changesets/changelog-github": "^0.4.5",
"@changesets/cli": "^2.23.2",
Expand Down
571 changes: 312 additions & 259 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/actions/public/mulitcall.bench-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attest } from '@arktype/attest'
import { attest } from '@ark/attest'
import { test } from 'vitest'

import {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/readContract.bench-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attest } from '@arktype/attest'
import { attest } from '@ark/attest'
import { test } from 'vitest'

import { usdcContractConfig } from '../../../test/src/abis.js'
Expand Down
19 changes: 10 additions & 9 deletions src/actions/public/simulateContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,34 @@ export type SimulateContractParameters<
>

export type SimulateContractReturnType<
abi extends Abi | readonly unknown[] = Abi,
functionName extends ContractFunctionName<
out abi extends Abi | readonly unknown[] = Abi,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never knew about this syntax! Where can I find the docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, not adding anything meaningful to the PR, but I am also only learning of this now and this is really cool. Cool to see more nuanced use of typescript and the performance comparison is really interesting too. How did you generate that graph for tsc build btw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yuripetusko There's a command for it in the attest CLI.

It's a thin wrapper around tsc --generateTrace + https://github.com/microsoft/typescript-analyze-trace

in out functionName extends ContractFunctionName<
abi,
'nonpayable' | 'payable'
> = ContractFunctionName<abi, 'nonpayable' | 'payable'>,
args extends ContractFunctionArgs<
in out args extends ContractFunctionArgs<
abi,
'nonpayable' | 'payable',
functionName
> = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,
chain extends Chain | undefined = Chain | undefined,
account extends Account | undefined = Account | undefined,
chainOverride extends Chain | undefined = Chain | undefined,
accountOverride extends Account | Address | undefined =
/** @ts-expect-error cast variance */
out chain extends Chain | undefined = Chain | undefined,
out account extends Account | undefined = Account | undefined,
out chainOverride extends Chain | undefined = Chain | undefined,
out accountOverride extends Account | Address | undefined =
| Account
| Address
| undefined,
///
minimizedAbi extends Abi = readonly [
in out minimizedAbi extends Abi = readonly [
ExtractAbiFunctionForArgs<
abi extends Abi ? abi : Abi,
'nonpayable' | 'payable',
functionName,
args
>,
],
resolvedAccount extends Account | undefined = accountOverride extends
out resolvedAccount extends Account | undefined = accountOverride extends
| Account
| Address
? ParseAccount<accountOverride>
Expand Down
2 changes: 1 addition & 1 deletion src/clients/createPublicClient.bench-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attest } from '@arktype/attest'
import { attest } from '@ark/attest'
import { test } from 'vitest'

import { createClient } from './createClient.js'
Expand Down
2 changes: 1 addition & 1 deletion src/clients/createTestClient.bench-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attest } from '@arktype/attest'
import { attest } from '@ark/attest'
import { test } from 'vitest'

import { createClient } from './createClient.js'
Expand Down
2 changes: 1 addition & 1 deletion src/clients/createWalletClient.bench-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attest } from '@arktype/attest'
import { attest } from '@ark/attest'
import { test } from 'vitest'

import { createClient } from './createClient.js'
Expand Down
4 changes: 2 additions & 2 deletions test/benchTypesGlobalSetup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { setup } from '@arktype/attest'
import { setup } from '@ark/attest'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
Expand All @@ -14,4 +14,4 @@ export default function () {
}

// biome-ignore lint/performance/noBarrelFile: <explanation>
export { teardown } from '@arktype/attest'
export { teardown } from '@ark/attest'