@t2000/cli 5.5.1 → 5.6.1
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-V6MPPVOY.js → chunk-5AD7I65O.js} +3 -3
- package/dist/{chunk-HRGEZK3M.js → chunk-I2DCISQP.js} +3 -3
- package/dist/{chunk-YKME3ZZ5.js → chunk-SC3LZKLE.js} +5 -5
- package/dist/{chunk-ZIKS3DOX.js → chunk-TP3M7BAU.js} +67 -837
- package/dist/chunk-TP3M7BAU.js.map +1 -0
- package/dist/{chunk-FORXEDQJ.js → chunk-X6ON6NN5.js} +1447 -1466
- package/dist/chunk-X6ON6NN5.js.map +1 -0
- package/dist/{dist-OMYCTHXH.js → dist-5TKR5HBZ.js} +2027 -2770
- package/dist/dist-5TKR5HBZ.js.map +1 -0
- package/dist/{dist-OPR66FUQ.js → dist-PLJ2M72I.js} +6 -7
- package/dist/{esm-EIRCX523.js → esm-RF62MWQV.js} +2 -2
- package/dist/{grpc-IINTSDGR.js → grpc-OLWNGPHN.js} +4 -4
- package/dist/index.js +146 -42
- package/dist/index.js.map +1 -1
- package/dist/{x402-TTLPDM7N.js → x402-UYN72OS3.js} +4 -5
- package/dist/{x402-TTLPDM7N.js.map → x402-UYN72OS3.js.map} +1 -1
- package/package.json +3 -3
- package/dist/chunk-FORXEDQJ.js.map +0 -1
- package/dist/chunk-OCLKPYUU.js +0 -2
- package/dist/chunk-ZIKS3DOX.js.map +0 -1
- package/dist/dist-OMYCTHXH.js.map +0 -1
- package/dist/grpc-IINTSDGR.js.map +0 -1
- package/dist/transactions-JPL6KL3D.js +0 -40
- package/dist/transactions-JPL6KL3D.js.map +0 -1
- /package/dist/{chunk-V6MPPVOY.js.map → chunk-5AD7I65O.js.map} +0 -0
- /package/dist/{chunk-HRGEZK3M.js.map → chunk-I2DCISQP.js.map} +0 -0
- /package/dist/{chunk-YKME3ZZ5.js.map → chunk-SC3LZKLE.js.map} +0 -0
- /package/dist/{chunk-OCLKPYUU.js.map → dist-PLJ2M72I.js.map} +0 -0
- /package/dist/{esm-EIRCX523.js.map → esm-RF62MWQV.js.map} +0 -0
- /package/dist/{dist-OPR66FUQ.js.map → grpc-OLWNGPHN.js.map} +0 -0
|
@@ -171,12 +171,11 @@ import {
|
|
|
171
171
|
processEndpoint,
|
|
172
172
|
processFlattenRoutes,
|
|
173
173
|
restituteMsafeFastRouterSwapParams
|
|
174
|
-
} from "./chunk-
|
|
175
|
-
import "./chunk-
|
|
176
|
-
import "./chunk-
|
|
177
|
-
import "./chunk-
|
|
178
|
-
import "./chunk-
|
|
179
|
-
import "./chunk-HRGEZK3M.js";
|
|
174
|
+
} from "./chunk-SC3LZKLE.js";
|
|
175
|
+
import "./chunk-5AD7I65O.js";
|
|
176
|
+
import "./chunk-TP3M7BAU.js";
|
|
177
|
+
import "./chunk-X6ON6NN5.js";
|
|
178
|
+
import "./chunk-I2DCISQP.js";
|
|
180
179
|
import "./chunk-SVEVGZKZ.js";
|
|
181
180
|
export {
|
|
182
181
|
AFSUI,
|
|
@@ -351,4 +350,4 @@ export {
|
|
|
351
350
|
processFlattenRoutes,
|
|
352
351
|
restituteMsafeFastRouterSwapParams
|
|
353
352
|
};
|
|
354
|
-
//# sourceMappingURL=dist-
|
|
353
|
+
//# sourceMappingURL=dist-PLJ2M72I.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
randomBytes,
|
|
15
15
|
toBase64,
|
|
16
16
|
toHex
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-I2DCISQP.js";
|
|
18
18
|
import {
|
|
19
19
|
__commonJS,
|
|
20
20
|
__toESM
|
|
@@ -1081,4 +1081,4 @@ export {
|
|
|
1081
1081
|
jwtToAddress2 as jwtToAddress,
|
|
1082
1082
|
poseidonHash
|
|
1083
1083
|
};
|
|
1084
|
-
//# sourceMappingURL=esm-
|
|
1084
|
+
//# sourceMappingURL=esm-RF62MWQV.js.map
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
SuiGrpcClient,
|
|
6
6
|
isSuiGrpcClient,
|
|
7
7
|
types_exports
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-5AD7I65O.js";
|
|
9
|
+
import "./chunk-X6ON6NN5.js";
|
|
10
|
+
import "./chunk-I2DCISQP.js";
|
|
11
11
|
import "./chunk-SVEVGZKZ.js";
|
|
12
12
|
export {
|
|
13
13
|
GrpcCoreClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
SuiGrpcClient,
|
|
17
17
|
isSuiGrpcClient
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=grpc-
|
|
19
|
+
//# sourceMappingURL=grpc-OLWNGPHN.js.map
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'module'; import { fileURLToPat
|
|
|
3
3
|
import {
|
|
4
4
|
AggregatorClient,
|
|
5
5
|
Env
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SC3LZKLE.js";
|
|
7
7
|
import {
|
|
8
8
|
BalanceChange,
|
|
9
9
|
BaseClient,
|
|
@@ -16,12 +16,11 @@ import {
|
|
|
16
16
|
parseTransactionEffectsBcs,
|
|
17
17
|
transactionDataToGrpcTransaction,
|
|
18
18
|
transactionToGrpcJson
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-OCLKPYUU.js";
|
|
19
|
+
} from "./chunk-5AD7I65O.js";
|
|
21
20
|
import {
|
|
22
21
|
Transaction,
|
|
23
22
|
coinWithBalance
|
|
24
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-TP3M7BAU.js";
|
|
25
24
|
import {
|
|
26
25
|
ObjectError,
|
|
27
26
|
SUI_TYPE_ARG,
|
|
@@ -32,7 +31,7 @@ import {
|
|
|
32
31
|
fromBase64 as fromBase642,
|
|
33
32
|
suiBcs,
|
|
34
33
|
toBase64 as toBase642
|
|
35
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-X6ON6NN5.js";
|
|
36
35
|
import {
|
|
37
36
|
SIGNATURE_FLAG_TO_SCHEME,
|
|
38
37
|
SIGNATURE_SCHEME_TO_FLAG,
|
|
@@ -83,7 +82,7 @@ import {
|
|
|
83
82
|
split,
|
|
84
83
|
toBase64,
|
|
85
84
|
toHex
|
|
86
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-I2DCISQP.js";
|
|
87
86
|
import {
|
|
88
87
|
__commonJS,
|
|
89
88
|
__require,
|
|
@@ -26692,6 +26691,38 @@ var init_errors = __esm({
|
|
|
26692
26691
|
};
|
|
26693
26692
|
}
|
|
26694
26693
|
});
|
|
26694
|
+
function preflightFail(code, error) {
|
|
26695
|
+
return { valid: false, code, error };
|
|
26696
|
+
}
|
|
26697
|
+
function checkPositiveAmount(amount, label = "Amount", max = PREFLIGHT_MAX_AMOUNT) {
|
|
26698
|
+
if (typeof amount !== "number" || !Number.isFinite(amount)) {
|
|
26699
|
+
return preflightFail("INVALID_AMOUNT", `${label} must be a finite number`);
|
|
26700
|
+
}
|
|
26701
|
+
if (amount <= 0) {
|
|
26702
|
+
return preflightFail("INVALID_AMOUNT", `${label} must be greater than zero`);
|
|
26703
|
+
}
|
|
26704
|
+
if (amount > max) {
|
|
26705
|
+
return preflightFail("INVALID_AMOUNT", `${label} ${amount} exceeds the sane maximum (${max})`);
|
|
26706
|
+
}
|
|
26707
|
+
return PREFLIGHT_OK;
|
|
26708
|
+
}
|
|
26709
|
+
function checkSuiAddress(address, label = "recipient") {
|
|
26710
|
+
try {
|
|
26711
|
+
if (typeof address === "string" && address.trim() !== "" && isValidSuiAddress(normalizeSuiAddress(address))) {
|
|
26712
|
+
return PREFLIGHT_OK;
|
|
26713
|
+
}
|
|
26714
|
+
} catch {
|
|
26715
|
+
}
|
|
26716
|
+
return preflightFail("INVALID_ADDRESS", `Invalid ${label} address: ${address}`);
|
|
26717
|
+
}
|
|
26718
|
+
var PREFLIGHT_MAX_AMOUNT;
|
|
26719
|
+
var PREFLIGHT_OK;
|
|
26720
|
+
var init_preflight = __esm({
|
|
26721
|
+
"src/preflight.ts"() {
|
|
26722
|
+
PREFLIGHT_MAX_AMOUNT = 1e6;
|
|
26723
|
+
PREFLIGHT_OK = { valid: true };
|
|
26724
|
+
}
|
|
26725
|
+
});
|
|
26695
26726
|
var token_registry_exports = {};
|
|
26696
26727
|
__export(token_registry_exports, {
|
|
26697
26728
|
COIN_REGISTRY: () => COIN_REGISTRY,
|
|
@@ -26828,6 +26859,7 @@ var init_token_registry = __esm({
|
|
|
26828
26859
|
});
|
|
26829
26860
|
var coinSelection_exports = {};
|
|
26830
26861
|
__export(coinSelection_exports, {
|
|
26862
|
+
buildCoinToAddressBalanceMigration: () => buildCoinToAddressBalanceMigration,
|
|
26831
26863
|
fetchAllCoins: () => fetchAllCoins,
|
|
26832
26864
|
selectAndSplitCoin: () => selectAndSplitCoin,
|
|
26833
26865
|
selectSuiCoin: () => selectSuiCoin
|
|
@@ -26942,6 +26974,32 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
|
|
|
26942
26974
|
});
|
|
26943
26975
|
return { coin, effectiveAmount, swapAll };
|
|
26944
26976
|
}
|
|
26977
|
+
function buildCoinToAddressBalanceMigration(args) {
|
|
26978
|
+
const { coins, coinType, owner, minAmount } = args;
|
|
26979
|
+
const sorted = [...coins].filter((c) => c.balance > 0n).sort((a, b) => b.balance > a.balance ? 1 : b.balance < a.balance ? -1 : 0);
|
|
26980
|
+
const selected = [];
|
|
26981
|
+
let migratedRaw = 0n;
|
|
26982
|
+
for (const c of sorted) {
|
|
26983
|
+
if (migratedRaw >= minAmount) break;
|
|
26984
|
+
selected.push(c);
|
|
26985
|
+
migratedRaw += c.balance;
|
|
26986
|
+
}
|
|
26987
|
+
if (migratedRaw < minAmount) {
|
|
26988
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${coinType} coin objects to migrate`, {
|
|
26989
|
+
available: migratedRaw.toString(),
|
|
26990
|
+
required: minAmount.toString()
|
|
26991
|
+
});
|
|
26992
|
+
}
|
|
26993
|
+
const tx = new Transaction();
|
|
26994
|
+
for (const c of selected) {
|
|
26995
|
+
tx.moveCall({
|
|
26996
|
+
target: "0x2::coin::send_funds",
|
|
26997
|
+
typeArguments: [coinType],
|
|
26998
|
+
arguments: [tx.object(c.objectId), tx.pure.address(owner)]
|
|
26999
|
+
});
|
|
27000
|
+
}
|
|
27001
|
+
return { tx, migratedRaw };
|
|
27002
|
+
}
|
|
26945
27003
|
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
|
|
26946
27004
|
if (sponsoredContext) {
|
|
26947
27005
|
const { SUI_TYPE: SUI_TYPE2 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
|
|
@@ -26965,10 +27023,28 @@ __export(cetus_swap_exports, {
|
|
|
26965
27023
|
findSwapRoute: () => findSwapRoute,
|
|
26966
27024
|
isCetusRouteFresh: () => isCetusRouteFresh,
|
|
26967
27025
|
isPrecomputedRouteCompatibleWithProviders: () => isPrecomputedRouteCompatibleWithProviders,
|
|
27026
|
+
preflightSwap: () => preflightSwap,
|
|
26968
27027
|
resolveTokenType: () => resolveTokenType,
|
|
26969
27028
|
serializeCetusRoute: () => serializeCetusRoute,
|
|
26970
27029
|
verifyCetusRouteCoinMatch: () => verifyCetusRouteCoinMatch
|
|
26971
27030
|
});
|
|
27031
|
+
function preflightSwap(input) {
|
|
27032
|
+
if (typeof input.from !== "string" || input.from.trim() === "") {
|
|
27033
|
+
return preflightFail("INVALID_ASSET", "A `from` token is required to swap");
|
|
27034
|
+
}
|
|
27035
|
+
if (typeof input.to !== "string" || input.to.trim() === "") {
|
|
27036
|
+
return preflightFail("INVALID_ASSET", "A `to` token is required to swap");
|
|
27037
|
+
}
|
|
27038
|
+
const amountCheck = checkPositiveAmount(input.amount, "Amount", Number.POSITIVE_INFINITY);
|
|
27039
|
+
if (!amountCheck.valid) return amountCheck;
|
|
27040
|
+
const resolvedFrom = resolveTokenType(input.from);
|
|
27041
|
+
const resolvedTo = resolveTokenType(input.to);
|
|
27042
|
+
const sameToken = input.from.trim() === input.to.trim() || resolvedFrom !== null && resolvedFrom === resolvedTo;
|
|
27043
|
+
if (sameToken) {
|
|
27044
|
+
return preflightFail("INVALID_ASSET", `Cannot swap ${input.from} to itself`);
|
|
27045
|
+
}
|
|
27046
|
+
return PREFLIGHT_OK;
|
|
27047
|
+
}
|
|
26972
27048
|
function serializeCetusRoute(route, context) {
|
|
26973
27049
|
return {
|
|
26974
27050
|
routerData: serializeRouterDataV3(route.routerData),
|
|
@@ -27221,6 +27297,7 @@ var clientCache;
|
|
|
27221
27297
|
var init_cetus_swap = __esm({
|
|
27222
27298
|
"src/protocols/cetus-swap.ts"() {
|
|
27223
27299
|
init_token_registry();
|
|
27300
|
+
init_preflight();
|
|
27224
27301
|
init_token_registry();
|
|
27225
27302
|
OVERLAY_FEE_RATE = 1e-3;
|
|
27226
27303
|
clientCache = /* @__PURE__ */ new Map();
|
|
@@ -27567,8 +27644,33 @@ async function executeTx(client, signer, buildTx, options = {}) {
|
|
|
27567
27644
|
return { digest: txn.digest, gasCostSui, effects };
|
|
27568
27645
|
}
|
|
27569
27646
|
init_errors();
|
|
27647
|
+
init_preflight();
|
|
27648
|
+
function preflightPay(input) {
|
|
27649
|
+
if (typeof input.url !== "string" || input.url.trim() === "") {
|
|
27650
|
+
return preflightFail("FACILITATOR_REJECTION", "A target URL is required to pay");
|
|
27651
|
+
}
|
|
27652
|
+
let parsed;
|
|
27653
|
+
try {
|
|
27654
|
+
parsed = new URL(input.url);
|
|
27655
|
+
} catch {
|
|
27656
|
+
return preflightFail("FACILITATOR_REJECTION", `Invalid URL: ${input.url}`);
|
|
27657
|
+
}
|
|
27658
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
27659
|
+
return preflightFail(
|
|
27660
|
+
"FACILITATOR_REJECTION",
|
|
27661
|
+
`URL must be http(s): got ${parsed.protocol}//`
|
|
27662
|
+
);
|
|
27663
|
+
}
|
|
27664
|
+
if (input.maxPrice !== void 0) {
|
|
27665
|
+
const priceCheck = checkPositiveAmount(input.maxPrice, "maxPrice");
|
|
27666
|
+
if (!priceCheck.valid) return priceCheck;
|
|
27667
|
+
}
|
|
27668
|
+
return PREFLIGHT_OK;
|
|
27669
|
+
}
|
|
27570
27670
|
async function payWithMpp(args) {
|
|
27571
27671
|
const { signer, client, options } = args;
|
|
27672
|
+
const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
|
|
27673
|
+
if (!pf.valid) throw new T2000Error(pf.code, pf.error);
|
|
27572
27674
|
const method = (options.method ?? "GET").toUpperCase();
|
|
27573
27675
|
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
27574
27676
|
const reqInit = {
|
|
@@ -27600,7 +27702,7 @@ async function pickSuiExactRequirements(response, network) {
|
|
|
27600
27702
|
}
|
|
27601
27703
|
async function payViaX402(args) {
|
|
27602
27704
|
const { signer, client, options, reqInit, requirements } = args;
|
|
27603
|
-
const { buildX402SignedPayment, X402_PAYMENT_HEADER, X402_PAYMENT_RESPONSE_HEADER } = await import("./x402-
|
|
27705
|
+
const { buildX402SignedPayment, X402_PAYMENT_HEADER, X402_PAYMENT_RESPONSE_HEADER } = await import("./x402-UYN72OS3.js");
|
|
27604
27706
|
const amountRaw = BigInt(requirements.maxAmountRequired);
|
|
27605
27707
|
const migrationGasSui = await ensureAddressBalanceCovers({
|
|
27606
27708
|
signer,
|
|
@@ -27648,40 +27750,26 @@ async function ensureAddressBalanceCovers(args) {
|
|
|
27648
27750
|
required: amountRaw.toString()
|
|
27649
27751
|
});
|
|
27650
27752
|
}
|
|
27753
|
+
const coins = [];
|
|
27651
27754
|
let coinSum = 0n;
|
|
27652
27755
|
let cursor;
|
|
27653
27756
|
let hasNext = true;
|
|
27654
27757
|
while (hasNext) {
|
|
27655
27758
|
const page = await client.core.listCoins({ owner, coinType: asset, cursor: cursor ?? void 0 });
|
|
27656
|
-
for (const c of page.objects)
|
|
27759
|
+
for (const c of page.objects) {
|
|
27760
|
+
coins.push({ objectId: c.objectId, balance: BigInt(c.balance) });
|
|
27761
|
+
coinSum += BigInt(c.balance);
|
|
27762
|
+
}
|
|
27657
27763
|
cursor = page.cursor;
|
|
27658
27764
|
hasNext = page.hasNextPage;
|
|
27659
27765
|
}
|
|
27660
27766
|
const addressBalance = total - coinSum;
|
|
27661
27767
|
if (addressBalance >= amountRaw) return 0;
|
|
27662
27768
|
const shortfall = amountRaw - addressBalance;
|
|
27663
|
-
const {
|
|
27664
|
-
const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
|
|
27769
|
+
const { buildCoinToAddressBalanceMigration: buildCoinToAddressBalanceMigration2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
|
|
27665
27770
|
const grpcClient = await makeGrpcBuildClient(client);
|
|
27666
|
-
const
|
|
27667
|
-
|
|
27668
|
-
signer,
|
|
27669
|
-
async () => {
|
|
27670
|
-
const tx = new Transaction6();
|
|
27671
|
-
const { coin } = await selectAndSplitCoin2(tx, client, owner, asset, shortfall, {
|
|
27672
|
-
sponsoredContext: true,
|
|
27673
|
-
// coin-objects-only — never the address balance
|
|
27674
|
-
allowSwapAll: false
|
|
27675
|
-
});
|
|
27676
|
-
tx.moveCall({
|
|
27677
|
-
target: "0x2::coin::send_funds",
|
|
27678
|
-
typeArguments: [asset],
|
|
27679
|
-
arguments: [coin, tx.pure.address(owner)]
|
|
27680
|
-
});
|
|
27681
|
-
return tx;
|
|
27682
|
-
},
|
|
27683
|
-
{ buildClient: grpcClient }
|
|
27684
|
-
);
|
|
27771
|
+
const { tx } = buildCoinToAddressBalanceMigration2({ coins, coinType: asset, owner, minAmount: shortfall });
|
|
27772
|
+
const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
|
|
27685
27773
|
return migration.gasCostSui;
|
|
27686
27774
|
}
|
|
27687
27775
|
async function finalize(response, opts) {
|
|
@@ -27695,7 +27783,7 @@ async function finalize(response, opts) {
|
|
|
27695
27783
|
return { status: response.status, body, paid: opts.paid };
|
|
27696
27784
|
}
|
|
27697
27785
|
async function makeGrpcBuildClient(client) {
|
|
27698
|
-
const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-
|
|
27786
|
+
const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-OLWNGPHN.js");
|
|
27699
27787
|
const network = client.network === "testnet" ? "testnet" : "mainnet";
|
|
27700
27788
|
const baseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
|
|
27701
27789
|
return new SuiGrpcClient2({ baseUrl, network });
|
|
@@ -27723,7 +27811,7 @@ var ZkLoginSigner = class {
|
|
|
27723
27811
|
return this.userAddress;
|
|
27724
27812
|
}
|
|
27725
27813
|
async signTransaction(txBytes) {
|
|
27726
|
-
const { getZkLoginSignature } = await import("./esm-
|
|
27814
|
+
const { getZkLoginSignature } = await import("./esm-RF62MWQV.js");
|
|
27727
27815
|
const ephSig = await this.ephemeralKeypair.signTransaction(txBytes);
|
|
27728
27816
|
return {
|
|
27729
27817
|
signature: getZkLoginSignature({
|
|
@@ -27734,7 +27822,7 @@ var ZkLoginSigner = class {
|
|
|
27734
27822
|
};
|
|
27735
27823
|
}
|
|
27736
27824
|
async signPersonalMessage(messageBytes) {
|
|
27737
|
-
const { getZkLoginSignature } = await import("./esm-
|
|
27825
|
+
const { getZkLoginSignature } = await import("./esm-RF62MWQV.js");
|
|
27738
27826
|
const { signature: ephSig, bytes } = await this.ephemeralKeypair.signPersonalMessage(messageBytes);
|
|
27739
27827
|
return {
|
|
27740
27828
|
signature: getZkLoginSignature({
|
|
@@ -27763,6 +27851,25 @@ for (const [key, info] of Object.entries(SUPPORTED_ASSETS)) {
|
|
|
27763
27851
|
ASSET_LOOKUP.set(info.displayName.toUpperCase(), key);
|
|
27764
27852
|
}
|
|
27765
27853
|
}
|
|
27854
|
+
init_preflight();
|
|
27855
|
+
function preflightSend(input) {
|
|
27856
|
+
try {
|
|
27857
|
+
assertAllowedAsset("send", input.asset);
|
|
27858
|
+
} catch (e) {
|
|
27859
|
+
return preflightFail("INVALID_ASSET", e.message);
|
|
27860
|
+
}
|
|
27861
|
+
const amountCheck = checkPositiveAmount(input.amount);
|
|
27862
|
+
if (!amountCheck.valid) return amountCheck;
|
|
27863
|
+
if ((input.asset === "USDC" || input.asset === "USDsui") && input.amount < GASLESS_MIN_STABLE_AMOUNT) {
|
|
27864
|
+
return preflightFail(
|
|
27865
|
+
"INVALID_AMOUNT",
|
|
27866
|
+
`Minimum gasless transfer is ${GASLESS_MIN_STABLE_AMOUNT} ${input.asset}. Got ${input.amount}.`
|
|
27867
|
+
);
|
|
27868
|
+
}
|
|
27869
|
+
const addressCheck = checkSuiAddress(input.to);
|
|
27870
|
+
if (!addressCheck.valid) return addressCheck;
|
|
27871
|
+
return PREFLIGHT_OK;
|
|
27872
|
+
}
|
|
27766
27873
|
async function buildSendTx({
|
|
27767
27874
|
client,
|
|
27768
27875
|
address,
|
|
@@ -27770,17 +27877,11 @@ async function buildSendTx({
|
|
|
27770
27877
|
amount,
|
|
27771
27878
|
asset
|
|
27772
27879
|
}) {
|
|
27773
|
-
|
|
27880
|
+
const pf = preflightSend({ to, amount, asset });
|
|
27881
|
+
if (!pf.valid) throw new T2000Error(pf.code, pf.error);
|
|
27774
27882
|
const recipient = validateAddress(to);
|
|
27775
27883
|
const assetInfo = SUPPORTED_ASSETS[asset];
|
|
27776
27884
|
if (!assetInfo) throw new T2000Error("ASSET_NOT_SUPPORTED", `Asset ${asset} is not supported`);
|
|
27777
|
-
if (amount <= 0) throw new T2000Error("INVALID_AMOUNT", "Amount must be greater than zero");
|
|
27778
|
-
if ((asset === "USDC" || asset === "USDsui") && amount < GASLESS_MIN_STABLE_AMOUNT) {
|
|
27779
|
-
throw new T2000Error(
|
|
27780
|
-
"INVALID_AMOUNT",
|
|
27781
|
-
`Minimum gasless transfer is ${GASLESS_MIN_STABLE_AMOUNT} ${asset}. Got ${amount}.`
|
|
27782
|
-
);
|
|
27783
|
-
}
|
|
27784
27885
|
const rawAmount = displayToRaw(amount, assetInfo.decimals);
|
|
27785
27886
|
const tx = new Transaction();
|
|
27786
27887
|
tx.setSender(address);
|
|
@@ -28463,7 +28564,9 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
28463
28564
|
amountUsd: approxUsdValue(params.from, params.amount) ?? 0,
|
|
28464
28565
|
force: params.force
|
|
28465
28566
|
});
|
|
28466
|
-
const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
28567
|
+
const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2, resolveTokenType: resolveTokenType2, preflightSwap: preflightSwap2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
|
|
28568
|
+
const pf = preflightSwap2({ from: params.from, to: params.to, amount: params.amount });
|
|
28569
|
+
if (!pf.valid) throw new T2000Error(pf.code, pf.error);
|
|
28467
28570
|
const fromType = resolveTokenType2(params.from);
|
|
28468
28571
|
const toType = resolveTokenType2(params.to);
|
|
28469
28572
|
if (!fromType) throw new T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.from}. Provide the full coin type.`);
|
|
@@ -28797,6 +28900,7 @@ init_errors();
|
|
|
28797
28900
|
init_swap_quote();
|
|
28798
28901
|
init_cetus_swap();
|
|
28799
28902
|
init_token_registry();
|
|
28903
|
+
init_preflight();
|
|
28800
28904
|
|
|
28801
28905
|
// ../../node_modules/.pnpm/@inquirer+core@10.3.2_@types+node@20.19.37/node_modules/@inquirer/core/dist/esm/lib/key.js
|
|
28802
28906
|
var isUpKey = (key, keybindings = []) => (
|
|
@@ -32390,7 +32494,7 @@ function registerMcpStart(parent) {
|
|
|
32390
32494
|
parent.command("start", { isDefault: true }).description("Start MCP server (stdio transport \u2014 for AI client integration)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
|
|
32391
32495
|
let mod2;
|
|
32392
32496
|
try {
|
|
32393
|
-
mod2 = await import("./dist-
|
|
32497
|
+
mod2 = await import("./dist-5TKR5HBZ.js");
|
|
32394
32498
|
} catch {
|
|
32395
32499
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
32396
32500
|
process.exit(1);
|