@t2000/sdk 0.22.3 → 0.27.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/README.md +1 -0
- package/dist/adapters/index.cjs +3 -3
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +3 -3
- package/dist/adapters/index.js.map +1 -1
- package/dist/browser.cjs +3 -3
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +3 -3
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +300 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -6
- package/dist/index.d.ts +117 -6
- package/dist/index.js +280 -6
- package/dist/index.js.map +1 -1
- package/dist/{token-registry-bf_caDsv.d.cts → token-registry-BYEXDwjs.d.cts} +13 -2
- package/dist/{token-registry-DLEKjV8I.d.ts → token-registry-CX_RDDO_.d.ts} +13 -2
- package/dist/{types-XWEUAS-X.d.cts → types-D9NstGUu.d.cts} +75 -1
- package/dist/{types-XWEUAS-X.d.ts → types-D9NstGUu.d.ts} +75 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var jsonRpc = require('@mysten/sui/jsonRpc');
|
|
|
7
7
|
var utils = require('@mysten/sui/utils');
|
|
8
8
|
var ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
9
9
|
var cryptography = require('@mysten/sui/cryptography');
|
|
10
|
-
var crypto = require('crypto');
|
|
10
|
+
var crypto$1 = require('crypto');
|
|
11
11
|
var promises = require('fs/promises');
|
|
12
12
|
var path = require('path');
|
|
13
13
|
var os = require('os');
|
|
@@ -490,15 +490,27 @@ function assertAllowedAsset(op, asset) {
|
|
|
490
490
|
);
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
|
-
var T2000_PACKAGE_ID = process.env.T2000_PACKAGE_ID ?? "
|
|
494
|
-
var T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? "
|
|
495
|
-
var
|
|
493
|
+
var T2000_PACKAGE_ID = process.env.T2000_PACKAGE_ID ?? "0xd775fcc66eae26797654d435d751dea56b82eeb999de51fd285348e573b968ad";
|
|
494
|
+
var T2000_CONFIG_ID = process.env.T2000_CONFIG_ID ?? "0x08ba26f0d260b5edf6a19c71492b3eb914906a7419baf2df1426765157e5862a";
|
|
495
|
+
var T2000_ADMIN_CAP_ID = "0xa97bfff140f5a2c268a03fe5422d382c228057deb7bcfdaf2967ca18b9bdbbd9";
|
|
496
|
+
var T2000_TREASURY_ID = process.env.T2000_TREASURY_ID ?? "0xf420ec0dcad44433042fb56e1413fb88d3ff65be94fcf425ef9ff750164590e8";
|
|
496
497
|
var DEFAULT_NETWORK = "mainnet";
|
|
497
498
|
var DEFAULT_RPC_URL = "https://fullnode.mainnet.sui.io:443";
|
|
498
499
|
var DEFAULT_KEY_PATH = "~/.t2000/wallet.key";
|
|
499
500
|
var API_BASE_URL = process.env.T2000_API_URL ?? "https://api.t2000.ai";
|
|
500
501
|
var CETUS_USDC_SUI_POOL = "0x51e883ba7c0b566a26cbc8a94cd33eb0abd418a77cc1e60ad22fd9b1f29cd2ab";
|
|
501
502
|
var GAS_RESERVE_MIN = 0.05;
|
|
503
|
+
var ALLOWANCE_FEATURES = {
|
|
504
|
+
BRIEFING: 0,
|
|
505
|
+
YIELD_ALERT: 1,
|
|
506
|
+
PAYMENT_ALERT: 2,
|
|
507
|
+
ACTION_REMIND: 3,
|
|
508
|
+
SESSION: 4,
|
|
509
|
+
AUTO_COMPOUND: 5,
|
|
510
|
+
DCA: 6,
|
|
511
|
+
HF_ALERT: 7
|
|
512
|
+
};
|
|
513
|
+
var FEATURES_ALL = 255;
|
|
502
514
|
|
|
503
515
|
// src/utils/sui.ts
|
|
504
516
|
init_errors();
|
|
@@ -534,13 +546,13 @@ function expandPath(p) {
|
|
|
534
546
|
return path.resolve(p);
|
|
535
547
|
}
|
|
536
548
|
function deriveKey(passphrase, salt) {
|
|
537
|
-
return crypto.scryptSync(passphrase, salt, 32, { N: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P });
|
|
549
|
+
return crypto$1.scryptSync(passphrase, salt, 32, { N: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P });
|
|
538
550
|
}
|
|
539
551
|
function encrypt(data, passphrase) {
|
|
540
|
-
const salt = crypto.randomBytes(SALT_LENGTH);
|
|
552
|
+
const salt = crypto$1.randomBytes(SALT_LENGTH);
|
|
541
553
|
const key = deriveKey(passphrase, salt);
|
|
542
|
-
const iv = crypto.randomBytes(IV_LENGTH);
|
|
543
|
-
const cipher = crypto.createCipheriv(ALGORITHM, key, iv);
|
|
554
|
+
const iv = crypto$1.randomBytes(IV_LENGTH);
|
|
555
|
+
const cipher = crypto$1.createCipheriv(ALGORITHM, key, iv);
|
|
544
556
|
const ciphertext = Buffer.concat([cipher.update(data), cipher.final()]);
|
|
545
557
|
const tag = cipher.getAuthTag();
|
|
546
558
|
return {
|
|
@@ -558,7 +570,7 @@ function decrypt(encrypted, passphrase) {
|
|
|
558
570
|
const iv = Buffer.from(encrypted.iv, "hex");
|
|
559
571
|
const tag = Buffer.from(encrypted.tag, "hex");
|
|
560
572
|
const ciphertext = Buffer.from(encrypted.ciphertext, "hex");
|
|
561
|
-
const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);
|
|
573
|
+
const decipher = crypto$1.createDecipheriv(ALGORITHM, key, iv);
|
|
562
574
|
decipher.setAuthTag(tag);
|
|
563
575
|
try {
|
|
564
576
|
return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
@@ -891,7 +903,7 @@ function extractCommands(txBlock) {
|
|
|
891
903
|
if (!data || typeof data !== "object") return result;
|
|
892
904
|
const inner = "transaction" in data ? data.transaction : void 0;
|
|
893
905
|
if (!inner || typeof inner !== "object") return result;
|
|
894
|
-
const commands = "commands" in inner ? inner.commands : void 0;
|
|
906
|
+
const commands = "commands" in inner ? inner.commands : "transactions" in inner ? inner.transactions : void 0;
|
|
895
907
|
if (!Array.isArray(commands)) return result;
|
|
896
908
|
for (const cmd of commands) {
|
|
897
909
|
if (cmd.MoveCall) {
|
|
@@ -1648,7 +1660,7 @@ function solveHashcash(challenge) {
|
|
|
1648
1660
|
let counter = 0;
|
|
1649
1661
|
while (true) {
|
|
1650
1662
|
const stamp = `${challenge}${counter.toString(16)}`;
|
|
1651
|
-
const hash = crypto.createHash("sha256").update(stamp).digest();
|
|
1663
|
+
const hash = crypto$1.createHash("sha256").update(stamp).digest();
|
|
1652
1664
|
if (hasLeadingZeroBits(hash, bits)) return stamp;
|
|
1653
1665
|
counter++;
|
|
1654
1666
|
}
|
|
@@ -2617,6 +2629,32 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
2617
2629
|
].join("\n")
|
|
2618
2630
|
};
|
|
2619
2631
|
}
|
|
2632
|
+
receive(params) {
|
|
2633
|
+
const amount = params?.amount ?? null;
|
|
2634
|
+
const currency = params?.currency ?? "USDC";
|
|
2635
|
+
const memo = params?.memo ?? null;
|
|
2636
|
+
const label = params?.label ?? null;
|
|
2637
|
+
const qrParts = [`sui:${this._address}`];
|
|
2638
|
+
const queryParams = [];
|
|
2639
|
+
if (amount != null) queryParams.push(`amount=${amount}`);
|
|
2640
|
+
if (currency !== "SUI") queryParams.push(`currency=${currency}`);
|
|
2641
|
+
if (memo) queryParams.push(`memo=${encodeURIComponent(memo)}`);
|
|
2642
|
+
if (label) queryParams.push(`label=${encodeURIComponent(label)}`);
|
|
2643
|
+
const qrUri = queryParams.length > 0 ? `${qrParts[0]}?${queryParams.join("&")}` : qrParts[0];
|
|
2644
|
+
const amountStr = amount != null ? `$${amount.toFixed(2)} ` : "";
|
|
2645
|
+
const displayParts = [`Send ${amountStr}${currency} to ${truncateAddress(this._address)}`];
|
|
2646
|
+
if (memo) displayParts.push(`Memo: ${memo}`);
|
|
2647
|
+
return {
|
|
2648
|
+
address: this._address,
|
|
2649
|
+
network: "mainnet",
|
|
2650
|
+
amount,
|
|
2651
|
+
currency,
|
|
2652
|
+
memo,
|
|
2653
|
+
label,
|
|
2654
|
+
qrUri,
|
|
2655
|
+
displayText: displayParts.join("\n")
|
|
2656
|
+
};
|
|
2657
|
+
}
|
|
2620
2658
|
exportKey() {
|
|
2621
2659
|
return exportPrivateKey(this.keypair);
|
|
2622
2660
|
}
|
|
@@ -3263,6 +3301,190 @@ async function callUsdcSponsorApi(address) {
|
|
|
3263
3301
|
|
|
3264
3302
|
// src/index.ts
|
|
3265
3303
|
init_errors();
|
|
3304
|
+
var USDC_TYPE2 = SUPPORTED_ASSETS.USDC.type;
|
|
3305
|
+
function buildCreateAllowanceTx(options = {}) {
|
|
3306
|
+
const tx = new transactions.Transaction();
|
|
3307
|
+
tx.moveCall({
|
|
3308
|
+
target: `${T2000_PACKAGE_ID}::allowance::create`,
|
|
3309
|
+
typeArguments: [USDC_TYPE2],
|
|
3310
|
+
arguments: [
|
|
3311
|
+
tx.pure.u64(options.permittedFeatures ?? BigInt(FEATURES_ALL)),
|
|
3312
|
+
tx.pure.u64(options.expiresAt ?? 0n),
|
|
3313
|
+
tx.pure.u64(options.dailyLimit ?? 0n),
|
|
3314
|
+
tx.object(CLOCK_ID)
|
|
3315
|
+
]
|
|
3316
|
+
});
|
|
3317
|
+
return tx;
|
|
3318
|
+
}
|
|
3319
|
+
function addDepositAllowanceTx(tx, allowanceId, paymentCoin) {
|
|
3320
|
+
tx.moveCall({
|
|
3321
|
+
target: `${T2000_PACKAGE_ID}::allowance::deposit`,
|
|
3322
|
+
typeArguments: [USDC_TYPE2],
|
|
3323
|
+
arguments: [tx.object(allowanceId), paymentCoin]
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
function buildDepositAllowanceTx(allowanceId, usdcCoin, amount) {
|
|
3327
|
+
const tx = new transactions.Transaction();
|
|
3328
|
+
const [split] = tx.splitCoins(tx.object(usdcCoin), [tx.pure.u64(amount)]);
|
|
3329
|
+
addDepositAllowanceTx(tx, allowanceId, split);
|
|
3330
|
+
return tx;
|
|
3331
|
+
}
|
|
3332
|
+
function buildAdminDepositAllowanceTx(allowanceId, usdcCoin, amount) {
|
|
3333
|
+
const tx = new transactions.Transaction();
|
|
3334
|
+
const [split] = tx.splitCoins(tx.object(usdcCoin), [tx.pure.u64(amount)]);
|
|
3335
|
+
tx.moveCall({
|
|
3336
|
+
target: `${T2000_PACKAGE_ID}::allowance::admin_deposit`,
|
|
3337
|
+
typeArguments: [USDC_TYPE2],
|
|
3338
|
+
arguments: [
|
|
3339
|
+
tx.object(allowanceId),
|
|
3340
|
+
tx.object(T2000_ADMIN_CAP_ID),
|
|
3341
|
+
split
|
|
3342
|
+
]
|
|
3343
|
+
});
|
|
3344
|
+
return tx;
|
|
3345
|
+
}
|
|
3346
|
+
function buildDeductAllowanceTx(allowanceId, amount, feature) {
|
|
3347
|
+
const tx = new transactions.Transaction();
|
|
3348
|
+
tx.moveCall({
|
|
3349
|
+
target: `${T2000_PACKAGE_ID}::allowance::deduct`,
|
|
3350
|
+
typeArguments: [USDC_TYPE2],
|
|
3351
|
+
arguments: [
|
|
3352
|
+
tx.object(allowanceId),
|
|
3353
|
+
tx.object(T2000_CONFIG_ID),
|
|
3354
|
+
tx.object(T2000_ADMIN_CAP_ID),
|
|
3355
|
+
tx.pure.u64(amount),
|
|
3356
|
+
tx.pure.u8(feature),
|
|
3357
|
+
tx.object(CLOCK_ID)
|
|
3358
|
+
]
|
|
3359
|
+
});
|
|
3360
|
+
return tx;
|
|
3361
|
+
}
|
|
3362
|
+
function buildWithdrawAllowanceTx(allowanceId) {
|
|
3363
|
+
const tx = new transactions.Transaction();
|
|
3364
|
+
tx.moveCall({
|
|
3365
|
+
target: `${T2000_PACKAGE_ID}::allowance::withdraw`,
|
|
3366
|
+
typeArguments: [USDC_TYPE2],
|
|
3367
|
+
arguments: [tx.object(allowanceId)]
|
|
3368
|
+
});
|
|
3369
|
+
return tx;
|
|
3370
|
+
}
|
|
3371
|
+
function buildWithdrawAmountAllowanceTx(allowanceId, amount) {
|
|
3372
|
+
const tx = new transactions.Transaction();
|
|
3373
|
+
tx.moveCall({
|
|
3374
|
+
target: `${T2000_PACKAGE_ID}::allowance::withdraw_amount`,
|
|
3375
|
+
typeArguments: [USDC_TYPE2],
|
|
3376
|
+
arguments: [tx.object(allowanceId), tx.pure.u64(amount)]
|
|
3377
|
+
});
|
|
3378
|
+
return tx;
|
|
3379
|
+
}
|
|
3380
|
+
async function getAllowance(client, allowanceId) {
|
|
3381
|
+
const obj = await client.getObject({
|
|
3382
|
+
id: allowanceId,
|
|
3383
|
+
options: { showContent: true, showType: true }
|
|
3384
|
+
});
|
|
3385
|
+
if (!obj.data?.content || obj.data.content.dataType !== "moveObject") {
|
|
3386
|
+
throw new Error(`Allowance ${allowanceId} not found or is not a Move object`);
|
|
3387
|
+
}
|
|
3388
|
+
const fields = obj.data.content.fields;
|
|
3389
|
+
const coinType = extractCoinType(obj.data.content.type);
|
|
3390
|
+
return {
|
|
3391
|
+
id: allowanceId,
|
|
3392
|
+
owner: fields.owner,
|
|
3393
|
+
balance: parseU64Field(fields.balance),
|
|
3394
|
+
totalDeposited: parseU64Field(fields.total_deposited),
|
|
3395
|
+
totalSpent: parseU64Field(fields.total_spent),
|
|
3396
|
+
createdAt: Number(fields.created_at),
|
|
3397
|
+
coinType,
|
|
3398
|
+
permittedFeatures: parseU64Field(fields.permitted_features),
|
|
3399
|
+
expiresAt: Number(fields.expires_at),
|
|
3400
|
+
dailyLimit: parseU64Field(fields.daily_limit),
|
|
3401
|
+
dailySpent: parseU64Field(fields.daily_spent),
|
|
3402
|
+
windowStart: Number(fields.window_start)
|
|
3403
|
+
};
|
|
3404
|
+
}
|
|
3405
|
+
async function getAllowanceBalance(client, allowanceId) {
|
|
3406
|
+
const info = await getAllowance(client, allowanceId);
|
|
3407
|
+
return info.balance;
|
|
3408
|
+
}
|
|
3409
|
+
function parseU64Field(raw) {
|
|
3410
|
+
if (typeof raw === "string" || typeof raw === "number") return BigInt(raw);
|
|
3411
|
+
if (typeof raw === "object" && raw !== null && "value" in raw) {
|
|
3412
|
+
return BigInt(raw.value);
|
|
3413
|
+
}
|
|
3414
|
+
return 0n;
|
|
3415
|
+
}
|
|
3416
|
+
function extractCoinType(objectType) {
|
|
3417
|
+
const match = objectType.match(/<(.+)>/);
|
|
3418
|
+
return match ? match[1] : "unknown";
|
|
3419
|
+
}
|
|
3420
|
+
|
|
3421
|
+
// src/protocols/financialSummary.ts
|
|
3422
|
+
var HF_WARN_THRESHOLD = 1.8;
|
|
3423
|
+
var HF_CRITICAL_THRESHOLD = 1.3;
|
|
3424
|
+
var HF_FALLBACK = {
|
|
3425
|
+
healthFactor: Infinity,
|
|
3426
|
+
supplied: 0,
|
|
3427
|
+
borrowed: 0,
|
|
3428
|
+
maxBorrow: 0,
|
|
3429
|
+
liquidationThreshold: 0.75
|
|
3430
|
+
};
|
|
3431
|
+
function classifyHF(hf, hasBorrow) {
|
|
3432
|
+
if (!hasBorrow || !Number.isFinite(hf)) return "none";
|
|
3433
|
+
if (hf <= HF_CRITICAL_THRESHOLD) return "critical";
|
|
3434
|
+
if (hf <= HF_WARN_THRESHOLD) return "warn";
|
|
3435
|
+
return "none";
|
|
3436
|
+
}
|
|
3437
|
+
async function fetchSuiPriceUsd(client) {
|
|
3438
|
+
try {
|
|
3439
|
+
const pool = await client.getObject({
|
|
3440
|
+
id: CETUS_USDC_SUI_POOL,
|
|
3441
|
+
options: { showContent: true }
|
|
3442
|
+
});
|
|
3443
|
+
if (pool.data?.content?.dataType === "moveObject") {
|
|
3444
|
+
const fields = pool.data.content.fields;
|
|
3445
|
+
const sqrtPrice = BigInt(String(fields.current_sqrt_price ?? "0"));
|
|
3446
|
+
if (sqrtPrice > 0n) {
|
|
3447
|
+
const Q64 = 2n ** 64n;
|
|
3448
|
+
const sqrtFloat = Number(sqrtPrice) / Number(Q64);
|
|
3449
|
+
const price = 1e3 / (sqrtFloat * sqrtFloat);
|
|
3450
|
+
if (price > 0.01 && price < 1e3) return price;
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
} catch {
|
|
3454
|
+
}
|
|
3455
|
+
return 1;
|
|
3456
|
+
}
|
|
3457
|
+
async function getFinancialSummary(client, walletAddress, options = {}) {
|
|
3458
|
+
const [usdcBal, suiBal, hf, rates, suiPrice, allowance] = await Promise.all([
|
|
3459
|
+
client.getBalance({ owner: walletAddress, coinType: SUPPORTED_ASSETS.USDC.type }).catch(() => ({ totalBalance: "0" })),
|
|
3460
|
+
client.getBalance({ owner: walletAddress, coinType: SUPPORTED_ASSETS.SUI.type }).catch(() => ({ totalBalance: "0" })),
|
|
3461
|
+
getHealthFactor(client, walletAddress).catch(() => HF_FALLBACK),
|
|
3462
|
+
getRates(client),
|
|
3463
|
+
fetchSuiPriceUsd(client),
|
|
3464
|
+
options.allowanceId ? getAllowanceBalance(client, options.allowanceId).catch(() => null) : Promise.resolve(null)
|
|
3465
|
+
]);
|
|
3466
|
+
const usdcAvailable = Number(usdcBal.totalBalance) / 10 ** SUPPORTED_ASSETS.USDC.decimals;
|
|
3467
|
+
const gasReserveSui = Number(suiBal.totalBalance) / Number(MIST_PER_SUI);
|
|
3468
|
+
const saveApy = rates.USDC?.saveApy ?? 0;
|
|
3469
|
+
const borrowApy = rates.USDC?.borrowApy ?? 0;
|
|
3470
|
+
const dailyYield = hf.supplied * (saveApy / 365);
|
|
3471
|
+
return {
|
|
3472
|
+
walletAddress,
|
|
3473
|
+
usdcAvailable,
|
|
3474
|
+
savingsBalance: hf.supplied,
|
|
3475
|
+
debtBalance: hf.borrowed,
|
|
3476
|
+
idleUsdc: Math.max(0, usdcAvailable),
|
|
3477
|
+
healthFactor: hf.healthFactor,
|
|
3478
|
+
hfAlertLevel: classifyHF(hf.healthFactor, hf.borrowed > 0),
|
|
3479
|
+
saveApy,
|
|
3480
|
+
borrowApy,
|
|
3481
|
+
dailyYield,
|
|
3482
|
+
gasReserveSui,
|
|
3483
|
+
gasReserveUsd: gasReserveSui * suiPrice,
|
|
3484
|
+
allowanceBalance: allowance,
|
|
3485
|
+
fetchedAt: Date.now()
|
|
3486
|
+
};
|
|
3487
|
+
}
|
|
3266
3488
|
|
|
3267
3489
|
// src/utils/simulate.ts
|
|
3268
3490
|
init_errors();
|
|
@@ -3374,7 +3596,60 @@ async function getSwapQuote(params) {
|
|
|
3374
3596
|
init_cetus_swap();
|
|
3375
3597
|
init_token_registry();
|
|
3376
3598
|
init_volo();
|
|
3599
|
+
var DEFAULT_TTL_MS = 6e4;
|
|
3600
|
+
async function buildScopedIntent(adminKeypair, params) {
|
|
3601
|
+
const now = Date.now();
|
|
3602
|
+
const nonceBytes = new Uint8Array(32);
|
|
3603
|
+
crypto.getRandomValues(nonceBytes);
|
|
3604
|
+
const nonce = Buffer.from(nonceBytes).toString("hex");
|
|
3605
|
+
const payload = {
|
|
3606
|
+
version: 1,
|
|
3607
|
+
userId: params.userId,
|
|
3608
|
+
walletAddress: params.walletAddress,
|
|
3609
|
+
allowanceObjectId: params.allowanceObjectId,
|
|
3610
|
+
featureCode: params.featureCode,
|
|
3611
|
+
maxAmount: params.maxAmount,
|
|
3612
|
+
issuedAt: now,
|
|
3613
|
+
expiresAt: now + (params.ttlMs ?? DEFAULT_TTL_MS),
|
|
3614
|
+
nonce
|
|
3615
|
+
};
|
|
3616
|
+
const message = canonicalIntentBytes(payload);
|
|
3617
|
+
const signature = await adminKeypair.sign(message);
|
|
3618
|
+
return {
|
|
3619
|
+
...payload,
|
|
3620
|
+
signature: Buffer.from(signature).toString("hex")
|
|
3621
|
+
};
|
|
3622
|
+
}
|
|
3623
|
+
async function verifyScopedIntent(intent, adminPublicKeyBytes) {
|
|
3624
|
+
if (Date.now() > intent.expiresAt) return false;
|
|
3625
|
+
const payload = {
|
|
3626
|
+
version: intent.version,
|
|
3627
|
+
userId: intent.userId,
|
|
3628
|
+
walletAddress: intent.walletAddress,
|
|
3629
|
+
allowanceObjectId: intent.allowanceObjectId,
|
|
3630
|
+
featureCode: intent.featureCode,
|
|
3631
|
+
maxAmount: intent.maxAmount,
|
|
3632
|
+
issuedAt: intent.issuedAt,
|
|
3633
|
+
expiresAt: intent.expiresAt,
|
|
3634
|
+
nonce: intent.nonce
|
|
3635
|
+
};
|
|
3636
|
+
const message = canonicalIntentBytes(payload);
|
|
3637
|
+
const signatureBytes = Buffer.from(intent.signature, "hex");
|
|
3638
|
+
try {
|
|
3639
|
+
const publicKey = new ed25519.Ed25519PublicKey(adminPublicKeyBytes);
|
|
3640
|
+
return await publicKey.verify(message, signatureBytes);
|
|
3641
|
+
} catch {
|
|
3642
|
+
return false;
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
function canonicalIntentBytes(payload) {
|
|
3646
|
+
const sorted = Object.fromEntries(
|
|
3647
|
+
Object.entries(payload).sort(([a], [b]) => a.localeCompare(b))
|
|
3648
|
+
);
|
|
3649
|
+
return new TextEncoder().encode(JSON.stringify(sorted));
|
|
3650
|
+
}
|
|
3377
3651
|
|
|
3652
|
+
exports.ALLOWANCE_FEATURES = ALLOWANCE_FEATURES;
|
|
3378
3653
|
exports.ALL_NAVI_ASSETS = ALL_NAVI_ASSETS;
|
|
3379
3654
|
exports.BPS_DENOMINATOR = BPS_DENOMINATOR;
|
|
3380
3655
|
exports.CETUS_USDC_SUI_POOL = CETUS_USDC_SUI_POOL;
|
|
@@ -3383,6 +3658,8 @@ exports.ContactManager = ContactManager;
|
|
|
3383
3658
|
exports.DEFAULT_NETWORK = DEFAULT_NETWORK;
|
|
3384
3659
|
exports.DEFAULT_SAFEGUARD_CONFIG = DEFAULT_SAFEGUARD_CONFIG;
|
|
3385
3660
|
exports.GAS_RESERVE_MIN = GAS_RESERVE_MIN;
|
|
3661
|
+
exports.HF_CRITICAL_THRESHOLD = HF_CRITICAL_THRESHOLD;
|
|
3662
|
+
exports.HF_WARN_THRESHOLD = HF_WARN_THRESHOLD;
|
|
3386
3663
|
exports.KeypairSigner = KeypairSigner;
|
|
3387
3664
|
exports.MIST_PER_SUI = MIST_PER_SUI;
|
|
3388
3665
|
exports.NaviAdapter = NaviAdapter;
|
|
@@ -3398,11 +3675,19 @@ exports.T2000 = T2000;
|
|
|
3398
3675
|
exports.USDC_DECIMALS = USDC_DECIMALS;
|
|
3399
3676
|
exports.ZkLoginSigner = ZkLoginSigner;
|
|
3400
3677
|
exports.addCollectFeeToTx = addCollectFeeToTx;
|
|
3678
|
+
exports.addDepositAllowanceTx = addDepositAllowanceTx;
|
|
3401
3679
|
exports.allDescriptors = allDescriptors;
|
|
3402
3680
|
exports.assertAllowedAsset = assertAllowedAsset;
|
|
3681
|
+
exports.buildAdminDepositAllowanceTx = buildAdminDepositAllowanceTx;
|
|
3682
|
+
exports.buildCreateAllowanceTx = buildCreateAllowanceTx;
|
|
3683
|
+
exports.buildDeductAllowanceTx = buildDeductAllowanceTx;
|
|
3684
|
+
exports.buildDepositAllowanceTx = buildDepositAllowanceTx;
|
|
3685
|
+
exports.buildScopedIntent = buildScopedIntent;
|
|
3403
3686
|
exports.buildStakeVSuiTx = buildStakeVSuiTx;
|
|
3404
3687
|
exports.buildSwapTx = buildSwapTx;
|
|
3405
3688
|
exports.buildUnstakeVSuiTx = buildUnstakeVSuiTx;
|
|
3689
|
+
exports.buildWithdrawAllowanceTx = buildWithdrawAllowanceTx;
|
|
3690
|
+
exports.buildWithdrawAmountAllowanceTx = buildWithdrawAmountAllowanceTx;
|
|
3406
3691
|
exports.calculateFee = calculateFee;
|
|
3407
3692
|
exports.executeAutoTopUp = executeAutoTopUp;
|
|
3408
3693
|
exports.executeWithGas = executeWithGas;
|
|
@@ -3413,8 +3698,11 @@ exports.formatSui = formatSui;
|
|
|
3413
3698
|
exports.formatUsd = formatUsd;
|
|
3414
3699
|
exports.generateKeypair = generateKeypair;
|
|
3415
3700
|
exports.getAddress = getAddress;
|
|
3701
|
+
exports.getAllowance = getAllowance;
|
|
3702
|
+
exports.getAllowanceBalance = getAllowanceBalance;
|
|
3416
3703
|
exports.getDecimals = getDecimals;
|
|
3417
3704
|
exports.getDecimalsForCoinType = getDecimalsForCoinType;
|
|
3705
|
+
exports.getFinancialSummary = getFinancialSummary;
|
|
3418
3706
|
exports.getGasStatus = getGasStatus;
|
|
3419
3707
|
exports.getRates = getRates;
|
|
3420
3708
|
exports.getSwapQuote = getSwapQuote;
|
|
@@ -3444,6 +3732,7 @@ exports.throwIfSimulationFailed = throwIfSimulationFailed;
|
|
|
3444
3732
|
exports.truncateAddress = truncateAddress;
|
|
3445
3733
|
exports.usdcToRaw = usdcToRaw;
|
|
3446
3734
|
exports.validateAddress = validateAddress;
|
|
3735
|
+
exports.verifyScopedIntent = verifyScopedIntent;
|
|
3447
3736
|
exports.walletExists = walletExists;
|
|
3448
3737
|
//# sourceMappingURL=index.cjs.map
|
|
3449
3738
|
//# sourceMappingURL=index.cjs.map
|