diff --git a/packages/massa-web3/src/experimental/basicElements/serializers/arrays.ts b/packages/massa-web3/src/experimental/basicElements/serializers/arrays.ts index 1c629706..77f7f3d3 100644 --- a/packages/massa-web3/src/experimental/basicElements/serializers/arrays.ts +++ b/packages/massa-web3/src/experimental/basicElements/serializers/arrays.ts @@ -197,15 +197,14 @@ export function bytesToArray(source: Uint8Array, type: ArrayTypes): T[] { const result: T[] = [] let elementSize: number - if (type !== ArrayTypes.STRING) { + if (type === ArrayTypes.STRING) { + elementSize = bytesToU32(source, byteOffset) + byteOffset += BYTES_32_OFFSET + } else { elementSize = getDatatypeSize(type) } while (byteOffset < sourceLength) { - if (type === ArrayTypes.STRING) { - elementSize = bytesToU32(source, byteOffset) - byteOffset += BYTES_32_OFFSET - } const elt = source.slice(byteOffset, byteOffset + elementSize) byteOffset += elementSize diff --git a/packages/massa-web3/src/experimental/crypto/cross-browser.ts b/packages/massa-web3/src/experimental/crypto/cross-browser.ts index 5053385c..c23279cb 100644 --- a/packages/massa-web3/src/experimental/crypto/cross-browser.ts +++ b/packages/massa-web3/src/experimental/crypto/cross-browser.ts @@ -77,7 +77,10 @@ async function pbkdf2Browser( ['encrypt', 'decrypt'] ) - return Buffer.from(crypto.subtle.exportKey('raw', derivedKey)) + const exportedKey = await crypto.subtle.exportKey('raw', derivedKey) + const buffer = Buffer.from(exportedKey) + + return buffer } export type PBKDF2Options = { diff --git a/packages/massa-web3/tsconfig.json b/packages/massa-web3/tsconfig.json index 0acccb47..54ee5901 100644 --- a/packages/massa-web3/tsconfig.json +++ b/packages/massa-web3/tsconfig.json @@ -4,10 +4,11 @@ "outDir": "./dist" }, "include": [ - "./src/**/*.ts" + "./src/experimental/**/*.ts" ], "exclude": [ "node_modules", "**/*.spec.ts" + ] } \ No newline at end of file diff --git a/packages/web3-utils/src/serializers/arrays.ts b/packages/web3-utils/src/serializers/arrays.ts index ee45b875..923d35ca 100644 --- a/packages/web3-utils/src/serializers/arrays.ts +++ b/packages/web3-utils/src/serializers/arrays.ts @@ -184,15 +184,14 @@ export function bytesToArray(source: Uint8Array, type: ArrayTypes): T[] { const result: T[] = [] let eltSize: number - if (type !== ArrayTypes.STRING) { + if (type === ArrayTypes.STRING) { + eltSize = bytesToU32(source, byteOffset) + byteOffset += 4 + } else { eltSize = getDatatypeSize(type) } while (byteOffset < sourceLength) { - if (type === ArrayTypes.STRING) { - eltSize = bytesToU32(source, byteOffset) - byteOffset += 4 - } const elt = source.slice(byteOffset, byteOffset + eltSize) byteOffset += eltSize