@bankr/cli 0.1.3 → 0.2.2

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/lib/api.d.ts CHANGED
@@ -61,7 +61,29 @@ export interface TokenBalanceInfo {
61
61
  imgUrl: string;
62
62
  decimals: number;
63
63
  };
64
+ pnl?: {
65
+ realizedPnl: number;
66
+ unrealizedPnl: number;
67
+ totalPnl: number;
68
+ averageEntryPrice: number;
69
+ };
70
+ };
71
+ }
72
+ export interface NftInfo {
73
+ name?: string;
74
+ tokenId: string;
75
+ collection?: {
76
+ name: string;
77
+ address: string;
78
+ nftStandard?: string;
64
79
  };
80
+ chain: string;
81
+ chainName?: string;
82
+ image?: {
83
+ thumbnail?: string;
84
+ original?: string;
85
+ };
86
+ openSeaUrl?: string;
65
87
  }
66
88
  export interface ChainBalanceInfo {
67
89
  nativeBalance: string;
@@ -69,13 +91,23 @@ export interface ChainBalanceInfo {
69
91
  tokenBalances: TokenBalanceInfo[];
70
92
  total: string;
71
93
  }
72
- export interface BalancesResponse {
94
+ export interface PortfolioResponse {
73
95
  success: boolean;
74
96
  evmAddress: string;
75
97
  solAddress?: string;
76
98
  balances: Record<string, ChainBalanceInfo>;
99
+ nfts?: NftInfo[];
100
+ }
101
+ export interface PortfolioOptions {
102
+ chains?: string[];
103
+ showLowValueTokens?: boolean;
104
+ include?: string[];
77
105
  }
78
- export declare function getBalances(chains?: string[]): Promise<BalancesResponse>;
106
+ export declare function getPortfolio(opts?: PortfolioOptions): Promise<PortfolioResponse>;
107
+ /** @deprecated Use PortfolioResponse instead */
108
+ export type BalancesResponse = PortfolioResponse;
109
+ /** @deprecated Use getPortfolio instead */
110
+ export declare const getBalances: (chains?: string[], showLowValueTokens?: boolean) => Promise<PortfolioResponse>;
79
111
  export declare function pollJob(jobId: string, opts?: {
80
112
  interval?: number;
81
113
  maxAttempts?: number;
@@ -324,5 +356,30 @@ export declare function addProjectUpdate(data: {
324
356
  title: string;
325
357
  content: string;
326
358
  }): Promise<AgentProfileResponse>;
359
+ export interface TokenSearchResult {
360
+ address: string;
361
+ symbol: string;
362
+ name: string;
363
+ decimals: number;
364
+ logoURI?: string;
365
+ priceUsd?: number;
366
+ }
367
+ export interface TokenSearchResponse {
368
+ tokens: TokenSearchResult[];
369
+ }
370
+ export declare function searchTokens(query: string, chainId?: number): Promise<TokenSearchResponse>;
371
+ export interface TransferRequest {
372
+ tokenAddress: string;
373
+ recipientAddress: string;
374
+ amount: string;
375
+ isNativeToken: boolean;
376
+ chain?: string;
377
+ }
378
+ export interface TransferResponse {
379
+ success: boolean;
380
+ txHash?: string;
381
+ error?: string;
382
+ }
383
+ export declare function transfer(request: TransferRequest): Promise<TransferResponse>;
327
384
  export declare function buildPublicClaimTxs(beneficiaryAddress: string, tokenAddresses: string[]): Promise<BuildClaimResponse>;
328
385
  //# sourceMappingURL=api.d.ts.map
package/dist/lib/api.js CHANGED
@@ -62,18 +62,25 @@ export async function validateApiKey() {
62
62
  }
63
63
  }
64
64
  export async function getUserInfo() {
65
- const res = await fetch(`${getApiUrl()}/agent/me`, {
65
+ const res = await fetch(`${getApiUrl()}/wallet/me`, {
66
66
  headers: authHeaders(),
67
67
  });
68
68
  return handleResponse(res);
69
69
  }
70
- export async function getBalances(chains) {
71
- const params = chains?.length ? `?chains=${chains.join(",")}` : "";
72
- const res = await fetch(`${getApiUrl()}/agent/balances${params}`, {
73
- headers: authHeaders(),
74
- });
70
+ export async function getPortfolio(opts = {}) {
71
+ const query = new URLSearchParams();
72
+ if (opts.chains?.length)
73
+ query.set("chains", opts.chains.join(","));
74
+ if (opts.showLowValueTokens)
75
+ query.set("showLowValueTokens", "true");
76
+ if (opts.include?.length)
77
+ query.set("include", opts.include.join(","));
78
+ const qs = query.toString();
79
+ const res = await fetch(`${getApiUrl()}/wallet/portfolio${qs ? `?${qs}` : ""}`, { headers: authHeaders() });
75
80
  return handleResponse(res);
76
81
  }
82
+ /** @deprecated Use getPortfolio instead */
83
+ export const getBalances = (chains, showLowValueTokens) => getPortfolio({ chains, showLowValueTokens });
77
84
  export async function pollJob(jobId, opts = {}) {
78
85
  const { interval = 2000, maxAttempts = 150, onStatus } = opts;
79
86
  let attempts = 0;
@@ -89,7 +96,7 @@ export async function pollJob(jobId, opts = {}) {
89
96
  throw new Error(`Polling timed out after ${maxAttempts} attempts`);
90
97
  }
91
98
  export async function sign(request) {
92
- const res = await fetch(`${getApiUrl()}/agent/sign`, {
99
+ const res = await fetch(`${getApiUrl()}/wallet/sign`, {
93
100
  method: "POST",
94
101
  headers: authHeaders(),
95
102
  body: JSON.stringify(request),
@@ -97,7 +104,7 @@ export async function sign(request) {
97
104
  return handleResponse(res);
98
105
  }
99
106
  export async function submit(request) {
100
- const res = await fetch(`${getApiUrl()}/agent/submit`, {
107
+ const res = await fetch(`${getApiUrl()}/wallet/submit`, {
101
108
  method: "POST",
102
109
  headers: authHeaders(),
103
110
  body: JSON.stringify(request),
@@ -254,6 +261,25 @@ export async function addProjectUpdate(data) {
254
261
  });
255
262
  return handleResponse(res);
256
263
  }
264
+ export async function searchTokens(query, chainId) {
265
+ const params = new URLSearchParams({ query });
266
+ if (chainId)
267
+ params.set("chainId", String(chainId));
268
+ const res = await fetch(`${getApiUrl()}/tokens/search?${params}`, {
269
+ headers: {
270
+ "User-Agent": CLI_USER_AGENT,
271
+ },
272
+ });
273
+ return handleResponse(res);
274
+ }
275
+ export async function transfer(request) {
276
+ const res = await fetch(`${getApiUrl()}/wallet/transfer`, {
277
+ method: "POST",
278
+ headers: authHeaders(),
279
+ body: JSON.stringify(request),
280
+ });
281
+ return handleResponse(res);
282
+ }
257
283
  export async function buildPublicClaimTxs(beneficiaryAddress, tokenAddresses) {
258
284
  const res = await fetch(`${getApiUrl()}/public/doppler/build-claim`, {
259
285
  method: "POST",
@@ -0,0 +1,5 @@
1
+ export declare const CHAIN_LABELS: Record<string, string>;
2
+ export declare const VALID_CHAINS: Set<string>;
3
+ export declare const CHAIN_IDS: Record<string, number>;
4
+ export declare const NATIVE_SYMBOLS: Record<string, string>;
5
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1,39 @@
1
+ export const CHAIN_LABELS = {
2
+ base: "Base",
3
+ polygon: "Polygon",
4
+ mainnet: "Ethereum",
5
+ unichain: "Unichain",
6
+ worldchain: "World Chain",
7
+ arbitrum: "Arbitrum",
8
+ bnb: "BNB Chain",
9
+ solana: "Solana",
10
+ };
11
+ export const VALID_CHAINS = new Set([
12
+ "base",
13
+ "polygon",
14
+ "mainnet",
15
+ "unichain",
16
+ "worldchain",
17
+ "arbitrum",
18
+ "bnb",
19
+ "solana",
20
+ ]);
21
+ export const CHAIN_IDS = {
22
+ base: 8453,
23
+ mainnet: 1,
24
+ polygon: 137,
25
+ unichain: 130,
26
+ worldchain: 480,
27
+ arbitrum: 42161,
28
+ bnb: 56,
29
+ };
30
+ export const NATIVE_SYMBOLS = {
31
+ base: "ETH",
32
+ mainnet: "ETH",
33
+ unichain: "ETH",
34
+ worldchain: "ETH",
35
+ arbitrum: "ETH",
36
+ polygon: "POL",
37
+ bnb: "BNB",
38
+ };
39
+ //# sourceMappingURL=chains.js.map
@@ -4,6 +4,8 @@ export declare const fmt: {
4
4
  readonly brand: import("chalk").ChalkInstance;
5
5
  readonly brandBold: import("chalk").ChalkInstance;
6
6
  readonly dim: import("chalk").ChalkInstance;
7
+ readonly success: import("chalk").ChalkInstance;
8
+ readonly warn: import("chalk").ChalkInstance;
7
9
  };
8
10
  export declare const bankrTheme: {
9
11
  prefix: string;
@@ -29,5 +31,7 @@ export declare function keyValue(key: string, value: string): void;
29
31
  export declare function spinner(text: string): Ora;
30
32
  export declare function maskApiKey(key: string): string;
31
33
  export declare function formatDuration(ms: number): string;
34
+ export declare function formatUsd(value: string | number): string;
35
+ export declare function formatBalance(value: string | number, decimals?: number): string;
32
36
  export declare function formatStatus(status: string): string;
33
37
  //# sourceMappingURL=output.d.ts.map
@@ -8,6 +8,8 @@ export const fmt = {
8
8
  brand: brandColor,
9
9
  brandBold: brandColorBold,
10
10
  dim: chalk.dim,
11
+ success: chalk.green,
12
+ warn: chalk.yellow,
11
13
  };
12
14
  export const bankrTheme = {
13
15
  prefix: brandColor("▸"),
@@ -66,6 +68,23 @@ export function formatDuration(ms) {
66
68
  return `${ms}ms`;
67
69
  return `${(ms / 1000).toFixed(1)}s`;
68
70
  }
71
+ export function formatUsd(value) {
72
+ const num = typeof value === "string" ? parseFloat(value) : value;
73
+ if (isNaN(num) || num === 0)
74
+ return chalk.dim("$0.00");
75
+ return `$${num.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
76
+ }
77
+ export function formatBalance(value, decimals = 6) {
78
+ const num = typeof value === "string" ? parseFloat(value) : value;
79
+ if (isNaN(num) || num === 0)
80
+ return "0";
81
+ if (num < 0.000001)
82
+ return "<0.000001";
83
+ return num.toLocaleString("en-US", {
84
+ minimumFractionDigits: 0,
85
+ maximumFractionDigits: decimals,
86
+ });
87
+ }
69
88
  export function formatStatus(status) {
70
89
  switch (status) {
71
90
  case "completed":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bankr/cli",
3
- "version": "0.1.3",
3
+ "version": "0.2.2",
4
4
  "description": "Official CLI for the Bankr AI agent platform",
5
5
  "type": "module",
6
6
  "bin": {