Skip to content

Commit f7be97a

Browse files
guanbinruicodingknitexylophonezswkatmask
authored
[Release] Hotfix 2.33.2 => 2.33.3 (patch) (#12236)
* chore: config weavevm * chore: config weavevm * chore: weavevm agent * chore: install bundler sdk * chore: update bundler sdk * chore: minor fix * chore: pull * chore: use envelopes to set mime type * chore: rebase package.json * chore: fix gateway and weavevm download url * chore: ui fixes * chore: cosmetic fix * chore: move deps * feat: weavevm-bundles to load0 * chore: bump version to 2.33.3 * fix: linter * chore: mf-6722 update and add plugin tutorial links (#12238) * docs(FileService): mf-6721 update terms of service (#12237) --------- Co-authored-by: Joel <[email protected]> Co-authored-by: Xylophone <[email protected]> Co-authored-by: guanbinrui <[email protected]> Co-authored-by: Wukong Sun <[email protected]>
1 parent 5d87951 commit f7be97a

File tree

32 files changed

+269
-38
lines changed

32 files changed

+269
-38
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"yarn": ">=999.0.0",
88
"npm": ">=999.0.0"
99
},
10-
"version": "2.33.2",
10+
"version": "2.33.3",
1111
"private": true,
1212
"license": "AGPL-3.0-or-later",
1313
"scripts": {

packages/plugins/Calendar/src/SiteAdaptor/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const site: Plugin.SiteAdaptor.Definition = {
2424
category: 'dapp',
2525
recommendFeature,
2626
description: recommendFeature.description,
27+
tutorialLink: 'https://mask.notion.site/Calendar-Web3-Daily-Digest-a59647e6e43a454eaccedd627fe50d3c',
2728
},
2829
],
2930
}

packages/plugins/FileService/src/SiteAdaptor/components/FileBrowser.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ enum ProviderTabs {
121121
All = 'All',
122122
IPFS = 'IPFS',
123123
Arweave = 'Arweave',
124+
Load = 'Load Network',
124125
}
125126

126127
const TabToProviderMap: Record<ProviderTabs, Provider | null> = {
127128
[ProviderTabs.All]: null,
128129
[ProviderTabs.IPFS]: Provider.IPFS,
129130
[ProviderTabs.Arweave]: Provider.Arweave,
131+
[ProviderTabs.Load]: Provider.Load,
130132
}
131133

132134
const providers = getEnumAsArray(ProviderTabs)

packages/plugins/FileService/src/SiteAdaptor/components/Terms.tsx

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,23 @@ export function Terms() {
9595
</Typography>
9696
<Typography variant="body2" className={classes.introduction}>
9797
<Trans>
98-
Web3 File Service is a decentralized storage service provided by Mask Network. It allows users
99-
to store files in different decentralized networks. This feature is powered by Mask Network's
100-
partner file storage protocols such as IPFS and Arweave. It supports files in PDF, DOC, JPG,
101-
PNG, MP3, MP4 and other formats. At present, the maximum file size is 10 MB.
98+
Web3 File Service is a decentralized storage solution provided by Mask Network that allows users
99+
to store files across multiple decentralized networks. This service is powered by Mask Networks
100+
partner protocols, including IPFS, Arweave, and Load Network. It supports various file formats
101+
such as PDF, DOC, JPG, PNG, MP3, MP4, and more, with a maximum file size of 10MB per upload.
102102
<br />
103+
Through the Web3 File Service, users can upload files to different decentralized networks and
104+
choose whether or not to encrypt them, thereby generating files with different levels of
105+
confidentiality. Mask Network users can share these files to social platforms via generated
106+
links. Using encryption helps protect file security and prevent privacy breaches.
103107
<br />
104-
You can store files in multiple decentralized networks through the Web3 file service. When
105-
uploading files, you can choose to encrypt or decrypt them. According to the selected encryption
106-
method, you can obtain two file links with and without encryption. Users of Mask Network can
107-
share files to social platforms through this link. By using the encryption, you can ensure the
108-
security of your files and prevent privacy leakage.
108+
Please note that anyone with the link can access and share the file. Due to the immutable nature
109+
of decentralized storage systems, uploaded files cannot be deleted or modified, so please
110+
exercise caution when uploading files containing personal information.
109111
<br />
110-
<br />
111-
It should be noted that any user who has the link can download and share the file. With the
112-
characteristics of decentralized file storage systems, your uploaded files can never be deleted
113-
or tampered. Be caution when uploading files with personal privacy.
114-
<br />
115-
<br />
116-
The Web3 File Service provided by Mask Network enables individuals to be free from data
117-
restrictions imposed by traditional social platforms, enabling free encrypted transmission and
118-
sharing of files. At present, the service is provisionally free for all users with Mask Network.
119-
Mask Network will provide updates on costs users may have to pay in the future.
112+
Mask Network’s Web3 File Service is designed to help users break free from the data limitations
113+
of traditional social platforms, enabling secure and decentralized file sharing. The service is
114+
currently free for all Mask Network users. Any future costs will be announced in advance.
120115
</Trans>
121116
</Typography>
122117
<Typography variant="body2" className={classes.footNote}>

packages/plugins/FileService/src/SiteAdaptor/components/UploadFile.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
// todo:the issue is potentially the file size limit
2+
13
import { Icons } from '@masknet/icons'
24
import { UploadDropArea } from '@masknet/shared'
35
import { makeStyles } from '@masknet/theme'
46
import { Checkbox, FormControlLabel, Radio, Typography } from '@mui/material'
57
import { useCallback, useMemo, useState, type ReactNode } from 'react'
6-
import { MAX_FILE_SIZE } from '../../constants.js'
8+
import { MAX_FILE_SIZE, MAX_FILE_SIZE_LOAD } from '../../constants.js'
79
import { downloadFile } from '../../helpers.js'
810
import { Provider } from '../../types.js'
911
import { useFileManagement } from '../contexts/index.js'
@@ -79,6 +81,8 @@ export function UploadFile() {
7981
const [provider, setProvider] = useState<Provider>(Provider.Arweave)
8082
const { recentFiles, uploadingFiles, uploadFile, attachToPost } = useFileManagement()
8183

84+
const FILE_SIZE = provider === Provider.Load ? MAX_FILE_SIZE_LOAD : MAX_FILE_SIZE
85+
8286
const files = useMemo(() => {
8387
return [...uploadingFiles, ...recentFiles]
8488
}, [uploadingFiles, recentFiles])
@@ -92,6 +96,10 @@ export function UploadFile() {
9296
provider: Provider.IPFS,
9397
name: <Trans>IPFS</Trans>,
9498
},
99+
{
100+
provider: Provider.Load,
101+
name: <Trans>Load Network</Trans>,
102+
},
95103
]
96104

97105
const onSelectFile = useCallback(
@@ -103,7 +111,7 @@ export function UploadFile() {
103111

104112
return (
105113
<section className={classes.container}>
106-
<UploadDropArea className={classes.uploadArea} maxFileSize={MAX_FILE_SIZE} onSelectFile={onSelectFile} />
114+
<UploadDropArea className={classes.uploadArea} maxFileSize={FILE_SIZE} onSelectFile={onSelectFile} />
107115
<div className={classes.options}>
108116
{providers.map((config: ProviderConfig) => (
109117
<FormControlLabel

packages/plugins/FileService/src/SiteAdaptor/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const definition: Plugin.SiteAdaptor.Definition = {
101101
),
102102
name,
103103
iconFilterColor,
104-
tutorialLink: 'https://realmasknetwork.notion.site/8c8fe1efce5a48b49739a38f4ea8c60f',
104+
tutorialLink: 'https://mask.notion.site/Web3-File-Service-ee60e0e79a674019a0560de16144ecb3',
105105
}
106106
})(),
107107
],
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import { isEmpty } from 'lodash-es'
2+
import { Attachment } from '@dimensiondev/common-protocols'
3+
import { encodeText } from '@masknet/kit'
4+
import { LANDING_PAGE, Provider } from '../constants.js'
5+
import type { ProviderAgent, LandingPageMetadata, AttachmentOptions } from '../types.js'
6+
import { makeFileKeySigned } from '../helpers.js'
7+
8+
const LOAD_GATEWAY_URL = 'https://load0.network/resolve'
9+
const LOAD_UPLOAD_ENDPOINT = 'https://load0.network/upload'
10+
const API_KEY = 'load_acc_ep4bep0uGlmUXMu46BxM0uWXKsqL5M5w' // move to env
11+
12+
class LoadAgent implements ProviderAgent {
13+
static providerName = 'Load Network'
14+
private uploadController?: AbortController
15+
16+
init() {
17+
this.uploadController = new AbortController()
18+
}
19+
20+
async makeAttachment(options: AttachmentOptions) {
21+
this.init()
22+
const passphrase = options.key ? encodeText(options.key) : undefined
23+
const encoded = await Attachment.encode(passphrase, {
24+
block: options.block,
25+
mime: isEmpty(options.type) ? 'application/octet-stream' : options.type,
26+
metadata: null,
27+
})
28+
29+
const effectiveType = isEmpty(options.type) ? 'application/octet-stream' : options.type
30+
const effectiveName = options.name || 'unnamed_file'
31+
const payloadTxID = await this.makePayload(encoded, effectiveType, effectiveName)
32+
return payloadTxID
33+
}
34+
35+
async *upload(id: string) {
36+
try {
37+
// Since we're using optimistic upload, we can yield progress immediately
38+
// The actual upload to Load Network happens in the background
39+
yield 50
40+
yield 100
41+
} catch (error) {
42+
console.error('Upload progress tracking failed:', error)
43+
throw error
44+
} finally {
45+
if (this.uploadController) {
46+
this.uploadController.abort()
47+
this.uploadController = undefined
48+
}
49+
}
50+
}
51+
52+
async uploadLandingPage(metadata: LandingPageMetadata) {
53+
this.init()
54+
const linkPrefix = LOAD_GATEWAY_URL
55+
const encodedMetadata = JSON.stringify({
56+
name: metadata.name,
57+
size: metadata.size,
58+
provider: Provider.Load,
59+
link: `${linkPrefix}/${metadata.txId}`,
60+
signed: await makeFileKeySigned(metadata.key),
61+
createdAt: new Date().toISOString(),
62+
})
63+
const response = await fetch(LANDING_PAGE)
64+
const text = await response.text()
65+
const replaced = text
66+
.replace('Arweave', LoadAgent.providerName)
67+
.replace('Over Arweave', `Over ${LoadAgent.providerName}`)
68+
.replace('__METADATA__', encodedMetadata)
69+
70+
const data = encodeText(replaced)
71+
72+
const landingPageTxId = await this.makePayload(data, 'text/html', `${metadata.name}-landing.html`)
73+
74+
return landingPageTxId
75+
}
76+
77+
async makePayload(data: Uint8Array, type: string, fileName: string = 'file.dat') {
78+
this.init()
79+
80+
try {
81+
const blob = new Blob([data], { type })
82+
const headers = {
83+
'Content-Type': type,
84+
Filename: fileName,
85+
'App-Name': 'Maskbook',
86+
'X-Load-Authorization': API_KEY,
87+
}
88+
89+
const response = await fetch(LOAD_UPLOAD_ENDPOINT, {
90+
method: 'POST',
91+
headers,
92+
body: blob,
93+
signal: this.uploadController?.signal,
94+
})
95+
96+
if (!response.ok) {
97+
throw new Error(`Upload failed: ${response.statusText}`)
98+
}
99+
100+
const { optimistic_hash } = await response.json()
101+
return optimistic_hash
102+
} catch (error) {
103+
const errorMessage = `Load Network upload failed: ${error instanceof Error ? error.message : String(error)}`
104+
console.error('Load Network detailed error:', errorMessage)
105+
106+
const enhancedError = new Error(errorMessage)
107+
if (error instanceof Error && error.stack) {
108+
enhancedError.stack = error.stack
109+
}
110+
111+
throw enhancedError
112+
}
113+
}
114+
}
115+
116+
export default new LoadAgent()

packages/plugins/FileService/src/Worker/service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { type AttachmentOptions, type LandingPageMetadata, Provider, type ProviderAgent } from '../types.js'
22
import arweave from './arweave.js'
33
import ipfs from './ipfs.js'
4+
import load from './load.js'
45

56
const allProviders: Record<Provider, ProviderAgent> = {
67
[Provider.Arweave]: arweave,
78
[Provider.IPFS]: ipfs,
9+
[Provider.Load]: load,
810
}
911

1012
export async function makeAttachment(provider: Provider, options: AttachmentOptions) {

packages/plugins/FileService/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export const META_KEY_2 = 'com.maskbook.fileservice:2'
33
export const META_KEY_3 = 'com.maskbook.fileservice:3'
44

55
export const MAX_FILE_SIZE = 10 * 1000 * 1000
6+
export const MAX_FILE_SIZE_LOAD = 10 * 1024 * 1024
67

78
export const LANDING_PAGE = 'https://files.r2d2.to/partner/arweave/landing-page.html'
89
export const RECOVERY_PAGE = 'https://fileservice.r2d2.to/recover'
@@ -19,4 +20,5 @@ export const enum RoutePaths {
1920
export const enum Provider {
2021
IPFS = 'ipfs',
2122
Arweave = 'arweave',
23+
Load = 'load',
2224
}

packages/plugins/FileService/src/helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const resolveGatewayAPI = createLookupTableResolver<Provider, string>(
4545
{
4646
[Provider.Arweave]: 'https://arweave.net',
4747
[Provider.IPFS]: 'https://mask.infura-ipfs.io/ipfs',
48+
[Provider.Load]: 'https://load0.network/resolve',
4849
},
4950
() => 'Unknown provider',
5051
)

0 commit comments

Comments
 (0)