@bolt-liquidity-hq/sui-client 0.2.0 → 0.3.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.
package/dist/index.d.cts CHANGED
@@ -307,7 +307,7 @@ declare class RouterClient {
307
307
  * for querying and executing transactions on Bolt Protocol's oracle and router smart contracts.
308
308
  * It uses SuiTransactionResponse as the transaction output type, providing detailed transaction execution information.
309
309
  *
310
- * @extends {BaseClient<Signer, SuiTransactionResponse>}
310
+ * @extends {BaseClient<Signer | WalletSigner, SuiTransactionResponse>}
311
311
  *
312
312
  * @group Bolt API Clients
313
313
  *
@@ -328,7 +328,7 @@ declare class RouterClient {
328
328
  * }, signer);
329
329
  * ```
330
330
  */
331
- declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionResponse> {
331
+ declare class BoltSuiClient extends BaseClient<Signer | WalletSigner, SuiTransactionResponse> {
332
332
  /**
333
333
  * The Sui-specific chain configuration including RPC endpoint
334
334
  */
@@ -341,10 +341,6 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionResponse> {
341
341
  * Object Id for the GlobalConfig of the deployed Pool contracts
342
342
  */
343
343
  poolGlobalConfigId: string;
344
- /**
345
- * Cached instance of the Signer for transaction execution
346
- */
347
- signer?: Signer | WalletSigner;
348
344
  /**
349
345
  * Instance of the Sui client to interact with the blockchain.
350
346
  */
@@ -434,30 +430,6 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionResponse> {
434
430
  * ```
435
431
  */
436
432
  constructor(config?: SuiClientConfig);
437
- /**
438
- * Gets or sets the signer for transaction execution.
439
- *
440
- * This method manages the signer instance used for signing transactions.
441
- * A signer must be provided either when creating the client, on first call,
442
- * or to replace the existing signer.
443
- *
444
- * @param newSigner - Optional new signer to replace the existing one
445
- *
446
- * @returns The current signer instance
447
- *
448
- * @throws {MissingParameterError} Thrown when no signer is available and none is provided
449
- *
450
- * @example
451
- * ```typescript
452
- * // Get the current signer (throws if none exists)
453
- * const currentSigner = client.getSigner();
454
- *
455
- * // Set a new signer
456
- * const newSigner = // ... obtain signer from wallet
457
- * const signer = client.getSigner(newSigner);
458
- * ```
459
- */
460
- getSigner(newSigner?: Signer | WalletSigner): Signer | WalletSigner;
461
433
  /** @inheritdoc */
462
434
  getOracleConfig(): Promise<OracleConfig>;
463
435
  /** @inheritdoc */
package/dist/index.d.ts CHANGED
@@ -307,7 +307,7 @@ declare class RouterClient {
307
307
  * for querying and executing transactions on Bolt Protocol's oracle and router smart contracts.
308
308
  * It uses SuiTransactionResponse as the transaction output type, providing detailed transaction execution information.
309
309
  *
310
- * @extends {BaseClient<Signer, SuiTransactionResponse>}
310
+ * @extends {BaseClient<Signer | WalletSigner, SuiTransactionResponse>}
311
311
  *
312
312
  * @group Bolt API Clients
313
313
  *
@@ -328,7 +328,7 @@ declare class RouterClient {
328
328
  * }, signer);
329
329
  * ```
330
330
  */
331
- declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionResponse> {
331
+ declare class BoltSuiClient extends BaseClient<Signer | WalletSigner, SuiTransactionResponse> {
332
332
  /**
333
333
  * The Sui-specific chain configuration including RPC endpoint
334
334
  */
@@ -341,10 +341,6 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionResponse> {
341
341
  * Object Id for the GlobalConfig of the deployed Pool contracts
342
342
  */
343
343
  poolGlobalConfigId: string;
344
- /**
345
- * Cached instance of the Signer for transaction execution
346
- */
347
- signer?: Signer | WalletSigner;
348
344
  /**
349
345
  * Instance of the Sui client to interact with the blockchain.
350
346
  */
@@ -434,30 +430,6 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionResponse> {
434
430
  * ```
435
431
  */
436
432
  constructor(config?: SuiClientConfig);
437
- /**
438
- * Gets or sets the signer for transaction execution.
439
- *
440
- * This method manages the signer instance used for signing transactions.
441
- * A signer must be provided either when creating the client, on first call,
442
- * or to replace the existing signer.
443
- *
444
- * @param newSigner - Optional new signer to replace the existing one
445
- *
446
- * @returns The current signer instance
447
- *
448
- * @throws {MissingParameterError} Thrown when no signer is available and none is provided
449
- *
450
- * @example
451
- * ```typescript
452
- * // Get the current signer (throws if none exists)
453
- * const currentSigner = client.getSigner();
454
- *
455
- * // Set a new signer
456
- * const newSigner = // ... obtain signer from wallet
457
- * const signer = client.getSigner(newSigner);
458
- * ```
459
- */
460
- getSigner(newSigner?: Signer | WalletSigner): Signer | WalletSigner;
461
433
  /** @inheritdoc */
462
434
  getOracleConfig(): Promise<OracleConfig>;
463
435
  /** @inheritdoc */
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
 
5
5
  // src/lib/client.ts
6
- import { BaseClient, MissingParameterError as MissingParameterError2 } from "@bolt-liquidity-hq/core";
6
+ import { BaseClient } from "@bolt-liquidity-hq/core";
7
7
  import { SuiGrpcClient } from "@mysten/sui/grpc";
8
8
  import { normalizeStructTag as normalizeStructTag7 } from "@mysten/sui/utils";
9
9
  import axios from "axios";
@@ -670,6 +670,7 @@ var queryDevInspect = async (suiClient, target, args, typeArguments, senderAddre
670
670
  import {
671
671
  DEFAULT_GAS_ADJUSTMENT,
672
672
  NotFoundError,
673
+ toAmount,
673
674
  TransactionFailedError as TransactionFailedError2,
674
675
  UnexpectedError as UnexpectedError2
675
676
  } from "@bolt-liquidity-hq/core";
@@ -685,6 +686,8 @@ var TX_INCLUDE = {
685
686
  var unwrapTransaction = (result) => result.$kind === "Transaction" ? result.Transaction : result.FailedTransaction;
686
687
  var buildSwapTxArgs = async (client, swapParams, signer) => {
687
688
  const { assetIn, amountIn, assetOut, minimumAmountOut, receiver, swapType = "buy" } = swapParams;
689
+ const amount = toAmount(amountIn, "amountIn");
690
+ const minimumAmount = minimumAmountOut ? toAmount(minimumAmountOut, "minimumAmountOut") : void 0;
688
691
  const pool = client.routerClient.getPool(assetIn, assetOut, swapType);
689
692
  if (!pool) {
690
693
  throw new NotFoundError(`Pool for the pair ${assetIn}/${assetOut}`);
@@ -704,8 +707,8 @@ var buildSwapTxArgs = async (client, swapParams, signer) => {
704
707
  client.contracts.oracle,
705
708
  SUI_CLOCK_OBJECT_ID,
706
709
  coinInput,
707
- bcs2.u64().serialize(amountIn),
708
- bcs2.option(bcs2.u64()).serialize(minimumAmountOut),
710
+ bcs2.u64().serialize(amount),
711
+ bcs2.option(bcs2.u64()).serialize(minimumAmount),
709
712
  bcs2.option(bcs2.string()).serialize(receiver)
710
713
  ],
711
714
  typeArguments: [pool.isInverse ? assetIn : assetOut, pool.isInverse ? assetOut : assetIn],
@@ -1288,10 +1291,11 @@ var RouterClient = class {
1288
1291
  };
1289
1292
 
1290
1293
  // src/lib/router/simulate-swap.ts
1291
- import { NotFoundError as NotFoundError7 } from "@bolt-liquidity-hq/core";
1294
+ import { NotFoundError as NotFoundError7, toAmount as toAmount2 } from "@bolt-liquidity-hq/core";
1292
1295
  import { bcs as bcs7 } from "@mysten/bcs";
1293
1296
  import { SUI_CLOCK_OBJECT_ID as SUI_CLOCK_OBJECT_ID2 } from "@mysten/sui/utils";
1294
1297
  var simulateSwap = async (client, { assetIn, amountIn, assetOut, swapType }) => {
1298
+ const amount = toAmount2(amountIn, "amountIn");
1295
1299
  const pool = client.routerClient.getPool(assetIn, assetOut, swapType);
1296
1300
  if (!pool) {
1297
1301
  throw new NotFoundError7("Pool", `Didn't find a pool to swap ${assetIn} for ${assetOut}`);
@@ -1300,7 +1304,7 @@ var simulateSwap = async (client, { assetIn, amountIn, assetOut, swapType }) =>
1300
1304
  const response = await queryDevInspect(
1301
1305
  client.suiClient,
1302
1306
  [client.packageId, POOL_MODULE, FUNCTION_NAME],
1303
- [pool.poolAddress, client.contracts.oracle, SUI_CLOCK_OBJECT_ID2, bcs7.u64().serialize(amountIn)],
1307
+ [pool.poolAddress, client.contracts.oracle, SUI_CLOCK_OBJECT_ID2, bcs7.u64().serialize(amount)],
1304
1308
  [pool.isInverse ? assetIn : assetOut, pool.isInverse ? assetOut : assetIn]
1305
1309
  );
1306
1310
  const output = parseDevInspectResult(response, SwapSimulationResultStruct);
@@ -1451,10 +1455,6 @@ var BoltSuiClient = class extends BaseClient {
1451
1455
  * Object Id for the GlobalConfig of the deployed Pool contracts
1452
1456
  */
1453
1457
  __publicField(this, "poolGlobalConfigId");
1454
- /**
1455
- * Cached instance of the Signer for transaction execution
1456
- */
1457
- __publicField(this, "signer");
1458
1458
  /**
1459
1459
  * Instance of the Sui client to interact with the blockchain.
1460
1460
  */
@@ -1481,36 +1481,6 @@ var BoltSuiClient = class extends BaseClient {
1481
1481
  this.routerClient = new RouterClient(pools);
1482
1482
  this.configFileUrl = isEnvironmentMainnet ? void 0 : TestnetConfigUrl;
1483
1483
  }
1484
- /**
1485
- * Gets or sets the signer for transaction execution.
1486
- *
1487
- * This method manages the signer instance used for signing transactions.
1488
- * A signer must be provided either when creating the client, on first call,
1489
- * or to replace the existing signer.
1490
- *
1491
- * @param newSigner - Optional new signer to replace the existing one
1492
- *
1493
- * @returns The current signer instance
1494
- *
1495
- * @throws {MissingParameterError} Thrown when no signer is available and none is provided
1496
- *
1497
- * @example
1498
- * ```typescript
1499
- * // Get the current signer (throws if none exists)
1500
- * const currentSigner = client.getSigner();
1501
- *
1502
- * // Set a new signer
1503
- * const newSigner = // ... obtain signer from wallet
1504
- * const signer = client.getSigner(newSigner);
1505
- * ```
1506
- */
1507
- getSigner(newSigner) {
1508
- this.signer = newSigner ?? this.signer;
1509
- if (!this.signer) {
1510
- throw new MissingParameterError2("signer");
1511
- }
1512
- return this.signer;
1513
- }
1514
1484
  // The following methods inherit their documentation from BaseClient
1515
1485
  // Only add documentation here if you need to override or add implementation-specific details
1516
1486
  /** @inheritdoc */