diff --git a/.changeset/twelve-gorillas-learn.md b/.changeset/twelve-gorillas-learn.md new file mode 100644 index 0000000000..156b854945 --- /dev/null +++ b/.changeset/twelve-gorillas-learn.md @@ -0,0 +1,29 @@ +--- +"@latticexyz/block-logs-stream": minor +"@latticexyz/cli": minor +"@latticexyz/common": minor +"@latticexyz/config": minor +"@latticexyz/dev-tools": minor +"@latticexyz/faucet": minor +"@latticexyz/protocol-parser": minor +"@latticexyz/schema-type": minor +"@latticexyz/store-indexer": minor +"@latticexyz/store-sync": minor +"@latticexyz/store": minor +"@latticexyz/world": minor +"create-mud": minor +--- + +Upgraded all packages and templates to viem v2.7.12 and abitype v1.0.0. + +Some viem APIs have changed and we've updated `getContract` to reflect those changes and keep it aligned with viem. It's one small code change: + +```diff + const worldContract = getContract({ + address: worldAddress, + abi: IWorldAbi, +- publicClient, +- walletClient, ++ client: { public: publicClient, wallet: walletClient }, + }); +``` diff --git a/e2e/packages/client-vanilla/package.json b/e2e/packages/client-vanilla/package.json index 7b36ac61e1..89bf99c5ec 100644 --- a/e2e/packages/client-vanilla/package.json +++ b/e2e/packages/client-vanilla/package.json @@ -29,7 +29,7 @@ "react": "^18.2.0", "rxjs": "7.5.5", "threads": "^1.7.0", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "rimraf": "^3.0.2", diff --git a/e2e/packages/client-vanilla/src/mud/setupNetwork.ts b/e2e/packages/client-vanilla/src/mud/setupNetwork.ts index 34e93b7bdc..8b6fdea78e 100644 --- a/e2e/packages/client-vanilla/src/mud/setupNetwork.ts +++ b/e2e/packages/client-vanilla/src/mud/setupNetwork.ts @@ -29,8 +29,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, }); const { components, latestBlock$, storedBlockLogs$, waitForTransaction } = await syncToRecs({ diff --git a/e2e/packages/sync-test/package.json b/e2e/packages/sync-test/package.json index 7b6a0620fc..b7478f5864 100644 --- a/e2e/packages/sync-test/package.json +++ b/e2e/packages/sync-test/package.json @@ -20,7 +20,7 @@ "@latticexyz/store-sync": "link:../../../packages/store-sync", "@latticexyz/utils": "link:../../../packages/utils", "@viem/anvil": "^0.0.6", - "abitype": "0.9.8", + "abitype": "1.0.0", "chalk": "^5.2.0", "dotenv": "^16.0.3", "drizzle-orm": "^0.28.5", @@ -28,7 +28,7 @@ "happy-dom": "^12.10.3", "postgres": "3.3.5", "typescript": "5.1.6", - "viem": "1.14.0", + "viem": "2.7.12", "vite": "^4.2.1", "vitest": "0.34.6", "zod": "^3.22.2" diff --git a/e2e/packages/test-data/generateLogs.ts b/e2e/packages/test-data/generateLogs.ts index 62da742de9..fff5449b2f 100644 --- a/e2e/packages/test-data/generateLogs.ts +++ b/e2e/packages/test-data/generateLogs.ts @@ -69,8 +69,7 @@ export async function generateLogs( const worldContract = getContract({ address: worldAddress, abi: IWorldAbi, - publicClient, - walletClient, + client: { public: publicClient, wallet: walletClient }, }); const lastTx = await transactionHook(worldContract); diff --git a/e2e/packages/test-data/package.json b/e2e/packages/test-data/package.json index a47a61c7b9..f44e8e616b 100644 --- a/e2e/packages/test-data/package.json +++ b/e2e/packages/test-data/package.json @@ -18,6 +18,6 @@ "execa": "^7.1.1", "tsx": "^3.12.6", "typescript": "5.1.6", - "viem": "1.14.0" + "viem": "2.7.12" } } diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 343f8419b6..5f0ff0d145 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -72,8 +72,8 @@ importers: specifier: ^1.7.0 version: 1.7.0 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.22.2) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.22.2) devDependencies: rimraf: specifier: ^3.0.2 @@ -157,8 +157,8 @@ importers: specifier: ^0.0.6 version: 0.0.6 abitype: - specifier: 0.9.8 - version: 0.9.8(typescript@5.1.6)(zod@3.22.2) + specifier: 1.0.0 + version: 1.0.0(typescript@5.1.6)(zod@3.22.2) chalk: specifier: ^5.2.0 version: 5.2.0 @@ -181,8 +181,8 @@ importers: specifier: 5.1.6 version: 5.1.6 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.22.2) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.22.2) vite: specifier: ^4.2.1 version: 4.3.5(@types/node@20.1.3) @@ -220,13 +220,13 @@ importers: specifier: 5.1.6 version: 5.1.6 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.22.2) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.22.2) packages: - /@adraffy/ens-normalize@1.9.4: - resolution: {integrity: sha512-UK0bHA7hh9cR39V+4gl2/NnBBjoXIxkuWAPCaY4X7fbH4L/azIi7ilWOCjMUYfpJgraLUAqkRi2BqrjME8Rynw==} + /@adraffy/ens-normalize@1.10.0: + resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} /@esbuild-kit/cjs-loader@2.4.2: resolution: {integrity: sha512-BDXFbYOJzT/NBEtp71cvsrGPwGAMGRB/349rwKuoxNSiKjPraNNnlK6MIIabViCjqZugu6j+xeMDlEkWdHHJSg==} @@ -748,9 +748,6 @@ packages: resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} dev: false - /@scure/base@1.1.1: - resolution: {integrity: sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==} - /@scure/base@1.1.3: resolution: {integrity: sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==} @@ -765,7 +762,7 @@ packages: resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} dependencies: '@noble/hashes': 1.3.2 - '@scure/base': 1.1.1 + '@scure/base': 1.1.3 /@sinclair/typebox@0.27.8: resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} @@ -788,11 +785,6 @@ packages: /@types/node@20.1.3: resolution: {integrity: sha512-NP2yfZpgmf2eDRPmgGq+fjGjSwFgYbihA8/gK+ey23qT9RkxsgNTZvGOEpXgzIGqesTYkElELLgtKoMQTys5vA==} - /@types/ws@8.5.5: - resolution: {integrity: sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==} - dependencies: - '@types/node': 20.1.3 - /@viem/anvil@0.0.6: resolution: {integrity: sha512-OjKR/+FVwzuygXYFqP8MBal1SXG8bT2gbZwqqB0XuLw81LNBBvmE/Repm6+5kkBh4IUj0PhYdrqOsnayS14Gtg==} dependencies: @@ -844,11 +836,11 @@ packages: pretty-format: 29.7.0 dev: true - /abitype@0.9.8(typescript@5.1.6)(zod@3.22.2): - resolution: {integrity: sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ==} + /abitype@1.0.0(typescript@5.1.6)(zod@3.22.2): + resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} peerDependencies: typescript: '>=5.0.4' - zod: ^3 >=3.19.1 + zod: ^3 >=3.22.0 peerDependenciesMeta: typescript: optional: true @@ -1319,8 +1311,8 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true - /isomorphic-ws@5.0.0(ws@8.13.0): - resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==} + /isows@1.0.3(ws@8.13.0): + resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} peerDependencies: ws: '*' dependencies: @@ -1770,22 +1762,21 @@ packages: resolution: {integrity: sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==} dev: true - /viem@1.14.0(typescript@5.1.6)(zod@3.22.2): - resolution: {integrity: sha512-4d+4/H3lnbkSAbrpQ15i1nBA7hne06joLFy3L3m0ZpMc+g+Zr3D4nuSTyeiqbHAYs9m2P9Kjap0HlyGkehasgg==} + /viem@2.7.12(typescript@5.1.6)(zod@3.22.2): + resolution: {integrity: sha512-NbV+Bycw0I4X8y6A04mgJ6+Imt7xXwflgnqisR3JXoJRNc77YSaQCscFN/dmwGLESTkgegJvi+j4nZY32GTpwQ==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: typescript: optional: true dependencies: - '@adraffy/ens-normalize': 1.9.4 + '@adraffy/ens-normalize': 1.10.0 '@noble/curves': 1.2.0 '@noble/hashes': 1.3.2 '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 - '@types/ws': 8.5.5 - abitype: 0.9.8(typescript@5.1.6)(zod@3.22.2) - isomorphic-ws: 5.0.0(ws@8.13.0) + abitype: 1.0.0(typescript@5.1.6)(zod@3.22.2) + isows: 1.0.3(ws@8.13.0) typescript: 5.1.6 ws: 8.13.0 transitivePeerDependencies: diff --git a/examples/minimal/packages/client-phaser/package.json b/examples/minimal/packages/client-phaser/package.json index d6835b6535..16644ea096 100644 --- a/examples/minimal/packages/client-phaser/package.json +++ b/examples/minimal/packages/client-phaser/package.json @@ -35,7 +35,7 @@ "styled-components": "^5.3.10", "threads": "^1.7.0", "use-resize-observer": "^9.1.0", - "viem": "1.14.0", + "viem": "2.7.12", "vite": "^4.2.1", "zustand": "^4.3.8" }, diff --git a/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts b/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts index 6c8e716ef3..e8348e953b 100644 --- a/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-phaser/src/mud/setupNetwork.ts @@ -31,8 +31,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/examples/minimal/packages/client-react/package.json b/examples/minimal/packages/client-react/package.json index 4a50f1453f..9473eb0f9e 100644 --- a/examples/minimal/packages/client-react/package.json +++ b/examples/minimal/packages/client-react/package.json @@ -32,7 +32,7 @@ "react-dom": "^18.2.0", "rxjs": "7.5.5", "threads": "^1.7.0", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/react": "18.2.22", diff --git a/examples/minimal/packages/client-react/src/mud/setupNetwork.ts b/examples/minimal/packages/client-react/src/mud/setupNetwork.ts index 96f6a3f17c..9a27f78768 100644 --- a/examples/minimal/packages/client-react/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-react/src/mud/setupNetwork.ts @@ -32,8 +32,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/examples/minimal/packages/client-vanilla/package.json b/examples/minimal/packages/client-vanilla/package.json index 33c15e3e32..a4566f54da 100644 --- a/examples/minimal/packages/client-vanilla/package.json +++ b/examples/minimal/packages/client-vanilla/package.json @@ -29,7 +29,7 @@ "react": "^18.2.0", "rxjs": "7.5.5", "threads": "^1.7.0", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "vite": "^4.2.1", diff --git a/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts b/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts index 4574062b9d..2260624657 100644 --- a/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts +++ b/examples/minimal/packages/client-vanilla/src/mud/setupNetwork.ts @@ -30,8 +30,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/examples/minimal/pnpm-lock.yaml b/examples/minimal/pnpm-lock.yaml index d05669c462..932aaf3a72 100644 --- a/examples/minimal/pnpm-lock.yaml +++ b/examples/minimal/pnpm-lock.yaml @@ -105,8 +105,8 @@ importers: specifier: ^9.1.0 version: 9.1.0(react-dom@18.2.0)(react@18.2.0) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6) vite: specifier: ^4.2.1 version: 4.2.1 @@ -208,8 +208,8 @@ importers: specifier: ^1.7.0 version: 1.7.0 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6) devDependencies: '@types/react': specifier: 18.2.22 @@ -293,8 +293,8 @@ importers: specifier: ^1.7.0 version: 1.7.0 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6) devDependencies: vite: specifier: ^4.2.1 @@ -396,8 +396,8 @@ importers: packages: - /@adraffy/ens-normalize@1.9.4: - resolution: {integrity: sha512-UK0bHA7hh9cR39V+4gl2/NnBBjoXIxkuWAPCaY4X7fbH4L/azIi7ilWOCjMUYfpJgraLUAqkRi2BqrjME8Rynw==} + /@adraffy/ens-normalize@1.10.0: + resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} dev: false /@ampproject/remapping@2.2.1: @@ -1007,10 +1007,6 @@ packages: resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} dev: false - /@scure/base@1.1.1: - resolution: {integrity: sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==} - dev: false - /@scure/base@1.1.3: resolution: {integrity: sha512-/+SgoRjLq7Xlf0CWuLHq2LUZeL/w65kfzAPG5NH9pcmBhs+nunQTn4gvdwgMTIXnt9b2C/1SeL2XiysZEyIC9Q==} dev: false @@ -1027,7 +1023,7 @@ packages: resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} dependencies: '@noble/hashes': 1.3.2 - '@scure/base': 1.1.1 + '@scure/base': 1.1.3 dev: false /@solidity-parser/parser@0.16.0: @@ -1108,12 +1104,6 @@ packages: csstype: 3.1.2 dev: true - /@types/ws@8.5.5: - resolution: {integrity: sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==} - dependencies: - '@types/node': 18.15.11 - dev: false - /@typescript-eslint/eslint-plugin@5.46.1(@typescript-eslint/parser@5.46.1)(eslint@8.29.0)(typescript@5.1.6): resolution: {integrity: sha512-YpzNv3aayRBwjs4J3oz65eVLXc9xx0PDbIRisHj+dYhvBn02MjYOD96P8YGiWEIFBrojaUjxvkaUpakD82phsA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1259,11 +1249,11 @@ packages: - supports-color dev: true - /abitype@0.9.8(typescript@5.1.6): - resolution: {integrity: sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ==} + /abitype@1.0.0(typescript@5.1.6): + resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} peerDependencies: typescript: '>=5.0.4' - zod: ^3 >=3.19.1 + zod: ^3 >=3.22.0 peerDependenciesMeta: typescript: optional: true @@ -2442,8 +2432,8 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true - /isomorphic-ws@5.0.0(ws@8.13.0): - resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==} + /isows@1.0.3(ws@8.13.0): + resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} peerDependencies: ws: '*' dependencies: @@ -3546,22 +3536,21 @@ packages: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} dev: true - /viem@1.14.0(typescript@5.1.6): - resolution: {integrity: sha512-4d+4/H3lnbkSAbrpQ15i1nBA7hne06joLFy3L3m0ZpMc+g+Zr3D4nuSTyeiqbHAYs9m2P9Kjap0HlyGkehasgg==} + /viem@2.7.12(typescript@5.1.6): + resolution: {integrity: sha512-NbV+Bycw0I4X8y6A04mgJ6+Imt7xXwflgnqisR3JXoJRNc77YSaQCscFN/dmwGLESTkgegJvi+j4nZY32GTpwQ==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: typescript: optional: true dependencies: - '@adraffy/ens-normalize': 1.9.4 + '@adraffy/ens-normalize': 1.10.0 '@noble/curves': 1.2.0 '@noble/hashes': 1.3.2 '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 - '@types/ws': 8.5.5 - abitype: 0.9.8(typescript@5.1.6) - isomorphic-ws: 5.0.0(ws@8.13.0) + abitype: 1.0.0(typescript@5.1.6) + isows: 1.0.3(ws@8.13.0) typescript: 5.1.6 ws: 8.13.0 transitivePeerDependencies: diff --git a/examples/multiple-accounts/packages/client/package.json b/examples/multiple-accounts/packages/client/package.json index 54e18b5348..bcd7943147 100644 --- a/examples/multiple-accounts/packages/client/package.json +++ b/examples/multiple-accounts/packages/client/package.json @@ -23,7 +23,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "rxjs": "7.5.5", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/react": "18.2.22", diff --git a/examples/multiple-accounts/packages/client/src/App.tsx b/examples/multiple-accounts/packages/client/src/App.tsx index 7a2119cd7b..d4ad3d21bf 100644 --- a/examples/multiple-accounts/packages/client/src/App.tsx +++ b/examples/multiple-accounts/packages/client/src/App.tsx @@ -31,8 +31,7 @@ const makeWorldContract = () => { world: getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient: publicClient, - walletClient: client, + client: { public: publicClient, wallet: client }, }), client, }; diff --git a/examples/multiple-accounts/packages/client/src/mud/setupNetwork.ts b/examples/multiple-accounts/packages/client/src/mud/setupNetwork.ts index 5cd26c31b1..f401de4702 100644 --- a/examples/multiple-accounts/packages/client/src/mud/setupNetwork.ts +++ b/examples/multiple-accounts/packages/client/src/mud/setupNetwork.ts @@ -60,8 +60,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/examples/multiple-accounts/pnpm-lock.yaml b/examples/multiple-accounts/pnpm-lock.yaml index 929ab649e5..7015942044 100644 --- a/examples/multiple-accounts/pnpm-lock.yaml +++ b/examples/multiple-accounts/pnpm-lock.yaml @@ -75,8 +75,8 @@ importers: specifier: 7.5.5 version: 7.5.5 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6) devDependencies: '@types/react': specifier: 18.2.22 @@ -150,8 +150,8 @@ packages: engines: {node: '>=0.10.0'} dev: true - /@adraffy/ens-normalize@1.9.4: - resolution: {integrity: sha512-UK0bHA7hh9cR39V+4gl2/NnBBjoXIxkuWAPCaY4X7fbH4L/azIi7ilWOCjMUYfpJgraLUAqkRi2BqrjME8Rynw==} + /@adraffy/ens-normalize@1.10.0: + resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} dev: false /@ampproject/remapping@2.2.1: @@ -718,6 +718,7 @@ packages: resolution: {integrity: sha512-X36s5CXMrrJOs2lQCdDF68apW4Rfx9ixYMawlepwmE4Anezv/AV2LSpKD1Ub8DAc+urp5bk0BGZ6NtmBitfnsg==} dependencies: undici-types: 5.26.5 + dev: true /@types/prettier@2.7.2: resolution: {integrity: sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==} @@ -749,12 +750,6 @@ packages: resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} dev: true - /@types/ws@8.5.10: - resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} - dependencies: - '@types/node': 18.19.6 - dev: false - /@typescript-eslint/eslint-plugin@5.46.1(@typescript-eslint/parser@5.46.1)(eslint@8.29.0)(typescript@5.1.6): resolution: {integrity: sha512-YpzNv3aayRBwjs4J3oz65eVLXc9xx0PDbIRisHj+dYhvBn02MjYOD96P8YGiWEIFBrojaUjxvkaUpakD82phsA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -900,11 +895,11 @@ packages: - supports-color dev: true - /abitype@0.9.8(typescript@5.1.6): - resolution: {integrity: sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ==} + /abitype@1.0.0(typescript@5.1.6): + resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} peerDependencies: typescript: '>=5.0.4' - zod: ^3 >=3.19.1 + zod: ^3 >=3.22.0 peerDependenciesMeta: typescript: optional: true @@ -1950,8 +1945,8 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true - /isomorphic-ws@5.0.0(ws@8.13.0): - resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==} + /isows@1.0.3(ws@8.13.0): + resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} peerDependencies: ws: '*' dependencies: @@ -2743,6 +2738,7 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + dev: true /update-browserslist-db@1.0.13(browserslist@4.22.2): resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} @@ -2761,22 +2757,21 @@ packages: punycode: 2.3.1 dev: true - /viem@1.14.0(typescript@5.1.6): - resolution: {integrity: sha512-4d+4/H3lnbkSAbrpQ15i1nBA7hne06joLFy3L3m0ZpMc+g+Zr3D4nuSTyeiqbHAYs9m2P9Kjap0HlyGkehasgg==} + /viem@2.7.12(typescript@5.1.6): + resolution: {integrity: sha512-NbV+Bycw0I4X8y6A04mgJ6+Imt7xXwflgnqisR3JXoJRNc77YSaQCscFN/dmwGLESTkgegJvi+j4nZY32GTpwQ==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: typescript: optional: true dependencies: - '@adraffy/ens-normalize': 1.9.4 + '@adraffy/ens-normalize': 1.10.0 '@noble/curves': 1.2.0 '@noble/hashes': 1.3.2 '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 - '@types/ws': 8.5.10 - abitype: 0.9.8(typescript@5.1.6) - isomorphic-ws: 5.0.0(ws@8.13.0) + abitype: 1.0.0(typescript@5.1.6) + isows: 1.0.3(ws@8.13.0) typescript: 5.1.6 ws: 8.13.0 transitivePeerDependencies: diff --git a/packages/block-logs-stream/package.json b/packages/block-logs-stream/package.json index 578f9a2c7e..f2986ec88e 100644 --- a/packages/block-logs-stream/package.json +++ b/packages/block-logs-stream/package.json @@ -25,10 +25,10 @@ }, "dependencies": { "@latticexyz/common": "workspace:*", - "abitype": "0.9.8", + "abitype": "1.0.0", "debug": "^4.3.4", "rxjs": "7.5.5", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/debug": "^4.1.7", diff --git a/packages/block-logs-stream/tsconfig.json b/packages/block-logs-stream/tsconfig.json index e590f0c026..376992556d 100644 --- a/packages/block-logs-stream/tsconfig.json +++ b/packages/block-logs-stream/tsconfig.json @@ -9,6 +9,7 @@ "isolatedModules": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, "strict": true } } diff --git a/packages/cli/package.json b/packages/cli/package.json index ccd00d61ae..2c429e3b87 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -60,7 +60,7 @@ "rxjs": "7.5.5", "throttle-debounce": "^5.0.0", "typescript": "5.1.6", - "viem": "1.14.0", + "viem": "2.7.12", "yargs": "^17.7.1", "zod": "^3.21.4", "zod-validation-error": "^1.3.0" diff --git a/packages/cli/src/deploy/ensureWorldFactory.ts b/packages/cli/src/deploy/ensureWorldFactory.ts index 3d27fb0988..1f2913a801 100644 --- a/packages/cli/src/deploy/ensureWorldFactory.ts +++ b/packages/cli/src/deploy/ensureWorldFactory.ts @@ -6,7 +6,7 @@ import initModuleBuild from "@latticexyz/world/out/InitModule.sol/InitModule.jso import initModuleAbi from "@latticexyz/world/out/InitModule.sol/InitModule.abi.json" assert { type: "json" }; import worldFactoryBuild from "@latticexyz/world/out/WorldFactory.sol/WorldFactory.json" assert { type: "json" }; import worldFactoryAbi from "@latticexyz/world/out/WorldFactory.sol/WorldFactory.abi.json" assert { type: "json" }; -import { Client, Transport, Chain, Account, Hex, getCreate2Address, encodeDeployData, size } from "viem"; +import { Client, Transport, Chain, Account, Hex, getCreate2Address, encodeDeployData, size, Abi } from "viem"; import { deployer } from "./ensureDeployer"; import { salt } from "./common"; import { ensureContractsDeployed } from "./ensureContractsDeployed"; @@ -17,7 +17,7 @@ export const accessManagementSystemDeployedBytecodeSize = size( ); export const accessManagementSystemBytecode = encodeDeployData({ bytecode: accessManagementSystemBuild.bytecode.object as Hex, - abi: [], + abi: [] as Abi, }); export const accessManagementSystem = getCreate2Address({ from: deployer, @@ -30,7 +30,7 @@ export const balanceTransferSystemDeployedBytecodeSize = size( ); export const balanceTransferSystemBytecode = encodeDeployData({ bytecode: balanceTransferSystemBuild.bytecode.object as Hex, - abi: [], + abi: [] as Abi, }); export const balanceTransferSystem = getCreate2Address({ from: deployer, @@ -41,14 +41,14 @@ export const balanceTransferSystem = getCreate2Address({ export const batchCallSystemDeployedBytecodeSize = size(batchCallSystemBuild.deployedBytecode.object as Hex); export const batchCallSystemBytecode = encodeDeployData({ bytecode: batchCallSystemBuild.bytecode.object as Hex, - abi: [], + abi: [] as Abi, }); export const batchCallSystem = getCreate2Address({ from: deployer, bytecode: batchCallSystemBytecode, salt }); export const registrationDeployedBytecodeSize = size(registrationSystemBuild.deployedBytecode.object as Hex); export const registrationBytecode = encodeDeployData({ bytecode: registrationSystemBuild.bytecode.object as Hex, - abi: [], + abi: [] as Abi, }); export const registration = getCreate2Address({ from: deployer, diff --git a/packages/common/package.json b/packages/common/package.json index e59867e710..216270c946 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -61,7 +61,7 @@ "p-retry": "^5.1.2", "prettier": "^2.8.4", "prettier-plugin-solidity": "1.1.3", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/debug": "^4.1.7", diff --git a/packages/common/src/chains/latticeTestnet.ts b/packages/common/src/chains/latticeTestnet.ts index 11761b7013..ff30540a33 100644 --- a/packages/common/src/chains/latticeTestnet.ts +++ b/packages/common/src/chains/latticeTestnet.ts @@ -3,7 +3,6 @@ import type { MUDChain } from "./types"; export const latticeTestnet = { name: "Lattice Testnet", id: 4242, - network: "lattice-testnet", nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" }, rpcUrls: { default: { diff --git a/packages/common/src/getContract.ts b/packages/common/src/getContract.ts index ac809e7139..a845359dd8 100644 --- a/packages/common/src/getContract.ts +++ b/packages/common/src/getContract.ts @@ -10,6 +10,8 @@ import { Transport, WalletClient, WriteContractParameters, + type ContractFunctionName, + type ContractFunctionArgs, getContract as viem_getContract, } from "viem"; import { UnionOmit } from "./type-utils/common"; @@ -41,7 +43,14 @@ export type GetContractOptions< TAccount extends Account, TPublicClient extends PublicClient, TWalletClient extends WalletClient -> = Required> & { +> = GetContractParameters< + TTransport, + TChain, + TAccount, + TAbi, + { public: TPublicClient; wallet: TWalletClient }, + TAddress +> & { onWrite?: (write: ContractWrite) => void; }; @@ -58,8 +67,7 @@ export function getContract< >({ abi, address, - publicClient, - walletClient, + client: { public: publicClient, wallet: walletClient }, onWrite, }: GetContractOptions< TTransport, @@ -69,13 +77,17 @@ export function getContract< TAccount, TPublicClient, TWalletClient ->): GetContractReturnType { - const contract = viem_getContract({ +>): GetContractReturnType { + const contract = viem_getContract({ abi, address, - publicClient, - walletClient, - }) as unknown as GetContractReturnType; + client: { + public: publicClient, + wallet: walletClient, + }, + }) as unknown as GetContractReturnType & { + write: unknown; + }; if (contract.write) { // Replace write calls with our own. Implemented ~the same as viem, but adds better handling of nonces (via queue + retries). @@ -98,7 +110,13 @@ export function getContract< args, ...options, onWrite, - } as unknown as WriteContractParameters; + } as unknown as WriteContractParameters< + TAbi, + ContractFunctionName, + ContractFunctionArgs, + TChain, + TAccount + >; const result = writeContract(walletClient, request); const id = `${walletClient.chain.id}:${walletClient.account.address}:${nextWriteId++}`; @@ -111,5 +129,5 @@ export function getContract< ); } - return contract as unknown as GetContractReturnType; + return contract as unknown as GetContractReturnType; } diff --git a/packages/common/src/sendTransaction.ts b/packages/common/src/sendTransaction.ts index 6f89df20ce..9e64497825 100644 --- a/packages/common/src/sendTransaction.ts +++ b/packages/common/src/sendTransaction.ts @@ -5,7 +5,7 @@ import { Client, SendTransactionParameters, Transport, - WriteContractReturnType, + SendTransactionReturnType, } from "viem"; import { call, sendTransaction as viem_sendTransaction } from "viem/actions"; import pRetry from "p-retry"; @@ -24,7 +24,7 @@ export async function sendTransaction< >( client: Client, request: SendTransactionParameters -): Promise { +): Promise { const rawAccount = request.account ?? client.account; if (!rawAccount) { // TODO: replace with viem AccountNotFoundError once its exported @@ -68,7 +68,8 @@ export async function sendTransaction< const nonce = nonceManager.nextNonce(); debug("sending tx with nonce", nonce, "to", preparedRequest.to); - return await viem_sendTransaction(client, { nonce, ...preparedRequest }); + const parameters: SendTransactionParameters = { nonce, ...preparedRequest }; + return await viem_sendTransaction(client, parameters); }, { retries: 3, diff --git a/packages/common/src/writeContract.ts b/packages/common/src/writeContract.ts index 07a0dd0964..973ecfb8bb 100644 --- a/packages/common/src/writeContract.ts +++ b/packages/common/src/writeContract.ts @@ -7,6 +7,8 @@ import { Transport, WriteContractParameters, WriteContractReturnType, + ContractFunctionName, + ContractFunctionArgs, } from "viem"; import { simulateContract, writeContract as viem_writeContract } from "viem/actions"; import pRetry from "p-retry"; @@ -19,14 +21,15 @@ const debug = parentDebug.extend("writeContract"); // TODO: migrate away from this approach once we can hook into viem's nonce management: https://github.com/wagmi-dev/viem/discussions/1230 export async function writeContract< - TChain extends Chain | undefined, - TAccount extends Account | undefined, - TAbi extends Abi | readonly unknown[], - TFunctionName extends string, - TChainOverride extends Chain | undefined + chain extends Chain | undefined, + account extends Account | undefined, + abi extends Abi | readonly unknown[], + functionName extends ContractFunctionName, + args extends ContractFunctionArgs, + chainOverride extends Chain | undefined >( - client: Client, - request: WriteContractParameters + client: Client, + request: WriteContractParameters ): Promise { const rawAccount = request.account ?? client.account; if (!rawAccount) { @@ -42,7 +45,7 @@ export async function writeContract< }); async function prepareWrite(): Promise< - WriteContractParameters + WriteContractParameters > { if (request.gas) { debug("gas provided, skipping simulate", request.functionName, request.address); @@ -50,13 +53,13 @@ export async function writeContract< } debug("simulating", request.functionName, "at", request.address); - const result = await simulateContract(client, { + const result = await simulateContract(client, { ...request, blockTag: "pending", account, - } as unknown as SimulateContractParameters); + } as unknown as SimulateContractParameters); - return result.request as unknown as WriteContractParameters; + return result.request as unknown as WriteContractParameters; } const preparedWrite = await prepareWrite(); diff --git a/packages/config/package.json b/packages/config/package.json index db81380a7a..2619576b50 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -41,7 +41,7 @@ "@latticexyz/schema-type": "workspace:*", "esbuild": "^0.17.15", "find-up": "^6.3.0", - "viem": "1.14.0", + "viem": "2.7.12", "zod": "^3.21.4", "zod-validation-error": "^1.3.0" }, diff --git a/packages/dev-tools/package.json b/packages/dev-tools/package.json index 52ca25b39e..b5ef1db8b4 100644 --- a/packages/dev-tools/package.json +++ b/packages/dev-tools/package.json @@ -37,7 +37,7 @@ "rxjs": "7.5.5", "tailwind-merge": "^1.12.0", "use-local-storage-state": "^18.3.2", - "viem": "1.14.0", + "viem": "2.7.12", "zustand": "^4.3.7" }, "devDependencies": { diff --git a/packages/dev-tools/tsconfig.json b/packages/dev-tools/tsconfig.json index e453e13efb..ef4ccc40de 100644 --- a/packages/dev-tools/tsconfig.json +++ b/packages/dev-tools/tsconfig.json @@ -9,6 +9,7 @@ "isolatedModules": true, "esModuleInterop": true, "jsx": "react-jsx", + "skipLibCheck": true, "jsxImportSource": "react" }, "include": ["src"] diff --git a/packages/faucet/package.json b/packages/faucet/package.json index beb31c37a2..c4a455a39d 100644 --- a/packages/faucet/package.json +++ b/packages/faucet/package.json @@ -36,7 +36,7 @@ "debug": "^4.3.4", "dotenv": "^16.0.3", "fastify": "^4.21.0", - "viem": "1.14.0", + "viem": "2.7.12", "zod": "^3.21.4" }, "devDependencies": { diff --git a/packages/protocol-parser/package.json b/packages/protocol-parser/package.json index 274a677926..08ca13b9d8 100644 --- a/packages/protocol-parser/package.json +++ b/packages/protocol-parser/package.json @@ -26,8 +26,8 @@ "dependencies": { "@latticexyz/common": "workspace:*", "@latticexyz/schema-type": "workspace:*", - "abitype": "0.9.8", - "viem": "1.14.0" + "abitype": "1.0.0", + "viem": "2.7.12" }, "devDependencies": { "tsup": "^6.7.0", diff --git a/packages/protocol-parser/tsconfig.json b/packages/protocol-parser/tsconfig.json index e590f0c026..376992556d 100644 --- a/packages/protocol-parser/tsconfig.json +++ b/packages/protocol-parser/tsconfig.json @@ -9,6 +9,7 @@ "isolatedModules": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, "strict": true } } diff --git a/packages/schema-type/package.json b/packages/schema-type/package.json index dc4d877804..caedfb79e0 100644 --- a/packages/schema-type/package.json +++ b/packages/schema-type/package.json @@ -34,8 +34,8 @@ "test:ci": "pnpm run test" }, "dependencies": { - "abitype": "0.9.8", - "viem": "1.14.0" + "abitype": "1.0.0", + "viem": "2.7.12" }, "devDependencies": { "@latticexyz/gas-report": "workspace:*", diff --git a/packages/schema-type/tsconfig.json b/packages/schema-type/tsconfig.json index 6bf6ff0ab6..413bf5de38 100644 --- a/packages/schema-type/tsconfig.json +++ b/packages/schema-type/tsconfig.json @@ -10,6 +10,7 @@ "isolatedModules": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, "strict": true } } diff --git a/packages/store-indexer/package.json b/packages/store-indexer/package.json index 8ec5d4e2c3..e8b79608f9 100644 --- a/packages/store-indexer/package.json +++ b/packages/store-indexer/package.json @@ -62,7 +62,7 @@ "rxjs": "7.5.5", "superjson": "^1.12.4", "trpc-koa-adapter": "^1.1.3", - "viem": "1.14.0", + "viem": "2.7.12", "zod": "^3.21.4" }, "devDependencies": { diff --git a/packages/store-sync/package.json b/packages/store-sync/package.json index 5162e29f9c..b6ce955f59 100644 --- a/packages/store-sync/package.json +++ b/packages/store-sync/package.json @@ -76,7 +76,7 @@ "rxjs": "7.5.5", "sql.js": "^1.8.0", "superjson": "^1.12.4", - "viem": "1.14.0", + "viem": "2.7.12", "zod": "^3.21.4", "zustand": "^4.3.7" }, diff --git a/packages/store/package.json b/packages/store/package.json index 86aa4b9471..cef5a69075 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -54,8 +54,8 @@ "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", "@latticexyz/schema-type": "workspace:*", - "abitype": "0.9.8", - "viem": "1.14.0", + "abitype": "1.0.0", + "viem": "2.7.12", "zod": "^3.21.4" }, "devDependencies": { diff --git a/packages/world/package.json b/packages/world/package.json index 5d2424c0af..dd3d3369e9 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -50,8 +50,8 @@ "@latticexyz/config": "workspace:*", "@latticexyz/schema-type": "workspace:*", "@latticexyz/store": "workspace:*", - "abitype": "0.9.8", - "viem": "1.14.0", + "abitype": "1.0.0", + "viem": "2.7.12", "zod": "^3.21.4" }, "devDependencies": { diff --git a/packages/world/ts/encodeSystemCall.ts b/packages/world/ts/encodeSystemCall.ts index 20d5fb53d2..a6a36e735b 100644 --- a/packages/world/ts/encodeSystemCall.ts +++ b/packages/world/ts/encodeSystemCall.ts @@ -1,30 +1,26 @@ -import { - Abi, - EncodeFunctionDataParameters, - ContractFunctionConfig, - GetFunctionArgs, - Hex, - encodeFunctionData, -} from "viem"; +import { Abi, EncodeFunctionDataParameters, Hex, encodeFunctionData, type ContractFunctionName } from "viem"; +import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype"; import IWorldCallAbi from "../out/IWorldKernel.sol/IWorldCall.abi.json"; -export type SystemCall = Pick< - ContractFunctionConfig, - "abi" | "functionName" | "args" +export type SystemCall> = EncodeFunctionDataParameters< + abi, + functionName > & { readonly systemId: Hex; }; /** Encode a system call to be passed as arguments into `World.call` */ -export function encodeSystemCall({ +export function encodeSystemCall>({ abi, systemId, functionName, args, -}: SystemCall): GetFunctionArgs["args"] { +}: SystemCall): AbiParametersToPrimitiveTypes< + ExtractAbiFunction["inputs"] +> { return [ systemId, - encodeFunctionData({ + encodeFunctionData({ abi, functionName, args, diff --git a/packages/world/ts/encodeSystemCallFrom.ts b/packages/world/ts/encodeSystemCallFrom.ts index 1688b8e0be..691675684e 100644 --- a/packages/world/ts/encodeSystemCallFrom.ts +++ b/packages/world/ts/encodeSystemCallFrom.ts @@ -1,23 +1,29 @@ -import { Abi, EncodeFunctionDataParameters, GetFunctionArgs, encodeFunctionData, Address } from "viem"; +import { Abi, EncodeFunctionDataParameters, encodeFunctionData, Address, type ContractFunctionName } from "viem"; +import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype"; import IWorldCallAbi from "../out/IWorldKernel.sol/IWorldCall.abi.json"; import { SystemCall } from "./encodeSystemCall"; -export type SystemCallFrom = SystemCall & { +export type SystemCallFrom> = SystemCall< + abi, + functionName +> & { readonly from: Address; }; /** Encode a system call to be passed as arguments into `World.callFrom` */ -export function encodeSystemCallFrom({ +export function encodeSystemCallFrom>({ abi, from, systemId, functionName, args, -}: SystemCallFrom): GetFunctionArgs["args"] { +}: SystemCallFrom): AbiParametersToPrimitiveTypes< + ExtractAbiFunction["inputs"] +> { return [ from, systemId, - encodeFunctionData({ + encodeFunctionData({ abi, functionName, args, diff --git a/packages/world/ts/encodeSystemCalls.ts b/packages/world/ts/encodeSystemCalls.ts index 6336822e0b..fe027924da 100644 --- a/packages/world/ts/encodeSystemCalls.ts +++ b/packages/world/ts/encodeSystemCalls.ts @@ -1,11 +1,12 @@ -import { Abi, GetFunctionArgs } from "viem"; +import { Abi, type ContractFunctionName } from "viem"; import IWorldCallAbi from "../out/IWorldKernel.sol/IWorldCall.abi.json"; import { SystemCall, encodeSystemCall } from "./encodeSystemCall"; +import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype"; /** Encode system calls to be passed as arguments into `World.batchCall` */ -export function encodeSystemCalls( +export function encodeSystemCalls>( abi: abi, systemCalls: readonly Omit, "abi">[] -): GetFunctionArgs["args"][] { +): AbiParametersToPrimitiveTypes["inputs"]>[] { return systemCalls.map((systemCall) => encodeSystemCall({ ...systemCall, abi } as SystemCall)); } diff --git a/packages/world/ts/encodeSystemCallsFrom.ts b/packages/world/ts/encodeSystemCallsFrom.ts index e63cc43bd0..f5c9bf548e 100644 --- a/packages/world/ts/encodeSystemCallsFrom.ts +++ b/packages/world/ts/encodeSystemCallsFrom.ts @@ -1,13 +1,14 @@ -import { Abi, Address, GetFunctionArgs } from "viem"; +import { Abi, Address, type ContractFunctionName } from "viem"; import IWorldCallAbi from "../out/IWorldKernel.sol/IWorldCall.abi.json"; import { SystemCallFrom, encodeSystemCallFrom } from "./encodeSystemCallFrom"; +import type { AbiParametersToPrimitiveTypes, ExtractAbiFunction } from "abitype"; /** Encode system calls to be passed as arguments into `World.batchCallFrom` */ -export function encodeSystemCallsFrom( +export function encodeSystemCallsFrom>( abi: abi, from: Address, systemCalls: readonly Omit, "abi" | "from">[] -): GetFunctionArgs["args"][] { +): AbiParametersToPrimitiveTypes["inputs"]>[] { return systemCalls.map((systemCall) => encodeSystemCallFrom({ ...systemCall, abi, from } as SystemCallFrom) ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 629d967201..ccb001cd7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -97,8 +97,8 @@ importers: specifier: workspace:* version: link:../common abitype: - specifier: 0.9.8 - version: 0.9.8(typescript@5.1.6)(zod@3.21.4) + specifier: 1.0.0 + version: 1.0.0(typescript@5.1.6)(zod@3.21.4) debug: specifier: ^4.3.4 version: 4.3.4(supports-color@8.1.1) @@ -106,8 +106,8 @@ importers: specifier: 7.5.5 version: 7.5.5 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) devDependencies: '@types/debug': specifier: ^4.1.7 @@ -212,8 +212,8 @@ importers: specifier: 5.1.6 version: 5.1.6 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) yargs: specifier: ^17.7.1 version: 17.7.1 @@ -288,8 +288,8 @@ importers: specifier: 1.1.3 version: 1.1.3(prettier@2.8.4) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) devDependencies: '@types/debug': specifier: ^4.1.7 @@ -319,8 +319,8 @@ importers: specifier: ^6.3.0 version: 6.3.0 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) zod: specifier: ^3.21.4 version: 3.21.4 @@ -390,8 +390,8 @@ importers: specifier: ^18.3.2 version: 18.3.2(react-dom@18.2.0)(react@18.2.0) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) zustand: specifier: ^4.3.7 version: 4.3.7(react@18.2.0) @@ -450,8 +450,8 @@ importers: specifier: ^4.21.0 version: 4.21.0 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) zod: specifier: ^3.21.4 version: 3.21.4 @@ -594,11 +594,11 @@ importers: specifier: workspace:* version: link:../schema-type abitype: - specifier: 0.9.8 - version: 0.9.8(typescript@5.1.6)(zod@3.21.4) + specifier: 1.0.0 + version: 1.0.0(typescript@5.1.6)(zod@3.21.4) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) devDependencies: tsup: specifier: ^6.7.0 @@ -696,11 +696,11 @@ importers: packages/schema-type: dependencies: abitype: - specifier: 0.9.8 - version: 0.9.8(typescript@5.1.6)(zod@3.21.4) + specifier: 1.0.0 + version: 1.0.0(typescript@5.1.6)(zod@3.21.4) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) devDependencies: '@latticexyz/gas-report': specifier: workspace:* @@ -777,11 +777,11 @@ importers: specifier: workspace:* version: link:../schema-type abitype: - specifier: 0.9.8 - version: 0.9.8(typescript@5.1.6)(zod@3.21.4) + specifier: 1.0.0 + version: 1.0.0(typescript@5.1.6)(zod@3.21.4) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) zod: specifier: ^3.21.4 version: 3.21.4 @@ -897,8 +897,8 @@ importers: specifier: ^1.1.3 version: 1.1.3(@trpc/server@10.34.0)(koa@2.14.2) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) zod: specifier: ^3.21.4 version: 3.21.4 @@ -991,8 +991,8 @@ importers: specifier: ^1.12.4 version: 1.12.4 viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) zod: specifier: ^3.21.4 version: 3.21.4 @@ -1053,11 +1053,11 @@ importers: specifier: workspace:* version: link:../store abitype: - specifier: 0.9.8 - version: 0.9.8(typescript@5.1.6)(zod@3.21.4) + specifier: 1.0.0 + version: 1.0.0(typescript@5.1.6)(zod@3.21.4) viem: - specifier: 1.14.0 - version: 1.14.0(typescript@5.1.6)(zod@3.21.4) + specifier: 2.7.12 + version: 2.7.12(typescript@5.1.6)(zod@3.21.4) zod: specifier: ^3.21.4 version: 3.21.4 @@ -1171,8 +1171,8 @@ importers: packages: - /@adraffy/ens-normalize@1.9.4: - resolution: {integrity: sha512-UK0bHA7hh9cR39V+4gl2/NnBBjoXIxkuWAPCaY4X7fbH4L/azIi7ilWOCjMUYfpJgraLUAqkRi2BqrjME8Rynw==} + /@adraffy/ens-normalize@1.10.0: + resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} dev: false /@alloc/quick-lru@5.2.0: @@ -3743,12 +3743,6 @@ packages: '@types/node': 18.15.11 dev: true - /@types/ws@8.5.6: - resolution: {integrity: sha512-8B5EO9jLVCy+B58PLHvLDuOD8DRVMgQzq8d55SjLCOn9kqGyqOvy27exVaTio1q1nX5zLu8/6N0n2ThSxOM6tg==} - dependencies: - '@types/node': 18.15.11 - dev: false - /@types/yargs-interactive@2.1.3: resolution: {integrity: sha512-bYB8ah0JPR6/lpHlxUzeHsrb3RK5OW7N8Hnth2nefnr6zQ5KFoDQ6wM5x58dTLEDYrwikFy3EPTf/O0HKLNaIg==} dependencies: @@ -3982,11 +3976,11 @@ packages: engines: {node: '>=6', npm: '>=3'} dev: false - /abitype@0.9.8(typescript@5.1.6)(zod@3.21.4): - resolution: {integrity: sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ==} + /abitype@1.0.0(typescript@5.1.6)(zod@3.21.4): + resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} peerDependencies: typescript: '>=5.0.4' - zod: ^3 >=3.19.1 + zod: ^3 >=3.22.0 peerDependenciesMeta: typescript: optional: true @@ -7675,8 +7669,8 @@ packages: /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - /isomorphic-ws@5.0.0(ws@8.13.0): - resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==} + /isows@1.0.3(ws@8.13.0): + resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} peerDependencies: ws: '*' dependencies: @@ -11907,22 +11901,21 @@ packages: engines: {node: '>= 0.8'} dev: false - /viem@1.14.0(typescript@5.1.6)(zod@3.21.4): - resolution: {integrity: sha512-4d+4/H3lnbkSAbrpQ15i1nBA7hne06joLFy3L3m0ZpMc+g+Zr3D4nuSTyeiqbHAYs9m2P9Kjap0HlyGkehasgg==} + /viem@2.7.12(typescript@5.1.6)(zod@3.21.4): + resolution: {integrity: sha512-NbV+Bycw0I4X8y6A04mgJ6+Imt7xXwflgnqisR3JXoJRNc77YSaQCscFN/dmwGLESTkgegJvi+j4nZY32GTpwQ==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: typescript: optional: true dependencies: - '@adraffy/ens-normalize': 1.9.4 + '@adraffy/ens-normalize': 1.10.0 '@noble/curves': 1.2.0 '@noble/hashes': 1.3.2 '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 - '@types/ws': 8.5.6 - abitype: 0.9.8(typescript@5.1.6)(zod@3.21.4) - isomorphic-ws: 5.0.0(ws@8.13.0) + abitype: 1.0.0(typescript@5.1.6)(zod@3.21.4) + isows: 1.0.3(ws@8.13.0) typescript: 5.1.6 ws: 8.13.0 transitivePeerDependencies: diff --git a/templates/phaser/packages/client/package.json b/templates/phaser/packages/client/package.json index 31b7f3b1ea..53c4f827d8 100644 --- a/templates/phaser/packages/client/package.json +++ b/templates/phaser/packages/client/package.json @@ -29,7 +29,7 @@ "simplex-noise": "^4.0.1", "styled-components": "^5.3.10", "use-resize-observer": "^9.1.0", - "viem": "1.14.0", + "viem": "2.7.12", "zustand": "^4.3.8" }, "devDependencies": { diff --git a/templates/phaser/packages/client/src/mud/setupNetwork.ts b/templates/phaser/packages/client/src/mud/setupNetwork.ts index 10bc9163d5..573f059d38 100644 --- a/templates/phaser/packages/client/src/mud/setupNetwork.ts +++ b/templates/phaser/packages/client/src/mud/setupNetwork.ts @@ -61,8 +61,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/templates/react-ecs/packages/client/package.json b/templates/react-ecs/packages/client/package.json index 952996ffa1..d5943713ef 100644 --- a/templates/react-ecs/packages/client/package.json +++ b/templates/react-ecs/packages/client/package.json @@ -24,7 +24,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "rxjs": "7.5.5", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/react": "18.2.22", diff --git a/templates/react-ecs/packages/client/src/mud/setupNetwork.ts b/templates/react-ecs/packages/client/src/mud/setupNetwork.ts index 7aa0031c4d..60dfc7bdda 100644 --- a/templates/react-ecs/packages/client/src/mud/setupNetwork.ts +++ b/templates/react-ecs/packages/client/src/mud/setupNetwork.ts @@ -63,8 +63,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/templates/react/packages/client/package.json b/templates/react/packages/client/package.json index 54e18b5348..bcd7943147 100644 --- a/templates/react/packages/client/package.json +++ b/templates/react/packages/client/package.json @@ -23,7 +23,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "rxjs": "7.5.5", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/react": "18.2.22", diff --git a/templates/react/packages/client/src/mud/setupNetwork.ts b/templates/react/packages/client/src/mud/setupNetwork.ts index 5cd26c31b1..f401de4702 100644 --- a/templates/react/packages/client/src/mud/setupNetwork.ts +++ b/templates/react/packages/client/src/mud/setupNetwork.ts @@ -60,8 +60,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/templates/threejs/packages/client/package.json b/templates/threejs/packages/client/package.json index f1cae3e0de..272a46de64 100644 --- a/templates/threejs/packages/client/package.json +++ b/templates/threejs/packages/client/package.json @@ -25,7 +25,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "rxjs": "7.5.5", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/react": "18.2.22", diff --git a/templates/threejs/packages/client/src/mud/setupNetwork.ts b/templates/threejs/packages/client/src/mud/setupNetwork.ts index a454f87352..20a639ceca 100644 --- a/templates/threejs/packages/client/src/mud/setupNetwork.ts +++ b/templates/threejs/packages/client/src/mud/setupNetwork.ts @@ -61,8 +61,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), }); diff --git a/templates/vanilla/packages/client/package.json b/templates/vanilla/packages/client/package.json index 289fb9f1da..b691535615 100644 --- a/templates/vanilla/packages/client/package.json +++ b/templates/vanilla/packages/client/package.json @@ -21,7 +21,7 @@ "@latticexyz/world": "link:../../../../packages/world", "contracts": "workspace:*", "rxjs": "7.5.5", - "viem": "1.14.0" + "viem": "2.7.12" }, "devDependencies": { "@types/react-dom": "18.2.7", diff --git a/templates/vanilla/packages/client/src/mud/setupNetwork.ts b/templates/vanilla/packages/client/src/mud/setupNetwork.ts index 7aa0031c4d..60dfc7bdda 100644 --- a/templates/vanilla/packages/client/src/mud/setupNetwork.ts +++ b/templates/vanilla/packages/client/src/mud/setupNetwork.ts @@ -63,8 +63,7 @@ export async function setupNetwork() { const worldContract = getContract({ address: networkConfig.worldAddress as Hex, abi: IWorldAbi, - publicClient, - walletClient: burnerWalletClient, + client: { public: publicClient, wallet: burnerWalletClient }, onWrite: (write) => write$.next(write), });