@meddleware/walrus-ui 0.1.12 → 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 +1 -1
- package/src/components/WalrusView.vue +21 -6
- package/src/config.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meddleware/walrus-ui",
|
|
3
|
-
"version": "0.1.
|
|
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,
|
|
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
|
-
|
|
66
|
-
|
|
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
|
|
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)
|
|
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
|
|
package/src/config.ts
CHANGED
|
@@ -34,8 +34,8 @@ export function relayHosts(network: WalrusNetwork): { operator: string; public:
|
|
|
34
34
|
return { operator: OPERATOR_RELAY_HOSTS[network], public: PUBLIC_WALRUS_RELAY_HOSTS[network] }
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/** Default relay tip ceiling (MIST) when `VITE_UPLOAD_RELAY_MAX_TIP_MIST` is unset (0.
|
|
38
|
-
export const DEFAULT_UPLOAD_RELAY_MAX_TIP_MIST =
|
|
37
|
+
/** Default relay tip ceiling (MIST) when `VITE_UPLOAD_RELAY_MAX_TIP_MIST` is unset (0.5 SUI). */
|
|
38
|
+
export const DEFAULT_UPLOAD_RELAY_MAX_TIP_MIST = 500_000_000
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Cap on the relay tip payment in MIST, from `VITE_UPLOAD_RELAY_MAX_TIP_MIST`. This is a ceiling to
|