aftermath-ts-sdk 1.2.64 → 1.2.66

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 +178 -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,14 +1,78 @@
1
1
  import { Byte, IFixed } from "../types";
2
+ /**
3
+ * The `IFixedUtils` class provides support for signed 18-decimal fixed math,
4
+ * referred to as "IFixed" in the Aftermath codebase. An `IFixed` value
5
+ * is a bigint that includes sign bit manipulation.
6
+ */
2
7
  export declare class IFixedUtils {
8
+ /**
9
+ * The representation of 1.0 in the IFixed format, i.e. 1e18.
10
+ */
3
11
  static readonly ONE: IFixed;
12
+ /**
13
+ * The greatest bit in a 256-bit representation. This is used to indicate negative values in some approaches.
14
+ */
4
15
  static readonly GREATEST_BIT: IFixed;
16
+ /**
17
+ * A mask that can be used to flip or remove the greatest bit in a 256-bit number.
18
+ */
5
19
  static readonly NOT_GREATEST_BIT: IFixed;
20
+ /**
21
+ * Converts an IFixed bigint into a floating-point number, extracting both the integer
22
+ * and decimal portions. For negative values, the sign bit is checked and value is negated.
23
+ *
24
+ * @param value - The IFixed value (signed 18-decimal) as a bigint.
25
+ * @returns A standard JavaScript number with fractional parts intact.
26
+ */
6
27
  static numberFromIFixed: (value: IFixed) => number;
28
+ /**
29
+ * Converts a floating-point number into an IFixed bigint with 18 decimals of precision.
30
+ * Negative numbers have the sign bit set.
31
+ *
32
+ * @param value - The JavaScript number to convert.
33
+ * @returns The resulting IFixed bigint in on-chain-compatible format.
34
+ */
7
35
  static iFixedFromNumber: (value: number) => IFixed;
36
+ /**
37
+ * Returns the absolute value of an IFixed number. If the value is negative,
38
+ * it's converted to its positive counterpart by flipping bits.
39
+ *
40
+ * @param value - The signed IFixed number as a bigint.
41
+ * @returns The absolute value in IFixed.
42
+ */
8
43
  static abs: (value: IFixed) => IFixed;
44
+ /**
45
+ * Determines the sign of an IFixed number.
46
+ * - If >= GREATEST_BIT, it's negative (-1).
47
+ * - If exactly 0, sign is 0.
48
+ * - Otherwise, sign is +1.
49
+ *
50
+ * @param value - The IFixed number to check.
51
+ * @returns `-1`, `0`, or `1` based on the sign.
52
+ */
9
53
  static sign: (value: IFixed) => number;
54
+ /**
55
+ * Negates an IFixed number by flipping bits. This effectively does `-value` for the signed 18-dec representation.
56
+ *
57
+ * @param value - The IFixed number to negate.
58
+ * @returns The negated IFixed number as a bigint.
59
+ */
10
60
  static neg: (value: IFixed) => IFixed;
61
+ /**
62
+ * Constructs an IFixed number from an array of bytes in little-endian format.
63
+ * The sign bit might be set if the top bit is `1`.
64
+ *
65
+ * @param bytes - The byte array representing the IFixed number.
66
+ * @returns The IFixed bigint.
67
+ */
11
68
  static iFixedFromBytes: (bytes: Byte[]) => IFixed;
69
+ /**
70
+ * Constructs an IFixed number from an array of stringified bytes,
71
+ * each representing a decimal numeric value (e.g., `"255"`, `"0"`).
72
+ *
73
+ * @param bytes - An array of string bytes.
74
+ * @returns The IFixed bigint.
75
+ */
12
76
  static iFixedFromStringBytes: (bytes: string[]) => IFixed;
13
77
  }
14
78
  //# sourceMappingURL=iFixedUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iFixedUtils.d.ts","sourceRoot":"","sources":["../../../src/general/utils/iFixedUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,WAAW;IACvB,gBAAuB,GAAG,EAAE,MAAM,CAAqC;IACvE,gBAAuB,YAAY,EAAE,MA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M,CAE7D;CACF"}
@@ -3,30 +3,74 @@ var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.IFixedUtils = void 0;
5
5
  const casting_1 = require("./casting");
6
+ /**
7
+ * The `IFixedUtils` class provides support for signed 18-decimal fixed math,
8
+ * referred to as "IFixed" in the Aftermath codebase. An `IFixed` value
9
+ * is a bigint that includes sign bit manipulation.
10
+ */
6
11
  class IFixedUtils {
7
12
  }
8
13
  exports.IFixedUtils = IFixedUtils;
9
14
  _a = IFixedUtils;
15
+ /**
16
+ * The representation of 1.0 in the IFixed format, i.e. 1e18.
17
+ */
10
18
  IFixedUtils.ONE = BigInt(1000000000000000000);
19
+ /**
20
+ * The greatest bit in a 256-bit representation. This is used to indicate negative values in some approaches.
21
+ */
11
22
  IFixedUtils.GREATEST_BIT = BigInt(1) << BigInt(255);
23
+ /**
24
+ * A mask that can be used to flip or remove the greatest bit in a 256-bit number.
25
+ */
12
26
  IFixedUtils.NOT_GREATEST_BIT = (BigInt(1) << BigInt(255)) - BigInt(1);
27
+ /**
28
+ * Converts an IFixed bigint into a floating-point number, extracting both the integer
29
+ * and decimal portions. For negative values, the sign bit is checked and value is negated.
30
+ *
31
+ * @param value - The IFixed value (signed 18-decimal) as a bigint.
32
+ * @returns A standard JavaScript number with fractional parts intact.
33
+ */
13
34
  IFixedUtils.numberFromIFixed = (value) => {
14
35
  const absVal = _a.abs(value);
15
36
  const integerPart = Number(absVal / _a.ONE);
16
37
  const decimalPart = Number(absVal % _a.ONE) / Number(_a.ONE);
17
38
  return _a.sign(value) * (integerPart + decimalPart);
18
39
  };
40
+ /**
41
+ * Converts a floating-point number into an IFixed bigint with 18 decimals of precision.
42
+ * Negative numbers have the sign bit set.
43
+ *
44
+ * @param value - The JavaScript number to convert.
45
+ * @returns The resulting IFixed bigint in on-chain-compatible format.
46
+ */
19
47
  IFixedUtils.iFixedFromNumber = (value) => {
20
48
  const newValue = BigInt(Math.floor(Math.abs(value) * Number(_a.ONE)));
21
49
  if (value < 0)
22
50
  return _a.neg(newValue);
23
51
  return newValue;
24
52
  };
53
+ /**
54
+ * Returns the absolute value of an IFixed number. If the value is negative,
55
+ * it's converted to its positive counterpart by flipping bits.
56
+ *
57
+ * @param value - The signed IFixed number as a bigint.
58
+ * @returns The absolute value in IFixed.
59
+ */
25
60
  IFixedUtils.abs = (value) => {
26
61
  if (value >= _a.GREATEST_BIT)
27
62
  return _a.neg(value);
28
63
  return value;
29
64
  };
65
+ /**
66
+ * Determines the sign of an IFixed number.
67
+ * - If >= GREATEST_BIT, it's negative (-1).
68
+ * - If exactly 0, sign is 0.
69
+ * - Otherwise, sign is +1.
70
+ *
71
+ * @param value - The IFixed number to check.
72
+ * @returns `-1`, `0`, or `1` based on the sign.
73
+ */
30
74
  IFixedUtils.sign = (value) => {
31
75
  if (value >= _a.GREATEST_BIT)
32
76
  return -1;
@@ -34,12 +78,32 @@ IFixedUtils.sign = (value) => {
34
78
  return 0;
35
79
  return 1;
36
80
  };
81
+ /**
82
+ * Negates an IFixed number by flipping bits. This effectively does `-value` for the signed 18-dec representation.
83
+ *
84
+ * @param value - The IFixed number to negate.
85
+ * @returns The negated IFixed number as a bigint.
86
+ */
37
87
  IFixedUtils.neg = (value) => {
38
88
  return (((value ^ _a.NOT_GREATEST_BIT) + BigInt(1)) ^ _a.GREATEST_BIT);
39
89
  };
90
+ /**
91
+ * Constructs an IFixed number from an array of bytes in little-endian format.
92
+ * The sign bit might be set if the top bit is `1`.
93
+ *
94
+ * @param bytes - The byte array representing the IFixed number.
95
+ * @returns The IFixed bigint.
96
+ */
40
97
  IFixedUtils.iFixedFromBytes = (bytes) => {
41
98
  return casting_1.Casting.bigIntFromBytes(bytes);
42
99
  };
100
+ /**
101
+ * Constructs an IFixed number from an array of stringified bytes,
102
+ * each representing a decimal numeric value (e.g., `"255"`, `"0"`).
103
+ *
104
+ * @param bytes - An array of string bytes.
105
+ * @returns The IFixed bigint.
106
+ */
43
107
  IFixedUtils.iFixedFromStringBytes = (bytes) => {
44
108
  return _a.iFixedFromBytes(casting_1.Casting.bytesFromStringBytes(bytes));
45
109
  };
@@ -2,18 +2,93 @@ import { ApiTransactionsBody, Balance, CallerConfig, SuiAddress, TransactionsWit
2
2
  import { CoinType, CoinsToBalance } from "../../packages/coin/coinTypes";
3
3
  import { Caller } from "../utils/caller";
4
4
  import { AftermathApi } from "../providers";
5
+ /**
6
+ * The `Wallet` class allows querying a user's balances and transactions.
7
+ * It handles fetching coin balances, transactions, and more by leveraging
8
+ * an `AftermathApi.Wallet` provider.
9
+ */
5
10
  export declare class Wallet extends Caller {
6
11
  readonly address: SuiAddress;
7
12
  private readonly Provider?;
13
+ /**
14
+ * Creates a new `Wallet` instance for a specific address.
15
+ *
16
+ * @param address - The Sui address for this wallet (e.g., "0x<address>").
17
+ * @param config - An optional caller configuration including network and authentication.
18
+ * @param Provider - An optional `AftermathApi` instance for wallet-specific methods.
19
+ */
8
20
  constructor(address: SuiAddress, config?: CallerConfig, Provider?: AftermathApi | undefined);
21
+ /**
22
+ * Fetches the balance for a single coin type in this wallet.
23
+ *
24
+ * @param inputs - An object containing the `coin` type to look up (e.g., "0x2::sui::SUI").
25
+ * @returns A promise that resolves to the coin balance as a bigint.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ *
30
+ * const afSdk = new Aftermath("MAINNET");
31
+ * await afSdk.init(); // initialize provider
32
+ *
33
+ * const wallet = afSdk.Wallet("0x<address>");
34
+ *
35
+ * const suiBalance = await wallet.getBalance({ coin: "0x2::sui::SUI" });
36
+ * console.log("SUI Balance:", suiBalance.toString());
37
+ * ```
38
+ */
9
39
  getBalance(inputs: {
10
40
  coin: CoinType;
11
41
  }): Promise<Balance>;
42
+ /**
43
+ * Fetches the balances for multiple specified coin types in this wallet.
44
+ * This method currently returns an array of balances in the same order
45
+ * as the requested coins.
46
+ *
47
+ * @param inputs - An object containing an array of `coins` (coin types).
48
+ * @returns A promise resolving to an array of `Balance`s, each matching the corresponding coin in `inputs.coins`.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const wallet = new Wallet("0x<address>");
53
+ * const balances = await wallet.getBalances({ coins: ["0x2::sui::SUI", "0x<...>"] });
54
+ * console.log(balances); // e.g. [1000000000n, 50000000000n]
55
+ * ```
56
+ */
12
57
  getBalances(inputs: {
13
58
  coins: CoinType[];
14
59
  }): Promise<Balance[]>;
60
+ /**
61
+ * Fetches all coin balances held by this wallet address, returning a record
62
+ * keyed by coin type.
63
+ *
64
+ * @returns A promise resolving to an object mapping coin types to balances (bigints).
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const wallet = new Wallet("0x<address>");
69
+ * const allBalances = await wallet.getAllBalances();
70
+ * console.log(allBalances); // { "0x2::sui::SUI": 1000000000n, "0x<other_coin>": 5000000000n, ... }
71
+ * ```
72
+ */
15
73
  getAllBalances(): Promise<CoinsToBalance>;
74
+ /**
75
+ * Fetches a paginated list of past transactions for this wallet address.
76
+ *
77
+ * @param inputs - An object implementing `ApiTransactionsBody`, which includes pagination parameters (`cursor`, `limit`) and an optional `order` or other fields.
78
+ * @returns A promise that resolves to transaction details, including a cursor if more results exist.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const wallet = new Wallet("0x<address>");
83
+ * const txHistory = await wallet.getPastTransactions({ cursor: "abc123", limit: 10 });
84
+ * console.log(txHistory.transactions, txHistory.nextCursor);
85
+ * ```
86
+ */
16
87
  getPastTransactions(inputs: ApiTransactionsBody): Promise<TransactionsWithCursor>;
88
+ /**
89
+ * Internal helper to return the `Wallet` provider from `AftermathApi`, throwing
90
+ * an error if the provider is not defined.
91
+ */
17
92
  private useProvider;
18
93
  }
19
94
  //# sourceMappingURL=wallet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/general/wallet/wallet.ts"],"names":[],"mappings":"AACA,OAAO,EACN,mBAAmB,EACnB,OAAO,EACP,YAAY,EACZ,UAAU,EACV,sBAAsB,EAEtB,MAAM,uBAA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,QAAQ,CAAC,0BAAc;IASzC;;;;;;;;;;;;;;;;;OAiBG;IACU,UAAU,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAOrE;;;;;;;;;;;;;;OAcG;IACU,WAAW,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,QAAQ,EAAE,CAAC;KAClB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAItB;;;;;;;;;;;;OAYG;IACU,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC;IAUtD;;;;;;;;;;;;OAYG;IACU,mBAAmB,CAAC,MAAM,EAAE,mBAAmB;IAW5D;;;OAGG;IACH,OAAO,CAAC,WAAW,CAIjB;CACF"}
@@ -11,7 +11,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Wallet = void 0;
13
13
  const caller_1 = require("../utils/caller");
14
+ /**
15
+ * The `Wallet` class allows querying a user's balances and transactions.
16
+ * It handles fetching coin balances, transactions, and more by leveraging
17
+ * an `AftermathApi.Wallet` provider.
18
+ */
14
19
  class Wallet extends caller_1.Caller {
20
+ /**
21
+ * Creates a new `Wallet` instance for a specific address.
22
+ *
23
+ * @param address - The Sui address for this wallet (e.g., "0x<address>").
24
+ * @param config - An optional caller configuration including network and authentication.
25
+ * @param Provider - An optional `AftermathApi` instance for wallet-specific methods.
26
+ */
15
27
  constructor(address, config, Provider) {
16
28
  super(config, `wallet/${address}`);
17
29
  this.address = address;
@@ -19,6 +31,10 @@ class Wallet extends caller_1.Caller {
19
31
  // =========================================================================
20
32
  // Private Helpers
21
33
  // =========================================================================
34
+ /**
35
+ * Internal helper to return the `Wallet` provider from `AftermathApi`, throwing
36
+ * an error if the provider is not defined.
37
+ */
22
38
  this.useProvider = () => {
23
39
  var _a;
24
40
  const provider = (_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Wallet();
@@ -30,21 +46,62 @@ class Wallet extends caller_1.Caller {
30
46
  // =========================================================================
31
47
  // Balances
32
48
  // =========================================================================
49
+ /**
50
+ * Fetches the balance for a single coin type in this wallet.
51
+ *
52
+ * @param inputs - An object containing the `coin` type to look up (e.g., "0x2::sui::SUI").
53
+ * @returns A promise that resolves to the coin balance as a bigint.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ *
58
+ * const afSdk = new Aftermath("MAINNET");
59
+ * await afSdk.init(); // initialize provider
60
+ *
61
+ * const wallet = afSdk.Wallet("0x<address>");
62
+ *
63
+ * const suiBalance = await wallet.getBalance({ coin: "0x2::sui::SUI" });
64
+ * console.log("SUI Balance:", suiBalance.toString());
65
+ * ```
66
+ */
33
67
  getBalance(inputs) {
34
68
  return __awaiter(this, void 0, void 0, function* () {
35
69
  return this.useProvider().fetchCoinBalance(Object.assign(Object.assign({}, inputs), { walletAddress: this.address }));
36
70
  });
37
71
  }
38
- // TODO: change return type to Record<Coin, Balance> ?
72
+ /**
73
+ * Fetches the balances for multiple specified coin types in this wallet.
74
+ * This method currently returns an array of balances in the same order
75
+ * as the requested coins.
76
+ *
77
+ * @param inputs - An object containing an array of `coins` (coin types).
78
+ * @returns A promise resolving to an array of `Balance`s, each matching the corresponding coin in `inputs.coins`.
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const wallet = new Wallet("0x<address>");
83
+ * const balances = await wallet.getBalances({ coins: ["0x2::sui::SUI", "0x<...>"] });
84
+ * console.log(balances); // e.g. [1000000000n, 50000000000n]
85
+ * ```
86
+ */
39
87
  getBalances(inputs) {
40
88
  return __awaiter(this, void 0, void 0, function* () {
41
- // const balances = await Promise.all(
42
- // inputs.coins.map((coin) => this.getBalance({ coin }))
43
- // );
44
- // return balances;
45
89
  return this.fetchApi(`balances/coins`, inputs);
46
90
  });
47
91
  }
92
+ /**
93
+ * Fetches all coin balances held by this wallet address, returning a record
94
+ * keyed by coin type.
95
+ *
96
+ * @returns A promise resolving to an object mapping coin types to balances (bigints).
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const wallet = new Wallet("0x<address>");
101
+ * const allBalances = await wallet.getAllBalances();
102
+ * console.log(allBalances); // { "0x2::sui::SUI": 1000000000n, "0x<other_coin>": 5000000000n, ... }
103
+ * ```
104
+ */
48
105
  getAllBalances() {
49
106
  return __awaiter(this, void 0, void 0, function* () {
50
107
  return this.useProvider().fetchAllCoinBalances({
@@ -55,6 +112,19 @@ class Wallet extends caller_1.Caller {
55
112
  // =========================================================================
56
113
  // Transactions
57
114
  // =========================================================================
115
+ /**
116
+ * Fetches a paginated list of past transactions for this wallet address.
117
+ *
118
+ * @param inputs - An object implementing `ApiTransactionsBody`, which includes pagination parameters (`cursor`, `limit`) and an optional `order` or other fields.
119
+ * @returns A promise that resolves to transaction details, including a cursor if more results exist.
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * const wallet = new Wallet("0x<address>");
124
+ * const txHistory = await wallet.getPastTransactions({ cursor: "abc123", limit: 10 });
125
+ * console.log(txHistory.transactions, txHistory.nextCursor);
126
+ * ```
127
+ */
58
128
  getPastTransactions(inputs) {
59
129
  return __awaiter(this, void 0, void 0, function* () {
60
130
  return this.useProvider().fetchPastTransactions(Object.assign(Object.assign({}, inputs), { walletAddress: this.address }));
@@ -1,14 +1,105 @@
1
1
  import { CallerConfig, SignMessageCallback, SuiAddress } from "../../types";
2
2
  import { Caller } from "../../general/utils/caller";
3
3
  import { RateLimit } from "./authTypes";
4
+ /**
5
+ * The `Auth` class manages creation and refreshing of access tokens
6
+ * to obtain higher rate limits on the Aftermath API. It includes methods
7
+ * to initialize authorization either by a direct callback-based approach
8
+ * or by importing a local Sui keystore. Optionally, administrative functions
9
+ * are provided for creating specialized auth accounts.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const auth = new Auth();
14
+ * const stopAuth = await auth.init({
15
+ * walletAddress: "0x<address>",
16
+ * signMessageCallback: async ({ message }) => {
17
+ * // sign message
18
+ * },
19
+ * });
20
+ * // ... make authenticated requests ...
21
+ * stopAuth(); // stop auto refresh
22
+ * ```
23
+ */
4
24
  export declare class Auth extends Caller {
25
+ /**
26
+ * Holds the timer reference for scheduled token refreshes.
27
+ */
5
28
  private refreshTimer;
29
+ /**
30
+ * Indicates whether the user has canceled auto token refresh.
31
+ */
6
32
  private isCanceled;
33
+ /**
34
+ * Creates a new `Auth` instance for token-based rate limit increases.
35
+ *
36
+ * @param config - Optional caller configuration, including network and access token.
37
+ */
7
38
  constructor(config?: CallerConfig);
39
+ /**
40
+ * Initializes the auth system by fetching an access token for the provided wallet address.
41
+ * After obtaining the token, it automatically schedules periodic refresh calls until stopped.
42
+ *
43
+ * @param inputs - An object containing the user's `walletAddress` and a `signMessageCallback` function
44
+ * for cryptographically signing messages.
45
+ *
46
+ * @returns A function that, when called, cancels further token refresh attempts.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const auth = new Auth();
51
+ * const stopAuth = await auth.init({
52
+ * walletAddress: "0x<address>",
53
+ * signMessageCallback: async ({ message }) => {
54
+ * // sign the message with your private key / keypair
55
+ * },
56
+ * });
57
+ *
58
+ * // ... make authorized calls ...
59
+ *
60
+ * stopAuth(); // Cancel further token refreshes
61
+ * ```
62
+ */
8
63
  init(inputs: {
9
64
  walletAddress: SuiAddress;
10
65
  signMessageCallback: SignMessageCallback;
11
66
  }): Promise<() => void>;
67
+ /**
68
+ * Initializes the auth system by reading a local Sui keystore file (on the server side),
69
+ * using the private keys matching a provided address to sign messages for token creation.
70
+ * After the token is obtained, it automatically schedules periodic refresh calls until stopped.
71
+ *
72
+ * @param inputs - An object containing the target `walletAddress` and an optional path to the `.keystore`.
73
+ * If `path` is not provided, it defaults to `~/.sui/sui_config/sui.keystore`.
74
+ * @returns A function that, when called, cancels further token refresh attempts.
75
+ *
76
+ * @throws If this method is called in a browser environment (client-side).
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // On server:
81
+ * const stopAuth = await auth.initFromSuiKeystore({
82
+ * walletAddress: "0x<address>",
83
+ * path: "/custom/path/to/keystore.json",
84
+ * });
85
+ * // authorized calls...
86
+ * stopAuth();
87
+ * ```
88
+ */
89
+ /**
90
+ * **Admin-only**: Creates a new auth account with specific rate limits for a given
91
+ * `accountWalletAddress`. The `walletAddress` performing this action must have
92
+ * admin privileges, or the call will fail. Use this to create custom sub-accounts
93
+ * with limited scope or usage rates.
94
+ *
95
+ * @param inputs - Contains:
96
+ * - `walletAddress`: The admin's wallet address
97
+ * - `signMessageCallback`: The admin's signing callback
98
+ * - `accountName`: A short name or identifier for the account
99
+ * - `accountWalletAddress`: The Sui address representing this sub-account
100
+ * - `rateLimits`: An array specifying the rate limits (method-based) for the sub-account
101
+ * @returns A promise resolving to `true` if successful, otherwise throws or returns `false`.
102
+ */
12
103
  adminCreateAuthAccount(inputs: {
13
104
  walletAddress: SuiAddress;
14
105
  signMessageCallback: SignMessageCallback;
@@ -16,7 +107,29 @@ export declare class Auth extends Caller {
16
107
  accountWalletAddress: SuiAddress;
17
108
  rateLimits: RateLimit[];
18
109
  }): Promise<boolean>;
110
+ /**
111
+ * Requests a new access token from the API by sending a signed message
112
+ * indicating the user wants a token.
113
+ *
114
+ * @param inputs - Contains the user's `walletAddress` and `signMessageCallback`.
115
+ * @returns A response object that includes the `accessToken` and an `expirationTimestamp`.
116
+ */
19
117
  private getAccessToken;
118
+ /**
119
+ * Creates a JSON string with a standard format:
120
+ * ```json
121
+ * {
122
+ * "date": <epoch-seconds>,
123
+ * "nonce": <random_number>,
124
+ * "method": <method_string>,
125
+ * "value": <passed_value>
126
+ * }
127
+ * ```
128
+ *
129
+ * @param method - A short method name describing the action ("GetAccessToken", "AccountCreate", etc.).
130
+ * @param value - The data object to embed under the `value` field.
131
+ * @returns A JSON-serialized string for signing.
132
+ */
20
133
  private static createSerializedJson;
21
134
  }
22
135
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/packages/auth/auth.ts"],"names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