@meddleware/walrus-ui 0.1.5 → 0.1.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meddleware/walrus-ui",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Standalone Vue 3 SPA for uploading blobs to Walrus decentralised storage and managing owned blobs — wallet-connected, NFT-gated relay support.",
5
5
  "author": "Meddleware <dev@meddleware.co.uk>",
6
6
  "license": "0BSD",
@@ -43,7 +43,7 @@
43
43
  "@meddleware/design-tokens": "^0.1.2",
44
44
  "@meddleware/nft-gate-client": "^0.0.6",
45
45
  "@meddleware/ui": "^0.1.6",
46
- "@meddleware/wallet-adapter": "^0.0.2",
46
+ "@meddleware/wallet-adapter": "^0.0.4",
47
47
  "@meddleware/walrus-client": "^0.0.5",
48
48
  "@meddleware/walrus-relay": "^0.1.3",
49
49
  "@mysten/sui": "^2.28.0",
@@ -3,7 +3,7 @@
3
3
  // Rendered standalone by walrus-ui's App.vue and inline by the dashboard. Wallet state comes
4
4
  // from the shared @meddleware/wallet-adapter singleton (via ./wallet.js), so connecting here or
5
5
  // in any other inline tool view reflects everywhere.
6
- import { ref } from 'vue'
6
+ import { ref, watch } from 'vue'
7
7
  import {
8
8
  WalrusUpload,
9
9
  AccessGateCta,
@@ -13,6 +13,7 @@ import {
13
13
  import type { UploadResult } from '@meddleware/walrus-relay'
14
14
  // Lightweight URL import — just the wasm asset URL (does not pull the walrus client).
15
15
  import walrusWasmUrl from '@mysten/walrus-wasm/web/walrus_wasm_bg.wasm?url'
16
+ import { WalletGuard } from '@meddleware/wallet-adapter'
16
17
  import { useWallet, getSuiClient } from '../wallet.js'
17
18
  import { NETWORK, relayHosts, accessGate, uploadRelayMaxTipMist } from '../config.js'
18
19
  import { runBlobUpload } from '../upload-flow.js'
@@ -21,20 +22,20 @@ import MyBlobs from './MyBlobs.vue'
21
22
  type Tab = 'upload' | 'blobs'
22
23
  const activeTab = ref<Tab>('upload')
23
24
 
24
- const { wallets, account, connect, disconnect, signPersonalMessage, buildExecutor } = useWallet()
25
+ const { account, signPersonalMessage, buildExecutor } = useWallet()
25
26
 
26
27
  const gate = accessGate(NETWORK)
27
28
  const gateState = useAccessGate({ gate, getClient: () => getSuiClient(NETWORK) })
28
29
  const purchasing = ref(false)
29
30
  const result = ref<UploadResult | null>(null)
30
31
 
31
- async function onConnectFirst(): Promise<void> {
32
- const w = wallets.value[0]
33
- if (w) {
34
- await connect(w)
35
- if (account.value) await gateState.checkOwnership(account.value.address)
36
- }
37
- }
32
+ // Check gate ownership whenever the connected account changes (handles connect, reconnect,
33
+ // and disconnect without needing a manual trigger from the connect button).
34
+ watch(
35
+ () => account.value?.address ?? null,
36
+ (addr) => { if (addr && gate) void gateState.checkOwnership(addr) },
37
+ { immediate: true },
38
+ )
38
39
 
39
40
  async function onPurchase(): Promise<void> {
40
41
  if (!account.value) return
@@ -91,36 +92,25 @@ function onUploaded(r: UploadResult): void {
91
92
  <div class="page">
92
93
  <p class="sub">Upload and manage blobs on Walrus decentralised storage ({{ NETWORK }}).</p>
93
94
 
94
- <nav class="tabs" aria-label="Feature tabs">
95
- <button
96
- type="button"
97
- class="tab"
98
- :class="{ active: activeTab === 'upload' }"
99
- @click="activeTab = 'upload'"
100
- >
101
- Upload
102
- </button>
103
- <button
104
- type="button"
105
- class="tab"
106
- :class="{ active: activeTab === 'blobs' }"
107
- @click="activeTab = 'blobs'"
108
- >
109
- My Blobs
110
- </button>
111
- </nav>
112
-
113
- <section class="wallet">
114
- <template v-if="account">
115
- <span class="addr">{{ account.address.slice(0, 8) }}…{{ account.address.slice(-4) }}</span>
116
- <button type="button" @click="disconnect">Disconnect</button>
117
- </template>
118
- <template v-else>
119
- <button type="button" :disabled="!wallets.length" @click="onConnectFirst">
120
- {{ wallets.length ? 'Connect wallet' : 'No wallet detected' }}
95
+ <WalletGuard message="Connect a Sui wallet to upload and manage your blobs.">
96
+ <nav class="tabs" aria-label="Feature tabs">
97
+ <button
98
+ type="button"
99
+ class="tab"
100
+ :class="{ active: activeTab === 'upload' }"
101
+ @click="activeTab = 'upload'"
102
+ >
103
+ Upload
121
104
  </button>
122
- </template>
123
- </section>
105
+ <button
106
+ type="button"
107
+ class="tab"
108
+ :class="{ active: activeTab === 'blobs' }"
109
+ @click="activeTab = 'blobs'"
110
+ >
111
+ My Blobs
112
+ </button>
113
+ </nav>
124
114
 
125
115
  <template v-if="activeTab === 'upload'">
126
116
  <AccessGateCta
@@ -155,6 +145,7 @@ function onUploaded(r: UploadResult): void {
155
145
  :address="account?.address ?? null"
156
146
  :build-executor="() => buildExecutor(NETWORK)"
157
147
  />
148
+ </WalletGuard>
158
149
  </div>
159
150
  </template>
160
151
 
@@ -171,18 +162,6 @@ function onUploaded(r: UploadResult): void {
171
162
  margin: 0.25rem 0 0;
172
163
  }
173
164
 
174
- .wallet {
175
- display: flex;
176
- align-items: center;
177
- gap: 0.75rem;
178
- margin: 1.25rem 0;
179
- }
180
-
181
- .addr {
182
- font-family: monospace;
183
- font-size: 0.9rem;
184
- }
185
-
186
165
  .result {
187
166
  margin-top: 1.5rem;
188
167
  padding: 1rem;