Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove text decoder method #196

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cli/src/commands/showFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export const showFileCommand = new Command('show')
console.log('Targeting website at address', sc.address)

const fileContent = await getFileFromAddress(provider, sc.address, filePath)
const decoder = new TextDecoder()
const fileContentString = decoder.decode(fileContent)
const fileContentString = Array.from(new Uint8Array(fileContent))
.map((byte) => String.fromCharCode(byte))
.join('')

console.log(fileContentString)
})
2 changes: 1 addition & 1 deletion cli/src/lib/index/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function getWebsiteOwner(

const keys = await provider.getStorageKeys(scAddress, prefix)
if (keys.length === 0) {
return ''
throw new Error('Website not found in the index')
}

const ownerKey = keys[0]
Expand Down
6 changes: 3 additions & 3 deletions cli/src/lib/website/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export async function listFiles(
)
const fileLocations = await provider.readStorage(scAddress, allStorageKeys)

const textDecoder = new TextDecoder()

return fileLocations.map((location) => textDecoder.decode(location))
return fileLocations.map((location) =>
String.fromCharCode(...new Uint8Array(location))
)
}

/**
Expand Down
Loading