Skip to content

Commit

Permalink
Merge pull request #3 from atomicals-community/fix/remove-unnecessary…
Browse files Browse the repository at this point in the history
…-verbose

Remove unnecessary verbose parameters
  • Loading branch information
wizz-wallet-dev authored Jun 14, 2024
2 parents ab13bdb + d605e46 commit 4b9a34b
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 73 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: Test

on:
push:
branches:
- '**'
pull_request:
branches:
- 'master'
branches:
- 'main'

jobs:
build:
Expand Down
12 changes: 6 additions & 6 deletions lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ program.command('get')
const config: ConfigurationInterface = validateCliInputs();
const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || ''));
const verbose = options.verbose ? true : false;
const result = await atomicals.resolveAtomical(atomicalAliasOrIdLC, AtomicalsGetFetchType.GET, undefined, verbose);
const result = await atomicals.resolveAtomical(atomicalAliasOrIdLC, AtomicalsGetFetchType.GET);
handleResultLogging(result);
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -1311,7 +1311,7 @@ program.command('location')
await validateWalletStorage();
const config: ConfigurationInterface = validateCliInputs();
const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || ''));
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.LOCATION, undefined, options.verbose);
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.LOCATION);
handleResultLogging(result);
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -1343,7 +1343,7 @@ program.command('state')
const config: ConfigurationInterface = validateCliInputs();
const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || ''));
const verbose = options.verbose ? true : false;
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.STATE, verbose);
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.STATE);
handleResultLogging(result);
} catch (error) {
console.log(error);
Expand All @@ -1360,7 +1360,7 @@ program.command('state-history')
const config: ConfigurationInterface = validateCliInputs();
const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || ''));
const verbose = options.verbose ? true : false;
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.STATE_HISTORY, undefined, verbose);
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.STATE_HISTORY);
handleResultLogging(result);
} catch (error) {
console.log(error);
Expand All @@ -1377,7 +1377,7 @@ program.command('events')
const config: ConfigurationInterface = validateCliInputs();
const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || ''));
const verbose = options.verbose ? true : false;
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.EVENT_HISTORY, undefined, verbose);
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.EVENT_HISTORY);
handleResultLogging(result);
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -2061,7 +2061,7 @@ program.command('tx-history')
const config: ConfigurationInterface = validateCliInputs();
const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || ''));
const verbose = options.verbose ? true : false;
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.TX_HISTORY, undefined, verbose);
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.TX_HISTORY);
handleResultLogging(result);
} catch (error) {
console.log(error);
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/download-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const writeFiles = async (inputIndexToFilesMap: any, txDir: string): Prom
const fullPath = inputTxDir + `/${fileNameWithExtension}`
await fileWriter(fullPath, JSON.stringify(fileEntry, null, 2));
const contentLength = fileEntry.length;
const body = fileEntry
const body = fileEntry
fileSummary[inputIndex]['files'][filename] = {
filename,
fileNameWithExtension,
Expand All @@ -98,14 +98,14 @@ export const writeFiles = async (inputIndexToFilesMap: any, txDir: string): Prom
return fileSummary;
}
export class DownloadCommand implements CommandInterface {
constructor(
constructor(
private electrumApi: ElectrumApiInterface,
private atomicalIdOrTxId: string,
) {
}
async run(): Promise<any> {
const txid = getTxIdFromAtomicalId(this.atomicalIdOrTxId);
const txResult = await this.electrumApi.getTx(txid, false);
const txResult = await this.electrumApi.getTx(txid);

if (!txResult || !txResult.success) {
throw `transaction not found ${txid}`;
Expand All @@ -130,4 +130,4 @@ export class DownloadCommand implements CommandInterface {
}
};
}
}
}
11 changes: 5 additions & 6 deletions lib/commands/get-by-container-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { decorateAtomical } from "../utils/atomical-format-helpers";
import { GetCommand } from "./get-command";

export class GetByContainerCommand implements CommandInterface {
constructor(

constructor(
private electrumApi: ElectrumApiInterface,
private container: string,
private fetchType: AtomicalsGetFetchType = AtomicalsGetFetchType.GET,
private verbose?: boolean
) {

}

async run(): Promise<any> {
Expand All @@ -23,7 +22,7 @@ export class GetByContainerCommand implements CommandInterface {
data: responseResult.result
}
}
const getDefaultCommand = new GetCommand(this.electrumApi, responseResult.result.atomical_id, this.fetchType, this.verbose);
const getDefaultCommand = new GetCommand(this.electrumApi, responseResult.result.atomical_id, this.fetchType);
const getDefaultCommandResponse = await getDefaultCommand.run();
const updatedRes = Object.assign({},
getDefaultCommandResponse.data,
Expand All @@ -36,4 +35,4 @@ export class GetByContainerCommand implements CommandInterface {
data: updatedRes
}
}
}
}
11 changes: 5 additions & 6 deletions lib/commands/get-by-realm-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ import { decorateAtomical } from "../utils/atomical-format-helpers";
import { GetCommand } from "./get-command";

export class GetByRealmCommand implements CommandInterface {

constructor(private electrumApi: ElectrumApiInterface,
private realm: string,
private fetchType: AtomicalsGetFetchType = AtomicalsGetFetchType.GET,
private verbose?: boolean
) {

}
async run(): Promise<any> {
const responseResult = await this.electrumApi.atomicalsGetRealmInfo(this.realm, this.verbose);
const responseResult = await this.electrumApi.atomicalsGetRealmInfo(this.realm);
if (!responseResult.result || !responseResult.result.atomical_id) {
return {
success: false,
data: responseResult.result
}
}
const getDefaultCommand = new GetCommand( this.electrumApi, responseResult.result.atomical_id, this.fetchType, this.verbose);
const getDefaultCommand = new GetCommand( this.electrumApi, responseResult.result.atomical_id, this.fetchType);
const getDefaultCommandResponse = await getDefaultCommand.run();
const updatedRes = Object.assign({},
getDefaultCommandResponse.data,
Expand All @@ -33,4 +32,4 @@ export class GetByRealmCommand implements CommandInterface {
data: updatedRes
}
}
}
}
7 changes: 3 additions & 4 deletions lib/commands/get-by-ticker-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { decorateAtomical } from "../utils/atomical-format-helpers";
import { GetCommand } from "./get-command";

export class GetByTickerCommand implements CommandInterface {
constructor(
constructor(
private electrumApi: ElectrumApiInterface,
private ticker: string,
private fetchType: AtomicalsGetFetchType = AtomicalsGetFetchType.GET,
private verbose?: boolean
) {

}
Expand All @@ -21,7 +20,7 @@ export class GetByTickerCommand implements CommandInterface {
data: responseResult.result
}
}
const getDefaultCommand = new GetCommand(this.electrumApi, responseResult.result.atomical_id, this.fetchType, this.verbose);
const getDefaultCommand = new GetCommand(this.electrumApi, responseResult.result.atomical_id, this.fetchType);
const getDefaultCommandResponse = await getDefaultCommand.run();
const updatedRes = Object.assign({},
getDefaultCommandResponse.data,
Expand All @@ -34,4 +33,4 @@ export class GetByTickerCommand implements CommandInterface {
data: updatedRes
}
}
}
}
7 changes: 3 additions & 4 deletions lib/commands/get-subrealm-info-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ export interface GetSubrealmInfoCommandResultInterface {
}

export class GetRealmInfoCommand implements CommandInterface {
constructor(
constructor(
private electrumApi: ElectrumApiInterface,
private realmOrSubrealm: any,
private verbose?: boolean
) {
}

async run(): Promise<any> {
const responseResult = await this.electrumApi.atomicalsGetRealmInfo(this.realmOrSubrealm, this.verbose);
const responseResult = await this.electrumApi.atomicalsGetRealmInfo(this.realmOrSubrealm);
return {
success: true,
data: responseResult.result
}

}
}
}
8 changes: 4 additions & 4 deletions lib/commands/init-interactive-dft-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class InitInteractiveDftCommand implements CommandInterface {
if (this.maxMints > 500000 || this.maxMints < 10000) {
throw new Error('Command line tool expects max mints to be between 10,000 and 500,000')
}

if (this.mintAmount > 100000000 || this.mintAmount < 546) {
throw new Error('mint amount must be between 546 and 100,000,000')
}
Expand Down Expand Up @@ -103,7 +103,7 @@ export class InitInteractiveDftCommand implements CommandInterface {
console.log('Mint Amount', this.mintAmount);
console.log('Data objects: ', filesData);
console.log('-----------------------')

if (this.mintBitworkc?.length < 5) {
console.log('WARNING: Mint Bitworkc is too easy to mine and can be mined in less than a minute or faster. Confirm if that is acceptable.', this.mintBitworkc);
}
Expand All @@ -118,7 +118,7 @@ export class InitInteractiveDftCommand implements CommandInterface {

await promptContinue();

const getExistingNameCommand = new GetByTickerCommand(this.electrumApi, this.requestTicker, AtomicalsGetFetchType.GET, undefined);
const getExistingNameCommand = new GetByTickerCommand(this.electrumApi, this.requestTicker, AtomicalsGetFetchType.GET);
try {
const getExistingNameResult = await getExistingNameCommand.run();
if (getExistingNameResult.success && getExistingNameResult.data) {
Expand Down Expand Up @@ -202,4 +202,4 @@ export class InitInteractiveDftCommand implements CommandInterface {
}
}

}
}
16 changes: 8 additions & 8 deletions lib/commands/init-interactive-fixed-dft-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class InitInteractiveFixedDftCommand implements CommandInterface {
if (this.maxMints > 10000000 || this.maxMints < 10000) {
throw new Error('Command line tool expects max mints to be between 10,000 and 10,000,000')
}

if (this.mintAmount > 100000000 || this.mintAmount < 546) {
throw new Error('mint amount must be between 546 and 100,000,000')
}
Expand All @@ -77,15 +77,15 @@ export class InitInteractiveFixedDftCommand implements CommandInterface {
if (!filesData['name']) {
throw new Error('Please set a name in the files metadata. See examples in /templates/fungible-tokens')
}

if (!filesData['legal']) {
throw new Error('Please set legal in the files metadata. See examples in /templates/fungible-tokens')
}

if (!filesData['legal']['terms']) {
throw new Error('Please set legal terms in the files metadata. See examples in /templates/fungible-tokens')
}

if (!this.noimage && filesData['image']) {
// Ex: atom:btc:dat:<location of store-file data>/image.png
const re = /atom\:btc\:dat\:[a-f0-9]{64}i0\/.*\.(png|jpeg|svg|jpg|gif|webp)/
Expand All @@ -99,7 +99,7 @@ export class InitInteractiveFixedDftCommand implements CommandInterface {
name: this.requestTicker.toUpperCase()
}
}

console.log('Initializing Fixed Decentralized FT Token')
console.log('-----------------------')

Expand All @@ -115,7 +115,7 @@ export class InitInteractiveFixedDftCommand implements CommandInterface {
console.log('Mint Amount: ', this.mintAmount);
console.log('Data objects: ', filesData);
console.log('-----------------------')

if (this.mintBitworkCommit?.length < 5) {
console.log('WARNING: Mint Bitworkc is too easy to mine and can be mined in less than a minute or faster. Confirm if that is acceptable.', this.mintBitworkCommit);
}
Expand All @@ -130,7 +130,7 @@ export class InitInteractiveFixedDftCommand implements CommandInterface {

await promptContinue();

const getExistingNameCommand = new GetByTickerCommand(this.electrumApi, this.requestTicker, AtomicalsGetFetchType.GET, undefined);
const getExistingNameCommand = new GetByTickerCommand(this.electrumApi, this.requestTicker, AtomicalsGetFetchType.GET);
try {
const getExistingNameResult = await getExistingNameCommand.run();
if (getExistingNameResult.success && getExistingNameResult.data) {
Expand Down Expand Up @@ -215,4 +215,4 @@ export class InitInteractiveFixedDftCommand implements CommandInterface {
}
}

}
}
20 changes: 10 additions & 10 deletions lib/commands/init-interactive-infinite-dft-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
if (this.maxMints > 100000 || this.maxMints < 1) {
throw new Error('Command line tool expects max mints to be between 1 and 100,000')
}

if (this.mintAmount > 100000000 || this.mintAmount < 546) {
throw new Error('mint amount must be between 546 and 100,000,000')
}
Expand All @@ -82,15 +82,15 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
if (!filesData['name']) {
throw new Error('Please set a name in the files metadata. See examples in /templates/fungible-tokens')
}

if (!filesData['legal']) {
throw new Error('Please set legal in the files metadata. See examples in /templates/fungible-tokens')
}

if (!filesData['legal']['terms']) {
throw new Error('Please set legal terms in the files metadata. See examples in /templates/fungible-tokens')
}

if (!this.noimage && filesData['image']) {
// Ex: atom:btc:dat:<location of store-file data>/image.png
const re = /atom\:btc\:dat\:[a-f0-9]{64}i0\/.*\.(png|jpeg|svg|jpg|gif|webp)/
Expand All @@ -104,7 +104,7 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
name: this.requestTicker.toUpperCase()
}
}

console.log('Initializing Infinite Decentralized FT Token')
console.log('-----------------------')
console.log('Total Supply (Satoshis): unbounded');
Expand All @@ -121,7 +121,7 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
console.log('Mint Amount: ', this.mintAmount);
console.log('Data objects: ', filesData);
console.log('-----------------------')

if (this.mintBitworkCommitIncrement < 1 || this.mintBitworkCommitIncrement > 64) {
throw new Error('Error: Mint Bitwork Commit Increment must be between 1 and 64')
}
Expand All @@ -134,7 +134,7 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
}
await promptContinue();

const getExistingNameCommand = new GetByTickerCommand(this.electrumApi, this.requestTicker, AtomicalsGetFetchType.GET, undefined);
const getExistingNameCommand = new GetByTickerCommand(this.electrumApi, this.requestTicker, AtomicalsGetFetchType.GET);
try {
const getExistingNameResult = await getExistingNameCommand.run();
if (getExistingNameResult.success && getExistingNameResult.data) {
Expand Down Expand Up @@ -174,7 +174,7 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
mint_height: Number(this.mintHeight),
max_mints: Number(this.maxMints),
};

// Set mint mode = perpetual/infinite
args['md'] = 1
args['bv'] = this.mintBitworkVector
Expand All @@ -201,7 +201,7 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
args['maxg'] = this.maxGlobalMints;
}


atomicalBuilder.setArgs(args);
// Set to request a container
atomicalBuilder.setRequestTicker(this.requestTicker);
Expand Down Expand Up @@ -233,4 +233,4 @@ export class InitInteractiveInfiniteDftCommand implements CommandInterface {
}
}

}
}
Loading

0 comments on commit 4b9a34b

Please sign in to comment.