Fix log decoder to return correct types
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
import * as BigNumber from 'bignumber.js';
|
||||||
import {AbiType, DecodedLogArgs, DecodedArgs} from '../types';
|
import {AbiType, DecodedLogArgs, DecodedArgs} from '../types';
|
||||||
import * as SolidityCoder from 'web3/lib/solidity/coder';
|
import * as SolidityCoder from 'web3/lib/solidity/coder';
|
||||||
|
|
||||||
@@ -31,9 +32,9 @@ export class AbiDecoder {
|
|||||||
dataIndex++;
|
dataIndex++;
|
||||||
}
|
}
|
||||||
if (param.type === 'address') {
|
if (param.type === 'address') {
|
||||||
value = this.padZeros(new Web3().toBigNumber(value).toString(16));
|
value = this.padZeros(new BigNumber(value).toString(16));
|
||||||
} else if (param.type === 'uint256' || param.type === 'uint8' || param.type === 'int' ) {
|
} else if (param.type === 'uint256' || param.type === 'uint8' || param.type === 'int' ) {
|
||||||
value = new Web3().toBigNumber(value).toString(10);
|
value = new BigNumber(value);
|
||||||
}
|
}
|
||||||
decodedParams[param.name] = value;
|
decodedParams[param.name] = value;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -226,11 +226,9 @@ describe('ZeroEx library', () => {
|
|||||||
const txReceiptWithDecodedLogs = await zeroEx.awaitTransactionMinedAsync(txHash);
|
const txReceiptWithDecodedLogs = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||||
const log = txReceiptWithDecodedLogs.logs[0] as LogWithDecodedArgs;
|
const log = txReceiptWithDecodedLogs.logs[0] as LogWithDecodedArgs;
|
||||||
expect(log.event).to.be.equal('Approval');
|
expect(log.event).to.be.equal('Approval');
|
||||||
expect(log.args).to.be.deep.equal({
|
expect(log.args._owner).to.be.equal(coinbase);
|
||||||
_owner: coinbase,
|
expect(log.args._spender).to.be.equal(proxyAddress);
|
||||||
_spender: proxyAddress,
|
expect(log.args._value).to.be.bignumber.equal(zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
|
||||||
_value: zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS.toString(),
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user