clawmoney 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,18 +60,39 @@ program
|
|
|
60
60
|
if (credResp.ok && credResp.data) {
|
|
61
61
|
console.log(` ${chalk.bold('Credits:')} $${Number(credResp.data.balance_usd ?? 0).toFixed(2)}`);
|
|
62
62
|
}
|
|
63
|
-
// Query
|
|
64
|
-
if
|
|
63
|
+
// Query Base mainnet USDC balance directly via JSON-RPC (no awal
|
|
64
|
+
// dependency — works even if awal wallet bridge is down). Base USDC
|
|
65
|
+
// is 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, balanceOf(address)
|
|
66
|
+
// selector = 0x70a08231.
|
|
67
|
+
if (a.wallet_address && typeof a.wallet_address === 'string') {
|
|
65
68
|
try {
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const walletLower = a.wallet_address.toLowerCase().replace(/^0x/, '').padStart(64, '0');
|
|
70
|
+
const data = '0x70a08231' + walletLower;
|
|
71
|
+
const rpcResp = await fetch('https://mainnet.base.org', {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: { 'content-type': 'application/json' },
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
jsonrpc: '2.0',
|
|
76
|
+
id: 1,
|
|
77
|
+
method: 'eth_call',
|
|
78
|
+
params: [
|
|
79
|
+
{
|
|
80
|
+
to: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
81
|
+
data,
|
|
82
|
+
},
|
|
83
|
+
'latest',
|
|
84
|
+
],
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
const rpcData = (await rpcResp.json());
|
|
88
|
+
if (rpcData.result) {
|
|
89
|
+
const atomic = BigInt(rpcData.result);
|
|
90
|
+
const usdc = Number(atomic) / 1_000_000;
|
|
91
|
+
console.log(` ${chalk.bold('On-chain:')} $${usdc.toFixed(2)} USDC (Base)`);
|
|
71
92
|
}
|
|
72
93
|
}
|
|
73
|
-
catch {
|
|
74
|
-
|
|
94
|
+
catch (err) {
|
|
95
|
+
console.log(` ${chalk.bold('On-chain:')} ${chalk.dim('(fetch failed)')}`);
|
|
75
96
|
}
|
|
76
97
|
}
|
|
77
98
|
console.log('');
|