PaulBernier / factomjs

Javascript library to build applications on the Factom blockchain.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: unexpected type, use Uint8Array

eolszewski opened this issue · comments

When trying to buy entry credits from a test that is using 'react-scripts', I get the following error:

TypeError: unexpected type, use Uint8Array
      
      at checkArrayTypes (node_modules/factom/node_modules/tweetnacl/nacl-fast.js:2151:13)
      at Function.Object.<anonymous>.nacl.sign.keyPair.fromSeed (node_modules/factom/node_modules/tweetnacl/nacl-fast.js:2313:3)
      at TransactionBuilder.input (node_modules/factom/src/transaction.js:209:38)
      at buildTransactionWithFees (node_modules/factom/src/send.js:73:10)
      at Object.createEntryCreditPurchaseTransaction (node_modules/factom/src/send.js:68:12)
          at <anonymous>

This is only happening when running this as a test - it cannot be replicated, otherwise.

I have gone into the transaction.js code an inspected every element, but can't find any difference between them - have you run into this previously? If not, I can link to the problematic code - I'll be trying to address it, until then.

This has been bugging me for hours, at this point, maybe you have seen it before?

Here's the code

You can run with docker and your .env file.

Running node factom.js succeeds while npm test src/decentralized-storage/factom/ fails.

I can reproduce the error, and this is head scratching indeed. But it is not a problem with factom.js or even tweetnacl. The crux is that when being executed in your test framework console.log(Buffer.from('test') instanceof Uint8Array) displays false, which shouldn't happen. I don't know the reason but I'd suggest opening an issue with your testing framework, or maybe it's some kind of configuration.

Agree, thanks for taking a look!