@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.
- package/lib/commonjs/adapter.js +69 -8
- package/lib/commonjs/adapter.js.map +1 -1
- package/lib/commonjs/connectors/PhantomConnector.js +4 -1
- package/lib/commonjs/connectors/PhantomConnector.js.map +1 -1
- package/lib/commonjs/connectors/SolflareConnector.js +4 -1
- package/lib/commonjs/connectors/SolflareConnector.js.map +1 -1
- package/lib/commonjs/utils/createSPLTokenTransaction.js +96 -0
- package/lib/commonjs/utils/createSPLTokenTransaction.js.map +1 -0
- package/lib/commonjs/utils/createSendTransaction.js +3 -17
- package/lib/commonjs/utils/createSendTransaction.js.map +1 -1
- package/lib/module/adapter.js +69 -8
- package/lib/module/adapter.js.map +1 -1
- package/lib/module/connectors/PhantomConnector.js +4 -1
- package/lib/module/connectors/PhantomConnector.js.map +1 -1
- package/lib/module/connectors/SolflareConnector.js +4 -1
- package/lib/module/connectors/SolflareConnector.js.map +1 -1
- package/lib/module/utils/createSPLTokenTransaction.js +92 -0
- package/lib/module/utils/createSPLTokenTransaction.js.map +1 -0
- package/lib/module/utils/createSendTransaction.js +4 -19
- package/lib/module/utils/createSendTransaction.js.map +1 -1
- package/lib/typescript/adapter.d.ts +2 -0
- package/lib/typescript/adapter.d.ts.map +1 -1
- package/lib/typescript/connectors/PhantomConnector.d.ts.map +1 -1
- package/lib/typescript/connectors/SolflareConnector.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +8 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/createSPLTokenTransaction.d.ts +4 -0
- package/lib/typescript/utils/createSPLTokenTransaction.d.ts.map +1 -0
- package/lib/typescript/utils/createSendTransaction.d.ts +2 -2
- package/lib/typescript/utils/createSendTransaction.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/adapter.ts +80 -12
- package/src/connectors/PhantomConnector.ts +4 -1
- package/src/connectors/SolflareConnector.ts +4 -1
- package/src/types.ts +9 -0
- package/src/utils/createSPLTokenTransaction.ts +152 -0
- 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
|
-
|
|
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
|
-
|
|
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(
|
|
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,
|