Skip to content

Commit 37b680f

Browse files
committed
extend init functionality
1 parent 5706af3 commit 37b680f

File tree

11 files changed

+665
-3584
lines changed

11 files changed

+665
-3584
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### [0.15.0](https://github.com/xdevguild/buildo-begins/releases/tag/v0.15.0) (2023-12-29)
2+
- add buildo.dev and Piggy Bank example dapps to the init functionality
3+
- update dependencies
4+
15
### [0.14.3](https://github.com/xdevguild/buildo-begins/releases/tag/v0.14.3) (2023-08-03)
26
- update dependencies and fix missing ora dependency
37

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Meet Buildo. He is here to help you start creating in the MultiversX blockchain
3030

3131
### How to work with Buildo:
3232

33-
1. Install globally `npm install buildo-begins -g` or you can also run commands with npx, for example `npx buildo-begins issue-esdt`
33+
1. Install globally `npm install buildo-begins -g` or you can also run commands with npx, for example `npx buildo-begins@latest issue-esdt`
3434
2. Derive the pem from seed phrase: `buildo-begins derive-pem`
3535
3. The walletKey.pem file will be created (**Be careful with this file when working with the mainnet. Please don't share it with anyone!**). (Other ways of signing, for example with hardware wallet are in plans)
3636
4. Check the commands with `buildo-begins --help`
@@ -46,7 +46,7 @@ Each command will display a set of self-explanatory prompts. If there is somethi
4646
#### General operations
4747

4848
- `buildo-begins derive-pem` - derive PEM file from seed phrase
49-
- `buildo-begins init` - initialize the NextJS dapp template or simple smart contract for learning purposes
49+
- `buildo-begins init` - initialize the NextJS dapp template, Piggy Bank smart contract and dapp for learning purposes or Buildo.dev dapp
5050
- `buildo-begins herotag` - create a herotag and assign it to address and check addresses of existing ones
5151
- `buildo-begins converters` - a set of converters based on excellent [MultiversX (Elrond) Converters](http://207.244.241.38/elrond-converters/) but in the CLI, always at hand!
5252
- `buildo-begins claim-developer-rewards` - Claim dev rewards from your smart contract. You have to use the owner's wallet address (PEM) when calling it

package-lock.json

Lines changed: 579 additions & 3526 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "buildo-begins",
33
"engines": {
4-
"node": "^14.13.1 || >=16.0.0"
4+
"node": ">=18.0.0"
55
},
6-
"version": "0.14.3",
6+
"version": "0.15.0",
77
"description": "MultiversX blockchain CLI helper tools (protocol, API and smart contracts interaction, also helper tools)",
88
"bin": {
9-
"buildo-begins": "./build/index.js"
9+
"buildo-begins": "build/index.js"
1010
},
1111
"type": "module",
1212
"main": "build/index.js",
@@ -25,7 +25,7 @@
2525
"homepage": "https://github.com/xdevguild/buildo-begins",
2626
"repository": {
2727
"type": "git",
28-
"url": "https://github.com/xdevguild/buildo-begins"
28+
"url": "git+https://github.com/xdevguild/buildo-begins.git"
2929
},
3030
"keywords": [
3131
"cli",
@@ -38,35 +38,35 @@
3838
"api"
3939
],
4040
"dependencies": {
41-
"@multiversx/sdk-core": "12.6.0",
42-
"@multiversx/sdk-network-providers": "1.5.0",
41+
"@multiversx/sdk-core": "12.17.0",
42+
"@multiversx/sdk-network-providers": "2.2.0",
4343
"@multiversx/sdk-transaction-decoder": "1.0.2",
4444
"@multiversx/sdk-wallet": "4.2.0",
4545
"adm-zip": "0.5.10",
46-
"axios": "1.4.0",
47-
"bignumber.js": "9.1.1",
46+
"axios": "1.6.3",
47+
"bignumber.js": "9.1.2",
4848
"chalk": "5.3.0",
49-
"cosmiconfig": "8.2.0",
49+
"cosmiconfig": "9.0.0",
5050
"cross-spawn": "7.0.3",
51-
"keccak": "3.0.3",
52-
"ora": "7.0.1",
51+
"keccak": "3.0.4",
52+
"ora": "8.0.1",
5353
"p-event": "6.0.0",
5454
"prompts": "2.4.2"
5555
},
5656
"devDependencies": {
57-
"@types/adm-zip": "0.5.0",
58-
"@types/cross-spawn": "6.0.2",
59-
"@types/keccak": "3.0.1",
60-
"@types/node": "20.4.6",
61-
"@types/prompts": "2.4.4",
62-
"@typescript-eslint/eslint-plugin": "6.2.1",
63-
"@typescript-eslint/parser": "6.2.1",
64-
"esbuild": "0.18.17",
65-
"eslint": "8.46.0",
66-
"eslint-config-prettier": "8.10.0",
67-
"eslint-plugin-prettier": "5.0.0",
68-
"prettier": "3.0.1",
69-
"rimraf": "5.0.1",
70-
"typescript": "5.1.6"
57+
"@types/adm-zip": "0.5.5",
58+
"@types/cross-spawn": "6.0.6",
59+
"@types/keccak": "3.0.4",
60+
"@types/node": "20.10.5",
61+
"@types/prompts": "2.4.9",
62+
"@typescript-eslint/eslint-plugin": "6.16.0",
63+
"@typescript-eslint/parser": "6.16.0",
64+
"esbuild": "0.19.10",
65+
"eslint": "8.56.0",
66+
"eslint-config-prettier": "9.1.0",
67+
"eslint-plugin-prettier": "5.1.2",
68+
"prettier": "3.1.1",
69+
"rimraf": "5.0.5",
70+
"typescript": "5.3.3"
7171
}
7272
}

src/change-owner-address.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ export const changeOwnerAddress = async () => {
3434
];
3535

3636
try {
37-
const { smartContractAddress, newOwnerAddress } = await prompts(
38-
promptQuestion
39-
);
37+
const { smartContractAddress, newOwnerAddress } =
38+
await prompts(promptQuestion);
4039

4140
if (!smartContractAddress || !newOwnerAddress) {
4241
console.log(

src/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,12 @@ export const specialOpertationsGasLimit = 300_000;
147147

148148
// Resources to download (URLs)
149149
export const downloadUrls: Record<string, string> = {
150-
nextJsDapp:
150+
nextJsDappTemplate:
151151
'https://github.com/xdevguild/nextjs-dapp-template/archive/refs/heads/main.zip',
152+
buildoDev:
153+
'https://github.com/xdevguild/buildo.dev/archive/refs/heads/main.zip',
152154
piggyBankExampleSc:
153-
'https://github.com/xdevguild/multiversx-simple-sc/archive/refs/heads/master.zip',
155+
'https://github.com/xdevguild/piggy-bank-sc/archive/refs/heads/master.zip',
156+
piggyBankExampleDapp:
157+
'https://github.com/xdevguild/piggy-bank-dapp/archive/refs/heads/main.zip',
154158
};

src/decode-transaction.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ const promptQuestions: PromptObject[] = [
3636

3737
export const decodeTransaction = async () => {
3838
try {
39-
const { senderAddress, receiverAddress, dataString, value } = await prompts(
40-
promptQuestions
41-
);
39+
const { senderAddress, receiverAddress, dataString, value } =
40+
await prompts(promptQuestions);
4241

4342
if (!senderAddress || !receiverAddress || !dataString) {
4443
console.log(

src/init.ts

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ import axios from 'axios';
77
import AdmZip from 'adm-zip';
88
import { downloadUrls } from './config';
99

10+
const mainDirInZipNameMap = {
11+
nextJsDappTemplate: 'nextjs-dapp-template-main',
12+
piggyBankExampleSc: 'piggy-bank-sc-master',
13+
piggyBankExampleDapp: 'piggy-bank-dapp-main',
14+
buildoDev: 'buildo.dev-main',
15+
};
16+
17+
const successMsgMap = (dappDirectoryName: string) => ({
18+
nextJsDappTemplate: `The NextJS Dapp template is initialized in the ${dappDirectoryName} directory. Npm dependencies installed. .env.example copied into .env.local - change the settings there.`,
19+
piggyBankExampleSc: `The PiggyBank Smart Contract is initialized in ${dappDirectoryName}. You can now use VS Code and MultiversX IDE extension to configure your workspace and work with it. Check MultiversX IDE for VS Code on how to start!`,
20+
piggyBankExampleDapp: `The Piggy Bank Dapp is initialized in the ${dappDirectoryName} directory. Npm dependencies installed. .env.example copied into .env.local - change the settings there.`,
21+
buildoDev: `The Buildo.dev Dapp is initialized in the ${dappDirectoryName} directory. Npm dependencies installed. .env.example copied into .env.local - change the settings there.`,
22+
});
23+
1024
const directoryNameRegex =
1125
// eslint-disable-next-line no-control-regex
1226
/^[^\s^\x00-\x1f\\?*:"";<>|/.][^\x00-\x1f\\?*:"";<>|/]*[^\s^\x00-\x1f\\?*:"";<>|/.]+$/g;
@@ -15,7 +29,8 @@ const directoryNameRegex =
1529
const triggerDownloadAndExtract = async (
1630
dappDirectoryName: string,
1731
resourceUrl: string,
18-
isNextJSDapp: boolean
32+
resourceType: keyof typeof mainDirInZipNameMap,
33+
isNextJSDappTemplate: boolean
1934
) => {
2035
try {
2136
const response = await axios.get(resourceUrl, {
@@ -27,9 +42,7 @@ const triggerDownloadAndExtract = async (
2742
const zip = new AdmZip(response.data);
2843
const zipEntries = zip.getEntries();
2944

30-
const mainDirInZipName = isNextJSDapp
31-
? 'nextjs-dapp-template-main'
32-
: 'multiversx-simple-sc-master';
45+
const mainDirInZipName = mainDirInZipNameMap[resourceType];
3346

3447
zipEntries.forEach((entry) => {
3548
const entryName = entry.entryName;
@@ -48,18 +61,17 @@ const triggerDownloadAndExtract = async (
4861
}
4962
});
5063

51-
if (isNextJSDapp) {
64+
if (isNextJSDappTemplate) {
5265
process.chdir(dappDirectoryName);
5366
spawn.sync('npm', ['install'], { stdio: 'inherit' });
5467
spawn.sync('cp', ['.env.example', '.env.local'], { stdio: 'inherit' });
5568
process.chdir('..');
5669
}
5770
console.log('\n');
58-
console.log(
59-
isNextJSDapp
60-
? `The NextJS Dapp template is initialized in the ${dappDirectoryName} directory. Npm dependencies installed. .env.example copied into .env.local - change the settings there.`
61-
: `The PiggyBank Smart Contract is initialized in ${dappDirectoryName}. You can now use VS Code and MultiversX IDE extension to configure your workspace and work with it. Check https://youtu.be/y0beoihLppA on how to start!`
62-
);
71+
console.log(successMsgMap(dappDirectoryName)[resourceType]);
72+
73+
console.log(isNextJSDappTemplate ? `` : ``);
74+
6375
console.log('\n');
6476
} catch (err) {
6577
if (axios.isAxiosError(err)) {
@@ -84,11 +96,23 @@ export const init = async () => {
8496
'The simple MultiversX smart contract for learning purposes.',
8597
value: 'piggyBankExampleSc',
8698
},
99+
{
100+
title: 'Piggy Bank Dapp example',
101+
description:
102+
'The simple MultiversX dapp for learning purposes. It integrates with Piggy Bank smart contract.',
103+
value: 'piggyBankExampleDapp',
104+
},
87105
{
88106
title: 'NextJS Dapp template',
89107
description:
90-
'The MultiversX Dapp template built with NextJS, Chakra UI and MultiversX JS SDK',
91-
value: 'nextJsDapp',
108+
'The MultiversX Dapp template built with Next.js, Shadcn UI (Tailwind, Radix) and MultiversX JS SDK',
109+
value: 'nextJsDappTemplate',
110+
},
111+
{
112+
title: 'Buildo.dev dapp',
113+
description:
114+
'Buildo.dev app for you to test locally. Besides that, you can use it at www.buildo.dev.',
115+
value: 'buildoDev',
92116
},
93117
],
94118
},
@@ -115,12 +139,13 @@ export const init = async () => {
115139
exit(9);
116140
}
117141

118-
const isDappTemplate = resourceType === 'nextJsDapp';
142+
const isNextJSDappTemplate = resourceType !== 'piggyBankExampleSc';
119143

120144
await triggerDownloadAndExtract(
121145
dappDirectoryName,
122146
downloadUrls[resourceType],
123-
isDappTemplate
147+
resourceType,
148+
isNextJSDappTemplate
124149
);
125150
} catch (e) {
126151
console.log((e as Error)?.message);

src/meta-esdt/create-meta-esdt.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ const promptQuestions: PromptObject[] = [
4444

4545
export const createMetaEsdt = async () => {
4646
try {
47-
const { ticker, initialQuantity, name, attributes } = await prompts(
48-
promptQuestions
49-
);
47+
const { ticker, initialQuantity, name, attributes } =
48+
await prompts(promptQuestions);
5049

5150
if (!initialQuantity || !ticker || !name) {
5251
console.log(

src/meta-esdt/issue-meta-esdt.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ const promptQuestions: PromptObject[] = [
7575

7676
export const issueMetaEsdt = async () => {
7777
try {
78-
const { name, ticker, tokenProperties, numberOfDecimals } = await prompts(
79-
promptQuestions
80-
);
78+
const { name, ticker, tokenProperties, numberOfDecimals } =
79+
await prompts(promptQuestions);
8180

8281
if (!name || !ticker || !numberOfDecimals) {
8382
console.log(

0 commit comments

Comments
 (0)