aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-07 03:32:29 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:10 +0800
commita1cff862c979d013f3f56af55c324fe38b588473 (patch)
treeffc07d3f825f63e8dfa1a4b8768cf0d37930bd03 /packages
parent79126f3b4a83d9cf58e5a7935051820ae5e1a8e0 (diff)
downloaddexon-0x-contracts-a1cff862c979d013f3f56af55c324fe38b588473.tar
dexon-0x-contracts-a1cff862c979d013f3f56af55c324fe38b588473.tar.gz
dexon-0x-contracts-a1cff862c979d013f3f56af55c324fe38b588473.tar.bz2
dexon-0x-contracts-a1cff862c979d013f3f56af55c324fe38b588473.tar.lz
dexon-0x-contracts-a1cff862c979d013f3f56af55c324fe38b588473.tar.xz
dexon-0x-contracts-a1cff862c979d013f3f56af55c324fe38b588473.tar.zst
dexon-0x-contracts-a1cff862c979d013f3f56af55c324fe38b588473.zip
Fixed width parsing for UINT
Diffstat (limited to 'packages')
-rw-r--r--packages/order-utils/test/abi_encoder_test.ts43
1 files changed, 26 insertions, 17 deletions
diff --git a/packages/order-utils/test/abi_encoder_test.ts b/packages/order-utils/test/abi_encoder_test.ts
index 87e1e7fba..f6f7fd93e 100644
--- a/packages/order-utils/test/abi_encoder_test.ts
+++ b/packages/order-utils/test/abi_encoder_test.ts
@@ -13,22 +13,24 @@ import { MethodAbi, DataItem } from 'ethereum-types';
import { BigNumber } from '@0x/utils';
const simpleAbi = {
- name: 'SimpleAbi',
+ constant: false,
inputs: [
{
- components: [
- {
- name: 'greg',
- type: 'uint256',
- },
- {
- name: 'gregStr',
- type: 'string',
- },
- ],
+ name: 'greg',
+ type: 'uint208',
+ },
+ {
+ name: 'gregStr',
+ type: 'string',
},
],
+ name: 'simpleFunction',
+ outputs: [],
+ payable: false,
+ stateMutability: 'nonpayable',
+ type: 'function',
} as MethodAbi;
+
const fillOrderAbi = {
constant: false,
inputs: [
@@ -198,7 +200,7 @@ namespace AbiEncoder {
super(dataItem);
const matches = Byte.matcher.exec(dataItem.type);
expect(matches).to.be.not.null();
- if (matches !== null && matches.length === 1) {
+ if (matches !== null && matches.length === 2) {
this.width = new BigNumber(matches[1], 10);
}
}
@@ -218,16 +220,20 @@ namespace AbiEncoder {
'^uint(8|16|24|32|40|48|56|64|72|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256){0,1}$',
);
- static DEFAULT_WIDTH: number = 1;
+ static DEFAULT_WIDTH: number = 256;
width: number = UInt.DEFAULT_WIDTH;
constructor(dataItem: DataItem) {
super(dataItem);
- const matches = Byte.matcher.exec(dataItem.type);
+ const matches = UInt.matcher.exec(dataItem.type);
expect(matches).to.be.not.null();
- if (matches !== null && matches.length === 1) {
+ console.log(JSON.stringify(matches));
+ if (matches !== null && matches.length === 2) {
this.width = parseInt(matches[1]);
+ } else {
+ this.width = 256;
}
+ console.log('Width = ' + this.width);
}
public getMaxValue() {
@@ -262,7 +268,7 @@ namespace AbiEncoder {
super(dataItem);
const matches = Byte.matcher.exec(dataItem.type);
expect(matches).to.be.not.null();
- if (matches !== null && matches.length === 1) {
+ if (matches !== null && matches.length === 2) {
this.width = new BigNumber(matches[1], 10);
}
}
@@ -377,6 +383,8 @@ namespace AbiEncoder {
class DataTypeFactory {
public static mapDataItemToDataType(dataItem: DataItem): DataType {
+ console.log(`Type: ${dataItem.type}`);
+
if (SolArray.matchGrammar(dataItem.type)) return new SolArray(dataItem);
if (Address.matchGrammar(dataItem.type)) return new Address(dataItem);
if (Bool.matchGrammar(dataItem.type)) return new Bool(dataItem);
@@ -415,7 +423,8 @@ namespace AbiEncoder {
this.name = abi.name;
this.params = [];
- _.each(abi.inputs, function(this: Method, input: DataItem) {
+ _.each(abi.inputs, (input: DataItem) => {
+ console.log('--input--\n', input, '--end input--');
this.params.push(DataTypeFactory.create(input));
});
}