Skip to content

Commit

Permalink
Send token identifier in the CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanstatescu committed Jun 5, 2022
1 parent 3b5b2b7 commit 6fe3239
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elrond-sft",
"version": "2.0.0",
"version": "2.1.0",
"description": "A simple CLI tool you can use to execute simple operations over Elrond SFTs (issue token, mint SFT, add qty, burn)",
"main": "build/index.js",
"scripts": {
Expand Down
15 changes: 9 additions & 6 deletions src/commands/mint-sft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ import {
import prompts, { PromptObject } from 'prompts';

import { chain, chainId, elrondExplorer, pemKeyFileName } from '../config';
import { loadConfigFromFile, publicEndpointSetup } from '../utils';
import { IConfig, loadConfigFromFile, publicEndpointSetup } from '../utils';

export const mintSft = async () => {
export const mintSft = async (_tokenIdentifier?: IConfig["tokenIdentifier"]) => {
const config = loadConfigFromFile();
if (!config.tokenIdentifier) {
console.log('Token identifier not found. Please run "issue-token" command first.');

const tokenIdentifier = _tokenIdentifier || config?.tokenIdentifier;

if (!tokenIdentifier) {
console.log(
'Token identifier not found. Please run "issue-token" command first or input it manually (check docs for details).'
);
return;
}

const tokenIdentifier = config.tokenIdentifier;

const promptQuestions: PromptObject[] = [
{
type: "number",
Expand Down
15 changes: 9 additions & 6 deletions src/commands/set-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,20 @@ import {
} from '@elrondnetwork/erdjs/out';

import { chain, chainId, elrondExplorer, issueTokenScAddress, pemKeyFileName } from '../config';
import { loadConfigFromFile, publicEndpointSetup } from '../utils';
import { IConfig, loadConfigFromFile, publicEndpointSetup } from '../utils';

export const setRoles = async () => {
export const setRoles = async (_tokenIdentifier?: IConfig["tokenIdentifier"]) => {
const config = loadConfigFromFile();
if (!config.tokenIdentifier) {
console.log('Token identifier not found. Please run "issue-token" command first.');

const tokenIdentifier = _tokenIdentifier || config?.tokenIdentifier;

if (!tokenIdentifier) {
console.log(
'Token identifier not found. Please run "issue-token" command first or input it manually (check docs for details).'
);
return;
}

const tokenIdentifier = config.tokenIdentifier;

try {
const { signer, provider, userAccount } = await publicEndpointSetup(pemKeyFileName);

Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ if (!command || !Object.values(COMMANDS).includes(command)) {

console.log(chalk.yellow(`Running on ${chain.toUpperCase()}\n`));

const commandParam = args ? args[3] : undefined;
switch (command) {
case COMMANDS.issueToken:
issueToken();
break;
case COMMANDS.setRoles:
setRoles();
setRoles(commandParam);
break;
case COMMANDS.mintSft:
mintSft();
mintSft(commandParam);
break;
case COMMANDS.addSftQuantity:
console.log("Not Implemented");
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const publicEndpointSetup = async (_pemKeyFileName?: string) => {
};
};

interface IConfig {
export interface IConfig {
tokenIdentifier: string;
}

Expand Down

0 comments on commit 6fe3239

Please sign in to comment.