@adelos/sdk 0.1.13 → 0.1.15

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.mts CHANGED
@@ -177,7 +177,7 @@ declare class AdelosSDK {
177
177
  * @param destination - Where to send the funds (can be ANY address)
178
178
  * @param amountLamports - Amount to withdraw in lamports (use BigInt)
179
179
  */
180
- createWithdrawTransaction(stealthSecretKey: Uint8Array, stealthAddress: PublicKey, destination: PublicKey, amountLamports: bigint): Promise<{
180
+ createWithdrawTransaction(stealthSecretKey: Uint8Array, stealthAddress: PublicKey, destination: PublicKey, amountLamports?: bigint): Promise<{
181
181
  transaction: VersionedTransaction;
182
182
  signature: string;
183
183
  }>;
package/dist/index.d.ts CHANGED
@@ -177,7 +177,7 @@ declare class AdelosSDK {
177
177
  * @param destination - Where to send the funds (can be ANY address)
178
178
  * @param amountLamports - Amount to withdraw in lamports (use BigInt)
179
179
  */
180
- createWithdrawTransaction(stealthSecretKey: Uint8Array, stealthAddress: PublicKey, destination: PublicKey, amountLamports: bigint): Promise<{
180
+ createWithdrawTransaction(stealthSecretKey: Uint8Array, stealthAddress: PublicKey, destination: PublicKey, amountLamports?: bigint): Promise<{
181
181
  transaction: VersionedTransaction;
182
182
  signature: string;
183
183
  }>;
package/dist/index.js CHANGED
@@ -166,7 +166,7 @@ function recoverStealthSecretKey(metaSk, sharedSecret) {
166
166
  const metaScalar = toScalar(metaSk);
167
167
  const stealthScalar = ed.etc.mod(metaScalar + scalar, ed.CURVE.n);
168
168
  const hex = stealthScalar.toString(16).padStart(64, "0");
169
- return hexToBytes(hex);
169
+ return hexToBytes(hex).reverse();
170
170
  }
171
171
  function generateStealthMemo(ephemeralPubkey) {
172
172
  return `${ADELOS_CONFIG.MEMO_PREFIX}${bytesToHex(ephemeralPubkey)}`;
@@ -421,10 +421,19 @@ var AdelosSDK = class {
421
421
  * @param amountLamports - Amount to withdraw in lamports (use BigInt)
422
422
  */
423
423
  async createWithdrawTransaction(stealthSecretKey, stealthAddress, destination, amountLamports) {
424
+ let finalAmount = amountLamports;
425
+ if (finalAmount === void 0) {
426
+ const balance = await this.connection.getBalance(stealthAddress);
427
+ const FEE_BUFFER = 5e3;
428
+ if (balance <= FEE_BUFFER) {
429
+ throw new Error(`Insufficient funds (Balance: ${balance}, Fee: ${FEE_BUFFER})`);
430
+ }
431
+ finalAmount = BigInt(balance - FEE_BUFFER);
432
+ }
424
433
  const ix = import_web33.SystemProgram.transfer({
425
434
  fromPubkey: stealthAddress,
426
435
  toPubkey: destination,
427
- lamports: amountLamports
436
+ lamports: finalAmount
428
437
  });
429
438
  const { blockhash } = await this.connection.getLatestBlockhash();
430
439
  const message = new import_web33.TransactionMessage({
package/dist/index.mjs CHANGED
@@ -116,7 +116,7 @@ function recoverStealthSecretKey(metaSk, sharedSecret) {
116
116
  const metaScalar = toScalar(metaSk);
117
117
  const stealthScalar = ed.etc.mod(metaScalar + scalar, ed.CURVE.n);
118
118
  const hex = stealthScalar.toString(16).padStart(64, "0");
119
- return hexToBytes(hex);
119
+ return hexToBytes(hex).reverse();
120
120
  }
121
121
  function generateStealthMemo(ephemeralPubkey) {
122
122
  return `${ADELOS_CONFIG.MEMO_PREFIX}${bytesToHex(ephemeralPubkey)}`;
@@ -371,10 +371,19 @@ var AdelosSDK = class {
371
371
  * @param amountLamports - Amount to withdraw in lamports (use BigInt)
372
372
  */
373
373
  async createWithdrawTransaction(stealthSecretKey, stealthAddress, destination, amountLamports) {
374
+ let finalAmount = amountLamports;
375
+ if (finalAmount === void 0) {
376
+ const balance = await this.connection.getBalance(stealthAddress);
377
+ const FEE_BUFFER = 5e3;
378
+ if (balance <= FEE_BUFFER) {
379
+ throw new Error(`Insufficient funds (Balance: ${balance}, Fee: ${FEE_BUFFER})`);
380
+ }
381
+ finalAmount = BigInt(balance - FEE_BUFFER);
382
+ }
374
383
  const ix = SystemProgram.transfer({
375
384
  fromPubkey: stealthAddress,
376
385
  toPubkey: destination,
377
- lamports: amountLamports
386
+ lamports: finalAmount
378
387
  });
379
388
  const { blockhash } = await this.connection.getLatestBlockhash();
380
389
  const message = new TransactionMessage({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adelos/sdk",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Adelos Protocol SDK - Privacy Stealth Transfers on Solana",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",