@0x/zero-ex
: Address CD post-audit feedback.
Add `LogMetadataTransformer`.
This commit is contained in:
parent
14d6330b40
commit
71700e69af
@ -17,6 +17,14 @@
|
||||
{
|
||||
"note": "Refund unused protocol fees to `refundReceiver` in FQT",
|
||||
"pr": 2657
|
||||
},
|
||||
{
|
||||
"note": "Address CD post-audit feedback",
|
||||
"pr": 2657
|
||||
},
|
||||
{
|
||||
"note": "Add `LogMetadataTransformer`",
|
||||
"pr": 2657
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -77,6 +77,7 @@ contract Bootstrap is
|
||||
/// @dev Self-destructs this contract.
|
||||
/// Can only be called by the deployer.
|
||||
function die() external {
|
||||
assert(address(this) == _implementation);
|
||||
if (msg.sender != _deployer) {
|
||||
LibProxyRichErrors.InvalidDieCallerError(msg.sender, _deployer).rrevert();
|
||||
}
|
||||
|
@ -271,7 +271,9 @@ contract MetaTransactions is
|
||||
|
||||
_validateMetaTransaction(state);
|
||||
|
||||
// Mark the transaction executed.
|
||||
// Mark the transaction executed by storing the block at which it was executed.
|
||||
// Currently the block number just indicates that the mtx was executed and
|
||||
// serves no other purpose from within this contract.
|
||||
LibMetaTransactionsStorage.getStorage()
|
||||
.mtxHashToExecutedBlockNumber[state.hash] = block.number;
|
||||
|
||||
|
@ -44,10 +44,6 @@ contract Ownable is
|
||||
|
||||
using LibRichErrorsV06 for bytes;
|
||||
|
||||
constructor() public FixinCommon() {
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
}
|
||||
|
||||
/// @dev Initializes this feature. The intial owner will be set to this (ZeroEx)
|
||||
/// to allow the bootstrappers to call `extend()`. Ownership should be
|
||||
/// transferred to the real owner by the bootstrapper after
|
||||
|
@ -49,10 +49,6 @@ contract SignatureValidator is
|
||||
/// @dev Version of this feature.
|
||||
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 0, 0);
|
||||
|
||||
constructor() public FixinCommon() {
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
}
|
||||
|
||||
/// @dev Initialize and register this feature.
|
||||
/// Should be delegatecalled by `Migrate.migrate()`.
|
||||
/// @return success `LibMigrate.SUCCESS` on success.
|
||||
|
@ -42,10 +42,6 @@ contract SimpleFunctionRegistry is
|
||||
|
||||
using LibRichErrorsV06 for bytes;
|
||||
|
||||
constructor() public FixinCommon() {
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
}
|
||||
|
||||
/// @dev Initializes this feature, registering its own functions.
|
||||
/// @return success Magic bytes if successful.
|
||||
function bootstrap()
|
||||
|
@ -48,10 +48,6 @@ contract TokenSpender is
|
||||
|
||||
using LibRichErrorsV06 for bytes;
|
||||
|
||||
constructor() public FixinCommon() {
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
}
|
||||
|
||||
/// @dev Initialize and register this feature. Should be delegatecalled
|
||||
/// into during a `Migrate.migrate()`.
|
||||
/// @param allowanceTarget An `allowanceTarget` instance, configured to have
|
||||
|
@ -61,10 +61,6 @@ contract TransformERC20 is
|
||||
/// @dev Version of this feature.
|
||||
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 2, 0);
|
||||
|
||||
constructor() public FixinCommon() {
|
||||
// solhint-disable-next-line no-empty-blocks
|
||||
}
|
||||
|
||||
/// @dev Initialize and register this feature.
|
||||
/// Should be delegatecalled by `Migrate.migrate()`.
|
||||
/// @param transformerDeployer The trusted deployer for transformers.
|
||||
@ -257,16 +253,15 @@ contract TransformERC20 is
|
||||
// Compute how much output token has been transferred to the taker.
|
||||
state.takerOutputTokenBalanceAfter =
|
||||
LibERC20Transformer.getTokenBalanceOf(args.outputToken, args.taker);
|
||||
if (state.takerOutputTokenBalanceAfter > state.takerOutputTokenBalanceBefore) {
|
||||
outputTokenAmount = state.takerOutputTokenBalanceAfter.safeSub(
|
||||
state.takerOutputTokenBalanceBefore
|
||||
);
|
||||
} else if (state.takerOutputTokenBalanceAfter < state.takerOutputTokenBalanceBefore) {
|
||||
if (state.takerOutputTokenBalanceAfter < state.takerOutputTokenBalanceBefore) {
|
||||
LibTransformERC20RichErrors.NegativeTransformERC20OutputError(
|
||||
address(args.outputToken),
|
||||
state.takerOutputTokenBalanceBefore - state.takerOutputTokenBalanceAfter
|
||||
).rrevert();
|
||||
}
|
||||
outputTokenAmount = state.takerOutputTokenBalanceAfter.safeSub(
|
||||
state.takerOutputTokenBalanceBefore
|
||||
);
|
||||
// Ensure enough output token has been sent to the taker.
|
||||
if (outputTokenAmount < args.minOutputTokenAmount) {
|
||||
LibTransformERC20RichErrors.IncompleteTransformERC20Error(
|
||||
|
@ -32,7 +32,6 @@ import "./LibERC20Transformer.sol";
|
||||
contract AffiliateFeeTransformer is
|
||||
Transformer
|
||||
{
|
||||
// solhint-disable no-empty-blocks
|
||||
using LibRichErrorsV06 for bytes;
|
||||
using LibSafeMathV06 for uint256;
|
||||
using LibERC20Transformer for IERC20TokenV06;
|
||||
@ -51,12 +50,6 @@ contract AffiliateFeeTransformer is
|
||||
|
||||
uint256 private constant MAX_UINT256 = uint256(-1);
|
||||
|
||||
/// @dev Create this contract.
|
||||
constructor()
|
||||
public
|
||||
Transformer()
|
||||
{}
|
||||
|
||||
/// @dev Transfers tokens to recipients.
|
||||
/// @param context Context information.
|
||||
/// @return success The success bytes (`LibERC20Transformer.TRANSFORMER_SUCCESS`).
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./Transformer.sol";
|
||||
import "./LibERC20Transformer.sol";
|
||||
|
||||
|
||||
/// @dev A transformer that just emits an event with an arbitrary byte payload.
|
||||
contract LogMetadataTransformer is
|
||||
Transformer
|
||||
{
|
||||
event TransformerMetadata(bytes32 callDataHash, address sender, address taker, bytes data);
|
||||
|
||||
/// @dev Maximum uint256 value.
|
||||
uint256 private constant MAX_UINT256 = uint256(-1);
|
||||
|
||||
/// @dev Emits an event.
|
||||
/// @param context Context information.
|
||||
/// @return success The success bytes (`LibERC20Transformer.TRANSFORMER_SUCCESS`).
|
||||
function transform(TransformContext calldata context)
|
||||
external
|
||||
override
|
||||
returns (bytes4 success)
|
||||
{
|
||||
emit TransformerMetadata(context.callDataHash, context.sender, context.taker, context.data);
|
||||
return LibERC20Transformer.TRANSFORMER_SUCCESS;
|
||||
}
|
||||
}
|
@ -39,9 +39,9 @@
|
||||
"publish:private": "yarn build && gitpkg publish"
|
||||
},
|
||||
"config": {
|
||||
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IAllowanceTarget,IERC20Transformer,IOwnable,ISimpleFunctionRegistry,ITokenSpender,ITransformERC20,FillQuoteTransformer,PayTakerTransformer,WethTransformer,Ownable,SimpleFunctionRegistry,TransformERC20,TokenSpender,AffiliateFeeTransformer,SignatureValidator,MetaTransactions",
|
||||
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IAllowanceTarget,IERC20Transformer,IOwnable,ISimpleFunctionRegistry,ITokenSpender,ITransformERC20,FillQuoteTransformer,PayTakerTransformer,WethTransformer,Ownable,SimpleFunctionRegistry,TransformERC20,TokenSpender,AffiliateFeeTransformer,SignatureValidator,MetaTransactions,LogMetadataTransformer",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|AllowanceTarget|Bootstrap|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinGasToken|FixinReentrancyGuard|FlashWallet|FullMigration|IAllowanceTarget|IBootstrap|IERC20Bridge|IERC20Transformer|IExchange|IFeature|IFlashWallet|IGasToken|IMetaTransactions|IOwnable|ISignatureValidator|ISimpleFunctionRegistry|ITestSimpleFunctionRegistryFeature|ITokenSpender|ITransformERC20|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignatureRichErrors|LibSignedCallData|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibSpenderRichErrors|LibStorage|LibTokenSpenderStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|MetaTransactions|Ownable|PayTakerTransformer|SignatureValidator|SimpleFunctionRegistry|TestCallTarget|TestDelegateCaller|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFullMigration|TestInitialMigration|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestTokenSpender|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TokenSpender|TransformERC20|Transformer|TransformerDeployer|WethTransformer|ZeroEx).json"
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|AllowanceTarget|Bootstrap|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinGasToken|FixinReentrancyGuard|FlashWallet|FullMigration|IAllowanceTarget|IBootstrap|IERC20Bridge|IERC20Transformer|IExchange|IFeature|IFlashWallet|IGasToken|IMetaTransactions|IOwnable|ISignatureValidator|ISimpleFunctionRegistry|ITestSimpleFunctionRegistryFeature|ITokenSpender|ITransformERC20|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignatureRichErrors|LibSignedCallData|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibSpenderRichErrors|LibStorage|LibTokenSpenderStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LogMetadataTransformer|MetaTransactions|Ownable|PayTakerTransformer|SignatureValidator|SimpleFunctionRegistry|TestCallTarget|TestDelegateCaller|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFullMigration|TestInitialMigration|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestTokenSpender|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TokenSpender|TransformERC20|Transformer|TransformerDeployer|WethTransformer|ZeroEx).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -17,6 +17,7 @@ import * as ISimpleFunctionRegistry from '../generated-artifacts/ISimpleFunction
|
||||
import * as ITokenSpender from '../generated-artifacts/ITokenSpender.json';
|
||||
import * as ITransformERC20 from '../generated-artifacts/ITransformERC20.json';
|
||||
import * as IZeroEx from '../generated-artifacts/IZeroEx.json';
|
||||
import * as LogMetadataTransformer from '../generated-artifacts/LogMetadataTransformer.json';
|
||||
import * as MetaTransactions from '../generated-artifacts/MetaTransactions.json';
|
||||
import * as Ownable from '../generated-artifacts/Ownable.json';
|
||||
import * as PayTakerTransformer from '../generated-artifacts/PayTakerTransformer.json';
|
||||
@ -48,4 +49,5 @@ export const artifacts = {
|
||||
AffiliateFeeTransformer: AffiliateFeeTransformer as ContractArtifact,
|
||||
SignatureValidator: SignatureValidator as ContractArtifact,
|
||||
MetaTransactions: MetaTransactions as ContractArtifact,
|
||||
LogMetadataTransformer: LogMetadataTransformer as ContractArtifact,
|
||||
};
|
||||
|
@ -9,6 +9,7 @@ export {
|
||||
ITokenSpenderContract,
|
||||
ITransformERC20Contract,
|
||||
IZeroExContract,
|
||||
LogMetadataTransformerContract,
|
||||
PayTakerTransformerContract,
|
||||
WethTransformerContract,
|
||||
ZeroExContract,
|
||||
|
@ -15,6 +15,7 @@ export * from '../generated-wrappers/i_token_spender';
|
||||
export * from '../generated-wrappers/i_transform_erc20';
|
||||
export * from '../generated-wrappers/i_zero_ex';
|
||||
export * from '../generated-wrappers/initial_migration';
|
||||
export * from '../generated-wrappers/log_metadata_transformer';
|
||||
export * from '../generated-wrappers/meta_transactions';
|
||||
export * from '../generated-wrappers/ownable';
|
||||
export * from '../generated-wrappers/pay_taker_transformer';
|
||||
|
@ -53,6 +53,7 @@ import * as LibTokenSpenderStorage from '../test/generated-artifacts/LibTokenSpe
|
||||
import * as LibTransformERC20RichErrors from '../test/generated-artifacts/LibTransformERC20RichErrors.json';
|
||||
import * as LibTransformERC20Storage from '../test/generated-artifacts/LibTransformERC20Storage.json';
|
||||
import * as LibWalletRichErrors from '../test/generated-artifacts/LibWalletRichErrors.json';
|
||||
import * as LogMetadataTransformer from '../test/generated-artifacts/LogMetadataTransformer.json';
|
||||
import * as MetaTransactions from '../test/generated-artifacts/MetaTransactions.json';
|
||||
import * as Ownable from '../test/generated-artifacts/Ownable.json';
|
||||
import * as PayTakerTransformer from '../test/generated-artifacts/PayTakerTransformer.json';
|
||||
@ -139,6 +140,7 @@ export const artifacts = {
|
||||
FillQuoteTransformer: FillQuoteTransformer as ContractArtifact,
|
||||
IERC20Transformer: IERC20Transformer as ContractArtifact,
|
||||
LibERC20Transformer: LibERC20Transformer as ContractArtifact,
|
||||
LogMetadataTransformer: LogMetadataTransformer as ContractArtifact,
|
||||
PayTakerTransformer: PayTakerTransformer as ContractArtifact,
|
||||
Transformer: Transformer as ContractArtifact,
|
||||
WethTransformer: WethTransformer as ContractArtifact,
|
||||
|
@ -51,6 +51,7 @@ export * from '../test/generated-wrappers/lib_token_spender_storage';
|
||||
export * from '../test/generated-wrappers/lib_transform_erc20_rich_errors';
|
||||
export * from '../test/generated-wrappers/lib_transform_erc20_storage';
|
||||
export * from '../test/generated-wrappers/lib_wallet_rich_errors';
|
||||
export * from '../test/generated-wrappers/log_metadata_transformer';
|
||||
export * from '../test/generated-wrappers/meta_transactions';
|
||||
export * from '../test/generated-wrappers/ownable';
|
||||
export * from '../test/generated-wrappers/pay_taker_transformer';
|
||||
|
@ -15,6 +15,7 @@
|
||||
"generated-artifacts/ITransformERC20.json",
|
||||
"generated-artifacts/IZeroEx.json",
|
||||
"generated-artifacts/InitialMigration.json",
|
||||
"generated-artifacts/LogMetadataTransformer.json",
|
||||
"generated-artifacts/MetaTransactions.json",
|
||||
"generated-artifacts/Ownable.json",
|
||||
"generated-artifacts/PayTakerTransformer.json",
|
||||
@ -72,6 +73,7 @@
|
||||
"test/generated-artifacts/LibTransformERC20RichErrors.json",
|
||||
"test/generated-artifacts/LibTransformERC20Storage.json",
|
||||
"test/generated-artifacts/LibWalletRichErrors.json",
|
||||
"test/generated-artifacts/LogMetadataTransformer.json",
|
||||
"test/generated-artifacts/MetaTransactions.json",
|
||||
"test/generated-artifacts/Ownable.json",
|
||||
"test/generated-artifacts/PayTakerTransformer.json",
|
||||
|
Loading…
x
Reference in New Issue
Block a user