@t2000/cli 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/{chunk-MISDVBTN.js → chunk-6ZRYQAOQ.js} +87 -20
- package/dist/chunk-6ZRYQAOQ.js.map +1 -0
- package/dist/{dist-7CFAS7YK.js → dist-M7AYQZSX.js} +16 -2
- package/dist/{dist-UHRQXWYX.js → dist-XPK5WGV5.js} +81 -21
- package/dist/{dist-UHRQXWYX.js.map → dist-XPK5WGV5.js.map} +1 -1
- package/dist/index.js +3 -3
- package/package.json +3 -3
- package/dist/chunk-MISDVBTN.js.map +0 -1
- /package/dist/{dist-7CFAS7YK.js.map → dist-M7AYQZSX.js.map} +0 -0
|
@@ -60996,13 +60996,78 @@ async function queryBalance(client, address) {
|
|
|
60996
60996
|
};
|
|
60997
60997
|
}
|
|
60998
60998
|
init_token_registry();
|
|
60999
|
+
init_token_registry();
|
|
60999
61000
|
var KNOWN_TARGETS = [
|
|
61000
61001
|
[/::suilend|::obligation/, "lending"],
|
|
61001
|
-
[/::navi|::incentive_v\d+|::oracle_pro/, "lending"],
|
|
61002
|
+
[/::navi|::lending_core|::incentive_v\d+|::oracle_pro/, "lending"],
|
|
61002
61003
|
[/::cetus|::pool/, "swap"],
|
|
61003
61004
|
[/::deepbook/, "swap"],
|
|
61004
61005
|
[/::transfer::public_transfer/, "send"]
|
|
61005
61006
|
];
|
|
61007
|
+
var LABEL_PATTERNS = [
|
|
61008
|
+
[/::pay(?:ment_kit|_kit)?::|::create_payment_link|::pay_link/, "payment_link"],
|
|
61009
|
+
[/::create_invoice|::invoice::/, "invoice"],
|
|
61010
|
+
[/::deposit|::supply|::mint_ctokens/, "deposit"],
|
|
61011
|
+
[/::withdraw|::redeem|::redeem_ctokens/, "withdraw"],
|
|
61012
|
+
[/::borrow/, "borrow"],
|
|
61013
|
+
[/::repay/, "repay"],
|
|
61014
|
+
[/::claim_reward|::claim::|::claim_incentive/, "claim"],
|
|
61015
|
+
[/::stake/, "stake"],
|
|
61016
|
+
[/::unstake|::burn::/, "unstake"],
|
|
61017
|
+
[/::liquidate/, "liquidate"]
|
|
61018
|
+
];
|
|
61019
|
+
function resolveOwner(owner) {
|
|
61020
|
+
if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
|
|
61021
|
+
if (typeof owner === "string") return owner;
|
|
61022
|
+
return null;
|
|
61023
|
+
}
|
|
61024
|
+
function classifyAction(targets, commandTypes) {
|
|
61025
|
+
for (const target of targets) {
|
|
61026
|
+
for (const [pattern, label] of KNOWN_TARGETS) {
|
|
61027
|
+
if (pattern.test(target)) return label;
|
|
61028
|
+
}
|
|
61029
|
+
}
|
|
61030
|
+
if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
|
|
61031
|
+
return "transaction";
|
|
61032
|
+
}
|
|
61033
|
+
function fallbackLabel(targets) {
|
|
61034
|
+
if (!targets.length) return "on-chain";
|
|
61035
|
+
const first = targets[0];
|
|
61036
|
+
const parts = first.split("::");
|
|
61037
|
+
if (parts.length >= 2 && parts[1]) return parts[1].toLowerCase();
|
|
61038
|
+
return "on-chain";
|
|
61039
|
+
}
|
|
61040
|
+
function classifyLabel(targets, commandTypes) {
|
|
61041
|
+
for (const target of targets) {
|
|
61042
|
+
for (const [pattern, label] of LABEL_PATTERNS) {
|
|
61043
|
+
if (pattern.test(target)) return label;
|
|
61044
|
+
}
|
|
61045
|
+
}
|
|
61046
|
+
if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
|
|
61047
|
+
return fallbackLabel(targets);
|
|
61048
|
+
}
|
|
61049
|
+
function refineLendingLabel(currentAction, currentLabel, moveCallTargets, changes, address) {
|
|
61050
|
+
if (currentAction !== "lending") return currentLabel;
|
|
61051
|
+
const labelMatchedSpecific = LABEL_PATTERNS.some(
|
|
61052
|
+
([p]) => moveCallTargets.some((t) => p.test(t))
|
|
61053
|
+
);
|
|
61054
|
+
if (labelMatchedSpecific) return currentLabel;
|
|
61055
|
+
const userNonSuiOutflow = changes.find(
|
|
61056
|
+
(c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) < 0n
|
|
61057
|
+
);
|
|
61058
|
+
if (userNonSuiOutflow) return "deposit";
|
|
61059
|
+
const userNonSuiInflow = changes.find(
|
|
61060
|
+
(c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) > 0n
|
|
61061
|
+
);
|
|
61062
|
+
if (userNonSuiInflow) return "withdraw";
|
|
61063
|
+
return currentLabel;
|
|
61064
|
+
}
|
|
61065
|
+
function classifyTransaction(moveCallTargets, commandTypes, balanceChanges, address) {
|
|
61066
|
+
const action = classifyAction(moveCallTargets, commandTypes);
|
|
61067
|
+
const baseLabel = classifyLabel(moveCallTargets, commandTypes);
|
|
61068
|
+
const label = refineLendingLabel(action, baseLabel, moveCallTargets, balanceChanges, address);
|
|
61069
|
+
return { action, label };
|
|
61070
|
+
}
|
|
61006
61071
|
async function queryHistory(client, address, limit = 20) {
|
|
61007
61072
|
const txns = await client.queryTransactionBlocks({
|
|
61008
61073
|
filter: { FromAddress: address },
|
|
@@ -61027,11 +61092,18 @@ function parseTxRecord(tx, address) {
|
|
|
61027
61092
|
const gasUsed = tx.effects?.gasUsed;
|
|
61028
61093
|
const gasCost = gasUsed ? (Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate)) / 1e9 : void 0;
|
|
61029
61094
|
const { moveCallTargets, commandTypes } = extractCommands(tx.transaction);
|
|
61030
|
-
const
|
|
61031
|
-
const
|
|
61095
|
+
const balanceChanges = tx.balanceChanges ?? [];
|
|
61096
|
+
const { amount, asset, recipient } = extractTransferDetails(balanceChanges, address);
|
|
61097
|
+
const { action, label } = classifyTransaction(
|
|
61098
|
+
moveCallTargets,
|
|
61099
|
+
commandTypes,
|
|
61100
|
+
balanceChanges,
|
|
61101
|
+
address
|
|
61102
|
+
);
|
|
61032
61103
|
return {
|
|
61033
61104
|
digest: tx.digest,
|
|
61034
61105
|
action,
|
|
61106
|
+
label,
|
|
61035
61107
|
amount,
|
|
61036
61108
|
asset,
|
|
61037
61109
|
recipient,
|
|
@@ -61039,15 +61111,15 @@ function parseTxRecord(tx, address) {
|
|
|
61039
61111
|
gasCost
|
|
61040
61112
|
};
|
|
61041
61113
|
}
|
|
61042
|
-
function
|
|
61114
|
+
function resolveOwner2(owner) {
|
|
61043
61115
|
if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
|
|
61044
61116
|
if (typeof owner === "string") return owner;
|
|
61045
61117
|
return null;
|
|
61046
61118
|
}
|
|
61047
61119
|
function extractTransferDetails(changes, sender) {
|
|
61048
61120
|
if (!changes || changes.length === 0) return {};
|
|
61049
|
-
const outflows = changes.filter((c) =>
|
|
61050
|
-
const inflows = changes.filter((c) =>
|
|
61121
|
+
const outflows = changes.filter((c) => resolveOwner2(c.owner) === sender && BigInt(c.amount) < 0n);
|
|
61122
|
+
const inflows = changes.filter((c) => resolveOwner2(c.owner) !== sender && BigInt(c.amount) > 0n);
|
|
61051
61123
|
const primaryOutflow = outflows.filter((c) => c.coinType !== SUI_TYPE).sort((a, b2) => Number(BigInt(a.amount) - BigInt(b2.amount)))[0] ?? outflows[0];
|
|
61052
61124
|
if (!primaryOutflow) return {};
|
|
61053
61125
|
const coinType = primaryOutflow.coinType;
|
|
@@ -61055,7 +61127,7 @@ function extractTransferDetails(changes, sender) {
|
|
|
61055
61127
|
const amount = Math.abs(Number(BigInt(primaryOutflow.amount))) / 10 ** decimals;
|
|
61056
61128
|
const asset = resolveSymbol(coinType);
|
|
61057
61129
|
const recipientChange = inflows.find((c) => c.coinType === coinType);
|
|
61058
|
-
const recipient = recipientChange ?
|
|
61130
|
+
const recipient = recipientChange ? resolveOwner2(recipientChange.owner) ?? void 0 : void 0;
|
|
61059
61131
|
return { amount, asset, recipient };
|
|
61060
61132
|
}
|
|
61061
61133
|
function extractCommands(txBlock) {
|
|
@@ -61081,18 +61153,6 @@ function extractCommands(txBlock) {
|
|
|
61081
61153
|
}
|
|
61082
61154
|
return result;
|
|
61083
61155
|
}
|
|
61084
|
-
function classifyAction(targets, commandTypes) {
|
|
61085
|
-
for (const target of targets) {
|
|
61086
|
-
for (const [pattern, label] of KNOWN_TARGETS) {
|
|
61087
|
-
if (pattern.test(target)) return label;
|
|
61088
|
-
}
|
|
61089
|
-
}
|
|
61090
|
-
const hasTransfer = commandTypes.includes("TransferObjects");
|
|
61091
|
-
const hasMoveCall = commandTypes.includes("MoveCall");
|
|
61092
|
-
if (hasTransfer && !hasMoveCall) return "send";
|
|
61093
|
-
if (hasMoveCall) return "transaction";
|
|
61094
|
-
return "transaction";
|
|
61095
|
-
}
|
|
61096
61156
|
init_token_registry();
|
|
61097
61157
|
var FEE_RATES = {
|
|
61098
61158
|
save: SAVE_FEE_BPS,
|
|
@@ -67361,6 +67421,13 @@ export {
|
|
|
67361
67421
|
formatUsd,
|
|
67362
67422
|
formatSui,
|
|
67363
67423
|
formatAssetAmount,
|
|
67424
|
+
KNOWN_TARGETS,
|
|
67425
|
+
LABEL_PATTERNS,
|
|
67426
|
+
classifyAction,
|
|
67427
|
+
fallbackLabel,
|
|
67428
|
+
classifyLabel,
|
|
67429
|
+
refineLendingLabel,
|
|
67430
|
+
classifyTransaction,
|
|
67364
67431
|
calculateFee,
|
|
67365
67432
|
addCollectFeeToTx,
|
|
67366
67433
|
getRates,
|
|
@@ -67439,4 +67506,4 @@ axios/dist/node/axios.cjs:
|
|
|
67439
67506
|
@scure/bip39/index.js:
|
|
67440
67507
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
67441
67508
|
*/
|
|
67442
|
-
//# sourceMappingURL=chunk-
|
|
67509
|
+
//# sourceMappingURL=chunk-6ZRYQAOQ.js.map
|