Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: eth api key migration #1486

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions .yarn/versions/4869cfe2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
releases:
"@fluent-wallet/account": patch
"@fluent-wallet/addr-by-network": patch
"@fluent-wallet/base32-address": patch
"@fluent-wallet/cfx_accounts": patch
"@fluent-wallet/cfx_call": patch
"@fluent-wallet/cfx_chain-id": patch
"@fluent-wallet/cfx_check-balance-against-transaction": patch
"@fluent-wallet/cfx_client-version": patch
"@fluent-wallet/cfx_epoch-number": patch
"@fluent-wallet/cfx_estimate-1559-fee": patch
"@fluent-wallet/cfx_estimate-gas-and-collateral": patch
"@fluent-wallet/cfx_fee-history": patch
"@fluent-wallet/cfx_gas-price": patch
"@fluent-wallet/cfx_get-account": patch
"@fluent-wallet/cfx_get-account-pending-info": patch
"@fluent-wallet/cfx_get-account-pending-transactions": patch
"@fluent-wallet/cfx_get-accumulate-interest-rate": patch
"@fluent-wallet/cfx_get-admin": patch
"@fluent-wallet/cfx_get-balance": patch
"@fluent-wallet/cfx_get-best-block-hash": patch
"@fluent-wallet/cfx_get-block-by-block-number": patch
"@fluent-wallet/cfx_get-block-by-epoch-number": patch
"@fluent-wallet/cfx_get-block-by-hash": patch
"@fluent-wallet/cfx_get-block-by-hash-with-pivot-assumption": patch
"@fluent-wallet/cfx_get-block-reward-info": patch
"@fluent-wallet/cfx_get-blocks-by-epoch": patch
"@fluent-wallet/cfx_get-code": patch
"@fluent-wallet/cfx_get-collateral-for-storage": patch
"@fluent-wallet/cfx_get-confirmation-risk-by-hash": patch
"@fluent-wallet/cfx_get-deposit-list": patch
"@fluent-wallet/cfx_get-fee-burnt": patch
"@fluent-wallet/cfx_get-interest-rate": patch
"@fluent-wallet/cfx_get-logs": patch
"@fluent-wallet/cfx_get-max-gas-limit": patch
"@fluent-wallet/cfx_get-next-nonce": patch
"@fluent-wallet/cfx_get-next-usable-nonce": patch
"@fluent-wallet/cfx_get-pos-economics": patch
"@fluent-wallet/cfx_get-pos-reward-by-epoch": patch
"@fluent-wallet/cfx_get-skipped-blocks-by-epoch": patch
"@fluent-wallet/cfx_get-sponsor-info": patch
"@fluent-wallet/cfx_get-staking-balance": patch
"@fluent-wallet/cfx_get-status": patch
"@fluent-wallet/cfx_get-storage-at": patch
"@fluent-wallet/cfx_get-storage-root": patch
"@fluent-wallet/cfx_get-supply-info": patch
"@fluent-wallet/cfx_get-transaction-by-hash": patch
"@fluent-wallet/cfx_get-transaction-receipt": patch
"@fluent-wallet/cfx_get-vote-list": patch
"@fluent-wallet/cfx_max-priority-fee-per-gas": patch
"@fluent-wallet/cfx_net-version": patch
"@fluent-wallet/cfx_opened-method-groups": patch
"@fluent-wallet/cfx_request-accounts": patch
"@fluent-wallet/cfx_send-raw-transaction": patch
"@fluent-wallet/cfx_send-transaction": patch
"@fluent-wallet/cfx_sign-transaction": patch
"@fluent-wallet/cfx_sign-tx-with-ledger-nano-s": patch
"@fluent-wallet/cfx_sign-typed-data_v4": patch
"@fluent-wallet/consts": patch
"@fluent-wallet/contract-method-name": patch
"@fluent-wallet/db": patch
"@fluent-wallet/detect-address-type": patch
"@fluent-wallet/did": patch
"@fluent-wallet/estimate-tx": patch
"@fluent-wallet/eth_accounts": patch
"@fluent-wallet/eth_block-number": patch
"@fluent-wallet/eth_call": patch
"@fluent-wallet/eth_chain-id": patch
"@fluent-wallet/eth_estimate-1559-fee": patch
"@fluent-wallet/eth_estimate-gas": patch
"@fluent-wallet/eth_fee-history": patch
"@fluent-wallet/eth_gas-price": patch
"@fluent-wallet/eth_get-balance": patch
"@fluent-wallet/eth_get-block-by-hash": patch
"@fluent-wallet/eth_get-block-by-number": patch
"@fluent-wallet/eth_get-code": patch
"@fluent-wallet/eth_get-logs": patch
"@fluent-wallet/eth_get-transaction-by-hash": patch
"@fluent-wallet/eth_get-transaction-count": patch
"@fluent-wallet/eth_get-transaction-receipt": patch
"@fluent-wallet/eth_max-priority-fee-per-gas": patch
"@fluent-wallet/eth_request-accounts": patch
"@fluent-wallet/eth_send-raw-transaction": patch
"@fluent-wallet/eth_send-transaction": patch
"@fluent-wallet/eth_sign-transaction": patch
"@fluent-wallet/eth_sign-tx-with-ledger-nano-s": patch
"@fluent-wallet/eth_sign-typed-data_v4": patch
"@fluent-wallet/ledger": patch
"@fluent-wallet/net_version": patch
"@fluent-wallet/personal_sign": patch
"@fluent-wallet/rpc-engine": patch
"@fluent-wallet/shorten-address": patch
"@fluent-wallet/signature": patch
"@fluent-wallet/single-call-balance-tracker": patch
"@fluent-wallet/spec": patch
"@fluent-wallet/tx-history-checker": patch
"@fluent-wallet/txpool_next-nonce": patch
"@fluent-wallet/wallet_accounts": patch
"@fluent-wallet/wallet_add-conflux-chain": patch
"@fluent-wallet/wallet_add-ethereum-chain": patch
"@fluent-wallet/wallet_add-hd-path": patch
"@fluent-wallet/wallet_add-network": patch
"@fluent-wallet/wallet_add-pending-user-auth-request": patch
"@fluent-wallet/wallet_add-vault": patch
"@fluent-wallet/wallet_after-unlock": patch
"@fluent-wallet/wallet_chain-id": patch
"@fluent-wallet/wallet_cleanup-tx": patch
"@fluent-wallet/wallet_create-account": patch
"@fluent-wallet/wallet_create-address": patch
"@fluent-wallet/wallet_db-query": patch
"@fluent-wallet/wallet_delete-account": patch
"@fluent-wallet/wallet_delete-account-group": patch
"@fluent-wallet/wallet_delete-app": patch
"@fluent-wallet/wallet_delete-memo": patch
"@fluent-wallet/wallet_delete-network": patch
"@fluent-wallet/wallet_detect-address-type": patch
"@fluent-wallet/wallet_detect-network-type": patch
"@fluent-wallet/wallet_discover-accounts": patch
"@fluent-wallet/wallet_enrich-conflux-tx": patch
"@fluent-wallet/wallet_enrich-ethereum-tx": patch
"@fluent-wallet/wallet_enrich-txs": patch
"@fluent-wallet/wallet_export-account": patch
"@fluent-wallet/wallet_export-account-group": patch
"@fluent-wallet/wallet_export-all": patch
"@fluent-wallet/wallet_generate-address": patch
"@fluent-wallet/wallet_generate-private-key": patch
"@fluent-wallet/wallet_get-account-address-by-network": patch
"@fluent-wallet/wallet_get-account-group": patch
"@fluent-wallet/wallet_get-account-group-vault-value": patch
"@fluent-wallet/wallet_get-address-private-key": patch
"@fluent-wallet/wallet_get-balance": patch
"@fluent-wallet/wallet_get-block-or-epoch-number": patch
"@fluent-wallet/wallet_get-block-time": patch
"@fluent-wallet/wallet_get-blockchain-explorer-url": patch
"@fluent-wallet/wallet_get-current-account": patch
"@fluent-wallet/wallet_get-current-network": patch
"@fluent-wallet/wallet_get-current-viewing-app": patch
"@fluent-wallet/wallet_get-fluent-metadata": patch
"@fluent-wallet/wallet_get-import-hardware-wallet-info": patch
"@fluent-wallet/wallet_get-network": patch
"@fluent-wallet/wallet_get-next-nonce": patch
"@fluent-wallet/wallet_get-next-usable-nonce": patch
"@fluent-wallet/wallet_get-pending-auth-request": patch
"@fluent-wallet/wallet_get-permissions": patch
"@fluent-wallet/wallet_get-preferences": patch
"@fluent-wallet/wallet_handle-unfinished-cfx-tx": patch
"@fluent-wallet/wallet_handle-unfinished-eth-tx": patch
"@fluent-wallet/wallet_handle-unfinished-txs": patch
"@fluent-wallet/wallet_import-address": patch
"@fluent-wallet/wallet_import-all": patch
"@fluent-wallet/wallet_import-hardware-wallet-account-group-or-account": patch
"@fluent-wallet/wallet_import-mnemonic": patch
"@fluent-wallet/wallet_import-private-key": patch
"@fluent-wallet/wallet_metadata-for-popup": patch
"@fluent-wallet/wallet_network1559compatible": patch
"@fluent-wallet/wallet_refetch-balance": patch
"@fluent-wallet/wallet_refetch-token-list": patch
"@fluent-wallet/wallet_refetch-tx-list": patch
"@fluent-wallet/wallet_register-site-metadata": patch
"@fluent-wallet/wallet_request-accounts": patch
"@fluent-wallet/wallet_request-permissions": patch
"@fluent-wallet/wallet_request-unlock-ui": patch
"@fluent-wallet/wallet_send-transaction": patch
"@fluent-wallet/wallet_send-transaction-with-action": patch
"@fluent-wallet/wallet_set-app-current-account": patch
"@fluent-wallet/wallet_set-app-current-network": patch
"@fluent-wallet/wallet_set-current-account": patch
"@fluent-wallet/wallet_set-current-network": patch
"@fluent-wallet/wallet_set-preferences": patch
"@fluent-wallet/wallet_switch-conflux-chain": patch
"@fluent-wallet/wallet_switch-ethereum-chain": patch
"@fluent-wallet/wallet_unlock": patch
"@fluent-wallet/wallet_unwatch-asset": patch
"@fluent-wallet/wallet_update-account": patch
"@fluent-wallet/wallet_update-account-group": patch
"@fluent-wallet/wallet_update-network": patch
"@fluent-wallet/wallet_update-token-list": patch
"@fluent-wallet/wallet_upsert-memo": patch
"@fluent-wallet/wallet_user-approved-auth-request": patch
"@fluent-wallet/wallet_user-rejected-auth-request": patch
"@fluent-wallet/wallet_validate-app-permissions": patch
"@fluent-wallet/wallet_validate-mnemonic": patch
"@fluent-wallet/wallet_validate-password": patch
"@fluent-wallet/wallet_validate-private-key": patch
"@fluent-wallet/wallet_validate20token": patch
"@fluent-wallet/wallet_watch-asset": patch
"@fluent-wallet/wallet_zero-account-group": patch
browser-extension: patch
helios-background: patch
helios-popup: patch
workspace-tools: patch

declined:
- helios
- doc
37 changes: 19 additions & 18 deletions packages/background/src/init-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,54 +245,55 @@ function initNetwork(d) {
},
{
network: {
name: ETH_GOERLI_NAME,
endpoint: ETH_GOERLI_RPC_ENDPOINT,
name: ETH_SEPOLIA_NAME,
endpoint: ETH_SEPOLIA_RPC_ENDPOINT,
type: 'eth',
chainId: ETH_GOERLI_CHAINID,
netId: ETH_GOERLI_NETID,
chainId: ETH_SEPOLIA_CHAINID,
netId: ETH_SEPOLIA_NETID,
icon: 'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/Ethereum.svg',
cacheTime: 15000,

ticker: {
name: ETH_GOERLI_CURRENCY_NAME,
symbol: ETH_GOERLI_CURRENCY_SYMBOL,
name: ETH_SEPOLIA_CURRENCY_NAME,
symbol: ETH_SEPOLIA_CURRENCY_SYMBOL,
decimals: DEFAULT_CURRENCY_DECIMALS,
iconUrls: [
'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/eth.svg',
],
},
scanUrl: ETH_GOERLI_EXPLORER_URL,
scanUrl: ETH_SEPOLIA_EXPLORER_URL,
hdPath: -2,
builtin: true,
isTestnet: true,
balanceChecker: '0x9788c4e93f9002a7ad8e72633b11e8d1ecd51f9b',
// TODO(SEPOLIA) There is currently no balance call address for Sepolia
balanceChecker: '',
gasBuffer: 1.5,
},
},
{
network: {
name: ETH_SEPOLIA_NAME,
endpoint: ETH_SEPOLIA_RPC_ENDPOINT,
name: ETH_GOERLI_NAME,
endpoint: ETH_GOERLI_RPC_ENDPOINT,
type: 'eth',
chainId: ETH_SEPOLIA_CHAINID,
netId: ETH_SEPOLIA_NETID,
chainId: ETH_GOERLI_CHAINID,
netId: ETH_GOERLI_NETID,
icon: 'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/Ethereum.svg',
cacheTime: 15000,

ticker: {
name: ETH_SEPOLIA_CURRENCY_NAME,
symbol: ETH_SEPOLIA_CURRENCY_SYMBOL,
name: ETH_GOERLI_CURRENCY_NAME,
symbol: ETH_GOERLI_CURRENCY_SYMBOL,
decimals: DEFAULT_CURRENCY_DECIMALS,
iconUrls: [
'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/eth.svg',
],
},
scanUrl: ETH_SEPOLIA_EXPLORER_URL,
scanUrl: ETH_GOERLI_EXPLORER_URL,
hdPath: -2,
builtin: true,
builtin: false,
isCustom: true,
isTestnet: true,
// TODO(SEPOLIA) There is currently no balance call address for Sepolia
balanceChecker: '',
balanceChecker: '0x9788c4e93f9002a7ad8e72633b11e8d1ecd51f9b',
gasBuffer: 1.5,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/consts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ADDRESS_TYPES = ['user', 'contract', 'builtin', 'null']
// * network setting
export const DEFAULT_CURRENCY_DECIMALS = 18
export const CONFLUX_API_LIMIT_KEY = '1BvViQet4km8KPALkc6Pa9'
export const ETH_API_LIMIT_KEY = '9aa3d95b3bc440fa88ea12eaa4456161'
export const ETH_API_LIMIT_KEY = 'b6bf7d3508c941499b10025c0776eaf8'

export const CFX_MAINNET_RPC_ENDPOINT = `https://main.confluxrpc.com/${CONFLUX_API_LIMIT_KEY}`
export const CFX_MAINNET_NAME = 'Conflux Mainnet'
Expand Down
4 changes: 2 additions & 2 deletions packages/db/src/main/cfxjs/db/migrations/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[cfxjs.db.migrations.m11]
[cfxjs.db.migrations.m12]
[cfxjs.db.migrations.m13]
[cfxjs.db.migrations.m14]
[cfxjs.db.migrations.m2]
[cfxjs.db.migrations.m3]
[cfxjs.db.migrations.m4]
Expand All @@ -26,5 +27,4 @@
cfxjs.db.migrations.m11/data
cfxjs.db.migrations.m12/data
cfxjs.db.migrations.m13/data
]
)
cfxjs.db.migrations.m14/data])
38 changes: 38 additions & 0 deletions packages/db/src/main/cfxjs/db/migrations/m14.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(ns cfxjs.db.migrations.m14
(:require
[cfxjs.db.migutil :refer [update-version-tx]]
["@fluent-wallet/consts" :refer [ETH_GOERLI_CHAINID ETH_API_LIMIT_KEY]]
[clojure.string :as str]
[cfxjs.db.datascript.core :as d]))

(def id 14)

(def OLD_ETH_API_LIMIT_KEY "9aa3d95b3bc440fa88ea12eaa4456161")

(defn get-network-id [db chainId chainType] (let [id (d/q '[:find ?net .
:in $ ?chainId ?chainType
:where
[?net :network/builtin true] [?net :network/type ?chainType]
[?net :network/chainId ?chainId]]
db chainId chainType)] id))

(defn up [old-db]
(let [networks (d/q '[:find [(pull ?e [*]) ...]
:in $ ?suffix
:where
[?e :network/builtin true]
[?e :network/endpoint ?endpoint]
[(clojure.string/ends-with? ?endpoint ?suffix)]]
old-db OLD_ETH_API_LIMIT_KEY)
eth-testnet-goerli-id (get-network-id old-db ETH_GOERLI_CHAINID "eth")
txs (mapv (fn [{:db/keys [id] :network/keys [endpoint]}]
{:db/id id
:network/endpoint (str/replace endpoint OLD_ETH_API_LIMIT_KEY ETH_API_LIMIT_KEY)})
networks)
txs (conj txs {:db/id eth-testnet-goerli-id :network/isCustom true :network/builtin false})
new-db (d/db-with old-db (concat txs [(update-version-tx old-db id)]))]
new-db))

(defn down [new-db] new-db)

(def data {:up up :down down :id id})
Loading