diff --git a/cli/src/commands/showFile.ts b/cli/src/commands/showFile.ts index 28e8f65..9ebf269 100644 --- a/cli/src/commands/showFile.ts +++ b/cli/src/commands/showFile.ts @@ -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) }) diff --git a/cli/src/lib/index/read.ts b/cli/src/lib/index/read.ts index 6461f08..1b50500 100644 --- a/cli/src/lib/index/read.ts +++ b/cli/src/lib/index/read.ts @@ -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] diff --git a/cli/src/lib/website/read.ts b/cli/src/lib/website/read.ts index b6aa30d..2915307 100644 --- a/cli/src/lib/website/read.ts +++ b/cli/src/lib/website/read.ts @@ -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)) + ) } /**