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,