@t2000/cli 0.45.0 → 0.46.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.
@@ -130548,13 +130548,78 @@ async function queryBalance(client, address2) {
130548
130548
  };
130549
130549
  }
130550
130550
  init_token_registry();
130551
+ init_token_registry();
130551
130552
  var KNOWN_TARGETS = [
130552
130553
  [/::suilend|::obligation/, "lending"],
130553
- [/::navi|::incentive_v\d+|::oracle_pro/, "lending"],
130554
+ [/::navi|::lending_core|::incentive_v\d+|::oracle_pro/, "lending"],
130554
130555
  [/::cetus|::pool/, "swap"],
130555
130556
  [/::deepbook/, "swap"],
130556
130557
  [/::transfer::public_transfer/, "send"]
130557
130558
  ];
130559
+ var LABEL_PATTERNS = [
130560
+ [/::pay(?:ment_kit|_kit)?::|::create_payment_link|::pay_link/, "payment_link"],
130561
+ [/::create_invoice|::invoice::/, "invoice"],
130562
+ [/::deposit|::supply|::mint_ctokens/, "deposit"],
130563
+ [/::withdraw|::redeem|::redeem_ctokens/, "withdraw"],
130564
+ [/::borrow/, "borrow"],
130565
+ [/::repay/, "repay"],
130566
+ [/::claim_reward|::claim::|::claim_incentive/, "claim"],
130567
+ [/::stake/, "stake"],
130568
+ [/::unstake|::burn::/, "unstake"],
130569
+ [/::liquidate/, "liquidate"]
130570
+ ];
130571
+ function resolveOwner(owner) {
130572
+ if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
130573
+ if (typeof owner === "string") return owner;
130574
+ return null;
130575
+ }
130576
+ function classifyAction(targets, commandTypes) {
130577
+ for (const target of targets) {
130578
+ for (const [pattern, label] of KNOWN_TARGETS) {
130579
+ if (pattern.test(target)) return label;
130580
+ }
130581
+ }
130582
+ if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
130583
+ return "transaction";
130584
+ }
130585
+ function fallbackLabel(targets) {
130586
+ if (!targets.length) return "on-chain";
130587
+ const first = targets[0];
130588
+ const parts = first.split("::");
130589
+ if (parts.length >= 2 && parts[1]) return parts[1].toLowerCase();
130590
+ return "on-chain";
130591
+ }
130592
+ function classifyLabel(targets, commandTypes) {
130593
+ for (const target of targets) {
130594
+ for (const [pattern, label] of LABEL_PATTERNS) {
130595
+ if (pattern.test(target)) return label;
130596
+ }
130597
+ }
130598
+ if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
130599
+ return fallbackLabel(targets);
130600
+ }
130601
+ function refineLendingLabel(currentAction, currentLabel, moveCallTargets, changes, address2) {
130602
+ if (currentAction !== "lending") return currentLabel;
130603
+ const labelMatchedSpecific = LABEL_PATTERNS.some(
130604
+ ([p]) => moveCallTargets.some((t) => p.test(t))
130605
+ );
130606
+ if (labelMatchedSpecific) return currentLabel;
130607
+ const userNonSuiOutflow = changes.find(
130608
+ (c) => resolveOwner(c.owner) === address2 && c.coinType !== SUI_TYPE2 && BigInt(c.amount) < 0n
130609
+ );
130610
+ if (userNonSuiOutflow) return "deposit";
130611
+ const userNonSuiInflow = changes.find(
130612
+ (c) => resolveOwner(c.owner) === address2 && c.coinType !== SUI_TYPE2 && BigInt(c.amount) > 0n
130613
+ );
130614
+ if (userNonSuiInflow) return "withdraw";
130615
+ return currentLabel;
130616
+ }
130617
+ function classifyTransaction(moveCallTargets, commandTypes, balanceChanges, address2) {
130618
+ const action = classifyAction(moveCallTargets, commandTypes);
130619
+ const baseLabel = classifyLabel(moveCallTargets, commandTypes);
130620
+ const label = refineLendingLabel(action, baseLabel, moveCallTargets, balanceChanges, address2);
130621
+ return { action, label };
130622
+ }
130558
130623
  async function queryHistory(client, address2, limit = 20) {
130559
130624
  const txns = await client.queryTransactionBlocks({
130560
130625
  filter: { FromAddress: address2 },
@@ -130579,11 +130644,18 @@ function parseTxRecord(tx, address2) {
130579
130644
  const gasUsed = tx.effects?.gasUsed;
130580
130645
  const gasCost = gasUsed ? (Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate)) / 1e9 : void 0;
130581
130646
  const { moveCallTargets, commandTypes } = extractCommands(tx.transaction);
130582
- const { amount: amount2, asset, recipient } = extractTransferDetails(tx.balanceChanges, address2);
130583
- const action = classifyAction(moveCallTargets, commandTypes);
130647
+ const balanceChanges = tx.balanceChanges ?? [];
130648
+ const { amount: amount2, asset, recipient } = extractTransferDetails(balanceChanges, address2);
130649
+ const { action, label } = classifyTransaction(
130650
+ moveCallTargets,
130651
+ commandTypes,
130652
+ balanceChanges,
130653
+ address2
130654
+ );
130584
130655
  return {
130585
130656
  digest: tx.digest,
130586
130657
  action,
130658
+ label,
130587
130659
  amount: amount2,
130588
130660
  asset,
130589
130661
  recipient,
@@ -130591,15 +130663,15 @@ function parseTxRecord(tx, address2) {
130591
130663
  gasCost
130592
130664
  };
130593
130665
  }
130594
- function resolveOwner(owner) {
130666
+ function resolveOwner2(owner) {
130595
130667
  if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
130596
130668
  if (typeof owner === "string") return owner;
130597
130669
  return null;
130598
130670
  }
130599
130671
  function extractTransferDetails(changes, sender) {
130600
130672
  if (!changes || changes.length === 0) return {};
130601
- const outflows = changes.filter((c) => resolveOwner(c.owner) === sender && BigInt(c.amount) < 0n);
130602
- const inflows = changes.filter((c) => resolveOwner(c.owner) !== sender && BigInt(c.amount) > 0n);
130673
+ const outflows = changes.filter((c) => resolveOwner2(c.owner) === sender && BigInt(c.amount) < 0n);
130674
+ const inflows = changes.filter((c) => resolveOwner2(c.owner) !== sender && BigInt(c.amount) > 0n);
130603
130675
  const primaryOutflow = outflows.filter((c) => c.coinType !== SUI_TYPE2).sort((a, b2) => Number(BigInt(a.amount) - BigInt(b2.amount)))[0] ?? outflows[0];
130604
130676
  if (!primaryOutflow) return {};
130605
130677
  const coinType = primaryOutflow.coinType;
@@ -130607,7 +130679,7 @@ function extractTransferDetails(changes, sender) {
130607
130679
  const amount2 = Math.abs(Number(BigInt(primaryOutflow.amount))) / 10 ** decimals2;
130608
130680
  const asset = resolveSymbol(coinType);
130609
130681
  const recipientChange = inflows.find((c) => c.coinType === coinType);
130610
- const recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
130682
+ const recipient = recipientChange ? resolveOwner2(recipientChange.owner) ?? void 0 : void 0;
130611
130683
  return { amount: amount2, asset, recipient };
130612
130684
  }
130613
130685
  function extractCommands(txBlock) {
@@ -130633,18 +130705,6 @@ function extractCommands(txBlock) {
130633
130705
  }
130634
130706
  return result;
130635
130707
  }
130636
- function classifyAction(targets, commandTypes) {
130637
- for (const target of targets) {
130638
- for (const [pattern, label] of KNOWN_TARGETS) {
130639
- if (pattern.test(target)) return label;
130640
- }
130641
- }
130642
- const hasTransfer = commandTypes.includes("TransferObjects");
130643
- const hasMoveCall = commandTypes.includes("MoveCall");
130644
- if (hasTransfer && !hasMoveCall) return "send";
130645
- if (hasMoveCall) return "transaction";
130646
- return "transaction";
130647
- }
130648
130708
  init_token_registry();
130649
130709
  var FEE_RATES = {
130650
130710
  save: SAVE_FEE_BPS,
@@ -137969,7 +138029,7 @@ ${context}
137969
138029
  })
137970
138030
  );
137971
138031
  }
137972
- var PKG_VERSION = "0.45.0";
138032
+ var PKG_VERSION = "0.46.1";
137973
138033
  console.log = (...args) => console.error("[log]", ...args);
137974
138034
  console.warn = (...args) => console.error("[warn]", ...args);
137975
138035
  async function startMcpServer(opts) {
@@ -138059,4 +138119,4 @@ axios/dist/node/axios.cjs:
138059
138119
  *)
138060
138120
  *)
138061
138121
  */
138062
- //# sourceMappingURL=dist-HPXLVXU7.js.map
138122
+ //# sourceMappingURL=dist-LGHHHTO2.js.map