@t2000/engine 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.
package/dist/index.d.ts CHANGED
@@ -1643,7 +1643,7 @@ declare const healthCheckTool: Tool<{}, {
1643
1643
  declare const ratesInfoTool: Tool<{}, _t2000_sdk.RatesResult>;
1644
1644
 
1645
1645
  declare const transactionHistoryTool: Tool<{
1646
- action?: "send" | "swap" | "lending" | "transaction" | undefined;
1646
+ action?: "send" | "swap" | "transaction" | "lending" | undefined;
1647
1647
  date?: string | undefined;
1648
1648
  limit?: number | undefined;
1649
1649
  }, Record<string, unknown>>;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { resolveSymbol, getDecimalsForCoinType, assertAllowedAsset, getSwapQuote, SUI_TYPE } from '@t2000/sdk';
2
+ import { resolveSymbol, getDecimalsForCoinType, assertAllowedAsset, getSwapQuote, SUI_TYPE, classifyTransaction } from '@t2000/sdk';
3
3
  import { readdirSync, readFileSync } from 'fs';
4
4
  import { join } from 'path';
5
5
  import yaml from 'js-yaml';
@@ -1005,27 +1005,11 @@ var ratesInfoTool = buildTool({
1005
1005
  return { data: rates, displayText: formatRatesSummary(rates) };
1006
1006
  }
1007
1007
  });
1008
- var KNOWN_TARGETS = [
1009
- [/::suilend|::obligation/, "lending"],
1010
- [/::navi|::incentive_v\d+|::oracle_pro/, "lending"],
1011
- [/::cetus|::pool/, "swap"],
1012
- [/::deepbook/, "swap"],
1013
- [/::transfer::public_transfer/, "send"]
1014
- ];
1015
1008
  function resolveOwner(owner) {
1016
1009
  if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
1017
1010
  if (typeof owner === "string") return owner;
1018
1011
  return null;
1019
1012
  }
1020
- function classifyAction(targets, commandTypes) {
1021
- for (const target of targets) {
1022
- for (const [pattern, label] of KNOWN_TARGETS) {
1023
- if (pattern.test(target)) return label;
1024
- }
1025
- }
1026
- if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
1027
- return "transaction";
1028
- }
1029
1013
  function parseRpcTx(tx, address) {
1030
1014
  const gasUsed = tx.effects?.gasUsed;
1031
1015
  const gasCost = gasUsed ? (Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate)) / 1e9 : void 0;
@@ -1064,9 +1048,11 @@ function parseRpcTx(tx, address) {
1064
1048
  recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
1065
1049
  }
1066
1050
  const timestampMs = Number(tx.timestampMs ?? 0);
1051
+ const { action, label } = classifyTransaction(moveCallTargets, commandTypes, changes, address);
1067
1052
  return {
1068
1053
  digest: tx.digest,
1069
- action: classifyAction(moveCallTargets, commandTypes),
1054
+ action,
1055
+ label,
1070
1056
  amount,
1071
1057
  asset,
1072
1058
  recipient,