Rename decodeAssetDataId to decodeAssetProxyId for consistency

This commit is contained in:
Fabio Berger 2018-07-18 11:49:30 +02:00
parent 8931388309
commit 12f02b9814
5 changed files with 13 additions and 13 deletions

View File

@ -26,7 +26,7 @@ export class AssetWrapper {
}); });
} }
public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> { public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
const proxyId = assetDataUtils.decodeAssetDataId(assetData); const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) { switch (proxyId) {
case AssetProxyId.ERC20: { case AssetProxyId.ERC20: {
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper; const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
@ -49,7 +49,7 @@ export class AssetWrapper {
} }
} }
public async setBalanceAsync(userAddress: string, assetData: string, desiredBalance: BigNumber): Promise<void> { public async setBalanceAsync(userAddress: string, assetData: string, desiredBalance: BigNumber): Promise<void> {
const proxyId = assetDataUtils.decodeAssetDataId(assetData); const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) { switch (proxyId) {
case AssetProxyId.ERC20: { case AssetProxyId.ERC20: {
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper; const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
@ -107,7 +107,7 @@ export class AssetWrapper {
} }
} }
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> { public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
const proxyId = assetDataUtils.decodeAssetDataId(assetData); const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) { switch (proxyId) {
case AssetProxyId.ERC20: { case AssetProxyId.ERC20: {
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper; const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
@ -141,7 +141,7 @@ export class AssetWrapper {
assetData: string, assetData: string,
desiredAllowance: BigNumber, desiredAllowance: BigNumber,
): Promise<void> { ): Promise<void> {
const proxyId = assetDataUtils.decodeAssetDataId(assetData); const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (proxyId) { switch (proxyId) {
case AssetProxyId.ERC20: { case AssetProxyId.ERC20: {
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper; const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;

View File

@ -598,8 +598,8 @@ export class CoreCombinatorialUtils {
break; break;
case TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount: case TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount:
const takerAssetProxyId = assetDataUtils.decodeAssetDataId(signedOrder.takerAssetData); const takerAssetProxyId = assetDataUtils.decodeAssetProxyId(signedOrder.takerAssetData);
const makerAssetProxyId = assetDataUtils.decodeAssetDataId(signedOrder.makerAssetData); const makerAssetProxyId = assetDataUtils.decodeAssetProxyId(signedOrder.makerAssetData);
const isEitherAssetERC721 = const isEitherAssetERC721 =
takerAssetProxyId === AssetProxyId.ERC721 || makerAssetProxyId === AssetProxyId.ERC721; takerAssetProxyId === AssetProxyId.ERC721 || makerAssetProxyId === AssetProxyId.ERC721;
if (isEitherAssetERC721) { if (isEitherAssetERC721) {

View File

@ -24,7 +24,7 @@ export class ForwarderWrapper {
private _zrxAddress: string; private _zrxAddress: string;
private static _createOptimizedSellOrders(signedOrders: SignedOrder[]): MarketSellOrders { private static _createOptimizedSellOrders(signedOrders: SignedOrder[]): MarketSellOrders {
const marketSellOrders = formatters.createMarketSellOrders(signedOrders, ZERO_AMOUNT); const marketSellOrders = formatters.createMarketSellOrders(signedOrders, ZERO_AMOUNT);
const assetDataId = assetDataUtils.decodeAssetDataId(signedOrders[0].makerAssetData); const assetDataId = assetDataUtils.decodeAssetProxyId(signedOrders[0].makerAssetData);
// Contract will fill this in for us as all of the assetData is assumed to be the same // Contract will fill this in for us as all of the assetData is assumed to be the same
for (let i = 0; i < signedOrders.length; i++) { for (let i = 0; i < signedOrders.length; i++) {
if (i !== 0 && assetDataId === AssetProxyId.ERC20) { if (i !== 0 && assetDataId === AssetProxyId.ERC20) {
@ -90,7 +90,7 @@ export class ForwarderWrapper {
txData: TxDataPayable, txData: TxDataPayable,
opts: { feeProportion?: number; feeRecipient?: string } = {}, opts: { feeProportion?: number; feeRecipient?: string } = {},
): Promise<TransactionReceiptWithDecodedLogs> { ): Promise<TransactionReceiptWithDecodedLogs> {
const assetDataId = assetDataUtils.decodeAssetDataId(orders[0].makerAssetData); const assetDataId = assetDataUtils.decodeAssetProxyId(orders[0].makerAssetData);
if (assetDataId !== AssetProxyId.ERC20) { if (assetDataId !== AssetProxyId.ERC20) {
throw new Error('Asset type not supported by marketSellEthForERC20'); throw new Error('Asset type not supported by marketSellEthForERC20');
} }
@ -116,7 +116,7 @@ export class ForwarderWrapper {
feeProportion: number, feeProportion: number,
makerAssetFillAmount: BigNumber, makerAssetFillAmount: BigNumber,
): Promise<BigNumber> { ): Promise<BigNumber> {
const assetProxyId = assetDataUtils.decodeAssetDataId(orders[0].makerAssetData); const assetProxyId = assetDataUtils.decodeAssetProxyId(orders[0].makerAssetData);
switch (assetProxyId) { switch (assetProxyId) {
case AssetProxyId.ERC20: { case AssetProxyId.ERC20: {
const fillAmountWei = this._calculateMarketBuyERC20FillAmountAsync( const fillAmountWei = this._calculateMarketBuyERC20FillAmountAsync(

View File

@ -233,7 +233,7 @@ export class MatchOrderTester {
const expectedNewERC20BalancesByOwner = _.cloneDeep(erc20BalancesByOwner); const expectedNewERC20BalancesByOwner = _.cloneDeep(erc20BalancesByOwner);
const expectedNewERC721TokenIdsByOwner = _.cloneDeep(erc721TokenIdsByOwner); const expectedNewERC721TokenIdsByOwner = _.cloneDeep(erc721TokenIdsByOwner);
// Left Maker Asset (Right Taker Asset) // Left Maker Asset (Right Taker Asset)
const makerAssetProxyIdLeft = assetDataUtils.decodeAssetDataId(signedOrderLeft.makerAssetData); const makerAssetProxyIdLeft = assetDataUtils.decodeAssetProxyId(signedOrderLeft.makerAssetData);
if (makerAssetProxyIdLeft === AssetProxyId.ERC20) { if (makerAssetProxyIdLeft === AssetProxyId.ERC20) {
// Decode asset data // Decode asset data
const erc20AssetData = assetDataUtils.decodeERC20AssetData(signedOrderLeft.makerAssetData); const erc20AssetData = assetDataUtils.decodeERC20AssetData(signedOrderLeft.makerAssetData);
@ -268,7 +268,7 @@ export class MatchOrderTester {
} }
// Left Taker Asset (Right Maker Asset) // Left Taker Asset (Right Maker Asset)
// Note: This exchange is only between the order makers: the Taker does not receive any of the left taker asset. // Note: This exchange is only between the order makers: the Taker does not receive any of the left taker asset.
const takerAssetProxyIdLeft = assetDataUtils.decodeAssetDataId(signedOrderLeft.takerAssetData); const takerAssetProxyIdLeft = assetDataUtils.decodeAssetProxyId(signedOrderLeft.takerAssetData);
if (takerAssetProxyIdLeft === AssetProxyId.ERC20) { if (takerAssetProxyIdLeft === AssetProxyId.ERC20) {
// Decode asset data // Decode asset data
const erc20AssetData = assetDataUtils.decodeERC20AssetData(signedOrderLeft.takerAssetData); const erc20AssetData = assetDataUtils.decodeERC20AssetData(signedOrderLeft.takerAssetData);

View File

@ -100,7 +100,7 @@ export const assetDataUtils = {
* @param assetData Hex encoded assetData string to decode * @param assetData Hex encoded assetData string to decode
* @return The assetProxyId * @return The assetProxyId
*/ */
decodeAssetDataId(assetData: string): AssetProxyId { decodeAssetProxyId(assetData: string): AssetProxyId {
const encodedAssetData = ethUtil.toBuffer(assetData); const encodedAssetData = ethUtil.toBuffer(assetData);
if (encodedAssetData.byteLength < constants.SELECTOR_LENGTH) { if (encodedAssetData.byteLength < constants.SELECTOR_LENGTH) {
throw new Error( throw new Error(
@ -119,7 +119,7 @@ export const assetDataUtils = {
* @return Either a ERC20 or ERC721 assetData object * @return Either a ERC20 or ERC721 assetData object
*/ */
decodeAssetData(assetData: string): ERC20AssetData | ERC721AssetData { decodeAssetData(assetData: string): ERC20AssetData | ERC721AssetData {
const assetProxyId = assetDataUtils.decodeAssetDataId(assetData); const assetProxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (assetProxyId) { switch (assetProxyId) {
case AssetProxyId.ERC20: case AssetProxyId.ERC20:
const erc20AssetData = assetDataUtils.decodeERC20AssetData(assetData); const erc20AssetData = assetDataUtils.decodeERC20AssetData(assetData);