ArkEcosystem / core

The ARK Core Blockchain Framework. Check https://learn.ark.dev for more information.
https://ark.io
MIT License
337 stars 286 forks source link

Don't use native numbers for storing arktoshi #2202

Closed vasild closed 5 years ago

vasild commented 5 years ago

Even though the code uses Bignum for manipulating arktoshi we have Bignum | number | string in the definitions of the classes. This is because the unit tests use fixtures/jsons that use numbers, e.g. amount: 123 instead of amount: "123".

The problem is that the amount of arktoshi could exceed JavaScript's Number.MAX_SAFE_INTEGER, so any chance of the code to accidentally start using native numbers should be nullified. Thus:

Change all Bignum | number | string to Bignum | string and adjust the fixtures.

faustbrian commented 5 years ago

number | string are only present because of tests that still use JSON fixtures so only Bignum should be used if you are going to work on this now.

faustbrian commented 5 years ago

https://github.com/ArkEcosystem/core/commit/df9fd4d242f6a49eb8ac85d328c1fc6b0c800de8