@sudobility/contracts 1.13.1 → 1.13.2

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 (198) hide show
  1. package/dist/evm/src/evm/evm-mailer-client.js +3 -3
  2. package/dist/evm/src/evm/evm-mailer-client.js.map +1 -1
  3. package/dist/evm/src/evm/index.d.ts +3 -3
  4. package/dist/evm/src/evm/index.d.ts.map +1 -1
  5. package/dist/evm/src/evm/index.js +4 -4
  6. package/dist/evm/src/evm/index.js.map +1 -1
  7. package/dist/solana/solana/index.d.ts +2 -2
  8. package/dist/solana/solana/index.d.ts.map +1 -1
  9. package/dist/solana/solana/index.js +3 -3
  10. package/dist/solana/solana/index.js.map +1 -1
  11. package/dist/solana/solana/solana-mailer-client.d.ts +1 -1
  12. package/dist/solana/solana/solana-mailer-client.d.ts.map +1 -1
  13. package/dist/solana/solana/solana-mailer-client.js +1 -1
  14. package/dist/solana/solana/solana-mailer-client.js.map +1 -1
  15. package/dist/solana/solana/types.d.ts +1 -1
  16. package/dist/solana/solana/types.d.ts.map +1 -1
  17. package/dist/solana/solana/types.js +5 -5
  18. package/dist/solana/solana/types.js.map +1 -1
  19. package/dist/unified/src/evm/evm-mailer-client.js +7 -11
  20. package/dist/unified/src/evm/evm-mailer-client.js.map +1 -1
  21. package/dist/unified/src/evm/index.d.ts +3 -3
  22. package/dist/unified/src/evm/index.d.ts.map +1 -1
  23. package/dist/unified/src/evm/index.js +2 -7
  24. package/dist/unified/src/evm/index.js.map +1 -1
  25. package/dist/unified/src/react/context/MailerProvider.js +14 -55
  26. package/dist/unified/src/react/context/MailerProvider.js.map +1 -1
  27. package/dist/unified/src/react/hooks/useMailerMutations.js +76 -98
  28. package/dist/unified/src/react/hooks/useMailerMutations.js.map +1 -1
  29. package/dist/unified/src/react/hooks/useMailerQueries.js +52 -68
  30. package/dist/unified/src/react/hooks/useMailerQueries.js.map +1 -1
  31. package/dist/unified/src/react/index.js +5 -47
  32. package/dist/unified/src/react/index.js.map +1 -1
  33. package/dist/unified/src/solana/index.d.ts +2 -2
  34. package/dist/unified/src/solana/index.d.ts.map +1 -1
  35. package/dist/unified/src/solana/index.js +2 -20
  36. package/dist/unified/src/solana/index.js.map +1 -1
  37. package/dist/unified/src/solana/solana-mailer-client.d.ts +1 -1
  38. package/dist/unified/src/solana/solana-mailer-client.d.ts.map +1 -1
  39. package/dist/unified/src/solana/solana-mailer-client.js +129 -133
  40. package/dist/unified/src/solana/solana-mailer-client.js.map +1 -1
  41. package/dist/unified/src/solana/types.d.ts +1 -1
  42. package/dist/unified/src/solana/types.d.ts.map +1 -1
  43. package/dist/unified/src/solana/types.js +6 -13
  44. package/dist/unified/src/solana/types.js.map +1 -1
  45. package/dist/unified/src/unified/index.d.ts +3 -3
  46. package/dist/unified/src/unified/index.d.ts.map +1 -1
  47. package/dist/unified/src/unified/index.js +2 -7
  48. package/dist/unified/src/unified/index.js.map +1 -1
  49. package/dist/unified/src/unified/onchain-mailer-client.d.ts +3 -3
  50. package/dist/unified/src/unified/onchain-mailer-client.d.ts.map +1 -1
  51. package/dist/unified/src/unified/onchain-mailer-client.js +88 -125
  52. package/dist/unified/src/unified/onchain-mailer-client.js.map +1 -1
  53. package/dist/unified/src/unified/types.js +1 -2
  54. package/dist/unified/src/unified/wallet-detector.js +10 -14
  55. package/dist/unified/src/unified/wallet-detector.js.map +1 -1
  56. package/dist/unified/src/utils/chain-config.d.ts +1 -1
  57. package/dist/unified/src/utils/chain-config.d.ts.map +1 -1
  58. package/dist/unified/src/utils/chain-config.js +9 -13
  59. package/dist/unified/src/utils/chain-config.js.map +1 -1
  60. package/dist/unified/src/utils/currency.js +6 -11
  61. package/dist/unified/src/utils/currency.js.map +1 -1
  62. package/dist/unified/src/utils/index.d.ts +3 -3
  63. package/dist/unified/src/utils/index.d.ts.map +1 -1
  64. package/dist/unified/src/utils/index.js +3 -19
  65. package/dist/unified/src/utils/index.js.map +1 -1
  66. package/dist/unified/src/utils/validation.js +11 -17
  67. package/dist/unified/src/utils/validation.js.map +1 -1
  68. package/dist/unified/typechain-types/Mailer.js +1 -2
  69. package/dist/unified/typechain-types/MockUSDC.js +1 -2
  70. package/dist/unified/typechain-types/common.js +1 -2
  71. package/dist/unified/typechain-types/factories/Mailer__factory.js +4 -8
  72. package/dist/unified/typechain-types/factories/Mailer__factory.js.map +1 -1
  73. package/dist/unified/typechain-types/factories/MockUSDC__factory.js +4 -8
  74. package/dist/unified/typechain-types/factories/MockUSDC__factory.js.map +1 -1
  75. package/dist/unified/typechain-types/factories/index.js +3 -41
  76. package/dist/unified/typechain-types/factories/index.js.map +1 -1
  77. package/dist/unified/typechain-types/factories/interfaces/IERC20__factory.js +4 -8
  78. package/dist/unified/typechain-types/factories/interfaces/IERC20__factory.js.map +1 -1
  79. package/dist/unified/typechain-types/factories/interfaces/index.js +1 -5
  80. package/dist/unified/typechain-types/factories/interfaces/index.js.map +1 -1
  81. package/dist/unified/typechain-types/index.js +4 -43
  82. package/dist/unified/typechain-types/index.js.map +1 -1
  83. package/dist/unified/typechain-types/interfaces/IERC20.js +1 -2
  84. package/dist/unified/typechain-types/interfaces/index.js +1 -2
  85. package/package.json +12 -18
  86. package/dist/unified/package.json +0 -3
  87. package/dist/unified-esm/src/evm/evm-mailer-client.d.ts +0 -1062
  88. package/dist/unified-esm/src/evm/evm-mailer-client.d.ts.map +0 -1
  89. package/dist/unified-esm/src/evm/evm-mailer-client.js +0 -920
  90. package/dist/unified-esm/src/evm/evm-mailer-client.js.map +0 -1
  91. package/dist/unified-esm/src/evm/index.d.ts +0 -4
  92. package/dist/unified-esm/src/evm/index.d.ts.map +0 -1
  93. package/dist/unified-esm/src/evm/index.js +0 -5
  94. package/dist/unified-esm/src/evm/index.js.map +0 -1
  95. package/dist/unified-esm/src/react/context/MailerProvider.d.ts +0 -108
  96. package/dist/unified-esm/src/react/context/MailerProvider.d.ts.map +0 -1
  97. package/dist/unified-esm/src/react/context/MailerProvider.js +0 -119
  98. package/dist/unified-esm/src/react/context/MailerProvider.js.map +0 -1
  99. package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts +0 -334
  100. package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts.map +0 -1
  101. package/dist/unified-esm/src/react/hooks/useMailerMutations.js +0 -392
  102. package/dist/unified-esm/src/react/hooks/useMailerMutations.js.map +0 -1
  103. package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts +0 -184
  104. package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts.map +0 -1
  105. package/dist/unified-esm/src/react/hooks/useMailerQueries.js +0 -316
  106. package/dist/unified-esm/src/react/hooks/useMailerQueries.js.map +0 -1
  107. package/dist/unified-esm/src/react/index.d.ts +0 -39
  108. package/dist/unified-esm/src/react/index.d.ts.map +0 -1
  109. package/dist/unified-esm/src/react/index.js +0 -43
  110. package/dist/unified-esm/src/react/index.js.map +0 -1
  111. package/dist/unified-esm/src/solana/index.d.ts +0 -3
  112. package/dist/unified-esm/src/solana/index.d.ts.map +0 -1
  113. package/dist/unified-esm/src/solana/index.js +0 -4
  114. package/dist/unified-esm/src/solana/index.js.map +0 -1
  115. package/dist/unified-esm/src/solana/solana-mailer-client.d.ts +0 -209
  116. package/dist/unified-esm/src/solana/solana-mailer-client.d.ts.map +0 -1
  117. package/dist/unified-esm/src/solana/solana-mailer-client.js +0 -1000
  118. package/dist/unified-esm/src/solana/solana-mailer-client.js.map +0 -1
  119. package/dist/unified-esm/src/solana/types.d.ts +0 -29
  120. package/dist/unified-esm/src/solana/types.d.ts.map +0 -1
  121. package/dist/unified-esm/src/solana/types.js +0 -16
  122. package/dist/unified-esm/src/solana/types.js.map +0 -1
  123. package/dist/unified-esm/src/unified/index.d.ts +0 -4
  124. package/dist/unified-esm/src/unified/index.d.ts.map +0 -1
  125. package/dist/unified-esm/src/unified/index.js +0 -4
  126. package/dist/unified-esm/src/unified/index.js.map +0 -1
  127. package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts +0 -258
  128. package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts.map +0 -1
  129. package/dist/unified-esm/src/unified/onchain-mailer-client.js +0 -731
  130. package/dist/unified-esm/src/unified/onchain-mailer-client.js.map +0 -1
  131. package/dist/unified-esm/src/unified/types.d.ts +0 -54
  132. package/dist/unified-esm/src/unified/types.d.ts.map +0 -1
  133. package/dist/unified-esm/src/unified/types.js +0 -2
  134. package/dist/unified-esm/src/unified/types.js.map +0 -1
  135. package/dist/unified-esm/src/unified/wallet-detector.d.ts +0 -28
  136. package/dist/unified-esm/src/unified/wallet-detector.d.ts.map +0 -1
  137. package/dist/unified-esm/src/unified/wallet-detector.js +0 -59
  138. package/dist/unified-esm/src/unified/wallet-detector.js.map +0 -1
  139. package/dist/unified-esm/src/utils/chain-config.d.ts +0 -75
  140. package/dist/unified-esm/src/utils/chain-config.d.ts.map +0 -1
  141. package/dist/unified-esm/src/utils/chain-config.js +0 -199
  142. package/dist/unified-esm/src/utils/chain-config.js.map +0 -1
  143. package/dist/unified-esm/src/utils/currency.d.ts +0 -26
  144. package/dist/unified-esm/src/utils/currency.d.ts.map +0 -1
  145. package/dist/unified-esm/src/utils/currency.js +0 -31
  146. package/dist/unified-esm/src/utils/currency.js.map +0 -1
  147. package/dist/unified-esm/src/utils/index.d.ts +0 -4
  148. package/dist/unified-esm/src/utils/index.d.ts.map +0 -1
  149. package/dist/unified-esm/src/utils/index.js +0 -4
  150. package/dist/unified-esm/src/utils/index.js.map +0 -1
  151. package/dist/unified-esm/src/utils/validation.d.ts +0 -10
  152. package/dist/unified-esm/src/utils/validation.d.ts.map +0 -1
  153. package/dist/unified-esm/src/utils/validation.js +0 -96
  154. package/dist/unified-esm/src/utils/validation.js.map +0 -1
  155. package/dist/unified-esm/typechain-types/Mailer.d.ts +0 -698
  156. package/dist/unified-esm/typechain-types/Mailer.d.ts.map +0 -1
  157. package/dist/unified-esm/typechain-types/Mailer.js +0 -2
  158. package/dist/unified-esm/typechain-types/Mailer.js.map +0 -1
  159. package/dist/unified-esm/typechain-types/MockUSDC.d.ts +0 -118
  160. package/dist/unified-esm/typechain-types/MockUSDC.d.ts.map +0 -1
  161. package/dist/unified-esm/typechain-types/MockUSDC.js +0 -2
  162. package/dist/unified-esm/typechain-types/MockUSDC.js.map +0 -1
  163. package/dist/unified-esm/typechain-types/common.d.ts +0 -51
  164. package/dist/unified-esm/typechain-types/common.d.ts.map +0 -1
  165. package/dist/unified-esm/typechain-types/common.js +0 -2
  166. package/dist/unified-esm/typechain-types/common.js.map +0 -1
  167. package/dist/unified-esm/typechain-types/factories/Mailer__factory.d.ts +0 -875
  168. package/dist/unified-esm/typechain-types/factories/Mailer__factory.d.ts.map +0 -1
  169. package/dist/unified-esm/typechain-types/factories/Mailer__factory.js +0 -1121
  170. package/dist/unified-esm/typechain-types/factories/Mailer__factory.js.map +0 -1
  171. package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.d.ts +0 -193
  172. package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.d.ts.map +0 -1
  173. package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.js +0 -259
  174. package/dist/unified-esm/typechain-types/factories/MockUSDC__factory.js.map +0 -1
  175. package/dist/unified-esm/typechain-types/factories/index.d.ts +0 -4
  176. package/dist/unified-esm/typechain-types/factories/index.d.ts.map +0 -1
  177. package/dist/unified-esm/typechain-types/factories/index.js +0 -7
  178. package/dist/unified-esm/typechain-types/factories/index.js.map +0 -1
  179. package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.d.ts +0 -80
  180. package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.d.ts.map +0 -1
  181. package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.js +0 -112
  182. package/dist/unified-esm/typechain-types/factories/interfaces/IERC20__factory.js.map +0 -1
  183. package/dist/unified-esm/typechain-types/factories/interfaces/index.d.ts +0 -2
  184. package/dist/unified-esm/typechain-types/factories/interfaces/index.d.ts.map +0 -1
  185. package/dist/unified-esm/typechain-types/factories/interfaces/index.js +0 -5
  186. package/dist/unified-esm/typechain-types/factories/interfaces/index.js.map +0 -1
  187. package/dist/unified-esm/typechain-types/index.d.ts +0 -10
  188. package/dist/unified-esm/typechain-types/index.d.ts.map +0 -1
  189. package/dist/unified-esm/typechain-types/index.js +0 -5
  190. package/dist/unified-esm/typechain-types/index.js.map +0 -1
  191. package/dist/unified-esm/typechain-types/interfaces/IERC20.d.ts +0 -70
  192. package/dist/unified-esm/typechain-types/interfaces/IERC20.d.ts.map +0 -1
  193. package/dist/unified-esm/typechain-types/interfaces/IERC20.js +0 -2
  194. package/dist/unified-esm/typechain-types/interfaces/IERC20.js.map +0 -1
  195. package/dist/unified-esm/typechain-types/interfaces/index.d.ts +0 -2
  196. package/dist/unified-esm/typechain-types/interfaces/index.d.ts.map +0 -1
  197. package/dist/unified-esm/typechain-types/interfaces/index.js +0 -2
  198. package/dist/unified-esm/typechain-types/interfaces/index.js.map +0 -1
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaMailerClient = void 0;
4
- const web3_js_1 = require("@solana/web3.js");
5
- const spl_token_1 = require("@solana/spl-token");
1
+ import { Connection, PublicKey, Transaction, TransactionInstruction, SystemProgram, ComputeBudgetProgram, } from '@solana/web3.js';
2
+ import { TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, createAssociatedTokenAccountInstruction, } from '@solana/spl-token';
6
3
  /**
7
4
  * Native Solana Program instruction types
8
5
  */
@@ -206,7 +203,7 @@ function encodeDistributeClaimableFunds(recipients) {
206
203
  * All methods take wallet and chainInfo as parameters.
207
204
  * No state is stored in the instance.
208
205
  */
209
- class SolanaMailerClient {
206
+ export class SolanaMailerClient {
210
207
  constructor() {
211
208
  this.defaultComputeUnitMultiplier = 1.2; // 20% buffer by default
212
209
  // Default compute unit limits for common operations
@@ -248,11 +245,11 @@ class SolanaMailerClient {
248
245
  }
249
246
  else {
250
247
  // Default Solana endpoints
251
- rpcUrl = chainInfo.isDev
248
+ rpcUrl = chainInfo.isTestNet
252
249
  ? 'https://api.devnet.solana.com'
253
250
  : 'https://api.mainnet-beta.solana.com';
254
251
  }
255
- return new web3_js_1.Connection(rpcUrl, 'confirmed');
252
+ return new Connection(rpcUrl, 'confirmed');
256
253
  }
257
254
  /**
258
255
  * Get program and state PDAs from chainInfo
@@ -261,8 +258,8 @@ class SolanaMailerClient {
261
258
  if (!chainInfo.mailerAddress) {
262
259
  throw new Error(`No mailer program deployed on ${chainInfo.name}`);
263
260
  }
264
- const programId = new web3_js_1.PublicKey(chainInfo.mailerAddress);
265
- const [mailerPda, bump] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('mailer')], programId);
261
+ const programId = new PublicKey(chainInfo.mailerAddress);
262
+ const [mailerPda, bump] = PublicKey.findProgramAddressSync([Buffer.from('mailer')], programId);
266
263
  return {
267
264
  programId,
268
265
  mailerStatePda: mailerPda,
@@ -286,8 +283,8 @@ class SolanaMailerClient {
286
283
  while (retryCount <= maxRetries) {
287
284
  try {
288
285
  // Set a high limit for simulation
289
- const simTransaction = new web3_js_1.Transaction().add(...transaction.instructions);
290
- simTransaction.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
286
+ const simTransaction = new Transaction().add(...transaction.instructions);
287
+ simTransaction.add(ComputeBudgetProgram.setComputeUnitLimit({
291
288
  units: 1400000, // Max for simulation
292
289
  }));
293
290
  simTransaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
@@ -324,10 +321,10 @@ class SolanaMailerClient {
324
321
  computeUnitLimit = defaultComputeUnits;
325
322
  }
326
323
  // Apply compute budget instructions
327
- const optimizedTx = new web3_js_1.Transaction();
324
+ const optimizedTx = new Transaction();
328
325
  // Add compute unit limit if specified
329
326
  if (computeUnitLimit) {
330
- optimizedTx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
327
+ optimizedTx.add(ComputeBudgetProgram.setComputeUnitLimit({
331
328
  units: computeUnitLimit,
332
329
  }));
333
330
  }
@@ -335,7 +332,7 @@ class SolanaMailerClient {
335
332
  const priorityFee = options?.computeUnitPrice ??
336
333
  (options?.autoOptimize ? this.priorityFeeRecommendations.normal : undefined);
337
334
  if (priorityFee) {
338
- optimizedTx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
335
+ optimizedTx.add(ComputeBudgetProgram.setComputeUnitPrice({
339
336
  microLamports: priorityFee,
340
337
  }));
341
338
  }
@@ -381,17 +378,17 @@ class SolanaMailerClient {
381
378
  if (!chainInfo.usdcAddress) {
382
379
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
383
380
  }
384
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
385
- const instruction = new web3_js_1.TransactionInstruction({
381
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
382
+ const instruction = new TransactionInstruction({
386
383
  programId,
387
384
  keys: [
388
385
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
389
386
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
390
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
387
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
391
388
  ],
392
389
  data: encodeInitialize(usdcMint),
393
390
  });
394
- const transaction = new web3_js_1.Transaction().add(instruction);
391
+ const transaction = new Transaction().add(instruction);
395
392
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
396
393
  }
397
394
  /**
@@ -403,12 +400,12 @@ class SolanaMailerClient {
403
400
  if (!chainInfo.usdcAddress) {
404
401
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
405
402
  }
406
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
407
- const toPubkey = typeof to === 'string' ? new web3_js_1.PublicKey(to) : to;
403
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
404
+ const toPubkey = typeof to === 'string' ? new PublicKey(to) : to;
408
405
  // Get token accounts
409
- const senderTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
410
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
411
- const [recipientInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), toPubkey.toBuffer()], programId);
406
+ const senderTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
407
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
408
+ const [recipientInfo] = PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), toPubkey.toBuffer()], programId);
412
409
  const keys = [
413
410
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
414
411
  { pubkey: toPubkey, isSigner: false, isWritable: false },
@@ -416,19 +413,19 @@ class SolanaMailerClient {
416
413
  { pubkey: senderTokenAccount, isSigner: false, isWritable: true },
417
414
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
418
415
  { pubkey: recipientInfo, isSigner: false, isWritable: true },
419
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
420
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
416
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
417
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
421
418
  ];
422
- const instruction = new web3_js_1.TransactionInstruction({
419
+ const instruction = new TransactionInstruction({
423
420
  programId,
424
421
  keys,
425
422
  data: encodeSend(toPubkey, subject, body, revenueShareToReceiver),
426
423
  });
427
- const transaction = new web3_js_1.Transaction().add(instruction);
424
+ const transaction = new Transaction().add(instruction);
428
425
  // Check if mailer token account exists, create if not
429
426
  const accountInfo = await connection.getAccountInfo(mailerTokenAccount);
430
427
  if (!accountInfo) {
431
- transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
428
+ transaction.add(createAssociatedTokenAccountInstruction(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
432
429
  }
433
430
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
434
431
  }
@@ -441,11 +438,11 @@ class SolanaMailerClient {
441
438
  if (!chainInfo.usdcAddress) {
442
439
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
443
440
  }
444
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
445
- const toPubkey = typeof to === 'string' ? new web3_js_1.PublicKey(to) : to;
446
- const senderTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
447
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
448
- const [recipientInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), toPubkey.toBuffer()], programId);
441
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
442
+ const toPubkey = typeof to === 'string' ? new PublicKey(to) : to;
443
+ const senderTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
444
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
445
+ const [recipientInfo] = PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), toPubkey.toBuffer()], programId);
449
446
  const keys = [
450
447
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
451
448
  { pubkey: toPubkey, isSigner: false, isWritable: false },
@@ -453,19 +450,19 @@ class SolanaMailerClient {
453
450
  { pubkey: senderTokenAccount, isSigner: false, isWritable: true },
454
451
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
455
452
  { pubkey: recipientInfo, isSigner: false, isWritable: true },
456
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
457
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
453
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
454
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
458
455
  ];
459
- const instruction = new web3_js_1.TransactionInstruction({
456
+ const instruction = new TransactionInstruction({
460
457
  programId,
461
458
  keys,
462
459
  data: encodeSendPrepared(toPubkey, mailId, revenueShareToReceiver),
463
460
  });
464
- const transaction = new web3_js_1.Transaction().add(instruction);
461
+ const transaction = new Transaction().add(instruction);
465
462
  // Check if mailer token account exists, create if not
466
463
  const accountInfo = await connection.getAccountInfo(mailerTokenAccount);
467
464
  if (!accountInfo) {
468
- transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
465
+ transaction.add(createAssociatedTokenAccountInstruction(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
469
466
  }
470
467
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
471
468
  }
@@ -478,11 +475,11 @@ class SolanaMailerClient {
478
475
  if (!chainInfo.usdcAddress) {
479
476
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
480
477
  }
481
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
482
- const toPubkey = typeof to === 'string' ? new web3_js_1.PublicKey(to) : to;
483
- const senderTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
484
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
485
- const [recipientInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), toPubkey.toBuffer()], programId);
478
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
479
+ const toPubkey = typeof to === 'string' ? new PublicKey(to) : to;
480
+ const senderTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
481
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
482
+ const [recipientInfo] = PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), toPubkey.toBuffer()], programId);
486
483
  const keys = [
487
484
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
488
485
  { pubkey: toPubkey, isSigner: false, isWritable: false },
@@ -490,18 +487,18 @@ class SolanaMailerClient {
490
487
  { pubkey: senderTokenAccount, isSigner: false, isWritable: true },
491
488
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
492
489
  { pubkey: recipientInfo, isSigner: false, isWritable: true },
493
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
494
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
490
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
491
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
495
492
  ];
496
- const instruction = new web3_js_1.TransactionInstruction({
493
+ const instruction = new TransactionInstruction({
497
494
  programId,
498
495
  keys,
499
496
  data: encodeSendThroughWebhook(toPubkey, subject, body, webhookId, revenueShareToReceiver),
500
497
  });
501
- const transaction = new web3_js_1.Transaction().add(instruction);
498
+ const transaction = new Transaction().add(instruction);
502
499
  const accountInfo = await connection.getAccountInfo(mailerTokenAccount);
503
500
  if (!accountInfo) {
504
- transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
501
+ transaction.add(createAssociatedTokenAccountInstruction(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
505
502
  }
506
503
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
507
504
  }
@@ -514,27 +511,27 @@ class SolanaMailerClient {
514
511
  if (!chainInfo.usdcAddress) {
515
512
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
516
513
  }
517
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
518
- const payerPubkey = typeof payer === 'string' ? new web3_js_1.PublicKey(payer) : payer;
519
- const senderTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
520
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
514
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
515
+ const payerPubkey = typeof payer === 'string' ? new PublicKey(payer) : payer;
516
+ const senderTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
517
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
521
518
  const keys = [
522
519
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
523
520
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
524
521
  { pubkey: senderTokenAccount, isSigner: false, isWritable: true },
525
522
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
526
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
527
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
523
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
524
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
528
525
  ];
529
- const instruction = new web3_js_1.TransactionInstruction({
526
+ const instruction = new TransactionInstruction({
530
527
  programId,
531
528
  keys,
532
529
  data: encodeSendToEmail(emailHash, subject, body, payerPubkey, revenueShareToReceiver),
533
530
  });
534
- const transaction = new web3_js_1.Transaction().add(instruction);
531
+ const transaction = new Transaction().add(instruction);
535
532
  const accountInfo = await connection.getAccountInfo(mailerTokenAccount);
536
533
  if (!accountInfo) {
537
- transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
534
+ transaction.add(createAssociatedTokenAccountInstruction(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
538
535
  }
539
536
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
540
537
  }
@@ -547,27 +544,27 @@ class SolanaMailerClient {
547
544
  if (!chainInfo.usdcAddress) {
548
545
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
549
546
  }
550
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
551
- const payerPubkey = typeof payer === 'string' ? new web3_js_1.PublicKey(payer) : payer;
552
- const senderTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
553
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
547
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
548
+ const payerPubkey = typeof payer === 'string' ? new PublicKey(payer) : payer;
549
+ const senderTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
550
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
554
551
  const keys = [
555
552
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
556
553
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
557
554
  { pubkey: senderTokenAccount, isSigner: false, isWritable: true },
558
555
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
559
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
560
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
556
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
557
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
561
558
  ];
562
- const instruction = new web3_js_1.TransactionInstruction({
559
+ const instruction = new TransactionInstruction({
563
560
  programId,
564
561
  keys,
565
562
  data: encodeSendPreparedToEmail(emailHash, mailId, payerPubkey, revenueShareToReceiver),
566
563
  });
567
- const transaction = new web3_js_1.Transaction().add(instruction);
564
+ const transaction = new Transaction().add(instruction);
568
565
  const accountInfo = await connection.getAccountInfo(mailerTokenAccount);
569
566
  if (!accountInfo) {
570
- transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
567
+ transaction.add(createAssociatedTokenAccountInstruction(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
571
568
  }
572
569
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
573
570
  }
@@ -580,24 +577,24 @@ class SolanaMailerClient {
580
577
  if (!chainInfo.usdcAddress) {
581
578
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
582
579
  }
583
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
584
- const recipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
585
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
586
- const [recipientInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), connectedWallet.wallet.publicKey.toBuffer()], programId);
580
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
581
+ const recipientTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
582
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
583
+ const [recipientInfo] = PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), connectedWallet.wallet.publicKey.toBuffer()], programId);
587
584
  const keys = [
588
585
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
589
586
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
590
587
  { pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
591
588
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
592
589
  { pubkey: recipientInfo, isSigner: false, isWritable: true },
593
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
590
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
594
591
  ];
595
- const instruction = new web3_js_1.TransactionInstruction({
592
+ const instruction = new TransactionInstruction({
596
593
  programId,
597
594
  keys,
598
595
  data: Buffer.from([InstructionType.ClaimRecipientShare]),
599
596
  });
600
- const transaction = new web3_js_1.Transaction().add(instruction);
597
+ const transaction = new Transaction().add(instruction);
601
598
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
602
599
  }
603
600
  /**
@@ -609,22 +606,22 @@ class SolanaMailerClient {
609
606
  if (!chainInfo.usdcAddress) {
610
607
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
611
608
  }
612
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
613
- const ownerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
614
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
609
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
610
+ const ownerTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
611
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
615
612
  const keys = [
616
613
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
617
614
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
618
615
  { pubkey: ownerTokenAccount, isSigner: false, isWritable: true },
619
616
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
620
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
617
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
621
618
  ];
622
- const instruction = new web3_js_1.TransactionInstruction({
619
+ const instruction = new TransactionInstruction({
623
620
  programId,
624
621
  keys,
625
622
  data: Buffer.from([InstructionType.ClaimOwnerShare]),
626
623
  });
627
- const transaction = new web3_js_1.Transaction().add(instruction);
624
+ const transaction = new Transaction().add(instruction);
628
625
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
629
626
  }
630
627
  /**
@@ -633,19 +630,19 @@ class SolanaMailerClient {
633
630
  async claimExpiredShares(connectedWallet, chainInfo, recipient, computeOptions) {
634
631
  const connection = await this.getOrCreateConnection(chainInfo, connectedWallet.connection);
635
632
  const { programId, mailerStatePda } = this.getProgramAddresses(chainInfo);
636
- const recipientPubkey = typeof recipient === 'string' ? new web3_js_1.PublicKey(recipient) : recipient;
637
- const [recipientInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), recipientPubkey.toBuffer()], programId);
633
+ const recipientPubkey = typeof recipient === 'string' ? new PublicKey(recipient) : recipient;
634
+ const [recipientInfo] = PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), recipientPubkey.toBuffer()], programId);
638
635
  const keys = [
639
636
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
640
637
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
641
638
  { pubkey: recipientInfo, isSigner: false, isWritable: true },
642
639
  ];
643
- const instruction = new web3_js_1.TransactionInstruction({
640
+ const instruction = new TransactionInstruction({
644
641
  programId,
645
642
  keys,
646
643
  data: encodeClaimExpiredShares(recipientPubkey),
647
644
  });
648
- const transaction = new web3_js_1.Transaction().add(instruction);
645
+ const transaction = new Transaction().add(instruction);
649
646
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
650
647
  }
651
648
  /**
@@ -657,31 +654,31 @@ class SolanaMailerClient {
657
654
  if (!chainInfo.usdcAddress) {
658
655
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
659
656
  }
660
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
657
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
661
658
  const delegatePubkey = delegate
662
- ? (typeof delegate === 'string' ? new web3_js_1.PublicKey(delegate) : delegate)
659
+ ? (typeof delegate === 'string' ? new PublicKey(delegate) : delegate)
663
660
  : null;
664
- const senderTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, connectedWallet.wallet.publicKey, false, spl_token_1.TOKEN_PROGRAM_ID);
665
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
666
- const [delegatorInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('delegator_info'), connectedWallet.wallet.publicKey.toBuffer()], programId);
661
+ const senderTokenAccount = getAssociatedTokenAddressSync(usdcMint, connectedWallet.wallet.publicKey, false, TOKEN_PROGRAM_ID);
662
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
663
+ const [delegatorInfo] = PublicKey.findProgramAddressSync([Buffer.from('delegator_info'), connectedWallet.wallet.publicKey.toBuffer()], programId);
667
664
  const keys = [
668
665
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
669
666
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
670
667
  { pubkey: senderTokenAccount, isSigner: false, isWritable: true },
671
668
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
672
669
  { pubkey: delegatorInfo, isSigner: false, isWritable: true },
673
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
674
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
670
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
671
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
675
672
  ];
676
- const instruction = new web3_js_1.TransactionInstruction({
673
+ const instruction = new TransactionInstruction({
677
674
  programId,
678
675
  keys,
679
676
  data: encodeDelegateTo(delegatePubkey),
680
677
  });
681
- const transaction = new web3_js_1.Transaction().add(instruction);
678
+ const transaction = new Transaction().add(instruction);
682
679
  const accountInfo = await connection.getAccountInfo(mailerTokenAccount);
683
680
  if (!accountInfo) {
684
- transaction.add((0, spl_token_1.createAssociatedTokenAccountInstruction)(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
681
+ transaction.add(createAssociatedTokenAccountInstruction(connectedWallet.wallet.publicKey, mailerTokenAccount, mailerStatePda, usdcMint));
685
682
  }
686
683
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
687
684
  }
@@ -691,18 +688,18 @@ class SolanaMailerClient {
691
688
  async rejectDelegation(connectedWallet, chainInfo, delegatingAddress, computeOptions) {
692
689
  const connection = await this.getOrCreateConnection(chainInfo, connectedWallet.connection);
693
690
  const { programId } = this.getProgramAddresses(chainInfo);
694
- const delegatorPubkey = typeof delegatingAddress === 'string' ? new web3_js_1.PublicKey(delegatingAddress) : delegatingAddress;
695
- const [delegatorInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('delegator_info'), delegatorPubkey.toBuffer()], programId);
691
+ const delegatorPubkey = typeof delegatingAddress === 'string' ? new PublicKey(delegatingAddress) : delegatingAddress;
692
+ const [delegatorInfo] = PublicKey.findProgramAddressSync([Buffer.from('delegator_info'), delegatorPubkey.toBuffer()], programId);
696
693
  const keys = [
697
694
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: false },
698
695
  { pubkey: delegatorInfo, isSigner: false, isWritable: true },
699
696
  ];
700
- const instruction = new web3_js_1.TransactionInstruction({
697
+ const instruction = new TransactionInstruction({
701
698
  programId,
702
699
  keys,
703
700
  data: encodeRejectDelegation(delegatorPubkey),
704
701
  });
705
- const transaction = new web3_js_1.Transaction().add(instruction);
702
+ const transaction = new Transaction().add(instruction);
706
703
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
707
704
  }
708
705
  /**
@@ -715,12 +712,12 @@ class SolanaMailerClient {
715
712
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: false },
716
713
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
717
714
  ];
718
- const instruction = new web3_js_1.TransactionInstruction({
715
+ const instruction = new TransactionInstruction({
719
716
  programId,
720
717
  keys,
721
718
  data: encodeSetFees(BigInt(sendFee), BigInt(delegationFee)),
722
719
  });
723
- const transaction = new web3_js_1.Transaction().add(instruction);
720
+ const transaction = new Transaction().add(instruction);
724
721
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
725
722
  }
726
723
  /**
@@ -729,20 +726,20 @@ class SolanaMailerClient {
729
726
  async setCustomFeePercentage(account, percentage, connectedWallet, chainInfo, computeOptions) {
730
727
  const connection = await this.getOrCreateConnection(chainInfo, connectedWallet.connection);
731
728
  const { programId, mailerStatePda } = this.getProgramAddresses(chainInfo);
732
- const accountPubkey = typeof account === 'string' ? new web3_js_1.PublicKey(account) : account;
733
- const [customFeeInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('custom_fee'), accountPubkey.toBuffer()], programId);
729
+ const accountPubkey = typeof account === 'string' ? new PublicKey(account) : account;
730
+ const [customFeeInfo] = PublicKey.findProgramAddressSync([Buffer.from('custom_fee'), accountPubkey.toBuffer()], programId);
734
731
  const keys = [
735
732
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: true },
736
733
  { pubkey: mailerStatePda, isSigner: false, isWritable: false },
737
734
  { pubkey: customFeeInfo, isSigner: false, isWritable: true },
738
- { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
735
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
739
736
  ];
740
- const instruction = new web3_js_1.TransactionInstruction({
737
+ const instruction = new TransactionInstruction({
741
738
  programId,
742
739
  keys,
743
740
  data: encodeSetCustomFeePercentage(accountPubkey, percentage),
744
741
  });
745
- const transaction = new web3_js_1.Transaction().add(instruction);
742
+ const transaction = new Transaction().add(instruction);
746
743
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
747
744
  }
748
745
  /**
@@ -751,19 +748,19 @@ class SolanaMailerClient {
751
748
  async clearCustomFeePercentage(account, connectedWallet, chainInfo, computeOptions) {
752
749
  const connection = await this.getOrCreateConnection(chainInfo, connectedWallet.connection);
753
750
  const { programId, mailerStatePda } = this.getProgramAddresses(chainInfo);
754
- const accountPubkey = typeof account === 'string' ? new web3_js_1.PublicKey(account) : account;
755
- const [customFeeInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('custom_fee'), accountPubkey.toBuffer()], programId);
751
+ const accountPubkey = typeof account === 'string' ? new PublicKey(account) : account;
752
+ const [customFeeInfo] = PublicKey.findProgramAddressSync([Buffer.from('custom_fee'), accountPubkey.toBuffer()], programId);
756
753
  const keys = [
757
754
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: false },
758
755
  { pubkey: mailerStatePda, isSigner: false, isWritable: false },
759
756
  { pubkey: customFeeInfo, isSigner: false, isWritable: true },
760
757
  ];
761
- const instruction = new web3_js_1.TransactionInstruction({
758
+ const instruction = new TransactionInstruction({
762
759
  programId,
763
760
  keys,
764
761
  data: encodeClearCustomFeePercentage(accountPubkey),
765
762
  });
766
- const transaction = new web3_js_1.Transaction().add(instruction);
763
+ const transaction = new Transaction().add(instruction);
767
764
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
768
765
  }
769
766
  /**
@@ -776,12 +773,12 @@ class SolanaMailerClient {
776
773
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: false },
777
774
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
778
775
  ];
779
- const instruction = new web3_js_1.TransactionInstruction({
776
+ const instruction = new TransactionInstruction({
780
777
  programId,
781
778
  keys,
782
779
  data: Buffer.from([InstructionType.Pause]),
783
780
  });
784
- const transaction = new web3_js_1.Transaction().add(instruction);
781
+ const transaction = new Transaction().add(instruction);
785
782
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
786
783
  }
787
784
  /**
@@ -794,12 +791,12 @@ class SolanaMailerClient {
794
791
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: false },
795
792
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
796
793
  ];
797
- const instruction = new web3_js_1.TransactionInstruction({
794
+ const instruction = new TransactionInstruction({
798
795
  programId,
799
796
  keys,
800
797
  data: Buffer.from([InstructionType.Unpause]),
801
798
  });
802
- const transaction = new web3_js_1.Transaction().add(instruction);
799
+ const transaction = new Transaction().add(instruction);
803
800
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
804
801
  }
805
802
  /**
@@ -812,12 +809,12 @@ class SolanaMailerClient {
812
809
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: false },
813
810
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
814
811
  ];
815
- const instruction = new web3_js_1.TransactionInstruction({
812
+ const instruction = new TransactionInstruction({
816
813
  programId,
817
814
  keys,
818
815
  data: Buffer.from([InstructionType.EmergencyUnpause]),
819
816
  });
820
- const transaction = new web3_js_1.Transaction().add(instruction);
817
+ const transaction = new Transaction().add(instruction);
821
818
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
822
819
  }
823
820
  /**
@@ -829,29 +826,29 @@ class SolanaMailerClient {
829
826
  if (!chainInfo.usdcAddress) {
830
827
  throw new Error(`No USDC mint configured for ${chainInfo.name}`);
831
828
  }
832
- const usdcMint = new web3_js_1.PublicKey(chainInfo.usdcAddress);
833
- const recipientPubkeys = recipients.map(r => typeof r === 'string' ? new web3_js_1.PublicKey(r) : r);
834
- const mailerTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, mailerStatePda, true, spl_token_1.TOKEN_PROGRAM_ID);
829
+ const usdcMint = new PublicKey(chainInfo.usdcAddress);
830
+ const recipientPubkeys = recipients.map(r => typeof r === 'string' ? new PublicKey(r) : r);
831
+ const mailerTokenAccount = getAssociatedTokenAddressSync(usdcMint, mailerStatePda, true, TOKEN_PROGRAM_ID);
835
832
  // Build keys array
836
833
  const keys = [
837
834
  { pubkey: connectedWallet.wallet.publicKey, isSigner: true, isWritable: false },
838
835
  { pubkey: mailerStatePda, isSigner: false, isWritable: true },
839
836
  { pubkey: mailerTokenAccount, isSigner: false, isWritable: true },
840
- { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
837
+ { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
841
838
  ];
842
839
  // Add recipient info and token accounts
843
840
  for (const recipient of recipientPubkeys) {
844
- const [recipientInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), recipient.toBuffer()], programId);
845
- const recipientTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(usdcMint, recipient, false, spl_token_1.TOKEN_PROGRAM_ID);
841
+ const [recipientInfo] = PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), recipient.toBuffer()], programId);
842
+ const recipientTokenAccount = getAssociatedTokenAddressSync(usdcMint, recipient, false, TOKEN_PROGRAM_ID);
846
843
  keys.push({ pubkey: recipientInfo, isSigner: false, isWritable: true });
847
844
  keys.push({ pubkey: recipientTokenAccount, isSigner: false, isWritable: true });
848
845
  }
849
- const instruction = new web3_js_1.TransactionInstruction({
846
+ const instruction = new TransactionInstruction({
850
847
  programId,
851
848
  keys,
852
849
  data: encodeDistributeClaimableFunds(recipientPubkeys),
853
850
  });
854
- const transaction = new web3_js_1.Transaction().add(instruction);
851
+ const transaction = new Transaction().add(instruction);
855
852
  return await this.sendTransaction(transaction, connectedWallet.wallet, connection, undefined, computeOptions);
856
853
  }
857
854
  // ============= Read Methods =============
@@ -894,8 +891,8 @@ class SolanaMailerClient {
894
891
  async getRecipientClaimable(recipient, chainInfo, connection) {
895
892
  const conn = await this.getOrCreateConnection(chainInfo, connection);
896
893
  const { programId } = this.getProgramAddresses(chainInfo);
897
- const recipientPubkey = typeof recipient === 'string' ? new web3_js_1.PublicKey(recipient) : recipient;
898
- const [recipientInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), recipientPubkey.toBuffer()], programId);
894
+ const recipientPubkey = typeof recipient === 'string' ? new PublicKey(recipient) : recipient;
895
+ const [recipientInfo] = PublicKey.findProgramAddressSync([Buffer.from('recipient_info'), recipientPubkey.toBuffer()], programId);
899
896
  const accountInfo = await conn.getAccountInfo(recipientInfo);
900
897
  if (!accountInfo || !accountInfo.data) {
901
898
  return null;
@@ -911,7 +908,7 @@ class SolanaMailerClient {
911
908
  amount: Number(amount),
912
909
  timestamp: Number(expiresAt), // Using expiresAt as timestamp
913
910
  expiresAt: Number(expiresAt),
914
- recipient: recipient instanceof web3_js_1.PublicKey ? recipient.toBase58() : recipient,
911
+ recipient: recipient instanceof PublicKey ? recipient.toBase58() : recipient,
915
912
  isExpired,
916
913
  };
917
914
  }
@@ -936,8 +933,8 @@ class SolanaMailerClient {
936
933
  async getDelegation(address, chainInfo, connection) {
937
934
  const conn = await this.getOrCreateConnection(chainInfo, connection);
938
935
  const { programId } = this.getProgramAddresses(chainInfo);
939
- const addressPubkey = typeof address === 'string' ? new web3_js_1.PublicKey(address) : address;
940
- const [delegatorInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('delegator_info'), addressPubkey.toBuffer()], programId);
936
+ const addressPubkey = typeof address === 'string' ? new PublicKey(address) : address;
937
+ const [delegatorInfo] = PublicKey.findProgramAddressSync([Buffer.from('delegator_info'), addressPubkey.toBuffer()], programId);
941
938
  const accountInfo = await conn.getAccountInfo(delegatorInfo);
942
939
  if (!accountInfo || !accountInfo.data) {
943
940
  return null;
@@ -950,7 +947,7 @@ class SolanaMailerClient {
950
947
  }
951
948
  // Read delegate pubkey
952
949
  const delegateBytes = data.slice(9, 41); // 32 bytes for pubkey
953
- return new web3_js_1.PublicKey(delegateBytes);
950
+ return new PublicKey(delegateBytes);
954
951
  }
955
952
  /**
956
953
  * Get custom fee percentage for an account
@@ -958,8 +955,8 @@ class SolanaMailerClient {
958
955
  async getCustomFeePercentage(account, chainInfo, connection) {
959
956
  const conn = await this.getOrCreateConnection(chainInfo, connection);
960
957
  const { programId } = this.getProgramAddresses(chainInfo);
961
- const accountPubkey = typeof account === 'string' ? new web3_js_1.PublicKey(account) : account;
962
- const [customFeeInfo] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('custom_fee'), accountPubkey.toBuffer()], programId);
958
+ const accountPubkey = typeof account === 'string' ? new PublicKey(account) : account;
959
+ const [customFeeInfo] = PublicKey.findProgramAddressSync([Buffer.from('custom_fee'), accountPubkey.toBuffer()], programId);
963
960
  const accountInfo = await conn.getAccountInfo(customFeeInfo);
964
961
  if (!accountInfo || !accountInfo.data) {
965
962
  return 100; // Default to 100% if no custom fee set
@@ -997,8 +994,7 @@ class SolanaMailerClient {
997
994
  // Parse the state data
998
995
  const data = accountInfo.data;
999
996
  const ownerBytes = data.slice(8, 40); // After discriminator(8)
1000
- return new web3_js_1.PublicKey(ownerBytes);
997
+ return new PublicKey(ownerBytes);
1001
998
  }
1002
999
  }
1003
- exports.SolanaMailerClient = SolanaMailerClient;
1004
1000
  //# sourceMappingURL=solana-mailer-client.js.map