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

fix(world): switch to TS for ABIs in utils #3429

Merged
merged 2 commits into from
Jan 8, 2025
Merged

Conversation

holic
Copy link
Member

@holic holic commented Jan 8, 2025

pulled out of #3419

it's common among our packages that you'll see these TS errors from world package when running tsc

% pnpm tsc
../world/ts/actions/callFrom.ts:135:9 - error TS2488: Type 'unknown' must have a '[Symbol.iterator]()' method that returns an iterator.

135   const [staticData, encodedLengths, dynamicData] = await _readContract({
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

../world/ts/encodeSystemCall.ts:19:22 - error TS2344: Type '{ type: string; name: string; inputs: { name: string; type: string; internalType: string; }[]; outputs: { name: string; type: string; internalType: string; }[]; stateMutability: string; }[]' does not satisfy the constraint 'Abi'.
  Type '{ type: string; name: string; inputs: { name: string; type: string; internalType: string; }[]; outputs: { name: string; type: string; internalType: string; }[]; stateMutability: string; }' is not assignable to type 'AbiFunction | AbiConstructor | AbiFallback | AbiReceive | AbiEvent | AbiError'.
    Type '{ type: string; name: string; inputs: { name: string; type: string; internalType: string; }[]; outputs: { name: string; type: string; internalType: string; }[]; stateMutability: string; }' is not assignable to type 'AbiFunction'.
      Types of property 'type' are incompatible.
        Type 'string' is not assignable to type '"function"'.

19   ExtractAbiFunction<typeof IWorldCallAbi, "call">["inputs"]
                        ~~~~~~~~~~~~~~~~~~~~

../world/ts/encodeSystemCall.ts:21:3 - error TS2322: Type '`0x${string}`[]' is not assignable to type 'never'.

21   return [
     ~~~~~~

../world/ts/encodeSystemCallFrom.ts:21:22 - error TS2344: Type '{ type: string; name: string; inputs: { name: string; type: string; internalType: string; }[]; outputs: { name: string; type: string; internalType: string; }[]; stateMutability: string; }[]' does not satisfy the constraint 'Abi'.

21   ExtractAbiFunction<typeof IWorldCallAbi, "callFrom">["inputs"]
                        ~~~~~~~~~~~~~~~~~~~~

../world/ts/encodeSystemCallFrom.ts:23:3 - error TS2322: Type '`0x${string}`[]' is not assignable to type 'never'.

23   return [
     ~~~~~~

../world/ts/encodeSystemCalls.ts:10:53 - error TS2344: Type '{ type: string; name: string; inputs: { name: string; type: string; internalType: string; }[]; outputs: { name: string; type: string; internalType: string; }[]; stateMutability: string; }[]' does not satisfy the constraint 'Abi'.

10 ): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, "call">["inputs"]>[] {
                                                       ~~~~~~~~~~~~~~~~~~~~

../world/ts/encodeSystemCallsFrom.ts:11:53 - error TS2344: Type '{ type: string; name: string; inputs: { name: string; type: string; internalType: string; }[]; outputs: { name: string; type: string; internalType: string; }[]; stateMutability: string; }[]' does not satisfy the constraint 'Abi'.

11 ): AbiParametersToPrimitiveTypes<ExtractAbiFunction<typeof IWorldCallAbi, "callFrom">["inputs"]>[] {
                                                       ~~~~~~~~~~~~~~~~~~~~


Found 7 errors in 5 files.

Errors  Files
     1  ../world/ts/actions/callFrom.ts:135
     2  ../world/ts/encodeSystemCall.ts:19
     2  ../world/ts/encodeSystemCallFrom.ts:21
     1  ../world/ts/encodeSystemCalls.ts:10
     1  ../world/ts/encodeSystemCallsFrom.ts:11

this has to do with our ABI JSON -> TS strategy (using DTS files generated by abi-ts), where things aren't resolving properly (see #3029)

in the meantime, we'll just hardcode just the ABIs we need as regular TS

@holic holic requested a review from alvrs as a code owner January 8, 2025 15:04
Copy link

changeset-bot bot commented Jan 8, 2025

🦋 Changeset detected

Latest commit: 2247516

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@latticexyz/world Patch
@latticexyz/cli Patch
@latticexyz/dev-tools Patch
@latticexyz/explorer Patch
@latticexyz/store-consumer Patch
@latticexyz/store-sync Patch
@latticexyz/world-module-erc20 Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
@latticexyz/store-indexer Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/paymaster Patch
@latticexyz/protocol-parser Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/stash Patch
@latticexyz/store Patch
@latticexyz/utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@holic holic changed the title fix(world): switch to TS for ABIs fix(world): switch to TS for ABIs in utils Jan 8, 2025
@holic holic merged commit 2d2aa08 into main Jan 8, 2025
16 checks passed
@holic holic deleted the holic/fix-world-abi-ts branch January 8, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants