@0xobelisk/sui-cli 0.5.18 → 0.5.19
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/obelisk.js +35 -6
- package/dist/obelisk.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/faucet.ts +21 -2
- package/src/commands/localnode.ts +1 -1
- package/src/utils/localnode/start.ts +41 -41
- package/src/utils/localnode/status.ts +24 -25
- package/src/utils/localnode/stop.ts +35 -12
- package/src/utils/publishHandler.ts +43 -57
package/dist/obelisk.js
CHANGED
|
@@ -1,10 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import Ie from"yargs";import{hideBin as Ne}from"yargs/helpers";import{Obelisk as re}from"@0xobelisk/sui-client";import{Transaction as F}from"@mysten/sui/transactions";import{getFullnodeUrl as ae,SuiClient as ie}from"@mysten/sui/client";import{execSync as le}from"child_process";import p from"chalk";import g from"chalk";import{ZodError as q}from"zod";import{fromZodError as J,ValidationError as W}from"zod-validation-error";var v=class extends Error{name="NotInsideProjectError";message="You are not inside a Obelisk project"},a=class extends Error{name="ObeliskCliError"};function h(e){if(e instanceof W)console.log(g.redBright(e.message));else if(e instanceof q){let o=J(e,{prefixSeparator:`
|
|
3
3
|
- `,issueSeparator:`
|
|
4
|
-
- `});console.log(
|
|
5
|
-
|
|
4
|
+
- `});console.log(g.redBright(o.message))}else e instanceof v?(console.log(g.red(e.message)),console.log(""),console.log(g.blue("To learn more about Obelisk's configuration, please go to https://github.com/0xobelisk"))):e instanceof a?console.log(g.red(e)):console.log(e)}import{mkdirSync as ee,writeFileSync as oe}from"fs";import{dirname as te}from"path";import{SUI_PRIVATE_KEY_PREFIX as ne}from"@mysten/sui/cryptography";import{execSync as Q,spawn as Z}from"child_process";import r from"chalk";function X(){try{let e=process.platform==="win32"?'tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH':'pgrep -f "sui start"',o=Q(e).toString().trim();return process.platform==="win32"?o.toLowerCase().includes("sui.exe"):o.length>0}catch{return!1}}async function k(e=!1){if(console.log(`
|
|
5
|
+
\u{1F50D} Checking Local Node Status...`),console.log(" \u251C\u2500 Scanning running processes"),X()){console.log(r.yellow(`
|
|
6
|
+
\u26A0\uFE0F Warning: Local Node Already Running`)),console.log(r.yellow(" \u251C\u2500 Cannot start a new instance")),console.log(r.yellow(" \u2514\u2500 Please stop the existing process first"));return}console.log(`
|
|
7
|
+
\u{1F680} Starting Local Node...`),console.log(" \u251C\u2500 Mode: "+(e?"Background":"Foreground")),console.log(" \u251C\u2500 Faucet: Enabled"),console.log(" \u2514\u2500 Force Regenesis: Yes");try{let o=Z("sui",["start","--with-faucet","--force-regenesis"],{env:{...process.env,RUST_LOG:"off,sui_node=info"},stdio:e?"ignore":"inherit",detached:e});o.on("error",t=>{console.error(r.red(`
|
|
8
|
+
\u274C Failed to Start Local Node`)),console.error(r.red(` \u2514\u2500 Error: ${t.message}`))}),e?(o.unref(),console.log(r.green(`
|
|
9
|
+
\u2705 Local Node Started in Background`)),process.platform==="win32"?(console.log(`
|
|
10
|
+
\u{1F4A1} Helpful Commands:`),console.log(" \u251C\u2500 Check Process: tasklist | findstr sui.exe"),console.log(" \u2514\u2500 Stop Node: taskkill /PID <process_id> /F")):(console.log(`
|
|
11
|
+
\u{1F4A1} Helpful Commands:`),console.log(" \u251C\u2500 Check Process: pgrep -f 'sui start'"),console.log(" \u2514\u2500 Stop Node: kill <process_id>"))):(o.on("exit",t=>{t===0?(console.log(r.green(`
|
|
12
|
+
\u2705 Local Node Stopped`)),console.log(r.green(" \u2514\u2500 Exit Status: Normal"))):(console.error(r.red(`
|
|
13
|
+
\u274C Local Node Crashed`)),console.error(r.red(` \u2514\u2500 Exit Code: ${t}`)))}),console.log(r.cyan(`
|
|
14
|
+
\u{1F4E1} Local Node Running`)),console.log(r.cyan(" \u2514\u2500 Press Ctrl+C to stop")),await new Promise(()=>{}))}catch(o){console.error(r.red(`
|
|
15
|
+
\u274C Failed to Start Local Node`)),console.error(r.red(` \u2514\u2500 Error: ${o.message}`))}}import{execSync as z}from"child_process";import i from"chalk";async function E(){console.log(`
|
|
16
|
+
\u{1F50D} Checking Local Node Status...`);try{let e=process.platform==="win32"?'tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH':"ps aux | grep '[s]ui start --with-faucet --force-regenesis'",o=z(e,{encoding:"utf8"});(process.platform==="win32"?o.toLowerCase().includes("sui.exe"):o.split(`
|
|
17
|
+
`).filter(Boolean).length>0)?(console.log(i.green(`
|
|
18
|
+
\u2705 Node Status: Running`)),console.log(i.gray(`
|
|
19
|
+
\u{1F4CA} Process Details:`)),console.log(i.gray(` \u2514\u2500 ${o.trim()}`))):(console.log(i.red(`
|
|
20
|
+
\u274C Node Status: Not Running`)),console.log(i.yellow(`
|
|
21
|
+
\u{1F4A1} Quick Start:`)),console.log(i.yellow(" \u2514\u2500 Run `obelisk localnode start`")))}catch{console.log(i.red(`
|
|
22
|
+
\u274C Node Status: Not Running`)),console.log(i.yellow(`
|
|
23
|
+
\u{1F4A1} Quick Start:`)),console.log(i.yellow(" \u2514\u2500 Run `obelisk localnode start`"))}}import{execSync as R}from"child_process";async function b(){console.log("Stopping local node...");try{let e=process.platform==="win32"?'tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH':"ps aux | grep '[s]ui start --with-faucet --force-regenesis'",o=R(e,{encoding:"utf8"});if(!o){console.log("No running local node process found");return}let t;if(process.platform==="win32"){let s=o.match(/"sui\.exe",["']?(\d+)/i);t=s?s[1]:null}else t=o.toString().split(/\s+/)[1];if(!t){console.log("No running local node process found");return}process.platform==="win32"?R(`taskkill /PID ${t} /F`):process.kill(Number(t)),console.log("\u2705 Local node stopped successfully")}catch(e){e.code==="ESRCH"||e.message.includes("no running tasks")?console.log("No running local node process found"):console.error("\u274C Error stopping local node:",e.message)}}function w(e){if(e.startsWith(ne))return e.length===70?e:!1;if(e.startsWith("0x")){let o=e.slice(2);return o.length===64?o:!1}else return e.length===64?e:!1}function $(e,o,t,s,m,d){let l={projectName:e,network:o,packageId:t,schemas:s,upgradeCap:m,version:d},u=process.cwd(),c=JSON.stringify(l,null,2);se(c,`${u}/contracts/${e}/.history/sui_${o}/latest.json`,"Update deploy log")}async function se(e,o,t){ee(te(o),{recursive:!0}),oe(o,e),t!==void 0&&console.log(`${t}: ${o}`)}async function ce(e){switch(e){case"testnet":return"0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b";default:return"0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b"}}async function A(e,o,t){console.log(`
|
|
24
|
+
\u{1F680} Starting Contract Publication...`),console.log(` \u251C\u2500 Project: ${e}`),console.log(` \u251C\u2500 Network: ${o}`);let m=`${process.cwd()}/contracts/${e}`;t=t||await ce(o),console.log(" \u251C\u2500 Validating Environment...");let d=process.env.PRIVATE_KEY;if(!d)throw new a(`Missing PRIVATE_KEY environment variable.
|
|
6
25
|
Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
|
|
7
|
-
in your contracts directory to use the default sui private key.`);let l=
|
|
26
|
+
in your contracts directory to use the default sui private key.`);let l=w(d);if(l===!1)throw new a("Please check your privateKey.");let c=new re({secretKey:l}).getKeypair();console.log(` \u2514\u2500 Account: ${c.toSuiAddress()}`);let x=new ie({url:ae(o)});console.log(`
|
|
27
|
+
\u{1F4E6} Building Contract...`);let P,O;try{let n=JSON.parse(le(`sui move build --dump-bytecode-as-base64 --path ${m}`,{encoding:"utf-8"}));P=n.modules,O=n.dependencies,console.log(" \u2514\u2500 Build successful")}catch(n){console.error(p.red(" \u2514\u2500 Build failed")),console.error(n.stdout),process.exit(1)}console.log(`
|
|
28
|
+
\u{1F504} Publishing Contract...`);let C=new F,[Y]=C.publish({modules:P,dependencies:O});C.transferObjects([Y],c.toSuiAddress());let f;try{f=await x.signAndExecuteTransaction({signer:c,transaction:C,options:{showObjectChanges:!0}})}catch(n){console.error(p.red(" \u2514\u2500 Publication failed")),console.error(n.message),process.exit(1)}f.effects?.status.status==="failure"&&(console.log(p.red(" \u2514\u2500 Publication failed")),process.exit(1)),console.log(" \u251C\u2500 Processing publication results...");let G=1,S="",I=[],N="";f.objectChanges.map(n=>{n.type==="published"&&(console.log(` \u251C\u2500 Package ID: ${n.packageId}`),S=n.packageId),n.type==="created"&&n.objectType==="0x2::package::UpgradeCap"&&(console.log(` \u251C\u2500 Upgrade Cap: ${n.objectId}`),N=n.objectId)}),console.log(` \u2514\u2500 Transaction: ${f.digest}`),console.log(`
|
|
29
|
+
\u26A1 Executing Deploy Hook...`),await new Promise(n=>setTimeout(n,5e3));let _=new F;_.moveCall({target:`${S}::deploy_hook::run`,arguments:[_.object(t),_.object("0x6")]});let y;try{y=await x.signAndExecuteTransaction({signer:c,transaction:_,options:{showEffects:!0,showObjectChanges:!0}})}catch(n){console.error(p.red(" \u2514\u2500 Deploy hook execution failed")),console.error(n.message),process.exit(1)}y.effects?.status.status==="success"?(console.log(" \u251C\u2500 Hook execution successful"),console.log(` \u251C\u2500 Transaction: ${y.digest}`),console.log(`
|
|
30
|
+
\u{1F4CB} Created Schemas:`),y.objectChanges?.map(n=>{n.type==="created"&&n.objectType.includes("schema")&&(console.log(` \u251C\u2500 ${n.objectType}`),console.log(` \u2514\u2500 ID: ${n.objectId}`),I.push({name:n.objectType,objectId:n.objectId}))}),$(e,o,S,I,N,G),console.log(`
|
|
31
|
+
\u2705 Contract Publication Complete
|
|
32
|
+
`)):(console.log(p.yellow(" \u2514\u2500 Deploy hook execution failed")),console.log(p.yellow(" Please republish or manually call deploy_hook::run")))}import de from"chalk";function M(){console.log(de.yellow(`
|
|
8
33
|
Welcome to obelisk world
|
|
9
34
|
--from team@obelisk
|
|
10
35
|
________ ________ _______ ___ ___ ________ ___ __
|
|
@@ -17,7 +42,11 @@ Welcome to obelisk world
|
|
|
17
42
|
\\|_________|
|
|
18
43
|
|
|
19
44
|
|
|
20
|
-
`))}var
|
|
45
|
+
`))}var pe={command:"localnode <action>",describe:"Manage local Sui node",builder(e){return e.positional("action",{describe:"Action to perform",choices:["start","stop","status","restart"],type:"string",demandOption:!0}).option("background",{alias:"b",type:"boolean",description:"Run node in background",default:!1})},async handler(e){let{action:o,background:t}=e;try{switch(o){case"start":await k(t);break;case"stop":await b();break;case"status":await E();break;case"restart":await me(t);break}}catch(s){console.error("Error executing command:",s),process.exit(1)}}};async function me(e){console.log("Restarting local Sui node..."),await b(),await k(e),console.log("Local node has been restarted")}var T=pe;import{Obelisk as ue}from"@0xobelisk/sui-client";import{requestSuiFromFaucetV0 as ge,getFaucetHost as fe}from"@mysten/sui/faucet";import{SuiClient as _e,getFullnodeUrl as ye}from"@mysten/sui/client";var he={command:"faucet",describe:"Interact with a Obelisk faucet",builder(e){return e.options({network:{type:"string",desc:"URL of the Obelisk faucet",choices:["testnet","devnet","localnet"],default:"localnet"},recipient:{type:"string",desc:"Sui address to fund"}})},async handler({network:e,recipient:o}){let t="";if(o===void 0){let l=process.env.PRIVATE_KEY;if(!l)throw new a(`Missing PRIVATE_KEY environment variable.
|
|
21
46
|
Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
|
|
22
|
-
in your contracts directory to use the default sui private key.`);let
|
|
47
|
+
in your contracts directory to use the default sui private key.`);let u=w(l);if(u===!1)throw new a("Please check your privateKey.");t=new ue({secretKey:u}).getKeypair().toSuiAddress()}else t=o;console.log(`
|
|
48
|
+
\u{1F30A} Starting Faucet Operation...`),console.log(` \u251C\u2500 Network: ${e}`),o===void 0?(console.log(" \u251C\u2500 Using Environment Private Key"),console.log(` \u251C\u2500 Generated Address: ${t}`)):console.log(` \u251C\u2500 Using Provided Address: ${t}`),console.log(" \u251C\u2500 Requesting funds from faucet..."),await ge({host:fe(e),recipient:t}),console.log(" \u2514\u2500 Checking balance...");let s=new _e({url:ye(e)}),m={owner:t},d=await s.getBalance(m);console.log(`
|
|
49
|
+
\u{1F4B0} Account Summary`),console.log(` \u251C\u2500 Address: ${t}`),console.log(` \u2514\u2500 Balance: ${d.totalBalance} SUI`),console.log(`
|
|
50
|
+
\u2705 Faucet Operation Complete
|
|
51
|
+
`),process.exit(0)}},L=he;import{schemaGen as ke,loadConfig as be}from"@0xobelisk/sui-common";import we from"chalk";var xe={command:"schemagen",describe:"Autogenerate Obelisk schemas based on the config file",builder:{configPath:{type:"string",default:"obelisk.config.ts",desc:"Path to the config file"},network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},frameworkId:{type:"string",desc:"Framework Package ID"}},async handler({configPath:e,network:o,frameworkId:t}){try{let s=await be(e);await ke(s,void 0,o,t),process.exit(0)}catch(s){console.log(we.red("Schemagen failed!")),console.error(s.message)}}},D=xe;import{loadConfig as Ce}from"@0xobelisk/sui-common";var Se={command:"publish",describe:"Publish obelisk move contract",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},configPath:{type:"string",default:"obelisk.config.ts",desc:"Configuration file path"},dappsObjectId:{type:"string",desc:"Optional dappsObjectId"}})},async handler({network:e,configPath:o,dappsObjectId:t}){try{let s=await Ce(o);await A(s.name,e,t)}catch(s){h(s),process.exit(1)}process.exit(0)}},V=Se;import{execSync as ve}from"child_process";import Ee from"chalk";var Pe={command:"test",describe:"Run tests in Obelisk contracts",builder(e){return e.options({packagePath:{type:"string",default:".",description:"Options to pass to forge test"}})},async handler({packagePath:e}){try{ve(`sui move test --path ${e}`,{encoding:"utf-8"})}catch(o){console.error(Ee.red("Error executing sui move test:")),console.log(o.stdout),process.exit(0)}}},B=Pe;var Oe={command:"hello",describe:"hello, obelisk",builder(e){return e},async handler(){M()}},K=Oe;var j=[V,T,L,D,B,K];import*as H from"dotenv";import U from"chalk";H.config();Ie(Ne(process.argv)).scriptName("obelisk").command(j).strict().fail((e,o)=>{console.error(U.red(e)),e.includes("Missing required argument")&&console.log(U.yellow(`Run 'pnpm obelisk ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),h(o),console.log(""),process.exit(1)}).alias({h:"help"}).argv;
|
|
23
52
|
//# sourceMappingURL=obelisk.js.map
|
package/dist/obelisk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/obelisk.ts","../src/utils/publishHandler.ts","../src/utils/errors.ts","../src/utils/utils.ts","../src/utils/localnode/start.ts","../src/utils/localnode/status.ts","../src/utils/localnode/stop.ts","../src/utils/printObelisk.ts","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/commands/test.ts","../src/commands/hello.ts","../src/commands/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { commands } from \"./commands\";\nimport { logError } from \"./utils/errors\";\n\n// Load .env file into process.env\nimport * as dotenv from \"dotenv\";\nimport chalk from \"chalk\";\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 \"obelisk\" for e.g. ts-node)\n .scriptName(\"obelisk\")\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 // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg, err) => {\n console.error(chalk.red(msg));\n if (msg.includes(\"Missing required argument\")) {\n console.log(\n chalk.yellow(`Run 'pnpm obelisk ${process.argv[2]} --help' for a list of available and required arguments.`)\n );\n }\n console.log(\"\");\n logError(err);\n console.log(\"\");\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: \"help\" }).argv;\n","import { Obelisk } from '@0xobelisk/sui-client';\nimport { Transaction } from '@mysten/sui/transactions';\nimport {\n\tgetFullnodeUrl,\n\tSuiClient,\n\tSuiTransactionBlockResponse,\n} from '@mysten/sui/client';\nimport { execSync } from 'child_process';\nimport chalk from 'chalk';\nimport { ObeliskCliError } from './errors';\nimport {\n\tupdateVersionInFile,\n\tsaveContractData,\n\tvalidatePrivateKey,\n\tschema,\n} from './utils';\n\nasync function getDappsObjectId(\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n\tswitch (network) {\n\t\tcase 'testnet':\n\t\t\treturn '0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b';\n\t\tdefault:\n\t\t\treturn '0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b';\n\t}\n}\n\nexport async function publishHandler(\n\tname: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tdappsObjectId?: string\n) {\n\tconst path = process.cwd();\n\tconst projectPath = `${path}/contracts/${name}`;\n\tdappsObjectId = dappsObjectId || (await getDappsObjectId(network));\n\tconst privateKey = process.env.PRIVATE_KEY;\n\tif (!privateKey)\n\t\tthrow new ObeliskCliError(\n\t\t\t`Missing PRIVATE_KEY environment variable.\nRun 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\nin your contracts directory to use the default sui private key.`\n\t\t);\n\n\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\tif (privateKeyFormat === false) {\n\t\tthrow new ObeliskCliError(`Please check your privateKey.`);\n\t}\n\tconst obelisk = new Obelisk({\n\t\tsecretKey: privateKeyFormat,\n\t});\n\tconst keypair = obelisk.getKeypair();\n\n\tconst client = new SuiClient({\n\t\turl: getFullnodeUrl(network),\n\t});\n\n\tlet modules: any, dependencies: any;\n\ttry {\n\t\tconst {\n\t\t\tmodules: extractedModules,\n\t\t\tdependencies: extractedDependencies,\n\t\t} = JSON.parse(\n\t\t\texecSync(\n\t\t\t\t`sui move build --dump-bytecode-as-base64 --path ${projectPath}`,\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf-8',\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tmodules = extractedModules;\n\t\tdependencies = extractedDependencies;\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red('Error executing sui move build:'));\n\t\tconsole.error(error.stdout);\n\t\tprocess.exit(1); // You might want to exit with a non-zero status code to indicate an error\n\t}\n\n\tconsole.log(chalk.blue(`Account: ${keypair.toSuiAddress()}`));\n\n\tconst tx = new Transaction();\n\tconst [upgradeCap] = tx.publish({\n\t\tmodules,\n\t\tdependencies,\n\t});\n\ttx.transferObjects([upgradeCap], keypair.toSuiAddress());\n\n\tlet result: SuiTransactionBlockResponse;\n\ttry {\n\t\tresult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: tx,\n\t\t\toptions: {\n\t\t\t\tshowObjectChanges: true,\n\t\t\t},\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(`Failed to execute publish, please republish`));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (result.effects?.status.status === 'failure') {\n\t\tconsole.log(chalk.red(`Failed to execute publish, please republish`));\n\t\tprocess.exit(1);\n\t}\n\n\tlet version = 1;\n\tlet packageId = '';\n\tlet schemas: schema[] = [];\n\tlet upgradeCapId = '';\n\tresult.objectChanges!.map(object => {\n\t\tif (object.type === 'published') {\n\t\t\tconsole.log(chalk.blue(`${name} PackageId: ${object.packageId}`));\n\t\t\tpackageId = object.packageId;\n\t\t}\n\t\tif (\n\t\t\tobject.type === 'created' &&\n\t\t\tobject.objectType === '0x2::package::UpgradeCap'\n\t\t) {\n\t\t\tconsole.log(chalk.blue(`${name} UpgradeCap: ${object.objectId}`));\n\t\t\tupgradeCapId = object.objectId;\n\t\t}\n\t});\n\n\tconsole.log(chalk.green(`Publish transaction digest: ${result.digest}`));\n\n\tconsole.log('Executing the deployHook: ');\n\tconst delay = (ms: number) =>\n\t\tnew Promise(resolve => setTimeout(resolve, ms));\n\tawait delay(5000);\n\n\tconst deployHookTx = new Transaction();\n\n\tdeployHookTx.moveCall({\n\t\ttarget: `${packageId}::deploy_hook::run`,\n\t\targuments: [\n\t\t\tdeployHookTx.object(dappsObjectId),\n\t\t\tdeployHookTx.object('0x6'),\n\t\t],\n\t});\n\n\tlet deployHookResult: SuiTransactionBlockResponse;\n\ttry {\n\t\tdeployHookResult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: deployHookTx,\n\t\t\toptions: {\n\t\t\t\tshowEffects: true,\n\t\t\t\tshowObjectChanges: true,\n\t\t\t},\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(\n\t\t\tchalk.red(\n\t\t\t\t`Failed to execute deployHook, please republish or manually call deploy_hook::run`\n\t\t\t)\n\t\t);\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (deployHookResult.effects?.status.status === 'success') {\n\t\tconsole.log(\n\t\t\tchalk.green(\n\t\t\t\t`Successful auto-execution of deployHook, please check the transaction digest: ${deployHookResult.digest}`\n\t\t\t)\n\t\t);\n\t\tdeployHookResult.objectChanges?.map(object => {\n\t\t\tif (\n\t\t\t\tobject.type === 'created' &&\n\t\t\t\tobject.objectType.includes('schema')\n\t\t\t) {\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.blue(`${name} Schema Object id: ${object.objectId}`)\n\t\t\t\t);\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.blue(\n\t\t\t\t\t\t`${name} Schema Object type: ${object.objectType}`\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tschemas.push({\n\t\t\t\t\tname: object.objectType,\n\t\t\t\t\tobjectId: object.objectId,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tsaveContractData(\n\t\t\tname,\n\t\t\tnetwork,\n\t\t\tpackageId,\n\t\t\tschemas,\n\t\t\tupgradeCapId,\n\t\t\tversion\n\t\t);\n\t} else {\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t`Failed to execute deployHook, please republish or manually call deploy_hook::run`\n\t\t\t)\n\t\t);\n\t}\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 Obelisk project\";\n}\n\nexport class ObeliskCliError extends Error {\n name = \"ObeliskCliError\";\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 Obelisk's configuration, please go to https://github.com/0xobelisk`\n )\n );\n } else if (error instanceof ObeliskCliError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\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';\nexport * from './localnode';\n\nexport type schema = {\n\tname: string;\n\tobjectId: string;\n};\n\nexport type DeploymentJsonType = {\n\tprojectName: string;\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\tpackageId: string;\n\tschemas: schema[];\n\tupgradeCap: string;\n\tversion: number;\n};\n\nexport function validatePrivateKey(privateKey: string): false | string {\n\tif (privateKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {\n\t\tif (privateKey.length === 70) {\n\t\t\treturn privateKey;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t} else if (privateKey.startsWith('0x')) {\n\t\tconst strippedPrivateKey = privateKey.slice(2);\n\t\tif (strippedPrivateKey.length === 64) {\n\t\t\treturn strippedPrivateKey;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t} else {\n\t\tif (privateKey.length === 64) {\n\t\t\treturn privateKey;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\nexport async function updateVersionInFile(\n\tprojectPath: string,\n\tnewVersion: string\n) {\n\ttry {\n\t\tconst filePath = `${projectPath}/sources/script/migrate.move`;\n\t\tconst data = await fsAsync.readFile(filePath, 'utf8');\n\n\t\t// update version data\n\t\tconst updatedData = data.replace(\n\t\t\t/const VERSION: u64 = \\d+;/,\n\t\t\t`const VERSION: u64 = ${newVersion};`\n\t\t);\n\n\t\t// write new version\n\t\twriteOutput(updatedData, filePath, 'Update package version');\n\t} catch {\n\t\tthrow new FsIibError('Fs update version failed.');\n\t}\n}\n\nasync function getDeploymentJson(projectPath: string, network: string) {\n\ttry {\n\t\tconst data = await fsAsync.readFile(\n\t\t\t`${projectPath}/.history/sui_${network}/latest.json`,\n\t\t\t'utf8'\n\t\t);\n\t\treturn JSON.parse(data) as DeploymentJsonType;\n\t} catch {\n\t\tthrow new FsIibError('Fs read deployment file failed.');\n\t}\n}\n\nexport async function getVersion(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<number> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.version;\n}\n\nexport async function getNetwork(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<'mainnet' | 'testnet' | 'devnet' | 'localnet'> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.network;\n}\n\nexport async function getOldPackageId(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<string> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.packageId;\n}\n\nexport async function getUpgradeCap(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<string> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.upgradeCap;\n}\n\nexport async function getObjectIdBySchemaName(\n\tprojectPath: string,\n\tnetwork: string,\n\tschemaName: string\n): Promise<string | undefined> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.schemas.find(schema => schema.name.includes(schemaName))\n\t\t?.objectId;\n}\n\nexport function saveContractData(\n\tprojectName: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tpackageId: string,\n\tschemas: schema[],\n\tupgradeCap: string,\n\tversion: number\n) {\n\tconst DeploymentData: DeploymentJsonType = {\n\t\tprojectName,\n\t\tnetwork,\n\t\tpackageId,\n\t\tschemas,\n\t\tupgradeCap,\n\t\tversion,\n\t};\n\n\tconst path = process.cwd();\n\tconst storeDeploymentData = JSON.stringify(DeploymentData, null, 2);\n\twriteOutput(\n\t\tstoreDeploymentData,\n\t\t`${path}/contracts/${projectName}/.history/sui_${network}/latest.json`,\n\t\t'Update deploy log'\n\t);\n}\n\nexport async function writeOutput(\n\toutput: string,\n\tfullOutputPath: string,\n\tlogPrefix?: string\n): Promise<void> {\n\tmkdirSync(dirname(fullOutputPath), { recursive: true });\n\n\twriteFileSync(fullOutputPath, output);\n\tif (logPrefix !== undefined) {\n\t\tconsole.log(`${logPrefix}: ${fullOutputPath}`);\n\t}\n}\n","import { execSync, spawn } from 'child_process';\nimport chalk from 'chalk';\n\nfunction isSuiStartRunning(): boolean {\n\ttry {\n\t\tconst result = execSync('pgrep -f \"sui start\"').toString().trim();\n\t\treturn result.length > 0;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\nexport async function startLocalnode(background: boolean = false) {\n\tconsole.log(chalk.blue('Checking if sui start process is running...'));\n\n\tif (isSuiStartRunning()) {\n\t\tconsole.log(\n\t\t\tchalk.yellow('Warning: sui start process is already running.')\n\t\t);\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t'Cannot start a new local node. Please stop the existing sui start process first.'\n\t\t\t)\n\t\t);\n\t\treturn;\n\t}\n\n\tconsole.log(chalk.green('Starting local node...'));\n\ttry {\n\t\tconst suiProcess = spawn(\n\t\t\t'sui',\n\t\t\t['start', '--with-faucet', '--force-regenesis'],\n\t\t\t{\n\t\t\t\tenv: { ...process.env, RUST_LOG: 'off,sui_node=info' },\n\t\t\t\tstdio: background ? 'ignore' : 'inherit',\n\t\t\t\tdetached: background,\n\t\t\t}\n\t\t);\n\n\t\tsuiProcess.on('error', error => {\n\t\t\tconsole.error(chalk.red('Failed to start local node:'), error);\n\t\t});\n\n\t\tif (!background) {\n\t\t\tsuiProcess.on('exit', code => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tconsole.log(chalk.green('Local node has exited normally'));\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\tchalk.red(\n\t\t\t\t\t\t\t`Local node exited abnormally with code: ${code}`\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconsole.log(chalk.cyan('Local node is running...'));\n\t\t\tconsole.log(chalk.cyan('Press Ctrl+C to stop the local node'));\n\n\t\t\t// Keep the script running\n\t\t\tawait new Promise(() => {});\n\t\t} else {\n\t\t\tsuiProcess.unref();\n\t\t\tconsole.log(\n\t\t\t\tchalk.green('Local node has been started in the background')\n\t\t\t);\n\t\t\tconsole.log(\n\t\t\t\tchalk.cyan(\n\t\t\t\t\t'Use \"pgrep -f \\'sui start\\'\" to check the process ID'\n\t\t\t\t)\n\t\t\t);\n\t\t\tconsole.log(\n\t\t\t\tchalk.cyan(\n\t\t\t\t\t'Use \"kill <process_id>\" to stop the background node'\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(chalk.red('Failed to start local node:'), error);\n\t}\n}\n\n// Get the background flag from command line arguments\nconst args = process.argv.slice(2);\nconst runInBackground = args.includes('--background') || args.includes('-b');\n\n// startLocalnode(runInBackground);\n","import { execSync } from 'child_process';\nimport chalk from 'chalk';\n\nexport async function checkLocalNodeStatus() {\n\ttry {\n\t\tconst output = execSync(\n\t\t\t\"ps aux | grep '[s]ui start --with-faucet --force-regenesis'\",\n\t\t\t{\n\t\t\t\tencoding: 'utf8',\n\t\t\t}\n\t\t);\n\n\t\tconst lines = output.split('\\n').filter(Boolean);\n\n\t\tif (lines.length > 0) {\n\t\t\tconsole.log(chalk.green('✓ Sui Local Node Status: Running'));\n\t\t\tconsole.log(chalk.gray('Process Details:'));\n\t\t\tfor (const line of lines) {\n\t\t\t\tconsole.log(chalk.gray(` ${line}`));\n\t\t\t}\n\t\t} else {\n\t\t\tconsole.log(chalk.red('✗ Sui Local Node Status: Not Running'));\n\t\t\tconsole.log(\n\t\t\t\tchalk.yellow(\n\t\t\t\t\t'Tip: Use `pnpm run start-localnode` to start the local node'\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tconsole.log(chalk.red('✗ Sui Local Node Status: Not Running'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t'Tip: Use `pnpm run start-localnode` to start the local node'\n\t\t\t)\n\t\t);\n\t}\n}\n\n// checkLocalNodeStatus();\n","import { execSync } from 'child_process';\n\nexport async function stopLocalnode() {\n\tconsole.log('Stopping local node...');\n\n\ttry {\n\t\t// Find localnode process using ps command\n\t\tconst output = execSync(\n\t\t\t\"ps aux | grep '[s]ui start --with-faucet --force-regenesis'\",\n\t\t\t{\n\t\t\t\tencoding: 'utf8',\n\t\t\t}\n\t\t);\n\n\t\tif (!output) {\n\t\t\tconsole.log('No running local node process found');\n\t\t\treturn;\n\t\t}\n\n\t\t// Get process ID\n\t\tconst pid = output.toString().split(/\\s+/)[1];\n\n\t\t// Kill the process\n\t\tprocess.kill(Number(pid));\n\t\tconsole.log('✅ Local node stopped successfully');\n\t} catch (error: any) {\n\t\tif (error.code === 'ESRCH') {\n\t\t\tconsole.log('No running local node process found');\n\t\t} else {\n\t\t\tconsole.error('❌ Error stopping local node:', error.message);\n\t\t}\n\t}\n}\n\n// stopLocalnode();\n","import chalk from \"chalk\";\n\nexport function printObelisk() {\n console.log(\n chalk.yellow(`\nWelcome to obelisk world\n\\t\\t\\t --from team@obelisk\n ________ ________ _______ ___ ___ ________ ___ __ \n|\\\\ __ \\\\|\\\\ __ \\\\|\\\\ ___ \\\\ |\\\\ \\\\ |\\\\ \\\\|\\\\ ____\\\\|\\\\ \\\\|\\\\ \\\\ \n\\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\|\\\\ /\\\\ \\\\ __/|\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\___|\\\\ \\\\ \\\\/ /|_ \n \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __ \\\\ \\\\ \\\\_|/_\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\_____ \\\\ \\\\ ___ \\\\ \n \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\_|\\\\ \\\\ \\\\ \\\\____\\\\ \\\\ \\\\|____|\\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \n \\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\__\\\\____\\\\_\\\\ \\\\ \\\\__\\\\\\\\ \\\\__\\\\\n \\\\|_______|\\\\|_______|\\\\|_______|\\\\|_______|\\\\|__|\\\\_________\\\\|__| \\\\|__|\n \\\\|_________| \n \n \n`)\n );\n}\n","import type { CommandModule } from 'yargs';\nimport { startLocalnode, stopLocalnode, checkLocalNodeStatus } from '../utils';\n\nconst commandModule: CommandModule = {\n\tcommand: 'localnode <action>',\n\n\tdescribe: 'Manage local Sui node',\n\n\tbuilder(yargs) {\n\t\treturn yargs\n\t\t\t.positional('action', {\n\t\t\t\tdescribe: 'Action to perform',\n\t\t\t\tchoices: ['start', 'stop', 'status', 'restart'],\n\t\t\t\ttype: 'string',\n\t\t\t\tdemandOption: true,\n\t\t\t})\n\t\t\t.option('background', {\n\t\t\t\talias: 'b',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Run node in background',\n\t\t\t\tdefault: true,\n\t\t\t});\n\t},\n\n\tasync handler(argv) {\n\t\tconst { action, background } = argv;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase 'start':\n\t\t\t\t\tawait startLocalnode(background as boolean);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'stop':\n\t\t\t\t\tawait stopLocalnode();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'status':\n\t\t\t\t\tawait checkLocalNodeStatus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'restart':\n\t\t\t\t\tawait restartNode(background as boolean);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('Error executing command:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t},\n};\n\nasync function restartNode(background: boolean) {\n\tconsole.log('Restarting local Sui node...');\n\tawait stopLocalnode();\n\tawait startLocalnode(background);\n\tconsole.log('Local node has been restarted');\n}\n\nexport default commandModule;\n","import { Obelisk } from '@0xobelisk/sui-client';\nimport type { CommandModule } from 'yargs';\nimport { requestSuiFromFaucetV0, getFaucetHost } from '@mysten/sui/faucet';\nimport {\n\tSuiClient,\n\tgetFullnodeUrl,\n\tGetBalanceParams,\n} from '@mysten/sui/client';\nimport { validatePrivateKey, ObeliskCliError } from '../utils';\n\ntype Options = {\n\tnetwork: any;\n\trecipient?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'faucet',\n\n\tdescribe: 'Interact with a Obelisk faucet',\n\n\tbuilder(yargs) {\n\t\treturn yargs.options({\n\t\t\tnetwork: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdesc: 'URL of the Obelisk faucet',\n\t\t\t\tchoices: ['testnet', 'devnet', 'localnet'],\n\t\t\t\tdefault: 'localnet',\n\t\t\t},\n\t\t\trecipient: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdesc: 'Sui address to fund',\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({ network, recipient }) {\n\t\tlet faucet_address = '';\n\t\tif (recipient === undefined) {\n\t\t\tconst privateKey = process.env.PRIVATE_KEY;\n\t\t\tif (!privateKey)\n\t\t\t\tthrow new ObeliskCliError(\n\t\t\t\t\t`Missing PRIVATE_KEY environment variable.\n Run 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\n in your contracts directory to use the default sui private key.`\n\t\t\t\t);\n\n\t\t\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\t\t\tif (privateKeyFormat === false) {\n\t\t\t\tthrow new ObeliskCliError(`Please check your privateKey.`);\n\t\t\t}\n\t\t\tconst obelisk = new Obelisk({\n\t\t\t\tsecretKey: privateKeyFormat,\n\t\t\t});\n\t\t\tconst keypair = obelisk.getKeypair();\n\t\t\tfaucet_address = keypair.toSuiAddress();\n\t\t} else {\n\t\t\tfaucet_address = recipient;\n\t\t}\n\t\tawait requestSuiFromFaucetV0({\n\t\t\thost: getFaucetHost(network),\n\t\t\trecipient: faucet_address,\n\t\t});\n\t\tconst client = new SuiClient({ url: getFullnodeUrl(network) });\n\t\tlet params = {\n\t\t\towner: faucet_address,\n\t\t} as GetBalanceParams;\n\t\tconsole.log(`Account: ${faucet_address}`);\n\t\tconsole.log(await client.getBalance(params));\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { schemaGen, loadConfig, ObeliskConfig } from '@0xobelisk/sui-common';\nimport chalk from 'chalk';\n\ntype Options = {\n\tconfigPath?: string;\n\tnetwork?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\tframeworkId?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'schemagen',\n\n\tdescribe: 'Autogenerate Obelisk schemas based on the config file',\n\n\tbuilder: {\n\t\tconfigPath: {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'obelisk.config.ts',\n\t\t\tdesc: 'Path to the config file',\n\t\t},\n\t\tnetwork: {\n\t\t\ttype: 'string',\n\t\t\tchoices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,\n\t\t\tdesc: 'Node network (mainnet/testnet/devnet/localnet)',\n\t\t},\n\t\tframeworkId: {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Framework Package ID',\n\t\t},\n\t},\n\n\tasync handler({ configPath, network, frameworkId }) {\n\t\ttry {\n\t\t\tconst obeliskConfig = (await loadConfig(\n\t\t\t\tconfigPath\n\t\t\t)) as ObeliskConfig;\n\t\t\tawait schemaGen(obeliskConfig, undefined, network, frameworkId);\n\t\t\tprocess.exit(0);\n\t\t} catch (error: any) {\n\t\t\tconsole.log(chalk.red('Schemagen failed!'));\n\t\t\tconsole.error(error.message);\n\t\t}\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { publishHandler } from '../utils';\nimport { loadConfig, ObeliskConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\tnetwork: any;\n\tconfigPath: string;\n\tdappsObjectId?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'publish',\n\n\tdescribe: 'Publish obelisk move contract',\n\n\tbuilder(yargs) {\n\t\treturn yargs.options({\n\t\t\tnetwork: {\n\t\t\t\ttype: 'string',\n\t\t\t\tchoices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n\t\t\t\tdesc: 'Node network (mainnet/testnet/devnet/localnet)',\n\t\t\t},\n\t\t\tconfigPath: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'obelisk.config.ts',\n\t\t\t\tdesc: 'Configuration file path',\n\t\t\t},\n\t\t\tdappsObjectId: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdesc: 'Optional dappsObjectId',\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({ network, configPath, dappsObjectId }) {\n\t\ttry {\n\t\t\tconst obeliskConfig = (await loadConfig(\n\t\t\t\tconfigPath\n\t\t\t)) as ObeliskConfig;\n\t\t\tawait publishHandler(obeliskConfig.name, network, dappsObjectId);\n\t\t} catch (error: any) {\n\t\t\tlogError(error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { execSync } from \"child_process\";\nimport chalk from \"chalk\";\n\ntype Options = {\n packagePath: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"test\",\n\n describe: \"Run tests in Obelisk contracts\",\n\n builder(yargs) {\n return yargs.options({\n packagePath: {\n type: \"string\",\n default: \".\",\n description: \"Options to pass to forge test\",\n },\n });\n },\n\n async handler({ packagePath }) {\n // Start an internal anvil process if no world address is provided\n try {\n execSync(`sui move test --path ${packagePath}`, {\n encoding: \"utf-8\",\n });\n } catch (error: any) {\n console.error(chalk.red(\"Error executing sui move test:\"));\n console.log(error.stdout);\n process.exit(0);\n }\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { printObelisk } from \"../utils\";\n\nconst commandModule: CommandModule = {\n command: \"hello\",\n\n describe: \"hello, obelisk\",\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n printObelisk();\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';\n// import upgrade from \"./upgrade\";\nimport test from './test';\nimport hello from './hello';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options\nexport const commands: CommandModule<any, any>[] = [\n\tpublish,\n\tlocalnode,\n\tfaucet,\n\tschemagen,\n\t// upgrade,\n\ttest,\n\thello,\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBCHxB,OAAS,WAAAC,OAAe,wBACxB,OAAS,eAAAC,MAAmB,2BAC5B,OACC,kBAAAC,GACA,aAAAC,OAEM,qBACP,OAAS,YAAAC,OAAgB,gBACzB,OAAOC,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["yargs","hideBin","Obelisk","Transaction","getFullnodeUrl","SuiClient","execSync","chalk","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","ObeliskCliError","logError","error","ValidationError","chalk","ZodError","validationError","fromZodError","NotInsideProjectError","ObeliskCliError","mkdirSync","writeFileSync","dirname","SUI_PRIVATE_KEY_PREFIX","execSync","spawn","chalk","isSuiStartRunning","startLocalnode","background","suiProcess","error","code","args","runInBackground","execSync","chalk","checkLocalNodeStatus","lines","line","execSync","stopLocalnode","output","pid","error","validatePrivateKey","privateKey","SUI_PRIVATE_KEY_PREFIX","strippedPrivateKey","saveContractData","projectName","network","packageId","schemas","upgradeCap","version","DeploymentData","path","storeDeploymentData","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","getDappsObjectId","network","publishHandler","name","dappsObjectId","projectPath","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","keypair","Obelisk","client","SuiClient","getFullnodeUrl","modules","dependencies","extractedModules","extractedDependencies","execSync","error","chalk","tx","Transaction","upgradeCap","result","version","packageId","schemas","upgradeCapId","object","ms","resolve","deployHookTx","deployHookResult","saveContractData","chalk","printObelisk","commandModule","yargs","argv","action","background","startLocalnode","stopLocalnode","checkLocalNodeStatus","restartNode","error","localnode_default","Obelisk","requestSuiFromFaucetV0","getFaucetHost","SuiClient","getFullnodeUrl","commandModule","yargs","network","recipient","faucet_address","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","Obelisk","requestSuiFromFaucetV0","getFaucetHost","client","SuiClient","getFullnodeUrl","params","faucet_default","schemaGen","loadConfig","chalk","commandModule","configPath","network","frameworkId","obeliskConfig","error","schemagen_default","loadConfig","commandModule","yargs","network","configPath","dappsObjectId","obeliskConfig","publishHandler","error","logError","publish_default","execSync","chalk","commandModule","yargs","packagePath","error","test_default","commandModule","yargs","printObelisk","hello_default","commands","publish_default","localnode_default","faucet_default","schemagen_default","test_default","hello_default","dotenv","chalk","yargs","hideBin","commands","msg","err","logError"]}
|
|
1
|
+
{"version":3,"sources":["../src/obelisk.ts","../src/utils/publishHandler.ts","../src/utils/errors.ts","../src/utils/utils.ts","../src/utils/localnode/start.ts","../src/utils/localnode/status.ts","../src/utils/localnode/stop.ts","../src/utils/printObelisk.ts","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/commands/test.ts","../src/commands/hello.ts","../src/commands/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport { commands } from \"./commands\";\nimport { logError } from \"./utils/errors\";\n\n// Load .env file into process.env\nimport * as dotenv from \"dotenv\";\nimport chalk from \"chalk\";\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 \"obelisk\" for e.g. ts-node)\n .scriptName(\"obelisk\")\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 // Enable strict mode.\n .strict()\n // Custom error handler\n .fail((msg, err) => {\n console.error(chalk.red(msg));\n if (msg.includes(\"Missing required argument\")) {\n console.log(\n chalk.yellow(`Run 'pnpm obelisk ${process.argv[2]} --help' for a list of available and required arguments.`)\n );\n }\n console.log(\"\");\n logError(err);\n console.log(\"\");\n\n process.exit(1);\n })\n // Useful aliases.\n .alias({ h: \"help\" }).argv;\n","import { Obelisk } from '@0xobelisk/sui-client';\nimport { Transaction } from '@mysten/sui/transactions';\nimport {\n\tgetFullnodeUrl,\n\tSuiClient,\n\tSuiTransactionBlockResponse,\n} from '@mysten/sui/client';\nimport { execSync } from 'child_process';\nimport chalk from 'chalk';\nimport { ObeliskCliError } from './errors';\nimport {\n\tupdateVersionInFile,\n\tsaveContractData,\n\tvalidatePrivateKey,\n\tschema,\n} from './utils';\n\nasync function getDappsObjectId(\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n\tswitch (network) {\n\t\tcase 'testnet':\n\t\t\treturn '0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b';\n\t\tdefault:\n\t\t\treturn '0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b';\n\t}\n}\n\nexport async function publishHandler(\n\tname: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tdappsObjectId?: string\n) {\n\tconsole.log('\\n🚀 Starting Contract Publication...');\n\tconsole.log(` ├─ Project: ${name}`);\n\tconsole.log(` ├─ Network: ${network}`);\n\n\tconst path = process.cwd();\n\tconst projectPath = `${path}/contracts/${name}`;\n\tdappsObjectId = dappsObjectId || (await getDappsObjectId(network));\n\n\tconsole.log(' ├─ Validating Environment...');\n\tconst privateKey = process.env.PRIVATE_KEY;\n\tif (!privateKey) {\n\t\tthrow new ObeliskCliError(\n\t\t\t`Missing PRIVATE_KEY environment variable.\nRun 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\nin your contracts directory to use the default sui private key.`\n\t\t);\n\t}\n\n\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\tif (privateKeyFormat === false) {\n\t\tthrow new ObeliskCliError(`Please check your privateKey.`);\n\t}\n\n\tconst obelisk = new Obelisk({ secretKey: privateKeyFormat });\n\tconst keypair = obelisk.getKeypair();\n\tconsole.log(` └─ Account: ${keypair.toSuiAddress()}`);\n\n\tconst client = new SuiClient({ url: getFullnodeUrl(network) });\n\n\tconsole.log('\\n📦 Building Contract...');\n\tlet modules: any, dependencies: any;\n\ttry {\n\t\tconst buildResult = JSON.parse(\n\t\t\texecSync(\n\t\t\t\t`sui move build --dump-bytecode-as-base64 --path ${projectPath}`,\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf-8',\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tmodules = buildResult.modules;\n\t\tdependencies = buildResult.dependencies;\n\t\tconsole.log(' └─ Build successful');\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Build failed'));\n\t\tconsole.error(error.stdout);\n\t\tprocess.exit(1);\n\t}\n\n\tconsole.log('\\n🔄 Publishing Contract...');\n\tconst tx = new Transaction();\n\tconst [upgradeCap] = tx.publish({ modules, dependencies });\n\ttx.transferObjects([upgradeCap], keypair.toSuiAddress());\n\n\tlet result: SuiTransactionBlockResponse;\n\ttry {\n\t\tresult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: tx,\n\t\t\toptions: { showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Publication failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (result.effects?.status.status === 'failure') {\n\t\tconsole.log(chalk.red(' └─ Publication failed'));\n\t\tprocess.exit(1);\n\t}\n\n\tconsole.log(' ├─ Processing publication results...');\n\tlet version = 1;\n\tlet packageId = '';\n\tlet schemas: schema[] = [];\n\tlet upgradeCapId = '';\n\n\tresult.objectChanges!.map(object => {\n\t\tif (object.type === 'published') {\n\t\t\tconsole.log(` ├─ Package ID: ${object.packageId}`);\n\t\t\tpackageId = object.packageId;\n\t\t}\n\t\tif (\n\t\t\tobject.type === 'created' &&\n\t\t\tobject.objectType === '0x2::package::UpgradeCap'\n\t\t) {\n\t\t\tconsole.log(` ├─ Upgrade Cap: ${object.objectId}`);\n\t\t\tupgradeCapId = object.objectId;\n\t\t}\n\t});\n\n\tconsole.log(` └─ Transaction: ${result.digest}`);\n\n\tconsole.log('\\n⚡ Executing Deploy Hook...');\n\tawait new Promise(resolve => setTimeout(resolve, 5000));\n\n\tconst deployHookTx = new Transaction();\n\tdeployHookTx.moveCall({\n\t\ttarget: `${packageId}::deploy_hook::run`,\n\t\targuments: [\n\t\t\tdeployHookTx.object(dappsObjectId),\n\t\t\tdeployHookTx.object('0x6'),\n\t\t],\n\t});\n\n\tlet deployHookResult: SuiTransactionBlockResponse;\n\ttry {\n\t\tdeployHookResult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: deployHookTx,\n\t\t\toptions: { showEffects: true, showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Deploy hook execution failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (deployHookResult.effects?.status.status === 'success') {\n\t\tconsole.log(' ├─ Hook execution successful');\n\t\tconsole.log(` ├─ Transaction: ${deployHookResult.digest}`);\n\n\t\tconsole.log('\\n📋 Created Schemas:');\n\t\tdeployHookResult.objectChanges?.map(object => {\n\t\t\tif (\n\t\t\t\tobject.type === 'created' &&\n\t\t\t\tobject.objectType.includes('schema')\n\t\t\t) {\n\t\t\t\tconsole.log(` ├─ ${object.objectType}`);\n\t\t\t\tconsole.log(` └─ ID: ${object.objectId}`);\n\t\t\t\tschemas.push({\n\t\t\t\t\tname: object.objectType,\n\t\t\t\t\tobjectId: object.objectId,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tsaveContractData(\n\t\t\tname,\n\t\t\tnetwork,\n\t\t\tpackageId,\n\t\t\tschemas,\n\t\t\tupgradeCapId,\n\t\t\tversion\n\t\t);\n\t\tconsole.log('\\n✅ Contract Publication Complete\\n');\n\t} else {\n\t\tconsole.log(chalk.yellow(' └─ Deploy hook execution failed'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t' Please republish or manually call deploy_hook::run'\n\t\t\t)\n\t\t);\n\t}\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 Obelisk project\";\n}\n\nexport class ObeliskCliError extends Error {\n name = \"ObeliskCliError\";\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 Obelisk's configuration, please go to https://github.com/0xobelisk`\n )\n );\n } else if (error instanceof ObeliskCliError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\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';\nexport * from './localnode';\n\nexport type schema = {\n\tname: string;\n\tobjectId: string;\n};\n\nexport type DeploymentJsonType = {\n\tprojectName: string;\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\tpackageId: string;\n\tschemas: schema[];\n\tupgradeCap: string;\n\tversion: number;\n};\n\nexport function validatePrivateKey(privateKey: string): false | string {\n\tif (privateKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {\n\t\tif (privateKey.length === 70) {\n\t\t\treturn privateKey;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t} else if (privateKey.startsWith('0x')) {\n\t\tconst strippedPrivateKey = privateKey.slice(2);\n\t\tif (strippedPrivateKey.length === 64) {\n\t\t\treturn strippedPrivateKey;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t} else {\n\t\tif (privateKey.length === 64) {\n\t\t\treturn privateKey;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\nexport async function updateVersionInFile(\n\tprojectPath: string,\n\tnewVersion: string\n) {\n\ttry {\n\t\tconst filePath = `${projectPath}/sources/script/migrate.move`;\n\t\tconst data = await fsAsync.readFile(filePath, 'utf8');\n\n\t\t// update version data\n\t\tconst updatedData = data.replace(\n\t\t\t/const VERSION: u64 = \\d+;/,\n\t\t\t`const VERSION: u64 = ${newVersion};`\n\t\t);\n\n\t\t// write new version\n\t\twriteOutput(updatedData, filePath, 'Update package version');\n\t} catch {\n\t\tthrow new FsIibError('Fs update version failed.');\n\t}\n}\n\nasync function getDeploymentJson(projectPath: string, network: string) {\n\ttry {\n\t\tconst data = await fsAsync.readFile(\n\t\t\t`${projectPath}/.history/sui_${network}/latest.json`,\n\t\t\t'utf8'\n\t\t);\n\t\treturn JSON.parse(data) as DeploymentJsonType;\n\t} catch {\n\t\tthrow new FsIibError('Fs read deployment file failed.');\n\t}\n}\n\nexport async function getVersion(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<number> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.version;\n}\n\nexport async function getNetwork(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<'mainnet' | 'testnet' | 'devnet' | 'localnet'> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.network;\n}\n\nexport async function getOldPackageId(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<string> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.packageId;\n}\n\nexport async function getUpgradeCap(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<string> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.upgradeCap;\n}\n\nexport async function getObjectIdBySchemaName(\n\tprojectPath: string,\n\tnetwork: string,\n\tschemaName: string\n): Promise<string | undefined> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.schemas.find(schema => schema.name.includes(schemaName))\n\t\t?.objectId;\n}\n\nexport function saveContractData(\n\tprojectName: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tpackageId: string,\n\tschemas: schema[],\n\tupgradeCap: string,\n\tversion: number\n) {\n\tconst DeploymentData: DeploymentJsonType = {\n\t\tprojectName,\n\t\tnetwork,\n\t\tpackageId,\n\t\tschemas,\n\t\tupgradeCap,\n\t\tversion,\n\t};\n\n\tconst path = process.cwd();\n\tconst storeDeploymentData = JSON.stringify(DeploymentData, null, 2);\n\twriteOutput(\n\t\tstoreDeploymentData,\n\t\t`${path}/contracts/${projectName}/.history/sui_${network}/latest.json`,\n\t\t'Update deploy log'\n\t);\n}\n\nexport async function writeOutput(\n\toutput: string,\n\tfullOutputPath: string,\n\tlogPrefix?: string\n): Promise<void> {\n\tmkdirSync(dirname(fullOutputPath), { recursive: true });\n\n\twriteFileSync(fullOutputPath, output);\n\tif (logPrefix !== undefined) {\n\t\tconsole.log(`${logPrefix}: ${fullOutputPath}`);\n\t}\n}\n","import { execSync, spawn } from 'child_process';\nimport chalk from 'chalk';\n\nfunction isSuiStartRunning(): boolean {\n\ttry {\n\t\tconst cmd =\n\t\t\tprocess.platform === 'win32'\n\t\t\t\t? `tasklist /FI \"IMAGENAME eq sui.exe\" /FO CSV /NH`\n\t\t\t\t: 'pgrep -f \"sui start\"';\n\n\t\tconst result = execSync(cmd).toString().trim();\n\t\treturn process.platform === 'win32'\n\t\t\t? result.toLowerCase().includes('sui.exe')\n\t\t\t: result.length > 0;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\nexport async function startLocalnode(background: boolean = false) {\n\tconsole.log('\\n🔍 Checking Local Node Status...');\n\tconsole.log(' ├─ Scanning running processes');\n\n\tif (isSuiStartRunning()) {\n\t\tconsole.log(chalk.yellow('\\n⚠️ Warning: Local Node Already Running'));\n\t\tconsole.log(chalk.yellow(' ├─ Cannot start a new instance'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(' └─ Please stop the existing process first')\n\t\t);\n\t\treturn;\n\t}\n\n\tconsole.log('\\n🚀 Starting Local Node...');\n\tconsole.log(' ├─ Mode: ' + (background ? 'Background' : 'Foreground'));\n\tconsole.log(' ├─ Faucet: Enabled');\n\tconsole.log(' └─ Force Regenesis: Yes');\n\n\ttry {\n\t\tconst suiProcess = spawn(\n\t\t\t'sui',\n\t\t\t['start', '--with-faucet', '--force-regenesis'],\n\t\t\t{\n\t\t\t\tenv: { ...process.env, RUST_LOG: 'off,sui_node=info' },\n\t\t\t\tstdio: background ? 'ignore' : 'inherit',\n\t\t\t\tdetached: background,\n\t\t\t}\n\t\t);\n\n\t\tsuiProcess.on('error', error => {\n\t\t\tconsole.error(chalk.red('\\n❌ Failed to Start Local Node'));\n\t\t\tconsole.error(chalk.red(` └─ Error: ${error.message}`));\n\t\t});\n\n\t\tif (!background) {\n\t\t\tsuiProcess.on('exit', code => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tconsole.log(chalk.green('\\n✅ Local Node Stopped'));\n\t\t\t\t\tconsole.log(chalk.green(' └─ Exit Status: Normal'));\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(chalk.red('\\n❌ Local Node Crashed'));\n\t\t\t\t\tconsole.error(chalk.red(` └─ Exit Code: ${code}`));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconsole.log(chalk.cyan('\\n📡 Local Node Running'));\n\t\t\tconsole.log(chalk.cyan(' └─ Press Ctrl+C to stop'));\n\n\t\t\tawait new Promise(() => {});\n\t\t} else {\n\t\t\tsuiProcess.unref();\n\t\t\tconsole.log(chalk.green('\\n✅ Local Node Started in Background'));\n\n\t\t\tif (process.platform === 'win32') {\n\t\t\t\tconsole.log('\\n💡 Helpful Commands:');\n\t\t\t\tconsole.log(' ├─ Check Process: tasklist | findstr sui.exe');\n\t\t\t\tconsole.log(' └─ Stop Node: taskkill /PID <process_id> /F');\n\t\t\t} else {\n\t\t\t\tconsole.log('\\n💡 Helpful Commands:');\n\t\t\t\tconsole.log(\" ├─ Check Process: pgrep -f 'sui start'\");\n\t\t\t\tconsole.log(' └─ Stop Node: kill <process_id>');\n\t\t\t}\n\t\t}\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red('\\n❌ Failed to Start Local Node'));\n\t\tconsole.error(chalk.red(` └─ Error: ${error.message}`));\n\t}\n}\n","import { execSync } from 'child_process';\nimport chalk from 'chalk';\n\nexport async function checkLocalNodeStatus() {\n\tconsole.log('\\n🔍 Checking Local Node Status...');\n\n\ttry {\n\t\tconst cmd =\n\t\t\tprocess.platform === 'win32'\n\t\t\t\t? `tasklist /FI \"IMAGENAME eq sui.exe\" /FO CSV /NH`\n\t\t\t\t: \"ps aux | grep '[s]ui start --with-faucet --force-regenesis'\";\n\n\t\tconst output = execSync(cmd, {\n\t\t\tencoding: 'utf8',\n\t\t});\n\n\t\tconst isRunning =\n\t\t\tprocess.platform === 'win32'\n\t\t\t\t? output.toLowerCase().includes('sui.exe')\n\t\t\t\t: output.split('\\n').filter(Boolean).length > 0;\n\n\t\tif (isRunning) {\n\t\t\tconsole.log(chalk.green('\\n✅ Node Status: Running'));\n\t\t\tconsole.log(chalk.gray('\\n📊 Process Details:'));\n\t\t\tconsole.log(chalk.gray(` └─ ${output.trim()}`));\n\t\t} else {\n\t\t\tconsole.log(chalk.red('\\n❌ Node Status: Not Running'));\n\t\t\tconsole.log(chalk.yellow('\\n💡 Quick Start:'));\n\t\t\tconsole.log(chalk.yellow(' └─ Run `obelisk localnode start`'));\n\t\t}\n\t} catch (error) {\n\t\tconsole.log(chalk.red('\\n❌ Node Status: Not Running'));\n\t\tconsole.log(chalk.yellow('\\n💡 Quick Start:'));\n\t\tconsole.log(chalk.yellow(' └─ Run `obelisk localnode start`'));\n\t}\n}\n\n// checkLocalNodeStatus();\n","import { execSync } from 'child_process';\n\nexport async function stopLocalnode() {\n\tconsole.log('Stopping local node...');\n\n\ttry {\n\t\t// Choose different commands based on the operating system\n\t\tconst cmd =\n\t\t\tprocess.platform === 'win32'\n\t\t\t\t? `tasklist /FI \"IMAGENAME eq sui.exe\" /FO CSV /NH`\n\t\t\t\t: \"ps aux | grep '[s]ui start --with-faucet --force-regenesis'\";\n\n\t\tconst output = execSync(cmd, {\n\t\t\tencoding: 'utf8',\n\t\t});\n\n\t\tif (!output) {\n\t\t\tconsole.log('No running local node process found');\n\t\t\treturn;\n\t\t}\n\n\t\t// Parse process ID based on the operating system\n\t\tlet pid;\n\t\tif (process.platform === 'win32') {\n\t\t\t// Windows output format: \"sui.exe\",\"1234\",... (CSV format)\n\t\t\tconst match = output.match(/\"sui\\.exe\",[\"']?(\\d+)/i);\n\t\t\tpid = match ? match[1] : null;\n\t\t} else {\n\t\t\t// Unix system output format: user pid %cpu ...\n\t\t\tpid = output.toString().split(/\\s+/)[1];\n\t\t}\n\n\t\tif (!pid) {\n\t\t\tconsole.log('No running local node process found');\n\t\t\treturn;\n\t\t}\n\n\t\t// Choose the command to terminate the process based on the operating system\n\t\tif (process.platform === 'win32') {\n\t\t\texecSync(`taskkill /PID ${pid} /F`);\n\t\t} else {\n\t\t\tprocess.kill(Number(pid));\n\t\t}\n\n\t\tconsole.log('✅ Local node stopped successfully');\n\t} catch (error: any) {\n\t\tif (\n\t\t\terror.code === 'ESRCH' ||\n\t\t\terror.message.includes('no running tasks')\n\t\t) {\n\t\t\tconsole.log('No running local node process found');\n\t\t} else {\n\t\t\tconsole.error('❌ Error stopping local node:', error.message);\n\t\t}\n\t}\n}\n\n// stopLocalnode();\n","import chalk from \"chalk\";\n\nexport function printObelisk() {\n console.log(\n chalk.yellow(`\nWelcome to obelisk world\n\\t\\t\\t --from team@obelisk\n ________ ________ _______ ___ ___ ________ ___ __ \n|\\\\ __ \\\\|\\\\ __ \\\\|\\\\ ___ \\\\ |\\\\ \\\\ |\\\\ \\\\|\\\\ ____\\\\|\\\\ \\\\|\\\\ \\\\ \n\\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\|\\\\ /\\\\ \\\\ __/|\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\___|\\\\ \\\\ \\\\/ /|_ \n \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __ \\\\ \\\\ \\\\_|/_\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\_____ \\\\ \\\\ ___ \\\\ \n \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\_|\\\\ \\\\ \\\\ \\\\____\\\\ \\\\ \\\\|____|\\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \n \\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\__\\\\____\\\\_\\\\ \\\\ \\\\__\\\\\\\\ \\\\__\\\\\n \\\\|_______|\\\\|_______|\\\\|_______|\\\\|_______|\\\\|__|\\\\_________\\\\|__| \\\\|__|\n \\\\|_________| \n \n \n`)\n );\n}\n","import type { CommandModule } from 'yargs';\nimport { startLocalnode, stopLocalnode, checkLocalNodeStatus } from '../utils';\n\nconst commandModule: CommandModule = {\n\tcommand: 'localnode <action>',\n\n\tdescribe: 'Manage local Sui node',\n\n\tbuilder(yargs) {\n\t\treturn yargs\n\t\t\t.positional('action', {\n\t\t\t\tdescribe: 'Action to perform',\n\t\t\t\tchoices: ['start', 'stop', 'status', 'restart'],\n\t\t\t\ttype: 'string',\n\t\t\t\tdemandOption: true,\n\t\t\t})\n\t\t\t.option('background', {\n\t\t\t\talias: 'b',\n\t\t\t\ttype: 'boolean',\n\t\t\t\tdescription: 'Run node in background',\n\t\t\t\tdefault: false,\n\t\t\t});\n\t},\n\n\tasync handler(argv) {\n\t\tconst { action, background } = argv;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase 'start':\n\t\t\t\t\tawait startLocalnode(background as boolean);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'stop':\n\t\t\t\t\tawait stopLocalnode();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'status':\n\t\t\t\t\tawait checkLocalNodeStatus();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'restart':\n\t\t\t\t\tawait restartNode(background as boolean);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('Error executing command:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t},\n};\n\nasync function restartNode(background: boolean) {\n\tconsole.log('Restarting local Sui node...');\n\tawait stopLocalnode();\n\tawait startLocalnode(background);\n\tconsole.log('Local node has been restarted');\n}\n\nexport default commandModule;\n","import { Obelisk } from '@0xobelisk/sui-client';\nimport type { CommandModule } from 'yargs';\nimport { requestSuiFromFaucetV0, getFaucetHost } from '@mysten/sui/faucet';\nimport {\n\tSuiClient,\n\tgetFullnodeUrl,\n\tGetBalanceParams,\n} from '@mysten/sui/client';\nimport { validatePrivateKey, ObeliskCliError } from '../utils';\n\ntype Options = {\n\tnetwork: any;\n\trecipient?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'faucet',\n\n\tdescribe: 'Interact with a Obelisk faucet',\n\n\tbuilder(yargs) {\n\t\treturn yargs.options({\n\t\t\tnetwork: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdesc: 'URL of the Obelisk faucet',\n\t\t\t\tchoices: ['testnet', 'devnet', 'localnet'],\n\t\t\t\tdefault: 'localnet',\n\t\t\t},\n\t\t\trecipient: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdesc: 'Sui address to fund',\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({ network, recipient }) {\n\t\tlet faucet_address = '';\n\t\tif (recipient === undefined) {\n\t\t\tconst privateKey = process.env.PRIVATE_KEY;\n\t\t\tif (!privateKey)\n\t\t\t\tthrow new ObeliskCliError(\n\t\t\t\t\t`Missing PRIVATE_KEY environment variable.\n Run 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\n in your contracts directory to use the default sui private key.`\n\t\t\t\t);\n\n\t\t\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\t\t\tif (privateKeyFormat === false) {\n\t\t\t\tthrow new ObeliskCliError(`Please check your privateKey.`);\n\t\t\t}\n\t\t\tconst obelisk = new Obelisk({\n\t\t\t\tsecretKey: privateKeyFormat,\n\t\t\t});\n\t\t\tconst keypair = obelisk.getKeypair();\n\t\t\tfaucet_address = keypair.toSuiAddress();\n\t\t} else {\n\t\t\tfaucet_address = recipient;\n\t\t}\n\n\t\tconsole.log('\\n🌊 Starting Faucet Operation...');\n\t\tconsole.log(` ├─ Network: ${network}`);\n\n\t\tif (recipient === undefined) {\n\t\t\tconsole.log(' ├─ Using Environment Private Key');\n\t\t\tconsole.log(` ├─ Generated Address: ${faucet_address}`);\n\t\t} else {\n\t\t\tconsole.log(` ├─ Using Provided Address: ${faucet_address}`);\n\t\t}\n\n\t\tconsole.log(' ├─ Requesting funds from faucet...');\n\t\tawait requestSuiFromFaucetV0({\n\t\t\thost: getFaucetHost(network),\n\t\t\trecipient: faucet_address,\n\t\t});\n\n\t\tconsole.log(' └─ Checking balance...');\n\t\tconst client = new SuiClient({ url: getFullnodeUrl(network) });\n\t\tlet params = {\n\t\t\towner: faucet_address,\n\t\t} as GetBalanceParams;\n\n\t\tconst balance = await client.getBalance(params);\n\t\tconsole.log('\\n💰 Account Summary');\n\t\tconsole.log(` ├─ Address: ${faucet_address}`);\n\t\tconsole.log(` └─ Balance: ${balance.totalBalance} SUI`);\n\n\t\tconsole.log('\\n✅ Faucet Operation Complete\\n');\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { schemaGen, loadConfig, ObeliskConfig } from '@0xobelisk/sui-common';\nimport chalk from 'chalk';\n\ntype Options = {\n\tconfigPath?: string;\n\tnetwork?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\tframeworkId?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'schemagen',\n\n\tdescribe: 'Autogenerate Obelisk schemas based on the config file',\n\n\tbuilder: {\n\t\tconfigPath: {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'obelisk.config.ts',\n\t\t\tdesc: 'Path to the config file',\n\t\t},\n\t\tnetwork: {\n\t\t\ttype: 'string',\n\t\t\tchoices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,\n\t\t\tdesc: 'Node network (mainnet/testnet/devnet/localnet)',\n\t\t},\n\t\tframeworkId: {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Framework Package ID',\n\t\t},\n\t},\n\n\tasync handler({ configPath, network, frameworkId }) {\n\t\ttry {\n\t\t\tconst obeliskConfig = (await loadConfig(\n\t\t\t\tconfigPath\n\t\t\t)) as ObeliskConfig;\n\t\t\tawait schemaGen(obeliskConfig, undefined, network, frameworkId);\n\t\t\tprocess.exit(0);\n\t\t} catch (error: any) {\n\t\t\tconsole.log(chalk.red('Schemagen failed!'));\n\t\t\tconsole.error(error.message);\n\t\t}\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { publishHandler } from '../utils';\nimport { loadConfig, ObeliskConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\tnetwork: any;\n\tconfigPath: string;\n\tdappsObjectId?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'publish',\n\n\tdescribe: 'Publish obelisk move contract',\n\n\tbuilder(yargs) {\n\t\treturn yargs.options({\n\t\t\tnetwork: {\n\t\t\t\ttype: 'string',\n\t\t\t\tchoices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n\t\t\t\tdesc: 'Node network (mainnet/testnet/devnet/localnet)',\n\t\t\t},\n\t\t\tconfigPath: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'obelisk.config.ts',\n\t\t\t\tdesc: 'Configuration file path',\n\t\t\t},\n\t\t\tdappsObjectId: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdesc: 'Optional dappsObjectId',\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({ network, configPath, dappsObjectId }) {\n\t\ttry {\n\t\t\tconst obeliskConfig = (await loadConfig(\n\t\t\t\tconfigPath\n\t\t\t)) as ObeliskConfig;\n\t\t\tawait publishHandler(obeliskConfig.name, network, dappsObjectId);\n\t\t} catch (error: any) {\n\t\t\tlogError(error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { execSync } from \"child_process\";\nimport chalk from \"chalk\";\n\ntype Options = {\n packagePath: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"test\",\n\n describe: \"Run tests in Obelisk contracts\",\n\n builder(yargs) {\n return yargs.options({\n packagePath: {\n type: \"string\",\n default: \".\",\n description: \"Options to pass to forge test\",\n },\n });\n },\n\n async handler({ packagePath }) {\n // Start an internal anvil process if no world address is provided\n try {\n execSync(`sui move test --path ${packagePath}`, {\n encoding: \"utf-8\",\n });\n } catch (error: any) {\n console.error(chalk.red(\"Error executing sui move test:\"));\n console.log(error.stdout);\n process.exit(0);\n }\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { printObelisk } from \"../utils\";\n\nconst commandModule: CommandModule = {\n command: \"hello\",\n\n describe: \"hello, obelisk\",\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n printObelisk();\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';\n// import upgrade from \"./upgrade\";\nimport test from './test';\nimport hello from './hello';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options\nexport const commands: CommandModule<any, any>[] = [\n\tpublish,\n\tlocalnode,\n\tfaucet,\n\tschemagen,\n\t// upgrade,\n\ttest,\n\thello,\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBCHxB,OAAS,WAAAC,OAAe,wBACxB,OAAS,eAAAC,MAAmB,2BAC5B,OACC,kBAAAC,GACA,aAAAC,OAEM,qBACP,OAAS,YAAAC,OAAgB,gBACzB,OAAOC,MAAW,Q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XA,UAAYC,MAAY,SACxB,OAAOC,MAAW,QACX,SAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,SAAS,EAGpB,QAAQC,CAAe,EAEvB,OAAO,EAEP,KAAK,CAACC,EAAKC,IAAQ,CAClB,QAAQ,MAAML,EAAM,IAAII,CAAG,CAAC,EACxBA,EAAI,SAAS,2BAA2B,GAC1C,QAAQ,IACNJ,EAAM,OAAO,qBAAqB,QAAQ,KAAK,CAAC,2DAA2D,CAC7G,EAEF,QAAQ,IAAI,EAAE,EACdM,EAASD,CAAG,EACZ,QAAQ,IAAI,EAAE,EAEd,QAAQ,KAAK,CAAC,CAChB,CAAC,EAEA,MAAM,CAAE,EAAG,MAAO,CAAC,EAAE","names":["yargs","hideBin","Obelisk","Transaction","getFullnodeUrl","SuiClient","execSync","chalk","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","ObeliskCliError","logError","error","ValidationError","chalk","ZodError","validationError","fromZodError","NotInsideProjectError","ObeliskCliError","mkdirSync","writeFileSync","dirname","SUI_PRIVATE_KEY_PREFIX","execSync","spawn","chalk","isSuiStartRunning","cmd","result","startLocalnode","background","suiProcess","error","code","execSync","chalk","checkLocalNodeStatus","cmd","output","execSync","stopLocalnode","cmd","output","pid","match","error","validatePrivateKey","privateKey","SUI_PRIVATE_KEY_PREFIX","strippedPrivateKey","saveContractData","projectName","network","packageId","schemas","upgradeCap","version","DeploymentData","path","storeDeploymentData","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","getDappsObjectId","network","publishHandler","name","dappsObjectId","projectPath","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","keypair","Obelisk","client","SuiClient","getFullnodeUrl","modules","dependencies","buildResult","execSync","error","chalk","tx","Transaction","upgradeCap","result","version","packageId","schemas","upgradeCapId","object","resolve","deployHookTx","deployHookResult","saveContractData","chalk","printObelisk","commandModule","yargs","argv","action","background","startLocalnode","stopLocalnode","checkLocalNodeStatus","restartNode","error","localnode_default","Obelisk","requestSuiFromFaucetV0","getFaucetHost","SuiClient","getFullnodeUrl","commandModule","yargs","network","recipient","faucet_address","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","Obelisk","requestSuiFromFaucetV0","getFaucetHost","client","SuiClient","getFullnodeUrl","params","balance","faucet_default","schemaGen","loadConfig","chalk","commandModule","configPath","network","frameworkId","obeliskConfig","error","schemagen_default","loadConfig","commandModule","yargs","network","configPath","dappsObjectId","obeliskConfig","publishHandler","error","logError","publish_default","execSync","chalk","commandModule","yargs","packagePath","error","test_default","commandModule","yargs","printObelisk","hello_default","commands","publish_default","localnode_default","faucet_default","schemagen_default","test_default","hello_default","dotenv","chalk","yargs","hideBin","commands","msg","err","logError"]}
|
package/package.json
CHANGED
package/src/commands/faucet.ts
CHANGED
|
@@ -56,16 +56,35 @@ const commandModule: CommandModule<Options, Options> = {
|
|
|
56
56
|
} else {
|
|
57
57
|
faucet_address = recipient;
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
console.log('\n🌊 Starting Faucet Operation...');
|
|
61
|
+
console.log(` ├─ Network: ${network}`);
|
|
62
|
+
|
|
63
|
+
if (recipient === undefined) {
|
|
64
|
+
console.log(' ├─ Using Environment Private Key');
|
|
65
|
+
console.log(` ├─ Generated Address: ${faucet_address}`);
|
|
66
|
+
} else {
|
|
67
|
+
console.log(` ├─ Using Provided Address: ${faucet_address}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log(' ├─ Requesting funds from faucet...');
|
|
59
71
|
await requestSuiFromFaucetV0({
|
|
60
72
|
host: getFaucetHost(network),
|
|
61
73
|
recipient: faucet_address,
|
|
62
74
|
});
|
|
75
|
+
|
|
76
|
+
console.log(' └─ Checking balance...');
|
|
63
77
|
const client = new SuiClient({ url: getFullnodeUrl(network) });
|
|
64
78
|
let params = {
|
|
65
79
|
owner: faucet_address,
|
|
66
80
|
} as GetBalanceParams;
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
|
|
82
|
+
const balance = await client.getBalance(params);
|
|
83
|
+
console.log('\n💰 Account Summary');
|
|
84
|
+
console.log(` ├─ Address: ${faucet_address}`);
|
|
85
|
+
console.log(` └─ Balance: ${balance.totalBalance} SUI`);
|
|
86
|
+
|
|
87
|
+
console.log('\n✅ Faucet Operation Complete\n');
|
|
69
88
|
process.exit(0);
|
|
70
89
|
},
|
|
71
90
|
};
|
|
@@ -3,29 +3,38 @@ import chalk from 'chalk';
|
|
|
3
3
|
|
|
4
4
|
function isSuiStartRunning(): boolean {
|
|
5
5
|
try {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const cmd =
|
|
7
|
+
process.platform === 'win32'
|
|
8
|
+
? `tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH`
|
|
9
|
+
: 'pgrep -f "sui start"';
|
|
10
|
+
|
|
11
|
+
const result = execSync(cmd).toString().trim();
|
|
12
|
+
return process.platform === 'win32'
|
|
13
|
+
? result.toLowerCase().includes('sui.exe')
|
|
14
|
+
: result.length > 0;
|
|
8
15
|
} catch (error) {
|
|
9
16
|
return false;
|
|
10
17
|
}
|
|
11
18
|
}
|
|
12
19
|
|
|
13
20
|
export async function startLocalnode(background: boolean = false) {
|
|
14
|
-
console.log(
|
|
21
|
+
console.log('\n🔍 Checking Local Node Status...');
|
|
22
|
+
console.log(' ├─ Scanning running processes');
|
|
15
23
|
|
|
16
24
|
if (isSuiStartRunning()) {
|
|
25
|
+
console.log(chalk.yellow('\n⚠️ Warning: Local Node Already Running'));
|
|
26
|
+
console.log(chalk.yellow(' ├─ Cannot start a new instance'));
|
|
17
27
|
console.log(
|
|
18
|
-
chalk.yellow('
|
|
19
|
-
);
|
|
20
|
-
console.log(
|
|
21
|
-
chalk.yellow(
|
|
22
|
-
'Cannot start a new local node. Please stop the existing sui start process first.'
|
|
23
|
-
)
|
|
28
|
+
chalk.yellow(' └─ Please stop the existing process first')
|
|
24
29
|
);
|
|
25
30
|
return;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
|
-
console.log(
|
|
33
|
+
console.log('\n🚀 Starting Local Node...');
|
|
34
|
+
console.log(' ├─ Mode: ' + (background ? 'Background' : 'Foreground'));
|
|
35
|
+
console.log(' ├─ Faucet: Enabled');
|
|
36
|
+
console.log(' └─ Force Regenesis: Yes');
|
|
37
|
+
|
|
29
38
|
try {
|
|
30
39
|
const suiProcess = spawn(
|
|
31
40
|
'sui',
|
|
@@ -38,50 +47,41 @@ export async function startLocalnode(background: boolean = false) {
|
|
|
38
47
|
);
|
|
39
48
|
|
|
40
49
|
suiProcess.on('error', error => {
|
|
41
|
-
console.error(chalk.red('Failed to
|
|
50
|
+
console.error(chalk.red('\n❌ Failed to Start Local Node'));
|
|
51
|
+
console.error(chalk.red(` └─ Error: ${error.message}`));
|
|
42
52
|
});
|
|
43
53
|
|
|
44
54
|
if (!background) {
|
|
45
55
|
suiProcess.on('exit', code => {
|
|
46
56
|
if (code === 0) {
|
|
47
|
-
console.log(chalk.green('Local
|
|
57
|
+
console.log(chalk.green('\n✅ Local Node Stopped'));
|
|
58
|
+
console.log(chalk.green(' └─ Exit Status: Normal'));
|
|
48
59
|
} else {
|
|
49
|
-
console.error(
|
|
50
|
-
|
|
51
|
-
`Local node exited abnormally with code: ${code}`
|
|
52
|
-
)
|
|
53
|
-
);
|
|
60
|
+
console.error(chalk.red('\n❌ Local Node Crashed'));
|
|
61
|
+
console.error(chalk.red(` └─ Exit Code: ${code}`));
|
|
54
62
|
}
|
|
55
63
|
});
|
|
56
64
|
|
|
57
|
-
console.log(chalk.cyan('Local
|
|
58
|
-
console.log(chalk.cyan('Press Ctrl+C to stop
|
|
65
|
+
console.log(chalk.cyan('\n📡 Local Node Running'));
|
|
66
|
+
console.log(chalk.cyan(' └─ Press Ctrl+C to stop'));
|
|
59
67
|
|
|
60
|
-
// Keep the script running
|
|
61
68
|
await new Promise(() => {});
|
|
62
69
|
} else {
|
|
63
70
|
suiProcess.unref();
|
|
64
|
-
console.log(
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
76
|
-
);
|
|
71
|
+
console.log(chalk.green('\n✅ Local Node Started in Background'));
|
|
72
|
+
|
|
73
|
+
if (process.platform === 'win32') {
|
|
74
|
+
console.log('\n💡 Helpful Commands:');
|
|
75
|
+
console.log(' ├─ Check Process: tasklist | findstr sui.exe');
|
|
76
|
+
console.log(' └─ Stop Node: taskkill /PID <process_id> /F');
|
|
77
|
+
} else {
|
|
78
|
+
console.log('\n💡 Helpful Commands:');
|
|
79
|
+
console.log(" ├─ Check Process: pgrep -f 'sui start'");
|
|
80
|
+
console.log(' └─ Stop Node: kill <process_id>');
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
|
-
} catch (error) {
|
|
79
|
-
console.error(chalk.red('Failed to
|
|
83
|
+
} catch (error: any) {
|
|
84
|
+
console.error(chalk.red('\n❌ Failed to Start Local Node'));
|
|
85
|
+
console.error(chalk.red(` └─ Error: ${error.message}`));
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
|
-
|
|
83
|
-
// Get the background flag from command line arguments
|
|
84
|
-
const args = process.argv.slice(2);
|
|
85
|
-
const runInBackground = args.includes('--background') || args.includes('-b');
|
|
86
|
-
|
|
87
|
-
// startLocalnode(runInBackground);
|
|
@@ -2,37 +2,36 @@ import { execSync } from 'child_process';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
|
|
4
4
|
export async function checkLocalNodeStatus() {
|
|
5
|
+
console.log('\n🔍 Checking Local Node Status...');
|
|
6
|
+
|
|
5
7
|
try {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const cmd =
|
|
9
|
+
process.platform === 'win32'
|
|
10
|
+
? `tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH`
|
|
11
|
+
: "ps aux | grep '[s]ui start --with-faucet --force-regenesis'";
|
|
12
|
+
|
|
13
|
+
const output = execSync(cmd, {
|
|
14
|
+
encoding: 'utf8',
|
|
15
|
+
});
|
|
12
16
|
|
|
13
|
-
const
|
|
17
|
+
const isRunning =
|
|
18
|
+
process.platform === 'win32'
|
|
19
|
+
? output.toLowerCase().includes('sui.exe')
|
|
20
|
+
: output.split('\n').filter(Boolean).length > 0;
|
|
14
21
|
|
|
15
|
-
if (
|
|
16
|
-
console.log(chalk.green('
|
|
17
|
-
console.log(chalk.gray('Process Details:'));
|
|
18
|
-
|
|
19
|
-
console.log(chalk.gray(` ${line}`));
|
|
20
|
-
}
|
|
22
|
+
if (isRunning) {
|
|
23
|
+
console.log(chalk.green('\n✅ Node Status: Running'));
|
|
24
|
+
console.log(chalk.gray('\n📊 Process Details:'));
|
|
25
|
+
console.log(chalk.gray(` └─ ${output.trim()}`));
|
|
21
26
|
} else {
|
|
22
|
-
console.log(chalk.red('
|
|
23
|
-
console.log(
|
|
24
|
-
|
|
25
|
-
'Tip: Use `pnpm run start-localnode` to start the local node'
|
|
26
|
-
)
|
|
27
|
-
);
|
|
27
|
+
console.log(chalk.red('\n❌ Node Status: Not Running'));
|
|
28
|
+
console.log(chalk.yellow('\n💡 Quick Start:'));
|
|
29
|
+
console.log(chalk.yellow(' └─ Run `obelisk localnode start`'));
|
|
28
30
|
}
|
|
29
31
|
} catch (error) {
|
|
30
|
-
console.log(chalk.red('
|
|
31
|
-
console.log(
|
|
32
|
-
|
|
33
|
-
'Tip: Use `pnpm run start-localnode` to start the local node'
|
|
34
|
-
)
|
|
35
|
-
);
|
|
32
|
+
console.log(chalk.red('\n❌ Node Status: Not Running'));
|
|
33
|
+
console.log(chalk.yellow('\n💡 Quick Start:'));
|
|
34
|
+
console.log(chalk.yellow(' └─ Run `obelisk localnode start`'));
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -4,27 +4,50 @@ export async function stopLocalnode() {
|
|
|
4
4
|
console.log('Stopping local node...');
|
|
5
5
|
|
|
6
6
|
try {
|
|
7
|
-
//
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
// Choose different commands based on the operating system
|
|
8
|
+
const cmd =
|
|
9
|
+
process.platform === 'win32'
|
|
10
|
+
? `tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH`
|
|
11
|
+
: "ps aux | grep '[s]ui start --with-faucet --force-regenesis'";
|
|
12
|
+
|
|
13
|
+
const output = execSync(cmd, {
|
|
14
|
+
encoding: 'utf8',
|
|
15
|
+
});
|
|
14
16
|
|
|
15
17
|
if (!output) {
|
|
16
18
|
console.log('No running local node process found');
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
+
// Parse process ID based on the operating system
|
|
23
|
+
let pid;
|
|
24
|
+
if (process.platform === 'win32') {
|
|
25
|
+
// Windows output format: "sui.exe","1234",... (CSV format)
|
|
26
|
+
const match = output.match(/"sui\.exe",["']?(\d+)/i);
|
|
27
|
+
pid = match ? match[1] : null;
|
|
28
|
+
} else {
|
|
29
|
+
// Unix system output format: user pid %cpu ...
|
|
30
|
+
pid = output.toString().split(/\s+/)[1];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!pid) {
|
|
34
|
+
console.log('No running local node process found');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Choose the command to terminate the process based on the operating system
|
|
39
|
+
if (process.platform === 'win32') {
|
|
40
|
+
execSync(`taskkill /PID ${pid} /F`);
|
|
41
|
+
} else {
|
|
42
|
+
process.kill(Number(pid));
|
|
43
|
+
}
|
|
22
44
|
|
|
23
|
-
// Kill the process
|
|
24
|
-
process.kill(Number(pid));
|
|
25
45
|
console.log('✅ Local node stopped successfully');
|
|
26
46
|
} catch (error: any) {
|
|
27
|
-
if (
|
|
47
|
+
if (
|
|
48
|
+
error.code === 'ESRCH' ||
|
|
49
|
+
error.message.includes('no running tasks')
|
|
50
|
+
) {
|
|
28
51
|
console.log('No running local node process found');
|
|
29
52
|
} else {
|
|
30
53
|
console.error('❌ Error stopping local node:', error.message);
|
|
@@ -31,36 +31,39 @@ export async function publishHandler(
|
|
|
31
31
|
network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
|
|
32
32
|
dappsObjectId?: string
|
|
33
33
|
) {
|
|
34
|
+
console.log('\n🚀 Starting Contract Publication...');
|
|
35
|
+
console.log(` ├─ Project: ${name}`);
|
|
36
|
+
console.log(` ├─ Network: ${network}`);
|
|
37
|
+
|
|
34
38
|
const path = process.cwd();
|
|
35
39
|
const projectPath = `${path}/contracts/${name}`;
|
|
36
40
|
dappsObjectId = dappsObjectId || (await getDappsObjectId(network));
|
|
41
|
+
|
|
42
|
+
console.log(' ├─ Validating Environment...');
|
|
37
43
|
const privateKey = process.env.PRIVATE_KEY;
|
|
38
|
-
if (!privateKey)
|
|
44
|
+
if (!privateKey) {
|
|
39
45
|
throw new ObeliskCliError(
|
|
40
46
|
`Missing PRIVATE_KEY environment variable.
|
|
41
47
|
Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
|
|
42
48
|
in your contracts directory to use the default sui private key.`
|
|
43
49
|
);
|
|
50
|
+
}
|
|
44
51
|
|
|
45
52
|
const privateKeyFormat = validatePrivateKey(privateKey);
|
|
46
53
|
if (privateKeyFormat === false) {
|
|
47
54
|
throw new ObeliskCliError(`Please check your privateKey.`);
|
|
48
55
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
56
|
+
|
|
57
|
+
const obelisk = new Obelisk({ secretKey: privateKeyFormat });
|
|
52
58
|
const keypair = obelisk.getKeypair();
|
|
59
|
+
console.log(` └─ Account: ${keypair.toSuiAddress()}`);
|
|
53
60
|
|
|
54
|
-
const client = new SuiClient({
|
|
55
|
-
url: getFullnodeUrl(network),
|
|
56
|
-
});
|
|
61
|
+
const client = new SuiClient({ url: getFullnodeUrl(network) });
|
|
57
62
|
|
|
63
|
+
console.log('\n📦 Building Contract...');
|
|
58
64
|
let modules: any, dependencies: any;
|
|
59
65
|
try {
|
|
60
|
-
const
|
|
61
|
-
modules: extractedModules,
|
|
62
|
-
dependencies: extractedDependencies,
|
|
63
|
-
} = JSON.parse(
|
|
66
|
+
const buildResult = JSON.parse(
|
|
64
67
|
execSync(
|
|
65
68
|
`sui move build --dump-bytecode-as-base64 --path ${projectPath}`,
|
|
66
69
|
{
|
|
@@ -68,21 +71,18 @@ in your contracts directory to use the default sui private key.`
|
|
|
68
71
|
}
|
|
69
72
|
)
|
|
70
73
|
);
|
|
71
|
-
modules =
|
|
72
|
-
dependencies =
|
|
74
|
+
modules = buildResult.modules;
|
|
75
|
+
dependencies = buildResult.dependencies;
|
|
76
|
+
console.log(' └─ Build successful');
|
|
73
77
|
} catch (error: any) {
|
|
74
|
-
console.error(chalk.red('
|
|
78
|
+
console.error(chalk.red(' └─ Build failed'));
|
|
75
79
|
console.error(error.stdout);
|
|
76
|
-
process.exit(1);
|
|
80
|
+
process.exit(1);
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
console.log(
|
|
80
|
-
|
|
83
|
+
console.log('\n🔄 Publishing Contract...');
|
|
81
84
|
const tx = new Transaction();
|
|
82
|
-
const [upgradeCap] = tx.publish({
|
|
83
|
-
modules,
|
|
84
|
-
dependencies,
|
|
85
|
-
});
|
|
85
|
+
const [upgradeCap] = tx.publish({ modules, dependencies });
|
|
86
86
|
tx.transferObjects([upgradeCap], keypair.toSuiAddress());
|
|
87
87
|
|
|
88
88
|
let result: SuiTransactionBlockResponse;
|
|
@@ -90,48 +90,45 @@ in your contracts directory to use the default sui private key.`
|
|
|
90
90
|
result = await client.signAndExecuteTransaction({
|
|
91
91
|
signer: keypair,
|
|
92
92
|
transaction: tx,
|
|
93
|
-
options: {
|
|
94
|
-
showObjectChanges: true,
|
|
95
|
-
},
|
|
93
|
+
options: { showObjectChanges: true },
|
|
96
94
|
});
|
|
97
95
|
} catch (error: any) {
|
|
98
|
-
console.error(chalk.red(
|
|
96
|
+
console.error(chalk.red(' └─ Publication failed'));
|
|
99
97
|
console.error(error.message);
|
|
100
98
|
process.exit(1);
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
if (result.effects?.status.status === 'failure') {
|
|
104
|
-
console.log(chalk.red(
|
|
102
|
+
console.log(chalk.red(' └─ Publication failed'));
|
|
105
103
|
process.exit(1);
|
|
106
104
|
}
|
|
107
105
|
|
|
106
|
+
console.log(' ├─ Processing publication results...');
|
|
108
107
|
let version = 1;
|
|
109
108
|
let packageId = '';
|
|
110
109
|
let schemas: schema[] = [];
|
|
111
110
|
let upgradeCapId = '';
|
|
111
|
+
|
|
112
112
|
result.objectChanges!.map(object => {
|
|
113
113
|
if (object.type === 'published') {
|
|
114
|
-
console.log(
|
|
114
|
+
console.log(` ├─ Package ID: ${object.packageId}`);
|
|
115
115
|
packageId = object.packageId;
|
|
116
116
|
}
|
|
117
117
|
if (
|
|
118
118
|
object.type === 'created' &&
|
|
119
119
|
object.objectType === '0x2::package::UpgradeCap'
|
|
120
120
|
) {
|
|
121
|
-
console.log(
|
|
121
|
+
console.log(` ├─ Upgrade Cap: ${object.objectId}`);
|
|
122
122
|
upgradeCapId = object.objectId;
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
console.log(
|
|
126
|
+
console.log(` └─ Transaction: ${result.digest}`);
|
|
127
127
|
|
|
128
|
-
console.log('Executing
|
|
129
|
-
|
|
130
|
-
new Promise(resolve => setTimeout(resolve, ms));
|
|
131
|
-
await delay(5000);
|
|
128
|
+
console.log('\n⚡ Executing Deploy Hook...');
|
|
129
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
132
130
|
|
|
133
131
|
const deployHookTx = new Transaction();
|
|
134
|
-
|
|
135
132
|
deployHookTx.moveCall({
|
|
136
133
|
target: `${packageId}::deploy_hook::run`,
|
|
137
134
|
arguments: [
|
|
@@ -145,46 +142,33 @@ in your contracts directory to use the default sui private key.`
|
|
|
145
142
|
deployHookResult = await client.signAndExecuteTransaction({
|
|
146
143
|
signer: keypair,
|
|
147
144
|
transaction: deployHookTx,
|
|
148
|
-
options: {
|
|
149
|
-
showEffects: true,
|
|
150
|
-
showObjectChanges: true,
|
|
151
|
-
},
|
|
145
|
+
options: { showEffects: true, showObjectChanges: true },
|
|
152
146
|
});
|
|
153
147
|
} catch (error: any) {
|
|
154
|
-
console.error(
|
|
155
|
-
chalk.red(
|
|
156
|
-
`Failed to execute deployHook, please republish or manually call deploy_hook::run`
|
|
157
|
-
)
|
|
158
|
-
);
|
|
148
|
+
console.error(chalk.red(' └─ Deploy hook execution failed'));
|
|
159
149
|
console.error(error.message);
|
|
160
150
|
process.exit(1);
|
|
161
151
|
}
|
|
162
152
|
|
|
163
153
|
if (deployHookResult.effects?.status.status === 'success') {
|
|
164
|
-
console.log(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
);
|
|
154
|
+
console.log(' ├─ Hook execution successful');
|
|
155
|
+
console.log(` ├─ Transaction: ${deployHookResult.digest}`);
|
|
156
|
+
|
|
157
|
+
console.log('\n📋 Created Schemas:');
|
|
169
158
|
deployHookResult.objectChanges?.map(object => {
|
|
170
159
|
if (
|
|
171
160
|
object.type === 'created' &&
|
|
172
161
|
object.objectType.includes('schema')
|
|
173
162
|
) {
|
|
174
|
-
console.log(
|
|
175
|
-
|
|
176
|
-
);
|
|
177
|
-
console.log(
|
|
178
|
-
chalk.blue(
|
|
179
|
-
`${name} Schema Object type: ${object.objectType}`
|
|
180
|
-
)
|
|
181
|
-
);
|
|
163
|
+
console.log(` ├─ ${object.objectType}`);
|
|
164
|
+
console.log(` └─ ID: ${object.objectId}`);
|
|
182
165
|
schemas.push({
|
|
183
166
|
name: object.objectType,
|
|
184
167
|
objectId: object.objectId,
|
|
185
168
|
});
|
|
186
169
|
}
|
|
187
170
|
});
|
|
171
|
+
|
|
188
172
|
saveContractData(
|
|
189
173
|
name,
|
|
190
174
|
network,
|
|
@@ -193,10 +177,12 @@ in your contracts directory to use the default sui private key.`
|
|
|
193
177
|
upgradeCapId,
|
|
194
178
|
version
|
|
195
179
|
);
|
|
180
|
+
console.log('\n✅ Contract Publication Complete\n');
|
|
196
181
|
} else {
|
|
182
|
+
console.log(chalk.yellow(' └─ Deploy hook execution failed'));
|
|
197
183
|
console.log(
|
|
198
184
|
chalk.yellow(
|
|
199
|
-
|
|
185
|
+
' Please republish or manually call deploy_hook::run'
|
|
200
186
|
)
|
|
201
187
|
);
|
|
202
188
|
}
|