Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
decodeAssetDataOrThrow(assetData: string): AssetData {
const assetProxyId = hexUtils.slice(assetData, 0, 4); // tslint:disable-line:custom-no-magic-numbers
switch (assetProxyId) {
case AssetProxyId.ERC20: {
const tokenAddress = assetDataEncoder.getABIDecodedTransactionData('ERC20Token', assetData);
return {
assetProxyId,
tokenAddress,
};
}
case AssetProxyId.ERC20Bridge: {
const [tokenAddress, bridgeAddress, bridgeData] = assetDataEncoder.getABIDecodedTransactionData<
[string, string, string]
>('ERC20Bridge', assetData);
return {
assetProxyId,
tokenAddress,
bridgeAddress,
bridgeData,
};
}
case AssetProxyId.ERC721: {
const [tokenAddress, tokenId] = assetDataEncoder.getABIDecodedTransactionData<[string, BigNumber]>(
'ERC721Token',
assetData,
);
return {
const registeredERC1155ProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC1155).callAsync();
warnIfMismatch(
registeredERC1155ProxyInMAP,
erc1155Proxy.address,
'Unexpected ERC1155Proxy registered in MultiAssetProxy',
);
const registeredStaticCallProxyInMAP = await multiAssetProxy.getAssetProxy(AssetProxyId.StaticCall).callAsync();
warnIfMismatch(
registeredStaticCallProxyInMAP,
addresses.staticCallProxy,
'Unexpected StaticCallProxy registered in MultiAssetProxy',
);
const registeredERC20BridgeProxyInMAP = await multiAssetProxy
.getAssetProxy(AssetProxyId.ERC20Bridge)
.callAsync();
warnIfMismatch(
registeredERC20BridgeProxyInMAP,
addresses.erc20BridgeProxy,
'Unexpected ERC20BridgeProxy registered in MultiAssetProxy',
);
}
const registeredMultiAssetProxy = await exchange.getAssetProxy(AssetProxyId.MultiAsset).callAsync();
warnIfMismatch(
registeredMultiAssetProxy,
multiAssetProxy.address,
'Unexpected MultiAssetProxy registered in Exchange',
);
const registeredStaticCallProxy = await exchange.getAssetProxy(AssetProxyId.StaticCall).callAsync();
warnIfMismatch(
registeredStaticCallProxy,
addresses.staticCallProxy,
'Unexpected StaticCallProxy registered in Exchange',
);
const registeredERC20BridgeProxy = await exchange.getAssetProxy(AssetProxyId.ERC20Bridge).callAsync();
warnIfMismatch(
registeredERC20BridgeProxy,
addresses.erc20BridgeProxy,
'Unexpected ERC20BridgeProxy registered in Exchange',
);
const protocolFeeCollector = await exchange.protocolFeeCollector().callAsync();
warnIfMismatch(protocolFeeCollector, addresses.stakingProxy, 'Unexpected StakingProxy attached to Exchange');
const protocolFeeMultiplier = await exchange.protocolFeeMultiplier().callAsync();
warnIfMismatch(protocolFeeMultiplier.toString(), '150000', 'Unexpected protocolFeeMultiplier in Exchange');
}