@chainflip/sdk 1.3.0 → 1.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { hexToU8a, u8aToHex, isHex } from '@polkadot/util';
2
- import { encodeAddress, decodeAddress, base58Decode } from '@polkadot/util-crypto';
1
+ import * as ss582 from '@chainflip/utils/ss58';
3
2
  import * as ethers from 'ethers';
3
+ import * as base58 from '@chainflip/utils/base58';
4
4
 
5
5
  var __create = Object.create;
6
6
  var __defProp = Object.defineProperty;
@@ -106,10 +106,10 @@ var require_encoding = __commonJS({
106
106
  });
107
107
  exports.CHECKSUM_LENGTH = void 0;
108
108
  exports.createChecksum = createChecksum;
109
- exports.decode = decode;
109
+ exports.decode = decode4;
110
110
  exports.decodeWithPrefix = decodeWithPrefix;
111
111
  exports.detectCase = detectCase;
112
- exports.encode = encode;
112
+ exports.encode = encode2;
113
113
  exports.expandPrefix = expandPrefix;
114
114
  exports.verifyChecksum = verifyChecksum;
115
115
  var _bitConverter = require_bit_converter();
@@ -186,13 +186,13 @@ var require_encoding = __commonJS({
186
186
  }
187
187
  }
188
188
  __name(createChecksum, "createChecksum");
189
- function encode(buffer) {
189
+ function encode2(buffer) {
190
190
  return buffer.reduce(function(acc, bits) {
191
191
  return acc + CHARSET[bits];
192
192
  }, "");
193
193
  }
194
- __name(encode, "encode");
195
- function decode(message, dst) {
194
+ __name(encode2, "encode");
195
+ function decode4(message, dst) {
196
196
  var realDst = dst || (0, _bitConverter.createBitArray)(message.length);
197
197
  for (var i = 0; i < message.length; i += 1) {
198
198
  var idx = CHAR_LOOKUP.get(message[i]);
@@ -203,12 +203,12 @@ var require_encoding = __commonJS({
203
203
  }
204
204
  return realDst;
205
205
  }
206
- __name(decode, "decode");
206
+ __name(decode4, "decode");
207
207
  function decodeWithPrefix(prefix, message) {
208
208
  var len = message.length + 2 * prefix.length + 1;
209
209
  var dst = (0, _bitConverter.createBitArray)(len);
210
210
  expandPrefix(prefix, dst.subarray(0, 2 * prefix.length + 1));
211
- decode(message, dst.subarray(2 * prefix.length + 1));
211
+ decode4(message, dst.subarray(2 * prefix.length + 1));
212
212
  return dst;
213
213
  }
214
214
  __name(decodeWithPrefix, "decodeWithPrefix");
@@ -245,9 +245,9 @@ var require_lib = __commonJS({
245
245
  value: true
246
246
  });
247
247
  exports.BitcoinAddress = void 0;
248
- exports.decode = decode;
248
+ exports.decode = decode4;
249
249
  exports.decodeTo5BitArray = decodeTo5BitArray;
250
- exports.encode = encode;
250
+ exports.encode = encode2;
251
251
  exports.encode5BitArray = encode5BitArray;
252
252
  exports.from5BitArray = from5BitArray;
253
253
  exports.to5BitArray = to5BitArray;
@@ -314,11 +314,11 @@ var require_lib = __commonJS({
314
314
  return "".concat(prefix, "1").concat(encoded);
315
315
  }
316
316
  __name(encode5BitArray, "encode5BitArray");
317
- function encode(prefix, data) {
317
+ function encode2(prefix, data) {
318
318
  var encoding = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "bech32";
319
319
  return encode5BitArray(prefix, to5BitArray(data), encoding);
320
320
  }
321
- __name(encode, "encode");
321
+ __name(encode2, "encode");
322
322
  function decodeTo5BitArray(message) {
323
323
  if (message.length > MAX_ENC_LENGTH) {
324
324
  throw new TypeError("Message too long; max ".concat(MAX_ENC_LENGTH, " expected"));
@@ -346,7 +346,7 @@ var require_lib = __commonJS({
346
346
  };
347
347
  }
348
348
  __name(decodeTo5BitArray, "decodeTo5BitArray");
349
- function decode(message) {
349
+ function decode4(message) {
350
350
  var _decodeTo5BitArray = decodeTo5BitArray(message), prefix = _decodeTo5BitArray.prefix, encoding = _decodeTo5BitArray.encoding, bitArray = _decodeTo5BitArray.data;
351
351
  return {
352
352
  prefix,
@@ -354,7 +354,7 @@ var require_lib = __commonJS({
354
354
  data: from5BitArray(bitArray)
355
355
  };
356
356
  }
357
- __name(decode, "decode");
357
+ __name(decode4, "decode");
358
358
  var BitcoinAddress2 = /* @__PURE__ */ function() {
359
359
  function BitcoinAddress3(prefix, scriptVersion, data) {
360
360
  _classCallCheck(this, BitcoinAddress3);
@@ -394,7 +394,7 @@ var require_lib = __commonJS({
394
394
  },
395
395
  {
396
396
  key: "encode",
397
- value: /* @__PURE__ */ __name(function encode2() {
397
+ value: /* @__PURE__ */ __name(function encode3() {
398
398
  var len = Math.ceil(this.data.length * 8 / 5);
399
399
  var converted = (0, _bitConverter.createBitArray)(len + 1);
400
400
  converted[0] = this.scriptVersion;
@@ -428,7 +428,7 @@ var require_lib = __commonJS({
428
428
  * @param {string} message
429
429
  * @returns {BitcoinAddress}
430
430
  */
431
- /* @__PURE__ */ __name(function decode2(message) {
431
+ /* @__PURE__ */ __name(function decode5(message) {
432
432
  var _decodeTo5BitArray2 = decodeTo5BitArray(message), prefix = _decodeTo5BitArray2.prefix, data = _decodeTo5BitArray2.data, encoding = _decodeTo5BitArray2.encoding;
433
433
  if (prefix !== "bc" && prefix !== "tb" && prefix !== "bcrt") {
434
434
  throw new Error('Invalid human-readable prefix, "bc", "tb", or "bcrt" expected');
@@ -591,18 +591,18 @@ function isValidAssetAndChain(assetAndChain2) {
591
591
  return validAssets.includes(asset2);
592
592
  }
593
593
  __name(isValidAssetAndChain, "isValidAssetAndChain");
594
- function assertIsValidAssetAndChain(assetAndChain2) {
595
- if (!isValidAssetAndChain(assetAndChain2)) {
596
- throw new Error(`invalid asset and chain combination: ${JSON.stringify(assetAndChain2)}`);
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
- return readChainAssetValue(map, asset2);
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.22.4/node_modules/zod/lib/index.mjs
642
+ // ../../node_modules/.pnpm/zod@3.23.8/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: issueData.message || errorMessage
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
- getErrorMap(),
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: await pair.key,
1045
- value: await pair.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
- if (iss.code !== "invalid_type")
1136
- return { message: ctx.defaultError };
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: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
1190
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
1139
1191
  }
1140
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
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 = /^[a-z][a-z0-9]*$/;
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 emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
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 = /^(((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}))$/;
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 datetimeRegex = /* @__PURE__ */ __name((args) => {
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
- if (args.offset) {
1402
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
1403
- } else {
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
- }, "datetimeRegex");
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
- ctx2,
1440
- {
1441
- code: ZodIssueCode.invalid_type,
1442
- expected: ZodParsedType.string,
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: await pair.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 Object.keys(type.enum);
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 null;
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._def.values.indexOf(input.data) === -1) {
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 (nativeEnumValues.indexOf(input.data) === -1) {
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
- return this._def.schema._parseAsync({
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
- return this._def.schema._parseSync({
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") {
@@ -4217,10 +4416,16 @@ var ZodPipeline = _ZodPipeline;
4217
4416
  var _ZodReadonly = class _ZodReadonly extends ZodType {
4218
4417
  _parse(input) {
4219
4418
  const result = this._def.innerType._parse(input);
4220
- if (isValid(result)) {
4221
- result.value = Object.freeze(result.value);
4222
- }
4223
- return result;
4419
+ const freeze = /* @__PURE__ */ __name((data) => {
4420
+ if (isValid(data)) {
4421
+ data.value = Object.freeze(data.value);
4422
+ }
4423
+ return data;
4424
+ }, "freeze");
4425
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
4426
+ }
4427
+ unwrap() {
4428
+ return this._def.innerType;
4224
4429
  }
4225
4430
  };
4226
4431
  __name(_ZodReadonly, "ZodReadonly");
@@ -4232,7 +4437,7 @@ ZodReadonly.create = (type, params) => {
4232
4437
  ...processCreateParams(params)
4233
4438
  });
4234
4439
  };
4235
- var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
4440
+ function custom(check, params = {}, fatal) {
4236
4441
  if (check)
4237
4442
  return ZodAny.create().superRefine((data, ctx) => {
4238
4443
  var _a, _b;
@@ -4244,7 +4449,8 @@ var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
4244
4449
  }
4245
4450
  });
4246
4451
  return ZodAny.create();
4247
- }, "custom");
4452
+ }
4453
+ __name(custom, "custom");
4248
4454
  var late = {
4249
4455
  object: ZodObject.lazycreate
4250
4456
  };
@@ -4363,6 +4569,7 @@ var z = /* @__PURE__ */ Object.freeze({
4363
4569
  ZodParsedType,
4364
4570
  getParsedType,
4365
4571
  ZodType,
4572
+ datetimeRegex,
4366
4573
  ZodString,
4367
4574
  ZodNumber,
4368
4575
  ZodBigInt,
@@ -4480,13 +4687,7 @@ var isValidSegwitAddress = /* @__PURE__ */ __name((address) => {
4480
4687
  // ../shared/src/validation/addressValidation.ts
4481
4688
  var validatePolkadotAddress = /* @__PURE__ */ __name((address) => {
4482
4689
  try {
4483
- const bytes = decodeAddress(address);
4484
- if (isHex(address)) {
4485
- const pubkey = u8aToHex(bytes);
4486
- if (pubkey.length !== 66)
4487
- return false;
4488
- }
4489
- encodeAddress(bytes);
4690
+ ss582.decode(address);
4490
4691
  return true;
4491
4692
  } catch {
4492
4693
  return false;
@@ -4501,7 +4702,7 @@ var assertArraylikeEqual = /* @__PURE__ */ __name((a, b) => {
4501
4702
  }, "assertArraylikeEqual");
4502
4703
  var validateP2PKHOrP2SHAddress = /* @__PURE__ */ __name((address, network) => {
4503
4704
  try {
4504
- const decoded = base58Decode(address);
4705
+ const decoded = new Uint8Array(base58.decode(address));
4505
4706
  assert(decoded.length === 25, "decoded address must be 25 bytes long");
4506
4707
  if (network === "mainnet") {
4507
4708
  assert(decoded[0] === 0 || decoded[0] === 5, "decoded address must start with 0x00 or 0x05");
@@ -4609,10 +4810,15 @@ var dotAddress = z.union([
4609
4810
  ]).transform((arg) => {
4610
4811
  try {
4611
4812
  if (arg.startsWith("0x")) {
4612
- return encodeAddress(hexToU8a(arg), DOT_PREFIX);
4813
+ return ss582.encode({
4814
+ data: arg,
4815
+ ss58Format: DOT_PREFIX
4816
+ });
4613
4817
  }
4614
- const hex = u8aToHex(decodeAddress(arg));
4615
- return encodeAddress(hex, DOT_PREFIX);
4818
+ return ss582.encode({
4819
+ data: ss582.decode(arg).data,
4820
+ ss58Format: DOT_PREFIX
4821
+ });
4616
4822
  } catch {
4617
4823
  return null;
4618
4824
  }
@@ -4622,6 +4828,9 @@ var dotAddress = z.union([
4622
4828
  var ethereumAddress = hexString.refine((address) => ethers.isAddress(address), (address) => ({
4623
4829
  message: `${address} is not a valid ethereum address`
4624
4830
  }));
4831
+ var chainflipAddress = string.refine((address) => address.startsWith("cF") && ss582.decode(address), (address) => ({
4832
+ message: `${address} is not a valid chainflip address`
4833
+ }));
4625
4834
  numericString.transform((arg) => BigInt(arg));
4626
4835
  var u128 = z.union([
4627
4836
  number,
@@ -4644,7 +4853,7 @@ var uncheckedAssetAndChain = z.object({
4644
4853
  asset: z.string(),
4645
4854
  chain: z.string()
4646
4855
  });
4647
- uncheckedAssetAndChain.refine(isValidAssetAndChain);
4856
+ uncheckedAssetAndChain.refine((value) => isValidAssetAndChain(value));
4648
4857
  z.union([
4649
4858
  z.object({
4650
4859
  __kind: z.literal("CcmPrincipal"),
@@ -4666,5 +4875,35 @@ z.union([
4666
4875
  type: "SWAP"
4667
4876
  }))
4668
4877
  ]);
4878
+ var chainflipSS58Prefix = 2112;
4879
+ z.union([
4880
+ hexString,
4881
+ string.regex(/^[a-f\d]$/i).transform((value) => `0x${value}`)
4882
+ ]).transform((value) => ss582.encode({
4883
+ data: value,
4884
+ ss58Format: chainflipSS58Prefix
4885
+ }));
4886
+ z.union([
4887
+ z.object({
4888
+ __kind: z.literal("Swap"),
4889
+ swapId: u128
4890
+ }),
4891
+ z.object({
4892
+ __kind: z.literal("LiquidityProvision"),
4893
+ lpAccount: hexString
4894
+ }),
4895
+ z.object({
4896
+ __kind: z.literal("CcmTransfer"),
4897
+ principalSwapId: u128.nullable().optional(),
4898
+ gasSwapId: u128.nullable().optional()
4899
+ }),
4900
+ z.object({
4901
+ __kind: z.literal("NoAction")
4902
+ }),
4903
+ z.object({
4904
+ __kind: z.literal("BoostersCredited"),
4905
+ prewitnessedDepositId: u128
4906
+ })
4907
+ ]);
4669
4908
 
4670
- export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, assertValidAddress, asset, assetConstants, btcAddress, chain, chainConstants, dotAddress, ethereumAddress, getInternalAsset, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isNotNullish, isTestnet, isValidAssetAndChain, numericOrEmptyString, numericString, readChainAssetValue, u128, uncheckedAssetAndChain, unsignedInteger, z };
4909
+ 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 };