@vue-solana/vue 0.4.2 → 0.6.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/README.md +32 -6
- package/dist/index.cjs +198 -103
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +196 -102
- package/dist/shared/vue.DEQJ23UM.cjs +92 -0
- package/dist/shared/vue.DHVYJk8P.cjs +72 -0
- package/dist/shared/{vue.CNhelr8H.cjs → vue.DQi38JeF.cjs} +20 -16
- package/dist/shared/vue.RQ9fETnm.mjs +90 -0
- package/dist/shared/{vue.CuhLIeDx.mjs → vue.gLqkzJY4.mjs} +20 -17
- package/dist/shared/vue.jOsz34kz.mjs +69 -0
- package/dist/useSignAndSendTransaction.cjs +3 -3
- package/dist/useSignAndSendTransaction.d.cts +19 -2
- package/dist/useSignAndSendTransaction.d.mts +19 -2
- package/dist/useSignAndSendTransaction.d.ts +19 -2
- package/dist/useSignAndSendTransaction.mjs +3 -3
- package/dist/useTransaction.cjs +1 -1
- package/dist/useTransaction.mjs +1 -1
- package/dist/useTransactionConfirmation.cjs +13 -0
- package/dist/useTransactionConfirmation.d.cts +26 -0
- package/dist/useTransactionConfirmation.d.mts +26 -0
- package/dist/useTransactionConfirmation.d.ts +26 -0
- package/dist/useTransactionConfirmation.mjs +6 -0
- package/package.json +7 -2
- package/dist/shared/vue.BfF-kOvb.mjs +0 -24
- package/dist/shared/vue.BwrQMPty.cjs +0 -26
package/README.md
CHANGED
|
@@ -154,6 +154,8 @@ const { publicKey, connected, connecting, connect, disconnect } = useWallet();
|
|
|
154
154
|
|
|
155
155
|
Browser extension wallets are discovered through the Solana Wallet Standard. Android Mobile Wallet Adapter wallets are registered through `@solana-mobile/wallet-standard-mobile` and exposed through the same `useWallets()` list on supported Android Chrome clients. iOS Phantom, Solflare, and Backpack entries are exposed through wallet-specific universal links on iOS browsers. `connect()` works after selecting a discovered wallet or configuring a custom `SolanaWallet`.
|
|
156
156
|
|
|
157
|
+
Selected discovered wallets are persisted under `localStorage["vue-solana:selected-wallet"]` as non-sensitive identity metadata: `name`, and `platform`/`source` when available. On reload, Vue Solana restores the selected wallet if the same wallet is discovered again. Pass `autoConnect: true` to opt into calling `connect()` for that restored wallet; arbitrary installed wallets are never auto-connected. Calling `selectWallet(null)` or `setWallet(customWallet)` clears the stored selection.
|
|
158
|
+
|
|
157
159
|
Desktop native app wallet adapters are planned but not implemented yet.
|
|
158
160
|
|
|
159
161
|
Composables return inert SSR-safe state when no plugin context is available. Real RPC and wallet operations still require the plugin-provided client context.
|
|
@@ -163,14 +165,30 @@ Composables return inert SSR-safe state when no plugin context is available. Rea
|
|
|
163
165
|
```ts
|
|
164
166
|
import { useSignAndSendTransaction } from "@vue-solana/vue/useSignAndSendTransaction";
|
|
165
167
|
|
|
166
|
-
const { signature, loading, error, execute } = useSignAndSendTransaction();
|
|
168
|
+
const { signature, confirmation, status, loading, error, execute } = useSignAndSendTransaction();
|
|
167
169
|
|
|
168
170
|
await execute(transaction, {
|
|
171
|
+
confirm: true,
|
|
172
|
+
confirmation: { commitment: "confirmed" },
|
|
169
173
|
skipPreflight: false,
|
|
170
174
|
});
|
|
171
175
|
```
|
|
172
176
|
|
|
173
|
-
The current wallet must be connected and support either `signAndSendTransaction` or `signTransaction`. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available.
|
|
177
|
+
The current wallet must be connected and support either `signAndSendTransaction` or `signTransaction`. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available. This avoids a mobile handoff edge case where the wallet sends successfully but the browser page does not receive the wallet adapter's returned signature.
|
|
178
|
+
|
|
179
|
+
Without `confirm: true`, `execute()` returns after submission and sets `status` to `sent`. With confirmation enabled, status moves through `sending`, `confirming`, and then `processed`, `confirmed`, or `finalized` to match the requested commitment. If confirmation times out or fails, the submitted `signature` remains available so the app can link to an explorer.
|
|
180
|
+
|
|
181
|
+
Use `useTransactionConfirmation()` when you already have a submitted signature and want to wait for confirmation separately:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
import { useTransactionConfirmation } from "@vue-solana/vue/useTransactionConfirmation";
|
|
185
|
+
|
|
186
|
+
const confirmation = useTransactionConfirmation({ commitment: "finalized" });
|
|
187
|
+
|
|
188
|
+
await confirmation.confirm(signature);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
`useSignAndSendTransaction()` also clears `loading` if a wallet adapter never returns a result. In that stale case, `error` is set and the chain status may be unknown, so check the connected wallet or an explorer before retrying.
|
|
174
192
|
|
|
175
193
|
## Example App
|
|
176
194
|
|
|
@@ -202,10 +220,11 @@ Docs: [Vue Solana Agent Skill](https://vue-solana-docs.vercel.app/agent-skill)
|
|
|
202
220
|
- `useRpc()`: returns cluster, endpoint, connection status, latest blockhash, and `checkConnection()`.
|
|
203
221
|
- `useConnection()`: returns the Solana `Connection`.
|
|
204
222
|
- `useWallet()`: returns wallet refs, computed connection state, and wallet actions.
|
|
205
|
-
- `useWallets()`: returns discovered browser extension wallets, Android Mobile Wallet Adapter wallets, and wallet selection actions.
|
|
223
|
+
- `useWallets()`: returns discovered browser extension wallets, Android Mobile Wallet Adapter wallets, iOS browser wallet links, and wallet selection actions.
|
|
206
224
|
- `useBalance(address, commitment?)`: loads lamport balance for a `PublicKey` or address string.
|
|
207
|
-
- `useTransaction(handler)`: generic async transaction state helper.
|
|
208
|
-
- `
|
|
225
|
+
- `useTransaction(handler, options?)`: generic async transaction state helper with optional timeout settings.
|
|
226
|
+
- `useTransactionConfirmation(options?)`: confirms a submitted signature with reactive status and timeout/error state.
|
|
227
|
+
- `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet, with optional confirmation waiting.
|
|
209
228
|
|
|
210
229
|
Direct composable subpaths:
|
|
211
230
|
|
|
@@ -216,6 +235,7 @@ Direct composable subpaths:
|
|
|
216
235
|
- `@vue-solana/vue/useWallet`
|
|
217
236
|
- `@vue-solana/vue/useWallets`
|
|
218
237
|
- `@vue-solana/vue/useTransaction`
|
|
238
|
+
- `@vue-solana/vue/useTransactionConfirmation`
|
|
219
239
|
- `@vue-solana/vue/useSignAndSendTransaction`
|
|
220
240
|
|
|
221
241
|
## Known TypeScript Issue
|
|
@@ -226,7 +246,13 @@ If TypeScript cannot resolve `@solana/web3-compat`, add `types/web3-compat.d.ts`
|
|
|
226
246
|
|
|
227
247
|
```ts
|
|
228
248
|
declare module "@solana/web3-compat" {
|
|
229
|
-
export type {
|
|
249
|
+
export type {
|
|
250
|
+
Commitment,
|
|
251
|
+
RpcResponseAndContext,
|
|
252
|
+
SendOptions,
|
|
253
|
+
SignatureResult,
|
|
254
|
+
TransactionSignature,
|
|
255
|
+
} from "@solana/web3.js";
|
|
230
256
|
export {
|
|
231
257
|
Connection,
|
|
232
258
|
Keypair,
|
package/dist/index.cjs
CHANGED
|
@@ -3,18 +3,168 @@
|
|
|
3
3
|
const useBalance = require('./shared/vue.D_AM1Nl8.cjs');
|
|
4
4
|
const useConnection = require('./shared/vue.CwhEmATP.cjs');
|
|
5
5
|
const useRpc = require('./shared/vue.COyyrsQU.cjs');
|
|
6
|
-
const useSignAndSendTransaction = require('./shared/vue.
|
|
6
|
+
const useSignAndSendTransaction = require('./shared/vue.DEQJ23UM.cjs');
|
|
7
7
|
const useSolana = require('./shared/vue.C4tLiG3R.cjs');
|
|
8
|
-
const useTransaction = require('./shared/vue.
|
|
8
|
+
const useTransaction = require('./shared/vue.DQi38JeF.cjs');
|
|
9
|
+
const useTransactionConfirmation = require('./shared/vue.DHVYJk8P.cjs');
|
|
9
10
|
const useWallet = require('./shared/vue.CwPjPFN6.cjs');
|
|
10
11
|
const useWallets = require('./shared/vue.P9tgeC5S.cjs');
|
|
11
|
-
const iosWallet = require('@vue-solana/core/ios-wallet');
|
|
12
|
-
const walletStandard = require('@vue-solana/core/wallet-standard');
|
|
13
12
|
const rpc = require('@vue-solana/core/rpc');
|
|
13
|
+
const walletStandard = require('@vue-solana/core/wallet-standard');
|
|
14
14
|
const vue = require('vue');
|
|
15
|
+
const iosWallet = require('@vue-solana/core/ios-wallet');
|
|
15
16
|
require('@solana/web3-compat');
|
|
16
17
|
require('@vue-solana/core/transaction');
|
|
17
18
|
|
|
19
|
+
const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
|
|
20
|
+
function readSelectedWallet() {
|
|
21
|
+
const storage = getLocalStorage();
|
|
22
|
+
if (!storage) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const value = storage.getItem(SELECTED_WALLET_STORAGE_KEY);
|
|
27
|
+
if (!value) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const wallet = JSON.parse(value);
|
|
31
|
+
return typeof wallet.name === "string" ? {
|
|
32
|
+
name: wallet.name,
|
|
33
|
+
platform: wallet.platform,
|
|
34
|
+
source: wallet.source
|
|
35
|
+
} : null;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function writeSelectedWallet(wallet) {
|
|
41
|
+
const storage = getLocalStorage();
|
|
42
|
+
if (!storage) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
if (wallet) {
|
|
47
|
+
storage.setItem(SELECTED_WALLET_STORAGE_KEY, stringifySelectedWallet(wallet));
|
|
48
|
+
} else {
|
|
49
|
+
storage.removeItem(SELECTED_WALLET_STORAGE_KEY);
|
|
50
|
+
}
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function stringifySelectedWallet(wallet) {
|
|
55
|
+
const value = { name: wallet.name };
|
|
56
|
+
if (wallet.platform) {
|
|
57
|
+
value.platform = wallet.platform;
|
|
58
|
+
}
|
|
59
|
+
if (wallet.source) {
|
|
60
|
+
value.source = wallet.source;
|
|
61
|
+
}
|
|
62
|
+
return JSON.stringify(value);
|
|
63
|
+
}
|
|
64
|
+
function getLocalStorage() {
|
|
65
|
+
if (typeof window === "undefined") {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return window.localStorage;
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function createSolanaWalletRegistry(options) {
|
|
76
|
+
const adaptedWallets = /* @__PURE__ */ new WeakMap();
|
|
77
|
+
function getAdaptedWallet(walletInfo) {
|
|
78
|
+
if (iosWallet.isSolanaIosWalletInfo(walletInfo)) {
|
|
79
|
+
return iosWallet.adaptSolanaIosWallet(walletInfo, {
|
|
80
|
+
chain: walletStandard.getSolanaChain(options.cluster),
|
|
81
|
+
cluster: options.cluster,
|
|
82
|
+
onChange: options.onWalletChange,
|
|
83
|
+
...options.iosWallet || {}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (!isObject(walletInfo.wallet)) {
|
|
87
|
+
return walletStandard.adaptSolanaStandardWallet(walletInfo, {
|
|
88
|
+
chain: walletStandard.getSolanaChain(options.cluster),
|
|
89
|
+
onChange: options.onWalletChange
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const cachedWallet = adaptedWallets.get(walletInfo.wallet);
|
|
93
|
+
if (cachedWallet) {
|
|
94
|
+
return cachedWallet;
|
|
95
|
+
}
|
|
96
|
+
const adaptedWallet = walletStandard.adaptSolanaStandardWallet(walletInfo, {
|
|
97
|
+
chain: walletStandard.getSolanaChain(options.cluster),
|
|
98
|
+
onChange: options.onWalletChange
|
|
99
|
+
});
|
|
100
|
+
const cachedAdapter = {
|
|
101
|
+
platform: walletInfo.platform,
|
|
102
|
+
source: walletInfo.source,
|
|
103
|
+
get publicKey() {
|
|
104
|
+
return adaptedWallet.publicKey;
|
|
105
|
+
},
|
|
106
|
+
get connected() {
|
|
107
|
+
return adaptedWallet.connected;
|
|
108
|
+
},
|
|
109
|
+
get connecting() {
|
|
110
|
+
return adaptedWallet.connecting;
|
|
111
|
+
},
|
|
112
|
+
get disconnecting() {
|
|
113
|
+
return adaptedWallet.disconnecting;
|
|
114
|
+
},
|
|
115
|
+
async connect() {
|
|
116
|
+
await adaptedWallet.connect();
|
|
117
|
+
await Promise.all(
|
|
118
|
+
Array.from(getCachedWallets()).map(
|
|
119
|
+
(otherWallet) => otherWallet !== cachedAdapter && otherWallet.connected ? otherWallet.disconnect() : void 0
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
disconnect: () => adaptedWallet.disconnect(),
|
|
124
|
+
signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
|
|
125
|
+
signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
|
|
126
|
+
signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet)
|
|
127
|
+
};
|
|
128
|
+
adaptedWallets.set(walletInfo.wallet, cachedAdapter);
|
|
129
|
+
return cachedAdapter;
|
|
130
|
+
}
|
|
131
|
+
function getDiscoveredWallets() {
|
|
132
|
+
return [
|
|
133
|
+
...walletStandard.getRegisteredSolanaWallets(),
|
|
134
|
+
...options.iosWallet === false ? [] : iosWallet.getSolanaIosWallets({
|
|
135
|
+
chains: [walletStandard.getSolanaChain(options.cluster)],
|
|
136
|
+
cluster: options.cluster,
|
|
137
|
+
...options.iosWallet || {}
|
|
138
|
+
})
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
function handleIosWalletCallback() {
|
|
142
|
+
try {
|
|
143
|
+
iosWallet.handleSolanaIosWalletCallback({ clearUrl: true });
|
|
144
|
+
} catch (cause) {
|
|
145
|
+
console.error("[Vue Solana] iOS wallet callback failed", cause);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function* getCachedWallets() {
|
|
149
|
+
for (const walletInfo of options.getWalletInfos()) {
|
|
150
|
+
if (isObject(walletInfo.wallet)) {
|
|
151
|
+
const cachedWallet = adaptedWallets.get(walletInfo.wallet);
|
|
152
|
+
if (cachedWallet) {
|
|
153
|
+
yield cachedWallet;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
getAdaptedWallet,
|
|
160
|
+
getDiscoveredWallets,
|
|
161
|
+
handleIosWalletCallback
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function isObject(value) {
|
|
165
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
166
|
+
}
|
|
167
|
+
|
|
18
168
|
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
19
169
|
function createSolanaPlugin(options = {}) {
|
|
20
170
|
return {
|
|
@@ -26,9 +176,15 @@ function createSolanaPlugin(options = {}) {
|
|
|
26
176
|
const status = vue.ref("idle");
|
|
27
177
|
const error = vue.ref(null);
|
|
28
178
|
const latestBlockhash = vue.ref(null);
|
|
29
|
-
const
|
|
179
|
+
const walletRegistry = createSolanaWalletRegistry({
|
|
180
|
+
cluster: context.cluster,
|
|
181
|
+
iosWallet: options.iosWallet,
|
|
182
|
+
getWalletInfos: () => wallets.value,
|
|
183
|
+
onWalletChange: () => vue.triggerRef(wallet)
|
|
184
|
+
});
|
|
30
185
|
let unsubscribeWallets = null;
|
|
31
186
|
let mobileWalletRegistrationPromise = null;
|
|
187
|
+
let attemptedAutoConnectWallet = null;
|
|
32
188
|
let rpcCheckId = 0;
|
|
33
189
|
async function checkConnection() {
|
|
34
190
|
const checkId = ++rpcCheckId;
|
|
@@ -40,7 +196,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
40
196
|
wsEndpoint: context.wsEndpoint
|
|
41
197
|
});
|
|
42
198
|
try {
|
|
43
|
-
const blockhash = await withTimeout(
|
|
199
|
+
const blockhash = await useTransaction.withTimeout(
|
|
44
200
|
context.connection.getLatestBlockhash(),
|
|
45
201
|
RPC_CHECK_TIMEOUT_MS,
|
|
46
202
|
`RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
|
|
@@ -67,17 +223,28 @@ function createSolanaPlugin(options = {}) {
|
|
|
67
223
|
}
|
|
68
224
|
function refreshWallets() {
|
|
69
225
|
unsubscribeWallets ??= walletStandard.subscribeSolanaWallets(refreshWallets);
|
|
70
|
-
handleIosWalletCallback();
|
|
71
|
-
wallets.value = getDiscoveredWallets();
|
|
226
|
+
walletRegistry.handleIosWalletCallback();
|
|
227
|
+
wallets.value = walletRegistry.getDiscoveredWallets();
|
|
228
|
+
let restoredWallet = null;
|
|
72
229
|
if (selectedWallet.value) {
|
|
73
230
|
selectedWallet.value = wallets.value.find((nextWallet) => isSameWallet(nextWallet, selectedWallet.value)) ?? null;
|
|
74
231
|
if (!selectedWallet.value) {
|
|
75
232
|
wallet.value = options.wallet ?? null;
|
|
76
233
|
}
|
|
234
|
+
} else if (!options.wallet) {
|
|
235
|
+
const persistedWallet = readSelectedWallet();
|
|
236
|
+
restoredWallet = persistedWallet ? wallets.value.find((nextWallet) => isSameWallet(nextWallet, persistedWallet)) ?? null : null;
|
|
237
|
+
if (restoredWallet) {
|
|
238
|
+
selectedWallet.value = restoredWallet;
|
|
239
|
+
wallet.value = walletRegistry.getAdaptedWallet(restoredWallet);
|
|
240
|
+
}
|
|
77
241
|
}
|
|
78
242
|
if (options.mobileWallet !== false) {
|
|
79
243
|
registerMobileWallets();
|
|
80
244
|
}
|
|
245
|
+
if (restoredWallet) {
|
|
246
|
+
autoConnectWallet(restoredWallet);
|
|
247
|
+
}
|
|
81
248
|
}
|
|
82
249
|
function registerMobileWallets() {
|
|
83
250
|
mobileWalletRegistrationPromise ??= import('@vue-solana/core/mobile-wallet').then(({ registerSolanaMobileWallet }) => {
|
|
@@ -85,7 +252,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
85
252
|
chains: [walletStandard.getSolanaChain(context.cluster)],
|
|
86
253
|
...options.mobileWallet || {}
|
|
87
254
|
});
|
|
88
|
-
|
|
255
|
+
refreshWallets();
|
|
89
256
|
}).catch((cause) => {
|
|
90
257
|
console.error("[Vue Solana] Mobile wallet registration failed", cause);
|
|
91
258
|
}).finally(() => {
|
|
@@ -94,88 +261,24 @@ function createSolanaPlugin(options = {}) {
|
|
|
94
261
|
}
|
|
95
262
|
function selectWallet(nextWallet) {
|
|
96
263
|
selectedWallet.value = nextWallet;
|
|
97
|
-
wallet.value = nextWallet ? getAdaptedWallet(nextWallet) : options.wallet ?? null;
|
|
264
|
+
wallet.value = nextWallet ? walletRegistry.getAdaptedWallet(nextWallet) : options.wallet ?? null;
|
|
265
|
+
writeSelectedWallet(nextWallet);
|
|
98
266
|
}
|
|
99
|
-
function
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
102
|
-
chain: walletStandard.getSolanaChain(context.cluster),
|
|
103
|
-
cluster: context.cluster,
|
|
104
|
-
onChange: () => vue.triggerRef(wallet),
|
|
105
|
-
...options.iosWallet || {}
|
|
106
|
-
});
|
|
267
|
+
function autoConnectWallet(walletInfo) {
|
|
268
|
+
if (!options.autoConnect) {
|
|
269
|
+
return;
|
|
107
270
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
271
|
+
const activeWallet = wallet.value;
|
|
272
|
+
const storageValue = stringifySelectedWallet(walletInfo);
|
|
273
|
+
if (!activeWallet || activeWallet.connected || activeWallet.connecting || attemptedAutoConnectWallet === storageValue) {
|
|
274
|
+
return;
|
|
113
275
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
chain: walletStandard.getSolanaChain(context.cluster),
|
|
120
|
-
onChange: () => vue.triggerRef(wallet)
|
|
276
|
+
attemptedAutoConnectWallet = storageValue;
|
|
277
|
+
void activeWallet.connect().catch((cause) => {
|
|
278
|
+
console.error("[Vue Solana] Wallet auto-connect failed", cause);
|
|
279
|
+
}).finally(() => {
|
|
280
|
+
vue.triggerRef(wallet);
|
|
121
281
|
});
|
|
122
|
-
const cachedAdapter = {
|
|
123
|
-
platform: walletInfo.platform,
|
|
124
|
-
source: walletInfo.source,
|
|
125
|
-
get publicKey() {
|
|
126
|
-
return adaptedWallet.publicKey;
|
|
127
|
-
},
|
|
128
|
-
get connected() {
|
|
129
|
-
return adaptedWallet.connected;
|
|
130
|
-
},
|
|
131
|
-
get connecting() {
|
|
132
|
-
return adaptedWallet.connecting;
|
|
133
|
-
},
|
|
134
|
-
get disconnecting() {
|
|
135
|
-
return adaptedWallet.disconnecting;
|
|
136
|
-
},
|
|
137
|
-
async connect() {
|
|
138
|
-
await adaptedWallet.connect();
|
|
139
|
-
await Promise.all(
|
|
140
|
-
Array.from(getCachedWallets()).map(
|
|
141
|
-
(otherWallet) => otherWallet !== cachedAdapter && otherWallet.connected ? otherWallet.disconnect() : void 0
|
|
142
|
-
)
|
|
143
|
-
);
|
|
144
|
-
},
|
|
145
|
-
disconnect: () => adaptedWallet.disconnect(),
|
|
146
|
-
signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
|
|
147
|
-
signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
|
|
148
|
-
signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet)
|
|
149
|
-
};
|
|
150
|
-
adaptedWallets.set(walletInfo.wallet, cachedAdapter);
|
|
151
|
-
return cachedAdapter;
|
|
152
|
-
}
|
|
153
|
-
function getDiscoveredWallets() {
|
|
154
|
-
return [
|
|
155
|
-
...walletStandard.getRegisteredSolanaWallets(),
|
|
156
|
-
...options.iosWallet === false ? [] : iosWallet.getSolanaIosWallets({
|
|
157
|
-
chains: [walletStandard.getSolanaChain(context.cluster)],
|
|
158
|
-
cluster: context.cluster,
|
|
159
|
-
...options.iosWallet || {}
|
|
160
|
-
})
|
|
161
|
-
];
|
|
162
|
-
}
|
|
163
|
-
function handleIosWalletCallback() {
|
|
164
|
-
try {
|
|
165
|
-
iosWallet.handleSolanaIosWalletCallback({ clearUrl: true });
|
|
166
|
-
} catch (cause) {
|
|
167
|
-
console.error("[Vue Solana] iOS wallet callback failed", cause);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function* getCachedWallets() {
|
|
171
|
-
for (const walletInfo of wallets.value) {
|
|
172
|
-
if (isObject(walletInfo.wallet)) {
|
|
173
|
-
const cachedWallet = adaptedWallets.get(walletInfo.wallet);
|
|
174
|
-
if (cachedWallet) {
|
|
175
|
-
yield cachedWallet;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
282
|
}
|
|
180
283
|
const vueContext = {
|
|
181
284
|
...context,
|
|
@@ -191,37 +294,27 @@ function createSolanaPlugin(options = {}) {
|
|
|
191
294
|
setWallet(nextWallet) {
|
|
192
295
|
selectedWallet.value = null;
|
|
193
296
|
wallet.value = nextWallet;
|
|
297
|
+
writeSelectedWallet(null);
|
|
194
298
|
}
|
|
195
299
|
};
|
|
196
300
|
app.provide(useSolana.solanaInjectionKey, vueContext);
|
|
197
301
|
if (typeof window !== "undefined") {
|
|
198
302
|
window.setTimeout(() => {
|
|
303
|
+
try {
|
|
304
|
+
refreshWallets();
|
|
305
|
+
} catch (cause) {
|
|
306
|
+
console.error("[Vue Solana] Wallet refresh failed", cause);
|
|
307
|
+
}
|
|
199
308
|
void checkConnection();
|
|
200
309
|
}, 0);
|
|
201
310
|
}
|
|
202
311
|
}
|
|
203
312
|
};
|
|
204
313
|
}
|
|
205
|
-
function isObject(value) {
|
|
206
|
-
return typeof value === "object" && value !== null || typeof value === "function";
|
|
207
|
-
}
|
|
208
314
|
function isSameWallet(wallet, selectedWallet) {
|
|
209
315
|
return wallet.name === selectedWallet?.name && wallet.source === selectedWallet.source && wallet.platform === selectedWallet.platform;
|
|
210
316
|
}
|
|
211
317
|
const VueSolana = createSolanaPlugin;
|
|
212
|
-
function withTimeout(promise, timeoutMs, message) {
|
|
213
|
-
let timeoutId;
|
|
214
|
-
const timeout = new Promise((_, reject) => {
|
|
215
|
-
timeoutId = setTimeout(() => {
|
|
216
|
-
reject(new Error(message));
|
|
217
|
-
}, timeoutMs);
|
|
218
|
-
});
|
|
219
|
-
return Promise.race([promise, timeout]).finally(() => {
|
|
220
|
-
if (timeoutId) {
|
|
221
|
-
clearTimeout(timeoutId);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
318
|
|
|
226
319
|
exports.useBalance = useBalance.useBalance;
|
|
227
320
|
exports.useConnection = useConnection.useConnection;
|
|
@@ -231,6 +324,8 @@ exports.solanaInjectionKey = useSolana.solanaInjectionKey;
|
|
|
231
324
|
exports.tryUseSolana = useSolana.tryUseSolana;
|
|
232
325
|
exports.useSolana = useSolana.useSolana;
|
|
233
326
|
exports.useTransaction = useTransaction.useTransaction;
|
|
327
|
+
exports.getConfirmedTransactionStatus = useTransactionConfirmation.getConfirmedTransactionStatus;
|
|
328
|
+
exports.useTransactionConfirmation = useTransactionConfirmation.useTransactionConfirmation;
|
|
234
329
|
exports.useWallet = useWallet.useWallet;
|
|
235
330
|
exports.useWallets = useWallets.useWallets;
|
|
236
331
|
exports.VueSolana = VueSolana;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { useBalance } from './useBalance.cjs';
|
|
2
2
|
export { useConnection } from './useConnection.cjs';
|
|
3
3
|
export { useRpc } from './useRpc.cjs';
|
|
4
|
-
export { useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
|
|
4
|
+
export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
|
|
5
5
|
export { tryUseSolana, useSolana } from './useSolana.cjs';
|
|
6
6
|
export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
|
|
7
|
+
export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.cjs';
|
|
7
8
|
export { useWallet } from './useWallet.cjs';
|
|
8
9
|
export { useWallets } from './useWallets.cjs';
|
|
9
10
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.cjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { useBalance } from './useBalance.mjs';
|
|
2
2
|
export { useConnection } from './useConnection.mjs';
|
|
3
3
|
export { useRpc } from './useRpc.mjs';
|
|
4
|
-
export { useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
|
|
4
|
+
export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
|
|
5
5
|
export { tryUseSolana, useSolana } from './useSolana.mjs';
|
|
6
6
|
export { UseTransactionOptions, useTransaction } from './useTransaction.mjs';
|
|
7
|
+
export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.mjs';
|
|
7
8
|
export { useWallet } from './useWallet.mjs';
|
|
8
9
|
export { useWallets } from './useWallets.mjs';
|
|
9
10
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { useBalance } from './useBalance.js';
|
|
2
2
|
export { useConnection } from './useConnection.js';
|
|
3
3
|
export { useRpc } from './useRpc.js';
|
|
4
|
-
export { useSignAndSendTransaction } from './useSignAndSendTransaction.js';
|
|
4
|
+
export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.js';
|
|
5
5
|
export { tryUseSolana, useSolana } from './useSolana.js';
|
|
6
6
|
export { UseTransactionOptions, useTransaction } from './useTransaction.js';
|
|
7
|
+
export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.js';
|
|
7
8
|
export { useWallet } from './useWallet.js';
|
|
8
9
|
export { useWallets } from './useWallets.js';
|
|
9
10
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.js';
|