@0xobelisk/sui-cli 1.2.0-pre.55 → 1.2.0-pre.56
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 de}from"@0xobelisk/sui-client";import{execSync as qt}from"child_process";import T from"chalk";import*as we from"fs/promises";import{mkdirSync as Mt,writeFileSync as Rt}from"fs";import{dirname as Ft}from"path";import{SUI_PRIVATE_KEY_PREFIX as jt}from"@mysten/sui/cryptography";import X from"chalk";import{ZodError as It}from"zod";import{fromZodError as At,ValidationError as Nt}from"zod-validation-error";var ye=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"},N=class extends Error{name="DubheCliError"},ie=class extends Error{name="UpgradeError"};function M(e){if(e instanceof Nt)console.log(X.redBright(e.message));else if(e instanceof It){let t=At(e,{prefixSeparator:`
|
|
14
14
|
- `,issueSeparator:`
|
|
15
|
-
- `});console.log(X.redBright(t.message))}else e instanceof ye?(console.log(X.red(e.message)),console.log(""),console.log(X.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof N?console.log(X.red(e)):console.log(e)}import*as L from"fs";import F from"chalk";import{spawn as _e}from"child_process";import{Dubhe as Ht,loadMetadata as Vt}from"@0xobelisk/sui-client";var R={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.
|
|
15
|
+
- `});console.log(X.redBright(t.message))}else e instanceof ye?(console.log(X.red(e.message)),console.log(""),console.log(X.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof N?console.log(X.red(e)):console.log(e)}import*as L from"fs";import F from"chalk";import{spawn as _e}from"child_process";import{Dubhe as Ht,loadMetadata as Vt}from"@0xobelisk/sui-client";var R={name:"@0xobelisk/sui-cli",version:"1.2.0-pre.56",description:"Tookit for interacting with move eps framework",keywords:["sui","obelisk labs","move","blockchain"],type:"module",author:"team@obelisk.build",homepage:"https://github.com/0xobelisk/dubhe/tree/main/packages/sui-cli#readme",bugs:"https://github.com/0xobelisk/dubhe/issues",repository:{type:"git",url:"https://github.com/0xobelisk/dubhe.git"},license:"Apache-2.0",publishConfig:{access:"public"},engines:{node:">=22.0.0"},exports:{".":"./dist/index.js"},types:"src/index.ts",bin:{dubhe:"./dist/dubhe.js"},scripts:{build:"pnpm run type-check && pnpm run build:js","build:js":"tsup && chmod +x ./dist/dubhe.js",clean:"pnpm run clean:js","clean:js":"rimraf dist",dev:"tsup --watch",lint:"eslint . --ext .ts",format:"prettier --write .","format:check":"prettier --check .","type-check":"tsc --noEmit",validate:"pnpm format:check && pnpm type-check"},dependencies:{"@0xobelisk/sui-client":"workspace:*","@0xobelisk/sui-common":"workspace:*","@mysten/sui":"^1.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",sqlite:"^5.1.1",sqlite3:"^5.1.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:"^8.56.0","eslint-config-prettier":"^9.1.0",prettier:"3.3.3","ts-node":"^10.9.1",tsup:"^6.7.0",tsx:"^3.12.6",vitest:"0.31.4"}};function ve(e){if(e.startsWith(jt))return e.length===70?e:!1;if(e.startsWith("0x")){let t=e.slice(2);return t.length===64?t:!1}else return e.length===64?e:!1}async function z(e,t){try{let o=await we.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 ae(e,t){try{let o=await we.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o).dappHub}catch{return""}}async function Y(e){let o=`${process.cwd()}/src/dubhe`;switch(e){case"mainnet":return await ae(o,"mainnet");case"testnet":return await ae(o,"testnet");case"devnet":return await ae(o,"devnet");case"localnet":return await ae(o,"localnet");default:throw new Error(`Invalid network: ${e}`)}}async function Te(e,t){return(await z(e,t)).components}async function De(e,t){return(await z(e,t)).resources}async function Ee(e,t){return(await z(e,t)).version}async function le(e,t){return(await z(e,t)).packageId}async function Ie(e,t){return(await z(e,t)).upgradeCap}async function Ae(e,t){return(await z(e,t)).startCheckpoint}async function Q(e,t,o,n,s,r,a,u,d,c){let g={projectName:e,network:t,startCheckpoint:o,packageId:n,dappHub:s,upgradeCap:r,version:a,components:u,resources:d,enums:c},f=process.cwd(),h=JSON.stringify(g,null,2);await be(h,`${f}/src/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function Z(e,t,o){let n=process.cwd();try{let s=await Vt(t,o);if(s){let r=JSON.stringify(s,null,2);await be(r,`${n}/src/${e}/.history/sui_${t}/${o}.json`,"Save package metadata"),await be(r,`${n}/metadata.json`,"Save latest metadata")}}catch(s){console.warn(F.yellow(`Warning: Failed to save metadata: ${s}`))}}async function be(e,t,o){Mt(Ft(t),{recursive:!0}),Rt(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function Ut(e){switch(e){case"localnet":return'Dubhe = { local = "../dubhe" }';case"testnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "packages/sui-framework/src/dubhe", rev = "v${R.version}" }`;case"mainnet":return`Dubhe = { git = "https://github.com/0xobelisk/dubhe.git", subdir = "packages/sui-framework/src/dubhe", rev = "v${R.version}" }`;default:throw new Error(`Unsupported network: ${e}`)}}async function ce(e,t){let o=L.readFileSync(e,"utf-8"),n=Ut(t),s=o.replace(/Dubhe = \{.*\}/,n);L.writeFileSync(e,s,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function Lt(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 zt(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 Lt(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 a="",u="",d=_e("sui",["client","new-env","--alias",e,"--rpc",t[e]],{env:{...process.env},stdio:"pipe"});d.stdout.on("data",c=>{u+=c.toString()}),d.stderr.on("data",c=>{a+=c.toString()}),d.on("error",c=>{console.error(F.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=>{if(a.includes("already exists")||u.includes("already exists")){console.log(F.yellow(`Environment ${e} already exists, proceeding...`)),s();return}if(c===0)console.log(F.green(`Successfully added environment ${e}`)),s();else{let g=a||u||`Process exited with code ${c}`;console.error(F.red(`
|
|
17
17
|
\u274C Failed to add environment ${e}`)),console.error(F.red(` \u2514\u2500 ${g.trim()}`)),r(new Error(g))}})})}async function W(e){try{return await zt(e),new Promise((t,o)=>{let n="",s="",r=_e("sui",["client","switch","--env",e],{env:{...process.env},stdio:"pipe"});r.stdout.on("data",a=>{s+=a.toString()}),r.stderr.on("data",a=>{n+=a.toString()}),r.on("error",a=>{console.error(F.red(`
|
|
18
18
|
\u274C Failed to execute sui command: ${a.message}`)),o(new Error(`Failed to execute sui command: ${a.message}`))}),r.on("exit",a=>{if(a===0)console.log(F.green(`Successfully switched to environment ${e}`)),t();else{let u=n||s||`Process exited with code ${a}`;console.error(F.red(`
|