@vue-solana/vue 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +170 -3
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -2,25 +2,192 @@
2
2
 
3
3
  Vue plugin and composables for Solana applications.
4
4
 
5
+ Use this package in Vue 3 apps that need Solana RPC access, balance reads, wallet state, and transaction helper state.
6
+
7
+ New to Solana? Start with the official docs and the project concepts guide:
8
+
9
+ - [Solana Documentation](https://solana.com/docs)
10
+ - [Solana RPC Methods](https://solana.com/docs/rpc)
11
+ - [Solana Clusters](https://solana.com/docs/references/clusters)
12
+ - [Vue Solana Concepts Guide](https://github.com/vue-solana/vue-solana/tree/main/apps/docs/content/concepts/solana-for-vue-developers.md)
13
+ - [`@vue-solana/vue` docs](https://github.com/vue-solana/vue-solana/tree/main/apps/docs/content/packages/vue.md)
14
+
5
15
  ## Install
6
16
 
7
17
  ```sh
8
18
  pnpm add @vue-solana/vue @vue-solana/core @solana/web3-compat
9
19
  ```
10
20
 
11
- ## Usage
21
+ ```sh
22
+ npm install @vue-solana/vue @vue-solana/core @solana/web3-compat
23
+ ```
24
+
25
+ ## Plugin Setup
12
26
 
13
27
  ```ts
14
28
  import { createApp } from 'vue'
15
29
  import { createSolanaPlugin } from '@vue-solana/vue'
30
+ import App from './App.vue'
16
31
 
32
+ createApp(App)
33
+ .use(createSolanaPlugin({
34
+ cluster: 'devnet'
35
+ }))
36
+ .mount('#app')
37
+ ```
38
+
39
+ You can also pass a custom RPC endpoint:
40
+
41
+ ```ts
17
42
  createApp(App).use(createSolanaPlugin({
18
- cluster: 'devnet'
43
+ cluster: 'mainnet-beta',
44
+ endpoint: 'https://your-rpc.example.com',
45
+ commitment: 'confirmed'
19
46
  }))
20
47
  ```
21
48
 
49
+ Supported clusters are `mainnet-beta`, `devnet`, `testnet`, and `localnet`. Use `mainnet-beta` for Solana mainnet; this is Solana's official cluster name.
50
+
51
+ For development, use `devnet` and request free test SOL from the official faucet:
52
+
53
+ ```txt
54
+ https://faucet.solana.com
55
+ ```
56
+
57
+ ## Read RPC State
58
+
59
+ ```vue
60
+ <script setup lang="ts">
61
+ import { useRpc } from '@vue-solana/vue'
62
+
63
+ const {
64
+ cluster,
65
+ endpoint,
66
+ status,
67
+ error,
68
+ latestBlockhash,
69
+ checkConnection
70
+ } = useRpc()
71
+ </script>
72
+
73
+ <template>
74
+ <section>
75
+ <p>Cluster: {{ cluster }}</p>
76
+ <p>Endpoint: {{ endpoint }}</p>
77
+ <p>Status: {{ status }}</p>
78
+ <p>Latest blockhash: {{ latestBlockhash }}</p>
79
+ <p v-if="error">Error: {{ error }}</p>
80
+ <button type="button" @click="checkConnection">Check RPC</button>
81
+ </section>
82
+ </template>
83
+ ```
84
+
85
+ ## Read Balance
86
+
87
+ ```vue
88
+ <script setup lang="ts">
89
+ import { ref } from 'vue'
90
+ import { useBalance } from '@vue-solana/vue'
91
+
92
+ const address = ref('PASTE_A_SOLANA_ADDRESS')
93
+ const { balance, loading, error, refresh } = useBalance(address)
94
+ </script>
95
+
96
+ <template>
97
+ <section>
98
+ <p>Lamports: {{ balance }}</p>
99
+ <p v-if="loading">Loading...</p>
100
+ <pre v-if="error">{{ error }}</pre>
101
+ <button type="button" @click="refresh">Refresh</button>
102
+ </section>
103
+ </template>
104
+ ```
105
+
106
+ ## Wallet State
107
+
108
+ ```vue
109
+ <script setup lang="ts">
110
+ import { useWallet } from '@vue-solana/vue'
111
+
112
+ const { publicKey, connected, connecting, connect, disconnect } = useWallet()
113
+ </script>
114
+
115
+ <template>
116
+ <section>
117
+ <p>Connected: {{ connected }}</p>
118
+ <p>Public key: {{ publicKey?.toBase58() }}</p>
119
+ <p v-if="connecting">Connecting...</p>
120
+ <button type="button" @click="connect">Connect</button>
121
+ <button type="button" @click="disconnect">Disconnect</button>
122
+ </section>
123
+ </template>
124
+ ```
125
+
126
+ Browser wallet discovery is not included yet. `connect()` works only after you configure a wallet object that implements `SolanaWallet`.
127
+
128
+ ## Transaction State
129
+
130
+ ```ts
131
+ import { useSignAndSendTransaction } from '@vue-solana/vue'
132
+
133
+ const { signature, loading, error, execute } = useSignAndSendTransaction()
134
+
135
+ await execute(transaction, {
136
+ skipPreflight: false
137
+ })
138
+ ```
139
+
140
+ The current wallet must be connected and support either `signAndSendTransaction` or `signTransaction`.
141
+
142
+ ## Example App
143
+
144
+ This README includes small snippets for quick reference. For a complete runnable Vue + Vite flow, see the example app:
145
+
146
+ ```sh
147
+ pnpm dev:vue
148
+ ```
149
+
150
+ Source: [`examples/vue-vite`](https://github.com/vue-solana/vue-solana/tree/main/examples/vue-vite)
151
+
152
+ ## API
153
+
154
+ - `createSolanaPlugin(options?)`: installs the Vue Solana context.
155
+ - `VueSolana`: alias for `createSolanaPlugin`.
156
+ - `useSolana()`: returns the full injected Solana context.
157
+ - `useRpc()`: returns cluster, endpoint, connection status, latest blockhash, and `checkConnection()`.
158
+ - `useConnection()`: returns the Solana `Connection`.
159
+ - `useWallet()`: returns wallet refs, computed connection state, and wallet actions.
160
+ - `useBalance(address, commitment?)`: loads lamport balance for a `PublicKey` or address string.
161
+ - `useTransaction(handler)`: generic async transaction state helper.
162
+ - `useSignAndSendTransaction()`: signs and sends a transaction through the configured wallet.
163
+
22
164
  ## Known TypeScript Issue
23
165
 
24
166
  `@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.
25
167
 
26
- Add `types/web3-compat.d.ts` to your app if TypeScript cannot resolve `@solana/web3-compat`. See the repository README for the full workaround.
168
+ If TypeScript cannot resolve `@solana/web3-compat`, add `types/web3-compat.d.ts` to your app:
169
+
170
+ ```ts
171
+ declare module '@solana/web3-compat' {
172
+ export type {
173
+ Commitment,
174
+ SendOptions,
175
+ TransactionSignature
176
+ } from '@solana/web3.js'
177
+ export {
178
+ Connection,
179
+ Keypair,
180
+ PublicKey,
181
+ SystemProgram,
182
+ Transaction,
183
+ TransactionInstruction,
184
+ VersionedTransaction
185
+ } from '@solana/web3.js'
186
+ }
187
+ ```
188
+
189
+ Make sure your `tsconfig.json` includes `types/**/*.d.ts` or another pattern that includes the shim.
190
+
191
+ ## Status
192
+
193
+ This package is early-stage. RPC and balance reads are usable; first-class browser wallet adapter support is planned.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-solana/vue",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Vue plugin and composables for Solana applications.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -11,7 +11,7 @@
11
11
  "web3",
12
12
  "wallet"
13
13
  ],
14
- "homepage": "https://github.com/vue-solana/vue-solana#readme",
14
+ "homepage": "https://vue-solana-docs.vercel.app/packages/vue",
15
15
  "bugs": {
16
16
  "url": "https://github.com/vue-solana/vue-solana/issues"
17
17
  },
@@ -38,7 +38,7 @@
38
38
  "access": "public"
39
39
  },
40
40
  "dependencies": {
41
- "@vue-solana/core": "0.1.0"
41
+ "@vue-solana/core": "0.1.2"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@solana/web3-compat": "^0.0.21",