@t2000/cli 0.22.6 → 0.22.7
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 +66 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -503,7 +503,6 @@ var ACTION_LABELS = {
|
|
|
503
503
|
send: "\u2197 send",
|
|
504
504
|
lending: "\u{1F3E6} lend",
|
|
505
505
|
swap: "\u{1F504} swap",
|
|
506
|
-
"mpp payment": "\u{1F4B3} mpp",
|
|
507
506
|
transaction: "\u{1F4E6} tx"
|
|
508
507
|
};
|
|
509
508
|
function relativeTime(ts) {
|
|
@@ -1606,7 +1605,7 @@ function registerLock(program2) {
|
|
|
1606
1605
|
});
|
|
1607
1606
|
program2.command("unlock").description("Unlock agent \u2014 resume operations").action(async () => {
|
|
1608
1607
|
try {
|
|
1609
|
-
const { T2000:
|
|
1608
|
+
const { T2000: T200028 } = await import("@t2000/sdk");
|
|
1610
1609
|
const MAX_ATTEMPTS2 = 3;
|
|
1611
1610
|
let pin;
|
|
1612
1611
|
for (let attempt = 1; attempt <= MAX_ATTEMPTS2; attempt++) {
|
|
@@ -1615,7 +1614,7 @@ function registerLock(program2) {
|
|
|
1615
1614
|
throw new Error("PIN required to unlock agent");
|
|
1616
1615
|
}
|
|
1617
1616
|
try {
|
|
1618
|
-
await
|
|
1617
|
+
await T200028.create({ pin });
|
|
1619
1618
|
break;
|
|
1620
1619
|
} catch (error) {
|
|
1621
1620
|
const msg = error instanceof Error ? error.message : "";
|
|
@@ -2955,6 +2954,69 @@ function registerClaimRewards(program2) {
|
|
|
2955
2954
|
});
|
|
2956
2955
|
}
|
|
2957
2956
|
|
|
2957
|
+
// src/commands/gas.ts
|
|
2958
|
+
import pc17 from "picocolors";
|
|
2959
|
+
import { T2000 as T200027, getGasStatus } from "@t2000/sdk";
|
|
2960
|
+
function registerGas(program2) {
|
|
2961
|
+
program2.command("gas").description("Check gas station status and wallet gas balance").option("--key <path>", "Key file path").action(async (opts) => {
|
|
2962
|
+
try {
|
|
2963
|
+
const pin = await resolvePin();
|
|
2964
|
+
const agent = await T200027.create({ pin, keyPath: opts.key });
|
|
2965
|
+
const address = agent.address();
|
|
2966
|
+
const [status, bal] = await Promise.allSettled([
|
|
2967
|
+
getGasStatus(address),
|
|
2968
|
+
agent.balance()
|
|
2969
|
+
]);
|
|
2970
|
+
const gasStatus = status.status === "fulfilled" ? status.value : null;
|
|
2971
|
+
const balData = bal.status === "fulfilled" ? bal.value : null;
|
|
2972
|
+
if (isJsonMode()) {
|
|
2973
|
+
printJson({
|
|
2974
|
+
gasStation: gasStatus ?? { error: status.status === "rejected" ? String(status.reason) : "unavailable" },
|
|
2975
|
+
wallet: balData ? { sui: balData.gasReserve.sui, available: balData.available } : null
|
|
2976
|
+
});
|
|
2977
|
+
return;
|
|
2978
|
+
}
|
|
2979
|
+
printHeader("Gas Status");
|
|
2980
|
+
if (gasStatus) {
|
|
2981
|
+
const cbStatus = gasStatus.circuitBreaker ? pc17.red("TRIPPED \u2014 sponsorship paused") : pc17.green("OK");
|
|
2982
|
+
printKeyValue("Gas Station", cbStatus);
|
|
2983
|
+
printKeyValue("SUI Price (TWAP)", `$${gasStatus.suiPrice.toFixed(4)}`);
|
|
2984
|
+
if (gasStatus.bootstrapRemaining !== void 0) {
|
|
2985
|
+
printKeyValue("Bootstrap", `${gasStatus.bootstrapUsed}/10 used (${gasStatus.bootstrapRemaining} remaining)`);
|
|
2986
|
+
}
|
|
2987
|
+
} else {
|
|
2988
|
+
printKeyValue("Gas Station", pc17.red("unreachable"));
|
|
2989
|
+
const reason = status.status === "rejected" ? status.reason : "unknown";
|
|
2990
|
+
printLine(` ${pc17.dim(reason instanceof Error ? reason.message : String(reason))}`);
|
|
2991
|
+
}
|
|
2992
|
+
printDivider();
|
|
2993
|
+
if (balData) {
|
|
2994
|
+
const suiBal = balData.gasReserve.sui;
|
|
2995
|
+
const suiColor = suiBal < 0.05 ? pc17.red : pc17.green;
|
|
2996
|
+
printKeyValue("SUI (gas)", suiColor(`${suiBal.toFixed(4)} SUI`));
|
|
2997
|
+
if (suiBal < 0.05) {
|
|
2998
|
+
printLine(` ${pc17.yellow("\u26A0")} Below gas threshold (0.05 SUI) \u2014 transactions will need sponsorship`);
|
|
2999
|
+
}
|
|
3000
|
+
printKeyValue("Available", `$${balData.available.toFixed(2)}`);
|
|
3001
|
+
} else {
|
|
3002
|
+
printKeyValue("Wallet", pc17.dim("could not fetch balances"));
|
|
3003
|
+
}
|
|
3004
|
+
printBlank();
|
|
3005
|
+
if (gasStatus && !gasStatus.circuitBreaker && (balData?.gasReserve.sui ?? 0) >= 0.05) {
|
|
3006
|
+
printLine(` ${pc17.green("\u2713")} Gas is healthy \u2014 transactions should succeed`);
|
|
3007
|
+
} else if (gasStatus && !gasStatus.circuitBreaker) {
|
|
3008
|
+
printLine(` ${pc17.yellow("\u26A0")} Low SUI but gas station is online \u2014 sponsorship available`);
|
|
3009
|
+
} else {
|
|
3010
|
+
printLine(` ${pc17.red("\u2717")} Gas station issues detected \u2014 fund wallet with SUI directly`);
|
|
3011
|
+
printInfo("Send SUI to your address: t2000 address");
|
|
3012
|
+
}
|
|
3013
|
+
printBlank();
|
|
3014
|
+
} catch (error) {
|
|
3015
|
+
handleError(error);
|
|
3016
|
+
}
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
|
|
2958
3020
|
// src/program.ts
|
|
2959
3021
|
var require2 = createRequire(import.meta.url);
|
|
2960
3022
|
var { version: CLI_VERSION } = require2("../package.json");
|
|
@@ -2994,6 +3056,7 @@ function createProgram() {
|
|
|
2994
3056
|
registerInvest(program2);
|
|
2995
3057
|
registerPortfolio(program2);
|
|
2996
3058
|
registerClaimRewards(program2);
|
|
3059
|
+
registerGas(program2);
|
|
2997
3060
|
return program2;
|
|
2998
3061
|
}
|
|
2999
3062
|
|