mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-10 02:55:41 +00:00
7541d6f486
* relayout rpc code, start contract helper * Dont ask for estimate if theres no value * Split out conversion of ether to wei hex into lib function. * big.js -> bignumber.js
16 lines
688 B
JavaScript
16 lines
688 B
JavaScript
// @flow
|
|
// Ref: https://github.com/ethereum/wiki/wiki/JSON-RPC
|
|
|
|
import type Big from 'bignumber.js';
|
|
import { toBuffer } from 'ethereumjs-util';
|
|
|
|
// When encoding QUANTITIES (integers, numbers): encode as hex, prefix with "0x", the most compact representation (slight exception: zero should be represented as "0x0").
|
|
export function hexEncodeQuantity(value: Big): string {
|
|
return '0x' + (value.toString(16) || '0');
|
|
}
|
|
|
|
// When encoding UNFORMATTED DATA (byte arrays, account addresses, hashes, bytecode arrays): encode as hex, prefix with "0x", two hex digits per byte.
|
|
export function hexEncodeData(value: string | Buffer): string {
|
|
return '0x' + toBuffer(value).toString('hex');
|
|
}
|