aftermath-ts-sdk 1.2.63 → 1.2.64-docs.1

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 (117) hide show
  1. package/README.md +61 -27
  2. package/dist/general/dynamicGas/dynamicGas.d.ts +34 -0
  3. package/dist/general/dynamicGas/dynamicGas.d.ts.map +1 -1
  4. package/dist/general/dynamicGas/dynamicGas.js +34 -0
  5. package/dist/general/dynamicGas/dynamicGasTypes.d.ts +25 -0
  6. package/dist/general/dynamicGas/dynamicGasTypes.d.ts.map +1 -1
  7. package/dist/general/prices/prices.d.ts +73 -0
  8. package/dist/general/prices/prices.d.ts.map +1 -1
  9. package/dist/general/prices/prices.js +73 -0
  10. package/dist/general/providers/aftermath.d.ts +106 -25
  11. package/dist/general/providers/aftermath.d.ts.map +1 -1
  12. package/dist/general/providers/aftermath.js +108 -27
  13. package/dist/general/providers/aftermathApi.d.ts +127 -8
  14. package/dist/general/providers/aftermathApi.d.ts.map +1 -1
  15. package/dist/general/providers/aftermathApi.js +132 -12
  16. package/dist/general/types/castingTypes.d.ts +0 -7
  17. package/dist/general/types/castingTypes.d.ts.map +1 -1
  18. package/dist/general/types/castingTypes.js +6 -0
  19. package/dist/general/types/generalTypes.d.ts +228 -7
  20. package/dist/general/types/generalTypes.d.ts.map +1 -1
  21. package/dist/general/types/suiTypes.d.ts +0 -16
  22. package/dist/general/types/suiTypes.d.ts.map +1 -1
  23. package/dist/general/types/suiTypes.js +3 -25
  24. package/dist/general/utils/casting.d.ts +159 -3
  25. package/dist/general/utils/casting.d.ts.map +1 -1
  26. package/dist/general/utils/casting.js +162 -16
  27. package/dist/general/utils/fixedUtils.d.ts +89 -2
  28. package/dist/general/utils/fixedUtils.d.ts.map +1 -1
  29. package/dist/general/utils/fixedUtils.js +81 -4
  30. package/dist/general/utils/helpers.d.ts +320 -9
  31. package/dist/general/utils/helpers.d.ts.map +1 -1
  32. package/dist/general/utils/helpers.js +350 -89
  33. package/dist/general/utils/iFixedUtils.d.ts +64 -0
  34. package/dist/general/utils/iFixedUtils.d.ts.map +1 -1
  35. package/dist/general/utils/iFixedUtils.js +64 -0
  36. package/dist/general/wallet/wallet.d.ts +75 -0
  37. package/dist/general/wallet/wallet.d.ts.map +1 -1
  38. package/dist/general/wallet/wallet.js +75 -5
  39. package/dist/packages/auth/auth.d.ts +113 -0
  40. package/dist/packages/auth/auth.d.ts.map +1 -1
  41. package/dist/packages/auth/auth.js +129 -15
  42. package/dist/packages/auth/authTypes.d.ts +66 -0
  43. package/dist/packages/auth/authTypes.d.ts.map +1 -1
  44. package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
  45. package/dist/packages/coin/api/coinApi.js +28 -20
  46. package/dist/packages/coin/coin.d.ts +250 -0
  47. package/dist/packages/coin/coin.d.ts.map +1 -1
  48. package/dist/packages/coin/coin.js +238 -14
  49. package/dist/packages/coin/coinTypes.d.ts +93 -0
  50. package/dist/packages/coin/coinTypes.d.ts.map +1 -1
  51. package/dist/packages/dca/dca.d.ts +124 -35
  52. package/dist/packages/dca/dca.d.ts.map +1 -1
  53. package/dist/packages/dca/dca.js +127 -37
  54. package/dist/packages/dca/dcaTypes.d.ts +213 -28
  55. package/dist/packages/dca/dcaTypes.d.ts.map +1 -1
  56. package/dist/packages/farms/farms.d.ts +184 -1
  57. package/dist/packages/farms/farms.d.ts.map +1 -1
  58. package/dist/packages/farms/farms.js +185 -11
  59. package/dist/packages/farms/farmsStakedPosition.d.ts +140 -6
  60. package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -1
  61. package/dist/packages/farms/farmsStakedPosition.js +189 -144
  62. package/dist/packages/farms/farmsStakingPool.d.ts +161 -1
  63. package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -1
  64. package/dist/packages/farms/farmsStakingPool.js +176 -70
  65. package/dist/packages/farms/farmsTypes.d.ts +283 -2
  66. package/dist/packages/farms/farmsTypes.d.ts.map +1 -1
  67. package/dist/packages/farms/farmsTypes.js +18 -0
  68. package/dist/packages/limitOrders/limitOrders.d.ts +108 -21
  69. package/dist/packages/limitOrders/limitOrders.d.ts.map +1 -1
  70. package/dist/packages/limitOrders/limitOrders.js +110 -22
  71. package/dist/packages/limitOrders/limitOrdersTypes.d.ts +142 -0
  72. package/dist/packages/limitOrders/limitOrdersTypes.d.ts.map +1 -1
  73. package/dist/packages/multisig/multisig.d.ts +33 -4
  74. package/dist/packages/multisig/multisig.d.ts.map +1 -1
  75. package/dist/packages/multisig/multisig.js +33 -4
  76. package/dist/packages/multisig/multisigTypes.d.ts +17 -0
  77. package/dist/packages/multisig/multisigTypes.d.ts.map +1 -1
  78. package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
  79. package/dist/packages/pools/pool.d.ts +327 -85
  80. package/dist/packages/pools/pool.d.ts.map +1 -1
  81. package/dist/packages/pools/pool.js +333 -91
  82. package/dist/packages/pools/pools.d.ts +299 -37
  83. package/dist/packages/pools/pools.d.ts.map +1 -1
  84. package/dist/packages/pools/pools.js +306 -52
  85. package/dist/packages/pools/poolsTypes.d.ts +267 -2
  86. package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
  87. package/dist/packages/referralVault/referralVault.d.ts +37 -0
  88. package/dist/packages/referralVault/referralVault.d.ts.map +1 -1
  89. package/dist/packages/referralVault/referralVault.js +37 -0
  90. package/dist/packages/router/router.d.ts +213 -17
  91. package/dist/packages/router/router.d.ts.map +1 -1
  92. package/dist/packages/router/router.js +214 -18
  93. package/dist/packages/router/routerTypes.d.ts +198 -14
  94. package/dist/packages/router/routerTypes.d.ts.map +1 -1
  95. package/dist/packages/staking/staking.d.ts +301 -43
  96. package/dist/packages/staking/staking.d.ts.map +1 -1
  97. package/dist/packages/staking/staking.js +308 -51
  98. package/dist/packages/staking/stakingTypes.d.ts +426 -6
  99. package/dist/packages/staking/stakingTypes.d.ts.map +1 -1
  100. package/dist/packages/staking/stakingTypes.js +19 -0
  101. package/dist/packages/sui/sui.d.ts +39 -0
  102. package/dist/packages/sui/sui.d.ts.map +1 -1
  103. package/dist/packages/sui/sui.js +39 -0
  104. package/dist/packages/userData/userData.d.ts +66 -12
  105. package/dist/packages/userData/userData.d.ts.map +1 -1
  106. package/dist/packages/userData/userData.js +66 -12
  107. package/dist/packages/userData/userDataTypes.d.ts +19 -0
  108. package/dist/packages/userData/userDataTypes.d.ts.map +1 -1
  109. package/dist/types.d.ts.map +1 -1
  110. package/dist/types.js +0 -1
  111. package/package.json +1 -1
  112. package/dist/general/historicalData/historicalData.d.ts +0 -15
  113. package/dist/general/historicalData/historicalData.d.ts.map +0 -1
  114. package/dist/general/historicalData/historicalData.js +0 -45
  115. package/dist/general/historicalData/historicalDataTypes.d.ts +0 -10
  116. package/dist/general/historicalData/historicalDataTypes.d.ts.map +0 -1
  117. package/dist/general/historicalData/historicalDataTypes.js +0 -2
@@ -12,42 +12,95 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Auth = void 0;
13
13
  const caller_1 = require("../../general/utils/caller");
14
14
  const utils_1 = require("../../general/utils");
15
+ /**
16
+ * The `Auth` class manages creation and refreshing of access tokens
17
+ * to obtain higher rate limits on the Aftermath API. It includes methods
18
+ * to initialize authorization either by a direct callback-based approach
19
+ * or by importing a local Sui keystore. Optionally, administrative functions
20
+ * are provided for creating specialized auth accounts.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const auth = new Auth();
25
+ * const stopAuth = await auth.init({
26
+ * walletAddress: "0x<address>",
27
+ * signMessageCallback: async ({ message }) => {
28
+ * // sign message
29
+ * },
30
+ * });
31
+ * // ... make authenticated requests ...
32
+ * stopAuth(); // stop auto refresh
33
+ * ```
34
+ */
15
35
  class Auth extends caller_1.Caller {
16
36
  // =========================================================================
17
37
  // Constructor
18
38
  // =========================================================================
39
+ /**
40
+ * Creates a new `Auth` instance for token-based rate limit increases.
41
+ *
42
+ * @param config - Optional caller configuration, including network and access token.
43
+ */
19
44
  constructor(config) {
20
45
  super(config, "auth");
21
46
  // =========================================================================
22
47
  // Private Class Members
23
48
  // =========================================================================
49
+ /**
50
+ * Holds the timer reference for scheduled token refreshes.
51
+ */
24
52
  this.refreshTimer = null;
53
+ /**
54
+ * Indicates whether the user has canceled auto token refresh.
55
+ */
25
56
  this.isCanceled = false;
26
57
  }
27
58
  // =========================================================================
28
59
  // User-Facing
29
60
  // =========================================================================
61
+ /**
62
+ * Initializes the auth system by fetching an access token for the provided wallet address.
63
+ * After obtaining the token, it automatically schedules periodic refresh calls until stopped.
64
+ *
65
+ * @param inputs - An object containing the user's `walletAddress` and a `signMessageCallback` function
66
+ * for cryptographically signing messages.
67
+ *
68
+ * @returns A function that, when called, cancels further token refresh attempts.
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const auth = new Auth();
73
+ * const stopAuth = await auth.init({
74
+ * walletAddress: "0x<address>",
75
+ * signMessageCallback: async ({ message }) => {
76
+ * // sign the message with your private key / keypair
77
+ * },
78
+ * });
79
+ *
80
+ * // ... make authorized calls ...
81
+ *
82
+ * stopAuth(); // Cancel further token refreshes
83
+ * ```
84
+ */
30
85
  init(inputs) {
31
86
  return __awaiter(this, void 0, void 0, function* () {
32
- // Step 1: Mark as "not canceled" before the new run
33
- this.isCanceled = false;
34
- // Step 2: Define a function that does the “work” + schedules next call
87
+ this.isCanceled = false; // Mark as active
35
88
  const startRefresh = () => __awaiter(this, void 0, void 0, function* () {
36
- // If canceled at the time we enter, don’t do anything
37
89
  if (this.isCanceled)
38
- return;
90
+ return; // No-op if canceled
39
91
  const { accessToken, expirationTimestamp } = yield this.getAccessToken(inputs);
40
92
  this.setAccessToken(accessToken);
41
93
  if (this.isCanceled)
42
- return; // double-check before scheduling next timer
94
+ return; // Double-check after token fetch
95
+ // Provide a margin by refreshing before actual expiration
43
96
  const TIMEOUT_REDUCTION_RATIO = 0.9;
44
97
  const interval = (expirationTimestamp - Date.now()) * TIMEOUT_REDUCTION_RATIO;
45
- // Store the timer so we can cancel it later
98
+ // Schedule next refresh
46
99
  this.refreshTimer = setTimeout(startRefresh, interval);
47
100
  });
48
- // Step 3: Kick off the first refresh
101
+ // Kick off first refresh
49
102
  yield startRefresh();
50
- // Step 4: Return a function that cancels further refreshes
103
+ // Return cancellation function
51
104
  return () => {
52
105
  this.isCanceled = true;
53
106
  if (this.refreshTimer) {
@@ -56,26 +109,48 @@ class Auth extends caller_1.Caller {
56
109
  };
57
110
  });
58
111
  }
112
+ /**
113
+ * Initializes the auth system by reading a local Sui keystore file (on the server side),
114
+ * using the private keys matching a provided address to sign messages for token creation.
115
+ * After the token is obtained, it automatically schedules periodic refresh calls until stopped.
116
+ *
117
+ * @param inputs - An object containing the target `walletAddress` and an optional path to the `.keystore`.
118
+ * If `path` is not provided, it defaults to `~/.sui/sui_config/sui.keystore`.
119
+ * @returns A function that, when called, cancels further token refresh attempts.
120
+ *
121
+ * @throws If this method is called in a browser environment (client-side).
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * // On server:
126
+ * const stopAuth = await auth.initFromSuiKeystore({
127
+ * walletAddress: "0x<address>",
128
+ * path: "/custom/path/to/keystore.json",
129
+ * });
130
+ * // authorized calls...
131
+ * stopAuth();
132
+ * ```
133
+ */
59
134
  // public async initFromSuiKeystore(inputs: {
60
135
  // walletAddress: SuiAddress;
61
136
  // path?: string;
62
137
  // }): Promise<() => void> {
63
138
  // const { walletAddress, path: pathStr } = inputs;
64
139
  // if (typeof window === "undefined") {
140
+ // // Node environment, proceed with reading a keystore
65
141
  // const fs = require("fs");
66
142
  // const path = require("path");
67
143
  // const os = require("os");
68
144
  // const keystorePath = pathStr
69
145
  // ? path.join(pathStr)
70
146
  // : (() => {
71
- // // Locate the user’s home directory
147
+ // // Default to ~/.sui/sui_config/sui.keystore
72
148
  // const homeDir = os.homedir();
73
149
  // if (!homeDir) {
74
150
  // throw new Error(
75
151
  // "cannot obtain home directory path"
76
152
  // );
77
153
  // }
78
- // // Construct the path: ~/.sui/sui_config/sui.keystore
79
154
  // return path.join(
80
155
  // homeDir,
81
156
  // ".sui",
@@ -83,7 +158,7 @@ class Auth extends caller_1.Caller {
83
158
  // "sui.keystore"
84
159
  // );
85
160
  // })();
86
- // // Read the JSON file from `keystorePath`
161
+ // // Read JSON with an array of private keys
87
162
  // let privateKeys: string[];
88
163
  // try {
89
164
  // const fileContent = fs.readFileSync(keystorePath, "utf-8");
@@ -99,6 +174,7 @@ class Auth extends caller_1.Caller {
99
174
  // if (privateKeys.length <= 0) {
100
175
  // throw new Error(`Empty keystore file`);
101
176
  // }
177
+ // // Find the matching key for the requested walletAddress
102
178
  // const foundKeypair = privateKeys
103
179
  // .map((privateKey) => Helpers.keypairFromPrivateKey(privateKey))
104
180
  // .find(
@@ -112,6 +188,7 @@ class Auth extends caller_1.Caller {
112
188
  // `No private key found in keystore file for ${walletAddress}`
113
189
  // );
114
190
  // }
191
+ // // Initialize with sign callback
115
192
  // return this.init({
116
193
  // walletAddress,
117
194
  // signMessageCallback: async ({ message }) =>
@@ -123,10 +200,24 @@ class Auth extends caller_1.Caller {
123
200
  // =========================================================================
124
201
  // Admin
125
202
  // =========================================================================
126
- // NOTE: admin only (should add docs)
203
+ /**
204
+ * **Admin-only**: Creates a new auth account with specific rate limits for a given
205
+ * `accountWalletAddress`. The `walletAddress` performing this action must have
206
+ * admin privileges, or the call will fail. Use this to create custom sub-accounts
207
+ * with limited scope or usage rates.
208
+ *
209
+ * @param inputs - Contains:
210
+ * - `walletAddress`: The admin's wallet address
211
+ * - `signMessageCallback`: The admin's signing callback
212
+ * - `accountName`: A short name or identifier for the account
213
+ * - `accountWalletAddress`: The Sui address representing this sub-account
214
+ * - `rateLimits`: An array specifying the rate limits (method-based) for the sub-account
215
+ * @returns A promise resolving to `true` if successful, otherwise throws or returns `false`.
216
+ */
127
217
  adminCreateAuthAccount(inputs) {
128
218
  return __awaiter(this, void 0, void 0, function* () {
129
219
  const { walletAddress, signMessageCallback, accountName, accountWalletAddress, rateLimits, } = inputs;
220
+ // Prepare the data to sign
130
221
  const serializedJson = Auth.createSerializedJson("AccountCreate", {
131
222
  sub: accountName,
132
223
  wallet_address: utils_1.Helpers.addLeadingZeroesToType(accountWalletAddress),
@@ -144,9 +235,17 @@ class Auth extends caller_1.Caller {
144
235
  // =========================================================================
145
236
  // Private
146
237
  // =========================================================================
238
+ /**
239
+ * Requests a new access token from the API by sending a signed message
240
+ * indicating the user wants a token.
241
+ *
242
+ * @param inputs - Contains the user's `walletAddress` and `signMessageCallback`.
243
+ * @returns A response object that includes the `accessToken` and an `expirationTimestamp`.
244
+ */
147
245
  getAccessToken(inputs) {
148
246
  return __awaiter(this, void 0, void 0, function* () {
149
247
  const { walletAddress, signMessageCallback } = inputs;
248
+ // Prepare signable data
150
249
  const serializedJson = Auth.createSerializedJson("GetAccessToken", {});
151
250
  const message = new TextEncoder().encode(serializedJson);
152
251
  const { signature } = yield signMessageCallback({ message });
@@ -160,14 +259,29 @@ class Auth extends caller_1.Caller {
160
259
  // =========================================================================
161
260
  // Private Static
162
261
  // =========================================================================
262
+ /**
263
+ * Creates a JSON string with a standard format:
264
+ * ```json
265
+ * {
266
+ * "date": <epoch-seconds>,
267
+ * "nonce": <random_number>,
268
+ * "method": <method_string>,
269
+ * "value": <passed_value>
270
+ * }
271
+ * ```
272
+ *
273
+ * @param method - A short method name describing the action ("GetAccessToken", "AccountCreate", etc.).
274
+ * @param value - The data object to embed under the `value` field.
275
+ * @returns A JSON-serialized string for signing.
276
+ */
163
277
  static createSerializedJson(method, value) {
164
278
  const timestampSeconds = Math.floor(Date.now() / 1000);
165
279
  const random = Math.floor(Math.random() * 1024 * 1024);
166
280
  const data = {
167
281
  date: timestampSeconds,
168
282
  nonce: random,
169
- method: method,
170
- value: value,
283
+ method,
284
+ value,
171
285
  };
172
286
  return JSON.stringify(data);
173
287
  }
@@ -1,6 +1,23 @@
1
1
  import { SuiAddress, Timestamp } from "../../types";
2
+ /**
3
+ * Interface specifying allowable rate limits for an auth account.
4
+ * The `p` field indicates the path or endpoint (e.g., "/pools"),
5
+ * while `m` indicates the method-based limits (GET or POST, or both).
6
+ */
2
7
  export interface RateLimit {
8
+ /**
9
+ * The path or endpoint to be rate-limited, e.g. "/pools" or "/router/trade".
10
+ */
3
11
  p: string;
12
+ /**
13
+ * The method-based limit specification.
14
+ * For example:
15
+ * ```
16
+ * { GET: { l: 100 } }
17
+ * { POST: { l: 50 } }
18
+ * { GET: { l: 100 }, POST: { l: 100 } }
19
+ * ```
20
+ */
4
21
  m: {
5
22
  GET: {
6
23
  l: number;
@@ -18,19 +35,68 @@ export interface RateLimit {
18
35
  };
19
36
  };
20
37
  }
38
+ /**
39
+ * The request body for creating a new auth account, typically
40
+ * reserved for admin usage. The admin signs a JSON containing
41
+ * an "AccountCreate" `method` plus desired sub-account data.
42
+ */
21
43
  export interface ApiCreateAuthAccountBody {
44
+ /**
45
+ * The admin's Sui address, zero-padded if necessary.
46
+ */
22
47
  walletAddress: SuiAddress;
48
+ /**
49
+ * The signature of the serialized JSON data, from the admin's private key.
50
+ */
23
51
  signature: string;
52
+ /**
53
+ * The JSON string that was signed, containing the method and sub-account details.
54
+ */
24
55
  serializedJson: string;
25
56
  }
57
+ /**
58
+ * The request body for obtaining or refreshing an access token. The user signs
59
+ * a "GetAccessToken" method message plus any relevant fields.
60
+ */
26
61
  export interface ApiGetAccessTokenBody {
62
+ /**
63
+ * The user's Sui address, zero-padded if needed.
64
+ */
27
65
  walletAddress: SuiAddress;
66
+ /**
67
+ * The signature over the JSON-serialized request data (nonce, date, etc.).
68
+ */
28
69
  signature: string;
70
+ /**
71
+ * The actual JSON string that was signed, e.g.:
72
+ * ```
73
+ * {
74
+ * "date": 1234567890,
75
+ * "nonce": 512,
76
+ * "method": "GetAccessToken",
77
+ * "value": {}
78
+ * }
79
+ * ```
80
+ */
29
81
  serializedJson: string;
30
82
  }
83
+ /**
84
+ * The response returned when a user obtains or refreshes an access token,
85
+ * containing the token string, the HTTP header name (usually "Authorization"),
86
+ * and the token's expiration timestamp in milliseconds.
87
+ */
31
88
  export interface ApiGetAccessTokenResponse {
89
+ /**
90
+ * The newly issued access token to be used in `Authorization` headers.
91
+ */
32
92
  accessToken: string;
93
+ /**
94
+ * The header key that should contain `accessToken` (e.g., "Authorization").
95
+ */
33
96
  header: string;
97
+ /**
98
+ * The UNIX timestamp (milliseconds) after which the token is invalid.
99
+ */
34
100
  expirationTimestamp: Timestamp;
35
101
  }
36
102
  //# sourceMappingURL=authTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/auth/authTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUpD,MAAM,WAAW,SAAS;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EACE;QAAE,GAAG,EAAE;YAAE,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GACtB;QAAE,IAAI,EAAE;YAAE,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GACvB;QAAE,GAAG,EAAE;YAAE,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,IAAI,EAAE;YAAE,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC/C;AAMD,MAAM,WAAW,wBAAwB;IACxC,aAAa,EAAE,UAAU,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACrC,aAAa,EAAE,UAAU,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACvB;AAMD,MAAM,WAAW,yBAAyB;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,SAAS,CAAC;CAC/B"}
1
+ {"version":3,"file":"authTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/auth/authTypes.ts"],"names":[],"mappings":"AAAA,OA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E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,qBAAa,OAAO;IAKP,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;IAM5C,qBAAqB,WAAkB;QAC7C,EAAE,EAAE,WAAW,GAAG,gBAAgB,CAAC;QACnC,aAAa,EAAE,UAAU,CAAC;QAC1B,QAAQ,EAAE,QAAQ,CAAC;QACnB,UAAU,EAAE,OAAO,CAAC;QACpB,aAAa,CAAC,EAAE,OAAO,CAAC;KACxB,KAAG,QAAQ,yBAAyB,CAAC,CAcpC;IAEK,sBAAsB,WAAkB;QAC9C,EAAE,EAAE,WAAW,CAAC;QAChB,aAAa,EAAE,UAAU,CAAC;QAC1B,SAAS,EAAE,QAAQ,EAAE,CAAC;QACtB,WAAW,EAAE,OAAO,EAAE,CAAC;QACvB,aAAa,CAAC,EAAE,OAAO,CAAC;KACxB,KAAG,QAAQ,yBAAyB,EAAE,CAAC,CA8BtC;IAGK,aAAa,WAAkB;QACrC,aAAa,EAAE,UAAU,CAAC;QAC1B,QAAQ,EAAE,QAAQ,CAAC;KAEnB,KAAG,QAAQ,UAAU,EAAE,CAAC,CAiCvB;IAMF,OAAO,CAAC,MAAM,CAAC,gBAAgB,CA+E7B;CACF"}
@@ -107,31 +107,39 @@ CoinApi.coinWithAmountTx = (inputs) => {
107
107
  const coinObjectIds = coinData.map((data) => data.coinObjectId);
108
108
  const mergedCoinObjectId = coinObjectIds[0];
109
109
  if (coinObjectIds.length > 1) {
110
- // tx.mergeCoins(tx.object(mergedCoinObjectId), [
111
- // ...coinObjectIds.slice(1).map((coinId) => tx.object(coinId)),
112
- // ]);
113
110
  // TODO: fix this (v1)
114
- tx.add({
115
- $kind: "MergeCoins",
116
- MergeCoins: {
117
- destination: tx.object(mergedCoinObjectId),
118
- sources: [
119
- ...coinObjectIds
120
- .slice(1)
121
- .map((coinId) => tx.object(coinId)),
122
- ],
123
- },
124
- });
111
+ if (isSponsoredTx) {
112
+ tx.add({
113
+ $kind: "MergeCoins",
114
+ MergeCoins: {
115
+ destination: tx.object(mergedCoinObjectId),
116
+ sources: [
117
+ ...coinObjectIds
118
+ .slice(1)
119
+ .map((coinId) => tx.object(coinId)),
120
+ ],
121
+ },
122
+ });
123
+ }
124
+ else {
125
+ tx.mergeCoins(tx.object(mergedCoinObjectId), [
126
+ ...coinObjectIds
127
+ .slice(1)
128
+ .map((coinId) => tx.object(coinId)),
129
+ ]);
130
+ }
125
131
  }
126
132
  // return tx.add({
127
133
  // kind: "SplitCoins",
128
134
  // coin: tx.object(mergedCoinObjectId),
129
135
  // amounts: [tx.pure(coinAmount)],
130
136
  // });
131
- return transactionsApiHelpers_1.TransactionsApiHelpers.splitCoinTx({
132
- tx,
133
- coinId: mergedCoinObjectId,
134
- amount: coinAmount,
135
- coinType,
136
- });
137
+ return isSponsoredTx
138
+ ? transactionsApiHelpers_1.TransactionsApiHelpers.splitCoinTx({
139
+ tx,
140
+ coinId: mergedCoinObjectId,
141
+ amount: coinAmount,
142
+ coinType,
143
+ })
144
+ : tx.splitCoins(mergedCoinObjectId, [coinAmount]);
137
145
  };