fix: test networks short-name->id (#18692)
* fix: test networks short-name->id
This commit is contained in:
parent
154fbb156d
commit
a6565b52ce
|
@ -410,14 +410,14 @@
|
||||||
(def ^:const ens-action-type-set-pub-key 2)
|
(def ^:const ens-action-type-set-pub-key 2)
|
||||||
|
|
||||||
;; wallet
|
;; wallet
|
||||||
(def ^:const ethereum-mainnet-chain-id 1)
|
(def ^:const ethereum-chain-id 1)
|
||||||
(def ^:const ethereum-goerli-chain-id 5)
|
(def ^:const goerli-chain-id 5)
|
||||||
|
(def ^:const arbitrum-chain-id 42161)
|
||||||
|
(def ^:const arbitrum-testnet-chain-id 421613)
|
||||||
|
(def ^:const optimism-chain-id 10)
|
||||||
|
(def ^:const optimism-testnet-chain-id 420)
|
||||||
(def ^:const ethereum-sepolia-chain-id 11155111)
|
(def ^:const ethereum-sepolia-chain-id 11155111)
|
||||||
(def ^:const arbitrum-mainnet-chain-id 42161)
|
|
||||||
(def ^:const arbitrum-goerli-chain-id 421613)
|
|
||||||
(def ^:const arbitrum-sepolia-chain-id 421614)
|
(def ^:const arbitrum-sepolia-chain-id 421614)
|
||||||
(def ^:const optimism-mainnet-chain-id 10)
|
|
||||||
(def ^:const optimism-goerli-chain-id 420)
|
|
||||||
(def ^:const optimism-sepolia-chain-id 11155420)
|
(def ^:const optimism-sepolia-chain-id 11155420)
|
||||||
|
|
||||||
(def ^:const mainnet-short-name "eth")
|
(def ^:const mainnet-short-name "eth")
|
||||||
|
|
|
@ -190,20 +190,30 @@
|
||||||
address))
|
address))
|
||||||
|
|
||||||
(def id->network
|
(def id->network
|
||||||
{constants/ethereum-mainnet-chain-id :ethereum
|
{constants/ethereum-chain-id :ethereum
|
||||||
constants/ethereum-goerli-chain-id :ethereum
|
constants/goerli-chain-id :ethereum
|
||||||
constants/ethereum-sepolia-chain-id :ethereum
|
constants/ethereum-sepolia-chain-id :ethereum
|
||||||
constants/optimism-mainnet-chain-id :optimism
|
constants/optimism-chain-id :optimism
|
||||||
constants/optimism-goerli-chain-id :optimism
|
constants/optimism-testnet-chain-id :optimism
|
||||||
constants/optimism-sepolia-chain-id :optimism
|
constants/optimism-sepolia-chain-id :optimism
|
||||||
constants/arbitrum-mainnet-chain-id :arbitrum
|
constants/arbitrum-chain-id :arbitrum
|
||||||
constants/arbitrum-goerli-chain-id :arbitrum
|
constants/arbitrum-testnet-chain-id :arbitrum
|
||||||
constants/arbitrum-sepolia-chain-id :arbitrum})
|
constants/arbitrum-sepolia-chain-id :arbitrum})
|
||||||
|
|
||||||
(def short-name->id
|
(defn- get-chain-id
|
||||||
{:eth constants/ethereum-mainnet-chain-id
|
[test-net?]
|
||||||
:opt constants/optimism-mainnet-chain-id
|
(if test-net?
|
||||||
:arb1 constants/arbitrum-mainnet-chain-id})
|
{:eth constants/goerli-chain-id
|
||||||
|
:opt constants/optimism-testnet-chain-id
|
||||||
|
:arb1 constants/arbitrum-testnet-chain-id}
|
||||||
|
{:eth constants/ethereum-chain-id
|
||||||
|
:opt constants/optimism-chain-id
|
||||||
|
:arb1 constants/arbitrum-chain-id}))
|
||||||
|
|
||||||
|
(defn short-name->id
|
||||||
|
[short-name test-net?]
|
||||||
|
(let [chain-id-map (get-chain-id test-net?)]
|
||||||
|
(get chain-id-map short-name)))
|
||||||
|
|
||||||
(defn get-standard-fiat-format
|
(defn get-standard-fiat-format
|
||||||
[crypto-value currency-symbol fiat-value]
|
[crypto-value currency-symbol fiat-value]
|
||||||
|
|
|
@ -62,10 +62,11 @@
|
||||||
:wallet/select-send-address
|
:wallet/select-send-address
|
||||||
(fn [{:keys [db]} [{:keys [address token recipient stack-id]}]]
|
(fn [{:keys [db]} [{:keys [address token recipient stack-id]}]]
|
||||||
(let [[prefix to-address] (utils/split-prefix-and-address address)
|
(let [[prefix to-address] (utils/split-prefix-and-address address)
|
||||||
|
test-net? (get-in db [:profile/profile :test-networks-enabled?])
|
||||||
prefix-seq (string/split prefix #":")
|
prefix-seq (string/split prefix #":")
|
||||||
selected-networks (->> prefix-seq
|
selected-networks (->> prefix-seq
|
||||||
(remove string/blank?)
|
(remove string/blank?)
|
||||||
(mapv #(utils/short-name->id (keyword %))))]
|
(mapv #(utils/short-name->id (keyword %) test-net?)))]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:wallet :ui :send :recipient] (or recipient address))
|
(assoc-in [:wallet :ui :send :recipient] (or recipient address))
|
||||||
(assoc-in [:wallet :ui :send :to-address] to-address)
|
(assoc-in [:wallet :ui :send :to-address] to-address)
|
||||||
|
|
|
@ -33,16 +33,16 @@
|
||||||
(defn get-network-details
|
(defn get-network-details
|
||||||
[chain-id]
|
[chain-id]
|
||||||
(case chain-id
|
(case chain-id
|
||||||
(constants/ethereum-mainnet-chain-id constants/ethereum-goerli-chain-id
|
(constants/ethereum-chain-id constants/goerli-chain-id
|
||||||
constants/ethereum-sepolia-chain-id)
|
constants/ethereum-sepolia-chain-id)
|
||||||
mainnet-network-details
|
mainnet-network-details
|
||||||
|
|
||||||
(constants/arbitrum-mainnet-chain-id constants/arbitrum-goerli-chain-id
|
(constants/arbitrum-chain-id constants/arbitrum-testnet-chain-id
|
||||||
constants/arbitrum-sepolia-chain-id)
|
constants/arbitrum-sepolia-chain-id)
|
||||||
arbitrum-network-details
|
arbitrum-network-details
|
||||||
|
|
||||||
(constants/optimism-mainnet-chain-id constants/optimism-goerli-chain-id
|
(constants/optimism-chain-id constants/optimism-testnet-chain-id
|
||||||
constants/optimism-sepolia-chain-id)
|
constants/optimism-sepolia-chain-id)
|
||||||
optimism-network-details
|
optimism-network-details
|
||||||
|
|
||||||
nil))
|
nil))
|
||||||
|
|
Loading…
Reference in New Issue