diff --git a/lib/api/electrum-api-mock.ts b/lib/api/electrum-api-mock.ts index 9cf181c..d99a562 100644 --- a/lib/api/electrum-api-mock.ts +++ b/lib/api/electrum-api-mock.ts @@ -23,7 +23,7 @@ export class ElectrumApiMock implements ElectrumApiInterface { } async dump() { - + } async resetConnection() { @@ -34,7 +34,7 @@ export class ElectrumApiMock implements ElectrumApiInterface { return null; } - + setSendTransaction(cb: Function) { return this.sendTransactionCallback = cb; @@ -73,7 +73,7 @@ export class ElectrumApiMock implements ElectrumApiInterface { return this.getTxCallback = cb; } - async getTx(txid: string, verbose = false): Promise { + async getTx(txid: string): Promise { if (!this.getTxCallback) { throw "getTxCallback undefined"; } @@ -118,7 +118,7 @@ export class ElectrumApiMock implements ElectrumApiInterface { public async atomicalsGetFtInfo(atomicalAliasOrId: string | number): Promise { return "atomicalsGetFtInfo" } - + public async atomicalsGetLocation(atomicalAliasOrId: string | number): Promise { return "atomicalsGetLocation" } @@ -170,7 +170,7 @@ export class ElectrumApiMock implements ElectrumApiInterface { public async atomicalsGetByContainerItemValidated(container: string, item: string, bitworkc: string, bitworkr: string, main: string, mainHash: string, proof: any, checkWithoutSealed: boolean): Promise { return "atomicalsGetByContainerItemValidated" } - + public async atomicalsFindTickers(tickerPrefix: string | null, asc?: boolean): Promise { return "atomicalsFindTickers" } diff --git a/lib/api/electrum-api.interface.ts b/lib/api/electrum-api.interface.ts index 0018f21..2a1c7f9 100644 --- a/lib/api/electrum-api.interface.ts +++ b/lib/api/electrum-api.interface.ts @@ -16,7 +16,7 @@ export interface ElectrumApiInterface { getUnspentAddress: (address: string) => Promise; getUnspentScripthash: (address: string) => Promise; waitUntilUTXO: (address: string, satoshis: number, sleepTimeSec: number, exactSatoshiAmount?: boolean) => Promise; - getTx: (txid: string, verbose?: boolean) => Promise; + getTx: (txid: string) => Promise; serverVersion: () => Promise; broadcast: (rawtx: string, force?: boolean) => Promise; history: (scripthash: string) => Promise; @@ -27,7 +27,7 @@ export interface ElectrumApiInterface { atomicalsGet: (atomicalAliasOrId: string | number) => Promise; atomicalsGetFtInfo: (atomicalAliasOrId: string | number) => Promise; atomicalsGetLocation: (atomicalAliasOrId: string | number) => Promise; - atomicalsGetState: (atomicalAliasOrId: string | number, verbose: boolean) => Promise; + atomicalsGetState: (atomicalAliasOrId: string | number) => Promise; atomicalsGetStateHistory: (atomicalAliasOrId: string | number) => Promise; atomicalsGetEventHistory: (atomicalAliasOrId: string | number) => Promise; atomicalsGetTxHistory: (atomicalAliasOrId: string | number) => Promise; @@ -38,7 +38,7 @@ export interface ElectrumApiInterface { atomicalsGetByContainerItem: (container: string, item: string) => Promise; atomicalsGetByContainerItemValidated: (container: string, item: string, bitworkc: string, bitworkr: string, main: string, mainHash: string, proof: any, checkWithoutSealed: boolean) => Promise; atomicalsGetByRealm: (realm: string) => Promise; - atomicalsGetRealmInfo: (realmOrSubRealm: string, verbose?: boolean) => Promise; + atomicalsGetRealmInfo: (realmOrSubRealm: string) => Promise; atomicalsGetByTicker: (ticker: string) => Promise; atomicalsGetByContainer: (container: string) => Promise; atomicalsGetContainerItems: (container: string, limit: number, offset: number) => Promise; @@ -46,4 +46,4 @@ export interface ElectrumApiInterface { atomicalsFindContainers: (containerPrefix: string | null, asc?: boolean) => Promise; atomicalsFindRealms: (realmPrefix: string | null, asc?: boolean) => Promise; atomicalsFindSubRealms: (parentRealmId: string, subrealmPrefix: string | null, mostRecentFirst?: boolean) => Promise; -} \ No newline at end of file +} diff --git a/lib/api/electrum-api.ts b/lib/api/electrum-api.ts index e2e4110..b3c98b2 100644 --- a/lib/api/electrum-api.ts +++ b/lib/api/electrum-api.ts @@ -55,14 +55,14 @@ export class ElectrumApi implements ElectrumApiInterface { url: url, ...(this.usePost ? { data: { params } } : { params: params }) }; - + const response = await axios(options); return response.data.response; } catch (error) { console.log(`Error using endpoint ${baseUrl}:`, error); } } - + throw new Error('All endpoints failed'); } @@ -70,9 +70,9 @@ export class ElectrumApi implements ElectrumApiInterface { return this.broadcast(signedRawTx); } - public getTx(txId: string, verbose = false): Promise { + public getTx(txId: string): Promise { return new Promise((resolve, reject) => { - this.call('blockchain.transaction.get', [txId, verbose ? 1 : 0] + this.call('blockchain.transaction.get', [txId] ).then((result: any) => { resolve({success: true, tx: result}); }).catch((error) => reject(error)) @@ -210,8 +210,8 @@ export class ElectrumApi implements ElectrumApiInterface { return this.call('blockchain.atomicals.get_state_history', [atomicalAliasOrId]); } - public atomicalsGetState(atomicalAliasOrId: string | number, verbose: boolean): Promise { - return this.call('blockchain.atomicals.get_state', [atomicalAliasOrId, verbose ? 1 : 0]); + public atomicalsGetState(atomicalAliasOrId: string | number): Promise { + return this.call('blockchain.atomicals.get_state', [atomicalAliasOrId]); } public atomicalsGetEventHistory(atomicalAliasOrId: string | number): Promise { diff --git a/lib/cli.ts b/lib/cli.ts index 610e032..8914a8c 100644 --- a/lib/cli.ts +++ b/lib/cli.ts @@ -600,10 +600,9 @@ program.command('tx') .action(async (txid, options) => { try { await validateWalletStorage(); - const verbose = options.verbose ? true : false; const config: ConfigurationInterface = validateCliInputs(); const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || '')); - const result = await atomicals.getTx(txid, verbose); + const result = await atomicals.getTx(txid); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.log(error); diff --git a/lib/commands/get-command.ts b/lib/commands/get-command.ts index e77f82f..0392b26 100644 --- a/lib/commands/get-command.ts +++ b/lib/commands/get-command.ts @@ -6,7 +6,6 @@ export class GetCommand implements CommandInterface { constructor(private electrumApi: ElectrumApiInterface, private atomicalAliasOrId: string, private fetchType: AtomicalsGetFetchType = AtomicalsGetFetchType.GET, - private verbose?: boolean ) { } @@ -17,7 +16,7 @@ export class GetCommand implements CommandInterface { } else if (this.fetchType === AtomicalsGetFetchType.LOCATION) { response = await this.electrumApi.atomicalsGetLocation(this.atomicalAliasOrId); } else if (this.fetchType === AtomicalsGetFetchType.STATE) { - response = await this.electrumApi.atomicalsGetState(this.atomicalAliasOrId, this.verbose || false); + response = await this.electrumApi.atomicalsGetState(this.atomicalAliasOrId); } else if (this.fetchType === AtomicalsGetFetchType.STATE_HISTORY) { response = await this.electrumApi.atomicalsGetStateHistory(this.atomicalAliasOrId); } else if (this.fetchType === AtomicalsGetFetchType.EVENT_HISTORY) { diff --git a/lib/commands/tx-command.ts b/lib/commands/tx-command.ts index f83b296..0ccc0ac 100644 --- a/lib/commands/tx-command.ts +++ b/lib/commands/tx-command.ts @@ -5,11 +5,10 @@ export class TxCommand implements CommandInterface { constructor( private electrumApi: ElectrumApiInterface, private txid: string, - private verbose: boolean ) { } async run(): Promise { - return this.electrumApi.getTx(this.txid, this.verbose); + return this.electrumApi.getTx(this.txid); } -} \ No newline at end of file +} diff --git a/lib/index.ts b/lib/index.ts index dcdbb62..c7567e1 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -457,12 +457,12 @@ export class Atomicals implements APIInterface { requestTicker: string, mintAmount: number, maxMints: number, - mintHeight: number, - mintBitworkVector: string, - mintBitworkCommitIncrement: number, - mintBitworkRevealIncrement: number | null, + mintHeight: number, + mintBitworkVector: string, + mintBitworkCommitIncrement: number, + mintBitworkRevealIncrement: number | null, mintBitworkCommitIncrementStart: number | null, - mintBitworkRevealIncrementStart: number | null, + mintBitworkRevealIncrementStart: number | null, maxGlobalMints: number | null, WIF: string, noImage?: boolean, @@ -470,17 +470,17 @@ export class Atomicals implements APIInterface { try { await this.electrumApi.open(); const command: CommandInterface = new InitInteractiveInfiniteDftCommand( - this.electrumApi, - options, + this.electrumApi, + options, file, address, requestTicker, - mintAmount, - maxMints, - mintHeight, - mintBitworkVector, + mintAmount, + maxMints, + mintHeight, + mintBitworkVector, mintBitworkCommitIncrement, - mintBitworkRevealIncrement, + mintBitworkRevealIncrement, mintBitworkCommitIncrementStart, mintBitworkRevealIncrementStart, maxGlobalMints, @@ -505,25 +505,25 @@ export class Atomicals implements APIInterface { requestTicker: string, mintAmount: number, maxMints: number, - mintHeight: number, - mintBitworkCommit: string, - mintBitworkReveal: string | null, + mintHeight: number, + mintBitworkCommit: string, + mintBitworkReveal: string | null, WIF: string, noImage?: boolean, ): Promise { try { await this.electrumApi.open(); const command: CommandInterface = new InitInteractiveFixedDftCommand( - this.electrumApi, - options, + this.electrumApi, + options, file, address, requestTicker, - mintAmount, - maxMints, - mintHeight, - mintBitworkCommit, - mintBitworkReveal, + mintAmount, + maxMints, + mintHeight, + mintBitworkCommit, + mintBitworkReveal, WIF, noImage); return await command.run(); @@ -634,7 +634,7 @@ export class Atomicals implements APIInterface { this.electrumApi.close(); } } - + async emitInteractive(options: BaseRequestOptions, atomicalId: string, files: string[], funding: IWalletRecord, atomicalOwner: IWalletRecord): Promise { try { await this.electrumApi.open(); @@ -962,10 +962,10 @@ export class Atomicals implements APIInterface { } } - async getAtomicalState(atomicalAliasOrId: string, verbose: boolean = false, keepElectrumAlive = false): Promise { + async getAtomicalState(atomicalAliasOrId: string, keepElectrumAlive = false): Promise { try { await this.electrumApi.open(); - const command: CommandInterface = new GetCommand(this.electrumApi, atomicalAliasOrId, AtomicalsGetFetchType.STATE, verbose); + const command: CommandInterface = new GetCommand(this.electrumApi, atomicalAliasOrId, AtomicalsGetFetchType.STATE); return await command.run(); } catch (error: any) { return { @@ -1384,10 +1384,10 @@ export class Atomicals implements APIInterface { } } - async getTx(txid: string, verbose: boolean): Promise { + async getTx(txid: string): Promise { try { await this.electrumApi.open(); - const command: CommandInterface = new TxCommand(this.electrumApi, txid, verbose); + const command: CommandInterface = new TxCommand(this.electrumApi, txid); return await command.run(); } catch (error: any) { return { diff --git a/lib/interfaces/api.interface.ts b/lib/interfaces/api.interface.ts index f6c76df..01597db 100644 --- a/lib/interfaces/api.interface.ts +++ b/lib/interfaces/api.interface.ts @@ -75,7 +75,7 @@ export interface APIInterface { getAtomical(atomicalId: string, keepElectrumAlive: boolean): Promise; getAtomicalLocation(atomicalId: string, keepElectrumAlive: boolean): Promise; getAtomicalHistory(atomicalId: string, keepElectrumAlive: boolean): Promise; - getAtomicalState(atomicalId: string, verbose: boolean, keepElectrumAlive: boolean): Promise; + getAtomicalState(atomicalId: string, keepElectrumAlive: boolean): Promise; getAtomicalStateHistory(atomicalId: string, keepElectrumAlive: boolean): Promise; getAtomicalEventHistory(atomicalId: string, keepElectrumAlive: boolean): Promise; searchTickers(prefix: string, keepElectrumAlive: boolean): Promise; diff --git a/package.json b/package.json index 08146fd..57e518a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "atomicals-js", - "version": "0.1.79", + "version": "0.1.80", "description": "Atomicals Javascript Library and CLI", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/test/e2e.test.js b/test/e2e.test.js index b06345c..c684319 100644 --- a/test/e2e.test.js +++ b/test/e2e.test.js @@ -4,15 +4,15 @@ var expect = require('chai').expect; var chaiAsPromised = require('chai-as-promised'); chai.use(chaiAsPromised); var index = require('../dist/index.js'); - + require('dotenv').config(); describe('e2e', () => { it('get latest state', async () => { const atomicals = new index.Atomicals(index.ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || '')); - const state = await atomicals.getAtomicalState('1', true); + const state = await atomicals.getAtomicalState('1'); console.log('state', state); }); -}); \ No newline at end of file +});