@0xobelisk/sui-cli 1.2.0-pre.85 → 1.2.0-pre.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dubhe.js +1 -1
- package/dist/dubhe.js.map +1 -1
- package/package.json +3 -3
package/dist/dubhe.js
CHANGED
|
@@ -12,7 +12,7 @@ Welcome to Dubhe
|
|
|
12
12
|
|
|
13
13
|
`))}import{Transaction as he}from"@0xobelisk/sui-client";import{execSync as ao}from"child_process";import T from"chalk";import*as _e from"fs/promises";import{mkdirSync as Gt,writeFileSync as Yt}from"fs";import{dirname as Jt}from"path";import{SUI_PRIVATE_KEY_PREFIX as Xt}from"@mysten/sui/cryptography";import ne from"chalk";import{ZodError as Wt}from"zod";import{fromZodError as Bt,ValidationError as qt}from"zod-validation-error";var $e=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"},R=class extends Error{name="DubheCliError"},pe=class extends Error{name="UpgradeError"};function j(e){if(e instanceof qt)console.log(ne.redBright(e.message));else if(e instanceof Wt){let t=Bt(e,{prefixSeparator:`
|
|
14
14
|
- `,issueSeparator:`
|
|
15
|
-
- `});console.log(ne.redBright(t.message))}else e instanceof $e?(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 Qt,loadMetadata as Zt}from"@0xobelisk/sui-client";var U={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.
|
|
15
|
+
- `});console.log(ne.redBright(t.message))}else e instanceof $e?(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 Qt,loadMetadata as Zt}from"@0xobelisk/sui-client";var U={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.86",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/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"}};var me="0xb65df6ea777f1ed0fb9a0d9173eec6b43f2ae1da4346af1b48f678d8af796379",ge="0xa09cd4137e604ec5a7a88f72c572ecd064b0e713a3fbf705a88456cdbccf36c0";function Pe(e){if(e.startsWith(Xt))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 _e.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 eo(e,t){try{let o=await _e.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 me;case"testnet":return me;case"devnet":return me;case"localnet":return await eo(o,"localnet");default:throw new Error(`Invalid network: ${e}`)}}async function Re(e){let o=`${process.cwd()}/src/dubhe`;switch(e){case"mainnet":return ge;case"testnet":return ge;case"devnet":return ge;case"localnet":return await se(o,e);default:throw new Error(`Invalid network: ${e}`)}}async function Fe(e,t){return(await W(e,t)).components}async function je(e,t){return(await W(e,t)).resources}async function Ue(e,t){return(await W(e,t)).version}async function se(e,t){return(await W(e,t)).packageId}async function He(e,t){return(await W(e,t)).upgradeCap}async function Le(e,t){return(await W(e,t)).startCheckpoint}async function re(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},u=process.cwd(),y=JSON.stringify(m,null,2);await ke(y,`${u}/src/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function ae(e,t,o){let n=process.cwd();try{let s=await Zt(t,o);if(s){let r=JSON.stringify(s,null,2);await ke(r,`${n}/src/${e}/.history/sui_${t}/${o}.json`,"Save package metadata"),await ke(r,`${n}/metadata.json`,"Save latest metadata")}}catch(s){console.warn(O.yellow(`Warning: Failed to save metadata: ${s}`))}}async function ke(e,t,o){Gt(Jt(t),{recursive:!0}),Yt(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function to(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 fe(e,t){let o=z.readFileSync(e,"utf-8"),n=to(t),s=o.replace(/Dubhe = \{.*\}/,n);z.writeFileSync(e,s,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function oo(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 no(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 oo(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 u;c===null?u=i||l||`Process was terminated by signal ${m||"unknown"}`:u=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 ${u.trim()}`)),r(new Error(u))}})})}async function so(){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(`
|