@moltium/world-cli 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
#!/usr/bin/env node
|
|
3
2
|
|
|
4
3
|
// src/index.ts
|
|
5
4
|
import { Command as Command5 } from "commander";
|
|
@@ -89,7 +88,7 @@ ${options.tokenType === "custom" ? "WORLD_TOKEN_ADDRESS=\n" : ""}
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
// src/templates/world-template.ts
|
|
92
|
-
function generateWorldTemplate(
|
|
91
|
+
function generateWorldTemplate(config3) {
|
|
93
92
|
const files = {};
|
|
94
93
|
files["src/index.ts"] = `import { World } from '@moltium/world-core';
|
|
95
94
|
import { loadWorldConfig } from '@moltium/world-core/config';
|
|
@@ -111,7 +110,7 @@ async function main() {
|
|
|
111
110
|
// Start HTTP server
|
|
112
111
|
await startWorldServer(world);
|
|
113
112
|
|
|
114
|
-
console.log(\`\u{1F30D} ${
|
|
113
|
+
console.log(\`\u{1F30D} ${config3.name} is running!\`);
|
|
115
114
|
console.log(\` Server: http://\${config.server.host}:\${config.server.port}\`);
|
|
116
115
|
console.log(\` Agents: \${world.getAgents().length}/\${config.admission.maxAgents}\`);
|
|
117
116
|
|
|
@@ -128,9 +127,9 @@ main().catch((error) => {
|
|
|
128
127
|
process.exit(1);
|
|
129
128
|
});
|
|
130
129
|
`;
|
|
131
|
-
if (
|
|
130
|
+
if (config3.worldType === "game") {
|
|
132
131
|
files["src/game-logic.ts"] = generateGameLogic();
|
|
133
|
-
} else if (
|
|
132
|
+
} else if (config3.worldType === "marketplace") {
|
|
134
133
|
files["src/marketplace-logic.ts"] = generateMarketplaceLogic();
|
|
135
134
|
}
|
|
136
135
|
return files;
|
|
@@ -453,10 +452,10 @@ var initCommand = new Command("init").description("Initialize a new world projec
|
|
|
453
452
|
process.exit(1);
|
|
454
453
|
}
|
|
455
454
|
});
|
|
456
|
-
function generateReadme(
|
|
457
|
-
return `# ${
|
|
455
|
+
function generateReadme(config3) {
|
|
456
|
+
return `# ${config3.name}
|
|
458
457
|
|
|
459
|
-
${
|
|
458
|
+
${config3.description}
|
|
460
459
|
|
|
461
460
|
## Getting Started
|
|
462
461
|
|
|
@@ -464,7 +463,7 @@ ${config.description}
|
|
|
464
463
|
# Install dependencies
|
|
465
464
|
npm install
|
|
466
465
|
|
|
467
|
-
${
|
|
466
|
+
${config3.hasCustomToken ? "# Deploy custom token\nnpm run token:deploy\n" : ""}# Deploy smart contracts
|
|
468
467
|
npm run deploy:contracts
|
|
469
468
|
|
|
470
469
|
# Start world server
|
|
@@ -474,11 +473,11 @@ npm run dev
|
|
|
474
473
|
## Configuration
|
|
475
474
|
|
|
476
475
|
- **World config:** \`world.config.json\`
|
|
477
|
-
${
|
|
476
|
+
${config3.hasCustomToken ? "- **Token config:** `token.config.json`\n" : ""}- **Environment:** \`.env\`
|
|
478
477
|
|
|
479
478
|
## Token Type
|
|
480
479
|
|
|
481
|
-
${
|
|
480
|
+
${config3.tokenType === "native" ? "**Native (MON)** - This world uses Monad's native currency for transactions." : "**Custom ERC20** - This world has its own custom token. Deploy it using `npm run token:deploy`."}
|
|
482
481
|
|
|
483
482
|
## Commands
|
|
484
483
|
|
|
@@ -486,7 +485,7 @@ ${config.tokenType === "native" ? "**Native (MON)** - This world uses Monad's na
|
|
|
486
485
|
- \`npm run build\` - Build for production
|
|
487
486
|
- \`npm run start\` - Start production server
|
|
488
487
|
- \`npm run deploy:contracts\` - Deploy smart contracts to Monad
|
|
489
|
-
${
|
|
488
|
+
${config3.hasCustomToken ? "- `npm run token:deploy` - Deploy custom token\n- `npm run token:verify` - Verify token contract\n" : ""}
|
|
490
489
|
## Documentation
|
|
491
490
|
|
|
492
491
|
For more information, visit: https://moltium.world/docs
|
|
@@ -500,6 +499,7 @@ import ora2 from "ora";
|
|
|
500
499
|
import fs3 from "fs/promises";
|
|
501
500
|
import path3 from "path";
|
|
502
501
|
import { execSync } from "child_process";
|
|
502
|
+
import { config } from "dotenv";
|
|
503
503
|
|
|
504
504
|
// src/lib/config-loader.ts
|
|
505
505
|
import fs2 from "fs/promises";
|
|
@@ -550,6 +550,7 @@ var tokenCommand = new Command2("token").description("Manage world token deploym
|
|
|
550
550
|
tokenCommand.command("deploy").description("Deploy custom ERC20 token").option("-c, --config <path>", "Token config file", "./token.config.json").option("-r, --rpc-url <url>", "RPC URL (overrides .env)").option("-s, --silent", "No interactive prompts").action(async (options) => {
|
|
551
551
|
console.log(chalk2.bold.cyan("\n\u{1FA99} Deploying Custom Token\n"));
|
|
552
552
|
try {
|
|
553
|
+
config({ path: path3.join(process.cwd(), ".env") });
|
|
553
554
|
const spinner = ora2("Loading configuration...").start();
|
|
554
555
|
const tokenConfig = await loadTokenConfig(options.config);
|
|
555
556
|
spinner.text = "Checking environment...";
|
|
@@ -594,7 +595,7 @@ tokenCommand.command("deploy").description("Deploy custom ERC20 token").option("
|
|
|
594
595
|
TOKEN_MAX_SUPPLY: tokenConfig.maxSupply?.toString() || "0",
|
|
595
596
|
TOKEN_DECIMALS: tokenConfig.decimals?.toString() || "18"
|
|
596
597
|
};
|
|
597
|
-
const worldCorePath = path3.join(process.cwd(), "
|
|
598
|
+
const worldCorePath = path3.join(process.cwd(), "node_modules", "@moltium", "world-core");
|
|
598
599
|
const command = `forge script script/DeployToken.s.sol:DeployTokenScript --rpc-url monad --broadcast -vvv`;
|
|
599
600
|
const output = execSync(command, {
|
|
600
601
|
cwd: worldCorePath,
|
|
@@ -662,7 +663,7 @@ tokenCommand.command("verify").description("Verify token contract on Sourcify").
|
|
|
662
663
|
console.log(` ${chalk2.gray("Contract:")} ${tokenAddress}\\n`);
|
|
663
664
|
const spinner = ora2("Verifying on Sourcify...").start();
|
|
664
665
|
try {
|
|
665
|
-
const worldCorePath = path3.join(process.cwd(), "
|
|
666
|
+
const worldCorePath = path3.join(process.cwd(), "node_modules", "@moltium", "world-core");
|
|
666
667
|
const command = `MONAD_ETHERSCAN_KEY="" forge verify-contract ${tokenAddress} contracts/WorldToken.sol:WorldToken --chain 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org/`;
|
|
667
668
|
execSync(command, {
|
|
668
669
|
cwd: worldCorePath,
|
|
@@ -714,9 +715,11 @@ import chalk4 from "chalk";
|
|
|
714
715
|
import ora4 from "ora";
|
|
715
716
|
import { execSync as execSync3 } from "child_process";
|
|
716
717
|
import path4 from "path";
|
|
718
|
+
import { config as config2 } from "dotenv";
|
|
717
719
|
var deployCommand = new Command4("deploy").description("Deploy smart contracts to Monad").option("-r, --rpc-url <url>", "RPC URL (overrides .env)").action(async (options) => {
|
|
718
720
|
console.log(chalk4.bold.cyan("\\n\u{1F680} Deploying Smart Contracts\\n"));
|
|
719
721
|
try {
|
|
722
|
+
config2({ path: path4.join(process.cwd(), ".env") });
|
|
720
723
|
const spinner = ora4("Checking environment...").start();
|
|
721
724
|
const privateKey = process.env.DEPLOYER_PRIVATE_KEY;
|
|
722
725
|
if (!privateKey) {
|
|
@@ -736,7 +739,7 @@ var deployCommand = new Command4("deploy").description("Deploy smart contracts t
|
|
|
736
739
|
console.log(` ${chalk4.gray("RPC URL:")} ${rpcUrl}\\n`);
|
|
737
740
|
const deploySpinner = ora4("Deploying AgentRegistry...").start();
|
|
738
741
|
try {
|
|
739
|
-
const worldCorePath = path4.join(process.cwd(), "
|
|
742
|
+
const worldCorePath = path4.join(process.cwd(), "node_modules", "@moltium", "world-core");
|
|
740
743
|
const env = {
|
|
741
744
|
...process.env,
|
|
742
745
|
MONAD_RPC_URL: rpcUrl,
|