quorumcontrol / tupelo-wasm-sdk

(ALPHA) A wasm-based TypeScript sdk that does not require the RPC server.
MIT License
9 stars 1 forks source link

fix getRandomValues() so that it works in our environment #102

Closed tobowers closed 4 years ago

tobowers commented 4 years ago

This could be a node version thing maybe but in my node 13, I was getting an error:

> const c = await sdk.Community.getDefault()
(node:85183) UnhandledPromiseRejectionWarning: TypeError: crypto.getRandomValues is not a function
    at runtime.getRandomData (/Users/tobowers/code/tupelo-wasm-sdk/lib/js/go/wasm_exec.js:339:14)
    at wasm-function[1045]:0xd75c2
    at wasm-function[586]:0x80336
    at wasm-function[970]:0xd4685
    at wasm-function[1022]:0xd72c4
    at global.Go.run (/Users/tobowers/code/tupelo-wasm-sdk/lib/js/go/wasm_exec.js:542:23)
    at Object.run (/Users/tobowers/code/tupelo-wasm-sdk/lib/js/go/index.js:76:19)
(node:85183) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:85183) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I'm unsure as to why the tests pass... it could be a ts-node vs node thing ( as this was in the REPL for node after building ). FWIW - I don't think this caused the hang, but needs to be fixed none the less.

tobowers commented 4 years ago

I'm pretty unsure actually - and we might need to add javascript-specific testing as opposed to typescript. This might have been in here since the 1.14 upgrade.