@vultisig/cli 4.6.0 → 4.7.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/index.js +1746 -115
  3. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1111,6 +1111,853 @@ var require_main = __commonJS({
1111
1111
  }
1112
1112
  });
1113
1113
 
1114
+ // ../../node_modules/abitype/dist/esm/version.js
1115
+ var version;
1116
+ var init_version = __esm({
1117
+ "../../node_modules/abitype/dist/esm/version.js"() {
1118
+ version = "1.2.3";
1119
+ }
1120
+ });
1121
+
1122
+ // ../../node_modules/abitype/dist/esm/errors.js
1123
+ var BaseError;
1124
+ var init_errors = __esm({
1125
+ "../../node_modules/abitype/dist/esm/errors.js"() {
1126
+ init_version();
1127
+ BaseError = class _BaseError extends Error {
1128
+ constructor(shortMessage, args = {}) {
1129
+ const details = args.cause instanceof _BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
1130
+ const docsPath = args.cause instanceof _BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
1131
+ const message = [
1132
+ shortMessage || "An error occurred.",
1133
+ "",
1134
+ ...args.metaMessages ? [...args.metaMessages, ""] : [],
1135
+ ...docsPath ? [`Docs: https://abitype.dev${docsPath}`] : [],
1136
+ ...details ? [`Details: ${details}`] : [],
1137
+ `Version: abitype@${version}`
1138
+ ].join("\n");
1139
+ super(message);
1140
+ Object.defineProperty(this, "details", {
1141
+ enumerable: true,
1142
+ configurable: true,
1143
+ writable: true,
1144
+ value: void 0
1145
+ });
1146
+ Object.defineProperty(this, "docsPath", {
1147
+ enumerable: true,
1148
+ configurable: true,
1149
+ writable: true,
1150
+ value: void 0
1151
+ });
1152
+ Object.defineProperty(this, "metaMessages", {
1153
+ enumerable: true,
1154
+ configurable: true,
1155
+ writable: true,
1156
+ value: void 0
1157
+ });
1158
+ Object.defineProperty(this, "shortMessage", {
1159
+ enumerable: true,
1160
+ configurable: true,
1161
+ writable: true,
1162
+ value: void 0
1163
+ });
1164
+ Object.defineProperty(this, "name", {
1165
+ enumerable: true,
1166
+ configurable: true,
1167
+ writable: true,
1168
+ value: "AbiTypeError"
1169
+ });
1170
+ if (args.cause)
1171
+ this.cause = args.cause;
1172
+ this.details = details;
1173
+ this.docsPath = docsPath;
1174
+ this.metaMessages = args.metaMessages;
1175
+ this.shortMessage = shortMessage;
1176
+ }
1177
+ };
1178
+ }
1179
+ });
1180
+
1181
+ // ../../node_modules/abitype/dist/esm/regex.js
1182
+ function execTyped(regex, string) {
1183
+ const match = regex.exec(string);
1184
+ return match?.groups;
1185
+ }
1186
+ var bytesRegex, integerRegex, isTupleRegex;
1187
+ var init_regex = __esm({
1188
+ "../../node_modules/abitype/dist/esm/regex.js"() {
1189
+ bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
1190
+ integerRegex = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
1191
+ isTupleRegex = /^\(.+?\).*?$/;
1192
+ }
1193
+ });
1194
+
1195
+ // ../../node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js
1196
+ function formatAbiParameter(abiParameter) {
1197
+ let type = abiParameter.type;
1198
+ if (tupleRegex.test(abiParameter.type) && "components" in abiParameter) {
1199
+ type = "(";
1200
+ const length = abiParameter.components.length;
1201
+ for (let i = 0; i < length; i++) {
1202
+ const component = abiParameter.components[i];
1203
+ type += formatAbiParameter(component);
1204
+ if (i < length - 1)
1205
+ type += ", ";
1206
+ }
1207
+ const result = execTyped(tupleRegex, abiParameter.type);
1208
+ type += `)${result?.array || ""}`;
1209
+ return formatAbiParameter({
1210
+ ...abiParameter,
1211
+ type
1212
+ });
1213
+ }
1214
+ if ("indexed" in abiParameter && abiParameter.indexed)
1215
+ type = `${type} indexed`;
1216
+ if (abiParameter.name)
1217
+ return `${type} ${abiParameter.name}`;
1218
+ return type;
1219
+ }
1220
+ var tupleRegex;
1221
+ var init_formatAbiParameter = __esm({
1222
+ "../../node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js"() {
1223
+ init_regex();
1224
+ tupleRegex = /^tuple(?<array>(\[(\d*)\])*)$/;
1225
+ }
1226
+ });
1227
+
1228
+ // ../../node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js
1229
+ function formatAbiParameters(abiParameters) {
1230
+ let params = "";
1231
+ const length = abiParameters.length;
1232
+ for (let i = 0; i < length; i++) {
1233
+ const abiParameter = abiParameters[i];
1234
+ params += formatAbiParameter(abiParameter);
1235
+ if (i !== length - 1)
1236
+ params += ", ";
1237
+ }
1238
+ return params;
1239
+ }
1240
+ var init_formatAbiParameters = __esm({
1241
+ "../../node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js"() {
1242
+ init_formatAbiParameter();
1243
+ }
1244
+ });
1245
+
1246
+ // ../../node_modules/abitype/dist/esm/human-readable/formatAbiItem.js
1247
+ function formatAbiItem(abiItem) {
1248
+ if (abiItem.type === "function")
1249
+ return `function ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability && abiItem.stateMutability !== "nonpayable" ? ` ${abiItem.stateMutability}` : ""}${abiItem.outputs?.length ? ` returns (${formatAbiParameters(abiItem.outputs)})` : ""}`;
1250
+ if (abiItem.type === "event")
1251
+ return `event ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
1252
+ if (abiItem.type === "error")
1253
+ return `error ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
1254
+ if (abiItem.type === "constructor")
1255
+ return `constructor(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability === "payable" ? " payable" : ""}`;
1256
+ if (abiItem.type === "fallback")
1257
+ return `fallback() external${abiItem.stateMutability === "payable" ? " payable" : ""}`;
1258
+ return "receive() external payable";
1259
+ }
1260
+ var init_formatAbiItem = __esm({
1261
+ "../../node_modules/abitype/dist/esm/human-readable/formatAbiItem.js"() {
1262
+ init_formatAbiParameters();
1263
+ }
1264
+ });
1265
+
1266
+ // ../../node_modules/abitype/dist/esm/human-readable/runtime/signatures.js
1267
+ function isErrorSignature(signature) {
1268
+ return errorSignatureRegex.test(signature);
1269
+ }
1270
+ function execErrorSignature(signature) {
1271
+ return execTyped(errorSignatureRegex, signature);
1272
+ }
1273
+ function isEventSignature(signature) {
1274
+ return eventSignatureRegex.test(signature);
1275
+ }
1276
+ function execEventSignature(signature) {
1277
+ return execTyped(eventSignatureRegex, signature);
1278
+ }
1279
+ function isFunctionSignature(signature) {
1280
+ return functionSignatureRegex.test(signature);
1281
+ }
1282
+ function execFunctionSignature(signature) {
1283
+ return execTyped(functionSignatureRegex, signature);
1284
+ }
1285
+ function isStructSignature(signature) {
1286
+ return structSignatureRegex.test(signature);
1287
+ }
1288
+ function execStructSignature(signature) {
1289
+ return execTyped(structSignatureRegex, signature);
1290
+ }
1291
+ function isConstructorSignature(signature) {
1292
+ return constructorSignatureRegex.test(signature);
1293
+ }
1294
+ function execConstructorSignature(signature) {
1295
+ return execTyped(constructorSignatureRegex, signature);
1296
+ }
1297
+ function isFallbackSignature(signature) {
1298
+ return fallbackSignatureRegex.test(signature);
1299
+ }
1300
+ function execFallbackSignature(signature) {
1301
+ return execTyped(fallbackSignatureRegex, signature);
1302
+ }
1303
+ function isReceiveSignature(signature) {
1304
+ return receiveSignatureRegex.test(signature);
1305
+ }
1306
+ var errorSignatureRegex, eventSignatureRegex, functionSignatureRegex, structSignatureRegex, constructorSignatureRegex, fallbackSignatureRegex, receiveSignatureRegex, eventModifiers, functionModifiers;
1307
+ var init_signatures = __esm({
1308
+ "../../node_modules/abitype/dist/esm/human-readable/runtime/signatures.js"() {
1309
+ init_regex();
1310
+ errorSignatureRegex = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
1311
+ eventSignatureRegex = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
1312
+ functionSignatureRegex = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
1313
+ structSignatureRegex = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
1314
+ constructorSignatureRegex = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;
1315
+ fallbackSignatureRegex = /^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;
1316
+ receiveSignatureRegex = /^receive\(\) external payable$/;
1317
+ eventModifiers = /* @__PURE__ */ new Set(["indexed"]);
1318
+ functionModifiers = /* @__PURE__ */ new Set([
1319
+ "calldata",
1320
+ "memory",
1321
+ "storage"
1322
+ ]);
1323
+ }
1324
+ });
1325
+
1326
+ // ../../node_modules/abitype/dist/esm/human-readable/errors/abiItem.js
1327
+ var UnknownTypeError, UnknownSolidityTypeError;
1328
+ var init_abiItem = __esm({
1329
+ "../../node_modules/abitype/dist/esm/human-readable/errors/abiItem.js"() {
1330
+ init_errors();
1331
+ UnknownTypeError = class extends BaseError {
1332
+ constructor({ type }) {
1333
+ super("Unknown type.", {
1334
+ metaMessages: [
1335
+ `Type "${type}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
1336
+ ]
1337
+ });
1338
+ Object.defineProperty(this, "name", {
1339
+ enumerable: true,
1340
+ configurable: true,
1341
+ writable: true,
1342
+ value: "UnknownTypeError"
1343
+ });
1344
+ }
1345
+ };
1346
+ UnknownSolidityTypeError = class extends BaseError {
1347
+ constructor({ type }) {
1348
+ super("Unknown type.", {
1349
+ metaMessages: [`Type "${type}" is not a valid ABI type.`]
1350
+ });
1351
+ Object.defineProperty(this, "name", {
1352
+ enumerable: true,
1353
+ configurable: true,
1354
+ writable: true,
1355
+ value: "UnknownSolidityTypeError"
1356
+ });
1357
+ }
1358
+ };
1359
+ }
1360
+ });
1361
+
1362
+ // ../../node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js
1363
+ var InvalidParameterError, SolidityProtectedKeywordError, InvalidModifierError, InvalidFunctionModifierError, InvalidAbiTypeParameterError;
1364
+ var init_abiParameter = __esm({
1365
+ "../../node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js"() {
1366
+ init_errors();
1367
+ InvalidParameterError = class extends BaseError {
1368
+ constructor({ param }) {
1369
+ super("Invalid ABI parameter.", {
1370
+ details: param
1371
+ });
1372
+ Object.defineProperty(this, "name", {
1373
+ enumerable: true,
1374
+ configurable: true,
1375
+ writable: true,
1376
+ value: "InvalidParameterError"
1377
+ });
1378
+ }
1379
+ };
1380
+ SolidityProtectedKeywordError = class extends BaseError {
1381
+ constructor({ param, name }) {
1382
+ super("Invalid ABI parameter.", {
1383
+ details: param,
1384
+ metaMessages: [
1385
+ `"${name}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
1386
+ ]
1387
+ });
1388
+ Object.defineProperty(this, "name", {
1389
+ enumerable: true,
1390
+ configurable: true,
1391
+ writable: true,
1392
+ value: "SolidityProtectedKeywordError"
1393
+ });
1394
+ }
1395
+ };
1396
+ InvalidModifierError = class extends BaseError {
1397
+ constructor({ param, type, modifier }) {
1398
+ super("Invalid ABI parameter.", {
1399
+ details: param,
1400
+ metaMessages: [
1401
+ `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`
1402
+ ]
1403
+ });
1404
+ Object.defineProperty(this, "name", {
1405
+ enumerable: true,
1406
+ configurable: true,
1407
+ writable: true,
1408
+ value: "InvalidModifierError"
1409
+ });
1410
+ }
1411
+ };
1412
+ InvalidFunctionModifierError = class extends BaseError {
1413
+ constructor({ param, type, modifier }) {
1414
+ super("Invalid ABI parameter.", {
1415
+ details: param,
1416
+ metaMessages: [
1417
+ `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`,
1418
+ `Data location can only be specified for array, struct, or mapping types, but "${modifier}" was given.`
1419
+ ]
1420
+ });
1421
+ Object.defineProperty(this, "name", {
1422
+ enumerable: true,
1423
+ configurable: true,
1424
+ writable: true,
1425
+ value: "InvalidFunctionModifierError"
1426
+ });
1427
+ }
1428
+ };
1429
+ InvalidAbiTypeParameterError = class extends BaseError {
1430
+ constructor({ abiParameter }) {
1431
+ super("Invalid ABI parameter.", {
1432
+ details: JSON.stringify(abiParameter, null, 2),
1433
+ metaMessages: ["ABI parameter type is invalid."]
1434
+ });
1435
+ Object.defineProperty(this, "name", {
1436
+ enumerable: true,
1437
+ configurable: true,
1438
+ writable: true,
1439
+ value: "InvalidAbiTypeParameterError"
1440
+ });
1441
+ }
1442
+ };
1443
+ }
1444
+ });
1445
+
1446
+ // ../../node_modules/abitype/dist/esm/human-readable/errors/signature.js
1447
+ var InvalidSignatureError, UnknownSignatureError, InvalidStructSignatureError;
1448
+ var init_signature = __esm({
1449
+ "../../node_modules/abitype/dist/esm/human-readable/errors/signature.js"() {
1450
+ init_errors();
1451
+ InvalidSignatureError = class extends BaseError {
1452
+ constructor({ signature, type }) {
1453
+ super(`Invalid ${type} signature.`, {
1454
+ details: signature
1455
+ });
1456
+ Object.defineProperty(this, "name", {
1457
+ enumerable: true,
1458
+ configurable: true,
1459
+ writable: true,
1460
+ value: "InvalidSignatureError"
1461
+ });
1462
+ }
1463
+ };
1464
+ UnknownSignatureError = class extends BaseError {
1465
+ constructor({ signature }) {
1466
+ super("Unknown signature.", {
1467
+ details: signature
1468
+ });
1469
+ Object.defineProperty(this, "name", {
1470
+ enumerable: true,
1471
+ configurable: true,
1472
+ writable: true,
1473
+ value: "UnknownSignatureError"
1474
+ });
1475
+ }
1476
+ };
1477
+ InvalidStructSignatureError = class extends BaseError {
1478
+ constructor({ signature }) {
1479
+ super("Invalid struct signature.", {
1480
+ details: signature,
1481
+ metaMessages: ["No properties exist."]
1482
+ });
1483
+ Object.defineProperty(this, "name", {
1484
+ enumerable: true,
1485
+ configurable: true,
1486
+ writable: true,
1487
+ value: "InvalidStructSignatureError"
1488
+ });
1489
+ }
1490
+ };
1491
+ }
1492
+ });
1493
+
1494
+ // ../../node_modules/abitype/dist/esm/human-readable/errors/struct.js
1495
+ var CircularReferenceError;
1496
+ var init_struct = __esm({
1497
+ "../../node_modules/abitype/dist/esm/human-readable/errors/struct.js"() {
1498
+ init_errors();
1499
+ CircularReferenceError = class extends BaseError {
1500
+ constructor({ type }) {
1501
+ super("Circular reference detected.", {
1502
+ metaMessages: [`Struct "${type}" is a circular reference.`]
1503
+ });
1504
+ Object.defineProperty(this, "name", {
1505
+ enumerable: true,
1506
+ configurable: true,
1507
+ writable: true,
1508
+ value: "CircularReferenceError"
1509
+ });
1510
+ }
1511
+ };
1512
+ }
1513
+ });
1514
+
1515
+ // ../../node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js
1516
+ var InvalidParenthesisError;
1517
+ var init_splitParameters = __esm({
1518
+ "../../node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js"() {
1519
+ init_errors();
1520
+ InvalidParenthesisError = class extends BaseError {
1521
+ constructor({ current, depth }) {
1522
+ super("Unbalanced parentheses.", {
1523
+ metaMessages: [
1524
+ `"${current.trim()}" has too many ${depth > 0 ? "opening" : "closing"} parentheses.`
1525
+ ],
1526
+ details: `Depth "${depth}"`
1527
+ });
1528
+ Object.defineProperty(this, "name", {
1529
+ enumerable: true,
1530
+ configurable: true,
1531
+ writable: true,
1532
+ value: "InvalidParenthesisError"
1533
+ });
1534
+ }
1535
+ };
1536
+ }
1537
+ });
1538
+
1539
+ // ../../node_modules/abitype/dist/esm/human-readable/runtime/cache.js
1540
+ function getParameterCacheKey(param, type, structs) {
1541
+ let structKey = "";
1542
+ if (structs)
1543
+ for (const struct of Object.entries(structs)) {
1544
+ if (!struct)
1545
+ continue;
1546
+ let propertyKey = "";
1547
+ for (const property of struct[1]) {
1548
+ propertyKey += `[${property.type}${property.name ? `:${property.name}` : ""}]`;
1549
+ }
1550
+ structKey += `(${struct[0]}{${propertyKey}})`;
1551
+ }
1552
+ if (type)
1553
+ return `${type}:${param}${structKey}`;
1554
+ return `${param}${structKey}`;
1555
+ }
1556
+ var parameterCache;
1557
+ var init_cache = __esm({
1558
+ "../../node_modules/abitype/dist/esm/human-readable/runtime/cache.js"() {
1559
+ parameterCache = /* @__PURE__ */ new Map([
1560
+ // Unnamed
1561
+ ["address", { type: "address" }],
1562
+ ["bool", { type: "bool" }],
1563
+ ["bytes", { type: "bytes" }],
1564
+ ["bytes32", { type: "bytes32" }],
1565
+ ["int", { type: "int256" }],
1566
+ ["int256", { type: "int256" }],
1567
+ ["string", { type: "string" }],
1568
+ ["uint", { type: "uint256" }],
1569
+ ["uint8", { type: "uint8" }],
1570
+ ["uint16", { type: "uint16" }],
1571
+ ["uint24", { type: "uint24" }],
1572
+ ["uint32", { type: "uint32" }],
1573
+ ["uint64", { type: "uint64" }],
1574
+ ["uint96", { type: "uint96" }],
1575
+ ["uint112", { type: "uint112" }],
1576
+ ["uint160", { type: "uint160" }],
1577
+ ["uint192", { type: "uint192" }],
1578
+ ["uint256", { type: "uint256" }],
1579
+ // Named
1580
+ ["address owner", { type: "address", name: "owner" }],
1581
+ ["address to", { type: "address", name: "to" }],
1582
+ ["bool approved", { type: "bool", name: "approved" }],
1583
+ ["bytes _data", { type: "bytes", name: "_data" }],
1584
+ ["bytes data", { type: "bytes", name: "data" }],
1585
+ ["bytes signature", { type: "bytes", name: "signature" }],
1586
+ ["bytes32 hash", { type: "bytes32", name: "hash" }],
1587
+ ["bytes32 r", { type: "bytes32", name: "r" }],
1588
+ ["bytes32 root", { type: "bytes32", name: "root" }],
1589
+ ["bytes32 s", { type: "bytes32", name: "s" }],
1590
+ ["string name", { type: "string", name: "name" }],
1591
+ ["string symbol", { type: "string", name: "symbol" }],
1592
+ ["string tokenURI", { type: "string", name: "tokenURI" }],
1593
+ ["uint tokenId", { type: "uint256", name: "tokenId" }],
1594
+ ["uint8 v", { type: "uint8", name: "v" }],
1595
+ ["uint256 balance", { type: "uint256", name: "balance" }],
1596
+ ["uint256 tokenId", { type: "uint256", name: "tokenId" }],
1597
+ ["uint256 value", { type: "uint256", name: "value" }],
1598
+ // Indexed
1599
+ [
1600
+ "event:address indexed from",
1601
+ { type: "address", name: "from", indexed: true }
1602
+ ],
1603
+ ["event:address indexed to", { type: "address", name: "to", indexed: true }],
1604
+ [
1605
+ "event:uint indexed tokenId",
1606
+ { type: "uint256", name: "tokenId", indexed: true }
1607
+ ],
1608
+ [
1609
+ "event:uint256 indexed tokenId",
1610
+ { type: "uint256", name: "tokenId", indexed: true }
1611
+ ]
1612
+ ]);
1613
+ }
1614
+ });
1615
+
1616
+ // ../../node_modules/abitype/dist/esm/human-readable/runtime/utils.js
1617
+ function parseSignature(signature, structs = {}) {
1618
+ if (isFunctionSignature(signature))
1619
+ return parseFunctionSignature(signature, structs);
1620
+ if (isEventSignature(signature))
1621
+ return parseEventSignature(signature, structs);
1622
+ if (isErrorSignature(signature))
1623
+ return parseErrorSignature(signature, structs);
1624
+ if (isConstructorSignature(signature))
1625
+ return parseConstructorSignature(signature, structs);
1626
+ if (isFallbackSignature(signature))
1627
+ return parseFallbackSignature(signature);
1628
+ if (isReceiveSignature(signature))
1629
+ return {
1630
+ type: "receive",
1631
+ stateMutability: "payable"
1632
+ };
1633
+ throw new UnknownSignatureError({ signature });
1634
+ }
1635
+ function parseFunctionSignature(signature, structs = {}) {
1636
+ const match = execFunctionSignature(signature);
1637
+ if (!match)
1638
+ throw new InvalidSignatureError({ signature, type: "function" });
1639
+ const inputParams = splitParameters(match.parameters);
1640
+ const inputs = [];
1641
+ const inputLength = inputParams.length;
1642
+ for (let i = 0; i < inputLength; i++) {
1643
+ inputs.push(parseAbiParameter(inputParams[i], {
1644
+ modifiers: functionModifiers,
1645
+ structs,
1646
+ type: "function"
1647
+ }));
1648
+ }
1649
+ const outputs = [];
1650
+ if (match.returns) {
1651
+ const outputParams = splitParameters(match.returns);
1652
+ const outputLength = outputParams.length;
1653
+ for (let i = 0; i < outputLength; i++) {
1654
+ outputs.push(parseAbiParameter(outputParams[i], {
1655
+ modifiers: functionModifiers,
1656
+ structs,
1657
+ type: "function"
1658
+ }));
1659
+ }
1660
+ }
1661
+ return {
1662
+ name: match.name,
1663
+ type: "function",
1664
+ stateMutability: match.stateMutability ?? "nonpayable",
1665
+ inputs,
1666
+ outputs
1667
+ };
1668
+ }
1669
+ function parseEventSignature(signature, structs = {}) {
1670
+ const match = execEventSignature(signature);
1671
+ if (!match)
1672
+ throw new InvalidSignatureError({ signature, type: "event" });
1673
+ const params = splitParameters(match.parameters);
1674
+ const abiParameters = [];
1675
+ const length = params.length;
1676
+ for (let i = 0; i < length; i++)
1677
+ abiParameters.push(parseAbiParameter(params[i], {
1678
+ modifiers: eventModifiers,
1679
+ structs,
1680
+ type: "event"
1681
+ }));
1682
+ return { name: match.name, type: "event", inputs: abiParameters };
1683
+ }
1684
+ function parseErrorSignature(signature, structs = {}) {
1685
+ const match = execErrorSignature(signature);
1686
+ if (!match)
1687
+ throw new InvalidSignatureError({ signature, type: "error" });
1688
+ const params = splitParameters(match.parameters);
1689
+ const abiParameters = [];
1690
+ const length = params.length;
1691
+ for (let i = 0; i < length; i++)
1692
+ abiParameters.push(parseAbiParameter(params[i], { structs, type: "error" }));
1693
+ return { name: match.name, type: "error", inputs: abiParameters };
1694
+ }
1695
+ function parseConstructorSignature(signature, structs = {}) {
1696
+ const match = execConstructorSignature(signature);
1697
+ if (!match)
1698
+ throw new InvalidSignatureError({ signature, type: "constructor" });
1699
+ const params = splitParameters(match.parameters);
1700
+ const abiParameters = [];
1701
+ const length = params.length;
1702
+ for (let i = 0; i < length; i++)
1703
+ abiParameters.push(parseAbiParameter(params[i], { structs, type: "constructor" }));
1704
+ return {
1705
+ type: "constructor",
1706
+ stateMutability: match.stateMutability ?? "nonpayable",
1707
+ inputs: abiParameters
1708
+ };
1709
+ }
1710
+ function parseFallbackSignature(signature) {
1711
+ const match = execFallbackSignature(signature);
1712
+ if (!match)
1713
+ throw new InvalidSignatureError({ signature, type: "fallback" });
1714
+ return {
1715
+ type: "fallback",
1716
+ stateMutability: match.stateMutability ?? "nonpayable"
1717
+ };
1718
+ }
1719
+ function parseAbiParameter(param, options) {
1720
+ const parameterCacheKey = getParameterCacheKey(param, options?.type, options?.structs);
1721
+ if (parameterCache.has(parameterCacheKey))
1722
+ return parameterCache.get(parameterCacheKey);
1723
+ const isTuple = isTupleRegex.test(param);
1724
+ const match = execTyped(isTuple ? abiParameterWithTupleRegex : abiParameterWithoutTupleRegex, param);
1725
+ if (!match)
1726
+ throw new InvalidParameterError({ param });
1727
+ if (match.name && isSolidityKeyword(match.name))
1728
+ throw new SolidityProtectedKeywordError({ param, name: match.name });
1729
+ const name = match.name ? { name: match.name } : {};
1730
+ const indexed = match.modifier === "indexed" ? { indexed: true } : {};
1731
+ const structs = options?.structs ?? {};
1732
+ let type;
1733
+ let components = {};
1734
+ if (isTuple) {
1735
+ type = "tuple";
1736
+ const params = splitParameters(match.type);
1737
+ const components_ = [];
1738
+ const length = params.length;
1739
+ for (let i = 0; i < length; i++) {
1740
+ components_.push(parseAbiParameter(params[i], { structs }));
1741
+ }
1742
+ components = { components: components_ };
1743
+ } else if (match.type in structs) {
1744
+ type = "tuple";
1745
+ components = { components: structs[match.type] };
1746
+ } else if (dynamicIntegerRegex.test(match.type)) {
1747
+ type = `${match.type}256`;
1748
+ } else if (match.type === "address payable") {
1749
+ type = "address";
1750
+ } else {
1751
+ type = match.type;
1752
+ if (!(options?.type === "struct") && !isSolidityType(type))
1753
+ throw new UnknownSolidityTypeError({ type });
1754
+ }
1755
+ if (match.modifier) {
1756
+ if (!options?.modifiers?.has?.(match.modifier))
1757
+ throw new InvalidModifierError({
1758
+ param,
1759
+ type: options?.type,
1760
+ modifier: match.modifier
1761
+ });
1762
+ if (functionModifiers.has(match.modifier) && !isValidDataLocation(type, !!match.array))
1763
+ throw new InvalidFunctionModifierError({
1764
+ param,
1765
+ type: options?.type,
1766
+ modifier: match.modifier
1767
+ });
1768
+ }
1769
+ const abiParameter = {
1770
+ type: `${type}${match.array ?? ""}`,
1771
+ ...name,
1772
+ ...indexed,
1773
+ ...components
1774
+ };
1775
+ parameterCache.set(parameterCacheKey, abiParameter);
1776
+ return abiParameter;
1777
+ }
1778
+ function splitParameters(params, result = [], current = "", depth = 0) {
1779
+ const length = params.trim().length;
1780
+ for (let i = 0; i < length; i++) {
1781
+ const char = params[i];
1782
+ const tail = params.slice(i + 1);
1783
+ switch (char) {
1784
+ case ",":
1785
+ return depth === 0 ? splitParameters(tail, [...result, current.trim()]) : splitParameters(tail, result, `${current}${char}`, depth);
1786
+ case "(":
1787
+ return splitParameters(tail, result, `${current}${char}`, depth + 1);
1788
+ case ")":
1789
+ return splitParameters(tail, result, `${current}${char}`, depth - 1);
1790
+ default:
1791
+ return splitParameters(tail, result, `${current}${char}`, depth);
1792
+ }
1793
+ }
1794
+ if (current === "")
1795
+ return result;
1796
+ if (depth !== 0)
1797
+ throw new InvalidParenthesisError({ current, depth });
1798
+ result.push(current.trim());
1799
+ return result;
1800
+ }
1801
+ function isSolidityType(type) {
1802
+ return type === "address" || type === "bool" || type === "function" || type === "string" || bytesRegex.test(type) || integerRegex.test(type);
1803
+ }
1804
+ function isSolidityKeyword(name) {
1805
+ return name === "address" || name === "bool" || name === "function" || name === "string" || name === "tuple" || bytesRegex.test(name) || integerRegex.test(name) || protectedKeywordsRegex.test(name);
1806
+ }
1807
+ function isValidDataLocation(type, isArray) {
1808
+ return isArray || type === "bytes" || type === "string" || type === "tuple";
1809
+ }
1810
+ var abiParameterWithoutTupleRegex, abiParameterWithTupleRegex, dynamicIntegerRegex, protectedKeywordsRegex;
1811
+ var init_utils = __esm({
1812
+ "../../node_modules/abitype/dist/esm/human-readable/runtime/utils.js"() {
1813
+ init_regex();
1814
+ init_abiItem();
1815
+ init_abiParameter();
1816
+ init_signature();
1817
+ init_splitParameters();
1818
+ init_cache();
1819
+ init_signatures();
1820
+ abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
1821
+ abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
1822
+ dynamicIntegerRegex = /^u?int$/;
1823
+ protectedKeywordsRegex = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
1824
+ }
1825
+ });
1826
+
1827
+ // ../../node_modules/abitype/dist/esm/human-readable/runtime/structs.js
1828
+ function parseStructs(signatures) {
1829
+ const shallowStructs = {};
1830
+ const signaturesLength = signatures.length;
1831
+ for (let i = 0; i < signaturesLength; i++) {
1832
+ const signature = signatures[i];
1833
+ if (!isStructSignature(signature))
1834
+ continue;
1835
+ const match = execStructSignature(signature);
1836
+ if (!match)
1837
+ throw new InvalidSignatureError({ signature, type: "struct" });
1838
+ const properties = match.properties.split(";");
1839
+ const components = [];
1840
+ const propertiesLength = properties.length;
1841
+ for (let k = 0; k < propertiesLength; k++) {
1842
+ const property = properties[k];
1843
+ const trimmed = property.trim();
1844
+ if (!trimmed)
1845
+ continue;
1846
+ const abiParameter = parseAbiParameter(trimmed, {
1847
+ type: "struct"
1848
+ });
1849
+ components.push(abiParameter);
1850
+ }
1851
+ if (!components.length)
1852
+ throw new InvalidStructSignatureError({ signature });
1853
+ shallowStructs[match.name] = components;
1854
+ }
1855
+ const resolvedStructs = {};
1856
+ const entries = Object.entries(shallowStructs);
1857
+ const entriesLength = entries.length;
1858
+ for (let i = 0; i < entriesLength; i++) {
1859
+ const [name, parameters] = entries[i];
1860
+ resolvedStructs[name] = resolveStructs(parameters, shallowStructs);
1861
+ }
1862
+ return resolvedStructs;
1863
+ }
1864
+ function resolveStructs(abiParameters = [], structs = {}, ancestors = /* @__PURE__ */ new Set()) {
1865
+ const components = [];
1866
+ const length = abiParameters.length;
1867
+ for (let i = 0; i < length; i++) {
1868
+ const abiParameter = abiParameters[i];
1869
+ const isTuple = isTupleRegex.test(abiParameter.type);
1870
+ if (isTuple)
1871
+ components.push(abiParameter);
1872
+ else {
1873
+ const match = execTyped(typeWithoutTupleRegex, abiParameter.type);
1874
+ if (!match?.type)
1875
+ throw new InvalidAbiTypeParameterError({ abiParameter });
1876
+ const { array, type } = match;
1877
+ if (type in structs) {
1878
+ if (ancestors.has(type))
1879
+ throw new CircularReferenceError({ type });
1880
+ components.push({
1881
+ ...abiParameter,
1882
+ type: `tuple${array ?? ""}`,
1883
+ components: resolveStructs(structs[type], structs, /* @__PURE__ */ new Set([...ancestors, type]))
1884
+ });
1885
+ } else {
1886
+ if (isSolidityType(type))
1887
+ components.push(abiParameter);
1888
+ else
1889
+ throw new UnknownTypeError({ type });
1890
+ }
1891
+ }
1892
+ }
1893
+ return components;
1894
+ }
1895
+ var typeWithoutTupleRegex;
1896
+ var init_structs = __esm({
1897
+ "../../node_modules/abitype/dist/esm/human-readable/runtime/structs.js"() {
1898
+ init_regex();
1899
+ init_abiItem();
1900
+ init_abiParameter();
1901
+ init_signature();
1902
+ init_struct();
1903
+ init_signatures();
1904
+ init_utils();
1905
+ typeWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
1906
+ }
1907
+ });
1908
+
1909
+ // ../../node_modules/abitype/dist/esm/human-readable/parseAbi.js
1910
+ function parseAbi(signatures) {
1911
+ const structs = parseStructs(signatures);
1912
+ const abi = [];
1913
+ const length = signatures.length;
1914
+ for (let i = 0; i < length; i++) {
1915
+ const signature = signatures[i];
1916
+ if (isStructSignature(signature))
1917
+ continue;
1918
+ abi.push(parseSignature(signature, structs));
1919
+ }
1920
+ return abi;
1921
+ }
1922
+ var init_parseAbi = __esm({
1923
+ "../../node_modules/abitype/dist/esm/human-readable/parseAbi.js"() {
1924
+ init_signatures();
1925
+ init_structs();
1926
+ init_utils();
1927
+ }
1928
+ });
1929
+
1930
+ // ../../node_modules/abitype/dist/esm/exports/index.js
1931
+ var init_exports = __esm({
1932
+ "../../node_modules/abitype/dist/esm/exports/index.js"() {
1933
+ init_formatAbiItem();
1934
+ init_parseAbi();
1935
+ }
1936
+ });
1937
+
1938
+ // ../../node_modules/viem/_esm/utils/abi/formatAbiItem.js
1939
+ function formatAbiItem2(abiItem, { includeName = false } = {}) {
1940
+ if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
1941
+ throw new InvalidDefinitionTypeError(abiItem.type);
1942
+ return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
1943
+ }
1944
+ function formatAbiParams(params, { includeName = false } = {}) {
1945
+ if (!params)
1946
+ return "";
1947
+ return params.map((param) => formatAbiParam(param, { includeName })).join(includeName ? ", " : ",");
1948
+ }
1949
+ function formatAbiParam(param, { includeName }) {
1950
+ if (param.type.startsWith("tuple")) {
1951
+ return `(${formatAbiParams(param.components, { includeName })})${param.type.slice("tuple".length)}`;
1952
+ }
1953
+ return param.type + (includeName && param.name ? ` ${param.name}` : "");
1954
+ }
1955
+ var init_formatAbiItem2 = __esm({
1956
+ "../../node_modules/viem/_esm/utils/abi/formatAbiItem.js"() {
1957
+ init_abi();
1958
+ }
1959
+ });
1960
+
1114
1961
  // ../../node_modules/viem/_esm/utils/data/isHex.js
1115
1962
  function isHex(value, { strict = true } = {}) {
1116
1963
  if (!value)
@@ -1137,10 +1984,10 @@ var init_size = __esm({
1137
1984
  });
1138
1985
 
1139
1986
  // ../../node_modules/viem/_esm/errors/version.js
1140
- var version;
1141
- var init_version = __esm({
1987
+ var version2;
1988
+ var init_version2 = __esm({
1142
1989
  "../../node_modules/viem/_esm/errors/version.js"() {
1143
- version = "2.55.10";
1990
+ version2 = "2.55.10";
1144
1991
  }
1145
1992
  });
1146
1993
 
@@ -1152,15 +1999,15 @@ function walk(err, fn) {
1152
1999
  return walk(err.cause, fn);
1153
2000
  return fn ? null : err;
1154
2001
  }
1155
- var errorConfig, BaseError;
2002
+ var errorConfig, BaseError2;
1156
2003
  var init_base = __esm({
1157
2004
  "../../node_modules/viem/_esm/errors/base.js"() {
1158
- init_version();
2005
+ init_version2();
1159
2006
  errorConfig = {
1160
2007
  getDocsUrl: ({ docsBaseUrl, docsPath = "", docsSlug }) => docsPath ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath}${docsSlug ? `#${docsSlug}` : ""}` : void 0,
1161
- version: `viem@${version}`
2008
+ version: `viem@${version2}`
1162
2009
  };
1163
- BaseError = class _BaseError extends Error {
2010
+ BaseError2 = class _BaseError extends Error {
1164
2011
  constructor(shortMessage, args = {}) {
1165
2012
  const details = (() => {
1166
2013
  if (args.cause instanceof _BaseError)
@@ -1220,27 +2067,68 @@ var init_base = __esm({
1220
2067
  writable: true,
1221
2068
  value: "BaseError"
1222
2069
  });
1223
- this.details = details;
1224
- this.docsPath = docsPath;
1225
- this.metaMessages = args.metaMessages;
1226
- this.name = args.name ?? this.name;
1227
- this.shortMessage = shortMessage;
1228
- this.version = version;
2070
+ this.details = details;
2071
+ this.docsPath = docsPath;
2072
+ this.metaMessages = args.metaMessages;
2073
+ this.name = args.name ?? this.name;
2074
+ this.shortMessage = shortMessage;
2075
+ this.version = version2;
2076
+ }
2077
+ walk(fn) {
2078
+ return walk(this, fn);
2079
+ }
2080
+ };
2081
+ }
2082
+ });
2083
+
2084
+ // ../../node_modules/viem/_esm/errors/abi.js
2085
+ var AbiDecodingDataSizeTooSmallError, AbiDecodingZeroDataError, AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, AbiFunctionSignatureNotFoundError, BytesSizeMismatchError, InvalidAbiEncodingTypeError, InvalidAbiDecodingTypeError, InvalidArrayError, InvalidDefinitionTypeError;
2086
+ var init_abi = __esm({
2087
+ "../../node_modules/viem/_esm/errors/abi.js"() {
2088
+ init_formatAbiItem2();
2089
+ init_size();
2090
+ init_base();
2091
+ AbiDecodingDataSizeTooSmallError = class extends BaseError2 {
2092
+ constructor({ data, params, size: size2 }) {
2093
+ super([`Data size of ${size2} bytes is too small for given parameters.`].join("\n"), {
2094
+ metaMessages: [
2095
+ `Params: (${formatAbiParams(params, { includeName: true })})`,
2096
+ `Data: ${data} (${size2} bytes)`
2097
+ ],
2098
+ name: "AbiDecodingDataSizeTooSmallError"
2099
+ });
2100
+ Object.defineProperty(this, "data", {
2101
+ enumerable: true,
2102
+ configurable: true,
2103
+ writable: true,
2104
+ value: void 0
2105
+ });
2106
+ Object.defineProperty(this, "params", {
2107
+ enumerable: true,
2108
+ configurable: true,
2109
+ writable: true,
2110
+ value: void 0
2111
+ });
2112
+ Object.defineProperty(this, "size", {
2113
+ enumerable: true,
2114
+ configurable: true,
2115
+ writable: true,
2116
+ value: void 0
2117
+ });
2118
+ this.data = data;
2119
+ this.params = params;
2120
+ this.size = size2;
1229
2121
  }
1230
- walk(fn) {
1231
- return walk(this, fn);
2122
+ };
2123
+ AbiDecodingZeroDataError = class extends BaseError2 {
2124
+ constructor({ cause } = {}) {
2125
+ super('Cannot decode zero data ("0x") with ABI parameters.', {
2126
+ name: "AbiDecodingZeroDataError",
2127
+ cause
2128
+ });
1232
2129
  }
1233
2130
  };
1234
- }
1235
- });
1236
-
1237
- // ../../node_modules/viem/_esm/errors/abi.js
1238
- var AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, BytesSizeMismatchError, InvalidAbiEncodingTypeError, InvalidArrayError;
1239
- var init_abi = __esm({
1240
- "../../node_modules/viem/_esm/errors/abi.js"() {
1241
- init_size();
1242
- init_base();
1243
- AbiEncodingArrayLengthMismatchError = class extends BaseError {
2131
+ AbiEncodingArrayLengthMismatchError = class extends BaseError2 {
1244
2132
  constructor({ expectedLength, givenLength, type }) {
1245
2133
  super([
1246
2134
  `ABI encoding array length mismatch for type ${type}.`,
@@ -1249,12 +2137,12 @@ var init_abi = __esm({
1249
2137
  ].join("\n"), { name: "AbiEncodingArrayLengthMismatchError" });
1250
2138
  }
1251
2139
  };
1252
- AbiEncodingBytesSizeMismatchError = class extends BaseError {
2140
+ AbiEncodingBytesSizeMismatchError = class extends BaseError2 {
1253
2141
  constructor({ expectedSize, value }) {
1254
2142
  super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
1255
2143
  }
1256
2144
  };
1257
- AbiEncodingLengthMismatchError = class extends BaseError {
2145
+ AbiEncodingLengthMismatchError = class extends BaseError2 {
1258
2146
  constructor({ expectedLength, givenLength }) {
1259
2147
  super([
1260
2148
  "ABI encoding params/values length mismatch.",
@@ -1263,14 +2151,26 @@ var init_abi = __esm({
1263
2151
  ].join("\n"), { name: "AbiEncodingLengthMismatchError" });
1264
2152
  }
1265
2153
  };
1266
- BytesSizeMismatchError = class extends BaseError {
2154
+ AbiFunctionSignatureNotFoundError = class extends BaseError2 {
2155
+ constructor(signature, { docsPath }) {
2156
+ super([
2157
+ `Encoded function signature "${signature}" not found on ABI.`,
2158
+ "Make sure you are using the correct ABI and that the function exists on it.",
2159
+ `You can look up the signature here: https://4byte.sourcify.dev/?q=${signature}.`
2160
+ ].join("\n"), {
2161
+ docsPath,
2162
+ name: "AbiFunctionSignatureNotFoundError"
2163
+ });
2164
+ }
2165
+ };
2166
+ BytesSizeMismatchError = class extends BaseError2 {
1267
2167
  constructor({ expectedSize, givenSize }) {
1268
2168
  super(`Expected bytes${expectedSize}, got bytes${givenSize}.`, {
1269
2169
  name: "BytesSizeMismatchError"
1270
2170
  });
1271
2171
  }
1272
2172
  };
1273
- InvalidAbiEncodingTypeError = class extends BaseError {
2173
+ InvalidAbiEncodingTypeError = class extends BaseError2 {
1274
2174
  constructor(type, { docsPath }) {
1275
2175
  super([
1276
2176
  `Type "${type}" is not a valid encoding type.`,
@@ -1278,13 +2178,29 @@ var init_abi = __esm({
1278
2178
  ].join("\n"), { docsPath, name: "InvalidAbiEncodingType" });
1279
2179
  }
1280
2180
  };
1281
- InvalidArrayError = class extends BaseError {
2181
+ InvalidAbiDecodingTypeError = class extends BaseError2 {
2182
+ constructor(type, { docsPath }) {
2183
+ super([
2184
+ `Type "${type}" is not a valid decoding type.`,
2185
+ "Please provide a valid ABI type."
2186
+ ].join("\n"), { docsPath, name: "InvalidAbiDecodingType" });
2187
+ }
2188
+ };
2189
+ InvalidArrayError = class extends BaseError2 {
1282
2190
  constructor(value) {
1283
2191
  super([`Value "${value}" is not a valid array.`].join("\n"), {
1284
2192
  name: "InvalidArrayError"
1285
2193
  });
1286
2194
  }
1287
2195
  };
2196
+ InvalidDefinitionTypeError = class extends BaseError2 {
2197
+ constructor(type) {
2198
+ super([
2199
+ `"${type}" is not a valid definition type.`,
2200
+ 'Valid types: "function", "event", "error"'
2201
+ ].join("\n"), { name: "InvalidDefinitionTypeError" });
2202
+ }
2203
+ };
1288
2204
  }
1289
2205
  });
1290
2206
 
@@ -1293,12 +2209,12 @@ var SliceOffsetOutOfBoundsError, SizeExceedsPaddingSizeError;
1293
2209
  var init_data = __esm({
1294
2210
  "../../node_modules/viem/_esm/errors/data.js"() {
1295
2211
  init_base();
1296
- SliceOffsetOutOfBoundsError = class extends BaseError {
2212
+ SliceOffsetOutOfBoundsError = class extends BaseError2 {
1297
2213
  constructor({ offset, position, size: size2 }) {
1298
2214
  super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size2}).`, { name: "SliceOffsetOutOfBoundsError" });
1299
2215
  }
1300
2216
  };
1301
- SizeExceedsPaddingSizeError = class extends BaseError {
2217
+ SizeExceedsPaddingSizeError = class extends BaseError2 {
1302
2218
  constructor({ size: size2, targetSize, type }) {
1303
2219
  super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
1304
2220
  }
@@ -1347,16 +2263,23 @@ var init_pad = __esm({
1347
2263
  });
1348
2264
 
1349
2265
  // ../../node_modules/viem/_esm/errors/encoding.js
1350
- var IntegerOutOfRangeError, SizeOverflowError;
2266
+ var IntegerOutOfRangeError, InvalidBytesBooleanError, SizeOverflowError;
1351
2267
  var init_encoding = __esm({
1352
2268
  "../../node_modules/viem/_esm/errors/encoding.js"() {
1353
2269
  init_base();
1354
- IntegerOutOfRangeError = class extends BaseError {
2270
+ IntegerOutOfRangeError = class extends BaseError2 {
1355
2271
  constructor({ max, min, signed, size: size2, value }) {
1356
2272
  super(`Number "${value}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
1357
2273
  }
1358
2274
  };
1359
- SizeOverflowError = class extends BaseError {
2275
+ InvalidBytesBooleanError = class extends BaseError2 {
2276
+ constructor(bytes) {
2277
+ super(`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, {
2278
+ name: "InvalidBytesBooleanError"
2279
+ });
2280
+ }
2281
+ };
2282
+ SizeOverflowError = class extends BaseError2 {
1360
2283
  constructor({ givenSize, maxSize }) {
1361
2284
  super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
1362
2285
  }
@@ -1364,6 +2287,29 @@ var init_encoding = __esm({
1364
2287
  }
1365
2288
  });
1366
2289
 
2290
+ // ../../node_modules/viem/_esm/utils/data/trim.js
2291
+ function trim(hexOrBytes, { dir = "left" } = {}) {
2292
+ let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes;
2293
+ let sliceLength = 0;
2294
+ for (let i = 0; i < data.length - 1; i++) {
2295
+ if (data[dir === "left" ? i : data.length - i - 1].toString() === "0")
2296
+ sliceLength++;
2297
+ else
2298
+ break;
2299
+ }
2300
+ data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength);
2301
+ if (typeof hexOrBytes === "string") {
2302
+ if (data.length === 1 && dir === "right")
2303
+ data = `${data}0`;
2304
+ return `0x${data.length % 2 === 1 ? `0${data}` : data}`;
2305
+ }
2306
+ return data;
2307
+ }
2308
+ var init_trim = __esm({
2309
+ "../../node_modules/viem/_esm/utils/data/trim.js"() {
2310
+ }
2311
+ });
2312
+
1367
2313
  // ../../node_modules/viem/_esm/utils/encoding/fromHex.js
1368
2314
  function assertSize(hexOrBytes, { size: size2 }) {
1369
2315
  if (size(hexOrBytes) > size2)
@@ -1522,7 +2468,7 @@ function hexToBytes(hex_, opts = {}) {
1522
2468
  const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++));
1523
2469
  const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++));
1524
2470
  if (nibbleLeft === void 0 || nibbleRight === void 0) {
1525
- throw new BaseError(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
2471
+ throw new BaseError2(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
1526
2472
  }
1527
2473
  bytes[index] = nibbleLeft * 16 + nibbleRight;
1528
2474
  }
@@ -1697,7 +2643,7 @@ function randomBytes2(bytesLength = 32) {
1697
2643
  throw new Error("crypto.getRandomValues must be defined");
1698
2644
  }
1699
2645
  var isLE, swap32IfBE, Hash;
1700
- var init_utils = __esm({
2646
+ var init_utils2 = __esm({
1701
2647
  "../../node_modules/@noble/hashes/esm/utils.js"() {
1702
2648
  init_cryptoNode();
1703
2649
  isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
@@ -1752,7 +2698,7 @@ var _0n, _1n, _2n, _7n, _256n, _0x71n, SHA3_PI, SHA3_ROTL, _SHA3_IOTA, IOTAS, SH
1752
2698
  var init_sha3 = __esm({
1753
2699
  "../../node_modules/@noble/hashes/esm/sha3.js"() {
1754
2700
  init_u64();
1755
- init_utils();
2701
+ init_utils2();
1756
2702
  _0n = BigInt(0);
1757
2703
  _1n = BigInt(1);
1758
2704
  _2n = BigInt(2);
@@ -1912,12 +2858,102 @@ var init_keccak256 = __esm({
1912
2858
  }
1913
2859
  });
1914
2860
 
2861
+ // ../../node_modules/viem/_esm/utils/hash/hashSignature.js
2862
+ function hashSignature(sig) {
2863
+ return hash(sig);
2864
+ }
2865
+ var hash;
2866
+ var init_hashSignature = __esm({
2867
+ "../../node_modules/viem/_esm/utils/hash/hashSignature.js"() {
2868
+ init_toBytes();
2869
+ init_keccak256();
2870
+ hash = (value) => keccak256(toBytes(value));
2871
+ }
2872
+ });
2873
+
2874
+ // ../../node_modules/viem/_esm/utils/hash/normalizeSignature.js
2875
+ function normalizeSignature(signature) {
2876
+ let active = true;
2877
+ let current = "";
2878
+ let level = 0;
2879
+ let result = "";
2880
+ let valid = false;
2881
+ for (let i = 0; i < signature.length; i++) {
2882
+ const char = signature[i];
2883
+ if (["(", ")", ","].includes(char))
2884
+ active = true;
2885
+ if (char === "(")
2886
+ level++;
2887
+ if (char === ")")
2888
+ level--;
2889
+ if (!active)
2890
+ continue;
2891
+ if (level === 0) {
2892
+ if (char === " " && ["event", "function", ""].includes(result))
2893
+ result = "";
2894
+ else {
2895
+ result += char;
2896
+ if (char === ")") {
2897
+ valid = true;
2898
+ break;
2899
+ }
2900
+ }
2901
+ continue;
2902
+ }
2903
+ if (char === " ") {
2904
+ if (signature[i - 1] !== "," && current !== "," && current !== ",(") {
2905
+ current = "";
2906
+ active = false;
2907
+ }
2908
+ continue;
2909
+ }
2910
+ result += char;
2911
+ current += char;
2912
+ }
2913
+ if (!valid)
2914
+ throw new BaseError2("Unable to normalize signature.");
2915
+ return result;
2916
+ }
2917
+ var init_normalizeSignature = __esm({
2918
+ "../../node_modules/viem/_esm/utils/hash/normalizeSignature.js"() {
2919
+ init_base();
2920
+ }
2921
+ });
2922
+
2923
+ // ../../node_modules/viem/_esm/utils/hash/toSignature.js
2924
+ var toSignature;
2925
+ var init_toSignature = __esm({
2926
+ "../../node_modules/viem/_esm/utils/hash/toSignature.js"() {
2927
+ init_exports();
2928
+ init_normalizeSignature();
2929
+ toSignature = (def) => {
2930
+ const def_ = (() => {
2931
+ if (typeof def === "string")
2932
+ return def;
2933
+ return formatAbiItem(def);
2934
+ })();
2935
+ return normalizeSignature(def_);
2936
+ };
2937
+ }
2938
+ });
2939
+
2940
+ // ../../node_modules/viem/_esm/utils/hash/toSignatureHash.js
2941
+ function toSignatureHash(fn) {
2942
+ return hashSignature(toSignature(fn));
2943
+ }
2944
+ var init_toSignatureHash = __esm({
2945
+ "../../node_modules/viem/_esm/utils/hash/toSignatureHash.js"() {
2946
+ init_hashSignature();
2947
+ init_toSignature();
2948
+ }
2949
+ });
2950
+
1915
2951
  // ../../node_modules/viem/_esm/errors/address.js
1916
2952
  var InvalidAddressError2;
1917
2953
  var init_address = __esm({
1918
2954
  "../../node_modules/viem/_esm/errors/address.js"() {
1919
2955
  init_base();
1920
- InvalidAddressError2 = class extends BaseError {
2956
+ InvalidAddressError2 = class extends BaseError2 {
1921
2957
  constructor({ address }) {
1922
2958
  super(`Address "${address}" is invalid.`, {
1923
2959
  metaMessages: [
@@ -1974,13 +3010,13 @@ function checksumAddress(address_, chainId) {
1974
3010
  if (checksumAddressCache.has(`${address_}.${chainId}`))
1975
3011
  return checksumAddressCache.get(`${address_}.${chainId}`);
1976
3012
  const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
1977
- const hash = keccak256(stringToBytes(hexAddress), "bytes");
3013
+ const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
1978
3014
  const address = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
1979
3015
  for (let i = 0; i < 40; i += 2) {
1980
- if (hash[i >> 1] >> 4 >= 8 && address[i]) {
3016
+ if (hash2[i >> 1] >> 4 >= 8 && address[i]) {
1981
3017
  address[i] = address[i].toUpperCase();
1982
3018
  }
1983
- if ((hash[i >> 1] & 15) >= 8 && address[i + 1]) {
3019
+ if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
1984
3020
  address[i + 1] = address[i + 1].toUpperCase();
1985
3021
  }
1986
3022
  }
@@ -2103,11 +3139,11 @@ var init_slice = __esm({
2103
3139
  });
2104
3140
 
2105
3141
  // ../../node_modules/viem/_esm/utils/regex.js
2106
- var bytesRegex, integerRegex;
2107
- var init_regex = __esm({
3142
+ var bytesRegex2, integerRegex2;
3143
+ var init_regex2 = __esm({
2108
3144
  "../../node_modules/viem/_esm/utils/regex.js"() {
2109
- bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
2110
- integerRegex = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
3145
+ bytesRegex2 = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
3146
+ integerRegex2 = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
2111
3147
  }
2112
3148
  });
2113
3149
 
@@ -2150,7 +3186,7 @@ function prepareParam({ param, value }) {
2150
3186
  }
2151
3187
  if (param.type.startsWith("uint") || param.type.startsWith("int")) {
2152
3188
  const signed = param.type.startsWith("int");
2153
- const [, , size2 = "256"] = integerRegex.exec(param.type) ?? [];
3189
+ const [, , size2 = "256"] = integerRegex2.exec(param.type) ?? [];
2154
3190
  return encodeNumber(value, {
2155
3191
  signed,
2156
3192
  size: Number(size2)
@@ -2257,7 +3293,7 @@ function encodeBytes(value, { param }) {
2257
3293
  }
2258
3294
  function encodeBool(value) {
2259
3295
  if (typeof value !== "boolean")
2260
- throw new BaseError(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
3296
+ throw new BaseError2(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
2261
3297
  return { dynamic: false, encoded: padHex(boolToHex(value)) };
2262
3298
  }
2263
3299
  function encodeNumber(value, { signed, size: size2 = 256 }) {
@@ -2351,7 +3387,467 @@ var init_encodeAbiParameters = __esm({
2351
3387
  init_size();
2352
3388
  init_slice();
2353
3389
  init_toHex();
2354
- init_regex();
3390
+ init_regex2();
3391
+ }
3392
+ });
3393
+
3394
+ // ../../node_modules/viem/_esm/utils/hash/toFunctionSelector.js
3395
+ var toFunctionSelector;
3396
+ var init_toFunctionSelector = __esm({
3397
+ "../../node_modules/viem/_esm/utils/hash/toFunctionSelector.js"() {
3398
+ init_slice();
3399
+ init_toSignatureHash();
3400
+ toFunctionSelector = (fn) => slice(toSignatureHash(fn), 0, 4);
3401
+ }
3402
+ });
3403
+
3404
+ // ../../node_modules/viem/_esm/errors/cursor.js
3405
+ var NegativeOffsetError, PositionOutOfBoundsError, RecursiveReadLimitExceededError;
3406
+ var init_cursor = __esm({
3407
+ "../../node_modules/viem/_esm/errors/cursor.js"() {
3408
+ init_base();
3409
+ NegativeOffsetError = class extends BaseError2 {
3410
+ constructor({ offset }) {
3411
+ super(`Offset \`${offset}\` cannot be negative.`, {
3412
+ name: "NegativeOffsetError"
3413
+ });
3414
+ }
3415
+ };
3416
+ PositionOutOfBoundsError = class extends BaseError2 {
3417
+ constructor({ length, position }) {
3418
+ super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`, { name: "PositionOutOfBoundsError" });
3419
+ }
3420
+ };
3421
+ RecursiveReadLimitExceededError = class extends BaseError2 {
3422
+ constructor({ count, limit }) {
3423
+ super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`, { name: "RecursiveReadLimitExceededError" });
3424
+ }
3425
+ };
3426
+ }
3427
+ });
3428
+
3429
+ // ../../node_modules/viem/_esm/utils/cursor.js
3430
+ function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
3431
+ const cursor = Object.create(staticCursor);
3432
+ cursor.bytes = bytes;
3433
+ cursor.dataView = new DataView(bytes.buffer ?? bytes, bytes.byteOffset, bytes.byteLength);
3434
+ cursor.positionReadCount = /* @__PURE__ */ new Map();
3435
+ cursor.recursiveReadLimit = recursiveReadLimit;
3436
+ return cursor;
3437
+ }
3438
+ var staticCursor;
3439
+ var init_cursor2 = __esm({
3440
+ "../../node_modules/viem/_esm/utils/cursor.js"() {
3441
+ init_cursor();
3442
+ staticCursor = {
3443
+ bytes: new Uint8Array(),
3444
+ dataView: new DataView(new ArrayBuffer(0)),
3445
+ position: 0,
3446
+ positionReadCount: /* @__PURE__ */ new Map(),
3447
+ recursiveReadCount: 0,
3448
+ recursiveReadLimit: Number.POSITIVE_INFINITY,
3449
+ assertReadLimit() {
3450
+ if (this.recursiveReadCount >= this.recursiveReadLimit)
3451
+ throw new RecursiveReadLimitExceededError({
3452
+ count: this.recursiveReadCount + 1,
3453
+ limit: this.recursiveReadLimit
3454
+ });
3455
+ },
3456
+ assertPosition(position) {
3457
+ if (position < 0 || position > this.bytes.length - 1)
3458
+ throw new PositionOutOfBoundsError({
3459
+ length: this.bytes.length,
3460
+ position
3461
+ });
3462
+ },
3463
+ decrementPosition(offset) {
3464
+ if (offset < 0)
3465
+ throw new NegativeOffsetError({ offset });
3466
+ const position = this.position - offset;
3467
+ this.assertPosition(position);
3468
+ this.position = position;
3469
+ },
3470
+ getReadCount(position) {
3471
+ return this.positionReadCount.get(position || this.position) || 0;
3472
+ },
3473
+ incrementPosition(offset) {
3474
+ if (offset < 0)
3475
+ throw new NegativeOffsetError({ offset });
3476
+ const position = this.position + offset;
3477
+ this.assertPosition(position);
3478
+ this.position = position;
3479
+ },
3480
+ inspectByte(position_) {
3481
+ const position = position_ ?? this.position;
3482
+ this.assertPosition(position);
3483
+ return this.bytes[position];
3484
+ },
3485
+ inspectBytes(length, position_) {
3486
+ const position = position_ ?? this.position;
3487
+ this.assertPosition(position + length - 1);
3488
+ return this.bytes.subarray(position, position + length);
3489
+ },
3490
+ inspectUint8(position_) {
3491
+ const position = position_ ?? this.position;
3492
+ this.assertPosition(position);
3493
+ return this.bytes[position];
3494
+ },
3495
+ inspectUint16(position_) {
3496
+ const position = position_ ?? this.position;
3497
+ this.assertPosition(position + 1);
3498
+ return this.dataView.getUint16(position);
3499
+ },
3500
+ inspectUint24(position_) {
3501
+ const position = position_ ?? this.position;
3502
+ this.assertPosition(position + 2);
3503
+ return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
3504
+ },
3505
+ inspectUint32(position_) {
3506
+ const position = position_ ?? this.position;
3507
+ this.assertPosition(position + 3);
3508
+ return this.dataView.getUint32(position);
3509
+ },
3510
+ pushByte(byte) {
3511
+ this.assertPosition(this.position);
3512
+ this.bytes[this.position] = byte;
3513
+ this.position++;
3514
+ },
3515
+ pushBytes(bytes) {
3516
+ this.assertPosition(this.position + bytes.length - 1);
3517
+ this.bytes.set(bytes, this.position);
3518
+ this.position += bytes.length;
3519
+ },
3520
+ pushUint8(value) {
3521
+ this.assertPosition(this.position);
3522
+ this.bytes[this.position] = value;
3523
+ this.position++;
3524
+ },
3525
+ pushUint16(value) {
3526
+ this.assertPosition(this.position + 1);
3527
+ this.dataView.setUint16(this.position, value);
3528
+ this.position += 2;
3529
+ },
3530
+ pushUint24(value) {
3531
+ this.assertPosition(this.position + 2);
3532
+ this.dataView.setUint16(this.position, value >> 8);
3533
+ this.dataView.setUint8(this.position + 2, value & ~4294967040);
3534
+ this.position += 3;
3535
+ },
3536
+ pushUint32(value) {
3537
+ this.assertPosition(this.position + 3);
3538
+ this.dataView.setUint32(this.position, value);
3539
+ this.position += 4;
3540
+ },
3541
+ readByte() {
3542
+ this.assertReadLimit();
3543
+ this._touch();
3544
+ const value = this.inspectByte();
3545
+ this.position++;
3546
+ return value;
3547
+ },
3548
+ readBytes(length, size2) {
3549
+ this.assertReadLimit();
3550
+ this._touch();
3551
+ const value = this.inspectBytes(length);
3552
+ this.position += size2 ?? length;
3553
+ return value;
3554
+ },
3555
+ readUint8() {
3556
+ this.assertReadLimit();
3557
+ this._touch();
3558
+ const value = this.inspectUint8();
3559
+ this.position += 1;
3560
+ return value;
3561
+ },
3562
+ readUint16() {
3563
+ this.assertReadLimit();
3564
+ this._touch();
3565
+ const value = this.inspectUint16();
3566
+ this.position += 2;
3567
+ return value;
3568
+ },
3569
+ readUint24() {
3570
+ this.assertReadLimit();
3571
+ this._touch();
3572
+ const value = this.inspectUint24();
3573
+ this.position += 3;
3574
+ return value;
3575
+ },
3576
+ readUint32() {
3577
+ this.assertReadLimit();
3578
+ this._touch();
3579
+ const value = this.inspectUint32();
3580
+ this.position += 4;
3581
+ return value;
3582
+ },
3583
+ get remaining() {
3584
+ return this.bytes.length - this.position;
3585
+ },
3586
+ setPosition(position) {
3587
+ const oldPosition = this.position;
3588
+ this.assertPosition(position);
3589
+ this.position = position;
3590
+ return () => this.position = oldPosition;
3591
+ },
3592
+ _touch() {
3593
+ if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
3594
+ return;
3595
+ const count = this.getReadCount();
3596
+ this.positionReadCount.set(this.position, count + 1);
3597
+ if (count > 0)
3598
+ this.recursiveReadCount++;
3599
+ }
3600
+ };
3601
+ }
3602
+ });
3603
+
3604
+ // ../../node_modules/viem/_esm/utils/encoding/fromBytes.js
3605
+ function bytesToBigInt(bytes, opts = {}) {
3606
+ if (typeof opts.size !== "undefined")
3607
+ assertSize(bytes, { size: opts.size });
3608
+ const hex = bytesToHex(bytes);
3609
+ return hexToBigInt(hex, opts);
3610
+ }
3611
+ function bytesToBool(bytes_, opts = {}) {
3612
+ let bytes = bytes_;
3613
+ if (typeof opts.size !== "undefined") {
3614
+ assertSize(bytes, { size: opts.size });
3615
+ bytes = trim(bytes);
3616
+ }
3617
+ if (bytes.length > 1 || bytes[0] > 1)
3618
+ throw new InvalidBytesBooleanError(bytes);
3619
+ return Boolean(bytes[0]);
3620
+ }
3621
+ function bytesToNumber(bytes, opts = {}) {
3622
+ if (typeof opts.size !== "undefined")
3623
+ assertSize(bytes, { size: opts.size });
3624
+ const hex = bytesToHex(bytes);
3625
+ return hexToNumber(hex, opts);
3626
+ }
3627
+ function bytesToString(bytes_, opts = {}) {
3628
+ let bytes = bytes_;
3629
+ if (typeof opts.size !== "undefined") {
3630
+ assertSize(bytes, { size: opts.size });
3631
+ bytes = trim(bytes, { dir: "right" });
3632
+ }
3633
+ return new TextDecoder().decode(bytes);
3634
+ }
3635
+ var init_fromBytes = __esm({
3636
+ "../../node_modules/viem/_esm/utils/encoding/fromBytes.js"() {
3637
+ init_encoding();
3638
+ init_trim();
3639
+ init_fromHex();
3640
+ init_toHex();
3641
+ }
3642
+ });
3643
+
3644
+ // ../../node_modules/viem/_esm/utils/abi/decodeAbiParameters.js
3645
+ function decodeAbiParameters(params, data) {
3646
+ const bytes = typeof data === "string" ? hexToBytes(data) : data;
3647
+ const cursor = createCursor(bytes);
3648
+ if (size(bytes) === 0 && params.length > 0)
3649
+ throw new AbiDecodingZeroDataError();
3650
+ if (size(data) && size(data) < 32)
3651
+ throw new AbiDecodingDataSizeTooSmallError({
3652
+ data: typeof data === "string" ? data : bytesToHex(data),
3653
+ params,
3654
+ size: size(data)
3655
+ });
3656
+ let consumed = 0;
3657
+ const values = [];
3658
+ for (let i = 0; i < params.length; ++i) {
3659
+ const param = params[i];
3660
+ if (consumed < bytes.length)
3661
+ cursor.setPosition(consumed);
3662
+ const [data2, consumed_] = decodeParameter(cursor, param, {
3663
+ staticPosition: 0
3664
+ });
3665
+ consumed += consumed_;
3666
+ values.push(data2);
3667
+ }
3668
+ return values;
3669
+ }
3670
+ function decodeParameter(cursor, param, { staticPosition }) {
3671
+ const arrayComponents = getArrayComponents(param.type);
3672
+ if (arrayComponents) {
3673
+ const [length, type] = arrayComponents;
3674
+ return decodeArray(cursor, { ...param, type }, { length, staticPosition });
3675
+ }
3676
+ if (param.type === "tuple")
3677
+ return decodeTuple(cursor, param, { staticPosition });
3678
+ if (param.type === "address")
3679
+ return decodeAddress(cursor);
3680
+ if (param.type === "bool")
3681
+ return decodeBool(cursor);
3682
+ if (param.type.startsWith("bytes"))
3683
+ return decodeBytes(cursor, param, { staticPosition });
3684
+ if (param.type.startsWith("uint") || param.type.startsWith("int"))
3685
+ return decodeNumber(cursor, param);
3686
+ if (param.type === "string")
3687
+ return decodeString(cursor, { staticPosition });
3688
+ throw new InvalidAbiDecodingTypeError(param.type, {
3689
+ docsPath: "/docs/contract/decodeAbiParameters"
3690
+ });
3691
+ }
3692
+ function decodeAddress(cursor) {
3693
+ const value = cursor.readBytes(32);
3694
+ return [checksumAddress(bytesToHex(sliceBytes(value, -20))), 32];
3695
+ }
3696
+ function decodeArray(cursor, param, { length, staticPosition }) {
3697
+ if (length === null) {
3698
+ const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
3699
+ const start = staticPosition + offset;
3700
+ const startOfData = start + sizeOfLength;
3701
+ cursor.setPosition(start);
3702
+ const length2 = bytesToNumber(cursor.readBytes(sizeOfLength));
3703
+ const dynamicChild = hasDynamicChild(param);
3704
+ let consumed2 = 0;
3705
+ const value2 = [];
3706
+ for (let i = 0; i < length2; ++i) {
3707
+ cursor.setPosition(startOfData + (dynamicChild ? i * 32 : consumed2));
3708
+ const [data, consumed_] = decodeParameter(cursor, param, {
3709
+ staticPosition: startOfData
3710
+ });
3711
+ consumed2 += consumed_;
3712
+ value2.push(data);
3713
+ if (consumed_ === 0) {
3714
+ cursor.assertReadLimit();
3715
+ cursor._touch();
3716
+ }
3717
+ }
3718
+ cursor.setPosition(staticPosition + 32);
3719
+ return [value2, 32];
3720
+ }
3721
+ if (hasDynamicChild(param)) {
3722
+ const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
3723
+ const start = staticPosition + offset;
3724
+ const value2 = [];
3725
+ for (let i = 0; i < length; ++i) {
3726
+ cursor.setPosition(start + i * 32);
3727
+ const [data] = decodeParameter(cursor, param, {
3728
+ staticPosition: start
3729
+ });
3730
+ value2.push(data);
3731
+ }
3732
+ cursor.setPosition(staticPosition + 32);
3733
+ return [value2, 32];
3734
+ }
3735
+ let consumed = 0;
3736
+ const value = [];
3737
+ for (let i = 0; i < length; ++i) {
3738
+ const [data, consumed_] = decodeParameter(cursor, param, {
3739
+ staticPosition: staticPosition + consumed
3740
+ });
3741
+ consumed += consumed_;
3742
+ value.push(data);
3743
+ if (consumed_ === 0) {
3744
+ cursor.assertReadLimit();
3745
+ cursor._touch();
3746
+ }
3747
+ }
3748
+ return [value, consumed];
3749
+ }
3750
+ function decodeBool(cursor) {
3751
+ return [bytesToBool(cursor.readBytes(32), { size: 32 }), 32];
3752
+ }
3753
+ function decodeBytes(cursor, param, { staticPosition }) {
3754
+ const [_, size2] = param.type.split("bytes");
3755
+ if (!size2) {
3756
+ const offset = bytesToNumber(cursor.readBytes(32));
3757
+ cursor.setPosition(staticPosition + offset);
3758
+ const length = bytesToNumber(cursor.readBytes(32));
3759
+ if (length === 0) {
3760
+ cursor.setPosition(staticPosition + 32);
3761
+ return ["0x", 32];
3762
+ }
3763
+ const data = cursor.readBytes(length);
3764
+ cursor.setPosition(staticPosition + 32);
3765
+ return [bytesToHex(data), 32];
3766
+ }
3767
+ const value = bytesToHex(cursor.readBytes(Number.parseInt(size2, 10), 32));
3768
+ return [value, 32];
3769
+ }
3770
+ function decodeNumber(cursor, param) {
3771
+ const signed = param.type.startsWith("int");
3772
+ const size2 = Number.parseInt(param.type.split("int")[1] || "256", 10);
3773
+ const value = cursor.readBytes(32);
3774
+ return [
3775
+ size2 > 48 ? bytesToBigInt(value, { signed }) : bytesToNumber(value, { signed }),
3776
+ 32
3777
+ ];
3778
+ }
3779
+ function decodeTuple(cursor, param, { staticPosition }) {
3780
+ const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
3781
+ const value = hasUnnamedChild ? [] : {};
3782
+ let consumed = 0;
3783
+ if (hasDynamicChild(param)) {
3784
+ const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
3785
+ const start = staticPosition + offset;
3786
+ for (let i = 0; i < param.components.length; ++i) {
3787
+ const component = param.components[i];
3788
+ cursor.setPosition(start + consumed);
3789
+ const [data, consumed_] = decodeParameter(cursor, component, {
3790
+ staticPosition: start
3791
+ });
3792
+ consumed += consumed_;
3793
+ value[hasUnnamedChild ? i : component?.name] = data;
3794
+ }
3795
+ cursor.setPosition(staticPosition + 32);
3796
+ return [value, 32];
3797
+ }
3798
+ for (let i = 0; i < param.components.length; ++i) {
3799
+ const component = param.components[i];
3800
+ const [data, consumed_] = decodeParameter(cursor, component, {
3801
+ staticPosition
3802
+ });
3803
+ value[hasUnnamedChild ? i : component?.name] = data;
3804
+ consumed += consumed_;
3805
+ }
3806
+ return [value, consumed];
3807
+ }
3808
+ function decodeString(cursor, { staticPosition }) {
3809
+ const offset = bytesToNumber(cursor.readBytes(32));
3810
+ const start = staticPosition + offset;
3811
+ cursor.setPosition(start);
3812
+ const length = bytesToNumber(cursor.readBytes(32));
3813
+ if (length === 0) {
3814
+ cursor.setPosition(staticPosition + 32);
3815
+ return ["", 32];
3816
+ }
3817
+ const data = cursor.readBytes(length, 32);
3818
+ const value = bytesToString(data);
3819
+ cursor.setPosition(staticPosition + 32);
3820
+ return [value, 32];
3821
+ }
3822
+ function hasDynamicChild(param) {
3823
+ const { type } = param;
3824
+ if (type === "string")
3825
+ return true;
3826
+ if (type === "bytes")
3827
+ return true;
3828
+ if (type.endsWith("[]"))
3829
+ return true;
3830
+ if (type === "tuple")
3831
+ return param.components?.some(hasDynamicChild);
3832
+ const arrayComponents = getArrayComponents(param.type);
3833
+ if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
3834
+ return true;
3835
+ return false;
3836
+ }
3837
+ var sizeOfLength, sizeOfOffset;
3838
+ var init_decodeAbiParameters = __esm({
3839
+ "../../node_modules/viem/_esm/utils/abi/decodeAbiParameters.js"() {
3840
+ init_abi();
3841
+ init_getAddress();
3842
+ init_cursor2();
3843
+ init_size();
3844
+ init_slice();
3845
+ init_fromBytes();
3846
+ init_toBytes();
3847
+ init_toHex();
3848
+ init_encodeAbiParameters();
3849
+ sizeOfLength = 32;
3850
+ sizeOfOffset = 32;
2355
3851
  }
2356
3852
  });
2357
3853
 
@@ -2421,7 +3917,7 @@ function Maj(a, b, c) {
2421
3917
  var HashMD, SHA256_IV;
2422
3918
  var init_md = __esm({
2423
3919
  "../../node_modules/@noble/hashes/esm/_md.js"() {
2424
- init_utils();
3920
+ init_utils2();
2425
3921
  HashMD = class extends Hash {
2426
3922
  constructor(blockLen, outputLen, padOffset, isLE2) {
2427
3923
  super();
@@ -2530,7 +4026,7 @@ var SHA256_K, SHA256_W, SHA256, sha256;
2530
4026
  var init_sha2 = __esm({
2531
4027
  "../../node_modules/@noble/hashes/esm/sha2.js"() {
2532
4028
  init_md();
2533
- init_utils();
4029
+ init_utils2();
2534
4030
  SHA256_K = /* @__PURE__ */ Uint32Array.from([
2535
4031
  1116352408,
2536
4032
  1899447441,
@@ -2676,26 +4172,26 @@ var init_sha2 = __esm({
2676
4172
  var HMAC, hmac;
2677
4173
  var init_hmac = __esm({
2678
4174
  "../../node_modules/@noble/hashes/esm/hmac.js"() {
2679
- init_utils();
4175
+ init_utils2();
2680
4176
  HMAC = class extends Hash {
2681
- constructor(hash, _key) {
4177
+ constructor(hash2, _key) {
2682
4178
  super();
2683
4179
  this.finished = false;
2684
4180
  this.destroyed = false;
2685
- ahash(hash);
4181
+ ahash(hash2);
2686
4182
  const key = toBytes2(_key);
2687
- this.iHash = hash.create();
4183
+ this.iHash = hash2.create();
2688
4184
  if (typeof this.iHash.update !== "function")
2689
4185
  throw new Error("Expected instance of class which extends utils.Hash");
2690
4186
  this.blockLen = this.iHash.blockLen;
2691
4187
  this.outputLen = this.iHash.outputLen;
2692
4188
  const blockLen = this.blockLen;
2693
4189
  const pad2 = new Uint8Array(blockLen);
2694
- pad2.set(key.length > blockLen ? hash.create().update(key).digest() : key);
4190
+ pad2.set(key.length > blockLen ? hash2.create().update(key).digest() : key);
2695
4191
  for (let i = 0; i < pad2.length; i++)
2696
4192
  pad2[i] ^= 54;
2697
4193
  this.iHash.update(pad2);
2698
- this.oHash = hash.create();
4194
+ this.oHash = hash2.create();
2699
4195
  for (let i = 0; i < pad2.length; i++)
2700
4196
  pad2[i] ^= 54 ^ 92;
2701
4197
  this.oHash.update(pad2);
@@ -2741,8 +4237,8 @@ var init_hmac = __esm({
2741
4237
  this.iHash.destroy();
2742
4238
  }
2743
4239
  };
2744
- hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
2745
- hmac.create = (hash, key) => new HMAC(hash, key);
4240
+ hmac = (hash2, key, message) => new HMAC(hash2, key).update(message).digest();
4241
+ hmac.create = (hash2, key) => new HMAC(hash2, key);
2746
4242
  }
2747
4243
  });
2748
4244
 
@@ -2949,7 +4445,7 @@ function memoized(fn) {
2949
4445
  };
2950
4446
  }
2951
4447
  var _0n2, _1n2, hasHexBuiltin, hexes2, asciis, isPosBig, bitMask, u8n, u8fr, validatorFns;
2952
- var init_utils2 = __esm({
4448
+ var init_utils3 = __esm({
2953
4449
  "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js"() {
2954
4450
  _0n2 = /* @__PURE__ */ BigInt(0);
2955
4451
  _1n2 = /* @__PURE__ */ BigInt(1);
@@ -3225,8 +4721,8 @@ function mapHashToField(key, fieldOrder, isLE2 = false) {
3225
4721
  var _0n3, _1n3, _2n2, _3n, _4n, _5n, _8n, FIELD_FIELDS;
3226
4722
  var init_modular = __esm({
3227
4723
  "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js"() {
3228
- init_utils();
3229
4724
  init_utils2();
4725
+ init_utils3();
3230
4726
  _0n3 = BigInt(0);
3231
4727
  _1n3 = BigInt(1);
3232
4728
  _2n2 = /* @__PURE__ */ BigInt(2);
@@ -3489,7 +4985,7 @@ var _0n4, _1n4, pointPrecomputes, pointWindowSizes;
3489
4985
  var init_curve = __esm({
3490
4986
  "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js"() {
3491
4987
  init_modular();
3492
- init_utils2();
4988
+ init_utils3();
3493
4989
  _0n4 = BigInt(0);
3494
4990
  _1n4 = BigInt(1);
3495
4991
  pointPrecomputes = /* @__PURE__ */ new WeakMap();
@@ -4162,14 +5658,14 @@ function weierstrass(curveDef) {
4162
5658
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
4163
5659
  if (["recovered", "canonical"].some((k) => k in opts))
4164
5660
  throw new Error("sign() legacy options not supported");
4165
- const { hash, randomBytes: randomBytes4 } = CURVE;
5661
+ const { hash: hash2, randomBytes: randomBytes4 } = CURVE;
4166
5662
  let { lowS, prehash, extraEntropy: ent } = opts;
4167
5663
  if (lowS == null)
4168
5664
  lowS = true;
4169
5665
  msgHash = ensureBytes("msgHash", msgHash);
4170
5666
  validateSigVerOpts(opts);
4171
5667
  if (prehash)
4172
- msgHash = ensureBytes("prehashed msgHash", hash(msgHash));
5668
+ msgHash = ensureBytes("prehashed msgHash", hash2(msgHash));
4173
5669
  const h1int = bits2int_modN(msgHash);
4174
5670
  const d = normPrivateKeyToScalar(privateKey);
4175
5671
  const seedArgs = [int2octets(d), int2octets(h1int)];
@@ -4377,7 +5873,7 @@ var init_weierstrass = __esm({
4377
5873
  "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
4378
5874
  init_curve();
4379
5875
  init_modular();
4380
- init_utils2();
5876
+ init_utils3();
4381
5877
  DERErr = class extends Error {
4382
5878
  constructor(m = "") {
4383
5879
  super(m);
@@ -4492,21 +5988,21 @@ var init_weierstrass = __esm({
4492
5988
  });
4493
5989
 
4494
5990
  // ../../node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js
4495
- function getHash(hash) {
5991
+ function getHash(hash2) {
4496
5992
  return {
4497
- hash,
4498
- hmac: (key, ...msgs) => hmac(hash, key, concatBytes(...msgs)),
5993
+ hash: hash2,
5994
+ hmac: (key, ...msgs) => hmac(hash2, key, concatBytes(...msgs)),
4499
5995
  randomBytes: randomBytes2
4500
5996
  };
4501
5997
  }
4502
5998
  function createCurve(curveDef, defHash) {
4503
- const create = (hash) => weierstrass({ ...curveDef, ...getHash(hash) });
5999
+ const create = (hash2) => weierstrass({ ...curveDef, ...getHash(hash2) });
4504
6000
  return { ...create(defHash), create };
4505
6001
  }
4506
6002
  var init_shortw_utils = __esm({
4507
6003
  "../../node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js"() {
4508
6004
  init_hmac();
4509
- init_utils();
6005
+ init_utils2();
4510
6006
  init_weierstrass();
4511
6007
  }
4512
6008
  });
@@ -4578,7 +6074,7 @@ function hash_to_field(msg, count, options) {
4578
6074
  k: "isSafeInteger",
4579
6075
  hash: "hash"
4580
6076
  });
4581
- const { p, k, m, hash, expand, DST: _DST } = options;
6077
+ const { p, k, m, hash: hash2, expand, DST: _DST } = options;
4582
6078
  abytes2(msg);
4583
6079
  anum(count);
4584
6080
  const DST = typeof _DST === "string" ? utf8ToBytes2(_DST) : _DST;
@@ -4587,9 +6083,9 @@ function hash_to_field(msg, count, options) {
4587
6083
  const len_in_bytes = count * m * L;
4588
6084
  let prb;
4589
6085
  if (expand === "xmd") {
4590
- prb = expand_message_xmd(msg, DST, len_in_bytes, hash);
6086
+ prb = expand_message_xmd(msg, DST, len_in_bytes, hash2);
4591
6087
  } else if (expand === "xof") {
4592
- prb = expand_message_xof(msg, DST, len_in_bytes, k, hash);
6088
+ prb = expand_message_xof(msg, DST, len_in_bytes, k, hash2);
4593
6089
  } else if (expand === "_internal_pass") {
4594
6090
  prb = msg;
4595
6091
  } else {
@@ -4661,7 +6157,7 @@ var os2ip;
4661
6157
  var init_hash_to_curve = __esm({
4662
6158
  "../../node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
4663
6159
  init_modular();
4664
- init_utils2();
6160
+ init_utils3();
4665
6161
  os2ip = bytesToNumberBE;
4666
6162
  }
4667
6163
  });
@@ -4772,11 +6268,11 @@ var secp256k1P, secp256k1N, _0n6, _1n6, _2n4, divNearest, Fpk1, secp256k1, TAGGE
4772
6268
  var init_secp256k1 = __esm({
4773
6269
  "../../node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js"() {
4774
6270
  init_sha2();
4775
- init_utils();
6271
+ init_utils2();
4776
6272
  init_shortw_utils();
4777
6273
  init_hash_to_curve();
4778
6274
  init_modular();
4779
- init_utils2();
6275
+ init_utils3();
4780
6276
  init_weierstrass();
4781
6277
  secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
4782
6278
  secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
@@ -4897,6 +6393,30 @@ var init_secp256k1 = __esm({
4897
6393
  }
4898
6394
  });
4899
6395
 
6396
+ // ../../node_modules/viem/_esm/utils/abi/decodeFunctionData.js
6397
+ function decodeFunctionData(parameters) {
6398
+ const { abi, data } = parameters;
6399
+ const signature = slice(data, 0, 4);
6400
+ const description = abi.find((x) => x.type === "function" && signature === toFunctionSelector(formatAbiItem2(x)));
6401
+ if (!description)
6402
+ throw new AbiFunctionSignatureNotFoundError(signature, {
6403
+ docsPath: "/docs/contract/decodeFunctionData"
6404
+ });
6405
+ return {
6406
+ functionName: description.name,
6407
+ args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbiParameters(description.inputs, slice(data, 4)) : void 0
6408
+ };
6409
+ }
6410
+ var init_decodeFunctionData = __esm({
6411
+ "../../node_modules/viem/_esm/utils/abi/decodeFunctionData.js"() {
6412
+ init_abi();
6413
+ init_slice();
6414
+ init_toFunctionSelector();
6415
+ init_decodeAbiParameters();
6416
+ init_formatAbiItem2();
6417
+ }
6418
+ });
6419
+
4900
6420
  // ../../node_modules/@msgpack/msgpack/dist.cjs/utils/utf8.cjs
4901
6421
  var require_utf8 = __commonJS({
4902
6422
  "../../node_modules/@msgpack/msgpack/dist.cjs/utils/utf8.cjs"(exports) {
@@ -6619,6 +8139,7 @@ import {
6619
8139
  Chain,
6620
8140
  getChainKind,
6621
8141
  StorageError,
8142
+ toCosmosSequenceMismatchError,
6622
8143
  VaultError,
6623
8144
  VaultErrorCode,
6624
8145
  VaultImportError,
@@ -6966,6 +8487,20 @@ function classifyVaultError(err) {
6966
8487
  case VaultErrorCode.BroadcastFailed: {
6967
8488
  const broadcastChain = getBroadcastErrorChain(err.message);
6968
8489
  const isCosmosBroadcast = broadcastChain !== void 0 && getChainKind(broadcastChain) === "cosmos";
8490
+ const sequenceMismatch = isCosmosBroadcast ? toCosmosSequenceMismatchError(err) : void 0;
8491
+ if (sequenceMismatch?.recovery === "resign") {
8492
+ return new InvalidInputError(
8493
+ err.message,
8494
+ "The account sequence changed after this transaction was prepared. Rebuild the transaction with the latest sequence and start a new signing ceremony; retrying the same signed bytes cannot succeed."
8495
+ );
8496
+ }
8497
+ if (sequenceMismatch?.recovery === "wait") {
8498
+ return new ExternalServiceError(
8499
+ err.message,
8500
+ "This transaction uses a future account sequence. Wait for the preceding transaction to be accepted before retrying these signed bytes.",
8501
+ ["If the chain advances past this sequence, rebuild the transaction and start a new signing ceremony"]
8502
+ );
8503
+ }
6969
8504
  if (isCosmosBroadcast && matchCosmosDeliverTxFailure(err.message)) {
6970
8505
  return new InvalidInputError(
6971
8506
  err.message,
@@ -8385,13 +9920,13 @@ function readRecords() {
8385
9920
  }
8386
9921
  return records;
8387
9922
  }
8388
- function recordBroadcast(fingerprint, hash, chain) {
8389
- if (!hash) return;
8390
- appendRecord({ t: "broadcast", fp: fingerprint, hash, chain, ts: nowMs() });
9923
+ function recordBroadcast(fingerprint, hash2, chain) {
9924
+ if (!hash2) return;
9925
+ appendRecord({ t: "broadcast", fp: fingerprint, hash: hash2, chain, ts: nowMs() });
8391
9926
  }
8392
- function recordResolution(hash, status) {
8393
- if (!hash) return;
8394
- appendRecord({ t: "resolved", hash, status, ts: nowMs() });
9927
+ function recordResolution(hash2, status) {
9928
+ if (!hash2) return;
9929
+ appendRecord({ t: "resolved", hash: hash2, status, ts: nowMs() });
8395
9930
  }
8396
9931
  function findRecentDuplicate(fingerprint, options = {}) {
8397
9932
  const windowMs = options.windowMs ?? DEFAULT_BROADCAST_WINDOW_MS;
@@ -8858,7 +10393,13 @@ async function executeAddresses(ctx2) {
8858
10393
  }
8859
10394
 
8860
10395
  // src/commands/tokens.ts
10396
+ import { getChainKind as getChainKind3 } from "@vultisig/sdk";
8861
10397
  import chalk4 from "chalk";
10398
+ function canonicalTokenId(chain, id) {
10399
+ const legacyPrefix = `${chain}-`;
10400
+ const bareId = id.toLowerCase().startsWith(legacyPrefix.toLowerCase()) ? id.slice(legacyPrefix.length) : id;
10401
+ return getChainKind3(chain) === "evm" ? bareId.toLowerCase() : bareId;
10402
+ }
8862
10403
  async function executeTokens(ctx2, options) {
8863
10404
  await ctx2.ensureActiveVault();
8864
10405
  if (options.discover) {
@@ -8917,9 +10458,10 @@ async function executeTokens(ctx2, options) {
8917
10458
  }
8918
10459
  async function addToken(ctx2, options) {
8919
10460
  const vault = await ctx2.ensureActiveVault();
10461
+ const contractAddress = canonicalTokenId(options.chain, options.contractAddress);
8920
10462
  await vault.addToken(options.chain, {
8921
- id: `${options.chain}-${options.contractAddress}`,
8922
- contractAddress: options.contractAddress,
10463
+ id: contractAddress,
10464
+ contractAddress,
8923
10465
  symbol: options.symbol,
8924
10466
  name: options.name,
8925
10467
  decimals: options.decimals,
@@ -8935,6 +10477,10 @@ async function removeToken(ctx2, chain, tokenId) {
8935
10477
  if (!removed) {
8936
10478
  throw new TokenNotFoundError(`Token "${tokenId}" not found on ${chain}`);
8937
10479
  }
10480
+ if (isJsonOutput()) {
10481
+ outputJson({ chain, tokenId, removed: true });
10482
+ return;
10483
+ }
8938
10484
  success(`
8939
10485
  + Removed token ${tokenId} from ${chain}`);
8940
10486
  }
@@ -8956,15 +10502,18 @@ async function discoverTokens(ctx2, chain) {
8956
10502
  return;
8957
10503
  }
8958
10504
  const existingTokens = vault.getTokens(chain);
8959
- const existingAddresses = new Set(existingTokens.map((t) => t.contractAddress ?? t.id));
8960
- const newTokens = discovered.filter((d) => d.contractAddress && !existingAddresses.has(d.contractAddress));
10505
+ const existingAddresses = new Set(existingTokens.map((t) => canonicalTokenId(chain, t.contractAddress ?? t.id)));
10506
+ const newTokens = discovered.filter(
10507
+ (d) => d.contractAddress && !existingAddresses.has(canonicalTokenId(chain, d.contractAddress))
10508
+ );
8961
10509
  for (const d of newTokens) {
10510
+ const contractAddress = canonicalTokenId(chain, d.contractAddress);
8962
10511
  await vault.addToken(chain, {
8963
- id: d.contractAddress,
10512
+ id: contractAddress,
8964
10513
  symbol: d.ticker,
8965
10514
  name: d.ticker,
8966
10515
  decimals: d.decimals,
8967
- contractAddress: d.contractAddress,
10516
+ contractAddress,
8968
10517
  chainId: chain,
8969
10518
  isNative: false
8970
10519
  });
@@ -10666,6 +12215,9 @@ Please specify more characters of the vault ID.`
10666
12215
  // src/commands/swap.ts
10667
12216
  import { toChainAmount } from "@vultisig/sdk";
10668
12217
 
12218
+ // ../../node_modules/viem/_esm/index.js
12219
+ init_exports();
12220
+
10669
12221
  // ../../node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js
10670
12222
  init_getAddress();
10671
12223
  init_keccak256();
@@ -10679,8 +12231,8 @@ init_isHex();
10679
12231
  init_size();
10680
12232
  init_fromHex();
10681
12233
  init_toHex();
10682
- async function recoverPublicKey({ hash, signature }) {
10683
- const hashHex = isHex(hash) ? hash : toHex(hash);
12234
+ async function recoverPublicKey({ hash: hash2, signature }) {
12235
+ const hashHex = isHex(hash2) ? hash2 : toHex(hash2);
10684
12236
  const { secp256k1: secp256k12 } = await Promise.resolve().then(() => (init_secp256k1(), secp256k1_exports));
10685
12237
  const signature_ = (() => {
10686
12238
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
@@ -10710,8 +12262,8 @@ function toRecoveryBit(yParityOrV) {
10710
12262
  }
10711
12263
 
10712
12264
  // ../../node_modules/viem/_esm/utils/signature/recoverAddress.js
10713
- async function recoverAddress({ hash, signature }) {
10714
- return publicKeyToAddress(await recoverPublicKey({ hash, signature }));
12265
+ async function recoverAddress({ hash: hash2, signature }) {
12266
+ return publicKeyToAddress(await recoverPublicKey({ hash: hash2, signature }));
10715
12267
  }
10716
12268
 
10717
12269
  // ../../node_modules/viem/_esm/utils/signature/hashTypedData.js
@@ -10727,14 +12279,14 @@ init_address();
10727
12279
  // ../../node_modules/viem/_esm/errors/typedData.js
10728
12280
  init_stringify();
10729
12281
  init_base();
10730
- var InvalidDomainError = class extends BaseError {
12282
+ var InvalidDomainError = class extends BaseError2 {
10731
12283
  constructor({ domain }) {
10732
12284
  super(`Invalid domain "${stringify(domain)}".`, {
10733
12285
  metaMessages: ["Must be a valid EIP-712 domain."]
10734
12286
  });
10735
12287
  }
10736
12288
  };
10737
- var InvalidPrimaryTypeError = class extends BaseError {
12289
+ var InvalidPrimaryTypeError = class extends BaseError2 {
10738
12290
  constructor({ primaryType, types }) {
10739
12291
  super(`Invalid primary type \`${primaryType}\` must be one of \`${JSON.stringify(Object.keys(types))}\`.`, {
10740
12292
  docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror",
@@ -10742,7 +12294,7 @@ var InvalidPrimaryTypeError = class extends BaseError {
10742
12294
  });
10743
12295
  }
10744
12296
  };
10745
- var InvalidStructTypeError = class extends BaseError {
12297
+ var InvalidStructTypeError = class extends BaseError2 {
10746
12298
  constructor({ type }) {
10747
12299
  super(`Struct type "${type}" is invalid.`, {
10748
12300
  metaMessages: ["Struct type must not be a Solidity type."],
@@ -10755,14 +12307,14 @@ var InvalidStructTypeError = class extends BaseError {
10755
12307
  init_isAddress();
10756
12308
  init_size();
10757
12309
  init_toHex();
10758
- init_regex();
12310
+ init_regex2();
10759
12311
  function validateTypedData(parameters) {
10760
12312
  const { domain, message, primaryType, types } = parameters;
10761
12313
  const validateData = (struct, data) => {
10762
12314
  for (const param of struct) {
10763
12315
  const { name, type } = param;
10764
12316
  const value = data[name];
10765
- const integerMatch = type.match(integerRegex);
12317
+ const integerMatch = type.match(integerRegex2);
10766
12318
  if (integerMatch && (typeof value === "number" || typeof value === "bigint")) {
10767
12319
  const [_type, base, size_] = integerMatch;
10768
12320
  numberToHex(value, {
@@ -10772,7 +12324,7 @@ function validateTypedData(parameters) {
10772
12324
  }
10773
12325
  if (type === "address" && typeof value === "string" && !isAddress(value))
10774
12326
  throw new InvalidAddressError2({ address: value });
10775
- const bytesMatch = type.match(bytesRegex);
12327
+ const bytesMatch = type.match(bytesRegex2);
10776
12328
  if (bytesMatch) {
10777
12329
  const [_type, size_] = bytesMatch;
10778
12330
  if (size_ && size(value) !== Number.parseInt(size_, 10))
@@ -10937,6 +12489,7 @@ function formatUnits(value, decimals) {
10937
12489
  }
10938
12490
 
10939
12491
  // ../../node_modules/viem/_esm/index.js
12492
+ init_decodeFunctionData();
10940
12493
  init_concat();
10941
12494
  init_toBytes();
10942
12495
  init_keccak256();
@@ -12167,15 +13720,16 @@ function extractSurfaceFromText(content, surfaceKey, parser) {
12167
13720
  import { randomUUID } from "node:crypto";
12168
13721
 
12169
13722
  // src/agent/toolOutputSigning.ts
12170
- import { getChainKind as getChainKind4 } from "@vultisig/sdk";
13723
+ import { getChainKind as getChainKind5 } from "@vultisig/sdk";
12171
13724
 
12172
13725
  // src/agent/executor.ts
12173
13726
  import {
12174
13727
  Chain as Chain11,
12175
13728
  chainFeeCoin as chainFeeCoin2,
12176
13729
  computeEip712Hash,
12177
- getChainKind as getChainKind3,
13730
+ getChainKind as getChainKind4,
12178
13731
  getEvmRpcUrl,
13732
+ knownTokensIndex,
12179
13733
  parseThorSwapMemo,
12180
13734
  resolveChainReference,
12181
13735
  toCanonicalEvmSignature,
@@ -12583,6 +14137,18 @@ var EVM_CHAINS = /* @__PURE__ */ new Set([
12583
14137
  "Hyperliquid",
12584
14138
  "Sei"
12585
14139
  ]);
14140
+ var ERC20_TRANSFER_SELECTOR = "0xa9059cbb";
14141
+ var ERC20_TRANSFER_ABI = parseAbi(["function transfer(address to, uint256 value)"]);
14142
+ function decodeErc20Transfer(calldata) {
14143
+ if (calldata.slice(0, ERC20_TRANSFER_SELECTOR.length).toLowerCase() !== ERC20_TRANSFER_SELECTOR) return null;
14144
+ try {
14145
+ const decoded = decodeFunctionData({ abi: ERC20_TRANSFER_ABI, data: calldata });
14146
+ const [recipient, amount] = decoded.args;
14147
+ return { recipient, amount };
14148
+ } catch {
14149
+ throw new Error("Invalid ERC-20 transfer calldata \u2014 refusing to sign");
14150
+ }
14151
+ }
12586
14152
  var isEvmChain = (chain) => EVM_CHAINS.has(chain);
12587
14153
  var AgentExecutor = class {
12588
14154
  vault;
@@ -12717,7 +14283,7 @@ var AgentExecutor = class {
12717
14283
  */
12718
14284
  buildBroadcastIntent(payload, chain, overrideTx) {
12719
14285
  const source = overrideTx ?? payload;
12720
- const dataIsEvmCalldata = getChainKind3(chain) === "evm";
14286
+ const dataIsEvmCalldata = getChainKind4(chain) === "evm";
12721
14287
  const nested = extractNestedTx(source);
12722
14288
  if (nested && (nested.to || nested.value || nested.data)) {
12723
14289
  return {
@@ -12823,7 +14389,7 @@ var AgentExecutor = class {
12823
14389
  const txArgs = txReadyData.txArgs;
12824
14390
  if (txArgs && typeof txArgs === "object" && typeof txArgs.to === "string" && typeof txArgs.amount === "string") {
12825
14391
  const chain2 = resolveChainFromTxReady(txReadyData) || Chain11.Ethereum;
12826
- if (getChainKind3(chain2) !== "evm") {
14392
+ if (getChainKind4(chain2) !== "evm") {
12827
14393
  this.pendingPayloads.clear();
12828
14394
  this.pendingLegs = [];
12829
14395
  this.pendingPayloads.set("latest", {
@@ -12834,7 +14400,7 @@ var AgentExecutor = class {
12834
14400
  });
12835
14401
  if (this.verbose)
12836
14402
  process.stderr.write(
12837
- `[executor] Stored non-EVM server tx for chain ${chain2} (kind=${getChainKind3(chain2)})
14403
+ `[executor] Stored non-EVM server tx for chain ${chain2} (kind=${getChainKind4(chain2)})
12838
14404
  `
12839
14405
  );
12840
14406
  return true;
@@ -12886,6 +14452,50 @@ var AgentExecutor = class {
12886
14452
  getPendingChain() {
12887
14453
  return this.pendingPayloads.get("latest")?.chain ?? null;
12888
14454
  }
14455
+ /**
14456
+ * If the transaction that will actually be signed carries ERC-20 `transfer`
14457
+ * calldata, decode its destination and amount and cross-check them against
14458
+ * the producer's declared values. Returns the decoded transfer (authoritative
14459
+ * for the summary) when the signed tx is a transfer, or null otherwise.
14460
+ *
14461
+ * Reads the signed tx via {@link extractNestedTx} — the SAME resolution the
14462
+ * signer uses (`swap_tx || send_tx || tx || txArgs.tx`) — not `txArgs.tx`
14463
+ * alone: a `send_tx`/`tx`/`swap_tx` envelope, or one carrying both a benign
14464
+ * `txArgs.tx` and a malicious higher-precedence key, must not be able to move
14465
+ * funds to an address the consent summary never showed. Fails closed —
14466
+ * clearing the buffered tx and throwing — on malformed transfer calldata or a
14467
+ * producer/calldata recipient or amount mismatch, so a divergent envelope can
14468
+ * never be signed. Invoked before the branch-specific summaries below so a
14469
+ * transfer cannot be disguised as a swap/contract-call to skip the check.
14470
+ */
14471
+ assertConsistentTransfer(p) {
14472
+ const signedTx = extractNestedTx(p);
14473
+ const calldata = typeof signedTx?.data === "string" ? signedTx.data : "";
14474
+ if (calldata === "" || calldata === "0x") return null;
14475
+ let transfer;
14476
+ try {
14477
+ transfer = decodeErc20Transfer(calldata);
14478
+ } catch (error2) {
14479
+ this.clearPendingTransaction();
14480
+ throw error2;
14481
+ }
14482
+ if (!transfer) return null;
14483
+ const producerRecipient = typeof p?.txArgs?.to === "string" ? p.txArgs.to : "";
14484
+ if (producerRecipient && transfer.recipient.toLowerCase() !== producerRecipient.toLowerCase()) {
14485
+ this.clearPendingTransaction();
14486
+ throw new Error(
14487
+ `ERC-20 recipient mismatch \u2014 refusing to sign: txArgs.to ${producerRecipient} does not match calldata destination ${transfer.recipient}`
14488
+ );
14489
+ }
14490
+ const producerAmount = typeof p?.txArgs?.amount === "string" ? p.txArgs.amount : "";
14491
+ if (producerAmount && /^\d+$/.test(producerAmount) && BigInt(producerAmount) !== transfer.amount) {
14492
+ this.clearPendingTransaction();
14493
+ throw new Error(
14494
+ `ERC-20 amount mismatch \u2014 refusing to sign: txArgs.amount ${producerAmount} does not match calldata value ${transfer.amount}`
14495
+ );
14496
+ }
14497
+ return { recipient: transfer.recipient, amount: transfer.amount };
14498
+ }
12889
14499
  /**
12890
14500
  * Human-readable one-line summary of the currently-buffered server tx
12891
14501
  * (set by storeServerTransaction), for the pre-sign confirmation prompt.
@@ -12897,6 +14507,7 @@ var AgentExecutor = class {
12897
14507
  if (!stored) return null;
12898
14508
  const p = stored.payload;
12899
14509
  const labels = p?.resolved?.labels ?? {};
14510
+ const transfer = this.assertConsistentTransfer(p);
12900
14511
  if (p?.__buildTx) {
12901
14512
  const action = typeof p?.action === "string" && p.action ? ` [${p.action}]` : "";
12902
14513
  if (p?.__multiLeg) {
@@ -12919,16 +14530,36 @@ var AgentExecutor = class {
12919
14530
  if (labels.estimated_fee) parts.push(`est. fee ${labels.estimated_fee}`);
12920
14531
  return parts.join(" ");
12921
14532
  }
14533
+ const signedTx = extractNestedTx(p);
14534
+ const contractTo = typeof signedTx?.to === "string" ? signedTx.to : "";
14535
+ const calldata = typeof signedTx?.data === "string" ? signedTx.data : "";
14536
+ const isContractSend = !!contractTo && calldata !== "" && calldata !== "0x";
14537
+ const producerRecipient = typeof p?.txArgs?.to === "string" ? p.txArgs.to : "";
14538
+ const to = transfer?.recipient || producerRecipient || labels.recipient_echo || "?";
14539
+ if (transfer) {
14540
+ return this.renderErc20TransferSummary(transfer.amount, contractTo, stored.chain, to);
14541
+ }
12922
14542
  const amount = labels.resolved_amount ?? p?.txArgs?.amount ?? "?";
12923
14543
  const symbol = labels.token_resolved || labels.token_symbol || "";
12924
14544
  const amountWithSymbol = symbol && !amount.endsWith(` ${symbol}`) ? `${amount} ${symbol}` : amount;
12925
- const to = p?.txArgs?.to || labels.recipient_echo || "?";
12926
- const contractTo = typeof p?.txArgs?.tx?.to === "string" ? p.txArgs.tx.to : "";
12927
- const calldata = typeof p?.txArgs?.tx?.data === "string" ? p.txArgs.tx.data : "";
12928
- const isContractSend = !!contractTo && calldata !== "" && calldata !== "0x";
12929
14545
  const contractPart = isContractSend && contractTo.toLowerCase() !== to.toLowerCase() ? ` (token contract ${contractTo})` : "";
12930
14546
  return `send ${amountWithSymbol} on ${stored.chain} to ${to}${contractPart}`;
12931
14547
  }
14548
+ /**
14549
+ * Render the consent amount for an ERC-20 transfer from the SIGNED calldata
14550
+ * value, never a producer label. Known tokens use trusted decimals/ticker from
14551
+ * knownTokensIndex; unknown tokens fall back to raw base units with an explicit
14552
+ * unverified marker (the recipient is already cross-checked, so we never fail
14553
+ * closed here).
14554
+ */
14555
+ renderErc20TransferSummary(amount, contractTo, chain, to) {
14556
+ const known = knownTokensIndex[chain]?.[contractTo.toLowerCase()];
14557
+ if (known) {
14558
+ const contractPart = contractTo.toLowerCase() !== to.toLowerCase() ? ` (token contract ${contractTo})` : "";
14559
+ return `send ${formatUnits(amount, known.decimals)} ${known.ticker} on ${chain} to ${to}${contractPart}`;
14560
+ }
14561
+ return `send ${amount} base units of token ${contractTo} (decimals unverified) on ${chain} to ${to}`;
14562
+ }
12932
14563
  /**
12933
14564
  * Wrap a per-tool handler body with normalised success/failure → RecentAction
12934
14565
  * conversion. Replaces the legacy executeAction → ActionResult adapter that
@@ -13199,7 +14830,7 @@ var AgentExecutor = class {
13199
14830
  */
13200
14831
  async signServerTx(serverTxData, defaultChain, params) {
13201
14832
  const chain = resolveChainFromTxReady(serverTxData) || defaultChain;
13202
- const chainKind = getChainKind3(chain);
14833
+ const chainKind = getChainKind4(chain);
13203
14834
  if (chainKind === "evm") {
13204
14835
  return this.signEvmServerTx(serverTxData, defaultChain, params);
13205
14836
  }
@@ -14186,7 +15817,7 @@ function resolveStrictEvmChain(chain, chainId) {
14186
15817
  const byName = resolveChain(chain);
14187
15818
  const byId = resolveChainId(chainId);
14188
15819
  if (!byName || !byId || byName !== byId) return null;
14189
- if (getChainKind4(byName) !== "evm") return null;
15820
+ if (getChainKind5(byName) !== "evm") return null;
14190
15821
  return byName;
14191
15822
  }
14192
15823
  function asChainString(value) {
@@ -14250,7 +15881,7 @@ function buildTxReadyFromYieldOutput(toolName, output) {
14250
15881
  const chain = asChainString(env.chain);
14251
15882
  if (!chain) return null;
14252
15883
  const resolved = resolveChain(chain);
14253
- if (!resolved || getChainKind4(resolved) !== "evm") return null;
15884
+ if (!resolved || getChainKind5(resolved) !== "evm") return null;
14254
15885
  const chainStr = chain;
14255
15886
  const rawTxs = env.transactions;
14256
15887
  if (!Array.isArray(rawTxs) || rawTxs.length === 0) return null;
@@ -15708,8 +17339,8 @@ var TX_CONFIRM_MAX_POLLS = 40;
15708
17339
  function hasUnacknowledgedBroadcastResult(results) {
15709
17340
  return results.some((r) => {
15710
17341
  if (!r.success || !r.data) return false;
15711
- const hash = r.data.tx_hash;
15712
- return typeof hash === "string" && hash.length > 0;
17342
+ const hash2 = r.data.tx_hash;
17343
+ return typeof hash2 === "string" && hash2.length > 0;
15713
17344
  });
15714
17345
  }
15715
17346
  function reportDeclinedSigning(executor, toolName, toolCallId, summary, input, ui) {
@@ -17547,7 +19178,7 @@ var cachedVersion = null;
17547
19178
  function getVersion() {
17548
19179
  if (cachedVersion) return cachedVersion;
17549
19180
  if (true) {
17550
- cachedVersion = "4.6.0";
19181
+ cachedVersion = "4.7.0";
17551
19182
  return cachedVersion;
17552
19183
  }
17553
19184
  try {
@@ -19935,8 +21566,8 @@ list, so it also changes what portfolio and balance --tokens report. Use
19935
21566
  Examples:
19936
21567
  vultisig tokens Ethereum
19937
21568
  vultisig tokens Ethereum --discover --output json
19938
- vultisig tokens Ethereum --add 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 --symbol USDC --decimals 6`
19939
- ).option("--symbol <symbol>", "Token symbol (for --add)").option("--name <name>", "Token name (for --add)").option("--decimals <decimals>", "Token decimals (for --add)", "18").action(
21569
+ vultisig tokens Ethereum --add 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 --symbol USDC --name "USD Coin" --decimals 6`
21570
+ ).option("--symbol <symbol>", "Token symbol (for --add)").option("--name <name>", "Token name (required with --add)").option("--decimals <decimals>", "Token decimals (for --add)", "18").action(
19940
21571
  withExit(
19941
21572
  async (chainStr, options) => {
19942
21573
  const chain = resolveChainOrThrow(chainStr);