Skip to content

Commit

Permalink
feat(cli): use namespace override
Browse files Browse the repository at this point in the history
  • Loading branch information
dk1a committed May 23, 2023
1 parent f2f9b08 commit 7c4c3f4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/cli/src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function deploy(
const resolvedConfig = resolveWorldConfig(mudConfig, existingContracts);

const startTime = Date.now();
const { worldContractName, namespace, postDeployScript } = mudConfig;
const { worldContractName, postDeployScript } = mudConfig;
const { profile, rpc, privateKey, priorityFeeMultiplier, debug, worldAddress, disableTxWait, pollInterval } =
deployConfig;
const forgeOutDirectory = await getOutDirectory(profile);
Expand Down Expand Up @@ -141,14 +141,17 @@ export async function deploy(
console.log(chalk.green("Installed core World modules"));
}

// Register namespace
if (namespace) await fastTxExecute(WorldContract, "registerNamespace", [toBytes16(namespace)], confirmations);
// Register namespaces
const namespaces = new Set(Object.values(mudConfig.tables).map(({ namespace }) => namespace));
for (const namespace of namespaces) {
if (namespace) await fastTxExecute(WorldContract, "registerNamespace", [toBytes16(namespace)], confirmations);
}

// Register tables
const tableIds: { [tableName: string]: Uint8Array } = {};
promises = [
...promises,
...Object.entries(mudConfig.tables).map(async ([tableName, { name, schema, keySchema }]) => {
...Object.entries(mudConfig.tables).map(async ([tableName, { namespace, name, schema, keySchema }]) => {
console.log(chalk.blue(`Registering table ${tableName} at ${namespace}/${name}`));

// Store the tableId for later use
Expand Down Expand Up @@ -188,7 +191,7 @@ export async function deploy(
promises = [
...promises,
...Object.entries(resolvedConfig.systems).map(
async ([systemName, { name, openAccess, registerFunctionSelectors }]) => {
async ([systemName, { namespace, name, openAccess, registerFunctionSelectors }]) => {
// Register system at route
console.log(chalk.blue(`Registering system ${systemName} at ${namespace}/${name}`));
await fastTxExecute(
Expand Down Expand Up @@ -245,7 +248,9 @@ export async function deploy(
promises = [];

// Grant access to systems
for (const [systemName, { name, accessListAddresses, accessListSystems }] of Object.entries(resolvedConfig.systems)) {
for (const [systemName, { namespace, name, accessListAddresses, accessListSystems }] of Object.entries(
resolvedConfig.systems
)) {
const resourceSelector = `${namespace}/${name}`;

// Grant access to addresses
Expand Down

0 comments on commit 7c4c3f4

Please sign in to comment.