nansen-cli 1.32.0 → 1.32.1
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/rpc-urls.js +3 -0
- package/src/x402.js +14 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.32.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#455](https://github.com/nansen-ai/nansen-cli/pull/455) [`875fabb`](https://github.com/nansen-ai/nansen-cli/commit/875fabb3f86736b03c874904e27a898315ef4bfa) Thanks [@gulshngill](https://github.com/gulshngill)! - Support x402 payments with USDT on BNB Smart Chain (`eip155:56`), which the Nansen API now advertises as a payment option. Payment signing already handled any EVM network generically; this adds BSC to the post-payment balance check with the correct token contract and 18-decimal precision (Base USDC and X Layer USDT0 use 6), plus a `bsc` entry in the shared RPC registry with a `NANSEN_BSC_RPC` override.
|
|
8
|
+
|
|
3
9
|
## 1.32.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/package.json
CHANGED
package/src/rpc-urls.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* Override env vars:
|
|
9
9
|
* NANSEN_EVM_RPC Custom Ethereum RPC (also used as generic EVM fallback)
|
|
10
10
|
* NANSEN_BASE_RPC Custom Base RPC
|
|
11
|
+
* NANSEN_BSC_RPC Custom BNB Smart Chain RPC
|
|
11
12
|
* NANSEN_XLAYER_RPC Custom X Layer RPC
|
|
12
13
|
* NANSEN_SOLANA_RPC Custom Solana RPC
|
|
13
14
|
*
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
|
|
21
22
|
const DEFAULT_EVM_RPC = 'https://eth.public-rpc.com';
|
|
22
23
|
const DEFAULT_BASE_RPC = 'https://mainnet.base.org';
|
|
24
|
+
const DEFAULT_BSC_RPC = 'https://bsc-dataseed.binance.org';
|
|
23
25
|
const DEFAULT_XLAYER_RPC = 'https://rpc.xlayer.tech';
|
|
24
26
|
const DEFAULT_SOLANA_RPC = 'https://api.mainnet-beta.solana.com';
|
|
25
27
|
|
|
@@ -27,6 +29,7 @@ export const CHAIN_RPCS = {
|
|
|
27
29
|
ethereum: process.env.NANSEN_EVM_RPC || DEFAULT_EVM_RPC,
|
|
28
30
|
evm: process.env.NANSEN_EVM_RPC || DEFAULT_EVM_RPC, // generic EVM fallback
|
|
29
31
|
base: process.env.NANSEN_BASE_RPC || process.env.NANSEN_RPC_BASE || DEFAULT_BASE_RPC,
|
|
32
|
+
bsc: process.env.NANSEN_BSC_RPC || DEFAULT_BSC_RPC,
|
|
30
33
|
xlayer: process.env.NANSEN_XLAYER_RPC || DEFAULT_XLAYER_RPC,
|
|
31
34
|
solana: process.env.NANSEN_SOLANA_RPC || DEFAULT_SOLANA_RPC,
|
|
32
35
|
};
|
package/src/x402.js
CHANGED
|
@@ -156,6 +156,17 @@ export async function createPaymentSignature(response, url, options = {}) {
|
|
|
156
156
|
return null;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
/**
|
|
160
|
+
* x402 payment tokens per EVM network, matching the stablecoins the API
|
|
161
|
+
* advertises in 402 `accepts` entries. `decimals` matters: USDT on BNB Smart
|
|
162
|
+
* Chain uses 18 decimals, unlike the 6-decimal tokens on Base and X Layer.
|
|
163
|
+
*/
|
|
164
|
+
export const EVM_X402_TOKENS = {
|
|
165
|
+
'eip155:8453': { token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', rpc: CHAIN_RPCS.base, symbol: 'USDC', decimals: 6 }, // Base USDC
|
|
166
|
+
'eip155:196': { token: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736', rpc: CHAIN_RPCS.xlayer, symbol: 'USDT0', decimals: 6 }, // X Layer USDT0
|
|
167
|
+
'eip155:56': { token: '0x55d398326f99059fF775485246999027B3197955', rpc: CHAIN_RPCS.bsc, symbol: 'USDT', decimals: 18 }, // BSC USDT
|
|
168
|
+
};
|
|
169
|
+
|
|
159
170
|
/**
|
|
160
171
|
* Check stablecoin balance for x402 payment wallet on the given network.
|
|
161
172
|
* Returns `{ balance, symbol }` (USD amount + token symbol) or null if check fails.
|
|
@@ -192,13 +203,9 @@ export async function checkX402Balance(network) {
|
|
|
192
203
|
}
|
|
193
204
|
|
|
194
205
|
if (network.startsWith('eip155:')) {
|
|
195
|
-
// Per-network token + RPC. Both tokens are 6-decimals.
|
|
196
206
|
// Default to Base USDC if the network is unknown so existing wallets keep working.
|
|
197
|
-
const
|
|
198
|
-
'eip155:8453'
|
|
199
|
-
'eip155:196': { token: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736', rpc: CHAIN_RPCS.xlayer, symbol: 'USDT0' }, // X Layer USDT0
|
|
200
|
-
};
|
|
201
|
-
const { token, rpc, symbol } = EVM_NETWORKS[network] || EVM_NETWORKS['eip155:8453'];
|
|
207
|
+
const { token, rpc, symbol, decimals } =
|
|
208
|
+
EVM_X402_TOKENS[network] || EVM_X402_TOKENS['eip155:8453'];
|
|
202
209
|
const addr = walletInfo.evm.replace('0x', '').toLowerCase().padStart(64, '0');
|
|
203
210
|
const resp = await fetch(rpc, {
|
|
204
211
|
method: 'POST',
|
|
@@ -210,7 +217,7 @@ export async function checkX402Balance(network) {
|
|
|
210
217
|
}),
|
|
211
218
|
});
|
|
212
219
|
const data = await resp.json();
|
|
213
|
-
return { balance: parseInt(data.result, 16) /
|
|
220
|
+
return { balance: parseInt(data.result, 16) / 10 ** decimals, symbol };
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
return null;
|