@meddleware/walrus-ui 0.1.13 → 0.1.14

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.13",
3
+ "version": "0.1.14",
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",
@@ -15,6 +15,7 @@ import type { UploadResult } from '@meddleware/walrus-relay'
15
15
  import walrusWasmUrl from '@mysten/walrus-wasm/web/walrus_wasm_bg.wasm?url'
16
16
  import { WalletGuard } from '@meddleware/wallet-adapter'
17
17
  import { useWallet, getSuiClient } from '../wallet.js'
18
+ import { fetchChallenge, buildAccessProof } from '@meddleware/nft-gate-client'
18
19
  import { NETWORK, relayHosts, accessGate, uploadRelayMaxTipMist } from '../config.js'
19
20
  import { runBlobUpload } from '../upload-flow.js'
20
21
  import { useOwnedBlobs } from '../composables/useOwnedBlobs.js'
@@ -59,13 +60,23 @@ async function performUpload(
59
60
  if (!account.value) throw new Error('Connect your wallet first.')
60
61
  const executor = await buildExecutor()
61
62
 
62
- // If the relay is NFT-gated and we hold access, attach a signed proof token.
63
+ // If the relay is NFT-gated and we hold access, run the SINGLE_USE consume flow:
64
+ // fetch a challenge nonce, execute the on-chain access_gate::consume tx to record
65
+ // use of that nonce (produces a consumeDigest), then sign a proof token that
66
+ // includes both. SINGLE_USE=true gateways reject proofs without a consumeDigest.
67
+ // TODO: replace this block with `gateState.consumeAndBuildToken(...)` once
68
+ // @meddleware/walrus-relay ≥ 0.1.6 is installed.
63
69
  let authToken: string | undefined
64
- if (gate && gateState.hasAccess.value === true) {
65
- authToken = await gateState.buildRelayAccessToken({
66
- relayHost: opts.relayHost,
70
+ if (gate && gateState.hasAccess.value === true && gateState.nftId.value) {
71
+ const challenge = await fetchChallenge(opts.relayHost)
72
+ const consumeTx = gateState.buildConsume(gateState.nftId.value, challenge.nonce)
73
+ const consumeResult = await executor.signAndExecute(consumeTx)
74
+ if (consumeResult.digest) await executor.waitForTransaction(consumeResult.digest).catch(() => {})
75
+ authToken = await buildAccessProof({
67
76
  address: account.value.address,
77
+ challenge,
68
78
  sign: signPersonalMessage,
79
+ consumeDigest: consumeResult.digest,
69
80
  })
70
81
  }
71
82
 
@@ -91,9 +102,13 @@ function onUploaded(r: UploadResult): void {
91
102
  }
92
103
 
93
104
  // Fires after every upload attempt (success or failure) — a failed UI run may still have landed
94
- // on-chain, so force-refresh the owned-blobs cache in the background regardless of outcome.
105
+ // on-chain, so force-refresh the owned-blobs cache and NFT ownership (uses remaining) in the
106
+ // background regardless of outcome.
95
107
  function onSettled(): void {
96
- if (account.value) void ownedBlobs.load(account.value.address, { force: true })
108
+ if (account.value) {
109
+ void ownedBlobs.load(account.value.address, { force: true })
110
+ void gateState.checkOwnership(account.value.address)
111
+ }
97
112
  }
98
113
  </script>
99
114