@trustwallet/cli 0.11.0 → 0.12.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/commands/setup.d.ts +14 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/index.js +1525 -801
- package/dist/setup/atomic-write.d.ts +2 -0
- package/dist/setup/atomic-write.d.ts.map +1 -0
- package/dist/setup/harnesses/claude-code.d.ts +3 -0
- package/dist/setup/harnesses/claude-code.d.ts.map +1 -0
- package/dist/setup/harnesses/claude-desktop.d.ts +4 -0
- package/dist/setup/harnesses/claude-desktop.d.ts.map +1 -0
- package/dist/setup/harnesses/codex.d.ts +4 -0
- package/dist/setup/harnesses/codex.d.ts.map +1 -0
- package/dist/setup/harnesses/cursor.d.ts +3 -0
- package/dist/setup/harnesses/cursor.d.ts.map +1 -0
- package/dist/setup/harnesses/index.d.ts +5 -0
- package/dist/setup/harnesses/index.d.ts.map +1 -0
- package/dist/setup/harnesses/json-base.d.ts +8 -0
- package/dist/setup/harnesses/json-base.d.ts.map +1 -0
- package/dist/setup/harnesses/types.d.ts +17 -0
- package/dist/setup/harnesses/types.d.ts.map +1 -0
- package/dist/setup/phase-credentials.d.ts +18 -0
- package/dist/setup/phase-credentials.d.ts.map +1 -0
- package/dist/setup/phase-harnesses.d.ts +19 -0
- package/dist/setup/phase-harnesses.d.ts.map +1 -0
- package/dist/setup/phase-wallet.d.ts +28 -0
- package/dist/setup/phase-wallet.d.ts.map +1 -0
- package/dist/setup/types.d.ts +14 -0
- package/dist/setup/types.d.ts.map +1 -0
- package/package.json +17 -15
package/dist/index.js
CHANGED
|
@@ -659,15 +659,15 @@ var require_help = __commonJS({
|
|
|
659
659
|
* @return {string}
|
|
660
660
|
*
|
|
661
661
|
*/
|
|
662
|
-
wrap(str, width,
|
|
662
|
+
wrap(str, width, indent2, minColumnWidth = 40) {
|
|
663
663
|
const indents = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF";
|
|
664
664
|
const manualIndent = new RegExp(`[\\n][${indents}]+`);
|
|
665
665
|
if (str.match(manualIndent)) return str;
|
|
666
|
-
const columnWidth = width -
|
|
666
|
+
const columnWidth = width - indent2;
|
|
667
667
|
if (columnWidth < minColumnWidth) return str;
|
|
668
|
-
const leadingStr = str.slice(0,
|
|
669
|
-
const columnText = str.slice(
|
|
670
|
-
const indentString = " ".repeat(
|
|
668
|
+
const leadingStr = str.slice(0, indent2);
|
|
669
|
+
const columnText = str.slice(indent2).replace("\r\n", "\n");
|
|
670
|
+
const indentString = " ".repeat(indent2);
|
|
671
671
|
const zeroWidthSpace = "\u200B";
|
|
672
672
|
const breaks = `\\s${zeroWidthSpace}`;
|
|
673
673
|
const regex = new RegExp(
|
|
@@ -1054,7 +1054,7 @@ var require_command = __commonJS({
|
|
|
1054
1054
|
var { Help: Help2 } = require_help();
|
|
1055
1055
|
var { Option: Option2, DualOptions } = require_option();
|
|
1056
1056
|
var { suggestSimilar } = require_suggestSimilar();
|
|
1057
|
-
var
|
|
1057
|
+
var Command3 = class _Command extends EventEmitter {
|
|
1058
1058
|
/**
|
|
1059
1059
|
* Initialize a new `Command`.
|
|
1060
1060
|
*
|
|
@@ -3080,7 +3080,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3080
3080
|
return arg;
|
|
3081
3081
|
});
|
|
3082
3082
|
}
|
|
3083
|
-
exports2.Command =
|
|
3083
|
+
exports2.Command = Command3;
|
|
3084
3084
|
}
|
|
3085
3085
|
});
|
|
3086
3086
|
|
|
@@ -3089,15 +3089,15 @@ var require_commander = __commonJS({
|
|
|
3089
3089
|
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/index.js"(exports2) {
|
|
3090
3090
|
"use strict";
|
|
3091
3091
|
var { Argument: Argument2 } = require_argument();
|
|
3092
|
-
var { Command:
|
|
3092
|
+
var { Command: Command3 } = require_command();
|
|
3093
3093
|
var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
3094
3094
|
var { Help: Help2 } = require_help();
|
|
3095
3095
|
var { Option: Option2 } = require_option();
|
|
3096
|
-
exports2.program = new
|
|
3097
|
-
exports2.createCommand = (name2) => new
|
|
3096
|
+
exports2.program = new Command3();
|
|
3097
|
+
exports2.createCommand = (name2) => new Command3(name2);
|
|
3098
3098
|
exports2.createOption = (flags, description) => new Option2(flags, description);
|
|
3099
3099
|
exports2.createArgument = (name2, description) => new Argument2(name2, description);
|
|
3100
|
-
exports2.Command =
|
|
3100
|
+
exports2.Command = Command3;
|
|
3101
3101
|
exports2.Option = Option2;
|
|
3102
3102
|
exports2.Argument = Argument2;
|
|
3103
3103
|
exports2.Help = Help2;
|
|
@@ -4366,14 +4366,14 @@ var init_dist = __esm({
|
|
|
4366
4366
|
});
|
|
4367
4367
|
|
|
4368
4368
|
// ../storage/dist/index.mjs
|
|
4369
|
-
function deriveKey(
|
|
4370
|
-
return
|
|
4371
|
-
}
|
|
4372
|
-
function encrypt(plaintext,
|
|
4373
|
-
const salt =
|
|
4374
|
-
const key = deriveKey(
|
|
4375
|
-
const iv =
|
|
4376
|
-
const cipher =
|
|
4369
|
+
function deriveKey(password2, salt) {
|
|
4370
|
+
return crypto22.pbkdf2Sync(password2, salt, ITERATIONS, KEY_LENGTH, "sha256");
|
|
4371
|
+
}
|
|
4372
|
+
function encrypt(plaintext, password2) {
|
|
4373
|
+
const salt = crypto22.randomBytes(SALT_LENGTH);
|
|
4374
|
+
const key = deriveKey(password2, salt);
|
|
4375
|
+
const iv = crypto22.randomBytes(IV_LENGTH);
|
|
4376
|
+
const cipher = crypto22.createCipheriv(ALGORITHM, key, iv);
|
|
4377
4377
|
let encrypted = cipher.update(plaintext, "utf-8", "hex");
|
|
4378
4378
|
encrypted += cipher.final("hex");
|
|
4379
4379
|
return {
|
|
@@ -4383,11 +4383,11 @@ function encrypt(plaintext, password) {
|
|
|
4383
4383
|
salt: salt.toString("hex")
|
|
4384
4384
|
};
|
|
4385
4385
|
}
|
|
4386
|
-
function decrypt(data,
|
|
4386
|
+
function decrypt(data, password2) {
|
|
4387
4387
|
const salt = Buffer.from(data.salt, "hex");
|
|
4388
|
-
const key = deriveKey(
|
|
4388
|
+
const key = deriveKey(password2, salt);
|
|
4389
4389
|
const iv = Buffer.from(data.iv, "hex");
|
|
4390
|
-
const decipher =
|
|
4390
|
+
const decipher = crypto22.createDecipheriv(ALGORITHM, key, iv);
|
|
4391
4391
|
decipher.setAuthTag(Buffer.from(data.authTag, "hex"));
|
|
4392
4392
|
let decrypted = decipher.update(data.ciphertext, "hex", "utf-8");
|
|
4393
4393
|
decrypted += decipher.final("utf-8");
|
|
@@ -4397,7 +4397,9 @@ function isNoEntryError(err) {
|
|
|
4397
4397
|
return err instanceof Error && /no entry|no such entry/i.test(err.message);
|
|
4398
4398
|
}
|
|
4399
4399
|
function isKeychainUnavailableError(err) {
|
|
4400
|
-
return err instanceof Error && (/no keychain service/i.test(err.message) || /org\.freedesktop/i.test(err.message) || /failed to unlock/i.test(err.message) || /secret service/i.test(err.message)
|
|
4400
|
+
return err instanceof Error && (/no keychain service/i.test(err.message) || /org\.freedesktop/i.test(err.message) || /failed to unlock/i.test(err.message) || /secret service/i.test(err.message) || // macOS — surfaces when there is no default keychain set up for the
|
|
4401
|
+
// session (Docker containers, headless launchd jobs, fresh CI runners).
|
|
4402
|
+
/default keychain.*not be found/i.test(err.message));
|
|
4401
4403
|
}
|
|
4402
4404
|
function getPassword(service, account) {
|
|
4403
4405
|
try {
|
|
@@ -4407,7 +4409,7 @@ function getPassword(service, account) {
|
|
|
4407
4409
|
throw err;
|
|
4408
4410
|
}
|
|
4409
4411
|
}
|
|
4410
|
-
var fs, path, os, crypto2,
|
|
4412
|
+
var fs, path, os, crypto2, crypto22, import_keyring, crypto3, crypto4, FileStore, ALGORITHM, KEY_LENGTH, IV_LENGTH, SALT_LENGTH, ITERATIONS, SERVICE, WALLET_ACCOUNT, API_SECRET_ACCOUNT, PROBE_ACCOUNT, KeychainManager, CREDENTIALS_FILE, CredentialManager, WALLET_FILE, WalletConfigStore, ALERTS_FILE, AlertStore, AUTOMATIONS_FILE, AutomationStore, SEEN_HASHES_FILE, SeenHashStore, ASSET_CACHE_FILE, AssetCache;
|
|
4411
4413
|
var init_dist2 = __esm({
|
|
4412
4414
|
"../storage/dist/index.mjs"() {
|
|
4413
4415
|
"use strict";
|
|
@@ -4415,9 +4417,10 @@ var init_dist2 = __esm({
|
|
|
4415
4417
|
path = __toESM(require("path"), 1);
|
|
4416
4418
|
os = __toESM(require("os"), 1);
|
|
4417
4419
|
crypto2 = __toESM(require("crypto"), 1);
|
|
4418
|
-
import_keyring = require("@napi-rs/keyring");
|
|
4419
4420
|
crypto22 = __toESM(require("crypto"), 1);
|
|
4421
|
+
import_keyring = require("@napi-rs/keyring");
|
|
4420
4422
|
crypto3 = __toESM(require("crypto"), 1);
|
|
4423
|
+
crypto4 = __toESM(require("crypto"), 1);
|
|
4421
4424
|
FileStore = class {
|
|
4422
4425
|
dataDir;
|
|
4423
4426
|
constructor(config2) {
|
|
@@ -4441,7 +4444,20 @@ var init_dist2 = __esm({
|
|
|
4441
4444
|
async write(filename, data) {
|
|
4442
4445
|
await fs.promises.mkdir(this.dataDir, { recursive: true, mode: 448 });
|
|
4443
4446
|
const filePath = path.join(this.dataDir, filename);
|
|
4444
|
-
|
|
4447
|
+
const tmpPath = `${filePath}.tmp.${crypto2.randomBytes(8).toString("hex")}`;
|
|
4448
|
+
await fs.promises.writeFile(tmpPath, JSON.stringify(data, null, 2), {
|
|
4449
|
+
encoding: "utf-8",
|
|
4450
|
+
mode: 384
|
|
4451
|
+
});
|
|
4452
|
+
try {
|
|
4453
|
+
await fs.promises.rename(tmpPath, filePath);
|
|
4454
|
+
} catch (err) {
|
|
4455
|
+
try {
|
|
4456
|
+
await fs.promises.rm(tmpPath, { force: true });
|
|
4457
|
+
} catch {
|
|
4458
|
+
}
|
|
4459
|
+
throw err;
|
|
4460
|
+
}
|
|
4445
4461
|
}
|
|
4446
4462
|
async exists(filename) {
|
|
4447
4463
|
const filePath = path.join(this.dataDir, filename);
|
|
@@ -4468,12 +4484,13 @@ var init_dist2 = __esm({
|
|
|
4468
4484
|
SERVICE = "twak";
|
|
4469
4485
|
WALLET_ACCOUNT = "wallet";
|
|
4470
4486
|
API_SECRET_ACCOUNT = "api-secret";
|
|
4487
|
+
PROBE_ACCOUNT = "probe";
|
|
4471
4488
|
KeychainManager = class {
|
|
4472
4489
|
async getWalletPassword() {
|
|
4473
4490
|
return getPassword(SERVICE, WALLET_ACCOUNT);
|
|
4474
4491
|
}
|
|
4475
|
-
async saveWalletPassword(
|
|
4476
|
-
new import_keyring.Entry(SERVICE, WALLET_ACCOUNT).setPassword(
|
|
4492
|
+
async saveWalletPassword(password2) {
|
|
4493
|
+
new import_keyring.Entry(SERVICE, WALLET_ACCOUNT).setPassword(password2);
|
|
4477
4494
|
}
|
|
4478
4495
|
async deleteWalletPassword() {
|
|
4479
4496
|
new import_keyring.Entry(SERVICE, WALLET_ACCOUNT).deletePassword();
|
|
@@ -4490,6 +4507,22 @@ var init_dist2 = __esm({
|
|
|
4490
4507
|
} catch {
|
|
4491
4508
|
}
|
|
4492
4509
|
}
|
|
4510
|
+
// Probe slot — write/read/delete by `twak setup` to verify the OS keychain
|
|
4511
|
+
// actually persists writes (`isAvailable()` is read-only and misses
|
|
4512
|
+
// session-scoped keychains). Isolated from WALLET_ACCOUNT and
|
|
4513
|
+
// API_SECRET_ACCOUNT so the probe can never overwrite real credentials.
|
|
4514
|
+
async saveProbe(value) {
|
|
4515
|
+
new import_keyring.Entry(SERVICE, PROBE_ACCOUNT).setPassword(value);
|
|
4516
|
+
}
|
|
4517
|
+
async getProbe() {
|
|
4518
|
+
return getPassword(SERVICE, PROBE_ACCOUNT);
|
|
4519
|
+
}
|
|
4520
|
+
async deleteProbe() {
|
|
4521
|
+
try {
|
|
4522
|
+
new import_keyring.Entry(SERVICE, PROBE_ACCOUNT).deletePassword();
|
|
4523
|
+
} catch {
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4493
4526
|
isAvailable() {
|
|
4494
4527
|
try {
|
|
4495
4528
|
new import_keyring.Entry(SERVICE, "__availability_probe__").getPassword();
|
|
@@ -4521,15 +4554,18 @@ var init_dist2 = __esm({
|
|
|
4521
4554
|
}
|
|
4522
4555
|
async save(credentials) {
|
|
4523
4556
|
await this.store.write(CREDENTIALS_FILE, credentials);
|
|
4524
|
-
if (this.kc.isAvailable()) {
|
|
4557
|
+
if (!this.kc.isAvailable()) {
|
|
4558
|
+
return { keychain: false };
|
|
4559
|
+
}
|
|
4560
|
+
try {
|
|
4561
|
+
await this.kc.saveApiSecret(credentials.hmacSecret);
|
|
4562
|
+
return { keychain: true };
|
|
4563
|
+
} catch {
|
|
4525
4564
|
try {
|
|
4526
|
-
await this.kc.
|
|
4565
|
+
await this.kc.deleteApiSecret();
|
|
4527
4566
|
} catch {
|
|
4528
|
-
try {
|
|
4529
|
-
await this.kc.deleteApiSecret();
|
|
4530
|
-
} catch {
|
|
4531
|
-
}
|
|
4532
4567
|
}
|
|
4568
|
+
return { keychain: false };
|
|
4533
4569
|
}
|
|
4534
4570
|
}
|
|
4535
4571
|
async exists() {
|
|
@@ -4546,8 +4582,8 @@ var init_dist2 = __esm({
|
|
|
4546
4582
|
constructor(config2) {
|
|
4547
4583
|
this.store = new FileStore(config2);
|
|
4548
4584
|
}
|
|
4549
|
-
async saveMnemonic(mnemonic,
|
|
4550
|
-
const encrypted = encrypt(mnemonic,
|
|
4585
|
+
async saveMnemonic(mnemonic, password2, chains) {
|
|
4586
|
+
const encrypted = encrypt(mnemonic, password2);
|
|
4551
4587
|
const config2 = {
|
|
4552
4588
|
encryptedMnemonic: encrypted.ciphertext,
|
|
4553
4589
|
iv: encrypted.iv,
|
|
@@ -4558,7 +4594,7 @@ var init_dist2 = __esm({
|
|
|
4558
4594
|
};
|
|
4559
4595
|
await this.store.write(WALLET_FILE, config2);
|
|
4560
4596
|
}
|
|
4561
|
-
async loadMnemonic(
|
|
4597
|
+
async loadMnemonic(password2) {
|
|
4562
4598
|
const config2 = await this.store.read(WALLET_FILE);
|
|
4563
4599
|
if (!config2) {
|
|
4564
4600
|
throw new Error("No wallet configuration found");
|
|
@@ -4569,7 +4605,7 @@ var init_dist2 = __esm({
|
|
|
4569
4605
|
authTag: config2.authTag,
|
|
4570
4606
|
salt: config2.salt
|
|
4571
4607
|
};
|
|
4572
|
-
return decrypt(encrypted,
|
|
4608
|
+
return decrypt(encrypted, password2);
|
|
4573
4609
|
}
|
|
4574
4610
|
async exists() {
|
|
4575
4611
|
return this.store.exists(WALLET_FILE);
|
|
@@ -4591,7 +4627,7 @@ var init_dist2 = __esm({
|
|
|
4591
4627
|
const alerts = await this.list();
|
|
4592
4628
|
const record2 = {
|
|
4593
4629
|
...alert,
|
|
4594
|
-
id:
|
|
4630
|
+
id: crypto3.randomUUID(),
|
|
4595
4631
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4596
4632
|
active: true
|
|
4597
4633
|
};
|
|
@@ -4639,7 +4675,7 @@ var init_dist2 = __esm({
|
|
|
4639
4675
|
const automations = await this.list();
|
|
4640
4676
|
const entry = {
|
|
4641
4677
|
...record2,
|
|
4642
|
-
id:
|
|
4678
|
+
id: crypto4.randomUUID(),
|
|
4643
4679
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4644
4680
|
active: true
|
|
4645
4681
|
};
|
|
@@ -6064,14 +6100,14 @@ var require_templates = __commonJS({
|
|
|
6064
6100
|
}
|
|
6065
6101
|
return results;
|
|
6066
6102
|
}
|
|
6067
|
-
function buildStyle(
|
|
6103
|
+
function buildStyle(chalk9, styles) {
|
|
6068
6104
|
const enabled = {};
|
|
6069
6105
|
for (const layer of styles) {
|
|
6070
6106
|
for (const style of layer.styles) {
|
|
6071
6107
|
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
6072
6108
|
}
|
|
6073
6109
|
}
|
|
6074
|
-
let current =
|
|
6110
|
+
let current = chalk9;
|
|
6075
6111
|
for (const [styleName, styles2] of Object.entries(enabled)) {
|
|
6076
6112
|
if (!Array.isArray(styles2)) {
|
|
6077
6113
|
continue;
|
|
@@ -6083,7 +6119,7 @@ var require_templates = __commonJS({
|
|
|
6083
6119
|
}
|
|
6084
6120
|
return current;
|
|
6085
6121
|
}
|
|
6086
|
-
module2.exports = (
|
|
6122
|
+
module2.exports = (chalk9, temporary) => {
|
|
6087
6123
|
const styles = [];
|
|
6088
6124
|
const chunks = [];
|
|
6089
6125
|
let chunk2 = [];
|
|
@@ -6093,13 +6129,13 @@ var require_templates = __commonJS({
|
|
|
6093
6129
|
} else if (style) {
|
|
6094
6130
|
const string4 = chunk2.join("");
|
|
6095
6131
|
chunk2 = [];
|
|
6096
|
-
chunks.push(styles.length === 0 ? string4 : buildStyle(
|
|
6132
|
+
chunks.push(styles.length === 0 ? string4 : buildStyle(chalk9, styles)(string4));
|
|
6097
6133
|
styles.push({ inverse, styles: parseStyle(style) });
|
|
6098
6134
|
} else if (close) {
|
|
6099
6135
|
if (styles.length === 0) {
|
|
6100
6136
|
throw new Error("Found extraneous } in Chalk template literal");
|
|
6101
6137
|
}
|
|
6102
|
-
chunks.push(buildStyle(
|
|
6138
|
+
chunks.push(buildStyle(chalk9, styles)(chunk2.join("")));
|
|
6103
6139
|
chunk2 = [];
|
|
6104
6140
|
styles.pop();
|
|
6105
6141
|
} else {
|
|
@@ -6147,16 +6183,16 @@ var require_source = __commonJS({
|
|
|
6147
6183
|
}
|
|
6148
6184
|
};
|
|
6149
6185
|
var chalkFactory = (options) => {
|
|
6150
|
-
const
|
|
6151
|
-
applyOptions(
|
|
6152
|
-
|
|
6153
|
-
Object.setPrototypeOf(
|
|
6154
|
-
Object.setPrototypeOf(
|
|
6155
|
-
|
|
6186
|
+
const chalk10 = {};
|
|
6187
|
+
applyOptions(chalk10, options);
|
|
6188
|
+
chalk10.template = (...arguments_) => chalkTag(chalk10.template, ...arguments_);
|
|
6189
|
+
Object.setPrototypeOf(chalk10, Chalk.prototype);
|
|
6190
|
+
Object.setPrototypeOf(chalk10.template, chalk10);
|
|
6191
|
+
chalk10.template.constructor = () => {
|
|
6156
6192
|
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
6157
6193
|
};
|
|
6158
|
-
|
|
6159
|
-
return
|
|
6194
|
+
chalk10.template.Instance = ChalkClass;
|
|
6195
|
+
return chalk10.template;
|
|
6160
6196
|
};
|
|
6161
6197
|
function Chalk(options) {
|
|
6162
6198
|
return chalkFactory(options);
|
|
@@ -6267,7 +6303,7 @@ var require_source = __commonJS({
|
|
|
6267
6303
|
return openAll + string4 + closeAll;
|
|
6268
6304
|
};
|
|
6269
6305
|
var template;
|
|
6270
|
-
var chalkTag = (
|
|
6306
|
+
var chalkTag = (chalk10, ...strings) => {
|
|
6271
6307
|
const [firstString] = strings;
|
|
6272
6308
|
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
6273
6309
|
return strings.join(" ");
|
|
@@ -6283,14 +6319,14 @@ var require_source = __commonJS({
|
|
|
6283
6319
|
if (template === void 0) {
|
|
6284
6320
|
template = require_templates();
|
|
6285
6321
|
}
|
|
6286
|
-
return template(
|
|
6322
|
+
return template(chalk10, parts.join(""));
|
|
6287
6323
|
};
|
|
6288
6324
|
Object.defineProperties(Chalk.prototype, styles);
|
|
6289
|
-
var
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
module2.exports =
|
|
6325
|
+
var chalk9 = Chalk();
|
|
6326
|
+
chalk9.supportsColor = stdoutColor;
|
|
6327
|
+
chalk9.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
6328
|
+
chalk9.stderr.supportsColor = stderrColor;
|
|
6329
|
+
module2.exports = chalk9;
|
|
6294
6330
|
}
|
|
6295
6331
|
});
|
|
6296
6332
|
|
|
@@ -6525,8 +6561,8 @@ function patchNodeStubs() {
|
|
|
6525
6561
|
if (nodeStubsPatched) return;
|
|
6526
6562
|
nodeStubsPatched = true;
|
|
6527
6563
|
const originalFetch = globalThis.fetch;
|
|
6528
|
-
globalThis.fetch = function(
|
|
6529
|
-
const url = typeof
|
|
6564
|
+
globalThis.fetch = function(input2, init3) {
|
|
6565
|
+
const url = typeof input2 === "string" ? input2 : input2 instanceof URL ? input2.href : input2.url;
|
|
6530
6566
|
let parsedUrl;
|
|
6531
6567
|
try {
|
|
6532
6568
|
parsedUrl = new URL(url);
|
|
@@ -6582,23 +6618,23 @@ function patchNodeStubs() {
|
|
|
6582
6618
|
resolvedUrl = resolvedUrl.replace("gateway.us.trustwallet.com", "tws.trustwallet.com");
|
|
6583
6619
|
}
|
|
6584
6620
|
if (resolvedUrl !== url) {
|
|
6585
|
-
const finalInput = typeof
|
|
6621
|
+
const finalInput = typeof input2 === "string" ? resolvedUrl : input2 instanceof URL ? new URL(resolvedUrl) : new Request(resolvedUrl, input2);
|
|
6586
6622
|
return originalFetch(finalInput, init3);
|
|
6587
6623
|
}
|
|
6588
|
-
return originalFetch(
|
|
6624
|
+
return originalFetch(input2, init3);
|
|
6589
6625
|
};
|
|
6590
6626
|
}
|
|
6591
6627
|
function patchNaasSession(sessionId) {
|
|
6592
6628
|
if (naasSessionPatched) return;
|
|
6593
6629
|
naasSessionPatched = true;
|
|
6594
6630
|
const originalFetch = globalThis.fetch;
|
|
6595
|
-
globalThis.fetch = function(
|
|
6596
|
-
let url = typeof
|
|
6631
|
+
globalThis.fetch = function(input2, init3) {
|
|
6632
|
+
let url = typeof input2 === "string" ? input2 : input2 instanceof URL ? input2.href : input2.url;
|
|
6597
6633
|
if (url.includes("twnodes.com") && NAAS_SESSION_RE.test(url)) {
|
|
6598
6634
|
url = url.replace(NAAS_SESSION_RE, `/naas/session/${encodeURIComponent(sessionId)}/`);
|
|
6599
|
-
|
|
6635
|
+
input2 = typeof input2 === "string" ? url : input2 instanceof URL ? new URL(url) : new Request(url, input2);
|
|
6600
6636
|
}
|
|
6601
|
-
return originalFetch.call(this,
|
|
6637
|
+
return originalFetch.call(this, input2, init3);
|
|
6602
6638
|
};
|
|
6603
6639
|
}
|
|
6604
6640
|
function buildCoinTypeMap() {
|
|
@@ -6753,6 +6789,30 @@ async function gatewayFetch(method, path22, config2, body) {
|
|
|
6753
6789
|
body: body ? JSON.stringify(body) : void 0
|
|
6754
6790
|
});
|
|
6755
6791
|
}
|
|
6792
|
+
async function verifyCredentials(config2) {
|
|
6793
|
+
const deviceId = config2.accessId;
|
|
6794
|
+
let response;
|
|
6795
|
+
try {
|
|
6796
|
+
response = await gatewayFetch("PUT", `/v2/devices/${deviceId}`, config2, DEVICE_INFO_BODY);
|
|
6797
|
+
} catch (err) {
|
|
6798
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
6799
|
+
throw new VerifyCredentialsError(
|
|
6800
|
+
"NETWORK_ERROR",
|
|
6801
|
+
`Could not reach Trust Wallet gateway: ${message}`
|
|
6802
|
+
);
|
|
6803
|
+
}
|
|
6804
|
+
if (response.status === 401 || response.status === 403) {
|
|
6805
|
+
throw new VerifyCredentialsError("UNAUTHORIZED", "Invalid API credentials", response.status);
|
|
6806
|
+
}
|
|
6807
|
+
if (response.status === 404) return;
|
|
6808
|
+
if (!response.ok) {
|
|
6809
|
+
throw new VerifyCredentialsError(
|
|
6810
|
+
"GATEWAY_ERROR",
|
|
6811
|
+
`Gateway returned ${response.status}`,
|
|
6812
|
+
response.status
|
|
6813
|
+
);
|
|
6814
|
+
}
|
|
6815
|
+
}
|
|
6756
6816
|
function toEip55Lowercase(address) {
|
|
6757
6817
|
return address.toLowerCase();
|
|
6758
6818
|
}
|
|
@@ -6768,15 +6828,7 @@ async function registerDeviceAndWallet(config2, accounts) {
|
|
|
6768
6828
|
const deviceId = config2.accessId;
|
|
6769
6829
|
const walletId = config2.walletId ?? deriveWalletId(accounts);
|
|
6770
6830
|
try {
|
|
6771
|
-
await gatewayFetch("PUT", `/v2/devices/${deviceId}`, config2,
|
|
6772
|
-
type: "extension",
|
|
6773
|
-
push_enabled: false,
|
|
6774
|
-
app_version: "1.0.0",
|
|
6775
|
-
wallets_version: 0,
|
|
6776
|
-
model_name: "",
|
|
6777
|
-
language: "en",
|
|
6778
|
-
currency: "USD"
|
|
6779
|
-
});
|
|
6831
|
+
await gatewayFetch("PUT", `/v2/devices/${deviceId}`, config2, DEVICE_INFO_BODY);
|
|
6780
6832
|
} catch {
|
|
6781
6833
|
}
|
|
6782
6834
|
const accountsPayload = accounts.map((a3) => ({
|
|
@@ -6817,7 +6869,7 @@ function registerShutdownHandlers(providers, onBeforeExit) {
|
|
|
6817
6869
|
process.removeListener("SIGTERM", handler);
|
|
6818
6870
|
};
|
|
6819
6871
|
}
|
|
6820
|
-
var fs2, path2, import_trust_sdk, import_trust_sdk2, import_trust_sdk3, import_trust_sdk4, import_crypto2, __require, polyfillsApplied, _credentials, _naasSessionId, nodeStubsPatched, NAAS_SESSION_RE, naasSessionPatched, coinTypeByValue, walletCore, initialized, SPONSORED_RPC, BlockchainClient, WalletCoreSigner, domainsByCoinId, GATEWAY_URL, WALLET_ID_SUFFIX, WALLET_ID_LENGTH, EVM_COIN_IDS, MAINTAINED_COIN_IDS, WalletProvider, AgentWalletProvider, SHUTDOWN_TIMEOUT_MS;
|
|
6872
|
+
var fs2, path2, import_trust_sdk, import_trust_sdk2, import_trust_sdk3, import_trust_sdk4, import_crypto2, __require, polyfillsApplied, _credentials, _naasSessionId, nodeStubsPatched, NAAS_SESSION_RE, naasSessionPatched, coinTypeByValue, walletCore, initialized, SPONSORED_RPC, BlockchainClient, WalletCoreSigner, domainsByCoinId, GATEWAY_URL, DEVICE_INFO_BODY, VerifyCredentialsError, WALLET_ID_SUFFIX, WALLET_ID_LENGTH, EVM_COIN_IDS, MAINTAINED_COIN_IDS, WalletProvider, AgentWalletProvider, SHUTDOWN_TIMEOUT_MS;
|
|
6821
6873
|
var init_dist3 = __esm({
|
|
6822
6874
|
"../wallet-core/dist/index.mjs"() {
|
|
6823
6875
|
"use strict";
|
|
@@ -7571,6 +7623,25 @@ var init_dist3 = __esm({
|
|
|
7571
7623
|
};
|
|
7572
7624
|
domainsByCoinId = null;
|
|
7573
7625
|
GATEWAY_URL = "https://tws.trustwallet.com";
|
|
7626
|
+
DEVICE_INFO_BODY = {
|
|
7627
|
+
type: "extension",
|
|
7628
|
+
push_enabled: false,
|
|
7629
|
+
app_version: "1.0.0",
|
|
7630
|
+
wallets_version: 0,
|
|
7631
|
+
model_name: "",
|
|
7632
|
+
language: "en",
|
|
7633
|
+
currency: "USD"
|
|
7634
|
+
};
|
|
7635
|
+
VerifyCredentialsError = class extends Error {
|
|
7636
|
+
code;
|
|
7637
|
+
httpStatus;
|
|
7638
|
+
constructor(code2, message, httpStatus) {
|
|
7639
|
+
super(message);
|
|
7640
|
+
this.name = "VerifyCredentialsError";
|
|
7641
|
+
this.code = code2;
|
|
7642
|
+
this.httpStatus = httpStatus;
|
|
7643
|
+
}
|
|
7644
|
+
};
|
|
7574
7645
|
WALLET_ID_SUFFIX = 3;
|
|
7575
7646
|
WALLET_ID_LENGTH = 40;
|
|
7576
7647
|
EVM_COIN_IDS = /* @__PURE__ */ new Set([60, 20000714, 966, 10042221, 10000070, 8453]);
|
|
@@ -7652,9 +7723,9 @@ var init_dist3 = __esm({
|
|
|
7652
7723
|
throw new Error("Wallet is locked. Re-authenticate to continue.");
|
|
7653
7724
|
}
|
|
7654
7725
|
this.reconnecting = (async () => {
|
|
7655
|
-
const
|
|
7726
|
+
const password2 = await this.passwordResolver();
|
|
7656
7727
|
const store = new WalletConfigStore();
|
|
7657
|
-
const mnemonic = await store.loadMnemonic(
|
|
7728
|
+
const mnemonic = await store.loadMnemonic(password2);
|
|
7658
7729
|
this.signer = await WalletCoreSigner.fromMnemonic(mnemonic);
|
|
7659
7730
|
this.blockchainClient = new BlockchainClient(this.signer);
|
|
7660
7731
|
this.connected = true;
|
|
@@ -7665,26 +7736,26 @@ var init_dist3 = __esm({
|
|
|
7665
7736
|
this.reconnecting = null;
|
|
7666
7737
|
}
|
|
7667
7738
|
}
|
|
7668
|
-
static async create(
|
|
7739
|
+
static async create(password2) {
|
|
7669
7740
|
const walletCore2 = getWalletCore();
|
|
7670
7741
|
const hdWallet = walletCore2.HDWallet.create(128, "");
|
|
7671
7742
|
const mnemonic = hdWallet.mnemonic();
|
|
7672
7743
|
const store = new WalletConfigStore();
|
|
7673
|
-
await store.saveMnemonic(mnemonic,
|
|
7744
|
+
await store.saveMnemonic(mnemonic, password2, Object.keys(CHAINS));
|
|
7674
7745
|
const signer = WalletCoreSigner.fromHDWallet(hdWallet);
|
|
7675
7746
|
const client = new BlockchainClient(signer);
|
|
7676
7747
|
return new _AgentWalletProvider(signer, client);
|
|
7677
7748
|
}
|
|
7678
|
-
static async fromStorage(
|
|
7749
|
+
static async fromStorage(password2) {
|
|
7679
7750
|
const store = new WalletConfigStore();
|
|
7680
|
-
const mnemonic = await store.loadMnemonic(
|
|
7751
|
+
const mnemonic = await store.loadMnemonic(password2);
|
|
7681
7752
|
const signer = await WalletCoreSigner.fromMnemonic(mnemonic);
|
|
7682
7753
|
const client = new BlockchainClient(signer);
|
|
7683
7754
|
return new _AgentWalletProvider(signer, client);
|
|
7684
7755
|
}
|
|
7685
|
-
static async fromMnemonic(mnemonic,
|
|
7756
|
+
static async fromMnemonic(mnemonic, password2) {
|
|
7686
7757
|
const store = new WalletConfigStore();
|
|
7687
|
-
await store.saveMnemonic(mnemonic,
|
|
7758
|
+
await store.saveMnemonic(mnemonic, password2, Object.keys(CHAINS));
|
|
7688
7759
|
const signer = await WalletCoreSigner.fromMnemonic(mnemonic);
|
|
7689
7760
|
const client = new BlockchainClient(signer);
|
|
7690
7761
|
return new _AgentWalletProvider(signer, client);
|
|
@@ -7805,6 +7876,7 @@ var init_dist3 = __esm({
|
|
|
7805
7876
|
var dist_exports2 = {};
|
|
7806
7877
|
__export(dist_exports2, {
|
|
7807
7878
|
BlockchainClient: () => BlockchainClient,
|
|
7879
|
+
VerifyCredentialsError: () => VerifyCredentialsError,
|
|
7808
7880
|
WalletCoreSigner: () => WalletCoreSigner,
|
|
7809
7881
|
_setWalletCore: () => _setWalletCore,
|
|
7810
7882
|
applyPolyfills: () => applyPolyfills,
|
|
@@ -7819,7 +7891,8 @@ __export(dist_exports2, {
|
|
|
7819
7891
|
patchNodeStubs: () => patchNodeStubs,
|
|
7820
7892
|
registerDeviceAndWallet: () => registerDeviceAndWallet,
|
|
7821
7893
|
setPolyfillCredentials: () => setPolyfillCredentials,
|
|
7822
|
-
setPolyfillNaasSessionId: () => setPolyfillNaasSessionId
|
|
7894
|
+
setPolyfillNaasSessionId: () => setPolyfillNaasSessionId,
|
|
7895
|
+
verifyCredentials: () => verifyCredentials
|
|
7823
7896
|
});
|
|
7824
7897
|
var init_dist4 = __esm({
|
|
7825
7898
|
"../blockchain/dist/index.mjs"() {
|
|
@@ -8500,13 +8573,13 @@ var require_util2 = __commonJS({
|
|
|
8500
8573
|
"../../node_modules/.pnpm/blakejs@1.2.1/node_modules/blakejs/util.js"(exports2, module2) {
|
|
8501
8574
|
"use strict";
|
|
8502
8575
|
var ERROR_MSG_INPUT = "Input must be an string, Buffer or Uint8Array";
|
|
8503
|
-
function normalizeInput(
|
|
8576
|
+
function normalizeInput(input2) {
|
|
8504
8577
|
let ret;
|
|
8505
|
-
if (
|
|
8506
|
-
ret =
|
|
8507
|
-
} else if (typeof
|
|
8578
|
+
if (input2 instanceof Uint8Array) {
|
|
8579
|
+
ret = input2;
|
|
8580
|
+
} else if (typeof input2 === "string") {
|
|
8508
8581
|
const encoder2 = new TextEncoder();
|
|
8509
|
-
ret = encoder2.encode(
|
|
8582
|
+
ret = encoder2.encode(input2);
|
|
8510
8583
|
} else {
|
|
8511
8584
|
throw new Error(ERROR_MSG_INPUT);
|
|
8512
8585
|
}
|
|
@@ -8541,15 +8614,15 @@ var require_util2 = __commonJS({
|
|
|
8541
8614
|
}
|
|
8542
8615
|
function testSpeed(hashFn, N11, M5) {
|
|
8543
8616
|
let startMs = (/* @__PURE__ */ new Date()).getTime();
|
|
8544
|
-
const
|
|
8617
|
+
const input2 = new Uint8Array(N11);
|
|
8545
8618
|
for (let i2 = 0; i2 < N11; i2++) {
|
|
8546
|
-
|
|
8619
|
+
input2[i2] = i2 % 256;
|
|
8547
8620
|
}
|
|
8548
8621
|
const genMs = (/* @__PURE__ */ new Date()).getTime();
|
|
8549
8622
|
console.log("Generated random input in " + (genMs - startMs) + "ms");
|
|
8550
8623
|
startMs = genMs;
|
|
8551
8624
|
for (let i2 = 0; i2 < M5; i2++) {
|
|
8552
|
-
const hashHex = hashFn(
|
|
8625
|
+
const hashHex = hashFn(input2);
|
|
8553
8626
|
const hashMs = (/* @__PURE__ */ new Date()).getTime();
|
|
8554
8627
|
const ms3 = hashMs - startMs;
|
|
8555
8628
|
startMs = hashMs;
|
|
@@ -8994,14 +9067,14 @@ var require_blake2b = __commonJS({
|
|
|
8994
9067
|
}
|
|
8995
9068
|
return ctx;
|
|
8996
9069
|
}
|
|
8997
|
-
function blake2bUpdate(ctx,
|
|
8998
|
-
for (let i2 = 0; i2 <
|
|
9070
|
+
function blake2bUpdate(ctx, input2) {
|
|
9071
|
+
for (let i2 = 0; i2 < input2.length; i2++) {
|
|
8999
9072
|
if (ctx.c === 128) {
|
|
9000
9073
|
ctx.t += ctx.c;
|
|
9001
9074
|
blake2bCompress(ctx, false);
|
|
9002
9075
|
ctx.c = 0;
|
|
9003
9076
|
}
|
|
9004
|
-
ctx.b[ctx.c++] =
|
|
9077
|
+
ctx.b[ctx.c++] = input2[i2];
|
|
9005
9078
|
}
|
|
9006
9079
|
}
|
|
9007
9080
|
function blake2bFinal(ctx) {
|
|
@@ -9016,9 +9089,9 @@ var require_blake2b = __commonJS({
|
|
|
9016
9089
|
}
|
|
9017
9090
|
return out;
|
|
9018
9091
|
}
|
|
9019
|
-
function blake2b(
|
|
9092
|
+
function blake2b(input2, key, outlen, salt, personal) {
|
|
9020
9093
|
outlen = outlen || 64;
|
|
9021
|
-
|
|
9094
|
+
input2 = util2.normalizeInput(input2);
|
|
9022
9095
|
if (salt) {
|
|
9023
9096
|
salt = util2.normalizeInput(salt);
|
|
9024
9097
|
}
|
|
@@ -9026,11 +9099,11 @@ var require_blake2b = __commonJS({
|
|
|
9026
9099
|
personal = util2.normalizeInput(personal);
|
|
9027
9100
|
}
|
|
9028
9101
|
const ctx = blake2bInit(outlen, key, salt, personal);
|
|
9029
|
-
blake2bUpdate(ctx,
|
|
9102
|
+
blake2bUpdate(ctx, input2);
|
|
9030
9103
|
return blake2bFinal(ctx);
|
|
9031
9104
|
}
|
|
9032
|
-
function blake2bHex(
|
|
9033
|
-
const output2 = blake2b(
|
|
9105
|
+
function blake2bHex(input2, key, outlen, salt, personal) {
|
|
9106
|
+
const output2 = blake2b(input2, key, outlen, salt, personal);
|
|
9034
9107
|
return util2.toHex(output2);
|
|
9035
9108
|
}
|
|
9036
9109
|
module2.exports = {
|
|
@@ -9293,14 +9366,14 @@ var require_blake2s = __commonJS({
|
|
|
9293
9366
|
}
|
|
9294
9367
|
return ctx;
|
|
9295
9368
|
}
|
|
9296
|
-
function blake2sUpdate(ctx,
|
|
9297
|
-
for (let i2 = 0; i2 <
|
|
9369
|
+
function blake2sUpdate(ctx, input2) {
|
|
9370
|
+
for (let i2 = 0; i2 < input2.length; i2++) {
|
|
9298
9371
|
if (ctx.c === 64) {
|
|
9299
9372
|
ctx.t += ctx.c;
|
|
9300
9373
|
blake2sCompress(ctx, false);
|
|
9301
9374
|
ctx.c = 0;
|
|
9302
9375
|
}
|
|
9303
|
-
ctx.b[ctx.c++] =
|
|
9376
|
+
ctx.b[ctx.c++] = input2[i2];
|
|
9304
9377
|
}
|
|
9305
9378
|
}
|
|
9306
9379
|
function blake2sFinal(ctx) {
|
|
@@ -9315,15 +9388,15 @@ var require_blake2s = __commonJS({
|
|
|
9315
9388
|
}
|
|
9316
9389
|
return out;
|
|
9317
9390
|
}
|
|
9318
|
-
function blake2s(
|
|
9391
|
+
function blake2s(input2, key, outlen) {
|
|
9319
9392
|
outlen = outlen || 32;
|
|
9320
|
-
|
|
9393
|
+
input2 = util2.normalizeInput(input2);
|
|
9321
9394
|
const ctx = blake2sInit(outlen, key);
|
|
9322
|
-
blake2sUpdate(ctx,
|
|
9395
|
+
blake2sUpdate(ctx, input2);
|
|
9323
9396
|
return blake2sFinal(ctx);
|
|
9324
9397
|
}
|
|
9325
|
-
function blake2sHex(
|
|
9326
|
-
const output2 = blake2s(
|
|
9398
|
+
function blake2sHex(input2, key, outlen) {
|
|
9399
|
+
const output2 = blake2s(input2, key, outlen);
|
|
9327
9400
|
return util2.toHex(output2);
|
|
9328
9401
|
}
|
|
9329
9402
|
module2.exports = {
|
|
@@ -11293,7 +11366,7 @@ var require_websocket = __commonJS({
|
|
|
11293
11366
|
var http2 = require("http");
|
|
11294
11367
|
var net = require("net");
|
|
11295
11368
|
var tls = require("tls");
|
|
11296
|
-
var { randomBytes:
|
|
11369
|
+
var { randomBytes: randomBytes6, createHash: createHash2 } = require("crypto");
|
|
11297
11370
|
var { Readable } = require("stream");
|
|
11298
11371
|
var { URL: URL2 } = require("url");
|
|
11299
11372
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -11753,7 +11826,7 @@ var require_websocket = __commonJS({
|
|
|
11753
11826
|
}
|
|
11754
11827
|
const isSecure = parsedUrl.protocol === "wss:" || parsedUrl.protocol === "https:";
|
|
11755
11828
|
const defaultPort = isSecure ? 443 : 80;
|
|
11756
|
-
const key =
|
|
11829
|
+
const key = randomBytes6(16).toString("base64");
|
|
11757
11830
|
const get2 = isSecure ? https2.get : http2.get;
|
|
11758
11831
|
let perMessageDeflate;
|
|
11759
11832
|
opts.createConnection = isSecure ? tlsConnect : netConnect;
|
|
@@ -12596,9 +12669,9 @@ var require_widest_line = __commonJS({
|
|
|
12596
12669
|
"../../node_modules/.pnpm/widest-line@3.1.0/node_modules/widest-line/index.js"(exports2, module2) {
|
|
12597
12670
|
"use strict";
|
|
12598
12671
|
var stringWidth = require_string_width();
|
|
12599
|
-
var widestLine = (
|
|
12672
|
+
var widestLine = (input2) => {
|
|
12600
12673
|
let max = 0;
|
|
12601
|
-
for (const line of
|
|
12674
|
+
for (const line of input2.split("\n")) {
|
|
12602
12675
|
max = Math.max(max, stringWidth(line));
|
|
12603
12676
|
}
|
|
12604
12677
|
return max;
|
|
@@ -12719,17 +12792,17 @@ var require_camelcase = __commonJS({
|
|
|
12719
12792
|
}
|
|
12720
12793
|
return string4;
|
|
12721
12794
|
};
|
|
12722
|
-
var preserveConsecutiveUppercase = (
|
|
12795
|
+
var preserveConsecutiveUppercase = (input2, toLowerCase) => {
|
|
12723
12796
|
LEADING_CAPITAL.lastIndex = 0;
|
|
12724
|
-
return
|
|
12797
|
+
return input2.replace(LEADING_CAPITAL, (m1) => toLowerCase(m1));
|
|
12725
12798
|
};
|
|
12726
|
-
var postProcess = (
|
|
12799
|
+
var postProcess = (input2, toUpperCase) => {
|
|
12727
12800
|
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
|
|
12728
12801
|
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
|
12729
|
-
return
|
|
12802
|
+
return input2.replace(SEPARATORS_AND_IDENTIFIER, (_2, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m2) => toUpperCase(m2));
|
|
12730
12803
|
};
|
|
12731
|
-
var camelCase = (
|
|
12732
|
-
if (!(typeof
|
|
12804
|
+
var camelCase = (input2, options) => {
|
|
12805
|
+
if (!(typeof input2 === "string" || Array.isArray(input2))) {
|
|
12733
12806
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
12734
12807
|
}
|
|
12735
12808
|
options = {
|
|
@@ -12737,33 +12810,33 @@ var require_camelcase = __commonJS({
|
|
|
12737
12810
|
preserveConsecutiveUppercase: false,
|
|
12738
12811
|
...options
|
|
12739
12812
|
};
|
|
12740
|
-
if (Array.isArray(
|
|
12741
|
-
|
|
12813
|
+
if (Array.isArray(input2)) {
|
|
12814
|
+
input2 = input2.map((x6) => x6.trim()).filter((x6) => x6.length).join("-");
|
|
12742
12815
|
} else {
|
|
12743
|
-
|
|
12816
|
+
input2 = input2.trim();
|
|
12744
12817
|
}
|
|
12745
|
-
if (
|
|
12818
|
+
if (input2.length === 0) {
|
|
12746
12819
|
return "";
|
|
12747
12820
|
}
|
|
12748
12821
|
const toLowerCase = options.locale === false ? (string4) => string4.toLowerCase() : (string4) => string4.toLocaleLowerCase(options.locale);
|
|
12749
12822
|
const toUpperCase = options.locale === false ? (string4) => string4.toUpperCase() : (string4) => string4.toLocaleUpperCase(options.locale);
|
|
12750
|
-
if (
|
|
12751
|
-
return options.pascalCase ? toUpperCase(
|
|
12823
|
+
if (input2.length === 1) {
|
|
12824
|
+
return options.pascalCase ? toUpperCase(input2) : toLowerCase(input2);
|
|
12752
12825
|
}
|
|
12753
|
-
const hasUpperCase =
|
|
12826
|
+
const hasUpperCase = input2 !== toLowerCase(input2);
|
|
12754
12827
|
if (hasUpperCase) {
|
|
12755
|
-
|
|
12828
|
+
input2 = preserveCamelCase(input2, toLowerCase, toUpperCase);
|
|
12756
12829
|
}
|
|
12757
|
-
|
|
12830
|
+
input2 = input2.replace(LEADING_SEPARATORS, "");
|
|
12758
12831
|
if (options.preserveConsecutiveUppercase) {
|
|
12759
|
-
|
|
12832
|
+
input2 = preserveConsecutiveUppercase(input2, toLowerCase);
|
|
12760
12833
|
} else {
|
|
12761
|
-
|
|
12834
|
+
input2 = toLowerCase(input2);
|
|
12762
12835
|
}
|
|
12763
12836
|
if (options.pascalCase) {
|
|
12764
|
-
|
|
12837
|
+
input2 = toUpperCase(input2.charAt(0)) + input2.slice(1);
|
|
12765
12838
|
}
|
|
12766
|
-
return postProcess(
|
|
12839
|
+
return postProcess(input2, toUpperCase);
|
|
12767
12840
|
};
|
|
12768
12841
|
module2.exports = camelCase;
|
|
12769
12842
|
module2.exports.default = camelCase;
|
|
@@ -12986,7 +13059,7 @@ var require_boxen = __commonJS({
|
|
|
12986
13059
|
"../../node_modules/.pnpm/boxen@5.1.2/node_modules/boxen/index.js"(exports2, module2) {
|
|
12987
13060
|
"use strict";
|
|
12988
13061
|
var stringWidth = require_string_width();
|
|
12989
|
-
var
|
|
13062
|
+
var chalk9 = require_source();
|
|
12990
13063
|
var widestLine = require_widest_line();
|
|
12991
13064
|
var cliBoxes = require_cli_boxes();
|
|
12992
13065
|
var camelCase = require_camelcase();
|
|
@@ -13129,9 +13202,9 @@ var require_boxen = __commonJS({
|
|
|
13129
13202
|
return lines.join(NL);
|
|
13130
13203
|
};
|
|
13131
13204
|
var isHex = (color) => color.match(/^#(?:[0-f]{3}){1,2}$/i);
|
|
13132
|
-
var isColorValid = (color) => typeof color === "string" && (
|
|
13133
|
-
var getColorFn = (color) => isHex(color) ?
|
|
13134
|
-
var getBGColorFn = (color) => isHex(color) ?
|
|
13205
|
+
var isColorValid = (color) => typeof color === "string" && (chalk9[color] || isHex(color));
|
|
13206
|
+
var getColorFn = (color) => isHex(color) ? chalk9.hex(color) : chalk9[color];
|
|
13207
|
+
var getBGColorFn = (color) => isHex(color) ? chalk9.bgHex(color) : chalk9[camelCase(["bg", color])];
|
|
13135
13208
|
module2.exports = (text, options) => {
|
|
13136
13209
|
options = {
|
|
13137
13210
|
padding: 0,
|
|
@@ -13157,7 +13230,7 @@ var require_boxen = __commonJS({
|
|
|
13157
13230
|
const margin = getObject(options.margin);
|
|
13158
13231
|
const colorizeBorder = (border) => {
|
|
13159
13232
|
const newBorder = options.borderColor ? getColorFn(options.borderColor)(border) : border;
|
|
13160
|
-
return options.dimBorder ?
|
|
13233
|
+
return options.dimBorder ? chalk9.dim(newBorder) : newBorder;
|
|
13161
13234
|
};
|
|
13162
13235
|
const colorizeContent = (content) => options.backgroundColor ? getBGColorFn(options.backgroundColor)(content) : content;
|
|
13163
13236
|
const columns = terminalColumns();
|
|
@@ -16379,27 +16452,27 @@ var require_utils2 = __commonJS({
|
|
|
16379
16452
|
"use strict";
|
|
16380
16453
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
16381
16454
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
16382
|
-
function stringArrayToHexStripped(
|
|
16455
|
+
function stringArrayToHexStripped(input2) {
|
|
16383
16456
|
let acc = "";
|
|
16384
16457
|
let code2 = 0;
|
|
16385
16458
|
let i2 = 0;
|
|
16386
|
-
for (i2 = 0; i2 <
|
|
16387
|
-
code2 =
|
|
16459
|
+
for (i2 = 0; i2 < input2.length; i2++) {
|
|
16460
|
+
code2 = input2[i2].charCodeAt(0);
|
|
16388
16461
|
if (code2 === 48) {
|
|
16389
16462
|
continue;
|
|
16390
16463
|
}
|
|
16391
16464
|
if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
|
|
16392
16465
|
return "";
|
|
16393
16466
|
}
|
|
16394
|
-
acc +=
|
|
16467
|
+
acc += input2[i2];
|
|
16395
16468
|
break;
|
|
16396
16469
|
}
|
|
16397
|
-
for (i2 += 1; i2 <
|
|
16398
|
-
code2 =
|
|
16470
|
+
for (i2 += 1; i2 < input2.length; i2++) {
|
|
16471
|
+
code2 = input2[i2].charCodeAt(0);
|
|
16399
16472
|
if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
|
|
16400
16473
|
return "";
|
|
16401
16474
|
}
|
|
16402
|
-
acc +=
|
|
16475
|
+
acc += input2[i2];
|
|
16403
16476
|
}
|
|
16404
16477
|
return acc;
|
|
16405
16478
|
}
|
|
@@ -16421,7 +16494,7 @@ var require_utils2 = __commonJS({
|
|
|
16421
16494
|
}
|
|
16422
16495
|
return true;
|
|
16423
16496
|
}
|
|
16424
|
-
function getIPV6(
|
|
16497
|
+
function getIPV6(input2) {
|
|
16425
16498
|
let tokenCount = 0;
|
|
16426
16499
|
const output2 = { error: false, address: "", zone: "" };
|
|
16427
16500
|
const address = [];
|
|
@@ -16429,8 +16502,8 @@ var require_utils2 = __commonJS({
|
|
|
16429
16502
|
let endipv6Encountered = false;
|
|
16430
16503
|
let endIpv6 = false;
|
|
16431
16504
|
let consume = consumeHextets;
|
|
16432
|
-
for (let i2 = 0; i2 <
|
|
16433
|
-
const cursor =
|
|
16505
|
+
for (let i2 = 0; i2 < input2.length; i2++) {
|
|
16506
|
+
const cursor = input2[i2];
|
|
16434
16507
|
if (cursor === "[" || cursor === "]") {
|
|
16435
16508
|
continue;
|
|
16436
16509
|
}
|
|
@@ -16445,7 +16518,7 @@ var require_utils2 = __commonJS({
|
|
|
16445
16518
|
output2.error = true;
|
|
16446
16519
|
break;
|
|
16447
16520
|
}
|
|
16448
|
-
if (i2 > 0 &&
|
|
16521
|
+
if (i2 > 0 && input2[i2 - 1] === ":") {
|
|
16449
16522
|
endipv6Encountered = true;
|
|
16450
16523
|
}
|
|
16451
16524
|
address.push(":");
|
|
@@ -16497,37 +16570,37 @@ var require_utils2 = __commonJS({
|
|
|
16497
16570
|
return ind;
|
|
16498
16571
|
}
|
|
16499
16572
|
function removeDotSegments(path5) {
|
|
16500
|
-
let
|
|
16573
|
+
let input2 = path5;
|
|
16501
16574
|
const output2 = [];
|
|
16502
16575
|
let nextSlash = -1;
|
|
16503
16576
|
let len = 0;
|
|
16504
|
-
while (len =
|
|
16577
|
+
while (len = input2.length) {
|
|
16505
16578
|
if (len === 1) {
|
|
16506
|
-
if (
|
|
16579
|
+
if (input2 === ".") {
|
|
16507
16580
|
break;
|
|
16508
|
-
} else if (
|
|
16581
|
+
} else if (input2 === "/") {
|
|
16509
16582
|
output2.push("/");
|
|
16510
16583
|
break;
|
|
16511
16584
|
} else {
|
|
16512
|
-
output2.push(
|
|
16585
|
+
output2.push(input2);
|
|
16513
16586
|
break;
|
|
16514
16587
|
}
|
|
16515
16588
|
} else if (len === 2) {
|
|
16516
|
-
if (
|
|
16517
|
-
if (
|
|
16589
|
+
if (input2[0] === ".") {
|
|
16590
|
+
if (input2[1] === ".") {
|
|
16518
16591
|
break;
|
|
16519
|
-
} else if (
|
|
16520
|
-
|
|
16592
|
+
} else if (input2[1] === "/") {
|
|
16593
|
+
input2 = input2.slice(2);
|
|
16521
16594
|
continue;
|
|
16522
16595
|
}
|
|
16523
|
-
} else if (
|
|
16524
|
-
if (
|
|
16596
|
+
} else if (input2[0] === "/") {
|
|
16597
|
+
if (input2[1] === "." || input2[1] === "/") {
|
|
16525
16598
|
output2.push("/");
|
|
16526
16599
|
break;
|
|
16527
16600
|
}
|
|
16528
16601
|
}
|
|
16529
16602
|
} else if (len === 3) {
|
|
16530
|
-
if (
|
|
16603
|
+
if (input2 === "/..") {
|
|
16531
16604
|
if (output2.length !== 0) {
|
|
16532
16605
|
output2.pop();
|
|
16533
16606
|
}
|
|
@@ -16535,24 +16608,24 @@ var require_utils2 = __commonJS({
|
|
|
16535
16608
|
break;
|
|
16536
16609
|
}
|
|
16537
16610
|
}
|
|
16538
|
-
if (
|
|
16539
|
-
if (
|
|
16540
|
-
if (
|
|
16541
|
-
|
|
16611
|
+
if (input2[0] === ".") {
|
|
16612
|
+
if (input2[1] === ".") {
|
|
16613
|
+
if (input2[2] === "/") {
|
|
16614
|
+
input2 = input2.slice(3);
|
|
16542
16615
|
continue;
|
|
16543
16616
|
}
|
|
16544
|
-
} else if (
|
|
16545
|
-
|
|
16617
|
+
} else if (input2[1] === "/") {
|
|
16618
|
+
input2 = input2.slice(2);
|
|
16546
16619
|
continue;
|
|
16547
16620
|
}
|
|
16548
|
-
} else if (
|
|
16549
|
-
if (
|
|
16550
|
-
if (
|
|
16551
|
-
|
|
16621
|
+
} else if (input2[0] === "/") {
|
|
16622
|
+
if (input2[1] === ".") {
|
|
16623
|
+
if (input2[2] === "/") {
|
|
16624
|
+
input2 = input2.slice(2);
|
|
16552
16625
|
continue;
|
|
16553
|
-
} else if (
|
|
16554
|
-
if (
|
|
16555
|
-
|
|
16626
|
+
} else if (input2[2] === ".") {
|
|
16627
|
+
if (input2[3] === "/") {
|
|
16628
|
+
input2 = input2.slice(3);
|
|
16556
16629
|
if (output2.length !== 0) {
|
|
16557
16630
|
output2.pop();
|
|
16558
16631
|
}
|
|
@@ -16561,12 +16634,12 @@ var require_utils2 = __commonJS({
|
|
|
16561
16634
|
}
|
|
16562
16635
|
}
|
|
16563
16636
|
}
|
|
16564
|
-
if ((nextSlash =
|
|
16565
|
-
output2.push(
|
|
16637
|
+
if ((nextSlash = input2.indexOf("/", 1)) === -1) {
|
|
16638
|
+
output2.push(input2);
|
|
16566
16639
|
break;
|
|
16567
16640
|
} else {
|
|
16568
|
-
output2.push(
|
|
16569
|
-
|
|
16641
|
+
output2.push(input2.slice(0, nextSlash));
|
|
16642
|
+
input2 = input2.slice(nextSlash);
|
|
16570
16643
|
}
|
|
16571
16644
|
}
|
|
16572
16645
|
return output2.join("");
|
|
@@ -22632,13 +22705,10 @@ async function getCredentials() {
|
|
|
22632
22705
|
if (credentials) {
|
|
22633
22706
|
return { accessId: credentials.accessId, hmacSecret: credentials.hmacSecret };
|
|
22634
22707
|
}
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22638
|
-
"Set TWAK_ACCESS_ID and TWAK_HMAC_SECRET environment variables, then run `twak init`"
|
|
22639
|
-
)
|
|
22708
|
+
throw new CommandError(
|
|
22709
|
+
"VALIDATION_ERROR",
|
|
22710
|
+
"No API credentials found. Run `twak setup` (or set TWAK_ACCESS_ID and TWAK_HMAC_SECRET env vars)."
|
|
22640
22711
|
);
|
|
22641
|
-
process.exit(1);
|
|
22642
22712
|
}
|
|
22643
22713
|
async function getClient() {
|
|
22644
22714
|
const creds = await getCredentials();
|
|
@@ -22876,20 +22946,20 @@ function deserializeRaw(value) {
|
|
|
22876
22946
|
}
|
|
22877
22947
|
return base64Decode(value.slice(BASE64_PREFIX.length));
|
|
22878
22948
|
}
|
|
22879
|
-
function base64Decode(
|
|
22949
|
+
function base64Decode(input2) {
|
|
22880
22950
|
if (globalThis.Buffer) {
|
|
22881
|
-
return Buffer.from(
|
|
22951
|
+
return Buffer.from(input2, "base64");
|
|
22882
22952
|
}
|
|
22883
22953
|
return Uint8Array.from(
|
|
22884
|
-
globalThis.atob(
|
|
22954
|
+
globalThis.atob(input2),
|
|
22885
22955
|
(c3) => c3.codePointAt(0)
|
|
22886
22956
|
);
|
|
22887
22957
|
}
|
|
22888
|
-
function base64Encode(
|
|
22958
|
+
function base64Encode(input2) {
|
|
22889
22959
|
if (globalThis.Buffer) {
|
|
22890
|
-
return Buffer.from(
|
|
22960
|
+
return Buffer.from(input2).toString("base64");
|
|
22891
22961
|
}
|
|
22892
|
-
return globalThis.btoa(String.fromCodePoint(...
|
|
22962
|
+
return globalThis.btoa(String.fromCodePoint(...input2));
|
|
22893
22963
|
}
|
|
22894
22964
|
function normalizeKey(key) {
|
|
22895
22965
|
if (!key) {
|
|
@@ -25527,7 +25597,7 @@ function walk(err, fn2) {
|
|
|
25527
25597
|
|
|
25528
25598
|
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
25529
25599
|
var nc = __toESM(require("crypto"), 1);
|
|
25530
|
-
var
|
|
25600
|
+
var crypto5 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
25531
25601
|
|
|
25532
25602
|
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
|
|
25533
25603
|
function isBytes(a3) {
|
|
@@ -25623,12 +25693,12 @@ function createHasher(hashCons) {
|
|
|
25623
25693
|
hashC.create = () => hashCons();
|
|
25624
25694
|
return hashC;
|
|
25625
25695
|
}
|
|
25626
|
-
function
|
|
25627
|
-
if (
|
|
25628
|
-
return
|
|
25696
|
+
function randomBytes3(bytesLength = 32) {
|
|
25697
|
+
if (crypto5 && typeof crypto5.getRandomValues === "function") {
|
|
25698
|
+
return crypto5.getRandomValues(new Uint8Array(bytesLength));
|
|
25629
25699
|
}
|
|
25630
|
-
if (
|
|
25631
|
-
return Uint8Array.from(
|
|
25700
|
+
if (crypto5 && typeof crypto5.randomBytes === "function") {
|
|
25701
|
+
return Uint8Array.from(crypto5.randomBytes(bytesLength));
|
|
25632
25702
|
}
|
|
25633
25703
|
throw new Error("crypto.getRandomValues must be defined");
|
|
25634
25704
|
}
|
|
@@ -28469,7 +28539,7 @@ function weierstrass(curveDef) {
|
|
|
28469
28539
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
28470
28540
|
if (["recovered", "canonical"].some((k4) => k4 in opts))
|
|
28471
28541
|
throw new Error("sign() legacy options not supported");
|
|
28472
|
-
const { hash, randomBytes:
|
|
28542
|
+
const { hash, randomBytes: randomBytes6 } = CURVE;
|
|
28473
28543
|
let { lowS, prehash, extraEntropy: ent } = opts;
|
|
28474
28544
|
if (lowS == null)
|
|
28475
28545
|
lowS = true;
|
|
@@ -28481,7 +28551,7 @@ function weierstrass(curveDef) {
|
|
|
28481
28551
|
const d3 = normPrivateKeyToScalar(privateKey);
|
|
28482
28552
|
const seedArgs = [int2octets(d3), int2octets(h1int)];
|
|
28483
28553
|
if (ent != null && ent !== false) {
|
|
28484
|
-
const e2 = ent === true ?
|
|
28554
|
+
const e2 = ent === true ? randomBytes6(Fp.BYTES) : ent;
|
|
28485
28555
|
seedArgs.push(ensureBytes("extraEntropy", e2));
|
|
28486
28556
|
}
|
|
28487
28557
|
const seed = concatBytes2(...seedArgs);
|
|
@@ -28585,7 +28655,7 @@ function getHash(hash) {
|
|
|
28585
28655
|
return {
|
|
28586
28656
|
hash,
|
|
28587
28657
|
hmac: (key, ...msgs) => hmac(hash, key, concatBytes(...msgs)),
|
|
28588
|
-
randomBytes:
|
|
28658
|
+
randomBytes: randomBytes3
|
|
28589
28659
|
};
|
|
28590
28660
|
}
|
|
28591
28661
|
function createCurve(curveDef, defHash) {
|
|
@@ -28927,8 +28997,8 @@ function isArrayOf(isString, arr) {
|
|
|
28927
28997
|
return arr.every((item) => Number.isSafeInteger(item));
|
|
28928
28998
|
}
|
|
28929
28999
|
}
|
|
28930
|
-
function astr(label,
|
|
28931
|
-
if (typeof
|
|
29000
|
+
function astr(label, input2) {
|
|
29001
|
+
if (typeof input2 !== "string")
|
|
28932
29002
|
throw new Error(`${label}: string expected`);
|
|
28933
29003
|
return true;
|
|
28934
29004
|
}
|
|
@@ -28936,16 +29006,16 @@ function anumber2(n4) {
|
|
|
28936
29006
|
if (!Number.isSafeInteger(n4))
|
|
28937
29007
|
throw new Error(`invalid integer: ${n4}`);
|
|
28938
29008
|
}
|
|
28939
|
-
function aArr(
|
|
28940
|
-
if (!Array.isArray(
|
|
29009
|
+
function aArr(input2) {
|
|
29010
|
+
if (!Array.isArray(input2))
|
|
28941
29011
|
throw new Error("array expected");
|
|
28942
29012
|
}
|
|
28943
|
-
function astrArr(label,
|
|
28944
|
-
if (!isArrayOf(true,
|
|
29013
|
+
function astrArr(label, input2) {
|
|
29014
|
+
if (!isArrayOf(true, input2))
|
|
28945
29015
|
throw new Error(`${label}: array of strings expected`);
|
|
28946
29016
|
}
|
|
28947
|
-
function anumArr(label,
|
|
28948
|
-
if (!isArrayOf(false,
|
|
29017
|
+
function anumArr(label, input2) {
|
|
29018
|
+
if (!isArrayOf(false, input2))
|
|
28949
29019
|
throw new Error(`${label}: array of numbers expected`);
|
|
28950
29020
|
}
|
|
28951
29021
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -28971,9 +29041,9 @@ function alphabet(letters) {
|
|
|
28971
29041
|
return lettersA[i2];
|
|
28972
29042
|
});
|
|
28973
29043
|
},
|
|
28974
|
-
decode: (
|
|
28975
|
-
aArr(
|
|
28976
|
-
return
|
|
29044
|
+
decode: (input2) => {
|
|
29045
|
+
aArr(input2);
|
|
29046
|
+
return input2.map((letter) => {
|
|
28977
29047
|
astr("alphabet.decode", letter);
|
|
28978
29048
|
const i2 = indexes.get(letter);
|
|
28979
29049
|
if (i2 === void 0)
|
|
@@ -29008,18 +29078,18 @@ function padding(bits, chr = "=") {
|
|
|
29008
29078
|
data.push(chr);
|
|
29009
29079
|
return data;
|
|
29010
29080
|
},
|
|
29011
|
-
decode(
|
|
29012
|
-
astrArr("padding.decode",
|
|
29013
|
-
let end =
|
|
29081
|
+
decode(input2) {
|
|
29082
|
+
astrArr("padding.decode", input2);
|
|
29083
|
+
let end = input2.length;
|
|
29014
29084
|
if (end * bits % 8)
|
|
29015
29085
|
throw new Error("padding: invalid, string should have whole number of bytes");
|
|
29016
|
-
for (; end > 0 &&
|
|
29086
|
+
for (; end > 0 && input2[end - 1] === chr; end--) {
|
|
29017
29087
|
const last = end - 1;
|
|
29018
29088
|
const byte = last * bits;
|
|
29019
29089
|
if (byte % 8 === 0)
|
|
29020
29090
|
throw new Error("padding: invalid, string has too much padding");
|
|
29021
29091
|
}
|
|
29022
|
-
return
|
|
29092
|
+
return input2.slice(0, end);
|
|
29023
29093
|
}
|
|
29024
29094
|
};
|
|
29025
29095
|
}
|
|
@@ -30922,13 +30992,13 @@ var ComposedDecoder = class {
|
|
|
30922
30992
|
or(decoder) {
|
|
30923
30993
|
return or2(this, decoder);
|
|
30924
30994
|
}
|
|
30925
|
-
decode(
|
|
30926
|
-
const prefix =
|
|
30995
|
+
decode(input2) {
|
|
30996
|
+
const prefix = input2[0];
|
|
30927
30997
|
const decoder = this.decoders[prefix];
|
|
30928
30998
|
if (decoder) {
|
|
30929
|
-
return decoder.decode(
|
|
30999
|
+
return decoder.decode(input2);
|
|
30930
31000
|
} else {
|
|
30931
|
-
throw RangeError(`Unable to decode multibase string ${JSON.stringify(
|
|
31001
|
+
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input2)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
30932
31002
|
}
|
|
30933
31003
|
}
|
|
30934
31004
|
};
|
|
@@ -30945,11 +31015,11 @@ var Codec = class {
|
|
|
30945
31015
|
this.encoder = new Encoder2(name2, prefix, baseEncode);
|
|
30946
31016
|
this.decoder = new Decoder2(name2, prefix, baseDecode);
|
|
30947
31017
|
}
|
|
30948
|
-
encode(
|
|
30949
|
-
return this.encoder.encode(
|
|
31018
|
+
encode(input2) {
|
|
31019
|
+
return this.encoder.encode(input2);
|
|
30950
31020
|
}
|
|
30951
|
-
decode(
|
|
30952
|
-
return this.decoder.decode(
|
|
31021
|
+
decode(input2) {
|
|
31022
|
+
return this.decoder.decode(input2);
|
|
30953
31023
|
}
|
|
30954
31024
|
};
|
|
30955
31025
|
var from6 = ({ name: name2, prefix, encode: encode6, decode: decode7 }) => new Codec(name2, prefix, encode6, decode7);
|
|
@@ -31020,11 +31090,11 @@ var rfc4648 = ({ name: name2, prefix, bitsPerChar, alphabet: alphabet3 }) => {
|
|
|
31020
31090
|
return from6({
|
|
31021
31091
|
prefix,
|
|
31022
31092
|
name: name2,
|
|
31023
|
-
encode(
|
|
31024
|
-
return encode2(
|
|
31093
|
+
encode(input2) {
|
|
31094
|
+
return encode2(input2, alphabet3, bitsPerChar);
|
|
31025
31095
|
},
|
|
31026
|
-
decode(
|
|
31027
|
-
return decode2(
|
|
31096
|
+
decode(input2) {
|
|
31097
|
+
return decode2(input2, alphabet3, bitsPerChar, name2);
|
|
31028
31098
|
}
|
|
31029
31099
|
});
|
|
31030
31100
|
};
|
|
@@ -31392,9 +31462,9 @@ var Hasher = class {
|
|
|
31392
31462
|
this.code = code2;
|
|
31393
31463
|
this.encode = encode6;
|
|
31394
31464
|
}
|
|
31395
|
-
digest(
|
|
31396
|
-
if (
|
|
31397
|
-
const result = this.encode(
|
|
31465
|
+
digest(input2) {
|
|
31466
|
+
if (input2 instanceof Uint8Array) {
|
|
31467
|
+
const result = this.encode(input2);
|
|
31398
31468
|
return result instanceof Uint8Array ? create(this.code, result) : result.then((digest2) => create(this.code, digest2));
|
|
31399
31469
|
} else {
|
|
31400
31470
|
throw Error("Unknown type, must be binary type");
|
|
@@ -31406,12 +31476,12 @@ var Hasher = class {
|
|
|
31406
31476
|
var sha2562 = from7({
|
|
31407
31477
|
name: "sha2-256",
|
|
31408
31478
|
code: 18,
|
|
31409
|
-
encode: (
|
|
31479
|
+
encode: (input2) => coerce(import_crypto4.default.createHash("sha256").update(input2).digest())
|
|
31410
31480
|
});
|
|
31411
31481
|
var sha512 = from7({
|
|
31412
31482
|
name: "sha2-512",
|
|
31413
31483
|
code: 19,
|
|
31414
|
-
encode: (
|
|
31484
|
+
encode: (input2) => coerce(import_crypto4.default.createHash("sha512").update(input2).digest())
|
|
31415
31485
|
});
|
|
31416
31486
|
|
|
31417
31487
|
// ../../node_modules/.pnpm/multiformats@9.9.0/node_modules/multiformats/esm/src/hashes/identity.js
|
|
@@ -31422,7 +31492,7 @@ __export(identity_exports2, {
|
|
|
31422
31492
|
var code = 0;
|
|
31423
31493
|
var name = "identity";
|
|
31424
31494
|
var encode5 = coerce;
|
|
31425
|
-
var digest = (
|
|
31495
|
+
var digest = (input2) => create(code, encode5(input2));
|
|
31426
31496
|
var identity2 = {
|
|
31427
31497
|
code,
|
|
31428
31498
|
name,
|
|
@@ -38874,8 +38944,8 @@ async function tryRegisterWallet() {
|
|
|
38874
38944
|
if (!await store.exists()) return;
|
|
38875
38945
|
try {
|
|
38876
38946
|
const creds = await ensureTrustSDK();
|
|
38877
|
-
const
|
|
38878
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
38947
|
+
const password2 = await resolvePassword();
|
|
38948
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
38879
38949
|
await registerWalletWithBackend(creds, provider);
|
|
38880
38950
|
info("Wallet registered with backend");
|
|
38881
38951
|
} catch {
|
|
@@ -38965,8 +39035,659 @@ function registerInitCommand(program3) {
|
|
|
38965
39035
|
});
|
|
38966
39036
|
}
|
|
38967
39037
|
|
|
38968
|
-
// src/commands/
|
|
39038
|
+
// src/commands/setup.ts
|
|
38969
39039
|
var import_chalk3 = __toESM(require_source());
|
|
39040
|
+
|
|
39041
|
+
// src/setup/harnesses/claude-code.ts
|
|
39042
|
+
var import_node_os = require("os");
|
|
39043
|
+
var import_node_path2 = require("path");
|
|
39044
|
+
|
|
39045
|
+
// src/setup/harnesses/json-base.ts
|
|
39046
|
+
var import_promises2 = require("fs/promises");
|
|
39047
|
+
|
|
39048
|
+
// src/setup/atomic-write.ts
|
|
39049
|
+
var import_node_crypto = require("crypto");
|
|
39050
|
+
var import_promises = require("fs/promises");
|
|
39051
|
+
var import_node_path = require("path");
|
|
39052
|
+
async function writeAtomic(path5, contents, mode = 420) {
|
|
39053
|
+
await (0, import_promises.mkdir)((0, import_node_path.dirname)(path5), { recursive: true });
|
|
39054
|
+
let effectiveMode = mode;
|
|
39055
|
+
try {
|
|
39056
|
+
const st4 = await (0, import_promises.stat)(path5);
|
|
39057
|
+
effectiveMode = st4.mode & 511;
|
|
39058
|
+
} catch {
|
|
39059
|
+
}
|
|
39060
|
+
const tmpPath = `${path5}.tmp.${(0, import_node_crypto.randomBytes)(8).toString("hex")}`;
|
|
39061
|
+
await (0, import_promises.writeFile)(tmpPath, contents, { mode: effectiveMode });
|
|
39062
|
+
try {
|
|
39063
|
+
await (0, import_promises.rename)(tmpPath, path5);
|
|
39064
|
+
} catch (err) {
|
|
39065
|
+
try {
|
|
39066
|
+
await (0, import_promises.rm)(tmpPath, { force: true });
|
|
39067
|
+
} catch {
|
|
39068
|
+
}
|
|
39069
|
+
throw err;
|
|
39070
|
+
}
|
|
39071
|
+
}
|
|
39072
|
+
|
|
39073
|
+
// src/setup/harnesses/types.ts
|
|
39074
|
+
var TARGET_ENTRY = {
|
|
39075
|
+
command: "twak",
|
|
39076
|
+
args: ["serve"]
|
|
39077
|
+
};
|
|
39078
|
+
function entriesEqual(a3, b3) {
|
|
39079
|
+
if (a3 === null || b3 === null) return a3 === b3;
|
|
39080
|
+
if (a3.command !== b3.command) return false;
|
|
39081
|
+
if (a3.args.length !== b3.args.length) return false;
|
|
39082
|
+
return a3.args.every((arg, i2) => arg === b3.args[i2]);
|
|
39083
|
+
}
|
|
39084
|
+
|
|
39085
|
+
// src/setup/harnesses/json-base.ts
|
|
39086
|
+
function createJsonMcpHarness(opts) {
|
|
39087
|
+
const { name: name2, displayName, configPath: configPath2 } = opts;
|
|
39088
|
+
async function readConfig2() {
|
|
39089
|
+
try {
|
|
39090
|
+
const raw = await (0, import_promises2.readFile)(configPath2(), "utf8");
|
|
39091
|
+
const parsed = JSON.parse(raw);
|
|
39092
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
39093
|
+
throw new Error(`${configPath2()}: root is not a JSON object`);
|
|
39094
|
+
}
|
|
39095
|
+
return parsed;
|
|
39096
|
+
} catch (err) {
|
|
39097
|
+
if (err.code === "ENOENT") return {};
|
|
39098
|
+
throw err;
|
|
39099
|
+
}
|
|
39100
|
+
}
|
|
39101
|
+
async function writeConfig2(config2) {
|
|
39102
|
+
await writeAtomic(configPath2(), JSON.stringify(config2, null, 2) + "\n");
|
|
39103
|
+
}
|
|
39104
|
+
return {
|
|
39105
|
+
name: name2,
|
|
39106
|
+
displayName,
|
|
39107
|
+
configPath: configPath2,
|
|
39108
|
+
async getCurrentEntry() {
|
|
39109
|
+
const config2 = await readConfig2();
|
|
39110
|
+
const entry = config2.mcpServers?.twak;
|
|
39111
|
+
if (!entry || typeof entry !== "object") return null;
|
|
39112
|
+
if (typeof entry.command !== "string") return null;
|
|
39113
|
+
if (!Array.isArray(entry.args) || !entry.args.every((a3) => typeof a3 === "string"))
|
|
39114
|
+
return null;
|
|
39115
|
+
return { command: entry.command, args: entry.args };
|
|
39116
|
+
},
|
|
39117
|
+
async getRawEntry() {
|
|
39118
|
+
const config2 = await readConfig2();
|
|
39119
|
+
return config2.mcpServers?.twak ?? null;
|
|
39120
|
+
},
|
|
39121
|
+
async writeEntry() {
|
|
39122
|
+
const config2 = await readConfig2();
|
|
39123
|
+
config2.mcpServers ??= {};
|
|
39124
|
+
config2.mcpServers.twak = { ...TARGET_ENTRY };
|
|
39125
|
+
await writeConfig2(config2);
|
|
39126
|
+
},
|
|
39127
|
+
async removeEntry() {
|
|
39128
|
+
const config2 = await readConfig2();
|
|
39129
|
+
if (!config2.mcpServers?.twak) return;
|
|
39130
|
+
delete config2.mcpServers.twak;
|
|
39131
|
+
if (Object.keys(config2.mcpServers).length === 0) {
|
|
39132
|
+
delete config2.mcpServers;
|
|
39133
|
+
}
|
|
39134
|
+
await writeConfig2(config2);
|
|
39135
|
+
}
|
|
39136
|
+
};
|
|
39137
|
+
}
|
|
39138
|
+
|
|
39139
|
+
// src/setup/harnesses/claude-code.ts
|
|
39140
|
+
var claude_code_default = createJsonMcpHarness({
|
|
39141
|
+
name: "claude-code",
|
|
39142
|
+
displayName: "Claude Code",
|
|
39143
|
+
configPath: () => (0, import_node_path2.join)((0, import_node_os.homedir)(), ".claude", "settings.json")
|
|
39144
|
+
});
|
|
39145
|
+
|
|
39146
|
+
// src/setup/harnesses/claude-desktop.ts
|
|
39147
|
+
var import_node_os2 = require("os");
|
|
39148
|
+
var import_node_path3 = require("path");
|
|
39149
|
+
function resolveConfigPath(platform2, env, home) {
|
|
39150
|
+
if (platform2 === "darwin") {
|
|
39151
|
+
return (0, import_node_path3.join)(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
39152
|
+
}
|
|
39153
|
+
if (platform2 === "win32") {
|
|
39154
|
+
const appData = env.APPDATA;
|
|
39155
|
+
if (!appData) {
|
|
39156
|
+
throw new Error(
|
|
39157
|
+
"APPDATA env var not set; cannot resolve Claude Desktop config path on Windows"
|
|
39158
|
+
);
|
|
39159
|
+
}
|
|
39160
|
+
return (0, import_node_path3.join)(appData, "Claude", "claude_desktop_config.json");
|
|
39161
|
+
}
|
|
39162
|
+
const xdgConfig = env.XDG_CONFIG_HOME || (0, import_node_path3.join)(home, ".config");
|
|
39163
|
+
return (0, import_node_path3.join)(xdgConfig, "Claude", "claude_desktop_config.json");
|
|
39164
|
+
}
|
|
39165
|
+
var claude_desktop_default = createJsonMcpHarness({
|
|
39166
|
+
name: "claude-desktop",
|
|
39167
|
+
displayName: "Claude Desktop",
|
|
39168
|
+
configPath: () => resolveConfigPath(process.platform, process.env, (0, import_node_os2.homedir)())
|
|
39169
|
+
});
|
|
39170
|
+
|
|
39171
|
+
// src/setup/harnesses/cursor.ts
|
|
39172
|
+
var import_node_os3 = require("os");
|
|
39173
|
+
var import_node_path4 = require("path");
|
|
39174
|
+
var cursor_default = createJsonMcpHarness({
|
|
39175
|
+
name: "cursor",
|
|
39176
|
+
displayName: "Cursor",
|
|
39177
|
+
configPath: () => (0, import_node_path4.join)((0, import_node_os3.homedir)(), ".cursor", "mcp.json")
|
|
39178
|
+
});
|
|
39179
|
+
|
|
39180
|
+
// src/setup/harnesses/codex.ts
|
|
39181
|
+
var import_toml = __toESM(require("@iarna/toml"));
|
|
39182
|
+
var import_promises3 = require("fs/promises");
|
|
39183
|
+
var import_node_os4 = require("os");
|
|
39184
|
+
var import_node_path5 = require("path");
|
|
39185
|
+
function configPath() {
|
|
39186
|
+
return (0, import_node_path5.join)((0, import_node_os4.homedir)(), ".codex", "config.toml");
|
|
39187
|
+
}
|
|
39188
|
+
async function readConfig() {
|
|
39189
|
+
let parsed;
|
|
39190
|
+
try {
|
|
39191
|
+
const raw = await (0, import_promises3.readFile)(configPath(), "utf8");
|
|
39192
|
+
parsed = import_toml.default.parse(raw);
|
|
39193
|
+
} catch (err) {
|
|
39194
|
+
if (err.code === "ENOENT") return {};
|
|
39195
|
+
throw err;
|
|
39196
|
+
}
|
|
39197
|
+
const mcp = parsed?.mcp_servers;
|
|
39198
|
+
if (Array.isArray(mcp)) {
|
|
39199
|
+
throw new Error(
|
|
39200
|
+
"[[mcp_servers]] array-of-tables form is not supported \u2014 twak needs a single [mcp_servers] table. Convert the section in ~/.codex/config.toml manually and re-run."
|
|
39201
|
+
);
|
|
39202
|
+
}
|
|
39203
|
+
return parsed ?? {};
|
|
39204
|
+
}
|
|
39205
|
+
async function writeConfig(config2) {
|
|
39206
|
+
const serialised = import_toml.default.stringify(config2);
|
|
39207
|
+
await writeAtomic(configPath(), serialised);
|
|
39208
|
+
}
|
|
39209
|
+
var codex = {
|
|
39210
|
+
name: "codex",
|
|
39211
|
+
displayName: "Codex CLI",
|
|
39212
|
+
configPath,
|
|
39213
|
+
async getCurrentEntry() {
|
|
39214
|
+
const config2 = await readConfig();
|
|
39215
|
+
const entry = config2.mcp_servers?.twak;
|
|
39216
|
+
if (!entry || typeof entry !== "object") return null;
|
|
39217
|
+
if (typeof entry.command !== "string") return null;
|
|
39218
|
+
if (!Array.isArray(entry.args) || !entry.args.every((a3) => typeof a3 === "string")) return null;
|
|
39219
|
+
return { command: entry.command, args: entry.args };
|
|
39220
|
+
},
|
|
39221
|
+
async getRawEntry() {
|
|
39222
|
+
const config2 = await readConfig();
|
|
39223
|
+
return config2.mcp_servers?.twak ?? null;
|
|
39224
|
+
},
|
|
39225
|
+
async writeEntry() {
|
|
39226
|
+
const config2 = await readConfig();
|
|
39227
|
+
config2.mcp_servers ??= {};
|
|
39228
|
+
config2.mcp_servers.twak = { ...TARGET_ENTRY };
|
|
39229
|
+
await writeConfig(config2);
|
|
39230
|
+
},
|
|
39231
|
+
async removeEntry() {
|
|
39232
|
+
const config2 = await readConfig();
|
|
39233
|
+
if (!config2.mcp_servers?.twak) return;
|
|
39234
|
+
delete config2.mcp_servers.twak;
|
|
39235
|
+
if (Object.keys(config2.mcp_servers).length === 0) {
|
|
39236
|
+
delete config2.mcp_servers;
|
|
39237
|
+
}
|
|
39238
|
+
await writeConfig(config2);
|
|
39239
|
+
}
|
|
39240
|
+
};
|
|
39241
|
+
var codex_default = codex;
|
|
39242
|
+
|
|
39243
|
+
// src/setup/harnesses/index.ts
|
|
39244
|
+
var ALL_HARNESSES = [claude_code_default, claude_desktop_default, cursor_default, codex_default];
|
|
39245
|
+
|
|
39246
|
+
// src/setup/phase-credentials.ts
|
|
39247
|
+
var import_prompts = require("@inquirer/prompts");
|
|
39248
|
+
init_dist2();
|
|
39249
|
+
init_dist();
|
|
39250
|
+
var PORTAL_URL = "https://portal.trustwallet.com/dashboard/apps";
|
|
39251
|
+
var defaultPrompter = {
|
|
39252
|
+
promptAccessId: () => (0, import_prompts.input)({
|
|
39253
|
+
message: "Access ID:",
|
|
39254
|
+
validate: (s2) => s2.trim().length > 0 ? true : "Access ID is required"
|
|
39255
|
+
}),
|
|
39256
|
+
promptHmacSecret: () => (0, import_prompts.password)({
|
|
39257
|
+
message: "HMAC secret:",
|
|
39258
|
+
mask: "\u25CF",
|
|
39259
|
+
validate: (s2) => s2.trim().length > 0 ? true : "HMAC secret is required"
|
|
39260
|
+
})
|
|
39261
|
+
};
|
|
39262
|
+
function makeDefaultDeps() {
|
|
39263
|
+
return {
|
|
39264
|
+
prompter: defaultPrompter,
|
|
39265
|
+
credManager: new CredentialManager(),
|
|
39266
|
+
env: process.env
|
|
39267
|
+
};
|
|
39268
|
+
}
|
|
39269
|
+
async function runCredentialsPhase(opts, deps = makeDefaultDeps()) {
|
|
39270
|
+
info("\nStep 1 of 3 \u2014 API credentials\n");
|
|
39271
|
+
const existing = await deps.credManager.load();
|
|
39272
|
+
if (existing && !opts.reconfigureCreds) {
|
|
39273
|
+
success(`Credentials already configured (access ID ${existing.accessId.slice(0, 8)})`);
|
|
39274
|
+
return;
|
|
39275
|
+
}
|
|
39276
|
+
const isRotation = existing !== null;
|
|
39277
|
+
if (opts.nonInteractive) {
|
|
39278
|
+
await runNonInteractive(deps);
|
|
39279
|
+
} else {
|
|
39280
|
+
info(`Get your API Credentials at: ${PORTAL_URL}
|
|
39281
|
+
`);
|
|
39282
|
+
await runInteractive(deps);
|
|
39283
|
+
}
|
|
39284
|
+
if (isRotation) {
|
|
39285
|
+
warn(
|
|
39286
|
+
"Heads up: if you previously hand-pasted `env: { TWAK_HMAC_SECRET: '\u2026' }` into a harness's MCP config, that value is now stale. The canonical twak entry pulls credentials from ~/.twak/credentials.json \u2014 drop any explicit env blocks so the new secret is used."
|
|
39287
|
+
);
|
|
39288
|
+
}
|
|
39289
|
+
}
|
|
39290
|
+
async function runNonInteractive(deps) {
|
|
39291
|
+
const accessId = deps.env.TWAK_ACCESS_ID?.trim();
|
|
39292
|
+
const hmacSecret = deps.env.TWAK_HMAC_SECRET?.trim();
|
|
39293
|
+
if (!accessId || !hmacSecret) {
|
|
39294
|
+
throw new CommandError(
|
|
39295
|
+
"VALIDATION_ERROR",
|
|
39296
|
+
"Non-interactive setup requires TWAK_ACCESS_ID and TWAK_HMAC_SECRET in the environment."
|
|
39297
|
+
);
|
|
39298
|
+
}
|
|
39299
|
+
const result = await deps.credManager.save({ accessId, hmacSecret });
|
|
39300
|
+
success(`Saved access ID ${accessId.slice(0, 8)} to ${storageLocation(result.keychain)}`);
|
|
39301
|
+
}
|
|
39302
|
+
async function runInteractive(deps) {
|
|
39303
|
+
const accessId = (await deps.prompter.promptAccessId()).trim();
|
|
39304
|
+
const hmacSecret = (await deps.prompter.promptHmacSecret()).trim();
|
|
39305
|
+
const result = await deps.credManager.save({ accessId, hmacSecret });
|
|
39306
|
+
success(`Saved access ID ${accessId.slice(0, 8)} to ${storageLocation(result.keychain)}`);
|
|
39307
|
+
}
|
|
39308
|
+
function storageLocation(keychain) {
|
|
39309
|
+
return keychain ? "~/.twak/credentials.json (0600) + OS keychain (HMAC secret mirror)" : "~/.twak/credentials.json (0600); OS keychain unavailable, secret only on disk";
|
|
39310
|
+
}
|
|
39311
|
+
|
|
39312
|
+
// src/setup/phase-harnesses.ts
|
|
39313
|
+
var import_prompts2 = require("@inquirer/prompts");
|
|
39314
|
+
init_dist();
|
|
39315
|
+
function indent(s2, spaces) {
|
|
39316
|
+
const prefix = " ".repeat(spaces);
|
|
39317
|
+
return s2.split("\n").map((line) => prefix + line).join("\n");
|
|
39318
|
+
}
|
|
39319
|
+
function entryHasExtras(raw) {
|
|
39320
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return false;
|
|
39321
|
+
return Object.keys(raw).some((k4) => k4 !== "command" && k4 !== "args");
|
|
39322
|
+
}
|
|
39323
|
+
function entryHasEnv(raw) {
|
|
39324
|
+
return !!raw && typeof raw === "object" && !Array.isArray(raw) && "env" in raw;
|
|
39325
|
+
}
|
|
39326
|
+
var defaultPrompter2 = {
|
|
39327
|
+
selectHarnesses: (choices) => (0, import_prompts2.checkbox)({
|
|
39328
|
+
message: "Which harnesses should be wired up? (\u2191/\u2193 to move, SPACE to toggle, A to toggle all, ENTER to confirm)",
|
|
39329
|
+
choices: choices.map((c3) => ({ name: c3.label, value: c3.name }))
|
|
39330
|
+
}),
|
|
39331
|
+
resolveConflict: (displayName, existing, target) => (0, import_prompts2.select)({
|
|
39332
|
+
message: `${displayName} has an existing twak entry that differs.
|
|
39333
|
+
|
|
39334
|
+
Current:
|
|
39335
|
+
${indent(JSON.stringify(existing, null, 2), 4)}
|
|
39336
|
+
|
|
39337
|
+
After "update":
|
|
39338
|
+
${indent(JSON.stringify(target, null, 2), 4)}
|
|
39339
|
+
|
|
39340
|
+
What now?`,
|
|
39341
|
+
choices: [
|
|
39342
|
+
{ name: "Update \u2014 replace with the shape above (drops any other fields)", value: "update" },
|
|
39343
|
+
{ name: "Keep \u2014 leave the existing entry alone", value: "keep" },
|
|
39344
|
+
{ name: "Remove \u2014 delete the twak entry entirely", value: "remove" }
|
|
39345
|
+
]
|
|
39346
|
+
})
|
|
39347
|
+
};
|
|
39348
|
+
function makeDefaultDeps2() {
|
|
39349
|
+
return {
|
|
39350
|
+
harnesses: ALL_HARNESSES,
|
|
39351
|
+
prompter: defaultPrompter2,
|
|
39352
|
+
env: process.env
|
|
39353
|
+
};
|
|
39354
|
+
}
|
|
39355
|
+
async function runHarnessesPhase(opts, deps = makeDefaultDeps2()) {
|
|
39356
|
+
info("\nStep 2 of 3 \u2014 Connect to your AI agent\n");
|
|
39357
|
+
if (opts.nonInteractive) {
|
|
39358
|
+
await runNonInteractive2(opts, deps);
|
|
39359
|
+
return;
|
|
39360
|
+
}
|
|
39361
|
+
if (opts.harness) {
|
|
39362
|
+
const writer = findHarness(deps.harnesses, opts.harness);
|
|
39363
|
+
await processHarness(writer, deps, true);
|
|
39364
|
+
return;
|
|
39365
|
+
}
|
|
39366
|
+
await runMultiSelect(deps);
|
|
39367
|
+
}
|
|
39368
|
+
async function runMultiSelect(deps) {
|
|
39369
|
+
const choices = deps.harnesses.map((h4) => ({ name: h4.name, label: h4.displayName }));
|
|
39370
|
+
const selected = await deps.prompter.selectHarnesses(choices);
|
|
39371
|
+
if (selected.length === 0) {
|
|
39372
|
+
info("No harnesses selected. Re-run `twak setup --harness <name>` later to wire one.");
|
|
39373
|
+
return;
|
|
39374
|
+
}
|
|
39375
|
+
let wrote = 0;
|
|
39376
|
+
let removed = 0;
|
|
39377
|
+
for (const name2 of selected) {
|
|
39378
|
+
const writer = deps.harnesses.find((h4) => h4.name === name2);
|
|
39379
|
+
if (!writer) continue;
|
|
39380
|
+
const result = await processHarness(writer, deps, false);
|
|
39381
|
+
if (result === "wrote") wrote++;
|
|
39382
|
+
else if (result === "removed") removed++;
|
|
39383
|
+
}
|
|
39384
|
+
if (wrote === 0 && removed === 0) {
|
|
39385
|
+
info("No harness configs changed.");
|
|
39386
|
+
return;
|
|
39387
|
+
}
|
|
39388
|
+
const parts = [];
|
|
39389
|
+
if (wrote > 0) parts.push(`Wired ${wrote} harness(es)`);
|
|
39390
|
+
if (removed > 0) parts.push(`removed ${removed}`);
|
|
39391
|
+
success(`${parts.join("; ")}. Restart any running harness for changes to take effect.`);
|
|
39392
|
+
}
|
|
39393
|
+
async function processHarness(writer, deps, verbose) {
|
|
39394
|
+
let current;
|
|
39395
|
+
try {
|
|
39396
|
+
current = await writer.getCurrentEntry();
|
|
39397
|
+
} catch (err) {
|
|
39398
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
39399
|
+
error(
|
|
39400
|
+
`Skipping ${writer.displayName}: config at ${writer.configPath()} is invalid (${msg}). Fix it manually and re-run \`twak setup --harness ${writer.name}\`.`
|
|
39401
|
+
);
|
|
39402
|
+
return null;
|
|
39403
|
+
}
|
|
39404
|
+
const raw = await writer.getRawEntry();
|
|
39405
|
+
if (current === null && raw === null) {
|
|
39406
|
+
info(`Wiring ${writer.displayName} \u2192 ${writer.configPath()}`);
|
|
39407
|
+
await writer.writeEntry();
|
|
39408
|
+
return "wrote";
|
|
39409
|
+
}
|
|
39410
|
+
if (current !== null && entriesEqual(current, TARGET_ENTRY) && !entryHasExtras(raw)) {
|
|
39411
|
+
if (verbose) success(`${writer.displayName} already wired (no changes)`);
|
|
39412
|
+
return null;
|
|
39413
|
+
}
|
|
39414
|
+
if (entryHasEnv(raw)) {
|
|
39415
|
+
warn(
|
|
39416
|
+
`${writer.displayName} has an existing twak entry with an \`env\` block. Choosing Update will drop it; if it contained credentials, the harness will fall back to ~/.twak/credentials.json (run \`twak setup --reconfigure-creds\` to refresh) before restarting.`
|
|
39417
|
+
);
|
|
39418
|
+
}
|
|
39419
|
+
const action = await deps.prompter.resolveConflict(writer.displayName, raw, TARGET_ENTRY);
|
|
39420
|
+
if (action === "update") {
|
|
39421
|
+
info(`Updating ${writer.displayName} \u2192 ${writer.configPath()}`);
|
|
39422
|
+
await writer.writeEntry();
|
|
39423
|
+
return "wrote";
|
|
39424
|
+
}
|
|
39425
|
+
if (action === "remove") {
|
|
39426
|
+
info(`Removing twak from ${writer.displayName}`);
|
|
39427
|
+
await writer.removeEntry();
|
|
39428
|
+
return "removed";
|
|
39429
|
+
}
|
|
39430
|
+
info(`Keeping existing ${writer.displayName} entry`);
|
|
39431
|
+
return null;
|
|
39432
|
+
}
|
|
39433
|
+
async function runNonInteractive2(opts, deps) {
|
|
39434
|
+
const envList = deps.env.TWAK_SETUP_HARNESSES;
|
|
39435
|
+
const fromEnv = envList ? envList.split(",").map((s2) => s2.trim()).filter(Boolean) : [];
|
|
39436
|
+
const names = opts.harness ? [opts.harness] : fromEnv;
|
|
39437
|
+
if (names.length === 0) {
|
|
39438
|
+
info(
|
|
39439
|
+
"No harnesses requested. Set TWAK_SETUP_HARNESSES=<comma-list> to wire harnesses non-interactively."
|
|
39440
|
+
);
|
|
39441
|
+
return;
|
|
39442
|
+
}
|
|
39443
|
+
const validNames = new Set(deps.harnesses.map((h4) => h4.name));
|
|
39444
|
+
const unknown2 = names.filter((n4) => !validNames.has(n4));
|
|
39445
|
+
if (unknown2.length > 0) {
|
|
39446
|
+
throw new CommandError(
|
|
39447
|
+
"VALIDATION_ERROR",
|
|
39448
|
+
`Unknown harness name(s): ${unknown2.join(", ")}. Valid: ${deps.harnesses.map((h4) => h4.name).join(", ")}.`
|
|
39449
|
+
);
|
|
39450
|
+
}
|
|
39451
|
+
const forceOverwrite = deps.env.TWAK_SETUP_FORCE_HARNESS_OVERWRITE === "1";
|
|
39452
|
+
for (const name2 of names) {
|
|
39453
|
+
const writer = findHarness(deps.harnesses, name2);
|
|
39454
|
+
let current;
|
|
39455
|
+
try {
|
|
39456
|
+
current = await writer.getCurrentEntry();
|
|
39457
|
+
} catch (err) {
|
|
39458
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
39459
|
+
throw new CommandError(
|
|
39460
|
+
"VALIDATION_ERROR",
|
|
39461
|
+
`Cannot wire ${writer.displayName}: config at ${writer.configPath()} is invalid (${msg}). Fix it manually and re-run.`
|
|
39462
|
+
);
|
|
39463
|
+
}
|
|
39464
|
+
const raw = await writer.getRawEntry();
|
|
39465
|
+
if (current === null && raw === null) {
|
|
39466
|
+
info(`Wiring ${writer.displayName} \u2192 ${writer.configPath()}`);
|
|
39467
|
+
await writer.writeEntry();
|
|
39468
|
+
continue;
|
|
39469
|
+
}
|
|
39470
|
+
if (current !== null && entriesEqual(current, TARGET_ENTRY) && !entryHasExtras(raw)) {
|
|
39471
|
+
info(`Skipped: ${writer.displayName} already wired`);
|
|
39472
|
+
continue;
|
|
39473
|
+
}
|
|
39474
|
+
if (forceOverwrite) {
|
|
39475
|
+
if (entryHasEnv(raw)) {
|
|
39476
|
+
warn(
|
|
39477
|
+
`${writer.displayName}: existing twak entry has an \`env\` block \u2014 dropping it because TWAK_SETUP_FORCE_HARNESS_OVERWRITE=1. If it held credentials, run \`twak setup --reconfigure-creds\` so they live in ~/.twak/credentials.json.`
|
|
39478
|
+
);
|
|
39479
|
+
} else {
|
|
39480
|
+
warn(
|
|
39481
|
+
`${writer.displayName}: overwriting existing twak entry because TWAK_SETUP_FORCE_HARNESS_OVERWRITE=1.`
|
|
39482
|
+
);
|
|
39483
|
+
}
|
|
39484
|
+
await writer.writeEntry();
|
|
39485
|
+
continue;
|
|
39486
|
+
}
|
|
39487
|
+
info(
|
|
39488
|
+
`Skipped: ${writer.displayName} has a different twak entry. Re-run interactively to choose update/keep/remove, or set TWAK_SETUP_FORCE_HARNESS_OVERWRITE=1 to overwrite non-interactively.`
|
|
39489
|
+
);
|
|
39490
|
+
}
|
|
39491
|
+
}
|
|
39492
|
+
function findHarness(harnesses, name2) {
|
|
39493
|
+
const writer = harnesses.find((h4) => h4.name === name2);
|
|
39494
|
+
if (!writer) {
|
|
39495
|
+
throw new CommandError(
|
|
39496
|
+
"VALIDATION_ERROR",
|
|
39497
|
+
`Unknown harness: ${name2}. Valid: ${harnesses.map((h4) => h4.name).join(", ")}.`
|
|
39498
|
+
);
|
|
39499
|
+
}
|
|
39500
|
+
return writer;
|
|
39501
|
+
}
|
|
39502
|
+
|
|
39503
|
+
// src/setup/phase-wallet.ts
|
|
39504
|
+
var import_node_crypto2 = require("crypto");
|
|
39505
|
+
var import_prompts3 = require("@inquirer/prompts");
|
|
39506
|
+
init_dist2();
|
|
39507
|
+
init_dist();
|
|
39508
|
+
var defaultPrompter3 = {
|
|
39509
|
+
selectWalletOption: () => (0, import_prompts3.select)({
|
|
39510
|
+
message: "Pick one:",
|
|
39511
|
+
choices: [
|
|
39512
|
+
{
|
|
39513
|
+
name: "1) Create a new agent wallet",
|
|
39514
|
+
value: "1",
|
|
39515
|
+
description: "Non-custodial HD wallet, encrypted on this machine. Best for automations."
|
|
39516
|
+
},
|
|
39517
|
+
{
|
|
39518
|
+
name: "2) Use WalletConnect with my existing wallet",
|
|
39519
|
+
value: "2",
|
|
39520
|
+
description: "Sign on your phone (e.g. Trust Wallet). Best for interactive use."
|
|
39521
|
+
},
|
|
39522
|
+
{
|
|
39523
|
+
name: "3) Skip for now",
|
|
39524
|
+
value: "3",
|
|
39525
|
+
description: "Read-only operations work without a wallet."
|
|
39526
|
+
}
|
|
39527
|
+
]
|
|
39528
|
+
})
|
|
39529
|
+
};
|
|
39530
|
+
function makeDefaultDeps3() {
|
|
39531
|
+
return {
|
|
39532
|
+
prompter: defaultPrompter3,
|
|
39533
|
+
storage: new WalletConfigStore(),
|
|
39534
|
+
walletCreator: {
|
|
39535
|
+
async create(password2) {
|
|
39536
|
+
await ensureTrustSDK();
|
|
39537
|
+
const provider = await AgentWalletProvider.create(password2);
|
|
39538
|
+
const primaryAddress = await provider.getAddress("ethereum") ?? "<unknown>";
|
|
39539
|
+
return { primaryAddress };
|
|
39540
|
+
}
|
|
39541
|
+
},
|
|
39542
|
+
keychain: {
|
|
39543
|
+
isAvailable: () => new KeychainManager().isAvailable(),
|
|
39544
|
+
async saveWalletPassword(password2) {
|
|
39545
|
+
await new KeychainManager().saveWalletPassword(password2);
|
|
39546
|
+
},
|
|
39547
|
+
async saveProbe(value) {
|
|
39548
|
+
await new KeychainManager().saveProbe(value);
|
|
39549
|
+
},
|
|
39550
|
+
async getProbe() {
|
|
39551
|
+
return new KeychainManager().getProbe();
|
|
39552
|
+
},
|
|
39553
|
+
async deleteProbe() {
|
|
39554
|
+
await new KeychainManager().deleteProbe();
|
|
39555
|
+
}
|
|
39556
|
+
},
|
|
39557
|
+
env: process.env,
|
|
39558
|
+
generatePassword: () => (0, import_node_crypto2.randomBytes)(32).toString("hex")
|
|
39559
|
+
};
|
|
39560
|
+
}
|
|
39561
|
+
async function runWalletPhase(opts, deps = makeDefaultDeps3()) {
|
|
39562
|
+
info("\nStep 3 of 3 \u2014 Wallet\n");
|
|
39563
|
+
if (await deps.storage.exists() && !opts.wallet) {
|
|
39564
|
+
success("Agent wallet already configured");
|
|
39565
|
+
return;
|
|
39566
|
+
}
|
|
39567
|
+
if (opts.nonInteractive) {
|
|
39568
|
+
await runNonInteractive3(deps);
|
|
39569
|
+
return;
|
|
39570
|
+
}
|
|
39571
|
+
info("To swap, transfer, or sign with twak, you need a wallet.\n");
|
|
39572
|
+
const choice = await deps.prompter.selectWalletOption();
|
|
39573
|
+
if (choice === "1") {
|
|
39574
|
+
await createAgentWallet(deps);
|
|
39575
|
+
} else if (choice === "2") {
|
|
39576
|
+
info("To use WalletConnect, prompt your harness to start `twak serve --walletconnect`.");
|
|
39577
|
+
info("WalletConnect only works in MCP mode.");
|
|
39578
|
+
} else {
|
|
39579
|
+
info("Skipped. Run `twak wallet create` or `twak serve --walletconnect` later.");
|
|
39580
|
+
}
|
|
39581
|
+
}
|
|
39582
|
+
async function createAgentWallet(deps) {
|
|
39583
|
+
if (await deps.storage.exists()) {
|
|
39584
|
+
throw new WalletError(
|
|
39585
|
+
"WALLET_EXISTS",
|
|
39586
|
+
"Wallet already exists. Back up ~/.twak/wallet.json, then delete it to create a new one."
|
|
39587
|
+
);
|
|
39588
|
+
}
|
|
39589
|
+
if (!deps.keychain.isAvailable()) {
|
|
39590
|
+
throw new CommandError(
|
|
39591
|
+
"STORAGE_ERROR",
|
|
39592
|
+
"OS keychain is unavailable in this environment. Run `twak wallet create --password <pw>` directly to set a password you control."
|
|
39593
|
+
);
|
|
39594
|
+
}
|
|
39595
|
+
await assertKeychainCanPersist(deps);
|
|
39596
|
+
info("Creating agent wallet...");
|
|
39597
|
+
const password2 = deps.generatePassword();
|
|
39598
|
+
const { primaryAddress } = await deps.walletCreator.create(password2);
|
|
39599
|
+
await deps.keychain.saveWalletPassword(password2);
|
|
39600
|
+
success("Wallet created.");
|
|
39601
|
+
info(` Primary ETH address: ${primaryAddress}`);
|
|
39602
|
+
success("Password saved to OS keychain.");
|
|
39603
|
+
}
|
|
39604
|
+
async function assertKeychainCanPersist(deps) {
|
|
39605
|
+
const probe = (0, import_node_crypto2.randomBytes)(16).toString("hex");
|
|
39606
|
+
let got = null;
|
|
39607
|
+
let probeErr = null;
|
|
39608
|
+
try {
|
|
39609
|
+
await deps.keychain.saveProbe(probe);
|
|
39610
|
+
got = await deps.keychain.getProbe();
|
|
39611
|
+
} catch (e2) {
|
|
39612
|
+
probeErr = e2;
|
|
39613
|
+
} finally {
|
|
39614
|
+
try {
|
|
39615
|
+
await deps.keychain.deleteProbe();
|
|
39616
|
+
} catch {
|
|
39617
|
+
}
|
|
39618
|
+
}
|
|
39619
|
+
if (probeErr || got !== probe) {
|
|
39620
|
+
const detail = probeErr ? `error: ${probeErr instanceof Error ? probeErr.message : String(probeErr)}` : got === null ? "no entry returned" : "value mismatch";
|
|
39621
|
+
throw new CommandError(
|
|
39622
|
+
"STORAGE_ERROR",
|
|
39623
|
+
`OS keychain cannot persist passwords here (${detail}). This usually means the keychain is session-only (headless / Docker / rebooted runners). Run \`twak wallet create --password <pw>\` directly to set a password you control.`
|
|
39624
|
+
);
|
|
39625
|
+
}
|
|
39626
|
+
}
|
|
39627
|
+
async function runNonInteractive3(deps) {
|
|
39628
|
+
const mode = deps.env.TWAK_SETUP_WALLET ?? "skip";
|
|
39629
|
+
if (mode === "create") {
|
|
39630
|
+
await createAgentWallet(deps);
|
|
39631
|
+
return;
|
|
39632
|
+
}
|
|
39633
|
+
if (mode === "skip") {
|
|
39634
|
+
info("Wallet creation skipped (set TWAK_SETUP_WALLET=create to opt in).");
|
|
39635
|
+
return;
|
|
39636
|
+
}
|
|
39637
|
+
throw new CommandError(
|
|
39638
|
+
"VALIDATION_ERROR",
|
|
39639
|
+
`Unknown TWAK_SETUP_WALLET value: ${mode}. Use 'create' or 'skip'.`
|
|
39640
|
+
);
|
|
39641
|
+
}
|
|
39642
|
+
|
|
39643
|
+
// src/commands/setup.ts
|
|
39644
|
+
var HARNESS_CHOICES = ALL_HARNESSES.map((h4) => h4.name);
|
|
39645
|
+
function parseSetupOpts(raw) {
|
|
39646
|
+
return {
|
|
39647
|
+
reconfigureCreds: !!raw.reconfigureCreds,
|
|
39648
|
+
harness: raw.harness ?? void 0,
|
|
39649
|
+
wallet: !!raw.wallet,
|
|
39650
|
+
nonInteractive: isNonInteractive()
|
|
39651
|
+
};
|
|
39652
|
+
}
|
|
39653
|
+
function isNonInteractive() {
|
|
39654
|
+
if (process.env.TWAK_NONINTERACTIVE === "1") return true;
|
|
39655
|
+
if (process.env.NO_PROMPT === "1") return true;
|
|
39656
|
+
return !process.stdin.isTTY && !process.stderr.isTTY;
|
|
39657
|
+
}
|
|
39658
|
+
function printSetupBanner() {
|
|
39659
|
+
process.stderr.write("\n" + import_chalk3.default.bold("\u26D3 Trust Wallet Agent Kit \u2014 Setup") + "\n\n");
|
|
39660
|
+
}
|
|
39661
|
+
async function runSetup(opts, phases = defaultPhases) {
|
|
39662
|
+
const noFlags = !opts.reconfigureCreds && !opts.harness && !opts.wallet;
|
|
39663
|
+
if (noFlags || opts.reconfigureCreds) await phases.credentials(opts);
|
|
39664
|
+
if (noFlags || opts.harness) await phases.harnesses(opts);
|
|
39665
|
+
if (noFlags || opts.wallet) await phases.wallet(opts);
|
|
39666
|
+
}
|
|
39667
|
+
var defaultPhases = {
|
|
39668
|
+
credentials: runCredentialsPhase,
|
|
39669
|
+
harnesses: runHarnessesPhase,
|
|
39670
|
+
wallet: runWalletPhase
|
|
39671
|
+
};
|
|
39672
|
+
function registerSetupCommand(program3) {
|
|
39673
|
+
program3.command("setup").description("Interactive onboarding: credentials, harness wiring, wallet").option("--reconfigure-creds", "Re-prompt for API credentials even if already configured").addOption(
|
|
39674
|
+
new Option("--harness <name>", "Run only the harness phase for one harness").choices(
|
|
39675
|
+
HARNESS_CHOICES
|
|
39676
|
+
)
|
|
39677
|
+
).option("--wallet", "Run only the wallet phase").action(async (raw) => {
|
|
39678
|
+
try {
|
|
39679
|
+
const opts = parseSetupOpts(raw);
|
|
39680
|
+
printSetupBanner();
|
|
39681
|
+
await runSetup(opts);
|
|
39682
|
+
success("Setup complete.");
|
|
39683
|
+
} catch (err) {
|
|
39684
|
+
handleCommandError(err, false, "Setup failed");
|
|
39685
|
+
}
|
|
39686
|
+
});
|
|
39687
|
+
}
|
|
39688
|
+
|
|
39689
|
+
// src/commands/auth.ts
|
|
39690
|
+
var import_chalk4 = __toESM(require_source());
|
|
38970
39691
|
init_dist2();
|
|
38971
39692
|
function registerAuthCommand(program3) {
|
|
38972
39693
|
const auth = program3.command("auth").description("Manage authentication");
|
|
@@ -38989,9 +39710,9 @@ function registerAuthCommand(program3) {
|
|
|
38989
39710
|
if (opts.json) {
|
|
38990
39711
|
output({ configured, source, accessId }, true);
|
|
38991
39712
|
} else {
|
|
38992
|
-
console.log(` ${
|
|
38993
|
-
console.log(` ${
|
|
38994
|
-
if (accessId) console.log(` ${
|
|
39713
|
+
console.log(` ${import_chalk4.default.dim("Status")} ${configured ? import_chalk4.default.green("configured") : import_chalk4.default.yellow("not configured")}`);
|
|
39714
|
+
console.log(` ${import_chalk4.default.dim("Source")} ${source}`);
|
|
39715
|
+
if (accessId) console.log(` ${import_chalk4.default.dim("Access ID")} ${accessId}...`);
|
|
38995
39716
|
if (!configured) info("\nRun `twak init` to set up credentials.");
|
|
38996
39717
|
}
|
|
38997
39718
|
});
|
|
@@ -38999,11 +39720,11 @@ function registerAuthCommand(program3) {
|
|
|
38999
39720
|
|
|
39000
39721
|
// src/commands/wallet.ts
|
|
39001
39722
|
init_dist2();
|
|
39002
|
-
var
|
|
39723
|
+
var import_chalk6 = __toESM(require_source());
|
|
39003
39724
|
init_dist();
|
|
39004
39725
|
|
|
39005
39726
|
// src/branding.ts
|
|
39006
|
-
var
|
|
39727
|
+
var import_chalk5 = __toESM(require_source());
|
|
39007
39728
|
var boxen = require_boxen();
|
|
39008
39729
|
var SHIELD = [
|
|
39009
39730
|
" @@=+ ",
|
|
@@ -39028,9 +39749,9 @@ var SHIELD = [
|
|
|
39028
39749
|
" @@ "
|
|
39029
39750
|
];
|
|
39030
39751
|
function printBanner(version4) {
|
|
39031
|
-
const logo = SHIELD.map((l4) =>
|
|
39032
|
-
const title =
|
|
39033
|
-
const ver =
|
|
39752
|
+
const logo = SHIELD.map((l4) => import_chalk5.default.green(l4)).join("\n");
|
|
39753
|
+
const title = import_chalk5.default.green.bold(" Trust Wallet Agent Kit");
|
|
39754
|
+
const ver = import_chalk5.default.dim(` v${version4}`);
|
|
39034
39755
|
console.log(
|
|
39035
39756
|
boxen(`${logo}
|
|
39036
39757
|
|
|
@@ -39125,15 +39846,15 @@ function registerWalletCommand(program3) {
|
|
|
39125
39846
|
throw new WalletError("CHAIN_UNSUPPORTED", `Unknown chain: ${opts.chain}`);
|
|
39126
39847
|
}
|
|
39127
39848
|
await ensureTrustSDK();
|
|
39128
|
-
const
|
|
39129
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
39849
|
+
const password2 = await resolvePassword(opts);
|
|
39850
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
39130
39851
|
const address = await provider.getAddress(opts.chain);
|
|
39131
39852
|
if (opts.json) {
|
|
39132
39853
|
output({ chain: opts.chain, address }, true);
|
|
39133
39854
|
} else {
|
|
39134
39855
|
const qr3 = getQRString(address);
|
|
39135
|
-
const content = `${
|
|
39136
|
-
${
|
|
39856
|
+
const content = `${import_chalk6.default.dim("Chain")} ${import_chalk6.default.bold(opts.chain)}
|
|
39857
|
+
${import_chalk6.default.dim("Address")} ${import_chalk6.default.green(address)}
|
|
39137
39858
|
|
|
39138
39859
|
${qr3}`;
|
|
39139
39860
|
console.log(box(content));
|
|
@@ -39149,8 +39870,8 @@ ${qr3}`;
|
|
|
39149
39870
|
).option("--json", "JSON output").action(async (opts) => {
|
|
39150
39871
|
try {
|
|
39151
39872
|
await ensureTrustSDK();
|
|
39152
|
-
const
|
|
39153
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
39873
|
+
const password2 = await resolvePassword(opts);
|
|
39874
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
39154
39875
|
const addresses = await provider.getAddresses();
|
|
39155
39876
|
if (opts.json) {
|
|
39156
39877
|
output({ addresses }, true);
|
|
@@ -39164,7 +39885,7 @@ ${qr3}`;
|
|
|
39164
39885
|
for (const [address, chains] of grouped) {
|
|
39165
39886
|
const qr3 = getQRString(address);
|
|
39166
39887
|
const maxWidth = Math.max(address.length + 9, 50);
|
|
39167
|
-
const chainLabel = `${
|
|
39888
|
+
const chainLabel = `${import_chalk6.default.dim("Chains")} `;
|
|
39168
39889
|
const chainLabelLen = 9;
|
|
39169
39890
|
const chainLines = [];
|
|
39170
39891
|
let line = "";
|
|
@@ -39178,9 +39899,9 @@ ${qr3}`;
|
|
|
39178
39899
|
}
|
|
39179
39900
|
}
|
|
39180
39901
|
if (line) chainLines.push(line);
|
|
39181
|
-
const chainsStr = chainLines.map((l4, i2) => (i2 === 0 ? chainLabel : " ".repeat(chainLabelLen)) +
|
|
39902
|
+
const chainsStr = chainLines.map((l4, i2) => (i2 === 0 ? chainLabel : " ".repeat(chainLabelLen)) + import_chalk6.default.bold(l4)).join("\n");
|
|
39182
39903
|
const content = `${chainsStr}
|
|
39183
|
-
${
|
|
39904
|
+
${import_chalk6.default.dim("Address")} ${import_chalk6.default.green(address)}
|
|
39184
39905
|
|
|
39185
39906
|
${qr3}`;
|
|
39186
39907
|
console.log(box(content));
|
|
@@ -39203,8 +39924,8 @@ ${qr3}`;
|
|
|
39203
39924
|
throw new WalletError("VALIDATION_ERROR", "Provide --chain <key> or --all");
|
|
39204
39925
|
}
|
|
39205
39926
|
await ensureTrustSDK();
|
|
39206
|
-
const
|
|
39207
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
39927
|
+
const password2 = await resolvePassword(opts);
|
|
39928
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
39208
39929
|
const httpClient = await getClient();
|
|
39209
39930
|
if (!opts.all) {
|
|
39210
39931
|
const chain2 = getChainById(opts.chain);
|
|
@@ -39305,16 +40026,16 @@ ${qr3}`;
|
|
|
39305
40026
|
const visible = opts.all ? orderedResults.filter((r3) => r3.total !== "0" || r3.tokens.length > 0) : orderedResults;
|
|
39306
40027
|
const renderBlock = (r3, withSeparator) => {
|
|
39307
40028
|
if (withSeparator) console.log("");
|
|
39308
|
-
console.log(
|
|
39309
|
-
console.log(` ${
|
|
39310
|
-
console.log(` ${
|
|
39311
|
-
if (r3.staked) console.log(` ${
|
|
40029
|
+
console.log(import_chalk6.default.bold.underline(`${r3.chain} (${r3.symbol})`));
|
|
40030
|
+
console.log(` ${import_chalk6.default.dim("Address")} ${r3.address}`);
|
|
40031
|
+
console.log(` ${import_chalk6.default.dim("Available")} ${r3.available}`);
|
|
40032
|
+
if (r3.staked) console.log(` ${import_chalk6.default.dim("Staked")} ${r3.staked}`);
|
|
39312
40033
|
const usdSuffix = r3.totalUsd !== null ? ` (\u2248 $${r3.totalUsd.toFixed(2)})` : "";
|
|
39313
|
-
console.log(` ${
|
|
40034
|
+
console.log(` ${import_chalk6.default.dim("Total")} ${r3.total}${usdSuffix}`);
|
|
39314
40035
|
if (r3.tokens.length > 0) {
|
|
39315
|
-
console.log(` ${
|
|
40036
|
+
console.log(` ${import_chalk6.default.dim("Tokens:")}`);
|
|
39316
40037
|
for (const t of r3.tokens) {
|
|
39317
|
-
console.log(` ${
|
|
40038
|
+
console.log(` ${import_chalk6.default.bold(t.symbol.padEnd(10))} ${t.balance}`);
|
|
39318
40039
|
}
|
|
39319
40040
|
}
|
|
39320
40041
|
};
|
|
@@ -39463,15 +40184,15 @@ ${qr3}`;
|
|
|
39463
40184
|
output(result, true);
|
|
39464
40185
|
} else {
|
|
39465
40186
|
console.log(
|
|
39466
|
-
` ${
|
|
40187
|
+
` ${import_chalk6.default.dim("Wallet")} ${exists ? import_chalk6.default.green("configured") : import_chalk6.default.yellow("not configured")}`
|
|
39467
40188
|
);
|
|
39468
|
-
if (createdAt) console.log(` ${
|
|
40189
|
+
if (createdAt) console.log(` ${import_chalk6.default.dim("Created")} ${createdAt}`);
|
|
39469
40190
|
console.log(
|
|
39470
|
-
` ${
|
|
40191
|
+
` ${import_chalk6.default.dim("Keychain")} ${keychainHasPassword ? import_chalk6.default.green("password stored") : import_chalk6.default.yellow("no password")}`
|
|
39471
40192
|
);
|
|
39472
|
-
console.log(` ${
|
|
40193
|
+
console.log(` ${import_chalk6.default.dim("Chains")} ${totalChains} supported`);
|
|
39473
40194
|
if (addressCount !== void 0)
|
|
39474
|
-
console.log(` ${
|
|
40195
|
+
console.log(` ${import_chalk6.default.dim("Addresses")} ${addressCount}`);
|
|
39475
40196
|
if (!exists) info("\nRun `twak wallet create --password <pw>` to create a wallet.");
|
|
39476
40197
|
}
|
|
39477
40198
|
} catch (err) {
|
|
@@ -39485,8 +40206,8 @@ ${qr3}`;
|
|
|
39485
40206
|
).option("--json", "JSON output").action(async (opts) => {
|
|
39486
40207
|
try {
|
|
39487
40208
|
await ensureTrustSDK();
|
|
39488
|
-
const
|
|
39489
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
40209
|
+
const password2 = await resolvePassword(opts);
|
|
40210
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
39490
40211
|
const httpClient = await getClient();
|
|
39491
40212
|
const allAddresses = await provider.getAddresses();
|
|
39492
40213
|
const chainsArg = opts.chains ?? Object.keys(CHAINS).join(",");
|
|
@@ -39600,8 +40321,8 @@ ${qr3}`;
|
|
|
39600
40321
|
throw new WalletError("CHAIN_UNSUPPORTED", `Unknown chain: ${opts.chain}`);
|
|
39601
40322
|
}
|
|
39602
40323
|
await ensureTrustSDK();
|
|
39603
|
-
const
|
|
39604
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
40324
|
+
const password2 = await resolvePassword(opts);
|
|
40325
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
39605
40326
|
const address = await provider.getAddress(opts.chain);
|
|
39606
40327
|
const signature = await provider.signMessage(opts.chain, opts.message);
|
|
39607
40328
|
output({ chain: opts.chain, address, message: opts.message, signature }, opts.json);
|
|
@@ -39613,8 +40334,8 @@ ${qr3}`;
|
|
|
39613
40334
|
wallet.command("register").description("Register wallet addresses with Trust Wallet backend (enables token holdings)").option("--password <password>", "Wallet password").option("--json", "JSON output").action(async (opts) => {
|
|
39614
40335
|
try {
|
|
39615
40336
|
const creds = await ensureTrustSDK();
|
|
39616
|
-
const
|
|
39617
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
40337
|
+
const password2 = await resolvePassword(opts);
|
|
40338
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
39618
40339
|
await registerWalletWithBackend(creds, provider);
|
|
39619
40340
|
if (!opts.json) success("Wallet registered with backend");
|
|
39620
40341
|
const addresses = await provider.getAddresses();
|
|
@@ -40216,8 +40937,8 @@ function registerTransferCommand(program3) {
|
|
|
40216
40937
|
).option("--json", "JSON output").action(async (opts) => {
|
|
40217
40938
|
try {
|
|
40218
40939
|
await ensureTrustSDK();
|
|
40219
|
-
const
|
|
40220
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
40940
|
+
const password2 = await resolvePassword2(opts);
|
|
40941
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
40221
40942
|
let coinId;
|
|
40222
40943
|
try {
|
|
40223
40944
|
({ coinId } = parseTokenId(opts.token));
|
|
@@ -40443,8 +41164,8 @@ function registerSwapCommand(program3) {
|
|
|
40443
41164
|
let amberDomains = /* @__PURE__ */ new Map();
|
|
40444
41165
|
if (needsWallet) {
|
|
40445
41166
|
await ensureTrustSDK();
|
|
40446
|
-
const
|
|
40447
|
-
provider = await AgentWalletProvider.fromStorage(
|
|
41167
|
+
const password2 = await resolvePassword(opts);
|
|
41168
|
+
provider = await AgentWalletProvider.fromStorage(password2);
|
|
40448
41169
|
walletAddress = await provider.getAddress(fromChain);
|
|
40449
41170
|
if (toChain !== fromChain) {
|
|
40450
41171
|
destinationAddress = await provider.getAddress(toChain);
|
|
@@ -40654,8 +41375,8 @@ function registerErc20Command(program3) {
|
|
|
40654
41375
|
).option("--json", "JSON output").action(async (opts) => {
|
|
40655
41376
|
try {
|
|
40656
41377
|
await ensureTrustSDK();
|
|
40657
|
-
const
|
|
40658
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
41378
|
+
const password2 = await resolvePassword(opts);
|
|
41379
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
40659
41380
|
let coinId;
|
|
40660
41381
|
let contractAddress;
|
|
40661
41382
|
try {
|
|
@@ -40721,8 +41442,8 @@ function registerErc20Command(program3) {
|
|
|
40721
41442
|
).option("--json", "JSON output").action(async (opts) => {
|
|
40722
41443
|
try {
|
|
40723
41444
|
await ensureTrustSDK();
|
|
40724
|
-
const
|
|
40725
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
41445
|
+
const password2 = await resolvePassword(opts);
|
|
41446
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
40726
41447
|
let coinId;
|
|
40727
41448
|
let contractAddress;
|
|
40728
41449
|
try {
|
|
@@ -41123,7 +41844,7 @@ var TransactionService = class {
|
|
|
41123
41844
|
|
|
41124
41845
|
// src/commands/query.ts
|
|
41125
41846
|
init_dist4();
|
|
41126
|
-
var
|
|
41847
|
+
var import_chalk7 = __toESM(require_source());
|
|
41127
41848
|
function handleError(err, json) {
|
|
41128
41849
|
handleCommandError(err, json ?? false, "Query failed");
|
|
41129
41850
|
}
|
|
@@ -41198,7 +41919,7 @@ function registerQueryCommand(program3) {
|
|
|
41198
41919
|
for (const r3 of results) {
|
|
41199
41920
|
const priceStr = r3.priceUsd !== null ? `$${r3.priceUsd.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 6 })}` : "N/A";
|
|
41200
41921
|
console.log(
|
|
41201
|
-
`${
|
|
41922
|
+
`${import_chalk7.default.bold(r3.token.padEnd(10))} ${priceStr.padStart(14)} ${import_chalk7.default.dim(r3.chain)}`
|
|
41202
41923
|
);
|
|
41203
41924
|
}
|
|
41204
41925
|
}
|
|
@@ -41249,7 +41970,7 @@ function registerQueryCommand(program3) {
|
|
|
41249
41970
|
output({ token: token.toUpperCase(), chain: chain2, priceUsd: price }, true);
|
|
41250
41971
|
} else {
|
|
41251
41972
|
const priceStr = `$${price.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 6 })}`;
|
|
41252
|
-
console.log(`${
|
|
41973
|
+
console.log(`${import_chalk7.default.bold(token.toUpperCase())} ${priceStr} ${import_chalk7.default.dim(chain2)}`);
|
|
41253
41974
|
}
|
|
41254
41975
|
} catch (err) {
|
|
41255
41976
|
handleError(err, opts.json);
|
|
@@ -41297,8 +42018,8 @@ function registerQueryCommand(program3) {
|
|
|
41297
42018
|
}
|
|
41298
42019
|
if (!opts.chain) {
|
|
41299
42020
|
await ensureTrustSDK();
|
|
41300
|
-
const
|
|
41301
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
42021
|
+
const password2 = await resolvePassword(opts);
|
|
42022
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
41302
42023
|
const allAddresses = await provider.getAddresses();
|
|
41303
42024
|
const addresses = allAddresses.map((wa2) => ({
|
|
41304
42025
|
chain: wa2.chainId,
|
|
@@ -41322,8 +42043,8 @@ function registerQueryCommand(program3) {
|
|
|
41322
42043
|
let address = opts.address;
|
|
41323
42044
|
if (!address) {
|
|
41324
42045
|
await ensureTrustSDK();
|
|
41325
|
-
const
|
|
41326
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
42046
|
+
const password2 = await resolvePassword(opts);
|
|
42047
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
41327
42048
|
address = await provider.getAddress(opts.chain);
|
|
41328
42049
|
}
|
|
41329
42050
|
const result = await service.getHistory({
|
|
@@ -41384,8 +42105,8 @@ function registerQueryCommand(program3) {
|
|
|
41384
42105
|
if (!address) {
|
|
41385
42106
|
try {
|
|
41386
42107
|
await ensureTrustSDK();
|
|
41387
|
-
const
|
|
41388
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
42108
|
+
const password2 = await resolvePassword(opts);
|
|
42109
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
41389
42110
|
address = await provider.getAddress(opts.chain);
|
|
41390
42111
|
} catch {
|
|
41391
42112
|
}
|
|
@@ -41438,7 +42159,7 @@ function registerQueryCommand(program3) {
|
|
|
41438
42159
|
const symW = Math.max(...rows.map((r3) => r3.symbol.length), 6);
|
|
41439
42160
|
const nsW = Math.max(...rows.map((r3) => r3.namespace.length), 9);
|
|
41440
42161
|
console.log(
|
|
41441
|
-
|
|
42162
|
+
import_chalk7.default.bold(
|
|
41442
42163
|
`${"KEY".padEnd(keyW)} ${"NAME".padEnd(nameW)} ${"SYMBOL".padEnd(symW)} NAMESPACE`
|
|
41443
42164
|
)
|
|
41444
42165
|
);
|
|
@@ -42362,41 +43083,41 @@ var ZodType = class {
|
|
|
42362
43083
|
get description() {
|
|
42363
43084
|
return this._def.description;
|
|
42364
43085
|
}
|
|
42365
|
-
_getType(
|
|
42366
|
-
return getParsedType(
|
|
43086
|
+
_getType(input2) {
|
|
43087
|
+
return getParsedType(input2.data);
|
|
42367
43088
|
}
|
|
42368
|
-
_getOrReturnCtx(
|
|
43089
|
+
_getOrReturnCtx(input2, ctx) {
|
|
42369
43090
|
return ctx || {
|
|
42370
|
-
common:
|
|
42371
|
-
data:
|
|
42372
|
-
parsedType: getParsedType(
|
|
43091
|
+
common: input2.parent.common,
|
|
43092
|
+
data: input2.data,
|
|
43093
|
+
parsedType: getParsedType(input2.data),
|
|
42373
43094
|
schemaErrorMap: this._def.errorMap,
|
|
42374
|
-
path:
|
|
42375
|
-
parent:
|
|
43095
|
+
path: input2.path,
|
|
43096
|
+
parent: input2.parent
|
|
42376
43097
|
};
|
|
42377
43098
|
}
|
|
42378
|
-
_processInputParams(
|
|
43099
|
+
_processInputParams(input2) {
|
|
42379
43100
|
return {
|
|
42380
43101
|
status: new ParseStatus(),
|
|
42381
43102
|
ctx: {
|
|
42382
|
-
common:
|
|
42383
|
-
data:
|
|
42384
|
-
parsedType: getParsedType(
|
|
43103
|
+
common: input2.parent.common,
|
|
43104
|
+
data: input2.data,
|
|
43105
|
+
parsedType: getParsedType(input2.data),
|
|
42385
43106
|
schemaErrorMap: this._def.errorMap,
|
|
42386
|
-
path:
|
|
42387
|
-
parent:
|
|
43107
|
+
path: input2.path,
|
|
43108
|
+
parent: input2.parent
|
|
42388
43109
|
}
|
|
42389
43110
|
};
|
|
42390
43111
|
}
|
|
42391
|
-
_parseSync(
|
|
42392
|
-
const result = this._parse(
|
|
43112
|
+
_parseSync(input2) {
|
|
43113
|
+
const result = this._parse(input2);
|
|
42393
43114
|
if (isAsync(result)) {
|
|
42394
43115
|
throw new Error("Synchronous parse encountered promise.");
|
|
42395
43116
|
}
|
|
42396
43117
|
return result;
|
|
42397
43118
|
}
|
|
42398
|
-
_parseAsync(
|
|
42399
|
-
const result = this._parse(
|
|
43119
|
+
_parseAsync(input2) {
|
|
43120
|
+
const result = this._parse(input2);
|
|
42400
43121
|
return Promise.resolve(result);
|
|
42401
43122
|
}
|
|
42402
43123
|
parse(data, params) {
|
|
@@ -42722,13 +43443,13 @@ function isValidCidr(ip, version4) {
|
|
|
42722
43443
|
return false;
|
|
42723
43444
|
}
|
|
42724
43445
|
var ZodString = class _ZodString2 extends ZodType {
|
|
42725
|
-
_parse(
|
|
43446
|
+
_parse(input2) {
|
|
42726
43447
|
if (this._def.coerce) {
|
|
42727
|
-
|
|
43448
|
+
input2.data = String(input2.data);
|
|
42728
43449
|
}
|
|
42729
|
-
const parsedType2 = this._getType(
|
|
43450
|
+
const parsedType2 = this._getType(input2);
|
|
42730
43451
|
if (parsedType2 !== ZodParsedType.string) {
|
|
42731
|
-
const ctx2 = this._getOrReturnCtx(
|
|
43452
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
42732
43453
|
addIssueToContext(ctx2, {
|
|
42733
43454
|
code: ZodIssueCode.invalid_type,
|
|
42734
43455
|
expected: ZodParsedType.string,
|
|
@@ -42740,8 +43461,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42740
43461
|
let ctx = void 0;
|
|
42741
43462
|
for (const check2 of this._def.checks) {
|
|
42742
43463
|
if (check2.kind === "min") {
|
|
42743
|
-
if (
|
|
42744
|
-
ctx = this._getOrReturnCtx(
|
|
43464
|
+
if (input2.data.length < check2.value) {
|
|
43465
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42745
43466
|
addIssueToContext(ctx, {
|
|
42746
43467
|
code: ZodIssueCode.too_small,
|
|
42747
43468
|
minimum: check2.value,
|
|
@@ -42753,8 +43474,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42753
43474
|
status.dirty();
|
|
42754
43475
|
}
|
|
42755
43476
|
} else if (check2.kind === "max") {
|
|
42756
|
-
if (
|
|
42757
|
-
ctx = this._getOrReturnCtx(
|
|
43477
|
+
if (input2.data.length > check2.value) {
|
|
43478
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42758
43479
|
addIssueToContext(ctx, {
|
|
42759
43480
|
code: ZodIssueCode.too_big,
|
|
42760
43481
|
maximum: check2.value,
|
|
@@ -42766,10 +43487,10 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42766
43487
|
status.dirty();
|
|
42767
43488
|
}
|
|
42768
43489
|
} else if (check2.kind === "length") {
|
|
42769
|
-
const tooBig =
|
|
42770
|
-
const tooSmall =
|
|
43490
|
+
const tooBig = input2.data.length > check2.value;
|
|
43491
|
+
const tooSmall = input2.data.length < check2.value;
|
|
42771
43492
|
if (tooBig || tooSmall) {
|
|
42772
|
-
ctx = this._getOrReturnCtx(
|
|
43493
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42773
43494
|
if (tooBig) {
|
|
42774
43495
|
addIssueToContext(ctx, {
|
|
42775
43496
|
code: ZodIssueCode.too_big,
|
|
@@ -42792,8 +43513,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42792
43513
|
status.dirty();
|
|
42793
43514
|
}
|
|
42794
43515
|
} else if (check2.kind === "email") {
|
|
42795
|
-
if (!emailRegex.test(
|
|
42796
|
-
ctx = this._getOrReturnCtx(
|
|
43516
|
+
if (!emailRegex.test(input2.data)) {
|
|
43517
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42797
43518
|
addIssueToContext(ctx, {
|
|
42798
43519
|
validation: "email",
|
|
42799
43520
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42805,8 +43526,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42805
43526
|
if (!emojiRegex) {
|
|
42806
43527
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
42807
43528
|
}
|
|
42808
|
-
if (!emojiRegex.test(
|
|
42809
|
-
ctx = this._getOrReturnCtx(
|
|
43529
|
+
if (!emojiRegex.test(input2.data)) {
|
|
43530
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42810
43531
|
addIssueToContext(ctx, {
|
|
42811
43532
|
validation: "emoji",
|
|
42812
43533
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42815,8 +43536,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42815
43536
|
status.dirty();
|
|
42816
43537
|
}
|
|
42817
43538
|
} else if (check2.kind === "uuid") {
|
|
42818
|
-
if (!uuidRegex.test(
|
|
42819
|
-
ctx = this._getOrReturnCtx(
|
|
43539
|
+
if (!uuidRegex.test(input2.data)) {
|
|
43540
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42820
43541
|
addIssueToContext(ctx, {
|
|
42821
43542
|
validation: "uuid",
|
|
42822
43543
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42825,8 +43546,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42825
43546
|
status.dirty();
|
|
42826
43547
|
}
|
|
42827
43548
|
} else if (check2.kind === "nanoid") {
|
|
42828
|
-
if (!nanoidRegex.test(
|
|
42829
|
-
ctx = this._getOrReturnCtx(
|
|
43549
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
43550
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42830
43551
|
addIssueToContext(ctx, {
|
|
42831
43552
|
validation: "nanoid",
|
|
42832
43553
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42835,8 +43556,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42835
43556
|
status.dirty();
|
|
42836
43557
|
}
|
|
42837
43558
|
} else if (check2.kind === "cuid") {
|
|
42838
|
-
if (!cuidRegex.test(
|
|
42839
|
-
ctx = this._getOrReturnCtx(
|
|
43559
|
+
if (!cuidRegex.test(input2.data)) {
|
|
43560
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42840
43561
|
addIssueToContext(ctx, {
|
|
42841
43562
|
validation: "cuid",
|
|
42842
43563
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42845,8 +43566,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42845
43566
|
status.dirty();
|
|
42846
43567
|
}
|
|
42847
43568
|
} else if (check2.kind === "cuid2") {
|
|
42848
|
-
if (!cuid2Regex.test(
|
|
42849
|
-
ctx = this._getOrReturnCtx(
|
|
43569
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
43570
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42850
43571
|
addIssueToContext(ctx, {
|
|
42851
43572
|
validation: "cuid2",
|
|
42852
43573
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42855,8 +43576,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42855
43576
|
status.dirty();
|
|
42856
43577
|
}
|
|
42857
43578
|
} else if (check2.kind === "ulid") {
|
|
42858
|
-
if (!ulidRegex.test(
|
|
42859
|
-
ctx = this._getOrReturnCtx(
|
|
43579
|
+
if (!ulidRegex.test(input2.data)) {
|
|
43580
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42860
43581
|
addIssueToContext(ctx, {
|
|
42861
43582
|
validation: "ulid",
|
|
42862
43583
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42866,9 +43587,9 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42866
43587
|
}
|
|
42867
43588
|
} else if (check2.kind === "url") {
|
|
42868
43589
|
try {
|
|
42869
|
-
new URL(
|
|
43590
|
+
new URL(input2.data);
|
|
42870
43591
|
} catch {
|
|
42871
|
-
ctx = this._getOrReturnCtx(
|
|
43592
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42872
43593
|
addIssueToContext(ctx, {
|
|
42873
43594
|
validation: "url",
|
|
42874
43595
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42878,9 +43599,9 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42878
43599
|
}
|
|
42879
43600
|
} else if (check2.kind === "regex") {
|
|
42880
43601
|
check2.regex.lastIndex = 0;
|
|
42881
|
-
const testResult = check2.regex.test(
|
|
43602
|
+
const testResult = check2.regex.test(input2.data);
|
|
42882
43603
|
if (!testResult) {
|
|
42883
|
-
ctx = this._getOrReturnCtx(
|
|
43604
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42884
43605
|
addIssueToContext(ctx, {
|
|
42885
43606
|
validation: "regex",
|
|
42886
43607
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42889,10 +43610,10 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42889
43610
|
status.dirty();
|
|
42890
43611
|
}
|
|
42891
43612
|
} else if (check2.kind === "trim") {
|
|
42892
|
-
|
|
43613
|
+
input2.data = input2.data.trim();
|
|
42893
43614
|
} else if (check2.kind === "includes") {
|
|
42894
|
-
if (!
|
|
42895
|
-
ctx = this._getOrReturnCtx(
|
|
43615
|
+
if (!input2.data.includes(check2.value, check2.position)) {
|
|
43616
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42896
43617
|
addIssueToContext(ctx, {
|
|
42897
43618
|
code: ZodIssueCode.invalid_string,
|
|
42898
43619
|
validation: { includes: check2.value, position: check2.position },
|
|
@@ -42901,12 +43622,12 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42901
43622
|
status.dirty();
|
|
42902
43623
|
}
|
|
42903
43624
|
} else if (check2.kind === "toLowerCase") {
|
|
42904
|
-
|
|
43625
|
+
input2.data = input2.data.toLowerCase();
|
|
42905
43626
|
} else if (check2.kind === "toUpperCase") {
|
|
42906
|
-
|
|
43627
|
+
input2.data = input2.data.toUpperCase();
|
|
42907
43628
|
} else if (check2.kind === "startsWith") {
|
|
42908
|
-
if (!
|
|
42909
|
-
ctx = this._getOrReturnCtx(
|
|
43629
|
+
if (!input2.data.startsWith(check2.value)) {
|
|
43630
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42910
43631
|
addIssueToContext(ctx, {
|
|
42911
43632
|
code: ZodIssueCode.invalid_string,
|
|
42912
43633
|
validation: { startsWith: check2.value },
|
|
@@ -42915,8 +43636,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42915
43636
|
status.dirty();
|
|
42916
43637
|
}
|
|
42917
43638
|
} else if (check2.kind === "endsWith") {
|
|
42918
|
-
if (!
|
|
42919
|
-
ctx = this._getOrReturnCtx(
|
|
43639
|
+
if (!input2.data.endsWith(check2.value)) {
|
|
43640
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42920
43641
|
addIssueToContext(ctx, {
|
|
42921
43642
|
code: ZodIssueCode.invalid_string,
|
|
42922
43643
|
validation: { endsWith: check2.value },
|
|
@@ -42926,8 +43647,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42926
43647
|
}
|
|
42927
43648
|
} else if (check2.kind === "datetime") {
|
|
42928
43649
|
const regex = datetimeRegex(check2);
|
|
42929
|
-
if (!regex.test(
|
|
42930
|
-
ctx = this._getOrReturnCtx(
|
|
43650
|
+
if (!regex.test(input2.data)) {
|
|
43651
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42931
43652
|
addIssueToContext(ctx, {
|
|
42932
43653
|
code: ZodIssueCode.invalid_string,
|
|
42933
43654
|
validation: "datetime",
|
|
@@ -42937,8 +43658,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42937
43658
|
}
|
|
42938
43659
|
} else if (check2.kind === "date") {
|
|
42939
43660
|
const regex = dateRegex;
|
|
42940
|
-
if (!regex.test(
|
|
42941
|
-
ctx = this._getOrReturnCtx(
|
|
43661
|
+
if (!regex.test(input2.data)) {
|
|
43662
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42942
43663
|
addIssueToContext(ctx, {
|
|
42943
43664
|
code: ZodIssueCode.invalid_string,
|
|
42944
43665
|
validation: "date",
|
|
@@ -42948,8 +43669,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42948
43669
|
}
|
|
42949
43670
|
} else if (check2.kind === "time") {
|
|
42950
43671
|
const regex = timeRegex(check2);
|
|
42951
|
-
if (!regex.test(
|
|
42952
|
-
ctx = this._getOrReturnCtx(
|
|
43672
|
+
if (!regex.test(input2.data)) {
|
|
43673
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42953
43674
|
addIssueToContext(ctx, {
|
|
42954
43675
|
code: ZodIssueCode.invalid_string,
|
|
42955
43676
|
validation: "time",
|
|
@@ -42958,8 +43679,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42958
43679
|
status.dirty();
|
|
42959
43680
|
}
|
|
42960
43681
|
} else if (check2.kind === "duration") {
|
|
42961
|
-
if (!durationRegex.test(
|
|
42962
|
-
ctx = this._getOrReturnCtx(
|
|
43682
|
+
if (!durationRegex.test(input2.data)) {
|
|
43683
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42963
43684
|
addIssueToContext(ctx, {
|
|
42964
43685
|
validation: "duration",
|
|
42965
43686
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42968,8 +43689,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42968
43689
|
status.dirty();
|
|
42969
43690
|
}
|
|
42970
43691
|
} else if (check2.kind === "ip") {
|
|
42971
|
-
if (!isValidIP(
|
|
42972
|
-
ctx = this._getOrReturnCtx(
|
|
43692
|
+
if (!isValidIP(input2.data, check2.version)) {
|
|
43693
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42973
43694
|
addIssueToContext(ctx, {
|
|
42974
43695
|
validation: "ip",
|
|
42975
43696
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42978,8 +43699,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42978
43699
|
status.dirty();
|
|
42979
43700
|
}
|
|
42980
43701
|
} else if (check2.kind === "jwt") {
|
|
42981
|
-
if (!isValidJWT(
|
|
42982
|
-
ctx = this._getOrReturnCtx(
|
|
43702
|
+
if (!isValidJWT(input2.data, check2.alg)) {
|
|
43703
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42983
43704
|
addIssueToContext(ctx, {
|
|
42984
43705
|
validation: "jwt",
|
|
42985
43706
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42988,8 +43709,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42988
43709
|
status.dirty();
|
|
42989
43710
|
}
|
|
42990
43711
|
} else if (check2.kind === "cidr") {
|
|
42991
|
-
if (!isValidCidr(
|
|
42992
|
-
ctx = this._getOrReturnCtx(
|
|
43712
|
+
if (!isValidCidr(input2.data, check2.version)) {
|
|
43713
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
42993
43714
|
addIssueToContext(ctx, {
|
|
42994
43715
|
validation: "cidr",
|
|
42995
43716
|
code: ZodIssueCode.invalid_string,
|
|
@@ -42998,8 +43719,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
42998
43719
|
status.dirty();
|
|
42999
43720
|
}
|
|
43000
43721
|
} else if (check2.kind === "base64") {
|
|
43001
|
-
if (!base64Regex.test(
|
|
43002
|
-
ctx = this._getOrReturnCtx(
|
|
43722
|
+
if (!base64Regex.test(input2.data)) {
|
|
43723
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43003
43724
|
addIssueToContext(ctx, {
|
|
43004
43725
|
validation: "base64",
|
|
43005
43726
|
code: ZodIssueCode.invalid_string,
|
|
@@ -43008,8 +43729,8 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
43008
43729
|
status.dirty();
|
|
43009
43730
|
}
|
|
43010
43731
|
} else if (check2.kind === "base64url") {
|
|
43011
|
-
if (!base64urlRegex.test(
|
|
43012
|
-
ctx = this._getOrReturnCtx(
|
|
43732
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
43733
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43013
43734
|
addIssueToContext(ctx, {
|
|
43014
43735
|
validation: "base64url",
|
|
43015
43736
|
code: ZodIssueCode.invalid_string,
|
|
@@ -43021,7 +43742,7 @@ var ZodString = class _ZodString2 extends ZodType {
|
|
|
43021
43742
|
util.assertNever(check2);
|
|
43022
43743
|
}
|
|
43023
43744
|
}
|
|
43024
|
-
return { status: status.value, value:
|
|
43745
|
+
return { status: status.value, value: input2.data };
|
|
43025
43746
|
}
|
|
43026
43747
|
_regex(regex, validation, message) {
|
|
43027
43748
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -43282,13 +44003,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
43282
44003
|
this.max = this.lte;
|
|
43283
44004
|
this.step = this.multipleOf;
|
|
43284
44005
|
}
|
|
43285
|
-
_parse(
|
|
44006
|
+
_parse(input2) {
|
|
43286
44007
|
if (this._def.coerce) {
|
|
43287
|
-
|
|
44008
|
+
input2.data = Number(input2.data);
|
|
43288
44009
|
}
|
|
43289
|
-
const parsedType2 = this._getType(
|
|
44010
|
+
const parsedType2 = this._getType(input2);
|
|
43290
44011
|
if (parsedType2 !== ZodParsedType.number) {
|
|
43291
|
-
const ctx2 = this._getOrReturnCtx(
|
|
44012
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
43292
44013
|
addIssueToContext(ctx2, {
|
|
43293
44014
|
code: ZodIssueCode.invalid_type,
|
|
43294
44015
|
expected: ZodParsedType.number,
|
|
@@ -43300,8 +44021,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
43300
44021
|
const status = new ParseStatus();
|
|
43301
44022
|
for (const check2 of this._def.checks) {
|
|
43302
44023
|
if (check2.kind === "int") {
|
|
43303
|
-
if (!util.isInteger(
|
|
43304
|
-
ctx = this._getOrReturnCtx(
|
|
44024
|
+
if (!util.isInteger(input2.data)) {
|
|
44025
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43305
44026
|
addIssueToContext(ctx, {
|
|
43306
44027
|
code: ZodIssueCode.invalid_type,
|
|
43307
44028
|
expected: "integer",
|
|
@@ -43311,9 +44032,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
43311
44032
|
status.dirty();
|
|
43312
44033
|
}
|
|
43313
44034
|
} else if (check2.kind === "min") {
|
|
43314
|
-
const tooSmall = check2.inclusive ?
|
|
44035
|
+
const tooSmall = check2.inclusive ? input2.data < check2.value : input2.data <= check2.value;
|
|
43315
44036
|
if (tooSmall) {
|
|
43316
|
-
ctx = this._getOrReturnCtx(
|
|
44037
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43317
44038
|
addIssueToContext(ctx, {
|
|
43318
44039
|
code: ZodIssueCode.too_small,
|
|
43319
44040
|
minimum: check2.value,
|
|
@@ -43325,9 +44046,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
43325
44046
|
status.dirty();
|
|
43326
44047
|
}
|
|
43327
44048
|
} else if (check2.kind === "max") {
|
|
43328
|
-
const tooBig = check2.inclusive ?
|
|
44049
|
+
const tooBig = check2.inclusive ? input2.data > check2.value : input2.data >= check2.value;
|
|
43329
44050
|
if (tooBig) {
|
|
43330
|
-
ctx = this._getOrReturnCtx(
|
|
44051
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43331
44052
|
addIssueToContext(ctx, {
|
|
43332
44053
|
code: ZodIssueCode.too_big,
|
|
43333
44054
|
maximum: check2.value,
|
|
@@ -43339,8 +44060,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
43339
44060
|
status.dirty();
|
|
43340
44061
|
}
|
|
43341
44062
|
} else if (check2.kind === "multipleOf") {
|
|
43342
|
-
if (floatSafeRemainder(
|
|
43343
|
-
ctx = this._getOrReturnCtx(
|
|
44063
|
+
if (floatSafeRemainder(input2.data, check2.value) !== 0) {
|
|
44064
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43344
44065
|
addIssueToContext(ctx, {
|
|
43345
44066
|
code: ZodIssueCode.not_multiple_of,
|
|
43346
44067
|
multipleOf: check2.value,
|
|
@@ -43349,8 +44070,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
43349
44070
|
status.dirty();
|
|
43350
44071
|
}
|
|
43351
44072
|
} else if (check2.kind === "finite") {
|
|
43352
|
-
if (!Number.isFinite(
|
|
43353
|
-
ctx = this._getOrReturnCtx(
|
|
44073
|
+
if (!Number.isFinite(input2.data)) {
|
|
44074
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43354
44075
|
addIssueToContext(ctx, {
|
|
43355
44076
|
code: ZodIssueCode.not_finite,
|
|
43356
44077
|
message: check2.message
|
|
@@ -43361,7 +44082,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
43361
44082
|
util.assertNever(check2);
|
|
43362
44083
|
}
|
|
43363
44084
|
}
|
|
43364
|
-
return { status: status.value, value:
|
|
44085
|
+
return { status: status.value, value: input2.data };
|
|
43365
44086
|
}
|
|
43366
44087
|
gte(value, message) {
|
|
43367
44088
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -43513,25 +44234,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
43513
44234
|
this.min = this.gte;
|
|
43514
44235
|
this.max = this.lte;
|
|
43515
44236
|
}
|
|
43516
|
-
_parse(
|
|
44237
|
+
_parse(input2) {
|
|
43517
44238
|
if (this._def.coerce) {
|
|
43518
44239
|
try {
|
|
43519
|
-
|
|
44240
|
+
input2.data = BigInt(input2.data);
|
|
43520
44241
|
} catch {
|
|
43521
|
-
return this._getInvalidInput(
|
|
44242
|
+
return this._getInvalidInput(input2);
|
|
43522
44243
|
}
|
|
43523
44244
|
}
|
|
43524
|
-
const parsedType2 = this._getType(
|
|
44245
|
+
const parsedType2 = this._getType(input2);
|
|
43525
44246
|
if (parsedType2 !== ZodParsedType.bigint) {
|
|
43526
|
-
return this._getInvalidInput(
|
|
44247
|
+
return this._getInvalidInput(input2);
|
|
43527
44248
|
}
|
|
43528
44249
|
let ctx = void 0;
|
|
43529
44250
|
const status = new ParseStatus();
|
|
43530
44251
|
for (const check2 of this._def.checks) {
|
|
43531
44252
|
if (check2.kind === "min") {
|
|
43532
|
-
const tooSmall = check2.inclusive ?
|
|
44253
|
+
const tooSmall = check2.inclusive ? input2.data < check2.value : input2.data <= check2.value;
|
|
43533
44254
|
if (tooSmall) {
|
|
43534
|
-
ctx = this._getOrReturnCtx(
|
|
44255
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43535
44256
|
addIssueToContext(ctx, {
|
|
43536
44257
|
code: ZodIssueCode.too_small,
|
|
43537
44258
|
type: "bigint",
|
|
@@ -43542,9 +44263,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
43542
44263
|
status.dirty();
|
|
43543
44264
|
}
|
|
43544
44265
|
} else if (check2.kind === "max") {
|
|
43545
|
-
const tooBig = check2.inclusive ?
|
|
44266
|
+
const tooBig = check2.inclusive ? input2.data > check2.value : input2.data >= check2.value;
|
|
43546
44267
|
if (tooBig) {
|
|
43547
|
-
ctx = this._getOrReturnCtx(
|
|
44268
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43548
44269
|
addIssueToContext(ctx, {
|
|
43549
44270
|
code: ZodIssueCode.too_big,
|
|
43550
44271
|
type: "bigint",
|
|
@@ -43555,8 +44276,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
43555
44276
|
status.dirty();
|
|
43556
44277
|
}
|
|
43557
44278
|
} else if (check2.kind === "multipleOf") {
|
|
43558
|
-
if (
|
|
43559
|
-
ctx = this._getOrReturnCtx(
|
|
44279
|
+
if (input2.data % check2.value !== BigInt(0)) {
|
|
44280
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43560
44281
|
addIssueToContext(ctx, {
|
|
43561
44282
|
code: ZodIssueCode.not_multiple_of,
|
|
43562
44283
|
multipleOf: check2.value,
|
|
@@ -43568,10 +44289,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
43568
44289
|
util.assertNever(check2);
|
|
43569
44290
|
}
|
|
43570
44291
|
}
|
|
43571
|
-
return { status: status.value, value:
|
|
44292
|
+
return { status: status.value, value: input2.data };
|
|
43572
44293
|
}
|
|
43573
|
-
_getInvalidInput(
|
|
43574
|
-
const ctx = this._getOrReturnCtx(
|
|
44294
|
+
_getInvalidInput(input2) {
|
|
44295
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
43575
44296
|
addIssueToContext(ctx, {
|
|
43576
44297
|
code: ZodIssueCode.invalid_type,
|
|
43577
44298
|
expected: ZodParsedType.bigint,
|
|
@@ -43680,13 +44401,13 @@ ZodBigInt.create = (params) => {
|
|
|
43680
44401
|
});
|
|
43681
44402
|
};
|
|
43682
44403
|
var ZodBoolean = class extends ZodType {
|
|
43683
|
-
_parse(
|
|
44404
|
+
_parse(input2) {
|
|
43684
44405
|
if (this._def.coerce) {
|
|
43685
|
-
|
|
44406
|
+
input2.data = Boolean(input2.data);
|
|
43686
44407
|
}
|
|
43687
|
-
const parsedType2 = this._getType(
|
|
44408
|
+
const parsedType2 = this._getType(input2);
|
|
43688
44409
|
if (parsedType2 !== ZodParsedType.boolean) {
|
|
43689
|
-
const ctx = this._getOrReturnCtx(
|
|
44410
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
43690
44411
|
addIssueToContext(ctx, {
|
|
43691
44412
|
code: ZodIssueCode.invalid_type,
|
|
43692
44413
|
expected: ZodParsedType.boolean,
|
|
@@ -43694,7 +44415,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
43694
44415
|
});
|
|
43695
44416
|
return INVALID;
|
|
43696
44417
|
}
|
|
43697
|
-
return OK(
|
|
44418
|
+
return OK(input2.data);
|
|
43698
44419
|
}
|
|
43699
44420
|
};
|
|
43700
44421
|
ZodBoolean.create = (params) => {
|
|
@@ -43705,13 +44426,13 @@ ZodBoolean.create = (params) => {
|
|
|
43705
44426
|
});
|
|
43706
44427
|
};
|
|
43707
44428
|
var ZodDate = class _ZodDate extends ZodType {
|
|
43708
|
-
_parse(
|
|
44429
|
+
_parse(input2) {
|
|
43709
44430
|
if (this._def.coerce) {
|
|
43710
|
-
|
|
44431
|
+
input2.data = new Date(input2.data);
|
|
43711
44432
|
}
|
|
43712
|
-
const parsedType2 = this._getType(
|
|
44433
|
+
const parsedType2 = this._getType(input2);
|
|
43713
44434
|
if (parsedType2 !== ZodParsedType.date) {
|
|
43714
|
-
const ctx2 = this._getOrReturnCtx(
|
|
44435
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
43715
44436
|
addIssueToContext(ctx2, {
|
|
43716
44437
|
code: ZodIssueCode.invalid_type,
|
|
43717
44438
|
expected: ZodParsedType.date,
|
|
@@ -43719,8 +44440,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
43719
44440
|
});
|
|
43720
44441
|
return INVALID;
|
|
43721
44442
|
}
|
|
43722
|
-
if (Number.isNaN(
|
|
43723
|
-
const ctx2 = this._getOrReturnCtx(
|
|
44443
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
44444
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
43724
44445
|
addIssueToContext(ctx2, {
|
|
43725
44446
|
code: ZodIssueCode.invalid_date
|
|
43726
44447
|
});
|
|
@@ -43730,8 +44451,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
43730
44451
|
let ctx = void 0;
|
|
43731
44452
|
for (const check2 of this._def.checks) {
|
|
43732
44453
|
if (check2.kind === "min") {
|
|
43733
|
-
if (
|
|
43734
|
-
ctx = this._getOrReturnCtx(
|
|
44454
|
+
if (input2.data.getTime() < check2.value) {
|
|
44455
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43735
44456
|
addIssueToContext(ctx, {
|
|
43736
44457
|
code: ZodIssueCode.too_small,
|
|
43737
44458
|
message: check2.message,
|
|
@@ -43743,8 +44464,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
43743
44464
|
status.dirty();
|
|
43744
44465
|
}
|
|
43745
44466
|
} else if (check2.kind === "max") {
|
|
43746
|
-
if (
|
|
43747
|
-
ctx = this._getOrReturnCtx(
|
|
44467
|
+
if (input2.data.getTime() > check2.value) {
|
|
44468
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
43748
44469
|
addIssueToContext(ctx, {
|
|
43749
44470
|
code: ZodIssueCode.too_big,
|
|
43750
44471
|
message: check2.message,
|
|
@@ -43761,7 +44482,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
43761
44482
|
}
|
|
43762
44483
|
return {
|
|
43763
44484
|
status: status.value,
|
|
43764
|
-
value: new Date(
|
|
44485
|
+
value: new Date(input2.data.getTime())
|
|
43765
44486
|
};
|
|
43766
44487
|
}
|
|
43767
44488
|
_addCheck(check2) {
|
|
@@ -43814,10 +44535,10 @@ ZodDate.create = (params) => {
|
|
|
43814
44535
|
});
|
|
43815
44536
|
};
|
|
43816
44537
|
var ZodSymbol = class extends ZodType {
|
|
43817
|
-
_parse(
|
|
43818
|
-
const parsedType2 = this._getType(
|
|
44538
|
+
_parse(input2) {
|
|
44539
|
+
const parsedType2 = this._getType(input2);
|
|
43819
44540
|
if (parsedType2 !== ZodParsedType.symbol) {
|
|
43820
|
-
const ctx = this._getOrReturnCtx(
|
|
44541
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
43821
44542
|
addIssueToContext(ctx, {
|
|
43822
44543
|
code: ZodIssueCode.invalid_type,
|
|
43823
44544
|
expected: ZodParsedType.symbol,
|
|
@@ -43825,7 +44546,7 @@ var ZodSymbol = class extends ZodType {
|
|
|
43825
44546
|
});
|
|
43826
44547
|
return INVALID;
|
|
43827
44548
|
}
|
|
43828
|
-
return OK(
|
|
44549
|
+
return OK(input2.data);
|
|
43829
44550
|
}
|
|
43830
44551
|
};
|
|
43831
44552
|
ZodSymbol.create = (params) => {
|
|
@@ -43835,10 +44556,10 @@ ZodSymbol.create = (params) => {
|
|
|
43835
44556
|
});
|
|
43836
44557
|
};
|
|
43837
44558
|
var ZodUndefined = class extends ZodType {
|
|
43838
|
-
_parse(
|
|
43839
|
-
const parsedType2 = this._getType(
|
|
44559
|
+
_parse(input2) {
|
|
44560
|
+
const parsedType2 = this._getType(input2);
|
|
43840
44561
|
if (parsedType2 !== ZodParsedType.undefined) {
|
|
43841
|
-
const ctx = this._getOrReturnCtx(
|
|
44562
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
43842
44563
|
addIssueToContext(ctx, {
|
|
43843
44564
|
code: ZodIssueCode.invalid_type,
|
|
43844
44565
|
expected: ZodParsedType.undefined,
|
|
@@ -43846,7 +44567,7 @@ var ZodUndefined = class extends ZodType {
|
|
|
43846
44567
|
});
|
|
43847
44568
|
return INVALID;
|
|
43848
44569
|
}
|
|
43849
|
-
return OK(
|
|
44570
|
+
return OK(input2.data);
|
|
43850
44571
|
}
|
|
43851
44572
|
};
|
|
43852
44573
|
ZodUndefined.create = (params) => {
|
|
@@ -43856,10 +44577,10 @@ ZodUndefined.create = (params) => {
|
|
|
43856
44577
|
});
|
|
43857
44578
|
};
|
|
43858
44579
|
var ZodNull = class extends ZodType {
|
|
43859
|
-
_parse(
|
|
43860
|
-
const parsedType2 = this._getType(
|
|
44580
|
+
_parse(input2) {
|
|
44581
|
+
const parsedType2 = this._getType(input2);
|
|
43861
44582
|
if (parsedType2 !== ZodParsedType.null) {
|
|
43862
|
-
const ctx = this._getOrReturnCtx(
|
|
44583
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
43863
44584
|
addIssueToContext(ctx, {
|
|
43864
44585
|
code: ZodIssueCode.invalid_type,
|
|
43865
44586
|
expected: ZodParsedType.null,
|
|
@@ -43867,7 +44588,7 @@ var ZodNull = class extends ZodType {
|
|
|
43867
44588
|
});
|
|
43868
44589
|
return INVALID;
|
|
43869
44590
|
}
|
|
43870
|
-
return OK(
|
|
44591
|
+
return OK(input2.data);
|
|
43871
44592
|
}
|
|
43872
44593
|
};
|
|
43873
44594
|
ZodNull.create = (params) => {
|
|
@@ -43881,8 +44602,8 @@ var ZodAny = class extends ZodType {
|
|
|
43881
44602
|
super(...arguments);
|
|
43882
44603
|
this._any = true;
|
|
43883
44604
|
}
|
|
43884
|
-
_parse(
|
|
43885
|
-
return OK(
|
|
44605
|
+
_parse(input2) {
|
|
44606
|
+
return OK(input2.data);
|
|
43886
44607
|
}
|
|
43887
44608
|
};
|
|
43888
44609
|
ZodAny.create = (params) => {
|
|
@@ -43896,8 +44617,8 @@ var ZodUnknown = class extends ZodType {
|
|
|
43896
44617
|
super(...arguments);
|
|
43897
44618
|
this._unknown = true;
|
|
43898
44619
|
}
|
|
43899
|
-
_parse(
|
|
43900
|
-
return OK(
|
|
44620
|
+
_parse(input2) {
|
|
44621
|
+
return OK(input2.data);
|
|
43901
44622
|
}
|
|
43902
44623
|
};
|
|
43903
44624
|
ZodUnknown.create = (params) => {
|
|
@@ -43907,8 +44628,8 @@ ZodUnknown.create = (params) => {
|
|
|
43907
44628
|
});
|
|
43908
44629
|
};
|
|
43909
44630
|
var ZodNever = class extends ZodType {
|
|
43910
|
-
_parse(
|
|
43911
|
-
const ctx = this._getOrReturnCtx(
|
|
44631
|
+
_parse(input2) {
|
|
44632
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
43912
44633
|
addIssueToContext(ctx, {
|
|
43913
44634
|
code: ZodIssueCode.invalid_type,
|
|
43914
44635
|
expected: ZodParsedType.never,
|
|
@@ -43924,10 +44645,10 @@ ZodNever.create = (params) => {
|
|
|
43924
44645
|
});
|
|
43925
44646
|
};
|
|
43926
44647
|
var ZodVoid = class extends ZodType {
|
|
43927
|
-
_parse(
|
|
43928
|
-
const parsedType2 = this._getType(
|
|
44648
|
+
_parse(input2) {
|
|
44649
|
+
const parsedType2 = this._getType(input2);
|
|
43929
44650
|
if (parsedType2 !== ZodParsedType.undefined) {
|
|
43930
|
-
const ctx = this._getOrReturnCtx(
|
|
44651
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
43931
44652
|
addIssueToContext(ctx, {
|
|
43932
44653
|
code: ZodIssueCode.invalid_type,
|
|
43933
44654
|
expected: ZodParsedType.void,
|
|
@@ -43935,7 +44656,7 @@ var ZodVoid = class extends ZodType {
|
|
|
43935
44656
|
});
|
|
43936
44657
|
return INVALID;
|
|
43937
44658
|
}
|
|
43938
|
-
return OK(
|
|
44659
|
+
return OK(input2.data);
|
|
43939
44660
|
}
|
|
43940
44661
|
};
|
|
43941
44662
|
ZodVoid.create = (params) => {
|
|
@@ -43945,8 +44666,8 @@ ZodVoid.create = (params) => {
|
|
|
43945
44666
|
});
|
|
43946
44667
|
};
|
|
43947
44668
|
var ZodArray = class _ZodArray extends ZodType {
|
|
43948
|
-
_parse(
|
|
43949
|
-
const { ctx, status } = this._processInputParams(
|
|
44669
|
+
_parse(input2) {
|
|
44670
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
43950
44671
|
const def = this._def;
|
|
43951
44672
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
43952
44673
|
addIssueToContext(ctx, {
|
|
@@ -44086,10 +44807,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
44086
44807
|
this._cached = { shape, keys: keys2 };
|
|
44087
44808
|
return this._cached;
|
|
44088
44809
|
}
|
|
44089
|
-
_parse(
|
|
44090
|
-
const parsedType2 = this._getType(
|
|
44810
|
+
_parse(input2) {
|
|
44811
|
+
const parsedType2 = this._getType(input2);
|
|
44091
44812
|
if (parsedType2 !== ZodParsedType.object) {
|
|
44092
|
-
const ctx2 = this._getOrReturnCtx(
|
|
44813
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
44093
44814
|
addIssueToContext(ctx2, {
|
|
44094
44815
|
code: ZodIssueCode.invalid_type,
|
|
44095
44816
|
expected: ZodParsedType.object,
|
|
@@ -44097,7 +44818,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
44097
44818
|
});
|
|
44098
44819
|
return INVALID;
|
|
44099
44820
|
}
|
|
44100
|
-
const { status, ctx } = this._processInputParams(
|
|
44821
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
44101
44822
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
44102
44823
|
const extraKeys = [];
|
|
44103
44824
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -44410,8 +45131,8 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
44410
45131
|
});
|
|
44411
45132
|
};
|
|
44412
45133
|
var ZodUnion = class extends ZodType {
|
|
44413
|
-
_parse(
|
|
44414
|
-
const { ctx } = this._processInputParams(
|
|
45134
|
+
_parse(input2) {
|
|
45135
|
+
const { ctx } = this._processInputParams(input2);
|
|
44415
45136
|
const options = this._def.options;
|
|
44416
45137
|
function handleResults(results) {
|
|
44417
45138
|
for (const result of results) {
|
|
@@ -44532,8 +45253,8 @@ var getDiscriminator = (type) => {
|
|
|
44532
45253
|
}
|
|
44533
45254
|
};
|
|
44534
45255
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
44535
|
-
_parse(
|
|
44536
|
-
const { ctx } = this._processInputParams(
|
|
45256
|
+
_parse(input2) {
|
|
45257
|
+
const { ctx } = this._processInputParams(input2);
|
|
44537
45258
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
44538
45259
|
addIssueToContext(ctx, {
|
|
44539
45260
|
code: ZodIssueCode.invalid_type,
|
|
@@ -44646,8 +45367,8 @@ function mergeValues(a3, b3) {
|
|
|
44646
45367
|
}
|
|
44647
45368
|
}
|
|
44648
45369
|
var ZodIntersection = class extends ZodType {
|
|
44649
|
-
_parse(
|
|
44650
|
-
const { status, ctx } = this._processInputParams(
|
|
45370
|
+
_parse(input2) {
|
|
45371
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
44651
45372
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
44652
45373
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
44653
45374
|
return INVALID;
|
|
@@ -44699,8 +45420,8 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
44699
45420
|
});
|
|
44700
45421
|
};
|
|
44701
45422
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
44702
|
-
_parse(
|
|
44703
|
-
const { status, ctx } = this._processInputParams(
|
|
45423
|
+
_parse(input2) {
|
|
45424
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
44704
45425
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
44705
45426
|
addIssueToContext(ctx, {
|
|
44706
45427
|
code: ZodIssueCode.invalid_type,
|
|
@@ -44772,8 +45493,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
44772
45493
|
get valueSchema() {
|
|
44773
45494
|
return this._def.valueType;
|
|
44774
45495
|
}
|
|
44775
|
-
_parse(
|
|
44776
|
-
const { status, ctx } = this._processInputParams(
|
|
45496
|
+
_parse(input2) {
|
|
45497
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
44777
45498
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
44778
45499
|
addIssueToContext(ctx, {
|
|
44779
45500
|
code: ZodIssueCode.invalid_type,
|
|
@@ -44825,8 +45546,8 @@ var ZodMap = class extends ZodType {
|
|
|
44825
45546
|
get valueSchema() {
|
|
44826
45547
|
return this._def.valueType;
|
|
44827
45548
|
}
|
|
44828
|
-
_parse(
|
|
44829
|
-
const { status, ctx } = this._processInputParams(
|
|
45549
|
+
_parse(input2) {
|
|
45550
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
44830
45551
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
44831
45552
|
addIssueToContext(ctx, {
|
|
44832
45553
|
code: ZodIssueCode.invalid_type,
|
|
@@ -44885,8 +45606,8 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
44885
45606
|
});
|
|
44886
45607
|
};
|
|
44887
45608
|
var ZodSet = class _ZodSet extends ZodType {
|
|
44888
|
-
_parse(
|
|
44889
|
-
const { status, ctx } = this._processInputParams(
|
|
45609
|
+
_parse(input2) {
|
|
45610
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
44890
45611
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
44891
45612
|
addIssueToContext(ctx, {
|
|
44892
45613
|
code: ZodIssueCode.invalid_type,
|
|
@@ -44974,8 +45695,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
44974
45695
|
super(...arguments);
|
|
44975
45696
|
this.validate = this.implement;
|
|
44976
45697
|
}
|
|
44977
|
-
_parse(
|
|
44978
|
-
const { ctx } = this._processInputParams(
|
|
45698
|
+
_parse(input2) {
|
|
45699
|
+
const { ctx } = this._processInputParams(input2);
|
|
44979
45700
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
44980
45701
|
addIssueToContext(ctx, {
|
|
44981
45702
|
code: ZodIssueCode.invalid_type,
|
|
@@ -45078,8 +45799,8 @@ var ZodLazy = class extends ZodType {
|
|
|
45078
45799
|
get schema() {
|
|
45079
45800
|
return this._def.getter();
|
|
45080
45801
|
}
|
|
45081
|
-
_parse(
|
|
45082
|
-
const { ctx } = this._processInputParams(
|
|
45802
|
+
_parse(input2) {
|
|
45803
|
+
const { ctx } = this._processInputParams(input2);
|
|
45083
45804
|
const lazySchema = this._def.getter();
|
|
45084
45805
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
45085
45806
|
}
|
|
@@ -45092,9 +45813,9 @@ ZodLazy.create = (getter, params) => {
|
|
|
45092
45813
|
});
|
|
45093
45814
|
};
|
|
45094
45815
|
var ZodLiteral = class extends ZodType {
|
|
45095
|
-
_parse(
|
|
45096
|
-
if (
|
|
45097
|
-
const ctx = this._getOrReturnCtx(
|
|
45816
|
+
_parse(input2) {
|
|
45817
|
+
if (input2.data !== this._def.value) {
|
|
45818
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
45098
45819
|
addIssueToContext(ctx, {
|
|
45099
45820
|
received: ctx.data,
|
|
45100
45821
|
code: ZodIssueCode.invalid_literal,
|
|
@@ -45102,7 +45823,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
45102
45823
|
});
|
|
45103
45824
|
return INVALID;
|
|
45104
45825
|
}
|
|
45105
|
-
return { status: "valid", value:
|
|
45826
|
+
return { status: "valid", value: input2.data };
|
|
45106
45827
|
}
|
|
45107
45828
|
get value() {
|
|
45108
45829
|
return this._def.value;
|
|
@@ -45123,9 +45844,9 @@ function createZodEnum(values, params) {
|
|
|
45123
45844
|
});
|
|
45124
45845
|
}
|
|
45125
45846
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
45126
|
-
_parse(
|
|
45127
|
-
if (typeof
|
|
45128
|
-
const ctx = this._getOrReturnCtx(
|
|
45847
|
+
_parse(input2) {
|
|
45848
|
+
if (typeof input2.data !== "string") {
|
|
45849
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
45129
45850
|
const expectedValues = this._def.values;
|
|
45130
45851
|
addIssueToContext(ctx, {
|
|
45131
45852
|
expected: util.joinValues(expectedValues),
|
|
@@ -45137,8 +45858,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
45137
45858
|
if (!this._cache) {
|
|
45138
45859
|
this._cache = new Set(this._def.values);
|
|
45139
45860
|
}
|
|
45140
|
-
if (!this._cache.has(
|
|
45141
|
-
const ctx = this._getOrReturnCtx(
|
|
45861
|
+
if (!this._cache.has(input2.data)) {
|
|
45862
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
45142
45863
|
const expectedValues = this._def.values;
|
|
45143
45864
|
addIssueToContext(ctx, {
|
|
45144
45865
|
received: ctx.data,
|
|
@@ -45147,7 +45868,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
45147
45868
|
});
|
|
45148
45869
|
return INVALID;
|
|
45149
45870
|
}
|
|
45150
|
-
return OK(
|
|
45871
|
+
return OK(input2.data);
|
|
45151
45872
|
}
|
|
45152
45873
|
get options() {
|
|
45153
45874
|
return this._def.values;
|
|
@@ -45188,9 +45909,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
45188
45909
|
};
|
|
45189
45910
|
ZodEnum.create = createZodEnum;
|
|
45190
45911
|
var ZodNativeEnum = class extends ZodType {
|
|
45191
|
-
_parse(
|
|
45912
|
+
_parse(input2) {
|
|
45192
45913
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
45193
|
-
const ctx = this._getOrReturnCtx(
|
|
45914
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
45194
45915
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
45195
45916
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
45196
45917
|
addIssueToContext(ctx, {
|
|
@@ -45203,7 +45924,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
45203
45924
|
if (!this._cache) {
|
|
45204
45925
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
45205
45926
|
}
|
|
45206
|
-
if (!this._cache.has(
|
|
45927
|
+
if (!this._cache.has(input2.data)) {
|
|
45207
45928
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
45208
45929
|
addIssueToContext(ctx, {
|
|
45209
45930
|
received: ctx.data,
|
|
@@ -45212,7 +45933,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
45212
45933
|
});
|
|
45213
45934
|
return INVALID;
|
|
45214
45935
|
}
|
|
45215
|
-
return OK(
|
|
45936
|
+
return OK(input2.data);
|
|
45216
45937
|
}
|
|
45217
45938
|
get enum() {
|
|
45218
45939
|
return this._def.values;
|
|
@@ -45229,8 +45950,8 @@ var ZodPromise = class extends ZodType {
|
|
|
45229
45950
|
unwrap() {
|
|
45230
45951
|
return this._def.type;
|
|
45231
45952
|
}
|
|
45232
|
-
_parse(
|
|
45233
|
-
const { ctx } = this._processInputParams(
|
|
45953
|
+
_parse(input2) {
|
|
45954
|
+
const { ctx } = this._processInputParams(input2);
|
|
45234
45955
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
45235
45956
|
addIssueToContext(ctx, {
|
|
45236
45957
|
code: ZodIssueCode.invalid_type,
|
|
@@ -45262,8 +45983,8 @@ var ZodEffects = class extends ZodType {
|
|
|
45262
45983
|
sourceType() {
|
|
45263
45984
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
45264
45985
|
}
|
|
45265
|
-
_parse(
|
|
45266
|
-
const { status, ctx } = this._processInputParams(
|
|
45986
|
+
_parse(input2) {
|
|
45987
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
45267
45988
|
const effect = this._def.effect || null;
|
|
45268
45989
|
const checkCtx = {
|
|
45269
45990
|
addIssue: (arg) => {
|
|
@@ -45395,12 +46116,12 @@ ZodEffects.createWithPreprocess = (preprocess2, schema, params) => {
|
|
|
45395
46116
|
});
|
|
45396
46117
|
};
|
|
45397
46118
|
var ZodOptional = class extends ZodType {
|
|
45398
|
-
_parse(
|
|
45399
|
-
const parsedType2 = this._getType(
|
|
46119
|
+
_parse(input2) {
|
|
46120
|
+
const parsedType2 = this._getType(input2);
|
|
45400
46121
|
if (parsedType2 === ZodParsedType.undefined) {
|
|
45401
46122
|
return OK(void 0);
|
|
45402
46123
|
}
|
|
45403
|
-
return this._def.innerType._parse(
|
|
46124
|
+
return this._def.innerType._parse(input2);
|
|
45404
46125
|
}
|
|
45405
46126
|
unwrap() {
|
|
45406
46127
|
return this._def.innerType;
|
|
@@ -45414,12 +46135,12 @@ ZodOptional.create = (type, params) => {
|
|
|
45414
46135
|
});
|
|
45415
46136
|
};
|
|
45416
46137
|
var ZodNullable = class extends ZodType {
|
|
45417
|
-
_parse(
|
|
45418
|
-
const parsedType2 = this._getType(
|
|
46138
|
+
_parse(input2) {
|
|
46139
|
+
const parsedType2 = this._getType(input2);
|
|
45419
46140
|
if (parsedType2 === ZodParsedType.null) {
|
|
45420
46141
|
return OK(null);
|
|
45421
46142
|
}
|
|
45422
|
-
return this._def.innerType._parse(
|
|
46143
|
+
return this._def.innerType._parse(input2);
|
|
45423
46144
|
}
|
|
45424
46145
|
unwrap() {
|
|
45425
46146
|
return this._def.innerType;
|
|
@@ -45433,8 +46154,8 @@ ZodNullable.create = (type, params) => {
|
|
|
45433
46154
|
});
|
|
45434
46155
|
};
|
|
45435
46156
|
var ZodDefault = class extends ZodType {
|
|
45436
|
-
_parse(
|
|
45437
|
-
const { ctx } = this._processInputParams(
|
|
46157
|
+
_parse(input2) {
|
|
46158
|
+
const { ctx } = this._processInputParams(input2);
|
|
45438
46159
|
let data = ctx.data;
|
|
45439
46160
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
45440
46161
|
data = this._def.defaultValue();
|
|
@@ -45458,8 +46179,8 @@ ZodDefault.create = (type, params) => {
|
|
|
45458
46179
|
});
|
|
45459
46180
|
};
|
|
45460
46181
|
var ZodCatch = class extends ZodType {
|
|
45461
|
-
_parse(
|
|
45462
|
-
const { ctx } = this._processInputParams(
|
|
46182
|
+
_parse(input2) {
|
|
46183
|
+
const { ctx } = this._processInputParams(input2);
|
|
45463
46184
|
const newCtx = {
|
|
45464
46185
|
...ctx,
|
|
45465
46186
|
common: {
|
|
@@ -45511,10 +46232,10 @@ ZodCatch.create = (type, params) => {
|
|
|
45511
46232
|
});
|
|
45512
46233
|
};
|
|
45513
46234
|
var ZodNaN = class extends ZodType {
|
|
45514
|
-
_parse(
|
|
45515
|
-
const parsedType2 = this._getType(
|
|
46235
|
+
_parse(input2) {
|
|
46236
|
+
const parsedType2 = this._getType(input2);
|
|
45516
46237
|
if (parsedType2 !== ZodParsedType.nan) {
|
|
45517
|
-
const ctx = this._getOrReturnCtx(
|
|
46238
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
45518
46239
|
addIssueToContext(ctx, {
|
|
45519
46240
|
code: ZodIssueCode.invalid_type,
|
|
45520
46241
|
expected: ZodParsedType.nan,
|
|
@@ -45522,7 +46243,7 @@ var ZodNaN = class extends ZodType {
|
|
|
45522
46243
|
});
|
|
45523
46244
|
return INVALID;
|
|
45524
46245
|
}
|
|
45525
|
-
return { status: "valid", value:
|
|
46246
|
+
return { status: "valid", value: input2.data };
|
|
45526
46247
|
}
|
|
45527
46248
|
};
|
|
45528
46249
|
ZodNaN.create = (params) => {
|
|
@@ -45533,8 +46254,8 @@ ZodNaN.create = (params) => {
|
|
|
45533
46254
|
};
|
|
45534
46255
|
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
45535
46256
|
var ZodBranded = class extends ZodType {
|
|
45536
|
-
_parse(
|
|
45537
|
-
const { ctx } = this._processInputParams(
|
|
46257
|
+
_parse(input2) {
|
|
46258
|
+
const { ctx } = this._processInputParams(input2);
|
|
45538
46259
|
const data = ctx.data;
|
|
45539
46260
|
return this._def.type._parse({
|
|
45540
46261
|
data,
|
|
@@ -45547,8 +46268,8 @@ var ZodBranded = class extends ZodType {
|
|
|
45547
46268
|
}
|
|
45548
46269
|
};
|
|
45549
46270
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
45550
|
-
_parse(
|
|
45551
|
-
const { status, ctx } = this._processInputParams(
|
|
46271
|
+
_parse(input2) {
|
|
46272
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
45552
46273
|
if (ctx.common.async) {
|
|
45553
46274
|
const handleAsync = async () => {
|
|
45554
46275
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -45602,8 +46323,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
45602
46323
|
}
|
|
45603
46324
|
};
|
|
45604
46325
|
var ZodReadonly = class extends ZodType {
|
|
45605
|
-
_parse(
|
|
45606
|
-
const result = this._def.innerType._parse(
|
|
46326
|
+
_parse(input2) {
|
|
46327
|
+
const result = this._def.innerType._parse(input2);
|
|
45607
46328
|
const freeze = (data) => {
|
|
45608
46329
|
if (isValid(data)) {
|
|
45609
46330
|
data.value = Object.freeze(data.value);
|
|
@@ -45795,13 +46516,13 @@ var BalanceActionProvider = class extends ActionProvider {
|
|
|
45795
46516
|
address: external_exports.string().describe("Wallet address"),
|
|
45796
46517
|
coin: external_exports.coerce.number().describe("SLIP44 coin ID (e.g., 60 for Ethereum)")
|
|
45797
46518
|
}),
|
|
45798
|
-
invoke: async (ctx,
|
|
46519
|
+
invoke: async (ctx, input2) => {
|
|
45799
46520
|
if (this.blockchainClient) {
|
|
45800
|
-
return this.blockchainClient.getBalance(`c${
|
|
46521
|
+
return this.blockchainClient.getBalance(`c${input2.coin}`, input2.address);
|
|
45801
46522
|
}
|
|
45802
46523
|
return ctx.httpClient.gateway("POST", "/v1/balance", {
|
|
45803
46524
|
version: 2,
|
|
45804
|
-
assets: [{ address:
|
|
46525
|
+
assets: [{ address: input2.address, coin: input2.coin }]
|
|
45805
46526
|
});
|
|
45806
46527
|
}
|
|
45807
46528
|
};
|
|
@@ -45814,11 +46535,11 @@ var BalanceActionProvider = class extends ActionProvider {
|
|
|
45814
46535
|
address: external_exports.string().describe("Wallet address"),
|
|
45815
46536
|
coin: external_exports.coerce.number().describe("SLIP44 coin ID")
|
|
45816
46537
|
}),
|
|
45817
|
-
invoke: async (ctx,
|
|
46538
|
+
invoke: async (ctx, input2) => {
|
|
45818
46539
|
const response = await ctx.httpClient.gateway("POST", "/v1/assets", {
|
|
45819
46540
|
version: 2,
|
|
45820
46541
|
includeDisabledAssets: false,
|
|
45821
|
-
assets: [{ address:
|
|
46542
|
+
assets: [{ address: input2.address, coin: input2.coin }]
|
|
45822
46543
|
});
|
|
45823
46544
|
const holdings = Array.isArray(response) ? response : response.docs ?? response.data ?? [];
|
|
45824
46545
|
const tokens = [];
|
|
@@ -45836,7 +46557,7 @@ var BalanceActionProvider = class extends ActionProvider {
|
|
|
45836
46557
|
}
|
|
45837
46558
|
}
|
|
45838
46559
|
}
|
|
45839
|
-
return { address:
|
|
46560
|
+
return { address: input2.address, coin: input2.coin, tokens };
|
|
45840
46561
|
}
|
|
45841
46562
|
};
|
|
45842
46563
|
}
|
|
@@ -45849,14 +46570,14 @@ var BalanceActionProvider = class extends ActionProvider {
|
|
|
45849
46570
|
networks: external_exports.string().optional().describe("Comma-separated coin IDs to filter"),
|
|
45850
46571
|
limit: external_exports.coerce.number().optional().default(10).describe("Max results")
|
|
45851
46572
|
}),
|
|
45852
|
-
invoke: async (ctx,
|
|
46573
|
+
invoke: async (ctx, input2) => {
|
|
45853
46574
|
const params = new URLSearchParams({
|
|
45854
|
-
query:
|
|
46575
|
+
query: input2.query,
|
|
45855
46576
|
type: "all",
|
|
45856
46577
|
version: "24",
|
|
45857
|
-
limit: (
|
|
46578
|
+
limit: (input2.limit || 10).toString()
|
|
45858
46579
|
});
|
|
45859
|
-
if (
|
|
46580
|
+
if (input2.networks) params.set("networks", input2.networks);
|
|
45860
46581
|
return ctx.httpClient.gateway("GET", "/v1/search/assets", void 0, params.toString());
|
|
45861
46582
|
}
|
|
45862
46583
|
};
|
|
@@ -45880,12 +46601,12 @@ var WalletActionProvider = class extends ActionProvider {
|
|
|
45880
46601
|
schema: external_exports.object({
|
|
45881
46602
|
chainId: external_exports.string().optional().default("eip155:1").describe("Chain ID")
|
|
45882
46603
|
}),
|
|
45883
|
-
invoke: async (_ctx,
|
|
46604
|
+
invoke: async (_ctx, input2) => {
|
|
45884
46605
|
const provider = this.agentWallet ?? this.walletProvider;
|
|
45885
46606
|
if (!provider) return { connected: false, error: "No wallet provider configured" };
|
|
45886
46607
|
try {
|
|
45887
|
-
const address = await provider.getAddress(
|
|
45888
|
-
return { connected: true, address, chainId:
|
|
46608
|
+
const address = await provider.getAddress(input2.chainId);
|
|
46609
|
+
return { connected: true, address, chainId: input2.chainId, provider: provider.name };
|
|
45889
46610
|
} catch {
|
|
45890
46611
|
return { connected: false };
|
|
45891
46612
|
}
|
|
@@ -45899,9 +46620,9 @@ var WalletActionProvider = class extends ActionProvider {
|
|
|
45899
46620
|
schema: external_exports.object({
|
|
45900
46621
|
chains: external_exports.array(external_exports.string()).optional().default(["eip155:1"]).describe("Chains to connect")
|
|
45901
46622
|
}),
|
|
45902
|
-
invoke: async (_ctx,
|
|
46623
|
+
invoke: async (_ctx, input2) => {
|
|
45903
46624
|
if (!this.walletProvider) return { success: false, error: "No wallet provider configured" };
|
|
45904
|
-
const result = await this.walletProvider.connect(
|
|
46625
|
+
const result = await this.walletProvider.connect(input2.chains);
|
|
45905
46626
|
return { success: true, ...result };
|
|
45906
46627
|
}
|
|
45907
46628
|
};
|
|
@@ -45990,19 +46711,19 @@ var TransferActionProvider = class extends ActionProvider {
|
|
|
45990
46711
|
token: external_exports.string().optional().describe("ERC-20 token contract address (omit for native token)"),
|
|
45991
46712
|
decimals: external_exports.coerce.number().optional().default(18).describe("Token decimals (default 18, use 6 for USDC/USDT)")
|
|
45992
46713
|
}),
|
|
45993
|
-
invoke: async (_ctx,
|
|
46714
|
+
invoke: async (_ctx, input2) => {
|
|
45994
46715
|
const signer = this.walletProvider;
|
|
45995
46716
|
if (!signer) return { success: false, error: "No wallet provider configured" };
|
|
45996
|
-
const caip2 = toCaip2(
|
|
46717
|
+
const caip2 = toCaip2(input2.chain);
|
|
45997
46718
|
if (this.priceLookup) {
|
|
45998
46719
|
try {
|
|
45999
46720
|
const evmId2 = extractEvmChainId(caip2);
|
|
46000
46721
|
const chain22 = getChainById(evmId2) ?? getChainByEvmId(evmId2);
|
|
46001
46722
|
const chainKey = chain22 ? coinTypeToChainKey(chain22.coinId) ?? evmId2 : caip2;
|
|
46002
|
-
const tokenAddress =
|
|
46723
|
+
const tokenAddress = input2.token || "";
|
|
46003
46724
|
const price = await this.priceLookup.getTokenPrice(chainKey, tokenAddress);
|
|
46004
46725
|
if (price && price > 0) {
|
|
46005
|
-
const usdValue = parseFloat(
|
|
46726
|
+
const usdValue = parseFloat(input2.amount) * price;
|
|
46006
46727
|
if (usdValue > this.maxTransferUsd) {
|
|
46007
46728
|
return {
|
|
46008
46729
|
success: false,
|
|
@@ -46013,16 +46734,16 @@ var TransferActionProvider = class extends ActionProvider {
|
|
|
46013
46734
|
} catch {
|
|
46014
46735
|
}
|
|
46015
46736
|
}
|
|
46016
|
-
const resolvedTo = await resolveAddressOrName(
|
|
46017
|
-
const atomicAmount = parseAmount(
|
|
46018
|
-
const isErc20 =
|
|
46737
|
+
const resolvedTo = await resolveAddressOrName(input2.to);
|
|
46738
|
+
const atomicAmount = parseAmount(input2.amount, input2.decimals ?? 18);
|
|
46739
|
+
const isErc20 = input2.token && input2.token !== NATIVE_TOKEN_PLACEHOLDER;
|
|
46019
46740
|
let txHash;
|
|
46020
46741
|
const evmId = extractEvmChainId(caip2);
|
|
46021
46742
|
if (isErc20) {
|
|
46022
46743
|
const calldata = encodeErc20Transfer(resolvedTo, BigInt(atomicAmount));
|
|
46023
46744
|
txHash = await signer.sendTransaction({
|
|
46024
46745
|
chainId: caip2,
|
|
46025
|
-
to:
|
|
46746
|
+
to: input2.token,
|
|
46026
46747
|
data: calldata,
|
|
46027
46748
|
value: "0x0"
|
|
46028
46749
|
});
|
|
@@ -46040,7 +46761,7 @@ var TransferActionProvider = class extends ActionProvider {
|
|
|
46040
46761
|
success: true,
|
|
46041
46762
|
txHash,
|
|
46042
46763
|
to: resolvedTo,
|
|
46043
|
-
resolvedFrom:
|
|
46764
|
+
resolvedFrom: input2.to !== resolvedTo ? input2.to : void 0,
|
|
46044
46765
|
explorer: explorerUrl || void 0
|
|
46045
46766
|
};
|
|
46046
46767
|
}
|
|
@@ -46104,47 +46825,47 @@ var SwapActionProvider = class extends ActionProvider {
|
|
|
46104
46825
|
amount: external_exports.string().describe("Human-readable amount to swap"),
|
|
46105
46826
|
slippage: external_exports.string().optional().default("1").describe("Slippage tolerance % (max 50)")
|
|
46106
46827
|
}),
|
|
46107
|
-
invoke: async (_ctx,
|
|
46828
|
+
invoke: async (_ctx, input2) => {
|
|
46108
46829
|
const signer = this.walletProvider;
|
|
46109
46830
|
if (!signer || !this.swapClient) {
|
|
46110
46831
|
return { success: false, error: "Wallet and swap client required" };
|
|
46111
46832
|
}
|
|
46112
|
-
const slippage = parseFloat(
|
|
46833
|
+
const slippage = parseFloat(input2.slippage ?? "1");
|
|
46113
46834
|
if (isNaN(slippage) || slippage <= 0 || slippage > 50) {
|
|
46114
|
-
return { success: false, error: `Slippage must be greater than 0% and at most 50%. Got: ${
|
|
46115
|
-
}
|
|
46116
|
-
const fromTokenInfo = resolveToken(
|
|
46117
|
-
if (!fromTokenInfo) return { success: false, error: `Unknown token: ${
|
|
46118
|
-
const toTokenInfo = resolveToken(
|
|
46119
|
-
if (!toTokenInfo) return { success: false, error: `Unknown token: ${
|
|
46120
|
-
const parsedAmount = parseAmount(
|
|
46121
|
-
const address = await signer.getAddress(
|
|
46835
|
+
return { success: false, error: `Slippage must be greater than 0% and at most 50%. Got: ${input2.slippage}` };
|
|
46836
|
+
}
|
|
46837
|
+
const fromTokenInfo = resolveToken(input2.fromToken, input2.fromChain);
|
|
46838
|
+
if (!fromTokenInfo) return { success: false, error: `Unknown token: ${input2.fromToken} on ${input2.fromChain}` };
|
|
46839
|
+
const toTokenInfo = resolveToken(input2.toToken, input2.toChain);
|
|
46840
|
+
if (!toTokenInfo) return { success: false, error: `Unknown token: ${input2.toToken} on ${input2.toChain}` };
|
|
46841
|
+
const parsedAmount = parseAmount(input2.amount, fromTokenInfo.decimals);
|
|
46842
|
+
const address = await signer.getAddress(input2.fromChain);
|
|
46122
46843
|
const quote = await this.swapClient.getQuote({
|
|
46123
|
-
fromChain:
|
|
46844
|
+
fromChain: input2.fromChain,
|
|
46124
46845
|
fromToken: fromTokenInfo.address,
|
|
46125
|
-
toChain:
|
|
46846
|
+
toChain: input2.toChain,
|
|
46126
46847
|
toToken: toTokenInfo.address,
|
|
46127
46848
|
amount: parsedAmount,
|
|
46128
46849
|
walletAddress: address,
|
|
46129
|
-
slippage:
|
|
46850
|
+
slippage: input2.slippage
|
|
46130
46851
|
});
|
|
46131
46852
|
if (quote.routes.length === 0) {
|
|
46132
46853
|
return { success: false, error: "No swap routes found" };
|
|
46133
46854
|
}
|
|
46134
46855
|
const route = quote.routes[0];
|
|
46135
|
-
const chainConfig = getChainById(
|
|
46856
|
+
const chainConfig = getChainById(input2.fromChain);
|
|
46136
46857
|
const transactions = await this.swapClient.getSwapTransactions(route);
|
|
46137
46858
|
let txHash = "";
|
|
46138
46859
|
for (const txData of transactions) {
|
|
46139
46860
|
txHash = await this.sendSwapTx(txData, chainConfig, signer);
|
|
46140
46861
|
const isApproval = txData.transaction.type === "approval" || txData.transaction.type === "revokeApproval";
|
|
46141
|
-
await this.pollConfirmation(
|
|
46862
|
+
await this.pollConfirmation(input2.fromChain, address, txHash, isApproval ? 6e4 : 12e4);
|
|
46142
46863
|
}
|
|
46143
46864
|
const firstStep = route.steps[0];
|
|
46144
46865
|
const lastStep = route.steps[route.steps.length - 1];
|
|
46145
46866
|
const inputAmt = formatAmount(firstStep.from.amount, firstStep.from.asset.metadata.decimals);
|
|
46146
46867
|
const outputAmt = formatAmount(lastStep.to.amount, lastStep.to.asset.metadata.decimals);
|
|
46147
|
-
const explorerUrl = getExplorerTxUrl(
|
|
46868
|
+
const explorerUrl = getExplorerTxUrl(input2.fromChain, txHash);
|
|
46148
46869
|
return {
|
|
46149
46870
|
success: true,
|
|
46150
46871
|
txHash,
|
|
@@ -46166,20 +46887,20 @@ var SwapActionProvider = class extends ActionProvider {
|
|
|
46166
46887
|
toToken: external_exports.string().describe("Destination token symbol or address"),
|
|
46167
46888
|
amount: external_exports.string().describe("Human-readable amount")
|
|
46168
46889
|
}),
|
|
46169
|
-
invoke: async (_ctx,
|
|
46890
|
+
invoke: async (_ctx, input2) => {
|
|
46170
46891
|
if (!this.swapClient) return { success: false, error: "Swap client required" };
|
|
46171
|
-
const fromTokenInfo = resolveToken(
|
|
46172
|
-
if (!fromTokenInfo) return { success: false, error: `Unknown token: ${
|
|
46173
|
-
const toTokenInfo = resolveToken(
|
|
46174
|
-
if (!toTokenInfo) return { success: false, error: `Unknown token: ${
|
|
46175
|
-
const parsedAmount = parseAmount(
|
|
46892
|
+
const fromTokenInfo = resolveToken(input2.fromToken, input2.fromChain);
|
|
46893
|
+
if (!fromTokenInfo) return { success: false, error: `Unknown token: ${input2.fromToken} on ${input2.fromChain}` };
|
|
46894
|
+
const toTokenInfo = resolveToken(input2.toToken, input2.toChain);
|
|
46895
|
+
if (!toTokenInfo) return { success: false, error: `Unknown token: ${input2.toToken} on ${input2.toChain}` };
|
|
46896
|
+
const parsedAmount = parseAmount(input2.amount, fromTokenInfo.decimals);
|
|
46176
46897
|
const quote = await this.swapClient.getQuote({
|
|
46177
|
-
fromChain:
|
|
46898
|
+
fromChain: input2.fromChain,
|
|
46178
46899
|
fromToken: fromTokenInfo.address,
|
|
46179
|
-
toChain:
|
|
46900
|
+
toChain: input2.toChain,
|
|
46180
46901
|
toToken: toTokenInfo.address,
|
|
46181
46902
|
amount: parsedAmount,
|
|
46182
|
-
walletAddress: getSampleAccount(
|
|
46903
|
+
walletAddress: getSampleAccount(input2.fromChain)
|
|
46183
46904
|
});
|
|
46184
46905
|
if (quote.routes.length === 0) return { success: false, error: "No routes found" };
|
|
46185
46906
|
const route = quote.routes[0];
|
|
@@ -46205,13 +46926,13 @@ var SwapActionProvider = class extends ActionProvider {
|
|
|
46205
46926
|
chain: external_exports.string().describe("Chain name (e.g., ethereum)"),
|
|
46206
46927
|
token: external_exports.string().describe("Token symbol or address")
|
|
46207
46928
|
}),
|
|
46208
|
-
invoke: async (_ctx,
|
|
46929
|
+
invoke: async (_ctx, input2) => {
|
|
46209
46930
|
if (!this.swapClient) return { success: false, error: "Swap client required" };
|
|
46210
|
-
const tokenInfo = resolveToken(
|
|
46211
|
-
if (!tokenInfo) return { success: false, error: `Unknown token: ${
|
|
46212
|
-
const price = await this.swapClient.getTokenPrice(
|
|
46213
|
-
if (price === null) return { success: false, error: `Price not found for ${
|
|
46214
|
-
return { success: true, token:
|
|
46931
|
+
const tokenInfo = resolveToken(input2.token, input2.chain);
|
|
46932
|
+
if (!tokenInfo) return { success: false, error: `Unknown token: ${input2.token} on ${input2.chain}` };
|
|
46933
|
+
const price = await this.swapClient.getTokenPrice(input2.chain, tokenInfo.address);
|
|
46934
|
+
if (price === null) return { success: false, error: `Price not found for ${input2.token}` };
|
|
46935
|
+
return { success: true, token: input2.token.toUpperCase(), chain: input2.chain, priceUsd: price };
|
|
46215
46936
|
}
|
|
46216
46937
|
};
|
|
46217
46938
|
}
|
|
@@ -46238,8 +46959,8 @@ var SecurityActionProvider = class extends ActionProvider {
|
|
|
46238
46959
|
assetId: external_exports.string().optional().describe("Asset ID"),
|
|
46239
46960
|
type: external_exports.string().optional().describe("Validation type")
|
|
46240
46961
|
}),
|
|
46241
|
-
invoke: async (ctx,
|
|
46242
|
-
return this.getService(ctx).validate(
|
|
46962
|
+
invoke: async (ctx, input2) => {
|
|
46963
|
+
return this.getService(ctx).validate(input2);
|
|
46243
46964
|
}
|
|
46244
46965
|
};
|
|
46245
46966
|
}
|
|
@@ -46250,8 +46971,8 @@ var SecurityActionProvider = class extends ActionProvider {
|
|
|
46250
46971
|
schema: external_exports.object({
|
|
46251
46972
|
assetId: external_exports.string().describe("Asset ID (e.g., c60_t0xA0b8...)")
|
|
46252
46973
|
}),
|
|
46253
|
-
invoke: async (ctx,
|
|
46254
|
-
return this.getService(ctx).getAssetInfo(
|
|
46974
|
+
invoke: async (ctx, input2) => {
|
|
46975
|
+
return this.getService(ctx).getAssetInfo(input2.assetId);
|
|
46255
46976
|
}
|
|
46256
46977
|
};
|
|
46257
46978
|
}
|
|
@@ -46280,8 +47001,8 @@ var HistoryActionProvider = class extends ActionProvider {
|
|
|
46280
47001
|
from: external_exports.string().optional().describe("Start date (ISO)"),
|
|
46281
47002
|
to: external_exports.string().optional().describe("End date (ISO)")
|
|
46282
47003
|
}),
|
|
46283
|
-
invoke: async (ctx,
|
|
46284
|
-
return this.getService(ctx).getHistory(
|
|
47004
|
+
invoke: async (ctx, input2) => {
|
|
47005
|
+
return this.getService(ctx).getHistory(input2);
|
|
46285
47006
|
}
|
|
46286
47007
|
};
|
|
46287
47008
|
}
|
|
@@ -46293,9 +47014,9 @@ var HistoryActionProvider = class extends ActionProvider {
|
|
|
46293
47014
|
hash: external_exports.string().describe("Transaction hash"),
|
|
46294
47015
|
chain: external_exports.string().describe("Chain name")
|
|
46295
47016
|
}),
|
|
46296
|
-
invoke: async (ctx,
|
|
46297
|
-
const details = await this.getService(ctx).getByHash(
|
|
46298
|
-
const explorer = getExplorerTxUrl(
|
|
47017
|
+
invoke: async (ctx, input2) => {
|
|
47018
|
+
const details = await this.getService(ctx).getByHash(input2.hash, input2.chain);
|
|
47019
|
+
const explorer = getExplorerTxUrl(input2.chain, input2.hash);
|
|
46299
47020
|
return { ...details, explorer: explorer || void 0 };
|
|
46300
47021
|
}
|
|
46301
47022
|
};
|
|
@@ -46309,8 +47030,8 @@ var HistoryActionProvider = class extends ActionProvider {
|
|
|
46309
47030
|
chain: external_exports.string().optional().describe("Chain name"),
|
|
46310
47031
|
limit: external_exports.coerce.number().optional().default(20).describe("Max results")
|
|
46311
47032
|
}),
|
|
46312
|
-
invoke: async (ctx,
|
|
46313
|
-
return this.getService(ctx).getSwapHistory(
|
|
47033
|
+
invoke: async (ctx, input2) => {
|
|
47034
|
+
return this.getService(ctx).getSwapHistory(input2);
|
|
46314
47035
|
}
|
|
46315
47036
|
};
|
|
46316
47037
|
}
|
|
@@ -46343,21 +47064,21 @@ var AlertActionProvider = class extends ActionProvider {
|
|
|
46343
47064
|
condition: external_exports.enum(["above", "below"]).describe("Alert when price goes above or below target"),
|
|
46344
47065
|
targetPrice: external_exports.coerce.number().positive().describe("Target price in USD")
|
|
46345
47066
|
}),
|
|
46346
|
-
invoke: async (_ctx,
|
|
47067
|
+
invoke: async (_ctx, input2) => {
|
|
46347
47068
|
try {
|
|
46348
|
-
parseTokenId(
|
|
47069
|
+
parseTokenId(input2.tokenId);
|
|
46349
47070
|
} catch {
|
|
46350
|
-
return { error: `Invalid tokenId format: ${
|
|
47071
|
+
return { error: `Invalid tokenId format: ${input2.tokenId}. Expected format: "c60" or "c60_t0xABC..."` };
|
|
46351
47072
|
}
|
|
46352
47073
|
const alert = await this.alertStore.create({
|
|
46353
|
-
tokenId:
|
|
46354
|
-
chainKey:
|
|
46355
|
-
condition:
|
|
46356
|
-
targetPrice:
|
|
47074
|
+
tokenId: input2.tokenId,
|
|
47075
|
+
chainKey: input2.chainKey,
|
|
47076
|
+
condition: input2.condition,
|
|
47077
|
+
targetPrice: input2.targetPrice
|
|
46357
47078
|
});
|
|
46358
47079
|
return {
|
|
46359
47080
|
id: alert.id,
|
|
46360
|
-
message: `Alert created: notify when ${
|
|
47081
|
+
message: `Alert created: notify when ${input2.tokenId} goes ${input2.condition} $${input2.targetPrice}`
|
|
46361
47082
|
};
|
|
46362
47083
|
}
|
|
46363
47084
|
};
|
|
@@ -46369,8 +47090,8 @@ var AlertActionProvider = class extends ActionProvider {
|
|
|
46369
47090
|
schema: external_exports.object({
|
|
46370
47091
|
activeOnly: external_exports.boolean().optional().default(false).describe("Only show active alerts")
|
|
46371
47092
|
}),
|
|
46372
|
-
invoke: async (_ctx,
|
|
46373
|
-
const alerts =
|
|
47093
|
+
invoke: async (_ctx, input2) => {
|
|
47094
|
+
const alerts = input2.activeOnly ? await this.alertStore.getActive() : await this.alertStore.list();
|
|
46374
47095
|
return { alerts, count: alerts.length };
|
|
46375
47096
|
}
|
|
46376
47097
|
};
|
|
@@ -46415,11 +47136,11 @@ var AlertActionProvider = class extends ActionProvider {
|
|
|
46415
47136
|
schema: external_exports.object({
|
|
46416
47137
|
id: external_exports.string().describe("Alert ID to delete")
|
|
46417
47138
|
}),
|
|
46418
|
-
invoke: async (_ctx,
|
|
46419
|
-
const deleted = await this.alertStore.delete(
|
|
47139
|
+
invoke: async (_ctx, input2) => {
|
|
47140
|
+
const deleted = await this.alertStore.delete(input2.id);
|
|
46420
47141
|
return {
|
|
46421
47142
|
success: deleted,
|
|
46422
|
-
message: deleted ? `Alert ${
|
|
47143
|
+
message: deleted ? `Alert ${input2.id} deleted` : `Alert ${input2.id} not found`
|
|
46423
47144
|
};
|
|
46424
47145
|
}
|
|
46425
47146
|
};
|
|
@@ -46447,8 +47168,8 @@ var AgentWalletActionProvider = class extends ActionProvider {
|
|
|
46447
47168
|
schema: external_exports.object({
|
|
46448
47169
|
password: external_exports.string().min(8).describe("Password to encrypt the wallet (min 8 characters)")
|
|
46449
47170
|
}),
|
|
46450
|
-
invoke: async (_ctx,
|
|
46451
|
-
const provider = await AgentWalletProvider.create(
|
|
47171
|
+
invoke: async (_ctx, input2) => {
|
|
47172
|
+
const provider = await AgentWalletProvider.create(input2.password);
|
|
46452
47173
|
return {
|
|
46453
47174
|
message: "Agent wallet created successfully",
|
|
46454
47175
|
addresses: await provider.getAddresses()
|
|
@@ -46464,10 +47185,10 @@ var AgentWalletActionProvider = class extends ActionProvider {
|
|
|
46464
47185
|
chainKey: external_exports.string().describe('Chain key (e.g., "ethereum", "bsc", "solana")'),
|
|
46465
47186
|
password: external_exports.string().describe("Wallet password to decrypt the mnemonic")
|
|
46466
47187
|
}),
|
|
46467
|
-
invoke: async (_ctx,
|
|
46468
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
46469
|
-
const address = await provider.getAddress(
|
|
46470
|
-
return { chainKey:
|
|
47188
|
+
invoke: async (_ctx, input2) => {
|
|
47189
|
+
const provider = await AgentWalletProvider.fromStorage(input2.password);
|
|
47190
|
+
const address = await provider.getAddress(input2.chainKey);
|
|
47191
|
+
return { chainKey: input2.chainKey, address };
|
|
46471
47192
|
}
|
|
46472
47193
|
};
|
|
46473
47194
|
}
|
|
@@ -46478,8 +47199,8 @@ var AgentWalletActionProvider = class extends ActionProvider {
|
|
|
46478
47199
|
schema: external_exports.object({
|
|
46479
47200
|
password: external_exports.string().describe("Wallet password to decrypt the mnemonic")
|
|
46480
47201
|
}),
|
|
46481
|
-
invoke: async (_ctx,
|
|
46482
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
47202
|
+
invoke: async (_ctx, input2) => {
|
|
47203
|
+
const provider = await AgentWalletProvider.fromStorage(input2.password);
|
|
46483
47204
|
const addresses = await provider.getAddresses();
|
|
46484
47205
|
return { addresses, count: addresses.length };
|
|
46485
47206
|
}
|
|
@@ -46493,19 +47214,19 @@ var AgentWalletActionProvider = class extends ActionProvider {
|
|
|
46493
47214
|
chainKey: external_exports.string().describe('Chain key (e.g., "ethereum", "bsc")'),
|
|
46494
47215
|
password: external_exports.string().describe("Wallet password")
|
|
46495
47216
|
}),
|
|
46496
|
-
invoke: async (_ctx,
|
|
46497
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
46498
|
-
const address = await provider.getAddress(
|
|
47217
|
+
invoke: async (_ctx, input2) => {
|
|
47218
|
+
const provider = await AgentWalletProvider.fromStorage(input2.password);
|
|
47219
|
+
const address = await provider.getAddress(input2.chainKey);
|
|
46499
47220
|
if (!this.blockchainClient) {
|
|
46500
|
-
return { chainKey:
|
|
47221
|
+
return { chainKey: input2.chainKey, address, balance: "BlockchainClient not available" };
|
|
46501
47222
|
}
|
|
46502
|
-
const coinType = chainKeyToCoinType(
|
|
47223
|
+
const coinType = chainKeyToCoinType(input2.chainKey);
|
|
46503
47224
|
if (coinType === void 0) {
|
|
46504
|
-
throw new Error(`Unsupported chain: ${
|
|
47225
|
+
throw new Error(`Unsupported chain: ${input2.chainKey}`);
|
|
46505
47226
|
}
|
|
46506
47227
|
const assetId = formatTokenId(coinType);
|
|
46507
47228
|
const balance = await this.blockchainClient.getBalance(assetId, address);
|
|
46508
|
-
return { chainKey:
|
|
47229
|
+
return { chainKey: input2.chainKey, address, balance };
|
|
46509
47230
|
}
|
|
46510
47231
|
};
|
|
46511
47232
|
}
|
|
@@ -46534,12 +47255,12 @@ var TokenActionProvider = class extends ActionProvider {
|
|
|
46534
47255
|
assetId: external_exports.string().describe('Token ID (e.g., "c60" for ETH, "c20000714_t0x55d3..." for BSC USDT)'),
|
|
46535
47256
|
address: external_exports.string().describe("Wallet address to check balance for")
|
|
46536
47257
|
}),
|
|
46537
|
-
invoke: async (_ctx,
|
|
47258
|
+
invoke: async (_ctx, input2) => {
|
|
46538
47259
|
if (!this.blockchainClient) {
|
|
46539
47260
|
throw new Error("BlockchainClient not available");
|
|
46540
47261
|
}
|
|
46541
|
-
const balance = await this.blockchainClient.getBalance(
|
|
46542
|
-
return { assetId:
|
|
47262
|
+
const balance = await this.blockchainClient.getBalance(input2.assetId, input2.address);
|
|
47263
|
+
return { assetId: input2.assetId, address: input2.address, balance };
|
|
46543
47264
|
}
|
|
46544
47265
|
};
|
|
46545
47266
|
}
|
|
@@ -46553,7 +47274,7 @@ var TokenActionProvider = class extends ActionProvider {
|
|
|
46553
47274
|
amount: external_exports.string().describe("Amount to transfer (in smallest unit)"),
|
|
46554
47275
|
memo: external_exports.string().optional().describe("Optional memo/note")
|
|
46555
47276
|
}),
|
|
46556
|
-
invoke: async (_ctx,
|
|
47277
|
+
invoke: async (_ctx, input2) => {
|
|
46557
47278
|
if (!this.blockchainClient) {
|
|
46558
47279
|
throw new Error("BlockchainClient not available");
|
|
46559
47280
|
}
|
|
@@ -46562,10 +47283,10 @@ var TokenActionProvider = class extends ActionProvider {
|
|
|
46562
47283
|
}
|
|
46563
47284
|
const hdWallet = this.agentWallet.getSigner().getHDWallet();
|
|
46564
47285
|
const result = await this.blockchainClient.transfer({
|
|
46565
|
-
assetId:
|
|
46566
|
-
to:
|
|
46567
|
-
amount:
|
|
46568
|
-
memo:
|
|
47286
|
+
assetId: input2.assetId,
|
|
47287
|
+
to: input2.to,
|
|
47288
|
+
amount: input2.amount,
|
|
47289
|
+
memo: input2.memo,
|
|
46569
47290
|
hdWallet
|
|
46570
47291
|
});
|
|
46571
47292
|
return { hash: result.hash, chainKey: result.chainKey };
|
|
@@ -46581,7 +47302,7 @@ var TokenActionProvider = class extends ActionProvider {
|
|
|
46581
47302
|
spender: external_exports.string().describe("Spender address to approve"),
|
|
46582
47303
|
amount: external_exports.string().describe('Amount to approve (in smallest unit, or "unlimited")')
|
|
46583
47304
|
}),
|
|
46584
|
-
invoke: async (_ctx,
|
|
47305
|
+
invoke: async (_ctx, input2) => {
|
|
46585
47306
|
if (!this.blockchainClient) {
|
|
46586
47307
|
throw new Error("BlockchainClient not available");
|
|
46587
47308
|
}
|
|
@@ -46589,10 +47310,10 @@ var TokenActionProvider = class extends ActionProvider {
|
|
|
46589
47310
|
throw new Error("Wallet not connected");
|
|
46590
47311
|
}
|
|
46591
47312
|
const hdWallet = this.agentWallet.getSigner().getHDWallet();
|
|
46592
|
-
const amount =
|
|
47313
|
+
const amount = input2.amount === "unlimited" ? "115792089237316195423570985008687907853269984665640564039457584007913129639935" : input2.amount;
|
|
46593
47314
|
const result = await this.blockchainClient.approve({
|
|
46594
|
-
assetId:
|
|
46595
|
-
spender:
|
|
47315
|
+
assetId: input2.assetId,
|
|
47316
|
+
spender: input2.spender,
|
|
46596
47317
|
amount,
|
|
46597
47318
|
hdWallet
|
|
46598
47319
|
});
|
|
@@ -46609,16 +47330,16 @@ var TokenActionProvider = class extends ActionProvider {
|
|
|
46609
47330
|
owner: external_exports.string().describe("Token owner address"),
|
|
46610
47331
|
spender: external_exports.string().describe("Spender address to check")
|
|
46611
47332
|
}),
|
|
46612
|
-
invoke: async (_ctx,
|
|
47333
|
+
invoke: async (_ctx, input2) => {
|
|
46613
47334
|
if (!this.blockchainClient) {
|
|
46614
47335
|
throw new Error("BlockchainClient not available");
|
|
46615
47336
|
}
|
|
46616
47337
|
const allowance = await this.blockchainClient.getAllowance({
|
|
46617
|
-
assetId:
|
|
46618
|
-
owner:
|
|
46619
|
-
spender:
|
|
47338
|
+
assetId: input2.assetId,
|
|
47339
|
+
owner: input2.owner,
|
|
47340
|
+
spender: input2.spender
|
|
46620
47341
|
});
|
|
46621
|
-
return { assetId:
|
|
47342
|
+
return { assetId: input2.assetId, owner: input2.owner, spender: input2.spender, allowance: allowance.toString() };
|
|
46622
47343
|
}
|
|
46623
47344
|
};
|
|
46624
47345
|
}
|
|
@@ -46643,8 +47364,8 @@ var MarketActionProvider = class extends ActionProvider {
|
|
|
46643
47364
|
schema: external_exports.object({
|
|
46644
47365
|
limit: external_exports.coerce.number().optional().default(20).describe("Number of tokens to return (default 20)")
|
|
46645
47366
|
}),
|
|
46646
|
-
invoke: async (ctx,
|
|
46647
|
-
const tokens = await this.getService(ctx).getAssetListings({ limit:
|
|
47367
|
+
invoke: async (ctx, input2) => {
|
|
47368
|
+
const tokens = await this.getService(ctx).getAssetListings({ limit: input2.limit });
|
|
46648
47369
|
return { success: true, count: tokens.length, tokens };
|
|
46649
47370
|
}
|
|
46650
47371
|
};
|
|
@@ -46656,13 +47377,13 @@ var MarketActionProvider = class extends ActionProvider {
|
|
|
46656
47377
|
schema: external_exports.object({
|
|
46657
47378
|
assetId: external_exports.string().describe("Asset ID (e.g., c60_t0xA0b8... for ERC-20, c60 for native)")
|
|
46658
47379
|
}),
|
|
46659
|
-
invoke: async (ctx,
|
|
46660
|
-
const status = await this.getService(ctx).checkCoinStatus(
|
|
47380
|
+
invoke: async (ctx, input2) => {
|
|
47381
|
+
const status = await this.getService(ctx).checkCoinStatus(input2.assetId);
|
|
46661
47382
|
const riskLevel = status.securityInfo?.riskLevel || status.solanaSecurityInfo?.riskLevel || "unknown";
|
|
46662
47383
|
const isHoneypot = status.securityInfo?.isHoneypot ?? false;
|
|
46663
47384
|
return {
|
|
46664
47385
|
success: true,
|
|
46665
|
-
assetId:
|
|
47386
|
+
assetId: input2.assetId,
|
|
46666
47387
|
name: status.name,
|
|
46667
47388
|
symbol: status.symbol,
|
|
46668
47389
|
isActive: status.isActive,
|
|
@@ -46803,16 +47524,16 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46803
47524
|
"Destination wallet address where the purchased crypto will be sent. OMIT to auto-derive from the configured wallet using cryptoAsset's chain \u2014 this is the safe default and prevents sending funds to a stranger by mistake. Only supply this when operating on behalf of a different user."
|
|
46804
47525
|
)
|
|
46805
47526
|
}),
|
|
46806
|
-
invoke: async (ctx,
|
|
46807
|
-
const address = await this.resolveAddress(
|
|
47527
|
+
invoke: async (ctx, input2) => {
|
|
47528
|
+
const address = await this.resolveAddress(input2.walletAddress, input2.cryptoAsset);
|
|
46808
47529
|
const query = new URLSearchParams({
|
|
46809
|
-
amount:
|
|
46810
|
-
currency:
|
|
47530
|
+
amount: input2.fiatAmount.toString(),
|
|
47531
|
+
currency: input2.fiatCurrency,
|
|
46811
47532
|
address
|
|
46812
47533
|
});
|
|
46813
47534
|
const result = await ctx.httpClient.gateway(
|
|
46814
47535
|
"GET",
|
|
46815
|
-
`/v1/buycrypto/quote/${encodeURIComponent(
|
|
47536
|
+
`/v1/buycrypto/quote/${encodeURIComponent(input2.cryptoAsset)}`,
|
|
46816
47537
|
void 0,
|
|
46817
47538
|
query.toString()
|
|
46818
47539
|
);
|
|
@@ -46822,7 +47543,7 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46822
47543
|
success: true,
|
|
46823
47544
|
summary: summarizeOnrampQuotes(quotes),
|
|
46824
47545
|
address,
|
|
46825
|
-
cryptoAsset:
|
|
47546
|
+
cryptoAsset: input2.cryptoAsset,
|
|
46826
47547
|
quotes,
|
|
46827
47548
|
nextAction: quotes.length > 0 ? "Call get_onramp_url with the chosen quoteId to receive a browser redirect URL for checkout. quotes[0] is the best deal (lowest vsBestPct)." : "No quotes available \u2014 try a different fiatAmount or cryptoAsset."
|
|
46828
47549
|
};
|
|
@@ -46842,14 +47563,14 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46842
47563
|
"Crypto asset ID that was used for the quote (e.g., c60 for ETH). Required when walletAddress is omitted so the chain can be derived for address lookup."
|
|
46843
47564
|
)
|
|
46844
47565
|
}),
|
|
46845
|
-
invoke: async (ctx,
|
|
46846
|
-
const address = await this.resolveAddress(
|
|
47566
|
+
invoke: async (ctx, input2) => {
|
|
47567
|
+
const address = await this.resolveAddress(input2.walletAddress, input2.cryptoAsset);
|
|
46847
47568
|
const query = new URLSearchParams({ address });
|
|
46848
47569
|
let result;
|
|
46849
47570
|
try {
|
|
46850
47571
|
result = await ctx.httpClient.gateway(
|
|
46851
47572
|
"GET",
|
|
46852
|
-
`/v1/buycrypto/request/${encodeURIComponent(
|
|
47573
|
+
`/v1/buycrypto/request/${encodeURIComponent(input2.quoteId)}`,
|
|
46853
47574
|
void 0,
|
|
46854
47575
|
query.toString()
|
|
46855
47576
|
);
|
|
@@ -46858,14 +47579,14 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46858
47579
|
return {
|
|
46859
47580
|
success: false,
|
|
46860
47581
|
address,
|
|
46861
|
-
summary: `No checkout URL returned for quoteId ${
|
|
47582
|
+
summary: `No checkout URL returned for quoteId ${input2.quoteId} \u2014 the quote has likely expired (buy quotes are short-lived). Request a fresh quote with get_onramp_quote and retry.`,
|
|
46862
47583
|
nextAction: "Call get_onramp_quote again to obtain a fresh quoteId, then retry get_onramp_url."
|
|
46863
47584
|
};
|
|
46864
47585
|
}
|
|
46865
47586
|
throw err;
|
|
46866
47587
|
}
|
|
46867
47588
|
const url = result.url ?? result.redirect_url;
|
|
46868
|
-
const followUp = url ? buildFollowUp(
|
|
47589
|
+
const followUp = url ? buildFollowUp(input2.cryptoAsset, address, "onramp") : void 0;
|
|
46869
47590
|
return {
|
|
46870
47591
|
success: Boolean(url),
|
|
46871
47592
|
address,
|
|
@@ -46893,25 +47614,25 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46893
47614
|
"Source wallet address holding the crypto to be sold. OMIT to auto-derive from the configured wallet using cryptoAsset's chain \u2014 this is the safe default. Only supply this when operating on behalf of a different user."
|
|
46894
47615
|
)
|
|
46895
47616
|
}),
|
|
46896
|
-
invoke: async (ctx,
|
|
46897
|
-
const address = await this.resolveAddress(
|
|
47617
|
+
invoke: async (ctx, input2) => {
|
|
47618
|
+
const address = await this.resolveAddress(input2.walletAddress, input2.cryptoAsset);
|
|
46898
47619
|
const query = new URLSearchParams({
|
|
46899
|
-
amount:
|
|
46900
|
-
currency:
|
|
47620
|
+
amount: input2.cryptoAmount.toString(),
|
|
47621
|
+
currency: input2.fiatCurrency,
|
|
46901
47622
|
// iOS sends `asset_id` as both path segment AND query param. Mirroring that.
|
|
46902
|
-
asset_id:
|
|
47623
|
+
asset_id: input2.cryptoAsset,
|
|
46903
47624
|
address,
|
|
46904
47625
|
// The HTTP gateway uses `payment_method` for both buy and sell, mirroring the
|
|
46905
47626
|
// iOS production client. The sell proto declares `payout_method` but the
|
|
46906
47627
|
// gateway doesn't honour it; trust runtime over proto.
|
|
46907
|
-
payment_method:
|
|
47628
|
+
payment_method: input2.paymentMethod ?? "ANY",
|
|
46908
47629
|
// iOS always sends this even when the user holds no TWT; omitting it appears
|
|
46909
47630
|
// to filter out fee-waiver-aware providers in some regions.
|
|
46910
47631
|
twt_amount: "0"
|
|
46911
47632
|
});
|
|
46912
47633
|
const result = await ctx.httpClient.gateway(
|
|
46913
47634
|
"GET",
|
|
46914
|
-
`/v1/sellcrypto/quote/${encodeURIComponent(
|
|
47635
|
+
`/v1/sellcrypto/quote/${encodeURIComponent(input2.cryptoAsset)}`,
|
|
46915
47636
|
void 0,
|
|
46916
47637
|
query.toString()
|
|
46917
47638
|
);
|
|
@@ -46921,7 +47642,7 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46921
47642
|
success: true,
|
|
46922
47643
|
summary: summarizeOfframpQuotes(quotes),
|
|
46923
47644
|
address,
|
|
46924
|
-
cryptoAsset:
|
|
47645
|
+
cryptoAsset: input2.cryptoAsset,
|
|
46925
47646
|
quotes,
|
|
46926
47647
|
nextAction: quotes.length > 0 ? "Call get_offramp_url with the chosen quoteId to receive a browser redirect URL for the sale. quotes[0] is the best deal (lowest vsBestPct)." : "No quotes available \u2014 try a different cryptoAmount, cryptoAsset, or paymentMethod."
|
|
46927
47648
|
};
|
|
@@ -46941,14 +47662,14 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46941
47662
|
"Crypto asset ID that was used for the quote (e.g., c60 for ETH). Required when walletAddress is omitted so the chain can be derived for address lookup."
|
|
46942
47663
|
)
|
|
46943
47664
|
}),
|
|
46944
|
-
invoke: async (ctx,
|
|
46945
|
-
const address = await this.resolveAddress(
|
|
47665
|
+
invoke: async (ctx, input2) => {
|
|
47666
|
+
const address = await this.resolveAddress(input2.walletAddress, input2.cryptoAsset);
|
|
46946
47667
|
const query = new URLSearchParams({ address });
|
|
46947
47668
|
let result;
|
|
46948
47669
|
try {
|
|
46949
47670
|
result = await ctx.httpClient.gateway(
|
|
46950
47671
|
"GET",
|
|
46951
|
-
`/v1/sellcrypto/request/${encodeURIComponent(
|
|
47672
|
+
`/v1/sellcrypto/request/${encodeURIComponent(input2.quoteId)}`,
|
|
46952
47673
|
void 0,
|
|
46953
47674
|
query.toString()
|
|
46954
47675
|
);
|
|
@@ -46957,14 +47678,14 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
46957
47678
|
return {
|
|
46958
47679
|
success: false,
|
|
46959
47680
|
address,
|
|
46960
|
-
summary: `No checkout URL returned for quoteId ${
|
|
47681
|
+
summary: `No checkout URL returned for quoteId ${input2.quoteId} \u2014 the quote has likely expired (sell quotes are short-lived). Request a fresh quote with get_offramp_quote and retry.`,
|
|
46961
47682
|
nextAction: "Call get_offramp_quote again to obtain a fresh quoteId, then retry get_offramp_url."
|
|
46962
47683
|
};
|
|
46963
47684
|
}
|
|
46964
47685
|
throw err;
|
|
46965
47686
|
}
|
|
46966
47687
|
const url = result.url ?? result.redirect_url;
|
|
46967
|
-
const followUp = url ? buildFollowUp(
|
|
47688
|
+
const followUp = url ? buildFollowUp(input2.cryptoAsset, address, "offramp") : void 0;
|
|
46968
47689
|
return {
|
|
46969
47690
|
success: Boolean(url),
|
|
46970
47691
|
address,
|
|
@@ -47000,36 +47721,36 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
47000
47721
|
"Quote ID from get_offramp_quote. Optional \u2014 included only for traceability in the response; tx details come from depositAddress / cryptoAmount."
|
|
47001
47722
|
)
|
|
47002
47723
|
}),
|
|
47003
|
-
invoke: async (_ctx,
|
|
47724
|
+
invoke: async (_ctx, input2) => {
|
|
47004
47725
|
const signer = this.walletProvider;
|
|
47005
47726
|
if (!signer) {
|
|
47006
47727
|
return { success: false, error: "No wallet provider configured" };
|
|
47007
47728
|
}
|
|
47008
47729
|
let parsed;
|
|
47009
47730
|
try {
|
|
47010
|
-
parsed = parseTokenId(
|
|
47731
|
+
parsed = parseTokenId(input2.cryptoAsset);
|
|
47011
47732
|
} catch {
|
|
47012
|
-
throw new TransferError("VALIDATION_ERROR", `Invalid cryptoAsset: ${
|
|
47733
|
+
throw new TransferError("VALIDATION_ERROR", `Invalid cryptoAsset: ${input2.cryptoAsset}`);
|
|
47013
47734
|
}
|
|
47014
47735
|
const chainKey = coinTypeToChainKey(parsed.coinId);
|
|
47015
47736
|
if (!chainKey) {
|
|
47016
47737
|
throw new TransferError(
|
|
47017
47738
|
"CHAIN_UNSUPPORTED",
|
|
47018
|
-
`Unsupported coin type in cryptoAsset: ${
|
|
47739
|
+
`Unsupported coin type in cryptoAsset: ${input2.cryptoAsset}`
|
|
47019
47740
|
);
|
|
47020
47741
|
}
|
|
47021
47742
|
const chainDef = getChainById(chainKey);
|
|
47022
47743
|
if (!chainDef || chainDef.namespace !== "eip155") {
|
|
47023
47744
|
throw new TransferError(
|
|
47024
47745
|
"CHAIN_UNSUPPORTED",
|
|
47025
|
-
`confirm_offramp_transfer is EVM-only. For ${chainKey} off-ramps use the CLI: twak onramp sell-confirm --asset ${
|
|
47746
|
+
`confirm_offramp_transfer is EVM-only. For ${chainKey} off-ramps use the CLI: twak onramp sell-confirm --asset ${input2.cryptoAsset} --to <deposit> --amount <n>${input2.memo ? " --memo <tag>" : ""}.`
|
|
47026
47747
|
);
|
|
47027
47748
|
}
|
|
47028
47749
|
const caip2 = `eip155:${chainDef.chainId}`;
|
|
47029
|
-
if (!EVM_ADDRESS_RE.test(
|
|
47750
|
+
if (!EVM_ADDRESS_RE.test(input2.depositAddress)) {
|
|
47030
47751
|
throw new TransferError(
|
|
47031
47752
|
"VALIDATION_ERROR",
|
|
47032
|
-
`depositAddress is not a valid EVM address: ${
|
|
47753
|
+
`depositAddress is not a valid EVM address: ${input2.depositAddress}. Double-check what the provider displayed.`
|
|
47033
47754
|
);
|
|
47034
47755
|
}
|
|
47035
47756
|
if (parsed.contractAddress && !EVM_ADDRESS_RE.test(parsed.contractAddress)) {
|
|
@@ -47038,15 +47759,15 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
47038
47759
|
`Malformed token contract in cryptoAsset: ${parsed.contractAddress}`
|
|
47039
47760
|
);
|
|
47040
47761
|
}
|
|
47041
|
-
if (parsed.contractAddress &&
|
|
47762
|
+
if (parsed.contractAddress && input2.decimals === void 0) {
|
|
47042
47763
|
throw new TransferError(
|
|
47043
47764
|
"VALIDATION_ERROR",
|
|
47044
|
-
`decimals is required for ERC-20 asset ${
|
|
47765
|
+
`decimals is required for ERC-20 asset ${input2.cryptoAsset}. Pass the token's decimals explicitly (6 for USDC/USDT, 18 for DAI, etc.) \u2014 silently defaulting to 18 could over-pay the provider by orders of magnitude.`
|
|
47045
47766
|
);
|
|
47046
47767
|
}
|
|
47047
|
-
const decimals = parsed.contractAddress ?
|
|
47768
|
+
const decimals = parsed.contractAddress ? input2.decimals : 18;
|
|
47048
47769
|
try {
|
|
47049
|
-
assertStrictPositiveAmount(
|
|
47770
|
+
assertStrictPositiveAmount(input2.cryptoAmount, decimals);
|
|
47050
47771
|
} catch (err) {
|
|
47051
47772
|
throw new TransferError(
|
|
47052
47773
|
"VALIDATION_ERROR",
|
|
@@ -47055,11 +47776,11 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
47055
47776
|
}
|
|
47056
47777
|
if (this.priceLookup) {
|
|
47057
47778
|
try {
|
|
47058
|
-
const tokenInfo = resolveToken(
|
|
47779
|
+
const tokenInfo = resolveToken(input2.cryptoAsset, chainKey);
|
|
47059
47780
|
const tokenAddress = tokenInfo?.address ?? parsed.contractAddress ?? "";
|
|
47060
47781
|
const price = await this.priceLookup.getTokenPrice(chainKey, tokenAddress);
|
|
47061
47782
|
if (price && price > 0) {
|
|
47062
|
-
const usdValue = parseFloat(
|
|
47783
|
+
const usdValue = parseFloat(input2.cryptoAmount) * price;
|
|
47063
47784
|
if (usdValue > this.maxTransferUsd) {
|
|
47064
47785
|
return {
|
|
47065
47786
|
success: false,
|
|
@@ -47070,10 +47791,10 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
47070
47791
|
} catch {
|
|
47071
47792
|
}
|
|
47072
47793
|
}
|
|
47073
|
-
const atomic = parseAmount(
|
|
47794
|
+
const atomic = parseAmount(input2.cryptoAmount, decimals);
|
|
47074
47795
|
let txHash;
|
|
47075
47796
|
if (parsed.contractAddress) {
|
|
47076
|
-
const calldata = encodeErc20Transfer2(
|
|
47797
|
+
const calldata = encodeErc20Transfer2(input2.depositAddress, BigInt(atomic));
|
|
47077
47798
|
txHash = await signer.sendTransaction({
|
|
47078
47799
|
chainId: caip2,
|
|
47079
47800
|
to: parsed.contractAddress,
|
|
@@ -47083,7 +47804,7 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
47083
47804
|
} else {
|
|
47084
47805
|
txHash = await signer.sendTransaction({
|
|
47085
47806
|
chainId: caip2,
|
|
47086
|
-
to:
|
|
47807
|
+
to: input2.depositAddress,
|
|
47087
47808
|
data: "0x",
|
|
47088
47809
|
value: "0x" + BigInt(atomic).toString(16)
|
|
47089
47810
|
});
|
|
@@ -47093,13 +47814,13 @@ var OnrampActionProvider = class extends ActionProvider {
|
|
|
47093
47814
|
success: true,
|
|
47094
47815
|
txHash,
|
|
47095
47816
|
chain: chainKey,
|
|
47096
|
-
to:
|
|
47097
|
-
amount:
|
|
47098
|
-
asset:
|
|
47099
|
-
memoIgnored:
|
|
47100
|
-
quoteId:
|
|
47817
|
+
to: input2.depositAddress,
|
|
47818
|
+
amount: input2.cryptoAmount,
|
|
47819
|
+
asset: input2.cryptoAsset,
|
|
47820
|
+
memoIgnored: input2.memo ? `A memo was supplied (${input2.memo}) but EVM transactions have no memo field \u2014 it was ignored. If the provider requires a memo, they likely expect a non-EVM chain.` : void 0,
|
|
47821
|
+
quoteId: input2.quoteId,
|
|
47101
47822
|
explorer: explorerUrl,
|
|
47102
|
-
summary: `Off-ramp payout of ${
|
|
47823
|
+
summary: `Off-ramp payout of ${input2.cryptoAmount} ${input2.cryptoAsset} broadcast to ${input2.depositAddress} on ${chainKey}. Fiat payout from the provider arrives separately.`
|
|
47103
47824
|
};
|
|
47104
47825
|
}
|
|
47105
47826
|
};
|
|
@@ -47137,24 +47858,24 @@ var AutomateActionProvider = class extends ActionProvider {
|
|
|
47137
47858
|
targetPrice: external_exports.coerce.number().optional().describe("Target price in USD for limit orders"),
|
|
47138
47859
|
condition: external_exports.enum(["above", "below"]).optional().describe("Price condition for limit orders")
|
|
47139
47860
|
}),
|
|
47140
|
-
invoke: async (_ctx,
|
|
47141
|
-
if (
|
|
47861
|
+
invoke: async (_ctx, input2) => {
|
|
47862
|
+
if (input2.type === "dca" && !input2.intervalMs) {
|
|
47142
47863
|
return { success: false, error: "DCA automations require intervalMs" };
|
|
47143
47864
|
}
|
|
47144
|
-
if (
|
|
47865
|
+
if (input2.type === "limit" && (input2.targetPrice == null || !input2.condition)) {
|
|
47145
47866
|
return { success: false, error: "Limit orders require targetPrice and condition" };
|
|
47146
47867
|
}
|
|
47147
47868
|
const record2 = await this.automationStore.create({
|
|
47148
|
-
type:
|
|
47149
|
-
fromToken:
|
|
47150
|
-
toToken:
|
|
47151
|
-
chain:
|
|
47152
|
-
amount:
|
|
47153
|
-
intervalMs:
|
|
47154
|
-
targetPrice:
|
|
47155
|
-
condition:
|
|
47869
|
+
type: input2.type,
|
|
47870
|
+
fromToken: input2.fromToken,
|
|
47871
|
+
toToken: input2.toToken,
|
|
47872
|
+
chain: input2.chain,
|
|
47873
|
+
amount: input2.amount,
|
|
47874
|
+
intervalMs: input2.intervalMs,
|
|
47875
|
+
targetPrice: input2.targetPrice,
|
|
47876
|
+
condition: input2.condition
|
|
47156
47877
|
});
|
|
47157
|
-
const summary =
|
|
47878
|
+
const summary = input2.type === "dca" ? `DCA: ${input2.amount} ${input2.fromToken} \u2192 ${input2.toToken} every ${Math.round((input2.intervalMs || 0) / 36e5)}h` : `Limit: swap ${input2.amount} ${input2.fromToken} \u2192 ${input2.toToken} when price ${input2.condition} $${input2.targetPrice}`;
|
|
47158
47879
|
return { success: true, id: record2.id, summary, record: record2 };
|
|
47159
47880
|
}
|
|
47160
47881
|
};
|
|
@@ -47166,9 +47887,9 @@ var AutomateActionProvider = class extends ActionProvider {
|
|
|
47166
47887
|
schema: external_exports.object({
|
|
47167
47888
|
activeOnly: external_exports.boolean().optional().default(true).describe("Only show active automations")
|
|
47168
47889
|
}),
|
|
47169
|
-
invoke: async (_ctx,
|
|
47890
|
+
invoke: async (_ctx, input2) => {
|
|
47170
47891
|
const all = await this.automationStore.list();
|
|
47171
|
-
const automations =
|
|
47892
|
+
const automations = input2.activeOnly ? all.filter((a3) => a3.active) : all;
|
|
47172
47893
|
return { success: true, count: automations.length, automations };
|
|
47173
47894
|
}
|
|
47174
47895
|
};
|
|
@@ -47180,9 +47901,9 @@ var AutomateActionProvider = class extends ActionProvider {
|
|
|
47180
47901
|
schema: external_exports.object({
|
|
47181
47902
|
id: external_exports.string().describe("Automation ID to delete")
|
|
47182
47903
|
}),
|
|
47183
|
-
invoke: async (_ctx,
|
|
47184
|
-
const deleted = await this.automationStore.delete(
|
|
47185
|
-
return deleted ? { success: true, message: `Automation ${
|
|
47904
|
+
invoke: async (_ctx, input2) => {
|
|
47905
|
+
const deleted = await this.automationStore.delete(input2.id);
|
|
47906
|
+
return deleted ? { success: true, message: `Automation ${input2.id} deleted` } : { success: false, error: `Automation ${input2.id} not found` };
|
|
47186
47907
|
}
|
|
47187
47908
|
};
|
|
47188
47909
|
}
|
|
@@ -47226,13 +47947,13 @@ var AutomateActionProvider = class extends ActionProvider {
|
|
|
47226
47947
|
schema: external_exports.object({
|
|
47227
47948
|
id: external_exports.string().describe("Automation ID to run")
|
|
47228
47949
|
}),
|
|
47229
|
-
invoke: async (_ctx,
|
|
47950
|
+
invoke: async (_ctx, input2) => {
|
|
47230
47951
|
if (!this.walletProvider || !this.swapClient) {
|
|
47231
47952
|
return { success: false, error: "Agent wallet and swap client required to execute automation" };
|
|
47232
47953
|
}
|
|
47233
|
-
const record2 = await this.automationStore.getById(
|
|
47234
|
-
if (!record2) return { success: false, error: `Automation ${
|
|
47235
|
-
if (!record2.active) return { success: false, error: `Automation ${
|
|
47954
|
+
const record2 = await this.automationStore.getById(input2.id);
|
|
47955
|
+
if (!record2) return { success: false, error: `Automation ${input2.id} not found` };
|
|
47956
|
+
if (!record2.active) return { success: false, error: `Automation ${input2.id} is inactive` };
|
|
47236
47957
|
const fromTokenInfo = resolveToken(record2.fromToken, record2.chain);
|
|
47237
47958
|
if (!fromTokenInfo) return { success: false, error: `Unknown token: ${record2.fromToken} on ${record2.chain}` };
|
|
47238
47959
|
const toTokenInfo = resolveToken(record2.toToken, record2.chain);
|
|
@@ -47428,8 +48149,8 @@ function cached(getter) {
|
|
|
47428
48149
|
}
|
|
47429
48150
|
};
|
|
47430
48151
|
}
|
|
47431
|
-
function nullish(
|
|
47432
|
-
return
|
|
48152
|
+
function nullish(input2) {
|
|
48153
|
+
return input2 === null || input2 === void 0;
|
|
47433
48154
|
}
|
|
47434
48155
|
function cleanRegex(source) {
|
|
47435
48156
|
const start = source.startsWith("^") ? 1 : 0;
|
|
@@ -47819,29 +48540,29 @@ function finalizeIssue(iss, ctx, config2) {
|
|
|
47819
48540
|
}
|
|
47820
48541
|
return full;
|
|
47821
48542
|
}
|
|
47822
|
-
function getSizableOrigin(
|
|
47823
|
-
if (
|
|
48543
|
+
function getSizableOrigin(input2) {
|
|
48544
|
+
if (input2 instanceof Set)
|
|
47824
48545
|
return "set";
|
|
47825
|
-
if (
|
|
48546
|
+
if (input2 instanceof Map)
|
|
47826
48547
|
return "map";
|
|
47827
|
-
if (
|
|
48548
|
+
if (input2 instanceof File)
|
|
47828
48549
|
return "file";
|
|
47829
48550
|
return "unknown";
|
|
47830
48551
|
}
|
|
47831
|
-
function getLengthableOrigin(
|
|
47832
|
-
if (Array.isArray(
|
|
48552
|
+
function getLengthableOrigin(input2) {
|
|
48553
|
+
if (Array.isArray(input2))
|
|
47833
48554
|
return "array";
|
|
47834
|
-
if (typeof
|
|
48555
|
+
if (typeof input2 === "string")
|
|
47835
48556
|
return "string";
|
|
47836
48557
|
return "unknown";
|
|
47837
48558
|
}
|
|
47838
48559
|
function issue(...args) {
|
|
47839
|
-
const [iss,
|
|
48560
|
+
const [iss, input2, inst] = args;
|
|
47840
48561
|
if (typeof iss === "string") {
|
|
47841
48562
|
return {
|
|
47842
48563
|
message: iss,
|
|
47843
48564
|
code: "custom",
|
|
47844
|
-
input,
|
|
48565
|
+
input: input2,
|
|
47845
48566
|
inst
|
|
47846
48567
|
};
|
|
47847
48568
|
}
|
|
@@ -48145,22 +48866,22 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
48145
48866
|
bag.pattern = integer;
|
|
48146
48867
|
});
|
|
48147
48868
|
inst._zod.check = (payload) => {
|
|
48148
|
-
const
|
|
48869
|
+
const input2 = payload.value;
|
|
48149
48870
|
if (isInt) {
|
|
48150
|
-
if (!Number.isInteger(
|
|
48871
|
+
if (!Number.isInteger(input2)) {
|
|
48151
48872
|
payload.issues.push({
|
|
48152
48873
|
expected: origin,
|
|
48153
48874
|
format: def.format,
|
|
48154
48875
|
code: "invalid_type",
|
|
48155
|
-
input,
|
|
48876
|
+
input: input2,
|
|
48156
48877
|
inst
|
|
48157
48878
|
});
|
|
48158
48879
|
return;
|
|
48159
48880
|
}
|
|
48160
|
-
if (!Number.isSafeInteger(
|
|
48161
|
-
if (
|
|
48881
|
+
if (!Number.isSafeInteger(input2)) {
|
|
48882
|
+
if (input2 > 0) {
|
|
48162
48883
|
payload.issues.push({
|
|
48163
|
-
input,
|
|
48884
|
+
input: input2,
|
|
48164
48885
|
code: "too_big",
|
|
48165
48886
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
48166
48887
|
note: "Integers must be within the safe integer range.",
|
|
@@ -48170,7 +48891,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
48170
48891
|
});
|
|
48171
48892
|
} else {
|
|
48172
48893
|
payload.issues.push({
|
|
48173
|
-
input,
|
|
48894
|
+
input: input2,
|
|
48174
48895
|
code: "too_small",
|
|
48175
48896
|
minimum: Number.MIN_SAFE_INTEGER,
|
|
48176
48897
|
note: "Integers must be within the safe integer range.",
|
|
@@ -48182,10 +48903,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
48182
48903
|
return;
|
|
48183
48904
|
}
|
|
48184
48905
|
}
|
|
48185
|
-
if (
|
|
48906
|
+
if (input2 < minimum) {
|
|
48186
48907
|
payload.issues.push({
|
|
48187
48908
|
origin: "number",
|
|
48188
|
-
input,
|
|
48909
|
+
input: input2,
|
|
48189
48910
|
code: "too_small",
|
|
48190
48911
|
minimum,
|
|
48191
48912
|
inclusive: true,
|
|
@@ -48193,10 +48914,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
|
|
|
48193
48914
|
continue: !def.abort
|
|
48194
48915
|
});
|
|
48195
48916
|
}
|
|
48196
|
-
if (
|
|
48917
|
+
if (input2 > maximum) {
|
|
48197
48918
|
payload.issues.push({
|
|
48198
48919
|
origin: "number",
|
|
48199
|
-
input,
|
|
48920
|
+
input: input2,
|
|
48200
48921
|
code: "too_big",
|
|
48201
48922
|
maximum,
|
|
48202
48923
|
inst
|
|
@@ -48217,17 +48938,17 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
|
|
|
48217
48938
|
inst2._zod.bag.maximum = def.maximum;
|
|
48218
48939
|
});
|
|
48219
48940
|
inst._zod.check = (payload) => {
|
|
48220
|
-
const
|
|
48221
|
-
const length2 =
|
|
48941
|
+
const input2 = payload.value;
|
|
48942
|
+
const length2 = input2.length;
|
|
48222
48943
|
if (length2 <= def.maximum)
|
|
48223
48944
|
return;
|
|
48224
|
-
const origin = getLengthableOrigin(
|
|
48945
|
+
const origin = getLengthableOrigin(input2);
|
|
48225
48946
|
payload.issues.push({
|
|
48226
48947
|
origin,
|
|
48227
48948
|
code: "too_big",
|
|
48228
48949
|
maximum: def.maximum,
|
|
48229
48950
|
inclusive: true,
|
|
48230
|
-
input,
|
|
48951
|
+
input: input2,
|
|
48231
48952
|
inst,
|
|
48232
48953
|
continue: !def.abort
|
|
48233
48954
|
});
|
|
@@ -48246,17 +48967,17 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
|
|
|
48246
48967
|
inst2._zod.bag.minimum = def.minimum;
|
|
48247
48968
|
});
|
|
48248
48969
|
inst._zod.check = (payload) => {
|
|
48249
|
-
const
|
|
48250
|
-
const length2 =
|
|
48970
|
+
const input2 = payload.value;
|
|
48971
|
+
const length2 = input2.length;
|
|
48251
48972
|
if (length2 >= def.minimum)
|
|
48252
48973
|
return;
|
|
48253
|
-
const origin = getLengthableOrigin(
|
|
48974
|
+
const origin = getLengthableOrigin(input2);
|
|
48254
48975
|
payload.issues.push({
|
|
48255
48976
|
origin,
|
|
48256
48977
|
code: "too_small",
|
|
48257
48978
|
minimum: def.minimum,
|
|
48258
48979
|
inclusive: true,
|
|
48259
|
-
input,
|
|
48980
|
+
input: input2,
|
|
48260
48981
|
inst,
|
|
48261
48982
|
continue: !def.abort
|
|
48262
48983
|
});
|
|
@@ -48276,11 +48997,11 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
|
|
|
48276
48997
|
bag.length = def.length;
|
|
48277
48998
|
});
|
|
48278
48999
|
inst._zod.check = (payload) => {
|
|
48279
|
-
const
|
|
48280
|
-
const length2 =
|
|
49000
|
+
const input2 = payload.value;
|
|
49001
|
+
const length2 = input2.length;
|
|
48281
49002
|
if (length2 === def.length)
|
|
48282
49003
|
return;
|
|
48283
|
-
const origin = getLengthableOrigin(
|
|
49004
|
+
const origin = getLengthableOrigin(input2);
|
|
48284
49005
|
const tooBig = length2 > def.length;
|
|
48285
49006
|
payload.issues.push({
|
|
48286
49007
|
origin,
|
|
@@ -48861,15 +49582,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
48861
49582
|
payload.value = Number(payload.value);
|
|
48862
49583
|
} catch (_2) {
|
|
48863
49584
|
}
|
|
48864
|
-
const
|
|
48865
|
-
if (typeof
|
|
49585
|
+
const input2 = payload.value;
|
|
49586
|
+
if (typeof input2 === "number" && !Number.isNaN(input2) && Number.isFinite(input2)) {
|
|
48866
49587
|
return payload;
|
|
48867
49588
|
}
|
|
48868
|
-
const received = typeof
|
|
49589
|
+
const received = typeof input2 === "number" ? Number.isNaN(input2) ? "NaN" : !Number.isFinite(input2) ? "Infinity" : void 0 : void 0;
|
|
48869
49590
|
payload.issues.push({
|
|
48870
49591
|
expected: "number",
|
|
48871
49592
|
code: "invalid_type",
|
|
48872
|
-
input,
|
|
49593
|
+
input: input2,
|
|
48873
49594
|
inst,
|
|
48874
49595
|
...received ? { received } : {}
|
|
48875
49596
|
});
|
|
@@ -48889,13 +49610,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
48889
49610
|
payload.value = Boolean(payload.value);
|
|
48890
49611
|
} catch (_2) {
|
|
48891
49612
|
}
|
|
48892
|
-
const
|
|
48893
|
-
if (typeof
|
|
49613
|
+
const input2 = payload.value;
|
|
49614
|
+
if (typeof input2 === "boolean")
|
|
48894
49615
|
return payload;
|
|
48895
49616
|
payload.issues.push({
|
|
48896
49617
|
expected: "boolean",
|
|
48897
49618
|
code: "invalid_type",
|
|
48898
|
-
input,
|
|
49619
|
+
input: input2,
|
|
48899
49620
|
inst
|
|
48900
49621
|
});
|
|
48901
49622
|
return payload;
|
|
@@ -48906,13 +49627,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
|
48906
49627
|
inst._zod.pattern = _null;
|
|
48907
49628
|
inst._zod.values = /* @__PURE__ */ new Set([null]);
|
|
48908
49629
|
inst._zod.parse = (payload, _ctx) => {
|
|
48909
|
-
const
|
|
48910
|
-
if (
|
|
49630
|
+
const input2 = payload.value;
|
|
49631
|
+
if (input2 === null)
|
|
48911
49632
|
return payload;
|
|
48912
49633
|
payload.issues.push({
|
|
48913
49634
|
expected: "null",
|
|
48914
49635
|
code: "invalid_type",
|
|
48915
|
-
input,
|
|
49636
|
+
input: input2,
|
|
48916
49637
|
inst
|
|
48917
49638
|
});
|
|
48918
49639
|
return payload;
|
|
@@ -48943,20 +49664,20 @@ function handleArrayResult(result, final, index) {
|
|
|
48943
49664
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
48944
49665
|
$ZodType.init(inst, def);
|
|
48945
49666
|
inst._zod.parse = (payload, ctx) => {
|
|
48946
|
-
const
|
|
48947
|
-
if (!Array.isArray(
|
|
49667
|
+
const input2 = payload.value;
|
|
49668
|
+
if (!Array.isArray(input2)) {
|
|
48948
49669
|
payload.issues.push({
|
|
48949
49670
|
expected: "array",
|
|
48950
49671
|
code: "invalid_type",
|
|
48951
|
-
input,
|
|
49672
|
+
input: input2,
|
|
48952
49673
|
inst
|
|
48953
49674
|
});
|
|
48954
49675
|
return payload;
|
|
48955
49676
|
}
|
|
48956
|
-
payload.value = Array(
|
|
49677
|
+
payload.value = Array(input2.length);
|
|
48957
49678
|
const proms = [];
|
|
48958
|
-
for (let i2 = 0; i2 <
|
|
48959
|
-
const item =
|
|
49679
|
+
for (let i2 = 0; i2 < input2.length; i2++) {
|
|
49680
|
+
const item = input2[i2];
|
|
48960
49681
|
const result = def.element._zod.run({
|
|
48961
49682
|
value: item,
|
|
48962
49683
|
issues: []
|
|
@@ -48979,10 +49700,10 @@ function handleObjectResult(result, final, key) {
|
|
|
48979
49700
|
}
|
|
48980
49701
|
final.value[key] = result.value;
|
|
48981
49702
|
}
|
|
48982
|
-
function handleOptionalObjectResult(result, final, key,
|
|
49703
|
+
function handleOptionalObjectResult(result, final, key, input2) {
|
|
48983
49704
|
if (result.issues.length) {
|
|
48984
|
-
if (
|
|
48985
|
-
if (key in
|
|
49705
|
+
if (input2[key] === void 0) {
|
|
49706
|
+
if (key in input2) {
|
|
48986
49707
|
final.value[key] = void 0;
|
|
48987
49708
|
} else {
|
|
48988
49709
|
final.value[key] = result.value;
|
|
@@ -48991,7 +49712,7 @@ function handleOptionalObjectResult(result, final, key, input) {
|
|
|
48991
49712
|
final.issues.push(...prefixIssues(key, result.issues));
|
|
48992
49713
|
}
|
|
48993
49714
|
} else if (result.value === void 0) {
|
|
48994
|
-
if (key in
|
|
49715
|
+
if (key in input2)
|
|
48995
49716
|
final.value[key] = void 0;
|
|
48996
49717
|
} else {
|
|
48997
49718
|
final.value[key] = result.value;
|
|
@@ -49092,12 +49813,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49092
49813
|
let value;
|
|
49093
49814
|
inst._zod.parse = (payload, ctx) => {
|
|
49094
49815
|
value ?? (value = _normalized.value);
|
|
49095
|
-
const
|
|
49096
|
-
if (!isObject2(
|
|
49816
|
+
const input2 = payload.value;
|
|
49817
|
+
if (!isObject2(input2)) {
|
|
49097
49818
|
payload.issues.push({
|
|
49098
49819
|
expected: "object",
|
|
49099
49820
|
code: "invalid_type",
|
|
49100
|
-
input,
|
|
49821
|
+
input: input2,
|
|
49101
49822
|
inst
|
|
49102
49823
|
});
|
|
49103
49824
|
return payload;
|
|
@@ -49112,12 +49833,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49112
49833
|
const shape = value.shape;
|
|
49113
49834
|
for (const key of value.keys) {
|
|
49114
49835
|
const el = shape[key];
|
|
49115
|
-
const r3 = el._zod.run({ value:
|
|
49836
|
+
const r3 = el._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
49116
49837
|
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
49117
49838
|
if (r3 instanceof Promise) {
|
|
49118
|
-
proms.push(r3.then((r4) => isOptional ? handleOptionalObjectResult(r4, payload, key,
|
|
49839
|
+
proms.push(r3.then((r4) => isOptional ? handleOptionalObjectResult(r4, payload, key, input2) : handleObjectResult(r4, payload, key)));
|
|
49119
49840
|
} else if (isOptional) {
|
|
49120
|
-
handleOptionalObjectResult(r3, payload, key,
|
|
49841
|
+
handleOptionalObjectResult(r3, payload, key, input2);
|
|
49121
49842
|
} else {
|
|
49122
49843
|
handleObjectResult(r3, payload, key);
|
|
49123
49844
|
}
|
|
@@ -49130,14 +49851,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49130
49851
|
const keySet = value.keySet;
|
|
49131
49852
|
const _catchall = catchall._zod;
|
|
49132
49853
|
const t = _catchall.def.type;
|
|
49133
|
-
for (const key of Object.keys(
|
|
49854
|
+
for (const key of Object.keys(input2)) {
|
|
49134
49855
|
if (keySet.has(key))
|
|
49135
49856
|
continue;
|
|
49136
49857
|
if (t === "never") {
|
|
49137
49858
|
unrecognized.push(key);
|
|
49138
49859
|
continue;
|
|
49139
49860
|
}
|
|
49140
|
-
const r3 = _catchall.run({ value:
|
|
49861
|
+
const r3 = _catchall.run({ value: input2[key], issues: [] }, ctx);
|
|
49141
49862
|
if (r3 instanceof Promise) {
|
|
49142
49863
|
proms.push(r3.then((r4) => handleObjectResult(r4, payload, key)));
|
|
49143
49864
|
} else {
|
|
@@ -49148,7 +49869,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
49148
49869
|
payload.issues.push({
|
|
49149
49870
|
code: "unrecognized_keys",
|
|
49150
49871
|
keys: unrecognized,
|
|
49151
|
-
input,
|
|
49872
|
+
input: input2,
|
|
49152
49873
|
inst
|
|
49153
49874
|
});
|
|
49154
49875
|
}
|
|
@@ -49251,17 +49972,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
49251
49972
|
return map;
|
|
49252
49973
|
});
|
|
49253
49974
|
inst._zod.parse = (payload, ctx) => {
|
|
49254
|
-
const
|
|
49255
|
-
if (!isObject(
|
|
49975
|
+
const input2 = payload.value;
|
|
49976
|
+
if (!isObject(input2)) {
|
|
49256
49977
|
payload.issues.push({
|
|
49257
49978
|
code: "invalid_type",
|
|
49258
49979
|
expected: "object",
|
|
49259
|
-
input,
|
|
49980
|
+
input: input2,
|
|
49260
49981
|
inst
|
|
49261
49982
|
});
|
|
49262
49983
|
return payload;
|
|
49263
49984
|
}
|
|
49264
|
-
const opt = disc.value.get(
|
|
49985
|
+
const opt = disc.value.get(input2?.[def.discriminator]);
|
|
49265
49986
|
if (opt) {
|
|
49266
49987
|
return opt._zod.run(payload, ctx);
|
|
49267
49988
|
}
|
|
@@ -49272,7 +49993,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
49272
49993
|
code: "invalid_union",
|
|
49273
49994
|
errors: [],
|
|
49274
49995
|
note: "No matching discriminator",
|
|
49275
|
-
input,
|
|
49996
|
+
input: input2,
|
|
49276
49997
|
path: [def.discriminator],
|
|
49277
49998
|
inst
|
|
49278
49999
|
});
|
|
@@ -49282,9 +50003,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
49282
50003
|
var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
49283
50004
|
$ZodType.init(inst, def);
|
|
49284
50005
|
inst._zod.parse = (payload, ctx) => {
|
|
49285
|
-
const
|
|
49286
|
-
const left = def.left._zod.run({ value:
|
|
49287
|
-
const right = def.right._zod.run({ value:
|
|
50006
|
+
const input2 = payload.value;
|
|
50007
|
+
const left = def.left._zod.run({ value: input2, issues: [] }, ctx);
|
|
50008
|
+
const right = def.right._zod.run({ value: input2, issues: [] }, ctx);
|
|
49288
50009
|
const async = left instanceof Promise || right instanceof Promise;
|
|
49289
50010
|
if (async) {
|
|
49290
50011
|
return Promise.all([left, right]).then(([left2, right2]) => {
|
|
@@ -49357,12 +50078,12 @@ function handleIntersectionResults(result, left, right) {
|
|
|
49357
50078
|
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
49358
50079
|
$ZodType.init(inst, def);
|
|
49359
50080
|
inst._zod.parse = (payload, ctx) => {
|
|
49360
|
-
const
|
|
49361
|
-
if (!isPlainObject(
|
|
50081
|
+
const input2 = payload.value;
|
|
50082
|
+
if (!isPlainObject(input2)) {
|
|
49362
50083
|
payload.issues.push({
|
|
49363
50084
|
expected: "record",
|
|
49364
50085
|
code: "invalid_type",
|
|
49365
|
-
input,
|
|
50086
|
+
input: input2,
|
|
49366
50087
|
inst
|
|
49367
50088
|
});
|
|
49368
50089
|
return payload;
|
|
@@ -49373,7 +50094,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
49373
50094
|
payload.value = {};
|
|
49374
50095
|
for (const key of values) {
|
|
49375
50096
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
49376
|
-
const result = def.valueType._zod.run({ value:
|
|
50097
|
+
const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
49377
50098
|
if (result instanceof Promise) {
|
|
49378
50099
|
proms.push(result.then((result2) => {
|
|
49379
50100
|
if (result2.issues.length) {
|
|
@@ -49390,7 +50111,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
49390
50111
|
}
|
|
49391
50112
|
}
|
|
49392
50113
|
let unrecognized;
|
|
49393
|
-
for (const key in
|
|
50114
|
+
for (const key in input2) {
|
|
49394
50115
|
if (!values.has(key)) {
|
|
49395
50116
|
unrecognized = unrecognized ?? [];
|
|
49396
50117
|
unrecognized.push(key);
|
|
@@ -49399,14 +50120,14 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
49399
50120
|
if (unrecognized && unrecognized.length > 0) {
|
|
49400
50121
|
payload.issues.push({
|
|
49401
50122
|
code: "unrecognized_keys",
|
|
49402
|
-
input,
|
|
50123
|
+
input: input2,
|
|
49403
50124
|
inst,
|
|
49404
50125
|
keys: unrecognized
|
|
49405
50126
|
});
|
|
49406
50127
|
}
|
|
49407
50128
|
} else {
|
|
49408
50129
|
payload.value = {};
|
|
49409
|
-
for (const key of Reflect.ownKeys(
|
|
50130
|
+
for (const key of Reflect.ownKeys(input2)) {
|
|
49410
50131
|
if (key === "__proto__")
|
|
49411
50132
|
continue;
|
|
49412
50133
|
const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
@@ -49425,7 +50146,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
49425
50146
|
payload.value[keyResult.value] = keyResult.value;
|
|
49426
50147
|
continue;
|
|
49427
50148
|
}
|
|
49428
|
-
const result = def.valueType._zod.run({ value:
|
|
50149
|
+
const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
|
|
49429
50150
|
if (result instanceof Promise) {
|
|
49430
50151
|
proms.push(result.then((result2) => {
|
|
49431
50152
|
if (result2.issues.length) {
|
|
@@ -49453,14 +50174,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
49453
50174
|
inst._zod.values = new Set(values);
|
|
49454
50175
|
inst._zod.pattern = new RegExp(`^(${values.filter((k4) => propertyKeyTypes.has(typeof k4)).map((o4) => typeof o4 === "string" ? escapeRegex(o4) : o4.toString()).join("|")})$`);
|
|
49455
50176
|
inst._zod.parse = (payload, _ctx) => {
|
|
49456
|
-
const
|
|
49457
|
-
if (inst._zod.values.has(
|
|
50177
|
+
const input2 = payload.value;
|
|
50178
|
+
if (inst._zod.values.has(input2)) {
|
|
49458
50179
|
return payload;
|
|
49459
50180
|
}
|
|
49460
50181
|
payload.issues.push({
|
|
49461
50182
|
code: "invalid_value",
|
|
49462
50183
|
values,
|
|
49463
|
-
input,
|
|
50184
|
+
input: input2,
|
|
49464
50185
|
inst
|
|
49465
50186
|
});
|
|
49466
50187
|
return payload;
|
|
@@ -49471,14 +50192,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
49471
50192
|
inst._zod.values = new Set(def.values);
|
|
49472
50193
|
inst._zod.pattern = new RegExp(`^(${def.values.map((o4) => typeof o4 === "string" ? escapeRegex(o4) : o4 ? o4.toString() : String(o4)).join("|")})$`);
|
|
49473
50194
|
inst._zod.parse = (payload, _ctx) => {
|
|
49474
|
-
const
|
|
49475
|
-
if (inst._zod.values.has(
|
|
50195
|
+
const input2 = payload.value;
|
|
50196
|
+
if (inst._zod.values.has(input2)) {
|
|
49476
50197
|
return payload;
|
|
49477
50198
|
}
|
|
49478
50199
|
payload.issues.push({
|
|
49479
50200
|
code: "invalid_value",
|
|
49480
50201
|
values: def.values,
|
|
49481
|
-
input,
|
|
50202
|
+
input: input2,
|
|
49482
50203
|
inst
|
|
49483
50204
|
});
|
|
49484
50205
|
return payload;
|
|
@@ -49679,20 +50400,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
|
49679
50400
|
return payload;
|
|
49680
50401
|
};
|
|
49681
50402
|
inst._zod.check = (payload) => {
|
|
49682
|
-
const
|
|
49683
|
-
const r3 = def.fn(
|
|
50403
|
+
const input2 = payload.value;
|
|
50404
|
+
const r3 = def.fn(input2);
|
|
49684
50405
|
if (r3 instanceof Promise) {
|
|
49685
|
-
return r3.then((r4) => handleRefineResult(r4, payload,
|
|
50406
|
+
return r3.then((r4) => handleRefineResult(r4, payload, input2, inst));
|
|
49686
50407
|
}
|
|
49687
|
-
handleRefineResult(r3, payload,
|
|
50408
|
+
handleRefineResult(r3, payload, input2, inst);
|
|
49688
50409
|
return;
|
|
49689
50410
|
};
|
|
49690
50411
|
});
|
|
49691
|
-
function handleRefineResult(result, payload,
|
|
50412
|
+
function handleRefineResult(result, payload, input2, inst) {
|
|
49692
50413
|
if (!result) {
|
|
49693
50414
|
const _iss = {
|
|
49694
50415
|
code: "custom",
|
|
49695
|
-
input,
|
|
50416
|
+
input: input2,
|
|
49696
50417
|
inst,
|
|
49697
50418
|
// incorporates params.error into issue reporting
|
|
49698
50419
|
path: [...inst._zod.def.path ?? []],
|
|
@@ -50269,16 +50990,16 @@ function _overwrite(tx) {
|
|
|
50269
50990
|
});
|
|
50270
50991
|
}
|
|
50271
50992
|
function _normalize(form) {
|
|
50272
|
-
return _overwrite((
|
|
50993
|
+
return _overwrite((input2) => input2.normalize(form));
|
|
50273
50994
|
}
|
|
50274
50995
|
function _trim() {
|
|
50275
|
-
return _overwrite((
|
|
50996
|
+
return _overwrite((input2) => input2.trim());
|
|
50276
50997
|
}
|
|
50277
50998
|
function _toLowerCase() {
|
|
50278
|
-
return _overwrite((
|
|
50999
|
+
return _overwrite((input2) => input2.toLowerCase());
|
|
50279
51000
|
}
|
|
50280
51001
|
function _toUpperCase() {
|
|
50281
|
-
return _overwrite((
|
|
51002
|
+
return _overwrite((input2) => input2.toUpperCase());
|
|
50282
51003
|
}
|
|
50283
51004
|
function _array(Class2, element, params) {
|
|
50284
51005
|
return new Class2({
|
|
@@ -54882,12 +55603,12 @@ var AjvJsonSchemaValidator = class {
|
|
|
54882
55603
|
*/
|
|
54883
55604
|
getValidator(schema) {
|
|
54884
55605
|
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
54885
|
-
return (
|
|
54886
|
-
const valid = ajvValidator(
|
|
55606
|
+
return (input2) => {
|
|
55607
|
+
const valid = ajvValidator(input2);
|
|
54887
55608
|
if (valid) {
|
|
54888
55609
|
return {
|
|
54889
55610
|
valid: true,
|
|
54890
|
-
data:
|
|
55611
|
+
data: input2,
|
|
54891
55612
|
errorMessage: void 0
|
|
54892
55613
|
};
|
|
54893
55614
|
} else {
|
|
@@ -56114,8 +56835,8 @@ function registerServeCommand(program3) {
|
|
|
56114
56835
|
const blockchainClient = new BlockchainClient();
|
|
56115
56836
|
let agentWallet;
|
|
56116
56837
|
try {
|
|
56117
|
-
const
|
|
56118
|
-
if (
|
|
56838
|
+
const password2 = opts.password || process.env.TWAK_WALLET_PASSWORD || await new KeychainManager().getWalletPassword();
|
|
56839
|
+
if (password2) agentWallet = await AgentWalletProvider.fromStorage(password2);
|
|
56119
56840
|
} catch {
|
|
56120
56841
|
}
|
|
56121
56842
|
let wallet;
|
|
@@ -56196,7 +56917,7 @@ function registerServeCommand(program3) {
|
|
|
56196
56917
|
}
|
|
56197
56918
|
|
|
56198
56919
|
// src/commands/onramp.ts
|
|
56199
|
-
var
|
|
56920
|
+
var import_chalk8 = __toESM(require_source());
|
|
56200
56921
|
init_dist();
|
|
56201
56922
|
var DEFAULT_MAX_OFFRAMP_USD2 = 1e4;
|
|
56202
56923
|
function fmtVsBest(pct) {
|
|
@@ -56220,7 +56941,7 @@ function printBuyQuoteTable(rows, fiatAmount, fiatCurrency, asset) {
|
|
|
56220
56941
|
console.log(`${rows.length} quotes for ${fiatAmount} ${fiatCurrency} \u2192 ${cryptoCurrency}
|
|
56221
56942
|
`);
|
|
56222
56943
|
console.log(
|
|
56223
|
-
|
|
56944
|
+
import_chalk8.default.bold(
|
|
56224
56945
|
`${"PROVIDER".padEnd(w4.provider)} ${"PAY".padEnd(w4.pay)} ${"RECEIVE".padEnd(w4.receive)} ${"VS BEST".padEnd(w4.vsBest)} QUOTE ID`
|
|
56225
56946
|
)
|
|
56226
56947
|
);
|
|
@@ -56232,7 +56953,7 @@ function printBuyQuoteTable(rows, fiatAmount, fiatCurrency, asset) {
|
|
|
56232
56953
|
const best = rows[0];
|
|
56233
56954
|
console.log(
|
|
56234
56955
|
`
|
|
56235
|
-
\u2192 best: ${
|
|
56956
|
+
\u2192 best: ${import_chalk8.default.bold(best.provider ?? "")} \u2014 run: ${import_chalk8.default.bold(`twak onramp buy --quote-id ${best.quoteId} --asset ${asset}`)}`
|
|
56236
56957
|
);
|
|
56237
56958
|
}
|
|
56238
56959
|
function printSellQuoteTable(rows, cryptoAmount, cryptoAsset) {
|
|
@@ -56253,7 +56974,7 @@ function printSellQuoteTable(rows, cryptoAmount, cryptoAsset) {
|
|
|
56253
56974
|
console.log(`${rows.length} quotes for ${cryptoAmount} ${cryptoAsset} \u2192 ${fiatCurrency}
|
|
56254
56975
|
`);
|
|
56255
56976
|
console.log(
|
|
56256
|
-
|
|
56977
|
+
import_chalk8.default.bold(
|
|
56257
56978
|
`${"PROVIDER".padEnd(w4.provider)} ${"PAY".padEnd(w4.pay)} ${"RECEIVE".padEnd(w4.receive)} ${"VS BEST".padEnd(w4.vsBest)} QUOTE ID`
|
|
56258
56979
|
)
|
|
56259
56980
|
);
|
|
@@ -56265,7 +56986,7 @@ function printSellQuoteTable(rows, cryptoAmount, cryptoAsset) {
|
|
|
56265
56986
|
const best = rows[0];
|
|
56266
56987
|
console.log(
|
|
56267
56988
|
`
|
|
56268
|
-
\u2192 best: ${
|
|
56989
|
+
\u2192 best: ${import_chalk8.default.bold(best.provider ?? "")} \u2014 run: ${import_chalk8.default.bold(`twak onramp sell --quote-id ${best.quoteId} --asset ${cryptoAsset}`)}`
|
|
56269
56990
|
);
|
|
56270
56991
|
}
|
|
56271
56992
|
async function resolveWalletAddress(opts, context) {
|
|
@@ -56287,8 +57008,8 @@ async function resolveWalletAddress(opts, context) {
|
|
|
56287
57008
|
);
|
|
56288
57009
|
}
|
|
56289
57010
|
await ensureTrustSDK();
|
|
56290
|
-
const
|
|
56291
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
57011
|
+
const password2 = await resolvePassword({ password: opts.password });
|
|
57012
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
56292
57013
|
const address = await provider.getAddress(chainKey);
|
|
56293
57014
|
info(`Using ${context} address ${address} on ${chainKey} (derived from your stored wallet).`);
|
|
56294
57015
|
return address;
|
|
@@ -56508,8 +57229,8 @@ ${url}`);
|
|
|
56508
57229
|
).option("--json", "JSON output").action(async (opts) => {
|
|
56509
57230
|
try {
|
|
56510
57231
|
await ensureTrustSDK();
|
|
56511
|
-
const
|
|
56512
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
57232
|
+
const password2 = await resolvePassword({ password: opts.password });
|
|
57233
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
56513
57234
|
let coinId;
|
|
56514
57235
|
try {
|
|
56515
57236
|
({ coinId } = parseTokenId(opts.asset));
|
|
@@ -56908,8 +57629,8 @@ function registerX402Command(program3) {
|
|
|
56908
57629
|
try {
|
|
56909
57630
|
await validateX402Url(url);
|
|
56910
57631
|
await ensureTrustSDK();
|
|
56911
|
-
const
|
|
56912
|
-
const provider = await AgentWalletProvider.fromStorage(
|
|
57632
|
+
const password2 = await resolvePassword3(opts);
|
|
57633
|
+
const provider = await AgentWalletProvider.fromStorage(password2);
|
|
56913
57634
|
const init3 = {
|
|
56914
57635
|
method: opts.method.toUpperCase(),
|
|
56915
57636
|
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
@@ -57028,12 +57749,12 @@ Confirm? [y/N] `,
|
|
|
57028
57749
|
var fs6 = __toESM(require("fs"));
|
|
57029
57750
|
var os4 = __toESM(require("os"));
|
|
57030
57751
|
var path4 = __toESM(require("path"));
|
|
57031
|
-
var
|
|
57752
|
+
var crypto7 = __toESM(require("crypto"));
|
|
57032
57753
|
|
|
57033
57754
|
// package.json
|
|
57034
57755
|
var package_default = {
|
|
57035
57756
|
name: "@trustwallet/cli",
|
|
57036
|
-
version: "0.
|
|
57757
|
+
version: "0.12.0",
|
|
57037
57758
|
description: "TWAK CLI \u2014 command-line interface for Trust Wallet Agent Kit",
|
|
57038
57759
|
main: "dist/index.js",
|
|
57039
57760
|
types: "dist/index.d.ts",
|
|
@@ -57054,20 +57775,18 @@ var package_default = {
|
|
|
57054
57775
|
clean: "rm -rf dist"
|
|
57055
57776
|
},
|
|
57056
57777
|
dependencies: {
|
|
57778
|
+
"@iarna/toml": "2.2.5",
|
|
57779
|
+
"@inquirer/prompts": "8.4.3",
|
|
57780
|
+
"@napi-rs/keyring": "1.2.0",
|
|
57781
|
+
"fake-indexeddb": "6.2.5",
|
|
57057
57782
|
"node-fetch": "2.7.0",
|
|
57058
57783
|
qrcode: "1.5.4",
|
|
57059
|
-
"qrcode-terminal": "0.12.0"
|
|
57060
|
-
"@napi-rs/keyring": "1.2.0",
|
|
57061
|
-
"fake-indexeddb": "6.2.5"
|
|
57784
|
+
"qrcode-terminal": "0.12.0"
|
|
57062
57785
|
},
|
|
57063
57786
|
optionalDependencies: {
|
|
57064
57787
|
"@amplitude/analytics-node": "1.5.39"
|
|
57065
57788
|
},
|
|
57066
57789
|
devDependencies: {
|
|
57067
|
-
boxen: "5.1.2",
|
|
57068
|
-
chalk: "4.1.2",
|
|
57069
|
-
commander: "12.1.0",
|
|
57070
|
-
ora: "5.4.1",
|
|
57071
57790
|
"@twak/actions": "workspace:*",
|
|
57072
57791
|
"@twak/blockchain": "workspace:*",
|
|
57073
57792
|
"@twak/core": "workspace:*",
|
|
@@ -57079,6 +57798,10 @@ var package_default = {
|
|
|
57079
57798
|
"@twak/wallet": "workspace:*",
|
|
57080
57799
|
"@twak/wallet-core": "workspace:*",
|
|
57081
57800
|
"@twak/walletconnect": "workspace:*",
|
|
57801
|
+
boxen: "5.1.2",
|
|
57802
|
+
chalk: "4.1.2",
|
|
57803
|
+
commander: "12.1.0",
|
|
57804
|
+
ora: "5.4.1",
|
|
57082
57805
|
tsup: "8.5.1",
|
|
57083
57806
|
typescript: "5.7.3",
|
|
57084
57807
|
vitest: "4.1.2"
|
|
@@ -57137,7 +57860,7 @@ function getUserId() {
|
|
|
57137
57860
|
if (fs6.existsSync(ID_FILE)) return fs6.readFileSync(ID_FILE, "utf-8").trim();
|
|
57138
57861
|
} catch (_e6) {
|
|
57139
57862
|
}
|
|
57140
|
-
const id =
|
|
57863
|
+
const id = crypto7.randomUUID();
|
|
57141
57864
|
try {
|
|
57142
57865
|
fs6.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
57143
57866
|
fs6.writeFileSync(ID_FILE, id);
|
|
@@ -57239,8 +57962,8 @@ function registerWatchCommand(program3) {
|
|
|
57239
57962
|
swapClient = new SwapClient(client);
|
|
57240
57963
|
if (!opts.dryRun) {
|
|
57241
57964
|
await ensureTrustSDK();
|
|
57242
|
-
const
|
|
57243
|
-
provider = await AgentWalletProvider.fromStorage(
|
|
57965
|
+
const password2 = await resolvePassword(opts);
|
|
57966
|
+
provider = await AgentWalletProvider.fromStorage(password2);
|
|
57244
57967
|
if (opts.autoLock) {
|
|
57245
57968
|
const minutes = parseInt(opts.autoLock, 10);
|
|
57246
57969
|
if (isNaN(minutes) || minutes <= 0) {
|
|
@@ -57536,6 +58259,7 @@ program2.name("twak").description("Trust Wallet Agent \u2014 AI-powered multicha
|
|
|
57536
58259
|
return "";
|
|
57537
58260
|
});
|
|
57538
58261
|
registerInitCommand(program2);
|
|
58262
|
+
registerSetupCommand(program2);
|
|
57539
58263
|
registerAuthCommand(program2);
|
|
57540
58264
|
registerWalletCommand(program2);
|
|
57541
58265
|
registerTransferCommand(program2);
|