input-output-hk / js-cardano-wasm

various cardano javascript using wasm bindings
MIT License
31 stars 21 forks source link

"RuntimeError: unreachable" when creating a new TxOut #42

Open vladikus10 opened 5 years ago

vladikus10 commented 5 years ago

I'm trying to build a transaction with the Tx object and when I try to add a new output:

let tx = Tx.create();
tx = Tx.addOutput(tx, Tx.newTxOut('Ae2tdPwUPEZ8d5Q2MEbU7tfGL9pF73A7zDb4ippdWPmKWseDPrh7GTYBvpo', 10));

I receive this error:

UnhandledPromiseRejectionWarning: RuntimeError: unreachable
    at wasm-function[197]:3358
    at wasm-function[250]:258
    at wasm-function[362]:153
    at wasm-function[428]:136
    at wasm-function[22]:833
    at exports.newTxOut (/home/user/NodeJS/project/node_modules/rust-cardano-crypto/dist/index.js:11711:26)
    at Object.args [as newTxOut] (/home/user/NodeJS/project/node_modules/rust-cardano-crypto/dist/index.js:2313:84)

I'm using Node 8.14.0 and rust-cardano-crypto ver 0.2.0 I also tried manually building from this repository with the same result.

Input seem to work just fine, the error is thrown only when trying to add a new output.

NicolasDP commented 5 years ago

thanks for reporting the issue. The address must be a Uint8Array in the current code. This is not very user friendly from the API...

How would you feel, instead, to try the new API I've started in #41 ? I think it will be more straight forward and feedback from users would be really welcome.

vladikus10 commented 5 years ago

Thanks for the reply,

How can I convert the the address to Uint8Array? I tried doing via Buffer:

const toUint8Array = address => new Uint8Array(Buffer.from(address, 'utf-8'));
//Ae2tdPwUPEZ8d5Q2MEbU7tfGL9pF73A7zDb4ippdWPmKWseDPrh7GTYBvpo => [65,101,50,116,100,80,119,85,80,69,90,56,100,53,81,50,77,69,98,85,55,116,102,71,76,57,112,70,55,51,65,55,122,68,98,52,105,112,112,100,87,80,109,75,87,115,101,68,80,114,104,55,71,84,89,66,118,112,111]

But I still get the same error.

About the new API, I'm not quite sure what is the difference except the updated rust module.