Skip to content

Commit 67db04d

Browse files
committed
god bless greg it works
1 parent 55158b4 commit 67db04d

File tree

4 files changed

+98
-71
lines changed

4 files changed

+98
-71
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/cross-chain/data-table.tsx

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import { useTxNotifications } from "hooks/useTxNotifications";
3434
import {
3535
ZERO_ADDRESS,
3636
defineChain,
37+
eth_getTransactionCount,
3738
getContract,
39+
getRpcClient,
3840
readContract,
3941
sendTransaction,
4042
waitForReceipt,
@@ -205,44 +207,53 @@ export function DataTable({
205207
client,
206208
});
207209

208-
await Promise.all(
209-
moduleDeployData.map(async (m) => {
210-
let moduleData: `0x${string}` | undefined;
210+
const rpcRequest = getRpcClient({
211+
client,
212+
chain,
213+
});
214+
const currentNonce = await eth_getTransactionCount(rpcRequest, {
215+
address: activeAccount.address,
216+
});
211217

212-
const moduleInstallParams = m.deployMetadata.abi.find(
213-
(abiType) =>
214-
(abiType as AbiFunction).name === "encodeBytesOnInstall",
215-
) as AbiFunction | undefined;
218+
for (const [i, m] of moduleDeployData.entries()) {
219+
let moduleData: `0x${string}` | undefined;
216220

217-
if (m.initializeParams && moduleInstallParams) {
218-
moduleData = encodeAbiParameters(
219-
(
220-
moduleInstallParams.inputs as { name: string; type: string }[]
221-
).map((p) => ({
222-
name: p.name,
223-
type: p.type,
224-
})),
225-
Object.values(m.initializeParams),
226-
);
227-
}
221+
const moduleInstallParams = m.deployMetadata.abi.find(
222+
(abiType) =>
223+
(abiType as AbiFunction).name === "encodeBytesOnInstall",
224+
) as AbiFunction | undefined;
228225

229-
const installTransaction = installPublishedModule({
230-
contract,
231-
account: activeAccount,
232-
moduleName: m.deployMetadata.name,
233-
publisher: m.deployMetadata.publisher,
234-
version: m.deployMetadata.version,
235-
moduleData,
236-
});
226+
if (m.initializeParams && moduleInstallParams) {
227+
moduleData = encodeAbiParameters(
228+
(
229+
moduleInstallParams.inputs as { name: string; type: string }[]
230+
).map((p) => ({
231+
name: p.name,
232+
type: p.type,
233+
})),
234+
Object.values(m.initializeParams),
235+
);
236+
}
237237

238-
const txResult = await sendTransaction({
239-
transaction: installTransaction,
240-
account: activeAccount,
241-
});
238+
const installTransaction = installPublishedModule({
239+
contract,
240+
account: activeAccount,
241+
moduleName: m.deployMetadata.name,
242+
publisher: m.deployMetadata.publisher,
243+
version: m.deployMetadata.version,
244+
moduleData,
245+
nonce: currentNonce + i,
246+
});
242247

243-
return await waitForReceipt(txResult);
244-
}),
245-
);
248+
const txResult = await sendTransaction({
249+
transaction: installTransaction,
250+
account: activeAccount,
251+
});
252+
253+
await waitForReceipt(txResult);
254+
// can't handle parallel transactions, so wait a bit
255+
await new Promise((resolve) => setTimeout(resolve, 1000));
256+
}
246257
}
247258

248259
deployStatusModal.nextStep();

apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import { useCallback, useMemo } from "react";
2828
import { FormProvider, type UseFormReturn, useForm } from "react-hook-form";
2929
import {
3030
ZERO_ADDRESS,
31+
eth_getTransactionCount,
3132
getContract,
33+
getRpcClient,
3234
sendTransaction,
3335
waitForReceipt,
3436
} from "thirdweb";
@@ -478,45 +480,54 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
478480
chain: walletChain,
479481
});
480482

481-
if (isSuperchainInterop && moduleDeployData) {
482-
await Promise.allSettled(
483-
moduleDeployData.map(async (m) => {
484-
let moduleData: `0x${string}` | undefined;
485-
486-
const moduleInstallParams = m.deployMetadata.abi.find(
487-
(abiType) =>
488-
(abiType as AbiFunction).name === "encodeBytesOnInstall",
489-
) as AbiFunction | undefined;
490-
491-
if (m.initializeParams && moduleInstallParams) {
492-
moduleData = encodeAbiParameters(
493-
(
494-
moduleInstallParams.inputs as { name: string; type: string }[]
495-
).map((p) => ({
496-
name: p.name,
497-
type: p.type,
498-
})),
499-
Object.values(m.initializeParams),
500-
);
501-
}
502-
503-
const installTransaction = installPublishedModule({
504-
contract: coreContract,
505-
account: activeAccount,
506-
moduleName: m.deployMetadata.name,
507-
publisher: m.deployMetadata.publisher,
508-
version: m.deployMetadata.version,
509-
moduleData,
510-
});
483+
const rpcRequest = getRpcClient({
484+
client: thirdwebClient,
485+
chain: walletChain,
486+
});
487+
const currentNonce = await eth_getTransactionCount(rpcRequest, {
488+
address: activeAccount.address,
489+
});
511490

512-
const txResult = await sendTransaction({
513-
transaction: installTransaction,
514-
account: activeAccount,
515-
});
491+
if (isSuperchainInterop && moduleDeployData) {
492+
for (const [i, m] of moduleDeployData.entries()) {
493+
let moduleData: `0x${string}` | undefined;
494+
495+
const moduleInstallParams = m.deployMetadata.abi.find(
496+
(abiType) =>
497+
(abiType as AbiFunction).name === "encodeBytesOnInstall",
498+
) as AbiFunction | undefined;
499+
500+
if (m.initializeParams && moduleInstallParams) {
501+
moduleData = encodeAbiParameters(
502+
(
503+
moduleInstallParams.inputs as { name: string; type: string }[]
504+
).map((p) => ({
505+
name: p.name,
506+
type: p.type,
507+
})),
508+
Object.values(m.initializeParams),
509+
);
510+
}
516511

517-
return await waitForReceipt(txResult);
518-
}),
519-
);
512+
const installTransaction = installPublishedModule({
513+
contract: coreContract,
514+
account: activeAccount,
515+
moduleName: m.deployMetadata.name,
516+
publisher: m.deployMetadata.publisher,
517+
version: m.deployMetadata.version,
518+
moduleData,
519+
nonce: currentNonce + i,
520+
});
521+
522+
const txResult = await sendTransaction({
523+
transaction: installTransaction,
524+
account: activeAccount,
525+
});
526+
527+
await waitForReceipt(txResult);
528+
// can't handle parallel transactions, so wait a bit
529+
await new Promise((resolve) => setTimeout(resolve, 1000));
530+
}
520531
}
521532

522533
return coreContractAddress;

packages/thirdweb/src/extensions/modules/common/installPublishedModule.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type InstallPublishedModuleOptions = {
1414
version?: string;
1515
constructorParams?: Record<string, unknown>;
1616
moduleData?: `0x${string}`;
17+
nonce?: number;
1718
};
1819

1920
/**
@@ -43,10 +44,14 @@ export function installPublishedModule(options: InstallPublishedModuleOptions) {
4344
constructorParams,
4445
publisher,
4546
moduleData,
47+
nonce,
4648
} = options;
4749

4850
return installModule({
4951
contract,
52+
overrides: {
53+
nonce,
54+
},
5055
asyncParams: async () => {
5156
const deployedModule = await getOrDeployInfraForPublishedContract({
5257
chain: contract.chain,

packages/thirdweb/src/extensions/prebuilts/deploy-published.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export async function deployContractfromDeployMetadata(
217217
account,
218218
modules,
219219
});
220-
return await deployViaAutoFactory({
220+
return deployViaAutoFactory({
221221
client,
222222
chain,
223223
account,

0 commit comments

Comments
 (0)