@0xobelisk/sui-cli 1.2.0-pre.33 โ 1.2.0-pre.34
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/dubhe.js +1 -1
- package/dist/dubhe.js.map +1 -1
- package/package.json +3 -3
package/dist/dubhe.js
CHANGED
|
@@ -12,7 +12,7 @@ Welcome to Dubhe
|
|
|
12
12
|
|
|
13
13
|
`))}import{Transaction as L}from"@0xobelisk/sui-client";import{execSync as nt}from"child_process";import y from"chalk";import*as G from"fs/promises";import{mkdirSync as Ye,writeFileSync as We}from"fs";import{dirname as Je}from"path";import{SUI_PRIVATE_KEY_PREFIX as Ge}from"@mysten/sui/cryptography";import N from"chalk";import{ZodError as Le}from"zod";import{fromZodError as He,ValidationError as Be}from"zod-validation-error";var W=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"},v=class extends Error{name="DubheCliError"};function _(e){if(e instanceof Be)console.log(N.redBright(e.message));else if(e instanceof Le){let t=He(e,{prefixSeparator:`
|
|
14
14
|
- `,issueSeparator:`
|
|
15
|
-
- `});console.log(N.redBright(t.message))}else e instanceof W?(console.log(N.red(e.message)),console.log(""),console.log(N.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof v?console.log(N.red(e)):console.log(e)}import*as D from"fs";import x from"chalk";import{spawn as ne}from"child_process";import{Dubhe as Xe,loadMetadata as Ze}from"@0xobelisk/sui-client";var M={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.
|
|
15
|
+
- `});console.log(N.redBright(t.message))}else e instanceof W?(console.log(N.red(e.message)),console.log(""),console.log(N.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof v?console.log(N.red(e)):console.log(e)}import*as D from"fs";import x from"chalk";import{spawn as ne}from"child_process";import{Dubhe as Xe,loadMetadata as Ze}from"@0xobelisk/sui-client";var M={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.34",description:"Tookit for interacting with move eps framework",keywords:["sui","obelisk labs","move","blockchain"],type:"module",author:"team@obelisk.build",homepage:"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme",bugs:"https://github.com/0xobelisk/dubhe/issues",repository:{type:"git",url:"https://github.com/0xobelisk/dubhe.git"},license:"Apache-2.0",publishConfig:{access:"public"},engines:{node:">=18"},exports:{".":"./dist/index.js"},types:"src/index.ts",bin:{dubhe:"./dist/dubhe.js"},scripts:{build:"pnpm run type-check && pnpm run build:js","build:js":"tsup && chmod +x ./dist/dubhe.js",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch",lint:"eslint . --ext .ts",format:"prettier --write .","format:check":"prettier --check .","type-check":"tsc --noEmit",validate:"pnpm format:check && pnpm type-check"},dependencies:{"@0xobelisk/sui-client":"workspace:*","@0xobelisk/sui-common":"workspace:*","@mysten/sui":"^1.19.0","@types/sqlite3":"^3.1.11","@types/wait-on":"^5.3.4",chalk:"^5.0.1",child_process:"^1.0.2",chokidar:"^3.5.3","cli-table3":"^0.6.5",dotenv:"^16.0.3",ejs:"^3.1.8",execa:"^7.0.0",glob:"^8.0.3",ora:"^5.4.1",path:"^0.12.7",sqlite:"^5.1.1",sqlite3:"^5.1.7",typescript:"5.1.6","wait-on":"^7.0.1",yargs:"^17.7.1",zod:"^3.22.3","zod-validation-error":"^1.3.0"},devDependencies:{"@types/ejs":"^3.1.1","@types/glob":"^7.2.0","@types/node":"^18.15.11","@types/yargs":"^17.0.10",eslint:"^8.56.0","eslint-config-prettier":"^9.1.0",prettier:"3.3.3","ts-node":"^10.9.1",tsup:"^6.7.0",tsx:"^3.12.6",vitest:"0.31.4"}};function X(e){if(e.startsWith(Ge))return e.length===70?e:!1;if(e.startsWith("0x")){let t=e.slice(2);return t.length===64?t:!1}else return e.length===64?e:!1}async function Z(e,t){try{let o=await G.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch(o){throw new Error(`read .history/sui_${t}/latest.json failed. ${o}`)}}async function V(e,t){try{let o=await G.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o).dappHub}catch{return""}}async function K(e){let o=`${process.cwd()}/src/dubhe`;switch(e){case"mainnet":return await V(o,"mainnet");case"testnet":return await V(o,"testnet");case"devnet":return await V(o,"devnet");case"localnet":return await V(o,"localnet");default:throw new Error(`Invalid network: ${e}`)}}async function se(e,t){return(await Z(e,t)).packageId}async function Q(e,t,o,n,s,r,i){let a={projectName:e,network:t,packageId:o,dappHub:n,components:i,upgradeCap:s,version:r},l=process.cwd(),c=JSON.stringify(a,null,2);await J(c,`${l}/src/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function O(e,t,o){let n=process.cwd();try{let s=await Ze(t,o);if(s){let r=JSON.stringify(s,null,2);await J(r,`${n}/src/${e}/.history/sui_${t}/${o}.json`,"Save package metadata"),await J(r,`${n}/metadata.json`,"Save latest metadata")}}catch(s){console.warn(x.yellow(`Warning: Failed to save metadata: ${s}`))}}async function J(e,t,o){Ye(Je(t),{recursive:!0}),We(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function Qe(e){switch(e){case"localnet":return'Dubhe = { local = "../dubhe" }';case"testnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe-wip.git", subdir = "packages/sui-framework/src/dubhe", rev = "v${M.version}" }`;case"mainnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe-wip.git", subdir = "packages/sui-framework/src/dubhe", rev = "v${M.version}" }`;default:throw new Error(`Unsupported network: ${e}`)}}async function q(e,t){let o=D.readFileSync(e,"utf-8"),n=Qe(t),s=o.replace(/Dubhe = \{.*\}/,n);D.writeFileSync(e,s,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function et(e){try{let t=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"sui_getLatestCheckpointSequenceNumber",params:[]})});return t.ok?!(await t.json()).error:!1}catch{return!1}}async function tt(e){let t={localnet:"http://127.0.0.1:9000",devnet:"https://fullnode.devnet.sui.io:443/",testnet:"https://fullnode.testnet.sui.io:443/",mainnet:"https://fullnode.mainnet.sui.io:443/"},o=t[e];if(!await et(o))throw new Error(`RPC endpoint ${o} is not available. Please check your network connection or try again later.`);return new Promise((s,r)=>{let i="",a="",l=ne("sui",["client","new-env","--alias",e,"--rpc",t[e]],{env:{...process.env},stdio:"pipe"});l.stdout.on("data",c=>{a+=c.toString()}),l.stderr.on("data",c=>{i+=c.toString()}),l.on("error",c=>{console.error(x.red(`
|
|
16
16
|
\u274C Failed to execute sui command: ${c.message}`)),r(new Error(`Failed to execute sui command: ${c.message}`))}),l.on("exit",c=>{if(i.includes("already exists")||a.includes("already exists")){console.log(x.yellow(`Environment ${e} already exists, proceeding...`)),s();return}if(c===0)console.log(x.green(`Successfully added environment ${e}`)),s();else{let g=i||a||`Process exited with code ${c}`;console.error(x.red(`
|
|
17
17
|
\u274C Failed to add environment ${e}`)),console.error(x.red(` \u2514\u2500 ${g.trim()}`)),r(new Error(g))}})})}async function I(e){try{return await tt(e),new Promise((t,o)=>{let n="",s="",r=ne("sui",["client","switch","--env",e],{env:{...process.env},stdio:"pipe"});r.stdout.on("data",i=>{s+=i.toString()}),r.stderr.on("data",i=>{n+=i.toString()}),r.on("error",i=>{console.error(x.red(`
|
|
18
18
|
\u274C Failed to execute sui command: ${i.message}`)),o(new Error(`Failed to execute sui command: ${i.message}`))}),r.on("exit",i=>{if(i===0)console.log(x.green(`Successfully switched to environment ${e}`)),t();else{let a=n||s||`Process exited with code ${i}`;console.error(x.red(`
|
package/dist/dubhe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dubhe.ts","../src/utils/startNode.ts","../src/utils/printDubhe.ts","../src/utils/publishHandler.ts","../src/utils/utils.ts","../src/utils/errors.ts","../package.json","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/commands/test.ts","../src/commands/build.ts","../src/commands/hello.ts","../src/utils/generateAccount.ts","../src/commands/generateKey.ts","../src/utils/checkBalance.ts","../src/commands/checkBalance.ts","../src/utils/storeConfig.ts","../src/commands/configStore.ts","../src/commands/watch.ts","../src/commands/wait.ts","../src/commands/switchEnv.ts","../src/commands/info.ts","../src/commands/loadMetadata.ts","../src/utils/metadataHandler.ts","../src/commands/doctor.ts","../src/commands/convertJson.ts","../src/commands/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport chalk from 'chalk';\nimport { commands } from './commands';\nimport { logError } from './utils/errors';\nimport packageJson from '../package.json';\n\n// Load .env file into process.env\nimport * as dotenv from 'dotenv';\ndotenv.config();\n\nyargs(hideBin(process.argv))\n // Explicit name to display in help (by default it's the entry file, which may not be \"dubhe\" for e.g. ts-node)\n .scriptName('dubhe')\n // Use the commands directory to scaffold\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy\n .command(commands as any)\n .version(packageJson.version)\n .demandCommand(1, 'Please provide a command')\n .recommendCommands()\n // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg, err) => {\n console.error(chalk.red(msg));\n\n if (msg.includes('Missing required argument')) {\n console.log(\n chalk.yellow(\n `Run 'pnpm dubhe ${process.argv[2]} --help' for a list of available and required arguments.`\n )\n );\n }\n console.log('');\n // Even though `.fail` type says we should get an `Error`, this can sometimes be undefined\n if (err != null) {\n logError(err);\n console.log('');\n }\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: 'help' }).argv;\n","import { execSync, spawn } from 'child_process';\nimport chalk from 'chalk';\nimport { printDubhe } from './printDubhe';\nimport { delay, DubheCliError, validatePrivateKey } from '../utils';\nimport { Dubhe } from '@0xobelisk/sui-client';\nimport * as fs from 'fs';\n\nexport function stopLocalNode(): void {\n console.log(chalk.yellow('๐ Stopping existing Local Node...'));\n\n let processStopped = false;\n\n if (process.platform === 'win32') {\n // Windows: Kill all sui.exe processes\n try {\n execSync('taskkill /F /IM sui.exe', { stdio: 'ignore' });\n processStopped = true;\n } catch (error) {\n // Process not found\n }\n } else {\n // Unix-like systems: Try multiple patterns to find sui processes\n const patterns = [\n 'sui start', // Exact match\n 'sui.*start', // Pattern with any flags\n '^sui', // Any sui command\n 'sui.*--with-faucet' // Match our specific startup pattern\n ];\n\n for (const pattern of patterns) {\n try {\n const result = execSync(`pgrep -f \"${pattern}\"`, { stdio: 'pipe' }).toString().trim();\n if (result) {\n const pids = result.split('\\n').filter((pid) => pid);\n console.log(chalk.cyan(` โโ Found ${pids.length} process(es) matching \"${pattern}\"`));\n\n pids.forEach((pid) => {\n try {\n // First try graceful termination\n execSync(`kill -TERM ${pid}`, { stdio: 'ignore' });\n console.log(chalk.cyan(` โโ Sent SIGTERM to process ${pid}`));\n } catch (error) {\n // If graceful termination fails, force kill\n try {\n execSync(`kill -KILL ${pid}`, { stdio: 'ignore' });\n console.log(chalk.cyan(` โโ Force killed process ${pid}`));\n } catch (killError) {\n console.log(chalk.gray(` โโ Process ${pid} already terminated`));\n }\n }\n });\n processStopped = true;\n break; // Stop after first successful pattern match\n }\n } catch (error) {\n // This pattern didn't match any processes, continue to next pattern\n continue;\n }\n }\n }\n\n if (processStopped) {\n console.log(chalk.green(' โโ Local Node stopped successfully'));\n } else {\n console.log(chalk.gray(' โโ No running Local Node found'));\n }\n}\n\nexport function removeDirectory(dirPath: string): void {\n try {\n if (fs.existsSync(dirPath)) {\n console.log(chalk.yellow(`๐๏ธ Removing directory: ${dirPath}`));\n fs.rmSync(dirPath, { recursive: true, force: true });\n console.log(chalk.green(' โโ Directory removed successfully'));\n } else {\n console.log(chalk.gray(` โโ Directory ${dirPath} does not exist`));\n }\n } catch (error: any) {\n console.error(chalk.red(` โโ Error removing directory: ${error.message}`));\n }\n}\n\nfunction isSuiStartRunning(): boolean {\n try {\n if (process.platform === 'win32') {\n const result = execSync(`tasklist /FI \"IMAGENAME eq sui.exe\" /FO CSV /NH`).toString().trim();\n return result.toLowerCase().includes('sui.exe');\n } else {\n // Try multiple patterns to detect running sui processes\n const patterns = ['sui start', 'sui.*start', '^sui', 'sui.*--with-faucet'];\n\n for (const pattern of patterns) {\n try {\n const result = execSync(`pgrep -f \"${pattern}\"`, { stdio: 'pipe' }).toString().trim();\n if (result && result.length > 0) {\n return true;\n }\n } catch (error) {\n continue;\n }\n }\n return false;\n }\n } catch (error) {\n return false;\n }\n}\n\nasync function printAccounts() {\n // These private keys are used for testing purposes only, do not use them in production.\n const privateKeys = [\n 'suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v',\n 'suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s',\n 'suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc',\n 'suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c',\n 'suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57',\n 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'\n ];\n console.log('๐Accounts');\n console.log('==========');\n privateKeys.forEach((privateKey, index) => {\n const dubhe = new Dubhe({ secretKey: privateKey });\n const keypair = dubhe.getSigner();\n spawn(\n 'curl',\n [\n '--location',\n '--request',\n 'POST',\n 'http://127.0.0.1:9123/gas',\n '--header',\n 'Content-Type: application/json',\n '--data-raw',\n `{\"FixedAmountRequest\": {\"recipient\": \"${keypair.toSuiAddress()}\"}}`\n ],\n {\n env: { ...process.env },\n stdio: 'ignore',\n detached: true\n }\n );\n console.log(` โโ Account #${index}: ${keypair.toSuiAddress()}(1000 SUI)`);\n console.log(` โโ Private Key: ${privateKey}`);\n });\n console.log('==========');\n console.log(\n chalk.yellow('โน๏ธ WARNING: These accounts, and their private keys, are publicly known.')\n );\n console.log(\n chalk.yellow('Any funds sent to them on Mainnet or any other live network WILL BE LOST.')\n );\n}\n\nfunction handleProcessSignals(suiProcess: ReturnType<typeof spawn> | null) {\n const cleanup = () => {\n console.log(chalk.yellow('\\n๐ Stopping Local Node...'));\n if (suiProcess) {\n suiProcess.kill('SIGINT');\n }\n process.exit(0);\n };\n\n process.on('SIGINT', cleanup);\n process.on('SIGTERM', cleanup);\n}\n\nexport async function startLocalNode(data_dir: string, force?: boolean) {\n if (force) {\n console.log(chalk.cyan('\\n๐ Force mode enabled'));\n stopLocalNode();\n console.log(chalk.yellow(' โโ Waiting for processes to terminate...'));\n await delay(3000); // Wait longer for process to fully stop\n removeDirectory(data_dir);\n console.log('');\n } else if (isSuiStartRunning()) {\n console.log(chalk.yellow('\\nโ ๏ธ Warning: Local Node Already Running'));\n console.log(chalk.yellow(' โโ Cannot start a new instance'));\n console.log(chalk.yellow(' โโ Please stop the existing process first'));\n return;\n }\n\n printDubhe();\n console.log('๐ Starting Local Node...');\n let suiProcess: ReturnType<typeof spawn> | null = null;\n try {\n suiProcess = spawn(\n 'sui',\n ['start', '--with-faucet', '--force-regenesis', '--data-ingestion-dir', data_dir],\n {\n env: { ...process.env, RUST_LOG: 'off,sui_node=info' },\n stdio: 'ignore'\n }\n );\n\n suiProcess.on('error', (error) => {\n console.error(chalk.red('\\nโ Failed to Start Local Node'));\n console.error(chalk.red(` โโ Error: ${error.message}`));\n });\n await delay(5000);\n console.log(' โโ Faucet: Enabled');\n console.log(' โโ Force Regenesis: Yes');\n console.log(' โโ HTTP server: http://127.0.0.1:9000/');\n console.log(' โโ Faucet server: http://127.0.0.1:9123/');\n\n await printAccounts();\n\n await delay(2000);\n\n const privateKeyFormat = validatePrivateKey(\n 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'\n );\n if (privateKeyFormat === false) {\n throw new DubheCliError(`Please check your privateKey.`);\n }\n\n console.log(chalk.green('๐ Local environment is ready!'));\n\n handleProcessSignals(suiProcess);\n\n await new Promise<void>((resolve) => {\n suiProcess?.on('exit', () => resolve());\n });\n } catch (error: any) {\n console.error(chalk.red('\\nโ Failed to Start Local Node'));\n console.error(chalk.red(` โโ Error: ${error.message}`));\n if (suiProcess) {\n suiProcess.kill('SIGINT');\n }\n process.exit(1);\n }\n}\n","import chalk from 'chalk';\n\nexport function printDubhe() {\n console.log(\n chalk.yellow(`\nWelcome to Dubhe\n\\t\\t\\t --from team@obelisk\n ________ ___ ___ ________ ___ ___ _______ \n |\\\\ ___ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ __ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ ___ \\\\ \n \\\\ \\\\ \\\\_|\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ /\\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __/| \n \\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __ \\\\ \\\\ __ \\\\ \\\\ \\\\_|/__ \n \\\\ \\\\ \\\\_\\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\_|\\\\ \\\\ \n \\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\__\\\\ \\\\__\\\\ \\\\_______\\\\\n \\\\|_______|\\\\|_______|\\\\|_______|\\\\|__|\\\\|__|\\\\|_______| \n \n`)\n );\n}\n","import { Dubhe, Transaction } from '@0xobelisk/sui-client';\nimport { execSync } from 'child_process';\nimport chalk from 'chalk';\nimport {\n saveContractData,\n updateDubheDependency,\n updateMoveTomlAddress,\n switchEnv,\n delay,\n getDubheDappHub,\n initializeDubhe,\n saveMetadata\n} from './utils';\nimport { DubheConfig } from '@0xobelisk/sui-common';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nasync function removeEnvContent(\n filePath: string,\n networkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n): Promise<void> {\n if (!fs.existsSync(filePath)) {\n return;\n }\n const content = fs.readFileSync(filePath, 'utf-8');\n const regex = new RegExp(`\\\\[env\\\\.${networkType}\\\\][\\\\s\\\\S]*?(?=\\\\[|$)`, 'g');\n const updatedContent = content.replace(regex, '');\n fs.writeFileSync(filePath, updatedContent, 'utf-8');\n}\n\ninterface EnvConfig {\n chainId: string;\n originalPublishedId: string;\n latestPublishedId: string;\n publishedVersion: number;\n}\n\nfunction updateEnvFile(\n filePath: string,\n networkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n operation: 'publish' | 'upgrade',\n chainId: string,\n publishedId: string\n): void {\n const envFilePath = path.resolve(filePath);\n const envContent = fs.readFileSync(envFilePath, 'utf-8');\n const envLines = envContent.split('\\n');\n\n const networkSectionIndex = envLines.findIndex((line) => line.trim() === `[env.${networkType}]`);\n const config: EnvConfig = {\n chainId: chainId,\n originalPublishedId: '',\n latestPublishedId: '',\n publishedVersion: 0\n };\n\n if (networkSectionIndex === -1) {\n // If network section is not found, add a new section\n if (operation === 'publish') {\n config.originalPublishedId = publishedId;\n config.latestPublishedId = publishedId;\n config.publishedVersion = 1;\n } else {\n throw new Error(\n `Network type [env.${networkType}] not found in the file and cannot upgrade.`\n );\n }\n } else {\n for (let i = networkSectionIndex + 1; i < envLines.length; i++) {\n const line = envLines[i].trim();\n if (line.startsWith('[')) break; // End of the current network section\n\n const [key, value] = line.split('=').map((part) => part.trim().replace(/\"/g, ''));\n switch (key) {\n case 'original-published-id':\n config.originalPublishedId = value;\n break;\n case 'latest-published-id':\n config.latestPublishedId = value;\n break;\n case 'published-version':\n config.publishedVersion = parseInt(value, 10);\n break;\n }\n }\n\n if (operation === 'publish') {\n config.originalPublishedId = publishedId;\n config.latestPublishedId = publishedId;\n config.publishedVersion = 1;\n } else if (operation === 'upgrade') {\n config.latestPublishedId = publishedId;\n config.publishedVersion += 1;\n }\n }\n\n const updatedSection = `\n[env.${networkType}]\nchain-id = \"${config.chainId}\"\noriginal-published-id = \"${config.originalPublishedId}\"\nlatest-published-id = \"${config.latestPublishedId}\"\npublished-version = \"${config.publishedVersion}\"\n`;\n\n const newEnvContent =\n networkSectionIndex === -1\n ? envContent + updatedSection\n : envLines.slice(0, networkSectionIndex).join('\\n') + updatedSection;\n\n fs.writeFileSync(envFilePath, newEnvContent, 'utf-8');\n}\n// function capitalizeAndRemoveUnderscores(input: string): string {\n// \treturn input\n// \t\t.split('_')\n// \t\t.map((word, index) => {\n// \t\t\treturn index === 0\n// \t\t\t\t? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n// \t\t\t\t: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n// \t\t})\n// \t\t.join('');\n// }\n//\n// function getLastSegment(input: string): string {\n// \tconst segments = input.split('::');\n// \treturn segments.length > 0 ? segments[segments.length - 1] : '';\n// }\n\nfunction buildContract(projectPath: string): string[][] {\n let modules: any, dependencies: any;\n try {\n const buildResult = JSON.parse(\n execSync(`sui move build --dump-bytecode-as-base64 --path ${projectPath}`, {\n encoding: 'utf-8',\n stdio: 'pipe'\n })\n );\n modules = buildResult.modules;\n dependencies = buildResult.dependencies;\n } catch (error: any) {\n console.error(chalk.red(' โโ Build failed'));\n console.error(error.stdout);\n process.exit(1);\n }\n return [modules, dependencies];\n}\n\ninterface ObjectChange {\n type: string;\n objectType?: string;\n packageId?: string;\n objectId?: string;\n}\n\nasync function waitForNode(dubhe: Dubhe): Promise<string> {\n const chainId = await dubhe.suiInteractor.currentClient.getChainIdentifier();\n console.log(` โโ ChainId: ${chainId}`);\n const address = dubhe.getAddress();\n const coins = await dubhe.suiInteractor.currentClient.getCoins({\n owner: address,\n coinType: '0x2::sui::SUI'\n });\n\n if (coins.data.length > 0) {\n const balance = coins.data.reduce((sum, coin) => sum + Number(coin.balance), 0);\n if (balance > 0) {\n console.log(` โโ Deployer balance: ${balance / 10 ** 9} SUI`);\n return chainId;\n } else {\n console.log(\n chalk.yellow(\n ` โโ Deployer balance: 0 SUI, please ensure your account has sufficient SUI balance`\n )\n );\n }\n }\n return chainId;\n}\n\nasync function publishContract(\n dubhe: Dubhe,\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n projectPath: string,\n gasBudget?: number\n) {\n console.log('\\n๐ Starting Contract Publication...');\n console.log(` โโ Project: ${projectPath}`);\n console.log(` โโ Network: ${network}`);\n console.log(' โโ Waiting for node...');\n\n const chainId = await waitForNode(dubhe);\n console.log(' โโ Validating Environment...');\n\n await removeEnvContent(`${projectPath}/Move.lock`, network);\n console.log(` โโ Account: ${dubhe.getAddress()}`);\n\n console.log('\\n๐ฆ Building Contract...');\n const [modules, dependencies] = buildContract(projectPath);\n\n console.log('\\n๐ Publishing Contract...');\n const tx = new Transaction();\n if (gasBudget) {\n tx.setGasBudget(gasBudget);\n }\n const [upgradeCap] = tx.publish({ modules, dependencies });\n tx.transferObjects([upgradeCap], dubhe.getAddress());\n\n let result;\n try {\n result = await dubhe.signAndSendTxn({ tx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Publication failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (!result || result.effects?.status.status === 'failure') {\n console.log(chalk.red(' โโ Publication failed'));\n process.exit(1);\n }\n\n console.log(' โโ Processing publication results...');\n let version = 1;\n let packageId = '';\n let dappHub = '';\n let components = dubheConfig.components;\n let upgradeCapId = '';\n\n let printObjects: any[] = [];\n\n result.objectChanges!.map((object: ObjectChange) => {\n if (object.type === 'published') {\n console.log(` โโ Package ID: ${object.packageId}`);\n packageId = object.packageId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType === '0x2::package::UpgradeCap'\n ) {\n console.log(` โโ Upgrade Cap: ${object.objectId}`);\n upgradeCapId = object.objectId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType.includes('dapp_hub::DappHub')\n ) {\n dappHub = object.objectId || '';\n }\n if (object.type === 'created') {\n printObjects.push(object);\n }\n });\n\n console.log(` โโ Transaction: ${result.digest}`);\n\n updateEnvFile(`${projectPath}/Move.lock`, network, 'publish', chainId, packageId);\n\n console.log('\\nโก Executing Deploy Hook...');\n await delay(5000);\n\n const deployHookTx = new Transaction();\n let args = [];\n let dubheDappHub = dubheConfig.name === 'dubhe' ? dappHub : await getDubheDappHub(network);\n args.push(deployHookTx.object(dubheDappHub));\n args.push(deployHookTx.object('0x6'));\n deployHookTx.moveCall({\n target: `${packageId}::genesis::run`,\n arguments: args\n });\n\n let deployHookResult;\n try {\n deployHookResult = await dubhe.signAndSendTxn({ tx: deployHookTx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Deploy hook execution failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (deployHookResult.effects?.status.status === 'success') {\n console.log(' โโ Hook execution successful');\n console.log(` โโ Transaction: ${deployHookResult.digest}`);\n\n console.log('\\n๐ Created Objects:');\n printObjects.map((object: ObjectChange) => {\n console.log(` โโ Type: ${object.objectType}`);\n console.log(` โโ ID: ${object.objectId}`);\n });\n\n await saveContractData(\n dubheConfig.name,\n network,\n packageId,\n dappHub,\n upgradeCapId,\n version,\n components\n );\n\n await saveMetadata(dubheConfig.name, network, packageId);\n\n // Insert package id to dubhe config\n let config = JSON.parse(fs.readFileSync(`${process.cwd()}/dubhe.config.json`, 'utf-8'));\n config.package_id = packageId;\n fs.writeFileSync(`${process.cwd()}/dubhe.config.json`, JSON.stringify(config, null, 2));\n\n console.log('\\nโ
Contract Publication Complete\\n');\n } else {\n console.log(chalk.yellow(' โโ Deploy hook execution failed'));\n console.log(chalk.yellow(' Please republish or manually call deploy_hook::run'));\n console.log(chalk.yellow(' Please check the transaction digest:'));\n console.log(chalk.yellow(` ${deployHookResult.digest}`));\n process.exit(1);\n }\n}\n\nasync function checkDubheFramework(projectPath: string): Promise<boolean> {\n if (!fs.existsSync(projectPath)) {\n console.log(chalk.yellow('\\nโน๏ธ Dubhe Framework Files Not Found'));\n console.log(chalk.yellow(' โโ Expected Path:'), projectPath);\n console.log(chalk.yellow(' โโ To set up Dubhe Framework:'));\n console.log(chalk.yellow(' โ 1. Create directory: mkdir -p contracts/dubhe'));\n console.log(\n chalk.yellow(\n ' โ 2. Clone repository: git clone https://github.com/0xobelisk/dubhe contracts/dubhe'\n )\n );\n console.log(chalk.yellow(' โ 3. Or download from: https://github.com/0xobelisk/dubhe'));\n console.log(chalk.yellow(' โโ After setup, restart the local node'));\n return false;\n }\n return true;\n}\n\nexport async function publishDubheFramework(\n dubhe: Dubhe,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n const path = process.cwd();\n const projectPath = `${path}/src/dubhe`;\n\n if (!(await checkDubheFramework(projectPath))) {\n return;\n }\n\n console.log('\\n๐ Starting Dubhe Framework Publication...');\n console.log(' โโ Waiting for node...');\n\n const chainId = await waitForNode(dubhe);\n\n await removeEnvContent(`${projectPath}/Move.lock`, network);\n await updateMoveTomlAddress(projectPath, \"0x0\");\n\n const [modules, dependencies] = buildContract(projectPath);\n const tx = new Transaction();\n const [upgradeCap] = tx.publish({ modules, dependencies });\n tx.transferObjects([upgradeCap], dubhe.getAddress());\n\n let result;\n try {\n result = await dubhe.signAndSendTxn({ tx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Publication failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (!result || result.effects?.status.status === 'failure') {\n console.log(chalk.red(' โโ Publication failed'));\n process.exit(1);\n }\n\n let version = 1;\n let packageId = '';\n let dappHub = '';\n let components = {};\n let upgradeCapId = '';\n\n result.objectChanges!.map((object: ObjectChange) => {\n if (object.type === 'published') {\n packageId = object.packageId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType === '0x2::package::UpgradeCap'\n ) {\n upgradeCapId = object.objectId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType.includes('dapp_hub::DappHub')\n ) {\n dappHub = object.objectId || '';\n }\n });\n\n await delay(3000);\n const deployHookTx = new Transaction();\n deployHookTx.moveCall({\n target: `${packageId}::dubhe_genesis::run`,\n arguments: [deployHookTx.object(dappHub), deployHookTx.object('0x6')]\n });\n\n let deployHookResult;\n try {\n deployHookResult = await dubhe.signAndSendTxn({ tx: deployHookTx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Deploy hook execution failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (deployHookResult.effects?.status.status !== 'success') {\n throw new Error('Deploy hook execution failed');\n }\n\n await updateMoveTomlAddress(projectPath, packageId);\n await saveContractData('dubhe', network, packageId, dappHub, upgradeCapId, version, components);\n\n updateEnvFile(`${projectPath}/Move.lock`, network, 'publish', chainId, packageId);\n}\n\nexport async function publishHandler(\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n gasBudget?: number\n) {\n await switchEnv(network);\n\n const dubhe = initializeDubhe({\n network\n });\n\n const path = process.cwd();\n const projectPath = `${path}/src/${dubheConfig.name}`;\n\n if (network === 'localnet' && dubheConfig.name !== 'dubhe') {\n await publishDubheFramework(dubhe, network);\n }\n\n if (dubheConfig.name !== 'dubhe') {\n await updateDubheDependency(`${projectPath}/Move.toml`, network);\n }\n await publishContract(dubhe, dubheConfig, network, projectPath, gasBudget);\n}\n","import * as fsAsync from 'fs/promises';\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { dirname } from 'path';\nimport { SUI_PRIVATE_KEY_PREFIX } from '@mysten/sui/cryptography';\nimport { FsIibError } from './errors';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\nimport { spawn } from 'child_process';\nimport { Dubhe, NetworkType, SuiMoveNormalizedModules, loadMetadata } from '@0xobelisk/sui-client';\nimport { DubheCliError } from './errors';\nimport packageJson from '../../package.json';\nimport { Component, MoveType, EmptyComponent, DubheConfig } from '@0xobelisk/sui-common';\n\nexport type DeploymentJsonType = {\n projectName: string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n packageId: string;\n dappHub: string;\n upgradeCap: string;\n version: number;\n components: Record<string, Component | MoveType | EmptyComponent>;\n};\n\nexport function validatePrivateKey(privateKey: string): false | string {\n if (privateKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {\n if (privateKey.length === 70) {\n return privateKey;\n } else {\n return false;\n }\n } else if (privateKey.startsWith('0x')) {\n const strippedPrivateKey = privateKey.slice(2);\n if (strippedPrivateKey.length === 64) {\n return strippedPrivateKey;\n } else {\n return false;\n }\n } else {\n if (privateKey.length === 64) {\n return privateKey;\n } else {\n return false;\n }\n }\n}\n\nexport async function updateVersionInFile(projectPath: string, newVersion: string) {\n try {\n const filePath = `${projectPath}/sources/script/migrate.move`;\n const data = await fsAsync.readFile(filePath, 'utf8');\n\n // update version data\n const updatedData = data.replace(\n /const VERSION: u64 = \\d+;/,\n `const VERSION: u64 = ${newVersion};`\n );\n\n // write new version\n writeOutput(updatedData, filePath, 'Update package version');\n } catch {\n throw new FsIibError('Fs update version failed.');\n }\n}\n\nexport async function getDeploymentJson(\n projectPath: string,\n network: string\n): Promise<DeploymentJsonType> {\n try {\n const data = await fsAsync.readFile(\n `${projectPath}/.history/sui_${network}/latest.json`,\n 'utf8'\n );\n return JSON.parse(data) as DeploymentJsonType;\n } catch (error) {\n throw new Error(`read .history/sui_${network}/latest.json failed. ${error}`);\n }\n}\n\nexport async function getDeploymentDappHub(projectPath: string, network: string): Promise<string> {\n try {\n const data = await fsAsync.readFile(\n `${projectPath}/.history/sui_${network}/latest.json`,\n 'utf8'\n );\n const deployment = JSON.parse(data) as DeploymentJsonType;\n return deployment.dappHub;\n } catch (error) {\n return '';\n }\n}\n\nexport async function getDubheDappHub(network: string) {\n const path = process.cwd();\n const contractPath = `${path}/src/dubhe`;\n\n switch (network) {\n case 'mainnet':\n return await getDeploymentDappHub(contractPath, 'mainnet');\n case 'testnet':\n return await getDeploymentDappHub(contractPath, 'testnet');\n case 'devnet':\n return await getDeploymentDappHub(contractPath, 'devnet');\n case 'localnet':\n return await getDeploymentDappHub(contractPath, 'localnet');\n default:\n throw new Error(`Invalid network: ${network}`);\n }\n}\n\nexport async function getOnchainComponents(\n projectPath: string,\n network: string\n): Promise<Record<string, Component | MoveType | EmptyComponent>> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.components;\n}\n\nexport async function getVersion(projectPath: string, network: string): Promise<number> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.version;\n}\n\nexport async function getNetwork(\n projectPath: string,\n network: string\n): Promise<'mainnet' | 'testnet' | 'devnet' | 'localnet'> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.network;\n}\n\nexport async function getOldPackageId(projectPath: string, network: string): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.packageId;\n}\n\nexport async function getDappHub(projectPath: string, network: string): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.dappHub;\n}\n\nexport async function getUpgradeCap(projectPath: string, network: string): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.upgradeCap;\n}\n\nexport async function saveContractData(\n projectName: string,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n packageId: string,\n dappHub: string,\n upgradeCap: string,\n version: number,\n components: Record<string, Component | MoveType | EmptyComponent>\n) {\n const DeploymentData: DeploymentJsonType = {\n projectName,\n network,\n packageId,\n dappHub,\n components,\n upgradeCap,\n version\n };\n\n const path = process.cwd();\n const storeDeploymentData = JSON.stringify(DeploymentData, null, 2);\n await writeOutput(\n storeDeploymentData,\n `${path}/src/${projectName}/.history/sui_${network}/latest.json`,\n 'Update deploy log'\n );\n}\n\nexport async function saveMetadata(\n projectName: string,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n packageId: string\n) {\n const path = process.cwd();\n\n // Save metadata files\n try {\n const metadata = await loadMetadata(network, packageId);\n if (metadata) {\n const metadataJson = JSON.stringify(metadata, null, 2);\n\n // Save packageId-specific metadata file\n await writeOutput(\n metadataJson,\n `${path}/src/${projectName}/.history/sui_${network}/${packageId}.json`,\n 'Save package metadata'\n );\n\n // Save latest metadata.json\n await writeOutput(metadataJson, `${path}/metadata.json`, 'Save latest metadata');\n }\n } catch (error) {\n console.warn(chalk.yellow(`Warning: Failed to save metadata: ${error}`));\n }\n}\n\nexport async function writeOutput(\n output: string,\n fullOutputPath: string,\n logPrefix?: string\n): Promise<void> {\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, output);\n if (logPrefix !== undefined) {\n console.log(`${logPrefix}: ${fullOutputPath}`);\n }\n}\n\nfunction getDubheDependency(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'): string {\n switch (network) {\n case 'localnet':\n return 'Dubhe = { local = \"../dubhe\" }';\n case 'testnet':\n return `Dubhe = { git = \"https://github.com/0xobelisk/dubhe-wip.git\", subdir = \"packages/sui-framework/src/dubhe\", rev = \"v${packageJson.version}\" }`;\n case 'mainnet':\n return `Dubhe = { git = \"https://github.com/0xobelisk/dubhe-wip.git\", subdir = \"packages/sui-framework/src/dubhe\", rev = \"v${packageJson.version}\" }`;\n default:\n throw new Error(`Unsupported network: ${network}`);\n }\n}\n\nexport async function updateDubheDependency(\n filePath: string,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n const newDependency = getDubheDependency(network);\n const updatedContent = fileContent.replace(/Dubhe = \\{.*\\}/, newDependency);\n fs.writeFileSync(filePath, updatedContent, 'utf-8');\n console.log(`Updated Dubhe dependency in ${filePath} for ${network}.`);\n}\n\nasync function checkRpcAvailability(rpcUrl: string): Promise<boolean> {\n try {\n const response = await fetch(rpcUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'sui_getLatestCheckpointSequenceNumber',\n params: []\n })\n });\n\n if (!response.ok) {\n return false;\n }\n\n const data = await response.json();\n return !data.error;\n } catch (error) {\n return false;\n }\n}\n\nexport async function addEnv(\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n): Promise<void> {\n const rpcMap = {\n localnet: 'http://127.0.0.1:9000',\n devnet: 'https://fullnode.devnet.sui.io:443/',\n testnet: 'https://fullnode.testnet.sui.io:443/',\n mainnet: 'https://fullnode.mainnet.sui.io:443/'\n };\n\n const rpcUrl = rpcMap[network];\n\n // Check RPC availability first\n const isRpcAvailable = await checkRpcAvailability(rpcUrl);\n if (!isRpcAvailable) {\n throw new Error(\n `RPC endpoint ${rpcUrl} is not available. Please check your network connection or try again later.`\n );\n }\n\n return new Promise<void>((resolve, reject) => {\n let errorOutput = '';\n let stdoutOutput = '';\n\n const suiProcess = spawn(\n 'sui',\n ['client', 'new-env', '--alias', network, '--rpc', rpcMap[network]],\n {\n env: { ...process.env },\n stdio: 'pipe'\n }\n );\n\n // Capture standard output\n suiProcess.stdout.on('data', (data) => {\n stdoutOutput += data.toString();\n });\n\n // Capture error output\n suiProcess.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n\n // Handle process errors (e.g., command not found)\n suiProcess.on('error', (error) => {\n console.error(chalk.red(`\\nโ Failed to execute sui command: ${error.message}`));\n reject(new Error(`Failed to execute sui command: ${error.message}`));\n });\n\n // Handle process exit\n suiProcess.on('exit', (code) => {\n // Check if \"already exists\" message is present\n if (errorOutput.includes('already exists') || stdoutOutput.includes('already exists')) {\n console.log(chalk.yellow(`Environment ${network} already exists, proceeding...`));\n resolve();\n return;\n }\n\n if (code === 0) {\n console.log(chalk.green(`Successfully added environment ${network}`));\n resolve();\n } else {\n const finalError = errorOutput || stdoutOutput || `Process exited with code ${code}`;\n console.error(chalk.red(`\\nโ Failed to add environment ${network}`));\n console.error(chalk.red(` โโ ${finalError.trim()}`));\n reject(new Error(finalError));\n }\n });\n });\n}\n\nexport async function switchEnv(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n try {\n // First, try to add the environment\n await addEnv(network);\n\n // Then switch to the specified environment\n return new Promise<void>((resolve, reject) => {\n let errorOutput = '';\n let stdoutOutput = '';\n\n const suiProcess = spawn('sui', ['client', 'switch', '--env', network], {\n env: { ...process.env },\n stdio: 'pipe'\n });\n\n suiProcess.stdout.on('data', (data) => {\n stdoutOutput += data.toString();\n });\n\n suiProcess.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n\n suiProcess.on('error', (error) => {\n console.error(chalk.red(`\\nโ Failed to execute sui command: ${error.message}`));\n reject(new Error(`Failed to execute sui command: ${error.message}`));\n });\n\n suiProcess.on('exit', (code) => {\n if (code === 0) {\n console.log(chalk.green(`Successfully switched to environment ${network}`));\n resolve();\n } else {\n const finalError = errorOutput || stdoutOutput || `Process exited with code ${code}`;\n console.error(chalk.red(`\\nโ Failed to switch to environment ${network}`));\n console.error(chalk.red(` โโ ${finalError.trim()}`));\n reject(new Error(finalError));\n }\n });\n });\n } catch (error) {\n // Re-throw the error for the caller to handle\n throw error;\n }\n}\n\nexport const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport function loadKey(): string {\n const privateKey = process.env.PRIVATE_KEY || process.env.NEXT_PUBLIC_PRIVATE_KEY;\n if (!privateKey) {\n throw new DubheCliError(\n `Missing private key environment variable.\n Run 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\n or 'echo \"NEXT_PUBLIC_PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\n in your contracts directory to use the default sui private key.`\n );\n }\n const privateKeyFormat = validatePrivateKey(privateKey);\n if (privateKeyFormat === false) {\n throw new DubheCliError(`Please check your privateKey.`);\n }\n return privateKeyFormat;\n}\n\nexport function initializeDubhe({\n network,\n packageId,\n metadata\n}: {\n network: NetworkType;\n packageId?: string;\n metadata?: SuiMoveNormalizedModules;\n}): Dubhe {\n const privateKey = loadKey();\n return new Dubhe({\n networkType: network,\n secretKey: privateKey,\n packageId,\n metadata\n });\n}\n\nexport function generateConfigJson(config: DubheConfig): string {\n const components = Object.entries(config.components).map(([name, component]) => {\n if (typeof component === 'string') {\n return {\n [name]: {\n fields: [\n { entity_id: 'address' },\n { value: component }\n ],\n keys: ['entity_id']\n }\n };\n }\n\n if (Object.keys(component as object).length === 0) {\n return {\n [name]: {\n fields: [\n { entity_id: 'address' }\n ],\n keys: ['entity_id']\n }\n };\n }\n\n const fields = (component as any).fields || {};\n const keys = (component as any).keys || ['entity_id'];\n\n // ensure entity_id field exists\n if (!fields.entity_id && keys.includes('entity_id')) {\n fields.entity_id = 'address';\n }\n\n return {\n [name]: {\n fields: Object.entries(fields).map(([fieldName, fieldType]) => ({\n [fieldName]: fieldType\n })),\n keys: keys\n }\n };\n });\n\n const resources = Object.entries(config.resources).map(([name, resource]) => {\n if (typeof resource === 'string') {\n return {\n [name]: {\n fields: [\n { value: resource }\n ],\n keys: []\n }\n };\n }\n\n if (Object.keys(resource as object).length === 0) {\n return {\n [name]: {\n fields: [],\n keys: []\n }\n };\n }\n\n const fields = (resource as any).fields || {};\n const keys = (resource as any).keys || [];\n\n return {\n [name]: {\n fields: Object.entries(fields).map(([fieldName, fieldType]) => ({\n [fieldName]: fieldType\n })),\n keys: keys\n }\n };\n });\n\n // handle enums\n const enums = Object.entries(config.enums || {}).map(([name, enumFields]) => {\n // Sort enum values by first letter\n let sortedFields = enumFields.sort((a, b) => a.localeCompare(b)).map((value, index) => ({\n [index]: value\n }));\n\n return {\n [name]: {\n fields: sortedFields\n }\n };\n });\n\n return JSON.stringify({\n components,\n resources,\n enums\n }, null, 2);\n}\n\n/**\n * Updates the dubhe address in Move.toml file\n * @param path - Directory path containing Move.toml file\n * @param packageAddress - New dubhe package address to set\n */\nexport function updateMoveTomlAddress(path: string, packageAddress: string) {\n const moveTomlPath = `${path}/Move.toml`;\n const moveTomlContent = fs.readFileSync(moveTomlPath, 'utf-8');\n // Use regex to match any dubhe address, not just \"0x0\"\n const updatedContent = moveTomlContent.replace(/dubhe\\s*=\\s*\"[^\"]*\"/, `dubhe = \"${packageAddress}\"`);\n fs.writeFileSync(moveTomlPath, updatedContent, 'utf-8');\n}\n","import chalk from 'chalk';\nimport { ZodError } from 'zod';\nimport { fromZodError, ValidationError } from 'zod-validation-error';\n\nexport class NotInsideProjectError extends Error {\n name = 'NotInsideProjectError';\n message = 'You are not inside a Dubhe project';\n}\n\nexport class DubheCliError extends Error {\n name = 'DubheCliError';\n}\n\nexport class UpgradeError extends Error {\n name = 'UpgradeError';\n}\n\nexport class FsIibError extends Error {\n name = 'FsIibError';\n}\n\nexport function logError(error: unknown) {\n if (error instanceof ValidationError) {\n console.log(chalk.redBright(error.message));\n } else if (error instanceof ZodError) {\n // TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n const validationError = fromZodError(error, {\n prefixSeparator: '\\n- ',\n issueSeparator: '\\n- '\n });\n console.log(chalk.redBright(validationError.message));\n } else if (error instanceof NotInsideProjectError) {\n console.log(chalk.red(error.message));\n console.log('');\n // TODO add docs to the website and update the link to the specific page\n console.log(\n chalk.blue(\n `To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk`\n )\n );\n } else if (error instanceof DubheCliError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\n}\n","{\n \"name\": \"@0xobelisk/sui-cli\",\n \"version\": \"1.2.0-pre.33\",\n \"description\": \"Tookit for interacting with move eps framework\",\n \"keywords\": [\n \"sui\",\n \"obelisk labs\",\n \"move\",\n \"blockchain\"\n ],\n \"type\": \"module\",\n \"author\": \"team@obelisk.build\",\n \"homepage\": \"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme\",\n \"bugs\": \"https://github.com/0xobelisk/dubhe/issues\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/0xobelisk/dubhe.git\"\n },\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"exports\": {\n \".\": \"./dist/index.js\"\n },\n \"types\": \"src/index.ts\",\n \"bin\": {\n \"dubhe\": \"./dist/dubhe.js\"\n },\n \"scripts\": {\n \"build\": \"pnpm run type-check && pnpm run build:js\",\n \"build:js\": \"tsup && chmod +x ./dist/dubhe.js\",\n \"clean\": \"pnpm run clean:js\",\n \"clean:js\": \"rimraf dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint . --ext .ts\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"type-check\": \"tsc --noEmit\",\n \"validate\": \"pnpm format:check && pnpm type-check\"\n },\n \"dependencies\": {\n \"@0xobelisk/sui-client\": \"workspace:*\",\n \"@0xobelisk/sui-common\": \"workspace:*\",\n \"@mysten/sui\": \"^1.19.0\",\n \"@types/sqlite3\": \"^3.1.11\",\n \"@types/wait-on\": \"^5.3.4\",\n \"chalk\": \"^5.0.1\",\n \"child_process\": \"^1.0.2\",\n \"chokidar\": \"^3.5.3\",\n \"cli-table3\": \"^0.6.5\",\n \"dotenv\": \"^16.0.3\",\n \"ejs\": \"^3.1.8\",\n \"execa\": \"^7.0.0\",\n \"glob\": \"^8.0.3\",\n \"ora\": \"^5.4.1\",\n \"path\": \"^0.12.7\",\n \"sqlite\": \"^5.1.1\",\n \"sqlite3\": \"^5.1.7\",\n \"typescript\": \"5.1.6\",\n \"wait-on\": \"^7.0.1\",\n \"yargs\": \"^17.7.1\",\n \"zod\": \"^3.22.3\",\n \"zod-validation-error\": \"^1.3.0\"\n },\n \"devDependencies\": {\n \"@types/ejs\": \"^3.1.1\",\n \"@types/glob\": \"^7.2.0\",\n \"@types/node\": \"^18.15.11\",\n \"@types/yargs\": \"^17.0.10\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-prettier\": \"^9.1.0\",\n \"prettier\": \"3.3.3\",\n \"ts-node\": \"^10.9.1\",\n \"tsup\": \"^6.7.0\",\n \"tsx\": \"^3.12.6\",\n \"vitest\": \"0.31.4\"\n }\n}\n","import type { CommandModule } from 'yargs';\nimport { startLocalNode } from '../utils/startNode';\n\ntype Options = {\n 'data-dir': string;\n force: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'node',\n\n describe: 'Manage local Sui node',\n\n builder: {\n 'data-dir': {\n type: 'string',\n default: '.chk',\n desc: 'Path to the data directory'\n },\n force: {\n type: 'boolean',\n default: false,\n desc: 'Force restart: stop existing node and remove data directory'\n }\n },\n\n async handler({ 'data-dir': data_dir, force }) {\n try {\n await startLocalNode(data_dir, force);\n } catch (error) {\n console.error('Error executing command:', error);\n process.exit(1);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { requestSuiFromFaucetV0, getFaucetHost } from '@mysten/sui/faucet';\nimport { SuiClient, getFullnodeUrl, GetBalanceParams } from '@mysten/sui/client';\nimport { initializeDubhe } from '../utils';\n\ntype Options = {\n network: any;\n recipient?: string;\n};\n\nconst MAX_RETRIES = 60; // 60s timeout\nconst RETRY_INTERVAL = 1000; // 1s retry interval\nconst SPINNER = ['โ ', 'โ ', 'โ น', 'โ ธ', 'โ ผ', 'โ ด', 'โ ฆ', 'โ ง', 'โ ', 'โ '];\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'faucet',\n\n describe: 'Interact with a Dubhe faucet',\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n desc: 'URL of the Dubhe faucet',\n choices: ['testnet', 'devnet', 'localnet'],\n default: 'localnet'\n },\n recipient: {\n type: 'string',\n desc: 'Sui address to fund'\n }\n });\n },\n\n async handler({ network, recipient }) {\n let faucet_address = '';\n if (recipient === undefined) {\n const dubhe = initializeDubhe(network);\n faucet_address = dubhe.getAddress();\n } else {\n faucet_address = recipient;\n }\n\n console.log('\\n๐ Starting Faucet Operation...');\n console.log(` โโ Network: ${network}`);\n\n if (recipient === undefined) {\n console.log(' โโ Using Environment PrivateKey');\n console.log(` โโ Generated Address: ${faucet_address}`);\n } else {\n console.log(` โโ Using Provided Address: ${faucet_address}`);\n }\n\n console.log(' โโ Requesting funds from faucet...');\n\n let retryCount = 0;\n let success = false;\n let spinnerIndex = 0;\n const startTime = Date.now();\n let isInterrupted = false;\n\n const handleInterrupt = () => {\n isInterrupted = true;\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n console.log('\\n โโ Operation cancelled by user');\n process.exit(0);\n };\n process.on('SIGINT', handleInterrupt);\n\n try {\n while (retryCount < MAX_RETRIES && !success && !isInterrupted) {\n try {\n await requestSuiFromFaucetV0({\n host: getFaucetHost(network),\n recipient: faucet_address\n });\n success = true;\n } catch (error) {\n if (isInterrupted) break;\n\n retryCount++;\n if (retryCount === MAX_RETRIES) {\n console.log(` โโ Failed to request funds after ${MAX_RETRIES} attempts.`);\n console.log(' โโ Please check your network connection and try again later.');\n process.exit(1);\n }\n\n const elapsedTime = Math.floor((Date.now() - startTime) / 1000);\n const spinner = SPINNER[spinnerIndex % SPINNER.length];\n spinnerIndex++;\n\n process.stdout.write(`\\r โโ ${spinner} Retrying... (${elapsedTime}s)`);\n await new Promise((resolve) => setTimeout(resolve, RETRY_INTERVAL));\n }\n }\n } finally {\n process.removeListener('SIGINT', handleInterrupt);\n }\n\n if (isInterrupted) {\n process.exit(0);\n }\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n\n console.log(' โโ Checking balance...');\n const client = new SuiClient({ url: getFullnodeUrl(network) });\n let params = {\n owner: faucet_address\n } as GetBalanceParams;\n\n const balance = await client.getBalance(params);\n\n console.log('\\n๐ฐ Account Summary');\n console.log(` โโ Address: ${faucet_address}`);\n console.log(` โโ Balance: ${(Number(balance.totalBalance) / 1_000_000_000).toFixed(4)} SUI`);\n\n console.log('\\nโ
Faucet Operation Complete\\n');\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { schemaGen, loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport chalk from 'chalk';\nimport path from \"node:path\";\n\ntype Options = {\n 'config-path'?: string;\n network?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'schemagen',\n\n describe: 'Autogenerate Dubhe schemas based on the config file',\n\n builder: {\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n desc: 'Path to the config file'\n },\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n }\n },\n\n async handler({ 'config-path': configPath, network }) {\n try {\n if (!configPath) throw new Error('Config path is required');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const rootDir = path.dirname(configPath);\n await schemaGen(rootDir, dubheConfig, network);\n process.exit(0);\n } catch (error: any) {\n console.log(chalk.red('Schemagen failed!'));\n console.error(error.message);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { publishHandler } from '../utils';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport { execSync } from 'child_process';\n\ntype Options = {\n network: any;\n 'config-path': string;\n 'gas-budget'?: number;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'publish',\n\n describe: 'Publish dubhe move contract',\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n default: 'localnet',\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n },\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n desc: 'Configuration file path'\n },\n 'gas-budget': {\n type: 'number',\n desc: 'Optional gas budget for the transaction',\n optional: true\n }\n });\n },\n\n async handler({ network, 'config-path': configPath, 'gas-budget': gasBudget }) {\n try {\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n execSync(`pnpm dubhe convert-json --config-path ${configPath}`, { encoding: 'utf-8' })\n await publishHandler(dubheConfig, network, gasBudget); \n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { execSync } from 'child_process';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n 'config-path': string;\n test?: string;\n 'gas-limit'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'test',\n\n describe: 'Run tests in Dubhe contracts',\n\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n description: 'Options to pass to forge test'\n },\n test: {\n type: 'string',\n desc: 'Run a specific test'\n },\n 'gas-limit': {\n type: 'string',\n desc: 'Set the gas limit for the test',\n default: '100000000'\n }\n });\n },\n\n async handler({ 'config-path': configPath, test, 'gas-limit': gasLimit }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('๐ Running move test');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/src/${dubheConfig.name}`;\n const command = `sui move test --path ${projectPath} ${\n test ? ` --test ${test}` : ''\n } --gas-limit ${gasLimit}`;\n execSync(command, { stdio: 'inherit', encoding: 'utf-8' });\n } catch (error: any) {\n process.exit(0);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { execSync, exec } from 'child_process';\nimport chalk from 'chalk';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\nimport { switchEnv, updateDubheDependency } from '../utils';\n\ntype Options = {\n 'config-path': string;\n network: any;\n 'dump-bytecode-as-base64'?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'build',\n describe: 'Run tests in Dubhe contracts',\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n description: 'Options to pass to forge test'\n },\n network: {\n type: 'string',\n default: 'localnet',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n },\n 'dump-bytecode-as-base64': {\n type: 'boolean',\n default: false,\n desc: 'Dump bytecode as base64'\n }\n });\n },\n\n async handler({\n 'config-path': configPath,\n network,\n 'dump-bytecode-as-base64': dumpBytecodeAsBase64\n }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('๐ Running move build');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/src/${dubheConfig.name}`;\n await switchEnv(network);\n await updateDubheDependency(projectPath + '/Move.toml', network);\n const command = `sui move build --path ${projectPath} ${\n dumpBytecodeAsBase64 ? ` --dump-bytecode-as-base64` : ''\n }`;\n const output = execSync(command, { encoding: 'utf-8' });\n console.log(output);\n exec(`pnpm dubhe convert-json --config-path ${configPath}`)\n } catch (error: any) {\n console.error(chalk.red('Error executing sui move build:'));\n console.log(error.stdout);\n process.exit(0);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { printDubhe } from '../utils';\n\nconst commandModule: CommandModule = {\n command: 'hello',\n\n describe: 'hello, dubhe',\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n printDubhe();\n }\n};\n\nexport default commandModule;\n","import { Dubhe } from '@0xobelisk/sui-client';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\n\nexport async function generateAccountHandler(\n force: boolean = false,\n useNextPublic: boolean = false\n) {\n if (useNextPublic) {\n console.log(\n chalk.gray(\n 'Note: The generated account will be stored in the .env file with NEXT_PUBLIC_ prefix for client-side usage.'\n )\n );\n console.log(\n chalk.yellow('Warning: Do not expose the .env file, it is intended for local testing only.\\n')\n );\n }\n const path = process.cwd();\n let privateKey: string | undefined;\n let envContent = '';\n\n // Check if .env file exists\n try {\n envContent = fs.readFileSync(`${path}/.env`, 'utf8');\n\n // privateKey = process.env.PRIVATE_KEY || process.env.NEXT_PUBLIC_PRIVATE_KEY;\n let privateKey = process.env.PRIVATE_KEY || process.env.NEXT_PUBLIC_PRIVATE_KEY;\n if (useNextPublic) {\n privateKey = process.env.NEXT_PUBLIC_PRIVATE_KEY || process.env.PRIVATE_KEY;\n }\n\n if (privateKey) {\n // If key exists, decide whether to update keyname based on useNextPublic\n const newKeyName = useNextPublic ? 'NEXT_PUBLIC_PRIVATE_KEY' : 'PRIVATE_KEY';\n\n // Find and update the last matching line based on privateKey value\n const lines = envContent.split('\\n');\n let shouldUpdate = false;\n\n // First check if the last matching line already has the correct keyname\n for (let i = lines.length - 1; i >= 0; i--) {\n const line = lines[i];\n if (line.endsWith(privateKey)) {\n // If useNextPublic is true, only update if the line starts with PRIVATE_KEY=\n // If useNextPublic is false, only update if the line starts with NEXT_PUBLIC_PRIVATE_KEY=\n const [currentKeyName] = line.split('=');\n if (useNextPublic) {\n shouldUpdate = currentKeyName === 'PRIVATE_KEY';\n } else {\n shouldUpdate = currentKeyName === 'NEXT_PUBLIC_PRIVATE_KEY';\n }\n break;\n }\n }\n\n // Only update if necessary\n if (shouldUpdate) {\n for (let i = lines.length - 1; i >= 0; i--) {\n const line = lines[i];\n if (line.endsWith(privateKey)) {\n const newLine = `${newKeyName}=${privateKey}`;\n lines[i] = newLine;\n envContent = lines.join('\\n');\n fs.writeFileSync(`${path}/.env`, envContent);\n break;\n }\n }\n }\n\n const dubhe = new Dubhe({ secretKey: privateKey });\n const keypair = dubhe.getSigner();\n console.log(chalk.blue(`Using existing account: ${keypair.toSuiAddress()}`));\n return;\n }\n } catch (error) {\n // .env file doesn't exist or failed to read, continue to generate new account\n }\n\n // Generate a new account if no existing key is found or force generation is requested\n if (force || !privateKey) {\n const dubhe = new Dubhe();\n const keypair = dubhe.getSigner();\n privateKey = keypair.getSecretKey();\n\n const newKeyName = useNextPublic ? 'NEXT_PUBLIC_PRIVATE_KEY' : 'PRIVATE_KEY';\n const newContent = `${newKeyName}=${privateKey}`;\n\n // If .env file exists, append new content; otherwise create a new file\n if (envContent) {\n envContent = envContent.trim() + '\\n' + newContent;\n } else {\n envContent = newContent;\n }\n\n fs.writeFileSync(`${path}/.env`, envContent);\n console.log(chalk.green(`File created/updated at: ${path}/.env`));\n\n console.log(chalk.blue(`New account generated: ${keypair.toSuiAddress()}`));\n }\n}\n","import type { CommandModule } from 'yargs';\nimport { generateAccountHandler } from '../utils/generateAccount';\n\ntype Options = {\n force?: boolean;\n 'use-next-public'?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'generate-key',\n describe: 'Generate a new account keypair and save it to a .env file',\n builder: {\n force: {\n type: 'boolean',\n default: false,\n desc: 'Force generate a new keypair'\n },\n 'use-next-public': {\n type: 'boolean',\n default: false,\n desc: 'Use the NEXT_PUBLIC_ prefix for client-side usage'\n }\n },\n async handler({ force, 'use-next-public': useNextPublic }) {\n try {\n await generateAccountHandler(force, useNextPublic);\n } catch (error) {\n console.error('Error generating account:', error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import chalk from 'chalk';\nimport dotenv from 'dotenv';\nimport { initializeDubhe } from './utils';\nimport { DubheCliError } from './errors';\ndotenv.config();\n\nexport async function checkBalanceHandler(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n try {\n const dubhe = initializeDubhe({\n network\n });\n\n const balance = await dubhe.getBalance();\n const balanceInSUI = Number(balance.totalBalance) / 1_000_000_000;\n\n if (balanceInSUI === 0) {\n throw new DubheCliError(`Your account balance is 0 SUI. Please get some SUI to proceed.`);\n }\n\n console.log(chalk.green(`Current account balance: ${balanceInSUI.toFixed(4)} SUI`));\n } catch (error) {\n throw new DubheCliError('Failed to check balance: ' + error);\n }\n}\n","import type { CommandModule } from 'yargs';\nimport { checkBalanceHandler } from '../utils/checkBalance';\n\ntype Options = {\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'check-balance',\n describe: 'Check the balance of the account',\n builder: {\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Network to check balance on',\n default: 'localnet'\n }\n },\n async handler({ network }) {\n try {\n await checkBalanceHandler(network);\n } catch (error) {\n console.error('Error checking balance:', error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import { mkdirSync, writeFileSync } from 'fs';\nimport { dirname } from 'path';\nimport { DubheConfig } from '@0xobelisk/sui-common';\nimport { getDeploymentJson, getDubheDappHub } from './utils';\n\nasync function storeConfig(network: string, packageId: string, outputPath: string) {\n const dubheDappHub = await getDubheDappHub(network);\n let code = `type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';\n\nexport const NETWORK: NetworkType = '${network}';\nexport const PACKAGE_ID = '${packageId}';\nexport const DUBHE_SCHEMA_ID = '${dubheDappHub}';\n`;\n\n writeOutput(code, outputPath, 'storeConfig');\n}\n\nasync function writeOutput(\n output: string,\n fullOutputPath: string,\n logPrefix?: string\n): Promise<void> {\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, output);\n if (logPrefix !== undefined) {\n console.log(`${logPrefix}: ${fullOutputPath}`);\n }\n}\n\nexport async function storeConfigHandler(\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n outputPath: string\n) {\n const path = process.cwd();\n const contractPath = `${path}/src/${dubheConfig.name}`;\n const deployment = await getDeploymentJson(contractPath, network);\n await storeConfig(deployment.network, deployment.packageId, outputPath);\n}\n","import type { CommandModule } from 'yargs';\nimport { storeConfigHandler } from '../utils/storeConfig';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n 'config-path': string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n 'output-ts-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'config-store',\n\n describe: 'Store configuration for the Dubhe project',\n\n builder: {\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n desc: 'Path to the config file'\n },\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Network to store config for'\n },\n 'output-ts-path': {\n type: 'string',\n desc: 'Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)'\n }\n },\n async handler({ 'config-path': configPath, network, 'output-ts-path': outputTsPath }) {\n try {\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n await storeConfigHandler(dubheConfig, network, outputTsPath);\n } catch (error) {\n console.error('Error storing config:', error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport chokidar from 'chokidar';\nimport { exec } from 'child_process';\n\nconst commandModule: CommandModule = {\n command: 'watch',\n\n describe: 'Watch dubhe config',\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n const configFilePath = 'dubhe.config.ts';\n\n const runSchemagen = () => {\n exec('pnpm dubhe schemagen', (error, stdout, stderr) => {\n if (error) {\n console.error(`Error executing schemagen: ${error.message}`);\n return;\n }\n if (stderr) {\n console.error(`schemagen stderr: ${stderr}`);\n return;\n }\n console.log(`schemagen stdout: ${stdout}`);\n });\n };\n\n const watcher = chokidar.watch(configFilePath, {\n persistent: true\n });\n\n watcher.on('change', (path) => {\n console.log(`${path} has been changed. Running schemagen...`);\n runSchemagen();\n });\n\n console.log(`Watching for changes in ${configFilePath}...`);\n\n process.on('SIGINT', () => {\n watcher.close();\n console.log('\\nWatch stopped.');\n process.exit();\n });\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport waitOn from 'wait-on';\nimport ora from 'ora';\nimport chalk from 'chalk';\n\ninterface WaitOptions {\n url: string;\n timeout: number;\n interval: number;\n}\n\nconst commandModule: CommandModule = {\n command: 'wait',\n describe: 'Wait for service to be ready',\n builder(yargs) {\n return yargs\n .option('url', {\n type: 'string',\n description: 'URL to wait for'\n })\n .option('timeout', {\n type: 'number',\n description: 'Timeout (in milliseconds)',\n default: 180000\n })\n .option('interval', {\n type: 'number',\n description: 'Check interval (in milliseconds)',\n default: 1000\n });\n },\n async handler(argv) {\n const options = argv as unknown as WaitOptions;\n const spinner = ora({\n text: `Waiting for service to start ${chalk.cyan(options.url)}...`,\n color: 'cyan'\n });\n\n spinner.start();\n\n try {\n await waitOn({\n resources: [options.url],\n timeout: options.timeout,\n interval: options.interval,\n validateStatus: (status: number) => status === 200\n });\n\n spinner.succeed(chalk.green('Service is ready!'));\n process.exit(0);\n } catch (error) {\n spinner.fail(chalk.red('Timeout waiting for service'));\n console.error(chalk.yellow('Please make sure the service is running...'));\n process.exit(1);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule, ArgumentsCamelCase } from 'yargs';\nimport { switchEnv } from '../utils';\n\ntype Options = {\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'switch-env',\n describe: 'Switch environment',\n builder(yargs) {\n return yargs.option('network', {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,\n default: 'localnet',\n desc: 'Switch to node network (mainnet/testnet/devnet/localnet)'\n }) as any;\n },\n async handler(argv: ArgumentsCamelCase<Options>) {\n await switchEnv(argv.network as 'mainnet' | 'testnet' | 'devnet' | 'localnet');\n }\n};\n\nexport default commandModule;\n","import { CommandModule } from 'yargs';\nimport { logError, initializeDubhe } from '../utils';\nimport dotenv from 'dotenv';\nimport chalk from 'chalk';\ndotenv.config();\n\ntype Options = {\n network: any;\n};\n\nconst InfoCommand: CommandModule<Options, Options> = {\n command: 'info',\n describe: 'Get information about the current Sui node',\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n default: 'localnet',\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n }\n });\n },\n handler: async ({ network }) => {\n try {\n const dubhe = initializeDubhe({ network });\n const keypair = dubhe.getSigner();\n\n console.log(chalk.blue('Account Information:'));\n console.log(` Network: ${chalk.green(network)}`);\n console.log(` Address: ${chalk.green(keypair.toSuiAddress())}`);\n\n try {\n const balance = await dubhe.getBalance('0x2::sui::SUI');\n const suiBalance = (Number(balance.totalBalance) / 10 ** 9).toFixed(4);\n console.log(` Balance: ${chalk.green(suiBalance)} SUI`);\n } catch (error) {\n console.log(\n ` Balance: ${chalk.red('Failed to fetch balance')} ${chalk.gray('(Network error)')}`\n );\n }\n } catch (error) {\n logError(error);\n process.exit(1);\n }\n }\n};\n\nexport default InfoCommand;\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport { loadMetadataHandler } from '../utils/metadataHandler';\n\ntype Options = {\n network: any;\n 'config-path': string;\n 'package-id'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'load-metadata',\n\n describe: 'Load metadata for a package',\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n default: 'localnet',\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n },\n 'config-path': {\n type: 'string',\n desc: 'Configuration file path',\n default: 'dubhe.config.ts'\n },\n 'package-id': {\n type: 'string',\n desc: 'Package ID to load metadata for',\n optional: true\n }\n });\n },\n\n async handler({ network, 'config-path': configPath, 'package-id': packageId }) {\n try {\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n await loadMetadataHandler(dubheConfig, network, packageId);\n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import { DubheConfig } from '@0xobelisk/sui-common';\nimport { getOldPackageId, saveMetadata } from './utils';\n\nexport async function loadMetadataHandler(\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n packageId?: string\n) {\n if (packageId) {\n await saveMetadata(dubheConfig.name, network, packageId);\n } else {\n const projectPath = `${process.cwd()}/src/${dubheConfig.name}`;\n const packageId = await getOldPackageId(projectPath, network);\n await saveMetadata(dubheConfig.name, network, packageId);\n }\n}\n","import type { CommandModule } from 'yargs';\nimport chalk from 'chalk';\nimport { spawn } from 'child_process';\nimport { existsSync } from 'fs';\nimport { homedir } from 'os';\nimport { join } from 'path';\nimport Table from 'cli-table3';\n\n// Check result type\ninterface CheckResult {\n name: string;\n status: 'success' | 'warning' | 'error';\n message: string;\n fixSuggestion?: string;\n}\n\n// Execute shell command and return output\nasync function execCommand(\n command: string,\n args: string[] = []\n): Promise<{ code: number; stdout: string; stderr: string }> {\n return new Promise((resolve) => {\n const child = spawn(command, args, { shell: true });\n let stdout = '';\n let stderr = '';\n\n child.stdout?.on('data', (data) => {\n stdout += data.toString();\n });\n\n child.stderr?.on('data', (data) => {\n stderr += data.toString();\n });\n\n child.on('close', (code) => {\n resolve({ code: code || 0, stdout, stderr });\n });\n\n child.on('error', () => {\n resolve({ code: -1, stdout, stderr });\n });\n });\n}\n\n// Check if command is available in PATH\nasync function checkCommand(\n command: string,\n versionFlag: string = '--version'\n): Promise<CheckResult> {\n try {\n const result = await execCommand(command, [versionFlag]);\n if (result.code === 0) {\n const version = result.stdout.trim().split('\\n')[0];\n return {\n name: command,\n status: 'success',\n message: `Installed ${version}`\n };\n } else {\n return {\n name: command,\n status: 'error',\n message: 'Not installed',\n fixSuggestion: getInstallSuggestion(command)\n };\n }\n } catch (error) {\n return {\n name: command,\n status: 'error',\n message: 'Not installed',\n fixSuggestion: getInstallSuggestion(command)\n };\n }\n}\n\n// Get installation suggestions\nfunction getInstallSuggestion(command: string): string {\n const suggestions: Record<string, string> = {\n docker: 'Visit https://docs.docker.com/get-docker/ to install Docker',\n 'docker-compose': 'Visit https://docs.docker.com/compose/install/ to install Docker Compose',\n sui: 'Visit https://docs.sui.io/guides/developer/getting-started/sui-install to install Sui CLI',\n pnpm: 'Run: npm install -g pnpm',\n node: 'Visit https://nodejs.org/ to download and install Node.js',\n git: 'Visit https://git-scm.com/downloads to install Git'\n };\n\n return suggestions[command] || `Please install ${command}`;\n}\n\n// Check if file exists\nfunction checkFileExists(filePath: string, description: string): CheckResult {\n const exists = existsSync(filePath);\n return {\n name: description,\n status: exists ? 'success' : 'warning',\n message: exists ? 'Available' : 'Not found',\n fixSuggestion: exists ? undefined : `Please create file: ${filePath}`\n };\n}\n\n// Check Node.js version\nasync function checkNodeVersion(): Promise<CheckResult> {\n try {\n const result = await execCommand('node', ['--version']);\n if (result.code === 0) {\n const version = result.stdout.trim();\n const versionNumber = parseFloat(version.replace('v', ''));\n\n if (versionNumber >= 18) {\n return {\n name: 'Node.js version',\n status: 'success',\n message: `${version} (meets requirement >=18.0)`\n };\n } else {\n return {\n name: 'Node.js version',\n status: 'warning',\n message: `${version} (recommend upgrade to >=18.0)`,\n fixSuggestion: 'Please upgrade Node.js to 18.0 or higher'\n };\n }\n } else {\n return {\n name: 'Node.js version',\n status: 'error',\n message: 'Not installed',\n fixSuggestion: 'Please install Node.js 18.0 or higher'\n };\n }\n } catch (error) {\n return {\n name: 'Node.js version',\n status: 'error',\n message: 'Check failed',\n fixSuggestion: 'Please install Node.js'\n };\n }\n}\n\n// Check Docker service status\nasync function checkDockerService(): Promise<CheckResult> {\n try {\n const result = await execCommand('docker', ['info']);\n if (result.code === 0) {\n return {\n name: 'Docker service',\n status: 'success',\n message: 'Running'\n };\n } else {\n return {\n name: 'Docker service',\n status: 'warning',\n message: 'Not running',\n fixSuggestion: 'Please start Docker service'\n };\n }\n } catch (error) {\n return {\n name: 'Docker service',\n status: 'error',\n message: 'Check failed',\n fixSuggestion: 'Please install and start Docker'\n };\n }\n}\n\n// Check NPM configuration\nasync function checkNpmConfig(): Promise<CheckResult> {\n try {\n const result = await execCommand('npm', ['config', 'get', 'registry']);\n if (result.code === 0) {\n const registry = result.stdout.trim();\n return {\n name: 'NPM configuration',\n status: 'success',\n message: `Configured (${registry})`\n };\n } else {\n return {\n name: 'NPM configuration',\n status: 'warning',\n message: 'Configuration issue',\n fixSuggestion: 'Check NPM config: npm config list'\n };\n }\n } catch (error) {\n return {\n name: 'NPM configuration',\n status: 'warning',\n message: 'Check failed',\n fixSuggestion: 'Please install Node.js and NPM'\n };\n }\n}\n\n// Create table row data\nfunction formatTableRow(result: CheckResult): string[] {\n const statusIcon = {\n success: chalk.green('โ'),\n warning: chalk.yellow('!'),\n error: chalk.red('โ')\n };\n\n const statusText = {\n success: chalk.green('YES'),\n warning: chalk.yellow('WARN'),\n error: chalk.red('NO')\n };\n\n // Decide what content to display based on status\n let fixContent = '';\n if (result.status === 'success') {\n fixContent = result.message;\n } else {\n fixContent = result.fixSuggestion || result.message;\n }\n\n return [result.name, `${statusIcon[result.status]} ${statusText[result.status]}`, fixContent];\n}\n\n// Main check function\nasync function runDoctorChecks() {\n console.log(chalk.bold.blue('\\n๐ Dubhe Doctor - Environment Check Tool\\n'));\n console.log(chalk.gray('Checking your development environment...\\n'));\n\n const results: CheckResult[] = [];\n\n // Execute all checks\n console.log('Running checks...\\n');\n\n // Required tools check\n const nodeCheck = await checkNodeVersion();\n results.push(nodeCheck);\n\n const pnpmCheck = await checkCommand('pnpm');\n results.push(pnpmCheck);\n\n const gitCheck = await checkCommand('git');\n results.push(gitCheck);\n\n // Package manager configuration check\n const npmConfigCheck = await checkNpmConfig();\n // Treat npm config as optional, don't affect overall status\n if (npmConfigCheck.status === 'error') {\n npmConfigCheck.status = 'warning';\n }\n results.push(npmConfigCheck);\n\n // Docker related checks\n const dockerCheck = await checkCommand('docker');\n results.push(dockerCheck);\n\n let dockerServiceCheck: CheckResult | null = null;\n if (dockerCheck.status === 'success') {\n dockerServiceCheck = await checkDockerService();\n results.push(dockerServiceCheck);\n }\n\n const dockerComposeCheck = await checkCommand('docker-compose');\n results.push(dockerComposeCheck);\n\n // Sui CLI check\n const suiCheck = await checkCommand('sui');\n results.push(suiCheck);\n\n // Configuration files check\n const gitConfigCheck = checkFileExists(join(homedir(), '.gitconfig'), 'Git configuration');\n results.push(gitConfigCheck);\n\n // Create and display table\n const table = new Table({\n head: [chalk.bold.cyan('Criteria'), chalk.bold.cyan('Result'), chalk.bold.cyan('Fix')],\n colWidths: [25, 15, 50],\n style: {\n head: ['cyan'],\n border: ['grey']\n },\n wordWrap: true\n });\n\n // Add table rows\n results.forEach((result) => {\n table.push(formatTableRow(result));\n });\n\n console.log(table.toString());\n\n // Summarize results\n const summary = {\n success: results.filter((r) => r.status === 'success').length,\n warning: results.filter((r) => r.status === 'warning').length,\n error: results.filter((r) => r.status === 'error').length\n };\n\n console.log('\\n' + chalk.bold('๐ Check Summary:'));\n console.log(` ${chalk.green('โ Passed:')} ${summary.success} items`);\n console.log(` ${chalk.yellow('! Warning:')} ${summary.warning} items`);\n console.log(` ${chalk.red('โ Error:')} ${summary.error} items`);\n\n if (summary.error > 0) {\n console.log(\n chalk.red(\n '\\nโ Your environment has some issues, please fix them according to the suggestions above.'\n )\n );\n process.exit(1);\n } else if (summary.warning > 0) {\n console.log(\n chalk.yellow(\n '\\nโ ๏ธ Your environment is basically ready, but it is recommended to fix warning items for a better development experience.'\n )\n );\n } else {\n console.log(chalk.green('\\nโ
Congratulations! Your development environment is fully ready!'));\n }\n\n console.log(\n chalk.gray(\n '\\n๐ก Tip: For more help, visit https://docs.sui.io/ or https://github.com/0xobelisk/dubhe'\n )\n );\n}\n\nconst commandModule: CommandModule = {\n command: 'doctor',\n describe: 'Check if local development environment is ready',\n builder(yargs) {\n return yargs.option('verbose', {\n alias: 'v',\n type: 'boolean',\n description: 'Show verbose output',\n default: false\n });\n },\n async handler() {\n try {\n await runDoctorChecks();\n } catch (error) {\n console.error(chalk.red('Error occurred during check:'), error);\n process.exit(1);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport chalk from 'chalk';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\nimport { generateConfigJson } from '../utils';\nimport fs from 'fs';\n\ntype Options = {\n 'config-path': string;\n 'output-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'convert-json',\n describe: 'Convert JSON from Dubhe config to config.json',\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n description: 'Options to pass to forge test'\n },\n 'output-path': {\n type: 'string',\n default: 'dubhe.config.json',\n description: 'Output path for the config.json file'\n }\n });\n },\n\n async handler({\n 'config-path': configPath,\n 'output-path': outputPath\n }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('๐ Running convert json');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const json = generateConfigJson(dubheConfig);\n // write to file\n fs.writeFileSync(outputPath, json);\n } catch (error: any) {\n console.error(chalk.red('Error executing convert json:'));\n console.log(error.stdout);\n process.exit(0);\n }\n }\n};\n\nexport default commandModule;\n","import { CommandModule } from 'yargs';\n\nimport localnode from './localnode';\nimport faucet from './faucet';\nimport schemagen from './schemagen';\nimport publish from './publish';\nimport test from './test';\nimport build from './build';\nimport hello from './hello';\nimport generateKey from './generateKey';\nimport checkBalance from './checkBalance';\nimport configStore from './configStore';\nimport watch from './watch';\nimport wait from './wait';\nimport switchEnv from './switchEnv';\nimport info from './info';\nimport loadMetadata from './loadMetadata';\nimport doctor from './doctor';\nimport convertJson from './convertJson';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options\nexport const commands: CommandModule<any, any>[] = [\n localnode,\n publish,\n // call,\n // query,\n faucet,\n schemagen,\n // upgrade,\n test,\n build,\n hello,\n generateKey,\n checkBalance,\n configStore,\n watch,\n wait,\n switchEnv,\n info,\n loadMetadata,\n doctor,\n convertJson\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBACxB,OAAOC,OAAW,QCJlB,OAAS,YAAAC,EAAU,SAAAC,OAAa,gBAChC,OAAOC,MAAW,QCDlB,OAAOC,OAAW,QAEX,SAASC,GAAa,CAC3B,QAAQ,IACND,GAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAWhB,CACC,CACF,CCjBA,OAAgB,eAAAE,MAAmB,wBACnC,OAAS,YAAAC,OAAgB,gBACzB,OAAOC,MAAW,QCFlB,UAAYC,MAAa,cACzB,OAAS,aAAAC,GAAW,iBAAAC,OAAqB,KACzC,OAAS,WAAAC,OAAe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,CAAW,EAE3CL,GAAG,cAAcI,EAAYG,CAAI,CACnC,OAASE,EAAP,CACA,QAAQ,MAAMC,GAAM,IAAI,+BAA+B,CAAC,EACxD,QAAQ,IAAID,EAAM,MAAM,EACxB,QAAQ,KAAK,CAAC,CAChB,CACF,CACF,EAEOE,GAAQV,GC3BR,IAAMW,GAAsC,CACjDC,GACAC,GAGAC,GACAC,GAEAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,EACF,E5BhCA,UAAYC,OAAY,SACjB,UAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,OAAO,EAGlB,QAAQC,EAAe,EACvB,QAAQC,EAAY,OAAO,EAC3B,cAAc,EAAG,0BAA0B,EAC3C,kBAAkB,EAElB,OAAO,EAEP,KAAK,CAACC,EAAKC,IAAQ,CAClB,QAAQ,MAAMC,GAAM,IAAIF,CAAG,CAAC,EAExBA,EAAI,SAAS,2BAA2B,GAC1C,QAAQ,IACNE,GAAM,OACJ,mBAAmB,QAAQ,KAAK,CAAC,2DACnC,CACF,EAEF,QAAQ,IAAI,EAAE,EAEVD,GAAO,OACTE,EAASF,CAAG,EACZ,QAAQ,IAAI,EAAE,GAGhB,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEA,MAAM,CAAE,EAAG,MAAO,CAAC,EAAE","names":["yargs","hideBin","chalk","execSync","spawn","chalk","chalk","printDubhe","Transaction","execSync","chalk","fsAsync","mkdirSync","writeFileSync","dirname","SUI_PRIVATE_KEY_PREFIX","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","DubheCliError","logError","error","ValidationError","chalk","ZodError","validationError","fromZodError","NotInsideProjectError","DubheCliError","fs","chalk","spawn","Dubhe","loadMetadata","package_default","validatePrivateKey","privateKey","SUI_PRIVATE_KEY_PREFIX","strippedPrivateKey","getDeploymentJson","projectPath","network","data","error","getDeploymentDappHub","getDubheDappHub","contractPath","getOldPackageId","projectPath","network","getDeploymentJson","saveContractData","projectName","network","packageId","dappHub","upgradeCap","version","components","DeploymentData","path","storeDeploymentData","writeOutput","saveMetadata","metadata","loadMetadata","metadataJson","error","chalk","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","getDubheDependency","package_default","updateDubheDependency","filePath","fileContent","newDependency","updatedContent","checkRpcAvailability","rpcUrl","response","addEnv","rpcMap","resolve","reject","errorOutput","stdoutOutput","suiProcess","spawn","data","code","finalError","switchEnv","delay","ms","loadKey","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","initializeDubhe","Dubhe","generateConfigJson","config","name","component","fields","keys","fieldName","fieldType","resources","resource","enums","enumFields","sortedFields","b","value","index","updateMoveTomlAddress","packageAddress","moveTomlPath","fs","path","removeEnvContent","filePath","networkType","content","regex","updatedContent","updateEnvFile","operation","chainId","publishedId","envFilePath","envContent","envLines","networkSectionIndex","line","config","i","key","value","part","updatedSection","newEnvContent","buildContract","projectPath","modules","dependencies","buildResult","execSync","error","chalk","waitForNode","dubhe","address","coins","balance","sum","coin","publishContract","dubheConfig","network","gasBudget","tx","Transaction","upgradeCap","result","version","packageId","dappHub","components","upgradeCapId","printObjects","object","delay","deployHookTx","args","dubheDappHub","getDubheDappHub","deployHookResult","saveContractData","saveMetadata","checkDubheFramework","publishDubheFramework","updateMoveTomlAddress","publishHandler","switchEnv","initializeDubhe","updateDubheDependency","Dubhe","fs","stopLocalNode","chalk","processStopped","execSync","patterns","pattern","result","pids","pid","removeDirectory","dirPath","error","isSuiStartRunning","printAccounts","privateKeys","privateKey","index","keypair","spawn","handleProcessSignals","suiProcess","cleanup","startLocalNode","data_dir","force","delay","printDubhe","validatePrivateKey","DubheCliError","resolve","commandModule","data_dir","force","startLocalNode","error","localnode_default","requestSuiFromFaucetV0","getFaucetHost","SuiClient","getFullnodeUrl","MAX_RETRIES","RETRY_INTERVAL","SPINNER","commandModule","yargs","network","recipient","faucet_address","initializeDubhe","retryCount","success","spinnerIndex","startTime","isInterrupted","handleInterrupt","requestSuiFromFaucetV0","getFaucetHost","elapsedTime","spinner","resolve","client","SuiClient","getFullnodeUrl","params","balance","faucet_default","schemaGen","loadConfig","chalk","path","commandModule","configPath","network","dubheConfig","rootDir","error","schemagen_default","loadConfig","execSync","commandModule","yargs","network","configPath","gasBudget","dubheConfig","publishHandler","error","logError","publish_default","execSync","loadConfig","commandModule","yargs","configPath","test","gasLimit","dubheConfig","command","test_default","execSync","exec","chalk","loadConfig","commandModule","yargs","configPath","network","dumpBytecodeAsBase64","dubheConfig","loadConfig","projectPath","switchEnv","updateDubheDependency","command","output","execSync","exec","error","chalk","build_default","commandModule","yargs","printDubhe","hello_default","Dubhe","fs","chalk","generateAccountHandler","force","useNextPublic","path","privateKey","envContent","newKeyName","lines","shouldUpdate","i","line","currentKeyName","newLine","keypair","newContent","commandModule","force","useNextPublic","generateAccountHandler","error","generateKey_default","chalk","dotenv","dotenv","checkBalanceHandler","network","balance","initializeDubhe","balanceInSUI","DubheCliError","chalk","error","commandModule","network","checkBalanceHandler","error","checkBalance_default","mkdirSync","writeFileSync","dirname","storeConfig","network","packageId","outputPath","dubheDappHub","getDubheDappHub","code","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","storeConfigHandler","dubheConfig","contractPath","deployment","getDeploymentJson","loadConfig","commandModule","configPath","network","outputTsPath","dubheConfig","storeConfigHandler","error","configStore_default","chokidar","exec","commandModule","yargs","configFilePath","runSchemagen","error","stdout","stderr","watcher","path","watch_default","waitOn","ora","chalk","commandModule","yargs","argv","options","spinner","status","wait_default","commandModule","yargs","argv","switchEnv","switchEnv_default","dotenv","chalk","InfoCommand","yargs","network","dubhe","initializeDubhe","keypair","balance","suiBalance","error","logError","info_default","loadConfig","loadMetadataHandler","dubheConfig","network","packageId","saveMetadata","projectPath","getOldPackageId","commandModule","yargs","network","configPath","packageId","dubheConfig","loadConfig","loadMetadataHandler","error","logError","loadMetadata_default","chalk","spawn","existsSync","homedir","join","Table","execCommand","command","args","resolve","child","stdout","stderr","data","code","checkCommand","versionFlag","result","version","getInstallSuggestion","checkFileExists","filePath","description","exists","checkNodeVersion","checkDockerService","checkNpmConfig","formatTableRow","statusIcon","statusText","fixContent","runDoctorChecks","results","nodeCheck","pnpmCheck","gitCheck","npmConfigCheck","dockerCheck","dockerServiceCheck","dockerComposeCheck","suiCheck","gitConfigCheck","table","summary","r","commandModule","yargs","error","doctor_default","chalk","loadConfig","fs","commandModule","yargs","configPath","outputPath","dubheConfig","loadConfig","json","generateConfigJson","error","chalk","convertJson_default","commands","localnode_default","publish_default","faucet_default","schemagen_default","test_default","build_default","hello_default","generateKey_default","checkBalance_default","configStore_default","watch_default","wait_default","switchEnv_default","info_default","loadMetadata_default","doctor_default","convertJson_default","dotenv","yargs","hideBin","commands","package_default","msg","err","chalk","logError"]}
|
|
1
|
+
{"version":3,"sources":["../src/dubhe.ts","../src/utils/startNode.ts","../src/utils/printDubhe.ts","../src/utils/publishHandler.ts","../src/utils/utils.ts","../src/utils/errors.ts","../package.json","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/commands/test.ts","../src/commands/build.ts","../src/commands/hello.ts","../src/utils/generateAccount.ts","../src/commands/generateKey.ts","../src/utils/checkBalance.ts","../src/commands/checkBalance.ts","../src/utils/storeConfig.ts","../src/commands/configStore.ts","../src/commands/watch.ts","../src/commands/wait.ts","../src/commands/switchEnv.ts","../src/commands/info.ts","../src/commands/loadMetadata.ts","../src/utils/metadataHandler.ts","../src/commands/doctor.ts","../src/commands/convertJson.ts","../src/commands/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport chalk from 'chalk';\nimport { commands } from './commands';\nimport { logError } from './utils/errors';\nimport packageJson from '../package.json';\n\n// Load .env file into process.env\nimport * as dotenv from 'dotenv';\ndotenv.config();\n\nyargs(hideBin(process.argv))\n // Explicit name to display in help (by default it's the entry file, which may not be \"dubhe\" for e.g. ts-node)\n .scriptName('dubhe')\n // Use the commands directory to scaffold\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- command array overload isn't typed, see https://github.com/yargs/yargs/blob/main/docs/advanced.md#esm-hierarchy\n .command(commands as any)\n .version(packageJson.version)\n .demandCommand(1, 'Please provide a command')\n .recommendCommands()\n // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg, err) => {\n console.error(chalk.red(msg));\n\n if (msg.includes('Missing required argument')) {\n console.log(\n chalk.yellow(\n `Run 'pnpm dubhe ${process.argv[2]} --help' for a list of available and required arguments.`\n )\n );\n }\n console.log('');\n // Even though `.fail` type says we should get an `Error`, this can sometimes be undefined\n if (err != null) {\n logError(err);\n console.log('');\n }\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: 'help' }).argv;\n","import { execSync, spawn } from 'child_process';\nimport chalk from 'chalk';\nimport { printDubhe } from './printDubhe';\nimport { delay, DubheCliError, validatePrivateKey } from '../utils';\nimport { Dubhe } from '@0xobelisk/sui-client';\nimport * as fs from 'fs';\n\nexport function stopLocalNode(): void {\n console.log(chalk.yellow('๐ Stopping existing Local Node...'));\n\n let processStopped = false;\n\n if (process.platform === 'win32') {\n // Windows: Kill all sui.exe processes\n try {\n execSync('taskkill /F /IM sui.exe', { stdio: 'ignore' });\n processStopped = true;\n } catch (error) {\n // Process not found\n }\n } else {\n // Unix-like systems: Try multiple patterns to find sui processes\n const patterns = [\n 'sui start', // Exact match\n 'sui.*start', // Pattern with any flags\n '^sui', // Any sui command\n 'sui.*--with-faucet' // Match our specific startup pattern\n ];\n\n for (const pattern of patterns) {\n try {\n const result = execSync(`pgrep -f \"${pattern}\"`, { stdio: 'pipe' }).toString().trim();\n if (result) {\n const pids = result.split('\\n').filter((pid) => pid);\n console.log(chalk.cyan(` โโ Found ${pids.length} process(es) matching \"${pattern}\"`));\n\n pids.forEach((pid) => {\n try {\n // First try graceful termination\n execSync(`kill -TERM ${pid}`, { stdio: 'ignore' });\n console.log(chalk.cyan(` โโ Sent SIGTERM to process ${pid}`));\n } catch (error) {\n // If graceful termination fails, force kill\n try {\n execSync(`kill -KILL ${pid}`, { stdio: 'ignore' });\n console.log(chalk.cyan(` โโ Force killed process ${pid}`));\n } catch (killError) {\n console.log(chalk.gray(` โโ Process ${pid} already terminated`));\n }\n }\n });\n processStopped = true;\n break; // Stop after first successful pattern match\n }\n } catch (error) {\n // This pattern didn't match any processes, continue to next pattern\n continue;\n }\n }\n }\n\n if (processStopped) {\n console.log(chalk.green(' โโ Local Node stopped successfully'));\n } else {\n console.log(chalk.gray(' โโ No running Local Node found'));\n }\n}\n\nexport function removeDirectory(dirPath: string): void {\n try {\n if (fs.existsSync(dirPath)) {\n console.log(chalk.yellow(`๐๏ธ Removing directory: ${dirPath}`));\n fs.rmSync(dirPath, { recursive: true, force: true });\n console.log(chalk.green(' โโ Directory removed successfully'));\n } else {\n console.log(chalk.gray(` โโ Directory ${dirPath} does not exist`));\n }\n } catch (error: any) {\n console.error(chalk.red(` โโ Error removing directory: ${error.message}`));\n }\n}\n\nfunction isSuiStartRunning(): boolean {\n try {\n if (process.platform === 'win32') {\n const result = execSync(`tasklist /FI \"IMAGENAME eq sui.exe\" /FO CSV /NH`).toString().trim();\n return result.toLowerCase().includes('sui.exe');\n } else {\n // Try multiple patterns to detect running sui processes\n const patterns = ['sui start', 'sui.*start', '^sui', 'sui.*--with-faucet'];\n\n for (const pattern of patterns) {\n try {\n const result = execSync(`pgrep -f \"${pattern}\"`, { stdio: 'pipe' }).toString().trim();\n if (result && result.length > 0) {\n return true;\n }\n } catch (error) {\n continue;\n }\n }\n return false;\n }\n } catch (error) {\n return false;\n }\n}\n\nasync function printAccounts() {\n // These private keys are used for testing purposes only, do not use them in production.\n const privateKeys = [\n 'suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v',\n 'suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s',\n 'suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc',\n 'suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c',\n 'suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57',\n 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'\n ];\n console.log('๐Accounts');\n console.log('==========');\n privateKeys.forEach((privateKey, index) => {\n const dubhe = new Dubhe({ secretKey: privateKey });\n const keypair = dubhe.getSigner();\n spawn(\n 'curl',\n [\n '--location',\n '--request',\n 'POST',\n 'http://127.0.0.1:9123/gas',\n '--header',\n 'Content-Type: application/json',\n '--data-raw',\n `{\"FixedAmountRequest\": {\"recipient\": \"${keypair.toSuiAddress()}\"}}`\n ],\n {\n env: { ...process.env },\n stdio: 'ignore',\n detached: true\n }\n );\n console.log(` โโ Account #${index}: ${keypair.toSuiAddress()}(1000 SUI)`);\n console.log(` โโ Private Key: ${privateKey}`);\n });\n console.log('==========');\n console.log(\n chalk.yellow('โน๏ธ WARNING: These accounts, and their private keys, are publicly known.')\n );\n console.log(\n chalk.yellow('Any funds sent to them on Mainnet or any other live network WILL BE LOST.')\n );\n}\n\nfunction handleProcessSignals(suiProcess: ReturnType<typeof spawn> | null) {\n const cleanup = () => {\n console.log(chalk.yellow('\\n๐ Stopping Local Node...'));\n if (suiProcess) {\n suiProcess.kill('SIGINT');\n }\n process.exit(0);\n };\n\n process.on('SIGINT', cleanup);\n process.on('SIGTERM', cleanup);\n}\n\nexport async function startLocalNode(data_dir: string, force?: boolean) {\n if (force) {\n console.log(chalk.cyan('\\n๐ Force mode enabled'));\n stopLocalNode();\n console.log(chalk.yellow(' โโ Waiting for processes to terminate...'));\n await delay(3000); // Wait longer for process to fully stop\n removeDirectory(data_dir);\n console.log('');\n } else if (isSuiStartRunning()) {\n console.log(chalk.yellow('\\nโ ๏ธ Warning: Local Node Already Running'));\n console.log(chalk.yellow(' โโ Cannot start a new instance'));\n console.log(chalk.yellow(' โโ Please stop the existing process first'));\n return;\n }\n\n printDubhe();\n console.log('๐ Starting Local Node...');\n let suiProcess: ReturnType<typeof spawn> | null = null;\n try {\n suiProcess = spawn(\n 'sui',\n ['start', '--with-faucet', '--force-regenesis', '--data-ingestion-dir', data_dir],\n {\n env: { ...process.env, RUST_LOG: 'off,sui_node=info' },\n stdio: 'ignore'\n }\n );\n\n suiProcess.on('error', (error) => {\n console.error(chalk.red('\\nโ Failed to Start Local Node'));\n console.error(chalk.red(` โโ Error: ${error.message}`));\n });\n await delay(5000);\n console.log(' โโ Faucet: Enabled');\n console.log(' โโ Force Regenesis: Yes');\n console.log(' โโ HTTP server: http://127.0.0.1:9000/');\n console.log(' โโ Faucet server: http://127.0.0.1:9123/');\n\n await printAccounts();\n\n await delay(2000);\n\n const privateKeyFormat = validatePrivateKey(\n 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'\n );\n if (privateKeyFormat === false) {\n throw new DubheCliError(`Please check your privateKey.`);\n }\n\n console.log(chalk.green('๐ Local environment is ready!'));\n\n handleProcessSignals(suiProcess);\n\n await new Promise<void>((resolve) => {\n suiProcess?.on('exit', () => resolve());\n });\n } catch (error: any) {\n console.error(chalk.red('\\nโ Failed to Start Local Node'));\n console.error(chalk.red(` โโ Error: ${error.message}`));\n if (suiProcess) {\n suiProcess.kill('SIGINT');\n }\n process.exit(1);\n }\n}\n","import chalk from 'chalk';\n\nexport function printDubhe() {\n console.log(\n chalk.yellow(`\nWelcome to Dubhe\n\\t\\t\\t --from team@obelisk\n ________ ___ ___ ________ ___ ___ _______ \n |\\\\ ___ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ __ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ ___ \\\\ \n \\\\ \\\\ \\\\_|\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ /\\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __/| \n \\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __ \\\\ \\\\ __ \\\\ \\\\ \\\\_|/__ \n \\\\ \\\\ \\\\_\\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\_|\\\\ \\\\ \n \\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\__\\\\ \\\\__\\\\ \\\\_______\\\\\n \\\\|_______|\\\\|_______|\\\\|_______|\\\\|__|\\\\|__|\\\\|_______| \n \n`)\n );\n}\n","import { Dubhe, Transaction } from '@0xobelisk/sui-client';\nimport { execSync } from 'child_process';\nimport chalk from 'chalk';\nimport {\n saveContractData,\n updateDubheDependency,\n updateMoveTomlAddress,\n switchEnv,\n delay,\n getDubheDappHub,\n initializeDubhe,\n saveMetadata\n} from './utils';\nimport { DubheConfig } from '@0xobelisk/sui-common';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nasync function removeEnvContent(\n filePath: string,\n networkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n): Promise<void> {\n if (!fs.existsSync(filePath)) {\n return;\n }\n const content = fs.readFileSync(filePath, 'utf-8');\n const regex = new RegExp(`\\\\[env\\\\.${networkType}\\\\][\\\\s\\\\S]*?(?=\\\\[|$)`, 'g');\n const updatedContent = content.replace(regex, '');\n fs.writeFileSync(filePath, updatedContent, 'utf-8');\n}\n\ninterface EnvConfig {\n chainId: string;\n originalPublishedId: string;\n latestPublishedId: string;\n publishedVersion: number;\n}\n\nfunction updateEnvFile(\n filePath: string,\n networkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n operation: 'publish' | 'upgrade',\n chainId: string,\n publishedId: string\n): void {\n const envFilePath = path.resolve(filePath);\n const envContent = fs.readFileSync(envFilePath, 'utf-8');\n const envLines = envContent.split('\\n');\n\n const networkSectionIndex = envLines.findIndex((line) => line.trim() === `[env.${networkType}]`);\n const config: EnvConfig = {\n chainId: chainId,\n originalPublishedId: '',\n latestPublishedId: '',\n publishedVersion: 0\n };\n\n if (networkSectionIndex === -1) {\n // If network section is not found, add a new section\n if (operation === 'publish') {\n config.originalPublishedId = publishedId;\n config.latestPublishedId = publishedId;\n config.publishedVersion = 1;\n } else {\n throw new Error(\n `Network type [env.${networkType}] not found in the file and cannot upgrade.`\n );\n }\n } else {\n for (let i = networkSectionIndex + 1; i < envLines.length; i++) {\n const line = envLines[i].trim();\n if (line.startsWith('[')) break; // End of the current network section\n\n const [key, value] = line.split('=').map((part) => part.trim().replace(/\"/g, ''));\n switch (key) {\n case 'original-published-id':\n config.originalPublishedId = value;\n break;\n case 'latest-published-id':\n config.latestPublishedId = value;\n break;\n case 'published-version':\n config.publishedVersion = parseInt(value, 10);\n break;\n }\n }\n\n if (operation === 'publish') {\n config.originalPublishedId = publishedId;\n config.latestPublishedId = publishedId;\n config.publishedVersion = 1;\n } else if (operation === 'upgrade') {\n config.latestPublishedId = publishedId;\n config.publishedVersion += 1;\n }\n }\n\n const updatedSection = `\n[env.${networkType}]\nchain-id = \"${config.chainId}\"\noriginal-published-id = \"${config.originalPublishedId}\"\nlatest-published-id = \"${config.latestPublishedId}\"\npublished-version = \"${config.publishedVersion}\"\n`;\n\n const newEnvContent =\n networkSectionIndex === -1\n ? envContent + updatedSection\n : envLines.slice(0, networkSectionIndex).join('\\n') + updatedSection;\n\n fs.writeFileSync(envFilePath, newEnvContent, 'utf-8');\n}\n// function capitalizeAndRemoveUnderscores(input: string): string {\n// \treturn input\n// \t\t.split('_')\n// \t\t.map((word, index) => {\n// \t\t\treturn index === 0\n// \t\t\t\t? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n// \t\t\t\t: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n// \t\t})\n// \t\t.join('');\n// }\n//\n// function getLastSegment(input: string): string {\n// \tconst segments = input.split('::');\n// \treturn segments.length > 0 ? segments[segments.length - 1] : '';\n// }\n\nfunction buildContract(projectPath: string): string[][] {\n let modules: any, dependencies: any;\n try {\n const buildResult = JSON.parse(\n execSync(`sui move build --dump-bytecode-as-base64 --path ${projectPath}`, {\n encoding: 'utf-8',\n stdio: 'pipe'\n })\n );\n modules = buildResult.modules;\n dependencies = buildResult.dependencies;\n } catch (error: any) {\n console.error(chalk.red(' โโ Build failed'));\n console.error(error.stdout);\n process.exit(1);\n }\n return [modules, dependencies];\n}\n\ninterface ObjectChange {\n type: string;\n objectType?: string;\n packageId?: string;\n objectId?: string;\n}\n\nasync function waitForNode(dubhe: Dubhe): Promise<string> {\n const chainId = await dubhe.suiInteractor.currentClient.getChainIdentifier();\n console.log(` โโ ChainId: ${chainId}`);\n const address = dubhe.getAddress();\n const coins = await dubhe.suiInteractor.currentClient.getCoins({\n owner: address,\n coinType: '0x2::sui::SUI'\n });\n\n if (coins.data.length > 0) {\n const balance = coins.data.reduce((sum, coin) => sum + Number(coin.balance), 0);\n if (balance > 0) {\n console.log(` โโ Deployer balance: ${balance / 10 ** 9} SUI`);\n return chainId;\n } else {\n console.log(\n chalk.yellow(\n ` โโ Deployer balance: 0 SUI, please ensure your account has sufficient SUI balance`\n )\n );\n }\n }\n return chainId;\n}\n\nasync function publishContract(\n dubhe: Dubhe,\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n projectPath: string,\n gasBudget?: number\n) {\n console.log('\\n๐ Starting Contract Publication...');\n console.log(` โโ Project: ${projectPath}`);\n console.log(` โโ Network: ${network}`);\n console.log(' โโ Waiting for node...');\n\n const chainId = await waitForNode(dubhe);\n console.log(' โโ Validating Environment...');\n\n await removeEnvContent(`${projectPath}/Move.lock`, network);\n console.log(` โโ Account: ${dubhe.getAddress()}`);\n\n console.log('\\n๐ฆ Building Contract...');\n const [modules, dependencies] = buildContract(projectPath);\n\n console.log('\\n๐ Publishing Contract...');\n const tx = new Transaction();\n if (gasBudget) {\n tx.setGasBudget(gasBudget);\n }\n const [upgradeCap] = tx.publish({ modules, dependencies });\n tx.transferObjects([upgradeCap], dubhe.getAddress());\n\n let result;\n try {\n result = await dubhe.signAndSendTxn({ tx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Publication failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (!result || result.effects?.status.status === 'failure') {\n console.log(chalk.red(' โโ Publication failed'));\n process.exit(1);\n }\n\n console.log(' โโ Processing publication results...');\n let version = 1;\n let packageId = '';\n let dappHub = '';\n let components = dubheConfig.components;\n let upgradeCapId = '';\n\n let printObjects: any[] = [];\n\n result.objectChanges!.map((object: ObjectChange) => {\n if (object.type === 'published') {\n console.log(` โโ Package ID: ${object.packageId}`);\n packageId = object.packageId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType === '0x2::package::UpgradeCap'\n ) {\n console.log(` โโ Upgrade Cap: ${object.objectId}`);\n upgradeCapId = object.objectId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType.includes('dapp_hub::DappHub')\n ) {\n dappHub = object.objectId || '';\n }\n if (object.type === 'created') {\n printObjects.push(object);\n }\n });\n\n console.log(` โโ Transaction: ${result.digest}`);\n\n updateEnvFile(`${projectPath}/Move.lock`, network, 'publish', chainId, packageId);\n\n console.log('\\nโก Executing Deploy Hook...');\n await delay(5000);\n\n const deployHookTx = new Transaction();\n let args = [];\n let dubheDappHub = dubheConfig.name === 'dubhe' ? dappHub : await getDubheDappHub(network);\n args.push(deployHookTx.object(dubheDappHub));\n args.push(deployHookTx.object('0x6'));\n deployHookTx.moveCall({\n target: `${packageId}::genesis::run`,\n arguments: args\n });\n\n let deployHookResult;\n try {\n deployHookResult = await dubhe.signAndSendTxn({ tx: deployHookTx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Deploy hook execution failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (deployHookResult.effects?.status.status === 'success') {\n console.log(' โโ Hook execution successful');\n console.log(` โโ Transaction: ${deployHookResult.digest}`);\n\n console.log('\\n๐ Created Objects:');\n printObjects.map((object: ObjectChange) => {\n console.log(` โโ Type: ${object.objectType}`);\n console.log(` โโ ID: ${object.objectId}`);\n });\n\n await saveContractData(\n dubheConfig.name,\n network,\n packageId,\n dappHub,\n upgradeCapId,\n version,\n components\n );\n\n await saveMetadata(dubheConfig.name, network, packageId);\n\n // Insert package id to dubhe config\n let config = JSON.parse(fs.readFileSync(`${process.cwd()}/dubhe.config.json`, 'utf-8'));\n config.package_id = packageId;\n fs.writeFileSync(`${process.cwd()}/dubhe.config.json`, JSON.stringify(config, null, 2));\n\n console.log('\\nโ
Contract Publication Complete\\n');\n } else {\n console.log(chalk.yellow(' โโ Deploy hook execution failed'));\n console.log(chalk.yellow(' Please republish or manually call deploy_hook::run'));\n console.log(chalk.yellow(' Please check the transaction digest:'));\n console.log(chalk.yellow(` ${deployHookResult.digest}`));\n process.exit(1);\n }\n}\n\nasync function checkDubheFramework(projectPath: string): Promise<boolean> {\n if (!fs.existsSync(projectPath)) {\n console.log(chalk.yellow('\\nโน๏ธ Dubhe Framework Files Not Found'));\n console.log(chalk.yellow(' โโ Expected Path:'), projectPath);\n console.log(chalk.yellow(' โโ To set up Dubhe Framework:'));\n console.log(chalk.yellow(' โ 1. Create directory: mkdir -p contracts/dubhe'));\n console.log(\n chalk.yellow(\n ' โ 2. Clone repository: git clone https://github.com/0xobelisk/dubhe contracts/dubhe'\n )\n );\n console.log(chalk.yellow(' โ 3. Or download from: https://github.com/0xobelisk/dubhe'));\n console.log(chalk.yellow(' โโ After setup, restart the local node'));\n return false;\n }\n return true;\n}\n\nexport async function publishDubheFramework(\n dubhe: Dubhe,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n const path = process.cwd();\n const projectPath = `${path}/src/dubhe`;\n\n if (!(await checkDubheFramework(projectPath))) {\n return;\n }\n\n console.log('\\n๐ Starting Dubhe Framework Publication...');\n console.log(' โโ Waiting for node...');\n\n const chainId = await waitForNode(dubhe);\n\n await removeEnvContent(`${projectPath}/Move.lock`, network);\n await updateMoveTomlAddress(projectPath, \"0x0\");\n\n const [modules, dependencies] = buildContract(projectPath);\n const tx = new Transaction();\n const [upgradeCap] = tx.publish({ modules, dependencies });\n tx.transferObjects([upgradeCap], dubhe.getAddress());\n\n let result;\n try {\n result = await dubhe.signAndSendTxn({ tx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Publication failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (!result || result.effects?.status.status === 'failure') {\n console.log(chalk.red(' โโ Publication failed'));\n process.exit(1);\n }\n\n let version = 1;\n let packageId = '';\n let dappHub = '';\n let components = {};\n let upgradeCapId = '';\n\n result.objectChanges!.map((object: ObjectChange) => {\n if (object.type === 'published') {\n packageId = object.packageId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType === '0x2::package::UpgradeCap'\n ) {\n upgradeCapId = object.objectId || '';\n }\n if (\n object.type === 'created' &&\n object.objectType &&\n object.objectType.includes('dapp_hub::DappHub')\n ) {\n dappHub = object.objectId || '';\n }\n });\n\n await delay(3000);\n const deployHookTx = new Transaction();\n deployHookTx.moveCall({\n target: `${packageId}::dubhe_genesis::run`,\n arguments: [deployHookTx.object(dappHub), deployHookTx.object('0x6')]\n });\n\n let deployHookResult;\n try {\n deployHookResult = await dubhe.signAndSendTxn({ tx: deployHookTx });\n } catch (error: any) {\n console.error(chalk.red(' โโ Deploy hook execution failed'));\n console.error(error.message);\n process.exit(1);\n }\n\n if (deployHookResult.effects?.status.status !== 'success') {\n throw new Error('Deploy hook execution failed');\n }\n\n await updateMoveTomlAddress(projectPath, packageId);\n await saveContractData('dubhe', network, packageId, dappHub, upgradeCapId, version, components);\n\n updateEnvFile(`${projectPath}/Move.lock`, network, 'publish', chainId, packageId);\n}\n\nexport async function publishHandler(\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n gasBudget?: number\n) {\n await switchEnv(network);\n\n const dubhe = initializeDubhe({\n network\n });\n\n const path = process.cwd();\n const projectPath = `${path}/src/${dubheConfig.name}`;\n\n if (network === 'localnet' && dubheConfig.name !== 'dubhe') {\n await publishDubheFramework(dubhe, network);\n }\n\n if (dubheConfig.name !== 'dubhe') {\n await updateDubheDependency(`${projectPath}/Move.toml`, network);\n }\n await publishContract(dubhe, dubheConfig, network, projectPath, gasBudget);\n}\n","import * as fsAsync from 'fs/promises';\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { dirname } from 'path';\nimport { SUI_PRIVATE_KEY_PREFIX } from '@mysten/sui/cryptography';\nimport { FsIibError } from './errors';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\nimport { spawn } from 'child_process';\nimport { Dubhe, NetworkType, SuiMoveNormalizedModules, loadMetadata } from '@0xobelisk/sui-client';\nimport { DubheCliError } from './errors';\nimport packageJson from '../../package.json';\nimport { Component, MoveType, EmptyComponent, DubheConfig } from '@0xobelisk/sui-common';\n\nexport type DeploymentJsonType = {\n projectName: string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n packageId: string;\n dappHub: string;\n upgradeCap: string;\n version: number;\n components: Record<string, Component | MoveType | EmptyComponent>;\n};\n\nexport function validatePrivateKey(privateKey: string): false | string {\n if (privateKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {\n if (privateKey.length === 70) {\n return privateKey;\n } else {\n return false;\n }\n } else if (privateKey.startsWith('0x')) {\n const strippedPrivateKey = privateKey.slice(2);\n if (strippedPrivateKey.length === 64) {\n return strippedPrivateKey;\n } else {\n return false;\n }\n } else {\n if (privateKey.length === 64) {\n return privateKey;\n } else {\n return false;\n }\n }\n}\n\nexport async function updateVersionInFile(projectPath: string, newVersion: string) {\n try {\n const filePath = `${projectPath}/sources/script/migrate.move`;\n const data = await fsAsync.readFile(filePath, 'utf8');\n\n // update version data\n const updatedData = data.replace(\n /const VERSION: u64 = \\d+;/,\n `const VERSION: u64 = ${newVersion};`\n );\n\n // write new version\n writeOutput(updatedData, filePath, 'Update package version');\n } catch {\n throw new FsIibError('Fs update version failed.');\n }\n}\n\nexport async function getDeploymentJson(\n projectPath: string,\n network: string\n): Promise<DeploymentJsonType> {\n try {\n const data = await fsAsync.readFile(\n `${projectPath}/.history/sui_${network}/latest.json`,\n 'utf8'\n );\n return JSON.parse(data) as DeploymentJsonType;\n } catch (error) {\n throw new Error(`read .history/sui_${network}/latest.json failed. ${error}`);\n }\n}\n\nexport async function getDeploymentDappHub(projectPath: string, network: string): Promise<string> {\n try {\n const data = await fsAsync.readFile(\n `${projectPath}/.history/sui_${network}/latest.json`,\n 'utf8'\n );\n const deployment = JSON.parse(data) as DeploymentJsonType;\n return deployment.dappHub;\n } catch (error) {\n return '';\n }\n}\n\nexport async function getDubheDappHub(network: string) {\n const path = process.cwd();\n const contractPath = `${path}/src/dubhe`;\n\n switch (network) {\n case 'mainnet':\n return await getDeploymentDappHub(contractPath, 'mainnet');\n case 'testnet':\n return await getDeploymentDappHub(contractPath, 'testnet');\n case 'devnet':\n return await getDeploymentDappHub(contractPath, 'devnet');\n case 'localnet':\n return await getDeploymentDappHub(contractPath, 'localnet');\n default:\n throw new Error(`Invalid network: ${network}`);\n }\n}\n\nexport async function getOnchainComponents(\n projectPath: string,\n network: string\n): Promise<Record<string, Component | MoveType | EmptyComponent>> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.components;\n}\n\nexport async function getVersion(projectPath: string, network: string): Promise<number> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.version;\n}\n\nexport async function getNetwork(\n projectPath: string,\n network: string\n): Promise<'mainnet' | 'testnet' | 'devnet' | 'localnet'> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.network;\n}\n\nexport async function getOldPackageId(projectPath: string, network: string): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.packageId;\n}\n\nexport async function getDappHub(projectPath: string, network: string): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.dappHub;\n}\n\nexport async function getUpgradeCap(projectPath: string, network: string): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.upgradeCap;\n}\n\nexport async function saveContractData(\n projectName: string,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n packageId: string,\n dappHub: string,\n upgradeCap: string,\n version: number,\n components: Record<string, Component | MoveType | EmptyComponent>\n) {\n const DeploymentData: DeploymentJsonType = {\n projectName,\n network,\n packageId,\n dappHub,\n components,\n upgradeCap,\n version\n };\n\n const path = process.cwd();\n const storeDeploymentData = JSON.stringify(DeploymentData, null, 2);\n await writeOutput(\n storeDeploymentData,\n `${path}/src/${projectName}/.history/sui_${network}/latest.json`,\n 'Update deploy log'\n );\n}\n\nexport async function saveMetadata(\n projectName: string,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n packageId: string\n) {\n const path = process.cwd();\n\n // Save metadata files\n try {\n const metadata = await loadMetadata(network, packageId);\n if (metadata) {\n const metadataJson = JSON.stringify(metadata, null, 2);\n\n // Save packageId-specific metadata file\n await writeOutput(\n metadataJson,\n `${path}/src/${projectName}/.history/sui_${network}/${packageId}.json`,\n 'Save package metadata'\n );\n\n // Save latest metadata.json\n await writeOutput(metadataJson, `${path}/metadata.json`, 'Save latest metadata');\n }\n } catch (error) {\n console.warn(chalk.yellow(`Warning: Failed to save metadata: ${error}`));\n }\n}\n\nexport async function writeOutput(\n output: string,\n fullOutputPath: string,\n logPrefix?: string\n): Promise<void> {\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, output);\n if (logPrefix !== undefined) {\n console.log(`${logPrefix}: ${fullOutputPath}`);\n }\n}\n\nfunction getDubheDependency(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'): string {\n switch (network) {\n case 'localnet':\n return 'Dubhe = { local = \"../dubhe\" }';\n case 'testnet':\n return `Dubhe = { git = \"https://github.com/0xobelisk/dubhe-wip.git\", subdir = \"packages/sui-framework/src/dubhe\", rev = \"v${packageJson.version}\" }`;\n case 'mainnet':\n return `Dubhe = { git = \"https://github.com/0xobelisk/dubhe-wip.git\", subdir = \"packages/sui-framework/src/dubhe\", rev = \"v${packageJson.version}\" }`;\n default:\n throw new Error(`Unsupported network: ${network}`);\n }\n}\n\nexport async function updateDubheDependency(\n filePath: string,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n const fileContent = fs.readFileSync(filePath, 'utf-8');\n const newDependency = getDubheDependency(network);\n const updatedContent = fileContent.replace(/Dubhe = \\{.*\\}/, newDependency);\n fs.writeFileSync(filePath, updatedContent, 'utf-8');\n console.log(`Updated Dubhe dependency in ${filePath} for ${network}.`);\n}\n\nasync function checkRpcAvailability(rpcUrl: string): Promise<boolean> {\n try {\n const response = await fetch(rpcUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'sui_getLatestCheckpointSequenceNumber',\n params: []\n })\n });\n\n if (!response.ok) {\n return false;\n }\n\n const data = await response.json();\n return !data.error;\n } catch (error) {\n return false;\n }\n}\n\nexport async function addEnv(\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n): Promise<void> {\n const rpcMap = {\n localnet: 'http://127.0.0.1:9000',\n devnet: 'https://fullnode.devnet.sui.io:443/',\n testnet: 'https://fullnode.testnet.sui.io:443/',\n mainnet: 'https://fullnode.mainnet.sui.io:443/'\n };\n\n const rpcUrl = rpcMap[network];\n\n // Check RPC availability first\n const isRpcAvailable = await checkRpcAvailability(rpcUrl);\n if (!isRpcAvailable) {\n throw new Error(\n `RPC endpoint ${rpcUrl} is not available. Please check your network connection or try again later.`\n );\n }\n\n return new Promise<void>((resolve, reject) => {\n let errorOutput = '';\n let stdoutOutput = '';\n\n const suiProcess = spawn(\n 'sui',\n ['client', 'new-env', '--alias', network, '--rpc', rpcMap[network]],\n {\n env: { ...process.env },\n stdio: 'pipe'\n }\n );\n\n // Capture standard output\n suiProcess.stdout.on('data', (data) => {\n stdoutOutput += data.toString();\n });\n\n // Capture error output\n suiProcess.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n\n // Handle process errors (e.g., command not found)\n suiProcess.on('error', (error) => {\n console.error(chalk.red(`\\nโ Failed to execute sui command: ${error.message}`));\n reject(new Error(`Failed to execute sui command: ${error.message}`));\n });\n\n // Handle process exit\n suiProcess.on('exit', (code) => {\n // Check if \"already exists\" message is present\n if (errorOutput.includes('already exists') || stdoutOutput.includes('already exists')) {\n console.log(chalk.yellow(`Environment ${network} already exists, proceeding...`));\n resolve();\n return;\n }\n\n if (code === 0) {\n console.log(chalk.green(`Successfully added environment ${network}`));\n resolve();\n } else {\n const finalError = errorOutput || stdoutOutput || `Process exited with code ${code}`;\n console.error(chalk.red(`\\nโ Failed to add environment ${network}`));\n console.error(chalk.red(` โโ ${finalError.trim()}`));\n reject(new Error(finalError));\n }\n });\n });\n}\n\nexport async function switchEnv(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n try {\n // First, try to add the environment\n await addEnv(network);\n\n // Then switch to the specified environment\n return new Promise<void>((resolve, reject) => {\n let errorOutput = '';\n let stdoutOutput = '';\n\n const suiProcess = spawn('sui', ['client', 'switch', '--env', network], {\n env: { ...process.env },\n stdio: 'pipe'\n });\n\n suiProcess.stdout.on('data', (data) => {\n stdoutOutput += data.toString();\n });\n\n suiProcess.stderr.on('data', (data) => {\n errorOutput += data.toString();\n });\n\n suiProcess.on('error', (error) => {\n console.error(chalk.red(`\\nโ Failed to execute sui command: ${error.message}`));\n reject(new Error(`Failed to execute sui command: ${error.message}`));\n });\n\n suiProcess.on('exit', (code) => {\n if (code === 0) {\n console.log(chalk.green(`Successfully switched to environment ${network}`));\n resolve();\n } else {\n const finalError = errorOutput || stdoutOutput || `Process exited with code ${code}`;\n console.error(chalk.red(`\\nโ Failed to switch to environment ${network}`));\n console.error(chalk.red(` โโ ${finalError.trim()}`));\n reject(new Error(finalError));\n }\n });\n });\n } catch (error) {\n // Re-throw the error for the caller to handle\n throw error;\n }\n}\n\nexport const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nexport function loadKey(): string {\n const privateKey = process.env.PRIVATE_KEY || process.env.NEXT_PUBLIC_PRIVATE_KEY;\n if (!privateKey) {\n throw new DubheCliError(\n `Missing private key environment variable.\n Run 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\n or 'echo \"NEXT_PUBLIC_PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\n in your contracts directory to use the default sui private key.`\n );\n }\n const privateKeyFormat = validatePrivateKey(privateKey);\n if (privateKeyFormat === false) {\n throw new DubheCliError(`Please check your privateKey.`);\n }\n return privateKeyFormat;\n}\n\nexport function initializeDubhe({\n network,\n packageId,\n metadata\n}: {\n network: NetworkType;\n packageId?: string;\n metadata?: SuiMoveNormalizedModules;\n}): Dubhe {\n const privateKey = loadKey();\n return new Dubhe({\n networkType: network,\n secretKey: privateKey,\n packageId,\n metadata\n });\n}\n\nexport function generateConfigJson(config: DubheConfig): string {\n const components = Object.entries(config.components).map(([name, component]) => {\n if (typeof component === 'string') {\n return {\n [name]: {\n fields: [\n { entity_id: 'address' },\n { value: component }\n ],\n keys: ['entity_id']\n }\n };\n }\n\n if (Object.keys(component as object).length === 0) {\n return {\n [name]: {\n fields: [\n { entity_id: 'address' }\n ],\n keys: ['entity_id']\n }\n };\n }\n\n const fields = (component as any).fields || {};\n const keys = (component as any).keys || ['entity_id'];\n\n // ensure entity_id field exists\n if (!fields.entity_id && keys.includes('entity_id')) {\n fields.entity_id = 'address';\n }\n\n return {\n [name]: {\n fields: Object.entries(fields).map(([fieldName, fieldType]) => ({\n [fieldName]: fieldType\n })),\n keys: keys\n }\n };\n });\n\n const resources = Object.entries(config.resources).map(([name, resource]) => {\n if (typeof resource === 'string') {\n return {\n [name]: {\n fields: [\n { value: resource }\n ],\n keys: []\n }\n };\n }\n\n if (Object.keys(resource as object).length === 0) {\n return {\n [name]: {\n fields: [],\n keys: []\n }\n };\n }\n\n const fields = (resource as any).fields || {};\n const keys = (resource as any).keys || [];\n\n return {\n [name]: {\n fields: Object.entries(fields).map(([fieldName, fieldType]) => ({\n [fieldName]: fieldType\n })),\n keys: keys\n }\n };\n });\n\n // handle enums\n const enums = Object.entries(config.enums || {}).map(([name, enumFields]) => {\n // Sort enum values by first letter\n let sortedFields = enumFields.sort((a, b) => a.localeCompare(b)).map((value, index) => ({\n [index]: value\n }));\n\n return {\n [name]: {\n fields: sortedFields\n }\n };\n });\n\n return JSON.stringify({\n components,\n resources,\n enums\n }, null, 2);\n}\n\n/**\n * Updates the dubhe address in Move.toml file\n * @param path - Directory path containing Move.toml file\n * @param packageAddress - New dubhe package address to set\n */\nexport function updateMoveTomlAddress(path: string, packageAddress: string) {\n const moveTomlPath = `${path}/Move.toml`;\n const moveTomlContent = fs.readFileSync(moveTomlPath, 'utf-8');\n // Use regex to match any dubhe address, not just \"0x0\"\n const updatedContent = moveTomlContent.replace(/dubhe\\s*=\\s*\"[^\"]*\"/, `dubhe = \"${packageAddress}\"`);\n fs.writeFileSync(moveTomlPath, updatedContent, 'utf-8');\n}\n","import chalk from 'chalk';\nimport { ZodError } from 'zod';\nimport { fromZodError, ValidationError } from 'zod-validation-error';\n\nexport class NotInsideProjectError extends Error {\n name = 'NotInsideProjectError';\n message = 'You are not inside a Dubhe project';\n}\n\nexport class DubheCliError extends Error {\n name = 'DubheCliError';\n}\n\nexport class UpgradeError extends Error {\n name = 'UpgradeError';\n}\n\nexport class FsIibError extends Error {\n name = 'FsIibError';\n}\n\nexport function logError(error: unknown) {\n if (error instanceof ValidationError) {\n console.log(chalk.redBright(error.message));\n } else if (error instanceof ZodError) {\n // TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n const validationError = fromZodError(error, {\n prefixSeparator: '\\n- ',\n issueSeparator: '\\n- '\n });\n console.log(chalk.redBright(validationError.message));\n } else if (error instanceof NotInsideProjectError) {\n console.log(chalk.red(error.message));\n console.log('');\n // TODO add docs to the website and update the link to the specific page\n console.log(\n chalk.blue(\n `To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk`\n )\n );\n } else if (error instanceof DubheCliError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\n}\n","{\n \"name\": \"@0xobelisk/sui-cli\",\n \"version\": \"1.2.0-pre.34\",\n \"description\": \"Tookit for interacting with move eps framework\",\n \"keywords\": [\n \"sui\",\n \"obelisk labs\",\n \"move\",\n \"blockchain\"\n ],\n \"type\": \"module\",\n \"author\": \"team@obelisk.build\",\n \"homepage\": \"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme\",\n \"bugs\": \"https://github.com/0xobelisk/dubhe/issues\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/0xobelisk/dubhe.git\"\n },\n \"license\": \"Apache-2.0\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"engines\": {\n \"node\": \">=18\"\n },\n \"exports\": {\n \".\": \"./dist/index.js\"\n },\n \"types\": \"src/index.ts\",\n \"bin\": {\n \"dubhe\": \"./dist/dubhe.js\"\n },\n \"scripts\": {\n \"build\": \"pnpm run type-check && pnpm run build:js\",\n \"build:js\": \"tsup && chmod +x ./dist/dubhe.js\",\n \"clean\": \"pnpm run clean:js\",\n \"clean:js\": \"rimraf dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint . --ext .ts\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"type-check\": \"tsc --noEmit\",\n \"validate\": \"pnpm format:check && pnpm type-check\"\n },\n \"dependencies\": {\n \"@0xobelisk/sui-client\": \"workspace:*\",\n \"@0xobelisk/sui-common\": \"workspace:*\",\n \"@mysten/sui\": \"^1.19.0\",\n \"@types/sqlite3\": \"^3.1.11\",\n \"@types/wait-on\": \"^5.3.4\",\n \"chalk\": \"^5.0.1\",\n \"child_process\": \"^1.0.2\",\n \"chokidar\": \"^3.5.3\",\n \"cli-table3\": \"^0.6.5\",\n \"dotenv\": \"^16.0.3\",\n \"ejs\": \"^3.1.8\",\n \"execa\": \"^7.0.0\",\n \"glob\": \"^8.0.3\",\n \"ora\": \"^5.4.1\",\n \"path\": \"^0.12.7\",\n \"sqlite\": \"^5.1.1\",\n \"sqlite3\": \"^5.1.7\",\n \"typescript\": \"5.1.6\",\n \"wait-on\": \"^7.0.1\",\n \"yargs\": \"^17.7.1\",\n \"zod\": \"^3.22.3\",\n \"zod-validation-error\": \"^1.3.0\"\n },\n \"devDependencies\": {\n \"@types/ejs\": \"^3.1.1\",\n \"@types/glob\": \"^7.2.0\",\n \"@types/node\": \"^18.15.11\",\n \"@types/yargs\": \"^17.0.10\",\n \"eslint\": \"^8.56.0\",\n \"eslint-config-prettier\": \"^9.1.0\",\n \"prettier\": \"3.3.3\",\n \"ts-node\": \"^10.9.1\",\n \"tsup\": \"^6.7.0\",\n \"tsx\": \"^3.12.6\",\n \"vitest\": \"0.31.4\"\n }\n}\n","import type { CommandModule } from 'yargs';\nimport { startLocalNode } from '../utils/startNode';\n\ntype Options = {\n 'data-dir': string;\n force: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'node',\n\n describe: 'Manage local Sui node',\n\n builder: {\n 'data-dir': {\n type: 'string',\n default: '.chk',\n desc: 'Path to the data directory'\n },\n force: {\n type: 'boolean',\n default: false,\n desc: 'Force restart: stop existing node and remove data directory'\n }\n },\n\n async handler({ 'data-dir': data_dir, force }) {\n try {\n await startLocalNode(data_dir, force);\n } catch (error) {\n console.error('Error executing command:', error);\n process.exit(1);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { requestSuiFromFaucetV0, getFaucetHost } from '@mysten/sui/faucet';\nimport { SuiClient, getFullnodeUrl, GetBalanceParams } from '@mysten/sui/client';\nimport { initializeDubhe } from '../utils';\n\ntype Options = {\n network: any;\n recipient?: string;\n};\n\nconst MAX_RETRIES = 60; // 60s timeout\nconst RETRY_INTERVAL = 1000; // 1s retry interval\nconst SPINNER = ['โ ', 'โ ', 'โ น', 'โ ธ', 'โ ผ', 'โ ด', 'โ ฆ', 'โ ง', 'โ ', 'โ '];\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'faucet',\n\n describe: 'Interact with a Dubhe faucet',\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n desc: 'URL of the Dubhe faucet',\n choices: ['testnet', 'devnet', 'localnet'],\n default: 'localnet'\n },\n recipient: {\n type: 'string',\n desc: 'Sui address to fund'\n }\n });\n },\n\n async handler({ network, recipient }) {\n let faucet_address = '';\n if (recipient === undefined) {\n const dubhe = initializeDubhe(network);\n faucet_address = dubhe.getAddress();\n } else {\n faucet_address = recipient;\n }\n\n console.log('\\n๐ Starting Faucet Operation...');\n console.log(` โโ Network: ${network}`);\n\n if (recipient === undefined) {\n console.log(' โโ Using Environment PrivateKey');\n console.log(` โโ Generated Address: ${faucet_address}`);\n } else {\n console.log(` โโ Using Provided Address: ${faucet_address}`);\n }\n\n console.log(' โโ Requesting funds from faucet...');\n\n let retryCount = 0;\n let success = false;\n let spinnerIndex = 0;\n const startTime = Date.now();\n let isInterrupted = false;\n\n const handleInterrupt = () => {\n isInterrupted = true;\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n console.log('\\n โโ Operation cancelled by user');\n process.exit(0);\n };\n process.on('SIGINT', handleInterrupt);\n\n try {\n while (retryCount < MAX_RETRIES && !success && !isInterrupted) {\n try {\n await requestSuiFromFaucetV0({\n host: getFaucetHost(network),\n recipient: faucet_address\n });\n success = true;\n } catch (error) {\n if (isInterrupted) break;\n\n retryCount++;\n if (retryCount === MAX_RETRIES) {\n console.log(` โโ Failed to request funds after ${MAX_RETRIES} attempts.`);\n console.log(' โโ Please check your network connection and try again later.');\n process.exit(1);\n }\n\n const elapsedTime = Math.floor((Date.now() - startTime) / 1000);\n const spinner = SPINNER[spinnerIndex % SPINNER.length];\n spinnerIndex++;\n\n process.stdout.write(`\\r โโ ${spinner} Retrying... (${elapsedTime}s)`);\n await new Promise((resolve) => setTimeout(resolve, RETRY_INTERVAL));\n }\n }\n } finally {\n process.removeListener('SIGINT', handleInterrupt);\n }\n\n if (isInterrupted) {\n process.exit(0);\n }\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n\n console.log(' โโ Checking balance...');\n const client = new SuiClient({ url: getFullnodeUrl(network) });\n let params = {\n owner: faucet_address\n } as GetBalanceParams;\n\n const balance = await client.getBalance(params);\n\n console.log('\\n๐ฐ Account Summary');\n console.log(` โโ Address: ${faucet_address}`);\n console.log(` โโ Balance: ${(Number(balance.totalBalance) / 1_000_000_000).toFixed(4)} SUI`);\n\n console.log('\\nโ
Faucet Operation Complete\\n');\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { schemaGen, loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport chalk from 'chalk';\nimport path from \"node:path\";\n\ntype Options = {\n 'config-path'?: string;\n network?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'schemagen',\n\n describe: 'Autogenerate Dubhe schemas based on the config file',\n\n builder: {\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n desc: 'Path to the config file'\n },\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n }\n },\n\n async handler({ 'config-path': configPath, network }) {\n try {\n if (!configPath) throw new Error('Config path is required');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const rootDir = path.dirname(configPath);\n await schemaGen(rootDir, dubheConfig, network);\n process.exit(0);\n } catch (error: any) {\n console.log(chalk.red('Schemagen failed!'));\n console.error(error.message);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { publishHandler } from '../utils';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport { execSync } from 'child_process';\n\ntype Options = {\n network: any;\n 'config-path': string;\n 'gas-budget'?: number;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'publish',\n\n describe: 'Publish dubhe move contract',\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n default: 'localnet',\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n },\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n desc: 'Configuration file path'\n },\n 'gas-budget': {\n type: 'number',\n desc: 'Optional gas budget for the transaction',\n optional: true\n }\n });\n },\n\n async handler({ network, 'config-path': configPath, 'gas-budget': gasBudget }) {\n try {\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n execSync(`pnpm dubhe convert-json --config-path ${configPath}`, { encoding: 'utf-8' })\n await publishHandler(dubheConfig, network, gasBudget); \n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { execSync } from 'child_process';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n 'config-path': string;\n test?: string;\n 'gas-limit'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'test',\n\n describe: 'Run tests in Dubhe contracts',\n\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n description: 'Options to pass to forge test'\n },\n test: {\n type: 'string',\n desc: 'Run a specific test'\n },\n 'gas-limit': {\n type: 'string',\n desc: 'Set the gas limit for the test',\n default: '100000000'\n }\n });\n },\n\n async handler({ 'config-path': configPath, test, 'gas-limit': gasLimit }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('๐ Running move test');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/src/${dubheConfig.name}`;\n const command = `sui move test --path ${projectPath} ${\n test ? ` --test ${test}` : ''\n } --gas-limit ${gasLimit}`;\n execSync(command, { stdio: 'inherit', encoding: 'utf-8' });\n } catch (error: any) {\n process.exit(0);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { execSync, exec } from 'child_process';\nimport chalk from 'chalk';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\nimport { switchEnv, updateDubheDependency } from '../utils';\n\ntype Options = {\n 'config-path': string;\n network: any;\n 'dump-bytecode-as-base64'?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'build',\n describe: 'Run tests in Dubhe contracts',\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n description: 'Options to pass to forge test'\n },\n network: {\n type: 'string',\n default: 'localnet',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n },\n 'dump-bytecode-as-base64': {\n type: 'boolean',\n default: false,\n desc: 'Dump bytecode as base64'\n }\n });\n },\n\n async handler({\n 'config-path': configPath,\n network,\n 'dump-bytecode-as-base64': dumpBytecodeAsBase64\n }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('๐ Running move build');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/src/${dubheConfig.name}`;\n await switchEnv(network);\n await updateDubheDependency(projectPath + '/Move.toml', network);\n const command = `sui move build --path ${projectPath} ${\n dumpBytecodeAsBase64 ? ` --dump-bytecode-as-base64` : ''\n }`;\n const output = execSync(command, { encoding: 'utf-8' });\n console.log(output);\n exec(`pnpm dubhe convert-json --config-path ${configPath}`)\n } catch (error: any) {\n console.error(chalk.red('Error executing sui move build:'));\n console.log(error.stdout);\n process.exit(0);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { printDubhe } from '../utils';\n\nconst commandModule: CommandModule = {\n command: 'hello',\n\n describe: 'hello, dubhe',\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n printDubhe();\n }\n};\n\nexport default commandModule;\n","import { Dubhe } from '@0xobelisk/sui-client';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\n\nexport async function generateAccountHandler(\n force: boolean = false,\n useNextPublic: boolean = false\n) {\n if (useNextPublic) {\n console.log(\n chalk.gray(\n 'Note: The generated account will be stored in the .env file with NEXT_PUBLIC_ prefix for client-side usage.'\n )\n );\n console.log(\n chalk.yellow('Warning: Do not expose the .env file, it is intended for local testing only.\\n')\n );\n }\n const path = process.cwd();\n let privateKey: string | undefined;\n let envContent = '';\n\n // Check if .env file exists\n try {\n envContent = fs.readFileSync(`${path}/.env`, 'utf8');\n\n // privateKey = process.env.PRIVATE_KEY || process.env.NEXT_PUBLIC_PRIVATE_KEY;\n let privateKey = process.env.PRIVATE_KEY || process.env.NEXT_PUBLIC_PRIVATE_KEY;\n if (useNextPublic) {\n privateKey = process.env.NEXT_PUBLIC_PRIVATE_KEY || process.env.PRIVATE_KEY;\n }\n\n if (privateKey) {\n // If key exists, decide whether to update keyname based on useNextPublic\n const newKeyName = useNextPublic ? 'NEXT_PUBLIC_PRIVATE_KEY' : 'PRIVATE_KEY';\n\n // Find and update the last matching line based on privateKey value\n const lines = envContent.split('\\n');\n let shouldUpdate = false;\n\n // First check if the last matching line already has the correct keyname\n for (let i = lines.length - 1; i >= 0; i--) {\n const line = lines[i];\n if (line.endsWith(privateKey)) {\n // If useNextPublic is true, only update if the line starts with PRIVATE_KEY=\n // If useNextPublic is false, only update if the line starts with NEXT_PUBLIC_PRIVATE_KEY=\n const [currentKeyName] = line.split('=');\n if (useNextPublic) {\n shouldUpdate = currentKeyName === 'PRIVATE_KEY';\n } else {\n shouldUpdate = currentKeyName === 'NEXT_PUBLIC_PRIVATE_KEY';\n }\n break;\n }\n }\n\n // Only update if necessary\n if (shouldUpdate) {\n for (let i = lines.length - 1; i >= 0; i--) {\n const line = lines[i];\n if (line.endsWith(privateKey)) {\n const newLine = `${newKeyName}=${privateKey}`;\n lines[i] = newLine;\n envContent = lines.join('\\n');\n fs.writeFileSync(`${path}/.env`, envContent);\n break;\n }\n }\n }\n\n const dubhe = new Dubhe({ secretKey: privateKey });\n const keypair = dubhe.getSigner();\n console.log(chalk.blue(`Using existing account: ${keypair.toSuiAddress()}`));\n return;\n }\n } catch (error) {\n // .env file doesn't exist or failed to read, continue to generate new account\n }\n\n // Generate a new account if no existing key is found or force generation is requested\n if (force || !privateKey) {\n const dubhe = new Dubhe();\n const keypair = dubhe.getSigner();\n privateKey = keypair.getSecretKey();\n\n const newKeyName = useNextPublic ? 'NEXT_PUBLIC_PRIVATE_KEY' : 'PRIVATE_KEY';\n const newContent = `${newKeyName}=${privateKey}`;\n\n // If .env file exists, append new content; otherwise create a new file\n if (envContent) {\n envContent = envContent.trim() + '\\n' + newContent;\n } else {\n envContent = newContent;\n }\n\n fs.writeFileSync(`${path}/.env`, envContent);\n console.log(chalk.green(`File created/updated at: ${path}/.env`));\n\n console.log(chalk.blue(`New account generated: ${keypair.toSuiAddress()}`));\n }\n}\n","import type { CommandModule } from 'yargs';\nimport { generateAccountHandler } from '../utils/generateAccount';\n\ntype Options = {\n force?: boolean;\n 'use-next-public'?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'generate-key',\n describe: 'Generate a new account keypair and save it to a .env file',\n builder: {\n force: {\n type: 'boolean',\n default: false,\n desc: 'Force generate a new keypair'\n },\n 'use-next-public': {\n type: 'boolean',\n default: false,\n desc: 'Use the NEXT_PUBLIC_ prefix for client-side usage'\n }\n },\n async handler({ force, 'use-next-public': useNextPublic }) {\n try {\n await generateAccountHandler(force, useNextPublic);\n } catch (error) {\n console.error('Error generating account:', error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import chalk from 'chalk';\nimport dotenv from 'dotenv';\nimport { initializeDubhe } from './utils';\nimport { DubheCliError } from './errors';\ndotenv.config();\n\nexport async function checkBalanceHandler(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n try {\n const dubhe = initializeDubhe({\n network\n });\n\n const balance = await dubhe.getBalance();\n const balanceInSUI = Number(balance.totalBalance) / 1_000_000_000;\n\n if (balanceInSUI === 0) {\n throw new DubheCliError(`Your account balance is 0 SUI. Please get some SUI to proceed.`);\n }\n\n console.log(chalk.green(`Current account balance: ${balanceInSUI.toFixed(4)} SUI`));\n } catch (error) {\n throw new DubheCliError('Failed to check balance: ' + error);\n }\n}\n","import type { CommandModule } from 'yargs';\nimport { checkBalanceHandler } from '../utils/checkBalance';\n\ntype Options = {\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'check-balance',\n describe: 'Check the balance of the account',\n builder: {\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Network to check balance on',\n default: 'localnet'\n }\n },\n async handler({ network }) {\n try {\n await checkBalanceHandler(network);\n } catch (error) {\n console.error('Error checking balance:', error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import { mkdirSync, writeFileSync } from 'fs';\nimport { dirname } from 'path';\nimport { DubheConfig } from '@0xobelisk/sui-common';\nimport { getDeploymentJson, getDubheDappHub } from './utils';\n\nasync function storeConfig(network: string, packageId: string, outputPath: string) {\n const dubheDappHub = await getDubheDappHub(network);\n let code = `type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';\n\nexport const NETWORK: NetworkType = '${network}';\nexport const PACKAGE_ID = '${packageId}';\nexport const DUBHE_SCHEMA_ID = '${dubheDappHub}';\n`;\n\n writeOutput(code, outputPath, 'storeConfig');\n}\n\nasync function writeOutput(\n output: string,\n fullOutputPath: string,\n logPrefix?: string\n): Promise<void> {\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, output);\n if (logPrefix !== undefined) {\n console.log(`${logPrefix}: ${fullOutputPath}`);\n }\n}\n\nexport async function storeConfigHandler(\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n outputPath: string\n) {\n const path = process.cwd();\n const contractPath = `${path}/src/${dubheConfig.name}`;\n const deployment = await getDeploymentJson(contractPath, network);\n await storeConfig(deployment.network, deployment.packageId, outputPath);\n}\n","import type { CommandModule } from 'yargs';\nimport { storeConfigHandler } from '../utils/storeConfig';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n 'config-path': string;\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n 'output-ts-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'config-store',\n\n describe: 'Store configuration for the Dubhe project',\n\n builder: {\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n desc: 'Path to the config file'\n },\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Network to store config for'\n },\n 'output-ts-path': {\n type: 'string',\n desc: 'Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)'\n }\n },\n async handler({ 'config-path': configPath, network, 'output-ts-path': outputTsPath }) {\n try {\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n await storeConfigHandler(dubheConfig, network, outputTsPath);\n } catch (error) {\n console.error('Error storing config:', error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport chokidar from 'chokidar';\nimport { exec } from 'child_process';\n\nconst commandModule: CommandModule = {\n command: 'watch',\n\n describe: 'Watch dubhe config',\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n const configFilePath = 'dubhe.config.ts';\n\n const runSchemagen = () => {\n exec('pnpm dubhe schemagen', (error, stdout, stderr) => {\n if (error) {\n console.error(`Error executing schemagen: ${error.message}`);\n return;\n }\n if (stderr) {\n console.error(`schemagen stderr: ${stderr}`);\n return;\n }\n console.log(`schemagen stdout: ${stdout}`);\n });\n };\n\n const watcher = chokidar.watch(configFilePath, {\n persistent: true\n });\n\n watcher.on('change', (path) => {\n console.log(`${path} has been changed. Running schemagen...`);\n runSchemagen();\n });\n\n console.log(`Watching for changes in ${configFilePath}...`);\n\n process.on('SIGINT', () => {\n watcher.close();\n console.log('\\nWatch stopped.');\n process.exit();\n });\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport waitOn from 'wait-on';\nimport ora from 'ora';\nimport chalk from 'chalk';\n\ninterface WaitOptions {\n url: string;\n timeout: number;\n interval: number;\n}\n\nconst commandModule: CommandModule = {\n command: 'wait',\n describe: 'Wait for service to be ready',\n builder(yargs) {\n return yargs\n .option('url', {\n type: 'string',\n description: 'URL to wait for'\n })\n .option('timeout', {\n type: 'number',\n description: 'Timeout (in milliseconds)',\n default: 180000\n })\n .option('interval', {\n type: 'number',\n description: 'Check interval (in milliseconds)',\n default: 1000\n });\n },\n async handler(argv) {\n const options = argv as unknown as WaitOptions;\n const spinner = ora({\n text: `Waiting for service to start ${chalk.cyan(options.url)}...`,\n color: 'cyan'\n });\n\n spinner.start();\n\n try {\n await waitOn({\n resources: [options.url],\n timeout: options.timeout,\n interval: options.interval,\n validateStatus: (status: number) => status === 200\n });\n\n spinner.succeed(chalk.green('Service is ready!'));\n process.exit(0);\n } catch (error) {\n spinner.fail(chalk.red('Timeout waiting for service'));\n console.error(chalk.yellow('Please make sure the service is running...'));\n process.exit(1);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule, ArgumentsCamelCase } from 'yargs';\nimport { switchEnv } from '../utils';\n\ntype Options = {\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'switch-env',\n describe: 'Switch environment',\n builder(yargs) {\n return yargs.option('network', {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,\n default: 'localnet',\n desc: 'Switch to node network (mainnet/testnet/devnet/localnet)'\n }) as any;\n },\n async handler(argv: ArgumentsCamelCase<Options>) {\n await switchEnv(argv.network as 'mainnet' | 'testnet' | 'devnet' | 'localnet');\n }\n};\n\nexport default commandModule;\n","import { CommandModule } from 'yargs';\nimport { logError, initializeDubhe } from '../utils';\nimport dotenv from 'dotenv';\nimport chalk from 'chalk';\ndotenv.config();\n\ntype Options = {\n network: any;\n};\n\nconst InfoCommand: CommandModule<Options, Options> = {\n command: 'info',\n describe: 'Get information about the current Sui node',\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n default: 'localnet',\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n }\n });\n },\n handler: async ({ network }) => {\n try {\n const dubhe = initializeDubhe({ network });\n const keypair = dubhe.getSigner();\n\n console.log(chalk.blue('Account Information:'));\n console.log(` Network: ${chalk.green(network)}`);\n console.log(` Address: ${chalk.green(keypair.toSuiAddress())}`);\n\n try {\n const balance = await dubhe.getBalance('0x2::sui::SUI');\n const suiBalance = (Number(balance.totalBalance) / 10 ** 9).toFixed(4);\n console.log(` Balance: ${chalk.green(suiBalance)} SUI`);\n } catch (error) {\n console.log(\n ` Balance: ${chalk.red('Failed to fetch balance')} ${chalk.gray('(Network error)')}`\n );\n }\n } catch (error) {\n logError(error);\n process.exit(1);\n }\n }\n};\n\nexport default InfoCommand;\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport { loadMetadataHandler } from '../utils/metadataHandler';\n\ntype Options = {\n network: any;\n 'config-path': string;\n 'package-id'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'load-metadata',\n\n describe: 'Load metadata for a package',\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n default: 'localnet',\n desc: 'Node network (mainnet/testnet/devnet/localnet)'\n },\n 'config-path': {\n type: 'string',\n desc: 'Configuration file path',\n default: 'dubhe.config.ts'\n },\n 'package-id': {\n type: 'string',\n desc: 'Package ID to load metadata for',\n optional: true\n }\n });\n },\n\n async handler({ network, 'config-path': configPath, 'package-id': packageId }) {\n try {\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n await loadMetadataHandler(dubheConfig, network, packageId);\n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n }\n};\n\nexport default commandModule;\n","import { DubheConfig } from '@0xobelisk/sui-common';\nimport { getOldPackageId, saveMetadata } from './utils';\n\nexport async function loadMetadataHandler(\n dubheConfig: DubheConfig,\n network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n packageId?: string\n) {\n if (packageId) {\n await saveMetadata(dubheConfig.name, network, packageId);\n } else {\n const projectPath = `${process.cwd()}/src/${dubheConfig.name}`;\n const packageId = await getOldPackageId(projectPath, network);\n await saveMetadata(dubheConfig.name, network, packageId);\n }\n}\n","import type { CommandModule } from 'yargs';\nimport chalk from 'chalk';\nimport { spawn } from 'child_process';\nimport { existsSync } from 'fs';\nimport { homedir } from 'os';\nimport { join } from 'path';\nimport Table from 'cli-table3';\n\n// Check result type\ninterface CheckResult {\n name: string;\n status: 'success' | 'warning' | 'error';\n message: string;\n fixSuggestion?: string;\n}\n\n// Execute shell command and return output\nasync function execCommand(\n command: string,\n args: string[] = []\n): Promise<{ code: number; stdout: string; stderr: string }> {\n return new Promise((resolve) => {\n const child = spawn(command, args, { shell: true });\n let stdout = '';\n let stderr = '';\n\n child.stdout?.on('data', (data) => {\n stdout += data.toString();\n });\n\n child.stderr?.on('data', (data) => {\n stderr += data.toString();\n });\n\n child.on('close', (code) => {\n resolve({ code: code || 0, stdout, stderr });\n });\n\n child.on('error', () => {\n resolve({ code: -1, stdout, stderr });\n });\n });\n}\n\n// Check if command is available in PATH\nasync function checkCommand(\n command: string,\n versionFlag: string = '--version'\n): Promise<CheckResult> {\n try {\n const result = await execCommand(command, [versionFlag]);\n if (result.code === 0) {\n const version = result.stdout.trim().split('\\n')[0];\n return {\n name: command,\n status: 'success',\n message: `Installed ${version}`\n };\n } else {\n return {\n name: command,\n status: 'error',\n message: 'Not installed',\n fixSuggestion: getInstallSuggestion(command)\n };\n }\n } catch (error) {\n return {\n name: command,\n status: 'error',\n message: 'Not installed',\n fixSuggestion: getInstallSuggestion(command)\n };\n }\n}\n\n// Get installation suggestions\nfunction getInstallSuggestion(command: string): string {\n const suggestions: Record<string, string> = {\n docker: 'Visit https://docs.docker.com/get-docker/ to install Docker',\n 'docker-compose': 'Visit https://docs.docker.com/compose/install/ to install Docker Compose',\n sui: 'Visit https://docs.sui.io/guides/developer/getting-started/sui-install to install Sui CLI',\n pnpm: 'Run: npm install -g pnpm',\n node: 'Visit https://nodejs.org/ to download and install Node.js',\n git: 'Visit https://git-scm.com/downloads to install Git'\n };\n\n return suggestions[command] || `Please install ${command}`;\n}\n\n// Check if file exists\nfunction checkFileExists(filePath: string, description: string): CheckResult {\n const exists = existsSync(filePath);\n return {\n name: description,\n status: exists ? 'success' : 'warning',\n message: exists ? 'Available' : 'Not found',\n fixSuggestion: exists ? undefined : `Please create file: ${filePath}`\n };\n}\n\n// Check Node.js version\nasync function checkNodeVersion(): Promise<CheckResult> {\n try {\n const result = await execCommand('node', ['--version']);\n if (result.code === 0) {\n const version = result.stdout.trim();\n const versionNumber = parseFloat(version.replace('v', ''));\n\n if (versionNumber >= 18) {\n return {\n name: 'Node.js version',\n status: 'success',\n message: `${version} (meets requirement >=18.0)`\n };\n } else {\n return {\n name: 'Node.js version',\n status: 'warning',\n message: `${version} (recommend upgrade to >=18.0)`,\n fixSuggestion: 'Please upgrade Node.js to 18.0 or higher'\n };\n }\n } else {\n return {\n name: 'Node.js version',\n status: 'error',\n message: 'Not installed',\n fixSuggestion: 'Please install Node.js 18.0 or higher'\n };\n }\n } catch (error) {\n return {\n name: 'Node.js version',\n status: 'error',\n message: 'Check failed',\n fixSuggestion: 'Please install Node.js'\n };\n }\n}\n\n// Check Docker service status\nasync function checkDockerService(): Promise<CheckResult> {\n try {\n const result = await execCommand('docker', ['info']);\n if (result.code === 0) {\n return {\n name: 'Docker service',\n status: 'success',\n message: 'Running'\n };\n } else {\n return {\n name: 'Docker service',\n status: 'warning',\n message: 'Not running',\n fixSuggestion: 'Please start Docker service'\n };\n }\n } catch (error) {\n return {\n name: 'Docker service',\n status: 'error',\n message: 'Check failed',\n fixSuggestion: 'Please install and start Docker'\n };\n }\n}\n\n// Check NPM configuration\nasync function checkNpmConfig(): Promise<CheckResult> {\n try {\n const result = await execCommand('npm', ['config', 'get', 'registry']);\n if (result.code === 0) {\n const registry = result.stdout.trim();\n return {\n name: 'NPM configuration',\n status: 'success',\n message: `Configured (${registry})`\n };\n } else {\n return {\n name: 'NPM configuration',\n status: 'warning',\n message: 'Configuration issue',\n fixSuggestion: 'Check NPM config: npm config list'\n };\n }\n } catch (error) {\n return {\n name: 'NPM configuration',\n status: 'warning',\n message: 'Check failed',\n fixSuggestion: 'Please install Node.js and NPM'\n };\n }\n}\n\n// Create table row data\nfunction formatTableRow(result: CheckResult): string[] {\n const statusIcon = {\n success: chalk.green('โ'),\n warning: chalk.yellow('!'),\n error: chalk.red('โ')\n };\n\n const statusText = {\n success: chalk.green('YES'),\n warning: chalk.yellow('WARN'),\n error: chalk.red('NO')\n };\n\n // Decide what content to display based on status\n let fixContent = '';\n if (result.status === 'success') {\n fixContent = result.message;\n } else {\n fixContent = result.fixSuggestion || result.message;\n }\n\n return [result.name, `${statusIcon[result.status]} ${statusText[result.status]}`, fixContent];\n}\n\n// Main check function\nasync function runDoctorChecks() {\n console.log(chalk.bold.blue('\\n๐ Dubhe Doctor - Environment Check Tool\\n'));\n console.log(chalk.gray('Checking your development environment...\\n'));\n\n const results: CheckResult[] = [];\n\n // Execute all checks\n console.log('Running checks...\\n');\n\n // Required tools check\n const nodeCheck = await checkNodeVersion();\n results.push(nodeCheck);\n\n const pnpmCheck = await checkCommand('pnpm');\n results.push(pnpmCheck);\n\n const gitCheck = await checkCommand('git');\n results.push(gitCheck);\n\n // Package manager configuration check\n const npmConfigCheck = await checkNpmConfig();\n // Treat npm config as optional, don't affect overall status\n if (npmConfigCheck.status === 'error') {\n npmConfigCheck.status = 'warning';\n }\n results.push(npmConfigCheck);\n\n // Docker related checks\n const dockerCheck = await checkCommand('docker');\n results.push(dockerCheck);\n\n let dockerServiceCheck: CheckResult | null = null;\n if (dockerCheck.status === 'success') {\n dockerServiceCheck = await checkDockerService();\n results.push(dockerServiceCheck);\n }\n\n const dockerComposeCheck = await checkCommand('docker-compose');\n results.push(dockerComposeCheck);\n\n // Sui CLI check\n const suiCheck = await checkCommand('sui');\n results.push(suiCheck);\n\n // Configuration files check\n const gitConfigCheck = checkFileExists(join(homedir(), '.gitconfig'), 'Git configuration');\n results.push(gitConfigCheck);\n\n // Create and display table\n const table = new Table({\n head: [chalk.bold.cyan('Criteria'), chalk.bold.cyan('Result'), chalk.bold.cyan('Fix')],\n colWidths: [25, 15, 50],\n style: {\n head: ['cyan'],\n border: ['grey']\n },\n wordWrap: true\n });\n\n // Add table rows\n results.forEach((result) => {\n table.push(formatTableRow(result));\n });\n\n console.log(table.toString());\n\n // Summarize results\n const summary = {\n success: results.filter((r) => r.status === 'success').length,\n warning: results.filter((r) => r.status === 'warning').length,\n error: results.filter((r) => r.status === 'error').length\n };\n\n console.log('\\n' + chalk.bold('๐ Check Summary:'));\n console.log(` ${chalk.green('โ Passed:')} ${summary.success} items`);\n console.log(` ${chalk.yellow('! Warning:')} ${summary.warning} items`);\n console.log(` ${chalk.red('โ Error:')} ${summary.error} items`);\n\n if (summary.error > 0) {\n console.log(\n chalk.red(\n '\\nโ Your environment has some issues, please fix them according to the suggestions above.'\n )\n );\n process.exit(1);\n } else if (summary.warning > 0) {\n console.log(\n chalk.yellow(\n '\\nโ ๏ธ Your environment is basically ready, but it is recommended to fix warning items for a better development experience.'\n )\n );\n } else {\n console.log(chalk.green('\\nโ
Congratulations! Your development environment is fully ready!'));\n }\n\n console.log(\n chalk.gray(\n '\\n๐ก Tip: For more help, visit https://docs.sui.io/ or https://github.com/0xobelisk/dubhe'\n )\n );\n}\n\nconst commandModule: CommandModule = {\n command: 'doctor',\n describe: 'Check if local development environment is ready',\n builder(yargs) {\n return yargs.option('verbose', {\n alias: 'v',\n type: 'boolean',\n description: 'Show verbose output',\n default: false\n });\n },\n async handler() {\n try {\n await runDoctorChecks();\n } catch (error) {\n console.error(chalk.red('Error occurred during check:'), error);\n process.exit(1);\n }\n }\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport chalk from 'chalk';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\nimport { generateConfigJson } from '../utils';\nimport fs from 'fs';\n\ntype Options = {\n 'config-path': string;\n 'output-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: 'convert-json',\n describe: 'Convert JSON from Dubhe config to config.json',\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: 'string',\n default: 'dubhe.config.ts',\n description: 'Options to pass to forge test'\n },\n 'output-path': {\n type: 'string',\n default: 'dubhe.config.json',\n description: 'Output path for the config.json file'\n }\n });\n },\n\n async handler({\n 'config-path': configPath,\n 'output-path': outputPath\n }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('๐ Running convert json');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const json = generateConfigJson(dubheConfig);\n // write to file\n fs.writeFileSync(outputPath, json);\n } catch (error: any) {\n console.error(chalk.red('Error executing convert json:'));\n console.log(error.stdout);\n process.exit(0);\n }\n }\n};\n\nexport default commandModule;\n","import { CommandModule } from 'yargs';\n\nimport localnode from './localnode';\nimport faucet from './faucet';\nimport schemagen from './schemagen';\nimport publish from './publish';\nimport test from './test';\nimport build from './build';\nimport hello from './hello';\nimport generateKey from './generateKey';\nimport checkBalance from './checkBalance';\nimport configStore from './configStore';\nimport watch from './watch';\nimport wait from './wait';\nimport switchEnv from './switchEnv';\nimport info from './info';\nimport loadMetadata from './loadMetadata';\nimport doctor from './doctor';\nimport convertJson from './convertJson';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options\nexport const commands: CommandModule<any, any>[] = [\n localnode,\n publish,\n // call,\n // query,\n faucet,\n schemagen,\n // upgrade,\n test,\n build,\n hello,\n generateKey,\n checkBalance,\n configStore,\n watch,\n wait,\n switchEnv,\n info,\n loadMetadata,\n doctor,\n convertJson\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBACxB,OAAOC,OAAW,QCJlB,OAAS,YAAAC,EAAU,SAAAC,OAAa,gBAChC,OAAOC,MAAW,QCDlB,OAAOC,OAAW,QAEX,SAASC,GAAa,CAC3B,QAAQ,IACND,GAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAWhB,CACC,CACF,CCjBA,OAAgB,eAAAE,MAAmB,wBACnC,OAAS,YAAAC,OAAgB,gBACzB,OAAOC,MAAW,QCFlB,UAAYC,MAAa,cACzB,OAAS,aAAAC,GAAW,iBAAAC,OAAqB,KACzC,OAAS,WAAAC,OAAe,OACxB,OAAS,0BAAAC,OAA8B,2BCHvC,OAAOC,MAAW,QAClB,OAAS,YAAAC,OAAgB,MACzB,OAAS,gBAAAC,GAAc,mBAAAC,OAAuB,uBAEvC,IAAMC,EAAN,cAAoC,KAAM,CAC/C,KAAO,wBACP,QAAU,oCACZ,EAEaC,EAAN,cAA4B,KAAM,CACvC,KAAO,eACT,EAUO,SAASC,EAASC,EAAgB,CACvC,GAAIA,aAAiBC,GACnB,QAAQ,IAAIC,EAAM,UAAUF,EAAM,OAAO,CAAC,UACjCA,aAAiBG,GAAU,CAEpC,IAAMC,EAAkBC,GAAaL,EAAO,CAC1C,gBAAiB;AAAA,IACjB,eAAgB;AAAA,GAClB,CAAC,EACD,QAAQ,IAAIE,EAAM,UAAUE,EAAgB,OAAO,CAAC,OAC3CJ,aAAiBM,GAC1B,QAA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AEP,KAAK,CAACC,EAAKC,IAAQ,CAClB,QAAQ,MAAMC,GAAM,IAAIF,CAAG,CAAC,EAExBA,EAAI,SAAS,2BAA2B,GAC1C,QAAQ,IACNE,GAAM,OACJ,mBAAmB,QAAQ,KAAK,CAAC,2DACnC,CACF,EAEF,QAAQ,IAAI,EAAE,EAEVD,GAAO,OACTE,EAASF,CAAG,EACZ,QAAQ,IAAI,EAAE,GAGhB,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEA,MAAM,CAAE,EAAG,MAAO,CAAC,EAAE","names":["yargs","hideBin","chalk","execSync","spawn","chalk","chalk","printDubhe","Transaction","execSync","chalk","fsAsync","mkdirSync","writeFileSync","dirname","SUI_PRIVATE_KEY_PREFIX","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","DubheCliError","logError","error","ValidationError","chalk","ZodError","validationError","fromZodError","NotInsideProjectError","DubheCliError","fs","chalk","spawn","Dubhe","loadMetadata","package_default","validatePrivateKey","privateKey","SUI_PRIVATE_KEY_PREFIX","strippedPrivateKey","getDeploymentJson","projectPath","network","data","error","getDeploymentDappHub","getDubheDappHub","contractPath","getOldPackageId","projectPath","network","getDeploymentJson","saveContractData","projectName","network","packageId","dappHub","upgradeCap","version","components","DeploymentData","path","storeDeploymentData","writeOutput","saveMetadata","metadata","loadMetadata","metadataJson","error","chalk","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","getDubheDependency","package_default","updateDubheDependency","filePath","fileContent","newDependency","updatedContent","checkRpcAvailability","rpcUrl","response","addEnv","rpcMap","resolve","reject","errorOutput","stdoutOutput","suiProcess","spawn","data","code","finalError","switchEnv","delay","ms","loadKey","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","initializeDubhe","Dubhe","generateConfigJson","config","name","component","fields","keys","fieldName","fieldType","resources","resource","enums","enumFields","sortedFields","b","value","index","updateMoveTomlAddress","packageAddress","moveTomlPath","fs","path","removeEnvContent","filePath","networkType","content","regex","updatedContent","updateEnvFile","operation","chainId","publishedId","envFilePath","envContent","envLines","networkSectionIndex","line","config","i","key","value","part","updatedSection","newEnvContent","buildContract","projectPath","modules","dependencies","buildResult","execSync","error","chalk","waitForNode","dubhe","address","coins","balance","sum","coin","publishContract","dubheConfig","network","gasBudget","tx","Transaction","upgradeCap","result","version","packageId","dappHub","components","upgradeCapId","printObjects","object","delay","deployHookTx","args","dubheDappHub","getDubheDappHub","deployHookResult","saveContractData","saveMetadata","checkDubheFramework","publishDubheFramework","updateMoveTomlAddress","publishHandler","switchEnv","initializeDubhe","updateDubheDependency","Dubhe","fs","stopLocalNode","chalk","processStopped","execSync","patterns","pattern","result","pids","pid","removeDirectory","dirPath","error","isSuiStartRunning","printAccounts","privateKeys","privateKey","index","keypair","spawn","handleProcessSignals","suiProcess","cleanup","startLocalNode","data_dir","force","delay","printDubhe","validatePrivateKey","DubheCliError","resolve","commandModule","data_dir","force","startLocalNode","error","localnode_default","requestSuiFromFaucetV0","getFaucetHost","SuiClient","getFullnodeUrl","MAX_RETRIES","RETRY_INTERVAL","SPINNER","commandModule","yargs","network","recipient","faucet_address","initializeDubhe","retryCount","success","spinnerIndex","startTime","isInterrupted","handleInterrupt","requestSuiFromFaucetV0","getFaucetHost","elapsedTime","spinner","resolve","client","SuiClient","getFullnodeUrl","params","balance","faucet_default","schemaGen","loadConfig","chalk","path","commandModule","configPath","network","dubheConfig","rootDir","error","schemagen_default","loadConfig","execSync","commandModule","yargs","network","configPath","gasBudget","dubheConfig","publishHandler","error","logError","publish_default","execSync","loadConfig","commandModule","yargs","configPath","test","gasLimit","dubheConfig","command","test_default","execSync","exec","chalk","loadConfig","commandModule","yargs","configPath","network","dumpBytecodeAsBase64","dubheConfig","loadConfig","projectPath","switchEnv","updateDubheDependency","command","output","execSync","exec","error","chalk","build_default","commandModule","yargs","printDubhe","hello_default","Dubhe","fs","chalk","generateAccountHandler","force","useNextPublic","path","privateKey","envContent","newKeyName","lines","shouldUpdate","i","line","currentKeyName","newLine","keypair","newContent","commandModule","force","useNextPublic","generateAccountHandler","error","generateKey_default","chalk","dotenv","dotenv","checkBalanceHandler","network","balance","initializeDubhe","balanceInSUI","DubheCliError","chalk","error","commandModule","network","checkBalanceHandler","error","checkBalance_default","mkdirSync","writeFileSync","dirname","storeConfig","network","packageId","outputPath","dubheDappHub","getDubheDappHub","code","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","storeConfigHandler","dubheConfig","contractPath","deployment","getDeploymentJson","loadConfig","commandModule","configPath","network","outputTsPath","dubheConfig","storeConfigHandler","error","configStore_default","chokidar","exec","commandModule","yargs","configFilePath","runSchemagen","error","stdout","stderr","watcher","path","watch_default","waitOn","ora","chalk","commandModule","yargs","argv","options","spinner","status","wait_default","commandModule","yargs","argv","switchEnv","switchEnv_default","dotenv","chalk","InfoCommand","yargs","network","dubhe","initializeDubhe","keypair","balance","suiBalance","error","logError","info_default","loadConfig","loadMetadataHandler","dubheConfig","network","packageId","saveMetadata","projectPath","getOldPackageId","commandModule","yargs","network","configPath","packageId","dubheConfig","loadConfig","loadMetadataHandler","error","logError","loadMetadata_default","chalk","spawn","existsSync","homedir","join","Table","execCommand","command","args","resolve","child","stdout","stderr","data","code","checkCommand","versionFlag","result","version","getInstallSuggestion","checkFileExists","filePath","description","exists","checkNodeVersion","checkDockerService","checkNpmConfig","formatTableRow","statusIcon","statusText","fixContent","runDoctorChecks","results","nodeCheck","pnpmCheck","gitCheck","npmConfigCheck","dockerCheck","dockerServiceCheck","dockerComposeCheck","suiCheck","gitConfigCheck","table","summary","r","commandModule","yargs","error","doctor_default","chalk","loadConfig","fs","commandModule","yargs","configPath","outputPath","dubheConfig","loadConfig","json","generateConfigJson","error","chalk","convertJson_default","commands","localnode_default","publish_default","faucet_default","schemagen_default","test_default","build_default","hello_default","generateKey_default","checkBalance_default","configStore_default","watch_default","wait_default","switchEnv_default","info_default","loadMetadata_default","doctor_default","convertJson_default","dotenv","yargs","hideBin","commands","package_default","msg","err","chalk","logError"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xobelisk/sui-cli",
|
|
3
|
-
"version": "1.2.0-pre.
|
|
3
|
+
"version": "1.2.0-pre.34",
|
|
4
4
|
"description": "Tookit for interacting with move eps framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"yargs": "^17.7.1",
|
|
52
52
|
"zod": "^3.22.3",
|
|
53
53
|
"zod-validation-error": "^1.3.0",
|
|
54
|
-
"@0xobelisk/sui-client": "1.2.0-pre.
|
|
55
|
-
"@0xobelisk/sui-common": "1.2.0-pre.
|
|
54
|
+
"@0xobelisk/sui-client": "1.2.0-pre.34",
|
|
55
|
+
"@0xobelisk/sui-common": "1.2.0-pre.34"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/ejs": "^3.1.1",
|