Skip to content

Commit 0933a31

Browse files
authored
Merge branch 'master' into fix/remove-deps
2 parents 3e11729 + cdae26c commit 0933a31

File tree

5 files changed

+54
-11
lines changed

5 files changed

+54
-11
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ WALLET_PATH=./wallets
1515
WALLET_FILE=wallet.json
1616
# testnet or livenet or regtest
1717
NETWORK=livenet
18+
DISABLE_DONATE_QUOTE=false

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ WALLET_PATH=./wallets
1515
WALLET_FILE=wallet.json
1616
# testnet or livenet or regtest
1717
NETWORK=livenet
18+
DISABLE_DONATE_QUOTE=false

lib/cli.ts

+44-9
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,52 @@ import { fileReader, jsonFileReader, jsonFileWriter } from './utils/file-utils';
1212
import * as cbor from 'borc';
1313
import { toOutputScript } from 'bitcoinjs-lib/src/address';
1414
import { compactIdToOutpoint, outpointToCompactId } from './utils/atomical-format-helpers';
15+
import * as quotes from 'success-motivational-quotes';
16+
import * as chalk from 'chalk';
17+
1518
dotenv.config();
1619

1720
/////////////////////////////////////////////////////////////////////////////////////////////
1821
// General Helper Functions
1922
/////////////////////////////////////////////////////////////////////////////////////////////
20-
function printOperationResult(data: any, error?: boolean) {
23+
function printSuccess(data: any, showDonation?: boolean) {
24+
console.log(JSON.stringify(data, null, 2));
25+
if (!showDonation) {
26+
return;
27+
}
28+
29+
if (process.env.DISABLE_DONATE_QUOTE && process.env.DISABLE_DONATE_QUOTE === 'true') {
30+
return;
31+
}
32+
console.log(chalk.blue("\n\n------------------------------------------------------------------------------"));
33+
34+
let q = 'Recommend to your children virtue; that alone can make them happy, not gold.';
35+
let by = 'Ludwig van Beethoven';
36+
try {
37+
const quoteObj = quotes.getTodaysQuote();
38+
q = quoteObj.body;
39+
by = quoteObj.by;
40+
} catch (ex) {
41+
// Lib not installed
42+
}
43+
console.log(chalk.green(q));
44+
console.log(chalk.green('- ' + by));
45+
console.log(chalk.blue("------------------------------------------------------------------------------\n"))
46+
const donate = 'bc1pl6k2z5ra403zfeyevzsu7llh0mdqqn4802p4uqfhz6l7qzddq2mqduqvc6';
47+
console.log('Thank you for your support and contributions to Atomicals CLI development! ❤️');
48+
console.log(`Donation address: ${donate}\n`);
49+
console.log(`Even a little goes a long way!\n`);
50+
console.log(`Scan QR Code to Donate:`);
51+
qrcode.generate(donate, { small: true });
52+
}
53+
function printFailure(data: any) {
2154
console.log(JSON.stringify(data, null, 2));
2255
}
23-
function handleResultLogging(result: any) {
24-
if (!result || !result.success) {
25-
printOperationResult(result, true);
56+
function handleResultLogging(result: any, showDonation?: boolean) {
57+
if (!result || !result.success || !result.data) {
58+
printFailure(result);
2659
} else {
27-
printOperationResult(result.data);
60+
printSuccess(result.data, showDonation);
2861
}
2962
}
3063

@@ -1022,7 +1055,7 @@ program.command('mint-item')
10221055
bitworkr: options.bitworkr,
10231056
disableMiningChalk: options.disablechalk,
10241057
}, containerName, itemName, manifestFile, initialOwnerAddress.address, fundingRecord.WIF, ownerWalletRecord);
1025-
handleResultLogging(result);
1058+
handleResultLogging(result, true);
10261059
} catch (error) {
10271060
console.log(error);
10281061
}
@@ -1171,6 +1204,7 @@ program.command('splat')
11711204
}
11721205
});
11731206

1207+
/*
11741208
program.command('split')
11751209
.description('Split operation to separate the FT Atomicals at a single UTXOs.')
11761210
.argument('<locationId>', 'string')
@@ -1194,6 +1228,7 @@ program.command('split')
11941228
console.log(error);
11951229
}
11961230
});
1231+
*/
11971232

11981233
program.command('get')
11991234
.description('Get the status of an Atomical')
@@ -1206,7 +1241,7 @@ program.command('get')
12061241
const atomicals = new Atomicals(ElectrumApi.createClient(process.env.ELECTRUMX_PROXY_BASE_URL || ''));
12071242
const verbose = options.verbose ? true : false;
12081243
const result = await atomicals.resolveAtomical(atomicalAliasOrId, AtomicalsGetFetchType.GET, undefined, verbose);
1209-
handleResultLogging(result);
1244+
handleResultLogging(result, true);
12101245
} catch (error) {
12111246
console.log(error);
12121247
}
@@ -1539,7 +1574,7 @@ program.command('mint-dft')
15391574
satsbyte: parseInt(options.satsbyte),
15401575
disableMiningChalk: options.disablechalk,
15411576
}, walletRecord.address, ticker, fundingRecord.WIF);
1542-
handleResultLogging(result);
1577+
handleResultLogging(result, true);
15431578
} catch (error) {
15441579
console.log(error);
15451580
}
@@ -1624,7 +1659,7 @@ program.command('mint-realm')
16241659
parentOwner: parentOwnerRecord,
16251660
disableMiningChalk: options.disablechalk,
16261661
}, realm, initialOwnerAddress.address, fundingRecord.WIF);
1627-
handleResultLogging(result);
1662+
handleResultLogging(result, true);
16281663
} catch (error) {
16291664
console.log(error);
16301665
}

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "atomicals-js",
3-
"version": "0.1.55",
3+
"version": "0.1.57",
44
"description": "Atomicals Javascript Library and CLI - atomicals.xyz",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -75,6 +75,7 @@
7575
"path": "^0.12.7",
7676
"qrcode-terminal": "^0.12.0",
7777
"rpc-websockets": "^7.5.0",
78+
"success-motivational-quotes": "^1.0.8",
7879
"terminal-image": "^2.0.0",
7980
"tiny-secp256k1": "^2.2.1",
8081
"varuint-bitcoin": "^1.1.2"
@@ -86,4 +87,4 @@
8687
"lib": "lib",
8788
"test": "test"
8889
}
89-
}
90+
}

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -6026,6 +6026,11 @@ strtok3@^6.2.4:
60266026
"@tokenizer/token" "^0.3.0"
60276027
peek-readable "^4.1.0"
60286028

6029+
success-motivational-quotes@^1.0.8:
6030+
version "1.0.8"
6031+
resolved "https://registry.yarnpkg.com/success-motivational-quotes/-/success-motivational-quotes-1.0.8.tgz#4a5c31c4a8f48e4f240e28f12f7f36009555f434"
6032+
integrity sha512-EfLnDThsqCQg+dJoDntdPY/OSDGag8hE+O/cuHnGbOv8pzmrZeiyKn0X00LSTNAHWfNETo0XRvsEXVoxqsNclw==
6033+
60296034
60306035
version "8.1.1"
60316036
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"

0 commit comments

Comments
 (0)