Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): wait for world init before transferring ownership
Browse files Browse the repository at this point in the history
alvrs committed Sep 23, 2024
1 parent 0f5b291 commit 9b6e041
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions packages/cli/src/deploy/deployCustomWorld.ts
Original file line number Diff line number Diff line change
@@ -97,26 +97,25 @@ export async function deployCustomWorld({
const deploy = logsToWorldDeploy(receipt.logs);
debug("deployed custom world to", deploy.address, "at block", deploy.deployBlock);

const initTxs = await Promise.all([
// initialize world via init module
writeContract(client, {
chain: client.chain ?? null,
address: deploy.address,
abi: worldAbi,
functionName: "initialize",
args: [contracts.InitModule.address],
}),
// transfer root namespace to deployer
writeContract(client, {
chain: client.chain ?? null,
address: deploy.address,
abi: worldAbi,
functionName: "transferOwnership",
args: [resourceToHex({ type: "namespace", namespace: "", name: "" }), client.account.address],
}),
]);
// initialize world via init module
const initTx = await writeContract(client, {
chain: client.chain ?? null,
address: deploy.address,
abi: worldAbi,
functionName: "initialize",
args: [contracts.InitModule.address],
});
await waitForTransactions({ client, hashes: [initTx], debugLabel: "world init" });

await waitForTransactions({ client, hashes: initTxs, debugLabel: "world init" });
// transfer root namespace to deployer after init module is installed so `transferOwnership` method is available
const transferOwnershipTx = await writeContract(client, {
chain: client.chain ?? null,
address: deploy.address,
abi: worldAbi,
functionName: "transferOwnership",
args: [resourceToHex({ type: "namespace", namespace: "", name: "" }), client.account.address],
});
await waitForTransactions({ client, hashes: [transferOwnershipTx], debugLabel: "world ownership transfer" });

return { ...deploy, stateBlock: deploy.deployBlock };
}

0 comments on commit 9b6e041

Please sign in to comment.