* remove assetDataUtils everywhere * export IAssetDataContract from @0x/contract-wrappers to allow @0x/instant to decode asset data synchronously * export generic function `decodeAssetDataOrThrow` and add ERC20Bridge support * export `hexUtils` from order-utils instead of contracts-test-utils
24 lines
906 B
TypeScript
24 lines
906 B
TypeScript
import { BigNumber } from '@0x/utils';
|
|
import * as ethAbi from 'ethereumjs-abi';
|
|
import * as ethUtil from 'ethereumjs-util';
|
|
|
|
export * from './balance_threshold_wrapper';
|
|
export * from './dutch_auction_test_wrapper';
|
|
|
|
// tslint:disable-next-line:completed-docs
|
|
export function encodeDutchAuctionAssetData(
|
|
assetData: string,
|
|
beginTimeSeconds: BigNumber,
|
|
beginAmount: BigNumber,
|
|
): string {
|
|
const assetDataBuffer = ethUtil.toBuffer(assetData);
|
|
const abiEncodedAuctionData = (ethAbi as any).rawEncode(
|
|
['uint256', 'uint256'],
|
|
[beginTimeSeconds.toString(), beginAmount.toString()],
|
|
);
|
|
const abiEncodedAuctionDataBuffer = ethUtil.toBuffer(abiEncodedAuctionData);
|
|
const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]);
|
|
const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer);
|
|
return dutchAuctionData;
|
|
}
|