@reown/appkit-solana-react-native 2.0.0-alpha.4 → 2.0.0-alpha.6

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 (37) hide show
  1. package/lib/commonjs/adapter.js +69 -8
  2. package/lib/commonjs/adapter.js.map +1 -1
  3. package/lib/commonjs/connectors/PhantomConnector.js +4 -1
  4. package/lib/commonjs/connectors/PhantomConnector.js.map +1 -1
  5. package/lib/commonjs/connectors/SolflareConnector.js +4 -1
  6. package/lib/commonjs/connectors/SolflareConnector.js.map +1 -1
  7. package/lib/commonjs/utils/createSPLTokenTransaction.js +96 -0
  8. package/lib/commonjs/utils/createSPLTokenTransaction.js.map +1 -0
  9. package/lib/commonjs/utils/createSendTransaction.js +3 -17
  10. package/lib/commonjs/utils/createSendTransaction.js.map +1 -1
  11. package/lib/module/adapter.js +69 -8
  12. package/lib/module/adapter.js.map +1 -1
  13. package/lib/module/connectors/PhantomConnector.js +4 -1
  14. package/lib/module/connectors/PhantomConnector.js.map +1 -1
  15. package/lib/module/connectors/SolflareConnector.js +4 -1
  16. package/lib/module/connectors/SolflareConnector.js.map +1 -1
  17. package/lib/module/utils/createSPLTokenTransaction.js +92 -0
  18. package/lib/module/utils/createSPLTokenTransaction.js.map +1 -0
  19. package/lib/module/utils/createSendTransaction.js +4 -19
  20. package/lib/module/utils/createSendTransaction.js.map +1 -1
  21. package/lib/typescript/adapter.d.ts +2 -0
  22. package/lib/typescript/adapter.d.ts.map +1 -1
  23. package/lib/typescript/connectors/PhantomConnector.d.ts.map +1 -1
  24. package/lib/typescript/connectors/SolflareConnector.d.ts.map +1 -1
  25. package/lib/typescript/types.d.ts +8 -0
  26. package/lib/typescript/types.d.ts.map +1 -1
  27. package/lib/typescript/utils/createSPLTokenTransaction.d.ts +4 -0
  28. package/lib/typescript/utils/createSPLTokenTransaction.d.ts.map +1 -0
  29. package/lib/typescript/utils/createSendTransaction.d.ts +2 -2
  30. package/lib/typescript/utils/createSendTransaction.d.ts.map +1 -1
  31. package/package.json +6 -4
  32. package/src/adapter.ts +80 -12
  33. package/src/connectors/PhantomConnector.ts +4 -1
  34. package/src/connectors/SolflareConnector.ts +4 -1
  35. package/src/types.ts +9 -0
  36. package/src/utils/createSPLTokenTransaction.ts +152 -0
  37. package/src/utils/createSendTransaction.ts +3 -19
@@ -1,5 +1,4 @@
1
1
  import {
2
- ComputeBudgetProgram,
3
2
  type Connection,
4
3
  LAMPORTS_PER_SOL,
5
4
  PublicKey,
@@ -7,41 +6,26 @@ import {
7
6
  Transaction
8
7
  } from '@solana/web3.js';
9
8
 
10
- // import type { Provider } from '@reown/appkit-utils/solana'
11
-
12
9
  type SendTransactionArgs = {
13
10
  connection: Connection;
14
11
  fromAddress: string;
15
12
  toAddress: string;
16
- value: number;
17
- };
18
-
19
- /**
20
- * These constants defines the cost of running the program, allowing to calculate the maximum
21
- * amount of SOL that can be sent in case of cleaning the account and remove the rent exemption error.
22
- */
23
- const COMPUTE_BUDGET_CONSTANTS = {
24
- UNIT_PRICE_MICRO_LAMPORTS: 20000000,
25
- UNIT_LIMIT: 500
13
+ amount: number;
26
14
  };
27
15
 
28
16
  export async function createSendTransaction({
29
17
  fromAddress,
30
18
  toAddress,
31
- value,
19
+ amount,
32
20
  connection
33
21
  }: SendTransactionArgs): Promise<Transaction> {
34
22
  const fromPubkey = new PublicKey(fromAddress);
35
23
  const toPubkey = new PublicKey(toAddress);
36
- const lamports = Math.floor(value * LAMPORTS_PER_SOL);
24
+ const lamports = Math.floor(amount * LAMPORTS_PER_SOL);
37
25
 
38
26
  const { blockhash } = await connection.getLatestBlockhash();
39
27
 
40
28
  const instructions = [
41
- ComputeBudgetProgram.setComputeUnitPrice({
42
- microLamports: COMPUTE_BUDGET_CONSTANTS.UNIT_PRICE_MICRO_LAMPORTS
43
- }),
44
- ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_BUDGET_CONSTANTS.UNIT_LIMIT }),
45
29
  SystemProgram.transfer({
46
30
  fromPubkey,
47
31
  toPubkey,