rafiki
rafiki copied to clipboard
Account crediting doesn't seem to add correctly
Pfry starts with initial balance of 0.01 USD.
After receiving payment of 8.71 USD, balance shows 18.71 USD.
Hmm, after taking a quick look I think it’s because in the webhook request handling we use
const amt = payment['receivedAmount'] as Amount
...
await mockAccounts.credit(acc.id, amt.value, false)
without casting the value at all to an integer from the incoming request. Then in the credit function we just do acc.creditsPosted += amount which leads to a string concat:
➜ node
Welcome to Node.js v16.17.1.
Type ".help" for more information.
> let num = BigInt(1)
undefined
> num += '871'
'1871'
TL;DR I think whenever we call methods on the AccountsServer we need to properly cast values we are passing in
@mkurapov But isn't it casted in
const amt = payment['receivedAmount'] as Amount
where Amount.value is a bigint?