Skip to content

Commit 1d054d0

Browse files
authored
feat: eth api key migration (#1486)
* feat: eth api key migration * fix: downgrade * feat: version * feat: version
1 parent f3df017 commit 1d054d0

File tree

5 files changed

+255
-21
lines changed

5 files changed

+255
-21
lines changed

.yarn/versions/4869cfe2.yml

+195
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
releases:
2+
"@fluent-wallet/account": patch
3+
"@fluent-wallet/addr-by-network": patch
4+
"@fluent-wallet/base32-address": patch
5+
"@fluent-wallet/cfx_accounts": patch
6+
"@fluent-wallet/cfx_call": patch
7+
"@fluent-wallet/cfx_chain-id": patch
8+
"@fluent-wallet/cfx_check-balance-against-transaction": patch
9+
"@fluent-wallet/cfx_client-version": patch
10+
"@fluent-wallet/cfx_epoch-number": patch
11+
"@fluent-wallet/cfx_estimate-1559-fee": patch
12+
"@fluent-wallet/cfx_estimate-gas-and-collateral": patch
13+
"@fluent-wallet/cfx_fee-history": patch
14+
"@fluent-wallet/cfx_gas-price": patch
15+
"@fluent-wallet/cfx_get-account": patch
16+
"@fluent-wallet/cfx_get-account-pending-info": patch
17+
"@fluent-wallet/cfx_get-account-pending-transactions": patch
18+
"@fluent-wallet/cfx_get-accumulate-interest-rate": patch
19+
"@fluent-wallet/cfx_get-admin": patch
20+
"@fluent-wallet/cfx_get-balance": patch
21+
"@fluent-wallet/cfx_get-best-block-hash": patch
22+
"@fluent-wallet/cfx_get-block-by-block-number": patch
23+
"@fluent-wallet/cfx_get-block-by-epoch-number": patch
24+
"@fluent-wallet/cfx_get-block-by-hash": patch
25+
"@fluent-wallet/cfx_get-block-by-hash-with-pivot-assumption": patch
26+
"@fluent-wallet/cfx_get-block-reward-info": patch
27+
"@fluent-wallet/cfx_get-blocks-by-epoch": patch
28+
"@fluent-wallet/cfx_get-code": patch
29+
"@fluent-wallet/cfx_get-collateral-for-storage": patch
30+
"@fluent-wallet/cfx_get-confirmation-risk-by-hash": patch
31+
"@fluent-wallet/cfx_get-deposit-list": patch
32+
"@fluent-wallet/cfx_get-fee-burnt": patch
33+
"@fluent-wallet/cfx_get-interest-rate": patch
34+
"@fluent-wallet/cfx_get-logs": patch
35+
"@fluent-wallet/cfx_get-max-gas-limit": patch
36+
"@fluent-wallet/cfx_get-next-nonce": patch
37+
"@fluent-wallet/cfx_get-next-usable-nonce": patch
38+
"@fluent-wallet/cfx_get-pos-economics": patch
39+
"@fluent-wallet/cfx_get-pos-reward-by-epoch": patch
40+
"@fluent-wallet/cfx_get-skipped-blocks-by-epoch": patch
41+
"@fluent-wallet/cfx_get-sponsor-info": patch
42+
"@fluent-wallet/cfx_get-staking-balance": patch
43+
"@fluent-wallet/cfx_get-status": patch
44+
"@fluent-wallet/cfx_get-storage-at": patch
45+
"@fluent-wallet/cfx_get-storage-root": patch
46+
"@fluent-wallet/cfx_get-supply-info": patch
47+
"@fluent-wallet/cfx_get-transaction-by-hash": patch
48+
"@fluent-wallet/cfx_get-transaction-receipt": patch
49+
"@fluent-wallet/cfx_get-vote-list": patch
50+
"@fluent-wallet/cfx_max-priority-fee-per-gas": patch
51+
"@fluent-wallet/cfx_net-version": patch
52+
"@fluent-wallet/cfx_opened-method-groups": patch
53+
"@fluent-wallet/cfx_request-accounts": patch
54+
"@fluent-wallet/cfx_send-raw-transaction": patch
55+
"@fluent-wallet/cfx_send-transaction": patch
56+
"@fluent-wallet/cfx_sign-transaction": patch
57+
"@fluent-wallet/cfx_sign-tx-with-ledger-nano-s": patch
58+
"@fluent-wallet/cfx_sign-typed-data_v4": patch
59+
"@fluent-wallet/consts": patch
60+
"@fluent-wallet/contract-method-name": patch
61+
"@fluent-wallet/db": patch
62+
"@fluent-wallet/detect-address-type": patch
63+
"@fluent-wallet/did": patch
64+
"@fluent-wallet/estimate-tx": patch
65+
"@fluent-wallet/eth_accounts": patch
66+
"@fluent-wallet/eth_block-number": patch
67+
"@fluent-wallet/eth_call": patch
68+
"@fluent-wallet/eth_chain-id": patch
69+
"@fluent-wallet/eth_estimate-1559-fee": patch
70+
"@fluent-wallet/eth_estimate-gas": patch
71+
"@fluent-wallet/eth_fee-history": patch
72+
"@fluent-wallet/eth_gas-price": patch
73+
"@fluent-wallet/eth_get-balance": patch
74+
"@fluent-wallet/eth_get-block-by-hash": patch
75+
"@fluent-wallet/eth_get-block-by-number": patch
76+
"@fluent-wallet/eth_get-code": patch
77+
"@fluent-wallet/eth_get-logs": patch
78+
"@fluent-wallet/eth_get-transaction-by-hash": patch
79+
"@fluent-wallet/eth_get-transaction-count": patch
80+
"@fluent-wallet/eth_get-transaction-receipt": patch
81+
"@fluent-wallet/eth_max-priority-fee-per-gas": patch
82+
"@fluent-wallet/eth_request-accounts": patch
83+
"@fluent-wallet/eth_send-raw-transaction": patch
84+
"@fluent-wallet/eth_send-transaction": patch
85+
"@fluent-wallet/eth_sign-transaction": patch
86+
"@fluent-wallet/eth_sign-tx-with-ledger-nano-s": patch
87+
"@fluent-wallet/eth_sign-typed-data_v4": patch
88+
"@fluent-wallet/ledger": patch
89+
"@fluent-wallet/net_version": patch
90+
"@fluent-wallet/personal_sign": patch
91+
"@fluent-wallet/rpc-engine": patch
92+
"@fluent-wallet/shorten-address": patch
93+
"@fluent-wallet/signature": patch
94+
"@fluent-wallet/single-call-balance-tracker": patch
95+
"@fluent-wallet/spec": patch
96+
"@fluent-wallet/tx-history-checker": patch
97+
"@fluent-wallet/txpool_next-nonce": patch
98+
"@fluent-wallet/wallet_accounts": patch
99+
"@fluent-wallet/wallet_add-conflux-chain": patch
100+
"@fluent-wallet/wallet_add-ethereum-chain": patch
101+
"@fluent-wallet/wallet_add-hd-path": patch
102+
"@fluent-wallet/wallet_add-network": patch
103+
"@fluent-wallet/wallet_add-pending-user-auth-request": patch
104+
"@fluent-wallet/wallet_add-vault": patch
105+
"@fluent-wallet/wallet_after-unlock": patch
106+
"@fluent-wallet/wallet_chain-id": patch
107+
"@fluent-wallet/wallet_cleanup-tx": patch
108+
"@fluent-wallet/wallet_create-account": patch
109+
"@fluent-wallet/wallet_create-address": patch
110+
"@fluent-wallet/wallet_db-query": patch
111+
"@fluent-wallet/wallet_delete-account": patch
112+
"@fluent-wallet/wallet_delete-account-group": patch
113+
"@fluent-wallet/wallet_delete-app": patch
114+
"@fluent-wallet/wallet_delete-memo": patch
115+
"@fluent-wallet/wallet_delete-network": patch
116+
"@fluent-wallet/wallet_detect-address-type": patch
117+
"@fluent-wallet/wallet_detect-network-type": patch
118+
"@fluent-wallet/wallet_discover-accounts": patch
119+
"@fluent-wallet/wallet_enrich-conflux-tx": patch
120+
"@fluent-wallet/wallet_enrich-ethereum-tx": patch
121+
"@fluent-wallet/wallet_enrich-txs": patch
122+
"@fluent-wallet/wallet_export-account": patch
123+
"@fluent-wallet/wallet_export-account-group": patch
124+
"@fluent-wallet/wallet_export-all": patch
125+
"@fluent-wallet/wallet_generate-address": patch
126+
"@fluent-wallet/wallet_generate-private-key": patch
127+
"@fluent-wallet/wallet_get-account-address-by-network": patch
128+
"@fluent-wallet/wallet_get-account-group": patch
129+
"@fluent-wallet/wallet_get-account-group-vault-value": patch
130+
"@fluent-wallet/wallet_get-address-private-key": patch
131+
"@fluent-wallet/wallet_get-balance": patch
132+
"@fluent-wallet/wallet_get-block-or-epoch-number": patch
133+
"@fluent-wallet/wallet_get-block-time": patch
134+
"@fluent-wallet/wallet_get-blockchain-explorer-url": patch
135+
"@fluent-wallet/wallet_get-current-account": patch
136+
"@fluent-wallet/wallet_get-current-network": patch
137+
"@fluent-wallet/wallet_get-current-viewing-app": patch
138+
"@fluent-wallet/wallet_get-fluent-metadata": patch
139+
"@fluent-wallet/wallet_get-import-hardware-wallet-info": patch
140+
"@fluent-wallet/wallet_get-network": patch
141+
"@fluent-wallet/wallet_get-next-nonce": patch
142+
"@fluent-wallet/wallet_get-next-usable-nonce": patch
143+
"@fluent-wallet/wallet_get-pending-auth-request": patch
144+
"@fluent-wallet/wallet_get-permissions": patch
145+
"@fluent-wallet/wallet_get-preferences": patch
146+
"@fluent-wallet/wallet_handle-unfinished-cfx-tx": patch
147+
"@fluent-wallet/wallet_handle-unfinished-eth-tx": patch
148+
"@fluent-wallet/wallet_handle-unfinished-txs": patch
149+
"@fluent-wallet/wallet_import-address": patch
150+
"@fluent-wallet/wallet_import-all": patch
151+
"@fluent-wallet/wallet_import-hardware-wallet-account-group-or-account": patch
152+
"@fluent-wallet/wallet_import-mnemonic": patch
153+
"@fluent-wallet/wallet_import-private-key": patch
154+
"@fluent-wallet/wallet_metadata-for-popup": patch
155+
"@fluent-wallet/wallet_network1559compatible": patch
156+
"@fluent-wallet/wallet_refetch-balance": patch
157+
"@fluent-wallet/wallet_refetch-token-list": patch
158+
"@fluent-wallet/wallet_refetch-tx-list": patch
159+
"@fluent-wallet/wallet_register-site-metadata": patch
160+
"@fluent-wallet/wallet_request-accounts": patch
161+
"@fluent-wallet/wallet_request-permissions": patch
162+
"@fluent-wallet/wallet_request-unlock-ui": patch
163+
"@fluent-wallet/wallet_send-transaction": patch
164+
"@fluent-wallet/wallet_send-transaction-with-action": patch
165+
"@fluent-wallet/wallet_set-app-current-account": patch
166+
"@fluent-wallet/wallet_set-app-current-network": patch
167+
"@fluent-wallet/wallet_set-current-account": patch
168+
"@fluent-wallet/wallet_set-current-network": patch
169+
"@fluent-wallet/wallet_set-preferences": patch
170+
"@fluent-wallet/wallet_switch-conflux-chain": patch
171+
"@fluent-wallet/wallet_switch-ethereum-chain": patch
172+
"@fluent-wallet/wallet_unlock": patch
173+
"@fluent-wallet/wallet_unwatch-asset": patch
174+
"@fluent-wallet/wallet_update-account": patch
175+
"@fluent-wallet/wallet_update-account-group": patch
176+
"@fluent-wallet/wallet_update-network": patch
177+
"@fluent-wallet/wallet_update-token-list": patch
178+
"@fluent-wallet/wallet_upsert-memo": patch
179+
"@fluent-wallet/wallet_user-approved-auth-request": patch
180+
"@fluent-wallet/wallet_user-rejected-auth-request": patch
181+
"@fluent-wallet/wallet_validate-app-permissions": patch
182+
"@fluent-wallet/wallet_validate-mnemonic": patch
183+
"@fluent-wallet/wallet_validate-password": patch
184+
"@fluent-wallet/wallet_validate-private-key": patch
185+
"@fluent-wallet/wallet_validate20token": patch
186+
"@fluent-wallet/wallet_watch-asset": patch
187+
"@fluent-wallet/wallet_zero-account-group": patch
188+
browser-extension: patch
189+
helios-background: patch
190+
helios-popup: patch
191+
workspace-tools: patch
192+
193+
declined:
194+
- helios
195+
- doc

packages/background/src/init-db.js

+19-18
Original file line numberDiff line numberDiff line change
@@ -245,54 +245,55 @@ function initNetwork(d) {
245245
},
246246
{
247247
network: {
248-
name: ETH_GOERLI_NAME,
249-
endpoint: ETH_GOERLI_RPC_ENDPOINT,
248+
name: ETH_SEPOLIA_NAME,
249+
endpoint: ETH_SEPOLIA_RPC_ENDPOINT,
250250
type: 'eth',
251-
chainId: ETH_GOERLI_CHAINID,
252-
netId: ETH_GOERLI_NETID,
251+
chainId: ETH_SEPOLIA_CHAINID,
252+
netId: ETH_SEPOLIA_NETID,
253253
icon: 'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/Ethereum.svg',
254254
cacheTime: 15000,
255255

256256
ticker: {
257-
name: ETH_GOERLI_CURRENCY_NAME,
258-
symbol: ETH_GOERLI_CURRENCY_SYMBOL,
257+
name: ETH_SEPOLIA_CURRENCY_NAME,
258+
symbol: ETH_SEPOLIA_CURRENCY_SYMBOL,
259259
decimals: DEFAULT_CURRENCY_DECIMALS,
260260
iconUrls: [
261261
'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/eth.svg',
262262
],
263263
},
264-
scanUrl: ETH_GOERLI_EXPLORER_URL,
264+
scanUrl: ETH_SEPOLIA_EXPLORER_URL,
265265
hdPath: -2,
266266
builtin: true,
267267
isTestnet: true,
268-
balanceChecker: '0x9788c4e93f9002a7ad8e72633b11e8d1ecd51f9b',
268+
// TODO(SEPOLIA) There is currently no balance call address for Sepolia
269+
balanceChecker: '',
269270
gasBuffer: 1.5,
270271
},
271272
},
272273
{
273274
network: {
274-
name: ETH_SEPOLIA_NAME,
275-
endpoint: ETH_SEPOLIA_RPC_ENDPOINT,
275+
name: ETH_GOERLI_NAME,
276+
endpoint: ETH_GOERLI_RPC_ENDPOINT,
276277
type: 'eth',
277-
chainId: ETH_SEPOLIA_CHAINID,
278-
netId: ETH_SEPOLIA_NETID,
278+
chainId: ETH_GOERLI_CHAINID,
279+
netId: ETH_GOERLI_NETID,
279280
icon: 'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/Ethereum.svg',
280281
cacheTime: 15000,
281282

282283
ticker: {
283-
name: ETH_SEPOLIA_CURRENCY_NAME,
284-
symbol: ETH_SEPOLIA_CURRENCY_SYMBOL,
284+
name: ETH_GOERLI_CURRENCY_NAME,
285+
symbol: ETH_GOERLI_CURRENCY_SYMBOL,
285286
decimals: DEFAULT_CURRENCY_DECIMALS,
286287
iconUrls: [
287288
'https://cdn.jsdelivr.net/gh/Conflux-Chain/helios@dev/packages/built-in-network-icons/eth.svg',
288289
],
289290
},
290-
scanUrl: ETH_SEPOLIA_EXPLORER_URL,
291+
scanUrl: ETH_GOERLI_EXPLORER_URL,
291292
hdPath: -2,
292-
builtin: true,
293+
builtin: false,
294+
isCustom: true,
293295
isTestnet: true,
294-
// TODO(SEPOLIA) There is currently no balance call address for Sepolia
295-
balanceChecker: '',
296+
balanceChecker: '0x9788c4e93f9002a7ad8e72633b11e8d1ecd51f9b',
296297
gasBuffer: 1.5,
297298
},
298299
},

packages/consts/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const ADDRESS_TYPES = ['user', 'contract', 'builtin', 'null']
2626
// * network setting
2727
export const DEFAULT_CURRENCY_DECIMALS = 18
2828
export const CONFLUX_API_LIMIT_KEY = '1BvViQet4km8KPALkc6Pa9'
29-
export const ETH_API_LIMIT_KEY = '9aa3d95b3bc440fa88ea12eaa4456161'
29+
export const ETH_API_LIMIT_KEY = 'b6bf7d3508c941499b10025c0776eaf8'
3030

3131
export const CFX_MAINNET_RPC_ENDPOINT = `https://main.confluxrpc.com/${CONFLUX_API_LIMIT_KEY}`
3232
export const CFX_MAINNET_NAME = 'Conflux Mainnet'

packages/db/src/main/cfxjs/db/migrations/core.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[cfxjs.db.migrations.m11]
66
[cfxjs.db.migrations.m12]
77
[cfxjs.db.migrations.m13]
8+
[cfxjs.db.migrations.m14]
89
[cfxjs.db.migrations.m2]
910
[cfxjs.db.migrations.m3]
1011
[cfxjs.db.migrations.m4]
@@ -26,5 +27,4 @@
2627
cfxjs.db.migrations.m11/data
2728
cfxjs.db.migrations.m12/data
2829
cfxjs.db.migrations.m13/data
29-
]
30-
)
30+
cfxjs.db.migrations.m14/data])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
(ns cfxjs.db.migrations.m14
2+
(:require
3+
[cfxjs.db.migutil :refer [update-version-tx]]
4+
["@fluent-wallet/consts" :refer [ETH_GOERLI_CHAINID ETH_API_LIMIT_KEY]]
5+
[clojure.string :as str]
6+
[cfxjs.db.datascript.core :as d]))
7+
8+
(def id 14)
9+
10+
(def OLD_ETH_API_LIMIT_KEY "9aa3d95b3bc440fa88ea12eaa4456161")
11+
12+
(defn get-network-id [db chainId chainType] (let [id (d/q '[:find ?net .
13+
:in $ ?chainId ?chainType
14+
:where
15+
[?net :network/builtin true] [?net :network/type ?chainType]
16+
[?net :network/chainId ?chainId]]
17+
db chainId chainType)] id))
18+
19+
(defn up [old-db]
20+
(let [networks (d/q '[:find [(pull ?e [*]) ...]
21+
:in $ ?suffix
22+
:where
23+
[?e :network/builtin true]
24+
[?e :network/endpoint ?endpoint]
25+
[(clojure.string/ends-with? ?endpoint ?suffix)]]
26+
old-db OLD_ETH_API_LIMIT_KEY)
27+
eth-testnet-goerli-id (get-network-id old-db ETH_GOERLI_CHAINID "eth")
28+
txs (mapv (fn [{:db/keys [id] :network/keys [endpoint]}]
29+
{:db/id id
30+
:network/endpoint (str/replace endpoint OLD_ETH_API_LIMIT_KEY ETH_API_LIMIT_KEY)})
31+
networks)
32+
txs (conj txs {:db/id eth-testnet-goerli-id :network/isCustom true :network/builtin false})
33+
new-db (d/db-with old-db (concat txs [(update-version-tx old-db id)]))]
34+
new-db))
35+
36+
(defn down [new-db] new-db)
37+
38+
(def data {:up up :down down :id id})

0 commit comments

Comments
 (0)