@0xobelisk/sui-cli 0.5.36 → 0.5.38

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
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import Ht from"yargs";import{hideBin as Jt}from"yargs/helpers";import{execSync as Xe,spawn as ce}from"child_process";import w from"chalk";import Oe from"chalk";function T(){console.log(Oe.yellow(`
2
+ import zt from"yargs";import{hideBin as Ht}from"yargs/helpers";import{execSync as Ze,spawn as ae}from"child_process";import _ from"chalk";import Fe from"chalk";function T(){console.log(Fe.yellow(`
3
3
  Welcome to Dubhe
4
4
  --from team@obelisk
5
5
  ________ ___ ___ ________ ___ ___ _______
@@ -10,65 +10,68 @@ Welcome to Dubhe
10
10
  \\ \\_______\\ \\_______\\ \\_______\\ \\__\\ \\__\\ \\_______\\
11
11
  \\|_______|\\|_______|\\|_______|\\|__|\\|__|\\|_______|
12
12
 
13
- `))}import{Dubhe as Le}from"@0xobelisk/sui-client";import{Transaction as H}from"@mysten/sui/transactions";import{getFullnodeUrl as ze,SuiClient as He}from"@mysten/sui/client";import{execSync as Je}from"child_process";import $ from"chalk";import O from"chalk";import{ZodError as Ke}from"zod";import{fromZodError as Re,ValidationError as Te}from"zod-validation-error";var z=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"},g=class extends Error{name="DubheCliError"},N=class extends Error{name="UpgradeError"},j=class extends Error{name="FsIibError"};function A(e){if(e instanceof Te)console.log(O.redBright(e.message));else if(e instanceof Ke){let t=Re(e,{prefixSeparator:`
13
+ `))}import{Dubhe as Ye}from"@0xobelisk/sui-client";import{Transaction as H}from"@mysten/sui/transactions";import{getFullnodeUrl as qe,SuiClient as Be}from"@mysten/sui/client";import{execSync as Le}from"child_process";import m from"chalk";import O from"chalk";import{ZodError as Ae}from"zod";import{fromZodError as Me,ValidationError as Oe}from"zod-validation-error";var z=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"},g=class extends Error{name="DubheCliError"},N=class extends Error{name="UpgradeError"},j=class extends Error{name="FsIibError"};function F(e){if(e instanceof Oe)console.log(O.redBright(e.message));else if(e instanceof Ae){let t=Me(e,{prefixSeparator:`
14
14
  - `,issueSeparator:`
15
- - `});console.log(O.redBright(t.message))}else e instanceof z?(console.log(O.red(e.message)),console.log(""),console.log(O.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof g?console.log(O.red(e)):console.log(e)}import*as X from"fs/promises";import{mkdirSync as Ne,writeFileSync as je}from"fs";import{dirname as Ue}from"path";import{SUI_PRIVATE_KEY_PREFIX as Ve}from"@mysten/sui/cryptography";import*as U from"fs";import E from"chalk";import{spawn as Ye}from"child_process";function k(e){if(e.startsWith(Ve))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 V(e,t){try{let o=await X.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch{throw new j("Fs read deployment file failed.")}}async function Q(e,t){return(await V(e,t)).schemas}async function ee(e,t){return(await V(e,t)).version}async function te(e,t){return(await V(e,t)).packageId}async function oe(e,t){return(await V(e,t)).upgradeCap}function K(e,t,o,r,n,s){let i={projectName:e,network:t,packageId:o,schemas:s,upgradeCap:r,version:n},c=process.cwd(),d=JSON.stringify(i,null,2);qe(d,`${c}/contracts/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function qe(e,t,o){Ne(Ue(t),{recursive:!0}),je(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function Be(e){switch(e){case"localnet":return'Dubhe = { local = "../dubhe-framework" }';case"testnet":return'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-testnet-v1.0.0" }';case"mainnet":return'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-mainnet-v1.0.0" }';default:throw new Error(`Unsupported network: ${e}`)}}function Y(e,t){let o=U.readFileSync(e,"utf-8"),r=Be(t),n=o.replace(/Dubhe = \{.*\}/,r);U.writeFileSync(e,n,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function F(e){try{return new Promise((t,o)=>{let r=Ye("sui",["client","switch","--env",e],{env:{...process.env},stdio:"pipe"});r.stdout.on("data",n=>{console.log(E.green(`${n.toString()}`))}),r.stderr.on("data",n=>{console.error(E.red(`
16
- \u274C Failed to Switch Env`)),console.error(E.red(` Error: ${n.toString()}`))}),r.on("error",n=>{console.error(E.red(`
17
- \u274C Failed to Switch Env`)),console.error(E.red(` Error: ${n.message}`)),o(n)}),r.on("exit",n=>{n!==0?(console.error(E.red(`
18
- \u274C Process exited with code: ${n}`)),o(new Error(`Process exited with code: ${n}`))):t()})})}catch(t){console.error(E.red(`
19
- \u274C Failed to Switch Env`)),console.error(E.red(` \u2514\u2500 Error: ${t}`))}}var R=e=>new Promise(t=>setTimeout(t,e));import*as I from"fs";import*as ne from"path";function re(e,t){if(!I.existsSync(e))return;let o=I.readFileSync(e,"utf-8"),r=new RegExp(`\\[env\\.${t}\\][\\s\\S]*?(?=\\[|$)`,"g"),n=o.replace(r,"");I.writeFileSync(e,n,"utf-8")}function se(e,t,o,r,n){let s=ne.resolve(e),i=I.readFileSync(s,"utf-8"),c=i.split(`
20
- `),d=c.findIndex(m=>m.trim()===`[env.${t}]`),a={chainId:r,originalPublishedId:"",latestPublishedId:"",publishedVersion:0};if(d===-1)if(o==="publish")a.originalPublishedId=n,a.latestPublishedId=n,a.publishedVersion=1;else throw new Error(`Network type [env.${t}] not found in the file and cannot upgrade.`);else{for(let m=d+1;m<c.length;m++){let _=c[m].trim();if(_.startsWith("["))break;let[y,b]=_.split("=").map(p=>p.trim().replace(/"/g,""));switch(y){case"original-published-id":a.originalPublishedId=b;break;case"latest-published-id":a.latestPublishedId=b;break;case"published-version":a.publishedVersion=parseInt(b,10);break}}o==="publish"?(a.originalPublishedId=n,a.latestPublishedId=n,a.publishedVersion=1):o==="upgrade"&&(a.latestPublishedId=n,a.publishedVersion+=1)}let u=`
15
+ - `});console.log(O.redBright(t.message))}else e instanceof z?(console.log(O.red(e.message)),console.log(""),console.log(O.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof g?console.log(O.red(e)):console.log(e)}import*as Z from"fs/promises";import{mkdirSync as Ke,writeFileSync as Re}from"fs";import{dirname as Te}from"path";import{SUI_PRIVATE_KEY_PREFIX as Ne}from"@mysten/sui/cryptography";import*as U from"fs";import I from"chalk";import{spawn as je}from"child_process";function $(e){if(e.startsWith(Ne))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 V(e,t){try{let o=await Z.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch{throw new j("Fs read deployment file failed.")}}async function X(e,t){return(await V(e,t)).schemas}async function Q(e,t){return(await V(e,t)).version}async function ee(e,t){return(await V(e,t)).packageId}async function te(e,t){return(await V(e,t)).upgradeCap}function K(e,t,o,n,r,s){let i={projectName:e,network:t,packageId:o,schemas:s,upgradeCap:n,version:r},c=process.cwd(),d=JSON.stringify(i,null,2);Ue(d,`${c}/contracts/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function Ue(e,t,o){Ke(Te(t),{recursive:!0}),Re(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function Ve(e){switch(e){case"localnet":return'Dubhe = { local = "../dubhe-framework" }';case"testnet":return'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-testnet-v1.1.0" }';case"mainnet":return'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-mainnet-v1.1.0" }';default:throw new Error(`Unsupported network: ${e}`)}}function Y(e,t){let o=U.readFileSync(e,"utf-8"),n=Ve(t),r=o.replace(/Dubhe = \{.*\}/,n);U.writeFileSync(e,r,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function A(e){try{return new Promise((t,o)=>{let n=je("sui",["client","switch","--env",e],{env:{...process.env},stdio:"pipe"});n.stdout.on("data",r=>{console.log(I.green(`${r.toString()}`))}),n.stderr.on("data",r=>{console.error(I.red(`
16
+ \u274C Failed to Switch Env`)),console.error(I.red(` Error: ${r.toString()}`))}),n.on("error",r=>{console.error(I.red(`
17
+ \u274C Failed to Switch Env`)),console.error(I.red(` Error: ${r.message}`)),o(r)}),n.on("exit",r=>{r!==0?(console.error(I.red(`
18
+ \u274C Process exited with code: ${r}`)),o(new Error(`Process exited with code: ${r}`))):t()})})}catch(t){console.error(I.red(`
19
+ \u274C Failed to Switch Env`)),console.error(I.red(` \u2514\u2500 Error: ${t}`))}}var R=e=>new Promise(t=>setTimeout(t,e));import*as E from"fs";import*as oe from"path";async function ne(e,t){if(!E.existsSync(e))return;let o=E.readFileSync(e,"utf-8"),n=new RegExp(`\\[env\\.${t}\\][\\s\\S]*?(?=\\[|$)`,"g"),r=o.replace(n,"");E.writeFileSync(e,r,"utf-8")}function re(e,t,o,n,r){let s=oe.resolve(e),i=E.readFileSync(s,"utf-8"),c=i.split(`
20
+ `),d=c.findIndex(f=>f.trim()===`[env.${t}]`),a={chainId:n,originalPublishedId:"",latestPublishedId:"",publishedVersion:0};if(d===-1)if(o==="publish")a.originalPublishedId=r,a.latestPublishedId=r,a.publishedVersion=1;else throw new Error(`Network type [env.${t}] not found in the file and cannot upgrade.`);else{for(let f=d+1;f<c.length;f++){let x=c[f].trim();if(x.startsWith("["))break;let[b,w]=x.split("=").map(p=>p.trim().replace(/"/g,""));switch(b){case"original-published-id":a.originalPublishedId=w;break;case"latest-published-id":a.latestPublishedId=w;break;case"published-version":a.publishedVersion=parseInt(w,10);break}}o==="publish"?(a.originalPublishedId=r,a.latestPublishedId=r,a.publishedVersion=1):o==="upgrade"&&(a.latestPublishedId=r,a.publishedVersion+=1)}let u=`
21
21
  [env.${t}]
22
22
  chain-id = "${a.chainId}"
23
23
  original-published-id = "${a.originalPublishedId}"
24
24
  latest-published-id = "${a.latestPublishedId}"
25
25
  published-version = "${a.publishedVersion}"
26
- `,h=d===-1?i+u:c.slice(0,d).join(`
27
- `)+u;I.writeFileSync(s,h,"utf-8")}function Ge(e){return e.split("_").map((t,o)=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function We(e){let t=e.split("::");return t.length>0?t[t.length-1]:""}function ie(e){let t,o;try{let r=JSON.parse(Je(`sui move build --dump-bytecode-as-base64 --path ${e}`,{encoding:"utf-8",stdio:"pipe"}));t=r.modules,o=r.dependencies,console.log(" \u2514\u2500 Build successful")}catch(r){console.error($.red(" \u2514\u2500 Build failed")),console.error(r.stdout),process.exit(1)}return[t,o]}async function Ze(e,t,o,r,n,s){let i=await e.getChainIdentifier();re(`${n}/Move.lock`,r),console.log(`
28
- \u{1F680} Starting Contract Publication...`),console.log(` \u251C\u2500 Project: ${n}`),console.log(` \u251C\u2500 Network: ${r}`),console.log(` \u251C\u2500 ChainId: ${i}`),console.log(" \u251C\u2500 Validating Environment...");let c=t.getKeypair();console.log(` \u2514\u2500 Account: ${c.toSuiAddress()}`),console.log(`
29
- \u{1F4E6} Building Contract...`);let[d,a]=ie(n);console.log(`
30
- \u{1F504} Publishing Contract...`);let u=new H;s&&u.setGasBudget(s);let[h]=u.publish({modules:d,dependencies:a});u.transferObjects([h],c.toSuiAddress());let m;try{m=await e.signAndExecuteTransaction({signer:c,transaction:u,options:{showObjectChanges:!0}})}catch(l){console.error($.red(" \u2514\u2500 Publication failed")),console.error(l.message),process.exit(1)}m.effects?.status.status==="failure"&&(console.log($.red(" \u2514\u2500 Publication failed")),process.exit(1)),console.log(" \u251C\u2500 Processing publication results...");let _=1,y="",b=[],p="";m.objectChanges.map(l=>{l.type==="published"&&(console.log(` \u251C\u2500 Package ID: ${l.packageId}`),y=l.packageId),l.type==="created"&&l.objectType==="0x2::package::UpgradeCap"&&(console.log(` \u251C\u2500 Upgrade Cap: ${l.objectId}`),p=l.objectId)}),console.log(` \u2514\u2500 Transaction: ${m.digest}`),se(`${n}/Move.lock`,r,"publish",i,y),console.log(`
31
- \u26A1 Executing Deploy Hook...`),await R(5e3);let x=new H;x.moveCall({target:`${y}::deploy_hook::run`,arguments:[x.object("0x6")]});let v;try{v=await e.signAndExecuteTransaction({signer:c,transaction:x,options:{showEffects:!0,showObjectChanges:!0}})}catch(l){console.error($.red(" \u2514\u2500 Deploy hook execution failed")),console.error(l.message),process.exit(1)}v.effects?.status.status==="success"?(console.log(" \u251C\u2500 Hook execution successful"),console.log(` \u251C\u2500 Transaction: ${v.digest}`),console.log(`
32
- \u{1F4CB} Created Schemas:`),v.objectChanges?.map(l=>{if(l.type==="created"&&l.objectType.includes("_schema")&&!l.objectType.includes("dynamic_field")){console.log(` \u251C\u2500 ${l.objectType}`),console.log(` \u2514\u2500 ID: ${l.objectId}`);let D={};for(let C in o.schemas)Ge(C)===We(l.objectType)&&(D=o.schemas[C].structure);b.push({name:l.objectType,objectId:l.objectId,structure:D})}}),K(o.name,r,y,p,_,b),console.log(`
26
+ `,y=d===-1?i+u:c.slice(0,d).join(`
27
+ `)+u;E.writeFileSync(s,y,"utf-8")}function ze(e){return e.split("_").map((t,o)=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function He(e){let t=e.split("::");return t.length>0?t[t.length-1]:""}function se(e){let t,o;try{let n=JSON.parse(Le(`sui move build --dump-bytecode-as-base64 --path ${e}`,{encoding:"utf-8",stdio:"pipe"}));t=n.modules,o=n.dependencies,console.log(" \u2514\u2500 Build successful")}catch(n){console.error(m.red(" \u2514\u2500 Build failed")),console.error(n.stdout),process.exit(1)}return[t,o]}async function Je(e,t,o,n,r,s){let i=await e.getChainIdentifier();await ne(`${r}/Move.lock`,n),console.log(`
28
+ \u{1F680} Starting Contract Publication...`),console.log(` \u251C\u2500 Project: ${r}`),console.log(` \u251C\u2500 Network: ${n}`),console.log(` \u251C\u2500 ChainId: ${i}`),console.log(" \u251C\u2500 Validating Environment...");let c=t.getKeypair();console.log(` \u2514\u2500 Account: ${c.toSuiAddress()}`),console.log(`
29
+ \u{1F4E6} Building Contract...`);let[d,a]=se(r);console.log(`
30
+ \u{1F504} Publishing Contract...`);let u=new H;s&&u.setGasBudget(s);let[y]=u.publish({modules:d,dependencies:a});u.transferObjects([y],c.toSuiAddress());let f;try{f=await e.signAndExecuteTransaction({signer:c,transaction:u,options:{showObjectChanges:!0}})}catch(l){console.error(m.red(" \u2514\u2500 Publication failed")),console.error(l.message),process.exit(1)}f.effects?.status.status==="failure"&&(console.log(m.red(" \u2514\u2500 Publication failed")),process.exit(1)),console.log(" \u251C\u2500 Processing publication results...");let x=1,b="",w=[],p="";f.objectChanges.map(l=>{l.type==="published"&&(console.log(` \u251C\u2500 Package ID: ${l.packageId}`),b=l.packageId),l.type==="created"&&l.objectType==="0x2::package::UpgradeCap"&&(console.log(` \u251C\u2500 Upgrade Cap: ${l.objectId}`),p=l.objectId)}),console.log(` \u2514\u2500 Transaction: ${f.digest}`),re(`${r}/Move.lock`,n,"publish",i,b),console.log(`
31
+ \u26A1 Executing Deploy Hook...`),await R(5e3);let k=new H;k.moveCall({target:`${b}::deploy_hook::run`,arguments:[k.object("0x6")]});let v;try{v=await e.signAndExecuteTransaction({signer:c,transaction:k,options:{showEffects:!0,showObjectChanges:!0}})}catch(l){console.error(m.red(" \u2514\u2500 Deploy hook execution failed")),console.error(l.message),process.exit(1)}v.effects?.status.status==="success"?(console.log(" \u251C\u2500 Hook execution successful"),console.log(` \u251C\u2500 Transaction: ${v.digest}`),console.log(`
32
+ \u{1F4CB} Created Schemas:`),v.objectChanges?.map(l=>{if(l.type==="created"&&l.objectType.includes("_schema")&&!l.objectType.includes("dynamic_field")){console.log(` \u251C\u2500 ${l.objectType}`),console.log(` \u2514\u2500 ID: ${l.objectId}`);let D={};for(let C in o.schemas)ze(C)===He(l.objectType)&&(D=o.schemas[C].structure);w.push({name:l.objectType,objectId:l.objectId,structure:D})}}),K(o.name,n,b,p,x,w),console.log(`
33
33
  \u2705 Contract Publication Complete
34
- `)):(console.log($.yellow(" \u2514\u2500 Deploy hook execution failed")),console.log($.yellow(" Please republish or manually call deploy_hook::run")),console.log($.yellow(" Please check the transaction digest:")),console.log($.yellow(` ${v.digest}`)),process.exit(1))}async function J(e,t,o){let n=`${process.cwd()}/contracts/dubhe-framework`,s=await e.getChainIdentifier();console.log(` \u2514\u2500 Chain ID: ${s}`),re(`${n}/Move.lock`,o),console.log(`
35
- \u{1F680} Starting Contract Publication...`),console.log(` \u251C\u2500 Project: ${n}`),console.log(` \u251C\u2500 Network: ${o}`),console.log(` \u251C\u2500 ChainId: ${s}`),console.log(" \u251C\u2500 Validating Environment...");let i=t.getKeypair();console.log(` \u2514\u2500 Account: ${i.toSuiAddress()}`),console.log(`
36
- \u{1F4E6} Building Contract...`);let[c,d]=ie(n);console.log(`
37
- \u{1F504} Publishing Contract...`);let a=new H,[u]=a.publish({modules:c,dependencies:d});a.transferObjects([u],i.toSuiAddress());let h;try{h=await e.signAndExecuteTransaction({signer:i,transaction:a,options:{showObjectChanges:!0}})}catch(p){console.error($.red(" \u2514\u2500 Publication failed")),console.error(p.message),process.exit(1)}h.effects?.status.status==="failure"&&(console.log($.red(" \u2514\u2500 Publication failed")),process.exit(1)),console.log(" \u251C\u2500 Processing publication results...");let m=1,_="",y=[],b="";h.objectChanges.map(p=>{p.type==="published"&&(console.log(` \u251C\u2500 Package ID: ${p.packageId}`),_=p.packageId),p.type==="created"&&p.objectType==="0x2::package::UpgradeCap"&&(console.log(` \u251C\u2500 Upgrade Cap: ${p.objectId}`),b=p.objectId)}),console.log(` \u2514\u2500 Transaction: ${h.digest}`),se(`${n}/Move.lock`,o,"publish",s,_),K("dubhe-framework",o,_,b,m,y)}async function ae(e,t,o,r){await F(t);let n=process.env.PRIVATE_KEY;if(!n)throw new g(`Missing PRIVATE_KEY environment variable.
34
+ `)):(console.log(m.yellow(" \u2514\u2500 Deploy hook execution failed")),console.log(m.yellow(" Please republish or manually call deploy_hook::run")),console.log(m.yellow(" Please check the transaction digest:")),console.log(m.yellow(` ${v.digest}`)),process.exit(1))}async function Ge(e){return E.existsSync(e)?!0:(console.log(m.yellow(`
35
+ \u2139\uFE0F Dubhe Framework Files Not Found`)),console.log(m.yellow(" \u251C\u2500 Expected Path:"),e),console.log(m.yellow(" \u251C\u2500 To set up Dubhe Framework:")),console.log(m.yellow(" \u2502 1. Create directory: mkdir -p contracts/dubhe-framework")),console.log(m.yellow(" \u2502 2. Clone repository: git clone https://github.com/0xobelisk/dubhe-framework contracts/dubhe-framework")),console.log(m.yellow(" \u2502 3. Or download from: https://github.com/0xobelisk/dubhe-framework")),console.log(m.yellow(" \u2514\u2500 After setup, restart the local node")),!1)}async function We(e,t,o){let r=`${process.cwd()}/contracts/dubhe-framework`;if(!await Ge(r)){console.log(m.yellow(`
36
+ \u2757 Framework Deployment Skipped`));return}let s=await e.getChainIdentifier();await ne(`${r}/Move.lock`,o),console.log(`
37
+ \u{1F680} Starting Contract Publication...`),console.log(` \u251C\u2500 Project: ${r}`),console.log(` \u251C\u2500 Network: ${o}`);let i=t.getKeypair();console.log(` \u2514\u2500 Account: ${i.toSuiAddress()}`),console.log(`
38
+ \u{1F4E6} Building Contract...`);let[c,d]=se(r);console.log(`
39
+ \u{1F504} Publishing Contract...`);let a=new H,[u]=a.publish({modules:c,dependencies:d});a.transferObjects([u],i.toSuiAddress());let y;try{y=await e.signAndExecuteTransaction({signer:i,transaction:a,options:{showObjectChanges:!0}})}catch(p){console.error(m.red(" \u2514\u2500 Publication failed")),console.error(p.message),process.exit(1)}y.effects?.status.status==="failure"&&(console.log(m.red(" \u2514\u2500 Publication failed")),process.exit(1));let f=1,x="",b=[],w="";y.objectChanges.map(p=>{p.type==="published"&&(console.log(` \u251C\u2500 Package ID: ${p.packageId}`),x=p.packageId),p.type==="created"&&p.objectType==="0x2::package::UpgradeCap"&&(console.log(` \u251C\u2500 Upgrade Cap: ${p.objectId}`),w=p.objectId)}),console.log(` \u2514\u2500 Transaction: ${y.digest}`),re(`${r}/Move.lock`,o,"publish",s,x),K("dubhe-framework",o,x,w,f,b),console.log(m.green(`
40
+ \u2705 Dubhe Framework deployed successfully`))}async function ie(e,t,o){await A(t);let n=process.env.PRIVATE_KEY;if(!n)throw new g(`Missing PRIVATE_KEY environment variable.
38
41
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
39
- in your contracts directory to use the default sui private key.`);let s=k(n);if(s===!1)throw new g("Please check your privateKey.");let i=new Le({secretKey:s}),c=new He({url:ze(t)});if(o=="dubhe-framework")await J(c,i,t);else{let a=`${process.cwd()}/contracts/${e.name}`;Y(`${a}/Move.toml`,t),await Ze(c,i,e,t,a,r)}}import{Dubhe as le}from"@0xobelisk/sui-client";import{getFullnodeUrl as Qe,SuiClient as et}from"@mysten/sui/client";function tt(){try{let e=process.platform==="win32"?'tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH':'pgrep -f "sui start"',t=Xe(e).toString().trim();return process.platform==="win32"?t.toLowerCase().includes("sui.exe"):t.length>0}catch{return!1}}async function ot(){let e=["suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v","suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s","suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc","suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c","suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57","suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c"];console.log("\u{1F4DD}Accounts"),console.log("=========="),e.forEach((t,o)=>{let n=new le({secretKey:t}).getKeypair();ce("curl",["--location","--request","POST","http://127.0.0.1:9123/gas","--header","Content-Type: application/json","--data-raw",`{"FixedAmountRequest": {"recipient": "${n.toSuiAddress()}"}}`],{env:{...process.env},stdio:"ignore",detached:!0}),console.log(` \u250C\u2500 Account #${o}: ${n.toSuiAddress()}(1000 SUI)`),console.log(` \u2514\u2500 Private Key: ${t}`)}),console.log("=========="),console.log(w.yellow("\u26A0\uFE0FWARNING: These accounts, and their private keys, are publicly known.")),console.log(w.yellow("Any funds sent to them on Mainnet or any other live network WILL BE LOST."))}async function de(){if(tt()){console.log(w.yellow(`
40
- \u26A0\uFE0F Warning: Local Node Already Running`)),console.log(w.yellow(" \u251C\u2500 Cannot start a new instance")),console.log(w.yellow(" \u2514\u2500 Please stop the existing process first"));return}T(),console.log("\u{1F680} Starting Local Node...");try{let e=ce("sui",["start","--with-faucet","--force-regenesis"],{env:{...process.env,RUST_LOG:"off,sui_node=info"},stdio:"ignore",detached:!0});e.on("error",s=>{console.error(w.red(`
41
- \u274C Failed to Start Local Node`)),console.error(w.red(` \u2514\u2500 Error: ${s.message}`))}),await R(5e3),console.log(" \u251C\u2500 Faucet: Enabled"),console.log(" \u2514\u2500 Force Regenesis: Yes"),console.log(" \u2514\u2500 HTTP server: http://127.0.0.1:9000/"),console.log(" \u2514\u2500 Faucet server: http://127.0.0.1:9123/"),await ot(),await R(2e3);let t=k("suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c");if(t===!1)throw new g("Please check your privateKey.");let o=new le({secretKey:t}),r=new et({url:Qe("localnet")}),n=console.log;console.log=()=>{},await J(r,o,"localnet"),console.log=n,process.on("SIGINT",()=>{console.log(w.yellow(`
42
- \u{1F514} Stopping Local Node...`)),e&&(e.kill(),console.log(w.green("\u2705 Local Node Stopped"))),process.exit()})}catch(e){console.error(w.red(`
43
- \u274C Failed to Start Local Node`)),console.error(w.red(` \u2514\u2500 Error: ${e.message}`))}}var nt={command:"node",describe:"Manage local Sui node",builder(e){return e},async handler(){try{await de()}catch(e){console.error("Error executing command:",e),process.exit(1)}}},pe=nt;import{Dubhe as rt}from"@0xobelisk/sui-client";import{requestSuiFromFaucetV0 as st,getFaucetHost as it}from"@mysten/sui/faucet";import{SuiClient as at,getFullnodeUrl as ct}from"@mysten/sui/client";var lt={command:"faucet",describe:"Interact with a Dubhe faucet",builder(e){return e.options({network:{type:"string",desc:"URL of the Dubhe 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 i=process.env.PRIVATE_KEY;if(!i)throw new g(`Missing PRIVATE_KEY environment variable.
42
+ in your contracts directory to use the default sui private key.`);let r=$(n);if(r===!1)throw new g("Please check your privateKey.");let s=new Ye({secretKey:r}),i=new Be({url:qe(t)});t==="localnet"&&await We(i,s,t);let d=`${process.cwd()}/contracts/${e.name}`;Y(`${d}/Move.toml`,t),await Je(i,s,e,t,d,o)}import{Dubhe as Xe}from"@0xobelisk/sui-client";function Qe(){try{let e=process.platform==="win32"?'tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH':'pgrep -f "sui start"',t=Ze(e).toString().trim();return process.platform==="win32"?t.toLowerCase().includes("sui.exe"):t.length>0}catch{return!1}}async function et(){let e=["suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v","suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s","suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc","suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c","suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57","suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c"];console.log("\u{1F4DD}Accounts"),console.log("=========="),e.forEach((t,o)=>{let r=new Xe({secretKey:t}).getKeypair();ae("curl",["--location","--request","POST","http://127.0.0.1:9123/gas","--header","Content-Type: application/json","--data-raw",`{"FixedAmountRequest": {"recipient": "${r.toSuiAddress()}"}}`],{env:{...process.env},stdio:"ignore",detached:!0}),console.log(` \u250C\u2500 Account #${o}: ${r.toSuiAddress()}(1000 SUI)`),console.log(` \u2514\u2500 Private Key: ${t}`)}),console.log("=========="),console.log(_.yellow("\u2139\uFE0F WARNING: These accounts, and their private keys, are publicly known.")),console.log(_.yellow("Any funds sent to them on Mainnet or any other live network WILL BE LOST."))}async function ce(){if(Qe()){console.log(_.yellow(`
43
+ \u26A0\uFE0F Warning: Local Node Already Running`)),console.log(_.yellow(" \u251C\u2500 Cannot start a new instance")),console.log(_.yellow(" \u2514\u2500 Please stop the existing process first"));return}T(),console.log("\u{1F680} Starting Local Node...");try{let e=ae("sui",["start","--with-faucet","--force-regenesis"],{env:{...process.env,RUST_LOG:"off,sui_node=info"},stdio:"ignore",detached:!0});if(e.on("error",o=>{console.error(_.red(`
44
+ \u274C Failed to Start Local Node`)),console.error(_.red(` \u2514\u2500 Error: ${o.message}`))}),await R(5e3),console.log(" \u251C\u2500 Faucet: Enabled"),console.log(" \u2514\u2500 Force Regenesis: Yes"),console.log(" \u2514\u2500 HTTP server: http://127.0.0.1:9000/"),console.log(" \u2514\u2500 Faucet server: http://127.0.0.1:9123/"),await et(),await R(2e3),$("suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c")===!1)throw new g("Please check your privateKey.");console.log(_.green("\u{1F389} Local environment is ready!")),process.on("SIGINT",()=>{console.log(_.yellow(`
45
+ \u{1F514} Stopping Local Node...`)),e&&(e.kill(),console.log(_.green("\u2705 Local Node Stopped"))),process.exit()})}catch(e){console.error(_.red(`
46
+ \u274C Failed to Start Local Node`)),console.error(_.red(` \u2514\u2500 Error: ${e.message}`)),process.exit(1)}}var tt={command:"node",describe:"Manage local Sui node",builder(e){return e},async handler(){try{await ce()}catch(e){console.error("Error executing command:",e),process.exit(1)}}},le=tt;import{Dubhe as ot}from"@0xobelisk/sui-client";import{requestSuiFromFaucetV0 as nt,getFaucetHost as rt}from"@mysten/sui/faucet";import{SuiClient as st,getFullnodeUrl as it}from"@mysten/sui/client";var at={command:"faucet",describe:"Interact with a Dubhe faucet",builder(e){return e.options({network:{type:"string",desc:"URL of the Dubhe 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 i=process.env.PRIVATE_KEY;if(!i)throw new g(`Missing PRIVATE_KEY environment variable.
44
47
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
45
- in your contracts directory to use the default sui private key.`);let c=k(i);if(c===!1)throw new g("Please check your PRIVATE_KEY.");o=new rt({secretKey:c}).getKeypair().toSuiAddress()}else o=t;console.log(`
46
- \u{1F30A} Starting Faucet Operation...`),console.log(` \u251C\u2500 Network: ${e}`),t===void 0?(console.log(" \u251C\u2500 Using Environment PrivateKey"),console.log(` \u251C\u2500 Generated Address: ${o}`)):console.log(` \u251C\u2500 Using Provided Address: ${o}`),console.log(" \u251C\u2500 Requesting funds from faucet..."),await st({host:it(e),recipient:o}),console.log(" \u2514\u2500 Checking balance...");let r=new at({url:ct(e)}),n={owner:o},s=await r.getBalance(n);console.log(`
48
+ in your contracts directory to use the default sui private key.`);let c=$(i);if(c===!1)throw new g("Please check your PRIVATE_KEY.");o=new ot({secretKey:c}).getKeypair().toSuiAddress()}else o=t;console.log(`
49
+ \u{1F30A} Starting Faucet Operation...`),console.log(` \u251C\u2500 Network: ${e}`),t===void 0?(console.log(" \u251C\u2500 Using Environment PrivateKey"),console.log(` \u251C\u2500 Generated Address: ${o}`)):console.log(` \u251C\u2500 Using Provided Address: ${o}`),console.log(" \u251C\u2500 Requesting funds from faucet..."),await nt({host:rt(e),recipient:o}),console.log(" \u2514\u2500 Checking balance...");let n=new st({url:it(e)}),r={owner:o},s=await n.getBalance(r);console.log(`
47
50
  \u{1F4B0} Account Summary`),console.log(` \u251C\u2500 Address: ${o}`),console.log(` \u2514\u2500 Balance: ${(Number(s.totalBalance)/1e9).toFixed(4)} SUI`),console.log(`
48
51
  \u2705 Faucet Operation Complete
49
- `),process.exit(0)}},ue=lt;import{schemaGen as dt,loadConfig as pt}from"@0xobelisk/sui-common";import ut from"chalk";var gt={command:"schemagen",describe:"Autogenerate Dubhe schemas based on the config file",builder:{"config-path":{type:"string",default:"dubhe.config.ts",desc:"Path to the config file"},network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},"framework-id":{type:"string",desc:"Framework Package ID"}},async handler({"config-path":e,network:t,"framework-id":o}){try{let r=await pt(e);await dt(r,void 0,t,o),process.exit(0)}catch(r){console.log(ut.red("Schemagen failed!")),console.error(r.message)}}},ge=gt;import{loadConfig as mt}from"@0xobelisk/sui-common";var ft={command:"publish",describe:"Publish dubhe move contract",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},"config-path":{type:"string",default:"dubhe.config.ts",desc:"Configuration file path"},"contract-name":{type:"string",desc:"Optional contract name in contracts/ directory"},"gas-budget":{type:"number",desc:"Optional gas budget for the transaction",optional:!0}})},async handler({network:e,"config-path":t,"contract-name":o,"gas-budget":r}){try{let n=await mt(t);await ae(n,e,o,r)}catch(n){A(n),process.exit(1)}process.exit(0)}},me=ft;import{Dubhe as ht}from"@0xobelisk/sui-client";import{Transaction as yt,UpgradePolicy as bt}from"@mysten/sui/transactions";import{getFullnodeUrl as vt,SuiClient as wt}from"@mysten/sui/client";import{execSync as _t}from"child_process";import q from"chalk";import*as M from"fs";import*as fe from"path";function xt(e,t){t.forEach(o=>{let r=`${e}/sources/codegen/schemas/${o.schemaName}.move`,n=M.readFileSync(r,"utf-8"),s=new RegExp(`public fun migrate\\(_${o.schemaName}: &mut ${G(o.schemaName)}, _cap: &UpgradeCap\\) {[^}]*}`),i=`
50
- public fun migrate(${o.schemaName}: &mut ${G(o.schemaName)}, _cap: &UpgradeCap) {
52
+ `),process.exit(0)}},de=at;import{schemaGen as ct,loadConfig as lt}from"@0xobelisk/sui-common";import dt from"chalk";var pt={command:"schemagen",describe:"Autogenerate Dubhe schemas based on the config file",builder:{"config-path":{type:"string",default:"dubhe.config.ts",desc:"Path to the config file"},network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},"framework-id":{type:"string",desc:"Framework Package ID"}},async handler({"config-path":e,network:t,"framework-id":o}){try{let n=await lt(e);await ct(n,void 0,t,o),process.exit(0)}catch(n){console.log(dt.red("Schemagen failed!")),console.error(n.message)}}},pe=pt;import{loadConfig as ut}from"@0xobelisk/sui-common";var gt={command:"publish",describe:"Publish dubhe move contract",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},"config-path":{type:"string",default:"dubhe.config.ts",desc:"Configuration file path"},"gas-budget":{type:"number",desc:"Optional gas budget for the transaction",optional:!0}})},async handler({network:e,"config-path":t,"gas-budget":o}){try{let n=await ut(t);await ie(n,e,o)}catch(n){F(n),process.exit(1)}process.exit(0)}},ue=gt;import{Dubhe as mt}from"@0xobelisk/sui-client";import{Transaction as ft,UpgradePolicy as ht}from"@mysten/sui/transactions";import{getFullnodeUrl as yt,SuiClient as bt}from"@mysten/sui/client";import{execSync as wt}from"child_process";import q from"chalk";import*as M from"fs";import*as ge from"path";function vt(e,t){t.forEach(o=>{let n=`${e}/sources/codegen/schemas/${o.schemaName}.move`,r=M.readFileSync(n,"utf-8"),s=new RegExp(`public fun migrate\\(_${o.schemaName}: &mut ${J(o.schemaName)}, _cap: &UpgradeCap\\) {[^}]*}`),i=`
53
+ public fun migrate(${o.schemaName}: &mut ${J(o.schemaName)}, _cap: &UpgradeCap) {
51
54
  ${o.fields.map(d=>{let a="";return d.type.includes("StorageValue")?a="storage_value::new()":d.type.includes("StorageMap")?a="storage_map::new()":d.type.includes("StorageDoubleMap")&&(a="storage_double_map::new()"),`storage_migration::add_field<${d.type}>(&mut ${o.schemaName}.id, b"${d.name}", ${a});`}).join("")}
52
55
  }
53
- `,c=n.replace(s,i);M.writeFileSync(r,c,"utf-8")})}function G(e){return e.split("_").map((t,o)=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function Ct(e){let t=e.split("::");return t.length>0?t[t.length-1]:""}function B(e,t,o,r){let n=fe.resolve(e),i=M.readFileSync(n,"utf-8").split(`
54
- `),c=i.findIndex(u=>u.trim()===`[env.${t}]`);if(c===-1)return console.log(`Network type [env.${t}] not found in the file.`),"";let d=-1,a="";for(let u=c+1;u<i.length;u++){let h=i[u].trim();if(h.startsWith("["))break;if(h.startsWith(o)){d=u,a=h.split("=")[1].trim().replace(/"/g,"");break}}if(d!==-1){i[d]=`${o} = "${r}"`;let u=i.join(`
55
- `);M.writeFileSync(n,u,"utf-8")}else console.log(`${o} not found for [env.${t}].`);return a}async function he(e,t,o){await F(o);let r=process.cwd(),n=`${r}/contracts/${t}`,s=process.env.PRIVATE_KEY;if(!s)throw new g(`Missing PRIVATE_KEY environment variable.
56
+ `,c=r.replace(s,i);M.writeFileSync(n,c,"utf-8")})}function J(e){return e.split("_").map((t,o)=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function _t(e){let t=e.split("::");return t.length>0?t[t.length-1]:""}function B(e,t,o,n){let r=ge.resolve(e),i=M.readFileSync(r,"utf-8").split(`
57
+ `),c=i.findIndex(u=>u.trim()===`[env.${t}]`);if(c===-1)return console.log(`Network type [env.${t}] not found in the file.`),"";let d=-1,a="";for(let u=c+1;u<i.length;u++){let y=i[u].trim();if(y.startsWith("["))break;if(y.startsWith(o)){d=u,a=y.split("=")[1].trim().replace(/"/g,"");break}}if(d!==-1){i[d]=`${o} = "${n}"`;let u=i.join(`
58
+ `);M.writeFileSync(r,u,"utf-8")}else console.log(`${o} not found for [env.${t}].`);return a}async function me(e,t,o){await A(o);let n=process.cwd(),r=`${n}/contracts/${t}`,s=process.env.PRIVATE_KEY;if(!s)throw new g(`Missing PRIVATE_KEY environment variable.
56
59
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
57
- in your contracts directory to use the default sui private key.`);let i=k(s);if(i===!1)throw new g("Please check your privateKey.");let d=new ht({secretKey:i}).getKeypair(),a=new wt({url:vt(o)}),u=Number(await ee(n,o)),h=await te(n,o),m=await oe(n,o),_=B(`${n}/Move.lock`,o,"original-published-id","0x0000000000000000000000000000000000000000000000000000000000000000"),y=[],b=await Q(n,o);for(let p in e.schemas)b.forEach(x=>{if(G(p)==Ct(x.name)){let v={schemaName:"",fields:[]},l=[],D=!1;for(let C in e.schemas[p].structure)C in x.structure||(D=!0,l.push({name:C,type:e.schemas[p].structure[C]}),x.structure[C]=e.schemas[p].structure[C]);D&&(v.schemaName=p,v.fields=l,y.push(v))}});y.forEach(p=>{console.log(`
58
- \u{1F680} Starting Migration for ${p.schemaName}...`),console.log("\u{1F4CB} Migration Fields:",p.fields)}),xt(n,y);try{let p,x,v;try{let{modules:P,dependencies:Fe,digest:Me}=JSON.parse(_t(`sui move build --dump-bytecode-as-base64 --path ${r}/contracts/${t}`,{encoding:"utf-8"}));p=P,x=Fe,v=Me}catch(P){throw new N(P.stdout)}console.log(`
59
- \u{1F680} Starting Upgrade Process...`),console.log("\u{1F4CB} OldPackageId:",h),console.log("\u{1F4CB} UpgradeCap Object Id:",m),console.log("\u{1F4CB} OldVersion:",u);let l=new yt,D=l.moveCall({target:"0x2::package::authorize_upgrade",arguments:[l.object(m),l.pure.u8(bt.COMPATIBLE),l.pure.vector("u8",v)]}),C=l.upgrade({modules:p,dependencies:x,package:h,ticket:D});l.moveCall({target:"0x2::package::commit_upgrade",arguments:[l.object(m),C]});let Z=await a.signAndExecuteTransaction({signer:d,transaction:l,options:{showObjectChanges:!0}}),L="";Z.objectChanges.map(P=>{P.type==="published"&&(console.log(q.blue(`${t} PackageId: ${P.packageId}`)),console.log(q.blue(`${t} Version: ${u+1}`)),L=P.packageId)}),B(`${n}/Move.lock`,o,"original-published-id",_),B(`${n}/Move.lock`,o,"latest-published-id",L),B(`${n}/Move.lock`,o,"published-version",u+1+""),console.log(q.green(`Upgrade Transaction Digest: ${Z.digest}`)),K(t,o,L,m,u+1,b)}catch(p){console.log(q.red("Upgrade failed!")),console.error(p.message)}}import{loadConfig as kt}from"@0xobelisk/sui-common";var $t={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)"},"config-path":{type:"string",default:"dubhe.config.ts",decs:"Path to the config file"}})},async handler({network:e,"config-path":t}){try{let o=await kt(t);await he(o,o.name,e)}catch(o){A(o),process.exit(1)}process.exit(0)}},ye=$t;import{execSync as St}from"child_process";import Et from"chalk";import{loadConfig as It}from"@0xobelisk/sui-common";var Dt={command:"test",describe:"Run tests in Dubhe contracts",builder(e){return e.options({"config-path":{type:"string",default:"dubhe.config.ts",description:"Options to pass to forge test"},test:{type:"string",desc:"Run a specific test"}})},async handler({"config-path":e,test:t}){try{console.log("\u{1F680} Running move test");let o=await It(e),s=`sui move test --path ${`${process.cwd()}/contracts/${o.name}`} ${t?` --test ${t}`:""}`,i=St(s,{encoding:"utf-8"});console.log(i)}catch(o){console.error(Et.red("Error executing sui move test:")),console.log(o.stdout),process.exit(0)}}},be=Dt;import{execSync as Pt}from"child_process";import At from"chalk";import{loadConfig as Ft}from"@0xobelisk/sui-common";var Mt={command:"build",describe:"Run tests in Dubhe contracts",builder(e){return e.options({"config-path":{type:"string",default:"dubhe.config.ts",description:"Options to pass to forge test"},network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},"dump-bytecode-as-base64":{type:"boolean",default:!1,desc:"Dump bytecode as base64"}})},async handler({"config-path":e,network:t,"dump-bytecode-as-base64":o}){try{console.log("\u{1F680} Running move build");let r=await Ft(e),s=`${process.cwd()}/contracts/${r.name}`;await F(t),Y(s+"/Move.toml",t);let i=`sui move build --path ${s} ${o?" --dump-bytecode-as-base64":""}`,c=Pt(i,{encoding:"utf-8"});console.log(c)}catch(r){console.error(At.red("Error executing sui move build:")),console.log(r.stdout),process.exit(0)}}},ve=Mt;var Ot={command:"hello",describe:"hello, dubhe",builder(e){return e},async handler(){T()}},we=Ot;import{Dubhe as W}from"@0xobelisk/sui-client";import*as f from"fs";import S from"chalk";async function _e(e=!1,t){t&&(console.log(S.blue("Note: The generated account will be stored in the .env file and the TypeScript file specified by the --output-ts-path option.")),console.log(S.yellow(`Warning: Do not expose the key file. It is intended for local testing only.
60
- `)));let o=process.cwd(),r;if(e){let c=new W().getKeypair();if(r=c.getSecretKey(),f.writeFileSync(`${o}/.env`,`PRIVATE_KEY=${r}`),console.log(S.green(`File created at: ${o}/.env`)),t){let d=t.substring(0,t.lastIndexOf("/"));f.existsSync(d)||f.mkdirSync(d,{recursive:!0}),f.writeFileSync(t,`export const PRIVATEKEY = '${r}';
60
+ in your contracts directory to use the default sui private key.`);let i=$(s);if(i===!1)throw new g("Please check your privateKey.");let d=new mt({secretKey:i}).getKeypair(),a=new bt({url:yt(o)}),u=Number(await Q(r,o)),y=await ee(r,o),f=await te(r,o),x=B(`${r}/Move.lock`,o,"original-published-id","0x0000000000000000000000000000000000000000000000000000000000000000"),b=[],w=await X(r,o);for(let p in e.schemas)w.forEach(k=>{if(J(p)==_t(k.name)){let v={schemaName:"",fields:[]},l=[],D=!1;for(let C in e.schemas[p].structure)C in k.structure||(D=!0,l.push({name:C,type:e.schemas[p].structure[C]}),k.structure[C]=e.schemas[p].structure[C]);D&&(v.schemaName=p,v.fields=l,b.push(v))}});b.forEach(p=>{console.log(`
61
+ \u{1F680} Starting Migration for ${p.schemaName}...`),console.log("\u{1F4CB} Migration Fields:",p.fields)}),vt(r,b);try{let p,k,v;try{let{modules:P,dependencies:De,digest:Pe}=JSON.parse(wt(`sui move build --dump-bytecode-as-base64 --path ${n}/contracts/${t}`,{encoding:"utf-8"}));p=P,k=De,v=Pe}catch(P){throw new N(P.stdout)}console.log(`
62
+ \u{1F680} Starting Upgrade Process...`),console.log("\u{1F4CB} OldPackageId:",y),console.log("\u{1F4CB} UpgradeCap Object Id:",f),console.log("\u{1F4CB} OldVersion:",u);let l=new ft,D=l.moveCall({target:"0x2::package::authorize_upgrade",arguments:[l.object(f),l.pure.u8(ht.COMPATIBLE),l.pure.vector("u8",v)]}),C=l.upgrade({modules:p,dependencies:k,package:y,ticket:D});l.moveCall({target:"0x2::package::commit_upgrade",arguments:[l.object(f),C]});let W=await a.signAndExecuteTransaction({signer:d,transaction:l,options:{showObjectChanges:!0}}),L="";W.objectChanges.map(P=>{P.type==="published"&&(console.log(q.blue(`${t} PackageId: ${P.packageId}`)),console.log(q.blue(`${t} Version: ${u+1}`)),L=P.packageId)}),B(`${r}/Move.lock`,o,"original-published-id",x),B(`${r}/Move.lock`,o,"latest-published-id",L),B(`${r}/Move.lock`,o,"published-version",u+1+""),console.log(q.green(`Upgrade Transaction Digest: ${W.digest}`)),K(t,o,L,f,u+1,w)}catch(p){console.log(q.red("Upgrade failed!")),console.error(p.message)}}import{loadConfig as xt}from"@0xobelisk/sui-common";var kt={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)"},"config-path":{type:"string",default:"dubhe.config.ts",decs:"Path to the config file"}})},async handler({network:e,"config-path":t}){try{let o=await xt(t);await me(o,o.name,e)}catch(o){F(o),process.exit(1)}process.exit(0)}},fe=kt;import{execSync as Ct}from"child_process";import $t from"chalk";import{loadConfig as St}from"@0xobelisk/sui-common";var Et={command:"test",describe:"Run tests in Dubhe contracts",builder(e){return e.options({"config-path":{type:"string",default:"dubhe.config.ts",description:"Options to pass to forge test"},test:{type:"string",desc:"Run a specific test"}})},async handler({"config-path":e,test:t}){try{console.log("\u{1F680} Running move test");let o=await St(e),s=`sui move test --path ${`${process.cwd()}/contracts/${o.name}`} ${t?` --test ${t}`:""}`,i=Ct(s,{encoding:"utf-8"});console.log(i)}catch(o){console.error($t.red("Error executing sui move test:")),console.log(o.stdout),process.exit(0)}}},he=Et;import{execSync as It}from"child_process";import Dt from"chalk";import{loadConfig as Pt}from"@0xobelisk/sui-common";var Ft={command:"build",describe:"Run tests in Dubhe contracts",builder(e){return e.options({"config-path":{type:"string",default:"dubhe.config.ts",description:"Options to pass to forge test"},network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Node network (mainnet/testnet/devnet/localnet)"},"dump-bytecode-as-base64":{type:"boolean",default:!1,desc:"Dump bytecode as base64"}})},async handler({"config-path":e,network:t,"dump-bytecode-as-base64":o}){try{console.log("\u{1F680} Running move build");let n=await Pt(e),s=`${process.cwd()}/contracts/${n.name}`;await A(t),Y(s+"/Move.toml",t);let i=`sui move build --path ${s} ${o?" --dump-bytecode-as-base64":""}`,c=It(i,{encoding:"utf-8"});console.log(c)}catch(n){console.error(Dt.red("Error executing sui move build:")),console.log(n.stdout),process.exit(0)}}},ye=Ft;var At={command:"hello",describe:"hello, dubhe",builder(e){return e},async handler(){T()}},be=At;import{Dubhe as G}from"@0xobelisk/sui-client";import*as h from"fs";import S from"chalk";async function we(e=!1,t){t&&(console.log(S.blue("Note: The generated account will be stored in the .env file and the TypeScript file specified by the --output-ts-path option.")),console.log(S.yellow(`Warning: Do not expose the key file. It is intended for local testing only.
63
+ `)));let o=process.cwd(),n;if(e){let c=new G().getKeypair();if(n=c.getSecretKey(),h.writeFileSync(`${o}/.env`,`PRIVATE_KEY=${n}`),console.log(S.green(`File created at: ${o}/.env`)),t){let d=t.substring(0,t.lastIndexOf("/"));h.existsSync(d)||h.mkdirSync(d,{recursive:!0}),h.writeFileSync(t,`export const PRIVATEKEY = '${n}';
61
64
  export const ACCOUNT = '${c.toSuiAddress()}';
62
65
  `),console.log(S.green(`File created at: ${t}
63
- `))}console.log(S.blue(`Force generate new Account: ${c.toSuiAddress()}`));return}try{let c=f.readFileSync(`${o}/.env`,"utf8").match(/PRIVATE_KEY=(.+)/);if(c&&c[1]){r=c[1];let a=new W({secretKey:r}).getKeypair();if(t){let u=t.substring(0,t.lastIndexOf("/"));f.existsSync(u)||f.mkdirSync(u,{recursive:!0}),f.writeFileSync(t,`export const PRIVATEKEY = '${r}';
66
+ `))}console.log(S.blue(`Force generate new Account: ${c.toSuiAddress()}`));return}try{let c=h.readFileSync(`${o}/.env`,"utf8").match(/PRIVATE_KEY=(.+)/);if(c&&c[1]){n=c[1];let a=new G({secretKey:n}).getKeypair();if(t){let u=t.substring(0,t.lastIndexOf("/"));h.existsSync(u)||h.mkdirSync(u,{recursive:!0}),h.writeFileSync(t,`export const PRIVATEKEY = '${n}';
64
67
  export const ACCOUNT = '${a.toSuiAddress()}';
65
68
  `),console.log(S.green(`File created at: ${t}
66
- `))}console.log(S.blue(`Using existing Account: ${a.toSuiAddress()}`));return}}catch{}let s=new W().getKeypair();if(r=s.getSecretKey(),f.writeFileSync(`${o}/.env`,`PRIVATE_KEY=${r}`),console.log(S.green(`File created at: ${o}/.env`)),t){let i=t.substring(0,t.lastIndexOf("/"));f.existsSync(i)||f.mkdirSync(i,{recursive:!0}),f.writeFileSync(t,`export const PRIVATEKEY = '${r}';
69
+ `))}console.log(S.blue(`Using existing Account: ${a.toSuiAddress()}`));return}}catch{}let s=new G().getKeypair();if(n=s.getSecretKey(),h.writeFileSync(`${o}/.env`,`PRIVATE_KEY=${n}`),console.log(S.green(`File created at: ${o}/.env`)),t){let i=t.substring(0,t.lastIndexOf("/"));h.existsSync(i)||h.mkdirSync(i,{recursive:!0}),h.writeFileSync(t,`export const PRIVATEKEY = '${n}';
67
70
  export const ACCOUNT = '${s.toSuiAddress()}';
68
71
  `),console.log(S.green(`File created at: ${t}
69
- `))}console.log(S.blue(`Generate new Account: ${s.toSuiAddress()}`))}var Kt={command:"generate-key",describe:"Generate a new account key pair and save it to a .env file, with an option to output to a TypeScript file.",builder:{force:{type:"boolean",default:!1,desc:"Force generate a new key pair"},"output-ts-path":{type:"string",desc:"Specify the path to output the TypeScript file containing the key pair (e.g., ./src/config/key.ts)"}},async handler({force:e,"output-ts-path":t}){try{await _e(e,t)}catch(o){console.error("Error generating account:",o),process.exit(1)}process.exit(0)}},xe=Kt;import{Dubhe as Rt}from"@0xobelisk/sui-client";import Ce from"chalk";import Tt from"dotenv";Tt.config();async function ke(e,t=2){try{console.log(Ce.blue("Note: You need at least 2 SUI for transaction fees and staking, and registering a Dapp will reserve 1 SUI for Dubhe Dapp Staking, which can be retrieved upon unregistering."));let o=process.env.PRIVATE_KEY;if(!o)throw new g(`Missing PRIVATE_KEY environment variable.
72
+ `))}console.log(S.blue(`Generate new Account: ${s.toSuiAddress()}`))}var Mt={command:"generate-key",describe:"Generate a new account key pair and save it to a .env file, with an option to output to a TypeScript file.",builder:{force:{type:"boolean",default:!1,desc:"Force generate a new key pair"},"output-ts-path":{type:"string",desc:"Specify the path to output the TypeScript file containing the key pair (e.g., ./src/config/key.ts)"}},async handler({force:e,"output-ts-path":t}){try{await we(e,t)}catch(o){console.error("Error generating account:",o),process.exit(1)}process.exit(0)}},ve=Mt;import{Dubhe as Ot}from"@0xobelisk/sui-client";import Kt from"chalk";import Rt from"dotenv";Rt.config();async function _e(e){try{let t=process.env.PRIVATE_KEY;if(!t)throw new g(`Missing PRIVATE_KEY environment variable.
70
73
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
71
- in your contracts directory to use the default sui private key.`);if(k(o)===!1)throw new g("Please check your privateKey.");let s=await new Rt({secretKey:process.env.PRIVATE_KEY,networkType:e}).getBalance(),i=Number(s.totalBalance)/1e9;if(i<t)throw new g(`Your account balance ${i.toFixed(4)} SUI is less than ${t} SUI. Please get more SUI.`);console.log(Ce.green(`Current account balance: ${i.toFixed(4)} SUI`))}catch(o){throw new g("Failed to check balance: "+o)}}var Nt={command:"check-balance",describe:"Check the balance of the account",builder:{network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Network to check balance on"},amount:{type:"number",default:2,desc:"Amount of SUI to check balance for"}},async handler({network:e,amount:t}){try{await ke(e,t)}catch(o){console.error("Error checking balance:",o),process.exit(1)}process.exit(0)}},$e=Nt;import*as Se from"fs/promises";import{mkdirSync as jt,writeFileSync as Ut}from"fs";import{dirname as Vt}from"path";async function Yt(e,t){try{let o=await Se.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}`)}}function qt(e,t,o,r){let n=`type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
74
+ in your contracts directory to use the default sui private key.`);if($(t)===!1)throw new g("Please check your privateKey.");let r=await new Ot({secretKey:process.env.PRIVATE_KEY,networkType:e}).getBalance(),s=Number(r.totalBalance)/1e9;if(s===0)throw new g("Your account balance is 0 SUI. Please get some SUI to proceed.");console.log(Kt.green(`Current account balance: ${s.toFixed(4)} SUI`))}catch(t){throw new g("Failed to check balance: "+t)}}var Tt={command:"check-balance",describe:"Check the balance of the account",builder:{network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Network to check balance on"}},async handler({network:e}){try{await _e(e)}catch(t){console.error("Error checking balance:",t),process.exit(1)}process.exit(0)}},xe=Tt;import*as ke from"fs/promises";import{mkdirSync as Nt,writeFileSync as jt}from"fs";import{dirname as Ut}from"path";async function Vt(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}`)}}function Yt(e,t,o,n){let r=`type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
72
75
 
73
76
  export const NETWORK: NetworkType = '${e}';
74
77
 
@@ -76,5 +79,5 @@ export const PACKAGE_ID = '${t}'
76
79
 
77
80
  ${o.map(s=>`export const ${s.name.split("::")[2]}_Object_Id = '${s.objectId}'`).join(`
78
81
  `)}
79
- `;Bt(n,r,"storeConfig")}async function Bt(e,t,o){jt(Vt(t),{recursive:!0}),Ut(t,e),o!==void 0&&console.log(`${o}: ${t}`)}async function Ee(e,t,o){let n=`${process.cwd()}/contracts/${e.name}`,s=await Yt(n,t);qt(s.network,s.packageId,s.schemas,o)}import{loadConfig as Lt}from"@0xobelisk/sui-common";var zt={command:"config-store",describe:"Store configuration for the Dubhe project",builder:{"config-path":{type:"string",default:"dubhe.config.ts",desc:"Path to the config file"},network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Network to store config for"},"output-ts-path":{type:"string",desc:"Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)"}},async handler({"config-path":e,network:t,"output-ts-path":o}){try{let r=await Lt(e);await Ee(r,t,o)}catch(r){console.error("Error storing config:",r),process.exit(1)}process.exit(0)}},Ie=zt;var De=[me,pe,ue,ge,ye,be,ve,we,xe,$e,Ie];import*as Ae from"dotenv";import Pe from"chalk";Ae.config();Ht(Jt(process.argv)).scriptName("dubhe").command(De).strict().fail((e,t)=>{console.error(Pe.red(e)),e.includes("Missing required argument")&&console.log(Pe.yellow(`Run 'pnpm dubhe ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),A(t),console.log(""),process.exit(1)}).alias({h:"help"}).argv;
82
+ `;qt(r,n,"storeConfig")}async function qt(e,t,o){Nt(Ut(t),{recursive:!0}),jt(t,e),o!==void 0&&console.log(`${o}: ${t}`)}async function Ce(e,t,o){let r=`${process.cwd()}/contracts/${e.name}`,s=await Vt(r,t);Yt(s.network,s.packageId,s.schemas,o)}import{loadConfig as Bt}from"@0xobelisk/sui-common";var Lt={command:"config-store",describe:"Store configuration for the Dubhe project",builder:{"config-path":{type:"string",default:"dubhe.config.ts",desc:"Path to the config file"},network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Network to store config for"},"output-ts-path":{type:"string",desc:"Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)"}},async handler({"config-path":e,network:t,"output-ts-path":o}){try{let n=await Bt(e);await Ce(n,t,o)}catch(n){console.error("Error storing config:",n),process.exit(1)}process.exit(0)}},$e=Lt;var Se=[ue,le,de,pe,fe,he,ye,be,ve,xe,$e];import*as Ie from"dotenv";import Ee from"chalk";Ie.config();zt(Ht(process.argv)).scriptName("dubhe").command(Se).strict().fail((e,t)=>{console.error(Ee.red(e)),e.includes("Missing required argument")&&console.log(Ee.yellow(`Run 'pnpm dubhe ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),F(t),console.log(""),process.exit(1)}).alias({h:"help"}).argv;
80
83
  //# sourceMappingURL=dubhe.js.map
package/dist/dubhe.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dubhe.ts","../src/utils/startNode.ts","../src/utils/printDubhe.ts","../src/utils/publishHandler.ts","../src/utils/errors.ts","../src/utils/utils.ts","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/utils/upgradeHandler.ts","../src/commands/upgrade.ts","../src/commands/test.ts","../src/commands/build.ts","../src/commands/hello.ts","../src/utils/generateAccount.ts","../src/commands/generateKey.ts","../src/utils/checkBalance.ts","../src/commands/checkBalance.ts","../src/utils/storeConfig.ts","../src/commands/configStore.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 \"dubhe\" for e.g. ts-node)\n .scriptName(\"dubhe\")\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 dubhe ${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 { execSync, spawn } from 'child_process';\nimport chalk from 'chalk';\nimport { printDubhe } from './printDubhe';\nimport { delay, DubheCliError, publishDubheFramework, validatePrivateKey } from '../utils';\nimport { Dubhe } from '@0xobelisk/sui-client';\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui/client';\n\nfunction isSuiStartRunning(): boolean {\n\ttry {\n\t\tconst cmd =\n\t\t\tprocess.platform === 'win32'\n\t\t\t\t? `tasklist /FI \"IMAGENAME eq sui.exe\" /FO CSV /NH`\n\t\t\t\t: 'pgrep -f \"sui start\"';\n\n\t\tconst result = execSync(cmd).toString().trim();\n\t\treturn process.platform === 'win32'\n\t\t\t? result.toLowerCase().includes('sui.exe')\n\t\t\t: result.length > 0;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\nasync function printAccounts() {\n\t// These private keys are used for testing purposes only, do not use them in production.\n\tconst privateKeys = [\n\t\t\"suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v\",\n\t\t\"suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s\",\n\t\t\"suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc\",\n\t\t\"suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c\",\n\t\t\"suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57\",\n\t\t\"suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c\",\n\t]\n\tconsole.log(\"📝Accounts\")\n\tconsole.log(\"==========\")\n\tprivateKeys.forEach((privateKey, index) => {\n\t\tconst dubhe = new Dubhe({ secretKey: privateKey });\n\t\tconst keypair = dubhe.getKeypair();\n\t\tspawn(\n\t\t\t'curl',\n\t\t\t['--location', '--request', 'POST', 'http://127.0.0.1:9123/gas', '--header', 'Content-Type: application/json', '--data-raw', `{\"FixedAmountRequest\": {\"recipient\": \"${keypair.toSuiAddress()}\"}}`],\n\t\t\t{\n\t\t\t\tenv: { ...process.env },\n\t\t\t\tstdio: 'ignore',\n\t\t\t\tdetached: true,\n\t\t\t}\n\t\t\t)\n\t\tconsole.log(` ┌─ Account #${index}: ${keypair.toSuiAddress()}(1000 SUI)`);\n\t\tconsole.log(` └─ Private Key: ${privateKey}`);\n\t});\n\tconsole.log(\"==========\")\n\tconsole.log(chalk.yellow(\"⚠️WARNING: These accounts, and their private keys, are publicly known.\"));\n\tconsole.log(chalk.yellow(\"Any funds sent to them on Mainnet or any other live network WILL BE LOST.\"));\n}\n\texport async function startLocalNode() {\n\tif (isSuiStartRunning()) {\n\t\tconsole.log(chalk.yellow('\\n⚠️ Warning: Local Node Already Running'));\n\t\tconsole.log(chalk.yellow(' ├─ Cannot start a new instance'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(' └─ Please stop the existing process first')\n\t\t);\n\t\treturn;\n\t}\n\n\tprintDubhe();\n\tconsole.log('🚀 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: 'ignore',\n\t\t\t\tdetached: true,\n\t\t\t}\n\t\t);\n\n\t\tsuiProcess.on('error', error => {\n\t\t\tconsole.error(chalk.red('\\n❌ Failed to Start Local Node'));\n\t\t\tconsole.error(chalk.red(` └─ Error: ${error.message}`));\n\t\t});\n\t\tawait delay(5000);\n\t\tconsole.log(' ├─ Faucet: Enabled');\n\t\tconsole.log(' └─ Force Regenesis: Yes');\n\t\tconsole.log(' └─ HTTP server: http://127.0.0.1:9000/');\n\t\tconsole.log(' └─ Faucet server: http://127.0.0.1:9123/');\n\n\t\tawait printAccounts();\n\n\t\tawait delay(2000);\n\n\t\tconst privateKeyFormat = validatePrivateKey(\"suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c\");\n\t\tif (privateKeyFormat === false) {\n\t\t\tthrow new DubheCliError(`Please check your privateKey.`);\n\t\t}\n\n\t\tconst dubhe = new Dubhe({ secretKey: privateKeyFormat });\n\t\tconst client = new SuiClient({ url: getFullnodeUrl('localnet') });\n\t\tconst originalLog = console.log;\n\n\t\tconsole.log = () => {};\n\t\tawait publishDubheFramework(client, dubhe, 'localnet');\n\t\tconsole.log = originalLog;\n\n\t\tprocess.on('SIGINT', () => {\n\t\t\tconsole.log(chalk.yellow('\\n🔔 Stopping Local Node...'));\n\t\t\tif (suiProcess) {\n\t\t\t\tsuiProcess.kill();\n\t\t\t\tconsole.log(chalk.green('✅ Local Node Stopped'));\n\t\t\t}\n\t\t\tprocess.exit();\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red('\\n❌ Failed to Start Local Node'));\n\t\tconsole.error(chalk.red(` └─ Error: ${error.message}`));\n\t}\n}\n","import chalk from \"chalk\";\n\nexport function printDubhe() {\n console.log(\n chalk.yellow(`\nWelcome to Dubhe\n\\t\\t\\t --from team@obelisk\n ________ ___ ___ ________ ___ ___ _______ \n |\\\\ ___ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ __ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ ___ \\\\ \n \\\\ \\\\ \\\\_|\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ /\\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __/| \n \\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __ \\\\ \\\\ __ \\\\ \\\\ \\\\_|/__ \n \\\\ \\\\ \\\\_\\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\_|\\\\ \\\\ \n \\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\__\\\\ \\\\__\\\\ \\\\_______\\\\\n \\\\|_______|\\\\|_______|\\\\|_______|\\\\|__|\\\\|__|\\\\|_______| \n \n`)\n );\n}\n","import { Dubhe } 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 { DubheCliError } from './errors';\nimport {\n\tupdateVersionInFile,\n\tsaveContractData,\n\tvalidatePrivateKey,\n\tschema,\n\tupdateDubheDependency,\n\tswitchEnv,\n\tdelay,\n} from './utils';\nimport { DubheConfig } from '@0xobelisk/sui-common';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nfunction removeEnvContent(\n\tfilePath: string,\n\tnetworkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n): void {\n\tif (!fs.existsSync(filePath)) {\n\t\treturn;\n\t}\n\tconst content = fs.readFileSync(filePath, 'utf-8');\n\tconst regex = new RegExp(\n\t\t`\\\\[env\\\\.${networkType}\\\\][\\\\s\\\\S]*?(?=\\\\[|$)`,\n\t\t'g'\n\t);\n\tconst updatedContent = content.replace(regex, '');\n\tfs.writeFileSync(filePath, updatedContent, 'utf-8');\n}\n\ninterface EnvConfig {\n\tchainId: string;\n\toriginalPublishedId: string;\n\tlatestPublishedId: string;\n\tpublishedVersion: number;\n}\n\nfunction updateEnvFile(\n\tfilePath: string,\n\tnetworkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\toperation: 'publish' | 'upgrade',\n\tchainId: string,\n\tpublishedId: string\n): void {\n\tconst envFilePath = path.resolve(filePath);\n\tconst envContent = fs.readFileSync(envFilePath, 'utf-8');\n\tconst envLines = envContent.split('\\n');\n\n\tconst networkSectionIndex = envLines.findIndex(\n\t\tline => line.trim() === `[env.${networkType}]`\n\t);\n\tconst config: EnvConfig = {\n\t\tchainId: chainId,\n\t\toriginalPublishedId: '',\n\t\tlatestPublishedId: '',\n\t\tpublishedVersion: 0,\n\t};\n\n\tif (networkSectionIndex === -1) {\n\t\t// If network section is not found, add a new section\n\t\tif (operation === 'publish') {\n\t\t\tconfig.originalPublishedId = publishedId;\n\t\t\tconfig.latestPublishedId = publishedId;\n\t\t\tconfig.publishedVersion = 1;\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Network type [env.${networkType}] not found in the file and cannot upgrade.`\n\t\t\t);\n\t\t}\n\t} else {\n\t\tfor (let i = networkSectionIndex + 1; i < envLines.length; i++) {\n\t\t\tconst line = envLines[i].trim();\n\t\t\tif (line.startsWith('[')) break; // End of the current network section\n\n\t\t\tconst [key, value] = line\n\t\t\t\t.split('=')\n\t\t\t\t.map(part => part.trim().replace(/\"/g, ''));\n\t\t\tswitch (key) {\n\t\t\t\tcase 'original-published-id':\n\t\t\t\t\tconfig.originalPublishedId = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'latest-published-id':\n\t\t\t\t\tconfig.latestPublishedId = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'published-version':\n\t\t\t\t\tconfig.publishedVersion = parseInt(value, 10);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (operation === 'publish') {\n\t\t\tconfig.originalPublishedId = publishedId;\n\t\t\tconfig.latestPublishedId = publishedId;\n\t\t\tconfig.publishedVersion = 1;\n\t\t} else if (operation === 'upgrade') {\n\t\t\tconfig.latestPublishedId = publishedId;\n\t\t\tconfig.publishedVersion += 1;\n\t\t}\n\t}\n\n\tconst updatedSection = `\n[env.${networkType}]\nchain-id = \"${config.chainId}\"\noriginal-published-id = \"${config.originalPublishedId}\"\nlatest-published-id = \"${config.latestPublishedId}\"\npublished-version = \"${config.publishedVersion}\"\n`;\n\n\tconst newEnvContent =\n\t\tnetworkSectionIndex === -1\n\t\t\t? envContent + updatedSection\n\t\t\t: envLines.slice(0, networkSectionIndex).join('\\n') +\n\t\t\t updatedSection;\n\n\tfs.writeFileSync(envFilePath, newEnvContent, 'utf-8');\n}\nfunction capitalizeAndRemoveUnderscores(input: string): string {\n\treturn input\n\t\t.split('_')\n\t\t.map((word, index) => {\n\t\t\treturn index === 0\n\t\t\t\t? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n\t\t\t\t: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n\t\t})\n\t\t.join('');\n}\n\nfunction getLastSegment(input: string): string {\n\tconst segments = input.split('::');\n\treturn segments.length > 0 ? segments[segments.length - 1] : '';\n}\n\nfunction buildContract(projectPath: string): string[][] {\n\tlet modules: any, dependencies: any;\n\ttry {\n\t\tconst buildResult = JSON.parse(\n\t\t\texecSync(\n\t\t\t\t`sui move build --dump-bytecode-as-base64 --path ${projectPath}`,\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf-8',\n\t\t\t\t\tstdio: 'pipe',\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tmodules = buildResult.modules;\n\t\tdependencies = buildResult.dependencies;\n\t\tconsole.log(' └─ Build successful');\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Build failed'));\n\t\tconsole.error(error.stdout);\n\t\tprocess.exit(1);\n\t}\n\treturn [modules, dependencies];\n}\n\nasync function publishContract(\n\tclient: SuiClient,\n\tdubhe: Dubhe,\n\tdubheConfig: DubheConfig,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tprojectPath: string,\n\tgasBudget?: number\n) {\n\tconst chainId = await client.getChainIdentifier();\n\tremoveEnvContent(`${projectPath}/Move.lock`, network);\n\tconsole.log('\\n🚀 Starting Contract Publication...');\n\tconsole.log(` ├─ Project: ${projectPath}`);\n\tconsole.log(` ├─ Network: ${network}`);\n\tconsole.log(` ├─ ChainId: ${chainId}`);\n\tconsole.log(' ├─ Validating Environment...');\n\n\tconst keypair = dubhe.getKeypair();\n\tconsole.log(` └─ Account: ${keypair.toSuiAddress()}`);\n\n\tconsole.log('\\n📦 Building Contract...');\n\tconst [modules, dependencies] = buildContract(projectPath);\n\n\tconsole.log('\\n🔄 Publishing Contract...');\n\tconst tx = new Transaction();\n\tif (gasBudget) {\n\t\ttx.setGasBudget(gasBudget);\n\t}\n\tconst [upgradeCap] = tx.publish({ modules, dependencies });\n\ttx.transferObjects([upgradeCap], keypair.toSuiAddress());\n\n\tlet result: SuiTransactionBlockResponse;\n\ttry {\n\t\tresult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: tx,\n\t\t\toptions: { showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Publication failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (result.effects?.status.status === 'failure') {\n\t\tconsole.log(chalk.red(' └─ Publication failed'));\n\t\tprocess.exit(1);\n\t}\n\n\tconsole.log(' ├─ Processing publication results...');\n\tlet version = 1;\n\tlet packageId = '';\n\tlet schemas: schema[] = [];\n\tlet upgradeCapId = '';\n\n\tresult.objectChanges!.map(object => {\n\t\tif (object.type === 'published') {\n\t\t\tconsole.log(` ├─ Package ID: ${object.packageId}`);\n\t\t\tpackageId = object.packageId;\n\t\t}\n\t\tif (\n\t\t\tobject.type === 'created' &&\n\t\t\tobject.objectType === '0x2::package::UpgradeCap'\n\t\t) {\n\t\t\tconsole.log(` ├─ Upgrade Cap: ${object.objectId}`);\n\t\t\tupgradeCapId = object.objectId;\n\t\t}\n\t});\n\n\tconsole.log(` └─ Transaction: ${result.digest}`);\n\n\tupdateEnvFile(\n\t\t`${projectPath}/Move.lock`,\n\t\tnetwork,\n\t\t'publish',\n\t\tchainId,\n\t\tpackageId\n\t);\n\n\tconsole.log('\\n⚡ Executing Deploy Hook...');\n\tawait delay(5000);\n\n\tconst deployHookTx = new Transaction();\n\tdeployHookTx.moveCall({\n\t\ttarget: `${packageId}::deploy_hook::run`,\n\t\targuments: [ deployHookTx.object('0x6') ],\n\t});\n\n\tlet deployHookResult: SuiTransactionBlockResponse;\n\ttry {\n\t\tdeployHookResult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: deployHookTx,\n\t\t\toptions: { showEffects: true, showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Deploy hook execution failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (deployHookResult.effects?.status.status === 'success') {\n\t\tconsole.log(' ├─ Hook execution successful');\n\t\tconsole.log(` ├─ Transaction: ${deployHookResult.digest}`);\n\n\t\tconsole.log('\\n📋 Created Schemas:');\n\t\tdeployHookResult.objectChanges?.map(object => {\n\t\t\tif (\n\t\t\t\tobject.type === 'created' &&\n\t\t\t\tobject.objectType.includes('_schema') &&\n\t\t\t\t!object.objectType.includes('dynamic_field')\n\t\t\t) {\n\t\t\t\tconsole.log(` ├─ ${object.objectType}`);\n\t\t\t\tconsole.log(` └─ ID: ${object.objectId}`);\n\n\t\t\t\tlet structure: Record<string, string> = {};\n\t\t\t\tfor (let schemaKey in dubheConfig.schemas) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcapitalizeAndRemoveUnderscores(schemaKey) ===\n\t\t\t\t\t\tgetLastSegment(object.objectType)\n\t\t\t\t\t) {\n\t\t\t\t\t\tstructure = dubheConfig.schemas[schemaKey].structure;\n\t\t\t\t\t}\n\t\t\t\t}\n\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\tstructure,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tsaveContractData(\n\t\t\tdubheConfig.name,\n\t\t\tnetwork,\n\t\t\tpackageId,\n\t\t\tupgradeCapId,\n\t\t\tversion,\n\t\t\tschemas\n\t\t);\n\t\tconsole.log('\\n✅ Contract Publication Complete\\n');\n\t} else {\n\t\tconsole.log(chalk.yellow(' └─ Deploy hook execution failed'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t' Please republish or manually call deploy_hook::run'\n\t\t\t)\n\t\t);\n\t\tconsole.log(chalk.yellow(' Please check the transaction digest:'));\n\t\tconsole.log(chalk.yellow(` ${deployHookResult.digest}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nexport async function publishDubheFramework(\n\tclient: SuiClient,\n\tdubhe: Dubhe,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n\tconst path = process.cwd();\n\tconst projectPath = `${path}/contracts/dubhe-framework`;\n\tconst chainId = await client.getChainIdentifier();\n\tconsole.log(` └─ Chain ID: ${chainId}`);\n\tremoveEnvContent(`${projectPath}/Move.lock`, network);\n\tconsole.log('\\n🚀 Starting Contract Publication...');\n\tconsole.log(` ├─ Project: ${projectPath}`);\n\tconsole.log(` ├─ Network: ${network}`);\n\tconsole.log(` ├─ ChainId: ${chainId}`);\n\tconsole.log(' ├─ Validating Environment...');\n\n\tconst keypair = dubhe.getKeypair();\n\tconsole.log(` └─ Account: ${keypair.toSuiAddress()}`);\n\n\tconsole.log('\\n📦 Building Contract...');\n\tconst [modules, dependencies] = buildContract(projectPath);\n\n\tconsole.log('\\n🔄 Publishing Contract...');\n\tconst tx = new Transaction();\n\tconst [upgradeCap] = tx.publish({ modules, dependencies });\n\ttx.transferObjects([upgradeCap], keypair.toSuiAddress());\n\n\tlet result: SuiTransactionBlockResponse;\n\ttry {\n\t\tresult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: tx,\n\t\t\toptions: { showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Publication failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (result.effects?.status.status === 'failure') {\n\t\tconsole.log(chalk.red(' └─ Publication failed'));\n\t\tprocess.exit(1);\n\t}\n\n\tconsole.log(' ├─ Processing publication results...');\n\tlet version = 1;\n\tlet packageId = '';\n\tlet schemas: schema[] = [];\n\tlet upgradeCapId = '';\n\n\tresult.objectChanges!.map(object => {\n\t\tif (object.type === 'published') {\n\t\t\tconsole.log(` ├─ Package ID: ${object.packageId}`);\n\t\t\tpackageId = object.packageId;\n\t\t}\n\t\tif (\n\t\t\tobject.type === 'created' &&\n\t\t\tobject.objectType === '0x2::package::UpgradeCap'\n\t\t) {\n\t\t\tconsole.log(` ├─ Upgrade Cap: ${object.objectId}`);\n\t\t\tupgradeCapId = object.objectId;\n\t\t}\n\t});\n\n\tconsole.log(` └─ Transaction: ${result.digest}`);\n\n\tupdateEnvFile(\n\t\t`${projectPath}/Move.lock`,\n\t\tnetwork,\n\t\t'publish',\n\t\tchainId,\n\t\tpackageId\n\t);\n\n\tsaveContractData(\n\t\t'dubhe-framework',\n\t\tnetwork,\n\t\tpackageId,\n\t\tupgradeCapId,\n\t\tversion,\n\t\tschemas\n\t);\n}\n\nexport async function publishHandler(\n\tdubheConfig: DubheConfig,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tcontractName?: string,\n\tgasBudget?: number\n) {\n\tawait switchEnv(network);\n\n\tconst privateKey = process.env.PRIVATE_KEY;\n\tif (!privateKey) {\n\t\tthrow new DubheCliError(\n\t\t\t`Missing PRIVATE_KEY environment variable.\nRun 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\nin your contracts directory to use the default sui private key.`\n\t\t);\n\t}\n\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\tif (privateKeyFormat === false) {\n\t\tthrow new DubheCliError(`Please check your privateKey.`);\n\t}\n\n\tconst dubhe = new Dubhe({ secretKey: privateKeyFormat });\n\tconst client = new SuiClient({ url: getFullnodeUrl(network) });\n\n\tif (contractName == 'dubhe-framework') {\n\t\tawait publishDubheFramework(client, dubhe, network);\n\t} else {\n\t\tconst path = process.cwd();\n\t\tconst projectPath = `${path}/contracts/${dubheConfig.name}`;\n\t\tupdateDubheDependency(`${projectPath}/Move.toml`, network);\n\t\tawait publishContract(\n\t\t\tclient,\n\t\t\tdubhe,\n\t\t\tdubheConfig,\n\t\t\tnetwork,\n\t\t\tprojectPath,\n\t\t\tgasBudget\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\tname = 'NotInsideProjectError';\n\tmessage = 'You are not inside a Dubhe project';\n}\n\nexport class DubheCliError extends Error {\n\tname = 'DubheCliError';\n}\n\nexport class UpgradeError extends Error {\n\tname = 'UpgradeError';\n}\n\nexport class FsIibError extends Error {\n\tname = 'FsIibError';\n}\n\nexport function logError(error: unknown) {\n\tif (error instanceof ValidationError) {\n\t\tconsole.log(chalk.redBright(error.message));\n\t} else if (error instanceof ZodError) {\n\t\t// TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n\t\tconst validationError = fromZodError(error, {\n\t\t\tprefixSeparator: '\\n- ',\n\t\t\tissueSeparator: '\\n- ',\n\t\t});\n\t\tconsole.log(chalk.redBright(validationError.message));\n\t} else if (error instanceof NotInsideProjectError) {\n\t\tconsole.log(chalk.red(error.message));\n\t\tconsole.log('');\n\t\t// TODO add docs to the website and update the link to the specific page\n\t\tconsole.log(\n\t\t\tchalk.blue(\n\t\t\t\t`To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk`\n\t\t\t)\n\t\t);\n\t} else if (error instanceof DubheCliError) {\n\t\tconsole.log(chalk.red(error));\n\t} else {\n\t\tconsole.log(error);\n\t}\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';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\nimport { spawn } from 'child_process';\n\nexport type schema = {\n\tname: string;\n\tobjectId: string;\n\tstructure: Record<string, string>\n};\n\nexport type DeploymentJsonType = {\n\tprojectName: string;\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\tpackageId: string;\n\tupgradeCap: string;\n\tversion: number;\n\tschemas: schema[];\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 getOnchainSchemas(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<schema[]> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.schemas;\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\tupgradeCap: string,\n\tversion: number,\n schemas: schema[],\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\nfunction getDubheDependency(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'): string {\n\tswitch (network) {\n\t\tcase 'localnet':\n\t\t\treturn 'Dubhe = { local = \"../dubhe-framework\" }';\n\t\tcase 'testnet':\n\t\t\treturn 'Dubhe = { git = \"https://github.com/0xobelisk/dubhe-framework.git\", rev = \"dubhe-testnet-v1.0.0\" }';\n\t\tcase 'mainnet':\n\t\t\treturn 'Dubhe = { git = \"https://github.com/0xobelisk/dubhe-framework.git\", rev = \"dubhe-mainnet-v1.0.0\" }';\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported network: ${network}`);\n\t}\n}\n\nexport function updateDubheDependency(filePath: string, network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n\tconst fileContent = fs.readFileSync(filePath, 'utf-8');\n\tconst newDependency = getDubheDependency(network);\n\tconst updatedContent = fileContent.replace(/Dubhe = \\{.*\\}/, newDependency);\n\tfs.writeFileSync(filePath, updatedContent, 'utf-8');\n\tconsole.log(`Updated Dubhe dependency in ${filePath} for ${network}.`);\n}\nexport async function switchEnv(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n\ttry {\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\tconst suiProcess = spawn(\n\t\t\t\t'sui',\n\t\t\t\t['client', 'switch', '--env', network],\n\t\t\t\t{\n\t\t\t\t\tenv: { ...process.env },\n\t\t\t\t\tstdio: 'pipe'\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tsuiProcess.stdout.on('data', data => {\n\t\t\t\tconsole.log(chalk.green(`${data.toString()}`));\n\t\t\t});\n\n\t\t\tsuiProcess.stderr.on('data', data => {\n\t\t\t\tconsole.error(chalk.red('\\n❌ Failed to Switch Env'));\n\t\t\t\tconsole.error(chalk.red(` Error: ${data.toString()}`));\n\t\t\t});\n\n\t\t\tsuiProcess.on('error', error => {\n\t\t\t\tconsole.error(chalk.red('\\n❌ Failed to Switch Env'));\n\t\t\t\tconsole.error(chalk.red(` Error: ${error.message}`));\n\t\t\t\treject(error); // Reject promise on error\n\t\t\t});\n\n\t\t\tsuiProcess.on('exit', (code) => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tconsole.error(chalk.red(`\\n❌ Process exited with code: ${code}`));\n\t\t\t\t\treject(new Error(`Process exited with code: ${code}`));\n\t\t\t\t} else {\n\t\t\t\t\tresolve(); // Resolve promise on successful exit\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t} catch (error) {\n\t\tconsole.error(chalk.red('\\n❌ Failed to Switch Env'));\n\t\tconsole.error(chalk.red(` └─ Error: ${error}`));\n\t}\n}\n\nexport const delay = (ms: number) =>\n\tnew Promise(resolve => setTimeout(resolve, ms));\n","import type { CommandModule } from 'yargs';\nimport { startLocalNode } from '../utils/startNode';\n\nconst commandModule: CommandModule = {\n\tcommand: 'node',\n\n\tdescribe: 'Manage local Sui node',\n\n\tbuilder(yargs) {\n\t\treturn yargs\n\t},\n\n\tasync handler() {\n\t\ttry {\n\t\t\tawait startLocalNode();\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\nexport default commandModule;\n","import { Dubhe } 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, DubheCliError } 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 Dubhe 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 Dubhe 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 DubheCliError(\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 DubheCliError(`Please check your PRIVATE_KEY.`);\n\t\t\t}\n\t\t\tconst dubhe = new Dubhe({\n\t\t\t\tsecretKey: privateKeyFormat,\n\t\t\t});\n\t\t\tconst keypair = dubhe.getKeypair();\n\t\t\tfaucet_address = keypair.toSuiAddress();\n\t\t} else {\n\t\t\tfaucet_address = recipient;\n\t\t}\n\n\t\tconsole.log('\\n🌊 Starting Faucet Operation...');\n\t\tconsole.log(` ├─ Network: ${network}`);\n\n\t\tif (recipient === undefined) {\n\t\t\tconsole.log(' ├─ Using Environment PrivateKey');\n\t\t\tconsole.log(` ├─ Generated Address: ${faucet_address}`);\n\t\t} else {\n\t\t\tconsole.log(` ├─ Using Provided Address: ${faucet_address}`);\n\t\t}\n\n\t\tconsole.log(' ├─ Requesting funds from faucet...');\n\t\tawait requestSuiFromFaucetV0({\n\t\t\thost: getFaucetHost(network),\n\t\t\trecipient: faucet_address,\n\t\t});\n\n\t\tconsole.log(' └─ Checking balance...');\n\t\tconst client = new SuiClient({ url: getFullnodeUrl(network) });\n\t\tlet params = {\n\t\t\towner: faucet_address,\n\t\t} as GetBalanceParams;\n\n\t\tconst balance = await client.getBalance(params);\n\n\t\tconsole.log('\\n💰 Account Summary');\n\t\tconsole.log(` ├─ Address: ${faucet_address}`);\n\t\tconsole.log(\n\t\t\t` └─ Balance: ${(\n\t\t\t\tNumber(balance.totalBalance) / 1_000_000_000\n\t\t\t).toFixed(4)} SUI`\n\t\t);\n\n\t\tconsole.log('\\n✅ Faucet Operation Complete\\n');\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { schemaGen, loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport chalk from 'chalk';\n\ntype Options = {\n\t'config-path'?: string;\n\tnetwork?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\t'framework-id'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'schemagen',\n\n\tdescribe: 'Autogenerate Dubhe schemas based on the config file',\n\n\tbuilder: {\n\t\t'config-path': {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'dubhe.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\t'framework-id': {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Framework Package ID',\n\t\t},\n\t},\n\n\tasync handler({\n\t\t'config-path': configPath,\n\t\tnetwork,\n\t\t'framework-id': frameworkId,\n\t}) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait schemaGen(dubheConfig, 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, DubheConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\tnetwork: any;\n\t'config-path': string;\n\t'contract-name'?: string;\n\t'gas-budget'?: number;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'publish',\n\n\tdescribe: 'Publish dubhe 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\t'config-path': {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'dubhe.config.ts',\n\t\t\t\tdesc: 'Configuration file path',\n\t\t\t},\n\t\t\t'contract-name': {\n\t\t\t\ttype: 'string',\n\t\t\t\tdesc: 'Optional contract name in contracts/ directory',\n\t\t\t},\n\t\t\t'gas-budget': {\n\t\t\t\ttype: 'number',\n\t\t\t\tdesc: 'Optional gas budget for the transaction',\n\t\t\t\toptional: true,\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({\n\t\tnetwork,\n\t\t'config-path': configPath,\n\t\t'contract-name': contractName,\n\t\t'gas-budget': gasBudget,\n\t}) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait publishHandler(dubheConfig, network, contractName, gasBudget);\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 { Dubhe } 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 { DubheCliError, UpgradeError } from './errors';\nimport {\n\tupdateVersionInFile,\n\tgetOldPackageId,\n\tgetVersion,\n\tgetUpgradeCap,\n\tsaveContractData,\n\tvalidatePrivateKey, getOnchainSchemas, switchEnv, delay,\n} from './utils';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { DubheConfig } from '@0xobelisk/sui-common';\n\ntype ObjectContent = {\n\ttype: string;\n\tfields: Record<string, any>;\n\thasPublicTransfer: boolean;\n\tdataType: string;\n};\n\ntype Field = {\n\tname: string;\n\ttype: string;\n}\n\ntype Migration = {\n\tschemaName: string;\n\tfields: Field[];\n};\n\nfunction updateMigrateMethod(projectPath: string, migrations: Migration[]): void {\n\tmigrations.forEach((migration) => {\n\t\tlet filePath = `${projectPath}/sources/codegen/schemas/${migration.schemaName}.move`;\n\t\tconst fileContent = fs.readFileSync(filePath, 'utf-8');\n\t\tconst migrateMethodRegex = new RegExp(`public fun migrate\\\\(_${migration.schemaName}: &mut ${capitalizeAndRemoveUnderscores(migration.schemaName)}, _cap: &UpgradeCap\\\\) {[^}]*}`);\n\t\tconst newMigrateMethod = `\npublic fun migrate(${migration.schemaName}: &mut ${capitalizeAndRemoveUnderscores(migration.schemaName)}, _cap: &UpgradeCap) {\n${migration.fields.map((field) => {\n\t\t\tlet storage_type = '';\n\t\t\tif (field.type.includes('StorageValue')) {\n\t\t\t\tstorage_type = `storage_value::new()`;\n\t\t\t} else if (field.type.includes('StorageMap')) {\n\t\t\t\tstorage_type = `storage_map::new()`;\n\t\t\t} else if (\n\t\t\t\tfield.type.includes('StorageDoubleMap')\n\t\t\t) {\n\t\t\t\tstorage_type = `storage_double_map::new()`;\n\t\t\t}\n\t\t\treturn `storage_migration::add_field<${field.type}>(&mut ${migration.schemaName}.id, b\"${field.name}\", ${storage_type});`;\n\t\t}).join('')}\n}\n`;\n\n\t\tconst updatedContent = fileContent.replace(migrateMethodRegex, newMigrateMethod);\n\t\tfs.writeFileSync(filePath, updatedContent, 'utf-8');\n\t});\n\n\n}\n\nfunction capitalizeAndRemoveUnderscores(input: string): string {\n\treturn input\n\t\t.split('_')\n\t\t.map((word, index) => {\n\t\t\treturn index === 0\n\t\t\t\t? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n\t\t\t\t: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n\t\t})\n\t\t.join('');\n}\n\nfunction getLastSegment(input: string): string {\n\tconst segments = input.split('::');\n\treturn segments.length > 0 ? segments[segments.length - 1] : '';\n}\n\nfunction replaceEnvField(\n\tfilePath: string,\n\tnetworkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tfield: 'original-published-id' | 'latest-published-id' | 'published-version',\n\tnewValue: string\n): string {\n\tconst envFilePath = path.resolve(filePath);\n\tconst envContent = fs.readFileSync(envFilePath, 'utf-8');\n\tconst envLines = envContent.split('\\n');\n\n\tconst networkSectionIndex = envLines.findIndex(line => line.trim() === `[env.${networkType}]`);\n\tif (networkSectionIndex === -1) {\n\t\tconsole.log(`Network type [env.${networkType}] not found in the file.`);\n\t\treturn \"\";\n\t}\n\n\tlet fieldIndex = -1;\n\tlet previousValue: string = \"\";\n\tfor (let i = networkSectionIndex + 1; i < envLines.length; i++) {\n\t\tconst line = envLines[i].trim();\n\t\tif (line.startsWith('[')) break; // End of the current network section\n\n\t\tif (line.startsWith(field)) {\n\t\t\tfieldIndex = i;\n\t\t\tpreviousValue = line.split('=')[1].trim().replace(/\"/g, '');\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (fieldIndex !== -1) {\n\t\tenvLines[fieldIndex] = `${field} = \"${newValue}\"`;\n\t\tconst newEnvContent = envLines.join('\\n');\n\t\tfs.writeFileSync(envFilePath, newEnvContent, 'utf-8');\n\t} else {\n\t\tconsole.log(`${field} not found for [env.${networkType}].`);\n\t}\n\n\treturn previousValue;\n}\nexport async function upgradeHandler(\n\tconfig: DubheConfig,\n\tname: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n) {\n\tawait switchEnv(network);\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 DubheCliError(\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 DubheCliError(`Please check your privateKey.`);\n\t}\n\tconst dubhe = new Dubhe({\n\t\tsecretKey: privateKeyFormat,\n\t});\n\tconst keypair = dubhe.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 upgradeCap = await getUpgradeCap(projectPath, network);\n\n\tconst original_published_id = replaceEnvField(`${projectPath}/Move.lock`, network, 'original-published-id', \"0x0000000000000000000000000000000000000000000000000000000000000000\");\n\n\tlet pendingMigration: Migration[] = [];\n\tlet schemas = await getOnchainSchemas(projectPath, network);\n\tfor (let schemaKey in config.schemas) {\n\t\tschemas.forEach((schema) => {\n\t\t\tif (capitalizeAndRemoveUnderscores(schemaKey) == getLastSegment(schema.name)) {\n\t\t\t\tlet migrate: Migration = { schemaName: '', fields: [] };\n\t\t\t\tlet fields: Field[] = [];\n\t\t\t\tlet isMigration = false;\n\t\t\t\tfor (const key in config.schemas[schemaKey].structure) {\n\t\t\t\t\tif (!(key in schema.structure)) {\n\t\t\t\t\t\tisMigration = true;\n\t\t\t\t\t\tfields.push({\n\t\t\t\t\t\t\tname: key,\n\t\t\t\t\t\t\ttype: config.schemas[schemaKey].structure[key],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tschema.structure[key] = config.schemas[schemaKey].structure[key];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (isMigration) {\n\t\t\t\t\tmigrate.schemaName = schemaKey;\n\t\t\t\t\tmigrate.fields = fields;\n\t\t\t\t\tpendingMigration.push(migrate);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\n\tpendingMigration.forEach((migration) => {\n\t\tconsole.log(`\\n🚀 Starting Migration for ${migration.schemaName}...`);\n\t\tconsole.log('📋 Migration Fields:', migration.fields);\n\t});\n\tupdateMigrateMethod(projectPath, pendingMigration);\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\tconsole.log('\\n🚀 Starting Upgrade Process...');\n\t\tconsole.log('📋 OldPackageId:', oldPackageId);\n\t\tconsole.log('📋 UpgradeCap Object Id:', upgradeCap);\n\t\tconsole.log('📋 OldVersion:', oldVersion);\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\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\tlet newPackageId = '';\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\tconsole.log(\n\t\t\t\t\tchalk.blue(`${name} Version: ${oldVersion + 1}`),\n\t\t\t\t);\n\t\t\t\tnewPackageId = object.packageId;\n\t\t\t}\n\t\t});\n\n\t\treplaceEnvField(`${projectPath}/Move.lock`, network, 'original-published-id', original_published_id);\n\t\treplaceEnvField(`${projectPath}/Move.lock`, network, 'latest-published-id', newPackageId);\n\t\treplaceEnvField(`${projectPath}/Move.lock`, network, 'published-version', (oldVersion + 1) + \"\");\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\tupgradeCap,\n\t\t\toldVersion + 1,\n\t\t\tschemas,\n\t\t);\n\n\t} catch (error: any) {\n\t\tconsole.log(chalk.red('Upgrade failed!'));\n\t\tconsole.error(error.message);\n\t}\n}\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { upgradeHandler } from '../utils/upgradeHandler';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\tnetwork: any;\n\t'config-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'upgrade',\n\n\tdescribe: 'Upgrade your move contracts',\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: 'Network of the node (mainnet/testnet/devnet/localnet)',\n\t\t\t},\n\t\t\t'config-path': {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'dubhe.config.ts',\n\t\t\t\tdecs: 'Path to the config file',\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({ network, 'config-path': configPath }) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait upgradeHandler(dubheConfig, dubheConfig.name, network);\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\";\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n 'config-path': string;\n 'test'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"test\",\n\n describe: \"Run tests in Dubhe contracts\",\n\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: \"string\",\n default: \"dubhe.config.ts\",\n description: \"Options to pass to forge test\",\n },\n test: {\n type: 'string',\n desc: 'Run a specific test',\n },\n });\n },\n\n async handler({ 'config-path': configPath, test }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('🚀 Running move test');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/contracts/${dubheConfig.name}`;\n const command = `sui move test --path ${projectPath} ${test ? ` --test ${test}` : ''}`;\n const output = execSync(command, { encoding: \"utf-8\" });\n console.log(output);\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 { execSync } from \"child_process\";\nimport chalk from \"chalk\";\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\nimport { switchEnv, updateDubheDependency } from '../utils';\n\ntype Options = {\n 'config-path': string;\n network: any;\n 'dump-bytecode-as-base64'?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"build\",\n describe: \"Run tests in Dubhe contracts\",\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: \"string\",\n default: \"dubhe.config.ts\",\n description: \"Options to pass to forge test\",\n },\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Node network (mainnet/testnet/devnet/localnet)',\n },\n 'dump-bytecode-as-base64': {\n type: 'boolean',\n default: false,\n desc: 'Dump bytecode as base64',\n },\n });\n },\n\n async handler({ 'config-path': configPath, network, 'dump-bytecode-as-base64': dumpBytecodeAsBase64 }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('🚀 Running move build');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/contracts/${dubheConfig.name}`;\n await switchEnv(network);\n updateDubheDependency(projectPath+'/Move.toml', network);\n const command = `sui move build --path ${projectPath} ${dumpBytecodeAsBase64 ? ` --dump-bytecode-as-base64` : ''}`;\n const output = execSync(command, { encoding: \"utf-8\" });\n console.log(output);\n } catch (error: any) {\n console.error(chalk.red(\"Error executing sui move build:\"));\n console.log(error.stdout);\n process.exit(0);\n }\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { printDubhe } from \"../utils\";\n\nconst commandModule: CommandModule = {\n command: \"hello\",\n\n describe: \"hello, dubhe\",\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n printDubhe();\n },\n};\n\nexport default commandModule;\n","import { Dubhe } from '@0xobelisk/sui-client';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\n\nexport async function generateAccountHandler(\n\tforce: boolean = false,\n\toutputTsPath?: string\n) {\n\tif (outputTsPath) {\n\t\tconsole.log(\n\t\t\tchalk.blue(\n\t\t\t\t'Note: The generated account will be stored in the .env file and the TypeScript file specified by the --output-ts-path option.'\n\t\t\t)\n\t\t);\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t'Warning: Do not expose the key file. It is intended for local testing only.\\n'\n\t\t\t)\n\t\t);\n\t}\n\tconst path = process.cwd();\n\tlet privateKey: string;\n\n\tif (force) {\n\t\tconst dubhe = new Dubhe();\n\t\tconst keypair = dubhe.getKeypair();\n\t\tprivateKey = keypair.getSecretKey();\n\n\t\tfs.writeFileSync(`${path}/.env`, `PRIVATE_KEY=${privateKey}`);\n\t\tconsole.log(chalk.green(`File created at: ${path}/.env`));\n\n\t\tif (outputTsPath) {\n\t\t\tconst dir = outputTsPath.substring(\n\t\t\t\t0,\n\t\t\t\toutputTsPath.lastIndexOf('/')\n\t\t\t);\n\t\t\tif (!fs.existsSync(dir)) {\n\t\t\t\tfs.mkdirSync(dir, { recursive: true });\n\t\t\t}\n\t\t\tfs.writeFileSync(\n\t\t\t\toutputTsPath,\n\t\t\t\t`export const PRIVATEKEY = '${privateKey}';\nexport const ACCOUNT = '${keypair.toSuiAddress()}';\n`\n\t\t\t);\n\t\t\tconsole.log(chalk.green(`File created at: ${outputTsPath}\\n`));\n\t\t}\n\n\t\tconsole.log(\n\t\t\tchalk.blue(`Force generate new Account: ${keypair.toSuiAddress()}`)\n\t\t);\n\t\treturn;\n\t}\n\n\t// Check if .env file exists and has content\n\ttry {\n\t\tconst envContent = fs.readFileSync(`${path}/.env`, 'utf8');\n\t\tconst match = envContent.match(/PRIVATE_KEY=(.+)/);\n\t\tif (match && match[1]) {\n\t\t\tprivateKey = match[1];\n\t\t\tconst dubhe = new Dubhe({ secretKey: privateKey });\n\t\t\tconst keypair = dubhe.getKeypair();\n\n\t\t\tif (outputTsPath) {\n\t\t\t\tconst dir = outputTsPath.substring(\n\t\t\t\t\t0,\n\t\t\t\t\toutputTsPath.lastIndexOf('/')\n\t\t\t\t);\n\t\t\t\tif (!fs.existsSync(dir)) {\n\t\t\t\t\tfs.mkdirSync(dir, { recursive: true });\n\t\t\t\t}\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\toutputTsPath,\n\t\t\t\t\t`export const PRIVATEKEY = '${privateKey}';\nexport const ACCOUNT = '${keypair.toSuiAddress()}';\n`\n\t\t\t\t);\n\t\t\t\tconsole.log(chalk.green(`File created at: ${outputTsPath}\\n`));\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\tchalk.blue(`Using existing Account: ${keypair.toSuiAddress()}`)\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t} catch (error) {\n\t\t// .env file doesn't exist or failed to read, continue to generate new account\n\t}\n\n\t// If no existing private key, generate new account\n\tconst dubhe = new Dubhe();\n\tconst keypair = dubhe.getKeypair();\n\tprivateKey = keypair.getSecretKey();\n\tfs.writeFileSync(`${path}/.env`, `PRIVATE_KEY=${privateKey}`);\n\tconsole.log(chalk.green(`File created at: ${path}/.env`));\n\n\tif (outputTsPath) {\n\t\tconst dir = outputTsPath.substring(0, outputTsPath.lastIndexOf('/'));\n\t\tif (!fs.existsSync(dir)) {\n\t\t\tfs.mkdirSync(dir, { recursive: true });\n\t\t}\n\t\tfs.writeFileSync(\n\t\t\toutputTsPath,\n\t\t\t`export const PRIVATEKEY = '${privateKey}';\nexport const ACCOUNT = '${keypair.toSuiAddress()}';\n`\n\t\t);\n\t\tconsole.log(chalk.green(`File created at: ${outputTsPath}\\n`));\n\t}\n\n\tconsole.log(chalk.blue(`Generate new Account: ${keypair.toSuiAddress()}`));\n}\n","import type { CommandModule } from 'yargs';\nimport { generateAccountHandler } from '../utils/generateAccount';\n\ntype Options = {\n\tforce?: boolean;\n\t'output-ts-path'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'generate-key',\n\tdescribe:\n\t\t'Generate a new account key pair and save it to a .env file, with an option to output to a TypeScript file.',\n\tbuilder: {\n\t\tforce: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\tdesc: 'Force generate a new key pair',\n\t\t},\n\t\t'output-ts-path': {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Specify the path to output the TypeScript file containing the key pair (e.g., ./src/config/key.ts)',\n\t\t},\n\t},\n\tasync handler({ force, 'output-ts-path': outputTsPath }) {\n\t\ttry {\n\t\t\tawait generateAccountHandler(force, outputTsPath);\n\t\t} catch (error) {\n\t\t\tconsole.error('Error generating account:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import { Dubhe, NetworkType } from '@0xobelisk/sui-client';\nimport chalk from 'chalk';\nimport dotenv from 'dotenv';\nimport { validatePrivateKey } from './utils';\nimport { DubheCliError } from './errors';\ndotenv.config();\n\nexport async function checkBalanceHandler(\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tamount: number = 2\n) {\n\ttry {\n\t\tconsole.log(\n\t\t\tchalk.blue(\n\t\t\t\t`Note: You need at least 2 SUI for transaction fees and staking, and registering a Dapp will reserve 1 SUI for Dubhe Dapp Staking, which can be retrieved upon unregistering.`\n\t\t\t)\n\t\t);\n\n\t\tconst privateKey = process.env.PRIVATE_KEY;\n\t\tif (!privateKey) {\n\t\t\tthrow new DubheCliError(\n\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);\n\t\t}\n\t\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\t\tif (privateKeyFormat === false) {\n\t\t\tthrow new DubheCliError(`Please check your privateKey.`);\n\t\t}\n\n\t\tconst dubhe = new Dubhe({\n\t\t\tsecretKey: process.env.PRIVATE_KEY,\n\t\t\tnetworkType: network as NetworkType,\n\t\t});\n\n\t\tconst balance = await dubhe.getBalance();\n\t\tconst balanceInSUI = Number(balance.totalBalance) / 1_000_000_000;\n\n\t\tif (balanceInSUI < amount) {\n\t\t\t// console.log(chalk.yellow(`Account balance is less than 2 SUI.`));\n\t\t\tthrow new DubheCliError(\n\t\t\t\t`Your account balance ${balanceInSUI.toFixed(\n\t\t\t\t\t4\n\t\t\t\t)} SUI is less than ${amount} SUI. Please get more SUI.`\n\t\t\t);\n\t\t}\n\n\t\tconsole.log(\n\t\t\tchalk.green(\n\t\t\t\t`Current account balance: ${balanceInSUI.toFixed(4)} SUI`\n\t\t\t)\n\t\t);\n\t} catch (error) {\n\t\tthrow new DubheCliError('Failed to check balance: ' + error);\n\t}\n}\n","import type { CommandModule } from 'yargs';\nimport { checkBalanceHandler } from '../utils/checkBalance';\n\ntype Options = {\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\tamount: number;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'check-balance',\n\tdescribe: 'Check the balance of the account',\n\tbuilder: {\n\t\tnetwork: {\n\t\t\ttype: 'string',\n\t\t\tchoices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n\t\t\tdesc: 'Network to check balance on',\n\t\t},\n\t\tamount: {\n\t\t\ttype: 'number',\n\t\t\tdefault: 2,\n\t\t\tdesc: 'Amount of SUI to check balance for',\n\t\t},\n\t},\n\tasync handler({ network, amount }) {\n\t\ttry {\n\t\t\tawait checkBalanceHandler(network, amount);\n\t\t} catch (error) {\n\t\t\tconsole.error('Error checking balance:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import * as fsAsync from 'fs/promises';\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { exit } from 'process';\nimport { dirname } from 'path';\nimport { DeploymentJsonType, schema } from './utils';\nimport { DubheConfig } from '@0xobelisk/sui-common';\n\nasync function getDeploymentJson(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<DeploymentJsonType> {\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 (error) {\n\t\tthrow new Error(\n\t\t\t`read .history/sui_${network}/latest.json failed. ${error}`\n\t\t);\n\t}\n}\n\nfunction storeConfig(\n\tnetwork: string,\n\tpackageId: string,\n\tschemas: schema[],\n\toutputPath: string\n) {\n\tlet code = `type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';\n\nexport const NETWORK: NetworkType = '${network}';\n\nexport const PACKAGE_ID = '${packageId}'\n\n${schemas\n\t.map(\n\t\tschema =>\n\t\t\t`export const ${schema.name.split('::')[2]}_Object_Id = '${\n\t\t\t\tschema.objectId\n\t\t\t}'`\n\t)\n\t.join('\\n')}\n`;\n\t// if (outputPath) {\n\twriteOutput(code, outputPath, 'storeConfig');\n\t// writeOutput(code, `${path}/src/chain/config.ts`, 'storeConfig');\n\t// }\n}\n\nasync 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\nexport async function storeConfigHandler(\n\tdubheConfig: DubheConfig,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\toutputPath: string\n) {\n\tconst path = process.cwd();\n\tconst contractPath = `${path}/contracts/${dubheConfig.name}`;\n\tconst deployment = await getDeploymentJson(contractPath, network);\n\tstoreConfig(\n\t\tdeployment.network,\n\t\tdeployment.packageId,\n\t\tdeployment.schemas,\n\t\toutputPath\n\t);\n}\n","import type { CommandModule } from 'yargs';\nimport { storeConfigHandler } from '../utils/storeConfig';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\t'config-path': string;\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\t'output-ts-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'config-store',\n\n\tdescribe: 'Store configuration for the Dubhe project',\n\n\tbuilder: {\n\t\t'config-path': {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'dubhe.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'],\n\t\t\tdesc: 'Network to store config for',\n\t\t},\n\t\t'output-ts-path': {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)',\n\t\t},\n\t},\n\tasync handler({\n\t\t'config-path': configPath,\n\t\tnetwork,\n\t\t'output-ts-path': outputTsPath,\n\t}) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait storeConfigHandler(dubheConfig, network, outputTsPath);\n\t\t} catch (error) {\n\t\t\tconsole.error('Error storing config:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\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 build from './build';\nimport hello from './hello';\nimport generateKey from './generateKey';\nimport checkBalance from './checkBalance';\nimport configStore from './configStore';\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\tupgrade,\n\ttest,\n\tbuild,\n\thello,\n\tgenerateKey,\n\tcheckBalance,\n\tconfigStore,\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBCHxB,OAAS,YAAAC,GAAU,SAAAC,OAAa,gBAChC,OAA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AQxC,IAAMC,GAAiD,CACtD,QAAS,eAET,SAAU,4CAEV,QAAS,CACR,cAAe,CACd,KAAM,SACN,QAAS,kBACT,KAAM,yBACP,EACA,QAAS,CACR,KAAM,SACN,QAAS,CAAC,UAAW,UAAW,SAAU,UAAU,EACpD,KAAM,6BACP,EACA,iBAAkB,CACjB,KAAM,SACN,KAAM,2GACP,CACD,EACA,MAAM,QAAQ,CACb,cAAeC,EACf,QAAAC,EACA,iBAAkBC,CACnB,EAAG,CACF,GAAI,CACH,IAAMC,EAAe,MAAML,GAAWE,CAAU,EAChD,MAAMI,GAAmBD,EAAaF,EAASC,CAAY,CAC5D,OAASG,EAAP,CACD,QAAQ,MAAM,wBAAyBA,CAAK,EAC5C,QAAQ,KAAK,CAAC,CACf,CACA,QAAQ,KAAK,CAAC,CACf,CACD,EAEOC,GAAQP,GChCR,IAAMQ,GAAsC,CAClDC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,EACD,ErBnBA,UAAYC,OAAY,SACxB,OAAOC,OAAW,QACX,UAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,OAAO,EAGlB,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,mBAAmB,QAAQ,KAAK,CAAC,2DAA2D,CAC3G,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","execSync","spawn","chalk","chalk","printDubhe","Dubhe","Transaction","getFullnodeUrl","SuiClient","execSync","chalk","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","DubheCliError","UpgradeError","FsIibError","logError","error","validationError","fsAsync","mkdirSync","writeFileSync","dirname","SUI_PRIVATE_KEY_PREFIX","fs","chalk","spawn","validatePrivateKey","privateKey","SUI_PRIVATE_KEY_PREFIX","strippedPrivateKey","getDeploymentJson","projectPath","network","data","FsIibError","getOnchainSchemas","getVersion","getOldPackageId","projectPath","network","getDeploymentJson","getUpgradeCap","saveContractData","projectName","network","packageId","upgradeCap","version","schemas","DeploymentData","path","storeDeploymentData","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","getDubheDependency","updateDubheDependency","filePath","fileContent","newDependency","updatedContent","switchEnv","resolve","reject","suiProcess","spawn","data","chalk","error","code","delay","ms","fs","path","removeEnvContent","filePath","networkType","content","regex","updatedContent","updateEnvFile","operation","chainId","publishedId","envFilePath","envContent","envLines","networkSectionIndex","line","config","i","key","value","part","updatedSection","newEnvContent","capitalizeAndRemoveUnderscores","input","word","index","getLastSegment","segments","buildContract","projectPath","modules","dependencies","buildResult","execSync","error","chalk","publishContract","client","dubhe","dubheConfig","network","gasBudget","keypair","tx","Transaction","upgradeCap","result","version","packageId","schemas","upgradeCapId","object","delay","deployHookTx","deployHookResult","structure","schemaKey","saveContractData","publishDubheFramework","publishHandler","contractName","switchEnv","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","Dubhe","SuiClient","getFullnodeUrl","updateDubheDependency","Dubhe","getFullnodeUrl","SuiClient","isSuiStartRunning","cmd","result","execSync","printAccounts","privateKeys","privateKey","index","keypair","spawn","chalk","startLocalNode","printDubhe","suiProcess","error","delay","privateKeyFormat","validatePrivateKey","DubheCliError","dubhe","client","originalLog","publishDubheFramework","commandModule","yargs","startLocalNode","error","localnode_default","Dubhe","requestSuiFromFaucetV0","getFaucetHost","SuiClient","getFullnodeUrl","commandModule","yargs","network","recipient","faucet_address","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","Dubhe","requestSuiFromFaucetV0","getFaucetHost","client","SuiClient","getFullnodeUrl","params","balance","faucet_default","schemaGen","loadConfig","chalk","commandModule","configPath","network","frameworkId","dubheConfig","error","schemagen_default","loadConfig","commandModule","yargs","network","configPath","contractName","gasBudget","dubheConfig","publishHandler","error","logError","publish_default","Dubhe","Transaction","UpgradePolicy","getFullnodeUrl","SuiClient","execSync","chalk","fs","path","updateMigrateMethod","projectPath","migrations","migration","filePath","fileContent","migrateMethodRegex","capitalizeAndRemoveUnderscores","newMigrateMethod","field","storage_type","updatedContent","input","word","index","getLastSegment","segments","replaceEnvField","networkType","newValue","envFilePath","envLines","networkSectionIndex","line","fieldIndex","previousValue","i","newEnvContent","upgradeHandler","config","name","network","switchEnv","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","keypair","Dubhe","client","SuiClient","getFullnodeUrl","oldVersion","getVersion","oldPackageId","getOldPackageId","upgradeCap","getUpgradeCap","original_published_id","pendingMigration","schemas","getOnchainSchemas","schemaKey","schema","migrate","fields","isMigration","key","modules","dependencies","digest","extractedModules","extractedDependencies","extractedDigest","execSync","error","UpgradeError","tx","Transaction","ticket","UpgradePolicy","receipt","result","newPackageId","object","chalk","saveContractData","loadConfig","commandModule","yargs","network","configPath","dubheConfig","upgradeHandler","error","logError","upgrade_default","execSync","chalk","loadConfig","commandModule","yargs","configPath","test","dubheConfig","command","output","error","test_default","execSync","chalk","loadConfig","commandModule","yargs","configPath","network","dumpBytecodeAsBase64","dubheConfig","loadConfig","projectPath","switchEnv","updateDubheDependency","command","output","execSync","error","chalk","build_default","commandModule","yargs","printDubhe","hello_default","Dubhe","fs","chalk","generateAccountHandler","force","outputTsPath","path","privateKey","keypair","dir","match","commandModule","force","outputTsPath","generateAccountHandler","error","generateKey_default","Dubhe","chalk","dotenv","dotenv","checkBalanceHandler","network","amount","chalk","privateKey","DubheCliError","validatePrivateKey","balance","Dubhe","balanceInSUI","error","commandModule","network","amount","checkBalanceHandler","error","checkBalance_default","fsAsync","mkdirSync","writeFileSync","dirname","getDeploymentJson","projectPath","network","data","error","storeConfig","packageId","schemas","outputPath","code","schema","writeOutput","output","fullOutputPath","logPrefix","storeConfigHandler","dubheConfig","contractPath","deployment","loadConfig","commandModule","configPath","network","outputTsPath","dubheConfig","storeConfigHandler","error","configStore_default","commands","publish_default","localnode_default","faucet_default","schemagen_default","upgrade_default","test_default","build_default","hello_default","generateKey_default","checkBalance_default","configStore_default","dotenv","chalk","yargs","hideBin","commands","msg","err","logError"]}
1
+ {"version":3,"sources":["../src/dubhe.ts","../src/utils/startNode.ts","../src/utils/printDubhe.ts","../src/utils/publishHandler.ts","../src/utils/errors.ts","../src/utils/utils.ts","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/utils/upgradeHandler.ts","../src/commands/upgrade.ts","../src/commands/test.ts","../src/commands/build.ts","../src/commands/hello.ts","../src/utils/generateAccount.ts","../src/commands/generateKey.ts","../src/utils/checkBalance.ts","../src/commands/checkBalance.ts","../src/utils/storeConfig.ts","../src/commands/configStore.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 \"dubhe\" for e.g. ts-node)\n .scriptName(\"dubhe\")\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 dubhe ${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 { execSync, spawn } from 'child_process';\nimport chalk from 'chalk';\nimport { printDubhe } from './printDubhe';\nimport {\n\tdelay,\n\tDubheCliError,\n\tpublishDubheFramework,\n\tvalidatePrivateKey,\n} from '../utils';\nimport { Dubhe } from '@0xobelisk/sui-client';\nimport { getFullnodeUrl, SuiClient } from '@mysten/sui/client';\n\nfunction isSuiStartRunning(): boolean {\n\ttry {\n\t\tconst cmd =\n\t\t\tprocess.platform === 'win32'\n\t\t\t\t? `tasklist /FI \"IMAGENAME eq sui.exe\" /FO CSV /NH`\n\t\t\t\t: 'pgrep -f \"sui start\"';\n\n\t\tconst result = execSync(cmd).toString().trim();\n\t\treturn process.platform === 'win32'\n\t\t\t? result.toLowerCase().includes('sui.exe')\n\t\t\t: result.length > 0;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\nasync function printAccounts() {\n\t// These private keys are used for testing purposes only, do not use them in production.\n\tconst privateKeys = [\n\t\t'suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v',\n\t\t'suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s',\n\t\t'suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc',\n\t\t'suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c',\n\t\t'suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57',\n\t\t'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c',\n\t];\n\tconsole.log('📝Accounts');\n\tconsole.log('==========');\n\tprivateKeys.forEach((privateKey, index) => {\n\t\tconst dubhe = new Dubhe({ secretKey: privateKey });\n\t\tconst keypair = dubhe.getKeypair();\n\t\tspawn(\n\t\t\t'curl',\n\t\t\t[\n\t\t\t\t'--location',\n\t\t\t\t'--request',\n\t\t\t\t'POST',\n\t\t\t\t'http://127.0.0.1:9123/gas',\n\t\t\t\t'--header',\n\t\t\t\t'Content-Type: application/json',\n\t\t\t\t'--data-raw',\n\t\t\t\t`{\"FixedAmountRequest\": {\"recipient\": \"${keypair.toSuiAddress()}\"}}`,\n\t\t\t],\n\t\t\t{\n\t\t\t\tenv: { ...process.env },\n\t\t\t\tstdio: 'ignore',\n\t\t\t\tdetached: true,\n\t\t\t}\n\t\t);\n\t\tconsole.log(\n\t\t\t` ┌─ Account #${index}: ${keypair.toSuiAddress()}(1000 SUI)`\n\t\t);\n\t\tconsole.log(` └─ Private Key: ${privateKey}`);\n\t});\n\tconsole.log('==========');\n\tconsole.log(\n\t\tchalk.yellow(\n\t\t\t'ℹ️ WARNING: These accounts, and their private keys, are publicly known.'\n\t\t)\n\t);\n\tconsole.log(\n\t\tchalk.yellow(\n\t\t\t'Any funds sent to them on Mainnet or any other live network WILL BE LOST.'\n\t\t)\n\t);\n}\nexport async function startLocalNode() {\n\tif (isSuiStartRunning()) {\n\t\tconsole.log(chalk.yellow('\\n⚠️ Warning: Local Node Already Running'));\n\t\tconsole.log(chalk.yellow(' ├─ Cannot start a new instance'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(' └─ Please stop the existing process first')\n\t\t);\n\t\treturn;\n\t}\n\n\tprintDubhe();\n\tconsole.log('🚀 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: 'ignore',\n\t\t\t\tdetached: true,\n\t\t\t}\n\t\t);\n\n\t\tsuiProcess.on('error', error => {\n\t\t\tconsole.error(chalk.red('\\n❌ Failed to Start Local Node'));\n\t\t\tconsole.error(chalk.red(` └─ Error: ${error.message}`));\n\t\t});\n\t\tawait delay(5000);\n\t\tconsole.log(' ├─ Faucet: Enabled');\n\t\tconsole.log(' └─ Force Regenesis: Yes');\n\t\tconsole.log(' └─ HTTP server: http://127.0.0.1:9000/');\n\t\tconsole.log(' └─ Faucet server: http://127.0.0.1:9123/');\n\n\t\tawait printAccounts();\n\n\t\tawait delay(2000);\n\n\t\tconst privateKeyFormat = validatePrivateKey(\n\t\t\t'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'\n\t\t);\n\t\tif (privateKeyFormat === false) {\n\t\t\tthrow new DubheCliError(`Please check your privateKey.`);\n\t\t}\n\n\t\tconsole.log(chalk.green('🎉 Local environment is ready!'));\n\n\t\tprocess.on('SIGINT', () => {\n\t\t\tconsole.log(chalk.yellow('\\n🔔 Stopping Local Node...'));\n\t\t\tif (suiProcess) {\n\t\t\t\tsuiProcess.kill();\n\t\t\t\tconsole.log(chalk.green('✅ Local Node Stopped'));\n\t\t\t}\n\t\t\tprocess.exit();\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red('\\n❌ Failed to Start Local Node'));\n\t\tconsole.error(chalk.red(` └─ Error: ${error.message}`));\n\t\tprocess.exit(1);\n\t}\n}\n","import chalk from \"chalk\";\n\nexport function printDubhe() {\n console.log(\n chalk.yellow(`\nWelcome to Dubhe\n\\t\\t\\t --from team@obelisk\n ________ ___ ___ ________ ___ ___ _______ \n |\\\\ ___ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ __ \\\\|\\\\ \\\\|\\\\ \\\\|\\\\ ___ \\\\ \n \\\\ \\\\ \\\\_|\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ /\\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __/| \n \\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __ \\\\ \\\\ __ \\\\ \\\\ \\\\_|/__ \n \\\\ \\\\ \\\\_\\\\\\\\ \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\_|\\\\ \\\\ \n \\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\__\\\\ \\\\__\\\\ \\\\_______\\\\\n \\\\|_______|\\\\|_______|\\\\|_______|\\\\|__|\\\\|__|\\\\|_______| \n \n`)\n );\n}\n","import { Dubhe } 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 { DubheCliError } from './errors';\nimport {\n\tupdateVersionInFile,\n\tsaveContractData,\n\tvalidatePrivateKey,\n\tschema,\n\tupdateDubheDependency,\n\tswitchEnv,\n\tdelay,\n} from './utils';\nimport { DubheConfig } from '@0xobelisk/sui-common';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nasync function removeEnvContent(\n\tfilePath: string,\n\tnetworkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n): Promise<void> {\n\tif (!fs.existsSync(filePath)) {\n\t\treturn;\n\t}\n\tconst content = fs.readFileSync(filePath, 'utf-8');\n\tconst regex = new RegExp(\n\t\t`\\\\[env\\\\.${networkType}\\\\][\\\\s\\\\S]*?(?=\\\\[|$)`,\n\t\t'g'\n\t);\n\tconst updatedContent = content.replace(regex, '');\n\tfs.writeFileSync(filePath, updatedContent, 'utf-8');\n}\n\ninterface EnvConfig {\n\tchainId: string;\n\toriginalPublishedId: string;\n\tlatestPublishedId: string;\n\tpublishedVersion: number;\n}\n\nfunction updateEnvFile(\n\tfilePath: string,\n\tnetworkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\toperation: 'publish' | 'upgrade',\n\tchainId: string,\n\tpublishedId: string\n): void {\n\tconst envFilePath = path.resolve(filePath);\n\tconst envContent = fs.readFileSync(envFilePath, 'utf-8');\n\tconst envLines = envContent.split('\\n');\n\n\tconst networkSectionIndex = envLines.findIndex(\n\t\tline => line.trim() === `[env.${networkType}]`\n\t);\n\tconst config: EnvConfig = {\n\t\tchainId: chainId,\n\t\toriginalPublishedId: '',\n\t\tlatestPublishedId: '',\n\t\tpublishedVersion: 0,\n\t};\n\n\tif (networkSectionIndex === -1) {\n\t\t// If network section is not found, add a new section\n\t\tif (operation === 'publish') {\n\t\t\tconfig.originalPublishedId = publishedId;\n\t\t\tconfig.latestPublishedId = publishedId;\n\t\t\tconfig.publishedVersion = 1;\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Network type [env.${networkType}] not found in the file and cannot upgrade.`\n\t\t\t);\n\t\t}\n\t} else {\n\t\tfor (let i = networkSectionIndex + 1; i < envLines.length; i++) {\n\t\t\tconst line = envLines[i].trim();\n\t\t\tif (line.startsWith('[')) break; // End of the current network section\n\n\t\t\tconst [key, value] = line\n\t\t\t\t.split('=')\n\t\t\t\t.map(part => part.trim().replace(/\"/g, ''));\n\t\t\tswitch (key) {\n\t\t\t\tcase 'original-published-id':\n\t\t\t\t\tconfig.originalPublishedId = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'latest-published-id':\n\t\t\t\t\tconfig.latestPublishedId = value;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'published-version':\n\t\t\t\t\tconfig.publishedVersion = parseInt(value, 10);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (operation === 'publish') {\n\t\t\tconfig.originalPublishedId = publishedId;\n\t\t\tconfig.latestPublishedId = publishedId;\n\t\t\tconfig.publishedVersion = 1;\n\t\t} else if (operation === 'upgrade') {\n\t\t\tconfig.latestPublishedId = publishedId;\n\t\t\tconfig.publishedVersion += 1;\n\t\t}\n\t}\n\n\tconst updatedSection = `\n[env.${networkType}]\nchain-id = \"${config.chainId}\"\noriginal-published-id = \"${config.originalPublishedId}\"\nlatest-published-id = \"${config.latestPublishedId}\"\npublished-version = \"${config.publishedVersion}\"\n`;\n\n\tconst newEnvContent =\n\t\tnetworkSectionIndex === -1\n\t\t\t? envContent + updatedSection\n\t\t\t: envLines.slice(0, networkSectionIndex).join('\\n') +\n\t\t\t updatedSection;\n\n\tfs.writeFileSync(envFilePath, newEnvContent, 'utf-8');\n}\nfunction capitalizeAndRemoveUnderscores(input: string): string {\n\treturn input\n\t\t.split('_')\n\t\t.map((word, index) => {\n\t\t\treturn index === 0\n\t\t\t\t? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n\t\t\t\t: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n\t\t})\n\t\t.join('');\n}\n\nfunction getLastSegment(input: string): string {\n\tconst segments = input.split('::');\n\treturn segments.length > 0 ? segments[segments.length - 1] : '';\n}\n\nfunction buildContract(projectPath: string): string[][] {\n\tlet modules: any, dependencies: any;\n\ttry {\n\t\tconst buildResult = JSON.parse(\n\t\t\texecSync(\n\t\t\t\t`sui move build --dump-bytecode-as-base64 --path ${projectPath}`,\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf-8',\n\t\t\t\t\tstdio: 'pipe',\n\t\t\t\t}\n\t\t\t)\n\t\t);\n\t\tmodules = buildResult.modules;\n\t\tdependencies = buildResult.dependencies;\n\t\tconsole.log(' └─ Build successful');\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Build failed'));\n\t\tconsole.error(error.stdout);\n\t\tprocess.exit(1);\n\t}\n\treturn [modules, dependencies];\n}\n\nasync function publishContract(\n\tclient: SuiClient,\n\tdubhe: Dubhe,\n\tdubheConfig: DubheConfig,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tprojectPath: string,\n\tgasBudget?: number\n) {\n\tconst chainId = await client.getChainIdentifier();\n\tawait removeEnvContent(`${projectPath}/Move.lock`, network);\n\tconsole.log('\\n🚀 Starting Contract Publication...');\n\tconsole.log(` ├─ Project: ${projectPath}`);\n\tconsole.log(` ├─ Network: ${network}`);\n\tconsole.log(` ├─ ChainId: ${chainId}`);\n\tconsole.log(' ├─ Validating Environment...');\n\n\tconst keypair = dubhe.getKeypair();\n\tconsole.log(` └─ Account: ${keypair.toSuiAddress()}`);\n\n\tconsole.log('\\n📦 Building Contract...');\n\tconst [modules, dependencies] = buildContract(projectPath);\n\n\tconsole.log('\\n🔄 Publishing Contract...');\n\tconst tx = new Transaction();\n\tif (gasBudget) {\n\t\ttx.setGasBudget(gasBudget);\n\t}\n\tconst [upgradeCap] = tx.publish({ modules, dependencies });\n\ttx.transferObjects([upgradeCap], keypair.toSuiAddress());\n\n\tlet result: SuiTransactionBlockResponse;\n\ttry {\n\t\tresult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: tx,\n\t\t\toptions: { showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Publication failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (result.effects?.status.status === 'failure') {\n\t\tconsole.log(chalk.red(' └─ Publication failed'));\n\t\tprocess.exit(1);\n\t}\n\n\tconsole.log(' ├─ Processing publication results...');\n\tlet version = 1;\n\tlet packageId = '';\n\tlet schemas: schema[] = [];\n\tlet upgradeCapId = '';\n\n\tresult.objectChanges!.map(object => {\n\t\tif (object.type === 'published') {\n\t\t\tconsole.log(` ├─ Package ID: ${object.packageId}`);\n\t\t\tpackageId = object.packageId;\n\t\t}\n\t\tif (\n\t\t\tobject.type === 'created' &&\n\t\t\tobject.objectType === '0x2::package::UpgradeCap'\n\t\t) {\n\t\t\tconsole.log(` ├─ Upgrade Cap: ${object.objectId}`);\n\t\t\tupgradeCapId = object.objectId;\n\t\t}\n\t});\n\n\tconsole.log(` └─ Transaction: ${result.digest}`);\n\n\tupdateEnvFile(\n\t\t`${projectPath}/Move.lock`,\n\t\tnetwork,\n\t\t'publish',\n\t\tchainId,\n\t\tpackageId\n\t);\n\n\tconsole.log('\\n⚡ Executing Deploy Hook...');\n\tawait delay(5000);\n\n\tconst deployHookTx = new Transaction();\n\tdeployHookTx.moveCall({\n\t\ttarget: `${packageId}::deploy_hook::run`,\n\t\targuments: [deployHookTx.object('0x6')],\n\t});\n\n\tlet deployHookResult: SuiTransactionBlockResponse;\n\ttry {\n\t\tdeployHookResult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: deployHookTx,\n\t\t\toptions: { showEffects: true, showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Deploy hook execution failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (deployHookResult.effects?.status.status === 'success') {\n\t\tconsole.log(' ├─ Hook execution successful');\n\t\tconsole.log(` ├─ Transaction: ${deployHookResult.digest}`);\n\n\t\tconsole.log('\\n📋 Created Schemas:');\n\t\tdeployHookResult.objectChanges?.map(object => {\n\t\t\tif (\n\t\t\t\tobject.type === 'created' &&\n\t\t\t\tobject.objectType.includes('_schema') &&\n\t\t\t\t!object.objectType.includes('dynamic_field')\n\t\t\t) {\n\t\t\t\tconsole.log(` ├─ ${object.objectType}`);\n\t\t\t\tconsole.log(` └─ ID: ${object.objectId}`);\n\n\t\t\t\tlet structure: Record<string, string> = {};\n\t\t\t\tfor (let schemaKey in dubheConfig.schemas) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcapitalizeAndRemoveUnderscores(schemaKey) ===\n\t\t\t\t\t\tgetLastSegment(object.objectType)\n\t\t\t\t\t) {\n\t\t\t\t\t\tstructure = dubheConfig.schemas[schemaKey].structure;\n\t\t\t\t\t}\n\t\t\t\t}\n\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\tstructure,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\n\t\tsaveContractData(\n\t\t\tdubheConfig.name,\n\t\t\tnetwork,\n\t\t\tpackageId,\n\t\t\tupgradeCapId,\n\t\t\tversion,\n\t\t\tschemas\n\t\t);\n\t\tconsole.log('\\n✅ Contract Publication Complete\\n');\n\t} else {\n\t\tconsole.log(chalk.yellow(' └─ Deploy hook execution failed'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t' Please republish or manually call deploy_hook::run'\n\t\t\t)\n\t\t);\n\t\tconsole.log(chalk.yellow(' Please check the transaction digest:'));\n\t\tconsole.log(chalk.yellow(` ${deployHookResult.digest}`));\n\t\tprocess.exit(1);\n\t}\n}\n\nasync function checkDubheFramework(projectPath: string): Promise<boolean> {\n\tif (!fs.existsSync(projectPath)) {\n\t\tconsole.log(chalk.yellow('\\nℹ️ Dubhe Framework Files Not Found'));\n\t\tconsole.log(chalk.yellow(' ├─ Expected Path:'), projectPath);\n\t\tconsole.log(chalk.yellow(' ├─ To set up Dubhe Framework:'));\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t' │ 1. Create directory: mkdir -p contracts/dubhe-framework'\n\t\t\t)\n\t\t);\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t' │ 2. Clone repository: git clone https://github.com/0xobelisk/dubhe-framework contracts/dubhe-framework'\n\t\t\t)\n\t\t);\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t' │ 3. Or download from: https://github.com/0xobelisk/dubhe-framework'\n\t\t\t)\n\t\t);\n\t\tconsole.log(chalk.yellow(' └─ After setup, restart the local node'));\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport async function publishDubheFramework(\n\tclient: SuiClient,\n\tdubhe: Dubhe,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n\tconst path = process.cwd();\n\tconst projectPath = `${path}/contracts/dubhe-framework`;\n\n\tif (!(await checkDubheFramework(projectPath))) {\n\t\tconsole.log(chalk.yellow('\\n❗ Framework Deployment Skipped'));\n\t\treturn;\n\t}\n\n\tconst chainId = await client.getChainIdentifier();\n\tawait removeEnvContent(`${projectPath}/Move.lock`, network);\n\tconsole.log('\\n🚀 Starting Contract Publication...');\n\tconsole.log(` ├─ Project: ${projectPath}`);\n\tconsole.log(` ├─ Network: ${network}`);\n\n\tconst keypair = dubhe.getKeypair();\n\tconsole.log(` └─ Account: ${keypair.toSuiAddress()}`);\n\n\tconsole.log('\\n📦 Building Contract...');\n\tconst [modules, dependencies] = buildContract(projectPath);\n\n\tconsole.log('\\n🔄 Publishing Contract...');\n\tconst tx = new Transaction();\n\tconst [upgradeCap] = tx.publish({ modules, dependencies });\n\ttx.transferObjects([upgradeCap], keypair.toSuiAddress());\n\n\tlet result: SuiTransactionBlockResponse;\n\ttry {\n\t\tresult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: tx,\n\t\t\toptions: { showObjectChanges: true },\n\t\t});\n\t} catch (error: any) {\n\t\tconsole.error(chalk.red(' └─ Publication failed'));\n\t\tconsole.error(error.message);\n\t\tprocess.exit(1);\n\t}\n\n\tif (result.effects?.status.status === 'failure') {\n\t\tconsole.log(chalk.red(' └─ Publication failed'));\n\t\tprocess.exit(1);\n\t}\n\n\tlet version = 1;\n\tlet packageId = '';\n\tlet schemas: schema[] = [];\n\tlet upgradeCapId = '';\n\n\tresult.objectChanges!.map(object => {\n\t\tif (object.type === 'published') {\n\t\t\tconsole.log(` ├─ Package ID: ${object.packageId}`);\n\t\t\tpackageId = object.packageId;\n\t\t}\n\t\tif (\n\t\t\tobject.type === 'created' &&\n\t\t\tobject.objectType === '0x2::package::UpgradeCap'\n\t\t) {\n\t\t\tconsole.log(` ├─ Upgrade Cap: ${object.objectId}`);\n\t\t\tupgradeCapId = object.objectId;\n\t\t}\n\t});\n\n\tconsole.log(` └─ Transaction: ${result.digest}`);\n\n\tupdateEnvFile(\n\t\t`${projectPath}/Move.lock`,\n\t\tnetwork,\n\t\t'publish',\n\t\tchainId,\n\t\tpackageId\n\t);\n\n\tsaveContractData(\n\t\t'dubhe-framework',\n\t\tnetwork,\n\t\tpackageId,\n\t\tupgradeCapId,\n\t\tversion,\n\t\tschemas\n\t);\n\tconsole.log(chalk.green('\\n✅ Dubhe Framework deployed successfully'));\n}\n\nexport async function publishHandler(\n\tdubheConfig: DubheConfig,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tgasBudget?: number\n) {\n\tawait switchEnv(network);\n\n\tconst privateKey = process.env.PRIVATE_KEY;\n\tif (!privateKey) {\n\t\tthrow new DubheCliError(\n\t\t\t`Missing PRIVATE_KEY environment variable.\nRun 'echo \"PRIVATE_KEY=YOUR_PRIVATE_KEY\" > .env'\nin your contracts directory to use the default sui private key.`\n\t\t);\n\t}\n\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\tif (privateKeyFormat === false) {\n\t\tthrow new DubheCliError(`Please check your privateKey.`);\n\t}\n\n\tconst dubhe = new Dubhe({ secretKey: privateKeyFormat });\n\tconst client = new SuiClient({ url: getFullnodeUrl(network) });\n\n\tif (network === 'localnet') {\n\t\tawait publishDubheFramework(client, dubhe, network);\n\t}\n\n\tconst path = process.cwd();\n\tconst projectPath = `${path}/contracts/${dubheConfig.name}`;\n\tupdateDubheDependency(`${projectPath}/Move.toml`, network);\n\tawait publishContract(\n\t\tclient,\n\t\tdubhe,\n\t\tdubheConfig,\n\t\tnetwork,\n\t\tprojectPath,\n\t\tgasBudget\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\tname = 'NotInsideProjectError';\n\tmessage = 'You are not inside a Dubhe project';\n}\n\nexport class DubheCliError extends Error {\n\tname = 'DubheCliError';\n}\n\nexport class UpgradeError extends Error {\n\tname = 'UpgradeError';\n}\n\nexport class FsIibError extends Error {\n\tname = 'FsIibError';\n}\n\nexport function logError(error: unknown) {\n\tif (error instanceof ValidationError) {\n\t\tconsole.log(chalk.redBright(error.message));\n\t} else if (error instanceof ZodError) {\n\t\t// TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n\t\tconst validationError = fromZodError(error, {\n\t\t\tprefixSeparator: '\\n- ',\n\t\t\tissueSeparator: '\\n- ',\n\t\t});\n\t\tconsole.log(chalk.redBright(validationError.message));\n\t} else if (error instanceof NotInsideProjectError) {\n\t\tconsole.log(chalk.red(error.message));\n\t\tconsole.log('');\n\t\t// TODO add docs to the website and update the link to the specific page\n\t\tconsole.log(\n\t\t\tchalk.blue(\n\t\t\t\t`To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk`\n\t\t\t)\n\t\t);\n\t} else if (error instanceof DubheCliError) {\n\t\tconsole.log(chalk.red(error));\n\t} else {\n\t\tconsole.log(error);\n\t}\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';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\nimport { spawn } from 'child_process';\n\nexport type schema = {\n\tname: string;\n\tobjectId: string;\n\tstructure: Record<string, string>\n};\n\nexport type DeploymentJsonType = {\n\tprojectName: string;\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\tpackageId: string;\n\tupgradeCap: string;\n\tversion: number;\n\tschemas: schema[];\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 getOnchainSchemas(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<schema[]> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.schemas;\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\tupgradeCap: string,\n\tversion: number,\n schemas: schema[],\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\nfunction getDubheDependency(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'): string {\n\tswitch (network) {\n\t\tcase 'localnet':\n\t\t\treturn 'Dubhe = { local = \"../dubhe-framework\" }';\n\t\tcase 'testnet':\n\t\t\treturn 'Dubhe = { git = \"https://github.com/0xobelisk/dubhe-framework.git\", rev = \"dubhe-testnet-v1.1.0\" }';\n\t\tcase 'mainnet':\n\t\t\treturn 'Dubhe = { git = \"https://github.com/0xobelisk/dubhe-framework.git\", rev = \"dubhe-mainnet-v1.1.0\" }';\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported network: ${network}`);\n\t}\n}\n\nexport function updateDubheDependency(filePath: string, network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n\tconst fileContent = fs.readFileSync(filePath, 'utf-8');\n\tconst newDependency = getDubheDependency(network);\n\tconst updatedContent = fileContent.replace(/Dubhe = \\{.*\\}/, newDependency);\n\tfs.writeFileSync(filePath, updatedContent, 'utf-8');\n\tconsole.log(`Updated Dubhe dependency in ${filePath} for ${network}.`);\n}\nexport async function switchEnv(network: 'mainnet' | 'testnet' | 'devnet' | 'localnet') {\n\ttry {\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\tconst suiProcess = spawn(\n\t\t\t\t'sui',\n\t\t\t\t['client', 'switch', '--env', network],\n\t\t\t\t{\n\t\t\t\t\tenv: { ...process.env },\n\t\t\t\t\tstdio: 'pipe'\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tsuiProcess.stdout.on('data', data => {\n\t\t\t\tconsole.log(chalk.green(`${data.toString()}`));\n\t\t\t});\n\n\t\t\tsuiProcess.stderr.on('data', data => {\n\t\t\t\tconsole.error(chalk.red('\\n❌ Failed to Switch Env'));\n\t\t\t\tconsole.error(chalk.red(` Error: ${data.toString()}`));\n\t\t\t});\n\n\t\t\tsuiProcess.on('error', error => {\n\t\t\t\tconsole.error(chalk.red('\\n❌ Failed to Switch Env'));\n\t\t\t\tconsole.error(chalk.red(` Error: ${error.message}`));\n\t\t\t\treject(error); // Reject promise on error\n\t\t\t});\n\n\t\t\tsuiProcess.on('exit', (code) => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tconsole.error(chalk.red(`\\n❌ Process exited with code: ${code}`));\n\t\t\t\t\treject(new Error(`Process exited with code: ${code}`));\n\t\t\t\t} else {\n\t\t\t\t\tresolve(); // Resolve promise on successful exit\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t} catch (error) {\n\t\tconsole.error(chalk.red('\\n❌ Failed to Switch Env'));\n\t\tconsole.error(chalk.red(` └─ Error: ${error}`));\n\t}\n}\n\nexport const delay = (ms: number) =>\n\tnew Promise(resolve => setTimeout(resolve, ms));\n","import type { CommandModule } from 'yargs';\nimport { startLocalNode } from '../utils/startNode';\n\nconst commandModule: CommandModule = {\n\tcommand: 'node',\n\n\tdescribe: 'Manage local Sui node',\n\n\tbuilder(yargs) {\n\t\treturn yargs\n\t},\n\n\tasync handler() {\n\t\ttry {\n\t\t\tawait startLocalNode();\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\nexport default commandModule;\n","import { Dubhe } 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, DubheCliError } 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 Dubhe 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 Dubhe 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 DubheCliError(\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 DubheCliError(`Please check your PRIVATE_KEY.`);\n\t\t\t}\n\t\t\tconst dubhe = new Dubhe({\n\t\t\t\tsecretKey: privateKeyFormat,\n\t\t\t});\n\t\t\tconst keypair = dubhe.getKeypair();\n\t\t\tfaucet_address = keypair.toSuiAddress();\n\t\t} else {\n\t\t\tfaucet_address = recipient;\n\t\t}\n\n\t\tconsole.log('\\n🌊 Starting Faucet Operation...');\n\t\tconsole.log(` ├─ Network: ${network}`);\n\n\t\tif (recipient === undefined) {\n\t\t\tconsole.log(' ├─ Using Environment PrivateKey');\n\t\t\tconsole.log(` ├─ Generated Address: ${faucet_address}`);\n\t\t} else {\n\t\t\tconsole.log(` ├─ Using Provided Address: ${faucet_address}`);\n\t\t}\n\n\t\tconsole.log(' ├─ Requesting funds from faucet...');\n\t\tawait requestSuiFromFaucetV0({\n\t\t\thost: getFaucetHost(network),\n\t\t\trecipient: faucet_address,\n\t\t});\n\n\t\tconsole.log(' └─ Checking balance...');\n\t\tconst client = new SuiClient({ url: getFullnodeUrl(network) });\n\t\tlet params = {\n\t\t\towner: faucet_address,\n\t\t} as GetBalanceParams;\n\n\t\tconst balance = await client.getBalance(params);\n\n\t\tconsole.log('\\n💰 Account Summary');\n\t\tconsole.log(` ├─ Address: ${faucet_address}`);\n\t\tconsole.log(\n\t\t\t` └─ Balance: ${(\n\t\t\t\tNumber(balance.totalBalance) / 1_000_000_000\n\t\t\t).toFixed(4)} SUI`\n\t\t);\n\n\t\tconsole.log('\\n✅ Faucet Operation Complete\\n');\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import type { CommandModule } from 'yargs';\nimport { schemaGen, loadConfig, DubheConfig } from '@0xobelisk/sui-common';\nimport chalk from 'chalk';\n\ntype Options = {\n\t'config-path'?: string;\n\tnetwork?: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\t'framework-id'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'schemagen',\n\n\tdescribe: 'Autogenerate Dubhe schemas based on the config file',\n\n\tbuilder: {\n\t\t'config-path': {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'dubhe.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\t'framework-id': {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Framework Package ID',\n\t\t},\n\t},\n\n\tasync handler({\n\t\t'config-path': configPath,\n\t\tnetwork,\n\t\t'framework-id': frameworkId,\n\t}) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait schemaGen(dubheConfig, 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, DubheConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\tnetwork: any;\n\t'config-path': string;\n\t'gas-budget'?: number;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'publish',\n\n\tdescribe: 'Publish dubhe 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\t'config-path': {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'dubhe.config.ts',\n\t\t\t\tdesc: 'Configuration file path',\n\t\t\t},\n\t\t\t'gas-budget': {\n\t\t\t\ttype: 'number',\n\t\t\t\tdesc: 'Optional gas budget for the transaction',\n\t\t\t\toptional: true,\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({\n\t\tnetwork,\n\t\t'config-path': configPath,\n\t\t'gas-budget': gasBudget,\n\t}) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait publishHandler(dubheConfig, network, gasBudget);\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 { Dubhe } 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 { DubheCliError, UpgradeError } from './errors';\nimport {\n\tupdateVersionInFile,\n\tgetOldPackageId,\n\tgetVersion,\n\tgetUpgradeCap,\n\tsaveContractData,\n\tvalidatePrivateKey, getOnchainSchemas, switchEnv, delay,\n} from './utils';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { DubheConfig } from '@0xobelisk/sui-common';\n\ntype ObjectContent = {\n\ttype: string;\n\tfields: Record<string, any>;\n\thasPublicTransfer: boolean;\n\tdataType: string;\n};\n\ntype Field = {\n\tname: string;\n\ttype: string;\n}\n\ntype Migration = {\n\tschemaName: string;\n\tfields: Field[];\n};\n\nfunction updateMigrateMethod(projectPath: string, migrations: Migration[]): void {\n\tmigrations.forEach((migration) => {\n\t\tlet filePath = `${projectPath}/sources/codegen/schemas/${migration.schemaName}.move`;\n\t\tconst fileContent = fs.readFileSync(filePath, 'utf-8');\n\t\tconst migrateMethodRegex = new RegExp(`public fun migrate\\\\(_${migration.schemaName}: &mut ${capitalizeAndRemoveUnderscores(migration.schemaName)}, _cap: &UpgradeCap\\\\) {[^}]*}`);\n\t\tconst newMigrateMethod = `\npublic fun migrate(${migration.schemaName}: &mut ${capitalizeAndRemoveUnderscores(migration.schemaName)}, _cap: &UpgradeCap) {\n${migration.fields.map((field) => {\n\t\t\tlet storage_type = '';\n\t\t\tif (field.type.includes('StorageValue')) {\n\t\t\t\tstorage_type = `storage_value::new()`;\n\t\t\t} else if (field.type.includes('StorageMap')) {\n\t\t\t\tstorage_type = `storage_map::new()`;\n\t\t\t} else if (\n\t\t\t\tfield.type.includes('StorageDoubleMap')\n\t\t\t) {\n\t\t\t\tstorage_type = `storage_double_map::new()`;\n\t\t\t}\n\t\t\treturn `storage_migration::add_field<${field.type}>(&mut ${migration.schemaName}.id, b\"${field.name}\", ${storage_type});`;\n\t\t}).join('')}\n}\n`;\n\n\t\tconst updatedContent = fileContent.replace(migrateMethodRegex, newMigrateMethod);\n\t\tfs.writeFileSync(filePath, updatedContent, 'utf-8');\n\t});\n\n\n}\n\nfunction capitalizeAndRemoveUnderscores(input: string): string {\n\treturn input\n\t\t.split('_')\n\t\t.map((word, index) => {\n\t\t\treturn index === 0\n\t\t\t\t? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n\t\t\t\t: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n\t\t})\n\t\t.join('');\n}\n\nfunction getLastSegment(input: string): string {\n\tconst segments = input.split('::');\n\treturn segments.length > 0 ? segments[segments.length - 1] : '';\n}\n\nfunction replaceEnvField(\n\tfilePath: string,\n\tnetworkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\tfield: 'original-published-id' | 'latest-published-id' | 'published-version',\n\tnewValue: string\n): string {\n\tconst envFilePath = path.resolve(filePath);\n\tconst envContent = fs.readFileSync(envFilePath, 'utf-8');\n\tconst envLines = envContent.split('\\n');\n\n\tconst networkSectionIndex = envLines.findIndex(line => line.trim() === `[env.${networkType}]`);\n\tif (networkSectionIndex === -1) {\n\t\tconsole.log(`Network type [env.${networkType}] not found in the file.`);\n\t\treturn \"\";\n\t}\n\n\tlet fieldIndex = -1;\n\tlet previousValue: string = \"\";\n\tfor (let i = networkSectionIndex + 1; i < envLines.length; i++) {\n\t\tconst line = envLines[i].trim();\n\t\tif (line.startsWith('[')) break; // End of the current network section\n\n\t\tif (line.startsWith(field)) {\n\t\t\tfieldIndex = i;\n\t\t\tpreviousValue = line.split('=')[1].trim().replace(/\"/g, '');\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (fieldIndex !== -1) {\n\t\tenvLines[fieldIndex] = `${field} = \"${newValue}\"`;\n\t\tconst newEnvContent = envLines.join('\\n');\n\t\tfs.writeFileSync(envFilePath, newEnvContent, 'utf-8');\n\t} else {\n\t\tconsole.log(`${field} not found for [env.${networkType}].`);\n\t}\n\n\treturn previousValue;\n}\nexport async function upgradeHandler(\n\tconfig: DubheConfig,\n\tname: string,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n) {\n\tawait switchEnv(network);\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 DubheCliError(\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 DubheCliError(`Please check your privateKey.`);\n\t}\n\tconst dubhe = new Dubhe({\n\t\tsecretKey: privateKeyFormat,\n\t});\n\tconst keypair = dubhe.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 upgradeCap = await getUpgradeCap(projectPath, network);\n\n\tconst original_published_id = replaceEnvField(`${projectPath}/Move.lock`, network, 'original-published-id', \"0x0000000000000000000000000000000000000000000000000000000000000000\");\n\n\tlet pendingMigration: Migration[] = [];\n\tlet schemas = await getOnchainSchemas(projectPath, network);\n\tfor (let schemaKey in config.schemas) {\n\t\tschemas.forEach((schema) => {\n\t\t\tif (capitalizeAndRemoveUnderscores(schemaKey) == getLastSegment(schema.name)) {\n\t\t\t\tlet migrate: Migration = { schemaName: '', fields: [] };\n\t\t\t\tlet fields: Field[] = [];\n\t\t\t\tlet isMigration = false;\n\t\t\t\tfor (const key in config.schemas[schemaKey].structure) {\n\t\t\t\t\tif (!(key in schema.structure)) {\n\t\t\t\t\t\tisMigration = true;\n\t\t\t\t\t\tfields.push({\n\t\t\t\t\t\t\tname: key,\n\t\t\t\t\t\t\ttype: config.schemas[schemaKey].structure[key],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tschema.structure[key] = config.schemas[schemaKey].structure[key];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (isMigration) {\n\t\t\t\t\tmigrate.schemaName = schemaKey;\n\t\t\t\t\tmigrate.fields = fields;\n\t\t\t\t\tpendingMigration.push(migrate);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\n\tpendingMigration.forEach((migration) => {\n\t\tconsole.log(`\\n🚀 Starting Migration for ${migration.schemaName}...`);\n\t\tconsole.log('📋 Migration Fields:', migration.fields);\n\t});\n\tupdateMigrateMethod(projectPath, pendingMigration);\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\tconsole.log('\\n🚀 Starting Upgrade Process...');\n\t\tconsole.log('📋 OldPackageId:', oldPackageId);\n\t\tconsole.log('📋 UpgradeCap Object Id:', upgradeCap);\n\t\tconsole.log('📋 OldVersion:', oldVersion);\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\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\tlet newPackageId = '';\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\tconsole.log(\n\t\t\t\t\tchalk.blue(`${name} Version: ${oldVersion + 1}`),\n\t\t\t\t);\n\t\t\t\tnewPackageId = object.packageId;\n\t\t\t}\n\t\t});\n\n\t\treplaceEnvField(`${projectPath}/Move.lock`, network, 'original-published-id', original_published_id);\n\t\treplaceEnvField(`${projectPath}/Move.lock`, network, 'latest-published-id', newPackageId);\n\t\treplaceEnvField(`${projectPath}/Move.lock`, network, 'published-version', (oldVersion + 1) + \"\");\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\tupgradeCap,\n\t\t\toldVersion + 1,\n\t\t\tschemas,\n\t\t);\n\n\t} catch (error: any) {\n\t\tconsole.log(chalk.red('Upgrade failed!'));\n\t\tconsole.error(error.message);\n\t}\n}\n","import type { CommandModule } from 'yargs';\nimport { logError } from '../utils/errors';\nimport { upgradeHandler } from '../utils/upgradeHandler';\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\tnetwork: any;\n\t'config-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'upgrade',\n\n\tdescribe: 'Upgrade your move contracts',\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: 'Network of the node (mainnet/testnet/devnet/localnet)',\n\t\t\t},\n\t\t\t'config-path': {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'dubhe.config.ts',\n\t\t\t\tdecs: 'Path to the config file',\n\t\t\t},\n\t\t});\n\t},\n\n\tasync handler({ network, 'config-path': configPath }) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait upgradeHandler(dubheConfig, dubheConfig.name, network);\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\";\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n 'config-path': string;\n 'test'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"test\",\n\n describe: \"Run tests in Dubhe contracts\",\n\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: \"string\",\n default: \"dubhe.config.ts\",\n description: \"Options to pass to forge test\",\n },\n test: {\n type: 'string',\n desc: 'Run a specific test',\n },\n });\n },\n\n async handler({ 'config-path': configPath, test }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('🚀 Running move test');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/contracts/${dubheConfig.name}`;\n const command = `sui move test --path ${projectPath} ${test ? ` --test ${test}` : ''}`;\n const output = execSync(command, { encoding: \"utf-8\" });\n console.log(output);\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 { execSync } from \"child_process\";\nimport chalk from \"chalk\";\nimport { DubheConfig, loadConfig } from '@0xobelisk/sui-common';\nimport { switchEnv, updateDubheDependency } from '../utils';\n\ntype Options = {\n 'config-path': string;\n network: any;\n 'dump-bytecode-as-base64'?: boolean;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"build\",\n describe: \"Run tests in Dubhe contracts\",\n builder(yargs) {\n return yargs.options({\n 'config-path': {\n type: \"string\",\n default: \"dubhe.config.ts\",\n description: \"Options to pass to forge test\",\n },\n network: {\n type: 'string',\n choices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n desc: 'Node network (mainnet/testnet/devnet/localnet)',\n },\n 'dump-bytecode-as-base64': {\n type: 'boolean',\n default: false,\n desc: 'Dump bytecode as base64',\n },\n });\n },\n\n async handler({ 'config-path': configPath, network, 'dump-bytecode-as-base64': dumpBytecodeAsBase64 }) {\n // Start an internal anvil process if no world address is provided\n try {\n console.log('🚀 Running move build');\n const dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n const path = process.cwd();\n const projectPath = `${path}/contracts/${dubheConfig.name}`;\n await switchEnv(network);\n updateDubheDependency(projectPath+'/Move.toml', network);\n const command = `sui move build --path ${projectPath} ${dumpBytecodeAsBase64 ? ` --dump-bytecode-as-base64` : ''}`;\n const output = execSync(command, { encoding: \"utf-8\" });\n console.log(output);\n } catch (error: any) {\n console.error(chalk.red(\"Error executing sui move build:\"));\n console.log(error.stdout);\n process.exit(0);\n }\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { printDubhe } from \"../utils\";\n\nconst commandModule: CommandModule = {\n command: \"hello\",\n\n describe: \"hello, dubhe\",\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n printDubhe();\n },\n};\n\nexport default commandModule;\n","import { Dubhe } from '@0xobelisk/sui-client';\nimport * as fs from 'fs';\nimport chalk from 'chalk';\n\nexport async function generateAccountHandler(\n\tforce: boolean = false,\n\toutputTsPath?: string\n) {\n\tif (outputTsPath) {\n\t\tconsole.log(\n\t\t\tchalk.blue(\n\t\t\t\t'Note: The generated account will be stored in the .env file and the TypeScript file specified by the --output-ts-path option.'\n\t\t\t)\n\t\t);\n\t\tconsole.log(\n\t\t\tchalk.yellow(\n\t\t\t\t'Warning: Do not expose the key file. It is intended for local testing only.\\n'\n\t\t\t)\n\t\t);\n\t}\n\tconst path = process.cwd();\n\tlet privateKey: string;\n\n\tif (force) {\n\t\tconst dubhe = new Dubhe();\n\t\tconst keypair = dubhe.getKeypair();\n\t\tprivateKey = keypair.getSecretKey();\n\n\t\tfs.writeFileSync(`${path}/.env`, `PRIVATE_KEY=${privateKey}`);\n\t\tconsole.log(chalk.green(`File created at: ${path}/.env`));\n\n\t\tif (outputTsPath) {\n\t\t\tconst dir = outputTsPath.substring(\n\t\t\t\t0,\n\t\t\t\toutputTsPath.lastIndexOf('/')\n\t\t\t);\n\t\t\tif (!fs.existsSync(dir)) {\n\t\t\t\tfs.mkdirSync(dir, { recursive: true });\n\t\t\t}\n\t\t\tfs.writeFileSync(\n\t\t\t\toutputTsPath,\n\t\t\t\t`export const PRIVATEKEY = '${privateKey}';\nexport const ACCOUNT = '${keypair.toSuiAddress()}';\n`\n\t\t\t);\n\t\t\tconsole.log(chalk.green(`File created at: ${outputTsPath}\\n`));\n\t\t}\n\n\t\tconsole.log(\n\t\t\tchalk.blue(`Force generate new Account: ${keypair.toSuiAddress()}`)\n\t\t);\n\t\treturn;\n\t}\n\n\t// Check if .env file exists and has content\n\ttry {\n\t\tconst envContent = fs.readFileSync(`${path}/.env`, 'utf8');\n\t\tconst match = envContent.match(/PRIVATE_KEY=(.+)/);\n\t\tif (match && match[1]) {\n\t\t\tprivateKey = match[1];\n\t\t\tconst dubhe = new Dubhe({ secretKey: privateKey });\n\t\t\tconst keypair = dubhe.getKeypair();\n\n\t\t\tif (outputTsPath) {\n\t\t\t\tconst dir = outputTsPath.substring(\n\t\t\t\t\t0,\n\t\t\t\t\toutputTsPath.lastIndexOf('/')\n\t\t\t\t);\n\t\t\t\tif (!fs.existsSync(dir)) {\n\t\t\t\t\tfs.mkdirSync(dir, { recursive: true });\n\t\t\t\t}\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\toutputTsPath,\n\t\t\t\t\t`export const PRIVATEKEY = '${privateKey}';\nexport const ACCOUNT = '${keypair.toSuiAddress()}';\n`\n\t\t\t\t);\n\t\t\t\tconsole.log(chalk.green(`File created at: ${outputTsPath}\\n`));\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\tchalk.blue(`Using existing Account: ${keypair.toSuiAddress()}`)\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t} catch (error) {\n\t\t// .env file doesn't exist or failed to read, continue to generate new account\n\t}\n\n\t// If no existing private key, generate new account\n\tconst dubhe = new Dubhe();\n\tconst keypair = dubhe.getKeypair();\n\tprivateKey = keypair.getSecretKey();\n\tfs.writeFileSync(`${path}/.env`, `PRIVATE_KEY=${privateKey}`);\n\tconsole.log(chalk.green(`File created at: ${path}/.env`));\n\n\tif (outputTsPath) {\n\t\tconst dir = outputTsPath.substring(0, outputTsPath.lastIndexOf('/'));\n\t\tif (!fs.existsSync(dir)) {\n\t\t\tfs.mkdirSync(dir, { recursive: true });\n\t\t}\n\t\tfs.writeFileSync(\n\t\t\toutputTsPath,\n\t\t\t`export const PRIVATEKEY = '${privateKey}';\nexport const ACCOUNT = '${keypair.toSuiAddress()}';\n`\n\t\t);\n\t\tconsole.log(chalk.green(`File created at: ${outputTsPath}\\n`));\n\t}\n\n\tconsole.log(chalk.blue(`Generate new Account: ${keypair.toSuiAddress()}`));\n}\n","import type { CommandModule } from 'yargs';\nimport { generateAccountHandler } from '../utils/generateAccount';\n\ntype Options = {\n\tforce?: boolean;\n\t'output-ts-path'?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'generate-key',\n\tdescribe:\n\t\t'Generate a new account key pair and save it to a .env file, with an option to output to a TypeScript file.',\n\tbuilder: {\n\t\tforce: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t\tdesc: 'Force generate a new key pair',\n\t\t},\n\t\t'output-ts-path': {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Specify the path to output the TypeScript file containing the key pair (e.g., ./src/config/key.ts)',\n\t\t},\n\t},\n\tasync handler({ force, 'output-ts-path': outputTsPath }) {\n\t\ttry {\n\t\t\tawait generateAccountHandler(force, outputTsPath);\n\t\t} catch (error) {\n\t\t\tconsole.error('Error generating account:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import { Dubhe, NetworkType } from '@0xobelisk/sui-client';\nimport chalk from 'chalk';\nimport dotenv from 'dotenv';\nimport { validatePrivateKey } from './utils';\nimport { DubheCliError } from './errors';\ndotenv.config();\n\nexport async function checkBalanceHandler(\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n\ttry {\n\t\tconst privateKey = process.env.PRIVATE_KEY;\n\t\tif (!privateKey) {\n\t\t\tthrow new DubheCliError(\n\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);\n\t\t}\n\t\tconst privateKeyFormat = validatePrivateKey(privateKey);\n\t\tif (privateKeyFormat === false) {\n\t\t\tthrow new DubheCliError(`Please check your privateKey.`);\n\t\t}\n\n\t\tconst dubhe = new Dubhe({\n\t\t\tsecretKey: process.env.PRIVATE_KEY,\n\t\t\tnetworkType: network as NetworkType,\n\t\t});\n\n\t\tconst balance = await dubhe.getBalance();\n\t\tconst balanceInSUI = Number(balance.totalBalance) / 1_000_000_000;\n\n\t\tif (balanceInSUI === 0) {\n\t\t\tthrow new DubheCliError(\n\t\t\t\t`Your account balance is 0 SUI. Please get some SUI to proceed.`\n\t\t\t);\n\t\t}\n\n\t\tconsole.log(\n\t\t\tchalk.green(\n\t\t\t\t`Current account balance: ${balanceInSUI.toFixed(4)} SUI`\n\t\t\t)\n\t\t);\n\t} catch (error) {\n\t\tthrow new DubheCliError('Failed to check balance: ' + error);\n\t}\n}\n","import type { CommandModule } from 'yargs';\nimport { checkBalanceHandler } from '../utils/checkBalance';\n\ntype Options = {\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'check-balance',\n\tdescribe: 'Check the balance of the account',\n\tbuilder: {\n\t\tnetwork: {\n\t\t\ttype: 'string',\n\t\t\tchoices: ['mainnet', 'testnet', 'devnet', 'localnet'],\n\t\t\tdesc: 'Network to check balance on',\n\t\t},\n\t},\n\tasync handler({ network }) {\n\t\ttry {\n\t\t\tawait checkBalanceHandler(network);\n\t\t} catch (error) {\n\t\t\tconsole.error('Error checking balance:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\n};\n\nexport default commandModule;\n","import * as fsAsync from 'fs/promises';\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { exit } from 'process';\nimport { dirname } from 'path';\nimport { DeploymentJsonType, schema } from './utils';\nimport { DubheConfig } from '@0xobelisk/sui-common';\n\nasync function getDeploymentJson(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<DeploymentJsonType> {\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 (error) {\n\t\tthrow new Error(\n\t\t\t`read .history/sui_${network}/latest.json failed. ${error}`\n\t\t);\n\t}\n}\n\nfunction storeConfig(\n\tnetwork: string,\n\tpackageId: string,\n\tschemas: schema[],\n\toutputPath: string\n) {\n\tlet code = `type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';\n\nexport const NETWORK: NetworkType = '${network}';\n\nexport const PACKAGE_ID = '${packageId}'\n\n${schemas\n\t.map(\n\t\tschema =>\n\t\t\t`export const ${schema.name.split('::')[2]}_Object_Id = '${\n\t\t\t\tschema.objectId\n\t\t\t}'`\n\t)\n\t.join('\\n')}\n`;\n\t// if (outputPath) {\n\twriteOutput(code, outputPath, 'storeConfig');\n\t// writeOutput(code, `${path}/src/chain/config.ts`, 'storeConfig');\n\t// }\n}\n\nasync 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\nexport async function storeConfigHandler(\n\tdubheConfig: DubheConfig,\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet',\n\toutputPath: string\n) {\n\tconst path = process.cwd();\n\tconst contractPath = `${path}/contracts/${dubheConfig.name}`;\n\tconst deployment = await getDeploymentJson(contractPath, network);\n\tstoreConfig(\n\t\tdeployment.network,\n\t\tdeployment.packageId,\n\t\tdeployment.schemas,\n\t\toutputPath\n\t);\n}\n","import type { CommandModule } from 'yargs';\nimport { storeConfigHandler } from '../utils/storeConfig';\nimport { loadConfig, DubheConfig } from '@0xobelisk/sui-common';\n\ntype Options = {\n\t'config-path': string;\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet';\n\t'output-ts-path': string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n\tcommand: 'config-store',\n\n\tdescribe: 'Store configuration for the Dubhe project',\n\n\tbuilder: {\n\t\t'config-path': {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'dubhe.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'],\n\t\t\tdesc: 'Network to store config for',\n\t\t},\n\t\t'output-ts-path': {\n\t\t\ttype: 'string',\n\t\t\tdesc: 'Specify the output path for the generated TypeScript configuration file (e.g., ./src/config/generated.ts)',\n\t\t},\n\t},\n\tasync handler({\n\t\t'config-path': configPath,\n\t\tnetwork,\n\t\t'output-ts-path': outputTsPath,\n\t}) {\n\t\ttry {\n\t\t\tconst dubheConfig = (await loadConfig(configPath)) as DubheConfig;\n\t\t\tawait storeConfigHandler(dubheConfig, network, outputTsPath);\n\t\t} catch (error) {\n\t\t\tconsole.error('Error storing config:', error);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tprocess.exit(0);\n\t},\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 build from './build';\nimport hello from './hello';\nimport generateKey from './generateKey';\nimport checkBalance from './checkBalance';\nimport configStore from './configStore';\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\tupgrade,\n\ttest,\n\tbuild,\n\thello,\n\tgenerateKey,\n\tcheckBalance,\n\tconfigStore,\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBCHxB,OAAS,YAAAC,GAAU,SAAAC,OAAa,gBAChC,OAAOC,MAAW,QCDlB,OAAOC,OAAW,QAEX,SAASC,GAAa,CAC3B,QAAQ,IACND,GAAM,OAAO;AAAA;A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,UAAW,UAAW,SAAU,UAAU,EACpD,KAAM,6BACP,EACA,iBAAkB,CACjB,KAAM,SACN,KAAM,2GACP,CACD,EACA,MAAM,QAAQ,CACb,cAAeC,EACf,QAAAC,EACA,iBAAkBC,CACnB,EAAG,CACF,GAAI,CACH,IAAMC,EAAe,MAAML,GAAWE,CAAU,EAChD,MAAMI,GAAmBD,EAAaF,EAASC,CAAY,CAC5D,OAASG,EAAP,CACD,QAAQ,MAAM,wBAAyBA,CAAK,EAC5C,QAAQ,KAAK,CAAC,CACf,CACA,QAAQ,KAAK,CAAC,CACf,CACD,EAEOC,GAAQP,GChCR,IAAMQ,GAAsC,CAClDC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,EACD,ErBnBA,UAAYC,OAAY,SACxB,OAAOC,OAAW,QACX,UAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,OAAO,EAGlB,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,mBAAmB,QAAQ,KAAK,CAAC,2DAA2D,CAC3G,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","execSync","spawn","chalk","chalk","printDubhe","Dubhe","Transaction","getFullnodeUrl","SuiClient","execSync","chalk","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","DubheCliError","UpgradeError","FsIibError","logError","error","validationError","fsAsync","mkdirSync","writeFileSync","dirname","SUI_PRIVATE_KEY_PREFIX","fs","chalk","spawn","validatePrivateKey","privateKey","SUI_PRIVATE_KEY_PREFIX","strippedPrivateKey","getDeploymentJson","projectPath","network","data","FsIibError","getOnchainSchemas","getVersion","getOldPackageId","projectPath","network","getDeploymentJson","getUpgradeCap","saveContractData","projectName","network","packageId","upgradeCap","version","schemas","DeploymentData","path","storeDeploymentData","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","getDubheDependency","updateDubheDependency","filePath","fileContent","newDependency","updatedContent","switchEnv","resolve","reject","suiProcess","spawn","data","chalk","error","code","delay","ms","fs","path","removeEnvContent","filePath","networkType","content","regex","updatedContent","updateEnvFile","operation","chainId","publishedId","envFilePath","envContent","envLines","networkSectionIndex","line","config","i","key","value","part","updatedSection","newEnvContent","capitalizeAndRemoveUnderscores","input","word","index","getLastSegment","segments","buildContract","projectPath","modules","dependencies","buildResult","execSync","error","chalk","publishContract","client","dubhe","dubheConfig","network","gasBudget","keypair","tx","Transaction","upgradeCap","result","version","packageId","schemas","upgradeCapId","object","delay","deployHookTx","deployHookResult","structure","schemaKey","saveContractData","checkDubheFramework","publishDubheFramework","publishHandler","switchEnv","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","Dubhe","SuiClient","getFullnodeUrl","updateDubheDependency","Dubhe","isSuiStartRunning","cmd","result","execSync","printAccounts","privateKeys","privateKey","index","keypair","spawn","chalk","startLocalNode","printDubhe","suiProcess","error","delay","validatePrivateKey","DubheCliError","commandModule","yargs","startLocalNode","error","localnode_default","Dubhe","requestSuiFromFaucetV0","getFaucetHost","SuiClient","getFullnodeUrl","commandModule","yargs","network","recipient","faucet_address","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","Dubhe","requestSuiFromFaucetV0","getFaucetHost","client","SuiClient","getFullnodeUrl","params","balance","faucet_default","schemaGen","loadConfig","chalk","commandModule","configPath","network","frameworkId","dubheConfig","error","schemagen_default","loadConfig","commandModule","yargs","network","configPath","gasBudget","dubheConfig","publishHandler","error","logError","publish_default","Dubhe","Transaction","UpgradePolicy","getFullnodeUrl","SuiClient","execSync","chalk","fs","path","updateMigrateMethod","projectPath","migrations","migration","filePath","fileContent","migrateMethodRegex","capitalizeAndRemoveUnderscores","newMigrateMethod","field","storage_type","updatedContent","input","word","index","getLastSegment","segments","replaceEnvField","networkType","newValue","envFilePath","envLines","networkSectionIndex","line","fieldIndex","previousValue","i","newEnvContent","upgradeHandler","config","name","network","switchEnv","privateKey","DubheCliError","privateKeyFormat","validatePrivateKey","keypair","Dubhe","client","SuiClient","getFullnodeUrl","oldVersion","getVersion","oldPackageId","getOldPackageId","upgradeCap","getUpgradeCap","original_published_id","pendingMigration","schemas","getOnchainSchemas","schemaKey","schema","migrate","fields","isMigration","key","modules","dependencies","digest","extractedModules","extractedDependencies","extractedDigest","execSync","error","UpgradeError","tx","Transaction","ticket","UpgradePolicy","receipt","result","newPackageId","object","chalk","saveContractData","loadConfig","commandModule","yargs","network","configPath","dubheConfig","upgradeHandler","error","logError","upgrade_default","execSync","chalk","loadConfig","commandModule","yargs","configPath","test","dubheConfig","command","output","error","test_default","execSync","chalk","loadConfig","commandModule","yargs","configPath","network","dumpBytecodeAsBase64","dubheConfig","loadConfig","projectPath","switchEnv","updateDubheDependency","command","output","execSync","error","chalk","build_default","commandModule","yargs","printDubhe","hello_default","Dubhe","fs","chalk","generateAccountHandler","force","outputTsPath","path","privateKey","keypair","dir","match","commandModule","force","outputTsPath","generateAccountHandler","error","generateKey_default","Dubhe","chalk","dotenv","dotenv","checkBalanceHandler","network","privateKey","DubheCliError","validatePrivateKey","balance","Dubhe","balanceInSUI","chalk","error","commandModule","network","checkBalanceHandler","error","checkBalance_default","fsAsync","mkdirSync","writeFileSync","dirname","getDeploymentJson","projectPath","network","data","error","storeConfig","packageId","schemas","outputPath","code","schema","writeOutput","output","fullOutputPath","logPrefix","storeConfigHandler","dubheConfig","contractPath","deployment","loadConfig","commandModule","configPath","network","outputTsPath","dubheConfig","storeConfigHandler","error","configStore_default","commands","publish_default","localnode_default","faucet_default","schemagen_default","upgrade_default","test_default","build_default","hello_default","generateKey_default","checkBalance_default","configStore_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.36",
3
+ "version": "0.5.38",
4
4
  "description": "Tookit for interacting with move eps framework",
5
5
  "keywords": [
6
6
  "sui",
@@ -45,8 +45,8 @@
45
45
  "yargs": "^17.7.1",
46
46
  "zod": "^3.22.3",
47
47
  "zod-validation-error": "^1.3.0",
48
- "@0xobelisk/sui-client": "0.5.30",
49
- "@0xobelisk/sui-common": "0.5.25"
48
+ "@0xobelisk/sui-common": "0.5.25",
49
+ "@0xobelisk/sui-client": "0.5.30"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/ejs": "^3.1.1",
@@ -3,7 +3,6 @@ import { checkBalanceHandler } from '../utils/checkBalance';
3
3
 
4
4
  type Options = {
5
5
  network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
6
- amount: number;
7
6
  };
8
7
 
9
8
  const commandModule: CommandModule<Options, Options> = {
@@ -15,15 +14,10 @@ const commandModule: CommandModule<Options, Options> = {
15
14
  choices: ['mainnet', 'testnet', 'devnet', 'localnet'],
16
15
  desc: 'Network to check balance on',
17
16
  },
18
- amount: {
19
- type: 'number',
20
- default: 2,
21
- desc: 'Amount of SUI to check balance for',
22
- },
23
17
  },
24
- async handler({ network, amount }) {
18
+ async handler({ network }) {
25
19
  try {
26
- await checkBalanceHandler(network, amount);
20
+ await checkBalanceHandler(network);
27
21
  } catch (error) {
28
22
  console.error('Error checking balance:', error);
29
23
  process.exit(1);
@@ -6,7 +6,6 @@ import { loadConfig, DubheConfig } from '@0xobelisk/sui-common';
6
6
  type Options = {
7
7
  network: any;
8
8
  'config-path': string;
9
- 'contract-name'?: string;
10
9
  'gas-budget'?: number;
11
10
  };
12
11
 
@@ -27,10 +26,6 @@ const commandModule: CommandModule<Options, Options> = {
27
26
  default: 'dubhe.config.ts',
28
27
  desc: 'Configuration file path',
29
28
  },
30
- 'contract-name': {
31
- type: 'string',
32
- desc: 'Optional contract name in contracts/ directory',
33
- },
34
29
  'gas-budget': {
35
30
  type: 'number',
36
31
  desc: 'Optional gas budget for the transaction',
@@ -42,12 +37,11 @@ const commandModule: CommandModule<Options, Options> = {
42
37
  async handler({
43
38
  network,
44
39
  'config-path': configPath,
45
- 'contract-name': contractName,
46
40
  'gas-budget': gasBudget,
47
41
  }) {
48
42
  try {
49
43
  const dubheConfig = (await loadConfig(configPath)) as DubheConfig;
50
- await publishHandler(dubheConfig, network, contractName, gasBudget);
44
+ await publishHandler(dubheConfig, network, gasBudget);
51
45
  } catch (error: any) {
52
46
  logError(error);
53
47
  process.exit(1);
@@ -6,16 +6,9 @@ import { DubheCliError } from './errors';
6
6
  dotenv.config();
7
7
 
8
8
  export async function checkBalanceHandler(
9
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
10
- amount: number = 2
9
+ network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'
11
10
  ) {
12
11
  try {
13
- console.log(
14
- chalk.blue(
15
- `Note: You need at least 2 SUI for transaction fees and staking, and registering a Dapp will reserve 1 SUI for Dubhe Dapp Staking, which can be retrieved upon unregistering.`
16
- )
17
- );
18
-
19
12
  const privateKey = process.env.PRIVATE_KEY;
20
13
  if (!privateKey) {
21
14
  throw new DubheCliError(
@@ -37,12 +30,9 @@ export async function checkBalanceHandler(
37
30
  const balance = await dubhe.getBalance();
38
31
  const balanceInSUI = Number(balance.totalBalance) / 1_000_000_000;
39
32
 
40
- if (balanceInSUI < amount) {
41
- // console.log(chalk.yellow(`Account balance is less than 2 SUI.`));
33
+ if (balanceInSUI === 0) {
42
34
  throw new DubheCliError(
43
- `Your account balance ${balanceInSUI.toFixed(
44
- 4
45
- )} SUI is less than ${amount} SUI. Please get more SUI.`
35
+ `Your account balance is 0 SUI. Please get some SUI to proceed.`
46
36
  );
47
37
  }
48
38
 
@@ -21,10 +21,10 @@ import { DubheConfig } from '@0xobelisk/sui-common';
21
21
  import * as fs from 'fs';
22
22
  import * as path from 'path';
23
23
 
24
- function removeEnvContent(
24
+ async function removeEnvContent(
25
25
  filePath: string,
26
26
  networkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet'
27
- ): void {
27
+ ): Promise<void> {
28
28
  if (!fs.existsSync(filePath)) {
29
29
  return;
30
30
  }
@@ -171,7 +171,7 @@ async function publishContract(
171
171
  gasBudget?: number
172
172
  ) {
173
173
  const chainId = await client.getChainIdentifier();
174
- removeEnvContent(`${projectPath}/Move.lock`, network);
174
+ await removeEnvContent(`${projectPath}/Move.lock`, network);
175
175
  console.log('\n🚀 Starting Contract Publication...');
176
176
  console.log(` ├─ Project: ${projectPath}`);
177
177
  console.log(` ├─ Network: ${network}`);
@@ -246,7 +246,7 @@ async function publishContract(
246
246
  const deployHookTx = new Transaction();
247
247
  deployHookTx.moveCall({
248
248
  target: `${packageId}::deploy_hook::run`,
249
- arguments: [ deployHookTx.object('0x6') ],
249
+ arguments: [deployHookTx.object('0x6')],
250
250
  });
251
251
 
252
252
  let deployHookResult: SuiTransactionBlockResponse;
@@ -316,6 +316,32 @@ async function publishContract(
316
316
  }
317
317
  }
318
318
 
319
+ async function checkDubheFramework(projectPath: string): Promise<boolean> {
320
+ if (!fs.existsSync(projectPath)) {
321
+ console.log(chalk.yellow('\nℹ️ Dubhe Framework Files Not Found'));
322
+ console.log(chalk.yellow(' ├─ Expected Path:'), projectPath);
323
+ console.log(chalk.yellow(' ├─ To set up Dubhe Framework:'));
324
+ console.log(
325
+ chalk.yellow(
326
+ ' │ 1. Create directory: mkdir -p contracts/dubhe-framework'
327
+ )
328
+ );
329
+ console.log(
330
+ chalk.yellow(
331
+ ' │ 2. Clone repository: git clone https://github.com/0xobelisk/dubhe-framework contracts/dubhe-framework'
332
+ )
333
+ );
334
+ console.log(
335
+ chalk.yellow(
336
+ ' │ 3. Or download from: https://github.com/0xobelisk/dubhe-framework'
337
+ )
338
+ );
339
+ console.log(chalk.yellow(' └─ After setup, restart the local node'));
340
+ return false;
341
+ }
342
+ return true;
343
+ }
344
+
319
345
  export async function publishDubheFramework(
320
346
  client: SuiClient,
321
347
  dubhe: Dubhe,
@@ -323,14 +349,17 @@ export async function publishDubheFramework(
323
349
  ) {
324
350
  const path = process.cwd();
325
351
  const projectPath = `${path}/contracts/dubhe-framework`;
352
+
353
+ if (!(await checkDubheFramework(projectPath))) {
354
+ console.log(chalk.yellow('\n❗ Framework Deployment Skipped'));
355
+ return;
356
+ }
357
+
326
358
  const chainId = await client.getChainIdentifier();
327
- console.log(` └─ Chain ID: ${chainId}`);
328
- removeEnvContent(`${projectPath}/Move.lock`, network);
359
+ await removeEnvContent(`${projectPath}/Move.lock`, network);
329
360
  console.log('\n🚀 Starting Contract Publication...');
330
361
  console.log(` ├─ Project: ${projectPath}`);
331
362
  console.log(` ├─ Network: ${network}`);
332
- console.log(` ├─ ChainId: ${chainId}`);
333
- console.log(' ├─ Validating Environment...');
334
363
 
335
364
  const keypair = dubhe.getKeypair();
336
365
  console.log(` └─ Account: ${keypair.toSuiAddress()}`);
@@ -361,7 +390,6 @@ export async function publishDubheFramework(
361
390
  process.exit(1);
362
391
  }
363
392
 
364
- console.log(' ├─ Processing publication results...');
365
393
  let version = 1;
366
394
  let packageId = '';
367
395
  let schemas: schema[] = [];
@@ -399,12 +427,12 @@ export async function publishDubheFramework(
399
427
  version,
400
428
  schemas
401
429
  );
430
+ console.log(chalk.green('\n✅ Dubhe Framework deployed successfully'));
402
431
  }
403
432
 
404
433
  export async function publishHandler(
405
434
  dubheConfig: DubheConfig,
406
435
  network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
407
- contractName?: string,
408
436
  gasBudget?: number
409
437
  ) {
410
438
  await switchEnv(network);
@@ -425,19 +453,19 @@ in your contracts directory to use the default sui private key.`
425
453
  const dubhe = new Dubhe({ secretKey: privateKeyFormat });
426
454
  const client = new SuiClient({ url: getFullnodeUrl(network) });
427
455
 
428
- if (contractName == 'dubhe-framework') {
456
+ if (network === 'localnet') {
429
457
  await publishDubheFramework(client, dubhe, network);
430
- } else {
431
- const path = process.cwd();
432
- const projectPath = `${path}/contracts/${dubheConfig.name}`;
433
- updateDubheDependency(`${projectPath}/Move.toml`, network);
434
- await publishContract(
435
- client,
436
- dubhe,
437
- dubheConfig,
438
- network,
439
- projectPath,
440
- gasBudget
441
- );
442
458
  }
459
+
460
+ const path = process.cwd();
461
+ const projectPath = `${path}/contracts/${dubheConfig.name}`;
462
+ updateDubheDependency(`${projectPath}/Move.toml`, network);
463
+ await publishContract(
464
+ client,
465
+ dubhe,
466
+ dubheConfig,
467
+ network,
468
+ projectPath,
469
+ gasBudget
470
+ );
443
471
  }
@@ -1,7 +1,12 @@
1
1
  import { execSync, spawn } from 'child_process';
2
2
  import chalk from 'chalk';
3
3
  import { printDubhe } from './printDubhe';
4
- import { delay, DubheCliError, publishDubheFramework, validatePrivateKey } from '../utils';
4
+ import {
5
+ delay,
6
+ DubheCliError,
7
+ publishDubheFramework,
8
+ validatePrivateKey,
9
+ } from '../utils';
5
10
  import { Dubhe } from '@0xobelisk/sui-client';
6
11
  import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';
7
12
 
@@ -24,35 +29,54 @@ function isSuiStartRunning(): boolean {
24
29
  async function printAccounts() {
25
30
  // These private keys are used for testing purposes only, do not use them in production.
26
31
  const privateKeys = [
27
- "suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v",
28
- "suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s",
29
- "suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc",
30
- "suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c",
31
- "suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57",
32
- "suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c",
33
- ]
34
- console.log("📝Accounts")
35
- console.log("==========")
32
+ 'suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v',
33
+ 'suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s',
34
+ 'suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc',
35
+ 'suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c',
36
+ 'suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57',
37
+ 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c',
38
+ ];
39
+ console.log('📝Accounts');
40
+ console.log('==========');
36
41
  privateKeys.forEach((privateKey, index) => {
37
42
  const dubhe = new Dubhe({ secretKey: privateKey });
38
43
  const keypair = dubhe.getKeypair();
39
44
  spawn(
40
45
  'curl',
41
- ['--location', '--request', 'POST', 'http://127.0.0.1:9123/gas', '--header', 'Content-Type: application/json', '--data-raw', `{"FixedAmountRequest": {"recipient": "${keypair.toSuiAddress()}"}}`],
46
+ [
47
+ '--location',
48
+ '--request',
49
+ 'POST',
50
+ 'http://127.0.0.1:9123/gas',
51
+ '--header',
52
+ 'Content-Type: application/json',
53
+ '--data-raw',
54
+ `{"FixedAmountRequest": {"recipient": "${keypair.toSuiAddress()}"}}`,
55
+ ],
42
56
  {
43
57
  env: { ...process.env },
44
58
  stdio: 'ignore',
45
59
  detached: true,
46
60
  }
47
- )
48
- console.log(` ┌─ Account #${index}: ${keypair.toSuiAddress()}(1000 SUI)`);
61
+ );
62
+ console.log(
63
+ ` ┌─ Account #${index}: ${keypair.toSuiAddress()}(1000 SUI)`
64
+ );
49
65
  console.log(` └─ Private Key: ${privateKey}`);
50
66
  });
51
- console.log("==========")
52
- console.log(chalk.yellow("⚠️WARNING: These accounts, and their private keys, are publicly known."));
53
- console.log(chalk.yellow("Any funds sent to them on Mainnet or any other live network WILL BE LOST."));
67
+ console.log('==========');
68
+ console.log(
69
+ chalk.yellow(
70
+ 'ℹ️ WARNING: These accounts, and their private keys, are publicly known.'
71
+ )
72
+ );
73
+ console.log(
74
+ chalk.yellow(
75
+ 'Any funds sent to them on Mainnet or any other live network WILL BE LOST.'
76
+ )
77
+ );
54
78
  }
55
- export async function startLocalNode() {
79
+ export async function startLocalNode() {
56
80
  if (isSuiStartRunning()) {
57
81
  console.log(chalk.yellow('\n⚠️ Warning: Local Node Already Running'));
58
82
  console.log(chalk.yellow(' ├─ Cannot start a new instance'));
@@ -89,18 +113,14 @@ async function printAccounts() {
89
113
 
90
114
  await delay(2000);
91
115
 
92
- const privateKeyFormat = validatePrivateKey("suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c");
116
+ const privateKeyFormat = validatePrivateKey(
117
+ 'suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c'
118
+ );
93
119
  if (privateKeyFormat === false) {
94
120
  throw new DubheCliError(`Please check your privateKey.`);
95
121
  }
96
122
 
97
- const dubhe = new Dubhe({ secretKey: privateKeyFormat });
98
- const client = new SuiClient({ url: getFullnodeUrl('localnet') });
99
- const originalLog = console.log;
100
-
101
- console.log = () => {};
102
- await publishDubheFramework(client, dubhe, 'localnet');
103
- console.log = originalLog;
123
+ console.log(chalk.green('🎉 Local environment is ready!'));
104
124
 
105
125
  process.on('SIGINT', () => {
106
126
  console.log(chalk.yellow('\n🔔 Stopping Local Node...'));
@@ -113,5 +133,6 @@ async function printAccounts() {
113
133
  } catch (error: any) {
114
134
  console.error(chalk.red('\n❌ Failed to Start Local Node'));
115
135
  console.error(chalk.red(` └─ Error: ${error.message}`));
136
+ process.exit(1);
116
137
  }
117
138
  }
@@ -172,9 +172,9 @@ function getDubheDependency(network: 'mainnet' | 'testnet' | 'devnet' | 'localn
172
172
  case 'localnet':
173
173
  return 'Dubhe = { local = "../dubhe-framework" }';
174
174
  case 'testnet':
175
- return 'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-testnet-v1.0.0" }';
175
+ return 'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-testnet-v1.1.0" }';
176
176
  case 'mainnet':
177
- return 'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-mainnet-v1.0.0" }';
177
+ return 'Dubhe = { git = "https://github.com/0xobelisk/dubhe-framework.git", rev = "dubhe-mainnet-v1.1.0" }';
178
178
  default:
179
179
  throw new Error(`Unsupported network: ${network}`);
180
180
  }