@vue-solana/vue 0.1.0 → 0.1.3

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