Skip to content

Commit

Permalink
[SDK/Dashboard] Fix: Deploy specified version of published contracts (#…
Browse files Browse the repository at this point in the history
…5923)

TOOL-3013
TOOL-3014

## Notes for the reviewer
Anything important to call out? Be sure to also clarify these in your comments.

## How to test
Unit tests, playground, etc.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on updating the deployment process for contracts in the `thirdweb` package, including changes to version handling and contract IDs.

### Detailed summary
- Updated `version` handling in the `custom-contract.tsx` file.
- Changed `contractId` from `"Forwarder"` to `"ForwarderEOAOnly"` in `deploy-pack.ts`.
- Added `version` to the options in `deployMarketplaceContract`.
- Modified `getAllDefaultConstructorParamsForImplementation` to use a dynamic `contractId`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
  • Loading branch information
kumaryash90 committed Jan 10, 2025
1 parent 7fb5ce1 commit 42a313f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-items-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix deploy version for published contracts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
? JSON.parse(params.deployParams._trustedForwarders as string)
: undefined,
},
version: metadata.version,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export type MarketplaceContractParams = {
export type DeployMarketplaceContractOptions = Prettify<
ClientAndChainAndAccount & {
params: MarketplaceContractParams;
} & {
version?: string;
}
>;

Expand All @@ -46,7 +48,7 @@ export type DeployMarketplaceContractOptions = Prettify<
export async function deployMarketplaceContract(
options: DeployMarketplaceContractOptions,
) {
const { chain, client, account, params } = options;
const { chain, client, account, params, version } = options;
const WETH = await getOrDeployInfraContract({
chain,
client,
Expand Down Expand Up @@ -127,6 +129,7 @@ export async function deployMarketplaceContract(
nativeTokenWrapper: WETH.address,
} as MarketplaceConstructorParams[number],
},
version,
});

const initializeTransaction = await getInitializeTransaction({
Expand Down
2 changes: 1 addition & 1 deletion packages/thirdweb/src/extensions/prebuilts/deploy-pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function deployPackContract(options: DeployPackContractOptions) {
chain,
client,
account,
contractId: "Forwarder",
contractId: "ForwarderEOAOnly",
}),
]);
const { cloneFactoryContract, implementationContract } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ export async function deployContractfromDeployMetadata(
(await getAllDefaultConstructorParamsForImplementation({
chain,
client,
contractId: deployMetadata.name,
})),
publisher: deployMetadata.publisher,
version: deployMetadata.version,
});

const initializeTransaction = await getInitializeTransaction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ async function getTransactionsForImplementation(options: {
(await getAllDefaultConstructorParamsForImplementation({
chain,
client,
contractId: deployMetadata.name,
}));

const result = await getDeployedInfraContract({
Expand Down Expand Up @@ -224,6 +225,7 @@ async function getTransactionsForMaketplaceV3(options: {
export async function getAllDefaultConstructorParamsForImplementation(args: {
chain: Chain;
client: ThirdwebClient;
contractId: string;
}) {
const { chain, client } = args;
const isZkSync = await isZkSyncChain(chain);
Expand All @@ -234,11 +236,14 @@ export async function getAllDefaultConstructorParamsForImplementation(args: {
nativeTokenWrapper: weth,
};
}

const forwarderContractId =
args.contractId === "Pack" ? "ForwarderEOAOnly" : "Forwarder";
const [forwarder, weth] = await Promise.all([
computePublishedContractAddress({
chain,
client,
contractId: "Forwarder",
contractId: forwarderContractId,
}),
computePublishedContractAddress({
chain,
Expand Down

0 comments on commit 42a313f

Please sign in to comment.