Encoding BigNumber produces Error
arjun-io opened this issue · 3 comments
arjun-io commented
Hi!
Noticed this issue with the latest version (0.11.0) of devkit, here are steps to reproduce:
let { abi } = require("thor-devkit")
let BigNumber = require('bignumber.js')
let fn = new abi.Function({
"constant": false,
"inputs": [
{
"name": "a1",
"type": "uint256"
},
{
"name": "a2",
"type": "string"
}
],
"name": "f1",
"outputs": [
{
"name": "r1",
"type": "address"
},
{
"name": "r2",
"type": "bytes"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
})
let data = fn.encode(1, 'foo') // works
data = fn.encode(new BigNumber(1), 'foo') // errors
"dependencies": {
"bignumber.js": "^9.0.0",
"thor-devkit": "^0.11.0"
}
libotony commented
devkit changed the ABI library since 0.9.1, a workaround for this is
fn.encode(new BigNumber(1).toString(), 'foo')
or, downgrade to 0.8.*
We'll find a way to solve this issue