@vue-solana/vue 0.2.3 → 0.3.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 +16 -4
- package/dist/index.cjs +21 -2
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +21 -2
- package/dist/shared/{vue.CjKm-Cw1.cjs → vue.CNkyBND6.cjs} +4 -2
- package/dist/shared/{vue.D81obqiN.mjs → vue.CgR3nGpz.mjs} +5 -3
- package/dist/useBalance.cjs +1 -1
- package/dist/useBalance.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,11 +16,11 @@ New to Solana? Start with the official docs and the project concepts guide:
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
|
-
pnpm add @vue-solana/vue @vue-solana/core @solana/web3-compat
|
|
19
|
+
pnpm add @vue-solana/vue @vue-solana/core @solana/web3-compat buffer
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
|
-
npm install @vue-solana/vue @vue-solana/core @solana/web3-compat
|
|
23
|
+
npm install @vue-solana/vue @vue-solana/core @solana/web3-compat buffer
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Plugin Setup
|
|
@@ -34,11 +34,20 @@ createApp(App)
|
|
|
34
34
|
.use(
|
|
35
35
|
createSolanaPlugin({
|
|
36
36
|
cluster: "devnet",
|
|
37
|
+
mobileWallet: {
|
|
38
|
+
appIdentity: {
|
|
39
|
+
name: "My Vue Solana App",
|
|
40
|
+
uri: "https://example.com",
|
|
41
|
+
icon: "favicon.ico",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
37
44
|
}),
|
|
38
45
|
)
|
|
39
46
|
.mount("#app");
|
|
40
47
|
```
|
|
41
48
|
|
|
49
|
+
Android Mobile Wallet Adapter registration is enabled by default on supported Android Chrome clients. Pass `mobileWallet` options to customize the MWA app identity, or pass `mobileWallet: false` to disable Android mobile wallet registration.
|
|
50
|
+
|
|
42
51
|
You can also pass a custom RPC endpoint:
|
|
43
52
|
|
|
44
53
|
```ts
|
|
@@ -142,7 +151,9 @@ const { publicKey, connected, connecting, connect, disconnect } = useWallet();
|
|
|
142
151
|
</template>
|
|
143
152
|
```
|
|
144
153
|
|
|
145
|
-
Browser wallets are discovered through the Solana Wallet Standard. `connect()` works after selecting a discovered wallet or configuring a custom `SolanaWallet`.
|
|
154
|
+
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. `connect()` works after selecting a discovered wallet or configuring a custom `SolanaWallet`.
|
|
155
|
+
|
|
156
|
+
iOS browser wallet adapters and desktop native app wallet adapters are planned but not implemented yet.
|
|
146
157
|
|
|
147
158
|
Composables return inert SSR-safe state when no plugin context is available. Real RPC and wallet operations still require the plugin-provided client context.
|
|
148
159
|
|
|
@@ -180,6 +191,7 @@ Live demo: [vue-solana-docs.vercel.app/demo](https://vue-solana-docs.vercel.app/
|
|
|
180
191
|
- `useRpc()`: returns cluster, endpoint, connection status, latest blockhash, and `checkConnection()`.
|
|
181
192
|
- `useConnection()`: returns the Solana `Connection`.
|
|
182
193
|
- `useWallet()`: returns wallet refs, computed connection state, and wallet actions.
|
|
194
|
+
- `useWallets()`: returns discovered browser extension wallets, Android Mobile Wallet Adapter wallets, and wallet selection actions.
|
|
183
195
|
- `useBalance(address, commitment?)`: loads lamport balance for a `PublicKey` or address string.
|
|
184
196
|
- `useTransaction(handler)`: generic async transaction state helper.
|
|
185
197
|
- `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet.
|
|
@@ -220,4 +232,4 @@ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern tha
|
|
|
220
232
|
|
|
221
233
|
## Status
|
|
222
234
|
|
|
223
|
-
This package is early-stage. RPC, balance, wallet, and transaction composables are usable.
|
|
235
|
+
This package is early-stage. RPC, balance, browser extension wallet, Android mobile wallet, and transaction composables are usable.
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useBalance = require('./shared/vue.
|
|
3
|
+
const useBalance = require('./shared/vue.CNkyBND6.cjs');
|
|
4
4
|
const useConnection = require('./shared/vue.CwhEmATP.cjs');
|
|
5
5
|
const useRpc = require('./shared/vue.COyyrsQU.cjs');
|
|
6
6
|
const useSignAndSendTransaction = require('./shared/vue.CTM6XQ47.cjs');
|
|
@@ -26,6 +26,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
26
26
|
const latestBlockhash = vue.ref(null);
|
|
27
27
|
const adaptedWallets = /* @__PURE__ */ new WeakMap();
|
|
28
28
|
let unsubscribeWallets = null;
|
|
29
|
+
let mobileWalletRegistrationPromise = null;
|
|
29
30
|
let rpcCheckId = 0;
|
|
30
31
|
async function checkConnection() {
|
|
31
32
|
const checkId = ++rpcCheckId;
|
|
@@ -71,6 +72,22 @@ function createSolanaPlugin(options = {}) {
|
|
|
71
72
|
wallet.value = options.wallet ?? null;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
75
|
+
if (options.mobileWallet !== false) {
|
|
76
|
+
registerMobileWallets();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function registerMobileWallets() {
|
|
80
|
+
mobileWalletRegistrationPromise ??= import('@vue-solana/core/mobile-wallet').then(({ registerSolanaMobileWallet }) => {
|
|
81
|
+
registerSolanaMobileWallet({
|
|
82
|
+
chains: [walletStandard.getSolanaChain(context.cluster)],
|
|
83
|
+
...options.mobileWallet || {}
|
|
84
|
+
});
|
|
85
|
+
wallets.value = walletStandard.getRegisteredSolanaWallets();
|
|
86
|
+
}).catch((cause) => {
|
|
87
|
+
console.error("[Vue Solana] Mobile wallet registration failed", cause);
|
|
88
|
+
}).finally(() => {
|
|
89
|
+
mobileWalletRegistrationPromise = null;
|
|
90
|
+
});
|
|
74
91
|
}
|
|
75
92
|
function selectWallet(nextWallet) {
|
|
76
93
|
selectedWallet.value = nextWallet;
|
|
@@ -148,7 +165,9 @@ function createSolanaPlugin(options = {}) {
|
|
|
148
165
|
};
|
|
149
166
|
app.provide(useSolana.solanaInjectionKey, vueContext);
|
|
150
167
|
if (typeof window !== "undefined") {
|
|
151
|
-
|
|
168
|
+
window.setTimeout(() => {
|
|
169
|
+
void checkConnection();
|
|
170
|
+
}, 0);
|
|
152
171
|
}
|
|
153
172
|
}
|
|
154
173
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -7,12 +7,14 @@ export { useTransaction } from './useTransaction.cjs';
|
|
|
7
7
|
export { useWallet } from './useWallet.cjs';
|
|
8
8
|
export { useWallets } from './useWallets.cjs';
|
|
9
9
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.cjs';
|
|
10
|
+
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
10
11
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
11
12
|
import { App } from 'vue';
|
|
12
13
|
import '@solana/web3-compat';
|
|
13
14
|
|
|
14
15
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
|
15
16
|
wallet?: SolanaWallet | null;
|
|
17
|
+
mobileWallet?: false | RegisterSolanaMobileWalletOptions;
|
|
16
18
|
}
|
|
17
19
|
declare function createSolanaPlugin(options?: VueSolanaPluginOptions): {
|
|
18
20
|
install(app: App): void;
|
package/dist/index.d.mts
CHANGED
|
@@ -7,12 +7,14 @@ export { useTransaction } from './useTransaction.mjs';
|
|
|
7
7
|
export { useWallet } from './useWallet.mjs';
|
|
8
8
|
export { useWallets } from './useWallets.mjs';
|
|
9
9
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.mjs';
|
|
10
|
+
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
10
11
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
11
12
|
import { App } from 'vue';
|
|
12
13
|
import '@solana/web3-compat';
|
|
13
14
|
|
|
14
15
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
|
15
16
|
wallet?: SolanaWallet | null;
|
|
17
|
+
mobileWallet?: false | RegisterSolanaMobileWalletOptions;
|
|
16
18
|
}
|
|
17
19
|
declare function createSolanaPlugin(options?: VueSolanaPluginOptions): {
|
|
18
20
|
install(app: App): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,14 @@ export { useTransaction } from './useTransaction.js';
|
|
|
7
7
|
export { useWallet } from './useWallet.js';
|
|
8
8
|
export { useWallets } from './useWallets.js';
|
|
9
9
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.js';
|
|
10
|
+
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
10
11
|
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
11
12
|
import { App } from 'vue';
|
|
12
13
|
import '@solana/web3-compat';
|
|
13
14
|
|
|
14
15
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
|
15
16
|
wallet?: SolanaWallet | null;
|
|
17
|
+
mobileWallet?: false | RegisterSolanaMobileWalletOptions;
|
|
16
18
|
}
|
|
17
19
|
declare function createSolanaPlugin(options?: VueSolanaPluginOptions): {
|
|
18
20
|
install(app: App): void;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { u as useBalance } from './shared/vue.
|
|
1
|
+
export { u as useBalance } from './shared/vue.CgR3nGpz.mjs';
|
|
2
2
|
export { u as useConnection } from './shared/vue.DlEAL2G8.mjs';
|
|
3
3
|
export { u as useRpc } from './shared/vue.BqDzSepb.mjs';
|
|
4
4
|
export { u as useSignAndSendTransaction } from './shared/vue.PoQ8Vpmy.mjs';
|
|
@@ -25,6 +25,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
25
25
|
const latestBlockhash = ref(null);
|
|
26
26
|
const adaptedWallets = /* @__PURE__ */ new WeakMap();
|
|
27
27
|
let unsubscribeWallets = null;
|
|
28
|
+
let mobileWalletRegistrationPromise = null;
|
|
28
29
|
let rpcCheckId = 0;
|
|
29
30
|
async function checkConnection() {
|
|
30
31
|
const checkId = ++rpcCheckId;
|
|
@@ -70,6 +71,22 @@ function createSolanaPlugin(options = {}) {
|
|
|
70
71
|
wallet.value = options.wallet ?? null;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
if (options.mobileWallet !== false) {
|
|
75
|
+
registerMobileWallets();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function registerMobileWallets() {
|
|
79
|
+
mobileWalletRegistrationPromise ??= import('@vue-solana/core/mobile-wallet').then(({ registerSolanaMobileWallet }) => {
|
|
80
|
+
registerSolanaMobileWallet({
|
|
81
|
+
chains: [getSolanaChain(context.cluster)],
|
|
82
|
+
...options.mobileWallet || {}
|
|
83
|
+
});
|
|
84
|
+
wallets.value = getRegisteredSolanaWallets();
|
|
85
|
+
}).catch((cause) => {
|
|
86
|
+
console.error("[Vue Solana] Mobile wallet registration failed", cause);
|
|
87
|
+
}).finally(() => {
|
|
88
|
+
mobileWalletRegistrationPromise = null;
|
|
89
|
+
});
|
|
73
90
|
}
|
|
74
91
|
function selectWallet(nextWallet) {
|
|
75
92
|
selectedWallet.value = nextWallet;
|
|
@@ -147,7 +164,9 @@ function createSolanaPlugin(options = {}) {
|
|
|
147
164
|
};
|
|
148
165
|
app.provide(solanaInjectionKey, vueContext);
|
|
149
166
|
if (typeof window !== "undefined") {
|
|
150
|
-
|
|
167
|
+
window.setTimeout(() => {
|
|
168
|
+
void checkConnection();
|
|
169
|
+
}, 0);
|
|
151
170
|
}
|
|
152
171
|
}
|
|
153
172
|
};
|
|
@@ -29,12 +29,14 @@ function useBalance(address, commitment) {
|
|
|
29
29
|
loading.value = false;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
vue.onMounted(() => {
|
|
33
|
+
void refresh().catch(() => void 0);
|
|
34
|
+
});
|
|
32
35
|
vue.watch(
|
|
33
36
|
() => vue.toValue(address),
|
|
34
37
|
() => {
|
|
35
38
|
void refresh().catch(() => void 0);
|
|
36
|
-
}
|
|
37
|
-
{ immediate: true }
|
|
39
|
+
}
|
|
38
40
|
);
|
|
39
41
|
return {
|
|
40
42
|
balance,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, watch, toValue } from 'vue';
|
|
1
|
+
import { ref, onMounted, watch, toValue } from 'vue';
|
|
2
2
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
3
3
|
import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
|
|
4
4
|
|
|
@@ -27,12 +27,14 @@ function useBalance(address, commitment) {
|
|
|
27
27
|
loading.value = false;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
onMounted(() => {
|
|
31
|
+
void refresh().catch(() => void 0);
|
|
32
|
+
});
|
|
30
33
|
watch(
|
|
31
34
|
() => toValue(address),
|
|
32
35
|
() => {
|
|
33
36
|
void refresh().catch(() => void 0);
|
|
34
|
-
}
|
|
35
|
-
{ immediate: true }
|
|
37
|
+
}
|
|
36
38
|
);
|
|
37
39
|
return {
|
|
38
40
|
balance,
|
package/dist/useBalance.cjs
CHANGED
package/dist/useBalance.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-solana/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Vue plugin and composables for Solana applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@vue-solana/core": "0.
|
|
81
|
+
"@vue-solana/core": "0.3.1"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@solana/web3-compat": "^0.0.21",
|