@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/funding.js CHANGED
@@ -1460,7 +1460,8 @@ var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allow
1460
1460
  if (allowance >= amount)
1461
1461
  return null;
1462
1462
  const transaction = await erc20.approve(spenderAddress, amount - allowance, extractOverrides(txOpts));
1463
- return transaction.wait(txOpts.wait);
1463
+ await transaction.wait(txOpts.wait);
1464
+ return transaction;
1464
1465
  }, "approve");
1465
1466
  var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
1466
1467
  const flipAddress = getTokenContractAddress(InternalAssets.Flip, network);
@@ -1468,7 +1469,7 @@ var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
1468
1469
  return flip.balanceOf(await signer.getAddress());
1469
1470
  }, "getFlipBalance");
1470
1471
 
1471
- // ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
1472
+ // ../../node_modules/.pnpm/zod@3.23.0/node_modules/zod/lib/index.mjs
1472
1473
  var util;
1473
1474
  (function(util2) {
1474
1475
  util2.assertEqual = (val) => val;
@@ -1683,6 +1684,11 @@ var _ZodError = class _ZodError extends Error {
1683
1684
  processError(this);
1684
1685
  return fieldErrors;
1685
1686
  }
1687
+ static assert(value) {
1688
+ if (!(value instanceof _ZodError)) {
1689
+ throw new Error(`Not a ZodError: ${value}`);
1690
+ }
1691
+ }
1686
1692
  toString() {
1687
1693
  return this.message;
1688
1694
  }
@@ -1829,6 +1835,13 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
1829
1835
  ...issueData,
1830
1836
  path: fullPath
1831
1837
  };
1838
+ if (issueData.message !== void 0) {
1839
+ return {
1840
+ ...issueData,
1841
+ path: fullPath,
1842
+ message: issueData.message
1843
+ };
1844
+ }
1832
1845
  let errorMessage = "";
1833
1846
  const maps = errorMaps.filter((m) => !!m).slice().reverse();
1834
1847
  for (const map of maps) {
@@ -1837,11 +1850,12 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
1837
1850
  return {
1838
1851
  ...issueData,
1839
1852
  path: fullPath,
1840
- message: issueData.message || errorMessage
1853
+ message: errorMessage
1841
1854
  };
1842
1855
  }, "makeIssue");
1843
1856
  var EMPTY_PATH = [];
1844
1857
  function addIssueToContext(ctx, issueData) {
1858
+ const overrideMap = getErrorMap();
1845
1859
  const issue = makeIssue({
1846
1860
  issueData,
1847
1861
  data: ctx.data,
@@ -1849,8 +1863,8 @@ function addIssueToContext(ctx, issueData) {
1849
1863
  errorMaps: [
1850
1864
  ctx.common.contextualErrorMap,
1851
1865
  ctx.schemaErrorMap,
1852
- getErrorMap(),
1853
- errorMap
1866
+ overrideMap,
1867
+ overrideMap === errorMap ? void 0 : errorMap
1854
1868
  // then global default map
1855
1869
  ].filter((x) => !!x)
1856
1870
  });
@@ -1883,9 +1897,11 @@ var _ParseStatus = class _ParseStatus {
1883
1897
  static async mergeObjectAsync(status, pairs) {
1884
1898
  const syncPairs = [];
1885
1899
  for (const pair of pairs) {
1900
+ const key = await pair.key;
1901
+ const value = await pair.value;
1886
1902
  syncPairs.push({
1887
- key: await pair.key,
1888
- value: await pair.value
1903
+ key,
1904
+ value
1889
1905
  });
1890
1906
  }
1891
1907
  return _ParseStatus.mergeObjectSync(status, syncPairs);
@@ -1920,11 +1936,31 @@ var isAborted = /* @__PURE__ */ __name((x) => x.status === "aborted", "isAborted
1920
1936
  var isDirty = /* @__PURE__ */ __name((x) => x.status === "dirty", "isDirty");
1921
1937
  var isValid = /* @__PURE__ */ __name((x) => x.status === "valid", "isValid");
1922
1938
  var isAsync = /* @__PURE__ */ __name((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
1939
+ function __classPrivateFieldGet(receiver, state, kind, f) {
1940
+ if (kind === "a" && !f)
1941
+ throw new TypeError("Private accessor was defined without a getter");
1942
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1943
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
1944
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1945
+ }
1946
+ __name(__classPrivateFieldGet, "__classPrivateFieldGet");
1947
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
1948
+ if (kind === "m")
1949
+ throw new TypeError("Private method is not writable");
1950
+ if (kind === "a" && !f)
1951
+ throw new TypeError("Private accessor was defined without a setter");
1952
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
1953
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
1954
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1955
+ }
1956
+ __name(__classPrivateFieldSet, "__classPrivateFieldSet");
1923
1957
  var errorUtil;
1924
1958
  (function(errorUtil2) {
1925
1959
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1926
1960
  errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1927
1961
  })(errorUtil || (errorUtil = {}));
1962
+ var _ZodEnum_cache;
1963
+ var _ZodNativeEnum_cache;
1928
1964
  var _ParseInputLazyPath = class _ParseInputLazyPath {
1929
1965
  constructor(parent, value, path, key) {
1930
1966
  this._cachedPath = [];
@@ -1975,12 +2011,17 @@ function processCreateParams(params) {
1975
2011
  if (errorMap3)
1976
2012
  return { errorMap: errorMap3, description };
1977
2013
  const customMap = /* @__PURE__ */ __name((iss, ctx) => {
1978
- if (iss.code !== "invalid_type")
1979
- return { message: ctx.defaultError };
2014
+ var _a, _b;
2015
+ const { message } = params;
2016
+ if (iss.code === "invalid_enum_value") {
2017
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
2018
+ }
1980
2019
  if (typeof ctx.data === "undefined") {
1981
- return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
2020
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
1982
2021
  }
1983
- return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
2022
+ if (iss.code !== "invalid_type")
2023
+ return { message: ctx.defaultError };
2024
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
1984
2025
  }, "customMap");
1985
2026
  return { errorMap: customMap, description };
1986
2027
  }
@@ -2231,35 +2272,43 @@ var _ZodType = class _ZodType {
2231
2272
  __name(_ZodType, "ZodType");
2232
2273
  var ZodType = _ZodType;
2233
2274
  var cuidRegex = /^c[^\s-]{8,}$/i;
2234
- var cuid2Regex = /^[a-z][a-z0-9]*$/;
2275
+ var cuid2Regex = /^[0-9a-z]+$/;
2235
2276
  var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
2236
2277
  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;
2237
- var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2278
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
2279
+ 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)?)??$/;
2280
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2238
2281
  var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
2239
2282
  var emojiRegex;
2240
- 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}))$/;
2283
+ 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])$/;
2241
2284
  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})))$/;
2242
- var datetimeRegex = /* @__PURE__ */ __name((args) => {
2285
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
2286
+ 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])))`;
2287
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
2288
+ function timeRegexSource(args) {
2289
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
2243
2290
  if (args.precision) {
2244
- if (args.offset) {
2245
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
2246
- } else {
2247
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
2248
- }
2249
- } else if (args.precision === 0) {
2250
- if (args.offset) {
2251
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
2252
- } else {
2253
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
2254
- }
2255
- } else {
2256
- if (args.offset) {
2257
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
2258
- } else {
2259
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
2260
- }
2291
+ regex = `${regex}\\.\\d{${args.precision}}`;
2292
+ } else if (args.precision == null) {
2293
+ regex = `${regex}(\\.\\d+)?`;
2261
2294
  }
2262
- }, "datetimeRegex");
2295
+ return regex;
2296
+ }
2297
+ __name(timeRegexSource, "timeRegexSource");
2298
+ function timeRegex(args) {
2299
+ return new RegExp(`^${timeRegexSource(args)}$`);
2300
+ }
2301
+ __name(timeRegex, "timeRegex");
2302
+ function datetimeRegex(args) {
2303
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
2304
+ const opts = [];
2305
+ opts.push(args.local ? `Z?` : `Z`);
2306
+ if (args.offset)
2307
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
2308
+ regex = `${regex}(${opts.join("|")})`;
2309
+ return new RegExp(`^${regex}$`);
2310
+ }
2311
+ __name(datetimeRegex, "datetimeRegex");
2263
2312
  function isValidIP(ip, version) {
2264
2313
  if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
2265
2314
  return true;
@@ -2278,15 +2327,11 @@ var _ZodString = class _ZodString extends ZodType {
2278
2327
  const parsedType = this._getType(input);
2279
2328
  if (parsedType !== ZodParsedType.string) {
2280
2329
  const ctx2 = this._getOrReturnCtx(input);
2281
- addIssueToContext(
2282
- ctx2,
2283
- {
2284
- code: ZodIssueCode.invalid_type,
2285
- expected: ZodParsedType.string,
2286
- received: ctx2.parsedType
2287
- }
2288
- //
2289
- );
2330
+ addIssueToContext(ctx2, {
2331
+ code: ZodIssueCode.invalid_type,
2332
+ expected: ZodParsedType.string,
2333
+ received: ctx2.parsedType
2334
+ });
2290
2335
  return INVALID;
2291
2336
  }
2292
2337
  const status = new ParseStatus();
@@ -2377,6 +2422,16 @@ var _ZodString = class _ZodString extends ZodType {
2377
2422
  });
2378
2423
  status.dirty();
2379
2424
  }
2425
+ } else if (check.kind === "nanoid") {
2426
+ if (!nanoidRegex.test(input.data)) {
2427
+ ctx = this._getOrReturnCtx(input, ctx);
2428
+ addIssueToContext(ctx, {
2429
+ validation: "nanoid",
2430
+ code: ZodIssueCode.invalid_string,
2431
+ message: check.message
2432
+ });
2433
+ status.dirty();
2434
+ }
2380
2435
  } else if (check.kind === "cuid") {
2381
2436
  if (!cuidRegex.test(input.data)) {
2382
2437
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2478,6 +2533,38 @@ var _ZodString = class _ZodString extends ZodType {
2478
2533
  });
2479
2534
  status.dirty();
2480
2535
  }
2536
+ } else if (check.kind === "date") {
2537
+ const regex = dateRegex;
2538
+ if (!regex.test(input.data)) {
2539
+ ctx = this._getOrReturnCtx(input, ctx);
2540
+ addIssueToContext(ctx, {
2541
+ code: ZodIssueCode.invalid_string,
2542
+ validation: "date",
2543
+ message: check.message
2544
+ });
2545
+ status.dirty();
2546
+ }
2547
+ } else if (check.kind === "time") {
2548
+ const regex = timeRegex(check);
2549
+ if (!regex.test(input.data)) {
2550
+ ctx = this._getOrReturnCtx(input, ctx);
2551
+ addIssueToContext(ctx, {
2552
+ code: ZodIssueCode.invalid_string,
2553
+ validation: "time",
2554
+ message: check.message
2555
+ });
2556
+ status.dirty();
2557
+ }
2558
+ } else if (check.kind === "duration") {
2559
+ if (!durationRegex.test(input.data)) {
2560
+ ctx = this._getOrReturnCtx(input, ctx);
2561
+ addIssueToContext(ctx, {
2562
+ validation: "duration",
2563
+ code: ZodIssueCode.invalid_string,
2564
+ message: check.message
2565
+ });
2566
+ status.dirty();
2567
+ }
2481
2568
  } else if (check.kind === "ip") {
2482
2569
  if (!isValidIP(input.data, check.version)) {
2483
2570
  ctx = this._getOrReturnCtx(input, ctx);
@@ -2488,6 +2575,16 @@ var _ZodString = class _ZodString extends ZodType {
2488
2575
  });
2489
2576
  status.dirty();
2490
2577
  }
2578
+ } else if (check.kind === "base64") {
2579
+ if (!base64Regex.test(input.data)) {
2580
+ ctx = this._getOrReturnCtx(input, ctx);
2581
+ addIssueToContext(ctx, {
2582
+ validation: "base64",
2583
+ code: ZodIssueCode.invalid_string,
2584
+ message: check.message
2585
+ });
2586
+ status.dirty();
2587
+ }
2491
2588
  } else {
2492
2589
  util.assertNever(check);
2493
2590
  }
@@ -2519,6 +2616,9 @@ var _ZodString = class _ZodString extends ZodType {
2519
2616
  uuid(message) {
2520
2617
  return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2521
2618
  }
2619
+ nanoid(message) {
2620
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2621
+ }
2522
2622
  cuid(message) {
2523
2623
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2524
2624
  }
@@ -2528,16 +2628,20 @@ var _ZodString = class _ZodString extends ZodType {
2528
2628
  ulid(message) {
2529
2629
  return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2530
2630
  }
2631
+ base64(message) {
2632
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2633
+ }
2531
2634
  ip(options) {
2532
2635
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2533
2636
  }
2534
2637
  datetime(options) {
2535
- var _a;
2638
+ var _a, _b;
2536
2639
  if (typeof options === "string") {
2537
2640
  return this._addCheck({
2538
2641
  kind: "datetime",
2539
2642
  precision: null,
2540
2643
  offset: false,
2644
+ local: false,
2541
2645
  message: options
2542
2646
  });
2543
2647
  }
@@ -2545,9 +2649,30 @@ var _ZodString = class _ZodString extends ZodType {
2545
2649
  kind: "datetime",
2546
2650
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2547
2651
  offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2652
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2548
2653
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2549
2654
  });
2550
2655
  }
2656
+ date(message) {
2657
+ return this._addCheck({ kind: "date", message });
2658
+ }
2659
+ time(options) {
2660
+ if (typeof options === "string") {
2661
+ return this._addCheck({
2662
+ kind: "time",
2663
+ precision: null,
2664
+ message: options
2665
+ });
2666
+ }
2667
+ return this._addCheck({
2668
+ kind: "time",
2669
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2670
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2671
+ });
2672
+ }
2673
+ duration(message) {
2674
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2675
+ }
2551
2676
  regex(regex, message) {
2552
2677
  return this._addCheck({
2553
2678
  kind: "regex",
@@ -2626,6 +2751,15 @@ var _ZodString = class _ZodString extends ZodType {
2626
2751
  get isDatetime() {
2627
2752
  return !!this._def.checks.find((ch) => ch.kind === "datetime");
2628
2753
  }
2754
+ get isDate() {
2755
+ return !!this._def.checks.find((ch) => ch.kind === "date");
2756
+ }
2757
+ get isTime() {
2758
+ return !!this._def.checks.find((ch) => ch.kind === "time");
2759
+ }
2760
+ get isDuration() {
2761
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
2762
+ }
2629
2763
  get isEmail() {
2630
2764
  return !!this._def.checks.find((ch) => ch.kind === "email");
2631
2765
  }
@@ -2638,6 +2772,9 @@ var _ZodString = class _ZodString extends ZodType {
2638
2772
  get isUUID() {
2639
2773
  return !!this._def.checks.find((ch) => ch.kind === "uuid");
2640
2774
  }
2775
+ get isNANOID() {
2776
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2777
+ }
2641
2778
  get isCUID() {
2642
2779
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
2643
2780
  }
@@ -2650,6 +2787,9 @@ var _ZodString = class _ZodString extends ZodType {
2650
2787
  get isIP() {
2651
2788
  return !!this._def.checks.find((ch) => ch.kind === "ip");
2652
2789
  }
2790
+ get isBase64() {
2791
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
2792
+ }
2653
2793
  get minLength() {
2654
2794
  let min = null;
2655
2795
  for (const ch of this._def.checks) {
@@ -3591,9 +3731,10 @@ var _ZodObject = class _ZodObject extends ZodType {
3591
3731
  const syncPairs = [];
3592
3732
  for (const pair of pairs) {
3593
3733
  const key = await pair.key;
3734
+ const value = await pair.value;
3594
3735
  syncPairs.push({
3595
3736
  key,
3596
- value: await pair.value,
3737
+ value,
3597
3738
  alwaysSet: pair.alwaysSet
3598
3739
  });
3599
3740
  }
@@ -3949,15 +4090,25 @@ var getDiscriminator = /* @__PURE__ */ __name((type) => {
3949
4090
  } else if (type instanceof ZodEnum) {
3950
4091
  return type.options;
3951
4092
  } else if (type instanceof ZodNativeEnum) {
3952
- return Object.keys(type.enum);
4093
+ return util.objectValues(type.enum);
3953
4094
  } else if (type instanceof ZodDefault) {
3954
4095
  return getDiscriminator(type._def.innerType);
3955
4096
  } else if (type instanceof ZodUndefined) {
3956
4097
  return [void 0];
3957
4098
  } else if (type instanceof ZodNull) {
3958
4099
  return [null];
4100
+ } else if (type instanceof ZodOptional) {
4101
+ return [void 0, ...getDiscriminator(type.unwrap())];
4102
+ } else if (type instanceof ZodNullable) {
4103
+ return [null, ...getDiscriminator(type.unwrap())];
4104
+ } else if (type instanceof ZodBranded) {
4105
+ return getDiscriminator(type.unwrap());
4106
+ } else if (type instanceof ZodReadonly) {
4107
+ return getDiscriminator(type.unwrap());
4108
+ } else if (type instanceof ZodCatch) {
4109
+ return getDiscriminator(type._def.innerType);
3959
4110
  } else {
3960
- return null;
4111
+ return [];
3961
4112
  }
3962
4113
  }, "getDiscriminator");
3963
4114
  var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
@@ -4017,7 +4168,7 @@ var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
4017
4168
  const optionsMap = /* @__PURE__ */ new Map();
4018
4169
  for (const type of options) {
4019
4170
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
4020
- if (!discriminatorValues) {
4171
+ if (!discriminatorValues.length) {
4021
4172
  throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
4022
4173
  }
4023
4174
  for (const value of discriminatorValues) {
@@ -4224,7 +4375,8 @@ var _ZodRecord = class _ZodRecord extends ZodType {
4224
4375
  for (const key in ctx.data) {
4225
4376
  pairs.push({
4226
4377
  key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
4227
- value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
4378
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
4379
+ alwaysSet: key in ctx.data
4228
4380
  });
4229
4381
  }
4230
4382
  if (ctx.common.async) {
@@ -4584,6 +4736,10 @@ function createZodEnum(values, params) {
4584
4736
  }
4585
4737
  __name(createZodEnum, "createZodEnum");
4586
4738
  var _ZodEnum = class _ZodEnum extends ZodType {
4739
+ constructor() {
4740
+ super(...arguments);
4741
+ _ZodEnum_cache.set(this, void 0);
4742
+ }
4587
4743
  _parse(input) {
4588
4744
  if (typeof input.data !== "string") {
4589
4745
  const ctx = this._getOrReturnCtx(input);
@@ -4595,7 +4751,10 @@ var _ZodEnum = class _ZodEnum extends ZodType {
4595
4751
  });
4596
4752
  return INVALID;
4597
4753
  }
4598
- if (this._def.values.indexOf(input.data) === -1) {
4754
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
4755
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
4756
+ }
4757
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
4599
4758
  const ctx = this._getOrReturnCtx(input);
4600
4759
  const expectedValues = this._def.values;
4601
4760
  addIssueToContext(ctx, {
@@ -4631,17 +4790,28 @@ var _ZodEnum = class _ZodEnum extends ZodType {
4631
4790
  }
4632
4791
  return enumValues2;
4633
4792
  }
4634
- extract(values) {
4635
- return _ZodEnum.create(values);
4793
+ extract(values, newDef = this._def) {
4794
+ return _ZodEnum.create(values, {
4795
+ ...this._def,
4796
+ ...newDef
4797
+ });
4636
4798
  }
4637
- exclude(values) {
4638
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
4799
+ exclude(values, newDef = this._def) {
4800
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4801
+ ...this._def,
4802
+ ...newDef
4803
+ });
4639
4804
  }
4640
4805
  };
4641
4806
  __name(_ZodEnum, "ZodEnum");
4642
4807
  var ZodEnum = _ZodEnum;
4808
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
4643
4809
  ZodEnum.create = createZodEnum;
4644
4810
  var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
4811
+ constructor() {
4812
+ super(...arguments);
4813
+ _ZodNativeEnum_cache.set(this, void 0);
4814
+ }
4645
4815
  _parse(input) {
4646
4816
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
4647
4817
  const ctx = this._getOrReturnCtx(input);
@@ -4654,7 +4824,10 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
4654
4824
  });
4655
4825
  return INVALID;
4656
4826
  }
4657
- if (nativeEnumValues.indexOf(input.data) === -1) {
4827
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
4828
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
4829
+ }
4830
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
4658
4831
  const expectedValues = util.objectValues(nativeEnumValues);
4659
4832
  addIssueToContext(ctx, {
4660
4833
  received: ctx.data,
@@ -4671,6 +4844,7 @@ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
4671
4844
  };
4672
4845
  __name(_ZodNativeEnum, "ZodNativeEnum");
4673
4846
  var ZodNativeEnum = _ZodNativeEnum;
4847
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
4674
4848
  ZodNativeEnum.create = (values, params) => {
4675
4849
  return new ZodNativeEnum({
4676
4850
  values,
@@ -4736,26 +4910,38 @@ var _ZodEffects = class _ZodEffects extends ZodType {
4736
4910
  checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4737
4911
  if (effect.type === "preprocess") {
4738
4912
  const processed = effect.transform(ctx.data, checkCtx);
4739
- if (ctx.common.issues.length) {
4740
- return {
4741
- status: "dirty",
4742
- value: ctx.data
4743
- };
4744
- }
4745
4913
  if (ctx.common.async) {
4746
- return Promise.resolve(processed).then((processed2) => {
4747
- return this._def.schema._parseAsync({
4914
+ return Promise.resolve(processed).then(async (processed2) => {
4915
+ if (status.value === "aborted")
4916
+ return INVALID;
4917
+ const result = await this._def.schema._parseAsync({
4748
4918
  data: processed2,
4749
4919
  path: ctx.path,
4750
4920
  parent: ctx
4751
4921
  });
4922
+ if (result.status === "aborted")
4923
+ return INVALID;
4924
+ if (result.status === "dirty")
4925
+ return DIRTY(result.value);
4926
+ if (status.value === "dirty")
4927
+ return DIRTY(result.value);
4928
+ return result;
4752
4929
  });
4753
4930
  } else {
4754
- return this._def.schema._parseSync({
4931
+ if (status.value === "aborted")
4932
+ return INVALID;
4933
+ const result = this._def.schema._parseSync({
4755
4934
  data: processed,
4756
4935
  path: ctx.path,
4757
4936
  parent: ctx
4758
4937
  });
4938
+ if (result.status === "aborted")
4939
+ return INVALID;
4940
+ if (result.status === "dirty")
4941
+ return DIRTY(result.value);
4942
+ if (status.value === "dirty")
4943
+ return DIRTY(result.value);
4944
+ return result;
4759
4945
  }
4760
4946
  }
4761
4947
  if (effect.type === "refinement") {
@@ -5065,6 +5251,9 @@ var _ZodReadonly = class _ZodReadonly extends ZodType {
5065
5251
  }
5066
5252
  return result;
5067
5253
  }
5254
+ unwrap() {
5255
+ return this._def.innerType;
5256
+ }
5068
5257
  };
5069
5258
  __name(_ZodReadonly, "ZodReadonly");
5070
5259
  var ZodReadonly = _ZodReadonly;
@@ -5075,7 +5264,7 @@ ZodReadonly.create = (type, params) => {
5075
5264
  ...processCreateParams(params)
5076
5265
  });
5077
5266
  };
5078
- var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
5267
+ function custom(check, params = {}, fatal) {
5079
5268
  if (check)
5080
5269
  return ZodAny.create().superRefine((data, ctx) => {
5081
5270
  var _a, _b;
@@ -5087,7 +5276,8 @@ var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
5087
5276
  }
5088
5277
  });
5089
5278
  return ZodAny.create();
5090
- }, "custom");
5279
+ }
5280
+ __name(custom, "custom");
5091
5281
  var late = {
5092
5282
  object: ZodObject.lazycreate
5093
5283
  };
@@ -5206,6 +5396,7 @@ var z = /* @__PURE__ */ Object.freeze({
5206
5396
  ZodParsedType,
5207
5397
  getParsedType,
5208
5398
  ZodType,
5399
+ datetimeRegex,
5209
5400
  ZodString,
5210
5401
  ZodNumber,
5211
5402
  ZodBigInt,
@@ -5349,6 +5540,9 @@ z.union([
5349
5540
  hexString.refine((address) => ethers2__namespace.isAddress(address), (address) => ({
5350
5541
  message: `${address} is not a valid ethereum address`
5351
5542
  }));
5543
+ string.refine((address) => address.startsWith("cF") && utilCrypto.decodeAddress(address), (address) => ({
5544
+ message: `${address} is not a valid chainflip address`
5545
+ }));
5352
5546
  numericString.transform((arg) => BigInt(arg));
5353
5547
  var u128 = z.union([
5354
5548
  number,
@@ -5371,7 +5565,7 @@ var uncheckedAssetAndChain = z.object({
5371
5565
  asset: z.string(),
5372
5566
  chain: z.string()
5373
5567
  });
5374
- uncheckedAssetAndChain.refine(isValidAssetAndChain);
5568
+ uncheckedAssetAndChain.refine((value) => isValidAssetAndChain(value));
5375
5569
  z.union([
5376
5570
  z.object({
5377
5571
  __kind: z.literal("CcmPrincipal"),
@@ -5393,6 +5587,11 @@ z.union([
5393
5587
  type: "SWAP"
5394
5588
  }))
5395
5589
  ]);
5590
+ var chainflipSS58Prefix = 2112;
5591
+ z.union([
5592
+ hexString,
5593
+ string.regex(/^[a-f\d]$/i).transform((value) => `0x${value}`)
5594
+ ]).transform((value) => utilCrypto.encodeAddress(value, chainflipSS58Prefix));
5396
5595
 
5397
5596
  // ../shared/src/rpc/index.ts
5398
5597
  var numberOrHex = z.union([
@@ -5401,8 +5600,10 @@ var numberOrHex = z.union([
5401
5600
  ]).transform((str) => BigInt(str));
5402
5601
  var camelCase = /* @__PURE__ */ __name((str) => str.replace(/_([a-z])/g, (_, char) => char.toUpperCase()), "camelCase");
5403
5602
  var camelCaseKeys = /* @__PURE__ */ __name((obj) => {
5404
- if (typeof obj !== "object" || Array.isArray(obj) || obj === null)
5603
+ if (typeof obj !== "object" || obj === null)
5405
5604
  return obj;
5605
+ if (Array.isArray(obj))
5606
+ return obj.map((item) => camelCaseKeys(item));
5406
5607
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => [
5407
5608
  camelCase(key),
5408
5609
  camelCaseKeys(value)
@@ -5430,6 +5631,24 @@ var createRequest = /* @__PURE__ */ __name((method, responseParser) => async (ur
5430
5631
  cause: data.error
5431
5632
  });
5432
5633
  }, "createRequest");
5634
+ var createRequestWithoutParser = /* @__PURE__ */ __name((method) => async (urlOrNetwork, ...params) => {
5635
+ const url = "network" in urlOrNetwork ? RPC_URLS[urlOrNetwork.network] : urlOrNetwork.rpcUrl;
5636
+ const { data } = await axios__default.default.post(
5637
+ url,
5638
+ {
5639
+ jsonrpc: "2.0",
5640
+ method,
5641
+ params,
5642
+ id: 1
5643
+ },
5644
+ // prevent JSON.parse from being called because the RPC we are requesting
5645
+ // returns numbers that are unsafe to parse
5646
+ {
5647
+ transformResponse: (d) => d
5648
+ }
5649
+ );
5650
+ return data;
5651
+ }, "createRequestWithoutParser");
5433
5652
  var fundingEnvironment = z.object({
5434
5653
  redemption_tax: numberOrHex,
5435
5654
  minimum_funding_amount: numberOrHex
@@ -5488,28 +5707,23 @@ var ingressEgressEnvironment = z.object({
5488
5707
  egress_dust_limits: "minimum_egress_amounts"
5489
5708
  }));
5490
5709
  createRequest("cf_ingress_egress_environment", ingressEgressEnvironment);
5491
- var rpcAsset = z.union([
5492
- z.literal("BTC"),
5710
+ var rpcAssetSchema = z.union([
5493
5711
  z.object({
5494
5712
  chain: z.literal("Bitcoin"),
5495
5713
  asset: z.literal("BTC")
5496
5714
  }),
5497
- z.literal("DOT"),
5498
5715
  z.object({
5499
5716
  chain: z.literal("Polkadot"),
5500
5717
  asset: z.literal("DOT")
5501
5718
  }),
5502
- z.literal("FLIP"),
5503
5719
  z.object({
5504
5720
  chain: z.literal("Ethereum"),
5505
5721
  asset: z.literal("FLIP")
5506
5722
  }),
5507
- z.literal("ETH"),
5508
5723
  z.object({
5509
5724
  chain: z.literal("Ethereum"),
5510
5725
  asset: z.literal("ETH")
5511
5726
  }),
5512
- z.literal("USDC"),
5513
5727
  z.object({
5514
5728
  chain: z.literal("Ethereum"),
5515
5729
  asset: z.literal("USDC")
@@ -5527,39 +5741,6 @@ var rpcAsset = z.union([
5527
5741
  asset: z.literal("USDC")
5528
5742
  })
5529
5743
  ]);
5530
- var poolInfo = z.intersection(z.object({
5531
- limit_order_fee_hundredth_pips: z.number(),
5532
- range_order_fee_hundredth_pips: z.number()
5533
- }), z.union([
5534
- z.object({
5535
- quote_asset: rpcAsset
5536
- }),
5537
- z.object({
5538
- pair_asset: rpcAsset
5539
- }).transform(({ pair_asset }) => ({
5540
- quote_asset: pair_asset
5541
- }))
5542
- ]));
5543
- var feesInfo = z.object({
5544
- Bitcoin: z.object({
5545
- BTC: poolInfo
5546
- }),
5547
- Ethereum: z.object({
5548
- ETH: poolInfo,
5549
- FLIP: poolInfo
5550
- }),
5551
- Polkadot: z.object({
5552
- DOT: poolInfo
5553
- }),
5554
- Arbitrum: z.object({
5555
- ETH: poolInfo,
5556
- USDC: poolInfo
5557
- }).optional()
5558
- });
5559
- var poolsEnvironment = z.object({
5560
- fees: feesInfo
5561
- });
5562
- createRequest("cf_pool_info", poolsEnvironment);
5563
5744
  var environment = z.object({
5564
5745
  ingress_egress: ingressEgressEnvironment,
5565
5746
  swapping: swappingEnvironment,
@@ -5571,30 +5752,21 @@ var swapRate = z.object({
5571
5752
  });
5572
5753
  createRequest("cf_swap_rate", swapRate);
5573
5754
  createRequest("state_getMetadata", hexString);
5574
- var supportedAssetsV120 = z.object({
5575
- Bitcoin: z.array(z.string()),
5576
- Ethereum: z.array(z.string()),
5577
- Polkadot: z.array(z.string())
5578
- }).transform((data) => [
5579
- ...data.Bitcoin.map((asset2) => ({
5580
- chain: "Bitcoin",
5581
- asset: asset2
5582
- })),
5583
- ...data.Ethereum.map((asset2) => ({
5584
- chain: "Ethereum",
5585
- asset: asset2
5586
- })),
5587
- ...data.Polkadot.map((asset2) => ({
5588
- chain: "Polkadot",
5589
- asset: asset2
5590
- }))
5591
- ]);
5592
- var supportedAssetsV130 = z.array(uncheckedAssetAndChain);
5593
- var supportedAssets = z.union([
5594
- supportedAssetsV120,
5595
- supportedAssetsV130
5596
- ]);
5755
+ var supportedAssets = z.array(uncheckedAssetAndChain);
5597
5756
  createRequest("cf_supported_assets", supportedAssets);
5757
+ createRequest("state_getRuntimeVersion", z.object({
5758
+ specVersion: z.number()
5759
+ }));
5760
+ createRequestWithoutParser("cf_pool_orders");
5761
+ createRequest("cf_pool_price_v2", z.object({
5762
+ range_order: numberOrHex
5763
+ }));
5764
+ createRequest("chain_getBlockHash", hexString);
5765
+ var boostPoolsDepthResponseSchema = z.array(z.intersection(rpcAssetSchema, z.object({
5766
+ tier: number,
5767
+ available_amount: u128
5768
+ })));
5769
+ createRequest("cf_boost_pools_depth", boostPoolsDepthResponseSchema);
5598
5770
 
5599
5771
  // ../shared/src/stateChainGateway/utils.ts
5600
5772
  var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
@@ -5617,18 +5789,20 @@ var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts
5617
5789
  }, "approveStateChainGateway");
5618
5790
 
5619
5791
  // ../shared/src/stateChainGateway/index.ts
5620
- var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, networkOpts, txOpts) => {
5792
+ var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId2, amount, networkOpts, txOpts) => {
5621
5793
  const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(InternalAssets.Flip, networkOpts.network);
5622
5794
  const stateChainGateway = getStateChainGateway(networkOpts);
5623
5795
  const { hasSufficientAllowance } = await checkAllowance(amount, await stateChainGateway.getAddress(), flipContractAddress, networkOpts.signer);
5624
5796
  assert(hasSufficientAllowance, "Insufficient allowance");
5625
- const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, extractOverrides(txOpts));
5626
- return transaction.wait(txOpts.wait);
5797
+ const transaction = await stateChainGateway.fundStateChainAccount(accountId2, amount, extractOverrides(txOpts));
5798
+ await transaction.wait(txOpts.wait);
5799
+ return transaction;
5627
5800
  }, "fundStateChainAccount");
5628
- var executeRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts, txOpts) => {
5801
+ var executeRedemption = /* @__PURE__ */ __name(async (accountId2, networkOpts, txOpts) => {
5629
5802
  const stateChainGateway = getStateChainGateway(networkOpts);
5630
- const transaction = await stateChainGateway.executeRedemption(accountId, extractOverrides(txOpts));
5631
- return transaction.wait(txOpts.wait);
5803
+ const transaction = await stateChainGateway.executeRedemption(accountId2, extractOverrides(txOpts));
5804
+ await transaction.wait(txOpts.wait);
5805
+ return transaction;
5632
5806
  }, "executeRedemption");
5633
5807
  var getMinimumFunding = /* @__PURE__ */ __name((networkOpts) => {
5634
5808
  const stateChainGateway = getStateChainGateway(networkOpts);
@@ -5638,10 +5812,10 @@ var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
5638
5812
  const stateChainGateway = getStateChainGateway(networkOpts);
5639
5813
  return stateChainGateway.REDEMPTION_DELAY();
5640
5814
  }, "getRedemptionDelay");
5641
- var getPendingRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts) => {
5815
+ var getPendingRedemption = /* @__PURE__ */ __name(async (accountId2, networkOpts) => {
5642
5816
  const stateChainGateway = getStateChainGateway(networkOpts);
5643
- const pendingRedemption = await stateChainGateway.getPendingRedemption(accountId);
5644
- return pendingRedemption.amount !== 0n ? stateChainGateway.getPendingRedemption(accountId) : void 0;
5817
+ const pendingRedemption = await stateChainGateway.getPendingRedemption(accountId2);
5818
+ return pendingRedemption.amount !== 0n ? stateChainGateway.getPendingRedemption(accountId2) : void 0;
5645
5819
  }, "getPendingRedemption");
5646
5820
 
5647
5821
  // src/funding/sdk.ts
@@ -5665,15 +5839,15 @@ var _FundingSDK = class _FundingSDK {
5665
5839
  * @param accountId the hex-encoded validator account id
5666
5840
  * @param amount the amount to fund in base units of FLIP
5667
5841
  */
5668
- async fundStateChainAccount(accountId, amount, txOpts = {}) {
5669
- const tx = await fundStateChainAccount(accountId, amount, this.options, txOpts);
5842
+ async fundStateChainAccount(accountId2, amount, txOpts = {}) {
5843
+ const tx = await fundStateChainAccount(accountId2, amount, this.options, txOpts);
5670
5844
  return tx.hash;
5671
5845
  }
5672
5846
  /**
5673
5847
  * @param accountId the hex-encoded validator account id
5674
5848
  */
5675
- async executeRedemption(accountId, txOpts = {}) {
5676
- const tx = await executeRedemption(accountId, this.options, txOpts);
5849
+ async executeRedemption(accountId2, txOpts = {}) {
5850
+ const tx = await executeRedemption(accountId2, this.options, txOpts);
5677
5851
  return tx.hash;
5678
5852
  }
5679
5853
  async getMinimumFunding() {
@@ -5685,16 +5859,16 @@ var _FundingSDK = class _FundingSDK {
5685
5859
  async getFlipBalance() {
5686
5860
  return getFlipBalance(this.options.network, this.options.signer);
5687
5861
  }
5688
- async getPendingRedemption(accountId) {
5689
- return getPendingRedemption(accountId, this.options);
5862
+ async getPendingRedemption(accountId2) {
5863
+ return getPendingRedemption(accountId2, this.options);
5690
5864
  }
5691
5865
  /**
5692
5866
  * @param the amount of FLIP to request approval for
5693
5867
  * @returns the transaction hash or null if no approval was required
5694
5868
  */
5695
5869
  async approveStateChainGateway(amount, txOpts = {}) {
5696
- const receipt = await approveStateChainGateway(amount, this.options, txOpts);
5697
- return receipt ? receipt.hash : null;
5870
+ const tx = await approveStateChainGateway(amount, this.options, txOpts);
5871
+ return tx ? tx.hash : null;
5698
5872
  }
5699
5873
  async getRedemptionTax() {
5700
5874
  this.redemptionTax ?? (this.redemptionTax = (await getFundingEnvironment(this.rpcConfig)).redemptionTax);