From c0ace2530eddf2a94b0422f79e428ec62e447b01 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Thu, 28 Mar 2019 18:07:18 -0300 Subject: [PATCH 1/9] fix requesting code for txs without tx to --- .DS_Store | Bin 0 -> 6148 bytes .package.json.swp | Bin 0 -> 12288 bytes .package.swp | Bin 0 -> 4096 bytes package-lock.json | 47 +++++++++++------------------------ src/TransactionController.ts | 2 +- 5 files changed, 15 insertions(+), 34 deletions(-) create mode 100644 .DS_Store create mode 100644 .package.json.swp create mode 100644 .package.swp diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..581b153c2bf2665a6e52e9a2dd5c5fec12daf27e GIT binary patch literal 6148 zcmeHK%}T>S5Z-O0ZYp9Af_lrvTMzw__9TQ_58i}`9#qJ1-QCwe<}lN}{w?x^V_^=A>>qPTKD1 z3VUa6I`Fi89>?L_cD;+BpLNSS$8nUpLDV0~_U;}YCr{Jo7eybVG2h|6 zGm64Ex&_}Xeilba3=jjv!0IrdPe8G`I$Nfl5(C7*4;jGo!2(6JHRcNC(E$x!A9373 zL;)M$5{Q;YTVt*eMnJeq1yreAKQXvU2fwA`Y>l}>mCm?a8RpR|bNxc$a&_=qGMsT+ zA+^K+F|f!$QFY5$|4+Vu|1Ty{j~E~Z{uKk<=s2A=Y)RMFrOjcjwLp8IC>WP3oTq>x hOEJV^Dc%E>0)7h(KwD$35Ii7s5s)-cLk#>X10R;tQ1k!* literal 0 HcmV?d00001 diff --git a/.package.json.swp b/.package.json.swp new file mode 100644 index 0000000000000000000000000000000000000000..8776dd2058f1026b2b153eb78e3657c62a58e601 GIT binary patch literal 12288 zcmeHN&8sCx6|Wflb~G5XFd%mNIYCFeZ{P3t1|*uyh*>;{aZErblT>%tz1{EjSE{P# zzOUaMvdbcYzVPF|u5;>~ zQ@`_37hcEFBM%;XhhfCf16P105CNY6-uMt> zuK|At{s{aQ_!;m+;M+h3JPaHH5pW5(2;2p{{z1lG27V3v6nGx^4)82c0*?b%fjMvy z_#|*Qa69nV4>0y3@MGY+Kn`31J`LOf{O|pY{S9~tcmXJYYrqlU0k6G}u~&c>fnNeI z0M7v*2mbqB#(obx3w#~854Zv-I?0U2q`y0BOI`&^^D5;s4RpN`)h>ofKZZTcq%I1P=sd8wvNS)z0XvPpuxTD8*Vbh;nDF~So~etF8ZQFEakW9gVG znylTTc(CGpwwf?e&vYPJ7i=Xmb2MXoYWVN*Q z7a<-?l%I-5RH>+vTqqpqX_WmluJ-k|5h{^+W9glQhuCD>f<$SZ7zSVrymwS-RpgbX zxL3$+BZbzvql&U~mSC%BEX>1kuUE7RPLLiWnSi+{oOj02cXj2q!0oP-5arfJ={StJ zlv`wQTaBtZ6@gVaXxgF}jc2n_CV1Kz-H#Cipc9#+ptsh-4uJ)D+c`Z^XPahFb{*- z))k&zS=bW9bC(@22u@|LMR)2;p{9EM2JHCf)6_5FR*7poCPgh<;cA!1kLIbSSvqr- zZs++|+8Xw)suMJ5dEIG`CsDV|rLslc>k%hI<<+MTaVaWt>+|B2Z=(=oUA5@ljHJ7Drg_}S~%q59N) zpMo*u)poVph_KYEmefD{eoQqQHCUl(>Qas;INpVG(*5n1b=nrP?GQP3g(D^2{pj zOj0k!{X&0|jP&SlS$ct7d32n|ZHUTghhbO6*7B*N(7(mBR*4s!p3^2Wo$1aiX;B=F z*MIBV1U1^ZBDT4is$Cg+HlwO*Eqv$e3U@@%aGiZVL~GjT&OfD_+!Lu#?uw=pQyY@l zwy+`AdFV9YIjPGsH)^C#KU`?IQdWI?*H8^py3p15$)wC+I)3n)RY~22gcOsf2i$L% zy7KCk*A!gSDFcpED4i!>M>|%%L<+8PfqP0MtrQ;Jx}+cqa!J!Q3S!*R;lkcae#J`@CB1i#FrQ}s2jw|dMF0Q* literal 0 HcmV?d00001 diff --git a/.package.swp b/.package.swp new file mode 100644 index 0000000000000000000000000000000000000000..bb7a93a942b8a5f4078a0f60b7504c047b69c258 GIT binary patch literal 4096 zcmYc?2=nw+u+TGL00IFJ0ReNKF)*YSm!u{o=H+JQ<->%r(ykD7#k#(U$xiwC*}4Hm z`Fc6|$%#3r%IlB})Gtac$S>AUPfSYGFGx(zPE1clRXoZY4S~@RpmGTCG8h{fg0s4^ rlA?mJP$-qnA2n_?1V%$(Gz3ONU^E0qLtr!nMnhmU1V%$(FoysDiyt54 literal 0 HcmV?d00001 diff --git a/package-lock.json b/package-lock.json index 97536a2ba11..5eb2bc084bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2570,7 +2570,7 @@ "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git", + "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "ethereumjs-util": "^5.1.1" } }, @@ -3282,8 +3282,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3304,14 +3303,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3326,20 +3323,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3456,8 +3450,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3469,7 +3462,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3484,7 +3476,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3492,14 +3483,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3518,7 +3507,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3599,8 +3587,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3612,7 +3599,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3698,8 +3684,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3735,7 +3720,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3755,7 +3739,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3799,14 +3782,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -8830,7 +8811,7 @@ "resolved": "https://registry.npmjs.org/web3/-/web3-0.20.7.tgz", "integrity": "sha512-VU6/DSUX93d1fCzBz7WP/SGCQizO1rKZi4Px9j/3yRyfssHyFcZamMw2/sj4E8TlfMXONvZLoforR8B4bRoyTQ==", "requires": { - "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", + "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", @@ -8868,7 +8849,7 @@ "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git", + "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "ethereumjs-util": "^5.1.1" } }, diff --git a/src/TransactionController.ts b/src/TransactionController.ts index 56806cfc030..bc63cffb23f 100644 --- a/src/TransactionController.ts +++ b/src/TransactionController.ts @@ -579,7 +579,7 @@ export class TransactionController extends BaseController Date: Thu, 28 Mar 2019 18:08:30 -0300 Subject: [PATCH 2/9] rm files --- .DS_Store | Bin 6148 -> 0 bytes .package.json.swp | Bin 12288 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 .package.json.swp diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 581b153c2bf2665a6e52e9a2dd5c5fec12daf27e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5Z-O0ZYp9Af_lrvTMzw__9TQ_58i}`9#qJ1-QCwe<}lN}{w?x^V_^=A>>qPTKD1 z3VUa6I`Fi89>?L_cD;+BpLNSS$8nUpLDV0~_U;}YCr{Jo7eybVG2h|6 zGm64Ex&_}Xeilba3=jjv!0IrdPe8G`I$Nfl5(C7*4;jGo!2(6JHRcNC(E$x!A9373 zL;)M$5{Q;YTVt*eMnJeq1yreAKQXvU2fwA`Y>l}>mCm?a8RpR|bNxc$a&_=qGMsT+ zA+^K+F|f!$QFY5$|4+Vu|1Ty{j~E~Z{uKk<=s2A=Y)RMFrOjcjwLp8IC>WP3oTq>x hOEJV^Dc%E>0)7h(KwD$35Ii7s5s)-cLk#>X10R;tQ1k!* diff --git a/.package.json.swp b/.package.json.swp deleted file mode 100644 index 8776dd2058f1026b2b153eb78e3657c62a58e601..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeHN&8sCx6|Wflb~G5XFd%mNIYCFeZ{P3t1|*uyh*>;{aZErblT>%tz1{EjSE{P# zzOUaMvdbcYzVPF|u5;>~ zQ@`_37hcEFBM%;XhhfCf16P105CNY6-uMt> zuK|At{s{aQ_!;m+;M+h3JPaHH5pW5(2;2p{{z1lG27V3v6nGx^4)82c0*?b%fjMvy z_#|*Qa69nV4>0y3@MGY+Kn`31J`LOf{O|pY{S9~tcmXJYYrqlU0k6G}u~&c>fnNeI z0M7v*2mbqB#(obx3w#~854Zv-I?0U2q`y0BOI`&^^D5;s4RpN`)h>ofKZZTcq%I1P=sd8wvNS)z0XvPpuxTD8*Vbh;nDF~So~etF8ZQFEakW9gVG znylTTc(CGpwwf?e&vYPJ7i=Xmb2MXoYWVN*Q z7a<-?l%I-5RH>+vTqqpqX_WmluJ-k|5h{^+W9glQhuCD>f<$SZ7zSVrymwS-RpgbX zxL3$+BZbzvql&U~mSC%BEX>1kuUE7RPLLiWnSi+{oOj02cXj2q!0oP-5arfJ={StJ zlv`wQTaBtZ6@gVaXxgF}jc2n_CV1Kz-H#Cipc9#+ptsh-4uJ)D+c`Z^XPahFb{*- z))k&zS=bW9bC(@22u@|LMR)2;p{9EM2JHCf)6_5FR*7poCPgh<;cA!1kLIbSSvqr- zZs++|+8Xw)suMJ5dEIG`CsDV|rLslc>k%hI<<+MTaVaWt>+|B2Z=(=oUA5@ljHJ7Drg_}S~%q59N) zpMo*u)poVph_KYEmefD{eoQqQHCUl(>Qas;INpVG(*5n1b=nrP?GQP3g(D^2{pj zOj0k!{X&0|jP&SlS$ct7d32n|ZHUTghhbO6*7B*N(7(mBR*4s!p3^2Wo$1aiX;B=F z*MIBV1U1^ZBDT4is$Cg+HlwO*Eqv$e3U@@%aGiZVL~GjT&OfD_+!Lu#?uw=pQyY@l zwy+`AdFV9YIjPGsH)^C#KU`?IQdWI?*H8^py3p15$)wC+I)3n)RY~22gcOsf2i$L% zy7KCk*A!gSDFcpED4i!>M>|%%L<+8PfqP0MtrQ;Jx}+cqa!J!Q3S!*R;lkcae#J`@CB1i#FrQ}s2jw|dMF0Q* From 947d5b5a6e90786976f2bc343ac357458b1f06ad Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 29 Mar 2019 16:17:09 -0300 Subject: [PATCH 3/9] handle method data wothout saving in state --- .package.swp | Bin 4096 -> 0 bytes package-lock.json | 209 +++++++++++++++++++++++++++++++++-- package.json | 1 + src/TransactionController.ts | 39 ++++++- 4 files changed, 237 insertions(+), 12 deletions(-) delete mode 100644 .package.swp diff --git a/.package.swp b/.package.swp deleted file mode 100644 index bb7a93a942b8a5f4078a0f60b7504c047b69c258..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4096 zcmYc?2=nw+u+TGL00IFJ0ReNKF)*YSm!u{o=H+JQ<->%r(ykD7#k#(U$xiwC*}4Hm z`Fc6|$%#3r%IlB})Gtac$S>AUPfSYGFGx(zPE1clRXoZY4S~@RpmGTCG8h{fg0s4^ rlA?mJP$-qnA2n_?1V%$(Gz3ONU^E0qLtr!nMnhmU1V%$(FoysDiyt54 diff --git a/package-lock.json b/package-lock.json index 5eb2bc084bc..22ba21e9724 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1509,10 +1509,6 @@ } } }, - "bignumber.js": { - "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", - "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git" - }, "bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -2570,8 +2566,33 @@ "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "ethereumjs-util": "^5.1.1" + }, + "dependencies": { + "ethereumjs-abi": { + "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", + "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", + "requires": { + "bn.js": "^4.11.8", + "ethereumjs-util": "^6.0.0" + }, + "dependencies": { + "ethereumjs-util": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz", + "integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==", + "requires": { + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "ethjs-util": "0.1.6", + "keccak": "^1.0.2", + "rlp": "^2.0.0", + "safe-buffer": "^5.1.1", + "secp256k1": "^3.0.1" + } + } + } + } } }, "ethereumjs-abi": { @@ -2600,6 +2621,13 @@ } } }, + "eth-method-registry": { + "version": "github:estebanmino/eth-method-registry#d5796eb145dcc3db120b7f6566519dd08d6bfb3b", + "from": "github:estebanmino/eth-method-registry#master", + "requires": { + "ethjs": "^0.3.0" + } + }, "eth-phishing-detect": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/eth-phishing-detect/-/eth-phishing-detect-1.1.13.tgz", @@ -2874,6 +2902,123 @@ } } }, + "ethjs": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/ethjs/-/ethjs-0.3.9.tgz", + "integrity": "sha512-gOQzA3tDUjoLpNONSOALJ/rUFtHi5tXl2mholHasF1cvXhoddqi06yU4OJFJu9AGd6n9v9ywzHlYeIKg1t1hdw==", + "requires": { + "bn.js": "4.11.6", + "ethjs-abi": "0.2.1", + "ethjs-contract": "0.2.2", + "ethjs-filter": "0.1.8", + "ethjs-provider-http": "0.1.6", + "ethjs-query": "0.3.7", + "ethjs-unit": "0.1.6", + "ethjs-util": "0.1.3", + "js-sha3": "0.5.5", + "number-to-bn": "1.7.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + }, + "ethjs-query": { + "version": "0.3.7", + "resolved": "https://registry.npmjs.org/ethjs-query/-/ethjs-query-0.3.7.tgz", + "integrity": "sha512-TZnKUwfkWjy0SowFdPLtmsytCorHi0i4vvkQn7Jg8rZt33cRzKhuzOwKr/G3vdigCc+ePXOhUGMcJSAPlOG44A==", + "requires": { + "ethjs-format": "0.2.7", + "ethjs-rpc": "0.2.0", + "promise-to-callback": "^1.0.0" + } + }, + "ethjs-util": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.3.tgz", + "integrity": "sha1-39XqSkANxeQhqInK9H4IGtp4u1U=", + "requires": { + "is-hex-prefixed": "1.0.0", + "strip-hex-prefix": "1.0.0" + } + }, + "js-sha3": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz", + "integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=" + } + } + }, + "ethjs-abi": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.1.tgz", + "integrity": "sha1-4KepOn6BFjqUR3utVu3lJKtt5TM=", + "requires": { + "bn.js": "4.11.6", + "js-sha3": "0.5.5", + "number-to-bn": "1.7.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + }, + "js-sha3": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz", + "integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=" + } + } + }, + "ethjs-contract": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/ethjs-contract/-/ethjs-contract-0.2.2.tgz", + "integrity": "sha512-xxPqEjsULQ/QNWuvX6Ako0PGs5RxALA8N/H3+boLvnaXDFZVGpD7H63H1gBCRTZyYqCldPpVlVHuw/rD45vazw==", + "requires": { + "ethjs-abi": "0.2.0", + "ethjs-filter": "0.1.8", + "ethjs-util": "0.1.3", + "js-sha3": "0.5.5" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + }, + "ethjs-abi": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.0.tgz", + "integrity": "sha1-0+LCIQEVIPxJm3FoIDbBT8wvWyU=", + "requires": { + "bn.js": "4.11.6", + "js-sha3": "0.5.5", + "number-to-bn": "1.7.0" + } + }, + "ethjs-util": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.3.tgz", + "integrity": "sha1-39XqSkANxeQhqInK9H4IGtp4u1U=", + "requires": { + "is-hex-prefixed": "1.0.0", + "strip-hex-prefix": "1.0.0" + } + }, + "js-sha3": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz", + "integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=" + } + } + }, + "ethjs-filter": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/ethjs-filter/-/ethjs-filter-0.1.8.tgz", + "integrity": "sha512-qTDPskDL2UadHwjvM8A+WG9HwM4/FoSY3p3rMJORkHltYcAuiQZd2otzOYKcL5w2Q3sbAkW/E3yt/FPFL/AVXA==" + }, "ethjs-format": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/ethjs-format/-/ethjs-format-0.2.7.tgz", @@ -2907,7 +3052,6 @@ "version": "0.1.6", "resolved": "https://registry.npmjs.org/ethjs-provider-http/-/ethjs-provider-http-0.1.6.tgz", "integrity": "sha1-HsXZtL4lfvHValALIqdBmF6IlCA=", - "dev": true, "requires": { "xhr2": "0.1.3" } @@ -2936,6 +3080,22 @@ "resolved": "https://registry.npmjs.org/ethjs-schema/-/ethjs-schema-0.2.1.tgz", "integrity": "sha512-DXd8lwNrhT9sjsh/Vd2Z+4pfyGxhc0POVnLBUfwk5udtdoBzADyq+sK39dcb48+ZU+2VgtwHxtGWnLnCfmfW5g==" }, + "ethjs-unit": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz", + "integrity": "sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk=", + "requires": { + "bn.js": "4.11.6", + "number-to-bn": "1.7.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + } + } + }, "ethjs-util": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz", @@ -8811,11 +8971,16 @@ "resolved": "https://registry.npmjs.org/web3/-/web3-0.20.7.tgz", "integrity": "sha512-VU6/DSUX93d1fCzBz7WP/SGCQizO1rKZi4Px9j/3yRyfssHyFcZamMw2/sj4E8TlfMXONvZLoforR8B4bRoyTQ==", "requires": { - "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", "xmlhttprequest": "*" + }, + "dependencies": { + "bignumber.js": { + "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", + "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934" + } } }, "web3-provider-engine": { @@ -8849,8 +9014,33 @@ "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "ethereumjs-util": "^5.1.1" + }, + "dependencies": { + "ethereumjs-abi": { + "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", + "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", + "requires": { + "bn.js": "^4.11.8", + "ethereumjs-util": "^6.0.0" + }, + "dependencies": { + "ethereumjs-util": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz", + "integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==", + "requires": { + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "ethjs-util": "0.1.6", + "keccak": "^1.0.2", + "rlp": "^2.0.0", + "safe-buffer": "^5.1.1", + "secp256k1": "^3.0.1" + } + } + } + } } }, "ethereumjs-abi": { @@ -9007,8 +9197,7 @@ "xhr2": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.1.3.tgz", - "integrity": "sha1-y/xHWaabSoiOeM9PILBRA4dXvRE=", - "dev": true + "integrity": "sha1-y/xHWaabSoiOeM9PILBRA4dXvRE=" }, "xhr2-cookies": { "version": "1.1.0", diff --git a/package.json b/package.json index b6368f6026b..ac7b1e08ddf 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "eth-contract-metadata": "github:MetaMask/eth-contract-metadata#faa4f56fb17b3ae8579df68708be59d617732f31", "eth-json-rpc-infura": "^3.1.2", "eth-keyring-controller": "^4.0.0", + "eth-method-registry": "github:estebanmino/eth-method-registry#master", "eth-phishing-detect": "^1.1.13", "eth-query": "^2.1.2", "eth-sig-util": "^2.1.0", diff --git a/src/TransactionController.ts b/src/TransactionController.ts index bc63cffb23f..3c594e80571 100644 --- a/src/TransactionController.ts +++ b/src/TransactionController.ts @@ -10,7 +10,7 @@ import { validateTransaction, isSmartContractCode } from './util'; - +const MethodRegistry = require('eth-method-registry'); const EthQuery = require('eth-query'); const Transaction = require('ethereumjs-tx'); const random = require('uuid/v1'); @@ -143,6 +143,11 @@ export interface TransactionConfig extends BaseConfig { sign?: (transaction: Transaction, from: string) => Promise; } +export interface MethodData { + registryMethod: string; + parsedRegistryMethod: string; +} + /** * @type TransactionState * @@ -152,6 +157,7 @@ export interface TransactionConfig extends BaseConfig { */ export interface TransactionState extends BaseState { transactions: TransactionMeta[]; + methodData: { [key: string]: MethodData }; } /** @@ -159,6 +165,7 @@ export interface TransactionState extends BaseState { */ export class TransactionController extends BaseController { private ethQuery: any; + private registry: any; private handle?: NodeJS.Timer; private failTransaction(transactionMeta: TransactionMeta, error: Error) { @@ -183,6 +190,12 @@ export class TransactionController extends BaseController { + const registryMethod = await this.registry.lookup(fourBytePrefix); + const parsedRegistryMethod = this.registry.parse(registryMethod); + return { registryMethod, parsedRegistryMethod }; + } + /** * Normalizes the transaction information from etherscan * to be compatible with the TransactionMeta interface @@ -246,7 +259,10 @@ export class TransactionController extends BaseController { + const { methodData } = this.state; + const knownMethod = fourBytePrefix in Object.keys(methodData); + if (knownMethod) { + return methodData[fourBytePrefix]; + } + const registry = await this.registryLookup(fourBytePrefix); + this.update({ methodData: { ...methodData, ...{ [fourBytePrefix]: registry } } }); + return registry; + } + /** * Add a new unapproved transaction to state. Parameters will be validated, a * unique transaction id will be generated, and gas and gasPrice will be calculated @@ -432,6 +464,9 @@ export class TransactionController extends BaseController { this.ethQuery = network.provider ? new EthQuery(network.provider) : /* istanbul ignore next */ null; + this.registry = network.provider + ? new MethodRegistry({ provider: network.provider }) /* istanbul ignore next */ + : null; }; onProviderUpdate(); network.subscribe(onProviderUpdate); From 37fcdf2b0c98e53f515a2077a1e1abf7b9c708dc Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Fri, 29 Mar 2019 18:47:10 -0300 Subject: [PATCH 4/9] add test --- src/TransactionController.test.ts | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/TransactionController.test.ts b/src/TransactionController.test.ts index 24d46ee8894..390b165d3be 100644 --- a/src/TransactionController.test.ts +++ b/src/TransactionController.test.ts @@ -48,6 +48,7 @@ function mockFetch(data: any) { const HttpProvider = require('ethjs-provider-http'); const MOCK_PRFERENCES = { state: { selectedAddress: 'foo' } }; const PROVIDER = new HttpProvider('https://ropsten.infura.io'); +const MAINNET_PROVIDER = new HttpProvider('https://mainnet.infura.io'); const MOCK_NETWORK = { provider: PROVIDER, state: { network: '3', provider: { type: 'ropsten' } }, @@ -55,6 +56,13 @@ const MOCK_NETWORK = { /* eslint-disable-line no-empty */ } }; +const MOCK_MAINNET_NETWORK = { + provider: MAINNET_PROVIDER, + state: { network: '1', provider: { type: 'mainnet' } }, + subscribe: () => { + /* eslint-disable-line no-empty */ + } +}; const MOCK_FETCH_TX_HISTORY_DATA_OK = { message: 'OK', @@ -132,7 +140,7 @@ describe('TransactionController', () => { it('should set default state', () => { const controller = new TransactionController(); - expect(controller.state).toEqual({ transactions: [] }); + expect(controller.state).toEqual({ methodData: {}, transactions: [] }); }); it('should set default config', () => { @@ -351,7 +359,6 @@ describe('TransactionController', () => { controller.approveTransaction(controller.state.transactions[0].id); }); }); - it('should query transaction statuses', () => { return new Promise((resolve) => { const controller = new TransactionController({ @@ -410,4 +417,19 @@ describe('TransactionController', () => { expect(controller.state.transactions.length).toBe(0); expect(result).toBe(undefined); }); + + it('should handle new method data', async () => { + const controller = new TransactionController({ provider: MOCK_MAINNET_NETWORK }); + controller.context = { + NetworkController: MOCK_MAINNET_NETWORK + } as any; + controller.onComposed(); + + const registry = await controller.handleMethodData('0xf39b5b9b'); + expect(registry.parsedRegistryMethod).toEqual({ + args: [{ type: 'uint256' }, { type: 'uint256' }], + name: 'Eth To Token Swap Input' + }); + expect(registry.registryMethod).toEqual('ethToTokenSwapInput(uint256,uint256)'); + }); }); From f8e719c7ecefc44daa4753acefa11faf7225b580 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 1 Apr 2019 12:00:16 -0300 Subject: [PATCH 5/9] fix race condition --- src/TransactionController.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/TransactionController.ts b/src/TransactionController.ts index 3c594e80571..7e89e62f328 100644 --- a/src/TransactionController.ts +++ b/src/TransactionController.ts @@ -15,6 +15,7 @@ const EthQuery = require('eth-query'); const Transaction = require('ethereumjs-tx'); const random = require('uuid/v1'); const { addHexPrefix, bufferToHex, BN } = require('ethereumjs-util'); +const Mutex = require('await-semaphore').Mutex; /** * @type Result @@ -167,6 +168,7 @@ export class TransactionController extends BaseController { + const releaseLock = await this.mutex.acquire(); const { methodData } = this.state; - const knownMethod = fourBytePrefix in Object.keys(methodData); + const knownMethod = Object.keys(methodData).includes(fourBytePrefix); if (knownMethod) { + releaseLock(); return methodData[fourBytePrefix]; } const registry = await this.registryLookup(fourBytePrefix); this.update({ methodData: { ...methodData, ...{ [fourBytePrefix]: registry } } }); + releaseLock(); return registry; } From b7c7d9515686ff390139e384de4517d362104c38 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 1 Apr 2019 12:07:03 -0300 Subject: [PATCH 6/9] fix includeS --- src/TransactionController.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/TransactionController.ts b/src/TransactionController.ts index 7e89e62f328..f03d85a64df 100644 --- a/src/TransactionController.ts +++ b/src/TransactionController.ts @@ -289,7 +289,9 @@ export class TransactionController extends BaseController { const releaseLock = await this.mutex.acquire(); const { methodData } = this.state; - const knownMethod = Object.keys(methodData).includes(fourBytePrefix); + const knownMethod = Object.keys(methodData).find( + (knownFourBytePrefix) => fourBytePrefix === knownFourBytePrefix + ); if (knownMethod) { releaseLock(); return methodData[fourBytePrefix]; From af231b2dc3783c0f8c88a39fc2eda821e930e98c Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 1 Apr 2019 12:14:09 -0300 Subject: [PATCH 7/9] tests --- src/TransactionController.test.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/TransactionController.test.ts b/src/TransactionController.test.ts index 0a62ee25f9f..6738530e26b 100644 --- a/src/TransactionController.test.ts +++ b/src/TransactionController.test.ts @@ -443,7 +443,6 @@ describe('TransactionController', () => { NetworkController: MOCK_MAINNET_NETWORK } as any; controller.onComposed(); - const registry = await controller.handleMethodData('0xf39b5b9b'); expect(registry.parsedRegistryMethod).toEqual({ args: [{ type: 'uint256' }, { type: 'uint256' }], @@ -451,4 +450,20 @@ describe('TransactionController', () => { }); expect(registry.registryMethod).toEqual('ethToTokenSwapInput(uint256,uint256)'); }); + + it('should handle known method data', async () => { + const controller = new TransactionController({ provider: MOCK_MAINNET_NETWORK }); + controller.context = { + NetworkController: MOCK_MAINNET_NETWORK + } as any; + controller.onComposed(); + const registry = await controller.handleMethodData('0xf39b5b9b'); + expect(registry.parsedRegistryMethod).toEqual({ + args: [{ type: 'uint256' }, { type: 'uint256' }], + name: 'Eth To Token Swap Input' + }); + const registryLookup = stub(controller, 'registryLookup' as any); + await controller.handleMethodData('0xf39b5b9b'); + expect(registryLookup.called).toBe(false); + }); }); From a7cf5603da571c81e73b17e3a8deb583e786900e Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 1 Apr 2019 14:14:13 -0300 Subject: [PATCH 8/9] add missing doc --- src/TransactionController.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/TransactionController.ts b/src/TransactionController.ts index b10b1017762..fdbadb1b4d9 100644 --- a/src/TransactionController.ts +++ b/src/TransactionController.ts @@ -144,9 +144,17 @@ export interface TransactionConfig extends BaseConfig { sign?: (transaction: Transaction, from: string) => Promise; } +/** + * @type MethodData + * + * Method data registry object + * + * @property registryMethod - Registry method raw string + * @property parsedRegistryMethod - Registry method object, containing name and method arguments + */ export interface MethodData { registryMethod: string; - parsedRegistryMethod: string; + parsedRegistryMethod: object; } /** @@ -155,6 +163,7 @@ export interface MethodData { * Transaction controller state * * @property transactions - A list of TransactionMeta objects + * @property methodData - Object containing all known method data information */ export interface TransactionState extends BaseState { transactions: TransactionMeta[]; @@ -287,6 +296,7 @@ export class TransactionController extends BaseController { const releaseLock = await this.mutex.acquire(); From 4f8b6cc0e5ffc652250833c7ec50a37e0527e7b7 Mon Sep 17 00:00:00 2001 From: Esteban Mino Date: Mon, 1 Apr 2019 15:09:29 -0300 Subject: [PATCH 9/9] use npm eth-method-registry --- package-lock.json | 22 ++++++++++++---------- package.json | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e2980ef733..a4cbc316777 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1509,6 +1509,10 @@ } } }, + "bignumber.js": { + "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", + "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git" + }, "bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -2566,12 +2570,13 @@ "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "requires": { + "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "ethereumjs-util": "^5.1.1" }, "dependencies": { "ethereumjs-abi": { "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", - "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", + "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git", "requires": { "bn.js": "^4.11.8", "ethereumjs-util": "^6.0.0" @@ -2622,8 +2627,9 @@ } }, "eth-method-registry": { - "version": "github:estebanmino/eth-method-registry#d5796eb145dcc3db120b7f6566519dd08d6bfb3b", - "from": "github:estebanmino/eth-method-registry#master", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eth-method-registry/-/eth-method-registry-1.1.0.tgz", + "integrity": "sha512-jGbbGYd19XJCtoGFtUD2qJYWefKCCbFcu7F/AQ5sJXvqTIVAHnFn3paaV2zhN5t7iyKYp1qxc+ugOky+72xcbg==", "requires": { "ethjs": "^0.3.0" } @@ -8971,16 +8977,11 @@ "resolved": "https://registry.npmjs.org/web3/-/web3-0.20.7.tgz", "integrity": "sha512-VU6/DSUX93d1fCzBz7WP/SGCQizO1rKZi4Px9j/3yRyfssHyFcZamMw2/sj4E8TlfMXONvZLoforR8B4bRoyTQ==", "requires": { + "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", "xmlhttprequest": "*" - }, - "dependencies": { - "bignumber.js": { - "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", - "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934" - } } }, "web3-provider-engine": { @@ -9014,12 +9015,13 @@ "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "requires": { + "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "ethereumjs-util": "^5.1.1" }, "dependencies": { "ethereumjs-abi": { "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", - "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", + "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git", "requires": { "bn.js": "^4.11.8", "ethereumjs-util": "^6.0.0" diff --git a/package.json b/package.json index c4ba1597ee4..fa241169fb5 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "eth-contract-metadata": "github:MetaMask/eth-contract-metadata#faa4f56fb17b3ae8579df68708be59d617732f31", "eth-json-rpc-infura": "^3.1.2", "eth-keyring-controller": "^4.0.0", - "eth-method-registry": "github:estebanmino/eth-method-registry#master", + "eth-method-registry": "1.1.0", "eth-phishing-detect": "^1.1.13", "eth-query": "^2.1.2", "eth-sig-util": "^2.1.0",