@0xobelisk/sui-cli 0.5.16 → 0.5.18

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 CHANGED
@@ -1,14 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import qe from"yargs";import{hideBin as Ge}from"yargs/helpers";import{execa as de}from"execa";var pe={command:"localnode",describe:"Start a local Sui node for development",builder(e){return e},async handler(){console.log("Clearing localnode history"),console.log("Running: sui-test-validator");let e=de("sui-test-validator");process.on("SIGINT",()=>{console.log(`
3
- gracefully shutting down from SIGINT (Crtl-C)`),e.kill(),process.exit()}),await e}},H=pe;import{Obelisk as $e}from"@0xobelisk/sui-client";import{requestSuiFromFaucetV0 as Te,getFaucetHost as Se}from"@mysten/sui/faucet";import{SuiClient as Re,getFullnodeUrl as je}from"@mysten/sui/client";import{Obelisk as be}from"@0xobelisk/sui-client";import{Transaction as L}from"@mysten/sui/transactions";import{getFullnodeUrl as we,SuiClient as ke}from"@mysten/sui/client";import{execSync as xe}from"child_process";import c from"chalk";import T from"chalk";import{ZodError as me}from"zod";import{fromZodError as ge,ValidationError as ue}from"zod-validation-error";var U=class extends Error{name="NotInsideProjectError";message="You are not inside a Obelisk project"},i=class extends Error{name="ObeliskCliError"},M=class extends Error{name="UpgradeError"},S=class extends Error{name="FsIibError"};function E(e){if(e instanceof ue)console.log(T.redBright(e.message));else if(e instanceof me){let t=ge(e,{prefixSeparator:`
2
+ import $e from"yargs";import{hideBin as Te}from"yargs/helpers";import{Obelisk as ie}from"@0xobelisk/sui-client";import{Transaction as F}from"@mysten/sui/transactions";import{getFullnodeUrl as ce,SuiClient as le}from"@mysten/sui/client";import{execSync as de}from"child_process";import a from"chalk";import m from"chalk";import{ZodError as W}from"zod";import{fromZodError as q,ValidationError as Z}from"zod-validation-error";var O=class extends Error{name="NotInsideProjectError";message="You are not inside a Obelisk project"},i=class extends Error{name="ObeliskCliError"};function y(e){if(e instanceof Z)console.log(m.redBright(e.message));else if(e instanceof W){let o=q(e,{prefixSeparator:`
4
3
  - `,issueSeparator:`
5
- - `});console.log(T.redBright(t.message))}else e instanceof U?(console.log(T.red(e.message)),console.log(""),console.log(T.blue("To learn more about Obelisk's configuration, please go to https://github.com/0xobelisk"))):e instanceof i?console.log(T.red(e)):console.log(e)}import*as D from"fs/promises";import{mkdirSync as fe,writeFileSync as _e}from"fs";import{dirname as ye}from"path";import{SUI_PRIVATE_KEY_PREFIX as he}from"@mysten/sui/cryptography";function I(e){if(e.startsWith(he))return e.length===70?e:!1;if(e.startsWith("0x")){let t=e.slice(2);return t.length===64?t:!1}else return e.length===64?e:!1}async function Y(e,t){try{let o=`${e}/sources/script/migrate.move`,r=(await D.readFile(o,"utf8")).replace(/const VERSION: u64 = \d+;/,`const VERSION: u64 = ${t};`);G(r,o,"Update package version")}catch{throw new S("Fs update version failed.")}}async function N(e,t){try{let o=await D.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch{throw new S("Fs read deployment file failed.")}}async function J(e,t){return(await N(e,t)).version}async function W(e,t){return(await N(e,t)).packageId}async function q(e,t){return(await N(e,t)).upgradeCap}function R(e,t,o,l,r,d){let u={projectName:e,network:t,packageId:o,schemas:l,upgradeCap:r,version:d},f=process.cwd(),m=JSON.stringify(u,null,2);G(m,`${f}/contracts/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function G(e,t,o){fe(ye(t),{recursive:!0}),_e(t,e),o!==void 0&&console.log(`${o}: ${t}`)}async function Z(e,t){let l=`${process.cwd()}/contracts/${e}`,r=process.env.PRIVATE_KEY;if(!r)throw new i(`Missing PRIVATE_KEY environment variable.
4
+ - `});console.log(m.redBright(o.message))}else e instanceof O?(console.log(m.red(e.message)),console.log(""),console.log(m.blue("To learn more about Obelisk's configuration, please go to https://github.com/0xobelisk"))):e instanceof i?console.log(m.red(e)):console.log(e)}import{mkdirSync as te,writeFileSync as ne}from"fs";import{dirname as se}from"path";import{SUI_PRIVATE_KEY_PREFIX as re}from"@mysten/sui/cryptography";import{execSync as X,spawn as z}from"child_process";import r from"chalk";function Q(){try{return X('pgrep -f "sui start"').toString().trim().length>0}catch{return!1}}async function h(e=!1){if(console.log(r.blue("Checking if sui start process is running...")),Q()){console.log(r.yellow("Warning: sui start process is already running.")),console.log(r.yellow("Cannot start a new local node. Please stop the existing sui start process first."));return}console.log(r.green("Starting local node..."));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("Failed to start local node:"),t)}),e?(o.unref(),console.log(r.green("Local node has been started in the background")),console.log(r.cyan(`Use "pgrep -f 'sui start'" to check the process ID`)),console.log(r.cyan('Use "kill <process_id>" to stop the background node'))):(o.on("exit",t=>{t===0?console.log(r.green("Local node has exited normally")):console.error(r.red(`Local node exited abnormally with code: ${t}`))}),console.log(r.cyan("Local node is running...")),console.log(r.cyan("Press Ctrl+C to stop the local node")),await new Promise(()=>{}))}catch(o){console.error(r.red("Failed to start local node:"),o)}}var T=process.argv.slice(2),De=T.includes("--background")||T.includes("-b");import{execSync as ee}from"child_process";import p from"chalk";async function C(){try{let o=ee("ps aux | grep '[s]ui start --with-faucet --force-regenesis'",{encoding:"utf8"}).split(`
5
+ `).filter(Boolean);if(o.length>0){console.log(p.green("\u2713 Sui Local Node Status: Running")),console.log(p.gray("Process Details:"));for(let t of o)console.log(p.gray(` ${t}`))}else console.log(p.red("\u2717 Sui Local Node Status: Not Running")),console.log(p.yellow("Tip: Use `pnpm run start-localnode` to start the local node"))}catch{console.log(p.red("\u2717 Sui Local Node Status: Not Running")),console.log(p.yellow("Tip: Use `pnpm run start-localnode` to start the local node"))}}import{execSync as oe}from"child_process";async function b(){console.log("Stopping local node...");try{let e=oe("ps aux | grep '[s]ui start --with-faucet --force-regenesis'",{encoding:"utf8"});if(!e){console.log("No running local node process found");return}let o=e.toString().split(/\s+/)[1];process.kill(Number(o)),console.log("\u2705 Local node stopped successfully")}catch(e){e.code==="ESRCH"?console.log("No running local node process found"):console.error("\u274C Error stopping local node:",e.message)}}function k(e){if(e.startsWith(re))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 M(e,o,t,s,u,c){let l={projectName:e,network:o,packageId:t,schemas:s,upgradeCap:u,version:c},x=process.cwd(),d=JSON.stringify(l,null,2);ae(d,`${x}/contracts/${e}/.history/sui_${o}/latest.json`,"Update deploy log")}async function ae(e,o,t){te(se(o),{recursive:!0}),ne(o,e),t!==void 0&&console.log(`${t}: ${o}`)}async function pe(e){switch(e){case"testnet":return"0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b";default:return"0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b"}}async function N(e,o,t){let u=`${process.cwd()}/contracts/${e}`;t=t||await pe(o);let c=process.env.PRIVATE_KEY;if(!c)throw new i(`Missing PRIVATE_KEY environment variable.
6
6
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
7
- in your contracts directory to use the default sui private key.`);let d=I(r);if(d===!1)throw new i("Please check your privateKey.");let f=new be({secretKey:d}).getKeypair(),m=new ke({url:we(t)}),x,h;try{let{modules:s,dependencies:O}=JSON.parse(xe(`sui move build --dump-bytecode-as-base64 --path ${l}`,{encoding:"utf-8"}));x=s,h=O}catch(s){console.error(c.red("Error executing sui move build:")),console.error(s.stdout),process.exit(1)}console.log(c.blue(`Account: ${f.toSuiAddress()}`));let b=new L,[_]=b.publish({modules:x,dependencies:h});b.transferObjects([_],f.toSuiAddress());let p;try{p=await m.signAndExecuteTransaction({signer:f,transaction:b,options:{showObjectChanges:!0}})}catch(s){console.error(c.red("Failed to execute publish, please republish")),console.error(s.message),process.exit(1)}p.effects?.status.status==="failure"&&(console.log(c.red("Failed to execute publish, please republish")),process.exit(1));let v=1,g="",w=[],P="";p.objectChanges.map(s=>{s.type==="published"&&(console.log(c.blue(`${e} PackageId: ${s.packageId}`)),g=s.packageId),s.type==="created"&&s.objectType==="0x2::package::UpgradeCap"&&(console.log(c.blue(`${e} UpgradeCap: ${s.objectId}`)),P=s.objectId)}),console.log(c.green(`Publish transaction digest: ${p.digest}`)),console.log("Executing the deployHook: "),await(s=>new Promise(O=>setTimeout(O,s)))(5e3);let a=new L;a.moveCall({target:`${g}::deploy_hook::run`,arguments:[a.object("0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b"),a.object("0x6")]});let C;try{C=await m.signAndExecuteTransaction({signer:f,transaction:a,options:{showEffects:!0,showObjectChanges:!0}})}catch(s){console.error(c.red("Failed to execute deployHook, please republish or manually call deploy_hook::run")),console.error(s.message),process.exit(1)}C.effects?.status.status==="success"?(console.log(c.green(`Successful auto-execution of deployHook, please check the transaction digest: ${C.digest}`)),C.objectChanges?.map(s=>{s.type==="created"&&s.objectType.includes("schema")&&(console.log(c.blue(`${e} Schema Object id: ${s.objectId}`)),console.log(c.blue(`${e} Schema Object type: ${s.objectType}`)),w.push({name:s.objectType,objectId:s.objectId}))}),R(e,t,g,w,P,v)):console.log(c.yellow("Failed to execute deployHook, please republish or manually call deploy_hook::run"))}import{Obelisk as ve}from"@0xobelisk/sui-client";import{Transaction as z,UpgradePolicy as Ce}from"@mysten/sui/transactions";import{getFullnodeUrl as Oe,SuiClient as Ee}from"@mysten/sui/client";import{execSync as Ie}from"child_process";import y from"chalk";async function X(e,t,o){let l=process.cwd(),r=`${l}/contracts/${e}`,d=process.env.PRIVATE_KEY;if(!d)throw new i(`Missing PRIVATE_KEY environment variable.
8
- Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
9
- in your contracts directory to use the default sui private key.`);let u=I(d);if(u===!1)throw new i("Please check your privateKey.");let m=new ve({secretKey:u}).getKeypair(),x=new Ee({url:Oe(t)}),h=Number(await J(r,t)),b=await W(r,t),_=await getWorldId(r,t),p=await q(r,t),v=await getAdminCap(r,t),g=h+1;await Y(r,g.toString());try{let w,P,A;try{let{modules:n,dependencies:F,digest:le}=JSON.parse(Ie(`sui move build --dump-bytecode-as-base64 --path ${l}/contracts/${e}`,{encoding:"utf-8"}));w=n,P=F,A=le}catch(n){throw new M(n.stdout)}let a=new z,C=a.moveCall({target:"0x2::package::authorize_upgrade",arguments:[a.object(p),a.pure.u8(Ce.COMPATIBLE),a.pure.vector("u8",A)]}),s=a.upgrade({modules:w,dependencies:P,package:b,ticket:C});a.moveCall({target:"0x2::package::commit_upgrade",arguments:[a.object(p),s]}),a.transferObjects([a.object(p)],m.toSuiAddress());let O=await x.signAndExecuteTransaction({signer:m,transaction:a,options:{showObjectChanges:!0}});console.log(""),console.log(`${e} WorldId: ${_}`);let $="",K="";O.objectChanges.map(n=>{n.type==="published"&&(console.log(y.blue(`${e} PackageId: ${n.packageId}`)),$=n.packageId),n.type==="mutated"&&n.objectType==="0x2::package::UpgradeCap"&&(console.log(y.blue(`${e} UpgradeCap: ${n.objectId}`)),K=n.objectId)}),console.log(y.green(`Upgrade Transaction Digest: ${O.digest}`)),R(e,t,$,_,K,v,g),b=$,p=K,h=g,console.log(`
10
- Executing the migrate: `),await(n=>new Promise(F=>setTimeout(F,n)))(5e3);let k=new z;k.moveCall({target:`${$}::migrate::run`,arguments:[k.object(_),k.object(v)]});let j=(await x.getObject({id:_,options:{showContent:!0,showDisplay:!0,showType:!0,showOwner:!0}})).data.content,B=o.filter(n=>!j.fields.schema_names.includes(n));console.log("new schema:",B);let V=[];for(let n of B)k.moveCall({target:`${$}::${n}_schema::register`,arguments:[k.object(_),k.object(v)]}),V.push(`${n}_schema`);(await x.signAndExecuteTransaction({signer:m,transaction:k,options:{showEffects:!0}})).effects?.status.status==="success"?(console.log(y.green(`${e} migrate world success, new world version is: ${j.fields.version}, package version is ${g}`)),V.length!==0&&console.log(y.green(`new schema: ${V.toString()} register success.`)),console.log(y.blue(`
11
- ${e} world schemas is ${j.fields.schema_names}`))):console.log(y.red(`${e} migrate world failed, world version is: ${j.fields.version}, package version is ${g}`))}catch(w){console.log(y.red("Upgrade failed!")),console.error(w.message),R(e,t,b,_,p,v,h),await Y(r,h.toString())}}import Pe from"chalk";function Q(){console.log(Pe.yellow(`
7
+ in your contracts directory to use the default sui private key.`);let l=k(c);if(l===!1)throw new i("Please check your privateKey.");let d=new ie({secretKey:l}).getKeypair(),E=new le({url:ce(o)}),P,I;try{let{modules:n,dependencies:S}=JSON.parse(de(`sui move build --dump-bytecode-as-base64 --path ${u}`,{encoding:"utf-8"}));P=n,I=S}catch(n){console.error(a.red("Error executing sui move build:")),console.error(n.stdout),process.exit(1)}console.log(a.blue(`Account: ${d.toSuiAddress()}`));let w=new F,[J]=w.publish({modules:P,dependencies:I});w.transferObjects([J],d.toSuiAddress());let g;try{g=await E.signAndExecuteTransaction({signer:d,transaction:w,options:{showObjectChanges:!0}})}catch(n){console.error(a.red("Failed to execute publish, please republish")),console.error(n.message),process.exit(1)}g.effects?.status.status==="failure"&&(console.log(a.red("Failed to execute publish, please republish")),process.exit(1));let G=1,v="",R=[],$="";g.objectChanges.map(n=>{n.type==="published"&&(console.log(a.blue(`${e} PackageId: ${n.packageId}`)),v=n.packageId),n.type==="created"&&n.objectType==="0x2::package::UpgradeCap"&&(console.log(a.blue(`${e} UpgradeCap: ${n.objectId}`)),$=n.objectId)}),console.log(a.green(`Publish transaction digest: ${g.digest}`)),console.log("Executing the deployHook: "),await(n=>new Promise(S=>setTimeout(S,n)))(5e3);let f=new F;f.moveCall({target:`${v}::deploy_hook::run`,arguments:[f.object(t),f.object("0x6")]});let _;try{_=await E.signAndExecuteTransaction({signer:d,transaction:f,options:{showEffects:!0,showObjectChanges:!0}})}catch(n){console.error(a.red("Failed to execute deployHook, please republish or manually call deploy_hook::run")),console.error(n.message),process.exit(1)}_.effects?.status.status==="success"?(console.log(a.green(`Successful auto-execution of deployHook, please check the transaction digest: ${_.digest}`)),_.objectChanges?.map(n=>{n.type==="created"&&n.objectType.includes("schema")&&(console.log(a.blue(`${e} Schema Object id: ${n.objectId}`)),console.log(a.blue(`${e} Schema Object type: ${n.objectType}`)),R.push({name:n.objectType,objectId:n.objectId}))}),M(e,o,v,R,$,G)):console.log(a.yellow("Failed to execute deployHook, please republish or manually call deploy_hook::run"))}import ue from"chalk";function A(){console.log(ue.yellow(`
12
8
  Welcome to obelisk world
13
9
  --from team@obelisk
14
10
  ________ ________ _______ ___ ___ ________ ___ __
@@ -21,7 +17,7 @@ Welcome to obelisk world
21
17
  \\|_________|
22
18
 
23
19
 
24
- `))}var Me={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:t}){let o="";if(t===void 0){let d=process.env.PRIVATE_KEY;if(!d)throw new i(`Missing PRIVATE_KEY environment variable.
20
+ `))}var me={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:!0})},async handler(e){let{action:o,background:t}=e;try{switch(o){case"start":await h(t);break;case"stop":await b();break;case"status":await C();break;case"restart":await ge(t);break}}catch(s){console.error("Error executing command:",s),process.exit(1)}}};async function ge(e){console.log("Restarting local Sui node..."),await b(),await h(e),console.log("Local node has been restarted")}var L=me;import{Obelisk as fe}from"@0xobelisk/sui-client";import{requestSuiFromFaucetV0 as _e,getFaucetHost as ye}from"@mysten/sui/faucet";import{SuiClient as he,getFullnodeUrl as be}from"@mysten/sui/client";var ke={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 c=process.env.PRIVATE_KEY;if(!c)throw new i(`Missing PRIVATE_KEY environment variable.
25
21
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
26
- in your contracts directory to use the default sui private key.`);let u=I(d);if(u===!1)throw new i("Please check your privateKey.");o=new $e({secretKey:u}).getKeypair().toSuiAddress()}else o=t;await Te({host:Se(e),recipient:o});let l=new Re({url:je(e)}),r={owner:o};console.log(`Account: ${o}`),console.log(await l.getBalance(r)),process.exit(0)}},ee=Me;import{worldgen as Ae,loadConfig as Ke}from"@0xobelisk/sui-common";import Ve from"chalk";var Fe={command:"schemagen",describe:"Autogenerate Obelisk schemas based on the config file",builder(e){return e.options({configPath:{type:"string",default:"obelisk.config.ts",desc:"Path to the config file"}})},async handler({configPath:e}){try{let t=await Ke(e);await Ae(t),process.exit(0)}catch(t){console.log(Ve.red("Schemagen failed!")),console.error(t.message)}}},te=Fe;import{loadConfig as Ue}from"@0xobelisk/sui-common";var De={command:"publish",describe:"Publish obelisk move contracts",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Network of the node (mainnet/testnet/devnet/localnet)"},configPath:{type:"string",default:"obelisk.config.ts",decs:"Path to the config file"}})},async handler({network:e,configPath:t}){try{let o=await Ue(t);await Z(o.name,e)}catch(o){E(o),process.exit(1)}process.exit(0)}},oe=De;import{loadConfig as Ye}from"@0xobelisk/sui-common";var Ne={command:"upgrade",describe:"Upgrade your move contracts",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Network of the node (mainnet/testnet/devnet/localnet)"},configPath:{type:"string",default:"obelisk.config.ts",decs:"Path to the config file"}})},async handler({network:e,configPath:t}){try{let o=await Ye(t),l=Object.keys(o.schemas).filter(r=>!(typeof o.schemas=="object"&&"ephemeral"in o.schemas&&o.schemas[r].ephemeral));await X(o.name,e,l)}catch(o){E(o),process.exit(1)}process.exit(0)}},se=Ne;import{execSync as Be}from"child_process";import He from"chalk";var Je={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{Be(`sui move test --path ${e}`,{encoding:"utf-8"})}catch(t){console.error(He.red("Error executing sui move test:")),console.log(t.stdout),process.exit(0)}}},re=Je;var We={command:"hello",describe:"hello, obelisk",builder(e){return e},async handler(){Q()}},ne=We;var ae=[oe,H,ee,te,se,re,ne];import*as ce from"dotenv";import ie from"chalk";ce.config();qe(Ge(process.argv)).scriptName("obelisk").command(ae).strict().fail((e,t)=>{console.error(ie.red(e)),e.includes("Missing required argument")&&console.log(ie.yellow(`Run 'pnpm obelisk ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),E(t),console.log(""),process.exit(1)}).alias({h:"help"}).argv;
22
+ in your contracts directory to use the default sui private key.`);let l=k(c);if(l===!1)throw new i("Please check your privateKey.");t=new fe({secretKey:l}).getKeypair().toSuiAddress()}else t=o;await _e({host:ye(e),recipient:t});let s=new he({url:be(e)}),u={owner:t};console.log(`Account: ${t}`),console.log(await s.getBalance(u)),process.exit(0)}},K=ke;import{schemaGen as xe,loadConfig as we}from"@0xobelisk/sui-common";import ve from"chalk";var Se={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 we(e);await xe(s,void 0,o,t),process.exit(0)}catch(s){console.log(ve.red("Schemagen failed!")),console.error(s.message)}}},j=Se;import{loadConfig as Oe}from"@0xobelisk/sui-common";var Ce={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 Oe(o);await N(s.name,e,t)}catch(s){y(s),process.exit(1)}process.exit(0)}},D=Ce;import{execSync as Ee}from"child_process";import Pe from"chalk";var Ie={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{Ee(`sui move test --path ${e}`,{encoding:"utf-8"})}catch(o){console.error(Pe.red("Error executing sui move test:")),console.log(o.stdout),process.exit(0)}}},U=Ie;var Re={command:"hello",describe:"hello, obelisk",builder(e){return e},async handler(){A()}},V=Re;var B=[D,L,K,j,U,V];import*as H from"dotenv";import Y from"chalk";H.config();$e(Te(process.argv)).scriptName("obelisk").command(B).strict().fail((e,o)=>{console.error(Y.red(e)),e.includes("Missing required argument")&&console.log(Y.yellow(`Run 'pnpm obelisk ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),y(o),console.log(""),process.exit(1)}).alias({h:"help"}).argv;
27
23
  //# sourceMappingURL=obelisk.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/obelisk.ts","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/utils/publishHandler.ts","../src/utils/errors.ts","../src/utils/utils.ts","../src/utils/upgradeHandler.ts","../src/utils/printObelisk.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/commands/upgrade.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 type { CommandModule } from \"yargs\";\nimport { execa } from \"execa\";\n\nconst commandModule: CommandModule = {\n command: \"localnode\",\n\n describe: \"Start a local Sui node for development\",\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n console.log(\"Clearing localnode history\");\n\n console.log(`Running: sui-test-validator`);\n const child = execa(\"sui-test-validator\");\n\n process.on(\"SIGINT\", () => {\n console.log(\"\\ngracefully shutting down from SIGINT (Crtl-C)\");\n child.kill();\n process.exit();\n });\n await child;\n },\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 { 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, schema,\n} from './utils';\nimport {log} from \"node:util\";\n\nexport async function publishHandler(\n\tname: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n\tconst path = process.cwd();\n\tconst projectPath = `${path}/contracts/${name}`;\n\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(\n\t\t[upgradeCap],\n\t\tkeypair.toSuiAddress()\n\t);\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(\"0xa66942c08d9fc318a70ab9d0cfd7e75f1a2dd1ac31aff12fde008d25bfa9604b\"),\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' && object.objectType.includes(\"schema\")\n\t\t\t) {\n\t\t\t\tconsole.log(chalk.blue(`${name} Schema Object id: ${object.objectId}`));\n\t\t\t\tconsole.log(chalk.blue(`${name} Schema Object type: ${object.objectType}`));\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';\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))?.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 { Obelisk } from '@0xobelisk/sui-client';\nimport { Transaction, UpgradePolicy } from '@mysten/sui/transactions';\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui/client';\nimport { execSync } from 'child_process';\nimport chalk from 'chalk';\nimport { ObeliskCliError, UpgradeError } from './errors';\nimport {\n\tupdateVersionInFile,\n\tgetOldPackageId,\n\tgetVersion,\n\tgetUpgradeCap,\n\tsaveContractData,\n\tvalidatePrivateKey,\n} from './utils';\n\ntype ObjectContent = {\n\ttype: string;\n\tfields: Record<string, any>;\n\thasPublicTransfer: boolean;\n\tdataType: string;\n};\n\nexport async function upgradeHandler(\n\tname: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tschemaNames: string[]\n) {\n\tconst path = process.cwd();\n\tconst projectPath = `${path}/contracts/${name}`;\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 oldVersion = Number(await getVersion(projectPath, network));\n\tlet oldPackageId = await getOldPackageId(projectPath, network);\n\tlet worldId = await getWorldId(projectPath, network);\n\tlet upgradeCap = await getUpgradeCap(projectPath, network);\n\tlet adminCap = await getAdminCap(projectPath, network);\n\n\tconst newVersion = oldVersion + 1;\n\tawait updateVersionInFile(projectPath, newVersion.toString());\n\n\ttry {\n\t\tlet modules: any, dependencies: any, digest: any;\n\t\ttry {\n\t\t\tconst {\n\t\t\t\tmodules: extractedModules,\n\t\t\t\tdependencies: extractedDependencies,\n\t\t\t\tdigest: extractedDigest,\n\t\t\t} = JSON.parse(\n\t\t\t\texecSync(\n\t\t\t\t\t`sui move build --dump-bytecode-as-base64 --path ${path}/contracts/${name}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tencoding: 'utf-8',\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tmodules = extractedModules;\n\t\t\tdependencies = extractedDependencies;\n\t\t\tdigest = extractedDigest;\n\t\t} catch (error: any) {\n\t\t\tthrow new UpgradeError(error.stdout);\n\t\t}\n\n\t\tconst tx = new Transaction();\n\t\tconst ticket = tx.moveCall({\n\t\t\ttarget: '0x2::package::authorize_upgrade',\n\t\t\targuments: [\n\t\t\t\ttx.object(upgradeCap),\n\t\t\t\ttx.pure.u8(UpgradePolicy.COMPATIBLE),\n\t\t\t\ttx.pure.vector('u8', digest),\n\t\t\t],\n\t\t});\n\n\t\tconst receipt = tx.upgrade({\n\t\t\tmodules,\n\t\t\tdependencies,\n\t\t\tpackage: oldPackageId,\n\t\t\tticket,\n\t\t});\n\n\t\ttx.moveCall({\n\t\t\ttarget: '0x2::package::commit_upgrade',\n\t\t\targuments: [tx.object(upgradeCap), receipt],\n\t\t});\n\n\t\ttx.transferObjects(\n\t\t\t[tx.object(upgradeCap)],\n\t\t\tkeypair.toSuiAddress()\n\t\t);\n\n\t\tconst result = 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\n\t\tconsole.log('');\n\t\tconsole.log(`${name} WorldId: ${worldId}`);\n\n\t\tlet newPackageId = '';\n\t\tlet newUpgradeCap = '';\n\t\tresult.objectChanges!.map(object => {\n\t\t\tif (object.type === 'published') {\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.blue(`${name} PackageId: ${object.packageId}`)\n\t\t\t\t);\n\t\t\t\tnewPackageId = object.packageId;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tobject.type === 'mutated' &&\n\t\t\t\tobject.objectType === '0x2::package::UpgradeCap'\n\t\t\t) {\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.blue(`${name} UpgradeCap: ${object.objectId}`)\n\t\t\t\t);\n\t\t\t\tnewUpgradeCap = object.objectId;\n\t\t\t}\n\t\t});\n\n\t\tconsole.log(\n\t\t\tchalk.green(`Upgrade Transaction Digest: ${result.digest}`)\n\t\t);\n\n\t\tsaveContractData(\n\t\t\tname,\n\t\t\tnetwork,\n\t\t\tnewPackageId,\n\t\t\tworldId,\n\t\t\tnewUpgradeCap,\n\t\t\tadminCap,\n\t\t\tnewVersion\n\t\t);\n\n\t\toldPackageId = newPackageId;\n\t\tupgradeCap = newUpgradeCap;\n\t\toldVersion = newVersion;\n\n\t\tconsole.log('\\nExecuting the migrate: ');\n\t\tconst delay = (ms: number) =>\n\t\t\tnew Promise(resolve => setTimeout(resolve, ms));\n\t\tawait delay(5000);\n\n\t\tconst migrateTx = new Transaction();\n\t\tmigrateTx.moveCall({\n\t\t\ttarget: `${newPackageId}::migrate::run`,\n\t\t\targuments: [migrateTx.object(worldId), migrateTx.object(adminCap)],\n\t\t});\n\n\t\tlet newWorldObject = await client.getObject({\n\t\t\tid: worldId,\n\t\t\toptions: {\n\t\t\t\tshowContent: true,\n\t\t\t\tshowDisplay: true,\n\t\t\t\tshowType: true,\n\t\t\t\tshowOwner: true,\n\t\t\t},\n\t\t});\n\t\tlet newObjectContent = newWorldObject.data!.content as ObjectContent;\n\n\t\tconst uniqueSchema: string[] = schemaNames.filter(\n\t\t\titem => !newObjectContent.fields['schema_names'].includes(item)\n\t\t);\n\n\t\tconsole.log('new schema:', uniqueSchema);\n\t\tlet needRegisterSchema = [];\n\t\tfor (const newSchema of uniqueSchema) {\n\t\t\tmigrateTx.moveCall({\n\t\t\t\ttarget: `${newPackageId}::${newSchema}_schema::register`,\n\t\t\t\targuments: [\n\t\t\t\t\tmigrateTx.object(worldId),\n\t\t\t\t\tmigrateTx.object(adminCap),\n\t\t\t\t],\n\t\t\t});\n\t\t\tneedRegisterSchema.push(`${newSchema}_schema`);\n\t\t}\n\t\tconst migrateResult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: migrateTx,\n\t\t\toptions: {\n\t\t\t\tshowEffects: true,\n\t\t\t},\n\t\t});\n\n\t\tif (migrateResult.effects?.status.status === 'success') {\n\t\t\tconsole.log(\n\t\t\t\tchalk.green(\n\t\t\t\t\t`${name} migrate world success, new world version is: ${newObjectContent.fields['version']}, package version is ${newVersion}`\n\t\t\t\t)\n\t\t\t);\n\t\t\tif (needRegisterSchema.length !== 0) {\n\t\t\t\tconsole.log(\n\t\t\t\t\tchalk.green(\n\t\t\t\t\t\t`new schema: ${needRegisterSchema.toString()} register success.`\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\tchalk.blue(\n\t\t\t\t\t`\\n${name} world schemas is ${newObjectContent.fields['schema_names']}`\n\t\t\t\t)\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.log(\n\t\t\t\tchalk.red(\n\t\t\t\t\t`${name} migrate world failed, world version is: ${newObjectContent.fields['version']}, package version is ${newVersion}`\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} catch (error: any) {\n\t\tconsole.log(chalk.red('Upgrade failed!'));\n\t\tconsole.error(error.message);\n\n\t\tsaveContractData(\n\t\t\tname,\n\t\t\tnetwork,\n\t\t\toldPackageId,\n\t\t\tworldId,\n\t\t\tupgradeCap,\n\t\t\tadminCap,\n\t\t\toldVersion\n\t\t);\n\t\tawait updateVersionInFile(projectPath, oldVersion.toString());\n\t}\n}\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 { worldgen, loadConfig, ObeliskConfig } from \"@0xobelisk/sui-common\";\nimport chalk from \"chalk\";\n\ntype Options = {\n configPath?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"schemagen\",\n\n describe: \"Autogenerate Obelisk schemas based on the config file\",\n\n builder(yargs) {\n return yargs.options({\n configPath: {\n type: \"string\",\n default: \"obelisk.config.ts\",\n desc: \"Path to the config file\"\n },\n });\n },\n\n async handler({ configPath }) {\n try {\n const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;\n await worldgen(obeliskConfig);\n process.exit(0);\n } catch (error: any) {\n console.log(chalk.red(\"Schemagen failed!\"));\n console.error(error.message);\n }\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { logError } from \"../utils/errors\";\nimport { publishHandler } from \"../utils\";\nimport { loadConfig, ObeliskConfig } from \"@0xobelisk/sui-common\";\n\ntype Options = {\n network: any;\n configPath: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"publish\",\n\n describe: \"Publish obelisk move contracts\",\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: \"string\",\n choices: [\"mainnet\", \"testnet\", \"devnet\", \"localnet\"],\n desc: \"Network of the node (mainnet/testnet/devnet/localnet)\",\n },\n configPath: {\n type: \"string\",\n default: \"obelisk.config.ts\",\n decs: \"Path to the config file\",\n },\n });\n },\n\n async handler({ network, configPath }) {\n try {\n const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;\n await publishHandler(obeliskConfig.name, network);\n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { logError } from \"../utils/errors\";\nimport { upgradeHandler } from \"../utils\";\nimport { ObeliskConfig, loadConfig, ValueType } from \"@0xobelisk/sui-common\";\n\ntype Options = {\n network: any;\n configPath: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"upgrade\",\n\n describe: \"Upgrade your move contracts\",\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: \"string\",\n choices: [\"mainnet\", \"testnet\", \"devnet\", \"localnet\"],\n desc: \"Network of the node (mainnet/testnet/devnet/localnet)\",\n },\n configPath: {\n type: \"string\",\n default: \"obelisk.config.ts\",\n decs: \"Path to the config file\",\n },\n });\n },\n\n async handler({ network, configPath }) {\n try {\n const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;\n\n let schemaNames = Object.keys(obeliskConfig.schemas).filter(\n (key) =>\n !(\n typeof obeliskConfig.schemas === \"object\" &&\n \"ephemeral\" in obeliskConfig.schemas &&\n (obeliskConfig.schemas[key] as ValueType).ephemeral\n )\n );\n\n await upgradeHandler(obeliskConfig.name, network, schemaNames);\n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { execSync } from \"child_process\";\nimport 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\";\nimport 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 publish,\n localnode,\n faucet,\n schemagen,\n upgrade,\n test,\n hello,\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBCFxB,OAA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,QAAQ,CAAE,YAAAC,CAAY,EAAG,CAE7B,GAAI,CACFJ,GAAS,wBAAwBI,IAAe,CAC9C,SAAU,OACZ,CAAC,CACH,OAASC,EAAP,CACA,QAAQ,MAAMJ,GAAM,IAAI,gCAAgC,CAAC,EACzD,QAAQ,IAAII,EAAM,MAAM,EACxB,QAAQ,KAAK,CAAC,CAChB,CACF,CACF,EAEOC,GAAQJ,GClCf,IAAMK,GAA+B,CACnC,QAAS,QAET,SAAU,iBAEV,QAAQC,EAAO,CACb,OAAOA,CACT,EAEA,MAAM,SAAU,CACdC,EAAa,CACf,CACF,EAEOC,GAAQH,GCNR,IAAMI,GAAsC,CACjDC,GACAC,EACAC,GACAC,GACAC,GACAC,GACAC,EACF,EbXA,UAAYC,OAAY,SACxB,OAAOC,OAAW,QACX,UAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,SAAS,EAGpB,QAAQC,EAAe,EAEvB,OAAO,EAEP,KAAK,CAACC,EAAKC,IAAQ,CAClB,QAAQ,MAAML,GAAM,IAAII,CAAG,CAAC,EACxBA,EAAI,SAAS,2BAA2B,GAC1C,QAAQ,IACNJ,GAAM,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","execa","commandModule","yargs","child","localnode_default","Obelisk","requestSuiFromFaucetV0","getFaucetHost","SuiClient","getFullnodeUrl","Obelisk","Transaction","getFullnodeUrl","SuiClient","execSync","chalk","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","ObeliskCliError","UpgradeError","FsIibError","logError","error","validationError","fsAsync","mkdirSync","writeFileSync","dirname","SUI_PRIVATE_KEY_PREFIX","validatePrivateKey","privateKey","SUI_PRIVATE_KEY_PREFIX","strippedPrivateKey","updateVersionInFile","projectPath","newVersion","filePath","updatedData","writeOutput","FsIibError","getDeploymentJson","network","data","getVersion","getOldPackageId","projectPath","network","getDeploymentJson","getUpgradeCap","saveContractData","projectName","network","packageId","schemas","upgradeCap","version","DeploymentData","path","storeDeploymentData","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","publishHandler","name","network","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","Obelisk","Transaction","UpgradePolicy","getFullnodeUrl","SuiClient","execSync","chalk","upgradeHandler","name","network","schemaNames","path","projectPath","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","keypair","Obelisk","client","SuiClient","getFullnodeUrl","oldVersion","getVersion","oldPackageId","getOldPackageId","worldId","upgradeCap","getUpgradeCap","adminCap","newVersion","updateVersionInFile","modules","dependencies","digest","extractedModules","extractedDependencies","extractedDigest","execSync","error","UpgradeError","tx","Transaction","ticket","UpgradePolicy","receipt","result","newPackageId","newUpgradeCap","object","chalk","saveContractData","ms","resolve","migrateTx","newObjectContent","uniqueSchema","item","needRegisterSchema","newSchema","chalk","printObelisk","commandModule","yargs","network","recipient","faucet_address","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","Obelisk","requestSuiFromFaucetV0","getFaucetHost","client","SuiClient","getFullnodeUrl","params","faucet_default","worldgen","loadConfig","chalk","commandModule","yargs","configPath","obeliskConfig","error","schemagen_default","loadConfig","commandModule","yargs","network","configPath","obeliskConfig","publishHandler","error","logError","publish_default","loadConfig","commandModule","yargs","network","configPath","obeliskConfig","schemaNames","key","upgradeHandler","error","logError","upgrade_default","execSync","chalk","commandModule","yargs","packagePath","error","test_default","commandModule","yargs","printObelisk","hello_default","commands","publish_default","localnode_default","faucet_default","schemagen_default","upgrade_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\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,MAAW,QCRlB,OAAOC,MAAW,QAClB,OAAS,YAAAC,MAAgB,MACzB,OAAS,gBAAAC,EAAc,mBAAAC,MAAuB,uBAEvC,IAAMC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AU,OAAgB,gBACzB,OAAOC,OAAW,QAMlB,IAAMC,GAAiD,CACrD,QAAS,OAET,SAAU,iCAEV,QAAQC,EAAO,CACb,OAAOA,EAAM,QAAQ,CACnB,YAAa,CACX,KAAM,SACN,QAAS,IACT,YAAa,+BACf,CACF,CAAC,CACH,EAEA,MAAM,QAAQ,CAAE,YAAAC,CAAY,EAAG,CAE7B,GAAI,CACFJ,GAAS,wBAAwBI,IAAe,CAC9C,SAAU,OACZ,CAAC,CACH,OAASC,EAAP,CACA,QAAQ,MAAMJ,GAAM,IAAI,gCAAgC,CAAC,EACzD,QAAQ,IAAII,EAAM,MAAM,EACxB,QAAQ,KAAK,CAAC,CAChB,CACF,CACF,EAEOC,EAAQJ,GClCf,IAAMK,GAA+B,CACnC,QAAS,QAET,SAAU,iBAEV,QAAQC,EAAO,CACb,OAAOA,CACT,EAEA,MAAM,SAAU,CACdC,EAAa,CACf,CACF,EAEOC,EAAQH,GCNR,IAAMI,EAAsC,CAClDC,EACAC,EACAC,EACAC,EAEAC,EACAC,CACD,EdXA,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","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xobelisk/sui-cli",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "description": "Tookit for interacting with move eps framework",
5
5
  "keywords": [
6
6
  "sui",
@@ -31,8 +31,8 @@
31
31
  "obelisk": "./dist/obelisk.js"
32
32
  },
33
33
  "dependencies": {
34
- "@0xobelisk/sui-client": "^0.5.23",
35
- "@0xobelisk/sui-common": "^0.5.15",
34
+ "@0xobelisk/sui-client": "^0.5.24",
35
+ "@0xobelisk/sui-common": "^0.5.16",
36
36
  "@mysten/sui": "^1.7.0",
37
37
  "chalk": "^5.0.1",
38
38
  "child_process": "^1.0.2",
@@ -1,20 +1,20 @@
1
- import { CommandModule } from "yargs";
1
+ import { CommandModule } from 'yargs';
2
2
 
3
- import localnode from "./localnode";
4
- import faucet from "./faucet";
5
- import schemagen from "./schemagen";
6
- import publish from "./publish";
7
- import upgrade from "./upgrade";
8
- import test from "./test";
9
- import hello from "./hello";
3
+ import localnode from './localnode';
4
+ import faucet from './faucet';
5
+ import schemagen from './schemagen';
6
+ import publish from './publish';
7
+ // import upgrade from "./upgrade";
8
+ import test from './test';
9
+ import hello from './hello';
10
10
 
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options
12
12
  export const commands: CommandModule<any, any>[] = [
13
- publish,
14
- localnode,
15
- faucet,
16
- schemagen,
17
- upgrade,
18
- test,
19
- hello,
13
+ publish,
14
+ localnode,
15
+ faucet,
16
+ schemagen,
17
+ // upgrade,
18
+ test,
19
+ hello,
20
20
  ];
@@ -1,28 +1,57 @@
1
- import type { CommandModule } from "yargs";
2
- import { execa } from "execa";
1
+ import type { CommandModule } from 'yargs';
2
+ import { startLocalnode, stopLocalnode, checkLocalNodeStatus } from '../utils';
3
3
 
4
4
  const commandModule: CommandModule = {
5
- command: "localnode",
5
+ command: 'localnode <action>',
6
6
 
7
- describe: "Start a local Sui node for development",
7
+ describe: 'Manage local Sui node',
8
8
 
9
- builder(yargs) {
10
- return yargs;
11
- },
9
+ builder(yargs) {
10
+ return yargs
11
+ .positional('action', {
12
+ describe: 'Action to perform',
13
+ choices: ['start', 'stop', 'status', 'restart'],
14
+ type: 'string',
15
+ demandOption: true,
16
+ })
17
+ .option('background', {
18
+ alias: 'b',
19
+ type: 'boolean',
20
+ description: 'Run node in background',
21
+ default: true,
22
+ });
23
+ },
12
24
 
13
- async handler() {
14
- console.log("Clearing localnode history");
25
+ async handler(argv) {
26
+ const { action, background } = argv;
15
27
 
16
- console.log(`Running: sui-test-validator`);
17
- const child = execa("sui-test-validator");
18
-
19
- process.on("SIGINT", () => {
20
- console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
21
- child.kill();
22
- process.exit();
23
- });
24
- await child;
25
- },
28
+ try {
29
+ switch (action) {
30
+ case 'start':
31
+ await startLocalnode(background as boolean);
32
+ break;
33
+ case 'stop':
34
+ await stopLocalnode();
35
+ break;
36
+ case 'status':
37
+ await checkLocalNodeStatus();
38
+ break;
39
+ case 'restart':
40
+ await restartNode(background as boolean);
41
+ break;
42
+ }
43
+ } catch (error) {
44
+ console.error('Error executing command:', error);
45
+ process.exit(1);
46
+ }
47
+ },
26
48
  };
27
49
 
50
+ async function restartNode(background: boolean) {
51
+ console.log('Restarting local Sui node...');
52
+ await stopLocalnode();
53
+ await startLocalnode(background);
54
+ console.log('Local node has been restarted');
55
+ }
56
+
28
57
  export default commandModule;
@@ -1,43 +1,50 @@
1
- import type { CommandModule } from "yargs";
2
- import { logError } from "../utils/errors";
3
- import { publishHandler } from "../utils";
4
- import { loadConfig, ObeliskConfig } from "@0xobelisk/sui-common";
1
+ import type { CommandModule } from 'yargs';
2
+ import { logError } from '../utils/errors';
3
+ import { publishHandler } from '../utils';
4
+ import { loadConfig, ObeliskConfig } from '@0xobelisk/sui-common';
5
5
 
6
6
  type Options = {
7
- network: any;
8
- configPath: string;
7
+ network: any;
8
+ configPath: string;
9
+ dappsObjectId?: string;
9
10
  };
10
11
 
11
12
  const commandModule: CommandModule<Options, Options> = {
12
- command: "publish",
13
+ command: 'publish',
13
14
 
14
- describe: "Publish obelisk move contracts",
15
+ describe: 'Publish obelisk move contract',
15
16
 
16
- builder(yargs) {
17
- return yargs.options({
18
- network: {
19
- type: "string",
20
- choices: ["mainnet", "testnet", "devnet", "localnet"],
21
- desc: "Network of the node (mainnet/testnet/devnet/localnet)",
22
- },
23
- configPath: {
24
- type: "string",
25
- default: "obelisk.config.ts",
26
- decs: "Path to the config file",
27
- },
28
- });
29
- },
17
+ builder(yargs) {
18
+ return yargs.options({
19
+ network: {
20
+ type: 'string',
21
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
22
+ desc: 'Node network (mainnet/testnet/devnet/localnet)',
23
+ },
24
+ configPath: {
25
+ type: 'string',
26
+ default: 'obelisk.config.ts',
27
+ desc: 'Configuration file path',
28
+ },
29
+ dappsObjectId: {
30
+ type: 'string',
31
+ desc: 'Optional dappsObjectId',
32
+ },
33
+ });
34
+ },
30
35
 
31
- async handler({ network, configPath }) {
32
- try {
33
- const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;
34
- await publishHandler(obeliskConfig.name, network);
35
- } catch (error: any) {
36
- logError(error);
37
- process.exit(1);
38
- }
39
- process.exit(0);
40
- },
36
+ async handler({ network, configPath, dappsObjectId }) {
37
+ try {
38
+ const obeliskConfig = (await loadConfig(
39
+ configPath
40
+ )) as ObeliskConfig;
41
+ await publishHandler(obeliskConfig.name, network, dappsObjectId);
42
+ } catch (error: any) {
43
+ logError(error);
44
+ process.exit(1);
45
+ }
46
+ process.exit(0);
47
+ },
41
48
  };
42
49
 
43
50
  export default commandModule;
@@ -1,36 +1,47 @@
1
- import type { CommandModule } from "yargs";
2
- import { worldgen, loadConfig, ObeliskConfig } from "@0xobelisk/sui-common";
3
- import chalk from "chalk";
1
+ import type { CommandModule } from 'yargs';
2
+ import { schemaGen, loadConfig, ObeliskConfig } from '@0xobelisk/sui-common';
3
+ import chalk from 'chalk';
4
4
 
5
5
  type Options = {
6
- configPath?: string;
6
+ configPath?: string;
7
+ network?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
8
+ frameworkId?: string;
7
9
  };
8
10
 
9
11
  const commandModule: CommandModule<Options, Options> = {
10
- command: "schemagen",
12
+ command: 'schemagen',
11
13
 
12
- describe: "Autogenerate Obelisk schemas based on the config file",
14
+ describe: 'Autogenerate Obelisk schemas based on the config file',
13
15
 
14
- builder(yargs) {
15
- return yargs.options({
16
- configPath: {
17
- type: "string",
18
- default: "obelisk.config.ts",
19
- desc: "Path to the config file"
20
- },
21
- });
22
- },
16
+ builder: {
17
+ configPath: {
18
+ type: 'string',
19
+ default: 'obelisk.config.ts',
20
+ desc: 'Path to the config file',
21
+ },
22
+ network: {
23
+ type: 'string',
24
+ choices: ['mainnet', 'testnet', 'devnet', 'localnet'] as const,
25
+ desc: 'Node network (mainnet/testnet/devnet/localnet)',
26
+ },
27
+ frameworkId: {
28
+ type: 'string',
29
+ desc: 'Framework Package ID',
30
+ },
31
+ },
23
32
 
24
- async handler({ configPath }) {
25
- try {
26
- const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;
27
- await worldgen(obeliskConfig);
28
- process.exit(0);
29
- } catch (error: any) {
30
- console.log(chalk.red("Schemagen failed!"));
31
- console.error(error.message);
32
- }
33
- },
33
+ async handler({ configPath, network, frameworkId }) {
34
+ try {
35
+ const obeliskConfig = (await loadConfig(
36
+ configPath
37
+ )) as ObeliskConfig;
38
+ await schemaGen(obeliskConfig, undefined, network, frameworkId);
39
+ process.exit(0);
40
+ } catch (error: any) {
41
+ console.log(chalk.red('Schemagen failed!'));
42
+ console.error(error.message);
43
+ }
44
+ },
34
45
  };
35
46
 
36
47
  export default commandModule;