[#12681] Enable UI for signing legacy txs on networks without eip1559 support

This commit is contained in:
Roman Volosovskyi 2021-10-08 11:30:11 +03:00
parent 1f357fd7c6
commit 12a99f40d2
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
8 changed files with 57 additions and 79 deletions

1
.env
View File

@ -29,6 +29,5 @@ APN_TOPIC=im.status.ethereum.pr
COMMUNITIES_ENABLED=1
DATABASE_MANAGEMENT_ENABLED=1
METRICS_ENABLED=0
EIP1559_ENABLED=1
DELETE_MESSAGE_ENABLED=1
COLLECTIBLES_ENABLED=1

View File

@ -32,5 +32,4 @@ DATABASE_MANAGEMENT_ENABLED=1
COMMUNITIES_ENABLED=1
COMMUNITIES_MANAGEMENT_ENABLED=1
METRICS_ENABLED=0
EIP1559_ENABLED=1
DELETE_MESSAGE_ENABLED=1

View File

@ -34,5 +34,4 @@ DATABASE_MANAGEMENT_ENABLED=1
COMMUNITIES_ENABLED=1
COMMUNITIES_MANAGEMENT_ENABLED=1
METRICS_ENABLED=0
EIP1559_ENABLED=1
DELETE_MESSAGE_ENABLED=1

View File

@ -23,5 +23,4 @@ BLANK_PREVIEW=0
COMMUNITIES_ENABLED=1
DATABASE_MANAGEMENT_ENABLED=1
METRICS_ENABLED=0
EIP1559_ENABLED=1
DELETE_MESSAGE_ENABLED=1

View File

@ -19,6 +19,5 @@ ENABLE_ROOT_ALERT=1
MAX_IMAGES_BATCH=1
ENABLE_REFERRAL_INVITE=0
METRICS_ENABLED=0
EIP1559_ENABLED=1
DELETE_MESSAGE_ENABLED=1
COLLECTIBLES_ENABLED=0

View File

@ -1,60 +1,49 @@
(ns status-im.signing.eip1559
(:require [re-frame.core :as re-frame]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.utils.config :as config]
[status-im.utils.money :as money]))
[status-im.ethereum.json-rpc :as json-rpc]))
(def activation-blocks
{"3" (money/bignumber 10499401)})
(defonce activated? (atom {}))
(defonce london-activated? (atom false))
(defonce activated-on-current-network? (atom nil))
(defn get-activation-block [network-id]
(get activation-blocks (str network-id)))
(defn london-is-definitely-activated [network-id]
(contains? #{"1" "3"} network-id))
(defn on-block [network-id callback header]
(let [london-activated?
(boolean
(and
(get-activation-block network-id)
(money/greater-than-or-equals
(money/bignumber (:number header))
(get-activation-block network-id))))]
(swap! activated? assoc network-id london-activated?)
(reset! activated-on-current-network? london-activated?)
(callback london-activated?)))
(defn on-block [callback header]
(let [activated? (contains? header :baseFeePerGas)]
(reset! london-activated? activated?)
(callback activated?)))
(defn check-activation [network-id callback]
(defn check-activation [callback]
(json-rpc/call
{:method "eth_getBlockByNumber"
:params ["latest" false]
:on-success (partial on-block network-id callback)
:on-success (partial on-block callback)
:on-error #(callback nil)}))
(defn sync-enabled? []
config/eip1559-enabled?)
(defn sync-enabled? [] @london-activated?)
(defn enabled? [network-id enabled-callback disabled-callback]
(let [london-activated? true]
(cond
(not config/eip1559-enabled?)
(disabled-callback)
(defn enabled?
([] @london-activated?)
([network-id enabled-callback disabled-callback]
(let [definitely-activated? (london-is-definitely-activated network-id)]
(cond
definitely-activated?
(do
(reset! london-activated? true)
(enabled-callback))
(nil? london-activated?)
(check-activation
network-id
(fn [activated?]
(if activated?
(enabled-callback)
(disabled-callback))))
(not definitely-activated?)
(check-activation
(fn [activated?]
(if activated?
(enabled-callback)
(disabled-callback))))
london-activated?
(enabled-callback)
:else
(disabled-callback))))
:else
(do
(reset! london-activated? false)
(disabled-callback))))))
(re-frame/reg-fx
::check-eip1559-activation

View File

@ -1,31 +1,32 @@
(ns status-im.ui.screens.signing.views
(:require-macros [status-im.utils.views :as views])
(:require [status-im.ui.components.react :as react]
[re-frame.core :as re-frame]
[status-im.multiaccounts.core :as multiaccounts]
[quo.design-system.colors :as colors]
[status-im.ui.components.copyable-text :as copyable-text]
[status-im.wallet.utils :as wallet.utils]
[status-im.keycard.common :as keycard.common]
[status-im.ui.screens.keycard.keycard-interaction :as keycard-sheet]
[status-im.ui.components.chat-icon.screen :as chat-icon]
[status-im.ui.components.icons.icons :as icons]
[status-im.i18n.i18n :as i18n]
[status-im.utils.security :as security]
[status-im.ui.screens.signing.sheets :as sheets]
[status-im.ethereum.tokens :as tokens]
[status-im.utils.types :as types]
[status-im.utils.platform :as platform]
[clojure.string :as string]
(:require [clojure.string :as string]
[quo.core :as quo]
[quo.design-system.colors :as colors]
[quo.gesture-handler :as gh]
[status-im.ui.screens.signing.styles :as styles]
[status-im.react-native.resources :as resources]
[status-im.ui.screens.keycard.pin.views :as pin.views]
[status-im.ui.components.bottom-panel.views :as bottom-panel]
[status-im.utils.utils :as utils]
[re-frame.core :as re-frame]
[reagent.core :as reagent]
[status-im.ui.screens.wallet.components.views :as wallet.components]))
[status-im.ethereum.tokens :as tokens]
[status-im.i18n.i18n :as i18n]
[status-im.keycard.common :as keycard.common]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.react-native.resources :as resources]
[status-im.signing.eip1559 :as eip1559]
[status-im.ui.components.bottom-panel.views :as bottom-panel]
[status-im.ui.components.chat-icon.screen :as chat-icon]
[status-im.ui.components.copyable-text :as copyable-text]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.components.react :as react]
[status-im.ui.screens.keycard.keycard-interaction :as keycard-sheet]
[status-im.ui.screens.keycard.pin.views :as pin.views]
[status-im.ui.screens.signing.sheets :as sheets]
[status-im.ui.screens.signing.styles :as styles]
[status-im.ui.screens.wallet.components.views :as wallet.components]
[status-im.utils.platform :as platform]
[status-im.utils.security :as security]
[status-im.utils.types :as types]
[status-im.utils.utils :as utils]
[status-im.wallet.utils :as wallet.utils]))
(defn separator []
[react/view {:height 1 :background-color colors/gray-lighter}])
@ -384,15 +385,9 @@
:on-press #(re-frame/dispatch
[:signing.ui/open-fee-sheet
{:content (fn []
[sheets/fee-bottom-sheet-eip1559-custom fee-display-symbol])
:content-height 270}])
#_(re-frame/dispatch
[:signing.ui/open-fee-sheet
{:content (fn []
(if (eip1559/sync-enabled?)
[sheets/fee-bottom-sheet-eip1559 fee-display-symbol]
[sheets/fee-bottom-sheet fee-display-symbol]))
:content-height 270}])}])))
(if (eip1559/enabled?)
[sheets/fee-bottom-sheet-eip1559-custom fee-display-symbol]
[sheets/fee-bottom-sheet fee-display-symbol]))}])}])))
(views/defview network-item []
(views/letsubs [network-name [:network-name]]

View File

@ -49,7 +49,6 @@
(def database-management-enabled? (enabled? (get-config :DATABASE_MANAGEMENT_ENABLED "0")))
(def debug-webview? (enabled? (get-config :DEBUG_WEBVIEW "0")))
(def metrics-enabled? (enabled? (get-config :METRICS_ENABLED "0")))
(def eip1559-enabled? (enabled? (get-config :EIP1559_ENABLED "0")))
(def delete-message-enabled? (enabled? (get-config :DELETE_MESSAGE_ENABLED "0")))
(def collectibles-enabled? (enabled? (get-config :COLLECTIBLES_ENABLED "1")))
(def test-stateofus? (enabled? (get-config :TEST_STATEOFUS "0")))