[FIX] Fix data serialization.

This commit is contained in:
Daniel Kmak 2018-04-03 16:03:57 +02:00 committed by Bagaric
parent a79b1d72e9
commit cc84e5fc4e
2 changed files with 9 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import BN from 'bn.js';
import abi from 'ethereumjs-abi';
import { toWei, Units } from './units';
import { toBuffer } from 'ethereumjs-util';
const TIME_BOUNTY_MIN = new BN('1');
@ -60,7 +61,7 @@ export const calcEACTotalCost = (
export const getScheduleData = (
toAddress: string,
callData = '',
callData: string | Buffer = '',
callGas: BN | null,
callValue: BN | null,
windowSize: number | null,
@ -73,6 +74,10 @@ export const getScheduleData = (
requiredDeposit = new BN(0);
}
if (typeof callData === 'string') {
callData = toBuffer(callData);
}
if (
!callValue ||
!callGas ||

View File

@ -1,19 +1,13 @@
declare module 'ethereumjs-abi' {
import BN from 'bn.js';
type Values = (string | number | BN | Array<any>)[];
type Values = (string | number | boolean | BN | Buffer | Array<any>)[];
type Types = string[];
export function eventID(name: string, types: Types): Buffer;
export function methodID(name: string, types: Types): Buffer;
export function rawEncode(types: Types, values: Values): Buffer;
export function rawDecode(
types: Types,
data: string | Buffer
): (Buffer | boolean | number | BN | string)[];
export function rawDecode(types: Types, data: string | Buffer): (Values)[];
export function simpleEncode(method: string, ...values: Values): Buffer;
export function simpleDecode(
method: string,
data: string | Buffer
): (Buffer | boolean | number | BN | string)[];
export function simpleDecode(method: string, data: string | Buffer): (Values)[];
export function stringify(types: Types, values: Values): string;
export function solidityPack(types: Types, values: Values): Buffer;
export function soliditySHA3(types: Types, values: Values): Buffer;