@solana/web3-compat 0.0.16 → 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/index.browser.mjs +1 -1
- package/dist/index.native.mjs +1 -1
- package/dist/types/client/src/client/actions.d.ts +3 -1
- package/dist/types/client/src/client/actions.d.ts.map +1 -1
- package/dist/types/client/src/client/createClient.d.ts.map +1 -1
- package/dist/types/client/src/client/createClientHelpers.d.ts +2 -1
- package/dist/types/client/src/client/createClientHelpers.d.ts.map +1 -1
- package/dist/types/client/src/client/defaultClient.d.ts +2 -1
- package/dist/types/client/src/client/defaultClient.d.ts.map +1 -1
- package/dist/types/client/src/client/watchers.d.ts +2 -1
- package/dist/types/client/src/client/watchers.d.ts.map +1 -1
- package/dist/types/client/src/controllers/wsolController.d.ts +30 -0
- package/dist/types/client/src/controllers/wsolController.d.ts.map +1 -0
- package/dist/types/client/src/features/sol.d.ts +118 -2
- package/dist/types/client/src/features/sol.d.ts.map +1 -1
- package/dist/types/client/src/features/spl.d.ts +165 -2
- package/dist/types/client/src/features/spl.d.ts.map +1 -1
- package/dist/types/client/src/features/stake.d.ts +208 -2
- package/dist/types/client/src/features/stake.d.ts.map +1 -1
- package/dist/types/client/src/features/transactions.d.ts +2 -1
- package/dist/types/client/src/features/transactions.d.ts.map +1 -1
- package/dist/types/client/src/features/wsol.d.ts +254 -0
- package/dist/types/client/src/features/wsol.d.ts.map +1 -0
- package/dist/types/client/src/index.d.ts +5 -1
- package/dist/types/client/src/index.d.ts.map +1 -1
- package/dist/types/client/src/rpc/types.d.ts +8 -0
- package/dist/types/client/src/rpc/types.d.ts.map +1 -0
- package/dist/types/client/src/signers/walletTransactionSigner.d.ts +1 -1
- package/dist/types/client/src/signers/walletTransactionSigner.d.ts.map +1 -1
- package/dist/types/client/src/types.d.ts +6 -64
- package/dist/types/client/src/types.d.ts.map +1 -1
- package/dist/types/client/src/wallet/connectors.d.ts +1 -1
- package/dist/types/client/src/wallet/connectors.d.ts.map +1 -1
- package/dist/types/client/src/wallet/registry.d.ts +1 -1
- package/dist/types/client/src/wallet/registry.d.ts.map +1 -1
- package/dist/types/client/src/wallet/standard.d.ts +1 -1
- package/dist/types/client/src/wallet/standard.d.ts.map +1 -1
- package/dist/types/client/src/wallet/types.d.ts +60 -0
- package/dist/types/client/src/wallet/types.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1,12 +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
|
-
import type { SolanaClientRuntime
|
|
2
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
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
|
+
*/
|
|
3
8
|
type BlockhashLifetime = Readonly<{
|
|
4
9
|
blockhash: Blockhash;
|
|
5
10
|
lastValidBlockHeight: bigint;
|
|
6
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
|
+
*/
|
|
7
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
|
+
*/
|
|
8
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
|
+
*/
|
|
9
37
|
export type StakeAccount = {
|
|
38
|
+
/** The stake account's public key address. */
|
|
10
39
|
pubkey: Address;
|
|
11
40
|
account: {
|
|
12
41
|
data: {
|
|
@@ -14,63 +43,149 @@ export type StakeAccount = {
|
|
|
14
43
|
info: {
|
|
15
44
|
stake?: {
|
|
16
45
|
delegation?: {
|
|
46
|
+
/** The validator vote account receiving the stake. */
|
|
17
47
|
voter: string;
|
|
48
|
+
/** Amount of lamports delegated. */
|
|
18
49
|
stake: string;
|
|
50
|
+
/** Epoch when stake became active. */
|
|
19
51
|
activationEpoch: string;
|
|
52
|
+
/** Epoch when stake will deactivate (max value if active). */
|
|
20
53
|
deactivationEpoch: string;
|
|
21
54
|
};
|
|
22
55
|
};
|
|
23
56
|
meta?: {
|
|
57
|
+
/** Rent-exempt reserve in lamports. */
|
|
24
58
|
rentExemptReserve: string;
|
|
25
59
|
authorized: {
|
|
60
|
+
/** Address authorized to delegate/undelegate. */
|
|
26
61
|
staker: string;
|
|
62
|
+
/** Address authorized to withdraw. */
|
|
27
63
|
withdrawer: string;
|
|
28
64
|
};
|
|
29
65
|
lockup: {
|
|
66
|
+
/** Unix timestamp when lockup expires (0 if none). */
|
|
30
67
|
unixTimestamp: number;
|
|
68
|
+
/** Epoch when lockup expires (0 if none). */
|
|
31
69
|
epoch: number;
|
|
70
|
+
/** Custodian who can modify lockup (system program if none). */
|
|
32
71
|
custodian: string;
|
|
33
72
|
};
|
|
34
73
|
};
|
|
35
74
|
};
|
|
36
75
|
};
|
|
37
76
|
};
|
|
77
|
+
/** Total lamports in the stake account. */
|
|
38
78
|
lamports: bigint;
|
|
39
79
|
};
|
|
40
80
|
};
|
|
41
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
|
+
*/
|
|
42
95
|
export type StakePrepareConfig = Readonly<{
|
|
96
|
+
/** Amount of SOL to stake in lamports, decimal SOL, or string SOL. */
|
|
43
97
|
amount: StakeAmount;
|
|
98
|
+
/** Authority that signs the transaction. Will be set as staker and withdrawer. */
|
|
44
99
|
authority: StakeAuthority;
|
|
100
|
+
/** Commitment level for RPC calls. */
|
|
45
101
|
commitment?: Commitment;
|
|
102
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
46
103
|
lifetime?: BlockhashLifetime;
|
|
104
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
47
105
|
transactionVersion?: TransactionVersion;
|
|
106
|
+
/** The validator's vote account address to delegate stake to. */
|
|
48
107
|
validatorId: Address | string;
|
|
49
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
|
+
*/
|
|
50
120
|
export type StakeSendOptions = Readonly<{
|
|
121
|
+
/** AbortSignal to cancel the transaction. */
|
|
51
122
|
abortSignal?: AbortSignal;
|
|
123
|
+
/** Commitment level for transaction confirmation. */
|
|
52
124
|
commitment?: Commitment;
|
|
125
|
+
/** Maximum number of times to retry sending the transaction. */
|
|
53
126
|
maxRetries?: bigint | number;
|
|
127
|
+
/** Minimum slot that the request can be evaluated at. */
|
|
54
128
|
minContextSlot?: Slot;
|
|
129
|
+
/** If true, skip the preflight transaction checks. */
|
|
55
130
|
skipPreflight?: boolean;
|
|
56
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
|
+
*/
|
|
57
144
|
export type UnstakePrepareConfig = Readonly<{
|
|
145
|
+
/** Authority that signed the original stake (must be the staker). */
|
|
58
146
|
authority: StakeAuthority;
|
|
147
|
+
/** Commitment level for RPC calls. */
|
|
59
148
|
commitment?: Commitment;
|
|
149
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
60
150
|
lifetime?: BlockhashLifetime;
|
|
151
|
+
/** The stake account address to deactivate. */
|
|
61
152
|
stakeAccount: Address | string;
|
|
153
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
62
154
|
transactionVersion?: TransactionVersion;
|
|
63
155
|
}>;
|
|
156
|
+
/** Options for sending unstake transactions. Same as StakeSendOptions. */
|
|
64
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
|
+
*/
|
|
65
172
|
export type WithdrawPrepareConfig = Readonly<{
|
|
173
|
+
/** Amount of SOL to withdraw in lamports, decimal SOL, or string SOL. */
|
|
66
174
|
amount: StakeAmount;
|
|
175
|
+
/** Authority that signed the original stake (must be the withdrawer). */
|
|
67
176
|
authority: StakeAuthority;
|
|
177
|
+
/** Commitment level for RPC calls. */
|
|
68
178
|
commitment?: Commitment;
|
|
179
|
+
/** Destination address to receive the withdrawn SOL. */
|
|
69
180
|
destination: Address | string;
|
|
181
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
70
182
|
lifetime?: BlockhashLifetime;
|
|
183
|
+
/** The stake account address to withdraw from. */
|
|
71
184
|
stakeAccount: Address | string;
|
|
185
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
72
186
|
transactionVersion?: TransactionVersion;
|
|
73
187
|
}>;
|
|
188
|
+
/** Options for sending withdrawal transactions. Same as StakeSendOptions. */
|
|
74
189
|
export type WithdrawSendOptions = StakeSendOptions;
|
|
75
190
|
type PreparedUnstake = Readonly<{
|
|
76
191
|
commitment?: Commitment;
|
|
@@ -97,19 +212,110 @@ type PreparedStake = Readonly<{
|
|
|
97
212
|
plan?: TransactionPlan;
|
|
98
213
|
stakeAccount: TransactionSigner<string>;
|
|
99
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
|
+
*/
|
|
100
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
|
+
*/
|
|
101
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
|
+
*/
|
|
102
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
|
+
*/
|
|
103
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
|
+
*/
|
|
104
270
|
prepareWithdraw(config: WithdrawPrepareConfig): Promise<PreparedWithdraw>;
|
|
271
|
+
/** Sends a previously prepared stake transaction. */
|
|
105
272
|
sendPreparedStake(prepared: PreparedStake, options?: StakeSendOptions): Promise<ReturnType<typeof signature>>;
|
|
273
|
+
/** Sends a previously prepared unstake transaction. */
|
|
106
274
|
sendPreparedUnstake(prepared: PreparedUnstake, options?: UnstakeSendOptions): Promise<ReturnType<typeof signature>>;
|
|
275
|
+
/** Sends a previously prepared withdrawal transaction. */
|
|
107
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
|
+
*/
|
|
108
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
|
+
*/
|
|
109
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
|
+
*/
|
|
110
291
|
sendWithdraw(config: WithdrawPrepareConfig, options?: WithdrawSendOptions): Promise<ReturnType<typeof signature>>;
|
|
111
292
|
}>;
|
|
112
|
-
/**
|
|
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
|
+
*/
|
|
113
319
|
export declare function createStakeHelper(runtime: SolanaClientRuntime): StakeHelper;
|
|
114
320
|
export {};
|
|
115
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;
|
|
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,C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G,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IACzG;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IAC/G;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,qBAAqB,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;CAClH,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,WAAW,CAiV3E"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Address, appendTransactionMessageInstruction, Blockhash, Commitment, InstructionPlan, Slot, TransactionPlan, TransactionPlannerConfig, TransactionSigner, TransactionVersion } from '@solana/kit';
|
|
2
2
|
import { signature, signTransactionMessageWithSigners } from '@solana/kit';
|
|
3
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
4
|
import { type PrepareTransactionMessage, type PrepareTransactionOptions } from '../transactions/prepareTransaction';
|
|
4
|
-
import type {
|
|
5
|
+
import type { WalletSession } from '../wallet/types';
|
|
5
6
|
type BlockhashLifetime = Readonly<{
|
|
6
7
|
blockhash: Blockhash;
|
|
7
8
|
lastValidBlockHeight: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/transactions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,OAAO,EACP,mCAAmC,EACnC,SAAS,EACT,UAAU,EACV,eAAe,EAEf,IAAI,EACJ,eAAe,EACf,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAeN,SAAS,EACT,iCAAiC,E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SAAS,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAoGH,wBAAsB,uBAAuB,CAC5C,OAAO,EAAE,yBAAyB,EAClC,OAAO,EAAE,wBAAwB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CA0E5B;AAWD,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,mBAAmB,EAC5B,qBAAqB,EAAE,MAAM,UAAU,GACrC,iBAAiB,CAgKnB"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { type Address, type Blockhash, type Commitment, signature, signTransactionMessageWithSigners, type TransactionPlan, type TransactionSigner, type TransactionVersion } from '@solana/kit';
|
|
2
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
|
+
import type { WalletSession } from '../wallet/types';
|
|
4
|
+
import type { SolTransferSendOptions } from './sol';
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
23
|
+
type BlockhashLifetime = Readonly<{
|
|
24
|
+
blockhash: Blockhash;
|
|
25
|
+
lastValidBlockHeight: bigint;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Authority that signs wSOL wrap/unwrap transactions.
|
|
29
|
+
* Can be either a connected wallet session or a raw transaction signer.
|
|
30
|
+
*/
|
|
31
|
+
type WsolAuthority = TransactionSigner<string> | WalletSession;
|
|
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
|
+
*/
|
|
46
|
+
export type WsolWrapPrepareConfig = Readonly<{
|
|
47
|
+
/** Amount of SOL to wrap. Can be lamports (bigint), decimal SOL (number), or string SOL. */
|
|
48
|
+
amount: bigint | number | string;
|
|
49
|
+
/** Authority that signs the transaction. Can be a WalletSession or raw TransactionSigner. */
|
|
50
|
+
authority: WsolAuthority;
|
|
51
|
+
/** Commitment level for RPC calls. */
|
|
52
|
+
commitment?: Commitment;
|
|
53
|
+
/** Optional pre-fetched blockhash lifetime. If not provided, one will be fetched. */
|
|
54
|
+
lifetime?: BlockhashLifetime;
|
|
55
|
+
/** Owner of the wSOL account. Defaults to the authority's address. */
|
|
56
|
+
owner?: Address | string;
|
|
57
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
58
|
+
transactionVersion?: TransactionVersion;
|
|
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
|
+
*/
|
|
72
|
+
export type WsolUnwrapPrepareConfig = Readonly<{
|
|
73
|
+
/** Authority that signs the transaction. Must be the owner of the wSOL account. */
|
|
74
|
+
authority: WsolAuthority;
|
|
75
|
+
/** Commitment level for RPC calls. */
|
|
76
|
+
commitment?: Commitment;
|
|
77
|
+
/** Optional pre-fetched blockhash lifetime. If not provided, one will be fetched. */
|
|
78
|
+
lifetime?: BlockhashLifetime;
|
|
79
|
+
/** Owner of the wSOL account. Defaults to the authority's address. */
|
|
80
|
+
owner?: Address | string;
|
|
81
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
82
|
+
transactionVersion?: TransactionVersion;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* A prepared wrap transaction ready to be signed and sent.
|
|
86
|
+
* Contains the transaction message and metadata needed for submission.
|
|
87
|
+
*/
|
|
88
|
+
type PreparedWsolWrap = Readonly<{
|
|
89
|
+
/** Amount being wrapped in lamports. */
|
|
90
|
+
amount: bigint;
|
|
91
|
+
/** The wSOL Associated Token Account address. */
|
|
92
|
+
ataAddress: Address;
|
|
93
|
+
/** Commitment level used. */
|
|
94
|
+
commitment?: Commitment;
|
|
95
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
96
|
+
lifetime: BlockhashLifetime;
|
|
97
|
+
/** The unsigned transaction message. */
|
|
98
|
+
message: SignableWsolTransactionMessage;
|
|
99
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
100
|
+
mode: 'partial' | 'send';
|
|
101
|
+
/** Owner of the wSOL account. */
|
|
102
|
+
owner: Address;
|
|
103
|
+
/** Transaction plan for execution. */
|
|
104
|
+
plan?: TransactionPlan;
|
|
105
|
+
/** The transaction signer. */
|
|
106
|
+
signer: TransactionSigner;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* A prepared unwrap transaction ready to be signed and sent.
|
|
110
|
+
* Contains the transaction message and metadata needed for submission.
|
|
111
|
+
*/
|
|
112
|
+
type PreparedWsolUnwrap = Readonly<{
|
|
113
|
+
/** The wSOL Associated Token Account address being closed. */
|
|
114
|
+
ataAddress: Address;
|
|
115
|
+
/** Commitment level used. */
|
|
116
|
+
commitment?: Commitment;
|
|
117
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
118
|
+
lifetime: BlockhashLifetime;
|
|
119
|
+
/** The unsigned transaction message. */
|
|
120
|
+
message: SignableWsolTransactionMessage;
|
|
121
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
122
|
+
mode: 'partial' | 'send';
|
|
123
|
+
/** Owner receiving the unwrapped SOL. */
|
|
124
|
+
owner: Address;
|
|
125
|
+
/** Transaction plan for execution. */
|
|
126
|
+
plan?: TransactionPlan;
|
|
127
|
+
/** The transaction signer. */
|
|
128
|
+
signer: TransactionSigner;
|
|
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
|
+
*/
|
|
156
|
+
export type WsolHelper = Readonly<{
|
|
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
|
+
*/
|
|
161
|
+
deriveWsolAddress(owner: Address | string): Promise<Address>;
|
|
162
|
+
/**
|
|
163
|
+
* Fetches the wSOL balance for an owner.
|
|
164
|
+
* Returns balance info including whether the wSOL account exists.
|
|
165
|
+
*/
|
|
166
|
+
fetchWsolBalance(owner: Address | string, commitment?: Commitment): Promise<WsolBalance>;
|
|
167
|
+
/**
|
|
168
|
+
* Prepares a wrap transaction without sending it.
|
|
169
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
170
|
+
*/
|
|
171
|
+
prepareWrap(config: WsolWrapPrepareConfig): Promise<PreparedWsolWrap>;
|
|
172
|
+
/**
|
|
173
|
+
* Prepares an unwrap transaction without sending it.
|
|
174
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
175
|
+
*/
|
|
176
|
+
prepareUnwrap(config: WsolUnwrapPrepareConfig): Promise<PreparedWsolUnwrap>;
|
|
177
|
+
/**
|
|
178
|
+
* Sends a previously prepared wrap transaction.
|
|
179
|
+
* Use this after prepareWrap() to submit the transaction.
|
|
180
|
+
*/
|
|
181
|
+
sendPreparedWrap(prepared: PreparedWsolWrap, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
182
|
+
/**
|
|
183
|
+
* Sends a previously prepared unwrap transaction.
|
|
184
|
+
* Use this after prepareUnwrap() to submit the transaction.
|
|
185
|
+
*/
|
|
186
|
+
sendPreparedUnwrap(prepared: PreparedWsolUnwrap, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
187
|
+
/**
|
|
188
|
+
* Wraps native SOL to wSOL in one call.
|
|
189
|
+
* Creates the wSOL token account if it doesn't exist.
|
|
190
|
+
*/
|
|
191
|
+
sendWrap(config: WsolWrapPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
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
|
+
*/
|
|
196
|
+
sendUnwrap(config: WsolUnwrapPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
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
|
+
*/
|
|
212
|
+
export type WsolBalance = Readonly<{
|
|
213
|
+
/** wSOL amount in lamports. */
|
|
214
|
+
amount: bigint;
|
|
215
|
+
/** The wSOL Associated Token Account address. */
|
|
216
|
+
ataAddress: Address;
|
|
217
|
+
/** Whether the wSOL token account exists on-chain. */
|
|
218
|
+
exists: boolean;
|
|
219
|
+
}>;
|
|
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
|
+
*/
|
|
252
|
+
export declare function createWsolHelper(runtime: SolanaClientRuntime): WsolHelper;
|
|
253
|
+
export {};
|
|
254
|
+
//# sourceMappingURL=wsol.d.ts.map
|
|
@@ -0,0 +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,MAAM,cAAc,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,wDAAyD,CAAC;AAEvF;;;GAGG;AACH,KAAK,iBAAiB,GAAG,QAAQ,CAAC;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB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;;;OAGG;IACH,gBAAgB,CACf,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,kBAAkB,CACjB,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,qBAAqB,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;IACjH;;;OAGG;IACH,UAAU,CACT,MAAM,EAAE,uBAAuB,EAC/B,OAAO,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"}
|
|
@@ -5,15 +5,18 @@ export { type CreateDefaultClientOptions, createDefaultClient, defaultWalletConn
|
|
|
5
5
|
export { createSolTransferController, type SolTransferController, type SolTransferControllerConfig, type SolTransferInput, } from './controllers/solTransferController';
|
|
6
6
|
export { createSplTransferController, type SplTransferController, type SplTransferControllerConfig, type SplTransferInput, } from './controllers/splTransferController';
|
|
7
7
|
export { createStakeController, type StakeController, type StakeControllerConfig, type StakeInput, type UnstakeInput, type WithdrawInput, } from './controllers/stakeController';
|
|
8
|
+
export { createWsolController, type WsolController, type WsolControllerConfig, type WsolUnwrapInput, type WsolWrapInput, } from './controllers/wsolController';
|
|
8
9
|
export { createSolTransferHelper, type SolTransferHelper, type SolTransferPrepareConfig, type SolTransferSendOptions, } from './features/sol';
|
|
9
10
|
export { createSplTokenHelper, type SplTokenBalance, type SplTokenHelper, type SplTokenHelperConfig, type SplTransferPrepareConfig, } from './features/spl';
|
|
10
11
|
export { createStakeHelper, type StakeAccount, type StakeHelper, type StakePrepareConfig, type StakeSendOptions, type UnstakePrepareConfig, type UnstakeSendOptions, type WithdrawPrepareConfig, type WithdrawSendOptions, } from './features/stake';
|
|
11
12
|
export { createTransactionHelper, createTransactionRecipe, type TransactionHelper, type TransactionInstructionInput, type TransactionPrepareAndSendRequest, type TransactionPrepared, type TransactionPrepareRequest, type TransactionRecipe, type TransactionRecipeContext, type TransactionSendOptions, type TransactionSignOptions, } from './features/transactions';
|
|
13
|
+
export { createWsolHelper, WRAPPED_SOL_MINT, type WsolBalance, type WsolHelper, type WsolUnwrapPrepareConfig, type WsolWrapPrepareConfig, } from './features/wsol';
|
|
12
14
|
export { createTokenAmount, type FormatAmountOptions, type ParseAmountOptions, type TokenAmountMath, } from './numeric/amounts';
|
|
13
15
|
export { LAMPORTS_PER_SOL, lamports, lamportsFromSol, lamportsMath, lamportsToSolString } from './numeric/lamports';
|
|
14
16
|
export { assertDecimals, assertNonNegative, type BigintLike, checkedAdd, checkedDivide, checkedMultiply, checkedSubtract, pow10, toBigint, } from './numeric/math';
|
|
15
17
|
export { type ApplyRatioOptions, applyRatio, createRatio, type Ratio, type RoundingMode } from './numeric/rational';
|
|
16
18
|
export { type CreateSolanaRpcClientConfig, createSolanaRpcClient, type SendAndConfirmTransactionOptions, type SimulateTransactionOptions, type SolanaRpcClient, } from './rpc/createSolanaRpcClient';
|
|
19
|
+
export type { SolanaClientRuntime } from './rpc/types';
|
|
17
20
|
export { bigintFromJson, bigintToJson, lamportsFromJson, lamportsToJson } from './serialization/json';
|
|
18
21
|
export { applySerializableState, deserializeSolanaState, getInitialSerializableState, serializeSolanaState, subscribeSolanaState, } from './serialization/state';
|
|
19
22
|
export { type ConfirmationCommitment, confirmationMeetsCommitment, deriveConfirmationStatus, normalizeSignature, SIGNATURE_STATUS_TIMEOUT_MS, type SignatureLike, type SignatureStatusLike, } from './signatures/status';
|
|
@@ -22,11 +25,12 @@ export { transactionToBase64, transactionToBase64WithSigners, } from './transact
|
|
|
22
25
|
export { type PrepareTransactionConfig, type PrepareTransactionMessage, type PrepareTransactionOptions, prepareTransaction, } from './transactions/prepareTransaction';
|
|
23
26
|
export { insertReferenceKey, insertReferenceKeys } from './transactions/referenceKeys';
|
|
24
27
|
export { createTransactionPoolController, type LatestBlockhashCache, type TransactionInstructionList, type TransactionPoolConfig, type TransactionPoolController, type TransactionPoolPrepareAndSendOptions, type TransactionPoolPrepareOptions, type TransactionPoolSendOptions, type TransactionPoolSignOptions, } from './transactions/transactionPoolController';
|
|
25
|
-
export type { AccountCache, AccountCacheEntry, AccountWatcherConfig, AddressLookupTableData, BalanceWatcherConfig, ClientActions, ClientHelpers, ClientLogger, ClientState, ClientStore, ClientWatchers, ConnectWalletParameters, ConnectWalletReturnType, CreateStoreFn, DisconnectWalletParameters, DisconnectWalletReturnType, FetchAccountParameters, FetchAccountReturnType, FetchBalanceParameters, FetchBalanceReturnType, FetchLookupTableParameters, FetchLookupTableReturnType, FetchLookupTablesParameters, FetchLookupTablesReturnType, FetchNonceAccountParameters, FetchNonceAccountReturnType, NonceAccountData, RequestAirdropParameters, RequestAirdropReturnType, SendTransactionParameters, SendTransactionReturnType, SerializableSolanaState, SetClusterParameters, SetClusterReturnType, SolanaClient, SolanaClientConfig,
|
|
28
|
+
export type { AccountCache, AccountCacheEntry, AccountWatcherConfig, AddressLookupTableData, BalanceWatcherConfig, ClientActions, ClientHelpers, ClientLogger, ClientState, ClientStore, ClientWatchers, ConnectWalletParameters, ConnectWalletReturnType, CreateStoreFn, DisconnectWalletParameters, DisconnectWalletReturnType, FetchAccountParameters, FetchAccountReturnType, FetchBalanceParameters, FetchBalanceReturnType, FetchLookupTableParameters, FetchLookupTableReturnType, FetchLookupTablesParameters, FetchLookupTablesReturnType, FetchNonceAccountParameters, FetchNonceAccountReturnType, NonceAccountData, RequestAirdropParameters, RequestAirdropReturnType, SendTransactionParameters, SendTransactionReturnType, SerializableSolanaState, SetClusterParameters, SetClusterReturnType, SolanaClient, SolanaClientConfig, } from './types';
|
|
26
29
|
export { type AddressLike, toAddress, toAddressString } from './utils/addressLike';
|
|
27
30
|
export { type ClusterMoniker, resolveCluster } from './utils/cluster';
|
|
28
31
|
export { stableStringify } from './utils/stableStringify';
|
|
29
32
|
export { autoDiscover, backpack, injected, metamask, phantom, solflare } from './wallet/connectors';
|
|
30
33
|
export { createWalletRegistry } from './wallet/registry';
|
|
31
34
|
export { createWalletStandardConnector, getWalletStandardConnectors, watchWalletStandardConnectors, } from './wallet/standard';
|
|
35
|
+
export type { WalletConnector, WalletConnectorMetadata, WalletRegistry, WalletSession, WalletStatus, } from './wallet/types';
|
|
32
36
|
//# sourceMappingURL=index.d.ts.map
|