Skip to content

Commit

Permalink
fix cli prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
fleandrei committed Feb 18, 2025
1 parent 0617d3c commit d8dfc29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 3 additions & 1 deletion cli/src/lib/website/filesInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ export async function filterUselessFileInits(

for (let i = 0; i < batch.length; i++) {
if (!results[i]) {
throw new Error(`Could not retrieve totalChunk data entry for file ${batch[i].preStore.location}`);
throw new Error(
`Could not retrieve totalChunk data entry for file ${batch[i].preStore.location}`
)
}
if (
(results[i] as Uint8Array).length !== U32.SIZE_BYTE ||
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib/website/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export async function getGlobalMetadata(
const metadataKeyBytes = metadataKeys[index].slice(
GLOBAL_METADATA_TAG.length
)
const key = String.fromCharCode(...new Uint8Array(metadataKeyBytes));
const key = String.fromCharCode(...new Uint8Array(metadataKeyBytes))
if (!m) {
throw new Error(`Global metadata with key ${key} has empty value`);
throw new Error(`Global metadata with key ${key} has empty value`)
}
const value = String.fromCharCode(...new Uint8Array(m))

Expand Down
25 changes: 12 additions & 13 deletions cli/src/lib/website/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ export async function listFiles(
const fileLocations = await provider.readStorage(scAddress, allStorageKeys)

return fileLocations.map((location, i) => {
if (!location) {
throw new Error(`File location not found at index ${i}`);
}
return String.fromCharCode(...new Uint8Array(location));
if (!location) {
throw new Error(`File location not found at index ${i}`)
}
);
return String.fromCharCode(...new Uint8Array(location))
})
}

/**
Expand Down Expand Up @@ -87,15 +86,15 @@ export async function getFileFromAddress(
datastoreKeys.push(fileChunkKey(new Uint8Array(filePathHash), i))
}

const rawChunks = (await provider.readStorage(scAddress, datastoreKeys))
.map( // allow to return Uint8Array[] instead of (Uint8Array | null)[]
(chunk, i) => {
if (!chunk) {
throw new Error(`file ${filePath} Chunk ${i} not found`);
}
return chunk;
const rawChunks = (await provider.readStorage(scAddress, datastoreKeys)).map(
// allow to return Uint8Array[] instead of (Uint8Array | null)[]
(chunk, i) => {
if (!chunk) {
throw new Error(`file ${filePath} Chunk ${i} not found`)
}
);
return chunk
}
)

const totalLength = rawChunks.reduce((acc, chunk) => acc + chunk.length, 0)
const concatenatedArray = new Uint8Array(totalLength)
Expand Down

0 comments on commit d8dfc29

Please sign in to comment.