Revert "Mutate ERC20 ABI to handle WETH Deposit and Withdrawl"
This reverts commit c5f6ebee188e35a4e7fc8b9363d04ca90e4f31ee.
This commit is contained in:
parent
c5f6ebee18
commit
d1203f90da
@ -26,16 +26,19 @@ export class CollisionResistanceAbiDecoder {
|
|||||||
this._restAbiDecoder = new AbiDecoder(abis);
|
this._restAbiDecoder = new AbiDecoder(abis);
|
||||||
}
|
}
|
||||||
public tryToDecodeLogOrNoop<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
|
public tryToDecodeLogOrNoop<ArgsType extends DecodedLogArgs>(log: LogEntry): LogWithDecodedArgs<ArgsType> | RawLog {
|
||||||
|
let maybeDecodedLog = log;
|
||||||
if (this._knownERC20Tokens.has(log.address)) {
|
if (this._knownERC20Tokens.has(log.address)) {
|
||||||
const maybeDecodedERC20Log = this._erc20AbiDecoder.tryToDecodeLogOrNoop(log);
|
maybeDecodedLog = this._erc20AbiDecoder.tryToDecodeLogOrNoop(log);
|
||||||
return maybeDecodedERC20Log;
|
|
||||||
} else if (this._knownERC721Tokens.has(log.address)) {
|
} else if (this._knownERC721Tokens.has(log.address)) {
|
||||||
const maybeDecodedERC721Log = this._erc721AbiDecoder.tryToDecodeLogOrNoop(log);
|
maybeDecodedLog = this._erc721AbiDecoder.tryToDecodeLogOrNoop(log);
|
||||||
return maybeDecodedERC721Log;
|
|
||||||
} else {
|
|
||||||
const maybeDecodedLog = this._restAbiDecoder.tryToDecodeLogOrNoop(log);
|
|
||||||
return maybeDecodedLog;
|
|
||||||
}
|
}
|
||||||
|
// Fall back to the supplied ABIs for decoding if the ERC20/ERC721 decoding fails
|
||||||
|
// This ensures we hit events like Deposit and Withdraw given WETH can be a known ERC20Token
|
||||||
|
const isLogDecoded = ((maybeDecodedLog as any) as LogWithDecodedArgs<DecodedLogArgs>).event !== undefined;
|
||||||
|
if (!isLogDecoded) {
|
||||||
|
maybeDecodedLog = this._restAbiDecoder.tryToDecodeLogOrNoop(log);
|
||||||
|
}
|
||||||
|
return maybeDecodedLog;
|
||||||
}
|
}
|
||||||
// Hints the ABI decoder that a particular token address is ERC20 and events from it should be decoded as ERC20 events
|
// Hints the ABI decoder that a particular token address is ERC20 and events from it should be decoded as ERC20 events
|
||||||
public addERC20Token(address: string): void {
|
public addERC20Token(address: string): void {
|
||||||
|
@ -119,20 +119,10 @@ export class OrderWatcher {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._provider = provider;
|
this._provider = provider;
|
||||||
const wethDepositEvent = _.find(
|
|
||||||
artifacts.WETH9.compilerOutput.abi,
|
|
||||||
item => item.type === 'event' && item.name === 'Deposit',
|
|
||||||
);
|
|
||||||
const wethWithdrawEvent = _.find(
|
|
||||||
artifacts.WETH9.compilerOutput.abi,
|
|
||||||
item => item.type === 'event' && item.name === 'Withdrawal',
|
|
||||||
);
|
|
||||||
// Combine ERC20 and WETH events into a single ABI. This is used as the default ERC20 ABI when decoding
|
|
||||||
const combinedWETHERC20Abi = [...artifacts.ERC20Token.compilerOutput.abi, wethDepositEvent, wethWithdrawEvent];
|
|
||||||
this._collisionResistantAbiDecoder = new CollisionResistanceAbiDecoder(
|
this._collisionResistantAbiDecoder = new CollisionResistanceAbiDecoder(
|
||||||
combinedWETHERC20Abi,
|
artifacts.ERC20Token.compilerOutput.abi,
|
||||||
artifacts.ERC721Token.compilerOutput.abi,
|
artifacts.ERC721Token.compilerOutput.abi,
|
||||||
[artifacts.Exchange.compilerOutput.abi],
|
[artifacts.WETH9.compilerOutput.abi, artifacts.Exchange.compilerOutput.abi],
|
||||||
);
|
);
|
||||||
const contractWrappers = new ContractWrappers(provider, {
|
const contractWrappers = new ContractWrappers(provider, {
|
||||||
networkId,
|
networkId,
|
||||||
@ -160,7 +150,6 @@ export class OrderWatcher {
|
|||||||
this._cleanupJobInterval = config.cleanupJobIntervalMs;
|
this._cleanupJobInterval = config.cleanupJobIntervalMs;
|
||||||
const zrxTokenAddress = assetDataUtils.decodeERC20AssetData(orderFilledCancelledFetcher.getZRXAssetData())
|
const zrxTokenAddress = assetDataUtils.decodeERC20AssetData(orderFilledCancelledFetcher.getZRXAssetData())
|
||||||
.tokenAddress;
|
.tokenAddress;
|
||||||
this._collisionResistantAbiDecoder.addERC20Token(zrxTokenAddress);
|
|
||||||
this._dependentOrderHashesTracker = new DependentOrderHashesTracker(zrxTokenAddress);
|
this._dependentOrderHashesTracker = new DependentOrderHashesTracker(zrxTokenAddress);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user