@ocap/util 1.27.15 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/esm/bn.d.ts +8 -6
  2. package/esm/bn.js +11 -7
  3. package/esm/constant.d.ts +4 -1
  4. package/esm/constant.js +5 -1
  5. package/esm/create-sorted-list.d.ts +4 -1
  6. package/esm/create-sorted-list.js +8 -3
  7. package/esm/curve.d.ts +85 -55
  8. package/esm/curve.js +132 -127
  9. package/esm/error.d.ts +12 -9
  10. package/esm/error.js +24 -17
  11. package/esm/get-list-field.d.ts +4 -1
  12. package/esm/get-list-field.js +7 -2
  13. package/esm/get-related-addr.d.ts +4 -1
  14. package/esm/get-related-addr.js +5 -1
  15. package/esm/index.d.ts +47 -44
  16. package/esm/index.js +364 -469
  17. package/esm/lodash.d.ts +12 -0
  18. package/esm/md5.d.ts +4 -1
  19. package/esm/md5.js +7 -3
  20. package/esm/ready.d.ts +13 -9
  21. package/esm/ready.js +33 -36
  22. package/esm/retry.d.ts +16 -9
  23. package/esm/retry.js +26 -27
  24. package/esm/tsfixme.d.ts +3 -0
  25. package/esm/url.d.ts +16 -12
  26. package/esm/url.js +67 -92
  27. package/lib/_virtual/rolldown_runtime.js +29 -0
  28. package/lib/bn.d.ts +8 -6
  29. package/lib/bn.js +12 -12
  30. package/lib/constant.d.ts +4 -1
  31. package/lib/constant.js +6 -4
  32. package/lib/create-sorted-list.d.ts +4 -1
  33. package/lib/create-sorted-list.js +11 -10
  34. package/lib/curve.d.ts +84 -55
  35. package/lib/curve.js +139 -137
  36. package/lib/error.d.ts +12 -9
  37. package/lib/error.js +25 -21
  38. package/lib/get-list-field.d.ts +4 -1
  39. package/lib/get-list-field.js +9 -9
  40. package/lib/get-related-addr.d.ts +4 -1
  41. package/lib/get-related-addr.js +5 -4
  42. package/lib/index.d.ts +47 -44
  43. package/lib/index.js +386 -506
  44. package/lib/lodash.d.ts +12 -0
  45. package/lib/md5.d.ts +4 -1
  46. package/lib/md5.js +9 -10
  47. package/lib/ready.d.ts +13 -9
  48. package/lib/ready.js +34 -42
  49. package/lib/retry.d.ts +16 -9
  50. package/lib/retry.js +27 -30
  51. package/lib/tsfixme.d.ts +3 -0
  52. package/lib/url.d.ts +16 -12
  53. package/lib/url.js +69 -118
  54. package/package.json +23 -9
package/lib/curve.d.ts CHANGED
@@ -1,84 +1,113 @@
1
- import { BN } from './index';
2
- export declare enum Direction {
3
- Mint = "mint",
4
- Burn = "burn"
1
+ import { BN } from "./bn.js";
2
+ import * as bn_js0 from "bn.js";
3
+
4
+ //#region src/curve.d.ts
5
+ declare enum Direction {
6
+ Mint = "mint",
7
+ Burn = "burn",
5
8
  }
6
9
  /**
7
10
  * Constant Curve
8
11
  * Price = fixedPrice
9
12
  */
10
- export declare function calcConstantPrice({ fixedPrice }: {
11
- fixedPrice: string;
13
+ declare function calcConstantPrice({
14
+ fixedPrice
15
+ }: {
16
+ fixedPrice: string;
12
17
  }): BN;
13
18
  /**
14
19
  * Constant Curve
15
20
  * Cost = amount * fixedPrice
16
21
  */
17
- export declare function calcConstantCost({ amount, fixedPrice, decimal, }: {
18
- amount: string;
19
- fixedPrice: string;
20
- decimal: number;
21
- }): import("bn.js");
22
+ declare function calcConstantCost({
23
+ amount,
24
+ fixedPrice,
25
+ decimal
26
+ }: {
27
+ amount: string;
28
+ fixedPrice: string;
29
+ decimal: number;
30
+ }): bn_js0;
22
31
  /**
23
32
  * linear Curve
24
33
  * Price = basePrice + slope * currentSupply
25
34
  */
26
- export declare function calcLinearPrice({ basePrice, slope, currentSupply, decimal, }: {
27
- basePrice: string;
28
- slope: string;
29
- currentSupply: string;
30
- decimal: number;
31
- }): import("bn.js");
35
+ declare function calcLinearPrice({
36
+ basePrice,
37
+ slope,
38
+ currentSupply,
39
+ decimal
40
+ }: {
41
+ basePrice: string;
42
+ slope: string;
43
+ currentSupply: string;
44
+ decimal: number;
45
+ }): bn_js0;
32
46
  /**
33
47
  * Linear Curve
34
48
  * mint Cost = (slope / 2) * ( (currentSupply + amount) ** 2 - currentSupply ** 2 ) + basePrice * amount;
35
49
  * burn Cost = (slope / 2) * ( currentSupply ** 2 - (currentSupply - amount) ** 2 ) + basePrice * amount;
36
50
  */
37
- export declare function calcLinearCost(params: {
38
- amount: string;
39
- currentSupply: string;
40
- basePrice: string;
41
- slope: string;
42
- decimal: number;
43
- direction: Direction;
44
- }): import("bn.js");
51
+ declare function calcLinearCost(params: {
52
+ amount: string;
53
+ currentSupply: string;
54
+ basePrice: string;
55
+ slope: string;
56
+ decimal: number;
57
+ direction: Direction;
58
+ }): bn_js0;
45
59
  /**
46
60
  * Quadratic Curve
47
61
  * Price = basePrice + currentSupply ** 2 / constant
48
62
  */
49
- export declare function calcQuadraticPrice(params: {
50
- basePrice: string;
51
- currentSupply: string;
52
- constant: string;
53
- decimal: number;
54
- }): import("bn.js");
63
+ declare function calcQuadraticPrice(params: {
64
+ basePrice: string;
65
+ currentSupply: string;
66
+ constant: string;
67
+ decimal: number;
68
+ }): bn_js0;
55
69
  /**
56
70
  * Quadratic Curve
57
71
  * Price = basePrice + currentSupply ** 2 / constant
58
72
  * mint Cost = ( (currentSupply + amount)^3 / 3 - currentSupply^3 / 3 ) / constant + basePrice * amount;
59
73
  * burn Cost = ( currentSupply^3 / 3 - (currentSupply - amount)^3 / 3 ) / constant + basePrice * amount;
60
74
  */
61
- export declare function calcQuadraticCost(params: {
62
- amount: string;
63
- currentSupply: string;
64
- basePrice: string;
65
- constant: string;
66
- decimal: number;
67
- direction: Direction;
68
- }): import("bn.js");
69
- export declare function calcFee({ reserveAmount, feeRate }: {
70
- reserveAmount: string;
71
- feeRate: string;
72
- }): import("bn.js");
73
- export declare function calcPrice({ currentSupply, decimal, curve }: {
74
- currentSupply: string;
75
- decimal: number;
76
- curve: any;
77
- }): import("bn.js");
78
- export declare function calcCost({ amount, decimal, currentSupply, direction, curve, }: {
79
- amount: string;
80
- decimal: number;
81
- currentSupply: string;
82
- curve: any;
83
- direction: Direction;
84
- }): import("bn.js");
75
+ declare function calcQuadraticCost(params: {
76
+ amount: string;
77
+ currentSupply: string;
78
+ basePrice: string;
79
+ constant: string;
80
+ decimal: number;
81
+ direction: Direction;
82
+ }): bn_js0;
83
+ declare function calcFee({
84
+ reserveAmount,
85
+ feeRate
86
+ }: {
87
+ reserveAmount: string;
88
+ feeRate: string;
89
+ }): bn_js0;
90
+ declare function calcPrice({
91
+ currentSupply,
92
+ decimal,
93
+ curve
94
+ }: {
95
+ currentSupply: string;
96
+ decimal: number;
97
+ curve: any;
98
+ }): bn_js0;
99
+ declare function calcCost({
100
+ amount,
101
+ decimal,
102
+ currentSupply,
103
+ direction,
104
+ curve
105
+ }: {
106
+ amount: string;
107
+ decimal: number;
108
+ currentSupply: string;
109
+ curve: any;
110
+ direction: Direction;
111
+ }): bn_js0;
112
+ //#endregion
113
+ export { Direction, calcConstantCost, calcConstantPrice, calcCost, calcFee, calcLinearCost, calcLinearPrice, calcPrice, calcQuadraticCost, calcQuadraticPrice };
package/lib/curve.js CHANGED
@@ -1,158 +1,160 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Direction = void 0;
4
- exports.calcConstantPrice = calcConstantPrice;
5
- exports.calcConstantCost = calcConstantCost;
6
- exports.calcLinearPrice = calcLinearPrice;
7
- exports.calcLinearCost = calcLinearCost;
8
- exports.calcQuadraticPrice = calcQuadraticPrice;
9
- exports.calcQuadraticCost = calcQuadraticCost;
10
- exports.calcFee = calcFee;
11
- exports.calcPrice = calcPrice;
12
- exports.calcCost = calcCost;
13
- const index_1 = require("./index");
14
- const ZERO = new index_1.BN(0);
15
- const TWO = new index_1.BN(2);
16
- const THREE = new index_1.BN(3);
17
- const TEN = new index_1.BN(10);
18
- var Direction;
19
- (function (Direction) {
20
- Direction["Mint"] = "mint";
21
- Direction["Burn"] = "burn";
22
- })(Direction || (exports.Direction = Direction = {}));
1
+ const require_bn = require('./bn.js');
2
+
3
+ //#region src/curve.ts
4
+ const ZERO = new require_bn.BN(0);
5
+ const TWO = new require_bn.BN(2);
6
+ const THREE = new require_bn.BN(3);
7
+ const TEN = new require_bn.BN(10);
8
+ let Direction = /* @__PURE__ */ function(Direction$1) {
9
+ Direction$1["Mint"] = "mint";
10
+ Direction$1["Burn"] = "burn";
11
+ return Direction$1;
12
+ }({});
23
13
  /**
24
- * Constant Curve
25
- * Price = fixedPrice
26
- */
14
+ * Constant Curve
15
+ * Price = fixedPrice
16
+ */
27
17
  function calcConstantPrice({ fixedPrice }) {
28
- return new index_1.BN(fixedPrice);
18
+ return new require_bn.BN(fixedPrice);
29
19
  }
30
20
  /**
31
- * Constant Curve
32
- * Cost = amount * fixedPrice
33
- */
34
- function calcConstantCost({ amount, fixedPrice, decimal, }) {
35
- const decimalFactor = TEN.pow(new index_1.BN(decimal));
36
- return new index_1.BN(amount).mul(new index_1.BN(fixedPrice)).div(decimalFactor);
21
+ * Constant Curve
22
+ * Cost = amount * fixedPrice
23
+ */
24
+ function calcConstantCost({ amount, fixedPrice, decimal }) {
25
+ const decimalFactor = TEN.pow(new require_bn.BN(decimal));
26
+ return new require_bn.BN(amount).mul(new require_bn.BN(fixedPrice)).div(decimalFactor);
37
27
  }
38
28
  /**
39
- * linear Curve
40
- * Price = basePrice + slope * currentSupply
41
- */
42
- function calcLinearPrice({ basePrice, slope, currentSupply, decimal, }) {
43
- const decimalFactor = TEN.pow(new index_1.BN(decimal));
44
- return new index_1.BN(basePrice).add(new index_1.BN(slope).mul(new index_1.BN(currentSupply)).div(decimalFactor));
29
+ * linear Curve
30
+ * Price = basePrice + slope * currentSupply
31
+ */
32
+ function calcLinearPrice({ basePrice, slope, currentSupply, decimal }) {
33
+ const decimalFactor = TEN.pow(new require_bn.BN(decimal));
34
+ return new require_bn.BN(basePrice).add(new require_bn.BN(slope).mul(new require_bn.BN(currentSupply)).div(decimalFactor));
45
35
  }
46
36
  /**
47
- * Linear Curve
48
- * mint Cost = (slope / 2) * ( (currentSupply + amount) ** 2 - currentSupply ** 2 ) + basePrice * amount;
49
- * burn Cost = (slope / 2) * ( currentSupply ** 2 - (currentSupply - amount) ** 2 ) + basePrice * amount;
50
- */
37
+ * Linear Curve
38
+ * mint Cost = (slope / 2) * ( (currentSupply + amount) ** 2 - currentSupply ** 2 ) + basePrice * amount;
39
+ * burn Cost = (slope / 2) * ( currentSupply ** 2 - (currentSupply - amount) ** 2 ) + basePrice * amount;
40
+ */
51
41
  function calcLinearCost(params) {
52
- const amount = new index_1.BN(params.amount);
53
- const currentSupply = new index_1.BN(params.currentSupply);
54
- const basePrice = new index_1.BN(params.basePrice);
55
- const slope = new index_1.BN(params.slope);
56
- const decimalFactor = TEN.pow(new index_1.BN(params.decimal));
57
- if (slope.lte(ZERO))
58
- throw new Error('INVALID_SLOPE');
59
- if (amount.lt(ZERO))
60
- throw new Error('INVALID_AMOUNT');
61
- if (currentSupply.lt(ZERO))
62
- throw new Error('INVALID_CURRENT_SUPPLY');
63
- if (basePrice.lt(ZERO))
64
- throw new Error('INVALID_BASE_PRICE');
65
- if (decimalFactor.lte(ZERO))
66
- throw new Error('INVALID_DECIMAL_FACTOR');
67
- if (params.direction === Direction.Burn && amount.gt(currentSupply)) {
68
- throw new Error('SUPPLY_INSUFFICIENT');
69
- }
70
- const integralDelta = params.direction === Direction.Mint
71
- ? amount.mul(currentSupply.mul(TWO).add(amount)) // (currentSupply + amount) ** 2 - currentSupply ** 2 = amount * (2 * currentSupply + amount)
72
- : amount.mul(currentSupply.mul(TWO).sub(amount)); // currentSupply ** 2 - (currentSupply - amount) ** 2 = amount * (2 * currentSupply - amount)
73
- const linearTerm = basePrice.mul(amount).div(decimalFactor);
74
- const integralTerm = slope.mul(integralDelta).div(TWO.mul(decimalFactor.sqr()));
75
- return linearTerm.add(integralTerm);
42
+ const amount = new require_bn.BN(params.amount);
43
+ const currentSupply = new require_bn.BN(params.currentSupply);
44
+ const basePrice = new require_bn.BN(params.basePrice);
45
+ const slope = new require_bn.BN(params.slope);
46
+ const decimalFactor = TEN.pow(new require_bn.BN(params.decimal));
47
+ if (slope.lte(ZERO)) throw new Error("INVALID_SLOPE");
48
+ if (amount.lt(ZERO)) throw new Error("INVALID_AMOUNT");
49
+ if (currentSupply.lt(ZERO)) throw new Error("INVALID_CURRENT_SUPPLY");
50
+ if (basePrice.lt(ZERO)) throw new Error("INVALID_BASE_PRICE");
51
+ if (decimalFactor.lte(ZERO)) throw new Error("INVALID_DECIMAL_FACTOR");
52
+ if (params.direction === Direction.Burn && amount.gt(currentSupply)) throw new Error("SUPPLY_INSUFFICIENT");
53
+ const integralDelta = params.direction === Direction.Mint ? amount.mul(currentSupply.mul(TWO).add(amount)) : amount.mul(currentSupply.mul(TWO).sub(amount));
54
+ const linearTerm = basePrice.mul(amount).div(decimalFactor);
55
+ const integralTerm = slope.mul(integralDelta).div(TWO.mul(decimalFactor.sqr()));
56
+ return linearTerm.add(integralTerm);
76
57
  }
77
58
  /**
78
- * Quadratic Curve
79
- * Price = basePrice + currentSupply ** 2 / constant
80
- */
59
+ * Quadratic Curve
60
+ * Price = basePrice + currentSupply ** 2 / constant
61
+ */
81
62
  function calcQuadraticPrice(params) {
82
- const basePrice = new index_1.BN(params.basePrice);
83
- const currentSupply = new index_1.BN(params.currentSupply);
84
- const constant = new index_1.BN(params.constant);
85
- const decimalFactor = TEN.pow(new index_1.BN(params.decimal)); // 10^decimal
86
- if (constant.lte(ZERO))
87
- throw new Error('INVALID_CONSTANT');
88
- if (currentSupply.lt(ZERO))
89
- throw new Error('INVALID_CURRENT_SUPPLY');
90
- if (basePrice.lt(ZERO))
91
- throw new Error('INVALID_BASE_PRICE');
92
- if (decimalFactor.lte(ZERO))
93
- throw new Error('INVALID_DECIMAL_FACTOR');
94
- // Single division to reduce double-flooring error
95
- const denom = constant.mul(decimalFactor);
96
- const a = currentSupply.sqr().div(denom);
97
- return basePrice.add(a);
63
+ const basePrice = new require_bn.BN(params.basePrice);
64
+ const currentSupply = new require_bn.BN(params.currentSupply);
65
+ const constant = new require_bn.BN(params.constant);
66
+ const decimalFactor = TEN.pow(new require_bn.BN(params.decimal));
67
+ if (constant.lte(ZERO)) throw new Error("INVALID_CONSTANT");
68
+ if (currentSupply.lt(ZERO)) throw new Error("INVALID_CURRENT_SUPPLY");
69
+ if (basePrice.lt(ZERO)) throw new Error("INVALID_BASE_PRICE");
70
+ if (decimalFactor.lte(ZERO)) throw new Error("INVALID_DECIMAL_FACTOR");
71
+ const denom = constant.mul(decimalFactor);
72
+ const a = currentSupply.sqr().div(denom);
73
+ return basePrice.add(a);
98
74
  }
99
75
  /**
100
- * Quadratic Curve
101
- * Price = basePrice + currentSupply ** 2 / constant
102
- * mint Cost = ( (currentSupply + amount)^3 / 3 - currentSupply^3 / 3 ) / constant + basePrice * amount;
103
- * burn Cost = ( currentSupply^3 / 3 - (currentSupply - amount)^3 / 3 ) / constant + basePrice * amount;
104
- */
76
+ * Quadratic Curve
77
+ * Price = basePrice + currentSupply ** 2 / constant
78
+ * mint Cost = ( (currentSupply + amount)^3 / 3 - currentSupply^3 / 3 ) / constant + basePrice * amount;
79
+ * burn Cost = ( currentSupply^3 / 3 - (currentSupply - amount)^3 / 3 ) / constant + basePrice * amount;
80
+ */
105
81
  function calcQuadraticCost(params) {
106
- const amount = new index_1.BN(params.amount);
107
- const currentSupply = new index_1.BN(params.currentSupply);
108
- const basePrice = new index_1.BN(params.basePrice);
109
- const constant = new index_1.BN(params.constant);
110
- const decimalFactor = TEN.pow(new index_1.BN(params.decimal)); // M = 10^decimal
111
- // Basic validations
112
- if (constant.lte(ZERO))
113
- throw new Error('INVALID_CONSTANT');
114
- if (amount.lt(ZERO))
115
- throw new Error('INVALID_AMOUNT');
116
- if (amount.isZero())
117
- return ZERO;
118
- // Compute new supply with direction guard
119
- const newSupply = params.direction === Direction.Mint ? currentSupply.add(amount) : currentSupply.sub(amount);
120
- if (params.direction === Direction.Burn && newSupply.lt(ZERO)) {
121
- throw new Error('SUPPLY_INSUFFICIENT');
122
- }
123
- // cubicDelta = |S1^3 - S0^3| = (S1 - S0) * (S1^2 + S1 * S0 + S0^2)
124
- const diff = params.direction === Direction.Mint ? newSupply.sub(currentSupply) : currentSupply.sub(newSupply);
125
- const sumSquaresAndProduct = newSupply.sqr().add(newSupply.mul(currentSupply)).add(currentSupply.sqr());
126
- const cubicDelta = diff.mul(sumSquaresAndProduct);
127
- // integral term: (S1^3 - S0^3) / (3 * constant * M^2)
128
- const denom = THREE.mul(constant).mul(decimalFactor.sqr());
129
- const cubicCost = cubicDelta.div(denom);
130
- // linear term: basePrice * amount / M
131
- const linearCost = basePrice.mul(amount).div(decimalFactor);
132
- return cubicCost.add(linearCost);
82
+ const amount = new require_bn.BN(params.amount);
83
+ const currentSupply = new require_bn.BN(params.currentSupply);
84
+ const basePrice = new require_bn.BN(params.basePrice);
85
+ const constant = new require_bn.BN(params.constant);
86
+ const decimalFactor = TEN.pow(new require_bn.BN(params.decimal));
87
+ if (constant.lte(ZERO)) throw new Error("INVALID_CONSTANT");
88
+ if (amount.lt(ZERO)) throw new Error("INVALID_AMOUNT");
89
+ if (amount.isZero()) return ZERO;
90
+ const newSupply = params.direction === Direction.Mint ? currentSupply.add(amount) : currentSupply.sub(amount);
91
+ if (params.direction === Direction.Burn && newSupply.lt(ZERO)) throw new Error("SUPPLY_INSUFFICIENT");
92
+ const diff = params.direction === Direction.Mint ? newSupply.sub(currentSupply) : currentSupply.sub(newSupply);
93
+ const sumSquaresAndProduct = newSupply.sqr().add(newSupply.mul(currentSupply)).add(currentSupply.sqr());
94
+ const cubicDelta = diff.mul(sumSquaresAndProduct);
95
+ const denom = THREE.mul(constant).mul(decimalFactor.sqr());
96
+ const cubicCost = cubicDelta.div(denom);
97
+ const linearCost = basePrice.mul(amount).div(decimalFactor);
98
+ return cubicCost.add(linearCost);
133
99
  }
134
100
  function calcFee({ reserveAmount, feeRate }) {
135
- return new index_1.BN(reserveAmount).mul(new index_1.BN(feeRate)).div(new index_1.BN(10000));
101
+ return new require_bn.BN(reserveAmount).mul(new require_bn.BN(feeRate)).div(new require_bn.BN(1e4));
136
102
  }
137
103
  function calcPrice({ currentSupply, decimal, curve }) {
138
- const calculator = {
139
- constant: () => calcConstantPrice({ currentSupply, decimal, ...curve }),
140
- linear: () => calcLinearPrice({ currentSupply, decimal, ...curve }),
141
- quadratic: () => calcQuadraticPrice({ currentSupply, decimal, ...curve }),
142
- }[curve.type];
143
- if (!calculator) {
144
- throw new Error('INVALID_CURVE_TYPE');
145
- }
146
- return calculator();
104
+ const calculator = {
105
+ constant: () => calcConstantPrice({
106
+ currentSupply,
107
+ decimal,
108
+ ...curve
109
+ }),
110
+ linear: () => calcLinearPrice({
111
+ currentSupply,
112
+ decimal,
113
+ ...curve
114
+ }),
115
+ quadratic: () => calcQuadraticPrice({
116
+ currentSupply,
117
+ decimal,
118
+ ...curve
119
+ })
120
+ }[curve.type];
121
+ if (!calculator) throw new Error("INVALID_CURVE_TYPE");
122
+ return calculator();
147
123
  }
148
- function calcCost({ amount, decimal, currentSupply, direction, curve, }) {
149
- const calculator = {
150
- constant: () => calcConstantCost({ amount, decimal, ...curve }),
151
- linear: () => calcLinearCost({ amount, decimal, currentSupply, direction, ...curve }),
152
- quadratic: () => calcQuadraticCost({ amount, decimal, currentSupply, direction, ...curve }),
153
- }[curve.type];
154
- if (!calculator) {
155
- throw new Error('INVALID_CURVE_TYPE');
156
- }
157
- return calculator();
124
+ function calcCost({ amount, decimal, currentSupply, direction, curve }) {
125
+ const calculator = {
126
+ constant: () => calcConstantCost({
127
+ amount,
128
+ decimal,
129
+ ...curve
130
+ }),
131
+ linear: () => calcLinearCost({
132
+ amount,
133
+ decimal,
134
+ currentSupply,
135
+ direction,
136
+ ...curve
137
+ }),
138
+ quadratic: () => calcQuadraticCost({
139
+ amount,
140
+ decimal,
141
+ currentSupply,
142
+ direction,
143
+ ...curve
144
+ })
145
+ }[curve.type];
146
+ if (!calculator) throw new Error("INVALID_CURVE_TYPE");
147
+ return calculator();
158
148
  }
149
+
150
+ //#endregion
151
+ exports.Direction = Direction;
152
+ exports.calcConstantCost = calcConstantCost;
153
+ exports.calcConstantPrice = calcConstantPrice;
154
+ exports.calcCost = calcCost;
155
+ exports.calcFee = calcFee;
156
+ exports.calcLinearCost = calcLinearCost;
157
+ exports.calcLinearPrice = calcLinearPrice;
158
+ exports.calcPrice = calcPrice;
159
+ exports.calcQuadraticCost = calcQuadraticCost;
160
+ exports.calcQuadraticPrice = calcQuadraticPrice;
package/lib/error.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- export declare class CustomError extends Error {
2
- code: string;
3
- props: {
4
- persist: boolean;
5
- [prop: string]: $TSFixMe;
6
- };
7
- constructor(code: string, message: string, props?: {});
1
+ //#region src/error.d.ts
2
+ declare class CustomError extends Error {
3
+ code: string;
4
+ props: {
5
+ persist: boolean;
6
+ [prop: string]: $TSFixMe;
7
+ };
8
+ constructor(code: string, message: string, props?: {});
8
9
  }
9
- export declare class PersistError extends CustomError {
10
- constructor(code: string, message: string, props?: {});
10
+ declare class PersistError extends CustomError {
11
+ constructor(code: string, message: string, props?: {});
11
12
  }
13
+ //#endregion
14
+ export { CustomError, PersistError };
package/lib/error.js CHANGED
@@ -1,22 +1,26 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PersistError = exports.CustomError = void 0;
4
- /* eslint-disable max-classes-per-file */
5
- class CustomError extends Error {
6
- constructor(code, message, props = {}) {
7
- super(message);
8
- if (Error.captureStackTrace) {
9
- Error.captureStackTrace(this, CustomError);
10
- }
11
- this.code = code;
12
- this.props = { persist: false, ...props };
13
- }
14
- }
1
+
2
+ //#region src/error.ts
3
+ var CustomError = class CustomError extends Error {
4
+ constructor(code, message, props = {}) {
5
+ super(message);
6
+ if (Error.captureStackTrace) Error.captureStackTrace(this, CustomError);
7
+ this.code = code;
8
+ this.props = {
9
+ persist: false,
10
+ ...props
11
+ };
12
+ }
13
+ };
14
+ var PersistError = class extends CustomError {
15
+ constructor(code, message, props = {}) {
16
+ super(code, message);
17
+ this.props = {
18
+ persist: true,
19
+ ...props
20
+ };
21
+ }
22
+ };
23
+
24
+ //#endregion
15
25
  exports.CustomError = CustomError;
16
- class PersistError extends CustomError {
17
- constructor(code, message, props = {}) {
18
- super(code, message);
19
- this.props = { persist: true, ...props };
20
- }
21
- }
22
- exports.PersistError = PersistError;
26
+ exports.PersistError = PersistError;
@@ -1 +1,4 @@
1
- export declare const getListField: (obj: $TSFixMe, key: string) => any;
1
+ //#region src/get-list-field.d.ts
2
+ declare const getListField: (obj: $TSFixMe, key: string) => any;
3
+ //#endregion
4
+ export { getListField };
@@ -1,9 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getListField = void 0;
7
- const get_1 = __importDefault(require("lodash/get"));
8
- const getListField = (obj, key) => (0, get_1.default)(obj, `${key}List`) || (0, get_1.default)(obj, key) || [];
9
- exports.getListField = getListField;
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.js');
2
+ let lodash_get = require("lodash/get");
3
+ lodash_get = require_rolldown_runtime.__toESM(lodash_get);
4
+
5
+ //#region src/get-list-field.ts
6
+ const getListField = (obj, key) => (0, lodash_get.default)(obj, `${key}List`) || (0, lodash_get.default)(obj, key) || [];
7
+
8
+ //#endregion
9
+ exports.getListField = getListField;
@@ -1 +1,4 @@
1
- export declare const getRelatedAddresses: (state: $TSFixMe) => any[];
1
+ //#region src/get-related-addr.d.ts
2
+ declare const getRelatedAddresses: (state: $TSFixMe) => any[];
3
+ //#endregion
4
+ export { getRelatedAddresses };
@@ -1,5 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRelatedAddresses = void 0;
1
+
2
+ //#region src/get-related-addr.ts
4
3
  const getRelatedAddresses = (state) => [state.address].concat(state.migratedFrom || []).filter(Boolean);
5
- exports.getRelatedAddresses = getRelatedAddresses;
4
+
5
+ //#endregion
6
+ exports.getRelatedAddresses = getRelatedAddresses;