@0xobelisk/sui-cli 1.2.0-pre.76 → 1.2.0-pre.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dubhe.js CHANGED
@@ -12,7 +12,7 @@ Welcome to Dubhe
12
12
 
13
13
  `))}import{Transaction as fe}from"@0xobelisk/sui-client";import{execSync as no}from"child_process";import T from"chalk";import*as ke from"fs/promises";import{mkdirSync as Bt,writeFileSync as Yt}from"fs";import{dirname as Kt}from"path";import{SUI_PRIVATE_KEY_PREFIX as Gt}from"@mysten/sui/cryptography";import ne from"chalk";import{ZodError as Vt}from"zod";import{fromZodError as zt,ValidationError as Wt}from"zod-validation-error";var Ce=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"},R=class extends Error{name="DubheCliError"},ue=class extends Error{name="UpgradeError"};function j(e){if(e instanceof Wt)console.log(ne.redBright(e.message));else if(e instanceof Vt){let t=zt(e,{prefixSeparator:`
14
14
  - `,issueSeparator:`
15
- - `});console.log(ne.redBright(t.message))}else e instanceof Ce?(console.log(ne.red(e.message)),console.log(""),console.log(ne.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof R?console.log(ne.red(e)):console.log(e)}import*as z from"fs";import O from"chalk";import{spawn as Se}from"child_process";import{Dubhe as Jt,loadMetadata as Xt}from"@0xobelisk/sui-client";var U={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.76",description:"Tookit for interacting with move eps framework",keywords:["sui","obelisk labs","move","blockchain"],homepage:"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme",bugs:"https://github.com/0xobelisk/dubhe/issues",repository:{type:"git",url:"https://github.com/0xobelisk/dubhe.git"},license:"Apache-2.0",author:"team@obelisk.build",type:"module",exports:{".":"./dist/index.js"},types:"src/index.ts",bin:{dubhe:"./dist/dubhe.js"},scripts:{build:"pnpm run type-check && pnpm run build:js","build:js":"tsup && chmod +x ./dist/dubhe.js",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch",format:"prettier --write .","format:check":"prettier --check .",lint:"eslint . --ext .ts","type-check":"tsc --noEmit",validate:"pnpm format:check && pnpm type-check"},dependencies:{"@0xobelisk/sui-client":"workspace:*","@0xobelisk/sui-common":"workspace:*","@mysten/sui":"^1.35.0","@types/sqlite3":"^3.1.11","@types/wait-on":"^5.3.4",axios:"^1.10.0",chalk:"^5.0.1",child_process:"^1.0.2",chokidar:"^3.5.3","cli-progress":"^3.12.0","cli-table3":"^0.6.5",dotenv:"^16.0.3",ejs:"^3.1.8",execa:"^7.0.0",glob:"^8.0.3","http-proxy-agent":"^7.0.2","https-proxy-agent":"^7.0.6",inquirer:"^9.2.15",ora:"^5.4.1",path:"^0.12.7",typescript:"^5.8.3","wait-on":"^7.0.1",yargs:"^17.7.1",zod:"^3.22.3","zod-validation-error":"^1.3.0"},devDependencies:{"@types/cli-progress":"^3.11.5","@types/ejs":"^3.1.1","@types/glob":"^7.2.0","@types/inquirer":"^9.0.7","@types/node":"^22.16.0","@types/yargs":"^17.0.10",eslint:"^9.0.0","eslint-config-prettier":"^9.1.0",prettier:"3.3.3","ts-node":"^10.9.1",tsup:"^6.7.0",tsx:"^3.12.6",vitest:"0.31.4"},engines:{node:">=22.0.0"},publishConfig:{access:"public"}};function _e(e){if(e.startsWith(Gt))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 W(e,t){try{let o=await ke.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch(o){throw new Error(`read .history/sui_${t}/latest.json failed. ${o}`)}}async function pe(e,t){try{let o=await ke.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o).dappHub}catch{return""}}async function Z(e){let o=`${process.cwd()}/src/dubhe`;switch(e){case"mainnet":return await pe(o,"mainnet");case"testnet":return await pe(o,"testnet");case"devnet":return await pe(o,"devnet");case"localnet":return await pe(o,"localnet");default:throw new Error(`Invalid network: ${e}`)}}async function Me(e,t){return(await W(e,t)).components}async function Re(e,t){return(await W(e,t)).resources}async function Fe(e,t){return(await W(e,t)).version}async function me(e,t){return(await W(e,t)).packageId}async function je(e,t){return(await W(e,t)).upgradeCap}async function Ue(e,t){return(await W(e,t)).startCheckpoint}async function se(e,t,o,n,s,r,i,l,d,c){let m={projectName:e,network:t,startCheckpoint:o,packageId:n,dappHub:s,upgradeCap:r,version:i,components:l,resources:d,enums:c},p=process.cwd(),y=JSON.stringify(m,null,2);await $e(y,`${p}/src/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function re(e,t,o){let n=process.cwd();try{let s=await Xt(t,o);if(s){let r=JSON.stringify(s,null,2);await $e(r,`${n}/src/${e}/.history/sui_${t}/${o}.json`,"Save package metadata"),await $e(r,`${n}/metadata.json`,"Save latest metadata")}}catch(s){console.warn(O.yellow(`Warning: Failed to save metadata: ${s}`))}}async function $e(e,t,o){Bt(Kt(t),{recursive:!0}),Yt(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function Qt(e){switch(e){case"localnet":return'Dubhe = { local = "../dubhe" }';case"testnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "framework/src/dubhe", rev = "v${U.version}" }`;case"mainnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "framework/src/dubhe", rev = "v${U.version}" }`;default:throw new Error(`Unsupported network: ${e}`)}}async function ge(e,t){let o=z.readFileSync(e,"utf-8"),n=Qt(t),s=o.replace(/Dubhe = \{.*\}/,n);z.writeFileSync(e,s,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function Zt(e){try{let t=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"sui_getLatestCheckpointSequenceNumber",params:[]})});return t.ok?!(await t.json()).error:!1}catch{return!1}}async function eo(e){let t={localnet:"http://127.0.0.1:9000",devnet:"https://fullnode.devnet.sui.io:443/",testnet:"https://fullnode.testnet.sui.io:443/",mainnet:"https://fullnode.mainnet.sui.io:443/"},o=t[e];if(!await Zt(o))throw new Error(`RPC endpoint ${o} is not available. Please check your network connection or try again later.`);return new Promise((s,r)=>{let i="",l="",d=Se("sui",["client","new-env","--alias",e,"--rpc",t[e]],{env:{...process.env},stdio:"pipe"});d.stdout.on("data",c=>{l+=c.toString()}),d.stderr.on("data",c=>{i+=c.toString()}),d.on("error",c=>{console.error(O.red(`
15
+ - `});console.log(ne.redBright(t.message))}else e instanceof Ce?(console.log(ne.red(e.message)),console.log(""),console.log(ne.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof R?console.log(ne.red(e)):console.log(e)}import*as z from"fs";import O from"chalk";import{spawn as Se}from"child_process";import{Dubhe as Jt,loadMetadata as Xt}from"@0xobelisk/sui-client";var U={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.77",description:"Tookit for interacting with move eps framework",keywords:["sui","obelisk labs","move","blockchain"],homepage:"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme",bugs:"https://github.com/0xobelisk/dubhe/issues",repository:{type:"git",url:"https://github.com/0xobelisk/dubhe.git"},license:"Apache-2.0",author:"team@obelisk.build",type:"module",exports:{".":"./dist/index.js"},types:"src/index.ts",bin:{dubhe:"./dist/dubhe.js"},scripts:{build:"pnpm run type-check && pnpm run build:js","build:js":"tsup && chmod +x ./dist/dubhe.js",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch",format:"prettier --write .","format:check":"prettier --check .",lint:"eslint . --ext .ts","type-check":"tsc --noEmit",validate:"pnpm format:check && pnpm type-check"},dependencies:{"@0xobelisk/sui-client":"workspace:*","@0xobelisk/sui-common":"workspace:*","@mysten/sui":"^1.35.0","@types/sqlite3":"^3.1.11","@types/wait-on":"^5.3.4",axios:"^1.10.0",chalk:"^5.0.1",child_process:"^1.0.2",chokidar:"^3.5.3","cli-progress":"^3.12.0","cli-table3":"^0.6.5",dotenv:"^16.0.3",ejs:"^3.1.8",execa:"^7.0.0",glob:"^8.0.3","http-proxy-agent":"^7.0.2","https-proxy-agent":"^7.0.6",inquirer:"^9.2.15",ora:"^5.4.1",path:"^0.12.7",typescript:"^5.8.3","wait-on":"^7.0.1",yargs:"^17.7.1",zod:"^3.22.3","zod-validation-error":"^1.3.0"},devDependencies:{"@types/cli-progress":"^3.11.5","@types/ejs":"^3.1.1","@types/glob":"^7.2.0","@types/inquirer":"^9.0.7","@types/node":"^22.16.0","@types/yargs":"^17.0.10",eslint:"^9.0.0","eslint-config-prettier":"^9.1.0",prettier:"3.3.3","ts-node":"^10.9.1",tsup:"^6.7.0",tsx:"^3.12.6",vitest:"0.31.4"},engines:{node:">=22.0.0"},publishConfig:{access:"public"}};function _e(e){if(e.startsWith(Gt))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 W(e,t){try{let o=await ke.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch(o){throw new Error(`read .history/sui_${t}/latest.json failed. ${o}`)}}async function pe(e,t){try{let o=await ke.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o).dappHub}catch{return""}}async function Z(e){let o=`${process.cwd()}/src/dubhe`;switch(e){case"mainnet":return await pe(o,"mainnet");case"testnet":return await pe(o,"testnet");case"devnet":return await pe(o,"devnet");case"localnet":return await pe(o,"localnet");default:throw new Error(`Invalid network: ${e}`)}}async function Me(e,t){return(await W(e,t)).components}async function Re(e,t){return(await W(e,t)).resources}async function Fe(e,t){return(await W(e,t)).version}async function me(e,t){return(await W(e,t)).packageId}async function je(e,t){return(await W(e,t)).upgradeCap}async function Ue(e,t){return(await W(e,t)).startCheckpoint}async function se(e,t,o,n,s,r,i,l,d,c){let m={projectName:e,network:t,startCheckpoint:o,packageId:n,dappHub:s,upgradeCap:r,version:i,components:l,resources:d,enums:c},p=process.cwd(),y=JSON.stringify(m,null,2);await $e(y,`${p}/src/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function re(e,t,o){let n=process.cwd();try{let s=await Xt(t,o);if(s){let r=JSON.stringify(s,null,2);await $e(r,`${n}/src/${e}/.history/sui_${t}/${o}.json`,"Save package metadata"),await $e(r,`${n}/metadata.json`,"Save latest metadata")}}catch(s){console.warn(O.yellow(`Warning: Failed to save metadata: ${s}`))}}async function $e(e,t,o){Bt(Kt(t),{recursive:!0}),Yt(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function Qt(e){switch(e){case"localnet":return'Dubhe = { local = "../dubhe" }';case"testnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "framework/src/dubhe", rev = "v${U.version}" }`;case"mainnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "framework/src/dubhe", rev = "v${U.version}" }`;default:throw new Error(`Unsupported network: ${e}`)}}async function ge(e,t){let o=z.readFileSync(e,"utf-8"),n=Qt(t),s=o.replace(/Dubhe = \{.*\}/,n);z.writeFileSync(e,s,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function Zt(e){try{let t=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"sui_getLatestCheckpointSequenceNumber",params:[]})});return t.ok?!(await t.json()).error:!1}catch{return!1}}async function eo(e){let t={localnet:"http://127.0.0.1:9000",devnet:"https://fullnode.devnet.sui.io:443/",testnet:"https://fullnode.testnet.sui.io:443/",mainnet:"https://fullnode.mainnet.sui.io:443/"},o=t[e];if(!await Zt(o))throw new Error(`RPC endpoint ${o} is not available. Please check your network connection or try again later.`);return new Promise((s,r)=>{let i="",l="",d=Se("sui",["client","new-env","--alias",e,"--rpc",t[e]],{env:{...process.env},stdio:"pipe"});d.stdout.on("data",c=>{l+=c.toString()}),d.stderr.on("data",c=>{i+=c.toString()}),d.on("error",c=>{console.error(O.red(`
16
16
  \u274C Failed to execute sui command: ${c.message}`)),r(new Error(`Failed to execute sui command: ${c.message}`))}),d.on("exit",(c,m)=>{if(i.includes("already exists")||l.includes("already exists")){console.log(O.yellow(`Environment ${e} already exists, proceeding...`)),s();return}if(c===0)console.log(O.green(`Successfully added environment ${e}`)),s();else{let p;c===null?p=i||l||`Process was terminated by signal ${m||"unknown"}`:p=i||l||`Process exited with code ${c}`,console.error(O.red(`
17
17
  \u274C Failed to add environment ${e}`)),console.error(O.red(` \u2514\u2500 ${p.trim()}`)),r(new Error(p))}})})}async function to(){try{return new Promise((e,t)=>{let o="",n="",s=Se("sui",["client","envs","--json"],{env:{...process.env},stdio:"pipe"});s.stdout.on("data",r=>{n+=r.toString()}),s.stderr.on("data",r=>{o+=r.toString()}),s.on("error",r=>{console.error(O.red(`
18
18
  \u274C Failed to execute sui command: ${r.message}`)),t(new Error(`Failed to execute sui command: ${r.message}`))}),s.on("exit",(r,i)=>{if(r===0)e(JSON.parse(n));else{let l;r===null?l=o||n||`Process was terminated by signal ${i||"unknown"}`:l=o||n||`Process exited with code ${r}`,console.error(O.red(`