Skip to content

Commit

Permalink
Merge branch '750-fixes-for-the-javascript' into 'develop'
Browse files Browse the repository at this point in the history
Resolve "fixes for the JavaScript"

Closes #750

See merge request in3/c/in3-core!467
  • Loading branch information
Martin Kuechler committed Jun 11, 2021
2 parents f0ecf5f + f2a1a90 commit 56b311d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
12 changes: 3 additions & 9 deletions c/src/verifier/btc/rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ btc:
cmdParams: -x -c btc -f 8
request:
- 'f3c06e17b04ef748ce6604ad68e5b9f68ca96914b57c2118a1bb9a09a194ddaf'
- true
- '000000000000000000103b2395f6cd94221b10d02eb9be5850303c0534307220'
# - true
# - '000000000000000000103b2395f6cd94221b10d02eb9be5850303c0534307220'
response:
in_active_chain: true
txid: f3c06e17b04ef748ce6604ad68e5b9f68ca96914b57c2118a1bb9a09a194ddaf
Expand Down Expand Up @@ -671,10 +671,6 @@ btc:

getdifficulty:
descr: Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
params:
blocknumber:
type: uint64
descr: 'Can be the number of a certain block to get its difficulty. To get the difficulty of the latest block use `latest`, `earliest`, `pending` or leave `params` empty (Hint: Latest block always means `actual latest block` minus `in3.finality`)'
in3Params:
finality:
descr: defines the amount of finality headers
Expand All @@ -687,7 +683,7 @@ btc:
type: bool

result:
type: uint256
type: double
descr: |
- `blocknumber` is a certain number: the difficulty of this block
- `blocknumber` is `latest`, `earliest`, `pending` or empty: the difficulty of the latest block (`actual latest block` minus `in3.finality`)
Expand Down Expand Up @@ -733,8 +729,6 @@ btc:
in3Params:
finality: 8
cmdParams: -x -c btc -f 8
request:
- 631910
response: 15138043247082.88
in3:
proof:
Expand Down
5 changes: 2 additions & 3 deletions wasm/src/in3_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,9 @@ function toNumber(val) {
case 'string':
return parseInt(val)
case 'undefined':
case 'null':
return 0
return undefined
default:
if (!val) return 0
if (!val) return val
if (val.readBigInt64BE) //nodejs Buffer
return val.length == 0 ? 0 : parseInt(toMinHex(val))
else if (val.redIMul)
Expand Down
4 changes: 2 additions & 2 deletions wasm/test/testUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ describe('Util-Tests', () => {
assert.equal(0, IN3.util.toNumber(false))
assert.equal(65535, IN3.util.toNumber(65535n))
assert.equal(65535, IN3.util.toNumber("65535"))
assert.equal(0, IN3.util.toNumber(undefined))
assert.equal(0, IN3.util.toNumber(null))
assert.equal(undefined, IN3.util.toNumber(undefined))
assert.equal(null, IN3.util.toNumber(null))
assert.equal(97, IN3.util.toNumber(Buffer.from('a', 'utf8')))
assert.equal(255, IN3.util.toNumber("0xff"))
assert.Throw(() => IN3.util.toNumber({}))
Expand Down

0 comments on commit 56b311d

Please sign in to comment.