remove web3 dependency

This commit is contained in:
yenda 2019-09-06 13:17:49 +02:00 committed by Pedro Pombeiro
parent 69819df39a
commit f538cfe848
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
14 changed files with 13 additions and 161 deletions

View File

@ -4,7 +4,8 @@
:figwheel-bridge "./figwheel-bridge.js" :figwheel-bridge "./figwheel-bridge.js"
;; JS modules ;; JS modules
:js-modules ["react-native-languages" :js-modules ["bignumber.js"
"react-native-languages"
"i18n-js" "i18n-js"
"dismissKeyboard" "dismissKeyboard"
"react-native-splash-screen" "react-native-splash-screen"
@ -22,7 +23,6 @@
"react-native-webview-bridge" "react-native-webview-bridge"
"react-native-firebase" "react-native-firebase"
"react-native-touch-id" "react-native-touch-id"
"web3"
"web3-utils" "web3-utils"
"chance" "chance"
"react-native-http-bridge" "react-native-http-bridge"
@ -45,7 +45,8 @@
"react-native-shake" "react-native-shake"
"@react-native-community/netinfo"] "@react-native-community/netinfo"]
;; Desktop modules ;; Desktop modules
:desktop-modules ["react-native-languages" :desktop-modules ["bignumber.js"
"react-native-languages"
"i18n-js" "i18n-js"
"dismissKeyboard" "dismissKeyboard"
"react-native-splash-screen" "react-native-splash-screen"
@ -57,7 +58,6 @@
"react-native-image-crop-picker" "react-native-image-crop-picker"
"react-native-securerandom" "react-native-securerandom"
"react-native-webview-bridge" "react-native-webview-bridge"
"web3"
"chance" "chance"
"react-native-http-bridge" "react-native-http-bridge"
"emojilib" "emojilib"

View File

@ -85,7 +85,6 @@
"react-navigation": "^2.12.1", "react-navigation": "^2.12.1",
"status-conan": "git+https://github.com/status-im/status-conan.git#v1.0.0", "status-conan": "git+https://github.com/status-im/status-conan.git#v1.0.0",
"url": "0.10.3", "url": "0.10.3",
"web3": "git+https://github.com/status-im/web3.js.git#0.20.3-status.alpha.3",
"web3-utils": "1.0.0-beta.36" "web3-utils": "1.0.0-beta.36"
}, },
"devDependencies": { "devDependencies": {

View File

@ -7878,16 +7878,6 @@ web3-utils@1.0.0-beta.36:
underscore "1.8.3" underscore "1.8.3"
utf8 "2.1.1" utf8 "2.1.1"
"web3@git+https://github.com/status-im/web3.js.git#0.20.3-status.alpha.3":
version "0.20.1"
resolved "git+https://github.com/status-im/web3.js.git#29677754c8b87c55c828df2694e35b0b760dca5f"
dependencies:
bignumber.js "git+https://github.com/status-im/bignumber.js.git#v4.0.2-status"
crypto-js "^3.1.4"
utf8 "^2.1.1"
xhr2 "*"
xmlhttprequest "*"
whatwg-fetch@>=0.10.0: whatwg-fetch@>=0.10.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb"

View File

@ -23,6 +23,7 @@ var TopLevel = {
"back" : function () {}, "back" : function () {},
"balanceOf" : function () {}, "balanceOf" : function () {},
"bezier" : function () {}, "bezier" : function () {},
"BigNumber" : function () {},
"blur" : function () {}, "blur" : function () {},
"button" : function () {}, "button" : function () {},
"bytesToHex" : function () {}, "bytesToHex" : function () {},
@ -489,7 +490,6 @@ var TopLevel = {
"timing" : function () {}, "timing" : function () {},
"title" : function () {}, "title" : function () {},
"toAscii" : function () {}, "toAscii" : function () {},
"toBigNumber" : function () {},
"toChecksumAddress" : function () {}, "toChecksumAddress" : function () {},
"toFixed" : function () {}, "toFixed" : function () {},
"toHex" : function () {}, "toHex" : function () {},
@ -519,7 +519,6 @@ var TopLevel = {
"vibrate" : function () {}, "vibrate" : function () {},
"View" : function () {}, "View" : function () {},
"warn" : function () {}, "warn" : function () {},
"Web3" : function () {},
"WebView" : function () {}, "WebView" : function () {},
"WebViewBridgeModule" : function () {}, "WebViewBridgeModule" : function () {},
"width" : function () {}, "width" : function () {},

View File

@ -26,11 +26,11 @@
"react-native-background-timer": "^2.1.1", "react-native-background-timer": "^2.1.1",
"react-native-camera": "git+https://github.com/status-im/react-native-camera.git#v1.1.5-1-status", "react-native-camera": "git+https://github.com/status-im/react-native-camera.git#v1.1.5-1-status",
"react-native-config": "git+https://github.com/status-im/react-native-config.git#0.11.2-1", "react-native-config": "git+https://github.com/status-im/react-native-config.git#0.11.2-1",
"react-native-gesture-handler": "1.3.0",
"react-native-dialogs": "^1.0.5", "react-native-dialogs": "^1.0.5",
"react-native-fetch-polyfill": "^1.1.3", "react-native-fetch-polyfill": "^1.1.3",
"react-native-firebase": "5.1.1", "react-native-firebase": "5.1.1",
"react-native-fs": "^2.14.1", "react-native-fs": "^2.14.1",
"react-native-gesture-handler": "1.3.0",
"react-native-http-bridge": "^0.6.1", "react-native-http-bridge": "^0.6.1",
"react-native-image-crop-picker": "^0.18.2", "react-native-image-crop-picker": "^0.18.2",
"react-native-image-resizer": "git+https://github.com/status-im/react-native-image-resizer.git#1.0.0-1-status", "react-native-image-resizer": "git+https://github.com/status-im/react-native-image-resizer.git#1.0.0-1-status",
@ -50,7 +50,6 @@
"react-native-touch-id": "^4.4.1", "react-native-touch-id": "^4.4.1",
"react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#fix/classnames-colision", "react-native-webview-bridge": "git+https://github.com/status-im/react-native-webview-bridge.git#fix/classnames-colision",
"react-navigation": "3.11.0", "react-navigation": "3.11.0",
"web3": "git+https://github.com/status-im/web3.js.git#0.20.3-status.alpha.3",
"web3-utils": "^1.2.1" "web3-utils": "^1.2.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1877,11 +1877,6 @@ cross-spawn@^6.0.0:
shebang-command "^1.2.0" shebang-command "^1.2.0"
which "^1.2.9" which "^1.2.9"
crypto-js@^3.1.4:
version "3.1.8"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.1.8.tgz#715f070bf6014f2ae992a98b3929258b713f08d5"
integrity sha1-cV8HC/YBTyrpkqmLOSkli3E/CNU=
d64@^1.0.0: d64@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/d64/-/d64-1.0.0.tgz#4002a87e850cbfc9f9d9706b60fca613a3336e90" resolved "https://registry.yarnpkg.com/d64/-/d64-1.0.0.tgz#4002a87e850cbfc9f9d9706b60fca613a3336e90"
@ -6213,16 +6208,6 @@ web3-utils@^1.2.1:
underscore "1.9.1" underscore "1.9.1"
utf8 "3.0.0" utf8 "3.0.0"
"web3@git+https://github.com/status-im/web3.js.git#0.20.3-status.alpha.3":
version "0.20.1"
resolved "git+https://github.com/status-im/web3.js.git#29677754c8b87c55c828df2694e35b0b760dca5f"
dependencies:
bignumber.js "git+https://github.com/status-im/bignumber.js.git#v4.0.2-status"
crypto-js "^3.1.4"
utf8 "^2.1.1"
xhr2 "*"
xmlhttprequest "*"
whatwg-fetch@>=0.10.0: whatwg-fetch@>=0.10.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb"
@ -6342,11 +6327,6 @@ xhr-request@^1.0.1:
url-set-query "^1.0.0" url-set-query "^1.0.0"
xhr "^2.0.4" xhr "^2.0.4"
xhr2@*:
version "0.2.0"
resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.2.0.tgz#eddeff782f3b7551061b8d75645085269396e521"
integrity sha512-BDtiD0i2iKPK/S8OAZfpk6tyzEDnKKSjxWHcMBVmh+LuqJ8A32qXTyOx+TVOg2dKvq6zGBq2sgKPkEeRs1qTRA==
xhr@^2.0.4: xhr@^2.0.4:
version "2.5.0" version "2.5.0"
resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.5.0.tgz#bed8d1676d5ca36108667692b74b316c496e49dd" resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.5.0.tgz#bed8d1676d5ca36108667692b74b316c496e49dd"
@ -6374,11 +6354,6 @@ xmldom@0.1.x:
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9" resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9"
integrity sha1-1QH5ezvbQDr4757MIFcxh6rawOk= integrity sha1-1QH5ezvbQDr4757MIFcxh6rawOk=
xmlhttprequest@*:
version "1.8.0"
resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc"
integrity sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=
xpipe@^1.0.5: xpipe@^1.0.5:
version "1.0.5" version "1.0.5"
resolved "https://registry.yarnpkg.com/xpipe/-/xpipe-1.0.5.tgz#8dd8bf45fc3f7f55f0e054b878f43a62614dafdf" resolved "https://registry.yarnpkg.com/xpipe/-/xpipe-1.0.5.tgz#8dd8bf45fc3f7f55f0e054b878f43a62614dafdf"

1
resources/js/web3.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,6 @@
(def emojis (js/require "emojilib")) (def emojis (js/require "emojilib"))
(def phishing-detect (js/require "eth-phishing-detect")) (def phishing-detect (js/require "eth-phishing-detect"))
(def identicon-js (js/require "identicon.js")) (def identicon-js (js/require "identicon.js"))
(def Web3 (js/require "web3")) (def BigNumber (js/require "bignumber.js"))
(def web3-prototype (.-prototype Web3))
(def web3-utils (js/require "web3-utils")) (def web3-utils (js/require "web3-utils"))
(def hi-base32 (js/require "hi-base32")) (def hi-base32 (js/require "hi-base32"))

View File

@ -9,7 +9,7 @@
(and (string? url) (s/starts-with? url local-protocol))) (and (string? url) (s/starts-with? url local-protocol)))
(def webview-js (slurp "resources/js/webview.js")) (def webview-js (slurp "resources/js/webview.js"))
(def web3-file (slurp "node_modules/web3/dist/web3.min.js")) (def web3-file (slurp "resources/js/web3.min.js"))
(def web3 (def web3
(memoize (memoize
(fn [] (fn []

View File

@ -30,26 +30,16 @@
(defn bignumber [n] (defn bignumber [n]
(when n (when n
(try (try
(.toBigNumber dependencies/web3-prototype (normalize (str n))) (new dependencies/BigNumber (normalize (str n)))
(catch :default err nil)))) (catch :default err nil))))
(defn valid? [bn] (defn valid? [bn]
(when bn (when bn
(.greaterThanOrEqualTo bn 0))) (.greaterThanOrEqualTo bn 0)))
(defn str->wei [s] (defn from-decimal [n]
(when-let [ns (normalize s)] (when n
(try (str "1" (string/join (repeat n "0")))))
(.toWei dependencies/web3-prototype ns "ether")
(catch :default err nil))))
(defn to-decimal [s]
(when s
(try
(.toDecimal dependencies/web3-prototype (normalize s))
(catch :default err nil))))
(defn from-decimal [n] (when n (str "1" (string/join (repeat n "0")))))
(def eth-units (def eth-units
{:wei (bignumber "1") {:wei (bignumber "1")

View File

@ -1,53 +0,0 @@
(ns status-im.test.protocol.core
(:require [cljs.test :refer-macros [deftest is testing async]]
[cljs.nodejs :as nodejs]
re-frame.db
status-im.ui.screens.events
[re-frame.core :as rf]
[cljs.core.async :as async]
[status-im.transport.utils :as transport.utils]
[day8.re-frame.test :refer-macros [run-test-async run-test-sync] :as rf-test]
[status-im.test.protocol.node :as node]
[status-im.transport.message.contact :as transport.contact]
[status-im.test.protocol.utils :as utils]))
;; NOTE(oskarth): All these tests are evaluated in NodeJS
(nodejs/enable-util-print!)
(def contact-public-key "0x048f7d5d4bda298447bbb5b021a34832509bd1a8dbe4e06f9b7223d00a59b6dc14f6e142b21d3220ceb3155a6d8f40ec115cd96394d3cc7c55055b433a1758dc74")
(def rpc-url (aget nodejs/process.env "WNODE_ADDRESS"))
(def Web3 (js/require "web3"))
(defn make-web3 []
(Web3. (Web3.providers.HttpProvider. rpc-url)))
(defn create-keys [shh]
(let [keypair-promise (.newKeyPair shh)]
(.getPublicKey shh keypair-promise)))
(deftest test-send-message!
(testing "send contact request & message"
(run-test-async
(let [web3 (make-web3)
shh (.-shh web3)
from (create-keys shh)]
(reset! re-frame.db/app-db {:web3 web3
:multiaccount {:public-key from}})
(rf/dispatch [:contact.ui/send-message-pressed {:public-key contact-public-key}])
(rf-test/wait-for [::transport.contact/send-new-sym-key]
(rf/dispatch [:set-chat-input-text "test message"])
(rf/dispatch [:send-current-message])
(rf-test/wait-for [:update-message-status :transport/send-status-message-error]
(is true)))))))
(deftest test-whisper-version!
(testing "Whisper version supported"
(async done
(let [web3 (make-web3)
shh (.-shh web3)]
(.version shh
(fn [& args]
(is (= "6.0" (second args)))
(done)))))))

View File

@ -1,9 +0,0 @@
(ns status-im.test.protocol.node
(:require [clojure.string :as s]
[status-im.test.protocol.utils :as utils]))
(def identity-1 "0x04eedbaafd6adf4a9233a13e7b1c3c14461fffeba2e9054b8d456ce5f6ebeafadcbf3dce3716253fbc391277fa5a086b60b283daf61fb5b1f26895f456c2f31ae3")
(def identity-2 "0x0490161b00f2c47542d28c2e8908e77159b1720dccceb6393d7c001850122efc3b1709bcea490fd8f5634ba1a145aa0722d86b9330b0e39a8d493cb981fd459da2")
(def topic-1 "0xdeadbeef")
(def topic-2 "0xbeefdead")

View File

@ -1,13 +0,0 @@
(ns status-im.test.protocol.runner
(:require [doo.runner :refer-macros [doo-tests]]
[status-im.test.protocol.core]))
(enable-console-print!)
;; Or doo will exit with an error, see:
;; https://github.com/bensu/doo/issues/83#issuecomment-165498172
(set! (.-error js/console) (fn [x] (.log js/console x)))
(set! goog.DEBUG false)
(doo-tests 'status-im.test.protocol.core)

View File

@ -1,25 +0,0 @@
(ns status-im.test.protocol.utils)
(def fs (js/require "fs"))
(def child-process (js/require "child_process"))
(def process (js/require "process"))
(def exist? (.-existsSync fs))
(defn exec-sync [command options]
(.execSync child-process command (clj->js options)))
(defn exec [command options]
(.exec child-process command (clj->js options)))
(defn spawn-sync [command args options]
(.spawnSync child-process command (clj->js args) (clj->js options)))
(defn spawn [command args options]
(.spawn child-process command (clj->js args) (clj->js options)))
(defn exit! []
(.exit process))
(defn mkdir-sync [dir]
(.mkdirSync fs dir))