@naculus/connect-appkit-vue 0.10.0 → 0.11.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 +103 -21
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
**Vue component wrappers for Naculus Connect Web Components** — auto-generated Vue proxies for all 28 Stencil components. Use `<connect-button>`, `<wallet-modal>`, etc. directly in Vue templates.
|
|
4
4
|
|
|
5
|
-
> **Components have parity with React
|
|
6
|
-
> are generated from the same Stencil source,
|
|
7
|
-
>
|
|
8
|
-
>
|
|
9
|
-
>
|
|
10
|
-
>
|
|
11
|
-
>
|
|
5
|
+
> **Components and composables have parity with React, with three named
|
|
6
|
+
> exceptions.** All 28 components are generated from the same Stencil source,
|
|
7
|
+
> so anything visual works the same in both. The composables cover the React
|
|
8
|
+
> hooks, including session keys and the transaction lifecycle, except:
|
|
9
|
+
>
|
|
10
|
+
> - React provider plumbing (`useWeb3`, `useViemClient`, `useWallet`,
|
|
11
|
+
> `useWeb3ErrorHandler`) has no Vue counterpart by design;
|
|
12
|
+
> - `useERC20Allowance` is React-only today;
|
|
13
|
+
> - `useAccounts` is Vue-only.
|
|
12
14
|
>
|
|
13
15
|
> `useCapabilities` (the EIP-5792 query) and `useSolanaRoles` (which of
|
|
14
16
|
> `identity` / `signer` / `payer` the connected Solana wallet can fill) are not
|
|
@@ -16,18 +18,19 @@
|
|
|
16
18
|
> `@naculus/connect-appkit-core`, so "absence is not a denial" cannot mean one
|
|
17
19
|
> thing in React and another here.
|
|
18
20
|
>
|
|
19
|
-
> This is said here rather than discovered later.
|
|
20
|
-
>
|
|
21
|
-
> surface.
|
|
21
|
+
> This is said here rather than discovered later. `docs/api.md` lists every
|
|
22
|
+
> runtime export of both packages.
|
|
22
23
|
|
|
23
24
|
> **🔗 Wraps `@naculus/connect-appkit-wc`. If you need the raw Web Components or another framework, see the table below.**
|
|
24
25
|
|
|
25
|
-
| Framework | Package |
|
|
26
|
-
|
|
27
|
-
| Web Components (base) | `@naculus/connect-appkit-wc` |
|
|
28
|
-
| React | `@naculus/connect-appkit-react` |
|
|
29
|
-
| **Vue** | `@naculus/connect-appkit-vue` |
|
|
30
|
-
| UI (shared styles) | `@naculus/connect-appkit-ui` |
|
|
26
|
+
| Framework | Package |
|
|
27
|
+
|-----------|---------|
|
|
28
|
+
| Web Components (base) | `@naculus/connect-appkit-wc` |
|
|
29
|
+
| React | `@naculus/connect-appkit-react` |
|
|
30
|
+
| **Vue** | `@naculus/connect-appkit-vue` |
|
|
31
|
+
| UI (shared styles) | `@naculus/connect-appkit-ui` |
|
|
32
|
+
|
|
33
|
+
All four packages are released together on one version; install the same version of each.
|
|
31
34
|
|
|
32
35
|
## Install
|
|
33
36
|
|
|
@@ -94,11 +97,90 @@ authorizations and refreshes after `revoke(entry)`. Inspect the returned
|
|
|
94
97
|
verifies its settlement in the background. Pending verification retries five
|
|
95
98
|
times at four-second intervals by default; pass `verifyRetry` to change that.
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
### Pay x402 from the connected wallet
|
|
101
|
+
|
|
102
|
+
Vue has no provider component, so `useX402Signer` takes the connection from
|
|
103
|
+
you: `useX402Signer(session, provider, switchChain, chainId)`. Pick the
|
|
104
|
+
provider with `findX402Provider` from `@naculus/connect-appkit-core`, which
|
|
105
|
+
chooses it by the session's wallet type, the same rule the React hook uses.
|
|
106
|
+
The injected wallets come from `@naculus/connector-evm-injected` and the
|
|
107
|
+
WalletConnect connector from `@naculus/connector-walletconnect`; install
|
|
108
|
+
whichever your app connects with.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import {
|
|
112
|
+
findX402Provider,
|
|
113
|
+
type PaymentFetch,
|
|
114
|
+
} from "@naculus/connect-appkit-core";
|
|
115
|
+
import type { SessionManager } from "@naculus/connect-core";
|
|
116
|
+
import {
|
|
117
|
+
usePaymentFetch,
|
|
118
|
+
useSession,
|
|
119
|
+
useX402Signer,
|
|
120
|
+
} from "@naculus/connect-appkit-vue";
|
|
121
|
+
import { eip6963Connector } from "@naculus/connector-evm-injected";
|
|
122
|
+
import type { WalletConnectConnector } from "@naculus/connector-walletconnect";
|
|
123
|
+
import { createX402Fetch } from "@naculus/payments-x402";
|
|
124
|
+
import { computed } from "vue";
|
|
125
|
+
|
|
126
|
+
// Your app's SessionManager, and its WalletConnect connector if it has one.
|
|
127
|
+
declare const manager: SessionManager;
|
|
128
|
+
declare const walletConnect: WalletConnectConnector | null;
|
|
129
|
+
|
|
130
|
+
const { session, activeChainId } = useSession(manager);
|
|
131
|
+
const provider = computed(() =>
|
|
132
|
+
findX402Provider(session.value, {
|
|
133
|
+
injected: eip6963Connector.getDiscoveredWallets(),
|
|
134
|
+
walletConnect,
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
const switchChain = (chainId: string) => manager.switchChain(chainId);
|
|
138
|
+
|
|
139
|
+
const { signer, reason } = useX402Signer(
|
|
140
|
+
session,
|
|
141
|
+
provider,
|
|
142
|
+
switchChain,
|
|
143
|
+
activeChainId,
|
|
144
|
+
);
|
|
145
|
+
const pay = computed<PaymentFetch | null>(() =>
|
|
146
|
+
signer.value ? createX402Fetch({ signer: signer.value }) : null,
|
|
147
|
+
);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`signer` and `reason` are computed refs. `usePaymentFetch` takes a paying
|
|
151
|
+
fetch, not `null`, so call it in a child component that is rendered only once
|
|
152
|
+
`pay` is set (`<PaidResource v-if="pay" :pay="pay" />`):
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
// PaidResource.vue, <script setup lang="ts">
|
|
156
|
+
import type { PaymentFetch } from "@naculus/connect-appkit-core";
|
|
157
|
+
import { usePaymentFetch } from "@naculus/connect-appkit-vue";
|
|
158
|
+
import { toRef } from "vue";
|
|
159
|
+
|
|
160
|
+
const props = defineProps<{ pay: PaymentFetch }>();
|
|
161
|
+
const { payFetch, isPending, lastPayment, error } = usePaymentFetch(
|
|
162
|
+
toRef(props, "pay"),
|
|
163
|
+
);
|
|
164
|
+
// Call payFetch(url) from an event handler.
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
`reason` is `null` whenever `signer` is set. Otherwise it says why there is no
|
|
168
|
+
signer, and what to show for it:
|
|
169
|
+
|
|
170
|
+
| `reason` | Meaning | Show |
|
|
171
|
+
|----------|---------|------|
|
|
172
|
+
| `"no-session"` | No wallet is connected. | The connect button. |
|
|
173
|
+
| `"not-evm"` | The session has no EVM (`eip155`) account, for example a Solana-only wallet. | Ask for an EVM account or an EVM wallet. |
|
|
174
|
+
| `"unsupported-wallet-type"` | The session is not an injected (EIP-6963) or WalletConnect wallet, or no provider was found for it. Embedded and passkey EVM wallets land here. | Offer a browser wallet or WalletConnect instead. |
|
|
175
|
+
|
|
176
|
+
The signer switches the wallet to the chain the server asks for before it
|
|
177
|
+
signs, through the `switchChain` you pass, so a wallet on another EVM chain is
|
|
178
|
+
not a `reason`.
|
|
179
|
+
|
|
180
|
+
WalletConnect sessions are supported when you pass the WalletConnect connector
|
|
181
|
+
to `findX402Provider`. The injected (EIP-6963) path is the one verified end to
|
|
182
|
+
end with real wallets; test WalletConnect against the wallets you target before
|
|
183
|
+
you rely on it.
|
|
102
184
|
|
|
103
185
|
## License
|
|
104
186
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naculus/connect-appkit-vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -17,23 +17,23 @@
|
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@naculus/payments-x402": "^0.
|
|
20
|
+
"@naculus/payments-x402": "^0.11.0",
|
|
21
21
|
"@stencil/vue-output-target": "^0.14.3",
|
|
22
|
-
"@naculus/connect-appkit-wc": "0.
|
|
22
|
+
"@naculus/connect-appkit-wc": "0.11.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@naculus/connect-appkit-core": "^0.
|
|
26
|
-
"@naculus/connect-core": "^0.
|
|
25
|
+
"@naculus/connect-appkit-core": "^0.11.1",
|
|
26
|
+
"@naculus/connect-core": "^0.11.0",
|
|
27
27
|
"vue": "^3.5.0"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@naculus/connect-core": "^0.
|
|
33
|
+
"@naculus/connect-core": "^0.11.0",
|
|
34
34
|
"vitest": "^5.0.0",
|
|
35
35
|
"vue": "^3.5.43",
|
|
36
|
-
"@naculus/connect-appkit-core": "0.
|
|
36
|
+
"@naculus/connect-appkit-core": "0.11.1"
|
|
37
37
|
},
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|