@solana/web3-compat 0.0.17 → 0.0.18
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/types/client/src/features/sol.d.ts +116 -1
- package/dist/types/client/src/features/sol.d.ts.map +1 -1
- package/dist/types/client/src/features/spl.d.ts +163 -1
- package/dist/types/client/src/features/spl.d.ts.map +1 -1
- package/dist/types/client/src/features/stake.d.ts +206 -1
- package/dist/types/client/src/features/stake.d.ts.map +1 -1
- package/dist/types/client/src/features/wsol.d.ts +189 -21
- package/dist/types/client/src/features/wsol.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,42 +1,157 @@
|
|
|
1
1
|
import { type Address, type Blockhash, type Commitment, type Slot, signature, signTransactionMessageWithSigners, type TransactionPlan, type TransactionSigner, type TransactionVersion } from '@solana/kit';
|
|
2
2
|
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
3
|
import type { WalletSession } from '../wallet/types';
|
|
4
|
+
/**
|
|
5
|
+
* Blockhash and last valid block height for transaction lifetime.
|
|
6
|
+
* Used to ensure transactions expire after a certain block height.
|
|
7
|
+
*/
|
|
4
8
|
type BlockhashLifetime = Readonly<{
|
|
5
9
|
blockhash: Blockhash;
|
|
6
10
|
lastValidBlockHeight: bigint;
|
|
7
11
|
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Amount of SOL to transfer. Can be specified as:
|
|
14
|
+
* - `bigint`: Raw lamports (1 SOL = 1_000_000_000 lamports)
|
|
15
|
+
* - `number`: SOL amount as decimal (e.g., 1.5 for 1.5 SOL)
|
|
16
|
+
* - `string`: SOL amount as string (e.g., "1.5" for 1.5 SOL)
|
|
17
|
+
*/
|
|
8
18
|
type SolTransferAmount = bigint | number | string;
|
|
19
|
+
/**
|
|
20
|
+
* Authority that signs the SOL transfer transaction.
|
|
21
|
+
* Can be either a connected wallet session or a raw transaction signer.
|
|
22
|
+
*/
|
|
9
23
|
type SolTransferAuthority = TransactionSigner<string> | WalletSession;
|
|
10
24
|
type SignableSolTransactionMessage = Parameters<typeof signTransactionMessageWithSigners>[0];
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for preparing a SOL transfer transaction.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const config: SolTransferPrepareConfig = {
|
|
31
|
+
* amount: 1_000_000_000n, // 1 SOL in lamports
|
|
32
|
+
* authority: walletSession,
|
|
33
|
+
* destination: 'RecipientAddress...',
|
|
34
|
+
* commitment: 'confirmed',
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
11
38
|
export type SolTransferPrepareConfig = Readonly<{
|
|
39
|
+
/** Amount of SOL to transfer in lamports, decimal SOL, or string SOL. */
|
|
12
40
|
amount: SolTransferAmount;
|
|
41
|
+
/** Authority that signs the transaction. Can be a WalletSession or raw TransactionSigner. */
|
|
13
42
|
authority: SolTransferAuthority;
|
|
43
|
+
/** Commitment level for fetching blockhash and sending transaction. Defaults to client commitment. */
|
|
14
44
|
commitment?: Commitment;
|
|
45
|
+
/** Destination wallet address to receive the SOL. */
|
|
15
46
|
destination: Address | string;
|
|
47
|
+
/** Optional pre-fetched blockhash lifetime. If not provided, one will be fetched. */
|
|
16
48
|
lifetime?: BlockhashLifetime;
|
|
49
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
17
50
|
transactionVersion?: TransactionVersion;
|
|
18
51
|
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Options for sending a SOL transfer transaction.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const options: SolTransferSendOptions = {
|
|
58
|
+
* commitment: 'confirmed',
|
|
59
|
+
* maxRetries: 3,
|
|
60
|
+
* skipPreflight: false,
|
|
61
|
+
* };
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
19
64
|
export type SolTransferSendOptions = Readonly<{
|
|
65
|
+
/** AbortSignal to cancel the transaction. */
|
|
20
66
|
abortSignal?: AbortSignal;
|
|
67
|
+
/** Commitment level for transaction confirmation. */
|
|
21
68
|
commitment?: Commitment;
|
|
69
|
+
/** Maximum number of times to retry sending the transaction. */
|
|
22
70
|
maxRetries?: bigint | number;
|
|
71
|
+
/** Minimum slot that the request can be evaluated at. */
|
|
23
72
|
minContextSlot?: Slot;
|
|
73
|
+
/** If true, skip the preflight transaction checks. */
|
|
24
74
|
skipPreflight?: boolean;
|
|
25
75
|
}>;
|
|
76
|
+
/**
|
|
77
|
+
* A prepared SOL transfer transaction ready to be signed and sent.
|
|
78
|
+
* Contains the transaction message, signer, and metadata needed for submission.
|
|
79
|
+
*/
|
|
26
80
|
type PreparedSolTransfer = Readonly<{
|
|
81
|
+
/** Commitment level used for this transaction. */
|
|
27
82
|
commitment?: Commitment;
|
|
83
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
28
84
|
lifetime: BlockhashLifetime;
|
|
85
|
+
/** The unsigned transaction message. */
|
|
29
86
|
message: SignableSolTransactionMessage;
|
|
87
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
30
88
|
mode: 'partial' | 'send';
|
|
89
|
+
/** The transaction signer. */
|
|
31
90
|
signer: TransactionSigner;
|
|
91
|
+
/** Transaction plan for execution. */
|
|
32
92
|
plan?: TransactionPlan;
|
|
33
93
|
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Helper interface for native SOL transfers using the System Program.
|
|
96
|
+
* Provides methods to prepare, sign, and send SOL transfer transactions.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { createSolTransferHelper } from '@solana/client';
|
|
101
|
+
*
|
|
102
|
+
* const helper = createSolTransferHelper(runtime);
|
|
103
|
+
*
|
|
104
|
+
* // Simple transfer
|
|
105
|
+
* const signature = await helper.sendTransfer({
|
|
106
|
+
* amount: 1_000_000_000n, // 1 SOL
|
|
107
|
+
* authority: walletSession,
|
|
108
|
+
* destination: 'RecipientAddress...',
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* // Or prepare and send separately
|
|
112
|
+
* const prepared = await helper.prepareTransfer({ ... });
|
|
113
|
+
* const signature = await helper.sendPreparedTransfer(prepared);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
34
116
|
export type SolTransferHelper = Readonly<{
|
|
117
|
+
/**
|
|
118
|
+
* Prepares a SOL transfer transaction without sending it.
|
|
119
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
120
|
+
*/
|
|
35
121
|
prepareTransfer(config: SolTransferPrepareConfig): Promise<PreparedSolTransfer>;
|
|
122
|
+
/**
|
|
123
|
+
* Sends a previously prepared SOL transfer transaction.
|
|
124
|
+
* Use this after prepareTransfer() to submit the transaction.
|
|
125
|
+
*/
|
|
36
126
|
sendPreparedTransfer(prepared: PreparedSolTransfer, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
127
|
+
/**
|
|
128
|
+
* Prepares and sends a SOL transfer in one call.
|
|
129
|
+
* This is the simplest way to transfer SOL.
|
|
130
|
+
*/
|
|
37
131
|
sendTransfer(config: SolTransferPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
38
132
|
}>;
|
|
39
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Creates helpers for building and submitting native SOL transfers via the System Program.
|
|
135
|
+
*
|
|
136
|
+
* @param runtime - The Solana client runtime with RPC connection.
|
|
137
|
+
* @returns A SolTransferHelper with methods to prepare and send SOL transfers.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { createClient } from '@solana/client';
|
|
142
|
+
*
|
|
143
|
+
* const client = createClient({ cluster: 'devnet' });
|
|
144
|
+
* const helper = client.helpers.sol;
|
|
145
|
+
*
|
|
146
|
+
* // Transfer 0.5 SOL
|
|
147
|
+
* const sig = await helper.sendTransfer({
|
|
148
|
+
* amount: 0.5, // Can use decimal SOL
|
|
149
|
+
* authority: session,
|
|
150
|
+
* destination: 'RecipientAddress...',
|
|
151
|
+
* });
|
|
152
|
+
* console.log('Transfer signature:', sig);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
40
155
|
export declare function createSolTransferHelper(runtime: SolanaClientRuntime): SolTransferHelper;
|
|
41
156
|
export {};
|
|
42
157
|
//# sourceMappingURL=sol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sol.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/sol.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,OAAO,EAGZ,KAAK,SAAS,EACd,KAAK,UAAU,EAMf,KAAK,IAAI,EAIT,SAAS,EACT,iCAAiC,EAEjC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,KAAK,iBAAiB,GAAG,QAAQ,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC,CAAC;AAEH,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,KAAK,oBAAoB,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC;AAEtE,KAAK,6BAA6B,GAAG,UAAU,CAAC,OAAO,iCAAiC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7F,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC/C,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,oBAAoB,CAAC;IAChC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,kBAAkB,CAAC,E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D;IACtD,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC,CAAC;AAEH;;;GAGG;AACH,KAAK,mBAAmB,GAAG,QAAQ,CAAC;IACnC,kDAAkD;IAClD,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,qDAAqD;IACrD,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,wCAAwC;IACxC,OAAO,EAAE,6BAA6B,CAAC;IACvC,uFAAuF;IACvF,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,8BAA8B;IAC9B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,sCAAsC;IACtC,IAAI,CAAC,EAAE,eAAe,CAAC;CACvB,CAAC,CAAC;AAiCH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACxC;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChF;;;OAGG;IACH,oBAAoB,CACnB,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,YAAY,CACX,MAAM,EAAE,wBAAwB,EAChC,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,GAAG,iBAAiB,CAyFvF"}
|
|
@@ -2,59 +2,221 @@ import { type Address, type Blockhash, type Commitment, signature, signTransacti
|
|
|
2
2
|
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
3
|
import type { WalletSession } from '../wallet/types';
|
|
4
4
|
import type { SolTransferSendOptions } from './sol';
|
|
5
|
+
/**
|
|
6
|
+
* Blockhash and last valid block height for transaction lifetime.
|
|
7
|
+
* Used to ensure transactions expire after a certain block height.
|
|
8
|
+
*/
|
|
5
9
|
type BlockhashLifetime = Readonly<{
|
|
6
10
|
blockhash: Blockhash;
|
|
7
11
|
lastValidBlockHeight: bigint;
|
|
8
12
|
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Authority that signs SPL token transfer transactions.
|
|
15
|
+
* Can be either a connected wallet session or a raw transaction signer.
|
|
16
|
+
*/
|
|
9
17
|
type SplTokenAuthority = TransactionSigner<string> | WalletSession;
|
|
10
18
|
type SignableSplTransactionMessage = Parameters<typeof signTransactionMessageWithSigners>[0];
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for creating an SPL token helper.
|
|
21
|
+
* Each helper instance is bound to a specific token mint.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const config: SplTokenHelperConfig = {
|
|
26
|
+
* mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
|
|
27
|
+
* decimals: 6, // Optional: provide to skip on-chain lookup
|
|
28
|
+
* commitment: 'confirmed',
|
|
29
|
+
* };
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
11
32
|
export type SplTokenHelperConfig = Readonly<{
|
|
33
|
+
/** Associated Token Program address. Defaults to standard ATA program. */
|
|
12
34
|
associatedTokenProgram?: Address | string;
|
|
35
|
+
/** Commitment level for RPC calls. */
|
|
13
36
|
commitment?: Commitment;
|
|
37
|
+
/** Token decimals. If not provided, will be fetched from the mint account. */
|
|
14
38
|
decimals?: number;
|
|
39
|
+
/** The SPL token mint address. */
|
|
15
40
|
mint: Address | string;
|
|
41
|
+
/** Token Program address. Defaults to standard Token Program. */
|
|
16
42
|
tokenProgram?: Address | string;
|
|
17
43
|
}>;
|
|
44
|
+
/**
|
|
45
|
+
* SPL token balance information for an owner's Associated Token Account.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const balance: SplTokenBalance = {
|
|
50
|
+
* amount: 1000000n, // Raw token amount in base units
|
|
51
|
+
* ataAddress: 'TokenAccountAddress...',
|
|
52
|
+
* decimals: 6,
|
|
53
|
+
* exists: true,
|
|
54
|
+
* uiAmount: '1.0', // Human-readable amount
|
|
55
|
+
* };
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
18
58
|
export type SplTokenBalance = Readonly<{
|
|
59
|
+
/** Token amount in base units (smallest denomination). */
|
|
19
60
|
amount: bigint;
|
|
61
|
+
/** The Associated Token Account address. */
|
|
20
62
|
ataAddress: Address;
|
|
63
|
+
/** Number of decimals for this token. */
|
|
21
64
|
decimals: number;
|
|
65
|
+
/** Whether the token account exists on-chain. */
|
|
22
66
|
exists: boolean;
|
|
67
|
+
/** Human-readable token amount as a string. */
|
|
23
68
|
uiAmount: string;
|
|
24
69
|
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for preparing an SPL token transfer transaction.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const config: SplTransferPrepareConfig = {
|
|
76
|
+
* amount: '10.5', // Transfer 10.5 tokens
|
|
77
|
+
* authority: walletSession,
|
|
78
|
+
* destinationOwner: 'RecipientWalletAddress...',
|
|
79
|
+
* ensureDestinationAta: true, // Create ATA if needed
|
|
80
|
+
* };
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
25
83
|
export type SplTransferPrepareConfig = Readonly<{
|
|
84
|
+
/** Amount to transfer. Interpreted based on amountInBaseUnits flag. */
|
|
26
85
|
amount: bigint | number | string;
|
|
86
|
+
/** If true, amount is in base units (raw). If false (default), amount is in decimal tokens. */
|
|
27
87
|
amountInBaseUnits?: boolean;
|
|
88
|
+
/** Authority that signs the transaction. Can be a WalletSession or raw TransactionSigner. */
|
|
28
89
|
authority: SplTokenAuthority;
|
|
90
|
+
/** Commitment level for RPC calls. */
|
|
29
91
|
commitment?: Commitment;
|
|
92
|
+
/** Wallet address of the recipient (not their token account). */
|
|
30
93
|
destinationOwner: Address | string;
|
|
94
|
+
/** Optional: explicit destination token account. If not provided, ATA is derived. */
|
|
31
95
|
destinationToken?: Address | string;
|
|
96
|
+
/** If true (default), creates the destination ATA if it doesn't exist. */
|
|
32
97
|
ensureDestinationAta?: boolean;
|
|
98
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
33
99
|
lifetime?: BlockhashLifetime;
|
|
100
|
+
/** Source wallet owner. Defaults to authority address. */
|
|
34
101
|
sourceOwner?: Address | string;
|
|
102
|
+
/** Optional: explicit source token account. If not provided, ATA is derived. */
|
|
35
103
|
sourceToken?: Address | string;
|
|
104
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
36
105
|
transactionVersion?: TransactionVersion;
|
|
37
106
|
}>;
|
|
107
|
+
/**
|
|
108
|
+
* A prepared SPL token transfer transaction ready to be signed and sent.
|
|
109
|
+
* Contains all the information needed to submit the transaction.
|
|
110
|
+
*/
|
|
38
111
|
type PreparedSplTransfer = Readonly<{
|
|
112
|
+
/** Token amount in base units. */
|
|
39
113
|
amount: bigint;
|
|
114
|
+
/** Commitment level used. */
|
|
40
115
|
commitment?: Commitment;
|
|
116
|
+
/** Token decimals. */
|
|
41
117
|
decimals: number;
|
|
118
|
+
/** Destination Associated Token Account address. */
|
|
42
119
|
destinationAta: Address;
|
|
120
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
43
121
|
lifetime: BlockhashLifetime;
|
|
122
|
+
/** The unsigned transaction message. */
|
|
44
123
|
message: SignableSplTransactionMessage;
|
|
124
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
45
125
|
mode: 'partial' | 'send';
|
|
126
|
+
/** The transaction signer. */
|
|
46
127
|
signer: TransactionSigner;
|
|
128
|
+
/** Source Associated Token Account address. */
|
|
47
129
|
sourceAta: Address;
|
|
130
|
+
/** Transaction plan for execution. */
|
|
48
131
|
plan?: TransactionPlan;
|
|
49
132
|
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Helper interface for SPL token operations including balance queries and transfers.
|
|
135
|
+
* Each helper instance is bound to a specific token mint.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { createSplTokenHelper } from '@solana/client';
|
|
140
|
+
*
|
|
141
|
+
* // Create helper for USDC
|
|
142
|
+
* const usdc = createSplTokenHelper(runtime, {
|
|
143
|
+
* mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
144
|
+
* decimals: 6,
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // Check balance
|
|
148
|
+
* const balance = await usdc.fetchBalance(walletAddress);
|
|
149
|
+
* console.log(`Balance: ${balance.uiAmount} USDC`);
|
|
150
|
+
*
|
|
151
|
+
* // Transfer tokens
|
|
152
|
+
* const sig = await usdc.sendTransfer({
|
|
153
|
+
* amount: 10, // 10 USDC
|
|
154
|
+
* authority: walletSession,
|
|
155
|
+
* destinationOwner: recipientAddress,
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
50
159
|
export type SplTokenHelper = Readonly<{
|
|
160
|
+
/**
|
|
161
|
+
* Derives the Associated Token Account (ATA) address for an owner.
|
|
162
|
+
* The ATA is a deterministic address based on the owner and mint.
|
|
163
|
+
*/
|
|
51
164
|
deriveAssociatedTokenAddress(owner: Address | string): Promise<Address>;
|
|
165
|
+
/**
|
|
166
|
+
* Fetches the token balance for an owner's Associated Token Account.
|
|
167
|
+
* Returns balance info including whether the account exists.
|
|
168
|
+
*/
|
|
52
169
|
fetchBalance(owner: Address | string, commitment?: Commitment): Promise<SplTokenBalance>;
|
|
170
|
+
/**
|
|
171
|
+
* Prepares a token transfer transaction without sending it.
|
|
172
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
173
|
+
*/
|
|
53
174
|
prepareTransfer(config: SplTransferPrepareConfig): Promise<PreparedSplTransfer>;
|
|
175
|
+
/**
|
|
176
|
+
* Sends a previously prepared token transfer transaction.
|
|
177
|
+
* Use this after prepareTransfer() to submit the transaction.
|
|
178
|
+
*/
|
|
54
179
|
sendPreparedTransfer(prepared: PreparedSplTransfer, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
180
|
+
/**
|
|
181
|
+
* Prepares and sends a token transfer in one call.
|
|
182
|
+
* Automatically creates the destination ATA if it doesn't exist (configurable).
|
|
183
|
+
*/
|
|
55
184
|
sendTransfer(config: SplTransferPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
56
185
|
}>;
|
|
57
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Creates helpers for SPL token operations bound to a specific token mint.
|
|
188
|
+
* Supports balance queries, ATA derivation, and token transfers.
|
|
189
|
+
*
|
|
190
|
+
* @param runtime - The Solana client runtime with RPC connection.
|
|
191
|
+
* @param config - Configuration specifying the token mint and optional settings.
|
|
192
|
+
* @returns An SplTokenHelper with methods for token operations.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* import { createClient } from '@solana/client';
|
|
197
|
+
*
|
|
198
|
+
* const client = createClient({ cluster: 'mainnet-beta' });
|
|
199
|
+
*
|
|
200
|
+
* // Create a helper for USDC
|
|
201
|
+
* const usdc = client.helpers.spl({
|
|
202
|
+
* mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
203
|
+
* decimals: 6, // Skip on-chain lookup
|
|
204
|
+
* });
|
|
205
|
+
*
|
|
206
|
+
* // Get token balance
|
|
207
|
+
* const balance = await usdc.fetchBalance(myWallet);
|
|
208
|
+
* if (balance.exists) {
|
|
209
|
+
* console.log(`USDC balance: ${balance.uiAmount}`);
|
|
210
|
+
* }
|
|
211
|
+
*
|
|
212
|
+
* // Transfer tokens
|
|
213
|
+
* const sig = await usdc.sendTransfer({
|
|
214
|
+
* amount: '25.50', // Can use string decimals
|
|
215
|
+
* authority: session,
|
|
216
|
+
* destinationOwner: recipientWallet,
|
|
217
|
+
* });
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
58
220
|
export declare function createSplTokenHelper(runtime: SolanaClientRuntime, config: SplTokenHelperConfig): SplTokenHelper;
|
|
59
221
|
export {};
|
|
60
222
|
//# sourceMappingURL=spl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spl.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/spl.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,OAAO,EAGZ,KAAK,SAAS,EACd,KAAK,UAAU,EAWf,SAAS,EACT,iCAAiC,EAEjC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,MAAM,aAAa,CAAC;AAUrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAEpD,KAAK,iBAAiB,GAAG,QAAQ,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC,CAAC;AAEH,KAAK,iBAAiB,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC;AAEnE,KAAK,6BAA6B,GAAG,UAAU,CAAC,OAAO,iCAAiC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7F,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC3C,sBAAsB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC,CAAC,CAAC;AAEH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AAmB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,YAAY,CACX,MAAM,EAAE,wBAAwB,EAChC,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,oBAAoB,GAAG,cAAc,CA8M/G"}
|
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
import { type Address, type Blockhash, type Commitment, type Slot, signature, signTransactionMessageWithSigners, type TransactionPlan, type TransactionSigner, type TransactionVersion } from '@solana/kit';
|
|
2
2
|
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
3
|
import type { WalletSession } from '../wallet/types';
|
|
4
|
+
/**
|
|
5
|
+
* Blockhash and last valid block height for transaction lifetime.
|
|
6
|
+
* Used to ensure transactions expire after a certain block height.
|
|
7
|
+
*/
|
|
4
8
|
type BlockhashLifetime = Readonly<{
|
|
5
9
|
blockhash: Blockhash;
|
|
6
10
|
lastValidBlockHeight: bigint;
|
|
7
11
|
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Amount of SOL to stake. Can be specified as:
|
|
14
|
+
* - `bigint`: Raw lamports (1 SOL = 1_000_000_000 lamports)
|
|
15
|
+
* - `number`: SOL amount as decimal (e.g., 1.5 for 1.5 SOL)
|
|
16
|
+
* - `string`: SOL amount as string (e.g., "1.5" for 1.5 SOL)
|
|
17
|
+
*/
|
|
8
18
|
type StakeAmount = bigint | number | string;
|
|
19
|
+
/**
|
|
20
|
+
* Authority that signs staking transactions.
|
|
21
|
+
* Can be either a connected wallet session or a raw transaction signer.
|
|
22
|
+
*/
|
|
9
23
|
type StakeAuthority = TransactionSigner<string> | WalletSession;
|
|
24
|
+
/**
|
|
25
|
+
* Represents a stake account with its delegation and metadata.
|
|
26
|
+
* Returned by getStakeAccounts() when querying stake positions.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const accounts = await stakeHelper.getStakeAccounts(walletAddress);
|
|
31
|
+
* for (const acc of accounts) {
|
|
32
|
+
* const delegation = acc.account.data.parsed.info.stake?.delegation;
|
|
33
|
+
* console.log(`Staked ${acc.account.lamports} to validator ${delegation?.voter}`);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
10
37
|
export type StakeAccount = {
|
|
38
|
+
/** The stake account's public key address. */
|
|
11
39
|
pubkey: Address;
|
|
12
40
|
account: {
|
|
13
41
|
data: {
|
|
@@ -15,63 +43,149 @@ export type StakeAccount = {
|
|
|
15
43
|
info: {
|
|
16
44
|
stake?: {
|
|
17
45
|
delegation?: {
|
|
46
|
+
/** The validator vote account receiving the stake. */
|
|
18
47
|
voter: string;
|
|
48
|
+
/** Amount of lamports delegated. */
|
|
19
49
|
stake: string;
|
|
50
|
+
/** Epoch when stake became active. */
|
|
20
51
|
activationEpoch: string;
|
|
52
|
+
/** Epoch when stake will deactivate (max value if active). */
|
|
21
53
|
deactivationEpoch: string;
|
|
22
54
|
};
|
|
23
55
|
};
|
|
24
56
|
meta?: {
|
|
57
|
+
/** Rent-exempt reserve in lamports. */
|
|
25
58
|
rentExemptReserve: string;
|
|
26
59
|
authorized: {
|
|
60
|
+
/** Address authorized to delegate/undelegate. */
|
|
27
61
|
staker: string;
|
|
62
|
+
/** Address authorized to withdraw. */
|
|
28
63
|
withdrawer: string;
|
|
29
64
|
};
|
|
30
65
|
lockup: {
|
|
66
|
+
/** Unix timestamp when lockup expires (0 if none). */
|
|
31
67
|
unixTimestamp: number;
|
|
68
|
+
/** Epoch when lockup expires (0 if none). */
|
|
32
69
|
epoch: number;
|
|
70
|
+
/** Custodian who can modify lockup (system program if none). */
|
|
33
71
|
custodian: string;
|
|
34
72
|
};
|
|
35
73
|
};
|
|
36
74
|
};
|
|
37
75
|
};
|
|
38
76
|
};
|
|
77
|
+
/** Total lamports in the stake account. */
|
|
39
78
|
lamports: bigint;
|
|
40
79
|
};
|
|
41
80
|
};
|
|
42
81
|
type SignableStakeTransactionMessage = Parameters<typeof signTransactionMessageWithSigners>[0];
|
|
82
|
+
/**
|
|
83
|
+
* Configuration for preparing a stake delegation transaction.
|
|
84
|
+
* Creates a new stake account and delegates it to a validator.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const config: StakePrepareConfig = {
|
|
89
|
+
* amount: 10, // Stake 10 SOL
|
|
90
|
+
* authority: walletSession,
|
|
91
|
+
* validatorId: 'ValidatorVoteAccountAddress...',
|
|
92
|
+
* };
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
43
95
|
export type StakePrepareConfig = Readonly<{
|
|
96
|
+
/** Amount of SOL to stake in lamports, decimal SOL, or string SOL. */
|
|
44
97
|
amount: StakeAmount;
|
|
98
|
+
/** Authority that signs the transaction. Will be set as staker and withdrawer. */
|
|
45
99
|
authority: StakeAuthority;
|
|
100
|
+
/** Commitment level for RPC calls. */
|
|
46
101
|
commitment?: Commitment;
|
|
102
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
47
103
|
lifetime?: BlockhashLifetime;
|
|
104
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
48
105
|
transactionVersion?: TransactionVersion;
|
|
106
|
+
/** The validator's vote account address to delegate stake to. */
|
|
49
107
|
validatorId: Address | string;
|
|
50
108
|
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Options for sending stake-related transactions.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const options: StakeSendOptions = {
|
|
115
|
+
* commitment: 'confirmed',
|
|
116
|
+
* maxRetries: 3,
|
|
117
|
+
* };
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
51
120
|
export type StakeSendOptions = Readonly<{
|
|
121
|
+
/** AbortSignal to cancel the transaction. */
|
|
52
122
|
abortSignal?: AbortSignal;
|
|
123
|
+
/** Commitment level for transaction confirmation. */
|
|
53
124
|
commitment?: Commitment;
|
|
125
|
+
/** Maximum number of times to retry sending the transaction. */
|
|
54
126
|
maxRetries?: bigint | number;
|
|
127
|
+
/** Minimum slot that the request can be evaluated at. */
|
|
55
128
|
minContextSlot?: Slot;
|
|
129
|
+
/** If true, skip the preflight transaction checks. */
|
|
56
130
|
skipPreflight?: boolean;
|
|
57
131
|
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Configuration for preparing an unstake (deactivate) transaction.
|
|
134
|
+
* Deactivating stake begins the cooldown period before withdrawal is possible.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const config: UnstakePrepareConfig = {
|
|
139
|
+
* authority: walletSession,
|
|
140
|
+
* stakeAccount: 'StakeAccountAddress...',
|
|
141
|
+
* };
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
58
144
|
export type UnstakePrepareConfig = Readonly<{
|
|
145
|
+
/** Authority that signed the original stake (must be the staker). */
|
|
59
146
|
authority: StakeAuthority;
|
|
147
|
+
/** Commitment level for RPC calls. */
|
|
60
148
|
commitment?: Commitment;
|
|
149
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
61
150
|
lifetime?: BlockhashLifetime;
|
|
151
|
+
/** The stake account address to deactivate. */
|
|
62
152
|
stakeAccount: Address | string;
|
|
153
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
63
154
|
transactionVersion?: TransactionVersion;
|
|
64
155
|
}>;
|
|
156
|
+
/** Options for sending unstake transactions. Same as StakeSendOptions. */
|
|
65
157
|
export type UnstakeSendOptions = StakeSendOptions;
|
|
158
|
+
/**
|
|
159
|
+
* Configuration for preparing a stake withdrawal transaction.
|
|
160
|
+
* Withdraws SOL from a deactivated stake account.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const config: WithdrawPrepareConfig = {
|
|
165
|
+
* amount: 10, // Withdraw 10 SOL
|
|
166
|
+
* authority: walletSession,
|
|
167
|
+
* destination: walletAddress,
|
|
168
|
+
* stakeAccount: 'StakeAccountAddress...',
|
|
169
|
+
* };
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
66
172
|
export type WithdrawPrepareConfig = Readonly<{
|
|
173
|
+
/** Amount of SOL to withdraw in lamports, decimal SOL, or string SOL. */
|
|
67
174
|
amount: StakeAmount;
|
|
175
|
+
/** Authority that signed the original stake (must be the withdrawer). */
|
|
68
176
|
authority: StakeAuthority;
|
|
177
|
+
/** Commitment level for RPC calls. */
|
|
69
178
|
commitment?: Commitment;
|
|
179
|
+
/** Destination address to receive the withdrawn SOL. */
|
|
70
180
|
destination: Address | string;
|
|
181
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
71
182
|
lifetime?: BlockhashLifetime;
|
|
183
|
+
/** The stake account address to withdraw from. */
|
|
72
184
|
stakeAccount: Address | string;
|
|
185
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
73
186
|
transactionVersion?: TransactionVersion;
|
|
74
187
|
}>;
|
|
188
|
+
/** Options for sending withdrawal transactions. Same as StakeSendOptions. */
|
|
75
189
|
export type WithdrawSendOptions = StakeSendOptions;
|
|
76
190
|
type PreparedUnstake = Readonly<{
|
|
77
191
|
commitment?: Commitment;
|
|
@@ -98,19 +212,110 @@ type PreparedStake = Readonly<{
|
|
|
98
212
|
plan?: TransactionPlan;
|
|
99
213
|
stakeAccount: TransactionSigner<string>;
|
|
100
214
|
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Helper interface for native SOL staking operations.
|
|
217
|
+
* Supports staking to validators, unstaking (deactivating), and withdrawing.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* import { createStakeHelper } from '@solana/client';
|
|
222
|
+
*
|
|
223
|
+
* const stakeHelper = createStakeHelper(runtime);
|
|
224
|
+
*
|
|
225
|
+
* // Stake SOL to a validator
|
|
226
|
+
* const stakeSig = await stakeHelper.sendStake({
|
|
227
|
+
* amount: 10, // 10 SOL
|
|
228
|
+
* authority: walletSession,
|
|
229
|
+
* validatorId: 'ValidatorVoteAccount...',
|
|
230
|
+
* });
|
|
231
|
+
*
|
|
232
|
+
* // Query stake accounts
|
|
233
|
+
* const accounts = await stakeHelper.getStakeAccounts(walletAddress);
|
|
234
|
+
*
|
|
235
|
+
* // Deactivate stake (begin cooldown)
|
|
236
|
+
* const unstakeSig = await stakeHelper.sendUnstake({
|
|
237
|
+
* authority: walletSession,
|
|
238
|
+
* stakeAccount: accounts[0].pubkey,
|
|
239
|
+
* });
|
|
240
|
+
*
|
|
241
|
+
* // Withdraw after cooldown (~2-3 days on mainnet)
|
|
242
|
+
* const withdrawSig = await stakeHelper.sendWithdraw({
|
|
243
|
+
* amount: 10,
|
|
244
|
+
* authority: walletSession,
|
|
245
|
+
* destination: walletAddress,
|
|
246
|
+
* stakeAccount: accounts[0].pubkey,
|
|
247
|
+
* });
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
101
250
|
export type StakeHelper = Readonly<{
|
|
251
|
+
/**
|
|
252
|
+
* Queries all stake accounts owned by a wallet.
|
|
253
|
+
* Optionally filter by validator to see stakes to a specific validator.
|
|
254
|
+
*/
|
|
102
255
|
getStakeAccounts(wallet: Address | string, validatorId?: Address | string): Promise<StakeAccount[]>;
|
|
256
|
+
/**
|
|
257
|
+
* Prepares a stake transaction without sending it.
|
|
258
|
+
* Creates a new stake account and delegates it to the specified validator.
|
|
259
|
+
*/
|
|
103
260
|
prepareStake(config: StakePrepareConfig): Promise<PreparedStake>;
|
|
261
|
+
/**
|
|
262
|
+
* Prepares an unstake (deactivate) transaction without sending it.
|
|
263
|
+
* Deactivating begins the cooldown period before funds can be withdrawn.
|
|
264
|
+
*/
|
|
104
265
|
prepareUnstake(config: UnstakePrepareConfig): Promise<PreparedUnstake>;
|
|
266
|
+
/**
|
|
267
|
+
* Prepares a withdrawal transaction without sending it.
|
|
268
|
+
* Can only withdraw from deactivated stake accounts after cooldown.
|
|
269
|
+
*/
|
|
105
270
|
prepareWithdraw(config: WithdrawPrepareConfig): Promise<PreparedWithdraw>;
|
|
271
|
+
/** Sends a previously prepared stake transaction. */
|
|
106
272
|
sendPreparedStake(prepared: PreparedStake, options?: StakeSendOptions): Promise<ReturnType<typeof signature>>;
|
|
273
|
+
/** Sends a previously prepared unstake transaction. */
|
|
107
274
|
sendPreparedUnstake(prepared: PreparedUnstake, options?: UnstakeSendOptions): Promise<ReturnType<typeof signature>>;
|
|
275
|
+
/** Sends a previously prepared withdrawal transaction. */
|
|
108
276
|
sendPreparedWithdraw(prepared: PreparedWithdraw, options?: WithdrawSendOptions): Promise<ReturnType<typeof signature>>;
|
|
277
|
+
/**
|
|
278
|
+
* Prepares and sends a stake transaction in one call.
|
|
279
|
+
* Creates a new stake account and delegates to the validator.
|
|
280
|
+
*/
|
|
109
281
|
sendStake(config: StakePrepareConfig, options?: StakeSendOptions): Promise<ReturnType<typeof signature>>;
|
|
282
|
+
/**
|
|
283
|
+
* Prepares and sends an unstake transaction in one call.
|
|
284
|
+
* Begins the cooldown period for the stake account.
|
|
285
|
+
*/
|
|
110
286
|
sendUnstake(config: UnstakePrepareConfig, options?: UnstakeSendOptions): Promise<ReturnType<typeof signature>>;
|
|
287
|
+
/**
|
|
288
|
+
* Prepares and sends a withdrawal transaction in one call.
|
|
289
|
+
* Withdraws SOL from a deactivated stake account.
|
|
290
|
+
*/
|
|
111
291
|
sendWithdraw(config: WithdrawPrepareConfig, options?: WithdrawSendOptions): Promise<ReturnType<typeof signature>>;
|
|
112
292
|
}>;
|
|
113
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Creates helpers for native SOL staking operations via the Stake Program.
|
|
295
|
+
* Supports full staking lifecycle: delegate, deactivate, and withdraw.
|
|
296
|
+
*
|
|
297
|
+
* @param runtime - The Solana client runtime with RPC connection.
|
|
298
|
+
* @returns A StakeHelper with methods for staking operations.
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```ts
|
|
302
|
+
* import { createClient } from '@solana/client';
|
|
303
|
+
*
|
|
304
|
+
* const client = createClient({ cluster: 'mainnet-beta' });
|
|
305
|
+
* const stake = client.helpers.stake;
|
|
306
|
+
*
|
|
307
|
+
* // Delegate 100 SOL to a validator
|
|
308
|
+
* const sig = await stake.sendStake({
|
|
309
|
+
* amount: 100,
|
|
310
|
+
* authority: session,
|
|
311
|
+
* validatorId: 'ValidatorVoteAccount...',
|
|
312
|
+
* });
|
|
313
|
+
*
|
|
314
|
+
* // Check stake accounts
|
|
315
|
+
* const accounts = await stake.getStakeAccounts(myWallet);
|
|
316
|
+
* console.log(`Found ${accounts.length} stake accounts`);
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
114
319
|
export declare function createStakeHelper(runtime: SolanaClientRuntime): StakeHelper;
|
|
115
320
|
export {};
|
|
116
321
|
//# sourceMappingURL=stake.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stake.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/stake.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,OAAO,EAIZ,KAAK,SAAS,EACd,KAAK,UAAU,EAOf,KAAK,IAAI,EAIT,SAAS,EACT,iCAAiC,EAEjC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,MAAM,aAAa,CAAC;AAUrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,KAAK,iBAAiB,GAAG,QAAQ,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC,CAAC;AAEH,KAAK,WAAW,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O,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;CAClH,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,WAAW,CAiV3E"}
|
|
@@ -2,85 +2,253 @@ import { type Address, type Blockhash, type Commitment, signature, signTransacti
|
|
|
2
2
|
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
3
|
import type { WalletSession } from '../wallet/types';
|
|
4
4
|
import type { SolTransferSendOptions } from './sol';
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* The Wrapped SOL (wSOL) mint address.
|
|
7
|
+
* This is the same address on all Solana clusters (mainnet, devnet, testnet).
|
|
8
|
+
* wSOL is an SPL token representation of native SOL, useful for DeFi protocols
|
|
9
|
+
* that require all assets to be SPL tokens.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { WRAPPED_SOL_MINT } from '@solana/client';
|
|
14
|
+
*
|
|
15
|
+
* console.log(WRAPPED_SOL_MINT); // 'So11111111111111111111111111111111111111112'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
6
18
|
export declare const WRAPPED_SOL_MINT: Address<"So11111111111111111111111111111111111111112">;
|
|
19
|
+
/**
|
|
20
|
+
* Blockhash and last valid block height for transaction lifetime.
|
|
21
|
+
* Used to ensure transactions expire after a certain block height.
|
|
22
|
+
*/
|
|
7
23
|
type BlockhashLifetime = Readonly<{
|
|
8
24
|
blockhash: Blockhash;
|
|
9
25
|
lastValidBlockHeight: bigint;
|
|
10
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Authority that signs wSOL wrap/unwrap transactions.
|
|
29
|
+
* Can be either a connected wallet session or a raw transaction signer.
|
|
30
|
+
*/
|
|
11
31
|
type WsolAuthority = TransactionSigner<string> | WalletSession;
|
|
12
32
|
type SignableWsolTransactionMessage = Parameters<typeof signTransactionMessageWithSigners>[0];
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for preparing a wrap SOL to wSOL transaction.
|
|
35
|
+
* Wrapping creates a wSOL token account and deposits native SOL into it.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const config: WsolWrapPrepareConfig = {
|
|
40
|
+
* amount: 1, // Wrap 1 SOL
|
|
41
|
+
* authority: walletSession,
|
|
42
|
+
* commitment: 'confirmed',
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
13
46
|
export type WsolWrapPrepareConfig = Readonly<{
|
|
14
|
-
/** Amount of SOL to wrap
|
|
47
|
+
/** Amount of SOL to wrap. Can be lamports (bigint), decimal SOL (number), or string SOL. */
|
|
15
48
|
amount: bigint | number | string;
|
|
16
|
-
/** Authority that signs the transaction
|
|
49
|
+
/** Authority that signs the transaction. Can be a WalletSession or raw TransactionSigner. */
|
|
17
50
|
authority: WsolAuthority;
|
|
18
|
-
/** Commitment level for
|
|
51
|
+
/** Commitment level for RPC calls. */
|
|
19
52
|
commitment?: Commitment;
|
|
20
|
-
/** Optional
|
|
53
|
+
/** Optional pre-fetched blockhash lifetime. If not provided, one will be fetched. */
|
|
21
54
|
lifetime?: BlockhashLifetime;
|
|
22
|
-
/** Owner of the wSOL account. Defaults to authority address. */
|
|
55
|
+
/** Owner of the wSOL account. Defaults to the authority's address. */
|
|
23
56
|
owner?: Address | string;
|
|
24
|
-
/** Transaction version
|
|
57
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
25
58
|
transactionVersion?: TransactionVersion;
|
|
26
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Configuration for preparing an unwrap wSOL to SOL transaction.
|
|
62
|
+
* Unwrapping closes the wSOL token account and returns all SOL to the owner.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const config: WsolUnwrapPrepareConfig = {
|
|
67
|
+
* authority: walletSession,
|
|
68
|
+
* commitment: 'confirmed',
|
|
69
|
+
* };
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
27
72
|
export type WsolUnwrapPrepareConfig = Readonly<{
|
|
28
|
-
/** Authority that signs the transaction
|
|
73
|
+
/** Authority that signs the transaction. Must be the owner of the wSOL account. */
|
|
29
74
|
authority: WsolAuthority;
|
|
30
|
-
/** Commitment level for
|
|
75
|
+
/** Commitment level for RPC calls. */
|
|
31
76
|
commitment?: Commitment;
|
|
32
|
-
/** Optional
|
|
77
|
+
/** Optional pre-fetched blockhash lifetime. If not provided, one will be fetched. */
|
|
33
78
|
lifetime?: BlockhashLifetime;
|
|
34
|
-
/** Owner of the wSOL account. Defaults to authority address. */
|
|
79
|
+
/** Owner of the wSOL account. Defaults to the authority's address. */
|
|
35
80
|
owner?: Address | string;
|
|
36
|
-
/** Transaction version
|
|
81
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
37
82
|
transactionVersion?: TransactionVersion;
|
|
38
83
|
}>;
|
|
84
|
+
/**
|
|
85
|
+
* A prepared wrap transaction ready to be signed and sent.
|
|
86
|
+
* Contains the transaction message and metadata needed for submission.
|
|
87
|
+
*/
|
|
39
88
|
type PreparedWsolWrap = Readonly<{
|
|
89
|
+
/** Amount being wrapped in lamports. */
|
|
40
90
|
amount: bigint;
|
|
91
|
+
/** The wSOL Associated Token Account address. */
|
|
41
92
|
ataAddress: Address;
|
|
93
|
+
/** Commitment level used. */
|
|
42
94
|
commitment?: Commitment;
|
|
95
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
43
96
|
lifetime: BlockhashLifetime;
|
|
97
|
+
/** The unsigned transaction message. */
|
|
44
98
|
message: SignableWsolTransactionMessage;
|
|
99
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
45
100
|
mode: 'partial' | 'send';
|
|
101
|
+
/** Owner of the wSOL account. */
|
|
46
102
|
owner: Address;
|
|
103
|
+
/** Transaction plan for execution. */
|
|
47
104
|
plan?: TransactionPlan;
|
|
105
|
+
/** The transaction signer. */
|
|
48
106
|
signer: TransactionSigner;
|
|
49
107
|
}>;
|
|
108
|
+
/**
|
|
109
|
+
* A prepared unwrap transaction ready to be signed and sent.
|
|
110
|
+
* Contains the transaction message and metadata needed for submission.
|
|
111
|
+
*/
|
|
50
112
|
type PreparedWsolUnwrap = Readonly<{
|
|
113
|
+
/** The wSOL Associated Token Account address being closed. */
|
|
51
114
|
ataAddress: Address;
|
|
115
|
+
/** Commitment level used. */
|
|
52
116
|
commitment?: Commitment;
|
|
117
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
53
118
|
lifetime: BlockhashLifetime;
|
|
119
|
+
/** The unsigned transaction message. */
|
|
54
120
|
message: SignableWsolTransactionMessage;
|
|
121
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
55
122
|
mode: 'partial' | 'send';
|
|
123
|
+
/** Owner receiving the unwrapped SOL. */
|
|
56
124
|
owner: Address;
|
|
125
|
+
/** Transaction plan for execution. */
|
|
57
126
|
plan?: TransactionPlan;
|
|
127
|
+
/** The transaction signer. */
|
|
58
128
|
signer: TransactionSigner;
|
|
59
129
|
}>;
|
|
130
|
+
/**
|
|
131
|
+
* Helper interface for wrapping and unwrapping SOL to/from wSOL.
|
|
132
|
+
* wSOL (Wrapped SOL) is an SPL token representation of native SOL.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* import { createWsolHelper } from '@solana/client';
|
|
137
|
+
*
|
|
138
|
+
* const wsol = createWsolHelper(runtime);
|
|
139
|
+
*
|
|
140
|
+
* // Check wSOL balance
|
|
141
|
+
* const balance = await wsol.fetchWsolBalance(walletAddress);
|
|
142
|
+
* console.log(`wSOL balance: ${balance.amount} lamports`);
|
|
143
|
+
*
|
|
144
|
+
* // Wrap 1 SOL to wSOL
|
|
145
|
+
* const wrapSig = await wsol.sendWrap({
|
|
146
|
+
* amount: 1, // 1 SOL
|
|
147
|
+
* authority: walletSession,
|
|
148
|
+
* });
|
|
149
|
+
*
|
|
150
|
+
* // Unwrap all wSOL back to SOL
|
|
151
|
+
* const unwrapSig = await wsol.sendUnwrap({
|
|
152
|
+
* authority: walletSession,
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
60
156
|
export type WsolHelper = Readonly<{
|
|
61
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* Derives the wSOL Associated Token Account (ATA) address for an owner.
|
|
159
|
+
* The ATA is a deterministic address based on the owner and wSOL mint.
|
|
160
|
+
*/
|
|
62
161
|
deriveWsolAddress(owner: Address | string): Promise<Address>;
|
|
63
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* Fetches the wSOL balance for an owner.
|
|
164
|
+
* Returns balance info including whether the wSOL account exists.
|
|
165
|
+
*/
|
|
64
166
|
fetchWsolBalance(owner: Address | string, commitment?: Commitment): Promise<WsolBalance>;
|
|
65
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Prepares a wrap transaction without sending it.
|
|
169
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
170
|
+
*/
|
|
66
171
|
prepareWrap(config: WsolWrapPrepareConfig): Promise<PreparedWsolWrap>;
|
|
67
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* Prepares an unwrap transaction without sending it.
|
|
174
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
175
|
+
*/
|
|
68
176
|
prepareUnwrap(config: WsolUnwrapPrepareConfig): Promise<PreparedWsolUnwrap>;
|
|
69
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Sends a previously prepared wrap transaction.
|
|
179
|
+
* Use this after prepareWrap() to submit the transaction.
|
|
180
|
+
*/
|
|
70
181
|
sendPreparedWrap(prepared: PreparedWsolWrap, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
71
|
-
/**
|
|
182
|
+
/**
|
|
183
|
+
* Sends a previously prepared unwrap transaction.
|
|
184
|
+
* Use this after prepareUnwrap() to submit the transaction.
|
|
185
|
+
*/
|
|
72
186
|
sendPreparedUnwrap(prepared: PreparedWsolUnwrap, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
73
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* Wraps native SOL to wSOL in one call.
|
|
189
|
+
* Creates the wSOL token account if it doesn't exist.
|
|
190
|
+
*/
|
|
74
191
|
sendWrap(config: WsolWrapPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
75
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* Unwraps all wSOL back to native SOL in one call.
|
|
194
|
+
* Closes the wSOL token account and returns all lamports to the owner.
|
|
195
|
+
*/
|
|
76
196
|
sendUnwrap(config: WsolUnwrapPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
77
197
|
}>;
|
|
198
|
+
/**
|
|
199
|
+
* wSOL balance information for an owner's Associated Token Account.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const balance = await wsolHelper.fetchWsolBalance(walletAddress);
|
|
204
|
+
* if (balance.exists) {
|
|
205
|
+
* console.log(`wSOL balance: ${balance.amount} lamports`);
|
|
206
|
+
* console.log(`Token account: ${balance.ataAddress}`);
|
|
207
|
+
* } else {
|
|
208
|
+
* console.log('No wSOL account exists');
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
78
212
|
export type WsolBalance = Readonly<{
|
|
213
|
+
/** wSOL amount in lamports. */
|
|
79
214
|
amount: bigint;
|
|
215
|
+
/** The wSOL Associated Token Account address. */
|
|
80
216
|
ataAddress: Address;
|
|
217
|
+
/** Whether the wSOL token account exists on-chain. */
|
|
81
218
|
exists: boolean;
|
|
82
219
|
}>;
|
|
83
|
-
/**
|
|
220
|
+
/**
|
|
221
|
+
* Creates helpers for wrapping native SOL to wSOL and unwrapping back.
|
|
222
|
+
* wSOL is useful for DeFi protocols that require all assets to be SPL tokens.
|
|
223
|
+
*
|
|
224
|
+
* @param runtime - The Solana client runtime with RPC connection.
|
|
225
|
+
* @returns A WsolHelper with methods for wrap/unwrap operations.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* import { createClient } from '@solana/client';
|
|
230
|
+
*
|
|
231
|
+
* const client = createClient({ cluster: 'devnet' });
|
|
232
|
+
* const wsol = client.helpers.wsol;
|
|
233
|
+
*
|
|
234
|
+
* // Wrap 0.5 SOL
|
|
235
|
+
* const wrapSig = await wsol.sendWrap({
|
|
236
|
+
* amount: 0.5,
|
|
237
|
+
* authority: session,
|
|
238
|
+
* });
|
|
239
|
+
* console.log('Wrapped SOL, signature:', wrapSig);
|
|
240
|
+
*
|
|
241
|
+
* // Check balance
|
|
242
|
+
* const balance = await wsol.fetchWsolBalance(myWallet);
|
|
243
|
+
* console.log(`wSOL: ${Number(balance.amount) / 1e9} SOL`);
|
|
244
|
+
*
|
|
245
|
+
* // Unwrap all wSOL back to native SOL
|
|
246
|
+
* const unwrapSig = await wsol.sendUnwrap({
|
|
247
|
+
* authority: session,
|
|
248
|
+
* });
|
|
249
|
+
* console.log('Unwrapped wSOL, signature:', unwrapSig);
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
84
252
|
export declare function createWsolHelper(runtime: SolanaClientRuntime): WsolHelper;
|
|
85
253
|
export {};
|
|
86
254
|
//# sourceMappingURL=wsol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsol.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/wsol.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,OAAO,EAIZ,KAAK,SAAS,EACd,KAAK,UAAU,EAWf,SAAS,EACT,iCAAiC,EAEjC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,MAAM,aAAa,CAAC;AAWrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MA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AO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IAClC,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,UAAU,EAAE,OAAO,CAAC;IACpB,sDAAsD;IACtD,MAAM,EAAE,OAAO,CAAC;CAChB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,UAAU,CAyNzE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/web3-compat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Compatibility layer that preserves the web3.js API while delegating to Kit primitives under the hood",
|
|
5
5
|
"exports": {
|
|
6
6
|
"edge-light": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@solana/transactions": "^5.0.0",
|
|
54
54
|
"@solana/web3.js": "^1.95.3",
|
|
55
55
|
"bs58": "^6.0.0",
|
|
56
|
-
"@solana/client": "1.4.
|
|
56
|
+
"@solana/client": "1.4.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^24"
|