XRPL-Labs / xrpld-hooks

ISC License
94 stars 28 forks source link

accept example fails payment (Version: latest) #19

Closed shortthefomo closed 1 year ago

shortthefomo commented 2 years ago

Issue Description

running the hook accept in the demo's fails if whole number not used.

Steps to Reproduce

node pay.js sh4ci7NFXhzQam4oLkqdF837Z66dh 1.1111 rnYdsuK9f7vVBhFhVzPB7s8APuf9C6QrAN

Expected Result

account rnYdsuK9f7vVBhFhVzPB7s8APuf9C6QrAN credited 1.1111 XRP

Actual Result

/opt/xrpld-hooks/accept/pay.js:9 const amount = BigInt(process.argv[3]) * 1000000n

SyntaxError: Cannot convert 1.1111 to a BigInt at BigInt () at Object. (/opt/xrpld-hooks/accept/pay.js:9:16) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

using node pay.js sh4ci7NFXhzQam4oLkqdF837Z66dh 2 rnYdsuK9f7vVBhFhVzPB7s8APuf9C6QrAN passes

Environment

docker container off the how to from Wieste blog

WietseWind commented 2 years ago

Thanks for reporting @lathanbritz!

@RichardAH

RichardAH commented 1 year ago

Thanks for the report but this is just a js test/example helper, not part of hooks proper. If you'd like to modify it change: const amount = BigInt(process.argv[3]) * 1000000n to const amount = Math.round(parseFloat(process.argv[3]) * 1000000))