@solana/client 0.1.3 → 0.2.0
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.cjs +240 -69
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +226 -70
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.native.mjs +226 -70
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +240 -69
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +226 -70
- package/dist/index.node.mjs.map +1 -1
- package/dist/types/actions.d.ts +9 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/client/createClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/serialization/state.d.ts +13 -1
- package/dist/types/serialization/state.d.ts.map +1 -1
- package/dist/types/types.d.ts +43 -10
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/wallet/connectors.d.ts +29 -0
- package/dist/types/wallet/connectors.d.ts.map +1 -0
- package/package.json +7 -1
package/dist/index.node.mjs
CHANGED
|
@@ -5,14 +5,44 @@ import { getTransferSolInstruction } from '@solana-program/system';
|
|
|
5
5
|
import { TOKEN_PROGRAM_ADDRESS, fetchMint, findAssociatedTokenPda, getCreateAssociatedTokenInstruction, getTransferCheckedInstruction } from '@solana-program/token';
|
|
6
6
|
import { getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction, COMPUTE_BUDGET_PROGRAM_ADDRESS, ComputeBudgetInstruction } from '@solana-program/compute-budget';
|
|
7
7
|
import { createStore } from 'zustand/vanilla';
|
|
8
|
-
import { getTransactionDecoder, getTransactionEncoder } from '@solana/transactions';
|
|
9
|
-
import { SolanaSignMessage, SolanaSignTransaction, SolanaSignAndSendTransaction } from '@solana/wallet-standard-features';
|
|
10
8
|
import { getWallets } from '@wallet-standard/app';
|
|
11
9
|
import { StandardConnect, StandardDisconnect } from '@wallet-standard/features';
|
|
10
|
+
import { getTransactionDecoder, getTransactionEncoder } from '@solana/transactions';
|
|
11
|
+
import { SolanaSignMessage, SolanaSignTransaction, SolanaSignAndSendTransaction } from '@solana/wallet-standard-features';
|
|
12
12
|
|
|
13
13
|
var __defProp = Object.defineProperty;
|
|
14
14
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
15
|
|
|
16
|
+
// src/actions.ts
|
|
17
|
+
function connectWallet(client, params) {
|
|
18
|
+
return client.actions.connectWallet(params.connectorId, params.options);
|
|
19
|
+
}
|
|
20
|
+
__name(connectWallet, "connectWallet");
|
|
21
|
+
function disconnectWallet(client, _params) {
|
|
22
|
+
return client.actions.disconnectWallet();
|
|
23
|
+
}
|
|
24
|
+
__name(disconnectWallet, "disconnectWallet");
|
|
25
|
+
function fetchAccount(client, params) {
|
|
26
|
+
return client.actions.fetchAccount(params.address, params.commitment);
|
|
27
|
+
}
|
|
28
|
+
__name(fetchAccount, "fetchAccount");
|
|
29
|
+
function fetchBalance(client, params) {
|
|
30
|
+
return client.actions.fetchBalance(params.address, params.commitment);
|
|
31
|
+
}
|
|
32
|
+
__name(fetchBalance, "fetchBalance");
|
|
33
|
+
function requestAirdrop(client, params) {
|
|
34
|
+
return client.actions.requestAirdrop(params.address, params.lamports);
|
|
35
|
+
}
|
|
36
|
+
__name(requestAirdrop, "requestAirdrop");
|
|
37
|
+
function sendTransaction(client, params) {
|
|
38
|
+
return client.actions.sendTransaction(params.transaction, params.commitment);
|
|
39
|
+
}
|
|
40
|
+
__name(sendTransaction, "sendTransaction");
|
|
41
|
+
function setCluster(client, params) {
|
|
42
|
+
return client.actions.setCluster(params.endpoint, params.config);
|
|
43
|
+
}
|
|
44
|
+
__name(setCluster, "setCluster");
|
|
45
|
+
|
|
16
46
|
// src/utils.ts
|
|
17
47
|
function deepFreeze(value) {
|
|
18
48
|
if (typeof value !== "object" || value === null) {
|
|
@@ -163,6 +193,94 @@ function createSolanaRpcClient(config) {
|
|
|
163
193
|
}
|
|
164
194
|
__name(createSolanaRpcClient, "createSolanaRpcClient");
|
|
165
195
|
|
|
196
|
+
// src/serialization/state.ts
|
|
197
|
+
var SERIALIZABLE_STATE_VERSION = 1;
|
|
198
|
+
function getInitialSerializableState(config) {
|
|
199
|
+
return {
|
|
200
|
+
autoconnect: false,
|
|
201
|
+
commitment: config.commitment,
|
|
202
|
+
endpoint: config.endpoint,
|
|
203
|
+
lastConnectorId: null,
|
|
204
|
+
lastPublicKey: null,
|
|
205
|
+
version: SERIALIZABLE_STATE_VERSION,
|
|
206
|
+
websocketEndpoint: config.websocketEndpoint
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
__name(getInitialSerializableState, "getInitialSerializableState");
|
|
210
|
+
function applySerializableState(config, state) {
|
|
211
|
+
if (!state) {
|
|
212
|
+
return config;
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
...config,
|
|
216
|
+
commitment: state.commitment ?? config.commitment,
|
|
217
|
+
endpoint: state.endpoint ?? config.endpoint,
|
|
218
|
+
websocketEndpoint: state.websocketEndpoint ?? config.websocketEndpoint
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
__name(applySerializableState, "applySerializableState");
|
|
222
|
+
function serializeSolanaState(state) {
|
|
223
|
+
return JSON.stringify(state);
|
|
224
|
+
}
|
|
225
|
+
__name(serializeSolanaState, "serializeSolanaState");
|
|
226
|
+
function deserializeSolanaState(json) {
|
|
227
|
+
if (!json) return null;
|
|
228
|
+
try {
|
|
229
|
+
const parsed = JSON.parse(json);
|
|
230
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
231
|
+
const state = parsed;
|
|
232
|
+
return {
|
|
233
|
+
autoconnect: state.autoconnect ?? false,
|
|
234
|
+
commitment: state.commitment,
|
|
235
|
+
endpoint: state.endpoint,
|
|
236
|
+
lastConnectorId: state.lastConnectorId ?? null,
|
|
237
|
+
lastPublicKey: state.lastPublicKey ?? null,
|
|
238
|
+
version: state.version ?? SERIALIZABLE_STATE_VERSION,
|
|
239
|
+
websocketEndpoint: state.websocketEndpoint
|
|
240
|
+
};
|
|
241
|
+
} catch {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
__name(deserializeSolanaState, "deserializeSolanaState");
|
|
246
|
+
function getSerializableStateSnapshot(client) {
|
|
247
|
+
const state = client.store.getState();
|
|
248
|
+
const wallet = state.wallet;
|
|
249
|
+
let lastConnectorId = null;
|
|
250
|
+
let lastPublicKey = null;
|
|
251
|
+
if ("connectorId" in wallet) {
|
|
252
|
+
lastConnectorId = wallet.connectorId ?? null;
|
|
253
|
+
if (wallet.status === "connected") {
|
|
254
|
+
lastPublicKey = wallet.session.account.address.toString();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
autoconnect: false,
|
|
259
|
+
commitment: state.cluster.commitment,
|
|
260
|
+
endpoint: state.cluster.endpoint,
|
|
261
|
+
lastConnectorId,
|
|
262
|
+
lastPublicKey,
|
|
263
|
+
version: SERIALIZABLE_STATE_VERSION,
|
|
264
|
+
websocketEndpoint: state.cluster.websocketEndpoint
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
__name(getSerializableStateSnapshot, "getSerializableStateSnapshot");
|
|
268
|
+
function subscribeSolanaState(client, listener) {
|
|
269
|
+
let previous = serializeSolanaState(getSerializableStateSnapshot(client));
|
|
270
|
+
listener(JSON.parse(previous));
|
|
271
|
+
const unsubscribe = client.store.subscribe(() => {
|
|
272
|
+
const snapshot = getSerializableStateSnapshot(client);
|
|
273
|
+
const serialized = serializeSolanaState(snapshot);
|
|
274
|
+
if (serialized === previous) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
previous = serialized;
|
|
278
|
+
listener(snapshot);
|
|
279
|
+
});
|
|
280
|
+
return unsubscribe;
|
|
281
|
+
}
|
|
282
|
+
__name(subscribeSolanaState, "subscribeSolanaState");
|
|
283
|
+
|
|
166
284
|
// src/wallet/registry.ts
|
|
167
285
|
function createWalletRegistry(connectors) {
|
|
168
286
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -214,7 +332,7 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
214
332
|
}
|
|
215
333
|
}
|
|
216
334
|
__name(warmupCluster, "warmupCluster");
|
|
217
|
-
async function
|
|
335
|
+
async function setCluster2(endpoint, config) {
|
|
218
336
|
const nextCommitment = config?.commitment ?? store.getState().cluster.commitment;
|
|
219
337
|
const websocketEndpoint = config?.websocketEndpoint ?? endpoint;
|
|
220
338
|
store.setState((state) => ({
|
|
@@ -265,8 +383,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
265
383
|
throw error;
|
|
266
384
|
}
|
|
267
385
|
}
|
|
268
|
-
__name(
|
|
269
|
-
async function
|
|
386
|
+
__name(setCluster2, "setCluster");
|
|
387
|
+
async function connectWallet2(connectorId, options = {}) {
|
|
270
388
|
const connector = connectors.get(connectorId);
|
|
271
389
|
if (!connector) {
|
|
272
390
|
throw new Error(`No wallet connector registered for id "${connectorId}".`);
|
|
@@ -305,8 +423,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
305
423
|
throw error;
|
|
306
424
|
}
|
|
307
425
|
}
|
|
308
|
-
__name(
|
|
309
|
-
async function
|
|
426
|
+
__name(connectWallet2, "connectWallet");
|
|
427
|
+
async function disconnectWallet3() {
|
|
310
428
|
const wallet = store.getState().wallet;
|
|
311
429
|
if (wallet.status === "disconnected") {
|
|
312
430
|
return;
|
|
@@ -328,8 +446,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
328
446
|
updateState(store, { wallet: { status: "disconnected" } });
|
|
329
447
|
}
|
|
330
448
|
}
|
|
331
|
-
__name(
|
|
332
|
-
async function
|
|
449
|
+
__name(disconnectWallet3, "disconnectWallet");
|
|
450
|
+
async function fetchBalance2(address4, commitment) {
|
|
333
451
|
const key = address4.toString();
|
|
334
452
|
store.setState((state) => ({
|
|
335
453
|
...state,
|
|
@@ -392,8 +510,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
392
510
|
throw error;
|
|
393
511
|
}
|
|
394
512
|
}
|
|
395
|
-
__name(
|
|
396
|
-
async function
|
|
513
|
+
__name(fetchBalance2, "fetchBalance");
|
|
514
|
+
async function fetchAccount2(address4, commitment) {
|
|
397
515
|
const key = address4.toString();
|
|
398
516
|
store.setState((state) => ({
|
|
399
517
|
...state,
|
|
@@ -457,8 +575,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
457
575
|
throw error;
|
|
458
576
|
}
|
|
459
577
|
}
|
|
460
|
-
__name(
|
|
461
|
-
async function
|
|
578
|
+
__name(fetchAccount2, "fetchAccount");
|
|
579
|
+
async function sendTransaction2(transaction, commitment) {
|
|
462
580
|
const targetCommitment = getCommitment(commitment);
|
|
463
581
|
const abortController = new AbortController();
|
|
464
582
|
const signature4 = await runtime.rpc.sendTransaction(getBase64EncodedWireTransaction(transaction), {
|
|
@@ -529,8 +647,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
529
647
|
throw error;
|
|
530
648
|
}
|
|
531
649
|
}
|
|
532
|
-
__name(
|
|
533
|
-
async function
|
|
650
|
+
__name(sendTransaction2, "sendTransaction");
|
|
651
|
+
async function requestAirdrop2(address4, lamports2) {
|
|
534
652
|
try {
|
|
535
653
|
const factory = airdropFactory({
|
|
536
654
|
rpc: runtime.rpc,
|
|
@@ -556,15 +674,15 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
556
674
|
throw error;
|
|
557
675
|
}
|
|
558
676
|
}
|
|
559
|
-
__name(
|
|
677
|
+
__name(requestAirdrop2, "requestAirdrop");
|
|
560
678
|
return {
|
|
561
|
-
connectWallet,
|
|
562
|
-
disconnectWallet:
|
|
563
|
-
fetchAccount,
|
|
564
|
-
fetchBalance,
|
|
565
|
-
requestAirdrop,
|
|
566
|
-
sendTransaction,
|
|
567
|
-
setCluster
|
|
679
|
+
connectWallet: connectWallet2,
|
|
680
|
+
disconnectWallet: disconnectWallet3,
|
|
681
|
+
fetchAccount: fetchAccount2,
|
|
682
|
+
fetchBalance: fetchBalance2,
|
|
683
|
+
requestAirdrop: requestAirdrop2,
|
|
684
|
+
sendTransaction: sendTransaction2,
|
|
685
|
+
setCluster: setCluster2
|
|
568
686
|
};
|
|
569
687
|
}
|
|
570
688
|
__name(createActions, "createActions");
|
|
@@ -998,13 +1116,13 @@ function createWalletTransactionSigner(session, config = {}) {
|
|
|
998
1116
|
}
|
|
999
1117
|
if (session.sendTransaction) {
|
|
1000
1118
|
const base58Encoder = getBase58Encoder();
|
|
1001
|
-
const
|
|
1119
|
+
const sendTransaction2 = session.sendTransaction.bind(session);
|
|
1002
1120
|
const sendingSigner = Object.freeze({
|
|
1003
1121
|
address: address4,
|
|
1004
1122
|
async signAndSendTransactions(transactions) {
|
|
1005
1123
|
const signatures = [];
|
|
1006
1124
|
for (const transaction of transactions) {
|
|
1007
|
-
const signatureString = await
|
|
1125
|
+
const signatureString = await sendTransaction2(
|
|
1008
1126
|
transaction,
|
|
1009
1127
|
commitment ? { commitment } : void 0
|
|
1010
1128
|
);
|
|
@@ -1190,7 +1308,7 @@ function createSplTokenHelper(runtime, config) {
|
|
|
1190
1308
|
return ata;
|
|
1191
1309
|
}
|
|
1192
1310
|
__name(deriveAssociatedTokenAddress, "deriveAssociatedTokenAddress");
|
|
1193
|
-
async function
|
|
1311
|
+
async function fetchBalance2(owner, commitment) {
|
|
1194
1312
|
const ataAddress = await deriveAssociatedTokenAddress(owner);
|
|
1195
1313
|
const decimals = await resolveDecimals(commitment);
|
|
1196
1314
|
try {
|
|
@@ -1215,7 +1333,7 @@ function createSplTokenHelper(runtime, config) {
|
|
|
1215
1333
|
};
|
|
1216
1334
|
}
|
|
1217
1335
|
}
|
|
1218
|
-
__name(
|
|
1336
|
+
__name(fetchBalance2, "fetchBalance");
|
|
1219
1337
|
async function prepareTransfer(config2) {
|
|
1220
1338
|
const commitment = config2.commitment;
|
|
1221
1339
|
const lifetime = await resolveLifetime2(runtime, commitment, config2.lifetime);
|
|
@@ -1332,7 +1450,7 @@ function createSplTokenHelper(runtime, config) {
|
|
|
1332
1450
|
__name(sendTransfer, "sendTransfer");
|
|
1333
1451
|
return {
|
|
1334
1452
|
deriveAssociatedTokenAddress,
|
|
1335
|
-
fetchBalance,
|
|
1453
|
+
fetchBalance: fetchBalance2,
|
|
1336
1454
|
prepareTransfer,
|
|
1337
1455
|
sendPreparedTransfer,
|
|
1338
1456
|
sendTransfer
|
|
@@ -2010,25 +2128,26 @@ __name(createWatchers, "createWatchers");
|
|
|
2010
2128
|
|
|
2011
2129
|
// src/client/createClient.ts
|
|
2012
2130
|
function createClient(config) {
|
|
2013
|
-
const
|
|
2014
|
-
const
|
|
2131
|
+
const hydratedConfig = config.initialState ? applySerializableState(config, config.initialState) : config;
|
|
2132
|
+
const commitment = hydratedConfig.commitment ?? "confirmed";
|
|
2133
|
+
const websocketEndpoint = hydratedConfig.websocketEndpoint ?? hydratedConfig.endpoint;
|
|
2015
2134
|
const initialState = createInitialClientState({
|
|
2016
2135
|
commitment,
|
|
2017
|
-
endpoint:
|
|
2136
|
+
endpoint: hydratedConfig.endpoint,
|
|
2018
2137
|
websocketEndpoint
|
|
2019
2138
|
});
|
|
2020
2139
|
const store = config.createStore ? config.createStore(initialState) : createClientStore(initialState);
|
|
2021
|
-
const rpcClient =
|
|
2140
|
+
const rpcClient = hydratedConfig.rpcClient ?? createSolanaRpcClient({
|
|
2022
2141
|
commitment,
|
|
2023
|
-
endpoint:
|
|
2142
|
+
endpoint: hydratedConfig.endpoint,
|
|
2024
2143
|
websocketEndpoint
|
|
2025
2144
|
});
|
|
2026
2145
|
const runtime = {
|
|
2027
2146
|
rpc: rpcClient.rpc,
|
|
2028
2147
|
rpcSubscriptions: rpcClient.rpcSubscriptions
|
|
2029
2148
|
};
|
|
2030
|
-
const connectors = createWalletRegistry(
|
|
2031
|
-
const logger = createLogger(
|
|
2149
|
+
const connectors = createWalletRegistry(hydratedConfig.walletConnectors ?? []);
|
|
2150
|
+
const logger = createLogger(hydratedConfig.logger);
|
|
2032
2151
|
const actions = createActions({ connectors, logger, runtime, store });
|
|
2033
2152
|
const watchers = createWatchers({ logger, runtime, store });
|
|
2034
2153
|
const helpers = createClientHelpers(runtime, store);
|
|
@@ -2040,7 +2159,7 @@ function createClient(config) {
|
|
|
2040
2159
|
},
|
|
2041
2160
|
lastUpdatedAt: now()
|
|
2042
2161
|
}));
|
|
2043
|
-
actions.setCluster(
|
|
2162
|
+
actions.setCluster(hydratedConfig.endpoint, { commitment, websocketEndpoint }).catch(
|
|
2044
2163
|
(error) => logger({
|
|
2045
2164
|
data: formatError(error),
|
|
2046
2165
|
level: "error",
|
|
@@ -2244,33 +2363,6 @@ function lamportsFromJson(value) {
|
|
|
2244
2363
|
return lamports(value, "lamports");
|
|
2245
2364
|
}
|
|
2246
2365
|
__name(lamportsFromJson, "lamportsFromJson");
|
|
2247
|
-
|
|
2248
|
-
// src/serialization/state.ts
|
|
2249
|
-
var SERIALIZABLE_STATE_VERSION = 1;
|
|
2250
|
-
function getInitialSerializableState(config) {
|
|
2251
|
-
return {
|
|
2252
|
-
autoconnect: false,
|
|
2253
|
-
commitment: config.commitment,
|
|
2254
|
-
endpoint: config.endpoint,
|
|
2255
|
-
lastConnectorId: null,
|
|
2256
|
-
lastPublicKey: null,
|
|
2257
|
-
version: SERIALIZABLE_STATE_VERSION,
|
|
2258
|
-
websocketEndpoint: config.websocketEndpoint
|
|
2259
|
-
};
|
|
2260
|
-
}
|
|
2261
|
-
__name(getInitialSerializableState, "getInitialSerializableState");
|
|
2262
|
-
function applySerializableState(config, state) {
|
|
2263
|
-
if (!state) {
|
|
2264
|
-
return config;
|
|
2265
|
-
}
|
|
2266
|
-
return {
|
|
2267
|
-
...config,
|
|
2268
|
-
commitment: state.commitment ?? config.commitment,
|
|
2269
|
-
endpoint: state.endpoint ?? config.endpoint,
|
|
2270
|
-
websocketEndpoint: state.websocketEndpoint ?? config.websocketEndpoint
|
|
2271
|
-
};
|
|
2272
|
-
}
|
|
2273
|
-
__name(applySerializableState, "applySerializableState");
|
|
2274
2366
|
var COMMITMENT_PRIORITY = {
|
|
2275
2367
|
processed: 0,
|
|
2276
2368
|
confirmed: 1,
|
|
@@ -2683,13 +2775,13 @@ function getChain(account) {
|
|
|
2683
2775
|
return preferred;
|
|
2684
2776
|
}
|
|
2685
2777
|
__name(getChain, "getChain");
|
|
2686
|
-
async function
|
|
2778
|
+
async function disconnectWallet2(wallet) {
|
|
2687
2779
|
const disconnectFeature = wallet.features[StandardDisconnect];
|
|
2688
2780
|
if (disconnectFeature) {
|
|
2689
2781
|
await disconnectFeature.disconnect();
|
|
2690
2782
|
}
|
|
2691
2783
|
}
|
|
2692
|
-
__name(
|
|
2784
|
+
__name(disconnectWallet2, "disconnectWallet");
|
|
2693
2785
|
function createWalletStandardConnector(wallet, options = {}) {
|
|
2694
2786
|
const metadata = {
|
|
2695
2787
|
canAutoConnect: options.canAutoConnect ?? Boolean(wallet.features[StandardConnect]),
|
|
@@ -2737,7 +2829,7 @@ function createWalletStandardConnector(wallet, options = {}) {
|
|
|
2737
2829
|
const [output] = await signTransactionFeature.signTransaction(request);
|
|
2738
2830
|
return transactionDecoder.decode(output.signedTransaction);
|
|
2739
2831
|
} : void 0;
|
|
2740
|
-
const
|
|
2832
|
+
const sendTransaction2 = signAndSendFeature ? async (transaction, config) => {
|
|
2741
2833
|
const wireBytes = new Uint8Array(transactionEncoder.encode(transaction));
|
|
2742
2834
|
const chain = options.defaultChain ?? getChain(primaryAccount) ?? "solana:mainnet-beta";
|
|
2743
2835
|
const [output] = await signAndSendFeature.signAndSendTransaction({
|
|
@@ -2751,21 +2843,21 @@ function createWalletStandardConnector(wallet, options = {}) {
|
|
|
2751
2843
|
return base58Decoder.decode(output.signature);
|
|
2752
2844
|
} : void 0;
|
|
2753
2845
|
async function disconnectSession() {
|
|
2754
|
-
await
|
|
2846
|
+
await disconnectWallet2(wallet);
|
|
2755
2847
|
}
|
|
2756
2848
|
__name(disconnectSession, "disconnectSession");
|
|
2757
2849
|
return {
|
|
2758
2850
|
account: sessionAccount,
|
|
2759
2851
|
connector: metadata,
|
|
2760
2852
|
disconnect: disconnectSession,
|
|
2761
|
-
sendTransaction,
|
|
2853
|
+
sendTransaction: sendTransaction2,
|
|
2762
2854
|
signMessage,
|
|
2763
2855
|
signTransaction
|
|
2764
2856
|
};
|
|
2765
2857
|
}
|
|
2766
2858
|
__name(connect, "connect");
|
|
2767
2859
|
async function disconnect() {
|
|
2768
|
-
await
|
|
2860
|
+
await disconnectWallet2(wallet);
|
|
2769
2861
|
}
|
|
2770
2862
|
__name(disconnect, "disconnect");
|
|
2771
2863
|
function isSupported() {
|
|
@@ -2821,6 +2913,70 @@ function watchWalletStandardConnectors(onChange, options = {}) {
|
|
|
2821
2913
|
}
|
|
2822
2914
|
__name(watchWalletStandardConnectors, "watchWalletStandardConnectors");
|
|
2823
2915
|
|
|
2824
|
-
|
|
2916
|
+
// src/wallet/connectors.ts
|
|
2917
|
+
function autoDiscover(options = {}) {
|
|
2918
|
+
const { get } = getWallets();
|
|
2919
|
+
const wallets = get().filter((wallet) => options.filter ? options.filter(wallet) : true);
|
|
2920
|
+
const connectors = wallets.map((wallet) => createWalletStandardConnector(wallet, options.overrides?.(wallet)));
|
|
2921
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2922
|
+
return connectors.filter((connector) => {
|
|
2923
|
+
if (seen.has(connector.id)) return false;
|
|
2924
|
+
seen.add(connector.id);
|
|
2925
|
+
return true;
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
__name(autoDiscover, "autoDiscover");
|
|
2929
|
+
function injected(options) {
|
|
2930
|
+
const connector = {
|
|
2931
|
+
canAutoConnect: true,
|
|
2932
|
+
id: "wallet-standard:injected",
|
|
2933
|
+
kind: "wallet-standard",
|
|
2934
|
+
name: "Injected Wallet",
|
|
2935
|
+
ready: typeof window !== "undefined",
|
|
2936
|
+
async connect() {
|
|
2937
|
+
const wallets = getWallets().get();
|
|
2938
|
+
const first = wallets.find((wallet) => StandardConnect in wallet.features);
|
|
2939
|
+
if (!first) {
|
|
2940
|
+
throw new Error("No Wallet Standard wallets available.");
|
|
2941
|
+
}
|
|
2942
|
+
return createWalletStandardConnector(first, options).connect();
|
|
2943
|
+
},
|
|
2944
|
+
async disconnect() {
|
|
2945
|
+
},
|
|
2946
|
+
isSupported() {
|
|
2947
|
+
return typeof window !== "undefined";
|
|
2948
|
+
}
|
|
2949
|
+
};
|
|
2950
|
+
return connector;
|
|
2951
|
+
}
|
|
2952
|
+
__name(injected, "injected");
|
|
2953
|
+
function filterByName(name) {
|
|
2954
|
+
const lower = name.toLowerCase();
|
|
2955
|
+
return (wallet) => wallet.name.toLowerCase().includes(lower);
|
|
2956
|
+
}
|
|
2957
|
+
__name(filterByName, "filterByName");
|
|
2958
|
+
function phantom(options) {
|
|
2959
|
+
return autoDiscover({
|
|
2960
|
+
filter: filterByName("phantom"),
|
|
2961
|
+
overrides: /* @__PURE__ */ __name(() => ({ ...options, id: "wallet-standard:phantom" }), "overrides")
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2964
|
+
__name(phantom, "phantom");
|
|
2965
|
+
function solflare(options) {
|
|
2966
|
+
return autoDiscover({
|
|
2967
|
+
filter: filterByName("solflare"),
|
|
2968
|
+
overrides: /* @__PURE__ */ __name(() => ({ ...options, id: "wallet-standard:solflare" }), "overrides")
|
|
2969
|
+
});
|
|
2970
|
+
}
|
|
2971
|
+
__name(solflare, "solflare");
|
|
2972
|
+
function backpack(options) {
|
|
2973
|
+
return autoDiscover({
|
|
2974
|
+
filter: filterByName("backpack"),
|
|
2975
|
+
overrides: /* @__PURE__ */ __name(() => ({ ...options, id: "wallet-standard:backpack" }), "overrides")
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
__name(backpack, "backpack");
|
|
2979
|
+
|
|
2980
|
+
export { LAMPORTS_PER_SOL, SIGNATURE_STATUS_TIMEOUT_MS, applyRatio, applySerializableState, assertDecimals, assertNonNegative, autoDiscover, backpack, bigintFromJson, bigintToJson, checkedAdd, checkedDivide, checkedMultiply, checkedSubtract, confirmationMeetsCommitment, connectWallet, createAsyncState, createClient, createClientStore, createDefaultClientStore, createInitialAsyncState, createInitialClientState, createRatio, createSolTransferController, createSolTransferHelper, createSolanaRpcClient, createSplTokenHelper, createSplTransferController, createTokenAmount, createTransactionHelper, createTransactionPoolController, createTransactionRecipe, createWalletRegistry, createWalletStandardConnector, deriveConfirmationStatus, deserializeSolanaState, disconnectWallet, fetchAccount, fetchBalance, getInitialSerializableState, getWalletStandardConnectors, injected, insertReferenceKey, insertReferenceKeys, lamports, lamportsFromJson, lamportsFromSol, lamportsMath, lamportsToJson, lamportsToSolString, normalizeSignature, phantom, pow10, prepareTransaction, requestAirdrop, resolveCluster, sendTransaction, serializeSolanaState, setCluster, solflare, stableStringify, subscribeSolanaState, toAddress2 as toAddress, toAddressString, toBigint2 as toBigint, transactionToBase64, transactionToBase64WithSigners, watchWalletStandardConnectors };
|
|
2825
2981
|
//# sourceMappingURL=index.node.mjs.map
|
|
2826
2982
|
//# sourceMappingURL=index.node.mjs.map
|