@0xobelisk/sui-cli 0.4.9

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/LICENSE ADDED
@@ -0,0 +1,92 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: Obelisk Labs
11
+
12
+ Licensed Work: Obelisk Engine
13
+ The Licensed Work is (c) 2023 Obelisk Labs
14
+
15
+ -----------------------------------------------------------------------------
16
+
17
+ Terms
18
+
19
+ The Licensor hereby grants you the right to copy, modify, create derivative
20
+ works, redistribute, and make non-production use of the Licensed Work. The
21
+ Licensor may make an Additional Use Grant, above, permitting limited
22
+ production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly
25
+ available distribution of a specific version of the Licensed Work under this
26
+ License, whichever comes first, the Licensor hereby grants you rights under
27
+ the terms of the Change License, and the rights granted in the paragraph
28
+ above terminate.
29
+
30
+ If your use of the Licensed Work does not comply with the requirements
31
+ currently in effect as described in this License, you must purchase a
32
+ commercial license from the Licensor, its affiliated entities, or authorized
33
+ resellers, or you must refrain from using the Licensed Work.
34
+
35
+ All copies of the original and modified Licensed Work, and derivative works
36
+ of the Licensed Work, are subject to this License. This License applies
37
+ separately for each version of the Licensed Work and the Change Date may vary
38
+ for each version of the Licensed Work released by Licensor.
39
+
40
+ You must conspicuously display this License on each original or modified copy
41
+ of the Licensed Work. If you receive the Licensed Work in original or
42
+ modified form from a third party, the terms and conditions set forth in this
43
+ License apply to your use of that work.
44
+
45
+ Any use of the Licensed Work in violation of this License will automatically
46
+ terminate your rights under this License for the current and all other
47
+ versions of the Licensed Work.
48
+
49
+ This License does not grant you any right in any trademark or logo of
50
+ Licensor or its affiliates (provided that you may use a trademark or logo of
51
+ Licensor as expressly required by this License).
52
+
53
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
54
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
55
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
56
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
57
+ TITLE.
58
+
59
+ MariaDB hereby grants you permission to use this License’s text to license
60
+ your works, and to refer to it using the trademark "Business Source License",
61
+ as long as you comply with the Covenants of Licensor below.
62
+
63
+ -----------------------------------------------------------------------------
64
+
65
+ Covenants of Licensor
66
+
67
+ In consideration of the right to use this License’s text and the "Business
68
+ Source License" name and trademark, Licensor covenants to MariaDB, and to all
69
+ other recipients of the licensed work to be provided by Licensor:
70
+
71
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
72
+ or a license that is compatible with GPL Version 2.0 or a later version,
73
+ where "compatible" means that software provided under the Change License can
74
+ be included in a program with software provided under GPL Version 2.0 or a
75
+ later version. Licensor may specify additional Change Licenses without
76
+ limitation.
77
+
78
+ 2. To either: (a) specify an additional grant of rights to use that does not
79
+ impose any additional restriction on the right granted in this License, as
80
+ the Additional Use Grant; or (b) insert the text "None".
81
+
82
+ 3. To specify a Change Date.
83
+
84
+ 4. Not to modify this License in any other way.
85
+
86
+ -----------------------------------------------------------------------------
87
+
88
+ Notice
89
+
90
+ The Business Source License (this document, or the "License") is not an Open
91
+ Source license. However, the Licensed Work will eventually be made available
92
+ under an Open Source License, as stated in this License.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ ## The Obelisk CLI
2
+
3
+ The Obelisk CLI is used for building and developing a Obelisk project.
4
+
5
+ It comes with
6
+
7
+
8
+ 1. `schemagen <configPath>`: Autogenerate Obelisk schemas based on the store schemas config file
9
+ 2. `publish`: Deploy your own world project on the specified sui network.
10
+ 3. `upgrade`: Upgrade your own world project on the specified sui network.
11
+ 4. `localnode`: Start a local Sui node for development
12
+ 5. `faucet`: An interface to the Devnet/Localnet faucet. It makes it easy to fund addresses on the Devnet/localnet
13
+
14
+ ## Installation
15
+
16
+ We don’t recommend installing the CLI globally.
17
+
18
+ Instead, you should add the CLI as a dev dependency to your project (done automatically if you start from a starter kit using `pnpm create obelisk-world`), and use it with `pnpm build` inside your project directory.
19
+
20
+ ## Using the CLI
21
+
22
+ Some commands expect a Obelisk config in the same folder where the CLI is being executed. This includes `schemagen` and `publish`.
23
+
24
+ `faucet`, and `localnode` can be executed anywhere.
25
+
26
+ ## Commands
27
+
28
+ ### `schemagen`
29
+
30
+ Generates Store libraries from a `obelisk.config.ts` file. See the [Store Config and `schemagen` documentation](../schemas/config) in the Store section for more details.
31
+
32
+ ```bash
33
+ # in a folder with a obelisk.config.ts
34
+ obelisk schemagen obelisk.config.ts
35
+ ```
36
+
37
+ ### `publish`
38
+
39
+ Deploy a Obelisk contract project with the World framework.
40
+
41
+ This tool will use the `obelisk.config.ts` to detect all systems, schemas and projectName in the World and will deploy them to the chain specified.
42
+
43
+ When using the deployer, you must set the private key of the deployer using the `PRIVATE_KEY` environment variable. You can make this easier by using [`dotenv`](https://www.npmjs.com/package/dotenv) before running `obelisk publish` in your deployment script.
44
+
45
+ To set up the target network for deploying the contract (mainnet/testnet/devnet/localnet), before deploying the contract, please make sure that you have some tokens in your account, which will be used for some fees when deploying the contract. (If you choose devnet/localnet, you can get some test tokens via `obelisk faucet`), if you need to deploy the contract on localnet, please make sure you have started localnode.
46
+
47
+ ```bash
48
+ # to deploy sui locally
49
+ obelisk publish --network localnet
50
+ # to deploy to sui devnet
51
+ obelisk publish --network devnet
52
+ # to deploy to sui testnet
53
+ obelisk publish --network testnet
54
+ # to deploy to sui mainnet
55
+ obelisk publish --network mainnet
56
+ ```
57
+
58
+
59
+ ### `upgrade`
60
+
61
+ Upgrade Obelisk contract project.
62
+
63
+ When you add a new schema or modify the system code, you need to upgrade the contract through the `upgrade` method. ([Contract upgrade specification](../migrating-from-others))
64
+
65
+ ```bash
66
+ obelisk upgrade --network <network:mainnet/testnet/devnet/localnet>
67
+ ```
68
+
69
+ ### `localnode`
70
+
71
+ The localnode uses the official `sui-test-validator` binary provided by sui to start the localnode.
72
+
73
+ The local rpc is `http://127.0.0.1:9000`
74
+
75
+ ```bash
76
+ obelisk localnode
77
+ ```
78
+
79
+ ### `faucet`
80
+
81
+ Connects to a Obelisk faucet service to fund an address.
82
+
83
+ ```bash
84
+ obelisk faucet --network <network:devnet/localnet>
85
+ obelisk faucet --network <network:devnet/localnet> --recipient <address>
86
+ ```
87
+
88
+ The default faucet service automatically gives test tokens to accounts in [`dotenv`](https://www.npmjs.com/package/dotenv).
89
+
90
+ To fund an address on the devnet/localnet, run `obelisk faucet --recipient <address>`
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ import Ge from"yargs";import{hideBin as Le}from"yargs/helpers";import{execa as me}from"execa";var ge={command:"localnode",describe:"Start a local Sui node for development",builder(e){return e},async handler(){console.log("Clearing localnode history"),console.log("Running: sui-test-validator");let e=me("sui-test-validator");process.on("SIGINT",()=>{console.log(`
3
+ gracefully shutting down from SIGINT (Crtl-C)`),e.kill(),process.exit()}),await e}},H=ge;import{requestSuiFromFaucetV0 as Te,getFaucetHost as Se}from"@mysten/sui.js/faucet";import{Ed25519Keypair as Re}from"@mysten/sui.js/keypairs/ed25519";import{SuiClient as Ke,getFullnodeUrl as Ae}from"@mysten/sui.js/client";import{TransactionBlock as z}from"@mysten/sui.js/transactions";import{Ed25519Keypair as we}from"@mysten/sui.js/keypairs/ed25519";import{getFullnodeUrl as ke,SuiClient as xe}from"@mysten/sui.js/client";import{execSync as ve}from"child_process";import l from"chalk";import S from"chalk";import{ZodError as ue}from"zod";import{fromZodError as fe,ValidationError as _e}from"zod-validation-error";var D=class extends Error{name="NotInsideProjectError";message="You are not inside a Obelisk project"},c=class extends Error{name="ObeliskCliError"},B=class extends Error{name="UpgradeError"},R=class extends Error{name="FsIibError"};function O(e){if(e instanceof _e)console.log(S.redBright(e.message));else if(e instanceof ue){let t=fe(e,{prefixSeparator:`
4
+ - `,issueSeparator:`
5
+ - `});console.log(S.redBright(t.message))}else e instanceof D?(console.log(S.red(e.message)),console.log(""),console.log(S.blue("To learn more about Obelisk's configuration, please go to https://github.com/0xobelisk"))):e instanceof c?console.log(S.red(e)):console.log(e)}import*as Y from"fs/promises";import{mkdirSync as ye,writeFileSync as he}from"fs";import{dirname as be}from"path";function P(e){if(e.startsWith("0x")){let t=e.slice(2);return t.length===64?t:!1}else return e.length===64?e:!1}async function K(e,t){try{let o=`${e}/sources/codegen/eps/world.move`,n=(await Y.readFile(o,"utf8")).replace(/const VERSION: u64 = \d+;/,`const VERSION: u64 = ${t};`);Z(n,o,"Update package version")}catch{throw new R("Fs update version failed.")}}async function A(e,t){try{let o=await Y.readFile(`${e}/.history/sui_${t}/latest.json`,"utf8");return JSON.parse(o)}catch{throw new R("Fs read deployment file failed.")}}async function W(e,t){return(await A(e,t)).version}async function J(e,t){return(await A(e,t)).packageId}async function q(e,t){return(await A(e,t)).worldId}async function G(e,t){return(await A(e,t)).upgradeCap}async function L(e,t){return(await A(e,t)).adminCap}function M(e,t,o,a,n,d,g){let p={projectName:e,network:t,packageId:o,worldId:a,upgradeCap:n,adminCap:d,version:g},u=process.cwd(),y=JSON.stringify(p,null,2);Z(y,`${u}/contracts/${e}/.history/sui_${t}/latest.json`,"Update deploy log")}async function Z(e,t,o){ye(be(t),{recursive:!0}),he(t,e),o!==void 0&&console.log(`${o}: ${t}`)}async function Q(e,t){let a=`${process.cwd()}/contracts/${e}`,n=process.env.PRIVATE_KEY;if(!n)throw new c(`Missing PRIVATE_KEY environment variable.
6
+ Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
7
+ in your contracts directory to use the default sui private key.`);let d=P(n);if(d===!1)throw new c("Please check your privateKey.");let g=Buffer.from(d,"hex"),p=we.fromSecretKey(g),u=new xe({url:ke(t)});await K(a,"1");let y,x;try{let{modules:r,dependencies:_}=JSON.parse(ve(`sui move build --dump-bytecode-as-base64 --path ${a}`,{encoding:"utf-8"}));y=r,x=_}catch(r){console.error(l.red("Error executing sui move build:")),console.error(r.stdout),process.exit(1)}console.log(l.blue(`Account: ${p.toSuiAddress()}`));let h=new z,[b]=h.publish({modules:y,dependencies:x});h.transferObjects([b],h.pure(p.getPublicKey().toSuiAddress()));let m;try{m=await u.signAndExecuteTransactionBlock({signer:p,transactionBlock:h,options:{showObjectChanges:!0}})}catch(r){console.error(l.red("Failed to execute publish, please republish")),console.error(r.message),process.exit(1)}m.effects?.status.status==="failure"&&(console.log(l.red("Failed to execute publish, please republish")),process.exit(1));let C=1,f="",w="",$="",E="";m.objectChanges.map(r=>{r.type==="published"&&(console.log(l.blue(`${e} PackageId: ${r.packageId}`)),f=r.packageId),r.type==="created"&&r.objectType.endsWith("::world::World")&&(console.log(l.blue(`${e} WorldId: ${r.objectId}`)),w=r.objectId),r.type==="created"&&r.objectType==="0x2::package::UpgradeCap"&&(console.log(l.blue(`${e} UpgradeCap: ${r.objectId}`)),$=r.objectId),r.type==="created"&&r.objectType.endsWith("::world::AdminCap")&&(console.log(l.blue(`${e} AdminCapId: ${r.objectId}`)),E=r.objectId)}),console.log(l.green(`Publish transaction digest: ${m.digest}`)),M(e,t,f,w,$,E,C),console.log("Executing the deployHook: "),await(r=>new Promise(_=>setTimeout(_,r)))(5e3);let I=new z;I.moveCall({target:`${f}::deploy_hook::run`,arguments:[I.object(w),I.object(E)]});let T;try{T=await u.signAndExecuteTransactionBlock({signer:p,transactionBlock:I,options:{showEffects:!0}})}catch(r){console.error(l.red("Failed to execute deployHook, please republish or manually call deploy_hook::run")),console.error(r.message),process.exit(1)}T.effects?.status.status==="success"?console.log(l.green(`Successful auto-execution of deployHook, please check the transaction digest: ${T.digest}`)):console.log(l.yellow("Failed to execute deployHook, please republish or manually call deploy_hook::run"))}import{TransactionBlock as X,UpgradePolicy as Ce}from"@mysten/sui.js/transactions";import{Ed25519Keypair as Ee}from"@mysten/sui.js/keypairs/ed25519";import{getFullnodeUrl as Ie,SuiClient as Oe}from"@mysten/sui.js/client";import{execSync as Pe}from"child_process";import k from"chalk";async function ee(e,t,o){let a=process.cwd(),n=`${a}/contracts/${e}`,d=process.env.PRIVATE_KEY;if(!d)throw new c(`Missing PRIVATE_KEY environment variable.
8
+ Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
9
+ in your contracts directory to use the default sui private key.`);let g=P(d);if(g===!1)throw new c("Please check your privateKey.");let p=Buffer.from(g,"hex"),u=Ee.fromSecretKey(p),y=new Oe({url:Ie(t)}),x=Number(await W(n,t)),h=await J(n,t),b=await q(n,t),m=await G(n,t),C=await L(n,t),f=x+1;await K(n,f.toString());try{let w,$,E;try{let{modules:s,dependencies:j,digest:pe}=JSON.parse(Pe(`sui move build --dump-bytecode-as-base64 --path ${a}/contracts/${e}`,{encoding:"utf-8"}));w=s,$=j,E=pe}catch(s){throw new B(s.stdout)}let i=new X,I=i.moveCall({target:"0x2::package::authorize_upgrade",arguments:[i.object(m),i.pure(Ce.COMPATIBLE),i.pure(E)]}),T=i.upgrade({modules:w,dependencies:$,packageId:h,ticket:I});i.moveCall({target:"0x2::package::commit_upgrade",arguments:[i.object(m),T]}),i.transferObjects([i.object(m)],i.pure(u.getPublicKey().toSuiAddress()));let r=await y.signAndExecuteTransactionBlock({signer:u,transactionBlock:i,options:{showObjectChanges:!0}});console.log(""),console.log(`${e} WorldId: ${b}`);let _="",F="";r.objectChanges.map(s=>{s.type==="published"&&(console.log(k.blue(`${e} PackageId: ${s.packageId}`)),_=s.packageId),s.type==="mutated"&&s.objectType==="0x2::package::UpgradeCap"&&(console.log(k.blue(`${e} UpgradeCap: ${s.objectId}`)),F=s.objectId)}),console.log(k.green(`Upgrade Transaction Digest: ${r.digest}`)),M(e,t,_,b,F,C,f),h=_,m=F,x=f,console.log(`
10
+ Executing the migrate: `),await(s=>new Promise(j=>setTimeout(j,s)))(5e3);let v=new X;v.moveCall({target:`${_}::world::migrate`,arguments:[v.object(b),v.object(C)]});let V=(await y.getObject({id:b,options:{showContent:!0,showDisplay:!0,showType:!0,showOwner:!0}})).data.content,N=o.filter(s=>!V.fields.schema_names.includes(s));console.log("new schema:",N);let U=[];for(let s of N)v.moveCall({target:`${_}::${s}_schema::register`,arguments:[v.object(b),v.object(C)]}),U.push(`${s}_schema`);(await y.signAndExecuteTransactionBlock({signer:u,transactionBlock:v,options:{showEffects:!0}})).effects?.status.status==="success"?(console.log(k.green(`${e} migrate world success, new world version is: ${V.fields.version}, package version is ${f}`)),U.length!==0&&console.log(k.green(`new schema: ${U.toString()} register success.`)),console.log(k.blue(`
11
+ ${e} world schemas is ${V.fields.schema_names}`))):console.log(k.red(`${e} migrate world failed, world version is: ${V.fields.version}, package version is ${f}`))}catch(w){console.log(k.red("Upgrade failed!")),console.error(w.message),M(e,t,h,b,m,C,x),await K(n,x.toString())}}import $e from"chalk";function te(){console.log($e.yellow(`
12
+ Welcome to obelisk world
13
+ --from team@obelisk
14
+ ________ ________ _______ ___ ___ ________ ___ __
15
+ |\\ __ \\|\\ __ \\|\\ ___ \\ |\\ \\ |\\ \\|\\ ____\\|\\ \\|\\ \\
16
+ \\ \\ \\|\\ \\ \\ \\|\\ /\\ \\ __/|\\ \\ \\ \\ \\ \\ \\ \\___|\\ \\ \\/ /|_
17
+ \\ \\ \\\\\\ \\ \\ __ \\ \\ \\_|/_\\ \\ \\ \\ \\ \\ \\_____ \\ \\ ___ \\
18
+ \\ \\ \\\\\\ \\ \\ \\|\\ \\ \\ \\_|\\ \\ \\ \\____\\ \\ \\|____|\\ \\ \\ \\\\ \\ \\
19
+ \\ \\_______\\ \\_______\\ \\_______\\ \\_______\\ \\__\\____\\_\\ \\ \\__\\\\ \\__\\
20
+ \\|_______|\\|_______|\\|_______|\\|_______|\\|__|\\_________\\|__| \\|__|
21
+ \\|_________|
22
+
23
+
24
+ `))}var Me={command:"faucet",describe:"Interact with a Obelisk faucet",builder(e){return e.options({network:{type:"string",desc:"URL of the Obelisk 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 d=process.env.PRIVATE_KEY;if(!d)throw new c(`Missing PRIVATE_KEY environment variable.
25
+ Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
26
+ in your contracts directory to use the default sui private key.`);let g=P(d);if(g===!1)throw new c("Please check your privateKey.");let p=Buffer.from(g,"hex");o=Re.fromSecretKey(p).toSuiAddress()}else o=t;await Te({host:Se(e),recipient:o});let a=new Ke({url:Ae(e)}),n={owner:o};console.log(`Account: ${o}`),console.log(await a.getBalance(n)),process.exit(0)}},oe=Me;import{worldgen as Ve,loadConfig as Be}from"@0xobelisk/sui-common";import Fe from"chalk";var Ue={command:"schemagen <configPath>",describe:"Autogenerate Obelisk schemas based on the config file",builder(e){return e.options({configPath:{type:"string",desc:"Path to the config file"}})},async handler({configPath:e}){try{let t=await Be(e);Ve(t),process.exit(0)}catch(t){console.log(Fe.red("Schemagen failed!")),console.error(t.message)}}},re=Ue;import{loadConfig as je}from"@0xobelisk/sui-common";var De={command:"publish",describe:"Publish obelisk move contracts",builder(e){return e.options({network:{type:"string",choices:["mainnet","testnet","devnet","localnet"],desc:"Network of the node (mainnet/testnet/devnet/localnet)"},configPath:{type:"string",default:"obelisk.config.ts",decs:"Path to the config file"}})},async handler({network:e,configPath:t}){try{let o=await je(t);await Q(o.name,e)}catch(o){O(o),process.exit(1)}process.exit(0)}},ne=De;import{loadConfig as Ye}from"@0xobelisk/sui-common";var Ne={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)"},configPath:{type:"string",default:"obelisk.config.ts",decs:"Path to the config file"}})},async handler({network:e,configPath:t}){try{let o=await Ye(t),a=Object.keys(o.schemas).filter(n=>!(typeof o.schemas=="object"&&"ephemeral"in o.schemas&&o.schemas[n].ephemeral));await ee(o.name,e,a)}catch(o){O(o),process.exit(1)}process.exit(0)}},se=Ne;import{execSync as He}from"child_process";import We from"chalk";var Je={command:"test",describe:"Run tests in Obelisk contracts",builder(e){return e.options({packagePath:{type:"string",default:".",description:"Options to pass to forge test"}})},async handler({packagePath:e}){try{He(`sui move test --path ${e}`,{encoding:"utf-8"})}catch(t){console.error(We.red("Error executing sui move test:")),console.log(t.stdout),process.exit(0)}}},ae=Je;var qe={command:"hello",describe:"hello, obelisk",builder(e){return e},async handler(){te()}},ie=qe;var ce=[ne,H,oe,re,se,ae,ie];import*as de from"dotenv";import le from"chalk";de.config();Ge(Le(process.argv)).scriptName("obelisk").command(ce).strict().fail((e,t)=>{console.error(le.red(e)),e.includes("Missing required argument")&&console.log(le.yellow(`Run 'pnpm obelisk ${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;
27
+ //# sourceMappingURL=obelisk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/obelisk.ts","../src/commands/localnode.ts","../src/commands/faucet.ts","../src/utils/publishHandler.ts","../src/utils/errors.ts","../src/utils/utils.ts","../src/utils/upgradeHandler.ts","../src/utils/printObelisk.ts","../src/commands/schemagen.ts","../src/commands/publish.ts","../src/commands/upgrade.ts","../src/commands/test.ts","../src/commands/hello.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 \"obelisk\" for e.g. ts-node)\n .scriptName(\"obelisk\")\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 obelisk ${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 type { CommandModule } from \"yargs\";\nimport { execa } from \"execa\";\n\nconst commandModule: CommandModule = {\n command: \"localnode\",\n\n describe: \"Start a local Sui node for development\",\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n console.log(\"Clearing localnode history\");\n\n console.log(`Running: sui-test-validator`);\n const child = execa(\"sui-test-validator\");\n\n process.on(\"SIGINT\", () => {\n console.log(\"\\ngracefully shutting down from SIGINT (Crtl-C)\");\n child.kill();\n process.exit();\n });\n await child;\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { requestSuiFromFaucetV0, getFaucetHost } from \"@mysten/sui.js/faucet\";\n\nimport { Ed25519Keypair } from \"@mysten/sui.js/keypairs/ed25519\";\n\nimport {\n SuiClient,\n getFullnodeUrl,\n GetBalanceParams,\n} from \"@mysten/sui.js/client\";\nimport { validatePrivateKey, ObeliskCliError } from \"../utils\";\n\ntype Options = {\n network: any;\n recipient?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"faucet\",\n\n describe: \"Interact with a Obelisk faucet\",\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: \"string\",\n desc: \"URL of the Obelisk faucet\",\n choices: [\"testnet\", \"devnet\", \"localnet\"],\n default: \"localnet\",\n },\n recipient: {\n type: \"string\",\n desc: \"Sui address to fund\",\n },\n });\n },\n\n async handler({ network, recipient }) {\n let faucet_address = \"\";\n if (recipient === undefined) {\n const privateKey = process.env.PRIVATE_KEY;\n if (!privateKey)\n throw new ObeliskCliError(\n `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 );\n\n const privateKeyFormat = validatePrivateKey(privateKey);\n if (privateKeyFormat === false) {\n throw new ObeliskCliError(`Please check your privateKey.`);\n }\n const privateKeyRaw = Buffer.from(privateKeyFormat as string, \"hex\");\n const keypair = Ed25519Keypair.fromSecretKey(privateKeyRaw);\n faucet_address = keypair.toSuiAddress();\n } else {\n faucet_address = recipient;\n }\n await requestSuiFromFaucetV0({\n host: getFaucetHost(network),\n recipient: faucet_address,\n });\n const client = new SuiClient({ url: getFullnodeUrl(network) });\n let params = {\n owner: faucet_address,\n } as GetBalanceParams;\n console.log(`Account: ${faucet_address}`);\n console.log(await client.getBalance(params));\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import { TransactionBlock } from \"@mysten/sui.js/transactions\";\nimport { Ed25519Keypair } from \"@mysten/sui.js/keypairs/ed25519\";\nimport {\n getFullnodeUrl,\n SuiClient,\n SuiTransactionBlockResponse,\n} from \"@mysten/sui.js/client\";\nimport { execSync } from \"child_process\";\nimport chalk from \"chalk\";\nimport { ObeliskCliError } from \"./errors\";\nimport {\n updateVersionInFile,\n saveContractData,\n validatePrivateKey,\n} from \"./utils\";\n\nexport async function publishHandler(\n name: string,\n network: \"mainnet\" | \"testnet\" | \"devnet\" | \"localnet\"\n) {\n const path = process.cwd();\n const projectPath = `${path}/contracts/${name}`;\n\n const privateKey = process.env.PRIVATE_KEY;\n if (!privateKey)\n throw new ObeliskCliError(\n `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 );\n\n const privateKeyFormat = validatePrivateKey(privateKey);\n if (privateKeyFormat === false) {\n throw new ObeliskCliError(`Please check your privateKey.`);\n }\n const privateKeyRaw = Buffer.from(privateKeyFormat as string, \"hex\");\n const keypair = Ed25519Keypair.fromSecretKey(privateKeyRaw);\n const client = new SuiClient({\n url: getFullnodeUrl(network),\n });\n\n // Set version 1\n await updateVersionInFile(projectPath, \"1\");\n let modules: any, dependencies: any;\n try {\n const { modules: extractedModules, dependencies: extractedDependencies } =\n JSON.parse(\n execSync(\n `sui move build --dump-bytecode-as-base64 --path ${projectPath}`,\n {\n encoding: \"utf-8\",\n }\n )\n );\n modules = extractedModules;\n dependencies = extractedDependencies;\n } catch (error: any) {\n console.error(chalk.red(\"Error executing sui move build:\"));\n console.error(error.stdout);\n process.exit(1); // You might want to exit with a non-zero status code to indicate an error\n }\n\n console.log(chalk.blue(`Account: ${keypair.toSuiAddress()}`));\n\n const tx = new TransactionBlock();\n const [upgradeCap] = tx.publish({\n modules,\n dependencies,\n });\n tx.transferObjects(\n [upgradeCap],\n tx.pure(keypair.getPublicKey().toSuiAddress())\n );\n\n let result: SuiTransactionBlockResponse;\n try {\n result = await client.signAndExecuteTransactionBlock({\n signer: keypair,\n transactionBlock: tx,\n options: {\n showObjectChanges: true,\n },\n });\n } catch (error: any) {\n console.error(chalk.red(`Failed to execute publish, please republish`));\n console.error(error.message);\n process.exit(1);\n }\n\n if (result.effects?.status.status === \"failure\") {\n console.log(chalk.red(`Failed to execute publish, please republish`));\n process.exit(1);\n }\n\n let version = 1;\n let packageId = \"\";\n let worldId = \"\";\n let upgradeCapId = \"\";\n let adminCapId = \"\";\n result.objectChanges!.map((object) => {\n if (object.type === \"published\") {\n console.log(chalk.blue(`${name} PackageId: ${object.packageId}`));\n packageId = object.packageId;\n }\n if (\n object.type === \"created\" &&\n object.objectType.endsWith(\"::world::World\")\n ) {\n console.log(chalk.blue(`${name} WorldId: ${object.objectId}`));\n worldId = object.objectId;\n }\n if (\n object.type === \"created\" &&\n object.objectType === \"0x2::package::UpgradeCap\"\n ) {\n console.log(chalk.blue(`${name} UpgradeCap: ${object.objectId}`));\n upgradeCapId = object.objectId;\n }\n if (\n object.type === \"created\" &&\n object.objectType.endsWith(\"::world::AdminCap\")\n ) {\n console.log(chalk.blue(`${name} AdminCapId: ${object.objectId}`));\n adminCapId = object.objectId;\n }\n });\n\n console.log(chalk.green(`Publish transaction digest: ${result.digest}`));\n\n saveContractData(\n name,\n network,\n packageId,\n worldId,\n upgradeCapId,\n adminCapId,\n version\n );\n\n console.log(\"Executing the deployHook: \");\n const delay = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n await delay(5000);\n\n const deployHookTx = new TransactionBlock();\n\n deployHookTx.moveCall({\n target: `${packageId}::deploy_hook::run`,\n arguments: [deployHookTx.object(worldId), deployHookTx.object(adminCapId)],\n });\n\n let deployHookResult: SuiTransactionBlockResponse;\n try {\n deployHookResult = await client.signAndExecuteTransactionBlock({\n signer: keypair,\n transactionBlock: deployHookTx,\n options: {\n showEffects: true,\n },\n });\n } catch (error: any) {\n console.error(\n chalk.red(\n `Failed to execute deployHook, please republish or manually call deploy_hook::run`\n )\n );\n console.error(error.message);\n process.exit(1);\n }\n\n if (deployHookResult.effects?.status.status === \"success\") {\n console.log(\n chalk.green(\n `Successful auto-execution of deployHook, please check the transaction digest: ${deployHookResult.digest}`\n )\n );\n } else {\n console.log(\n chalk.yellow(\n `Failed to execute deployHook, please republish or manually call deploy_hook::run`\n )\n );\n }\n}\n","import chalk from \"chalk\";\nimport { ZodError } from \"zod\";\nimport { fromZodError, ValidationError } from \"zod-validation-error\";\n\nexport class NotInsideProjectError extends Error {\n name = \"NotInsideProjectError\";\n message = \"You are not inside a Obelisk project\";\n}\n\nexport class ObeliskCliError extends Error {\n name = \"ObeliskCliError\";\n}\n\nexport class UpgradeError extends Error {\n name = \"UpgradeError\";\n}\n\nexport class FsIibError extends Error {\n name = \"FsIibError\";\n}\n\nexport function logError(error: unknown) {\n if (error instanceof ValidationError) {\n console.log(chalk.redBright(error.message));\n } else if (error instanceof ZodError) {\n // TODO currently this error shouldn't happen, use `fromZodErrorCustom`\n const validationError = fromZodError(error, {\n prefixSeparator: \"\\n- \",\n issueSeparator: \"\\n- \",\n });\n console.log(chalk.redBright(validationError.message));\n } else if (error instanceof NotInsideProjectError) {\n console.log(chalk.red(error.message));\n console.log(\"\");\n // TODO add docs to the website and update the link to the specific page\n console.log(\n chalk.blue(\n `To learn more about Obelisk's configuration, please go to https://github.com/0xobelisk`\n )\n );\n } else if (error instanceof ObeliskCliError) {\n console.log(chalk.red(error));\n } else {\n console.log(error);\n }\n}\n","import * as fsAsync from \"fs/promises\";\nimport { mkdirSync, writeFileSync } from \"fs\";\nimport { dirname } from \"path\";\nimport { FsIibError } from \"./errors\";\n\nexport type DeploymentJsonType = {\n projectName: string;\n network: \"mainnet\" | \"testnet\" | \"devnet\" | \"localnet\";\n packageId: string;\n worldId: string;\n upgradeCap: string;\n adminCap: string;\n version: number;\n};\n\nexport function validatePrivateKey(privateKey: string): boolean | string {\n if (privateKey.startsWith(\"0x\")) {\n const strippedPrivateKey = privateKey.slice(2);\n if (strippedPrivateKey.length === 64) {\n return strippedPrivateKey;\n } else {\n return false;\n }\n } else {\n if (privateKey.length === 64) {\n return privateKey;\n } else {\n return false;\n }\n }\n}\n\nexport async function updateVersionInFile(\n projectPath: string,\n newVersion: string\n) {\n try {\n const filePath = `${projectPath}/sources/codegen/eps/world.move`;\n const data = await fsAsync.readFile(filePath, \"utf8\");\n\n // update version data\n const updatedData = data.replace(\n /const VERSION: u64 = \\d+;/,\n `const VERSION: u64 = ${newVersion};`\n );\n\n // write new version\n writeOutput(updatedData, filePath, \"Update package version\");\n } catch {\n throw new FsIibError(\"Fs update version failed.\");\n }\n}\n\nasync function getDeploymentJson(projectPath: string, network: string) {\n try {\n const data = await fsAsync.readFile(\n `${projectPath}/.history/sui_${network}/latest.json`,\n \"utf8\"\n );\n return JSON.parse(data) as DeploymentJsonType;\n } catch {\n throw new FsIibError(\"Fs read deployment file failed.\");\n }\n}\n\nexport async function getVersion(\n projectPath: string,\n network: string\n): Promise<number> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.version;\n}\n\nexport async function getNetwork(\n projectPath: string,\n network: string\n): Promise<\"mainnet\" | \"testnet\" | \"devnet\" | \"localnet\"> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.network;\n}\n\nexport async function getOldPackageId(\n projectPath: string,\n network: string\n): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.packageId;\n}\n\nexport async function getWorldId(\n projectPath: string,\n network: string\n): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.worldId;\n}\n\nexport async function getUpgradeCap(\n projectPath: string,\n network: string\n): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.upgradeCap;\n}\n\nexport async function getAdminCap(\n projectPath: string,\n network: string\n): Promise<string> {\n const deployment = await getDeploymentJson(projectPath, network);\n return deployment.adminCap;\n}\n\nexport function saveContractData(\n projectName: string,\n network: \"mainnet\" | \"testnet\" | \"devnet\" | \"localnet\",\n packageId: string,\n worldId: string,\n upgradeCap: string,\n adminCap: string,\n version: number\n) {\n const DeploymentData: DeploymentJsonType = {\n projectName,\n network,\n packageId,\n worldId,\n upgradeCap,\n adminCap,\n version,\n };\n\n const path = process.cwd();\n const storeDeploymentData = JSON.stringify(DeploymentData, null, 2);\n writeOutput(\n storeDeploymentData,\n `${path}/contracts/${projectName}/.history/sui_${network}/latest.json`,\n \"Update deploy log\"\n );\n}\n\nexport async function writeOutput(\n output: string,\n fullOutputPath: string,\n logPrefix?: string\n): Promise<void> {\n mkdirSync(dirname(fullOutputPath), { recursive: true });\n\n writeFileSync(fullOutputPath, output);\n if (logPrefix !== undefined) {\n console.log(`${logPrefix}: ${fullOutputPath}`);\n }\n}\n","import { TransactionBlock, UpgradePolicy } from \"@mysten/sui.js/transactions\";\nimport { Ed25519Keypair } from \"@mysten/sui.js/keypairs/ed25519\";\nimport { getFullnodeUrl, SuiClient } from \"@mysten/sui.js/client\";\nimport { execSync } from \"child_process\";\nimport chalk from \"chalk\";\nimport { ObeliskCliError, UpgradeError } from \"./errors\";\nimport {\n updateVersionInFile,\n getOldPackageId,\n getVersion,\n getWorldId,\n getUpgradeCap,\n saveContractData,\n validatePrivateKey,\n getAdminCap,\n} from \"./utils\";\n\ntype ObjectContent = {\n type: string;\n fields: Record<string, any>;\n hasPublicTransfer: boolean;\n dataType: string;\n};\n\nexport async function upgradeHandler(\n name: string,\n network: \"mainnet\" | \"testnet\" | \"devnet\" | \"localnet\",\n schemaNames: string[]\n) {\n const path = process.cwd();\n const projectPath = `${path}/contracts/${name}`;\n const privateKey = process.env.PRIVATE_KEY;\n if (!privateKey)\n throw new ObeliskCliError(\n `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 );\n\n const privateKeyFormat = validatePrivateKey(privateKey);\n if (privateKeyFormat === false) {\n throw new ObeliskCliError(`Please check your privateKey.`);\n }\n const privateKeyRaw = Buffer.from(privateKeyFormat as string, \"hex\");\n const keypair = Ed25519Keypair.fromSecretKey(privateKeyRaw);\n\n const client = new SuiClient({\n url: getFullnodeUrl(network),\n });\n\n let oldVersion = Number(await getVersion(projectPath, network));\n let oldPackageId = await getOldPackageId(projectPath, network);\n let worldId = await getWorldId(projectPath, network);\n let upgradeCap = await getUpgradeCap(projectPath, network);\n let adminCap = await getAdminCap(projectPath, network);\n\n const newVersion = oldVersion + 1;\n await updateVersionInFile(projectPath, newVersion.toString());\n\n try {\n let modules: any, dependencies: any, digest: any;\n try {\n const {\n modules: extractedModules,\n dependencies: extractedDependencies,\n digest: extractedDigest,\n } = JSON.parse(\n execSync(\n `sui move build --dump-bytecode-as-base64 --path ${path}/contracts/${name}`,\n {\n encoding: \"utf-8\",\n }\n )\n );\n\n modules = extractedModules;\n dependencies = extractedDependencies;\n digest = extractedDigest;\n } catch (error: any) {\n throw new UpgradeError(error.stdout);\n }\n\n const tx = new TransactionBlock();\n const ticket = tx.moveCall({\n target: \"0x2::package::authorize_upgrade\",\n arguments: [\n tx.object(upgradeCap),\n tx.pure(UpgradePolicy.COMPATIBLE),\n tx.pure(digest),\n ],\n });\n\n const receipt = tx.upgrade({\n modules,\n dependencies,\n packageId: oldPackageId,\n ticket,\n });\n\n tx.moveCall({\n target: \"0x2::package::commit_upgrade\",\n arguments: [tx.object(upgradeCap), receipt],\n });\n\n tx.transferObjects(\n [tx.object(upgradeCap)],\n tx.pure(keypair.getPublicKey().toSuiAddress())\n );\n\n const result = await client.signAndExecuteTransactionBlock({\n signer: keypair,\n transactionBlock: tx,\n options: {\n showObjectChanges: true,\n },\n });\n\n console.log(\"\");\n console.log(`${name} WorldId: ${worldId}`);\n\n let newPackageId = \"\";\n let newUpgradeCap = \"\";\n result.objectChanges!.map((object) => {\n if (object.type === \"published\") {\n console.log(chalk.blue(`${name} PackageId: ${object.packageId}`));\n newPackageId = object.packageId;\n }\n if (\n object.type === \"mutated\" &&\n object.objectType === \"0x2::package::UpgradeCap\"\n ) {\n console.log(chalk.blue(`${name} UpgradeCap: ${object.objectId}`));\n newUpgradeCap = object.objectId;\n }\n });\n\n console.log(chalk.green(`Upgrade Transaction Digest: ${result.digest}`));\n\n saveContractData(\n name,\n network,\n newPackageId,\n worldId,\n newUpgradeCap,\n adminCap,\n newVersion\n );\n\n oldPackageId = newPackageId;\n upgradeCap = newUpgradeCap;\n oldVersion = newVersion;\n\n console.log(\"\\nExecuting the migrate: \");\n const delay = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n await delay(5000);\n\n const migrateTx = new TransactionBlock();\n migrateTx.moveCall({\n target: `${newPackageId}::world::migrate`,\n arguments: [migrateTx.object(worldId), migrateTx.object(adminCap)],\n });\n\n let newWorldObject = await client.getObject({\n id: worldId,\n options: {\n showContent: true,\n showDisplay: true,\n showType: true,\n showOwner: true,\n },\n });\n let newObjectContent = newWorldObject.data!.content as ObjectContent;\n\n const uniqueSchema: string[] = schemaNames.filter(\n (item) => !newObjectContent.fields[\"schema_names\"].includes(item)\n );\n\n console.log(\"new schema:\", uniqueSchema);\n let needRegisterSchema = [];\n for (const newSchema of uniqueSchema) {\n migrateTx.moveCall({\n target: `${newPackageId}::${newSchema}_schema::register`,\n arguments: [migrateTx.object(worldId), migrateTx.object(adminCap)],\n });\n needRegisterSchema.push(`${newSchema}_schema`);\n }\n const migrateResult = await client.signAndExecuteTransactionBlock({\n signer: keypair,\n transactionBlock: migrateTx,\n options: {\n showEffects: true,\n },\n });\n\n if (migrateResult.effects?.status.status === \"success\") {\n console.log(\n chalk.green(\n `${name} migrate world success, new world version is: ${newObjectContent.fields[\"version\"]}, package version is ${newVersion}`\n )\n );\n if (needRegisterSchema.length !== 0) {\n console.log(\n chalk.green(\n `new schema: ${needRegisterSchema.toString()} register success.`\n )\n );\n }\n\n console.log(\n chalk.blue(\n `\\n${name} world schemas is ${newObjectContent.fields[\"schema_names\"]}`\n )\n );\n } else {\n console.log(\n chalk.red(\n `${name} migrate world failed, world version is: ${newObjectContent.fields[\"version\"]}, package version is ${newVersion}`\n )\n );\n }\n } catch (error: any) {\n console.log(chalk.red(\"Upgrade failed!\"));\n console.error(error.message);\n\n saveContractData(\n name,\n network,\n oldPackageId,\n worldId,\n upgradeCap,\n adminCap,\n oldVersion\n );\n await updateVersionInFile(projectPath, oldVersion.toString());\n }\n}\n","import chalk from \"chalk\";\n\nexport function printObelisk() {\n console.log(\n chalk.yellow(`\nWelcome to obelisk world\n\\t\\t\\t --from team@obelisk\n ________ ________ _______ ___ ___ ________ ___ __ \n|\\\\ __ \\\\|\\\\ __ \\\\|\\\\ ___ \\\\ |\\\\ \\\\ |\\\\ \\\\|\\\\ ____\\\\|\\\\ \\\\|\\\\ \\\\ \n\\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\|\\\\ /\\\\ \\\\ __/|\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\___|\\\\ \\\\ \\\\/ /|_ \n \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ __ \\\\ \\\\ \\\\_|/_\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\_____ \\\\ \\\\ ___ \\\\ \n \\\\ \\\\ \\\\\\\\\\\\ \\\\ \\\\ \\\\|\\\\ \\\\ \\\\ \\\\_|\\\\ \\\\ \\\\ \\\\____\\\\ \\\\ \\\\|____|\\\\ \\\\ \\\\ \\\\\\\\ \\\\ \\\\ \n \\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\_______\\\\ \\\\__\\\\____\\\\_\\\\ \\\\ \\\\__\\\\\\\\ \\\\__\\\\\n \\\\|_______|\\\\|_______|\\\\|_______|\\\\|_______|\\\\|__|\\\\_________\\\\|__| \\\\|__|\n \\\\|_________| \n \n \n`)\n );\n}\n","import type { CommandModule } from \"yargs\";\nimport { worldgen, loadConfig, ObeliskConfig } from \"@0xobelisk/sui-common\";\nimport chalk from \"chalk\";\n\ntype Options = {\n configPath?: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"schemagen <configPath>\",\n\n describe: \"Autogenerate Obelisk schemas based on the config file\",\n\n builder(yargs) {\n return yargs.options({\n configPath: { type: \"string\", desc: \"Path to the config file\" },\n });\n },\n\n async handler({ configPath }) {\n try {\n const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;\n worldgen(obeliskConfig);\n process.exit(0);\n } catch (error: any) {\n console.log(chalk.red(\"Schemagen failed!\"));\n console.error(error.message);\n }\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { logError } from \"../utils/errors\";\nimport { publishHandler } from \"../utils\";\nimport { loadConfig, ObeliskConfig } from \"@0xobelisk/sui-common\";\n\ntype Options = {\n network: any;\n configPath: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"publish\",\n\n describe: \"Publish obelisk move contracts\",\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: \"string\",\n choices: [\"mainnet\", \"testnet\", \"devnet\", \"localnet\"],\n desc: \"Network of the node (mainnet/testnet/devnet/localnet)\",\n },\n configPath: {\n type: \"string\",\n default: \"obelisk.config.ts\",\n decs: \"Path to the config file\",\n },\n });\n },\n\n async handler({ network, configPath }) {\n try {\n const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;\n await publishHandler(obeliskConfig.name, network);\n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { logError } from \"../utils/errors\";\nimport { upgradeHandler } from \"../utils\";\nimport { ObeliskConfig, loadConfig, ValueType } from \"@0xobelisk/sui-common\";\n\ntype Options = {\n network: any;\n configPath: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"upgrade\",\n\n describe: \"Upgrade your move contracts\",\n\n builder(yargs) {\n return yargs.options({\n network: {\n type: \"string\",\n choices: [\"mainnet\", \"testnet\", \"devnet\", \"localnet\"],\n desc: \"Network of the node (mainnet/testnet/devnet/localnet)\",\n },\n configPath: {\n type: \"string\",\n default: \"obelisk.config.ts\",\n decs: \"Path to the config file\",\n },\n });\n },\n\n async handler({ network, configPath }) {\n try {\n const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;\n\n let schemaNames = Object.keys(obeliskConfig.schemas).filter(\n (key) =>\n !(\n typeof obeliskConfig.schemas === \"object\" &&\n \"ephemeral\" in obeliskConfig.schemas &&\n (obeliskConfig.schemas[key] as ValueType).ephemeral\n )\n );\n\n await upgradeHandler(obeliskConfig.name, network, schemaNames);\n } catch (error: any) {\n logError(error);\n process.exit(1);\n }\n process.exit(0);\n },\n};\n\nexport default commandModule;\n","import type { CommandModule } from \"yargs\";\nimport { execSync } from \"child_process\";\nimport chalk from \"chalk\";\n\ntype Options = {\n packagePath: string;\n};\n\nconst commandModule: CommandModule<Options, Options> = {\n command: \"test\",\n\n describe: \"Run tests in Obelisk contracts\",\n\n builder(yargs) {\n return yargs.options({\n packagePath: {\n type: \"string\",\n default: \".\",\n description: \"Options to pass to forge test\",\n },\n });\n },\n\n async handler({ packagePath }) {\n // Start an internal anvil process if no world address is provided\n try {\n execSync(`sui move test --path ${packagePath}`, {\n encoding: \"utf-8\",\n });\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 { printObelisk } from \"../utils\";\n\nconst commandModule: CommandModule = {\n command: \"hello\",\n\n describe: \"hello, obelisk\",\n\n builder(yargs) {\n return yargs;\n },\n\n async handler() {\n printObelisk();\n },\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 hello from \"./hello\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options\nexport const commands: CommandModule<any, any>[] = [\n publish,\n localnode,\n faucet,\n schemagen,\n upgrade,\n test,\n hello,\n];\n"],"mappings":";AAEA,OAAOA,OAAW,QAClB,OAAS,WAAAC,OAAe,gBCFxB,OAAS,SAAAC,OAAa,QAEtB,IAAMC,GAA+B,CACnC,QAAS,YAET,SAAU,yCAEV,QAAQC,EAAO,CACb,OAAOA,CACT,EAEA,MAAM,SAAU,CACd,QAAQ,IAAI,4BAA4B,EAExC,QAAQ,IAAI,6BAA6B,EACzC,IAAMC,EAAQH,GAAM,oBAAoB,EAExC,QAAQ,GAAG,SAAU,IAAM,CACzB,QAAQ,IAAI;AAAA,8CAAiD,EAC7DG,EAAM,KAAK,EACX,QAAQ,KAAK,CACf,CAAC,EACD,MAAMA,CACR,CACF,EAEOC,EAAQH,GC1Bf,OAAS,0BAAAI,GAAwB,iBAAAC,OAAqB,wBAEtD,OAAS,kBAAAC,OAAsB,kCAE/B,OACE,aAAAC,GACA,kBAAAC,OAEK,wBCTP,OAAS,oBAAAC,MAAwB,8BACjC,OAAS,kBAAAC,OAAsB,kCAC/B,OACE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,SAAU,iBAEV,QAAQC,EAAO,CACb,OAAOA,CACT,EAEA,MAAM,SAAU,CACdC,GAAa,CACf,CACF,EAEOC,GAAQH,GCNR,IAAMI,GAAsC,CACjDC,GACAC,EACAC,GACAC,GACAC,GACAC,GACAC,EACF,EbXA,UAAYC,OAAY,SACxB,OAAOC,OAAW,QACX,UAAO,EAEdC,GAAMC,GAAQ,QAAQ,IAAI,CAAC,EAExB,WAAW,SAAS,EAGpB,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,qBAAqB,QAAQ,KAAK,CAAC,2DAA2D,CAC7G,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","execa","commandModule","yargs","child","localnode_default","requestSuiFromFaucetV0","getFaucetHost","Ed25519Keypair","SuiClient","getFullnodeUrl","TransactionBlock","Ed25519Keypair","getFullnodeUrl","SuiClient","execSync","chalk","chalk","ZodError","fromZodError","ValidationError","NotInsideProjectError","ObeliskCliError","UpgradeError","FsIibError","logError","error","validationError","fsAsync","mkdirSync","writeFileSync","dirname","validatePrivateKey","privateKey","strippedPrivateKey","updateVersionInFile","projectPath","newVersion","filePath","updatedData","writeOutput","FsIibError","getDeploymentJson","network","data","getVersion","getOldPackageId","projectPath","network","getDeploymentJson","getWorldId","getUpgradeCap","getAdminCap","saveContractData","projectName","packageId","worldId","upgradeCap","adminCap","version","DeploymentData","path","storeDeploymentData","writeOutput","output","fullOutputPath","logPrefix","mkdirSync","dirname","writeFileSync","publishHandler","name","network","projectPath","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","privateKeyRaw","keypair","Ed25519Keypair","client","SuiClient","getFullnodeUrl","updateVersionInFile","modules","dependencies","extractedModules","extractedDependencies","execSync","error","chalk","tx","TransactionBlock","upgradeCap","result","version","packageId","worldId","upgradeCapId","adminCapId","object","saveContractData","ms","resolve","deployHookTx","deployHookResult","TransactionBlock","UpgradePolicy","Ed25519Keypair","getFullnodeUrl","SuiClient","execSync","chalk","upgradeHandler","name","network","schemaNames","path","projectPath","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","privateKeyRaw","keypair","Ed25519Keypair","client","SuiClient","getFullnodeUrl","oldVersion","getVersion","oldPackageId","getOldPackageId","worldId","getWorldId","upgradeCap","getUpgradeCap","adminCap","getAdminCap","newVersion","updateVersionInFile","modules","dependencies","digest","extractedModules","extractedDependencies","extractedDigest","execSync","error","UpgradeError","tx","TransactionBlock","ticket","UpgradePolicy","receipt","result","newPackageId","newUpgradeCap","object","chalk","saveContractData","ms","resolve","migrateTx","newObjectContent","uniqueSchema","item","needRegisterSchema","newSchema","chalk","printObelisk","commandModule","yargs","network","recipient","faucet_address","privateKey","ObeliskCliError","privateKeyFormat","validatePrivateKey","privateKeyRaw","Ed25519Keypair","requestSuiFromFaucetV0","getFaucetHost","client","SuiClient","getFullnodeUrl","params","faucet_default","worldgen","loadConfig","chalk","commandModule","yargs","configPath","obeliskConfig","error","schemagen_default","loadConfig","commandModule","yargs","network","configPath","obeliskConfig","publishHandler","error","logError","publish_default","loadConfig","commandModule","yargs","network","configPath","obeliskConfig","schemaNames","key","upgradeHandler","error","logError","upgrade_default","execSync","chalk","commandModule","yargs","packagePath","error","test_default","commandModule","yargs","printObelisk","hello_default","commands","publish_default","localnode_default","faucet_default","schemagen_default","upgrade_default","test_default","hello_default","dotenv","chalk","yargs","hideBin","commands","msg","err","logError"]}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@0xobelisk/sui-cli",
3
+ "version": "0.4.9",
4
+ "description": "Tookit for interacting with move eps framework",
5
+ "keywords": [
6
+ "sui",
7
+ "obelisk labs",
8
+ "move",
9
+ "blockchain"
10
+ ],
11
+ "type": "module",
12
+ "author": "team@obelisk.build",
13
+ "homepage": "https://github.com/0xobelisk/obelisk-engine/tree/main/packages/sui-cli#readme",
14
+ "bugs": "https://github.com/0xobelisk/obelisk-engine/issues",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/0xobelisk/obelisk-engine.git"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "exports": {
27
+ ".": "./dist/index.js"
28
+ },
29
+ "types": "src/index.ts",
30
+ "bin": {
31
+ "obelisk": "./dist/obelisk.js"
32
+ },
33
+ "dependencies": {
34
+ "@mysten/sui.js": "^0.41.0",
35
+ "chalk": "^5.0.1",
36
+ "child_process": "^1.0.2",
37
+ "dotenv": "^16.0.3",
38
+ "ejs": "^3.1.8",
39
+ "execa": "^7.0.0",
40
+ "glob": "^8.0.3",
41
+ "path": "^0.12.7",
42
+ "prettier": "^2.8.4",
43
+ "prettier-plugin-rust": "^0.1.9",
44
+ "typescript": "5.1.6",
45
+ "yargs": "^17.7.1",
46
+ "zod": "^3.22.3",
47
+ "zod-validation-error": "^1.3.0",
48
+ "@0xobelisk/sui-common": "0.4.9"
49
+ },
50
+ "devDependencies": {
51
+ "@types/ejs": "^3.1.1",
52
+ "@types/glob": "^7.2.0",
53
+ "@types/node": "^18.15.11",
54
+ "@types/yargs": "^17.0.10",
55
+ "ts-node": "^10.9.1",
56
+ "tsup": "^6.7.0",
57
+ "tsx": "^3.12.6",
58
+ "vitest": "0.31.4"
59
+ },
60
+ "scripts": {
61
+ "build": "pnpm run build:js",
62
+ "build:js": "tsup && chmod +x ./dist/obelisk.js",
63
+ "clean": "pnpm run clean:js",
64
+ "clean:js": "rimraf dist",
65
+ "dev": "tsup --watch",
66
+ "lint": "eslint . --ext .ts"
67
+ }
68
+ }
@@ -0,0 +1,73 @@
1
+ import type { CommandModule } from "yargs";
2
+ import { requestSuiFromFaucetV0, getFaucetHost } from "@mysten/sui.js/faucet";
3
+
4
+ import { Ed25519Keypair } from "@mysten/sui.js/keypairs/ed25519";
5
+
6
+ import {
7
+ SuiClient,
8
+ getFullnodeUrl,
9
+ GetBalanceParams,
10
+ } from "@mysten/sui.js/client";
11
+ import { validatePrivateKey, ObeliskCliError } from "../utils";
12
+
13
+ type Options = {
14
+ network: any;
15
+ recipient?: string;
16
+ };
17
+
18
+ const commandModule: CommandModule<Options, Options> = {
19
+ command: "faucet",
20
+
21
+ describe: "Interact with a Obelisk faucet",
22
+
23
+ builder(yargs) {
24
+ return yargs.options({
25
+ network: {
26
+ type: "string",
27
+ desc: "URL of the Obelisk faucet",
28
+ choices: ["testnet", "devnet", "localnet"],
29
+ default: "localnet",
30
+ },
31
+ recipient: {
32
+ type: "string",
33
+ desc: "Sui address to fund",
34
+ },
35
+ });
36
+ },
37
+
38
+ async handler({ network, recipient }) {
39
+ let faucet_address = "";
40
+ if (recipient === undefined) {
41
+ const privateKey = process.env.PRIVATE_KEY;
42
+ if (!privateKey)
43
+ throw new ObeliskCliError(
44
+ `Missing PRIVATE_KEY environment variable.
45
+ Run 'echo "PRIVATE_KEY=YOUR_PRIVATE_KEY" > .env'
46
+ in your contracts directory to use the default sui private key.`
47
+ );
48
+
49
+ const privateKeyFormat = validatePrivateKey(privateKey);
50
+ if (privateKeyFormat === false) {
51
+ throw new ObeliskCliError(`Please check your privateKey.`);
52
+ }
53
+ const privateKeyRaw = Buffer.from(privateKeyFormat as string, "hex");
54
+ const keypair = Ed25519Keypair.fromSecretKey(privateKeyRaw);
55
+ faucet_address = keypair.toSuiAddress();
56
+ } else {
57
+ faucet_address = recipient;
58
+ }
59
+ await requestSuiFromFaucetV0({
60
+ host: getFaucetHost(network),
61
+ recipient: faucet_address,
62
+ });
63
+ const client = new SuiClient({ url: getFullnodeUrl(network) });
64
+ let params = {
65
+ owner: faucet_address,
66
+ } as GetBalanceParams;
67
+ console.log(`Account: ${faucet_address}`);
68
+ console.log(await client.getBalance(params));
69
+ process.exit(0);
70
+ },
71
+ };
72
+
73
+ export default commandModule;
@@ -0,0 +1,18 @@
1
+ import type { CommandModule } from "yargs";
2
+ import { printObelisk } from "../utils";
3
+
4
+ const commandModule: CommandModule = {
5
+ command: "hello",
6
+
7
+ describe: "hello, obelisk",
8
+
9
+ builder(yargs) {
10
+ return yargs;
11
+ },
12
+
13
+ async handler() {
14
+ printObelisk();
15
+ },
16
+ };
17
+
18
+ export default commandModule;
@@ -0,0 +1,20 @@
1
+ import { CommandModule } from "yargs";
2
+
3
+ import localnode from "./localnode";
4
+ import faucet from "./faucet";
5
+ import schemagen from "./schemagen";
6
+ import publish from "./publish";
7
+ import upgrade from "./upgrade";
8
+ import test from "./test";
9
+ import hello from "./hello";
10
+
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Each command has different options
12
+ export const commands: CommandModule<any, any>[] = [
13
+ publish,
14
+ localnode,
15
+ faucet,
16
+ schemagen,
17
+ upgrade,
18
+ test,
19
+ hello,
20
+ ];
@@ -0,0 +1,28 @@
1
+ import type { CommandModule } from "yargs";
2
+ import { execa } from "execa";
3
+
4
+ const commandModule: CommandModule = {
5
+ command: "localnode",
6
+
7
+ describe: "Start a local Sui node for development",
8
+
9
+ builder(yargs) {
10
+ return yargs;
11
+ },
12
+
13
+ async handler() {
14
+ console.log("Clearing localnode history");
15
+
16
+ console.log(`Running: sui-test-validator`);
17
+ const child = execa("sui-test-validator");
18
+
19
+ process.on("SIGINT", () => {
20
+ console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
21
+ child.kill();
22
+ process.exit();
23
+ });
24
+ await child;
25
+ },
26
+ };
27
+
28
+ export default commandModule;
@@ -0,0 +1,43 @@
1
+ import type { CommandModule } from "yargs";
2
+ import { logError } from "../utils/errors";
3
+ import { publishHandler } from "../utils";
4
+ import { loadConfig, ObeliskConfig } from "@0xobelisk/sui-common";
5
+
6
+ type Options = {
7
+ network: any;
8
+ configPath: string;
9
+ };
10
+
11
+ const commandModule: CommandModule<Options, Options> = {
12
+ command: "publish",
13
+
14
+ describe: "Publish obelisk move contracts",
15
+
16
+ builder(yargs) {
17
+ return yargs.options({
18
+ network: {
19
+ type: "string",
20
+ choices: ["mainnet", "testnet", "devnet", "localnet"],
21
+ desc: "Network of the node (mainnet/testnet/devnet/localnet)",
22
+ },
23
+ configPath: {
24
+ type: "string",
25
+ default: "obelisk.config.ts",
26
+ decs: "Path to the config file",
27
+ },
28
+ });
29
+ },
30
+
31
+ async handler({ network, configPath }) {
32
+ try {
33
+ const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;
34
+ await publishHandler(obeliskConfig.name, network);
35
+ } catch (error: any) {
36
+ logError(error);
37
+ process.exit(1);
38
+ }
39
+ process.exit(0);
40
+ },
41
+ };
42
+
43
+ export default commandModule;
@@ -0,0 +1,32 @@
1
+ import type { CommandModule } from "yargs";
2
+ import { worldgen, loadConfig, ObeliskConfig } from "@0xobelisk/sui-common";
3
+ import chalk from "chalk";
4
+
5
+ type Options = {
6
+ configPath?: string;
7
+ };
8
+
9
+ const commandModule: CommandModule<Options, Options> = {
10
+ command: "schemagen <configPath>",
11
+
12
+ describe: "Autogenerate Obelisk schemas based on the config file",
13
+
14
+ builder(yargs) {
15
+ return yargs.options({
16
+ configPath: { type: "string", desc: "Path to the config file" },
17
+ });
18
+ },
19
+
20
+ async handler({ configPath }) {
21
+ try {
22
+ const obeliskConfig = (await loadConfig(configPath)) as ObeliskConfig;
23
+ worldgen(obeliskConfig);
24
+ process.exit(0);
25
+ } catch (error: any) {
26
+ console.log(chalk.red("Schemagen failed!"));
27
+ console.error(error.message);
28
+ }
29
+ },
30
+ };
31
+
32
+ export default commandModule;