Skip to content

Commit f7030d3

Browse files
committed
test
1 parent f7d0830 commit f7030d3

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

packages/thirdweb/src/contract/deployment/deploy-via-autofactory.test.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { TEST_CLIENT } from "../../../test/src/test-clients.js";
44
import { TEST_ACCOUNT_A } from "../../../test/src/test-wallets.js";
55
import { parseEventLogs } from "../../event/actions/parse-logs.js";
66
import { initialize } from "../../extensions/prebuilts/__generated__/DropERC721/write/initialize.js";
7+
import { deployContractfromDeployMetadata } from "../../extensions/prebuilts/deploy-published.js";
78
import { proxyDeployedV2Event } from "../../extensions/thirdweb/__generated__/IContractFactory/events/ProxyDeployedV2.js";
89
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
910
import { sendTransaction } from "../../transaction/actions/send-transaction.js";
1011
import { keccakId } from "../../utils/any-evm/keccak-id.js";
1112
import { prepareAutoFactoryDeployTransaction } from "./deploy-via-autofactory.js";
13+
import { fetchPublishedContractMetadata } from "./publisher.js";
1214
import { deployCloneFactory, deployImplementation } from "./utils/bootstrap.js";
1315
import { getDeployedCloneFactoryContract } from "./utils/clone-factory.js";
1416
import { getDeployedInfraContract } from "./utils/infra.js";
@@ -123,6 +125,69 @@ describe.runIf(process.env.TW_SECRET_KEY)("deployFromMetadata", () => {
123125
},
124126
);
125127

128+
it.sequential("should deploy with crosschain option", async () => {
129+
const cloneFactoryContract = await getDeployedCloneFactoryContract({
130+
chain: ANVIL_CHAIN,
131+
client: TEST_CLIENT,
132+
});
133+
if (!cloneFactoryContract) {
134+
throw new Error("Clone factory not found");
135+
}
136+
const implementationContract = await getDeployedInfraContract({
137+
chain: ANVIL_CHAIN,
138+
client: TEST_CLIENT,
139+
contractId: "DropERC721",
140+
});
141+
if (!implementationContract) {
142+
throw new Error("Clone factory not found");
143+
}
144+
145+
const initializeTransaction = initialize({
146+
contract: implementationContract,
147+
name: "NFTDrop unified",
148+
symbol: "NFTD",
149+
defaultAdmin: TEST_ACCOUNT_A.address,
150+
platformFeeBps: 0n,
151+
platformFeeRecipient: TEST_ACCOUNT_A.address,
152+
royaltyBps: 0n,
153+
royaltyRecipient: TEST_ACCOUNT_A.address,
154+
saleRecipient: TEST_ACCOUNT_A.address,
155+
trustedForwarders: [],
156+
contractURI: "",
157+
});
158+
159+
const transaction = prepareAutoFactoryDeployTransaction({
160+
chain: ANVIL_CHAIN,
161+
client: TEST_CLIENT,
162+
cloneFactoryContract,
163+
initializeTransaction,
164+
});
165+
const receipt = await sendAndConfirmTransaction({
166+
transaction,
167+
account: TEST_ACCOUNT_A,
168+
});
169+
const proxyEvent = proxyDeployedV2Event();
170+
const decodedEvent = parseEventLogs({
171+
events: [proxyEvent],
172+
logs: receipt.logs,
173+
});
174+
175+
const deployMetadata = await fetchPublishedContractMetadata({
176+
client: TEST_CLIENT,
177+
contractId: "DropERC721",
178+
});
179+
const deployed = await deployContractfromDeployMetadata({
180+
account: TEST_ACCOUNT_A,
181+
chain: ANVIL_CHAIN,
182+
client: TEST_CLIENT,
183+
deployMetadata,
184+
isCrosschain: true,
185+
initializeData: decodedEvent[0]?.args.data,
186+
});
187+
188+
expect(deployed).toBeDefined();
189+
});
190+
126191
it.sequential("should generate salt based on input params", async () => {
127192
const cloneFactoryContract = await getDeployedCloneFactoryContract({
128193
chain: ANVIL_CHAIN,

0 commit comments

Comments
 (0)