@t2000/sdk 0.44.0 → 0.46.0

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.
@@ -1,7 +1,7 @@
1
1
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
4
- import { G as GasMethod } from './types-DxNs-mLT.js';
4
+ import { G as GasMethod } from './types-DfwfwsAN.js';
5
5
 
6
6
  /**
7
7
  * Abstract signing interface that decouples the SDK from any specific
@@ -241,6 +241,76 @@ declare const GAS_RESERVE_MIN = 0.05;
241
241
  declare function validateAddress(address: string): string;
242
242
  declare function truncateAddress(address: string): string;
243
243
 
244
+ /**
245
+ * Shared transaction classifier.
246
+ *
247
+ * Consumed by both the SDK's `parseTxRecord` (production agent path) and
248
+ * the engine's `transaction_history` tool (cold-start RPC path). Keeping
249
+ * a single source of truth here prevents the two paths from drifting —
250
+ * see v1.5.3 regression where the SDK path was emitting `action:
251
+ * 'transaction'` (rendered as "On-chain") while the engine path was
252
+ * already producing fine-grained labels.
253
+ */
254
+ /**
255
+ * Coarse action bucket — one of `'send' | 'lending' | 'swap' |
256
+ * 'transaction'`. Used by the ACI `action` filter on the
257
+ * `transaction_history` tool. STABLE: downstream queries depend on
258
+ * exactly these values.
259
+ */
260
+ declare const KNOWN_TARGETS: readonly [RegExp, string][];
261
+ /**
262
+ * Finer-grained display labels — derived from MoveCall function names.
263
+ * The card renders `label ?? action`, so when this map matches we get
264
+ * "Deposit" / "Withdraw" / "Borrow" / "Repay" / "Payment link" instead
265
+ * of the generic "Lending" or "Transaction".
266
+ *
267
+ * Order matters: more specific patterns first. Each entry is
268
+ * (regex, label) where the regex is matched against the
269
+ * fully-qualified MoveCall target `pkg::module::function`.
270
+ */
271
+ declare const LABEL_PATTERNS: readonly [RegExp, string][];
272
+ interface ClassifyBalanceChange {
273
+ owner: {
274
+ AddressOwner?: string;
275
+ } | string;
276
+ coinType: string;
277
+ amount: string;
278
+ }
279
+ declare function classifyAction(targets: string[], commandTypes: string[]): string;
280
+ /**
281
+ * Fallback label when no `LABEL_PATTERNS` match.
282
+ *
283
+ * Returns the first MoveCall's *module* name (e.g. "navi", "cetus",
284
+ * "spam") so the card shows something more useful than the literal
285
+ * word "transaction". When no MoveCall exists, returns 'on-chain'
286
+ * instead — strictly more informative than "transaction".
287
+ */
288
+ declare function fallbackLabel(targets: string[]): string;
289
+ declare function classifyLabel(targets: string[], commandTypes: string[]): string;
290
+ /**
291
+ * Balance-direction tiebreaker for ambiguous lending calls.
292
+ *
293
+ * Many lending modules expose generic entry points (NAVI's bundled
294
+ * flash actions, `lending_core::*::entry_*`, etc.) that don't carry
295
+ * a `deposit`/`withdraw`/`borrow`/`repay` keyword in the function
296
+ * name. When `classifyLabel` falls back to a bare module name like
297
+ * `"lending"` for a known lending tx, infer direction from the user's
298
+ * non-SUI balance change:
299
+ * - net outflow of the supplied asset → deposit (also covers repay,
300
+ * but repay-without-keyword is essentially never emitted).
301
+ * - net inflow of the supplied asset → withdraw (also covers borrow).
302
+ * SUI is excluded so gas-only transactions don't get mislabeled.
303
+ *
304
+ * If `LABEL_PATTERNS` matched a specific keyword, the existing label is
305
+ * returned unchanged.
306
+ */
307
+ declare function refineLendingLabel(currentAction: string, currentLabel: string, moveCallTargets: string[], changes: ClassifyBalanceChange[], address: string): string;
308
+ interface ClassifyResult {
309
+ action: string;
310
+ label: string;
311
+ }
312
+ declare function classifyTransaction(moveCallTargets: string[], commandTypes: string[], balanceChanges: ClassifyBalanceChange[], address: string): ClassifyResult;
313
+
244
314
  declare function mistToSui(mist: bigint): number;
245
315
  declare function suiToMist(sui: number): bigint;
246
316
  declare function usdcToRaw(amount: number): bigint;
@@ -369,4 +439,4 @@ declare const IKA_TYPE: string;
369
439
  declare const LOFI_TYPE: string;
370
440
  declare const MANIFEST_TYPE: string;
371
441
 
372
- export { formatAssetAmount as $, ALL_NAVI_ASSETS as A, BPS_DENOMINATOR as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, USDSUI_TYPE as H, IKA_TYPE as I, USDT_TYPE as J, KeypairSigner as K, LOFI_TYPE as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, WBTC_TYPE as Q, ZkLoginSigner as R, STABLE_ASSETS as S, T2000Error as T, USDC_DECIMALS as U, addCollectFeeToTx as V, WAL_TYPE as W, calculateFee as X, executeAutoTopUp as Y, type ZkLoginProof as Z, executeWithGas as _, type AutoTopUpResult as a, formatSui as a0, formatUsd as a1, getDecimals as a2, getDecimalsForCoinType as a3, getGasStatus as a4, getTier as a5, isSupported as a6, isTier1 as a7, isTier2 as a8, mapMoveAbortCode as a9, mapWalletError as aa, mistToSui as ab, rawToStable as ac, rawToUsdc as ad, resolveSymbol as ae, resolveTokenType as af, shouldAutoTopUp as ag, stableToRaw as ah, suiToMist as ai, truncateAddress as aj, usdcToRaw as ak, validateAddress as al, SafeguardEnforcer as am, BORROW_FEE_BPS as an, CETUS_USDC_SUI_POOL as ao, OPERATION_ASSETS as ap, type Operation as aq, SAVE_FEE_BPS as ar, assertAllowedAsset as as, isAllowedAsset as at, simulateTransaction as au, throwIfSimulationFailed as av, COIN_REGISTRY as b, type CoinMeta as c, DEFAULT_SAFEGUARD_CONFIG as d, type GasExecutionResult as e, type GasRequestType as f, type GasSponsorResponse as g, type GasStatusResponse as h, MIST_PER_SUI as i, SUI_DECIMALS as j, SUI_TYPE as k, SUPPORTED_ASSETS as l, type SafeguardConfig as m, SafeguardError as n, type SafeguardErrorDetails as o, type SafeguardRule as p, type SimulationResult as q, type StableAsset as r, type SupportedAsset as s, type T2000ErrorCode as t, type T2000ErrorData as u, TOKEN_MAP as v, type TransactionSigner as w, type TxMetadata as x, USDC_TYPE as y, USDE_TYPE as z };
442
+ export { addCollectFeeToTx as $, ALL_NAVI_ASSETS as A, BPS_DENOMINATOR as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type TransactionSigner as H, IKA_TYPE as I, type TxMetadata as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, USDC_TYPE as Q, USDE_TYPE as R, STABLE_ASSETS as S, T2000Error as T, USDC_DECIMALS as U, USDSUI_TYPE as V, USDT_TYPE as W, WAL_TYPE as X, WBTC_TYPE as Y, type ZkLoginProof as Z, ZkLoginSigner as _, type AutoTopUpResult as a, calculateFee as a0, classifyAction as a1, classifyLabel as a2, classifyTransaction as a3, executeAutoTopUp as a4, executeWithGas as a5, fallbackLabel as a6, formatAssetAmount as a7, formatSui as a8, formatUsd as a9, SAVE_FEE_BPS as aA, assertAllowedAsset as aB, isAllowedAsset as aC, simulateTransaction as aD, throwIfSimulationFailed as aE, getDecimals as aa, getDecimalsForCoinType as ab, getGasStatus as ac, getTier as ad, isSupported as ae, isTier1 as af, isTier2 as ag, mapMoveAbortCode as ah, mapWalletError as ai, mistToSui as aj, rawToStable as ak, rawToUsdc as al, refineLendingLabel as am, resolveSymbol as an, resolveTokenType as ao, shouldAutoTopUp as ap, stableToRaw as aq, suiToMist as ar, truncateAddress as as, usdcToRaw as at, validateAddress as au, SafeguardEnforcer as av, BORROW_FEE_BPS as aw, CETUS_USDC_SUI_POOL as ax, OPERATION_ASSETS as ay, type Operation as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type GasExecutionResult as g, type GasRequestType as h, type GasSponsorResponse as i, type GasStatusResponse as j, KeypairSigner as k, LOFI_TYPE as l, MIST_PER_SUI as m, SUI_DECIMALS as n, SUI_TYPE as o, SUPPORTED_ASSETS as p, type SafeguardConfig as q, SafeguardError as r, type SafeguardErrorDetails as s, type SafeguardRule as t, type SimulationResult as u, type StableAsset as v, type SupportedAsset as w, type T2000ErrorCode as x, type T2000ErrorData as y, TOKEN_MAP as z };
@@ -1,7 +1,7 @@
1
1
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
4
- import { G as GasMethod } from './types-DxNs-mLT.cjs';
4
+ import { G as GasMethod } from './types-DfwfwsAN.cjs';
5
5
 
6
6
  /**
7
7
  * Abstract signing interface that decouples the SDK from any specific
@@ -241,6 +241,76 @@ declare const GAS_RESERVE_MIN = 0.05;
241
241
  declare function validateAddress(address: string): string;
242
242
  declare function truncateAddress(address: string): string;
243
243
 
244
+ /**
245
+ * Shared transaction classifier.
246
+ *
247
+ * Consumed by both the SDK's `parseTxRecord` (production agent path) and
248
+ * the engine's `transaction_history` tool (cold-start RPC path). Keeping
249
+ * a single source of truth here prevents the two paths from drifting —
250
+ * see v1.5.3 regression where the SDK path was emitting `action:
251
+ * 'transaction'` (rendered as "On-chain") while the engine path was
252
+ * already producing fine-grained labels.
253
+ */
254
+ /**
255
+ * Coarse action bucket — one of `'send' | 'lending' | 'swap' |
256
+ * 'transaction'`. Used by the ACI `action` filter on the
257
+ * `transaction_history` tool. STABLE: downstream queries depend on
258
+ * exactly these values.
259
+ */
260
+ declare const KNOWN_TARGETS: readonly [RegExp, string][];
261
+ /**
262
+ * Finer-grained display labels — derived from MoveCall function names.
263
+ * The card renders `label ?? action`, so when this map matches we get
264
+ * "Deposit" / "Withdraw" / "Borrow" / "Repay" / "Payment link" instead
265
+ * of the generic "Lending" or "Transaction".
266
+ *
267
+ * Order matters: more specific patterns first. Each entry is
268
+ * (regex, label) where the regex is matched against the
269
+ * fully-qualified MoveCall target `pkg::module::function`.
270
+ */
271
+ declare const LABEL_PATTERNS: readonly [RegExp, string][];
272
+ interface ClassifyBalanceChange {
273
+ owner: {
274
+ AddressOwner?: string;
275
+ } | string;
276
+ coinType: string;
277
+ amount: string;
278
+ }
279
+ declare function classifyAction(targets: string[], commandTypes: string[]): string;
280
+ /**
281
+ * Fallback label when no `LABEL_PATTERNS` match.
282
+ *
283
+ * Returns the first MoveCall's *module* name (e.g. "navi", "cetus",
284
+ * "spam") so the card shows something more useful than the literal
285
+ * word "transaction". When no MoveCall exists, returns 'on-chain'
286
+ * instead — strictly more informative than "transaction".
287
+ */
288
+ declare function fallbackLabel(targets: string[]): string;
289
+ declare function classifyLabel(targets: string[], commandTypes: string[]): string;
290
+ /**
291
+ * Balance-direction tiebreaker for ambiguous lending calls.
292
+ *
293
+ * Many lending modules expose generic entry points (NAVI's bundled
294
+ * flash actions, `lending_core::*::entry_*`, etc.) that don't carry
295
+ * a `deposit`/`withdraw`/`borrow`/`repay` keyword in the function
296
+ * name. When `classifyLabel` falls back to a bare module name like
297
+ * `"lending"` for a known lending tx, infer direction from the user's
298
+ * non-SUI balance change:
299
+ * - net outflow of the supplied asset → deposit (also covers repay,
300
+ * but repay-without-keyword is essentially never emitted).
301
+ * - net inflow of the supplied asset → withdraw (also covers borrow).
302
+ * SUI is excluded so gas-only transactions don't get mislabeled.
303
+ *
304
+ * If `LABEL_PATTERNS` matched a specific keyword, the existing label is
305
+ * returned unchanged.
306
+ */
307
+ declare function refineLendingLabel(currentAction: string, currentLabel: string, moveCallTargets: string[], changes: ClassifyBalanceChange[], address: string): string;
308
+ interface ClassifyResult {
309
+ action: string;
310
+ label: string;
311
+ }
312
+ declare function classifyTransaction(moveCallTargets: string[], commandTypes: string[], balanceChanges: ClassifyBalanceChange[], address: string): ClassifyResult;
313
+
244
314
  declare function mistToSui(mist: bigint): number;
245
315
  declare function suiToMist(sui: number): bigint;
246
316
  declare function usdcToRaw(amount: number): bigint;
@@ -369,4 +439,4 @@ declare const IKA_TYPE: string;
369
439
  declare const LOFI_TYPE: string;
370
440
  declare const MANIFEST_TYPE: string;
371
441
 
372
- export { formatAssetAmount as $, ALL_NAVI_ASSETS as A, BPS_DENOMINATOR as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, USDSUI_TYPE as H, IKA_TYPE as I, USDT_TYPE as J, KeypairSigner as K, LOFI_TYPE as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, WBTC_TYPE as Q, ZkLoginSigner as R, STABLE_ASSETS as S, T2000Error as T, USDC_DECIMALS as U, addCollectFeeToTx as V, WAL_TYPE as W, calculateFee as X, executeAutoTopUp as Y, type ZkLoginProof as Z, executeWithGas as _, type AutoTopUpResult as a, formatSui as a0, formatUsd as a1, getDecimals as a2, getDecimalsForCoinType as a3, getGasStatus as a4, getTier as a5, isSupported as a6, isTier1 as a7, isTier2 as a8, mapMoveAbortCode as a9, mapWalletError as aa, mistToSui as ab, rawToStable as ac, rawToUsdc as ad, resolveSymbol as ae, resolveTokenType as af, shouldAutoTopUp as ag, stableToRaw as ah, suiToMist as ai, truncateAddress as aj, usdcToRaw as ak, validateAddress as al, SafeguardEnforcer as am, BORROW_FEE_BPS as an, CETUS_USDC_SUI_POOL as ao, OPERATION_ASSETS as ap, type Operation as aq, SAVE_FEE_BPS as ar, assertAllowedAsset as as, isAllowedAsset as at, simulateTransaction as au, throwIfSimulationFailed as av, COIN_REGISTRY as b, type CoinMeta as c, DEFAULT_SAFEGUARD_CONFIG as d, type GasExecutionResult as e, type GasRequestType as f, type GasSponsorResponse as g, type GasStatusResponse as h, MIST_PER_SUI as i, SUI_DECIMALS as j, SUI_TYPE as k, SUPPORTED_ASSETS as l, type SafeguardConfig as m, SafeguardError as n, type SafeguardErrorDetails as o, type SafeguardRule as p, type SimulationResult as q, type StableAsset as r, type SupportedAsset as s, type T2000ErrorCode as t, type T2000ErrorData as u, TOKEN_MAP as v, type TransactionSigner as w, type TxMetadata as x, USDC_TYPE as y, USDE_TYPE as z };
442
+ export { addCollectFeeToTx as $, ALL_NAVI_ASSETS as A, BPS_DENOMINATOR as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type TransactionSigner as H, IKA_TYPE as I, type TxMetadata as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, USDC_TYPE as Q, USDE_TYPE as R, STABLE_ASSETS as S, T2000Error as T, USDC_DECIMALS as U, USDSUI_TYPE as V, USDT_TYPE as W, WAL_TYPE as X, WBTC_TYPE as Y, type ZkLoginProof as Z, ZkLoginSigner as _, type AutoTopUpResult as a, calculateFee as a0, classifyAction as a1, classifyLabel as a2, classifyTransaction as a3, executeAutoTopUp as a4, executeWithGas as a5, fallbackLabel as a6, formatAssetAmount as a7, formatSui as a8, formatUsd as a9, SAVE_FEE_BPS as aA, assertAllowedAsset as aB, isAllowedAsset as aC, simulateTransaction as aD, throwIfSimulationFailed as aE, getDecimals as aa, getDecimalsForCoinType as ab, getGasStatus as ac, getTier as ad, isSupported as ae, isTier1 as af, isTier2 as ag, mapMoveAbortCode as ah, mapWalletError as ai, mistToSui as aj, rawToStable as ak, rawToUsdc as al, refineLendingLabel as am, resolveSymbol as an, resolveTokenType as ao, shouldAutoTopUp as ap, stableToRaw as aq, suiToMist as ar, truncateAddress as as, usdcToRaw as at, validateAddress as au, SafeguardEnforcer as av, BORROW_FEE_BPS as aw, CETUS_USDC_SUI_POOL as ax, OPERATION_ASSETS as ay, type Operation as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type GasExecutionResult as g, type GasRequestType as h, type GasSponsorResponse as i, type GasStatusResponse as j, KeypairSigner as k, LOFI_TYPE as l, MIST_PER_SUI as m, SUI_DECIMALS as n, SUI_TYPE as o, SUPPORTED_ASSETS as p, type SafeguardConfig as q, SafeguardError as r, type SafeguardErrorDetails as s, type SafeguardRule as t, type SimulationResult as u, type StableAsset as v, type SupportedAsset as w, type T2000ErrorCode as x, type T2000ErrorData as y, TOKEN_MAP as z };
@@ -139,7 +139,15 @@ interface PaymentRequest {
139
139
  }
140
140
  interface TransactionRecord {
141
141
  digest: string;
142
+ /** Coarse bucket — `'send' | 'lending' | 'swap' | 'transaction'`. STABLE. */
142
143
  action: string;
144
+ /**
145
+ * Finer-grained display label derived from the Move-call function
146
+ * name (e.g. `'deposit'`, `'withdraw'`, `'payment_link'`,
147
+ * `'on-chain'`). Optional — frontends should fall back to `action`
148
+ * when missing. Never used by ACI filters.
149
+ */
150
+ label?: string;
143
151
  amount?: number;
144
152
  asset?: string;
145
153
  recipient?: string;
@@ -139,7 +139,15 @@ interface PaymentRequest {
139
139
  }
140
140
  interface TransactionRecord {
141
141
  digest: string;
142
+ /** Coarse bucket — `'send' | 'lending' | 'swap' | 'transaction'`. STABLE. */
142
143
  action: string;
144
+ /**
145
+ * Finer-grained display label derived from the Move-call function
146
+ * name (e.g. `'deposit'`, `'withdraw'`, `'payment_link'`,
147
+ * `'on-chain'`). Optional — frontends should fall back to `action`
148
+ * when missing. Never used by ACI filters.
149
+ */
150
+ label?: string;
143
151
  amount?: number;
144
152
  asset?: string;
145
153
  recipient?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t2000/sdk",
3
- "version": "0.44.0",
3
+ "version": "0.46.0",
4
4
  "description": "TypeScript SDK for AI agent bank accounts on Sui — send, save, borrow, swap. NAVI lending + Cetus aggregator routing, sponsored gas, zkLogin compatible.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",