@t2000/engine 0.31.1 → 0.31.3
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 +4 -2
- package/dist/index.js +54 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -833,10 +833,12 @@ declare const healthCheckTool: Tool<{}, {
|
|
|
833
833
|
declare const ratesInfoTool: Tool<{}, _t2000_sdk.RatesResult>;
|
|
834
834
|
|
|
835
835
|
declare const transactionHistoryTool: Tool<{
|
|
836
|
+
date?: string | undefined;
|
|
836
837
|
limit?: number | undefined;
|
|
837
838
|
}, {
|
|
838
839
|
transactions: _t2000_sdk.TransactionRecord[];
|
|
839
840
|
count: number;
|
|
841
|
+
date: string | null;
|
|
840
842
|
}>;
|
|
841
843
|
|
|
842
844
|
declare const saveDepositTool: Tool<{
|
|
@@ -1097,7 +1099,7 @@ interface SpendingResponse {
|
|
|
1097
1099
|
byService: unknown[];
|
|
1098
1100
|
}
|
|
1099
1101
|
declare const spendingAnalyticsTool: Tool<{
|
|
1100
|
-
period?: "
|
|
1102
|
+
period?: "month" | "year" | "all" | "week" | undefined;
|
|
1101
1103
|
}, SpendingResponse>;
|
|
1102
1104
|
|
|
1103
1105
|
interface YieldSummary {
|
|
@@ -1126,7 +1128,7 @@ interface ActivitySummary {
|
|
|
1126
1128
|
yieldEarnedUsd: number;
|
|
1127
1129
|
}
|
|
1128
1130
|
declare const activitySummaryTool: Tool<{
|
|
1129
|
-
period?: "
|
|
1131
|
+
period?: "month" | "year" | "all" | "week" | undefined;
|
|
1130
1132
|
}, ActivitySummary>;
|
|
1131
1133
|
|
|
1132
1134
|
declare const defillamaYieldPoolsTool: Tool<{
|
package/dist/index.js
CHANGED
|
@@ -992,7 +992,7 @@ function parseRpcTx(tx, address) {
|
|
|
992
992
|
gasCost
|
|
993
993
|
};
|
|
994
994
|
}
|
|
995
|
-
async function
|
|
995
|
+
async function queryHistoryPage(rpcUrl, address, limit, cursor) {
|
|
996
996
|
const res = await fetch(rpcUrl, {
|
|
997
997
|
method: "POST",
|
|
998
998
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1002,7 +1002,7 @@ async function queryHistoryRpc(rpcUrl, address, limit) {
|
|
|
1002
1002
|
method: "suix_queryTransactionBlocks",
|
|
1003
1003
|
params: [
|
|
1004
1004
|
{ filter: { FromAddress: address }, options: { showEffects: true, showInput: true, showBalanceChanges: true } },
|
|
1005
|
-
|
|
1005
|
+
cursor,
|
|
1006
1006
|
limit,
|
|
1007
1007
|
true
|
|
1008
1008
|
]
|
|
@@ -1012,13 +1012,48 @@ async function queryHistoryRpc(rpcUrl, address, limit) {
|
|
|
1012
1012
|
if (!res.ok) throw new Error(`Sui RPC error: ${res.status}`);
|
|
1013
1013
|
const json = await res.json();
|
|
1014
1014
|
if (json.error) throw new Error(`RPC error: ${json.error.message}`);
|
|
1015
|
-
return
|
|
1015
|
+
return {
|
|
1016
|
+
data: json.result?.data ?? [],
|
|
1017
|
+
nextCursor: json.result?.nextCursor ?? null,
|
|
1018
|
+
hasNextPage: json.result?.hasNextPage ?? false
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
async function queryHistoryRpc(rpcUrl, address, limit) {
|
|
1022
|
+
const page = await queryHistoryPage(rpcUrl, address, limit, null);
|
|
1023
|
+
return page.data.map((tx) => parseRpcTx(tx, address));
|
|
1024
|
+
}
|
|
1025
|
+
async function queryHistoryByDate(rpcUrl, address, targetDate, limit) {
|
|
1026
|
+
const target = new Date(targetDate);
|
|
1027
|
+
const dayStart = new Date(target.getFullYear(), target.getMonth(), target.getDate()).getTime();
|
|
1028
|
+
const dayEnd = dayStart + 864e5;
|
|
1029
|
+
const MAX_PAGES = 20;
|
|
1030
|
+
const PAGE_SIZE = 50;
|
|
1031
|
+
const results = [];
|
|
1032
|
+
let cursor = null;
|
|
1033
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
1034
|
+
const res = await queryHistoryPage(rpcUrl, address, PAGE_SIZE, cursor);
|
|
1035
|
+
if (res.data.length === 0) break;
|
|
1036
|
+
for (const tx of res.data) {
|
|
1037
|
+
const ts = Number(tx.timestampMs ?? 0);
|
|
1038
|
+
if (ts === 0) continue;
|
|
1039
|
+
if (ts < dayStart) {
|
|
1040
|
+
return results.slice(0, limit);
|
|
1041
|
+
}
|
|
1042
|
+
if (ts >= dayStart && ts < dayEnd) {
|
|
1043
|
+
results.push(parseRpcTx(tx, address));
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (!res.hasNextPage || !res.nextCursor) break;
|
|
1047
|
+
cursor = res.nextCursor;
|
|
1048
|
+
}
|
|
1049
|
+
return results.slice(0, limit);
|
|
1016
1050
|
}
|
|
1017
1051
|
var transactionHistoryTool = buildTool({
|
|
1018
1052
|
name: "transaction_history",
|
|
1019
|
-
description: "Retrieve
|
|
1053
|
+
description: "Retrieve transaction history: past sends, saves, withdrawals, borrows, repayments, and rewards claims. Pass a date (YYYY-MM-DD) to find transactions from a specific day, or omit for the most recent.",
|
|
1020
1054
|
inputSchema: z.object({
|
|
1021
|
-
limit: z.number().int().min(1).max(50).optional()
|
|
1055
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
1056
|
+
date: z.string().optional().describe("Specific date to search for transactions (YYYY-MM-DD format). Paginates back to find that day.")
|
|
1022
1057
|
}),
|
|
1023
1058
|
jsonSchema: {
|
|
1024
1059
|
type: "object",
|
|
@@ -1026,6 +1061,10 @@ var transactionHistoryTool = buildTool({
|
|
|
1026
1061
|
limit: {
|
|
1027
1062
|
type: "number",
|
|
1028
1063
|
description: "Maximum number of transactions to return (1-50, default 10)"
|
|
1064
|
+
},
|
|
1065
|
+
date: {
|
|
1066
|
+
type: "string",
|
|
1067
|
+
description: "Specific date to search for transactions (YYYY-MM-DD format). Paginates back to find that day."
|
|
1029
1068
|
}
|
|
1030
1069
|
}
|
|
1031
1070
|
},
|
|
@@ -1036,16 +1075,24 @@ var transactionHistoryTool = buildTool({
|
|
|
1036
1075
|
const agent = requireAgent(context);
|
|
1037
1076
|
const records2 = await agent.history({ limit });
|
|
1038
1077
|
return {
|
|
1039
|
-
data: { transactions: records2, count: records2.length },
|
|
1078
|
+
data: { transactions: records2, count: records2.length, date: input.date ?? null },
|
|
1040
1079
|
displayText: `${records2.length} recent transaction(s)`
|
|
1041
1080
|
};
|
|
1042
1081
|
}
|
|
1043
1082
|
if (!context.walletAddress || !context.suiRpcUrl) {
|
|
1044
1083
|
throw new Error("Transaction history requires a wallet address");
|
|
1045
1084
|
}
|
|
1085
|
+
if (input.date) {
|
|
1086
|
+
const records2 = await queryHistoryByDate(context.suiRpcUrl, context.walletAddress, input.date, limit);
|
|
1087
|
+
const dateLabel = new Date(input.date).toLocaleDateString("en-US", { month: "long", day: "numeric", year: "numeric" });
|
|
1088
|
+
return {
|
|
1089
|
+
data: { transactions: records2, count: records2.length, date: input.date },
|
|
1090
|
+
displayText: records2.length > 0 ? `${records2.length} transaction(s) on ${dateLabel}` : `No transactions found on ${dateLabel}`
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1046
1093
|
const records = await queryHistoryRpc(context.suiRpcUrl, context.walletAddress, limit);
|
|
1047
1094
|
return {
|
|
1048
|
-
data: { transactions: records, count: records.length },
|
|
1095
|
+
data: { transactions: records, count: records.length, date: null },
|
|
1049
1096
|
displayText: `${records.length} recent transaction(s)`
|
|
1050
1097
|
};
|
|
1051
1098
|
}
|