@vue-solana/nuxt 0.5.0 → 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 +56 -3
- package/dist/module.cjs +21 -18
- package/dist/module.mjs +21 -18
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Nuxt module for Solana applications.
|
|
4
4
|
|
|
5
|
-
Use this package in Nuxt apps that need the Vue Solana plugin installed automatically plus auto-imported composables.
|
|
5
|
+
Use this package in Nuxt apps that need the Vue Solana plugin installed automatically plus auto-imported composables for RPC, wallet state, message signing, and transactions.
|
|
6
6
|
|
|
7
7
|
New to Solana? Start with the official docs and the project concepts guide:
|
|
8
8
|
|
|
@@ -65,10 +65,14 @@ The module auto-imports these composables from direct `@vue-solana/vue/*` subpat
|
|
|
65
65
|
- `useSolana()`
|
|
66
66
|
- `useSolanaRpc()`
|
|
67
67
|
- `useSolanaConnection()`
|
|
68
|
+
- `useSolanaAccountInfo()`
|
|
68
69
|
- `useSolanaWallet()`
|
|
69
70
|
- `useSolanaWallets()`
|
|
70
71
|
- `useSolanaBalance()`
|
|
72
|
+
- `useSolanaProgramAccounts()`
|
|
71
73
|
- `useSolanaTransactionConfirmation()`
|
|
74
|
+
- `useSolanaSignatureStatus()`
|
|
75
|
+
- `useSolanaSignMessage()`
|
|
72
76
|
- `useSolanaSignAndSendTransaction()`
|
|
73
77
|
|
|
74
78
|
The runtime plugin is client-only. Auto-imported composables can be called during SSR and return inert state until hydration provides the real client context. Trigger RPC and wallet work from client lifecycle hooks or user actions.
|
|
@@ -111,12 +115,31 @@ const { balance, loading, error, refresh } = useSolanaBalance(address);
|
|
|
111
115
|
</template>
|
|
112
116
|
```
|
|
113
117
|
|
|
118
|
+
## Read Account Data
|
|
119
|
+
|
|
120
|
+
```vue
|
|
121
|
+
<script setup lang="ts">
|
|
122
|
+
const address = ref("PASTE_A_SOLANA_ADDRESS");
|
|
123
|
+
const programId = ref("PASTE_A_SOLANA_PROGRAM_ID");
|
|
124
|
+
const signature = ref("PASTE_A_TRANSACTION_SIGNATURE");
|
|
125
|
+
|
|
126
|
+
const account = useSolanaAccountInfo(address, { watch: true });
|
|
127
|
+
const programAccounts = useSolanaProgramAccounts(programId, {
|
|
128
|
+
dataSlice: { offset: 0, length: 32 },
|
|
129
|
+
filters: [{ dataSize: 165 }],
|
|
130
|
+
});
|
|
131
|
+
const signatureStatus = useSolanaSignatureStatus(signature, { pollIntervalMs: 2_000 });
|
|
132
|
+
</script>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Use `useSolanaProgramAccounts()` carefully on public RPC nodes. Prefer narrow filters, use `dataSlice` for partial reads, and avoid polling broad scans.
|
|
136
|
+
|
|
114
137
|
## Wallet State
|
|
115
138
|
|
|
116
139
|
```vue
|
|
117
140
|
<script setup lang="ts">
|
|
118
141
|
const { wallets, selectedWallet, selectWallet, refreshWallets } = useSolanaWallets();
|
|
119
|
-
const { publicKey, connected, connect, disconnect } = useSolanaWallet();
|
|
142
|
+
const { publicKey, connected, canSignMessage, connect, disconnect } = useSolanaWallet();
|
|
120
143
|
</script>
|
|
121
144
|
|
|
122
145
|
<template>
|
|
@@ -133,6 +156,7 @@ const { publicKey, connected, connect, disconnect } = useSolanaWallet();
|
|
|
133
156
|
<p>Selected: {{ selectedWallet?.name ?? "None" }}</p>
|
|
134
157
|
<p>Connected: {{ connected }}</p>
|
|
135
158
|
<p>Public key: {{ publicKey?.toBase58() }}</p>
|
|
159
|
+
<p>Can sign messages: {{ canSignMessage }}</p>
|
|
136
160
|
<button type="button" :disabled="!selectedWallet || connected" @click="connect">Connect</button>
|
|
137
161
|
<button type="button" :disabled="!connected" @click="disconnect">Disconnect</button>
|
|
138
162
|
</section>
|
|
@@ -143,6 +167,33 @@ Browser extension wallets are discovered through the Solana Wallet Standard. And
|
|
|
143
167
|
|
|
144
168
|
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. Set `solana.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.
|
|
145
169
|
|
|
170
|
+
## Message Signing
|
|
171
|
+
|
|
172
|
+
```vue
|
|
173
|
+
<script setup lang="ts">
|
|
174
|
+
const { connected, canSignMessage } = useSolanaWallet();
|
|
175
|
+
const { signature, status, error, execute } = useSolanaSignMessage();
|
|
176
|
+
|
|
177
|
+
async function signIn() {
|
|
178
|
+
const message = new TextEncoder().encode("Sign in to My Nuxt Solana App");
|
|
179
|
+
await execute(message);
|
|
180
|
+
}
|
|
181
|
+
</script>
|
|
182
|
+
|
|
183
|
+
<template>
|
|
184
|
+
<section>
|
|
185
|
+
<button type="button" :disabled="!connected || !canSignMessage" @click="signIn">
|
|
186
|
+
Sign message
|
|
187
|
+
</button>
|
|
188
|
+
<p>Status: {{ status }}</p>
|
|
189
|
+
<p v-if="signature">Signature bytes: {{ signature.length }}</p>
|
|
190
|
+
<pre v-if="error">{{ error.message }}</pre>
|
|
191
|
+
</section>
|
|
192
|
+
</template>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Message signing is for wallet ownership or authentication challenges. It is separate from transaction signing and does not authorize on-chain activity. For auth flows, use a server-issued nonce and verify the returned signature server-side.
|
|
196
|
+
|
|
146
197
|
## Example App
|
|
147
198
|
|
|
148
199
|
This README includes small snippets for quick reference. For a complete runnable Nuxt flow, see the example app:
|
|
@@ -174,10 +225,12 @@ If TypeScript cannot resolve `@solana/web3-compat`, add `types/web3-compat.d.ts`
|
|
|
174
225
|
```ts
|
|
175
226
|
declare module "@solana/web3-compat" {
|
|
176
227
|
export type {
|
|
228
|
+
AccountInfo,
|
|
177
229
|
Commitment,
|
|
178
230
|
RpcResponseAndContext,
|
|
179
231
|
SendOptions,
|
|
180
232
|
SignatureResult,
|
|
233
|
+
SignatureStatus,
|
|
181
234
|
TransactionSignature,
|
|
182
235
|
} from "@solana/web3.js";
|
|
183
236
|
export {
|
|
@@ -196,4 +249,4 @@ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern tha
|
|
|
196
249
|
|
|
197
250
|
## Status
|
|
198
251
|
|
|
199
|
-
This package is early-stage. RPC, balance, browser extension wallet, Android mobile wallet, and transaction composables are usable in Nuxt apps.
|
|
252
|
+
This package is early-stage. RPC, balance, browser extension wallet, Android mobile wallet, iOS browser wallet, message signing, and transaction composables are usable in Nuxt apps.
|
package/dist/module.cjs
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
const kit = require('@nuxt/kit');
|
|
4
4
|
|
|
5
5
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
6
|
+
const SOLANA_COMPOSABLE_IMPORTS = [
|
|
7
|
+
["useAccountInfo", "useSolanaAccountInfo"],
|
|
8
|
+
["useBalance", "useSolanaBalance"],
|
|
9
|
+
["useConnection", "useSolanaConnection"],
|
|
10
|
+
["useProgramAccounts", "useSolanaProgramAccounts"],
|
|
11
|
+
["useRpc", "useSolanaRpc"],
|
|
12
|
+
["useSignMessage", "useSolanaSignMessage"],
|
|
13
|
+
["useSignAndSendTransaction", "useSolanaSignAndSendTransaction"],
|
|
14
|
+
["useSignatureStatus", "useSolanaSignatureStatus"],
|
|
15
|
+
["useSolana", "useSolana"],
|
|
16
|
+
["useTransactionConfirmation", "useSolanaTransactionConfirmation"],
|
|
17
|
+
["useWallet", "useSolanaWallet"],
|
|
18
|
+
["useWallets", "useSolanaWallets"]
|
|
19
|
+
];
|
|
20
|
+
const SOLANA_IMPORTS = SOLANA_COMPOSABLE_IMPORTS.map(([name, as]) => ({
|
|
21
|
+
name,
|
|
22
|
+
as,
|
|
23
|
+
from: `@vue-solana/vue/${name}`
|
|
24
|
+
}));
|
|
25
|
+
|
|
6
26
|
const VITE_OPTIMIZE_DEPS = [
|
|
7
27
|
"@solana/web3-compat",
|
|
8
28
|
"@solana/web3.js",
|
|
@@ -50,24 +70,7 @@ const module$1 = kit.defineNuxtModule({
|
|
|
50
70
|
src: resolver.resolve("./runtime/plugin"),
|
|
51
71
|
mode: "client"
|
|
52
72
|
});
|
|
53
|
-
kit.addImports(
|
|
54
|
-
{ name: "useBalance", as: "useSolanaBalance", from: "@vue-solana/vue/useBalance" },
|
|
55
|
-
{ name: "useConnection", as: "useSolanaConnection", from: "@vue-solana/vue/useConnection" },
|
|
56
|
-
{ name: "useRpc", as: "useSolanaRpc", from: "@vue-solana/vue/useRpc" },
|
|
57
|
-
{
|
|
58
|
-
name: "useSignAndSendTransaction",
|
|
59
|
-
as: "useSolanaSignAndSendTransaction",
|
|
60
|
-
from: "@vue-solana/vue/useSignAndSendTransaction"
|
|
61
|
-
},
|
|
62
|
-
{ name: "useSolana", as: "useSolana", from: "@vue-solana/vue/useSolana" },
|
|
63
|
-
{
|
|
64
|
-
name: "useTransactionConfirmation",
|
|
65
|
-
as: "useSolanaTransactionConfirmation",
|
|
66
|
-
from: "@vue-solana/vue/useTransactionConfirmation"
|
|
67
|
-
},
|
|
68
|
-
{ name: "useWallet", as: "useSolanaWallet", from: "@vue-solana/vue/useWallet" },
|
|
69
|
-
{ name: "useWallets", as: "useSolanaWallets", from: "@vue-solana/vue/useWallets" }
|
|
70
|
-
]);
|
|
73
|
+
kit.addImports(SOLANA_IMPORTS);
|
|
71
74
|
}
|
|
72
75
|
});
|
|
73
76
|
function toPublicSolanaConfig(options) {
|
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addPlugin, addImports } from '@nuxt/kit';
|
|
2
2
|
|
|
3
|
+
const SOLANA_COMPOSABLE_IMPORTS = [
|
|
4
|
+
["useAccountInfo", "useSolanaAccountInfo"],
|
|
5
|
+
["useBalance", "useSolanaBalance"],
|
|
6
|
+
["useConnection", "useSolanaConnection"],
|
|
7
|
+
["useProgramAccounts", "useSolanaProgramAccounts"],
|
|
8
|
+
["useRpc", "useSolanaRpc"],
|
|
9
|
+
["useSignMessage", "useSolanaSignMessage"],
|
|
10
|
+
["useSignAndSendTransaction", "useSolanaSignAndSendTransaction"],
|
|
11
|
+
["useSignatureStatus", "useSolanaSignatureStatus"],
|
|
12
|
+
["useSolana", "useSolana"],
|
|
13
|
+
["useTransactionConfirmation", "useSolanaTransactionConfirmation"],
|
|
14
|
+
["useWallet", "useSolanaWallet"],
|
|
15
|
+
["useWallets", "useSolanaWallets"]
|
|
16
|
+
];
|
|
17
|
+
const SOLANA_IMPORTS = SOLANA_COMPOSABLE_IMPORTS.map(([name, as]) => ({
|
|
18
|
+
name,
|
|
19
|
+
as,
|
|
20
|
+
from: `@vue-solana/vue/${name}`
|
|
21
|
+
}));
|
|
22
|
+
|
|
3
23
|
const VITE_OPTIMIZE_DEPS = [
|
|
4
24
|
"@solana/web3-compat",
|
|
5
25
|
"@solana/web3.js",
|
|
@@ -47,24 +67,7 @@ const module$1 = defineNuxtModule({
|
|
|
47
67
|
src: resolver.resolve("./runtime/plugin"),
|
|
48
68
|
mode: "client"
|
|
49
69
|
});
|
|
50
|
-
addImports(
|
|
51
|
-
{ name: "useBalance", as: "useSolanaBalance", from: "@vue-solana/vue/useBalance" },
|
|
52
|
-
{ name: "useConnection", as: "useSolanaConnection", from: "@vue-solana/vue/useConnection" },
|
|
53
|
-
{ name: "useRpc", as: "useSolanaRpc", from: "@vue-solana/vue/useRpc" },
|
|
54
|
-
{
|
|
55
|
-
name: "useSignAndSendTransaction",
|
|
56
|
-
as: "useSolanaSignAndSendTransaction",
|
|
57
|
-
from: "@vue-solana/vue/useSignAndSendTransaction"
|
|
58
|
-
},
|
|
59
|
-
{ name: "useSolana", as: "useSolana", from: "@vue-solana/vue/useSolana" },
|
|
60
|
-
{
|
|
61
|
-
name: "useTransactionConfirmation",
|
|
62
|
-
as: "useSolanaTransactionConfirmation",
|
|
63
|
-
from: "@vue-solana/vue/useTransactionConfirmation"
|
|
64
|
-
},
|
|
65
|
-
{ name: "useWallet", as: "useSolanaWallet", from: "@vue-solana/vue/useWallet" },
|
|
66
|
-
{ name: "useWallets", as: "useSolanaWallets", from: "@vue-solana/vue/useWallets" }
|
|
67
|
-
]);
|
|
70
|
+
addImports(SOLANA_IMPORTS);
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
function toPublicSolanaConfig(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-solana/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Nuxt module for Solana applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@vue-solana/core": "0.
|
|
42
|
-
"@vue-solana/vue": "0.
|
|
41
|
+
"@vue-solana/core": "0.6.0",
|
|
42
|
+
"@vue-solana/vue": "0.7.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@solana/web3-compat": "^0.0.21",
|