chain-insights 0.2.21 → 0.2.24

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.
Files changed (38) hide show
  1. package/README.md +2 -1
  2. package/dist/{capabilities-Bm0JDbV7.cjs → capabilities-B4hvro_I.cjs} +1 -1
  3. package/dist/{capabilities-BShqspb-.mjs → capabilities-mXm_rCe8.mjs} +2 -2
  4. package/dist/{capabilities-BShqspb-.mjs.map → capabilities-mXm_rCe8.mjs.map} +1 -1
  5. package/dist/cli.cjs +32 -16
  6. package/dist/cli.mjs +32 -16
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/{client-DPc2eyVN.cjs → client-BYnFGA0y.cjs} +45 -10
  9. package/dist/{client-D4_hd4AP.mjs → client-Dl-uHrh1.mjs} +46 -11
  10. package/dist/client-Dl-uHrh1.mjs.map +1 -0
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.mts.map +1 -1
  14. package/dist/index.mjs +2 -2
  15. package/dist/{init-4tn7jfhN.mjs → init-CB_ga4_8.mjs} +2 -2
  16. package/dist/init-CB_ga4_8.mjs.map +1 -0
  17. package/dist/{init-TCQY5RDJ.cjs → init-jhOZ_RvC.cjs} +1 -1
  18. package/dist/mcp-proxy.cjs +8 -8
  19. package/dist/mcp-proxy.mjs +8 -8
  20. package/dist/mcp-proxy.mjs.map +1 -1
  21. package/dist/{public-tools-BC1fi0DV.cjs → public-tools-q4NMdmDX.cjs} +227 -10
  22. package/dist/{public-tools-B13J0MJZ.mjs → public-tools-w7En2m3q.mjs} +228 -11
  23. package/dist/public-tools-w7En2m3q.mjs.map +1 -0
  24. package/dist/{runner-DIs04IhN.mjs → runner-BBH5Ks6q.mjs} +2 -2
  25. package/dist/{runner-DIs04IhN.mjs.map → runner-BBH5Ks6q.mjs.map} +1 -1
  26. package/dist/{runner-ZYowxCVl.cjs → runner-e9slg6R2.cjs} +1 -1
  27. package/dist/tools-D6RBAhSX.mjs +298 -0
  28. package/dist/tools-D6RBAhSX.mjs.map +1 -0
  29. package/dist/tools-UH5hRXYG.cjs +343 -0
  30. package/dist/topup-server-BJgVw6Jt.mjs.map +1 -1
  31. package/docs/mcp-proxy.md +4 -2
  32. package/package.json +1 -1
  33. package/dist/client-D4_hd4AP.mjs.map +0 -1
  34. package/dist/init-4tn7jfhN.mjs.map +0 -1
  35. package/dist/public-tools-B13J0MJZ.mjs.map +0 -1
  36. package/dist/tools-DY8h0WbE.cjs +0 -139
  37. package/dist/tools-Py6SXg6J.mjs +0 -100
  38. package/dist/tools-Py6SXg6J.mjs.map +0 -1
@@ -1,139 +0,0 @@
1
- const require_chunk = require("./chunk-DakpK96I.cjs");
2
- const require_wallet = require("./wallet-TAlNMvIM.cjs");
3
- let viem_accounts = require("viem/accounts");
4
- let viem = require("viem");
5
- let viem_chains = require("viem/chains");
6
- //#region src/wallet/tools.ts
7
- var tools_exports = /* @__PURE__ */ require_chunk.__exportAll({
8
- BASE_CHAIN_ID: () => BASE_CHAIN_ID,
9
- DEFAULT_BASE_RPC_URL: () => DEFAULT_BASE_RPC_URL,
10
- PUBLIC_BASE_RPC_URLS: () => PUBLIC_BASE_RPC_URLS,
11
- USDC_ADDRESS: () => USDC_ADDRESS,
12
- buildTopupInfo: () => buildTopupInfo,
13
- formatWalletBalance: () => formatWalletBalance,
14
- getBalanceEth: () => getBalanceEth,
15
- getBalanceUsdc: () => getBalanceUsdc,
16
- getWalletAccount: () => getWalletAccount,
17
- getWalletBalanceText: () => getWalletBalanceText
18
- });
19
- const BASE_CHAIN_ID = 8453;
20
- const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
21
- const DEFAULT_BASE_RPC_URL = "https://mainnet.base.org";
22
- const PUBLIC_BASE_RPC_URLS = [
23
- DEFAULT_BASE_RPC_URL,
24
- "https://base-rpc.publicnode.com",
25
- "https://base.drpc.org",
26
- "https://1rpc.io/base"
27
- ];
28
- const USDC_ABI = [{
29
- type: "function",
30
- name: "balanceOf",
31
- stateMutability: "view",
32
- inputs: [{
33
- name: "account",
34
- type: "address"
35
- }],
36
- outputs: [{
37
- name: "",
38
- type: "uint256"
39
- }]
40
- }];
41
- async function getWalletAccount() {
42
- const privateKey = require_wallet.normalizeWalletPrivateKey(await require_wallet.decryptKey());
43
- return {
44
- address: (0, viem_accounts.privateKeyToAccount)(privateKey).address,
45
- privateKey
46
- };
47
- }
48
- async function getBalanceUsdc(address, rpcUrl = process.env["BASE_RPC_URL"]) {
49
- const rpcUrls = [...rpcUrl ? [rpcUrl] : [], ...PUBLIC_BASE_RPC_URLS.filter((fallbackUrl) => fallbackUrl !== rpcUrl)];
50
- for (const url of rpcUrls) try {
51
- return (0, viem.formatUnits)(await (0, viem.createPublicClient)({
52
- chain: viem_chains.base,
53
- transport: (0, viem.http)(url)
54
- }).readContract({
55
- address: USDC_ADDRESS,
56
- abi: USDC_ABI,
57
- functionName: "balanceOf",
58
- args: [address]
59
- }), 6);
60
- } catch {}
61
- return "unknown";
62
- }
63
- async function getBalanceEth(address, rpcUrl = process.env["BASE_RPC_URL"]) {
64
- const rpcUrls = [...rpcUrl ? [rpcUrl] : [], ...PUBLIC_BASE_RPC_URLS.filter((fallbackUrl) => fallbackUrl !== rpcUrl)];
65
- for (const url of rpcUrls) try {
66
- return (0, viem.formatEther)(await (0, viem.createPublicClient)({
67
- chain: viem_chains.base,
68
- transport: (0, viem.http)(url)
69
- }).getBalance({ address }));
70
- } catch {}
71
- return "unknown";
72
- }
73
- function formatWalletBalance(address, balanceUsdc, balanceEth) {
74
- return [
75
- `Balance: ${balanceUsdc} USDC`,
76
- balanceEth === void 0 ? void 0 : `Gas: ${balanceEth} ETH on Base`,
77
- "Network: Base",
78
- "Base ETH is required for one-time USDC Permit2 approval gas.",
79
- `Address: ${address}`
80
- ].filter(Boolean).join("\n");
81
- }
82
- async function getWalletBalanceText(account) {
83
- const wallet = account ?? await getWalletAccount();
84
- const [balanceUsdc, balanceEth] = await Promise.all([getBalanceUsdc(wallet.address), getBalanceEth(wallet.address)]);
85
- return formatWalletBalance(wallet.address, balanceUsdc, balanceEth);
86
- }
87
- function buildTopupInfo(address, topupUrl) {
88
- return {
89
- wallet_address: address,
90
- network: "Base",
91
- chain_id: BASE_CHAIN_ID,
92
- token: "USDC",
93
- token_contract: USDC_ADDRESS,
94
- ...topupUrl ? { topup_url: topupUrl } : {}
95
- };
96
- }
97
- //#endregion
98
- Object.defineProperty(exports, "buildTopupInfo", {
99
- enumerable: true,
100
- get: function() {
101
- return buildTopupInfo;
102
- }
103
- });
104
- Object.defineProperty(exports, "formatWalletBalance", {
105
- enumerable: true,
106
- get: function() {
107
- return formatWalletBalance;
108
- }
109
- });
110
- Object.defineProperty(exports, "getBalanceEth", {
111
- enumerable: true,
112
- get: function() {
113
- return getBalanceEth;
114
- }
115
- });
116
- Object.defineProperty(exports, "getBalanceUsdc", {
117
- enumerable: true,
118
- get: function() {
119
- return getBalanceUsdc;
120
- }
121
- });
122
- Object.defineProperty(exports, "getWalletAccount", {
123
- enumerable: true,
124
- get: function() {
125
- return getWalletAccount;
126
- }
127
- });
128
- Object.defineProperty(exports, "getWalletBalanceText", {
129
- enumerable: true,
130
- get: function() {
131
- return getWalletBalanceText;
132
- }
133
- });
134
- Object.defineProperty(exports, "tools_exports", {
135
- enumerable: true,
136
- get: function() {
137
- return tools_exports;
138
- }
139
- });
@@ -1,100 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { i as normalizeWalletPrivateKey, t as decryptKey } from "./wallet-D8IqFRKY.mjs";
3
- import { privateKeyToAccount } from "viem/accounts";
4
- import { createPublicClient, formatEther, formatUnits, http } from "viem";
5
- import { base } from "viem/chains";
6
- //#region src/wallet/tools.ts
7
- var tools_exports = /* @__PURE__ */ __exportAll({
8
- BASE_CHAIN_ID: () => BASE_CHAIN_ID,
9
- DEFAULT_BASE_RPC_URL: () => DEFAULT_BASE_RPC_URL,
10
- PUBLIC_BASE_RPC_URLS: () => PUBLIC_BASE_RPC_URLS,
11
- USDC_ADDRESS: () => USDC_ADDRESS,
12
- buildTopupInfo: () => buildTopupInfo,
13
- formatWalletBalance: () => formatWalletBalance,
14
- getBalanceEth: () => getBalanceEth,
15
- getBalanceUsdc: () => getBalanceUsdc,
16
- getWalletAccount: () => getWalletAccount,
17
- getWalletBalanceText: () => getWalletBalanceText
18
- });
19
- const BASE_CHAIN_ID = 8453;
20
- const USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
21
- const DEFAULT_BASE_RPC_URL = "https://mainnet.base.org";
22
- const PUBLIC_BASE_RPC_URLS = [
23
- DEFAULT_BASE_RPC_URL,
24
- "https://base-rpc.publicnode.com",
25
- "https://base.drpc.org",
26
- "https://1rpc.io/base"
27
- ];
28
- const USDC_ABI = [{
29
- type: "function",
30
- name: "balanceOf",
31
- stateMutability: "view",
32
- inputs: [{
33
- name: "account",
34
- type: "address"
35
- }],
36
- outputs: [{
37
- name: "",
38
- type: "uint256"
39
- }]
40
- }];
41
- async function getWalletAccount() {
42
- const privateKey = normalizeWalletPrivateKey(await decryptKey());
43
- return {
44
- address: privateKeyToAccount(privateKey).address,
45
- privateKey
46
- };
47
- }
48
- async function getBalanceUsdc(address, rpcUrl = process.env["BASE_RPC_URL"]) {
49
- const rpcUrls = [...rpcUrl ? [rpcUrl] : [], ...PUBLIC_BASE_RPC_URLS.filter((fallbackUrl) => fallbackUrl !== rpcUrl)];
50
- for (const url of rpcUrls) try {
51
- return formatUnits(await createPublicClient({
52
- chain: base,
53
- transport: http(url)
54
- }).readContract({
55
- address: USDC_ADDRESS,
56
- abi: USDC_ABI,
57
- functionName: "balanceOf",
58
- args: [address]
59
- }), 6);
60
- } catch {}
61
- return "unknown";
62
- }
63
- async function getBalanceEth(address, rpcUrl = process.env["BASE_RPC_URL"]) {
64
- const rpcUrls = [...rpcUrl ? [rpcUrl] : [], ...PUBLIC_BASE_RPC_URLS.filter((fallbackUrl) => fallbackUrl !== rpcUrl)];
65
- for (const url of rpcUrls) try {
66
- return formatEther(await createPublicClient({
67
- chain: base,
68
- transport: http(url)
69
- }).getBalance({ address }));
70
- } catch {}
71
- return "unknown";
72
- }
73
- function formatWalletBalance(address, balanceUsdc, balanceEth) {
74
- return [
75
- `Balance: ${balanceUsdc} USDC`,
76
- balanceEth === void 0 ? void 0 : `Gas: ${balanceEth} ETH on Base`,
77
- "Network: Base",
78
- "Base ETH is required for one-time USDC Permit2 approval gas.",
79
- `Address: ${address}`
80
- ].filter(Boolean).join("\n");
81
- }
82
- async function getWalletBalanceText(account) {
83
- const wallet = account ?? await getWalletAccount();
84
- const [balanceUsdc, balanceEth] = await Promise.all([getBalanceUsdc(wallet.address), getBalanceEth(wallet.address)]);
85
- return formatWalletBalance(wallet.address, balanceUsdc, balanceEth);
86
- }
87
- function buildTopupInfo(address, topupUrl) {
88
- return {
89
- wallet_address: address,
90
- network: "Base",
91
- chain_id: BASE_CHAIN_ID,
92
- token: "USDC",
93
- token_contract: USDC_ADDRESS,
94
- ...topupUrl ? { topup_url: topupUrl } : {}
95
- };
96
- }
97
- //#endregion
98
- export { getWalletAccount as a, getBalanceUsdc as i, formatWalletBalance as n, getWalletBalanceText as o, getBalanceEth as r, tools_exports as s, buildTopupInfo as t };
99
-
100
- //# sourceMappingURL=tools-Py6SXg6J.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools-Py6SXg6J.mjs","names":[],"sources":["../src/wallet/tools.ts"],"sourcesContent":["import { createPublicClient, formatEther, formatUnits, http, type Address, type Hex } from 'viem'\nimport { base } from 'viem/chains'\nimport { privateKeyToAccount } from 'viem/accounts'\nimport { decryptKey, normalizeWalletPrivateKey } from './index.js'\n\nexport const BASE_CHAIN_ID = 8453\nexport const USDC_ADDRESS = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' as const\nexport const DEFAULT_BASE_RPC_URL = 'https://mainnet.base.org'\nexport const PUBLIC_BASE_RPC_URLS = [\n DEFAULT_BASE_RPC_URL,\n 'https://base-rpc.publicnode.com',\n 'https://base.drpc.org',\n 'https://1rpc.io/base',\n] as const\n\nconst USDC_ABI = [\n {\n type: 'function',\n name: 'balanceOf',\n stateMutability: 'view',\n inputs: [{ name: 'account', type: 'address' }],\n outputs: [{ name: '', type: 'uint256' }],\n },\n] as const\n\nexport interface PaymentWalletAccount {\n address: Address\n privateKey: Hex\n}\n\nexport interface TopupInfo {\n wallet_address: string\n network: 'Base'\n chain_id: typeof BASE_CHAIN_ID\n token: 'USDC'\n token_contract: typeof USDC_ADDRESS\n topup_url?: string\n}\n\nexport async function getWalletAccount(): Promise<PaymentWalletAccount> {\n const privateKey = normalizeWalletPrivateKey(await decryptKey()) as Hex\n const account = privateKeyToAccount(privateKey)\n return { address: account.address, privateKey }\n}\n\nexport async function getBalanceUsdc(\n address: Address | string,\n rpcUrl = process.env['BASE_RPC_URL'],\n): Promise<string> {\n const rpcUrls = [\n ...(rpcUrl ? [rpcUrl] : []),\n ...PUBLIC_BASE_RPC_URLS.filter((fallbackUrl) => fallbackUrl !== rpcUrl),\n ]\n\n for (const url of rpcUrls) {\n try {\n const client = createPublicClient({\n chain: base,\n transport: http(url),\n })\n const balance = await client.readContract({\n address: USDC_ADDRESS,\n abi: USDC_ABI,\n functionName: 'balanceOf',\n args: [address as Address],\n })\n return formatUnits(balance, 6)\n } catch {\n // Try the next public Base RPC endpoint.\n }\n }\n\n return 'unknown'\n}\n\nexport async function getBalanceEth(\n address: Address | string,\n rpcUrl = process.env['BASE_RPC_URL'],\n): Promise<string> {\n const rpcUrls = [\n ...(rpcUrl ? [rpcUrl] : []),\n ...PUBLIC_BASE_RPC_URLS.filter((fallbackUrl) => fallbackUrl !== rpcUrl),\n ]\n\n for (const url of rpcUrls) {\n try {\n const client = createPublicClient({\n chain: base,\n transport: http(url),\n })\n const balance = await client.getBalance({ address: address as Address })\n return formatEther(balance)\n } catch {\n // Try the next public Base RPC endpoint.\n }\n }\n\n return 'unknown'\n}\n\nexport function formatWalletBalance(address: string, balanceUsdc: string, balanceEth?: string): string {\n return [\n `Balance: ${balanceUsdc} USDC`,\n balanceEth === undefined ? undefined : `Gas: ${balanceEth} ETH on Base`,\n 'Network: Base',\n 'Base ETH is required for one-time USDC Permit2 approval gas.',\n `Address: ${address}`,\n ].filter(Boolean).join('\\n')\n}\n\nexport async function getWalletBalanceText(account?: PaymentWalletAccount): Promise<string> {\n const wallet = account ?? await getWalletAccount()\n const [balanceUsdc, balanceEth] = await Promise.all([\n getBalanceUsdc(wallet.address),\n getBalanceEth(wallet.address),\n ])\n return formatWalletBalance(wallet.address, balanceUsdc, balanceEth)\n}\n\nexport function buildTopupInfo(address: string, topupUrl?: string): TopupInfo {\n return {\n wallet_address: address,\n network: 'Base',\n chain_id: BASE_CHAIN_ID,\n token: 'USDC',\n token_contract: USDC_ADDRESS,\n ...(topupUrl ? { topup_url: topupUrl } : {}),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,MAAa,gBAAgB;AAC7B,MAAa,eAAe;AAC5B,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;AACF;AAEA,MAAM,WAAW,CACf;CACE,MAAM;CACN,MAAM;CACN,iBAAiB;CACjB,QAAQ,CAAC;EAAE,MAAM;EAAW,MAAM;CAAU,CAAC;CAC7C,SAAS,CAAC;EAAE,MAAM;EAAI,MAAM;CAAU,CAAC;AACzC,CACF;AAgBA,eAAsB,mBAAkD;CACtE,MAAM,aAAa,0BAA0B,MAAM,WAAW,CAAC;CAE/D,OAAO;EAAE,SADO,oBAAoB,UACZ,EAAE;EAAS;CAAW;AAChD;AAEA,eAAsB,eACpB,SACA,SAAS,QAAQ,IAAI,iBACJ;CACjB,MAAM,UAAU,CACd,GAAI,SAAS,CAAC,MAAM,IAAI,CAAC,GACzB,GAAG,qBAAqB,QAAQ,gBAAgB,gBAAgB,MAAM,CACxE;CAEA,KAAK,MAAM,OAAO,SAChB,IAAI;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