1- import { Account , Address , Chain , Client , Hex , Transport , stringToHex } from "viem" ;
1+ import { Address , Hex , stringToHex } from "viem" ;
22import { ensureDeployer } from "./ensureDeployer" ;
33import { deployWorld } from "./deployWorld" ;
44import { ensureTables } from "./ensureTables" ;
5- import { Library , Module , System , WorldDeploy , supportedStoreVersions , supportedWorldVersions } from "./common" ;
5+ import {
6+ CommonDeployOptions ,
7+ Library ,
8+ Module ,
9+ System ,
10+ WorldDeploy ,
11+ supportedStoreVersions ,
12+ supportedWorldVersions ,
13+ } from "./common" ;
614import { ensureSystems } from "./ensureSystems" ;
715import { getWorldDeploy } from "./getWorldDeploy" ;
816import { ensureFunctions } from "./ensureFunctions" ;
@@ -23,7 +31,6 @@ import { getLibraryMap } from "./getLibraryMap";
2331
2432type DeployOptions = {
2533 config : World ;
26- client : Client < Transport , Chain | undefined , Account > ;
2734 tables : readonly Table [ ] ;
2835 systems : readonly System [ ] ;
2936 libraries : readonly Library [ ] ;
@@ -39,7 +46,7 @@ type DeployOptions = {
3946 */
4047 deployerAddress ?: Hex ;
4148 withWorldProxy ?: boolean ;
42- } ;
49+ } & Omit < CommonDeployOptions , "worldDeploy" > ;
4350
4451/**
4552 * Given a viem client and MUD config, we attempt to introspect the world
@@ -58,6 +65,8 @@ export async function deploy({
5865 salt,
5966 worldAddress : existingWorldAddress ,
6067 deployerAddress : initialDeployerAddress ,
68+ indexerUrl,
69+ chainId,
6170} : DeployOptions ) : Promise < WorldDeploy > {
6271 const deployerAddress = initialDeployerAddress ?? ( await ensureDeployer ( client ) ) ;
6372
@@ -77,6 +86,13 @@ export async function deploy({
7786 config . deploy . upgradeableWorldImplementation ,
7887 ) ;
7988
89+ const commonDeployOptions = {
90+ client,
91+ indexerUrl,
92+ chainId,
93+ worldDeploy,
94+ } satisfies CommonDeployOptions ;
95+
8096 if ( ! supportedStoreVersions . includes ( worldDeploy . storeVersion ) ) {
8197 throw new Error ( `Unsupported Store version: ${ worldDeploy . storeVersion } ` ) ;
8298 }
@@ -86,7 +102,7 @@ export async function deploy({
86102
87103 const libraryMap = getLibraryMap ( libraries ) ;
88104 await ensureContractsDeployed ( {
89- client ,
105+ ... commonDeployOptions ,
90106 deployerAddress,
91107 contracts : [
92108 ...libraries . map ( ( library ) => ( {
@@ -108,24 +124,21 @@ export async function deploy({
108124 } ) ;
109125
110126 const namespaceTxs = await ensureNamespaceOwner ( {
111- client,
112- worldDeploy,
127+ ...commonDeployOptions ,
113128 resourceIds : [ ...tables . map ( ( { tableId } ) => tableId ) , ...systems . map ( ( { systemId } ) => systemId ) ] ,
114129 } ) ;
115130 // Wait for namespaces to be available, otherwise referencing them below may fail.
116131 // This is only here because OPStack chains don't let us estimate gas with pending block tag.
117132 await waitForTransactions ( { client, hashes : namespaceTxs , debugLabel : "namespace registrations" } ) ;
118133
119134 const tableTxs = await ensureTables ( {
120- client,
121- worldDeploy,
135+ ...commonDeployOptions ,
122136 tables,
123137 } ) ;
124138 const systemTxs = await ensureSystems ( {
125- client ,
139+ ... commonDeployOptions ,
126140 deployerAddress,
127141 libraryMap,
128- worldDeploy,
129142 systems,
130143 } ) ;
131144 // Wait for tables and systems to be available, otherwise referencing their resource IDs below may fail.
@@ -137,15 +150,13 @@ export async function deploy({
137150 } ) ;
138151
139152 const functionTxs = await ensureFunctions ( {
140- client,
141- worldDeploy,
153+ ...commonDeployOptions ,
142154 functions : systems . flatMap ( ( system ) => system . worldFunctions ) ,
143155 } ) ;
144156 const moduleTxs = await ensureModules ( {
145- client ,
157+ ... commonDeployOptions ,
146158 deployerAddress,
147159 libraryMap,
148- worldDeploy,
149160 modules,
150161 } ) ;
151162
@@ -174,10 +185,9 @@ export async function deploy({
174185 ] ) ;
175186
176187 const tagTxs = await ensureResourceTags ( {
177- client ,
188+ ... commonDeployOptions ,
178189 deployerAddress,
179190 libraryMap,
180- worldDeploy,
181191 tags : [ ...namespaceTags , ...tableTags , ...systemTags ] ,
182192 valueToHex : stringToHex ,
183193 } ) ;
0 commit comments