Skip to content

Commit

Permalink
remove text decoder method + fix ownership estimation (#196)
Browse files Browse the repository at this point in the history
* remove text decoder method

* chanhe show files command

* Throw error if website not found in index

---------

Co-authored-by: thomas-senechal <[email protected]>
  • Loading branch information
pivilartisant and thomas-senechal authored Dec 19, 2024
1 parent 72667ee commit e650cfe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
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

0 comments on commit e650cfe

Please sign in to comment.