Skip to content

Commit cd2c0f3

Browse files
feat: handle zksync direct deploys in deployContract (#5002)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `thirdweb` library with new features and bug fixes, particularly for zkSync deployments and improvements to various ERC1155 and ERC721 modules. ### Detailed summary - Added support for zkSync direct deploys in `deployContract`. - Updated `SequentialTokenIdERC1155` to include `startTokenId` in its module. - Modified event signatures for `BatchMetadataUpdate` in both ERC721 and ERC1155. - Increased test retry count and max concurrency in `vitest.config.ts`. - Introduced new methods for batch metadata handling, including `getBatchIndex` and `getMetadataBatch`. - Added `setBaseURI` functionality for both `BatchMetadataERC721` and `BatchMetadataERC1155`. - Created parameter encoding functions for `updateTokenIdERC1155`. - Enhanced error handling and configuration retrieval methods in modules. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 4f346e6 commit cd2c0f3

File tree

24 files changed

+1400
-111
lines changed

24 files changed

+1400
-111
lines changed

.changeset/rich-steaks-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Handle zk sync direct deploys in `deployContract`
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[
22
"function encodeBytesOnInstall() pure returns (bytes)",
33
"function getAllMetadataBatches() view returns ((uint256 startTokenIdInclusive, uint256 endTokenIdInclusive, string baseURI)[])",
4+
"function getBatchIndex(uint256 _tokenId) view returns (uint256)",
5+
"function getMetadataBatch(uint256 _batchIndex) view returns ((uint256 startTokenIdInclusive, uint256 endTokenIdInclusive, string baseURI))",
6+
"function getModuleConfig() pure returns ((bool registerInstallationCallback, bytes4[] requiredInterfaces, bytes4[] supportedInterfaces, (bytes4 selector)[] callbackFunctions, (bytes4 selector, uint256 permissionBits)[] fallbackFunctions) config)",
7+
"function setBaseURI(uint256 _batchIndex, string _baseURI)",
48
"function uploadMetadata(uint256 _amount, string _baseURI)",
5-
"event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId)"
9+
"event BatchMetadataUpdate(uint256 startTokenIdIncluside, uint256 endTokenIdInclusive, string baseURI)"
610
]
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[
22
"function encodeBytesOnInstall() pure returns (bytes)",
33
"function getAllMetadataBatches() view returns ((uint256 startTokenIdInclusive, uint256 endTokenIdInclusive, string baseURI)[])",
4+
"function getBatchIndex(uint256 _tokenId) view returns (uint256)",
5+
"function getMetadataBatch(uint256 _batchIndex) view returns ((uint256 startTokenIdInclusive, uint256 endTokenIdInclusive, string baseURI))",
6+
"function getModuleConfig() pure returns ((bool registerInstallationCallback, bytes4[] requiredInterfaces, bytes4[] supportedInterfaces, (bytes4 selector)[] callbackFunctions, (bytes4 selector, uint256 permissionBits)[] fallbackFunctions) config)",
7+
"function setBaseURI(uint256 _batchIndex, string _baseURI)",
48
"function uploadMetadata(uint256 _amount, string _baseURI)",
5-
"event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId)"
9+
"event BatchMetadataUpdate(uint256 startTokenIdIncluside, uint256 endTokenIdInclusive, string baseURI)"
610
]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
2-
"function encodeBytesOnInstall() pure returns (bytes)",
2+
"function encodeBytesOnInstall(uint256 startTokenId) pure returns (bytes)",
3+
"function getModuleConfig() pure returns ((bool registerInstallationCallback, bytes4[] requiredInterfaces, bytes4[] supportedInterfaces, (bytes4 selector)[] callbackFunctions, (bytes4 selector, uint256 permissionBits)[] fallbackFunctions) config)",
34
"function getNextTokenId() view returns (uint256)",
4-
"error SequentialTokenIdInvalidTokenId()",
5-
"error UpdateTokenIdCallbackERC1155NotImplemented()"
5+
"function updateTokenIdERC1155(uint256 _tokenId) payable returns (uint256)"
66
]

packages/thirdweb/src/contract/deployment/deploy-with-abi.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { encodeAbiParameters } from "../../utils/abi/encodeAbiParameters.js";
55
import { normalizeFunctionParams } from "../../utils/abi/normalizeFunctionParams.js";
66
import { computeDeploymentAddress } from "../../utils/any-evm/compute-deployment-address.js";
77
import { computeDeploymentInfoFromBytecode } from "../../utils/any-evm/compute-published-contract-deploy-info.js";
8+
import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
89
import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
910
import { ensureBytecodePrefix } from "../../utils/bytecode/prefix.js";
1011
import { concatHex } from "../../utils/encoding/helpers/concat-hex.js";
@@ -13,6 +14,7 @@ import type { Prettify } from "../../utils/type-utils.js";
1314
import type { ClientAndChain } from "../../utils/types.js";
1415
import type { Account } from "../../wallets/interfaces/wallet.js";
1516
import { getContract } from "../contract.js";
17+
import { zkDeployContract } from "./zksync/zkDeployContract.js";
1618

1719
/**
1820
* @extension DEPLOY
@@ -121,6 +123,18 @@ export async function deployContract(
121123
salt?: string;
122124
},
123125
) {
126+
if (await isZkSyncChain(options.chain)) {
127+
return zkDeployContract({
128+
account: options.account,
129+
client: options.client,
130+
chain: options.chain,
131+
bytecode: options.bytecode,
132+
abi: options.abi,
133+
params: options.constructorParams,
134+
salt: options.salt,
135+
});
136+
}
137+
124138
if (options.salt !== undefined) {
125139
// Deploy with CREATE2 if salt is provided
126140
const info = await computeDeploymentInfoFromBytecode(options);

packages/thirdweb/src/extensions/ens/resolve-avatar.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { describe, expect, it } from "vitest";
2-
32
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
43
import { resolveAvatar } from "./resolve-avatar.js";
54

@@ -22,9 +21,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("ENS:resolve-avatar", () => {
2221
client: TEST_CLIENT,
2322
name: "vitalik.eth",
2423
});
25-
expect(avatarUri?.split("/ipfs/")[1]).toMatchInlineSnapshot(
26-
`"QmSP4nq9fnN9dAiCj42ug9Wa79rqmQerZXZch82VqpiH7U/image.gif"`,
27-
);
24+
expect(avatarUri).toMatchInlineSnapshot(`"https://euc.li/vitalik.eth"`);
2825
});
2926

3027
it("resolves name without avatar record to null", async () => {

packages/thirdweb/src/extensions/modules/MintableERC1155/mintableERC1155.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ describe.runIf(process.env.TW_SECRET_KEY)("ModularTokenERC1155", () => {
4040
primarySaleRecipient: TEST_ACCOUNT_A.address,
4141
}),
4242
BatchMetadataERC1155.module(),
43-
SequentialTokenIdERC1155.module(),
43+
SequentialTokenIdERC1155.module({
44+
startTokenId: 0n,
45+
}),
4446
],
4547
});
4648
contract = getContract({

packages/thirdweb/src/extensions/modules/__generated__/BatchMetadataERC1155/events/BatchMetadataUpdate.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/modules/__generated__/BatchMetadataERC1155/read/getBatchIndex.ts

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/thirdweb/src/extensions/modules/__generated__/BatchMetadataERC1155/read/getMetadataBatch.ts

Lines changed: 142 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)