aftermath-ts-sdk 1.2.64 → 1.2.65

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 (114) hide show
  1. package/dist/general/dynamicGas/dynamicGas.d.ts +34 -0
  2. package/dist/general/dynamicGas/dynamicGas.d.ts.map +1 -1
  3. package/dist/general/dynamicGas/dynamicGas.js +34 -0
  4. package/dist/general/dynamicGas/dynamicGasTypes.d.ts +25 -0
  5. package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +1 -1
  6. package/dist/general/prices/prices.d.ts +73 -0
  7. package/dist/general/prices/prices.d.ts.map +1 -1
  8. package/dist/general/prices/prices.js +73 -0
  9. package/dist/general/providers/aftermath.d.ts +106 -25
  10. package/dist/general/providers/aftermath.d.ts.map +1 -1
  11. package/dist/general/providers/aftermath.js +108 -27
  12. package/dist/general/providers/aftermathApi.d.ts +127 -8
  13. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  14. package/dist/general/providers/aftermathApi.js +132 -12
  15. package/dist/general/types/castingTypes.d.ts +0 -7
  16. package/dist/general/types/castingTypes.d.ts.map +1 -1
  17. package/dist/general/types/castingTypes.js +6 -0
  18. package/dist/general/types/generalTypes.d.ts +228 -7
  19. package/dist/general/types/generalTypes.d.ts.map +1 -1
  20. package/dist/general/types/suiTypes.d.ts +0 -16
  21. package/dist/general/types/suiTypes.d.ts.map +1 -1
  22. package/dist/general/types/suiTypes.js +3 -25
  23. package/dist/general/utils/casting.d.ts +159 -3
  24. package/dist/general/utils/casting.d.ts.map +1 -1
  25. package/dist/general/utils/casting.js +162 -16
  26. package/dist/general/utils/fixedUtils.d.ts +89 -2
  27. package/dist/general/utils/fixedUtils.d.ts.map +1 -1
  28. package/dist/general/utils/fixedUtils.js +81 -4
  29. package/dist/general/utils/helpers.d.ts +320 -9
  30. package/dist/general/utils/helpers.d.ts.map +1 -1
  31. package/dist/general/utils/helpers.js +350 -89
  32. package/dist/general/utils/iFixedUtils.d.ts +64 -0
  33. package/dist/general/utils/iFixedUtils.d.ts.map +1 -1
  34. package/dist/general/utils/iFixedUtils.js +64 -0
  35. package/dist/general/wallet/wallet.d.ts +75 -0
  36. package/dist/general/wallet/wallet.d.ts.map +1 -1
  37. package/dist/general/wallet/wallet.js +75 -5
  38. package/dist/packages/auth/auth.d.ts +113 -0
  39. package/dist/packages/auth/auth.d.ts.map +1 -1
  40. package/dist/packages/auth/auth.js +129 -15
  41. package/dist/packages/auth/authTypes.d.ts +66 -0
  42. package/dist/packages/auth/authTypes.d.ts.map +1 -1
  43. package/dist/packages/coin/coin.d.ts +250 -0
  44. package/dist/packages/coin/coin.d.ts.map +1 -1
  45. package/dist/packages/coin/coin.js +238 -14
  46. package/dist/packages/coin/coinTypes.d.ts +93 -0
  47. package/dist/packages/coin/coinTypes.d.ts.map +1 -1
  48. package/dist/packages/dca/dca.d.ts +124 -35
  49. package/dist/packages/dca/dca.d.ts.map +1 -1
  50. package/dist/packages/dca/dca.js +127 -37
  51. package/dist/packages/dca/dcaTypes.d.ts +213 -28
  52. package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
  53. package/dist/packages/farms/farms.d.ts +184 -1
  54. package/dist/packages/farms/farms.d.ts.map +1 -1
  55. package/dist/packages/farms/farms.js +185 -11
  56. package/dist/packages/farms/farmsStakedPosition.d.ts +140 -6
  57. package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
  58. package/dist/packages/farms/farmsStakedPosition.js +189 -144
  59. package/dist/packages/farms/farmsStakingPool.d.ts +161 -1
  60. package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
  61. package/dist/packages/farms/farmsStakingPool.js +176 -70
  62. package/dist/packages/farms/farmsTypes.d.ts +283 -2
  63. package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
  64. package/dist/packages/farms/farmsTypes.js +18 -0
  65. package/dist/packages/limitOrders/limitOrders.d.ts +108 -21
  66. package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -1
  67. package/dist/packages/limitOrders/limitOrders.js +110 -22
  68. package/dist/packages/limitOrders/limitOrdersTypes.d.ts +142 -0
  69. package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -1
  70. package/dist/packages/multisig/multisig.d.ts +33 -4
  71. package/dist/packages/multisig/multisig.d.ts.map +1 -1
  72. package/dist/packages/multisig/multisig.js +33 -4
  73. package/dist/packages/multisig/multisigTypes.d.ts +17 -0
  74. package/dist/packages/multisig/multisigTypes.d.ts.map +1 -1
  75. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
  76. package/dist/packages/pools/pool.d.ts +327 -85
  77. package/dist/packages/pools/pool.d.ts.map +1 -1
  78. package/dist/packages/pools/pool.js +333 -91
  79. package/dist/packages/pools/pools.d.ts +299 -37
  80. package/dist/packages/pools/pools.d.ts.map +1 -1
  81. package/dist/packages/pools/pools.js +306 -52
  82. package/dist/packages/pools/poolsTypes.d.ts +267 -2
  83. package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
  84. package/dist/packages/referralVault/referralVault.d.ts +37 -0
  85. package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
  86. package/dist/packages/referralVault/referralVault.js +37 -0
  87. package/dist/packages/router/router.d.ts +213 -17
  88. package/dist/packages/router/router.d.ts.map +1 -1
  89. package/dist/packages/router/router.js +214 -18
  90. package/dist/packages/router/routerTypes.d.ts +198 -14
  91. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  92. package/dist/packages/staking/staking.d.ts +301 -43
  93. package/dist/packages/staking/staking.d.ts.map +1 -1
  94. package/dist/packages/staking/staking.js +308 -51
  95. package/dist/packages/staking/stakingTypes.d.ts +426 -6
  96. package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
  97. package/dist/packages/staking/stakingTypes.js +19 -0
  98. package/dist/packages/sui/sui.d.ts +39 -0
  99. package/dist/packages/sui/sui.d.ts.map +1 -1
  100. package/dist/packages/sui/sui.js +39 -0
  101. package/dist/packages/userData/userData.d.ts +66 -12
  102. package/dist/packages/userData/userData.d.ts.map +1 -1
  103. package/dist/packages/userData/userData.js +66 -12
  104. package/dist/packages/userData/userDataTypes.d.ts +19 -0
  105. package/dist/packages/userData/userDataTypes.d.ts.map +1 -1
  106. package/dist/types.d.ts.map +1 -1
  107. package/dist/types.js +0 -1
  108. package/package.json +1 -1
  109. package/dist/general/historicalData/historicalData.d.ts +0 -15
  110. package/dist/general/historicalData/historicalData.d.ts.map +0 -1
  111. package/dist/general/historicalData/historicalData.js +0 -45
  112. package/dist/general/historicalData/historicalDataTypes.d.ts +0 -10
  113. package/dist/general/historicalData/historicalDataTypes.d.ts.map +0 -1
  114. package/dist/general/historicalData/historicalDataTypes.js +0 -2
@@ -1,23 +1,100 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FixedUtils = void 0;
4
+ /**
5
+ * The `FixedUtils` class provides utilities for fixed-point arithmetic
6
+ * with a standard 18-decimal precision, along with some convenience
7
+ * methods for normalizing/un-normalizing amounts based on token decimals.
8
+ */
4
9
  class FixedUtils {
5
10
  }
6
11
  exports.FixedUtils = FixedUtils;
7
- // 18 decimal places
12
+ /**
13
+ * Represents 1.0 in 18-decimal fixed math as a float: 1_000_000_000_000_000_000.
14
+ */
8
15
  FixedUtils.fixedOneN = 1000000000000000000;
16
+ /**
17
+ * Represents 1.0 in 18-decimal fixed math as a bigint: 1000000000000000000n.
18
+ */
9
19
  FixedUtils.fixedOneB = BigInt("1000000000000000000");
10
- // 9 decimal places
20
+ /**
21
+ * Represents 1.0 in 9-decimal fixed math as a float: 1_000_000_000.
22
+ */
11
23
  FixedUtils.fixedOneN9 = 1000000000;
24
+ /**
25
+ * Represents 1.0 in 9-decimal fixed math as a bigint: 1000000000n.
26
+ */
12
27
  FixedUtils.fixedOneB9 = BigInt(1000000000);
13
- // These terms come from their on chain counterparts. They are backwards from the point of view of js.
14
- // On chain direct cast means e.g. taking ((x: u64) as u256).
28
+ // These methods relate to direct cast/un-cast logic for on-chain usage:
29
+ /**
30
+ * Directly convert an on-chain `u64` (stored as a bigint) into a float, effectively no scaling.
31
+ *
32
+ * @param n - The on-chain number as a bigint.
33
+ * @returns The converted number as a float.
34
+ */
15
35
  FixedUtils.convertFromInt = (n) => Number(n);
36
+ /**
37
+ * Convert a floating number back to an on-chain integer (bigint),
38
+ * truncating decimals.
39
+ *
40
+ * @param n - The local float.
41
+ * @returns The truncated bigint.
42
+ */
16
43
  FixedUtils.convertToInt = (n) => BigInt(Math.floor(n));
44
+ /**
45
+ * Converts a fixed-18 on-chain number to a floating local number by dividing by `fixedOneN`.
46
+ *
47
+ * @param n - The on-chain 18-decimal fixed number (as a bigint).
48
+ * @returns A float representing the unscaled value.
49
+ */
17
50
  FixedUtils.directCast = (n) => Number(n) / FixedUtils.fixedOneN;
51
+ /**
52
+ * Converts a floating local number to an on-chain 18-decimal fixed bigint by multiplying by `fixedOneN`.
53
+ *
54
+ * @param n - The local float to be scaled.
55
+ * @returns The scaled 18-decimal fixed as a bigint.
56
+ */
18
57
  FixedUtils.directUncast = (n) => BigInt(Math.floor(n * FixedUtils.fixedOneN));
58
+ /**
59
+ * Returns the complement of the number in `[0,1]`, i.e., `1 - n`.
60
+ * If `n` is negative, it's treated as zero; if `n` > 1, also treated as zero for the complement.
61
+ *
62
+ * @param n - The local float in [0,1].
63
+ * @returns The complement of `n` in [0,1].
64
+ */
19
65
  FixedUtils.complement = (n) => Math.max(0, 1 - Math.max(0, n));
66
+ /**
67
+ * Multiplies a raw integer `amount` by a `decimalsScalar` to produce
68
+ * a "normalized" form. E.g., if decimals = 9, we store it as 10^9 scale.
69
+ *
70
+ * @param decimalsScalar - The scale factor for the coin (e.g., 1e9).
71
+ * @param amount - The raw integer (balance) to be scaled.
72
+ * @returns The scaled (normalized) amount as a `number`.
73
+ */
20
74
  FixedUtils.normalizeAmount = (decimalsScalar, amount) => amount * decimalsScalar;
75
+ /**
76
+ * Divides a normalized amount by the `decimalsScalar` to get back the
77
+ * raw on-chain integer. This is typically used after floating computations.
78
+ *
79
+ * @param decimalsScalar - The scale factor for the coin (e.g., 1e9).
80
+ * @param normalizedAmount - The scaled amount to reduce.
81
+ * @returns The raw integer balance.
82
+ */
21
83
  FixedUtils.unnormalizeAmount = (decimalsScalar, normalizedAmount) => normalizedAmount / decimalsScalar;
84
+ /**
85
+ * Directly cast a `Balance` to an 18-decimal float, factoring in token decimals.
86
+ *
87
+ * @param decimalsScalar - The token's decimal scale factor.
88
+ * @param amount - The raw integer `Balance`.
89
+ * @returns A float representing the 18-decimal scale cast.
90
+ */
22
91
  FixedUtils.castAndNormalize = (decimalsScalar, amount) => FixedUtils.directCast(FixedUtils.normalizeAmount(decimalsScalar, amount));
92
+ /**
93
+ * Reverse the cast of a normalized float back to a raw `Balance`,
94
+ * factoring in the token decimals.
95
+ *
96
+ * @param decimalsScalar - The token's decimal scale factor.
97
+ * @param normalizedAmount - A local float in 18-decimal domain.
98
+ * @returns A raw integer `Balance`.
99
+ */
23
100
  FixedUtils.uncastAndUnnormalize = (decimalsScalar, normalizedAmount) => FixedUtils.unnormalizeAmount(decimalsScalar, FixedUtils.directUncast(normalizedAmount));
@@ -9,72 +9,366 @@ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions
9
9
  import { MoveErrors } from "../types/moveErrorsInterface";
10
10
  import { Keypair } from "@mysten/sui/cryptography";
11
11
  /**
12
- * A utility class containing various helper functions for general use.
12
+ * A utility class containing various helper functions for general use across
13
+ * the Aftermath TS ecosystem. This includes numeric operations, object field
14
+ * extraction, array transformations, slippage adjustments, and Move error parsing.
13
15
  */
14
16
  export declare class Helpers {
17
+ /**
18
+ * Static reference to the `DynamicFieldsApiHelpers`, providing utility methods
19
+ * for working with dynamic fields in Sui objects.
20
+ */
15
21
  static readonly dynamicFields: typeof DynamicFieldsApiHelpers;
22
+ /**
23
+ * Static reference to the `EventsApiHelpers`, providing methods for
24
+ * querying and filtering Sui events.
25
+ */
16
26
  static readonly events: typeof EventsApiHelpers;
27
+ /**
28
+ * Static reference to the `InspectionsApiHelpers`, used for reading
29
+ * Summaries or inspection data from objects.
30
+ */
17
31
  static readonly inspections: typeof InspectionsApiHelpers;
32
+ /**
33
+ * Static reference to the `ObjectsApiHelpers`, providing direct
34
+ * retrieval or manipulation of on-chain Sui objects.
35
+ */
18
36
  static readonly objects: typeof ObjectsApiHelpers;
37
+ /**
38
+ * Static reference to the `TransactionsApiHelpers`, enabling easier
39
+ * queries for transaction data by digest or other criteria.
40
+ */
19
41
  static readonly transactions: typeof TransactionsApiHelpers;
20
42
  /**
21
- * Removes leading zeroes from the hexadecimal representation of a given object type.
22
- * @param type - The object type to strip leading zeroes from.
23
- * @returns The object type with leading zeroes removed from its hexadecimal representation.
43
+ * Removes all leading zeroes (after the '0x') from a string that represents
44
+ * a Sui address or object type. For instance, "0x0000123" => "0x123".
45
+ *
46
+ * @param type - The hex string to process, potentially including "::" module syntax.
47
+ * @returns The same string with unnecessary leading zeroes stripped out.
24
48
  */
25
49
  static stripLeadingZeroesFromType: (type: AnyObjectType) => AnyObjectType;
26
50
  /**
27
- * Adds leading zeroes to a given `AnyObjectType` until it reaches a length of 64 characters.
28
- * If the input type already has a length greater than 64, an error is thrown.
29
- * @param type - The `AnyObjectType` to add leading zeroes to.
30
- * @returns The modified `AnyObjectType` with leading zeroes added.
31
- * @throws An error if the input type has a length greater than 64.
51
+ * Ensures the given Sui address or object type is zero-padded to 64 hex digits
52
+ * after the "0x". If a "::" suffix is present, only the address portion is padded.
53
+ *
54
+ * @param type - The "0x..." string or extended type (0x..::module).
55
+ * @returns A new string normalized to a 64-hex-digit address or object ID.
56
+ * @throws If the address portion is already longer than 64 hex digits.
32
57
  */
33
58
  static addLeadingZeroesToType: (type: AnyObjectType) => AnyObjectType;
59
+ /**
60
+ * Splits a non-SUI coin type string that may be prefixed by a chain ID for external usage,
61
+ * returning the chain and the coin type. If no chain is recognized, defaults to `"sui"`.
62
+ *
63
+ * @param coin - The coin string, which may look like `"bsc:0x<...>"` or just `"0x<...>"`.
64
+ * @returns An object with the `chain` (e.g. "bsc") and the `coinType`.
65
+ */
34
66
  static splitNonSuiCoinType: (coin: CoinType) => {
35
67
  chain: CoinGeckoChain;
36
68
  coinType: CoinType;
37
69
  };
70
+ /**
71
+ * Checks if a given string represents a valid number (integer or decimal).
72
+ *
73
+ * @param str - The string to test.
74
+ * @returns `true` if it's a valid numeric string, otherwise `false`.
75
+ */
38
76
  static isNumber: (str: string) => boolean;
77
+ /**
78
+ * Sums an array of floating-point numbers, returning the numeric total.
79
+ *
80
+ * @param arr - The array of numbers to sum.
81
+ * @returns The total as a float.
82
+ */
39
83
  static sum: (arr: number[]) => number;
84
+ /**
85
+ * Sums an array of bigints, returning the total as a bigint.
86
+ *
87
+ * @param arr - The array of bigints to sum.
88
+ * @returns The resulting total as a bigint.
89
+ */
40
90
  static sumBigInt: (arr: bigint[]) => bigint;
91
+ /**
92
+ * Determines if two numbers are close within a given tolerance factor,
93
+ * i.e., `|a - b| <= tolerance * max(a, b)`.
94
+ *
95
+ * @param a - The first number.
96
+ * @param b - The second number.
97
+ * @param tolerance - A fraction representing the max allowed difference relative to max(a, b).
98
+ * @returns `true` if within tolerance, otherwise `false`.
99
+ */
41
100
  static closeEnough: (a: number, b: number, tolerance: number) => boolean;
101
+ /**
102
+ * Determines if two bigints are close within a given tolerance factor,
103
+ * by casting them to numbers internally.
104
+ *
105
+ * @param a - First bigint.
106
+ * @param b - Second bigint.
107
+ * @param tolerance - A fraction representing the max allowed difference relative to max(a, b).
108
+ * @returns `true` if within tolerance, otherwise `false`.
109
+ */
42
110
  static closeEnoughBigInt: (a: bigint, b: bigint, tolerance: number) => boolean;
111
+ /**
112
+ * Checks whether the integer divisions of `a` and `b` (by `fixedOne`) differ
113
+ * by at most 1. Typically used in fixed math scenarios to see if two scaled
114
+ * values are "very close."
115
+ *
116
+ * @param a - First number (scaled).
117
+ * @param b - Second number (scaled).
118
+ * @param fixedOne - The scaling factor representing 1.0 in the same scale as `a` and `b`.
119
+ * @returns `true` if the integer parts differ by <= 1, otherwise `false`.
120
+ */
43
121
  static veryCloseInt: (a: number, b: number, fixedOne: number) => boolean;
122
+ /**
123
+ * A small object containing "blended" math operations that handle
124
+ * mixed numeric types (number vs. bigint). This is primarily for
125
+ * internal usage in advanced math scenarios.
126
+ */
44
127
  static blendedOperations: {
128
+ /**
129
+ * Multiply two floating-point numbers.
130
+ */
45
131
  mulNNN: (a: number, b: number) => number;
132
+ /**
133
+ * Multiply a float and a bigint, returning a bigint (floor).
134
+ */
46
135
  mulNNB: (a: number, b: number) => bigint;
136
+ /**
137
+ * Multiply a float and a bigint, returning a float.
138
+ */
47
139
  mulNBN: (a: number, b: bigint) => number;
140
+ /**
141
+ * Multiply a float and a bigint, returning a bigint (floor).
142
+ */
48
143
  mulNBB: (a: number, b: bigint) => bigint;
144
+ /**
145
+ * Multiply two bigints, returning a float.
146
+ */
49
147
  mulBBN: (a: bigint, b: bigint) => number;
148
+ /**
149
+ * Multiply two bigints, returning a bigint.
150
+ */
50
151
  mulBBB: (a: bigint, b: bigint) => bigint;
51
152
  };
153
+ /**
154
+ * Returns the maximum of multiple bigints.
155
+ *
156
+ * @param args - The bigints to compare.
157
+ * @returns The largest bigint.
158
+ */
52
159
  static maxBigInt: (...args: bigint[]) => bigint;
160
+ /**
161
+ * Returns the minimum of multiple bigints.
162
+ *
163
+ * @param args - The bigints to compare.
164
+ * @returns The smallest bigint.
165
+ */
53
166
  static minBigInt: (...args: bigint[]) => bigint;
167
+ /**
168
+ * Returns the absolute value of a bigint.
169
+ *
170
+ * @param num - The input bigint.
171
+ * @returns A bigint representing the absolute value of `num`.
172
+ */
54
173
  static absBigInt: (num: bigint) => bigint;
174
+ /**
175
+ * Capitalizes only the first letter of a string, making the rest lowercase.
176
+ * E.g., "HELLO" => "Hello".
177
+ *
178
+ * @param str - The input string to transform.
179
+ * @returns The resulting string with the first character in uppercase and the rest in lowercase.
180
+ */
55
181
  static capitalizeOnlyFirstLetter: (str: string) => string;
182
+ /**
183
+ * Parses a JSON string containing potential BigInt values.
184
+ * By default, it only converts strings ending in 'n' (like `"123n"`) to BigInts.
185
+ *
186
+ * @param json - The JSON string to parse.
187
+ * @param unsafeStringNumberConversion - If `true`, all numeric strings (e.g., "123") will also become BigInts.
188
+ * @returns The parsed JSON object with BigInt conversions where applicable.
189
+ */
56
190
  static parseJsonWithBigint: (json: string, unsafeStringNumberConversion?: boolean) => any;
191
+ /**
192
+ * Creates a deep copy of the given target, handling nested arrays and objects.
193
+ * Dates are cloned by their timestamp.
194
+ *
195
+ * @param target - The data to clone deeply.
196
+ * @returns A new object/array/date structure mirroring `target`.
197
+ */
57
198
  static deepCopy: <T>(target: T) => T;
199
+ /**
200
+ * Finds the index of the maximum value in an array. Returns -1 if the array is empty.
201
+ *
202
+ * @param arr - The input array.
203
+ * @returns The index of the maximum value, or -1 if the array is empty.
204
+ */
58
205
  static indexOfMax: (arr: any[]) => number;
206
+ /**
207
+ * Returns a new array with unique elements from the input array,
208
+ * preserving the order of first occurrences.
209
+ *
210
+ * @param arr - The original array.
211
+ * @returns An array of unique items.
212
+ */
59
213
  static uniqueArray: <T>(arr: T[]) => T[];
214
+ /**
215
+ * Returns a Promise that resolves after a specified number of milliseconds.
216
+ *
217
+ * @param ms - The delay time in milliseconds.
218
+ * @returns A promise that resolves after `ms` milliseconds.
219
+ */
60
220
  static sleep: (ms: number) => Promise<unknown>;
221
+ /**
222
+ * Creates a unique ID-like string by combining the current timestamp and random base36 digits.
223
+ *
224
+ * @returns A short random string (base36) that can serve as a unique identifier.
225
+ */
61
226
  static createUid: () => string;
227
+ /**
228
+ * Splits an array into two groups: those for which `func` returns `true` (or truthy),
229
+ * and those for which it returns `false`. The result is returned as a tuple `[trues, falses]`.
230
+ *
231
+ * @param array - The array to filter.
232
+ * @param func - The function used to test each element.
233
+ * @returns A tuple containing two arrays: `[elements that pass, elements that fail]`.
234
+ */
62
235
  static bifilter: <ArrayType>(array: ArrayType[], func: (item: ArrayType, index: number, arr: ArrayType[]) => boolean) => [trues: ArrayType[], falses: ArrayType[]];
236
+ /**
237
+ * An async version of `bifilter`, returning a tuple of `[trues, falses]`.
238
+ * Each element is tested asynchronously in parallel via `func`.
239
+ *
240
+ * @param array - The array to filter.
241
+ * @param func - An async function returning `true` or `false`.
242
+ * @returns A tuple `[trues, falses]` after asynchronous evaluation.
243
+ */
63
244
  static bifilterAsync: <ArrayType>(array: ArrayType[], func: (item: ArrayType, index: number, arr: ArrayType[]) => Promise<boolean>) => Promise<[trues: ArrayType[], falses: ArrayType[]]>;
245
+ /**
246
+ * Filters the entries of an object based on a predicate function,
247
+ * returning a new object with only those entries for which `predicate`
248
+ * returns `true`.
249
+ *
250
+ * @param obj - The original object to filter.
251
+ * @param predicate - A function taking `(key, value)` and returning a boolean.
252
+ * @returns A new object with only the entries that pass the predicate.
253
+ */
64
254
  static filterObject: <Value>(obj: Record<string, Value>, predicate: (key: string, value: Value) => boolean) => Record<string, Value>;
255
+ /**
256
+ * Applies downward slippage to a bigint amount by subtracting `slippage * amount`.
257
+ * For instance, for 1% slippage, we reduce the amount by 1%.
258
+ *
259
+ * @param amount - The original bigint amount.
260
+ * @param slippage - An integer percent (e.g., 1 => 1%).
261
+ * @returns The adjusted bigint after subtracting the slippage portion.
262
+ */
65
263
  static applySlippageBigInt: (amount: Balance, slippage: Slippage) => bigint;
264
+ /**
265
+ * Applies downward slippage to a floating-point amount. E.g., for 1% slippage,
266
+ * reduce by 1% of `amount`.
267
+ *
268
+ * @param amount - The original float value.
269
+ * @param slippage - An integer percent (e.g., 1 => 1%).
270
+ * @returns The float after applying slippage.
271
+ */
66
272
  static applySlippage: (amount: number, slippage: Slippage) => number;
273
+ /**
274
+ * Combines two arrays into a single array of pairs. The result length is the
275
+ * minimum of the two input arrays' lengths.
276
+ *
277
+ * @param firstCollection - The first array.
278
+ * @param lastCollection - The second array.
279
+ * @returns An array of `[firstCollection[i], lastCollection[i]]` pairs.
280
+ */
67
281
  static zip<S1, S2>(firstCollection: Array<S1>, lastCollection: Array<S2>): Array<[S1, S2]>;
282
+ /**
283
+ * Removes circular references from an object or array, returning a JSON-safe structure.
284
+ * Any cyclic references are replaced with `undefined`.
285
+ *
286
+ * @param obj - The object or array to remove circular references from.
287
+ * @param seen - Internal usage to track references that have already been visited.
288
+ * @returns A structure that can be safely JSON-stringified.
289
+ */
68
290
  static removeCircularReferences<T>(obj: T, seen?: WeakSet<object>): T | undefined;
291
+ /**
292
+ * Checks if an unknown value is an array of strings.
293
+ *
294
+ * @param value - The value to check.
295
+ * @returns `true` if `value` is a string array, otherwise `false`.
296
+ */
69
297
  static isArrayOfStrings(value: unknown): value is string[];
298
+ /**
299
+ * Roughly checks if a string is a valid Sui type (e.g., "0x2::sui::SUI").
300
+ * This is not guaranteed to be perfect, but covers common cases.
301
+ *
302
+ * @param str - The string to validate.
303
+ * @returns `true` if it meets the minimum structure, otherwise `false`.
304
+ */
70
305
  static isValidType: (str: string) => boolean;
306
+ /**
307
+ * Checks if a string is a valid hex representation, optionally prefixed with "0x".
308
+ *
309
+ * @param hexString - The string to check.
310
+ * @returns `true` if `hexString` is a valid hex, otherwise `false`.
311
+ */
71
312
  static isValidHex: (hexString: string) => boolean;
313
+ /**
314
+ * Extracts the fully qualified type (e.g., "0x2::coin::Coin<...>") from a `SuiObjectResponse`,
315
+ * normalizing it with leading zeroes if necessary.
316
+ *
317
+ * @param data - The object response from Sui.
318
+ * @returns The normalized object type string.
319
+ * @throws If the type is not found.
320
+ */
72
321
  static getObjectType(data: SuiObjectResponse): ObjectId;
322
+ /**
323
+ * Extracts the object ID from a `SuiObjectResponse`, normalizing it with leading zeroes.
324
+ *
325
+ * @param data - The object response from Sui.
326
+ * @returns A zero-padded `ObjectId`.
327
+ * @throws If the objectId is not found.
328
+ */
73
329
  static getObjectId(data: SuiObjectResponse): ObjectId;
330
+ /**
331
+ * Retrieves the fields of a Move object from a `SuiObjectResponse`.
332
+ *
333
+ * @param data - The Sui object response containing a Move object.
334
+ * @returns A record of fields for that object.
335
+ * @throws If no fields are found.
336
+ */
74
337
  static getObjectFields(data: SuiObjectResponse): Record<string, any>;
338
+ /**
339
+ * Retrieves display metadata from a Sui object response, if present.
340
+ *
341
+ * @param data - The Sui object response.
342
+ * @returns The display fields for that object.
343
+ * @throws If display fields are not found.
344
+ */
75
345
  static getObjectDisplay(data: SuiObjectResponse): DisplayFieldsResponse;
346
+ /**
347
+ * Utility for building transaction commands with either a string-based
348
+ * `ObjectId` or an existing transaction object argument. If it's a string,
349
+ * it's converted via `tx.object(...)`; if already a `TransactionObjectArgument`,
350
+ * it's returned as-is.
351
+ *
352
+ * @param tx - The current `Transaction` block to add the object to.
353
+ * @param object - Either an `ObjectId` or a `TransactionObjectArgument`.
354
+ * @returns A `TransactionObjectArgument` referencing the provided object.
355
+ */
76
356
  static addTxObject: (tx: Transaction, object: ObjectId | TransactionObjectArgument) => TransactionObjectArgument;
357
+ /**
358
+ * Checks if a given string is a valid Sui address by normalizing it to a
359
+ * 64-hex-digit form and calling `isValidSuiAddress`.
360
+ *
361
+ * @param address - The Sui address to validate.
362
+ * @returns `true` if valid, `false` otherwise.
363
+ */
77
364
  static isValidSuiAddress: (address: SuiAddress) => boolean;
365
+ /**
366
+ * Parses a MoveAbort error message from Sui into a possible `(errorCode, packageId, module)`,
367
+ * if the message follows a known pattern. Otherwise returns undefined.
368
+ *
369
+ * @param inputs - The object containing the raw `errorMessage` from Sui.
370
+ * @returns A partial structure of the error details or undefined.
371
+ */
78
372
  static parseMoveErrorMessage(inputs: {
79
373
  errorMessage: string;
80
374
  }): {
@@ -82,6 +376,14 @@ export declare class Helpers {
82
376
  packageId: ObjectId;
83
377
  module: ModuleName;
84
378
  } | undefined;
379
+ /**
380
+ * Translates a Move abort error message into a known error string if it matches
381
+ * entries in a given `moveErrors` table. This is used to map on-chain error codes
382
+ * to user-friendly messages.
383
+ *
384
+ * @param inputs - Includes the raw `errorMessage` and a `moveErrors` object keyed by package, module, and code.
385
+ * @returns A structure with `errorCode`, `packageId`, `module`, and a human-readable `error` string, or `undefined`.
386
+ */
85
387
  static translateMoveErrorMessage(inputs: {
86
388
  errorMessage: string;
87
389
  moveErrors: MoveErrors;
@@ -91,6 +393,15 @@ export declare class Helpers {
91
393
  module: ModuleName;
92
394
  error: string;
93
395
  } | undefined;
396
+ /**
397
+ * Constructs a `Keypair` instance from a private key string. The `privateKey`
398
+ * may indicate the signing scheme (ED25519, Secp256k1, or Secp256r1) via prefix,
399
+ * as recognized by `decodeSuiPrivateKey`.
400
+ *
401
+ * @param privateKey - The full private key string (e.g., "0x<64_hex_chars>").
402
+ * @returns A new `Keypair` instance for signing transactions.
403
+ * @throws If the schema is unsupported.
404
+ */
94
405
  static keypairFromPrivateKey: (privateKey: string) => Keypair;
95
406
  }
96
407
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/general/utils/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EAErB,iBAAiB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,aAAa,EACb,OAAO,EAIP,QAAQ,EACR,QAAQ,EACR,UAAU,EAEV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,cAAc,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E,OAAO,EACN,WAAW,EACX,yBAAyB,EACzB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,OAAO,EAAuB,OAAO,EAAE,MAAM,0BAA0B,CAA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