Skip to content

Commit 9a0e5a1

Browse files
authored
chore: update key name (#12267)
* chore: update key name * refactor: rm unnecessary try-catch * fix: cspell * chore: ignore patches on cspell
1 parent c4efccc commit 9a0e5a1

2 files changed

Lines changed: 24 additions & 28 deletions

File tree

cspell.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"./packages/icons/**",
88
"./packages/mask/swap/webgl/**",
99
"./packages/web3-contracts/types/**",
10+
"./patches/**",
1011
".github",
1112
".gitignore",
1213
".patch",
@@ -66,6 +67,7 @@
6667
"cyberconnect",
6768
"cyberlab",
6869
"darkweb",
70+
"dataitem",
6971
"debank",
7072
"deficonnect",
7173
"devnet",

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

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,44 +67,38 @@ class LoadAgent implements ProviderAgent {
6767
.replace('__METADATA__', encodedMetadata)
6868

6969
const data = encodeText(replaced)
70-
7170
const landingPageTxId = await this.makePayload(data, 'text/html', `${metadata.name}-landing.html`)
72-
7371
return landingPageTxId
7472
}
7573

7674
async makePayload(data: Uint8Array, type: string, fileName: string = 'file.dat') {
7775
this.init()
7876

79-
try {
80-
const blob = new Blob([data], { type })
81-
const formData = new FormData()
82-
formData.append('file', blob)
83-
formData.append('content_type', type)
84-
formData.append('app_name', 'Maskbook')
85-
86-
const response = await fetch(LOAD_UPLOAD_ENDPOINT, {
87-
method: 'POST',
88-
headers: {
89-
Authorization: `Bearer ${process.env.LOAD_KEY}`,
90-
},
91-
body: formData,
92-
signal: this.uploadController?.signal,
93-
})
94-
95-
if (!response.ok) {
96-
throw new Error(`Upload failed: ${response.statusText}`)
97-
}
77+
const blob = new Blob([data], { type })
78+
const formData = new FormData()
79+
formData.append('file', blob)
80+
formData.append('content_type', type)
81+
formData.append('app_name', 'Maskbook')
82+
83+
const response = await fetch(LOAD_UPLOAD_ENDPOINT, {
84+
method: 'POST',
85+
headers: {
86+
Authorization: `Bearer ${process.env.LOAD_NETWORK_KEY}`,
87+
},
88+
body: formData,
89+
signal: this.uploadController?.signal,
90+
})
9891

99-
const result = await response.json()
100-
if (!result.success || !result.dataitem_id) {
101-
throw new Error('Invalid response from upload service')
102-
}
92+
if (!response.ok) {
93+
throw new Error(`Upload failed: ${response.statusText}`)
94+
}
10395

104-
return result.dataitem_id
105-
} catch (error) {
106-
throw error
96+
const result = await response.json()
97+
if (!result.success || !result.dataitem_id) {
98+
throw new Error('Invalid response from upload service')
10799
}
100+
101+
return result.dataitem_id
108102
}
109103
}
110104

0 commit comments

Comments
 (0)