@0xobelisk/sui-cli 0.5.34 → 0.5.35

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 Wt from"yargs";import{hideBin as Zt}from"yargs/helpers";import{execSync as tt,spawn as de}from"child_process";import _ from"chalk";import Re from"chalk";function V(){console.log(Re.yellow(`
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(`
3
3
  Welcome to Dubhe
4
4
  --from team@obelisk
5
5
  ________ ___ ___ ________ ___ ___ _______
@@ -10,65 +10,65 @@ Welcome to Dubhe
10
10
  \\ \\_______\\ \\_______\\ \\_______\\ \\__\\ \\__\\ \\_______\\
11
11
  \\|_______|\\|_______|\\|_______|\\|__|\\|__|\\|_______|
12
12
 
13
- `))}import{Dubhe as Be}from"@0xobelisk/sui-client";import{Transaction as W}from"@mysten/sui/transactions";import{getFullnodeUrl as Ge,SuiClient as Je}from"@mysten/sui/client";import{execSync as We}from"child_process";import S from"chalk";import T from"chalk";import{ZodError as Te}from"zod";import{fromZodError as je,ValidationError as Ne}from"zod-validation-error";var J=class extends Error{name="NotInsideProjectError";message="You are not inside a Dubhe project"},g=class extends Error{name="DubheCliError"},Y=class extends Error{name="UpgradeError"},q=class extends Error{name="FsIibError"};function O(e){if(e instanceof Ne)console.log(T.redBright(e.message));else if(e instanceof Te){let t=je(e,{prefixSeparator:`
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:`
14
14
  - `,issueSeparator:`
15
- - `});console.log(T.redBright(t.message))}else e instanceof J?(console.log(T.red(e.message)),console.log(""),console.log(T.blue("To learn more about Dubhe's configuration, please go to https://github.com/0xobelisk"))):e instanceof g?console.log(T.red(e)):console.log(e)}import*as ee from"fs/promises";import{mkdirSync as Ue,writeFileSync as Ve}from"fs";import{dirname as Ye}from"path";import{SUI_PRIVATE_KEY_PREFIX as qe}from"@mysten/sui/cryptography";import*as H from"fs";import E from"chalk";import{spawn as He}from"child_process";function $(e){if(e.startsWith(qe))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 j(e,t){try{let o=await ee.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch{throw new q("Fs read deployment file failed.")}}async function te(e,t){return(await j(e,t)).schemas}async function oe(e,t){return(await j(e,t)).version}async function ne(e,t){return(await j(e,t)).packageId}async function re(e,t){return(await j(e,t)).upgradeCap}async function L(e,t){return(await j(e,t)).schemaHub}function N(e,t,o,r,n,s,a){let c={projectName:e,network:t,packageId:o,schemas:a,upgradeCap:r,schemaHub:n,version:s},d=process.cwd(),i=JSON.stringify(c,null,2);Le(i,`${d}/contracts/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function Le(e,t,o){Ue(Ye(t),{recursive:!0}),Ve(t,e),o!==void 0&&console.log(`${o}: ${t}`)}function ze(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 z(e,t){let o=H.readFileSync(e,"utf-8"),r=ze(t),n=o.replace(/Dubhe = \{.*\}/,r);H.writeFileSync(e,n,"utf-8"),console.log(`Updated Dubhe dependency in ${e} for ${t}.`)}async function M(e){try{return new Promise((t,o)=>{let r=He("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(`
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
16
  \u274C Failed to Switch Env`)),console.error(E.red(` Error: ${n.toString()}`))}),r.on("error",n=>{console.error(E.red(`
17
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
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 U=e=>new Promise(t=>setTimeout(t,e));import*as D from"fs";import*as se from"path";async function Ze(e){switch(e){case"localnet":{let t=process.cwd();return await L(`${t}/contracts/dubhe-framework`,e)}case"testnet":return"0x8dbf8d28ac027ba214c9e0951b09f6842843be6cb87242b7d9a326a2677cd47a";default:return"0x8dbf8d28ac027ba214c9e0951b09f6842843be6cb87242b7d9a326a2677cd47a"}}function ae(e,t){if(!D.existsSync(e))return;let o=D.readFileSync(e,"utf-8"),r=new RegExp(`\\[env\\.${t}\\][\\s\\S]*?(?=\\[|$)`,"g"),n=o.replace(r,"");D.writeFileSync(e,n,"utf-8")}function ie(e,t,o,r,n){let s=se.resolve(e),a=D.readFileSync(s,"utf-8"),c=a.split(`
20
- `),d=c.findIndex(w=>w.trim()===`[env.${t}]`),i={chainId:r,originalPublishedId:"",latestPublishedId:"",publishedVersion:0};if(d===-1)if(o==="publish")i.originalPublishedId=n,i.latestPublishedId=n,i.publishedVersion=1;else throw new Error(`Network type [env.${t}] not found in the file and cannot upgrade.`);else{for(let w=d+1;w<c.length;w++){let f=c[w].trim();if(f.startsWith("["))break;let[P,b]=f.split("=").map(x=>x.trim().replace(/"/g,""));switch(P){case"original-published-id":i.originalPublishedId=b;break;case"latest-published-id":i.latestPublishedId=b;break;case"published-version":i.publishedVersion=parseInt(b,10);break}}o==="publish"?(i.originalPublishedId=n,i.latestPublishedId=n,i.publishedVersion=1):o==="upgrade"&&(i.latestPublishedId=n,i.publishedVersion+=1)}let u=`
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=`
21
21
  [env.${t}]
22
- chain-id = "${i.chainId}"
23
- original-published-id = "${i.originalPublishedId}"
24
- latest-published-id = "${i.latestPublishedId}"
25
- published-version = "${i.publishedVersion}"
26
- `,m=d===-1?a+u:c.slice(0,d).join(`
27
- `)+u;D.writeFileSync(s,m,"utf-8")}function Xe(e){return e.split("_").map((t,o)=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function Qe(e){let t=e.split("::");return t.length>0?t[t.length-1]:""}function ce(e){let t,o;try{let r=JSON.parse(We(`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(S.red(" \u2514\u2500 Build failed")),console.error(r.stdout),process.exit(1)}return[t,o]}async function et(e,t,o,r,n,s){let a=await Ze(r);console.log("dappsObjectId",a);let c=await e.getChainIdentifier();ae(`${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: ${c}`),console.log(" \u251C\u2500 Validating Environment...");let d=t.getKeypair();console.log(` \u2514\u2500 Account: ${d.toSuiAddress()}`),console.log(`
29
- \u{1F4E6} Building Contract...`);let[i,u]=ce(n);console.log(`
30
- \u{1F504} Publishing Contract...`);let m=new W;s&&m.setGasBudget(s);let[w]=m.publish({modules:i,dependencies:u});m.transferObjects([w],d.toSuiAddress());let f;try{f=await e.signAndExecuteTransaction({signer:d,transaction:m,options:{showObjectChanges:!0}})}catch(l){console.error(S.red(" \u2514\u2500 Publication failed")),console.error(l.message),process.exit(1)}f.effects?.status.status==="failure"&&(console.log(S.red(" \u2514\u2500 Publication failed")),process.exit(1)),console.log(" \u251C\u2500 Processing publication results...");let P=1,b="",x=[],p="",C="";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),l.type==="created"&&l.objectType.includes("schema_hub")&&(console.log(` \u251C\u2500 Schema Hub: ${l.objectId}`),C=l.objectId)}),console.log(` \u2514\u2500 Transaction: ${f.digest}`),ie(`${n}/Move.lock`,r,"publish",c,b),console.log(`
31
- \u26A1 Executing Deploy Hook...`),await U(5e3);let h=new W;s&&h.setGasBudget(s);let[v]=h.splitCoins(h.gas,["1000000000"]);h.moveCall({target:`${b}::deploy_hook::run`,arguments:[h.object(C),h.object(a),h.object(p),h.object("0x6"),v]});let k;try{k=await e.signAndExecuteTransaction({signer:d,transaction:h,options:{showEffects:!0,showObjectChanges:!0}})}catch(l){console.error(S.red(" \u2514\u2500 Deploy hook execution failed")),console.error(l.message),process.exit(1)}k.effects?.status.status==="success"?(console.log(" \u251C\u2500 Hook execution successful"),console.log(` \u251C\u2500 Transaction: ${k.digest}`),console.log(`
32
- \u{1F4CB} Created Schemas:`),k.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 R={};for(let F in o.schemas)Xe(F)===Qe(l.objectType)&&(R=o.schemas[F].structure);x.push({name:l.objectType,objectId:l.objectId,structure:R})}}),N(o.name,r,b,p,C,P,x),console.log(`
22
+ chain-id = "${a.chainId}"
23
+ original-published-id = "${a.originalPublishedId}"
24
+ latest-published-id = "${a.latestPublishedId}"
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(`
33
33
  \u2705 Contract Publication Complete
34
- `)):(console.log(S.yellow(" \u2514\u2500 Deploy hook execution failed")),console.log(S.yellow(" Please republish or manually call deploy_hook::run")),console.log(S.yellow(" Please check the transaction digest:")),console.log(S.yellow(` ${k.digest}`)),process.exit(1))}async function Z(e,t,o){let n=`${process.cwd()}/contracts/dubhe-framework`,s=await e.getChainIdentifier();console.log(` \u2514\u2500 Chain ID: ${s}`),ae(`${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 a=t.getKeypair();console.log(` \u2514\u2500 Account: ${a.toSuiAddress()}`),console.log(`
36
- \u{1F4E6} Building Contract...`);let[c,d]=ce(n);console.log(`
37
- \u{1F504} Publishing Contract...`);let i=new W,[u]=i.publish({modules:c,dependencies:d});i.transferObjects([u],a.toSuiAddress());let m;try{m=await e.signAndExecuteTransaction({signer:a,transaction:i,options:{showObjectChanges:!0}})}catch(p){console.error(S.red(" \u2514\u2500 Publication failed")),console.error(p.message),process.exit(1)}m.effects?.status.status==="failure"&&(console.log(S.red(" \u2514\u2500 Publication failed")),process.exit(1)),console.log(" \u251C\u2500 Processing publication results...");let w=1,f="",P=[],b="",x="";m.objectChanges.map(p=>{p.type==="published"&&(console.log(` \u251C\u2500 Package ID: ${p.packageId}`),f=p.packageId),p.type==="created"&&p.objectType==="0x2::package::UpgradeCap"&&(console.log(` \u251C\u2500 Upgrade Cap: ${p.objectId}`),b=p.objectId),p.type==="created"&&p.objectType.includes("dapps")&&(console.log(` \u251C\u2500 Dapps: ${p.objectId}`),x=p.objectId)}),console.log(` \u2514\u2500 Transaction: ${m.digest}`),ie(`${n}/Move.lock`,o,"publish",s,f),N("dubhe-framework",o,f,b,x,w,P)}async function le(e,t,o,r){await M(t);let n=process.env.PRIVATE_KEY;if(!n)throw new g(`Missing PRIVATE_KEY environment variable.
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.
38
38
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
39
- in your contracts directory to use the default sui private key.`);let s=$(n);if(s===!1)throw new g("Please check your privateKey.");let a=new Be({secretKey:s}),c=new Je({url:Ge(t)});if(o=="dubhe-framework")await Z(c,a,t);else{let i=`${process.cwd()}/contracts/${e.name}`;z(`${i}/Move.toml`,t),await et(c,a,e,t,i,r)}}import{Dubhe as pe}from"@0xobelisk/sui-client";import{getFullnodeUrl as ot,SuiClient as nt}from"@mysten/sui/client";function rt(){try{let e=process.platform==="win32"?'tasklist /FI "IMAGENAME eq sui.exe" /FO CSV /NH':'pgrep -f "sui start"',t=tt(e).toString().trim();return process.platform==="win32"?t.toLowerCase().includes("sui.exe"):t.length>0}catch{return!1}}async function st(){let e=["suiprivkey1qq3ez3dje66l8pypgxynr7yymwps6uhn7vyczespj84974j3zya0wdpu76v","suiprivkey1qp6vcyg8r2x88fllmjmxtpzjl95gd9dugqrgz7xxf50w6rqdqzetg7x4d7s","suiprivkey1qpy3a696eh3m55fwa8h38ss063459u4n2dm9t24w2hlxxzjp2x34q8sdsnc","suiprivkey1qzxwp29favhzrjd95f6uj9nskjwal6nh9g509jpun395y6g72d6jqlmps4c","suiprivkey1qzhq4lv38sesah4uzsqkkmeyjx860xqjdz8qgw36tmrdd5tnle3evxpng57","suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c"];console.log("\u{1F4DD}Accounts"),console.log("=========="),e.forEach((t,o)=>{let n=new pe({secretKey:t}).getKeypair();de("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(_.yellow("\u26A0\uFE0FWARNING: 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 ue(){if(rt()){console.log(_.yellow(`
40
- \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}V(),console.log("\u{1F680} Starting Local Node...");try{let e=de("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(_.red(`
41
- \u274C Failed to Start Local Node`)),console.error(_.red(` \u2514\u2500 Error: ${s.message}`))}),await U(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 st(),await U(2e3);let t=$("suiprivkey1qzez45sjjsepjgtksqvpq6jw7dzw3zq0dx7a4sulfypd73acaynw5jl9x2c");if(t===!1)throw new g("Please check your privateKey.");let o=new pe({secretKey:t}),r=new nt({url:ot("localnet")}),n=console.log;console.log=()=>{},await Z(r,o,"localnet"),console.log=n,process.on("SIGINT",()=>{console.log(_.yellow(`
42
- \u{1F514} Stopping Local Node...`)),e&&(e.kill(),console.log(_.green("\u2705 Local Node Stopped"))),process.exit()})}catch(e){console.error(_.red(`
43
- \u274C Failed to Start Local Node`)),console.error(_.red(` \u2514\u2500 Error: ${e.message}`))}}var at={command:"node",describe:"Manage local Sui node",builder(e){return e},async handler(){try{await ue()}catch(e){console.error("Error executing command:",e),process.exit(1)}}},ge=at;import{Dubhe as it}from"@0xobelisk/sui-client";import{requestSuiFromFaucetV0 as ct,getFaucetHost as lt}from"@mysten/sui/faucet";import{SuiClient as dt,getFullnodeUrl as pt}from"@mysten/sui/client";var ut={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 a=process.env.PRIVATE_KEY;if(!a)throw new g(`Missing PRIVATE_KEY environment variable.
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.
44
44
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
45
- in your contracts directory to use the default sui private key.`);let c=$(a);if(c===!1)throw new g("Please check your PRIVATE_KEY.");o=new it({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 ct({host:lt(e),recipient:o}),console.log(" \u2514\u2500 Checking balance...");let r=new dt({url:pt(e)}),n={owner:o},s=await r.getBalance(n);console.log(`
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(`
47
47
  \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
48
  \u2705 Faucet Operation Complete
49
- `),process.exit(0)}},me=ut;import{schemaGen as gt,loadConfig as mt}from"@0xobelisk/sui-common";import ft from"chalk";var ht={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 mt(e);await gt(r,void 0,t,o),process.exit(0)}catch(r){console.log(ft.red("Schemagen failed!")),console.error(r.message)}}},fe=ht;import{loadConfig as yt}from"@0xobelisk/sui-common";var bt={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 yt(t);await le(n,e,o,r)}catch(n){O(n),process.exit(1)}process.exit(0)}},he=bt;import{Dubhe as vt}from"@0xobelisk/sui-client";import{Transaction as wt,UpgradePolicy as _t}from"@mysten/sui/transactions";import{getFullnodeUrl as xt,SuiClient as Ct}from"@mysten/sui/client";import{execSync as kt}from"child_process";import B from"chalk";import*as K from"fs";import*as ye from"path";function $t(e,t){t.forEach(o=>{let r=`${e}/sources/codegen/schemas/${o.schemaName}.move`,n=K.readFileSync(r,"utf-8"),s=new RegExp(`public fun migrate\\(_${o.schemaName}: &mut ${X(o.schemaName)}, _cap: &UpgradeCap\\) {[^}]*}`),a=`
50
- public fun migrate(${o.schemaName}: &mut ${X(o.schemaName)}, _cap: &UpgradeCap) {
51
- ${o.fields.map(d=>{let i="";return d.type.includes("StorageValue")?i="storage_value::new()":d.type.includes("StorageMap")?i="storage_map::new()":d.type.includes("StorageDoubleMap")&&(i="storage_double_map::new()"),`storage_migrate::add_field<${d.type}>(&mut ${o.schemaName}.id, b"${d.name}", ${i});`}).join("")}
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) {
51
+ ${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
52
  }
53
- `,c=n.replace(s,a);K.writeFileSync(r,c,"utf-8")})}function X(e){return e.split("_").map((t,o)=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join("")}function St(e){let t=e.split("::");return t.length>0?t[t.length-1]:""}function G(e,t,o,r){let n=ye.resolve(e),a=K.readFileSync(n,"utf-8").split(`
54
- `),c=a.findIndex(u=>u.trim()===`[env.${t}]`);if(c===-1)return console.log(`Network type [env.${t}] not found in the file.`),"";let d=-1,i="";for(let u=c+1;u<a.length;u++){let m=a[u].trim();if(m.startsWith("["))break;if(m.startsWith(o)){d=u,i=m.split("=")[1].trim().replace(/"/g,"");break}}if(d!==-1){a[d]=`${o} = "${r}"`;let u=a.join(`
55
- `);K.writeFileSync(n,u,"utf-8")}else console.log(`${o} not found for [env.${t}].`);return i}async function be(e,t,o){await M(o);let r=process.cwd(),n=`${r}/contracts/${t}`,s=process.env.PRIVATE_KEY;if(!s)throw new g(`Missing PRIVATE_KEY environment variable.
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
56
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
57
- in your contracts directory to use the default sui private key.`);let a=$(s);if(a===!1)throw new g("Please check your privateKey.");let d=new vt({secretKey:a}).getKeypair(),i=new Ct({url:xt(o)}),u=Number(await oe(n,o)),m=await ne(n,o),w=await L(n,o),f=await re(n,o),P=G(`${n}/Move.lock`,o,"original-published-id","0x0000000000000000000000000000000000000000000000000000000000000000"),b=[],x=await te(n,o);for(let p in e.schemas)x.forEach(C=>{if(X(p)==St(C.name)){let h={schemaName:"",fields:[]},v=[],k=!1;for(let l in e.schemas[p].structure)l in C.structure||(k=!0,v.push({name:l,type:e.schemas[p].structure[l]}),C.structure[l]=e.schemas[p].structure[l]);k&&(h.schemaName=p,h.fields=v,b.push(h))}});b.forEach(p=>{console.log(`
58
- \u{1F680} Starting Migration for ${p.schemaName}...`),console.log("\u{1F4CB} Migration Fields:",p.fields)}),$t(n,b);try{let p,C,h;try{let{modules:A,dependencies:Me,digest:Ke}=JSON.parse(kt(`sui move build --dump-bytecode-as-base64 --path ${r}/contracts/${t}`,{encoding:"utf-8"}));p=A,C=Me,h=Ke}catch(A){throw new Y(A.stdout)}console.log(`
59
- \u{1F680} Starting Upgrade Process...`),console.log("\u{1F4CB} OldPackageId:",m),console.log("\u{1F4CB} UpgradeCap Object Id:",f),console.log("\u{1F4CB} OldVersion:",u);let v=new wt,k=v.moveCall({target:"0x2::package::authorize_upgrade",arguments:[v.object(f),v.pure.u8(_t.COMPATIBLE),v.pure.vector("u8",h)]}),l=v.upgrade({modules:p,dependencies:C,package:m,ticket:k});v.moveCall({target:"0x2::package::commit_upgrade",arguments:[v.object(f),l]});let R=await i.signAndExecuteTransaction({signer:d,transaction:v,options:{showObjectChanges:!0}}),F="";R.objectChanges.map(A=>{A.type==="published"&&(console.log(B.blue(`${t} PackageId: ${A.packageId}`)),console.log(B.blue(`${t} Version: ${u+1}`)),F=A.packageId)}),G(`${n}/Move.lock`,o,"original-published-id",P),G(`${n}/Move.lock`,o,"latest-published-id",F),G(`${n}/Move.lock`,o,"published-version",u+1+""),console.log(B.green(`Upgrade Transaction Digest: ${R.digest}`)),N(t,o,F,f,w,u+1,x)}catch(p){console.log(B.red("Upgrade failed!")),console.error(p.message)}}import{loadConfig as It}from"@0xobelisk/sui-common";var Et={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 It(t);await be(o,o.name,e)}catch(o){O(o),process.exit(1)}process.exit(0)}},ve=Et;import{execSync as Dt}from"child_process";import Pt from"chalk";import{loadConfig as At}from"@0xobelisk/sui-common";var Ft={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 At(e),s=`sui move test --path ${`${process.cwd()}/contracts/${o.name}`} ${t?` --test ${t}`:""}`,a=Dt(s,{encoding:"utf-8"});console.log(a)}catch(o){console.error(Pt.red("Error executing sui move test:")),console.log(o.stdout),process.exit(0)}}},we=Ft;import{execSync as Ot}from"child_process";import Mt from"chalk";import{loadConfig as Kt}from"@0xobelisk/sui-common";var Rt={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 Kt(e),s=`${process.cwd()}/contracts/${r.name}`;await M(t),z(s+"/Move.toml",t);let a=`sui move build --path ${s} ${o?" --dump-bytecode-as-base64":""}`,c=Ot(a,{encoding:"utf-8"});console.log(c)}catch(r){console.error(Mt.red("Error executing sui move build:")),console.log(r.stdout),process.exit(0)}}},_e=Rt;var Tt={command:"hello",describe:"hello, dubhe",builder(e){return e},async handler(){V()}},xe=Tt;import{Dubhe as Q}from"@0xobelisk/sui-client";import*as y from"fs";import I from"chalk";async function Ce(e=!1,t){t&&(console.log(I.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(I.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 Q().getKeypair();if(r=c.getSecretKey(),y.writeFileSync(`${o}/.env`,`PRIVATE_KEY=${r}`),console.log(I.green(`File created at: ${o}/.env`)),t){let d=t.substring(0,t.lastIndexOf("/"));y.existsSync(d)||y.mkdirSync(d,{recursive:!0}),y.writeFileSync(t,`export const PRIVATEKEY = '${r}';
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}';
61
61
  export const ACCOUNT = '${c.toSuiAddress()}';
62
- `),console.log(I.green(`File created at: ${t}
63
- `))}console.log(I.blue(`Force generate new Account: ${c.toSuiAddress()}`));return}try{let c=y.readFileSync(`${o}/.env`,"utf8").match(/PRIVATE_KEY=(.+)/);if(c&&c[1]){r=c[1];let i=new Q({secretKey:r}).getKeypair();if(t){let u=t.substring(0,t.lastIndexOf("/"));y.existsSync(u)||y.mkdirSync(u,{recursive:!0}),y.writeFileSync(t,`export const PRIVATEKEY = '${r}';
64
- export const ACCOUNT = '${i.toSuiAddress()}';
65
- `),console.log(I.green(`File created at: ${t}
66
- `))}console.log(I.blue(`Using existing Account: ${i.toSuiAddress()}`));return}}catch{}let s=new Q().getKeypair();if(r=s.getSecretKey(),y.writeFileSync(`${o}/.env`,`PRIVATE_KEY=${r}`),console.log(I.green(`File created at: ${o}/.env`)),t){let a=t.substring(0,t.lastIndexOf("/"));y.existsSync(a)||y.mkdirSync(a,{recursive:!0}),y.writeFileSync(t,`export const PRIVATEKEY = '${r}';
62
+ `),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}';
64
+ export const ACCOUNT = '${a.toSuiAddress()}';
65
+ `),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}';
67
67
  export const ACCOUNT = '${s.toSuiAddress()}';
68
- `),console.log(I.green(`File created at: ${t}
69
- `))}console.log(I.blue(`Generate new Account: ${s.toSuiAddress()}`))}var jt={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 Ce(e,t)}catch(o){console.error("Error generating account:",o),process.exit(1)}process.exit(0)}},ke=jt;import{Dubhe as Nt}from"@0xobelisk/sui-client";import $e from"chalk";import Ut from"dotenv";Ut.config();async function Se(e,t=2){try{console.log($e.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.
68
+ `),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.
70
70
  Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
71
- in your contracts directory to use the default sui private key.`);if($(o)===!1)throw new g("Please check your privateKey.");let s=await new Nt({secretKey:process.env.PRIVATE_KEY,networkType:e}).getBalance(),a=Number(s.totalBalance)/1e9;if(a<t)throw new g(`Your account balance ${a.toFixed(4)} SUI is less than ${t} SUI. Please get more SUI.`);console.log($e.green(`Current account balance: ${a.toFixed(4)} SUI`))}catch(o){throw new g("Failed to check balance: "+o)}}var Vt={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 Se(e,t)}catch(o){console.error("Error checking balance:",o),process.exit(1)}process.exit(0)}},Ie=Vt;import*as Ee from"fs/promises";import{mkdirSync as Yt,writeFileSync as qt}from"fs";import{dirname as Ht}from"path";async function Lt(e,t){try{let o=await Ee.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 zt(e,t,o,r){let n=`type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet';
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';
72
72
 
73
73
  export const NETWORK: NetworkType = '${e}';
74
74
 
@@ -76,5 +76,5 @@ export const PACKAGE_ID = '${t}'
76
76
 
77
77
  ${o.map(s=>`export const ${s.name.split("::")[2]}_Object_Id = '${s.objectId}'`).join(`
78
78
  `)}
79
- `;Bt(n,r,"storeConfig")}async function Bt(e,t,o){Yt(Ht(t),{recursive:!0}),qt(t,e),o!==void 0&&console.log(`${o}: ${t}`)}async function De(e,t,o){let n=`${process.cwd()}/contracts/${e.name}`,s=await Lt(n,t);zt(s.network,s.packageId,s.schemas,o)}import{loadConfig as Gt}from"@0xobelisk/sui-common";var Jt={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 Gt(e);await De(r,t,o)}catch(r){console.error("Error storing config:",r),process.exit(1)}process.exit(0)}},Pe=Jt;var Ae=[he,ge,me,fe,ve,we,_e,xe,ke,Ie,Pe];import*as Oe from"dotenv";import Fe from"chalk";Oe.config();Wt(Zt(process.argv)).scriptName("dubhe").command(Ae).strict().fail((e,t)=>{console.error(Fe.red(e)),e.includes("Missing required argument")&&console.log(Fe.yellow(`Run 'pnpm dubhe ${process.argv[2]} --help' for a list of available and required arguments.`)),console.log(""),O(t),console.log(""),process.exit(1)}).alias({h:"help"}).argv;
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;
80
80
  //# 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\tgetSchemaHub,\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 getDappsObjectId(\n\tnetwork: 'mainnet' | 'testnet' | 'devnet' | 'localnet'\n) {\n\tswitch (network) {\n\t\tcase 'localnet': {\n\t\t\tconst path = process.cwd();\n\t\t\treturn await getSchemaHub(\n\t\t\t\t`${path}/contracts/dubhe-framework`,\n\t\t\t\tnetwork\n\t\t\t);\n\t\t}\n\t\tcase 'testnet':\n\t\t\treturn '0x8dbf8d28ac027ba214c9e0951b09f6842843be6cb87242b7d9a326a2677cd47a';\n\t\tdefault:\n\t\t\treturn '0x8dbf8d28ac027ba214c9e0951b09f6842843be6cb87242b7d9a326a2677cd47a';\n\t}\n}\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\nconst chainIds: { [key: string]: string } = {\n\tlocalnet: 'dfa7bb83',\n\ttestnet: '4c78adac',\n\tmainnet: '35834a8a',\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 dappsObjectId = await getDappsObjectId(network);\n\tconsole.log('dappsObjectId', dappsObjectId);\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\tlet schemaHubId = '';\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\tif (\n\t\t\tobject.type === 'created' &&\n\t\t\tobject.objectType.includes('schema_hub')\n\t\t) {\n\t\t\tconsole.log(` ā”œā”€ Schema Hub: ${object.objectId}`);\n\t\t\tschemaHubId = 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\tif (gasBudget) {\n\t\tdeployHookTx.setGasBudget(gasBudget);\n\t}\n\tconst [txCoin] = deployHookTx.splitCoins(deployHookTx.gas, ['1000000000']);\n\tdeployHookTx.moveCall({\n\t\ttarget: `${packageId}::deploy_hook::run`,\n\t\targuments: [\n\t\t\tdeployHookTx.object(schemaHubId),\n\t\t\tdeployHookTx.object(dappsObjectId),\n\t\t\tdeployHookTx.object(upgradeCapId),\n\t\t\tdeployHookTx.object('0x6'),\n\t\t\ttxCoin,\n\t\t],\n\t});\n\n\tlet deployHookResult: SuiTransactionBlockResponse;\n\ttry {\n\t\tdeployHookResult = await client.signAndExecuteTransaction({\n\t\t\tsigner: keypair,\n\t\t\ttransaction: deployHookTx,\n\t\t\toptions: { 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\tschemaHubId,\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\tlet schemaHubId = '';\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\tif (object.type === 'created' && object.objectType.includes('dapps')) {\n\t\t\tconsole.log(` ā”œā”€ Dapps: ${object.objectId}`);\n\t\t\tschemaHubId = 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\tschemaHubId,\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\tschemaHub: 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 getSchemaHub(\n\tprojectPath: string,\n\tnetwork: string\n): Promise<string> {\n\tconst deployment = await getDeploymentJson(projectPath, network);\n\treturn deployment.schemaHub;\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\tschemaHub: 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\tschemaHub,\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, getSchemaHub, 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_migrate::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 schemaHub = await getSchemaHub(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\tschemaHub,\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,OAAOC,MAAW,QCDlB,OAAOC,OAAW,QAEX,SAASC,GAAa,CAC3B,QAAQ,IACND,GAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAWhB,CACC,CACF,CCjBA,OAAS,SAAAE,OAAa,wBACtB,OAAS,eAAAC,MAAmB,2BAC5B,OACC,kBAAAC,GACA,aAAAC,OAE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AC,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","getSchemaHub","saveContractData","projectName","network","packageId","upgradeCap","schemaHub","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","getDappsObjectId","network","getSchemaHub","removeEnvContent","filePath","networkType","content","regex","updatedContent","updateEnvFile","filePath","networkType","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","dappsObjectId","getDappsObjectId","removeEnvContent","keypair","tx","Transaction","upgradeCap","result","version","packageId","schemas","upgradeCapId","schemaHubId","object","delay","deployHookTx","txCoin","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","schemaHub","getSchemaHub","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 { 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,OAAOC,MAAW,QCDlB,OAAOC,OAAW,QAEX,SAASC,GAAa,CAC3B,QAAQ,IACND,GAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAWhB,CACC,CACF,CCjBA,OAAS,SAAAE,OAAa,wBACtB,OAAS,eAAAC,MAAmB,2BAC5B,OACC,kBAAAC,GACA,aAAAC,OAEM,qBACP,OAAS,YAAAC,OAAgB,gBACzB,OAAOC,MAAW,QCRlB,OAAOC,MAAW,QAClB,OAAS,YAAAC,OAAgB,MACzB,OAAS,gBAAAC,GAAc,mBAAAC,OAAuB,uBAEvC,IAAMC,EAAN,cAAoC,KAAM,CAChD,KAAO,wBACP,QAAU,oCACX,EAEaC,EAAN,cAA4B,KAAM,CACxC,KAAO,eACR,EAEaC,EAAN,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OC,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xobelisk/sui-cli",
3
- "version": "0.5.34",
3
+ "version": "0.5.35",
4
4
  "description": "Tookit for interacting with move eps framework",
5
5
  "keywords": [
6
6
  "sui",
@@ -31,8 +31,6 @@
31
31
  "dubhe": "./dist/dubhe.js"
32
32
  },
33
33
  "dependencies": {
34
- "@0xobelisk/sui-client": "^0.5.28",
35
- "@0xobelisk/sui-common": "^0.5.23",
36
34
  "@mysten/sui": "^1.7.0",
37
35
  "chalk": "^5.0.1",
38
36
  "child_process": "^1.0.2",
@@ -46,7 +44,9 @@
46
44
  "typescript": "5.1.6",
47
45
  "yargs": "^17.7.1",
48
46
  "zod": "^3.22.3",
49
- "zod-validation-error": "^1.3.0"
47
+ "zod-validation-error": "^1.3.0",
48
+ "@0xobelisk/sui-common": "0.5.24",
49
+ "@0xobelisk/sui-client": "0.5.30"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/ejs": "^3.1.1",
@@ -13,7 +13,6 @@ import {
13
13
  saveContractData,
14
14
  validatePrivateKey,
15
15
  schema,
16
- getSchemaHub,
17
16
  updateDubheDependency,
18
17
  switchEnv,
19
18
  delay,
@@ -22,24 +21,6 @@ import { DubheConfig } from '@0xobelisk/sui-common';
22
21
  import * as fs from 'fs';
23
22
  import * as path from 'path';
24
23
 
25
- async function getDappsObjectId(
26
- network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'
27
- ) {
28
- switch (network) {
29
- case 'localnet': {
30
- const path = process.cwd();
31
- return await getSchemaHub(
32
- `${path}/contracts/dubhe-framework`,
33
- network
34
- );
35
- }
36
- case 'testnet':
37
- return '0x8dbf8d28ac027ba214c9e0951b09f6842843be6cb87242b7d9a326a2677cd47a';
38
- default:
39
- return '0x8dbf8d28ac027ba214c9e0951b09f6842843be6cb87242b7d9a326a2677cd47a';
40
- }
41
- }
42
-
43
24
  function removeEnvContent(
44
25
  filePath: string,
45
26
  networkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet'
@@ -63,12 +44,6 @@ interface EnvConfig {
63
44
  publishedVersion: number;
64
45
  }
65
46
 
66
- const chainIds: { [key: string]: string } = {
67
- localnet: 'dfa7bb83',
68
- testnet: '4c78adac',
69
- mainnet: '35834a8a',
70
- };
71
-
72
47
  function updateEnvFile(
73
48
  filePath: string,
74
49
  networkType: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
@@ -195,8 +170,6 @@ async function publishContract(
195
170
  projectPath: string,
196
171
  gasBudget?: number
197
172
  ) {
198
- const dappsObjectId = await getDappsObjectId(network);
199
- console.log('dappsObjectId', dappsObjectId);
200
173
  const chainId = await client.getChainIdentifier();
201
174
  removeEnvContent(`${projectPath}/Move.lock`, network);
202
175
  console.log('\nšŸš€ Starting Contract Publication...');
@@ -242,7 +215,6 @@ async function publishContract(
242
215
  let packageId = '';
243
216
  let schemas: schema[] = [];
244
217
  let upgradeCapId = '';
245
- let schemaHubId = '';
246
218
 
247
219
  result.objectChanges!.map(object => {
248
220
  if (object.type === 'published') {
@@ -256,13 +228,6 @@ async function publishContract(
256
228
  console.log(` ā”œā”€ Upgrade Cap: ${object.objectId}`);
257
229
  upgradeCapId = object.objectId;
258
230
  }
259
- if (
260
- object.type === 'created' &&
261
- object.objectType.includes('schema_hub')
262
- ) {
263
- console.log(` ā”œā”€ Schema Hub: ${object.objectId}`);
264
- schemaHubId = object.objectId;
265
- }
266
231
  });
267
232
 
268
233
  console.log(` └─ Transaction: ${result.digest}`);
@@ -279,19 +244,9 @@ async function publishContract(
279
244
  await delay(5000);
280
245
 
281
246
  const deployHookTx = new Transaction();
282
- if (gasBudget) {
283
- deployHookTx.setGasBudget(gasBudget);
284
- }
285
- const [txCoin] = deployHookTx.splitCoins(deployHookTx.gas, ['1000000000']);
286
247
  deployHookTx.moveCall({
287
248
  target: `${packageId}::deploy_hook::run`,
288
- arguments: [
289
- deployHookTx.object(schemaHubId),
290
- deployHookTx.object(dappsObjectId),
291
- deployHookTx.object(upgradeCapId),
292
- deployHookTx.object('0x6'),
293
- txCoin,
294
- ],
249
+ arguments: [ deployHookTx.object('0x6') ],
295
250
  });
296
251
 
297
252
  let deployHookResult: SuiTransactionBlockResponse;
@@ -344,7 +299,6 @@ async function publishContract(
344
299
  network,
345
300
  packageId,
346
301
  upgradeCapId,
347
- schemaHubId,
348
302
  version,
349
303
  schemas
350
304
  );
@@ -412,7 +366,6 @@ export async function publishDubheFramework(
412
366
  let packageId = '';
413
367
  let schemas: schema[] = [];
414
368
  let upgradeCapId = '';
415
- let schemaHubId = '';
416
369
 
417
370
  result.objectChanges!.map(object => {
418
371
  if (object.type === 'published') {
@@ -426,10 +379,6 @@ export async function publishDubheFramework(
426
379
  console.log(` ā”œā”€ Upgrade Cap: ${object.objectId}`);
427
380
  upgradeCapId = object.objectId;
428
381
  }
429
- if (object.type === 'created' && object.objectType.includes('dapps')) {
430
- console.log(` ā”œā”€ Dapps: ${object.objectId}`);
431
- schemaHubId = object.objectId;
432
- }
433
382
  });
434
383
 
435
384
  console.log(` └─ Transaction: ${result.digest}`);
@@ -447,7 +396,6 @@ export async function publishDubheFramework(
447
396
  network,
448
397
  packageId,
449
398
  upgradeCapId,
450
- schemaHubId,
451
399
  version,
452
400
  schemas
453
401
  );
@@ -10,7 +10,7 @@ import {
10
10
  getVersion,
11
11
  getUpgradeCap,
12
12
  saveContractData,
13
- validatePrivateKey, getOnchainSchemas, getSchemaHub, switchEnv, delay,
13
+ validatePrivateKey, getOnchainSchemas, switchEnv, delay,
14
14
  } from './utils';
15
15
  import * as fs from 'fs';
16
16
  import * as path from 'path';
@@ -51,7 +51,7 @@ ${migration.fields.map((field) => {
51
51
  ) {
52
52
  storage_type = `storage_double_map::new()`;
53
53
  }
54
- return `storage_migrate::add_field<${field.type}>(&mut ${migration.schemaName}.id, b"${field.name}", ${storage_type});`;
54
+ return `storage_migration::add_field<${field.type}>(&mut ${migration.schemaName}.id, b"${field.name}", ${storage_type});`;
55
55
  }).join('')}
56
56
  }
57
57
  `;
@@ -150,7 +150,6 @@ in your contracts directory to use the default sui private key.`,
150
150
 
151
151
  let oldVersion = Number(await getVersion(projectPath, network));
152
152
  let oldPackageId = await getOldPackageId(projectPath, network);
153
- let schemaHub = await getSchemaHub(projectPath, network);
154
153
  let upgradeCap = await getUpgradeCap(projectPath, network);
155
154
 
156
155
  const original_published_id = replaceEnvField(`${projectPath}/Move.lock`, network, 'original-published-id', "0x0000000000000000000000000000000000000000000000000000000000000000");
@@ -273,7 +272,6 @@ in your contracts directory to use the default sui private key.`,
273
272
  network,
274
273
  newPackageId,
275
274
  upgradeCap,
276
- schemaHub,
277
275
  oldVersion + 1,
278
276
  schemas,
279
277
  );
@@ -18,7 +18,6 @@ export type DeploymentJsonType = {
18
18
  network: 'mainnet' | 'testnet' | 'devnet' | 'localnet';
19
19
  packageId: string;
20
20
  upgradeCap: string;
21
- schemaHub: string;
22
21
  version: number;
23
22
  schemas: schema[];
24
23
  };
@@ -119,14 +118,6 @@ export async function getUpgradeCap(
119
118
  return deployment.upgradeCap;
120
119
  }
121
120
 
122
- export async function getSchemaHub(
123
- projectPath: string,
124
- network: string
125
- ): Promise<string> {
126
- const deployment = await getDeploymentJson(projectPath, network);
127
- return deployment.schemaHub;
128
- }
129
-
130
121
  export async function getObjectIdBySchemaName(
131
122
  projectPath: string,
132
123
  network: string,
@@ -142,7 +133,6 @@ export function saveContractData(
142
133
  network: 'mainnet' | 'testnet' | 'devnet' | 'localnet',
143
134
  packageId: string,
144
135
  upgradeCap: string,
145
- schemaHub: string,
146
136
  version: number,
147
137
  schemas: schema[],
148
138
  ) {
@@ -152,7 +142,6 @@ export function saveContractData(
152
142
  packageId,
153
143
  schemas,
154
144
  upgradeCap,
155
- schemaHub,
156
145
  version,
157
146
  };
158
147