@vue-solana/vue 0.2.2 → 0.3.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 +41 -8
- package/dist/index.cjs +93 -195
- package/dist/index.d.cts +16 -77
- package/dist/index.d.mts +16 -77
- package/dist/index.d.ts +16 -77
- package/dist/index.mjs +81 -183
- package/dist/shared/vue.1M_c5FWA.mjs +46 -0
- package/dist/shared/vue.BMUEDN2t.mjs +28 -0
- package/dist/shared/vue.BSVxQ9Yi.cjs +30 -0
- package/dist/shared/vue.BqDzSepb.mjs +18 -0
- package/dist/shared/vue.C4tLiG3R.cjs +50 -0
- package/dist/shared/vue.CNkyBND6.cjs +49 -0
- package/dist/shared/vue.COyyrsQU.cjs +20 -0
- package/dist/shared/vue.CTM6XQ47.cjs +19 -0
- package/dist/shared/vue.CgR3nGpz.mjs +47 -0
- package/dist/shared/vue.CwPjPFN6.cjs +69 -0
- package/dist/shared/vue.CwhEmATP.cjs +9 -0
- package/dist/shared/vue.DGhodYJh.d.cts +20 -0
- package/dist/shared/vue.DGhodYJh.d.mts +20 -0
- package/dist/shared/vue.DGhodYJh.d.ts +20 -0
- package/dist/shared/vue.DYf_CRDv.mjs +67 -0
- package/dist/shared/vue.DlEAL2G8.mjs +7 -0
- package/dist/shared/vue.P9tgeC5S.cjs +15 -0
- package/dist/shared/vue.PoQ8Vpmy.mjs +17 -0
- package/dist/shared/vue.h-uS8MXN.mjs +13 -0
- package/dist/useBalance.cjs +11 -0
- package/dist/useBalance.d.cts +12 -0
- package/dist/useBalance.d.mts +12 -0
- package/dist/useBalance.d.ts +12 -0
- package/dist/useBalance.mjs +5 -0
- package/dist/useConnection.cjs +10 -0
- package/dist/useConnection.d.cts +3 -0
- package/dist/useConnection.d.mts +3 -0
- package/dist/useConnection.d.ts +3 -0
- package/dist/useConnection.mjs +4 -0
- package/dist/useRpc.cjs +9 -0
- package/dist/useRpc.d.cts +16 -0
- package/dist/useRpc.d.mts +16 -0
- package/dist/useRpc.d.ts +16 -0
- package/dist/useRpc.mjs +3 -0
- package/dist/useSignAndSendTransaction.cjs +14 -0
- package/dist/useSignAndSendTransaction.d.cts +11 -0
- package/dist/useSignAndSendTransaction.d.mts +11 -0
- package/dist/useSignAndSendTransaction.d.ts +11 -0
- package/dist/useSignAndSendTransaction.mjs +8 -0
- package/dist/useSolana.cjs +9 -0
- package/dist/useSolana.d.cts +8 -0
- package/dist/useSolana.d.mts +8 -0
- package/dist/useSolana.d.ts +8 -0
- package/dist/useSolana.mjs +2 -0
- package/dist/useTransaction.cjs +8 -0
- package/dist/useTransaction.d.cts +11 -0
- package/dist/useTransaction.d.mts +11 -0
- package/dist/useTransaction.d.ts +11 -0
- package/dist/useTransaction.mjs +2 -0
- package/dist/useWallet.cjs +9 -0
- package/dist/useWallet.d.cts +16 -0
- package/dist/useWallet.d.mts +16 -0
- package/dist/useWallet.d.ts +16 -0
- package/dist/useWallet.mjs +3 -0
- package/dist/useWallets.cjs +9 -0
- package/dist/useWallets.d.cts +11 -0
- package/dist/useWallets.d.mts +11 -0
- package/dist/useWallets.d.ts +11 -0
- package/dist/useWallets.mjs +3 -0
- package/package.json +42 -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
|
|
@@ -53,6 +62,13 @@ createApp(App).use(
|
|
|
53
62
|
|
|
54
63
|
Supported clusters are `mainnet-beta`, `devnet`, `testnet`, and `localnet`. Use `mainnet-beta` for Solana mainnet; this is Solana's official cluster name.
|
|
55
64
|
|
|
65
|
+
The root export remains supported. For composables, prefer direct subpath imports in new code so bundlers can avoid evaluating unrelated package entry code:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { useRpc } from "@vue-solana/vue/useRpc";
|
|
69
|
+
import { useWallet } from "@vue-solana/vue/useWallet";
|
|
70
|
+
```
|
|
71
|
+
|
|
56
72
|
For development, use `devnet` and request free test SOL from the official faucet:
|
|
57
73
|
|
|
58
74
|
```txt
|
|
@@ -63,7 +79,7 @@ https://faucet.solana.com
|
|
|
63
79
|
|
|
64
80
|
```vue
|
|
65
81
|
<script setup lang="ts">
|
|
66
|
-
import { useRpc } from "@vue-solana/vue";
|
|
82
|
+
import { useRpc } from "@vue-solana/vue/useRpc";
|
|
67
83
|
|
|
68
84
|
const { cluster, endpoint, status, error, latestBlockhash, checkConnection } = useRpc();
|
|
69
85
|
</script>
|
|
@@ -85,7 +101,7 @@ const { cluster, endpoint, status, error, latestBlockhash, checkConnection } = u
|
|
|
85
101
|
```vue
|
|
86
102
|
<script setup lang="ts">
|
|
87
103
|
import { ref } from "vue";
|
|
88
|
-
import { useBalance } from "@vue-solana/vue";
|
|
104
|
+
import { useBalance } from "@vue-solana/vue/useBalance";
|
|
89
105
|
|
|
90
106
|
const address = ref("PASTE_A_SOLANA_ADDRESS");
|
|
91
107
|
const { balance, loading, error, refresh } = useBalance(address);
|
|
@@ -105,7 +121,8 @@ const { balance, loading, error, refresh } = useBalance(address);
|
|
|
105
121
|
|
|
106
122
|
```vue
|
|
107
123
|
<script setup lang="ts">
|
|
108
|
-
import { useWallet
|
|
124
|
+
import { useWallet } from "@vue-solana/vue/useWallet";
|
|
125
|
+
import { useWallets } from "@vue-solana/vue/useWallets";
|
|
109
126
|
|
|
110
127
|
const { wallets, selectedWallet, selectWallet, refreshWallets } = useWallets();
|
|
111
128
|
const { publicKey, connected, connecting, connect, disconnect } = useWallet();
|
|
@@ -134,12 +151,16 @@ const { publicKey, connected, connecting, connect, disconnect } = useWallet();
|
|
|
134
151
|
</template>
|
|
135
152
|
```
|
|
136
153
|
|
|
137
|
-
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.
|
|
157
|
+
|
|
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.
|
|
138
159
|
|
|
139
160
|
## Transaction State
|
|
140
161
|
|
|
141
162
|
```ts
|
|
142
|
-
import { useSignAndSendTransaction } from "@vue-solana/vue";
|
|
163
|
+
import { useSignAndSendTransaction } from "@vue-solana/vue/useSignAndSendTransaction";
|
|
143
164
|
|
|
144
165
|
const { signature, loading, error, execute } = useSignAndSendTransaction();
|
|
145
166
|
|
|
@@ -170,10 +191,22 @@ Live demo: [vue-solana-docs.vercel.app/demo](https://vue-solana-docs.vercel.app/
|
|
|
170
191
|
- `useRpc()`: returns cluster, endpoint, connection status, latest blockhash, and `checkConnection()`.
|
|
171
192
|
- `useConnection()`: returns the Solana `Connection`.
|
|
172
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.
|
|
173
195
|
- `useBalance(address, commitment?)`: loads lamport balance for a `PublicKey` or address string.
|
|
174
196
|
- `useTransaction(handler)`: generic async transaction state helper.
|
|
175
197
|
- `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet.
|
|
176
198
|
|
|
199
|
+
Direct composable subpaths:
|
|
200
|
+
|
|
201
|
+
- `@vue-solana/vue/useSolana`
|
|
202
|
+
- `@vue-solana/vue/useRpc`
|
|
203
|
+
- `@vue-solana/vue/useConnection`
|
|
204
|
+
- `@vue-solana/vue/useBalance`
|
|
205
|
+
- `@vue-solana/vue/useWallet`
|
|
206
|
+
- `@vue-solana/vue/useWallets`
|
|
207
|
+
- `@vue-solana/vue/useTransaction`
|
|
208
|
+
- `@vue-solana/vue/useSignAndSendTransaction`
|
|
209
|
+
|
|
177
210
|
## Known TypeScript Issue
|
|
178
211
|
|
|
179
212
|
`@solana/web3-compat@0.0.21` currently has broken TypeScript metadata. Runtime imports still use the real package, but TypeScript consumers may need a local declaration shim.
|
|
@@ -199,4 +232,4 @@ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern tha
|
|
|
199
232
|
|
|
200
233
|
## Status
|
|
201
234
|
|
|
202
|
-
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,196 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const useBalance = require('./shared/vue.CNkyBND6.cjs');
|
|
4
|
+
const useConnection = require('./shared/vue.CwhEmATP.cjs');
|
|
5
|
+
const useRpc = require('./shared/vue.COyyrsQU.cjs');
|
|
6
|
+
const useSignAndSendTransaction = require('./shared/vue.CTM6XQ47.cjs');
|
|
7
|
+
const useSolana = require('./shared/vue.C4tLiG3R.cjs');
|
|
8
|
+
const useTransaction = require('./shared/vue.BSVxQ9Yi.cjs');
|
|
9
|
+
const useWallet = require('./shared/vue.CwPjPFN6.cjs');
|
|
10
|
+
const useWallets = require('./shared/vue.P9tgeC5S.cjs');
|
|
11
|
+
const walletStandard = require('@vue-solana/core/wallet-standard');
|
|
12
|
+
const mobileWallet = require('@vue-solana/core/mobile-wallet');
|
|
13
|
+
const rpc = require('@vue-solana/core/rpc');
|
|
4
14
|
const vue = require('vue');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const solanaInjectionKey = Symbol("VueSolana");
|
|
8
|
-
|
|
9
|
-
function useSolana() {
|
|
10
|
-
const context = vue.inject(solanaInjectionKey);
|
|
11
|
-
if (!context) {
|
|
12
|
-
throw new Error("Vue Solana plugin is not installed");
|
|
13
|
-
}
|
|
14
|
-
return context;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function useRpc() {
|
|
18
|
-
const solana = useSolana();
|
|
19
|
-
return {
|
|
20
|
-
cluster: vue.computed(() => solana.cluster),
|
|
21
|
-
endpoint: vue.computed(() => solana.endpoint),
|
|
22
|
-
wsEndpoint: vue.computed(() => solana.wsEndpoint),
|
|
23
|
-
status: solana.status,
|
|
24
|
-
error: solana.error,
|
|
25
|
-
latestBlockhash: solana.latestBlockhash,
|
|
26
|
-
checkConnection: solana.checkConnection,
|
|
27
|
-
connection: solana.connection
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function useConnection() {
|
|
32
|
-
return useRpc().connection;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function useBalance(address, commitment) {
|
|
36
|
-
const connection = useConnection();
|
|
37
|
-
const balance = vue.ref(null);
|
|
38
|
-
const loading = vue.ref(false);
|
|
39
|
-
const error = vue.ref(null);
|
|
40
|
-
async function refresh() {
|
|
41
|
-
const value = vue.toValue(address);
|
|
42
|
-
if (!value) {
|
|
43
|
-
balance.value = null;
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
loading.value = true;
|
|
47
|
-
error.value = null;
|
|
48
|
-
try {
|
|
49
|
-
const publicKey = typeof value === "string" ? new web3Compat.PublicKey(value) : value;
|
|
50
|
-
balance.value = await connection.getBalance(publicKey, commitment);
|
|
51
|
-
return balance.value;
|
|
52
|
-
} catch (cause) {
|
|
53
|
-
error.value = cause;
|
|
54
|
-
throw cause;
|
|
55
|
-
} finally {
|
|
56
|
-
loading.value = false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
vue.watch(
|
|
60
|
-
() => vue.toValue(address),
|
|
61
|
-
() => {
|
|
62
|
-
void refresh().catch(() => void 0);
|
|
63
|
-
},
|
|
64
|
-
{ immediate: true }
|
|
65
|
-
);
|
|
66
|
-
return {
|
|
67
|
-
balance,
|
|
68
|
-
loading,
|
|
69
|
-
error,
|
|
70
|
-
refresh
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function useWallet() {
|
|
75
|
-
const solana = useSolana();
|
|
76
|
-
const wallet = solana.wallet;
|
|
77
|
-
const connecting = vue.ref(false);
|
|
78
|
-
const disconnecting = vue.ref(false);
|
|
79
|
-
async function connect() {
|
|
80
|
-
const activeWallet = wallet.value;
|
|
81
|
-
if (!activeWallet) {
|
|
82
|
-
throw new Error("No Solana wallet is configured");
|
|
83
|
-
}
|
|
84
|
-
connecting.value = true;
|
|
85
|
-
try {
|
|
86
|
-
const connection = activeWallet.connect();
|
|
87
|
-
vue.triggerRef(wallet);
|
|
88
|
-
await connection;
|
|
89
|
-
vue.triggerRef(wallet);
|
|
90
|
-
console.info("[Vue Solana] Wallet connected", {
|
|
91
|
-
publicKey: activeWallet.publicKey?.toBase58() ?? null
|
|
92
|
-
});
|
|
93
|
-
} catch (error) {
|
|
94
|
-
vue.triggerRef(wallet);
|
|
95
|
-
console.error("[Vue Solana] Wallet connection failed", error);
|
|
96
|
-
throw error;
|
|
97
|
-
} finally {
|
|
98
|
-
connecting.value = false;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async function disconnect() {
|
|
102
|
-
const activeWallet = wallet.value;
|
|
103
|
-
if (!activeWallet) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const publicKey = activeWallet.publicKey?.toBase58() ?? null;
|
|
107
|
-
disconnecting.value = true;
|
|
108
|
-
try {
|
|
109
|
-
await activeWallet.disconnect();
|
|
110
|
-
vue.triggerRef(wallet);
|
|
111
|
-
console.info("[Vue Solana] Wallet disconnected", { publicKey });
|
|
112
|
-
} catch (error) {
|
|
113
|
-
vue.triggerRef(wallet);
|
|
114
|
-
console.error("[Vue Solana] Wallet disconnection failed", error);
|
|
115
|
-
throw error;
|
|
116
|
-
} finally {
|
|
117
|
-
disconnecting.value = false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const isConnecting = vue.computed(() => Boolean(connecting.value || wallet.value?.connecting));
|
|
121
|
-
const isDisconnecting = vue.computed(
|
|
122
|
-
() => Boolean(disconnecting.value || wallet.value?.disconnecting)
|
|
123
|
-
);
|
|
124
|
-
return {
|
|
125
|
-
wallet,
|
|
126
|
-
publicKey: vue.computed(() => wallet.value?.publicKey ?? null),
|
|
127
|
-
connected: vue.computed(() => Boolean(wallet.value?.connected && wallet.value.publicKey)),
|
|
128
|
-
connecting: isConnecting,
|
|
129
|
-
disconnecting: isDisconnecting,
|
|
130
|
-
loading: vue.computed(() => isConnecting.value || isDisconnecting.value),
|
|
131
|
-
setWallet: solana.setWallet,
|
|
132
|
-
connect,
|
|
133
|
-
disconnect
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function useTransaction(handler) {
|
|
138
|
-
const signature = vue.ref(null);
|
|
139
|
-
const loading = vue.ref(false);
|
|
140
|
-
const error = vue.ref(null);
|
|
141
|
-
async function execute(...args) {
|
|
142
|
-
loading.value = true;
|
|
143
|
-
error.value = null;
|
|
144
|
-
try {
|
|
145
|
-
signature.value = await handler(...args);
|
|
146
|
-
return signature.value;
|
|
147
|
-
} catch (cause) {
|
|
148
|
-
error.value = cause;
|
|
149
|
-
throw cause;
|
|
150
|
-
} finally {
|
|
151
|
-
loading.value = false;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
signature,
|
|
156
|
-
loading,
|
|
157
|
-
error,
|
|
158
|
-
execute
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function useSignAndSendTransaction() {
|
|
163
|
-
const connection = useConnection();
|
|
164
|
-
const { wallet } = useWallet();
|
|
165
|
-
return useTransaction((transaction, options) => {
|
|
166
|
-
if (!wallet.value) {
|
|
167
|
-
return Promise.reject(new Error("No Solana wallet is configured"));
|
|
168
|
-
}
|
|
169
|
-
return core.signAndSendTransaction(connection, wallet.value, transaction, options);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
function useWallets() {
|
|
174
|
-
const solana = useSolana();
|
|
175
|
-
return {
|
|
176
|
-
wallets: solana.wallets,
|
|
177
|
-
selectedWallet: solana.selectedWallet,
|
|
178
|
-
refreshWallets: solana.refreshWallets,
|
|
179
|
-
selectWallet: solana.selectWallet
|
|
180
|
-
};
|
|
181
|
-
}
|
|
15
|
+
require('@vue-solana/core/transaction');
|
|
182
16
|
|
|
183
17
|
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
184
18
|
function createSolanaPlugin(options = {}) {
|
|
185
19
|
return {
|
|
186
20
|
install(app) {
|
|
187
|
-
const context =
|
|
21
|
+
const context = rpc.createSolanaContext(options);
|
|
188
22
|
const wallet = vue.shallowRef(options.wallet ?? null);
|
|
189
23
|
const wallets = vue.shallowRef([]);
|
|
190
24
|
const selectedWallet = vue.shallowRef(null);
|
|
191
25
|
const status = vue.ref("idle");
|
|
192
26
|
const error = vue.ref(null);
|
|
193
27
|
const latestBlockhash = vue.ref(null);
|
|
28
|
+
const adaptedWallets = /* @__PURE__ */ new WeakMap();
|
|
194
29
|
let unsubscribeWallets = null;
|
|
195
30
|
let rpcCheckId = 0;
|
|
196
31
|
async function checkConnection() {
|
|
@@ -229,8 +64,14 @@ function createSolanaPlugin(options = {}) {
|
|
|
229
64
|
}
|
|
230
65
|
}
|
|
231
66
|
function refreshWallets() {
|
|
232
|
-
|
|
233
|
-
|
|
67
|
+
if (options.mobileWallet !== false) {
|
|
68
|
+
mobileWallet.registerSolanaMobileWallet({
|
|
69
|
+
chains: [walletStandard.getSolanaChain(context.cluster)],
|
|
70
|
+
...options.mobileWallet || {}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
unsubscribeWallets ??= walletStandard.subscribeSolanaWallets(refreshWallets);
|
|
74
|
+
wallets.value = walletStandard.getRegisteredSolanaWallets();
|
|
234
75
|
if (selectedWallet.value) {
|
|
235
76
|
selectedWallet.value = wallets.value.find((nextWallet) => nextWallet.name === selectedWallet.value?.name) ?? null;
|
|
236
77
|
if (!selectedWallet.value) {
|
|
@@ -240,10 +81,61 @@ function createSolanaPlugin(options = {}) {
|
|
|
240
81
|
}
|
|
241
82
|
function selectWallet(nextWallet) {
|
|
242
83
|
selectedWallet.value = nextWallet;
|
|
243
|
-
wallet.value = nextWallet ?
|
|
244
|
-
|
|
84
|
+
wallet.value = nextWallet ? getAdaptedWallet(nextWallet) : options.wallet ?? null;
|
|
85
|
+
}
|
|
86
|
+
function getAdaptedWallet(walletInfo) {
|
|
87
|
+
if (!isObject(walletInfo.wallet)) {
|
|
88
|
+
return walletStandard.adaptSolanaStandardWallet(walletInfo, {
|
|
89
|
+
chain: walletStandard.getSolanaChain(context.cluster),
|
|
90
|
+
onChange: () => vue.triggerRef(wallet)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const cachedWallet = adaptedWallets.get(walletInfo.wallet);
|
|
94
|
+
if (cachedWallet) {
|
|
95
|
+
return cachedWallet;
|
|
96
|
+
}
|
|
97
|
+
const adaptedWallet = walletStandard.adaptSolanaStandardWallet(walletInfo, {
|
|
98
|
+
chain: walletStandard.getSolanaChain(context.cluster),
|
|
245
99
|
onChange: () => vue.triggerRef(wallet)
|
|
246
|
-
})
|
|
100
|
+
});
|
|
101
|
+
const cachedAdapter = {
|
|
102
|
+
get publicKey() {
|
|
103
|
+
return adaptedWallet.publicKey;
|
|
104
|
+
},
|
|
105
|
+
get connected() {
|
|
106
|
+
return adaptedWallet.connected;
|
|
107
|
+
},
|
|
108
|
+
get connecting() {
|
|
109
|
+
return adaptedWallet.connecting;
|
|
110
|
+
},
|
|
111
|
+
get disconnecting() {
|
|
112
|
+
return adaptedWallet.disconnecting;
|
|
113
|
+
},
|
|
114
|
+
async connect() {
|
|
115
|
+
await adaptedWallet.connect();
|
|
116
|
+
await Promise.all(
|
|
117
|
+
Array.from(getCachedWallets()).map(
|
|
118
|
+
(otherWallet) => otherWallet !== cachedAdapter && otherWallet.connected ? otherWallet.disconnect() : void 0
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
disconnect: () => adaptedWallet.disconnect(),
|
|
123
|
+
signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
|
|
124
|
+
signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
|
|
125
|
+
signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet)
|
|
126
|
+
};
|
|
127
|
+
adaptedWallets.set(walletInfo.wallet, cachedAdapter);
|
|
128
|
+
return cachedAdapter;
|
|
129
|
+
}
|
|
130
|
+
function* getCachedWallets() {
|
|
131
|
+
for (const walletInfo of wallets.value) {
|
|
132
|
+
if (isObject(walletInfo.wallet)) {
|
|
133
|
+
const cachedWallet = adaptedWallets.get(walletInfo.wallet);
|
|
134
|
+
if (cachedWallet) {
|
|
135
|
+
yield cachedWallet;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
247
139
|
}
|
|
248
140
|
const vueContext = {
|
|
249
141
|
...context,
|
|
@@ -261,13 +153,18 @@ function createSolanaPlugin(options = {}) {
|
|
|
261
153
|
wallet.value = nextWallet;
|
|
262
154
|
}
|
|
263
155
|
};
|
|
264
|
-
app.provide(solanaInjectionKey, vueContext);
|
|
156
|
+
app.provide(useSolana.solanaInjectionKey, vueContext);
|
|
265
157
|
if (typeof window !== "undefined") {
|
|
266
|
-
|
|
158
|
+
window.setTimeout(() => {
|
|
159
|
+
void checkConnection();
|
|
160
|
+
}, 0);
|
|
267
161
|
}
|
|
268
162
|
}
|
|
269
163
|
};
|
|
270
164
|
}
|
|
165
|
+
function isObject(value) {
|
|
166
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
167
|
+
}
|
|
271
168
|
const VueSolana = createSolanaPlugin;
|
|
272
169
|
function withTimeout(promise, timeoutMs, message) {
|
|
273
170
|
let timeoutId;
|
|
@@ -283,14 +180,15 @@ function withTimeout(promise, timeoutMs, message) {
|
|
|
283
180
|
});
|
|
284
181
|
}
|
|
285
182
|
|
|
183
|
+
exports.useBalance = useBalance.useBalance;
|
|
184
|
+
exports.useConnection = useConnection.useConnection;
|
|
185
|
+
exports.useRpc = useRpc.useRpc;
|
|
186
|
+
exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
|
|
187
|
+
exports.solanaInjectionKey = useSolana.solanaInjectionKey;
|
|
188
|
+
exports.tryUseSolana = useSolana.tryUseSolana;
|
|
189
|
+
exports.useSolana = useSolana.useSolana;
|
|
190
|
+
exports.useTransaction = useTransaction.useTransaction;
|
|
191
|
+
exports.useWallet = useWallet.useWallet;
|
|
192
|
+
exports.useWallets = useWallets.useWallets;
|
|
286
193
|
exports.VueSolana = VueSolana;
|
|
287
194
|
exports.createSolanaPlugin = createSolanaPlugin;
|
|
288
|
-
exports.solanaInjectionKey = solanaInjectionKey;
|
|
289
|
-
exports.useBalance = useBalance;
|
|
290
|
-
exports.useConnection = useConnection;
|
|
291
|
-
exports.useRpc = useRpc;
|
|
292
|
-
exports.useSignAndSendTransaction = useSignAndSendTransaction;
|
|
293
|
-
exports.useSolana = useSolana;
|
|
294
|
-
exports.useTransaction = useTransaction;
|
|
295
|
-
exports.useWallet = useWallet;
|
|
296
|
-
exports.useWallets = useWallets;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,86 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
declare function useConnection(): Connection;
|
|
15
|
-
|
|
16
|
-
declare function useRpc(): {
|
|
17
|
-
cluster: vue.ComputedRef<_vue_solana_core.SolanaCluster>;
|
|
18
|
-
endpoint: vue.ComputedRef<string>;
|
|
19
|
-
wsEndpoint: vue.ComputedRef<string>;
|
|
20
|
-
status: vue.Ref<SolanaConnectionStatus, SolanaConnectionStatus>;
|
|
21
|
-
error: vue.Ref<string | null, string | null>;
|
|
22
|
-
latestBlockhash: vue.Ref<string | null, string | null>;
|
|
23
|
-
checkConnection: () => Promise<void>;
|
|
24
|
-
connection: Connection;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare function useSignAndSendTransaction(): {
|
|
28
|
-
signature: any;
|
|
29
|
-
loading: vue.Ref<boolean, boolean>;
|
|
30
|
-
error: vue.Ref<unknown, unknown>;
|
|
31
|
-
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<any>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
declare function useSolana(): VueSolanaContext;
|
|
35
|
-
|
|
36
|
-
declare function useTransaction<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<TransactionSignature>): {
|
|
37
|
-
signature: any;
|
|
38
|
-
loading: vue.Ref<boolean, boolean>;
|
|
39
|
-
error: vue.Ref<unknown, unknown>;
|
|
40
|
-
execute: (...args: TArgs) => Promise<any>;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
declare function useWallet(): {
|
|
44
|
-
wallet: vue.Ref<_vue_solana_core.SolanaWallet | null, _vue_solana_core.SolanaWallet | null>;
|
|
45
|
-
publicKey: vue.ComputedRef<any>;
|
|
46
|
-
connected: vue.ComputedRef<boolean>;
|
|
47
|
-
connecting: vue.ComputedRef<boolean>;
|
|
48
|
-
disconnecting: vue.ComputedRef<boolean>;
|
|
49
|
-
loading: vue.ComputedRef<boolean>;
|
|
50
|
-
setWallet: (wallet: _vue_solana_core.SolanaWallet | null) => void;
|
|
51
|
-
connect: () => Promise<void>;
|
|
52
|
-
disconnect: () => Promise<void>;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
declare function useWallets(): {
|
|
56
|
-
wallets: vue.Ref<_vue_solana_core.SolanaWalletInfo[], _vue_solana_core.SolanaWalletInfo[]>;
|
|
57
|
-
selectedWallet: vue.Ref<_vue_solana_core.SolanaWalletInfo | null, _vue_solana_core.SolanaWalletInfo | null>;
|
|
58
|
-
refreshWallets: () => void;
|
|
59
|
-
selectWallet: (wallet: _vue_solana_core.SolanaWalletInfo | null) => void;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
|
|
63
|
-
interface VueSolanaContext extends SolanaContext {
|
|
64
|
-
wallet: Ref<SolanaWallet | null>;
|
|
65
|
-
status: Ref<SolanaConnectionStatus>;
|
|
66
|
-
error: Ref<string | null>;
|
|
67
|
-
latestBlockhash: Ref<string | null>;
|
|
68
|
-
wallets: Ref<SolanaWalletInfo[]>;
|
|
69
|
-
selectedWallet: Ref<SolanaWalletInfo | null>;
|
|
70
|
-
checkConnection: () => Promise<void>;
|
|
71
|
-
setWallet: (wallet: SolanaWallet | null) => void;
|
|
72
|
-
refreshWallets: () => void;
|
|
73
|
-
selectWallet: (wallet: SolanaWalletInfo | null) => void;
|
|
74
|
-
}
|
|
75
|
-
declare const solanaInjectionKey: InjectionKey<VueSolanaContext>;
|
|
1
|
+
export { useBalance } from './useBalance.cjs';
|
|
2
|
+
export { useConnection } from './useConnection.cjs';
|
|
3
|
+
export { useRpc } from './useRpc.cjs';
|
|
4
|
+
export { useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
|
|
5
|
+
export { tryUseSolana, useSolana } from './useSolana.cjs';
|
|
6
|
+
export { useTransaction } from './useTransaction.cjs';
|
|
7
|
+
export { useWallet } from './useWallet.cjs';
|
|
8
|
+
export { useWallets } from './useWallets.cjs';
|
|
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';
|
|
11
|
+
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
12
|
+
import { App } from 'vue';
|
|
13
|
+
import '@solana/web3-compat';
|
|
76
14
|
|
|
77
15
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
|
78
16
|
wallet?: SolanaWallet | null;
|
|
17
|
+
mobileWallet?: false | RegisterSolanaMobileWalletOptions;
|
|
79
18
|
}
|
|
80
19
|
declare function createSolanaPlugin(options?: VueSolanaPluginOptions): {
|
|
81
20
|
install(app: App): void;
|
|
82
21
|
};
|
|
83
22
|
declare const VueSolana: typeof createSolanaPlugin;
|
|
84
23
|
|
|
85
|
-
export { VueSolana, createSolanaPlugin
|
|
86
|
-
export type {
|
|
24
|
+
export { VueSolana, createSolanaPlugin };
|
|
25
|
+
export type { VueSolanaPluginOptions };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,86 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
declare function useConnection(): Connection;
|
|
15
|
-
|
|
16
|
-
declare function useRpc(): {
|
|
17
|
-
cluster: vue.ComputedRef<_vue_solana_core.SolanaCluster>;
|
|
18
|
-
endpoint: vue.ComputedRef<string>;
|
|
19
|
-
wsEndpoint: vue.ComputedRef<string>;
|
|
20
|
-
status: vue.Ref<SolanaConnectionStatus, SolanaConnectionStatus>;
|
|
21
|
-
error: vue.Ref<string | null, string | null>;
|
|
22
|
-
latestBlockhash: vue.Ref<string | null, string | null>;
|
|
23
|
-
checkConnection: () => Promise<void>;
|
|
24
|
-
connection: Connection;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
declare function useSignAndSendTransaction(): {
|
|
28
|
-
signature: any;
|
|
29
|
-
loading: vue.Ref<boolean, boolean>;
|
|
30
|
-
error: vue.Ref<unknown, unknown>;
|
|
31
|
-
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<any>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
declare function useSolana(): VueSolanaContext;
|
|
35
|
-
|
|
36
|
-
declare function useTransaction<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<TransactionSignature>): {
|
|
37
|
-
signature: any;
|
|
38
|
-
loading: vue.Ref<boolean, boolean>;
|
|
39
|
-
error: vue.Ref<unknown, unknown>;
|
|
40
|
-
execute: (...args: TArgs) => Promise<any>;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
declare function useWallet(): {
|
|
44
|
-
wallet: vue.Ref<_vue_solana_core.SolanaWallet | null, _vue_solana_core.SolanaWallet | null>;
|
|
45
|
-
publicKey: vue.ComputedRef<any>;
|
|
46
|
-
connected: vue.ComputedRef<boolean>;
|
|
47
|
-
connecting: vue.ComputedRef<boolean>;
|
|
48
|
-
disconnecting: vue.ComputedRef<boolean>;
|
|
49
|
-
loading: vue.ComputedRef<boolean>;
|
|
50
|
-
setWallet: (wallet: _vue_solana_core.SolanaWallet | null) => void;
|
|
51
|
-
connect: () => Promise<void>;
|
|
52
|
-
disconnect: () => Promise<void>;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
declare function useWallets(): {
|
|
56
|
-
wallets: vue.Ref<_vue_solana_core.SolanaWalletInfo[], _vue_solana_core.SolanaWalletInfo[]>;
|
|
57
|
-
selectedWallet: vue.Ref<_vue_solana_core.SolanaWalletInfo | null, _vue_solana_core.SolanaWalletInfo | null>;
|
|
58
|
-
refreshWallets: () => void;
|
|
59
|
-
selectWallet: (wallet: _vue_solana_core.SolanaWalletInfo | null) => void;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
type SolanaConnectionStatus = "idle" | "checking" | "connected" | "error";
|
|
63
|
-
interface VueSolanaContext extends SolanaContext {
|
|
64
|
-
wallet: Ref<SolanaWallet | null>;
|
|
65
|
-
status: Ref<SolanaConnectionStatus>;
|
|
66
|
-
error: Ref<string | null>;
|
|
67
|
-
latestBlockhash: Ref<string | null>;
|
|
68
|
-
wallets: Ref<SolanaWalletInfo[]>;
|
|
69
|
-
selectedWallet: Ref<SolanaWalletInfo | null>;
|
|
70
|
-
checkConnection: () => Promise<void>;
|
|
71
|
-
setWallet: (wallet: SolanaWallet | null) => void;
|
|
72
|
-
refreshWallets: () => void;
|
|
73
|
-
selectWallet: (wallet: SolanaWalletInfo | null) => void;
|
|
74
|
-
}
|
|
75
|
-
declare const solanaInjectionKey: InjectionKey<VueSolanaContext>;
|
|
1
|
+
export { useBalance } from './useBalance.mjs';
|
|
2
|
+
export { useConnection } from './useConnection.mjs';
|
|
3
|
+
export { useRpc } from './useRpc.mjs';
|
|
4
|
+
export { useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
|
|
5
|
+
export { tryUseSolana, useSolana } from './useSolana.mjs';
|
|
6
|
+
export { useTransaction } from './useTransaction.mjs';
|
|
7
|
+
export { useWallet } from './useWallet.mjs';
|
|
8
|
+
export { useWallets } from './useWallets.mjs';
|
|
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';
|
|
11
|
+
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
12
|
+
import { App } from 'vue';
|
|
13
|
+
import '@solana/web3-compat';
|
|
76
14
|
|
|
77
15
|
interface VueSolanaPluginOptions extends SolanaConfig {
|
|
78
16
|
wallet?: SolanaWallet | null;
|
|
17
|
+
mobileWallet?: false | RegisterSolanaMobileWalletOptions;
|
|
79
18
|
}
|
|
80
19
|
declare function createSolanaPlugin(options?: VueSolanaPluginOptions): {
|
|
81
20
|
install(app: App): void;
|
|
82
21
|
};
|
|
83
22
|
declare const VueSolana: typeof createSolanaPlugin;
|
|
84
23
|
|
|
85
|
-
export { VueSolana, createSolanaPlugin
|
|
86
|
-
export type {
|
|
24
|
+
export { VueSolana, createSolanaPlugin };
|
|
25
|
+
export type { VueSolanaPluginOptions };
|