@minswap/noodles-sdk 0.0.10 → 0.0.11

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.cjs CHANGED
@@ -1504,18 +1504,13 @@ var calculation_MoonbagsCalculation;
1504
1504
  var transaction_MoonbagsTransaction;
1505
1505
  const ed25519_namespaceObject = require("@mysten/sui/keypairs/ed25519");
1506
1506
  const CONSTANTS = {
1507
- SUI_DECIMALS: 9,
1508
- GAS_FEE_BUFFER_PERCENTAGE: 0.1,
1509
- MIN_TRANSFER_AMOUNT: 0.000000001
1507
+ GAS_FEE_BUFFER_PERCENTAGE: 0.1
1510
1508
  };
1511
1509
  class DraftTransferTx {
1512
1510
  suiClient;
1513
1511
  constructor(suiClient){
1514
1512
  this.suiClient = suiClient;
1515
1513
  }
1516
- suiToMist(suiAmount) {
1517
- return BigInt(Math.floor(suiAmount * 10 ** CONSTANTS.SUI_DECIMALS));
1518
- }
1519
1514
  validatePrivateKey(privateKey, expectedSender) {
1520
1515
  tiny_invariant_default()(privateKey?.trim(), "Private key is required");
1521
1516
  const keypair = ed25519_namespaceObject.Ed25519Keypair.fromSecretKey(privateKey);
@@ -1523,16 +1518,15 @@ class DraftTransferTx {
1523
1518
  if (derivedAddress !== expectedSender) throw new Error(`Private key mismatch. Expected: ${expectedSender}, Got: ${derivedAddress}`);
1524
1519
  return keypair;
1525
1520
  }
1526
- async createDraft(sender, recipient, suiAmount) {
1521
+ async createDraft(sender, recipient, amountMIST) {
1527
1522
  tiny_invariant_default()(sender?.trim(), "Sender address is required");
1528
1523
  tiny_invariant_default()(recipient?.trim(), "Recipient address is required");
1529
1524
  tiny_invariant_default()(sender !== recipient, "Sender and recipient cannot be the same");
1530
- tiny_invariant_default()(suiAmount > CONSTANTS.MIN_TRANSFER_AMOUNT, `Transfer amount must be greater than ${CONSTANTS.MIN_TRANSFER_AMOUNT} SUI`);
1531
- const suiAmountMist = this.suiToMist(suiAmount);
1525
+ tiny_invariant_default()(amountMIST > 0n, "Transfer amount must be at least 1 MIST");
1532
1526
  try {
1533
1527
  let transaction = new transactions_namespaceObject.Transaction();
1534
1528
  const [coin] = transaction.splitCoins(transaction.gas, [
1535
- suiAmountMist
1529
+ amountMIST
1536
1530
  ]);
1537
1531
  transaction.transferObjects([
1538
1532
  coin
@@ -1545,7 +1539,7 @@ class DraftTransferTx {
1545
1539
  inheritTx: transaction,
1546
1540
  sender,
1547
1541
  feeAmount,
1548
- suiInputAmount: suiAmountMist
1542
+ suiInputAmount: amountMIST
1549
1543
  });
1550
1544
  const txBytes = await transaction.build({
1551
1545
  client: this.suiClient
@@ -1555,7 +1549,7 @@ class DraftTransferTx {
1555
1549
  return {
1556
1550
  sender,
1557
1551
  recipient,
1558
- suiAmount,
1552
+ amountMIST,
1559
1553
  txDraftBase64,
1560
1554
  txDigest
1561
1555
  };
package/dist/index.d.ts CHANGED
@@ -438,7 +438,7 @@ export declare function createCompatibleSuiClient(client: SuiClient): LegacySuiC
438
438
  export declare type DraftTransaction = {
439
439
  readonly sender: string;
440
440
  readonly recipient: string;
441
- readonly suiAmount: number;
441
+ readonly amountMIST: bigint;
442
442
  readonly txDigest: string;
443
443
  readonly txDraftBase64: string;
444
444
  };
@@ -446,11 +446,6 @@ export declare type DraftTransaction = {
446
446
  export declare class DraftTransferTx {
447
447
  private readonly suiClient;
448
448
  constructor(suiClient: SuiClient);
449
- /**
450
- * Converts SUI amount to MIST (smallest unit)
451
- * @private
452
- */
453
- private suiToMist;
454
449
  /**
455
450
  * Validates private key against expected sender address
456
451
  * @private
@@ -462,7 +457,7 @@ export declare class DraftTransferTx {
462
457
  * @returns Draft transaction object with encoded transaction data
463
458
  * @throws {Error} If validation fails or transaction building fails
464
459
  */
465
- createDraft(sender: string, recipient: string, suiAmount: number): Promise<DraftTransaction>;
460
+ createDraft(sender: string, recipient: string, amountMIST: bigint): Promise<DraftTransaction>;
466
461
  /**
467
462
  * Executes a draft transaction on the Sui network
468
463
  * @param draftTx - Draft transaction to execute
package/dist/index.js CHANGED
@@ -1420,18 +1420,13 @@ var calculation_MoonbagsCalculation;
1420
1420
  })(transaction_MoonbagsTransaction || (transaction_MoonbagsTransaction = {}));
1421
1421
  var transaction_MoonbagsTransaction;
1422
1422
  const CONSTANTS = {
1423
- SUI_DECIMALS: 9,
1424
- GAS_FEE_BUFFER_PERCENTAGE: 0.1,
1425
- MIN_TRANSFER_AMOUNT: 0.000000001
1423
+ GAS_FEE_BUFFER_PERCENTAGE: 0.1
1426
1424
  };
1427
1425
  class DraftTransferTx {
1428
1426
  suiClient;
1429
1427
  constructor(suiClient){
1430
1428
  this.suiClient = suiClient;
1431
1429
  }
1432
- suiToMist(suiAmount) {
1433
- return BigInt(Math.floor(suiAmount * 10 ** CONSTANTS.SUI_DECIMALS));
1434
- }
1435
1430
  validatePrivateKey(privateKey, expectedSender) {
1436
1431
  tiny_invariant(privateKey?.trim(), "Private key is required");
1437
1432
  const keypair = Ed25519Keypair.fromSecretKey(privateKey);
@@ -1439,16 +1434,15 @@ class DraftTransferTx {
1439
1434
  if (derivedAddress !== expectedSender) throw new Error(`Private key mismatch. Expected: ${expectedSender}, Got: ${derivedAddress}`);
1440
1435
  return keypair;
1441
1436
  }
1442
- async createDraft(sender, recipient, suiAmount) {
1437
+ async createDraft(sender, recipient, amountMIST) {
1443
1438
  tiny_invariant(sender?.trim(), "Sender address is required");
1444
1439
  tiny_invariant(recipient?.trim(), "Recipient address is required");
1445
1440
  tiny_invariant(sender !== recipient, "Sender and recipient cannot be the same");
1446
- tiny_invariant(suiAmount > CONSTANTS.MIN_TRANSFER_AMOUNT, `Transfer amount must be greater than ${CONSTANTS.MIN_TRANSFER_AMOUNT} SUI`);
1447
- const suiAmountMist = this.suiToMist(suiAmount);
1441
+ tiny_invariant(amountMIST > 0n, "Transfer amount must be at least 1 MIST");
1448
1442
  try {
1449
1443
  let transaction = new Transaction();
1450
1444
  const [coin] = transaction.splitCoins(transaction.gas, [
1451
- suiAmountMist
1445
+ amountMIST
1452
1446
  ]);
1453
1447
  transaction.transferObjects([
1454
1448
  coin
@@ -1461,7 +1455,7 @@ class DraftTransferTx {
1461
1455
  inheritTx: transaction,
1462
1456
  sender,
1463
1457
  feeAmount,
1464
- suiInputAmount: suiAmountMist
1458
+ suiInputAmount: amountMIST
1465
1459
  });
1466
1460
  const txBytes = await transaction.build({
1467
1461
  client: this.suiClient
@@ -1471,7 +1465,7 @@ class DraftTransferTx {
1471
1465
  return {
1472
1466
  sender,
1473
1467
  recipient,
1474
- suiAmount,
1468
+ amountMIST,
1475
1469
  txDraftBase64,
1476
1470
  txDigest
1477
1471
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minswap/noodles-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -53,6 +53,7 @@
53
53
  "build": "rslib build",
54
54
  "lint": "biome check --write",
55
55
  "dev": "rslib build --watch",
56
- "format": "biome format --write"
56
+ "format": "biome check --write",
57
+ "typecheck": "tsc --noEmit"
57
58
  }
58
59
  }