Skip to content

Commit

Permalink
migrate sdks
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Apr 23, 2023
1 parent 070ab7e commit 407c40a
Show file tree
Hide file tree
Showing 21 changed files with 1,066 additions and 602 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### [0.12.0](https://github.com/xdevguild/buildo-begins/releases/tag/v0.12.0) (2023-04-23)
- update dependencies including `sdk-core` and `sdk-wallet`
- code ajustments because of changes in core dependencies

### [0.11.0](https://github.com/xdevguild/buildo-begins/releases/tag/v0.11.0) (2023-02-04)
- added `ESDTTransferRole` for ESDT (fungible)
- dependencies update
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Meet Buildo. He is here to help you start creating in the MultiversX blockchain

1. Install globally `npm install buildo-begins -g`
2. Derive the pem from seed phrase: `buildo-begins derive-pem`
3. The walletKey.pem file will be created
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!**)
4. Check the commands with `buildo-begins --help`
5. Use one of available commands, check them below.
5. You will get some prompts, fill up the required data
Expand Down
1,460 changes: 959 additions & 501 deletions package-lock.json

Large diffs are not rendered by default.

58 changes: 32 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
"engines": {
"node": "^14.13.1 || >=16.0.0"
},
"type": "module",
"types": "build/types",
"version": "0.11.0",
"description": "MultiversX blockchain CLI helper tools (protocol, API and smart contracts interaction, also helper tools)",
"main": "build/index.js",
"bin": {
"buildo-begins": "./build/index.js"
},
"type": "module",
"main": "build/index.js",
"exports": {
".": {
"import": "./build/index.js",
"default": "./build/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"build": "rimraf build && node ./esbuild.config.js && tsc",
"dev:lint": "eslint src/** --fix",
Expand All @@ -35,36 +41,36 @@
"api"
],
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/decompress": "^4.2.4",
"@types/cross-spawn": "6.0.2",
"@types/decompress": "4.2.4",
"@types/keccak": "3.0.1",
"@types/node": "18.11.18",
"@types/prompts": "2.4.2",
"@typescript-eslint/eslint-plugin": "5.50.0",
"@typescript-eslint/parser": "5.50.0",
"esbuild": "0.17.5",
"eslint": "8.33.0",
"eslint-config-prettier": "8.6.0",
"@types/node": "18.16.0",
"@types/prompts": "2.4.4",
"@typescript-eslint/eslint-plugin": "5.59.0",
"@typescript-eslint/parser": "5.59.0",
"esbuild": "0.17.18",
"eslint": "8.39.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "4.2.1",
"prettier": "2.8.3",
"rimraf": "4.1.2",
"typescript": "4.9.5"
"prettier": "2.8.7",
"rimraf": "5.0.0",
"typescript": "5.0.4"
},
"dependencies": {
"@multiversx/sdk-core": "11.2.0",
"@multiversx/sdk-network-providers": "1.3.0",
"@multiversx/sdk-wallet": "2.1.3",
"axios": "1.3.2",
"@multiversx/sdk-core": "12.1.1",
"@multiversx/sdk-network-providers": "1.4.0",
"@multiversx/sdk-wallet": "4.0.0",
"axios": "1.3.6",
"bignumber.js": "9.1.1",
"chalk": "5.2.0",
"cosmiconfig": "8.0.0",
"cross-spawn": "^7.0.3",
"decompress": "^4.2.1",
"get-stream": "^6.0.1",
"got": "^12.5.3",
"cosmiconfig": "8.1.3",
"cross-spawn": "7.0.3",
"decompress": "4.2.1",
"get-stream": "6.0.1",
"got": "12.6.0",
"keccak": "3.0.3",
"ora": "6.1.2",
"p-event": "^5.0.1",
"ora": "6.3.0",
"p-event": "5.0.1",
"prompts": "2.4.2"
}
}
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export const issueTokenPayment = '0.05';

export const commonOpertationsGasLimit = 60_000_000;
export const commonBuiltInOpertationsGasLimit = 6_000_000;
export const specialOpertationsGasLimit = 3_000_000;
export const nftCreateOpertationsGasLimit = 3_000_000;
export const specialOpertationsGasLimit = 300_000;

// Resources to download (URLs)
export const downloadUrls: Record<string, string> = {
Expand Down
6 changes: 3 additions & 3 deletions src/converters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prompts, { PromptObject } from 'prompts';
import { exit } from 'process';

import { Address, TokenPayment } from '@multiversx/sdk-core';
import { Address, TokenTransfer } from '@multiversx/sdk-core';
import BigNumber from 'bignumber.js';

enum ConverterType {
Expand Down Expand Up @@ -146,13 +146,13 @@ const base64ToDecimal = (inputValue: string) => {
};

const amountToDenominated = (inputValue: string) => {
const balance = TokenPayment.egldFromAmount(inputValue);
const balance = TokenTransfer.egldFromAmount(inputValue);
console.log('\nEGLD amount to denominated amount result:');
console.log(`${balance.toString()}\n`);
};

const denominatedToAmount = (inputValue: string) => {
const balance = TokenPayment.egldFromBigInteger(inputValue);
const balance = TokenTransfer.egldFromBigInteger(inputValue);
console.log('\nEGLD denominated amount to amount result:');
console.log(`${balance.toPrettyString()}\n`);
};
Expand Down
6 changes: 3 additions & 3 deletions src/egld/send-egld.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prompts, { PromptObject } from 'prompts';
import { exit } from 'process';
import {
TokenPayment,
TokenTransfer,
Transaction,
TransactionPayload,
Address,
Expand All @@ -14,7 +14,7 @@ const promptQuestions: PromptObject[] = [
{
type: 'text',
name: 'address',
message: 'Please provide the erd address (receiver)\n',
message: 'Please provide the receiver address\n',
validate: (value) => (!value ? 'Required!' : true),
},
{
Expand Down Expand Up @@ -47,7 +47,7 @@ export const sendEgld = async () => {

const { signer, userAccount, provider } = await setup();

const payment = TokenPayment.egldFromAmount(amount);
const payment = TokenTransfer.egldFromAmount(amount);

const data = new TransactionPayload(msg || '');

Expand Down
2 changes: 1 addition & 1 deletion src/esdt/freeze-unfreeze-esdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const promptQuestions: PromptObject[] = [
{
type: 'text',
name: 'address',
message: 'Please provide the address to freeze/unfreeze\n',
message: (prev, values) => `Please provide the address to ${values.type}\n`,
validate: (value) => (!value ? 'Required!' : true),
},
];
Expand Down
6 changes: 3 additions & 3 deletions src/esdt/issue-esdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import prompts, { PromptObject } from 'prompts';
import { exit } from 'process';
import Bignumber from 'bignumber.js';
import {
TokenPayment,
TokenTransfer,
Transaction,
BytesValue,
U32Value,
Expand Down Expand Up @@ -66,7 +66,7 @@ const promptQuestions: PromptObject[] = [
type: 'text',
name: 'initialSupply',
message:
'Please provide the initial supply (remember to take into consideration the number of decimals)\n',
'Please provide the initial supply (remember to take into consideration the number of decimals for example 100 with 2 decimal places will be 10000)\n',
validate: (value) =>
!value || new Bignumber(value).isNaN() ? 'Required number!' : true,
},
Expand Down Expand Up @@ -98,7 +98,7 @@ export const issueEsdt = async () => {

const { signer, userAccount, provider } = await setup();

const payment = TokenPayment.egldFromAmount(issueTokenPayment);
const payment = TokenTransfer.egldFromAmount(issueTokenPayment);

const args: TypedValue[] = [
BytesValue.fromUTF8(name),
Expand Down
3 changes: 2 additions & 1 deletion src/esdt/mint-burn-esdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const promptQuestions: PromptObject[] = [
{
type: 'text',
name: 'supply',
message: 'Please provide the supply\n',
message: (prev, values) =>
`Please provide the amount to ${values.type} (Remember about decimal places)\n`,
validate: (value) =>
!value || new Bignumber(value).isNaN() ? 'Required number!' : true,
},
Expand Down
20 changes: 10 additions & 10 deletions src/esdt/send-esdt.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import prompts, { PromptObject } from 'prompts';
import { exit } from 'process';
import {
TokenPayment,
Transaction,
ESDTTransferPayloadBuilder,
TokenTransfer,
GasEstimator,
TransferTransactionsFactory,
Address,
} from '@multiversx/sdk-core';
import axios from 'axios';
Expand All @@ -15,7 +15,7 @@ const promptQuestions: PromptObject[] = [
{
type: 'text',
name: 'address',
message: 'Please provide the erd address (receiver)\n',
message: 'Please provide the receiver address\n',
validate: (value) => (!value ? 'Required!' : true),
},
{
Expand Down Expand Up @@ -62,18 +62,18 @@ export const sendEsdt = async () => {
const numDecimals = esdtOnNetwork?.data?.decimals;

if (numDecimals !== undefined && numDecimals !== null) {
const payment = TokenPayment.fungibleFromAmount(
const transfer = TokenTransfer.fungibleFromAmount(
token,
amount,
numDecimals
);
const data = new ESDTTransferPayloadBuilder().setPayment(payment).build();

const tx = new Transaction({
data,
gasLimit: 50000 + 1500 * data.length() + 300000,
receiver: new Address(address.trim()),
const factory = new TransferTransactionsFactory(new GasEstimator());

const tx = factory.createESDTTransfer({
tokenTransfer: transfer,
sender: signer.getAddress(),
receiver: new Address(address.trim()),
chainID: shortChainId[chain],
});

Expand Down
2 changes: 1 addition & 1 deletion src/esdt/wipe-esdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const promptQuestions: PromptObject[] = [
type: 'text',
name: 'address',
message:
'Please provide the address to from which the token will be wiped\n',
'Please provide the frozen address from which the token will be wiped\n',
validate: (value) => (!value ? 'Required!' : true),
},
];
Expand Down
6 changes: 3 additions & 3 deletions src/meta-esdt/create-meta-esdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import Bignumber from 'bignumber.js';

import { areYouSureAnswer, setup, commonTxOperations } from '../utils';
import { chain, shortChainId, specialOpertationsGasLimit } from '../config';
import { chain, shortChainId, nftCreateOpertationsGasLimit } from '../config';

const promptQuestions: PromptObject[] = [
{
Expand All @@ -24,7 +24,7 @@ const promptQuestions: PromptObject[] = [
type: 'text',
name: 'initialQuantity',
message:
'Please provide the initial quantity Please provide the initial supply (remember to take into consideration the number of decimals)\n',
'Please provide the initial supply (remember to take into consideration the number of decimals for example 100 with 2 decimal places will be 10000)\n',
validate: (value) =>
!value || new Bignumber(value).isNaN() ? 'Required number!' : true,
},
Expand Down Expand Up @@ -76,7 +76,7 @@ export const createMetaEsdt = async () => {

const tx = new Transaction({
data,
gasLimit: specialOpertationsGasLimit + data.length() * 1500 + 50000,
gasLimit: nftCreateOpertationsGasLimit + data.length() * 1500 + 50000,
receiver: signer.getAddress(),
sender: signer.getAddress(),
value: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/meta-esdt/issue-meta-esdt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prompts, { PromptObject } from 'prompts';
import { exit } from 'process';
import {
TokenPayment,
TokenTransfer,
Transaction,
BytesValue,
Address,
Expand Down Expand Up @@ -90,7 +90,7 @@ export const issueMetaEsdt = async () => {

const { signer, userAccount, provider } = await setup();

const payment = TokenPayment.egldFromAmount(issueTokenPayment);
const payment = TokenTransfer.egldFromAmount(issueTokenPayment);

const args: TypedValue[] = [
BytesValue.fromUTF8(name),
Expand Down
23 changes: 10 additions & 13 deletions src/meta-esdt/send-meta-esdt.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import prompts, { PromptObject } from 'prompts';
import { exit } from 'process';
import {
TokenPayment,
Transaction,
ESDTNFTTransferPayloadBuilder,
TokenTransfer,
GasEstimator,
TransferTransactionsFactory,
Address,
} from '@multiversx/sdk-core';
import axios from 'axios';
Expand All @@ -15,7 +15,7 @@ const promptQuestions: PromptObject[] = [
{
type: 'text',
name: 'address',
message: 'Please provide the erd address (receiver)\n',
message: 'Please provide the receiver address\n',
validate: (value) => (!value ? 'Required!' : true),
},
{
Expand Down Expand Up @@ -73,23 +73,20 @@ export const sendMetaEsdt = async () => {
collectionTicker !== undefined &&
collectionTicker !== null
) {
const payment = TokenPayment.metaEsdtFromAmount(
const transfer = TokenTransfer.metaEsdtFromAmount(
collectionTicker,
nonce,
amount,
numDecimals
);
const data = new ESDTNFTTransferPayloadBuilder()
.setPayment(payment)
.setDestination(new Address(address.trim()))
.build();

const tx = new Transaction({
const factory = new TransferTransactionsFactory(new GasEstimator());

const tx = factory.createESDTNFTTransfer({
tokenTransfer: transfer,
nonce,
data,
gasLimit: 50000 + 1500 * data.length() + 300000,
receiver: signer.getAddress(), // Same as sender address!
sender: signer.getAddress(),
destination: new Address(address.trim()),
chainID: shortChainId[chain],
});

Expand Down
4 changes: 2 additions & 2 deletions src/nft/create-nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import Bignumber from 'bignumber.js';

import { areYouSureAnswer, setup, commonTxOperations } from '../utils';
import { chain, shortChainId, specialOpertationsGasLimit } from '../config';
import { chain, shortChainId, nftCreateOpertationsGasLimit } from '../config';

const promptQuestions: PromptObject[] = [
{
Expand Down Expand Up @@ -92,7 +92,7 @@ export const createNft = async () => {
const tx = new Transaction({
data,
gasLimit:
specialOpertationsGasLimit +
nftCreateOpertationsGasLimit +
data.length() * 1500 +
(attributes?.length || 0 + hash?.length || 0) * 50000,
receiver: signer.getAddress(),
Expand Down
4 changes: 2 additions & 2 deletions src/nft/issue-nft.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prompts, { PromptObject } from 'prompts';
import { exit } from 'process';
import {
TokenPayment,
TokenTransfer,
Transaction,
BytesValue,
Address,
Expand Down Expand Up @@ -78,7 +78,7 @@ export const issueNft = async () => {

const { signer, userAccount, provider } = await setup();

const payment = TokenPayment.egldFromAmount(issueTokenPayment);
const payment = TokenTransfer.egldFromAmount(issueTokenPayment);

const args: TypedValue[] = [
BytesValue.fromUTF8(name),
Expand Down
Loading

0 comments on commit 407c40a

Please sign in to comment.