@0x/contracts-zero-ex
: Add RFQT taker enforcement to FQT.
`@0x/contracts-zero-ex`: Remove redundant event from `BridgeAdapter`. `@0x/contracts-zero-ex`: Treat all calldata as signed if quote signer is not in `TransformERC20Feature`. `@0x/contracts-zero-ex`: Update bridge adapters
This commit is contained in:
@@ -28,11 +28,11 @@ import {
|
||||
TransformERC20FeatureEvents,
|
||||
} from '../wrappers';
|
||||
|
||||
const { NULL_BYTES, NULL_BYTES32 } = constants;
|
||||
const { NULL_ADDRESS, NULL_BYTES, NULL_BYTES32 } = constants;
|
||||
|
||||
type MintTokenTransformerEvent = DecodedLogEntry<TestMintTokenERC20TransformerMintTransformEventArgs>;
|
||||
|
||||
blockchainTests.resets('TransformERC20 feature', env => {
|
||||
blockchainTests.resets.only('TransformERC20 feature', env => {
|
||||
const callDataSignerKey = hexUtils.random();
|
||||
const callDataSigner = ethjs.bufferToHex(ethjs.privateToAddress(ethjs.toBuffer(callDataSignerKey)));
|
||||
let owner: string;
|
||||
@@ -687,6 +687,37 @@ blockchainTests.resets('TransformERC20 feature', env => {
|
||||
expect(actualCallDataHash).to.eq(hexUtils.hash(callData));
|
||||
});
|
||||
|
||||
it('passes the calldata hash to transformer when no quote signer configured', async () => {
|
||||
const startingOutputTokenBalance = getRandomInteger(0, '100e18');
|
||||
const startingInputTokenBalance = getRandomInteger(0, '100e18');
|
||||
await outputToken.mint(taker, startingOutputTokenBalance).awaitTransactionSuccessAsync();
|
||||
await inputToken.mint(taker, startingInputTokenBalance).awaitTransactionSuccessAsync();
|
||||
const inputTokenAmount = getRandomPortion(startingInputTokenBalance);
|
||||
const minOutputTokenAmount = getRandomInteger(1, '1e18');
|
||||
const outputTokenMintAmount = minOutputTokenAmount;
|
||||
const callValue = getRandomInteger(1, '1e18');
|
||||
const transformation = createMintTokenTransformation({
|
||||
outputTokenMintAmount,
|
||||
inputTokenBurnAmunt: inputTokenAmount,
|
||||
});
|
||||
const bakedCall = feature.transformERC20(
|
||||
inputToken.address,
|
||||
outputToken.address,
|
||||
inputTokenAmount,
|
||||
minOutputTokenAmount,
|
||||
[transformation],
|
||||
);
|
||||
const callData = bakedCall.getABIEncodedTransactionData();
|
||||
await feature.setQuoteSigner(NULL_ADDRESS).awaitTransactionSuccessAsync({ from: owner });
|
||||
const receipt = await bakedCall.awaitTransactionSuccessAsync({
|
||||
from: taker,
|
||||
value: callValue,
|
||||
data: callData,
|
||||
});
|
||||
const { callDataHash: actualCallDataHash } = (receipt.logs[0] as MintTokenTransformerEvent).args;
|
||||
expect(actualCallDataHash).to.eq(hexUtils.hash(callData));
|
||||
});
|
||||
|
||||
it('passes empty calldata hash to transformer with improperly signed calldata', async () => {
|
||||
const startingOutputTokenBalance = getRandomInteger(0, '100e18');
|
||||
const startingInputTokenBalance = getRandomInteger(0, '100e18');
|
||||
|
Reference in New Issue
Block a user