Skip to content

Commit

Permalink
fix: serialization #130
Browse files Browse the repository at this point in the history
  • Loading branch information
tomicvladan committed Apr 6, 2023
1 parent 5c0f0cd commit 0d9011c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions library/src/utils/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export function isSerializedUint8Array(data: unknown): data is BytesMessage {
}

export function uint8ArrayToString(bytes: Uint8Array): string {
return new TextDecoder().decode(bytes)
return bytes.toString()
}

export function stringToUint8Array(serializedBytes: string): Uint8Array {
return new TextEncoder().encode(serializedBytes)
return Uint8Array.from(serializedBytes.split(',').map(num => Number(num)))
}

export function uint8ArrayToSerializedParameter(bytes: Uint8Array): BytesMessage {
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/services/storage/storage-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ export async function migrate(newVersionString: string): Promise<void> {
await updateObject<AccountDapps>(Storage.dappsKey, updatedAccountDapps)
}

await this.setStorageVesion(newVersionString)
await storage.setStorageVesion(newVersionString)
}
4 changes: 2 additions & 2 deletions src/utils/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export function versionToString(version: Version): string {
}

export function uint8ArrayToString(bytes: Uint8Array): string {
return new TextDecoder().decode(bytes)
return bytes.toString()
}

export function stringToUint8Array(serializedBytes: string): Uint8Array {
return new TextEncoder().encode(serializedBytes)
return Uint8Array.from(serializedBytes.split(',').map((num) => Number(num)))
}

export function uint8ArrayToSerializedParameter(bytes: Uint8Array): BytesMessage {
Expand Down

0 comments on commit 0d9011c

Please sign in to comment.