Skip to content

Commit cdae26c

Browse files
author
archx
committed
Add motivational quote and donate prompt to some mints
1 parent e053962 commit cdae26c

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) {
2124
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 });
2252
}
23-
function handleResultLogging(result: any) {
24-
if (!result || !result.success) {
25-
printOperationResult(result, true);
53+
function printFailure(data: any) {
54+
console.log(JSON.stringify(data, null, 2));
55+
}
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
}
@@ -1170,6 +1203,7 @@ program.command('splat')
11701203
console.log(error);
11711204
}
11721205
});
1206+
11731207
/*
11741208
program.command('split')
11751209
.description('Split operation to separate the FT Atomicals at a single UTXOs.')
@@ -1195,6 +1229,7 @@ program.command('split')
11951229
}
11961230
});
11971231
*/
1232+
11981233
program.command('get')
11991234
.description('Get the status of an Atomical')
12001235
.argument('<atomicalAliasOrId>', 'string')
@@ -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.56",
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",
@@ -91,6 +91,7 @@
9191
"path": "^0.12.7",
9292
"qrcode-terminal": "^0.12.0",
9393
"rpc-websockets": "^7.5.0",
94+
"success-motivational-quotes": "^1.0.8",
9495
"terminal-image": "^2.0.0",
9596
"tiny-secp256k1": "^2.2.1",
9697
"varuint-bitcoin": "^1.1.2"
@@ -102,4 +103,4 @@
102103
"lib": "lib",
103104
"test": "test"
104105
}
105-
}
106+
}

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -9275,6 +9275,11 @@ subarg@^1.0.0:
92759275
dependencies:
92769276
minimist "^1.1.0"
92779277

9278+
success-motivational-quotes@^1.0.8:
9279+
version "1.0.8"
9280+
resolved "https://registry.yarnpkg.com/success-motivational-quotes/-/success-motivational-quotes-1.0.8.tgz#4a5c31c4a8f48e4f240e28f12f7f36009555f434"
9281+
integrity sha512-EfLnDThsqCQg+dJoDntdPY/OSDGag8hE+O/cuHnGbOv8pzmrZeiyKn0X00LSTNAHWfNETo0XRvsEXVoxqsNclw==
9282+
92789283
92799284
version "8.1.1"
92809285
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"

0 commit comments

Comments
 (0)