import BigNumber from 'bignumber.js' ; import { BN } from 'bn.js' ; import { common , ECPoint , ECPointHex , UInt160 , UInt160Hex , UInt256 , UInt256Hex } from './common' ; export const JSONHelper = { writeUInt64LE : ( value ) : string => value . toString ( 16 , 16 ) , readUInt64LE : ( value ) : BN => new BN ( value , 16 ) , writeUInt64 : ( value ) : string => value . toString ( 10 ) , readUInt64 : ( value ) : BigNumber => new BigNumber ( value ) , writeUInt160 : ( value ) : string => common . uInt160ToString ( value ) , readUInt160 : ( hash ) : UInt160 => common . stringToUInt160 ( hash ) , writeUInt256 : ( value ) : string => common . uInt256ToString ( value ) , readUInt256 : ( hash ) : UInt256 => common . stringToUInt256 ( hash ) , writeFixed8 : ( value ) : string => common . fixed8ToDecimal ( value ) . toString ( ) , readFixed8 : ( value ) : BN => common . fixed8FromDecimal ( new BigNumber ( value ) ) , writeECPoint : ( value ) : string => common . ecPointToString ( value ) , readECPoint : ( value ) : ECPoint => common . stringToECPoint ( value ) , writeBuffer : ( value ) : string => value . toString ( 'hex' ) , readBuffer : ( value ) : Buffer => Buffer . from ( value , 'hex' ) , writeBase64Buffer : ( value ) : string => value . toString ( 'base64' ) , readBase64Buffer : ( value ) : Buffer => Buffer . from ( value , 'base64' ) } ;