aftermath-ts-sdk 1.3.28 → 2.0.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 (410) hide show
  1. package/dist/index.d.ts +16828 -5
  2. package/dist/index.js +22695 -19
  3. package/dist/index.js.map +1 -0
  4. package/package.json +69 -60
  5. package/dist/general/apiHelpers/dynamicFieldsApiHelpers.d.ts +0 -41
  6. package/dist/general/apiHelpers/dynamicFieldsApiHelpers.d.ts.map +0 -1
  7. package/dist/general/apiHelpers/dynamicFieldsApiHelpers.js +0 -110
  8. package/dist/general/apiHelpers/eventsApiHelpers.d.ts +0 -43
  9. package/dist/general/apiHelpers/eventsApiHelpers.d.ts.map +0 -1
  10. package/dist/general/apiHelpers/eventsApiHelpers.js +0 -170
  11. package/dist/general/apiHelpers/inspectionsApiHelpers.d.ts +0 -28
  12. package/dist/general/apiHelpers/inspectionsApiHelpers.d.ts.map +0 -1
  13. package/dist/general/apiHelpers/inspectionsApiHelpers.js +0 -58
  14. package/dist/general/apiHelpers/objectsApiHelpers.d.ts +0 -77
  15. package/dist/general/apiHelpers/objectsApiHelpers.d.ts.map +0 -1
  16. package/dist/general/apiHelpers/objectsApiHelpers.js +0 -197
  17. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts +0 -50
  18. package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +0 -1
  19. package/dist/general/apiHelpers/transactionsApiHelpers.js +0 -256
  20. package/dist/general/dynamicGas/dynamicGas.d.ts +0 -48
  21. package/dist/general/dynamicGas/dynamicGas.d.ts.map +0 -1
  22. package/dist/general/dynamicGas/dynamicGas.js +0 -69
  23. package/dist/general/dynamicGas/dynamicGasTypes.d.ts +0 -37
  24. package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +0 -1
  25. package/dist/general/dynamicGas/dynamicGasTypes.js +0 -2
  26. package/dist/general/nfts/nftsApi.d.ts +0 -35
  27. package/dist/general/nfts/nftsApi.d.ts.map +0 -1
  28. package/dist/general/nfts/nftsApi.js +0 -124
  29. package/dist/general/nfts/nftsApiCasting.d.ts +0 -11
  30. package/dist/general/nfts/nftsApiCasting.d.ts.map +0 -1
  31. package/dist/general/nfts/nftsApiCasting.js +0 -115
  32. package/dist/general/nfts/nftsTypes.d.ts +0 -31
  33. package/dist/general/nfts/nftsTypes.d.ts.map +0 -1
  34. package/dist/general/nfts/nftsTypes.js +0 -2
  35. package/dist/general/priceFeeds/priceFeeds.d.ts +0 -3
  36. package/dist/general/priceFeeds/priceFeeds.d.ts.map +0 -1
  37. package/dist/general/priceFeeds/priceFeeds.js +0 -26
  38. package/dist/general/priceFeeds/priceFeedsApi.d.ts +0 -3
  39. package/dist/general/priceFeeds/priceFeedsApi.d.ts.map +0 -1
  40. package/dist/general/priceFeeds/priceFeedsApi.js +0 -33
  41. package/dist/general/priceFeeds/priceFeedsTypes.d.ts +0 -3
  42. package/dist/general/priceFeeds/priceFeedsTypes.d.ts.map +0 -1
  43. package/dist/general/priceFeeds/priceFeedsTypes.js +0 -7
  44. package/dist/general/prices/coinGeckoTypes.d.ts +0 -16
  45. package/dist/general/prices/coinGeckoTypes.d.ts.map +0 -1
  46. package/dist/general/prices/coinGeckoTypes.js +0 -2
  47. package/dist/general/prices/prices.d.ts +0 -92
  48. package/dist/general/prices/prices.d.ts.map +0 -1
  49. package/dist/general/prices/prices.js +0 -124
  50. package/dist/general/providers/aftermath.d.ts +0 -200
  51. package/dist/general/providers/aftermath.d.ts.map +0 -1
  52. package/dist/general/providers/aftermath.js +0 -258
  53. package/dist/general/providers/aftermathApi.d.ts +0 -197
  54. package/dist/general/providers/aftermathApi.d.ts.map +0 -1
  55. package/dist/general/providers/aftermathApi.js +0 -255
  56. package/dist/general/providers/index.d.ts +0 -3
  57. package/dist/general/providers/index.d.ts.map +0 -1
  58. package/dist/general/providers/index.js +0 -18
  59. package/dist/general/types/castingTypes.d.ts +0 -51
  60. package/dist/general/types/castingTypes.d.ts.map +0 -1
  61. package/dist/general/types/castingTypes.js +0 -8
  62. package/dist/general/types/configTypes.d.ts +0 -187
  63. package/dist/general/types/configTypes.d.ts.map +0 -1
  64. package/dist/general/types/configTypes.js +0 -2
  65. package/dist/general/types/generalTypes.d.ts +0 -349
  66. package/dist/general/types/generalTypes.d.ts.map +0 -1
  67. package/dist/general/types/generalTypes.js +0 -2
  68. package/dist/general/types/index.d.ts +0 -7
  69. package/dist/general/types/index.d.ts.map +0 -1
  70. package/dist/general/types/index.js +0 -22
  71. package/dist/general/types/moveErrorsInterface.d.ts +0 -6
  72. package/dist/general/types/moveErrorsInterface.d.ts.map +0 -1
  73. package/dist/general/types/moveErrorsInterface.js +0 -2
  74. package/dist/general/types/suiTypes.d.ts +0 -2
  75. package/dist/general/types/suiTypes.d.ts.map +0 -1
  76. package/dist/general/types/suiTypes.js +0 -5
  77. package/dist/general/utils/caller.d.ts +0 -58
  78. package/dist/general/utils/caller.d.ts.map +0 -1
  79. package/dist/general/utils/caller.js +0 -231
  80. package/dist/general/utils/casting.d.ts +0 -212
  81. package/dist/general/utils/casting.d.ts.map +0 -1
  82. package/dist/general/utils/casting.js +0 -273
  83. package/dist/general/utils/fixedUtils.d.ts +0 -109
  84. package/dist/general/utils/fixedUtils.d.ts.map +0 -1
  85. package/dist/general/utils/fixedUtils.js +0 -100
  86. package/dist/general/utils/helpers.d.ts +0 -408
  87. package/dist/general/utils/helpers.d.ts.map +0 -1
  88. package/dist/general/utils/helpers.js +0 -725
  89. package/dist/general/utils/iFixedUtils.d.ts +0 -78
  90. package/dist/general/utils/iFixedUtils.d.ts.map +0 -1
  91. package/dist/general/utils/iFixedUtils.js +0 -109
  92. package/dist/general/utils/index.d.ts +0 -3
  93. package/dist/general/utils/index.d.ts.map +0 -1
  94. package/dist/general/utils/index.js +0 -18
  95. package/dist/general/wallet/wallet.d.ts +0 -89
  96. package/dist/general/wallet/wallet.d.ts.map +0 -1
  97. package/dist/general/wallet/wallet.js +0 -120
  98. package/dist/general/wallet/walletApi.d.ts +0 -20
  99. package/dist/general/wallet/walletApi.d.ts.map +0 -1
  100. package/dist/general/wallet/walletApi.js +0 -66
  101. package/dist/index.d.ts.map +0 -1
  102. package/dist/packages/auth/auth.d.ts +0 -135
  103. package/dist/packages/auth/auth.d.ts.map +0 -1
  104. package/dist/packages/auth/auth.js +0 -289
  105. package/dist/packages/auth/authTypes.d.ts +0 -102
  106. package/dist/packages/auth/authTypes.d.ts.map +0 -1
  107. package/dist/packages/auth/authTypes.js +0 -2
  108. package/dist/packages/auth/index.d.ts +0 -2
  109. package/dist/packages/auth/index.d.ts.map +0 -1
  110. package/dist/packages/auth/index.js +0 -17
  111. package/dist/packages/coin/api/coinApi.d.ts +0 -33
  112. package/dist/packages/coin/api/coinApi.d.ts.map +0 -1
  113. package/dist/packages/coin/api/coinApi.js +0 -167
  114. package/dist/packages/coin/coin.d.ts +0 -320
  115. package/dist/packages/coin/coin.d.ts.map +0 -1
  116. package/dist/packages/coin/coin.js +0 -467
  117. package/dist/packages/coin/coinTypes.d.ts +0 -139
  118. package/dist/packages/coin/coinTypes.d.ts.map +0 -1
  119. package/dist/packages/coin/coinTypes.js +0 -2
  120. package/dist/packages/coin/index.d.ts +0 -2
  121. package/dist/packages/coin/index.d.ts.map +0 -1
  122. package/dist/packages/coin/index.js +0 -17
  123. package/dist/packages/dca/api/dcaApi.d.ts +0 -26
  124. package/dist/packages/dca/api/dcaApi.d.ts.map +0 -1
  125. package/dist/packages/dca/api/dcaApi.js +0 -60
  126. package/dist/packages/dca/dca.d.ts +0 -174
  127. package/dist/packages/dca/dca.d.ts.map +0 -1
  128. package/dist/packages/dca/dca.js +0 -230
  129. package/dist/packages/dca/dcaTypes.d.ts +0 -319
  130. package/dist/packages/dca/dcaTypes.d.ts.map +0 -1
  131. package/dist/packages/dca/dcaTypes.js +0 -2
  132. package/dist/packages/dca/index.d.ts +0 -2
  133. package/dist/packages/dca/index.d.ts.map +0 -1
  134. package/dist/packages/dca/index.js +0 -17
  135. package/dist/packages/farms/api/farmsApi.d.ts +0 -996
  136. package/dist/packages/farms/api/farmsApi.d.ts.map +0 -1
  137. package/dist/packages/farms/api/farmsApi.js +0 -1826
  138. package/dist/packages/farms/api/farmsApiCasting.d.ts +0 -39
  139. package/dist/packages/farms/api/farmsApiCasting.d.ts.map +0 -1
  140. package/dist/packages/farms/api/farmsApiCasting.js +0 -427
  141. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts +0 -235
  142. package/dist/packages/farms/api/farmsApiCastingTypes.d.ts.map +0 -1
  143. package/dist/packages/farms/api/farmsApiCastingTypes.js +0 -2
  144. package/dist/packages/farms/farms.d.ts +0 -221
  145. package/dist/packages/farms/farms.d.ts.map +0 -1
  146. package/dist/packages/farms/farms.js +0 -302
  147. package/dist/packages/farms/farmsStakedPosition.d.ts +0 -229
  148. package/dist/packages/farms/farmsStakedPosition.d.ts.map +0 -1
  149. package/dist/packages/farms/farmsStakedPosition.js +0 -473
  150. package/dist/packages/farms/farmsStakingPool.d.ts +0 -285
  151. package/dist/packages/farms/farmsStakingPool.d.ts.map +0 -1
  152. package/dist/packages/farms/farmsStakingPool.js +0 -488
  153. package/dist/packages/farms/farmsTypes.d.ts +0 -571
  154. package/dist/packages/farms/farmsTypes.d.ts.map +0 -1
  155. package/dist/packages/farms/farmsTypes.js +0 -49
  156. package/dist/packages/farms/index.d.ts +0 -4
  157. package/dist/packages/farms/index.d.ts.map +0 -1
  158. package/dist/packages/farms/index.js +0 -19
  159. package/dist/packages/faucet/api/faucetApi.d.ts +0 -37
  160. package/dist/packages/faucet/api/faucetApi.d.ts.map +0 -1
  161. package/dist/packages/faucet/api/faucetApi.js +0 -145
  162. package/dist/packages/faucet/api/faucetApiCasting.d.ts +0 -7
  163. package/dist/packages/faucet/api/faucetApiCasting.d.ts.map +0 -1
  164. package/dist/packages/faucet/api/faucetApiCasting.js +0 -33
  165. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts +0 -10
  166. package/dist/packages/faucet/api/faucetApiCastingTypes.d.ts.map +0 -1
  167. package/dist/packages/faucet/api/faucetApiCastingTypes.js +0 -2
  168. package/dist/packages/faucet/faucet.d.ts +0 -16
  169. package/dist/packages/faucet/faucet.d.ts.map +0 -1
  170. package/dist/packages/faucet/faucet.js +0 -64
  171. package/dist/packages/faucet/faucetTypes.d.ts +0 -20
  172. package/dist/packages/faucet/faucetTypes.d.ts.map +0 -1
  173. package/dist/packages/faucet/faucetTypes.js +0 -2
  174. package/dist/packages/faucet/index.d.ts +0 -2
  175. package/dist/packages/faucet/index.d.ts.map +0 -1
  176. package/dist/packages/faucet/index.js +0 -17
  177. package/dist/packages/index.d.ts +0 -14
  178. package/dist/packages/index.d.ts.map +0 -1
  179. package/dist/packages/index.js +0 -29
  180. package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts +0 -202
  181. package/dist/packages/leveragedStaking/api/leveragedStakingApi.d.ts.map +0 -1
  182. package/dist/packages/leveragedStaking/api/leveragedStakingApi.js +0 -1104
  183. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.d.ts +0 -12
  184. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.d.ts.map +0 -1
  185. package/dist/packages/leveragedStaking/api/leveragedStakingApiCasting.js +0 -69
  186. package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.d.ts +0 -39
  187. package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.d.ts.map +0 -1
  188. package/dist/packages/leveragedStaking/api/leveragedStakingApiCastingTypes.js +0 -2
  189. package/dist/packages/leveragedStaking/index.d.ts +0 -2
  190. package/dist/packages/leveragedStaking/index.d.ts.map +0 -1
  191. package/dist/packages/leveragedStaking/index.js +0 -17
  192. package/dist/packages/leveragedStaking/leveragedStaking.d.ts +0 -68
  193. package/dist/packages/leveragedStaking/leveragedStaking.d.ts.map +0 -1
  194. package/dist/packages/leveragedStaking/leveragedStaking.js +0 -154
  195. package/dist/packages/leveragedStaking/leveragedStakingTypes.d.ts +0 -48
  196. package/dist/packages/leveragedStaking/leveragedStakingTypes.d.ts.map +0 -1
  197. package/dist/packages/leveragedStaking/leveragedStakingTypes.js +0 -16
  198. package/dist/packages/limitOrders/api/limitOrdersApi.d.ts +0 -12
  199. package/dist/packages/limitOrders/api/limitOrdersApi.d.ts.map +0 -1
  200. package/dist/packages/limitOrders/api/limitOrdersApi.js +0 -25
  201. package/dist/packages/limitOrders/index.d.ts +0 -2
  202. package/dist/packages/limitOrders/index.d.ts.map +0 -1
  203. package/dist/packages/limitOrders/index.js +0 -17
  204. package/dist/packages/limitOrders/limitOrders.d.ts +0 -143
  205. package/dist/packages/limitOrders/limitOrders.d.ts.map +0 -1
  206. package/dist/packages/limitOrders/limitOrders.js +0 -190
  207. package/dist/packages/limitOrders/limitOrdersTypes.d.ts +0 -211
  208. package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +0 -1
  209. package/dist/packages/limitOrders/limitOrdersTypes.js +0 -2
  210. package/dist/packages/multisig/api/multisigApi.d.ts +0 -10
  211. package/dist/packages/multisig/api/multisigApi.d.ts.map +0 -1
  212. package/dist/packages/multisig/api/multisigApi.js +0 -39
  213. package/dist/packages/multisig/index.d.ts +0 -2
  214. package/dist/packages/multisig/index.d.ts.map +0 -1
  215. package/dist/packages/multisig/index.js +0 -17
  216. package/dist/packages/multisig/multisig.d.ts +0 -46
  217. package/dist/packages/multisig/multisig.d.ts.map +0 -1
  218. package/dist/packages/multisig/multisig.js +0 -65
  219. package/dist/packages/multisig/multisigTypes.d.ts +0 -26
  220. package/dist/packages/multisig/multisigTypes.d.ts.map +0 -1
  221. package/dist/packages/multisig/multisigTypes.js +0 -2
  222. package/dist/packages/nftAmm/api/nftAmmApi.d.ts +0 -93
  223. package/dist/packages/nftAmm/api/nftAmmApi.d.ts.map +0 -1
  224. package/dist/packages/nftAmm/api/nftAmmApi.js +0 -250
  225. package/dist/packages/nftAmm/api/nftAmmApiCasting.d.ts +0 -6
  226. package/dist/packages/nftAmm/api/nftAmmApiCasting.d.ts.map +0 -1
  227. package/dist/packages/nftAmm/api/nftAmmApiCasting.js +0 -43
  228. package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.d.ts +0 -10
  229. package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.d.ts.map +0 -1
  230. package/dist/packages/nftAmm/api/nftAmmApiCastingTypes.js +0 -2
  231. package/dist/packages/nftAmm/index.d.ts +0 -2
  232. package/dist/packages/nftAmm/index.d.ts.map +0 -1
  233. package/dist/packages/nftAmm/index.js +0 -17
  234. package/dist/packages/nftAmm/nftAmm.d.ts +0 -18
  235. package/dist/packages/nftAmm/nftAmm.d.ts.map +0 -1
  236. package/dist/packages/nftAmm/nftAmm.js +0 -73
  237. package/dist/packages/nftAmm/nftAmmMarket.d.ts +0 -54
  238. package/dist/packages/nftAmm/nftAmmMarket.d.ts.map +0 -1
  239. package/dist/packages/nftAmm/nftAmmMarket.js +0 -154
  240. package/dist/packages/nftAmm/nftAmmTypes.d.ts +0 -51
  241. package/dist/packages/nftAmm/nftAmmTypes.d.ts.map +0 -1
  242. package/dist/packages/nftAmm/nftAmmTypes.js +0 -2
  243. package/dist/packages/perpetuals/api/perpetualsApi.d.ts +0 -44
  244. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +0 -1
  245. package/dist/packages/perpetuals/api/perpetualsApi.js +0 -1420
  246. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +0 -27
  247. package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +0 -1
  248. package/dist/packages/perpetuals/api/perpetualsApiCasting.js +0 -463
  249. package/dist/packages/perpetuals/index.d.ts +0 -5
  250. package/dist/packages/perpetuals/index.d.ts.map +0 -1
  251. package/dist/packages/perpetuals/index.js +0 -20
  252. package/dist/packages/perpetuals/perpetuals.d.ts +0 -860
  253. package/dist/packages/perpetuals/perpetuals.d.ts.map +0 -1
  254. package/dist/packages/perpetuals/perpetuals.js +0 -1102
  255. package/dist/packages/perpetuals/perpetualsAccount.d.ts +0 -780
  256. package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +0 -1
  257. package/dist/packages/perpetuals/perpetualsAccount.js +0 -1406
  258. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +0 -170
  259. package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +0 -1
  260. package/dist/packages/perpetuals/perpetualsCastingTypes.js +0 -2
  261. package/dist/packages/perpetuals/perpetualsMarket.d.ts +0 -360
  262. package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +0 -1
  263. package/dist/packages/perpetuals/perpetualsMarket.js +0 -475
  264. package/dist/packages/perpetuals/perpetualsTypes.d.ts +0 -2968
  265. package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +0 -1
  266. package/dist/packages/perpetuals/perpetualsTypes.js +0 -165
  267. package/dist/packages/perpetuals/perpetualsVault.d.ts +0 -438
  268. package/dist/packages/perpetuals/perpetualsVault.d.ts.map +0 -1
  269. package/dist/packages/perpetuals/perpetualsVault.js +0 -601
  270. package/dist/packages/perpetuals/utils/index.d.ts +0 -2
  271. package/dist/packages/perpetuals/utils/index.d.ts.map +0 -1
  272. package/dist/packages/perpetuals/utils/index.js +0 -17
  273. package/dist/packages/perpetuals/utils/perpetualsOrderUtils.d.ts +0 -12
  274. package/dist/packages/perpetuals/utils/perpetualsOrderUtils.d.ts.map +0 -1
  275. package/dist/packages/perpetuals/utils/perpetualsOrderUtils.js +0 -60
  276. package/dist/packages/pools/api/poolsApi.d.ts +0 -342
  277. package/dist/packages/pools/api/poolsApi.d.ts.map +0 -1
  278. package/dist/packages/pools/api/poolsApi.js +0 -857
  279. package/dist/packages/pools/api/poolsApiCasting.d.ts +0 -13
  280. package/dist/packages/pools/api/poolsApiCasting.d.ts.map +0 -1
  281. package/dist/packages/pools/api/poolsApiCasting.js +0 -91
  282. package/dist/packages/pools/api/poolsApiCastingTypes.d.ts +0 -64
  283. package/dist/packages/pools/api/poolsApiCastingTypes.d.ts.map +0 -1
  284. package/dist/packages/pools/api/poolsApiCastingTypes.js +0 -2
  285. package/dist/packages/pools/index.d.ts +0 -3
  286. package/dist/packages/pools/index.d.ts.map +0 -1
  287. package/dist/packages/pools/index.js +0 -18
  288. package/dist/packages/pools/pool.d.ts +0 -459
  289. package/dist/packages/pools/pool.d.ts.map +0 -1
  290. package/dist/packages/pools/pool.js +0 -647
  291. package/dist/packages/pools/pools.d.ts +0 -405
  292. package/dist/packages/pools/pools.d.ts.map +0 -1
  293. package/dist/packages/pools/pools.js +0 -533
  294. package/dist/packages/pools/poolsTypes.d.ts +0 -469
  295. package/dist/packages/pools/poolsTypes.d.ts.map +0 -1
  296. package/dist/packages/pools/poolsTypes.js +0 -2
  297. package/dist/packages/pools/utils/cmmmCalculations.d.ts +0 -42
  298. package/dist/packages/pools/utils/cmmmCalculations.d.ts.map +0 -1
  299. package/dist/packages/pools/utils/cmmmCalculations.js +0 -1380
  300. package/dist/packages/referralVault/api/referralVaultApi.d.ts +0 -39
  301. package/dist/packages/referralVault/api/referralVaultApi.d.ts.map +0 -1
  302. package/dist/packages/referralVault/api/referralVaultApi.js +0 -125
  303. package/dist/packages/referralVault/index.d.ts +0 -2
  304. package/dist/packages/referralVault/index.d.ts.map +0 -1
  305. package/dist/packages/referralVault/index.js +0 -17
  306. package/dist/packages/referralVault/referralVault.d.ts +0 -47
  307. package/dist/packages/referralVault/referralVault.d.ts.map +0 -1
  308. package/dist/packages/referralVault/referralVault.js +0 -71
  309. package/dist/packages/referralVault/referralVaultTypes.d.ts +0 -2
  310. package/dist/packages/referralVault/referralVaultTypes.d.ts.map +0 -1
  311. package/dist/packages/referralVault/referralVaultTypes.js +0 -2
  312. package/dist/packages/referrals/index.d.ts +0 -2
  313. package/dist/packages/referrals/index.d.ts.map +0 -1
  314. package/dist/packages/referrals/index.js +0 -17
  315. package/dist/packages/referrals/referrals.d.ts +0 -27
  316. package/dist/packages/referrals/referrals.d.ts.map +0 -1
  317. package/dist/packages/referrals/referrals.js +0 -95
  318. package/dist/packages/referrals/referralsTypes.d.ts +0 -166
  319. package/dist/packages/referrals/referralsTypes.d.ts.map +0 -1
  320. package/dist/packages/referrals/referralsTypes.js +0 -2
  321. package/dist/packages/rewards/index.d.ts +0 -2
  322. package/dist/packages/rewards/index.d.ts.map +0 -1
  323. package/dist/packages/rewards/index.js +0 -17
  324. package/dist/packages/rewards/rewards.d.ts +0 -21
  325. package/dist/packages/rewards/rewards.d.ts.map +0 -1
  326. package/dist/packages/rewards/rewards.js +0 -65
  327. package/dist/packages/rewards/rewardsTypes.d.ts +0 -169
  328. package/dist/packages/rewards/rewardsTypes.d.ts.map +0 -1
  329. package/dist/packages/rewards/rewardsTypes.js +0 -2
  330. package/dist/packages/router/api/routerApi.d.ts +0 -35
  331. package/dist/packages/router/api/routerApi.d.ts.map +0 -1
  332. package/dist/packages/router/api/routerApi.js +0 -88
  333. package/dist/packages/router/api/routerApiCasting.d.ts +0 -6
  334. package/dist/packages/router/api/routerApiCasting.d.ts.map +0 -1
  335. package/dist/packages/router/api/routerApiCasting.js +0 -22
  336. package/dist/packages/router/api/routerApiCastingTypes.d.ts +0 -12
  337. package/dist/packages/router/api/routerApiCastingTypes.d.ts.map +0 -1
  338. package/dist/packages/router/api/routerApiCastingTypes.js +0 -2
  339. package/dist/packages/router/index.d.ts +0 -2
  340. package/dist/packages/router/index.d.ts.map +0 -1
  341. package/dist/packages/router/index.js +0 -17
  342. package/dist/packages/router/router.d.ts +0 -224
  343. package/dist/packages/router/router.d.ts.map +0 -1
  344. package/dist/packages/router/router.js +0 -283
  345. package/dist/packages/router/routerTypes.d.ts +0 -300
  346. package/dist/packages/router/routerTypes.d.ts.map +0 -1
  347. package/dist/packages/router/routerTypes.js +0 -2
  348. package/dist/packages/staking/api/stakingApi.d.ts +0 -129
  349. package/dist/packages/staking/api/stakingApi.d.ts.map +0 -1
  350. package/dist/packages/staking/api/stakingApi.js +0 -487
  351. package/dist/packages/staking/api/stakingApiCasting.d.ts +0 -11
  352. package/dist/packages/staking/api/stakingApiCasting.d.ts.map +0 -1
  353. package/dist/packages/staking/api/stakingApiCasting.js +0 -87
  354. package/dist/packages/staking/api/stakingApiCastingTypes.d.ts +0 -97
  355. package/dist/packages/staking/api/stakingApiCastingTypes.d.ts.map +0 -1
  356. package/dist/packages/staking/api/stakingApiCastingTypes.js +0 -2
  357. package/dist/packages/staking/index.d.ts +0 -2
  358. package/dist/packages/staking/index.d.ts.map +0 -1
  359. package/dist/packages/staking/index.js +0 -17
  360. package/dist/packages/staking/staking.d.ts +0 -385
  361. package/dist/packages/staking/staking.d.ts.map +0 -1
  362. package/dist/packages/staking/staking.js +0 -501
  363. package/dist/packages/staking/stakingTypes.d.ts +0 -575
  364. package/dist/packages/staking/stakingTypes.d.ts.map +0 -1
  365. package/dist/packages/staking/stakingTypes.js +0 -45
  366. package/dist/packages/sui/api/suiApi.d.ts +0 -21
  367. package/dist/packages/sui/api/suiApi.d.ts.map +0 -1
  368. package/dist/packages/sui/api/suiApi.js +0 -46
  369. package/dist/packages/sui/index.d.ts +0 -2
  370. package/dist/packages/sui/index.d.ts.map +0 -1
  371. package/dist/packages/sui/index.js +0 -17
  372. package/dist/packages/sui/sui.d.ts +0 -53
  373. package/dist/packages/sui/sui.d.ts.map +0 -1
  374. package/dist/packages/sui/sui.js +0 -77
  375. package/dist/packages/suiFrens/api/suiFrensApi.d.ts +0 -204
  376. package/dist/packages/suiFrens/api/suiFrensApi.d.ts.map +0 -1
  377. package/dist/packages/suiFrens/api/suiFrensApi.js +0 -756
  378. package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts +0 -21
  379. package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts.map +0 -1
  380. package/dist/packages/suiFrens/api/suiFrensApiCasting.js +0 -181
  381. package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts +0 -77
  382. package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts.map +0 -1
  383. package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.js +0 -2
  384. package/dist/packages/suiFrens/index.d.ts +0 -4
  385. package/dist/packages/suiFrens/index.d.ts.map +0 -1
  386. package/dist/packages/suiFrens/index.js +0 -19
  387. package/dist/packages/suiFrens/stakedSuiFren.d.ts +0 -31
  388. package/dist/packages/suiFrens/stakedSuiFren.d.ts.map +0 -1
  389. package/dist/packages/suiFrens/stakedSuiFren.js +0 -90
  390. package/dist/packages/suiFrens/suiFren.d.ts +0 -32
  391. package/dist/packages/suiFrens/suiFren.d.ts.map +0 -1
  392. package/dist/packages/suiFrens/suiFren.js +0 -150
  393. package/dist/packages/suiFrens/suiFrens.d.ts +0 -56
  394. package/dist/packages/suiFrens/suiFrens.d.ts.map +0 -1
  395. package/dist/packages/suiFrens/suiFrens.js +0 -218
  396. package/dist/packages/suiFrens/suiFrensTypes.d.ts +0 -148
  397. package/dist/packages/suiFrens/suiFrensTypes.d.ts.map +0 -1
  398. package/dist/packages/suiFrens/suiFrensTypes.js +0 -8
  399. package/dist/packages/userData/index.d.ts +0 -2
  400. package/dist/packages/userData/index.d.ts.map +0 -1
  401. package/dist/packages/userData/index.js +0 -17
  402. package/dist/packages/userData/userData.d.ts +0 -89
  403. package/dist/packages/userData/userData.d.ts.map +0 -1
  404. package/dist/packages/userData/userData.js +0 -119
  405. package/dist/packages/userData/userDataTypes.d.ts +0 -29
  406. package/dist/packages/userData/userDataTypes.d.ts.map +0 -1
  407. package/dist/packages/userData/userDataTypes.js +0 -2
  408. package/dist/types.d.ts +0 -15
  409. package/dist/types.d.ts.map +0 -1
  410. package/dist/types.js +0 -31
@@ -1,725 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var _a;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Helpers = void 0;
14
- const dynamicFieldsApiHelpers_1 = require("../apiHelpers/dynamicFieldsApiHelpers");
15
- const eventsApiHelpers_1 = require("../apiHelpers/eventsApiHelpers");
16
- const inspectionsApiHelpers_1 = require("../apiHelpers/inspectionsApiHelpers");
17
- const objectsApiHelpers_1 = require("../apiHelpers/objectsApiHelpers");
18
- const transactionsApiHelpers_1 = require("../apiHelpers/transactionsApiHelpers");
19
- const utils_1 = require("@mysten/sui/utils");
20
- const cryptography_1 = require("@mysten/sui/cryptography");
21
- const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
22
- const secp256k1_1 = require("@mysten/sui/keypairs/secp256k1");
23
- const secp256r1_1 = require("@mysten/sui/keypairs/secp256r1");
24
- /**
25
- * A utility class containing various helper functions for general use across
26
- * the Aftermath TS ecosystem. This includes numeric operations, object field
27
- * extraction, array transformations, slippage adjustments, and Move error parsing.
28
- */
29
- class Helpers {
30
- static uniqueObjectArray(arr) {
31
- const seen = new Set();
32
- return arr.filter((obj) => {
33
- const str = JSON.stringify(obj);
34
- if (seen.has(str)) {
35
- return false;
36
- }
37
- seen.add(str);
38
- return true;
39
- });
40
- }
41
- /**
42
- * Combines two arrays into a single array of pairs. The result length is the
43
- * minimum of the two input arrays' lengths.
44
- *
45
- * @param firstCollection - The first array.
46
- * @param lastCollection - The second array.
47
- * @returns An array of `[firstCollection[i], lastCollection[i]]` pairs.
48
- */
49
- static zip(firstCollection, lastCollection) {
50
- const length = Math.min(firstCollection.length, lastCollection.length);
51
- const zipped = [];
52
- for (let index = 0; index < length; index++) {
53
- zipped.push([firstCollection[index], lastCollection[index]]);
54
- }
55
- return zipped;
56
- }
57
- /**
58
- * Removes circular references from an object or array, returning a JSON-safe structure.
59
- * Any cyclic references are replaced with `undefined`.
60
- *
61
- * @param obj - The object or array to remove circular references from.
62
- * @param seen - Internal usage to track references that have already been visited.
63
- * @returns A structure that can be safely JSON-stringified.
64
- */
65
- static removeCircularReferences(obj, seen = new WeakSet()) {
66
- if (obj && typeof obj === "object") {
67
- if (seen.has(obj)) {
68
- return undefined;
69
- }
70
- seen.add(obj);
71
- if (Array.isArray(obj)) {
72
- return obj.map((item) => this.removeCircularReferences(item, seen));
73
- }
74
- else {
75
- const entries = Object.entries(obj).map(([key, value]) => [
76
- key,
77
- this.removeCircularReferences(value, seen),
78
- ]);
79
- return Object.fromEntries(entries);
80
- }
81
- }
82
- return obj;
83
- }
84
- // =========================================================================
85
- // Type Checking
86
- // =========================================================================
87
- /**
88
- * Checks if an unknown value is an array of strings.
89
- *
90
- * @param value - The value to check.
91
- * @returns `true` if `value` is a string array, otherwise `false`.
92
- */
93
- static isArrayOfStrings(value) {
94
- return (Array.isArray(value) &&
95
- value.every((item) => typeof item === "string"));
96
- }
97
- // =========================================================================
98
- // Sui Object Parsing
99
- // =========================================================================
100
- /**
101
- * Extracts the fully qualified type (e.g., "0x2::coin::Coin<...>") from a `SuiObjectResponse`,
102
- * normalizing it with leading zeroes if necessary.
103
- *
104
- * @param data - The object response from Sui.
105
- * @returns The normalized object type string.
106
- * @throws If the type is not found.
107
- */
108
- static getObjectType(data) {
109
- var _b, _c;
110
- const objectType = (_b = data.data) === null || _b === void 0 ? void 0 : _b.type;
111
- if (objectType)
112
- return _a.addLeadingZeroesToType(objectType);
113
- throw new Error("no object type found on " + ((_c = data.data) === null || _c === void 0 ? void 0 : _c.objectId));
114
- }
115
- /**
116
- * Extracts the object ID from a `SuiObjectResponse`, normalizing it with leading zeroes.
117
- *
118
- * @param data - The object response from Sui.
119
- * @returns A zero-padded `ObjectId`.
120
- * @throws If the objectId is not found.
121
- */
122
- static getObjectId(data) {
123
- var _b, _c;
124
- const objectId = (_b = data.data) === null || _b === void 0 ? void 0 : _b.objectId;
125
- if (objectId)
126
- return _a.addLeadingZeroesToType(objectId);
127
- throw new Error("no object id found on " + ((_c = data.data) === null || _c === void 0 ? void 0 : _c.type));
128
- }
129
- /**
130
- * Retrieves the fields of a Move object from a `SuiObjectResponse`.
131
- *
132
- * @param data - The Sui object response containing a Move object.
133
- * @returns A record of fields for that object.
134
- * @throws If no fields are found.
135
- */
136
- static getObjectFields(data) {
137
- var _b, _c;
138
- try {
139
- const content = (_b = data.data) === null || _b === void 0 ? void 0 : _b.content;
140
- return content.fields;
141
- }
142
- catch (e) {
143
- throw new Error("no object fields found on " + ((_c = data.data) === null || _c === void 0 ? void 0 : _c.objectId));
144
- }
145
- }
146
- /**
147
- * Retrieves display metadata from a Sui object response, if present.
148
- *
149
- * @param data - The Sui object response.
150
- * @returns The display fields for that object.
151
- * @throws If display fields are not found.
152
- */
153
- static getObjectDisplay(data) {
154
- var _b, _c;
155
- const display = (_b = data.data) === null || _b === void 0 ? void 0 : _b.display;
156
- if (display)
157
- return display;
158
- throw new Error("no object display found on " + ((_c = data.data) === null || _c === void 0 ? void 0 : _c.objectId));
159
- }
160
- // =========================================================================
161
- // Error Parsing
162
- // =========================================================================
163
- /**
164
- * Parses a MoveAbort error message from Sui into a possible `(errorCode, packageId, module)`,
165
- * if the message follows a known pattern. Otherwise returns undefined.
166
- *
167
- * @param inputs - The object containing the raw `errorMessage` from Sui.
168
- * @returns A partial structure of the error details or undefined.
169
- */
170
- static parseMoveErrorMessage(inputs) {
171
- const { errorMessage } = inputs;
172
- if (!errorMessage.toLowerCase().includes("moveabort"))
173
- return undefined;
174
- /*
175
- MoveAbort(MoveLocation { module: ModuleId { address: 8d8946c2a433e2bf795414498d9f7b32e04aca8dbf35a20257542dc51406242b, name: Identifier("orderbook") }, function: 11, instruction: 117, function_name: Some("fill_market_order") }, 3005) in command 2
176
-
177
- MoveAbort(MoveLocation { module: ModuleId { address: 7c995f9c0c0553c0f3bfac7cf3c8b85716f0ca522305586bd0168ca20aeed277, name: Identifier("clearing_house") }, function: 37, instruction: 17, function_name: Some("place_limit_order") }, 1) in command 1
178
- */
179
- const moveErrorCode = (inputs) => {
180
- const { errorMessage } = inputs;
181
- const startIndex = errorMessage.lastIndexOf(",");
182
- const endIndex = errorMessage.lastIndexOf(")");
183
- if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)
184
- return undefined;
185
- try {
186
- const errorCode = parseInt(errorMessage.slice(startIndex + 1, endIndex));
187
- if (Number.isNaN(errorCode))
188
- return undefined;
189
- return errorCode;
190
- }
191
- catch (_b) {
192
- return undefined;
193
- }
194
- };
195
- const moveErrorPackageId = (inputs) => {
196
- const { errorMessage } = inputs;
197
- const startIndex = errorMessage.toLowerCase().indexOf("address:");
198
- const endIndex = errorMessage.indexOf(", name:");
199
- if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)
200
- return undefined;
201
- try {
202
- const pkgStr = errorMessage
203
- .slice(startIndex + 8, endIndex)
204
- .trim()
205
- .replaceAll("0x", "");
206
- const packageId = _a.addLeadingZeroesToType("0x" + pkgStr);
207
- if (!this.isValidHex(packageId))
208
- return undefined;
209
- return packageId;
210
- }
211
- catch (_b) {
212
- return undefined;
213
- }
214
- };
215
- const moveErrorModule = (inputs) => {
216
- const { errorMessage } = inputs;
217
- const startIndex = errorMessage
218
- .toLowerCase()
219
- .indexOf('identifier("');
220
- const endIndex = errorMessage.indexOf('")');
221
- if (startIndex <= 0 || endIndex <= 0 || startIndex >= endIndex)
222
- return undefined;
223
- try {
224
- return errorMessage.slice(startIndex + 12, endIndex).trim();
225
- }
226
- catch (_b) {
227
- return undefined;
228
- }
229
- };
230
- const errorCode = moveErrorCode({ errorMessage });
231
- const packageId = moveErrorPackageId({ errorMessage });
232
- const module = moveErrorModule({ errorMessage });
233
- if (errorCode === undefined || !packageId || !module)
234
- return undefined;
235
- return { errorCode, packageId, module };
236
- }
237
- /**
238
- * Translates a Move abort error message into a known error string if it matches
239
- * entries in a given `moveErrors` table. This is used to map on-chain error codes
240
- * to user-friendly messages.
241
- *
242
- * @param inputs - Includes the raw `errorMessage` and a `moveErrors` object keyed by package, module, and code.
243
- * @returns A structure with `errorCode`, `packageId`, `module`, and a human-readable `error` string, or `undefined`.
244
- */
245
- static translateMoveErrorMessage(inputs) {
246
- const { errorMessage, moveErrors } = inputs;
247
- const parsed = this.parseMoveErrorMessage({ errorMessage });
248
- if (!parsed || !(parsed.packageId in moveErrors))
249
- return undefined;
250
- let error;
251
- if (parsed.module in moveErrors[parsed.packageId] &&
252
- parsed.errorCode in moveErrors[parsed.packageId][parsed.module]) {
253
- error =
254
- moveErrors[parsed.packageId][parsed.module][parsed.errorCode];
255
- }
256
- else if ("ANY" in moveErrors[parsed.packageId] &&
257
- parsed.errorCode in moveErrors[parsed.packageId]["ANY"]) {
258
- error = moveErrors[parsed.packageId]["ANY"][parsed.errorCode];
259
- }
260
- else
261
- return undefined;
262
- return Object.assign(Object.assign({}, parsed), { error });
263
- }
264
- }
265
- exports.Helpers = Helpers;
266
- _a = Helpers;
267
- // =========================================================================
268
- // Api Helpers (Static References)
269
- // =========================================================================
270
- /**
271
- * Static reference to the `DynamicFieldsApiHelpers`, providing utility methods
272
- * for working with dynamic fields in Sui objects.
273
- */
274
- Helpers.dynamicFields = dynamicFieldsApiHelpers_1.DynamicFieldsApiHelpers;
275
- /**
276
- * Static reference to the `EventsApiHelpers`, providing methods for
277
- * querying and filtering Sui events.
278
- */
279
- Helpers.events = eventsApiHelpers_1.EventsApiHelpers;
280
- /**
281
- * Static reference to the `InspectionsApiHelpers`, used for reading
282
- * Summaries or inspection data from objects.
283
- */
284
- Helpers.inspections = inspectionsApiHelpers_1.InspectionsApiHelpers;
285
- /**
286
- * Static reference to the `ObjectsApiHelpers`, providing direct
287
- * retrieval or manipulation of on-chain Sui objects.
288
- */
289
- Helpers.objects = objectsApiHelpers_1.ObjectsApiHelpers;
290
- /**
291
- * Static reference to the `TransactionsApiHelpers`, enabling easier
292
- * queries for transaction data by digest or other criteria.
293
- */
294
- Helpers.transactions = transactionsApiHelpers_1.TransactionsApiHelpers;
295
- // =========================================================================
296
- // Type Manipulation
297
- // =========================================================================
298
- /**
299
- * Removes all leading zeroes (after the '0x') from a string that represents
300
- * a Sui address or object type. For instance, "0x0000123" => "0x123".
301
- *
302
- * @param type - The hex string to process, potentially including "::" module syntax.
303
- * @returns The same string with unnecessary leading zeroes stripped out.
304
- */
305
- Helpers.stripLeadingZeroesFromType = (type) => type.replaceAll(/x0+/g, "x");
306
- /**
307
- * Ensures the given Sui address or object type is zero-padded to 64 hex digits
308
- * after the "0x". If a "::" suffix is present, only the address portion is padded.
309
- *
310
- * @param type - The "0x..." string or extended type (0x..::module).
311
- * @returns A new string normalized to a 64-hex-digit address or object ID.
312
- * @throws If the address portion is already longer than 64 hex digits.
313
- */
314
- Helpers.addLeadingZeroesToType = (type) => {
315
- const EXPECTED_TYPE_LENGTH = 64;
316
- let strippedType = type.replace("0x", "");
317
- let typeSuffix = "";
318
- if (strippedType.includes("::")) {
319
- const splitType = strippedType.replace("0x", "").split("::");
320
- typeSuffix = splitType
321
- .slice(1)
322
- .reduce((acc, str) => acc + "::" + str, "");
323
- strippedType = splitType[0];
324
- }
325
- const typeLength = strippedType.length;
326
- if (typeLength > EXPECTED_TYPE_LENGTH)
327
- throw new Error("invalid type length");
328
- const zerosNeeded = EXPECTED_TYPE_LENGTH - typeLength;
329
- const zeroString = Array(zerosNeeded).fill("0").join("");
330
- const newType = "0x" + zeroString + strippedType;
331
- return newType + typeSuffix;
332
- };
333
- /**
334
- * Splits a non-SUI coin type string that may be prefixed by a chain ID for external usage,
335
- * returning the chain and the coin type. If no chain is recognized, defaults to `"sui"`.
336
- *
337
- * @param coin - The coin string, which may look like `"bsc:0x<...>"` or just `"0x<...>"`.
338
- * @returns An object with the `chain` (e.g. "bsc") and the `coinType`.
339
- */
340
- Helpers.splitNonSuiCoinType = (coin) => {
341
- const [uncastChain, coinType] = coin.split(":");
342
- if (!uncastChain || !coinType)
343
- return { coinType: coin, chain: "sui" };
344
- const chain = uncastChain;
345
- return { chain, coinType };
346
- };
347
- // =========================================================================
348
- // Numbers
349
- // =========================================================================
350
- /**
351
- * Checks if a given string represents a valid number (integer or decimal).
352
- *
353
- * @param str - The string to test.
354
- * @returns `true` if it's a valid numeric string, otherwise `false`.
355
- */
356
- Helpers.isNumber = (str) => /^\d*\.?\d*$/g.test(str);
357
- /**
358
- * Sums an array of floating-point numbers, returning the numeric total.
359
- *
360
- * @param arr - The array of numbers to sum.
361
- * @returns The total as a float.
362
- */
363
- Helpers.sum = (arr) => arr.reduce((prev, cur) => prev + cur, 0);
364
- /**
365
- * Sums an array of bigints, returning the total as a bigint.
366
- *
367
- * @param arr - The array of bigints to sum.
368
- * @returns The resulting total as a bigint.
369
- */
370
- Helpers.sumBigInt = (arr) => arr.reduce((prev, cur) => prev + cur, BigInt(0));
371
- /**
372
- * Determines if two numbers are close within a given tolerance factor,
373
- * i.e., `|a - b| <= tolerance * max(a, b)`.
374
- *
375
- * @param a - The first number.
376
- * @param b - The second number.
377
- * @param tolerance - A fraction representing the max allowed difference relative to max(a, b).
378
- * @returns `true` if within tolerance, otherwise `false`.
379
- */
380
- Helpers.closeEnough = (a, b, tolerance) => Math.abs(a - b) <= tolerance * Math.max(a, b);
381
- /**
382
- * Determines if two bigints are close within a given tolerance factor,
383
- * by casting them to numbers internally.
384
- *
385
- * @param a - First bigint.
386
- * @param b - Second bigint.
387
- * @param tolerance - A fraction representing the max allowed difference relative to max(a, b).
388
- * @returns `true` if within tolerance, otherwise `false`.
389
- */
390
- Helpers.closeEnoughBigInt = (a, b, tolerance) => _a.closeEnough(Number(a), Number(b), tolerance);
391
- /**
392
- * Checks whether the integer divisions of `a` and `b` (by `fixedOne`) differ
393
- * by at most 1. Typically used in fixed math scenarios to see if two scaled
394
- * values are "very close."
395
- *
396
- * @param a - First number (scaled).
397
- * @param b - Second number (scaled).
398
- * @param fixedOne - The scaling factor representing 1.0 in the same scale as `a` and `b`.
399
- * @returns `true` if the integer parts differ by <= 1, otherwise `false`.
400
- */
401
- Helpers.veryCloseInt = (a, b, fixedOne) => Math.abs(Math.floor(a / fixedOne) - Math.floor(b / fixedOne)) <= 1;
402
- /**
403
- * A small object containing "blended" math operations that handle
404
- * mixed numeric types (number vs. bigint). This is primarily for
405
- * internal usage in advanced math scenarios.
406
- */
407
- Helpers.blendedOperations = {
408
- /**
409
- * Multiply two floating-point numbers.
410
- */
411
- mulNNN: (a, b) => a * b,
412
- /**
413
- * Multiply a float and a bigint, returning a bigint (floor).
414
- */
415
- mulNNB: (a, b) => BigInt(Math.floor(a * b)),
416
- /**
417
- * Multiply a float and a bigint, returning a float.
418
- */
419
- mulNBN: (a, b) => a * Number(b),
420
- /**
421
- * Multiply a float and a bigint, returning a bigint (floor).
422
- */
423
- mulNBB: (a, b) => BigInt(Math.floor(a * Number(b))),
424
- /**
425
- * Multiply two bigints, returning a float.
426
- */
427
- mulBBN: (a, b) => Number(a * b),
428
- /**
429
- * Multiply two bigints, returning a bigint.
430
- */
431
- mulBBB: (a, b) => a * b,
432
- };
433
- /**
434
- * Returns the maximum of multiple bigints.
435
- *
436
- * @param args - The bigints to compare.
437
- * @returns The largest bigint.
438
- */
439
- Helpers.maxBigInt = (...args) => args.reduce((m, e) => (e > m ? e : m));
440
- /**
441
- * Returns the minimum of multiple bigints.
442
- *
443
- * @param args - The bigints to compare.
444
- * @returns The smallest bigint.
445
- */
446
- Helpers.minBigInt = (...args) => args.reduce((m, e) => (e < m ? e : m));
447
- /**
448
- * Returns the absolute value of a bigint.
449
- *
450
- * @param num - The input bigint.
451
- * @returns A bigint representing the absolute value of `num`.
452
- */
453
- Helpers.absBigInt = (num) => (num < BigInt(0) ? -num : num);
454
- // =========================================================================
455
- // Display
456
- // =========================================================================
457
- /**
458
- * Capitalizes only the first letter of a string, making the rest lowercase.
459
- * E.g., "HELLO" => "Hello".
460
- *
461
- * @param str - The input string to transform.
462
- * @returns The resulting string with the first character in uppercase and the rest in lowercase.
463
- */
464
- Helpers.capitalizeOnlyFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
465
- // =========================================================================
466
- // JSON
467
- // =========================================================================
468
- /**
469
- * Parses a JSON string containing potential BigInt values.
470
- * By default, it only converts strings ending in 'n' (like `"123n"`) to BigInts.
471
- *
472
- * @param json - The JSON string to parse.
473
- * @param unsafeStringNumberConversion - If `true`, all numeric strings (e.g., "123") will also become BigInts.
474
- * @returns The parsed JSON object with BigInt conversions where applicable.
475
- */
476
- Helpers.parseJsonWithBigint = (json, unsafeStringNumberConversion = false) => JSON.parse(json, (key, value) => {
477
- // convert null -> undefined everywhere
478
- if (value === null)
479
- return undefined;
480
- // handles bigint casting
481
- if (typeof value === "string" && /^-?\d+n$/.test(value)) {
482
- return BigInt(value.slice(0, -1));
483
- }
484
- if (unsafeStringNumberConversion &&
485
- typeof value === "string" &&
486
- _a.isNumber(value)) {
487
- return BigInt(value);
488
- }
489
- return value;
490
- });
491
- // =========================================================================
492
- // General
493
- // =========================================================================
494
- /**
495
- * Creates a deep copy of the given target, handling nested arrays and objects.
496
- * Dates are cloned by their timestamp.
497
- *
498
- * @param target - The data to clone deeply.
499
- * @returns A new object/array/date structure mirroring `target`.
500
- */
501
- Helpers.deepCopy = (target) => {
502
- if (target === null) {
503
- return target;
504
- }
505
- if (target instanceof Date) {
506
- return new Date(target.getTime());
507
- }
508
- if (Array.isArray(target)) {
509
- const cp = [];
510
- target.forEach((v) => {
511
- cp.push(v);
512
- });
513
- return cp.map((n) => _a.deepCopy(n));
514
- }
515
- if (typeof target === "object") {
516
- const cp = Object.assign({}, target);
517
- Object.keys(cp).forEach((k) => {
518
- cp[k] = _a.deepCopy(cp[k]);
519
- });
520
- return cp;
521
- }
522
- return target;
523
- };
524
- /**
525
- * Finds the index of the maximum value in an array. Returns -1 if the array is empty.
526
- *
527
- * @param arr - The input array.
528
- * @returns The index of the maximum value, or -1 if the array is empty.
529
- */
530
- Helpers.indexOfMax = (arr) => {
531
- if (arr.length === 0)
532
- return -1;
533
- let max = arr[0];
534
- let maxIndex = 0;
535
- for (let i = 1; i < arr.length; i++) {
536
- if (arr[i] > max) {
537
- maxIndex = i;
538
- max = arr[i];
539
- }
540
- }
541
- return maxIndex;
542
- };
543
- /**
544
- * Returns a new array with unique elements from the input array,
545
- * preserving the order of first occurrences.
546
- *
547
- * @param arr - The original array.
548
- * @returns An array of unique items.
549
- */
550
- Helpers.uniqueArray = (arr) => arr.length <= 0
551
- ? []
552
- : typeof arr[0] === "object"
553
- ? _a.uniqueObjectArray(arr)
554
- : [...new Set(arr)];
555
- /**
556
- * Returns a Promise that resolves after a specified number of milliseconds.
557
- *
558
- * @param ms - The delay time in milliseconds.
559
- * @returns A promise that resolves after `ms` milliseconds.
560
- */
561
- Helpers.sleep = (ms) => new Promise((r) => setTimeout(r, ms));
562
- /**
563
- * Creates a unique ID-like string by combining the current timestamp and random base36 digits.
564
- *
565
- * @returns A short random string (base36) that can serve as a unique identifier.
566
- */
567
- Helpers.createUid = () => Date.now().toString(36) + Math.random().toString(36).substring(2);
568
- /**
569
- * Splits an array into two groups: those for which `func` returns `true` (or truthy),
570
- * and those for which it returns `false`. The result is returned as a tuple `[trues, falses]`.
571
- *
572
- * @param array - The array to filter.
573
- * @param func - The function used to test each element.
574
- * @returns A tuple containing two arrays: `[elements that pass, elements that fail]`.
575
- */
576
- Helpers.bifilter = (array, func) => {
577
- const trues = [];
578
- const falses = [];
579
- for (let index = 0; index < array.length; index++) {
580
- const item = array[index];
581
- if (func(item, index, array))
582
- trues[trues.length] = item;
583
- else
584
- falses[falses.length] = item;
585
- }
586
- return [trues, falses];
587
- };
588
- /**
589
- * An async version of `bifilter`, returning a tuple of `[trues, falses]`.
590
- * Each element is tested asynchronously in parallel via `func`.
591
- *
592
- * @param array - The array to filter.
593
- * @param func - An async function returning `true` or `false`.
594
- * @returns A tuple `[trues, falses]` after asynchronous evaluation.
595
- */
596
- Helpers.bifilterAsync = (array, func) => __awaiter(void 0, void 0, void 0, function* () {
597
- const predicates = yield Promise.all(array.map(func));
598
- return _a.bifilter(array, (_, index) => predicates[index]);
599
- });
600
- /**
601
- * Filters the entries of an object based on a predicate function,
602
- * returning a new object with only those entries for which `predicate`
603
- * returns `true`.
604
- *
605
- * @param obj - The original object to filter.
606
- * @param predicate - A function taking `(key, value)` and returning a boolean.
607
- * @returns A new object with only the entries that pass the predicate.
608
- */
609
- Helpers.filterObject = (obj, predicate) => Object.keys(obj).reduce((acc, key) => {
610
- const val = obj[key];
611
- if (!predicate(key, val))
612
- return acc;
613
- return Object.assign(Object.assign({}, acc), { [key]: val });
614
- }, {});
615
- /**
616
- * Applies downward slippage to a bigint amount by subtracting `slippage * amount`.
617
- * For instance, for 1% slippage, we reduce the amount by 1%.
618
- *
619
- * @param amount - The original bigint amount.
620
- * @param slippage - An integer percent (e.g., 1 => 1%).
621
- * @returns The adjusted bigint after subtracting the slippage portion.
622
- */
623
- Helpers.applySlippageBigInt = (amount, slippage) => {
624
- return (amount -
625
- BigInt(Math.floor((slippage / 100) *
626
- Number(amount))));
627
- };
628
- /**
629
- * Applies downward slippage to a floating-point amount. E.g., for 1% slippage,
630
- * reduce by 1% of `amount`.
631
- *
632
- * @param amount - The original float value.
633
- * @param slippage - An integer percent (e.g., 1 => 1%).
634
- * @returns The float after applying slippage.
635
- */
636
- Helpers.applySlippage = (amount, slippage) => {
637
- return amount - (slippage / 100) * amount;
638
- };
639
- /**
640
- * Roughly checks if a string is a valid Sui type (e.g., "0x2::sui::SUI").
641
- * This is not guaranteed to be perfect, but covers common cases.
642
- *
643
- * @param str - The string to validate.
644
- * @returns `true` if it meets the minimum structure, otherwise `false`.
645
- */
646
- Helpers.isValidType = (str) => {
647
- // TODO: use regex
648
- const trimmedStr = str.trim();
649
- return (trimmedStr.startsWith("0x") &&
650
- trimmedStr.length >= 9 &&
651
- trimmedStr.indexOf("::") >= 3 &&
652
- trimmedStr.lastIndexOf("::") >= 6 &&
653
- !trimmedStr.endsWith(":"));
654
- };
655
- /**
656
- * Checks if a string is a valid hex representation, optionally prefixed with "0x".
657
- *
658
- * @param hexString - The string to check.
659
- * @returns `true` if `hexString` is a valid hex, otherwise `false`.
660
- */
661
- Helpers.isValidHex = (hexString) => {
662
- const hexPattern = /^(0x)?[0-9A-F]+$/i;
663
- return hexPattern.test(hexString);
664
- };
665
- // =========================================================================
666
- // Tx Command Input Construction
667
- // =========================================================================
668
- /**
669
- * Utility for building transaction commands with either a string-based
670
- * `ObjectId` or an existing transaction object argument. If it's a string,
671
- * it's converted via `tx.object(...)`; if already a `TransactionObjectArgument`,
672
- * it's returned as-is.
673
- *
674
- * @param tx - The current `Transaction` block to add the object to.
675
- * @param object - Either an `ObjectId` or a `TransactionObjectArgument`.
676
- * @returns A `TransactionObjectArgument` referencing the provided object.
677
- */
678
- Helpers.addTxObject = (tx, object) => {
679
- return typeof object === "string" ? tx.object(object) : object;
680
- };
681
- // =========================================================================
682
- // Sui Address / Key Checking
683
- // =========================================================================
684
- /**
685
- * Checks if a given string is a valid Sui address by normalizing it to a
686
- * 64-hex-digit form and calling `isValidSuiAddress`.
687
- *
688
- * @param address - The Sui address to validate.
689
- * @returns `true` if valid, `false` otherwise.
690
- */
691
- Helpers.isValidSuiAddress = (address) => (0, utils_1.isValidSuiAddress)((() => {
692
- if (!address.startsWith("0x") || address.length < 3)
693
- return "";
694
- try {
695
- return _a.addLeadingZeroesToType(address);
696
- }
697
- catch (e) {
698
- return "";
699
- }
700
- })());
701
- // =========================================================================
702
- // Keypair
703
- // =========================================================================
704
- /**
705
- * Constructs a `Keypair` instance from a private key string. The `privateKey`
706
- * may indicate the signing scheme (ED25519, Secp256k1, or Secp256r1) via prefix,
707
- * as recognized by `decodeSuiPrivateKey`.
708
- *
709
- * @param privateKey - The full private key string (e.g., "0x<64_hex_chars>").
710
- * @returns A new `Keypair` instance for signing transactions.
711
- * @throws If the schema is unsupported.
712
- */
713
- Helpers.keypairFromPrivateKey = (privateKey) => {
714
- const parsedKeypair = (0, cryptography_1.decodeSuiPrivateKey)(privateKey);
715
- switch (parsedKeypair.schema) {
716
- case "ED25519":
717
- return ed25519_1.Ed25519Keypair.fromSecretKey(parsedKeypair.secretKey);
718
- case "Secp256k1":
719
- return secp256k1_1.Secp256k1Keypair.fromSecretKey(parsedKeypair.secretKey);
720
- case "Secp256r1":
721
- return secp256r1_1.Secp256r1Keypair.fromSecretKey(parsedKeypair.secretKey);
722
- default:
723
- throw new Error(`unsupported schema \`${parsedKeypair.schema}\``);
724
- }
725
- };