From db4f1c382e3a70c3360833424a990b49271cc7f6 Mon Sep 17 00:00:00 2001 From: jacogr Date: Sat, 22 Oct 2016 09:58:50 +0200 Subject: [PATCH 1/4] format blockNumber consistently --- js/src/3rdparty/etherscan/account.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/src/3rdparty/etherscan/account.js b/js/src/3rdparty/etherscan/account.js index 596e6d9cb..cb99c22c6 100644 --- a/js/src/3rdparty/etherscan/account.js +++ b/js/src/3rdparty/etherscan/account.js @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import BigNumber from 'bignumber.js'; + const PAGE_SIZE = 25; import util from '../../api/util'; @@ -56,7 +58,7 @@ function transactions (address, page, test = false) { from: util.toChecksumAddress(tx.from), to: util.toChecksumAddress(tx.to), hash: tx.hash, - blockNumber: tx.blockNumber, + blockNumber: new BigNumber(tx.blockNumber), timeStamp: tx.timeStamp, value: tx.value }; From c312f4fb92d540643c6ea0895dec887a6d67b863 Mon Sep 17 00:00:00 2001 From: jacogr Date: Sat, 22 Oct 2016 10:21:33 +0200 Subject: [PATCH 2/4] don't attempt to map empty types --- js/src/api/util/decode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/api/util/decode.js b/js/src/api/util/decode.js index 065d516e9..f2611c7f6 100644 --- a/js/src/api/util/decode.js +++ b/js/src/api/util/decode.js @@ -73,7 +73,7 @@ export function methodToAbi (method) { const name = method.substr(0, typesStart); const types = method.substr(typesStart + 1, length - (typesStart + 1) - 1).split(','); - const inputs = types.map((_type) => { + const inputs = types.filter((_type) => _type.length).map((_type) => { const type = fromParamType(toParamType(_type)); return { type }; From 8a60ed1315f8943235a7128506e4f274f63ebbc3 Mon Sep 17 00:00:00 2001 From: jacogr Date: Sat, 22 Oct 2016 10:38:34 +0200 Subject: [PATCH 3/4] empty data is allowed --- js/src/api/util/decode.js | 16 ++++++++-------- js/src/api/util/decode.spec.js | 4 ---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/js/src/api/util/decode.js b/js/src/api/util/decode.js index f2611c7f6..2d6eee75b 100644 --- a/js/src/api/util/decode.js +++ b/js/src/api/util/decode.js @@ -42,14 +42,14 @@ export function decodeCallData (data) { export function decodeMethodInput (methodAbi, paramdata) { if (!methodAbi) { throw new Error('decodeMethodInput should receive valid method-specific ABI'); - } else if (!paramdata) { - throw new Error('decodeMethodInput should receive valid parameter input data'); - } else if (!isHex(paramdata)) { - throw new Error('Input to decodeMethodInput should be a hex value'); - } else if (paramdata.substr(0, 2) === '0x') { - return decodeMethodInput(methodAbi, paramdata.slice(2)); - } else if (paramdata.length % 64 !== 0) { - throw new Error('Parameter length in decodeMethodInput not a multiple of 64 characters'); + } else if (paramdata && paramdata.length) { + if (!isHex(paramdata)) { + throw new Error('Input to decodeMethodInput should be a hex value'); + } else if (paramdata.substr(0, 2) === '0x') { + return decodeMethodInput(methodAbi, paramdata.slice(2)); + } else if (paramdata.length % 64 !== 0) { + throw new Error('Parameter length in decodeMethodInput not a multiple of 64 characters'); + } } return new Func(methodAbi).decodeInput(paramdata).map((decoded) => decoded.value); diff --git a/js/src/api/util/decode.spec.js b/js/src/api/util/decode.spec.js index 665af6d03..70bc44bc5 100644 --- a/js/src/api/util/decode.spec.js +++ b/js/src/api/util/decode.spec.js @@ -44,10 +44,6 @@ describe('api/util/decode', () => { expect(() => decodeMethodInput(null, null)).to.throw(/should receive valid method/); }); - it('expects valid parameter data', () => { - expect(() => decodeMethodInput({}, null)).to.throw(/should receive valid parameter/); - }); - it('expect valid hex parameter data', () => { expect(() => decodeMethodInput({}, 'invalid')).to.throw(/should be a hex value/); }); From 82496ae52565a6bcd3f0d182301689e8ceeb6f7b Mon Sep 17 00:00:00 2001 From: jacogr Date: Sat, 22 Oct 2016 10:38:48 +0200 Subject: [PATCH 4/4] validate meta properly --- js/src/ui/Form/InputAddress/inputAddress.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/ui/Form/InputAddress/inputAddress.js b/js/src/ui/Form/InputAddress/inputAddress.js index 2c99dd1d1..2a6fd15b2 100644 --- a/js/src/ui/Form/InputAddress/inputAddress.js +++ b/js/src/ui/Form/InputAddress/inputAddress.js @@ -46,7 +46,7 @@ class InputAddress extends Component { const { value, text, accountsInfo, tokens } = this.props; const account = accountsInfo[value] || tokens[value]; - const hasAccount = account && !account.meta.deleted; + const hasAccount = account && (!account.meta || !account.meta.deleted); const inputValue = text && hasAccount ? account.name : value; const isEmpty = (!inputValue || inputValue.length === 0); @@ -74,7 +74,7 @@ class InputAddress extends Component { classes.push(isEmpty ? styles.inputEmpty : styles.input); const account = accountsInfo[value] || tokens[value]; - const hasAccount = account && !account.meta.deleted; + const hasAccount = account && (!account.meta || !account.meta.deleted); return (