From 4734acbe61d6961ee95dce138e13fee5ecd6a149 Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Wed, 26 Jun 2019 15:46:39 -0400 Subject: [PATCH] `@0x/contracts-test-utils`: Add `hexConcat()` in `hex_utils.ts`. --- contracts/test-utils/CHANGELOG.json | 4 ++++ contracts/test-utils/src/hex_utils.ts | 8 ++++++++ contracts/test-utils/src/index.ts | 1 + 3 files changed, 13 insertions(+) create mode 100644 contracts/test-utils/src/hex_utils.ts diff --git a/contracts/test-utils/CHANGELOG.json b/contracts/test-utils/CHANGELOG.json index 03327c5a1c..e90a09bbbe 100644 --- a/contracts/test-utils/CHANGELOG.json +++ b/contracts/test-utils/CHANGELOG.json @@ -29,6 +29,10 @@ { "note": "Remove formatters", "pr": 1834 + }, + { + "note": "Add `hexConcat()` in `hex_utils.ts`", + "pr": 1885 } ] }, diff --git a/contracts/test-utils/src/hex_utils.ts b/contracts/test-utils/src/hex_utils.ts new file mode 100644 index 0000000000..95c2435b1f --- /dev/null +++ b/contracts/test-utils/src/hex_utils.ts @@ -0,0 +1,8 @@ +import * as ethUtil from 'ethereumjs-util'; + +/** + * Concatenate all arguments as a hex string. + */ +export function hexConcat(...args: Array): string { + return ethUtil.bufferToHex(Buffer.concat(args.map(h => ethUtil.toBuffer(h)))); +} diff --git a/contracts/test-utils/src/index.ts b/contracts/test-utils/src/index.ts index f98a6309f8..44c101adcc 100644 --- a/contracts/test-utils/src/index.ts +++ b/contracts/test-utils/src/index.ts @@ -27,6 +27,7 @@ export { OrderFactory } from './order_factory'; export { bytes32Values, testCombinatoriallyWithReferenceFuncAsync, uint256Values } from './combinatorial_utils'; export { TransactionFactory } from './transaction_factory'; export { testWithReferenceFuncAsync } from './test_with_reference'; +export { hexConcat } from './hex_utils'; export { ContractName, ERC20BalancesByOwner,