@chainflip/sdk 1.3.0 → 1.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{broker-6ZGPANTJ.mjs → broker-5HOSXLXI.mjs} +15 -6
- package/dist/chunk-75XPVTLV.mjs +65 -0
- package/dist/{chunk-BFEB7XAP.mjs → chunk-HT34JS2O.mjs} +39 -65
- package/dist/{chunk-QNH6727P.mjs → chunk-Q6JCV35Y.mjs} +290 -78
- package/dist/{contracts-b0BB7B5m.d.mts → contracts-ZLesmWHT.d.mts} +4 -2
- package/dist/{contracts-b0BB7B5m.d.ts → contracts-ZLesmWHT.d.ts} +4 -2
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/funding.js +320 -146
- package/dist/funding.mjs +8 -6
- package/dist/swap.d.mts +36 -9
- package/dist/swap.d.ts +36 -9
- package/dist/swap.js +463 -244
- package/dist/swap.mjs +69 -78
- package/package.json +2 -2
- package/dist/chunk-J5DGP4KI.mjs +0 -31
|
@@ -591,18 +591,18 @@ function isValidAssetAndChain(assetAndChain2) {
|
|
|
591
591
|
return validAssets.includes(asset2);
|
|
592
592
|
}
|
|
593
593
|
__name(isValidAssetAndChain, "isValidAssetAndChain");
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}
|
|
599
|
-
__name(assertIsValidAssetAndChain, "assertIsValidAssetAndChain");
|
|
600
|
-
var readChainAssetValue = /* @__PURE__ */ __name((map, assetAndChain2) => {
|
|
601
|
-
assertIsValidAssetAndChain(assetAndChain2);
|
|
602
|
-
const chainValues = map[assetAndChain2.chain];
|
|
603
|
-
return chainValues[assetAndChain2.asset];
|
|
594
|
+
var readChainAssetValue = /* @__PURE__ */ __name((map, asset2) => {
|
|
595
|
+
const { chain: chain2, asset: symbol } = assetConstants[asset2];
|
|
596
|
+
const chainValues = map[chain2];
|
|
597
|
+
return chainValues[symbol];
|
|
604
598
|
}, "readChainAssetValue");
|
|
605
|
-
function getInternalAsset(asset2) {
|
|
599
|
+
function getInternalAsset(asset2, assert2 = true) {
|
|
600
|
+
if (!isValidAssetAndChain(asset2)) {
|
|
601
|
+
if (assert2) {
|
|
602
|
+
throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset2)}`);
|
|
603
|
+
}
|
|
604
|
+
return null;
|
|
605
|
+
}
|
|
606
606
|
const map = {
|
|
607
607
|
[Chains.Ethereum]: {
|
|
608
608
|
[Assets.USDC]: InternalAssets.Usdc,
|
|
@@ -621,11 +621,25 @@ function getInternalAsset(asset2) {
|
|
|
621
621
|
[Assets.ETH]: InternalAssets.ArbEth
|
|
622
622
|
}
|
|
623
623
|
};
|
|
624
|
-
|
|
624
|
+
const chain2 = map[asset2.chain];
|
|
625
|
+
return chain2[asset2.asset];
|
|
625
626
|
}
|
|
626
627
|
__name(getInternalAsset, "getInternalAsset");
|
|
628
|
+
function getInternalAssets({ srcAsset, srcChain, destAsset, destChain }, assert2 = true) {
|
|
629
|
+
return {
|
|
630
|
+
srcAsset: getInternalAsset({
|
|
631
|
+
asset: srcAsset,
|
|
632
|
+
chain: srcChain
|
|
633
|
+
}, assert2),
|
|
634
|
+
destAsset: getInternalAsset({
|
|
635
|
+
asset: destAsset,
|
|
636
|
+
chain: destChain
|
|
637
|
+
}, assert2)
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
__name(getInternalAssets, "getInternalAssets");
|
|
627
641
|
|
|
628
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
642
|
+
// ../../node_modules/.pnpm/zod@3.23.0/node_modules/zod/lib/index.mjs
|
|
629
643
|
var util;
|
|
630
644
|
(function(util2) {
|
|
631
645
|
util2.assertEqual = (val) => val;
|
|
@@ -840,6 +854,11 @@ var _ZodError = class _ZodError extends Error {
|
|
|
840
854
|
processError(this);
|
|
841
855
|
return fieldErrors;
|
|
842
856
|
}
|
|
857
|
+
static assert(value) {
|
|
858
|
+
if (!(value instanceof _ZodError)) {
|
|
859
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
843
862
|
toString() {
|
|
844
863
|
return this.message;
|
|
845
864
|
}
|
|
@@ -986,6 +1005,13 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
|
|
|
986
1005
|
...issueData,
|
|
987
1006
|
path: fullPath
|
|
988
1007
|
};
|
|
1008
|
+
if (issueData.message !== void 0) {
|
|
1009
|
+
return {
|
|
1010
|
+
...issueData,
|
|
1011
|
+
path: fullPath,
|
|
1012
|
+
message: issueData.message
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
989
1015
|
let errorMessage = "";
|
|
990
1016
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
991
1017
|
for (const map of maps) {
|
|
@@ -994,11 +1020,12 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
|
|
|
994
1020
|
return {
|
|
995
1021
|
...issueData,
|
|
996
1022
|
path: fullPath,
|
|
997
|
-
message:
|
|
1023
|
+
message: errorMessage
|
|
998
1024
|
};
|
|
999
1025
|
}, "makeIssue");
|
|
1000
1026
|
var EMPTY_PATH = [];
|
|
1001
1027
|
function addIssueToContext(ctx, issueData) {
|
|
1028
|
+
const overrideMap = getErrorMap();
|
|
1002
1029
|
const issue = makeIssue({
|
|
1003
1030
|
issueData,
|
|
1004
1031
|
data: ctx.data,
|
|
@@ -1006,8 +1033,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
1006
1033
|
errorMaps: [
|
|
1007
1034
|
ctx.common.contextualErrorMap,
|
|
1008
1035
|
ctx.schemaErrorMap,
|
|
1009
|
-
|
|
1010
|
-
errorMap
|
|
1036
|
+
overrideMap,
|
|
1037
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
1011
1038
|
// then global default map
|
|
1012
1039
|
].filter((x) => !!x)
|
|
1013
1040
|
});
|
|
@@ -1040,9 +1067,11 @@ var _ParseStatus = class _ParseStatus {
|
|
|
1040
1067
|
static async mergeObjectAsync(status, pairs) {
|
|
1041
1068
|
const syncPairs = [];
|
|
1042
1069
|
for (const pair of pairs) {
|
|
1070
|
+
const key = await pair.key;
|
|
1071
|
+
const value = await pair.value;
|
|
1043
1072
|
syncPairs.push({
|
|
1044
|
-
key
|
|
1045
|
-
value
|
|
1073
|
+
key,
|
|
1074
|
+
value
|
|
1046
1075
|
});
|
|
1047
1076
|
}
|
|
1048
1077
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -1077,11 +1106,31 @@ var isAborted = /* @__PURE__ */ __name((x) => x.status === "aborted", "isAborted
|
|
|
1077
1106
|
var isDirty = /* @__PURE__ */ __name((x) => x.status === "dirty", "isDirty");
|
|
1078
1107
|
var isValid = /* @__PURE__ */ __name((x) => x.status === "valid", "isValid");
|
|
1079
1108
|
var isAsync = /* @__PURE__ */ __name((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
|
|
1109
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
1110
|
+
if (kind === "a" && !f)
|
|
1111
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
1112
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
1113
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1114
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1115
|
+
}
|
|
1116
|
+
__name(__classPrivateFieldGet, "__classPrivateFieldGet");
|
|
1117
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
1118
|
+
if (kind === "m")
|
|
1119
|
+
throw new TypeError("Private method is not writable");
|
|
1120
|
+
if (kind === "a" && !f)
|
|
1121
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
1122
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
1123
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1124
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
1125
|
+
}
|
|
1126
|
+
__name(__classPrivateFieldSet, "__classPrivateFieldSet");
|
|
1080
1127
|
var errorUtil;
|
|
1081
1128
|
(function(errorUtil2) {
|
|
1082
1129
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
1083
1130
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
1084
1131
|
})(errorUtil || (errorUtil = {}));
|
|
1132
|
+
var _ZodEnum_cache;
|
|
1133
|
+
var _ZodNativeEnum_cache;
|
|
1085
1134
|
var _ParseInputLazyPath = class _ParseInputLazyPath {
|
|
1086
1135
|
constructor(parent, value, path, key) {
|
|
1087
1136
|
this._cachedPath = [];
|
|
@@ -1132,12 +1181,17 @@ function processCreateParams(params) {
|
|
|
1132
1181
|
if (errorMap3)
|
|
1133
1182
|
return { errorMap: errorMap3, description };
|
|
1134
1183
|
const customMap = /* @__PURE__ */ __name((iss, ctx) => {
|
|
1135
|
-
|
|
1136
|
-
|
|
1184
|
+
var _a, _b;
|
|
1185
|
+
const { message } = params;
|
|
1186
|
+
if (iss.code === "invalid_enum_value") {
|
|
1187
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
1188
|
+
}
|
|
1137
1189
|
if (typeof ctx.data === "undefined") {
|
|
1138
|
-
return { message:
|
|
1190
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
1139
1191
|
}
|
|
1140
|
-
|
|
1192
|
+
if (iss.code !== "invalid_type")
|
|
1193
|
+
return { message: ctx.defaultError };
|
|
1194
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
1141
1195
|
}, "customMap");
|
|
1142
1196
|
return { errorMap: customMap, description };
|
|
1143
1197
|
}
|
|
@@ -1388,35 +1442,43 @@ var _ZodType = class _ZodType {
|
|
|
1388
1442
|
__name(_ZodType, "ZodType");
|
|
1389
1443
|
var ZodType = _ZodType;
|
|
1390
1444
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
1391
|
-
var cuid2Regex = /^[
|
|
1445
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
1392
1446
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
1393
1447
|
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
1394
|
-
var
|
|
1448
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
1449
|
+
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
1450
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
1395
1451
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1396
1452
|
var emojiRegex;
|
|
1397
|
-
var ipv4Regex = /^((
|
|
1453
|
+
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
1398
1454
|
var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
|
1399
|
-
var
|
|
1455
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1456
|
+
var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
1457
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
1458
|
+
function timeRegexSource(args) {
|
|
1459
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
1400
1460
|
if (args.precision) {
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
1405
|
-
}
|
|
1406
|
-
} else if (args.precision === 0) {
|
|
1407
|
-
if (args.offset) {
|
|
1408
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
1409
|
-
} else {
|
|
1410
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
1411
|
-
}
|
|
1412
|
-
} else {
|
|
1413
|
-
if (args.offset) {
|
|
1414
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
1415
|
-
} else {
|
|
1416
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
1417
|
-
}
|
|
1461
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
1462
|
+
} else if (args.precision == null) {
|
|
1463
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
1418
1464
|
}
|
|
1419
|
-
|
|
1465
|
+
return regex;
|
|
1466
|
+
}
|
|
1467
|
+
__name(timeRegexSource, "timeRegexSource");
|
|
1468
|
+
function timeRegex(args) {
|
|
1469
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
1470
|
+
}
|
|
1471
|
+
__name(timeRegex, "timeRegex");
|
|
1472
|
+
function datetimeRegex(args) {
|
|
1473
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
1474
|
+
const opts = [];
|
|
1475
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
1476
|
+
if (args.offset)
|
|
1477
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
1478
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
1479
|
+
return new RegExp(`^${regex}$`);
|
|
1480
|
+
}
|
|
1481
|
+
__name(datetimeRegex, "datetimeRegex");
|
|
1420
1482
|
function isValidIP(ip, version) {
|
|
1421
1483
|
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
1422
1484
|
return true;
|
|
@@ -1435,15 +1497,11 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1435
1497
|
const parsedType = this._getType(input);
|
|
1436
1498
|
if (parsedType !== ZodParsedType.string) {
|
|
1437
1499
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1438
|
-
addIssueToContext(
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
received: ctx2.parsedType
|
|
1444
|
-
}
|
|
1445
|
-
//
|
|
1446
|
-
);
|
|
1500
|
+
addIssueToContext(ctx2, {
|
|
1501
|
+
code: ZodIssueCode.invalid_type,
|
|
1502
|
+
expected: ZodParsedType.string,
|
|
1503
|
+
received: ctx2.parsedType
|
|
1504
|
+
});
|
|
1447
1505
|
return INVALID;
|
|
1448
1506
|
}
|
|
1449
1507
|
const status = new ParseStatus();
|
|
@@ -1534,6 +1592,16 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1534
1592
|
});
|
|
1535
1593
|
status.dirty();
|
|
1536
1594
|
}
|
|
1595
|
+
} else if (check.kind === "nanoid") {
|
|
1596
|
+
if (!nanoidRegex.test(input.data)) {
|
|
1597
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1598
|
+
addIssueToContext(ctx, {
|
|
1599
|
+
validation: "nanoid",
|
|
1600
|
+
code: ZodIssueCode.invalid_string,
|
|
1601
|
+
message: check.message
|
|
1602
|
+
});
|
|
1603
|
+
status.dirty();
|
|
1604
|
+
}
|
|
1537
1605
|
} else if (check.kind === "cuid") {
|
|
1538
1606
|
if (!cuidRegex.test(input.data)) {
|
|
1539
1607
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1635,6 +1703,38 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1635
1703
|
});
|
|
1636
1704
|
status.dirty();
|
|
1637
1705
|
}
|
|
1706
|
+
} else if (check.kind === "date") {
|
|
1707
|
+
const regex = dateRegex;
|
|
1708
|
+
if (!regex.test(input.data)) {
|
|
1709
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1710
|
+
addIssueToContext(ctx, {
|
|
1711
|
+
code: ZodIssueCode.invalid_string,
|
|
1712
|
+
validation: "date",
|
|
1713
|
+
message: check.message
|
|
1714
|
+
});
|
|
1715
|
+
status.dirty();
|
|
1716
|
+
}
|
|
1717
|
+
} else if (check.kind === "time") {
|
|
1718
|
+
const regex = timeRegex(check);
|
|
1719
|
+
if (!regex.test(input.data)) {
|
|
1720
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1721
|
+
addIssueToContext(ctx, {
|
|
1722
|
+
code: ZodIssueCode.invalid_string,
|
|
1723
|
+
validation: "time",
|
|
1724
|
+
message: check.message
|
|
1725
|
+
});
|
|
1726
|
+
status.dirty();
|
|
1727
|
+
}
|
|
1728
|
+
} else if (check.kind === "duration") {
|
|
1729
|
+
if (!durationRegex.test(input.data)) {
|
|
1730
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1731
|
+
addIssueToContext(ctx, {
|
|
1732
|
+
validation: "duration",
|
|
1733
|
+
code: ZodIssueCode.invalid_string,
|
|
1734
|
+
message: check.message
|
|
1735
|
+
});
|
|
1736
|
+
status.dirty();
|
|
1737
|
+
}
|
|
1638
1738
|
} else if (check.kind === "ip") {
|
|
1639
1739
|
if (!isValidIP(input.data, check.version)) {
|
|
1640
1740
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1645,6 +1745,16 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1645
1745
|
});
|
|
1646
1746
|
status.dirty();
|
|
1647
1747
|
}
|
|
1748
|
+
} else if (check.kind === "base64") {
|
|
1749
|
+
if (!base64Regex.test(input.data)) {
|
|
1750
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1751
|
+
addIssueToContext(ctx, {
|
|
1752
|
+
validation: "base64",
|
|
1753
|
+
code: ZodIssueCode.invalid_string,
|
|
1754
|
+
message: check.message
|
|
1755
|
+
});
|
|
1756
|
+
status.dirty();
|
|
1757
|
+
}
|
|
1648
1758
|
} else {
|
|
1649
1759
|
util.assertNever(check);
|
|
1650
1760
|
}
|
|
@@ -1676,6 +1786,9 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1676
1786
|
uuid(message) {
|
|
1677
1787
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
1678
1788
|
}
|
|
1789
|
+
nanoid(message) {
|
|
1790
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
1791
|
+
}
|
|
1679
1792
|
cuid(message) {
|
|
1680
1793
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
1681
1794
|
}
|
|
@@ -1685,16 +1798,20 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1685
1798
|
ulid(message) {
|
|
1686
1799
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
1687
1800
|
}
|
|
1801
|
+
base64(message) {
|
|
1802
|
+
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1803
|
+
}
|
|
1688
1804
|
ip(options) {
|
|
1689
1805
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1690
1806
|
}
|
|
1691
1807
|
datetime(options) {
|
|
1692
|
-
var _a;
|
|
1808
|
+
var _a, _b;
|
|
1693
1809
|
if (typeof options === "string") {
|
|
1694
1810
|
return this._addCheck({
|
|
1695
1811
|
kind: "datetime",
|
|
1696
1812
|
precision: null,
|
|
1697
1813
|
offset: false,
|
|
1814
|
+
local: false,
|
|
1698
1815
|
message: options
|
|
1699
1816
|
});
|
|
1700
1817
|
}
|
|
@@ -1702,9 +1819,30 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1702
1819
|
kind: "datetime",
|
|
1703
1820
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1704
1821
|
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
1822
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
1823
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
date(message) {
|
|
1827
|
+
return this._addCheck({ kind: "date", message });
|
|
1828
|
+
}
|
|
1829
|
+
time(options) {
|
|
1830
|
+
if (typeof options === "string") {
|
|
1831
|
+
return this._addCheck({
|
|
1832
|
+
kind: "time",
|
|
1833
|
+
precision: null,
|
|
1834
|
+
message: options
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
return this._addCheck({
|
|
1838
|
+
kind: "time",
|
|
1839
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1705
1840
|
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
|
|
1706
1841
|
});
|
|
1707
1842
|
}
|
|
1843
|
+
duration(message) {
|
|
1844
|
+
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
1845
|
+
}
|
|
1708
1846
|
regex(regex, message) {
|
|
1709
1847
|
return this._addCheck({
|
|
1710
1848
|
kind: "regex",
|
|
@@ -1783,6 +1921,15 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1783
1921
|
get isDatetime() {
|
|
1784
1922
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1785
1923
|
}
|
|
1924
|
+
get isDate() {
|
|
1925
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
1926
|
+
}
|
|
1927
|
+
get isTime() {
|
|
1928
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
1929
|
+
}
|
|
1930
|
+
get isDuration() {
|
|
1931
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
1932
|
+
}
|
|
1786
1933
|
get isEmail() {
|
|
1787
1934
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
1788
1935
|
}
|
|
@@ -1795,6 +1942,9 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1795
1942
|
get isUUID() {
|
|
1796
1943
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
1797
1944
|
}
|
|
1945
|
+
get isNANOID() {
|
|
1946
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
1947
|
+
}
|
|
1798
1948
|
get isCUID() {
|
|
1799
1949
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
1800
1950
|
}
|
|
@@ -1807,6 +1957,9 @@ var _ZodString = class _ZodString extends ZodType {
|
|
|
1807
1957
|
get isIP() {
|
|
1808
1958
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1809
1959
|
}
|
|
1960
|
+
get isBase64() {
|
|
1961
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1962
|
+
}
|
|
1810
1963
|
get minLength() {
|
|
1811
1964
|
let min = null;
|
|
1812
1965
|
for (const ch of this._def.checks) {
|
|
@@ -2748,9 +2901,10 @@ var _ZodObject = class _ZodObject extends ZodType {
|
|
|
2748
2901
|
const syncPairs = [];
|
|
2749
2902
|
for (const pair of pairs) {
|
|
2750
2903
|
const key = await pair.key;
|
|
2904
|
+
const value = await pair.value;
|
|
2751
2905
|
syncPairs.push({
|
|
2752
2906
|
key,
|
|
2753
|
-
value
|
|
2907
|
+
value,
|
|
2754
2908
|
alwaysSet: pair.alwaysSet
|
|
2755
2909
|
});
|
|
2756
2910
|
}
|
|
@@ -3106,15 +3260,25 @@ var getDiscriminator = /* @__PURE__ */ __name((type) => {
|
|
|
3106
3260
|
} else if (type instanceof ZodEnum) {
|
|
3107
3261
|
return type.options;
|
|
3108
3262
|
} else if (type instanceof ZodNativeEnum) {
|
|
3109
|
-
return
|
|
3263
|
+
return util.objectValues(type.enum);
|
|
3110
3264
|
} else if (type instanceof ZodDefault) {
|
|
3111
3265
|
return getDiscriminator(type._def.innerType);
|
|
3112
3266
|
} else if (type instanceof ZodUndefined) {
|
|
3113
3267
|
return [void 0];
|
|
3114
3268
|
} else if (type instanceof ZodNull) {
|
|
3115
3269
|
return [null];
|
|
3270
|
+
} else if (type instanceof ZodOptional) {
|
|
3271
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
3272
|
+
} else if (type instanceof ZodNullable) {
|
|
3273
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
3274
|
+
} else if (type instanceof ZodBranded) {
|
|
3275
|
+
return getDiscriminator(type.unwrap());
|
|
3276
|
+
} else if (type instanceof ZodReadonly) {
|
|
3277
|
+
return getDiscriminator(type.unwrap());
|
|
3278
|
+
} else if (type instanceof ZodCatch) {
|
|
3279
|
+
return getDiscriminator(type._def.innerType);
|
|
3116
3280
|
} else {
|
|
3117
|
-
return
|
|
3281
|
+
return [];
|
|
3118
3282
|
}
|
|
3119
3283
|
}, "getDiscriminator");
|
|
3120
3284
|
var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -3174,7 +3338,7 @@ var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
3174
3338
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
3175
3339
|
for (const type of options) {
|
|
3176
3340
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
3177
|
-
if (!discriminatorValues) {
|
|
3341
|
+
if (!discriminatorValues.length) {
|
|
3178
3342
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
3179
3343
|
}
|
|
3180
3344
|
for (const value of discriminatorValues) {
|
|
@@ -3381,7 +3545,8 @@ var _ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3381
3545
|
for (const key in ctx.data) {
|
|
3382
3546
|
pairs.push({
|
|
3383
3547
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
3384
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
3548
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
3549
|
+
alwaysSet: key in ctx.data
|
|
3385
3550
|
});
|
|
3386
3551
|
}
|
|
3387
3552
|
if (ctx.common.async) {
|
|
@@ -3741,6 +3906,10 @@ function createZodEnum(values, params) {
|
|
|
3741
3906
|
}
|
|
3742
3907
|
__name(createZodEnum, "createZodEnum");
|
|
3743
3908
|
var _ZodEnum = class _ZodEnum extends ZodType {
|
|
3909
|
+
constructor() {
|
|
3910
|
+
super(...arguments);
|
|
3911
|
+
_ZodEnum_cache.set(this, void 0);
|
|
3912
|
+
}
|
|
3744
3913
|
_parse(input) {
|
|
3745
3914
|
if (typeof input.data !== "string") {
|
|
3746
3915
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3752,7 +3921,10 @@ var _ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3752
3921
|
});
|
|
3753
3922
|
return INVALID;
|
|
3754
3923
|
}
|
|
3755
|
-
if (this
|
|
3924
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
3925
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
3926
|
+
}
|
|
3927
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
3756
3928
|
const ctx = this._getOrReturnCtx(input);
|
|
3757
3929
|
const expectedValues = this._def.values;
|
|
3758
3930
|
addIssueToContext(ctx, {
|
|
@@ -3788,17 +3960,28 @@ var _ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3788
3960
|
}
|
|
3789
3961
|
return enumValues2;
|
|
3790
3962
|
}
|
|
3791
|
-
extract(values) {
|
|
3792
|
-
return _ZodEnum.create(values
|
|
3963
|
+
extract(values, newDef = this._def) {
|
|
3964
|
+
return _ZodEnum.create(values, {
|
|
3965
|
+
...this._def,
|
|
3966
|
+
...newDef
|
|
3967
|
+
});
|
|
3793
3968
|
}
|
|
3794
|
-
exclude(values) {
|
|
3795
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt))
|
|
3969
|
+
exclude(values, newDef = this._def) {
|
|
3970
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
3971
|
+
...this._def,
|
|
3972
|
+
...newDef
|
|
3973
|
+
});
|
|
3796
3974
|
}
|
|
3797
3975
|
};
|
|
3798
3976
|
__name(_ZodEnum, "ZodEnum");
|
|
3799
3977
|
var ZodEnum = _ZodEnum;
|
|
3978
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3800
3979
|
ZodEnum.create = createZodEnum;
|
|
3801
3980
|
var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
|
|
3981
|
+
constructor() {
|
|
3982
|
+
super(...arguments);
|
|
3983
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
3984
|
+
}
|
|
3802
3985
|
_parse(input) {
|
|
3803
3986
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3804
3987
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3811,7 +3994,10 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
|
|
|
3811
3994
|
});
|
|
3812
3995
|
return INVALID;
|
|
3813
3996
|
}
|
|
3814
|
-
if (
|
|
3997
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
3998
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
3999
|
+
}
|
|
4000
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
3815
4001
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3816
4002
|
addIssueToContext(ctx, {
|
|
3817
4003
|
received: ctx.data,
|
|
@@ -3828,6 +4014,7 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
|
|
|
3828
4014
|
};
|
|
3829
4015
|
__name(_ZodNativeEnum, "ZodNativeEnum");
|
|
3830
4016
|
var ZodNativeEnum = _ZodNativeEnum;
|
|
4017
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3831
4018
|
ZodNativeEnum.create = (values, params) => {
|
|
3832
4019
|
return new ZodNativeEnum({
|
|
3833
4020
|
values,
|
|
@@ -3893,26 +4080,38 @@ var _ZodEffects = class _ZodEffects extends ZodType {
|
|
|
3893
4080
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3894
4081
|
if (effect.type === "preprocess") {
|
|
3895
4082
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
3896
|
-
if (ctx.common.issues.length) {
|
|
3897
|
-
return {
|
|
3898
|
-
status: "dirty",
|
|
3899
|
-
value: ctx.data
|
|
3900
|
-
};
|
|
3901
|
-
}
|
|
3902
4083
|
if (ctx.common.async) {
|
|
3903
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
3904
|
-
|
|
4084
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
4085
|
+
if (status.value === "aborted")
|
|
4086
|
+
return INVALID;
|
|
4087
|
+
const result = await this._def.schema._parseAsync({
|
|
3905
4088
|
data: processed2,
|
|
3906
4089
|
path: ctx.path,
|
|
3907
4090
|
parent: ctx
|
|
3908
4091
|
});
|
|
4092
|
+
if (result.status === "aborted")
|
|
4093
|
+
return INVALID;
|
|
4094
|
+
if (result.status === "dirty")
|
|
4095
|
+
return DIRTY(result.value);
|
|
4096
|
+
if (status.value === "dirty")
|
|
4097
|
+
return DIRTY(result.value);
|
|
4098
|
+
return result;
|
|
3909
4099
|
});
|
|
3910
4100
|
} else {
|
|
3911
|
-
|
|
4101
|
+
if (status.value === "aborted")
|
|
4102
|
+
return INVALID;
|
|
4103
|
+
const result = this._def.schema._parseSync({
|
|
3912
4104
|
data: processed,
|
|
3913
4105
|
path: ctx.path,
|
|
3914
4106
|
parent: ctx
|
|
3915
4107
|
});
|
|
4108
|
+
if (result.status === "aborted")
|
|
4109
|
+
return INVALID;
|
|
4110
|
+
if (result.status === "dirty")
|
|
4111
|
+
return DIRTY(result.value);
|
|
4112
|
+
if (status.value === "dirty")
|
|
4113
|
+
return DIRTY(result.value);
|
|
4114
|
+
return result;
|
|
3916
4115
|
}
|
|
3917
4116
|
}
|
|
3918
4117
|
if (effect.type === "refinement") {
|
|
@@ -4222,6 +4421,9 @@ var _ZodReadonly = class _ZodReadonly extends ZodType {
|
|
|
4222
4421
|
}
|
|
4223
4422
|
return result;
|
|
4224
4423
|
}
|
|
4424
|
+
unwrap() {
|
|
4425
|
+
return this._def.innerType;
|
|
4426
|
+
}
|
|
4225
4427
|
};
|
|
4226
4428
|
__name(_ZodReadonly, "ZodReadonly");
|
|
4227
4429
|
var ZodReadonly = _ZodReadonly;
|
|
@@ -4232,7 +4434,7 @@ ZodReadonly.create = (type, params) => {
|
|
|
4232
4434
|
...processCreateParams(params)
|
|
4233
4435
|
});
|
|
4234
4436
|
};
|
|
4235
|
-
|
|
4437
|
+
function custom(check, params = {}, fatal) {
|
|
4236
4438
|
if (check)
|
|
4237
4439
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
4238
4440
|
var _a, _b;
|
|
@@ -4244,7 +4446,8 @@ var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
|
|
|
4244
4446
|
}
|
|
4245
4447
|
});
|
|
4246
4448
|
return ZodAny.create();
|
|
4247
|
-
}
|
|
4449
|
+
}
|
|
4450
|
+
__name(custom, "custom");
|
|
4248
4451
|
var late = {
|
|
4249
4452
|
object: ZodObject.lazycreate
|
|
4250
4453
|
};
|
|
@@ -4363,6 +4566,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4363
4566
|
ZodParsedType,
|
|
4364
4567
|
getParsedType,
|
|
4365
4568
|
ZodType,
|
|
4569
|
+
datetimeRegex,
|
|
4366
4570
|
ZodString,
|
|
4367
4571
|
ZodNumber,
|
|
4368
4572
|
ZodBigInt,
|
|
@@ -4622,6 +4826,9 @@ var dotAddress = z.union([
|
|
|
4622
4826
|
var ethereumAddress = hexString.refine((address) => ethers.isAddress(address), (address) => ({
|
|
4623
4827
|
message: `${address} is not a valid ethereum address`
|
|
4624
4828
|
}));
|
|
4829
|
+
var chainflipAddress = string.refine((address) => address.startsWith("cF") && decodeAddress(address), (address) => ({
|
|
4830
|
+
message: `${address} is not a valid chainflip address`
|
|
4831
|
+
}));
|
|
4625
4832
|
numericString.transform((arg) => BigInt(arg));
|
|
4626
4833
|
var u128 = z.union([
|
|
4627
4834
|
number,
|
|
@@ -4644,7 +4851,7 @@ var uncheckedAssetAndChain = z.object({
|
|
|
4644
4851
|
asset: z.string(),
|
|
4645
4852
|
chain: z.string()
|
|
4646
4853
|
});
|
|
4647
|
-
uncheckedAssetAndChain.refine(isValidAssetAndChain);
|
|
4854
|
+
uncheckedAssetAndChain.refine((value) => isValidAssetAndChain(value));
|
|
4648
4855
|
z.union([
|
|
4649
4856
|
z.object({
|
|
4650
4857
|
__kind: z.literal("CcmPrincipal"),
|
|
@@ -4666,5 +4873,10 @@ z.union([
|
|
|
4666
4873
|
type: "SWAP"
|
|
4667
4874
|
}))
|
|
4668
4875
|
]);
|
|
4876
|
+
var chainflipSS58Prefix = 2112;
|
|
4877
|
+
z.union([
|
|
4878
|
+
hexString,
|
|
4879
|
+
string.regex(/^[a-f\d]$/i).transform((value) => `0x${value}`)
|
|
4880
|
+
]).transform((value) => encodeAddress(value, chainflipSS58Prefix));
|
|
4669
4881
|
|
|
4670
|
-
export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, assertValidAddress, asset, assetConstants, btcAddress, chain, chainConstants, dotAddress, ethereumAddress, getInternalAsset, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isNotNullish, isTestnet,
|
|
4882
|
+
export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, assertValidAddress, asset, assetConstants, btcAddress, chain, chainConstants, chainflipAddress, dotAddress, ethereumAddress, getInternalAsset, getInternalAssets, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isNotNullish, isTestnet, number, numericOrEmptyString, numericString, readChainAssetValue, u128, uncheckedAssetAndChain, unsignedInteger, z };
|