@t2000/engine 0.44.0 → 0.45.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.js +43 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1012,6 +1012,34 @@ var KNOWN_TARGETS = [
|
|
|
1012
1012
|
[/::deepbook/, "swap"],
|
|
1013
1013
|
[/::transfer::public_transfer/, "send"]
|
|
1014
1014
|
];
|
|
1015
|
+
var LABEL_PATTERNS = [
|
|
1016
|
+
[/::pay(?:ment_kit|_kit)?::|::create_payment_link|::pay_link/, "payment_link"],
|
|
1017
|
+
[/::create_invoice|::invoice::/, "invoice"],
|
|
1018
|
+
[/::deposit|::supply|::mint_ctokens/, "deposit"],
|
|
1019
|
+
[/::withdraw|::redeem|::redeem_ctokens/, "withdraw"],
|
|
1020
|
+
[/::borrow/, "borrow"],
|
|
1021
|
+
[/::repay/, "repay"],
|
|
1022
|
+
[/::claim_reward|::claim::|::claim_incentive/, "claim"],
|
|
1023
|
+
[/::stake/, "stake"],
|
|
1024
|
+
[/::unstake|::burn::/, "unstake"],
|
|
1025
|
+
[/::liquidate/, "liquidate"]
|
|
1026
|
+
];
|
|
1027
|
+
function fallbackLabel(targets) {
|
|
1028
|
+
if (!targets.length) return "on-chain";
|
|
1029
|
+
const first = targets[0];
|
|
1030
|
+
const parts = first.split("::");
|
|
1031
|
+
if (parts.length >= 2 && parts[1]) return parts[1].toLowerCase();
|
|
1032
|
+
return "on-chain";
|
|
1033
|
+
}
|
|
1034
|
+
function classifyLabel(targets, commandTypes) {
|
|
1035
|
+
for (const target of targets) {
|
|
1036
|
+
for (const [pattern, label] of LABEL_PATTERNS) {
|
|
1037
|
+
if (pattern.test(target)) return label;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
|
|
1041
|
+
return fallbackLabel(targets);
|
|
1042
|
+
}
|
|
1015
1043
|
function resolveOwner(owner) {
|
|
1016
1044
|
if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
|
|
1017
1045
|
if (typeof owner === "string") return owner;
|
|
@@ -1064,9 +1092,23 @@ function parseRpcTx(tx, address) {
|
|
|
1064
1092
|
recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
|
|
1065
1093
|
}
|
|
1066
1094
|
const timestampMs = Number(tx.timestampMs ?? 0);
|
|
1095
|
+
const action = classifyAction(moveCallTargets, commandTypes);
|
|
1096
|
+
let label = classifyLabel(moveCallTargets, commandTypes);
|
|
1097
|
+
const labelMatchedSpecific = LABEL_PATTERNS.some(([p]) => moveCallTargets.some((t) => p.test(t)));
|
|
1098
|
+
if (action === "lending" && !labelMatchedSpecific) {
|
|
1099
|
+
const userNonSuiOutflow = changes.find(
|
|
1100
|
+
(c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) < 0n
|
|
1101
|
+
);
|
|
1102
|
+
const userNonSuiInflow = changes.find(
|
|
1103
|
+
(c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) > 0n
|
|
1104
|
+
);
|
|
1105
|
+
if (userNonSuiOutflow) label = "deposit";
|
|
1106
|
+
else if (userNonSuiInflow) label = "withdraw";
|
|
1107
|
+
}
|
|
1067
1108
|
return {
|
|
1068
1109
|
digest: tx.digest,
|
|
1069
|
-
action
|
|
1110
|
+
action,
|
|
1111
|
+
label,
|
|
1070
1112
|
amount,
|
|
1071
1113
|
asset,
|
|
1072
1114
|
recipient,
|