@vue-solana/vue 0.2.0 → 0.2.1
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 +4 -1
- package/dist/index.cjs +27 -1
- package/dist/index.mjs +27 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ New to Solana? Start with the official docs and the project concepts guide:
|
|
|
11
11
|
- [Solana Clusters](https://solana.com/docs/references/clusters)
|
|
12
12
|
- [Vue Solana Concepts Guide](https://vue-solana-docs.vercel.app/concepts/solana-for-vue-developers)
|
|
13
13
|
- [`@vue-solana/vue` docs](https://vue-solana-docs.vercel.app/packages/vue)
|
|
14
|
+
- [Live demo](https://vue-solana-docs.vercel.app/demo)
|
|
14
15
|
|
|
15
16
|
## Install
|
|
16
17
|
|
|
@@ -157,7 +158,9 @@ This README includes small snippets for quick reference. For a complete runnable
|
|
|
157
158
|
pnpm dev:vue
|
|
158
159
|
```
|
|
159
160
|
|
|
160
|
-
Docs:
|
|
161
|
+
Docs: <a href="https://vue-solana-docs.vercel.app/examples/vue-vite" target="_blank" rel="noopener noreferrer"><code>examples/vue-vite</code></a>
|
|
162
|
+
|
|
163
|
+
Live demo: [vue-solana-docs.vercel.app/demo](https://vue-solana-docs.vercel.app/demo)
|
|
161
164
|
|
|
162
165
|
## API
|
|
163
166
|
|
package/dist/index.cjs
CHANGED
|
@@ -180,6 +180,7 @@ function useWallets() {
|
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
183
184
|
function createSolanaPlugin(options = {}) {
|
|
184
185
|
return {
|
|
185
186
|
install(app) {
|
|
@@ -191,7 +192,9 @@ function createSolanaPlugin(options = {}) {
|
|
|
191
192
|
const error = vue.ref(null);
|
|
192
193
|
const latestBlockhash = vue.ref(null);
|
|
193
194
|
let unsubscribeWallets = null;
|
|
195
|
+
let rpcCheckId = 0;
|
|
194
196
|
async function checkConnection() {
|
|
197
|
+
const checkId = ++rpcCheckId;
|
|
195
198
|
status.value = "checking";
|
|
196
199
|
error.value = null;
|
|
197
200
|
console.info("[Vue Solana] Checking RPC connection", {
|
|
@@ -200,7 +203,14 @@ function createSolanaPlugin(options = {}) {
|
|
|
200
203
|
wsEndpoint: context.wsEndpoint
|
|
201
204
|
});
|
|
202
205
|
try {
|
|
203
|
-
const blockhash = await
|
|
206
|
+
const blockhash = await withTimeout(
|
|
207
|
+
context.connection.getLatestBlockhash(),
|
|
208
|
+
RPC_CHECK_TIMEOUT_MS,
|
|
209
|
+
`RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
|
|
210
|
+
);
|
|
211
|
+
if (checkId !== rpcCheckId) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
204
214
|
latestBlockhash.value = blockhash.blockhash;
|
|
205
215
|
status.value = "connected";
|
|
206
216
|
console.info("[Vue Solana] Connected", {
|
|
@@ -210,6 +220,9 @@ function createSolanaPlugin(options = {}) {
|
|
|
210
220
|
blockhash
|
|
211
221
|
});
|
|
212
222
|
} catch (cause) {
|
|
223
|
+
if (checkId !== rpcCheckId) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
213
226
|
status.value = "error";
|
|
214
227
|
error.value = cause instanceof Error ? cause.message : String(cause);
|
|
215
228
|
console.error("[Vue Solana] Connection failed", cause);
|
|
@@ -254,6 +267,19 @@ function createSolanaPlugin(options = {}) {
|
|
|
254
267
|
};
|
|
255
268
|
}
|
|
256
269
|
const VueSolana = createSolanaPlugin;
|
|
270
|
+
function withTimeout(promise, timeoutMs, message) {
|
|
271
|
+
let timeoutId;
|
|
272
|
+
const timeout = new Promise((_, reject) => {
|
|
273
|
+
timeoutId = setTimeout(() => {
|
|
274
|
+
reject(new Error(message));
|
|
275
|
+
}, timeoutMs);
|
|
276
|
+
});
|
|
277
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
278
|
+
if (timeoutId) {
|
|
279
|
+
clearTimeout(timeoutId);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
257
283
|
|
|
258
284
|
exports.VueSolana = VueSolana;
|
|
259
285
|
exports.createSolanaPlugin = createSolanaPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -178,6 +178,7 @@ function useWallets() {
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
181
182
|
function createSolanaPlugin(options = {}) {
|
|
182
183
|
return {
|
|
183
184
|
install(app) {
|
|
@@ -189,7 +190,9 @@ function createSolanaPlugin(options = {}) {
|
|
|
189
190
|
const error = ref(null);
|
|
190
191
|
const latestBlockhash = ref(null);
|
|
191
192
|
let unsubscribeWallets = null;
|
|
193
|
+
let rpcCheckId = 0;
|
|
192
194
|
async function checkConnection() {
|
|
195
|
+
const checkId = ++rpcCheckId;
|
|
193
196
|
status.value = "checking";
|
|
194
197
|
error.value = null;
|
|
195
198
|
console.info("[Vue Solana] Checking RPC connection", {
|
|
@@ -198,7 +201,14 @@ function createSolanaPlugin(options = {}) {
|
|
|
198
201
|
wsEndpoint: context.wsEndpoint
|
|
199
202
|
});
|
|
200
203
|
try {
|
|
201
|
-
const blockhash = await
|
|
204
|
+
const blockhash = await withTimeout(
|
|
205
|
+
context.connection.getLatestBlockhash(),
|
|
206
|
+
RPC_CHECK_TIMEOUT_MS,
|
|
207
|
+
`RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
|
|
208
|
+
);
|
|
209
|
+
if (checkId !== rpcCheckId) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
202
212
|
latestBlockhash.value = blockhash.blockhash;
|
|
203
213
|
status.value = "connected";
|
|
204
214
|
console.info("[Vue Solana] Connected", {
|
|
@@ -208,6 +218,9 @@ function createSolanaPlugin(options = {}) {
|
|
|
208
218
|
blockhash
|
|
209
219
|
});
|
|
210
220
|
} catch (cause) {
|
|
221
|
+
if (checkId !== rpcCheckId) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
211
224
|
status.value = "error";
|
|
212
225
|
error.value = cause instanceof Error ? cause.message : String(cause);
|
|
213
226
|
console.error("[Vue Solana] Connection failed", cause);
|
|
@@ -252,5 +265,18 @@ function createSolanaPlugin(options = {}) {
|
|
|
252
265
|
};
|
|
253
266
|
}
|
|
254
267
|
const VueSolana = createSolanaPlugin;
|
|
268
|
+
function withTimeout(promise, timeoutMs, message) {
|
|
269
|
+
let timeoutId;
|
|
270
|
+
const timeout = new Promise((_, reject) => {
|
|
271
|
+
timeoutId = setTimeout(() => {
|
|
272
|
+
reject(new Error(message));
|
|
273
|
+
}, timeoutMs);
|
|
274
|
+
});
|
|
275
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
276
|
+
if (timeoutId) {
|
|
277
|
+
clearTimeout(timeoutId);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}
|
|
255
281
|
|
|
256
282
|
export { VueSolana, createSolanaPlugin, solanaInjectionKey, useBalance, useConnection, useRpc, useSignAndSendTransaction, useSolana, useTransaction, useWallet, useWallets };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-solana/vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Vue plugin and composables for Solana applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@vue-solana/core": "0.2.
|
|
41
|
+
"@vue-solana/core": "0.2.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@solana/web3-compat": "^0.0.21",
|