@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.browser.cjs
CHANGED
|
@@ -7,14 +7,44 @@ var system = require('@solana-program/system');
|
|
|
7
7
|
var token = require('@solana-program/token');
|
|
8
8
|
var computeBudget = require('@solana-program/compute-budget');
|
|
9
9
|
var vanilla = require('zustand/vanilla');
|
|
10
|
-
var transactions = require('@solana/transactions');
|
|
11
|
-
var walletStandardFeatures = require('@solana/wallet-standard-features');
|
|
12
10
|
var app = require('@wallet-standard/app');
|
|
13
11
|
var features = require('@wallet-standard/features');
|
|
12
|
+
var transactions = require('@solana/transactions');
|
|
13
|
+
var walletStandardFeatures = require('@solana/wallet-standard-features');
|
|
14
14
|
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
16
16
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
17
|
|
|
18
|
+
// src/actions.ts
|
|
19
|
+
function connectWallet(client, params) {
|
|
20
|
+
return client.actions.connectWallet(params.connectorId, params.options);
|
|
21
|
+
}
|
|
22
|
+
__name(connectWallet, "connectWallet");
|
|
23
|
+
function disconnectWallet(client, _params) {
|
|
24
|
+
return client.actions.disconnectWallet();
|
|
25
|
+
}
|
|
26
|
+
__name(disconnectWallet, "disconnectWallet");
|
|
27
|
+
function fetchAccount(client, params) {
|
|
28
|
+
return client.actions.fetchAccount(params.address, params.commitment);
|
|
29
|
+
}
|
|
30
|
+
__name(fetchAccount, "fetchAccount");
|
|
31
|
+
function fetchBalance(client, params) {
|
|
32
|
+
return client.actions.fetchBalance(params.address, params.commitment);
|
|
33
|
+
}
|
|
34
|
+
__name(fetchBalance, "fetchBalance");
|
|
35
|
+
function requestAirdrop(client, params) {
|
|
36
|
+
return client.actions.requestAirdrop(params.address, params.lamports);
|
|
37
|
+
}
|
|
38
|
+
__name(requestAirdrop, "requestAirdrop");
|
|
39
|
+
function sendTransaction(client, params) {
|
|
40
|
+
return client.actions.sendTransaction(params.transaction, params.commitment);
|
|
41
|
+
}
|
|
42
|
+
__name(sendTransaction, "sendTransaction");
|
|
43
|
+
function setCluster(client, params) {
|
|
44
|
+
return client.actions.setCluster(params.endpoint, params.config);
|
|
45
|
+
}
|
|
46
|
+
__name(setCluster, "setCluster");
|
|
47
|
+
|
|
18
48
|
// src/utils.ts
|
|
19
49
|
function deepFreeze(value) {
|
|
20
50
|
if (typeof value !== "object" || value === null) {
|
|
@@ -165,6 +195,94 @@ function createSolanaRpcClient(config) {
|
|
|
165
195
|
}
|
|
166
196
|
__name(createSolanaRpcClient, "createSolanaRpcClient");
|
|
167
197
|
|
|
198
|
+
// src/serialization/state.ts
|
|
199
|
+
var SERIALIZABLE_STATE_VERSION = 1;
|
|
200
|
+
function getInitialSerializableState(config) {
|
|
201
|
+
return {
|
|
202
|
+
autoconnect: false,
|
|
203
|
+
commitment: config.commitment,
|
|
204
|
+
endpoint: config.endpoint,
|
|
205
|
+
lastConnectorId: null,
|
|
206
|
+
lastPublicKey: null,
|
|
207
|
+
version: SERIALIZABLE_STATE_VERSION,
|
|
208
|
+
websocketEndpoint: config.websocketEndpoint
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
__name(getInitialSerializableState, "getInitialSerializableState");
|
|
212
|
+
function applySerializableState(config, state) {
|
|
213
|
+
if (!state) {
|
|
214
|
+
return config;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
...config,
|
|
218
|
+
commitment: state.commitment ?? config.commitment,
|
|
219
|
+
endpoint: state.endpoint ?? config.endpoint,
|
|
220
|
+
websocketEndpoint: state.websocketEndpoint ?? config.websocketEndpoint
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
__name(applySerializableState, "applySerializableState");
|
|
224
|
+
function serializeSolanaState(state) {
|
|
225
|
+
return JSON.stringify(state);
|
|
226
|
+
}
|
|
227
|
+
__name(serializeSolanaState, "serializeSolanaState");
|
|
228
|
+
function deserializeSolanaState(json) {
|
|
229
|
+
if (!json) return null;
|
|
230
|
+
try {
|
|
231
|
+
const parsed = JSON.parse(json);
|
|
232
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
233
|
+
const state = parsed;
|
|
234
|
+
return {
|
|
235
|
+
autoconnect: state.autoconnect ?? false,
|
|
236
|
+
commitment: state.commitment,
|
|
237
|
+
endpoint: state.endpoint,
|
|
238
|
+
lastConnectorId: state.lastConnectorId ?? null,
|
|
239
|
+
lastPublicKey: state.lastPublicKey ?? null,
|
|
240
|
+
version: state.version ?? SERIALIZABLE_STATE_VERSION,
|
|
241
|
+
websocketEndpoint: state.websocketEndpoint
|
|
242
|
+
};
|
|
243
|
+
} catch {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
__name(deserializeSolanaState, "deserializeSolanaState");
|
|
248
|
+
function getSerializableStateSnapshot(client) {
|
|
249
|
+
const state = client.store.getState();
|
|
250
|
+
const wallet = state.wallet;
|
|
251
|
+
let lastConnectorId = null;
|
|
252
|
+
let lastPublicKey = null;
|
|
253
|
+
if ("connectorId" in wallet) {
|
|
254
|
+
lastConnectorId = wallet.connectorId ?? null;
|
|
255
|
+
if (wallet.status === "connected") {
|
|
256
|
+
lastPublicKey = wallet.session.account.address.toString();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
autoconnect: false,
|
|
261
|
+
commitment: state.cluster.commitment,
|
|
262
|
+
endpoint: state.cluster.endpoint,
|
|
263
|
+
lastConnectorId,
|
|
264
|
+
lastPublicKey,
|
|
265
|
+
version: SERIALIZABLE_STATE_VERSION,
|
|
266
|
+
websocketEndpoint: state.cluster.websocketEndpoint
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
__name(getSerializableStateSnapshot, "getSerializableStateSnapshot");
|
|
270
|
+
function subscribeSolanaState(client, listener) {
|
|
271
|
+
let previous = serializeSolanaState(getSerializableStateSnapshot(client));
|
|
272
|
+
listener(JSON.parse(previous));
|
|
273
|
+
const unsubscribe = client.store.subscribe(() => {
|
|
274
|
+
const snapshot = getSerializableStateSnapshot(client);
|
|
275
|
+
const serialized = serializeSolanaState(snapshot);
|
|
276
|
+
if (serialized === previous) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
previous = serialized;
|
|
280
|
+
listener(snapshot);
|
|
281
|
+
});
|
|
282
|
+
return unsubscribe;
|
|
283
|
+
}
|
|
284
|
+
__name(subscribeSolanaState, "subscribeSolanaState");
|
|
285
|
+
|
|
168
286
|
// src/wallet/registry.ts
|
|
169
287
|
function createWalletRegistry(connectors) {
|
|
170
288
|
const byId = /* @__PURE__ */ new Map();
|
|
@@ -216,7 +334,7 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
216
334
|
}
|
|
217
335
|
}
|
|
218
336
|
__name(warmupCluster, "warmupCluster");
|
|
219
|
-
async function
|
|
337
|
+
async function setCluster2(endpoint, config) {
|
|
220
338
|
const nextCommitment = config?.commitment ?? store.getState().cluster.commitment;
|
|
221
339
|
const websocketEndpoint = config?.websocketEndpoint ?? endpoint;
|
|
222
340
|
store.setState((state) => ({
|
|
@@ -267,8 +385,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
267
385
|
throw error;
|
|
268
386
|
}
|
|
269
387
|
}
|
|
270
|
-
__name(
|
|
271
|
-
async function
|
|
388
|
+
__name(setCluster2, "setCluster");
|
|
389
|
+
async function connectWallet2(connectorId, options = {}) {
|
|
272
390
|
const connector = connectors.get(connectorId);
|
|
273
391
|
if (!connector) {
|
|
274
392
|
throw new Error(`No wallet connector registered for id "${connectorId}".`);
|
|
@@ -307,8 +425,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
307
425
|
throw error;
|
|
308
426
|
}
|
|
309
427
|
}
|
|
310
|
-
__name(
|
|
311
|
-
async function
|
|
428
|
+
__name(connectWallet2, "connectWallet");
|
|
429
|
+
async function disconnectWallet3() {
|
|
312
430
|
const wallet = store.getState().wallet;
|
|
313
431
|
if (wallet.status === "disconnected") {
|
|
314
432
|
return;
|
|
@@ -330,8 +448,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
330
448
|
updateState(store, { wallet: { status: "disconnected" } });
|
|
331
449
|
}
|
|
332
450
|
}
|
|
333
|
-
__name(
|
|
334
|
-
async function
|
|
451
|
+
__name(disconnectWallet3, "disconnectWallet");
|
|
452
|
+
async function fetchBalance2(address4, commitment) {
|
|
335
453
|
const key = address4.toString();
|
|
336
454
|
store.setState((state) => ({
|
|
337
455
|
...state,
|
|
@@ -394,8 +512,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
394
512
|
throw error;
|
|
395
513
|
}
|
|
396
514
|
}
|
|
397
|
-
__name(
|
|
398
|
-
async function
|
|
515
|
+
__name(fetchBalance2, "fetchBalance");
|
|
516
|
+
async function fetchAccount2(address4, commitment) {
|
|
399
517
|
const key = address4.toString();
|
|
400
518
|
store.setState((state) => ({
|
|
401
519
|
...state,
|
|
@@ -459,8 +577,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
459
577
|
throw error;
|
|
460
578
|
}
|
|
461
579
|
}
|
|
462
|
-
__name(
|
|
463
|
-
async function
|
|
580
|
+
__name(fetchAccount2, "fetchAccount");
|
|
581
|
+
async function sendTransaction2(transaction, commitment) {
|
|
464
582
|
const targetCommitment = getCommitment(commitment);
|
|
465
583
|
const abortController = new AbortController();
|
|
466
584
|
const signature4 = await runtime.rpc.sendTransaction(kit.getBase64EncodedWireTransaction(transaction), {
|
|
@@ -531,8 +649,8 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
531
649
|
throw error;
|
|
532
650
|
}
|
|
533
651
|
}
|
|
534
|
-
__name(
|
|
535
|
-
async function
|
|
652
|
+
__name(sendTransaction2, "sendTransaction");
|
|
653
|
+
async function requestAirdrop2(address4, lamports2) {
|
|
536
654
|
try {
|
|
537
655
|
const factory = kit.airdropFactory({
|
|
538
656
|
rpc: runtime.rpc,
|
|
@@ -558,15 +676,15 @@ function createActions({ connectors, logger: inputLogger, runtime, store }) {
|
|
|
558
676
|
throw error;
|
|
559
677
|
}
|
|
560
678
|
}
|
|
561
|
-
__name(
|
|
679
|
+
__name(requestAirdrop2, "requestAirdrop");
|
|
562
680
|
return {
|
|
563
|
-
connectWallet,
|
|
564
|
-
disconnectWallet:
|
|
565
|
-
fetchAccount,
|
|
566
|
-
fetchBalance,
|
|
567
|
-
requestAirdrop,
|
|
568
|
-
sendTransaction,
|
|
569
|
-
setCluster
|
|
681
|
+
connectWallet: connectWallet2,
|
|
682
|
+
disconnectWallet: disconnectWallet3,
|
|
683
|
+
fetchAccount: fetchAccount2,
|
|
684
|
+
fetchBalance: fetchBalance2,
|
|
685
|
+
requestAirdrop: requestAirdrop2,
|
|
686
|
+
sendTransaction: sendTransaction2,
|
|
687
|
+
setCluster: setCluster2
|
|
570
688
|
};
|
|
571
689
|
}
|
|
572
690
|
__name(createActions, "createActions");
|
|
@@ -1000,13 +1118,13 @@ function createWalletTransactionSigner(session, config = {}) {
|
|
|
1000
1118
|
}
|
|
1001
1119
|
if (session.sendTransaction) {
|
|
1002
1120
|
const base58Encoder = codecsStrings.getBase58Encoder();
|
|
1003
|
-
const
|
|
1121
|
+
const sendTransaction2 = session.sendTransaction.bind(session);
|
|
1004
1122
|
const sendingSigner = Object.freeze({
|
|
1005
1123
|
address: address4,
|
|
1006
1124
|
async signAndSendTransactions(transactions) {
|
|
1007
1125
|
const signatures = [];
|
|
1008
1126
|
for (const transaction of transactions) {
|
|
1009
|
-
const signatureString = await
|
|
1127
|
+
const signatureString = await sendTransaction2(
|
|
1010
1128
|
transaction,
|
|
1011
1129
|
commitment ? { commitment } : void 0
|
|
1012
1130
|
);
|
|
@@ -1192,7 +1310,7 @@ function createSplTokenHelper(runtime, config) {
|
|
|
1192
1310
|
return ata;
|
|
1193
1311
|
}
|
|
1194
1312
|
__name(deriveAssociatedTokenAddress, "deriveAssociatedTokenAddress");
|
|
1195
|
-
async function
|
|
1313
|
+
async function fetchBalance2(owner, commitment) {
|
|
1196
1314
|
const ataAddress = await deriveAssociatedTokenAddress(owner);
|
|
1197
1315
|
const decimals = await resolveDecimals(commitment);
|
|
1198
1316
|
try {
|
|
@@ -1217,7 +1335,7 @@ function createSplTokenHelper(runtime, config) {
|
|
|
1217
1335
|
};
|
|
1218
1336
|
}
|
|
1219
1337
|
}
|
|
1220
|
-
__name(
|
|
1338
|
+
__name(fetchBalance2, "fetchBalance");
|
|
1221
1339
|
async function prepareTransfer(config2) {
|
|
1222
1340
|
const commitment = config2.commitment;
|
|
1223
1341
|
const lifetime = await resolveLifetime2(runtime, commitment, config2.lifetime);
|
|
@@ -1334,7 +1452,7 @@ function createSplTokenHelper(runtime, config) {
|
|
|
1334
1452
|
__name(sendTransfer, "sendTransfer");
|
|
1335
1453
|
return {
|
|
1336
1454
|
deriveAssociatedTokenAddress,
|
|
1337
|
-
fetchBalance,
|
|
1455
|
+
fetchBalance: fetchBalance2,
|
|
1338
1456
|
prepareTransfer,
|
|
1339
1457
|
sendPreparedTransfer,
|
|
1340
1458
|
sendTransfer
|
|
@@ -2012,25 +2130,26 @@ __name(createWatchers, "createWatchers");
|
|
|
2012
2130
|
|
|
2013
2131
|
// src/client/createClient.ts
|
|
2014
2132
|
function createClient(config) {
|
|
2015
|
-
const
|
|
2016
|
-
const
|
|
2133
|
+
const hydratedConfig = config.initialState ? applySerializableState(config, config.initialState) : config;
|
|
2134
|
+
const commitment = hydratedConfig.commitment ?? "confirmed";
|
|
2135
|
+
const websocketEndpoint = hydratedConfig.websocketEndpoint ?? hydratedConfig.endpoint;
|
|
2017
2136
|
const initialState = createInitialClientState({
|
|
2018
2137
|
commitment,
|
|
2019
|
-
endpoint:
|
|
2138
|
+
endpoint: hydratedConfig.endpoint,
|
|
2020
2139
|
websocketEndpoint
|
|
2021
2140
|
});
|
|
2022
2141
|
const store = config.createStore ? config.createStore(initialState) : createClientStore(initialState);
|
|
2023
|
-
const rpcClient =
|
|
2142
|
+
const rpcClient = hydratedConfig.rpcClient ?? createSolanaRpcClient({
|
|
2024
2143
|
commitment,
|
|
2025
|
-
endpoint:
|
|
2144
|
+
endpoint: hydratedConfig.endpoint,
|
|
2026
2145
|
websocketEndpoint
|
|
2027
2146
|
});
|
|
2028
2147
|
const runtime = {
|
|
2029
2148
|
rpc: rpcClient.rpc,
|
|
2030
2149
|
rpcSubscriptions: rpcClient.rpcSubscriptions
|
|
2031
2150
|
};
|
|
2032
|
-
const connectors = createWalletRegistry(
|
|
2033
|
-
const logger = createLogger(
|
|
2151
|
+
const connectors = createWalletRegistry(hydratedConfig.walletConnectors ?? []);
|
|
2152
|
+
const logger = createLogger(hydratedConfig.logger);
|
|
2034
2153
|
const actions = createActions({ connectors, logger, runtime, store });
|
|
2035
2154
|
const watchers = createWatchers({ logger, runtime, store });
|
|
2036
2155
|
const helpers = createClientHelpers(runtime, store);
|
|
@@ -2042,7 +2161,7 @@ function createClient(config) {
|
|
|
2042
2161
|
},
|
|
2043
2162
|
lastUpdatedAt: now()
|
|
2044
2163
|
}));
|
|
2045
|
-
actions.setCluster(
|
|
2164
|
+
actions.setCluster(hydratedConfig.endpoint, { commitment, websocketEndpoint }).catch(
|
|
2046
2165
|
(error) => logger({
|
|
2047
2166
|
data: formatError(error),
|
|
2048
2167
|
level: "error",
|
|
@@ -2246,33 +2365,6 @@ function lamportsFromJson(value) {
|
|
|
2246
2365
|
return lamports(value, "lamports");
|
|
2247
2366
|
}
|
|
2248
2367
|
__name(lamportsFromJson, "lamportsFromJson");
|
|
2249
|
-
|
|
2250
|
-
// src/serialization/state.ts
|
|
2251
|
-
var SERIALIZABLE_STATE_VERSION = 1;
|
|
2252
|
-
function getInitialSerializableState(config) {
|
|
2253
|
-
return {
|
|
2254
|
-
autoconnect: false,
|
|
2255
|
-
commitment: config.commitment,
|
|
2256
|
-
endpoint: config.endpoint,
|
|
2257
|
-
lastConnectorId: null,
|
|
2258
|
-
lastPublicKey: null,
|
|
2259
|
-
version: SERIALIZABLE_STATE_VERSION,
|
|
2260
|
-
websocketEndpoint: config.websocketEndpoint
|
|
2261
|
-
};
|
|
2262
|
-
}
|
|
2263
|
-
__name(getInitialSerializableState, "getInitialSerializableState");
|
|
2264
|
-
function applySerializableState(config, state) {
|
|
2265
|
-
if (!state) {
|
|
2266
|
-
return config;
|
|
2267
|
-
}
|
|
2268
|
-
return {
|
|
2269
|
-
...config,
|
|
2270
|
-
commitment: state.commitment ?? config.commitment,
|
|
2271
|
-
endpoint: state.endpoint ?? config.endpoint,
|
|
2272
|
-
websocketEndpoint: state.websocketEndpoint ?? config.websocketEndpoint
|
|
2273
|
-
};
|
|
2274
|
-
}
|
|
2275
|
-
__name(applySerializableState, "applySerializableState");
|
|
2276
2368
|
var COMMITMENT_PRIORITY = {
|
|
2277
2369
|
processed: 0,
|
|
2278
2370
|
confirmed: 1,
|
|
@@ -2685,13 +2777,13 @@ function getChain(account) {
|
|
|
2685
2777
|
return preferred;
|
|
2686
2778
|
}
|
|
2687
2779
|
__name(getChain, "getChain");
|
|
2688
|
-
async function
|
|
2780
|
+
async function disconnectWallet2(wallet) {
|
|
2689
2781
|
const disconnectFeature = wallet.features[features.StandardDisconnect];
|
|
2690
2782
|
if (disconnectFeature) {
|
|
2691
2783
|
await disconnectFeature.disconnect();
|
|
2692
2784
|
}
|
|
2693
2785
|
}
|
|
2694
|
-
__name(
|
|
2786
|
+
__name(disconnectWallet2, "disconnectWallet");
|
|
2695
2787
|
function createWalletStandardConnector(wallet, options = {}) {
|
|
2696
2788
|
const metadata = {
|
|
2697
2789
|
canAutoConnect: options.canAutoConnect ?? Boolean(wallet.features[features.StandardConnect]),
|
|
@@ -2739,7 +2831,7 @@ function createWalletStandardConnector(wallet, options = {}) {
|
|
|
2739
2831
|
const [output] = await signTransactionFeature.signTransaction(request);
|
|
2740
2832
|
return transactionDecoder.decode(output.signedTransaction);
|
|
2741
2833
|
} : void 0;
|
|
2742
|
-
const
|
|
2834
|
+
const sendTransaction2 = signAndSendFeature ? async (transaction, config) => {
|
|
2743
2835
|
const wireBytes = new Uint8Array(transactionEncoder.encode(transaction));
|
|
2744
2836
|
const chain = options.defaultChain ?? getChain(primaryAccount) ?? "solana:mainnet-beta";
|
|
2745
2837
|
const [output] = await signAndSendFeature.signAndSendTransaction({
|
|
@@ -2753,21 +2845,21 @@ function createWalletStandardConnector(wallet, options = {}) {
|
|
|
2753
2845
|
return base58Decoder.decode(output.signature);
|
|
2754
2846
|
} : void 0;
|
|
2755
2847
|
async function disconnectSession() {
|
|
2756
|
-
await
|
|
2848
|
+
await disconnectWallet2(wallet);
|
|
2757
2849
|
}
|
|
2758
2850
|
__name(disconnectSession, "disconnectSession");
|
|
2759
2851
|
return {
|
|
2760
2852
|
account: sessionAccount,
|
|
2761
2853
|
connector: metadata,
|
|
2762
2854
|
disconnect: disconnectSession,
|
|
2763
|
-
sendTransaction,
|
|
2855
|
+
sendTransaction: sendTransaction2,
|
|
2764
2856
|
signMessage,
|
|
2765
2857
|
signTransaction
|
|
2766
2858
|
};
|
|
2767
2859
|
}
|
|
2768
2860
|
__name(connect, "connect");
|
|
2769
2861
|
async function disconnect() {
|
|
2770
|
-
await
|
|
2862
|
+
await disconnectWallet2(wallet);
|
|
2771
2863
|
}
|
|
2772
2864
|
__name(disconnect, "disconnect");
|
|
2773
2865
|
function isSupported() {
|
|
@@ -2823,12 +2915,78 @@ function watchWalletStandardConnectors(onChange, options = {}) {
|
|
|
2823
2915
|
}
|
|
2824
2916
|
__name(watchWalletStandardConnectors, "watchWalletStandardConnectors");
|
|
2825
2917
|
|
|
2918
|
+
// src/wallet/connectors.ts
|
|
2919
|
+
function autoDiscover(options = {}) {
|
|
2920
|
+
const { get } = app.getWallets();
|
|
2921
|
+
const wallets = get().filter((wallet) => options.filter ? options.filter(wallet) : true);
|
|
2922
|
+
const connectors = wallets.map((wallet) => createWalletStandardConnector(wallet, options.overrides?.(wallet)));
|
|
2923
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2924
|
+
return connectors.filter((connector) => {
|
|
2925
|
+
if (seen.has(connector.id)) return false;
|
|
2926
|
+
seen.add(connector.id);
|
|
2927
|
+
return true;
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
__name(autoDiscover, "autoDiscover");
|
|
2931
|
+
function injected(options) {
|
|
2932
|
+
const connector = {
|
|
2933
|
+
canAutoConnect: true,
|
|
2934
|
+
id: "wallet-standard:injected",
|
|
2935
|
+
kind: "wallet-standard",
|
|
2936
|
+
name: "Injected Wallet",
|
|
2937
|
+
ready: typeof window !== "undefined",
|
|
2938
|
+
async connect() {
|
|
2939
|
+
const wallets = app.getWallets().get();
|
|
2940
|
+
const first = wallets.find((wallet) => features.StandardConnect in wallet.features);
|
|
2941
|
+
if (!first) {
|
|
2942
|
+
throw new Error("No Wallet Standard wallets available.");
|
|
2943
|
+
}
|
|
2944
|
+
return createWalletStandardConnector(first, options).connect();
|
|
2945
|
+
},
|
|
2946
|
+
async disconnect() {
|
|
2947
|
+
},
|
|
2948
|
+
isSupported() {
|
|
2949
|
+
return typeof window !== "undefined";
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
return connector;
|
|
2953
|
+
}
|
|
2954
|
+
__name(injected, "injected");
|
|
2955
|
+
function filterByName(name) {
|
|
2956
|
+
const lower = name.toLowerCase();
|
|
2957
|
+
return (wallet) => wallet.name.toLowerCase().includes(lower);
|
|
2958
|
+
}
|
|
2959
|
+
__name(filterByName, "filterByName");
|
|
2960
|
+
function phantom(options) {
|
|
2961
|
+
return autoDiscover({
|
|
2962
|
+
filter: filterByName("phantom"),
|
|
2963
|
+
overrides: /* @__PURE__ */ __name(() => ({ ...options, id: "wallet-standard:phantom" }), "overrides")
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
__name(phantom, "phantom");
|
|
2967
|
+
function solflare(options) {
|
|
2968
|
+
return autoDiscover({
|
|
2969
|
+
filter: filterByName("solflare"),
|
|
2970
|
+
overrides: /* @__PURE__ */ __name(() => ({ ...options, id: "wallet-standard:solflare" }), "overrides")
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
__name(solflare, "solflare");
|
|
2974
|
+
function backpack(options) {
|
|
2975
|
+
return autoDiscover({
|
|
2976
|
+
filter: filterByName("backpack"),
|
|
2977
|
+
overrides: /* @__PURE__ */ __name(() => ({ ...options, id: "wallet-standard:backpack" }), "overrides")
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
__name(backpack, "backpack");
|
|
2981
|
+
|
|
2826
2982
|
exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
|
|
2827
2983
|
exports.SIGNATURE_STATUS_TIMEOUT_MS = SIGNATURE_STATUS_TIMEOUT_MS;
|
|
2828
2984
|
exports.applyRatio = applyRatio;
|
|
2829
2985
|
exports.applySerializableState = applySerializableState;
|
|
2830
2986
|
exports.assertDecimals = assertDecimals;
|
|
2831
2987
|
exports.assertNonNegative = assertNonNegative;
|
|
2988
|
+
exports.autoDiscover = autoDiscover;
|
|
2989
|
+
exports.backpack = backpack;
|
|
2832
2990
|
exports.bigintFromJson = bigintFromJson;
|
|
2833
2991
|
exports.bigintToJson = bigintToJson;
|
|
2834
2992
|
exports.checkedAdd = checkedAdd;
|
|
@@ -2836,6 +2994,7 @@ exports.checkedDivide = checkedDivide;
|
|
|
2836
2994
|
exports.checkedMultiply = checkedMultiply;
|
|
2837
2995
|
exports.checkedSubtract = checkedSubtract;
|
|
2838
2996
|
exports.confirmationMeetsCommitment = confirmationMeetsCommitment;
|
|
2997
|
+
exports.connectWallet = connectWallet;
|
|
2839
2998
|
exports.createAsyncState = createAsyncState;
|
|
2840
2999
|
exports.createClient = createClient;
|
|
2841
3000
|
exports.createClientStore = createClientStore;
|
|
@@ -2855,8 +3014,13 @@ exports.createTransactionRecipe = createTransactionRecipe;
|
|
|
2855
3014
|
exports.createWalletRegistry = createWalletRegistry;
|
|
2856
3015
|
exports.createWalletStandardConnector = createWalletStandardConnector;
|
|
2857
3016
|
exports.deriveConfirmationStatus = deriveConfirmationStatus;
|
|
3017
|
+
exports.deserializeSolanaState = deserializeSolanaState;
|
|
3018
|
+
exports.disconnectWallet = disconnectWallet;
|
|
3019
|
+
exports.fetchAccount = fetchAccount;
|
|
3020
|
+
exports.fetchBalance = fetchBalance;
|
|
2858
3021
|
exports.getInitialSerializableState = getInitialSerializableState;
|
|
2859
3022
|
exports.getWalletStandardConnectors = getWalletStandardConnectors;
|
|
3023
|
+
exports.injected = injected;
|
|
2860
3024
|
exports.insertReferenceKey = insertReferenceKey;
|
|
2861
3025
|
exports.insertReferenceKeys = insertReferenceKeys;
|
|
2862
3026
|
exports.lamports = lamports;
|
|
@@ -2866,10 +3030,17 @@ exports.lamportsMath = lamportsMath;
|
|
|
2866
3030
|
exports.lamportsToJson = lamportsToJson;
|
|
2867
3031
|
exports.lamportsToSolString = lamportsToSolString;
|
|
2868
3032
|
exports.normalizeSignature = normalizeSignature;
|
|
3033
|
+
exports.phantom = phantom;
|
|
2869
3034
|
exports.pow10 = pow10;
|
|
2870
3035
|
exports.prepareTransaction = prepareTransaction;
|
|
3036
|
+
exports.requestAirdrop = requestAirdrop;
|
|
2871
3037
|
exports.resolveCluster = resolveCluster;
|
|
3038
|
+
exports.sendTransaction = sendTransaction;
|
|
3039
|
+
exports.serializeSolanaState = serializeSolanaState;
|
|
3040
|
+
exports.setCluster = setCluster;
|
|
3041
|
+
exports.solflare = solflare;
|
|
2872
3042
|
exports.stableStringify = stableStringify;
|
|
3043
|
+
exports.subscribeSolanaState = subscribeSolanaState;
|
|
2873
3044
|
exports.toAddress = toAddress2;
|
|
2874
3045
|
exports.toAddressString = toAddressString;
|
|
2875
3046
|
exports.toBigint = toBigint2;
|