- Send native token + transaction type: + + legacy + eip1559 + eip2930 + send native token to myself diff --git a/examples/basic-dapp/index.js b/examples/basic-dapp/index.js index b3f7ff8b8..09013959f 100644 --- a/examples/basic-dapp/index.js +++ b/examples/basic-dapp/index.js @@ -421,10 +421,14 @@ async function walletInitialized() { // send 1 native token to the connected address sendNativeTokenButton.onclick = async () => { const [connectedAddress] = await provider.request({method: 'cfx_accounts'}) + + const txType = document.querySelector('#tx-type').value + const tx = { from: connectedAddress, value: '0xde0b6b3a7640000', to: connectedAddress, + type: txType, } provider diff --git a/package.json b/package.json index 8415448cf..7599f0704 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "helios", "private": true, - "version": "2.7.8", + "version": "2.8.0", "workspaces": [ "websites/*", "packages/doc-ui/*", diff --git a/packages/account/index.js b/packages/account/index.js index a5e607002..36593809b 100644 --- a/packages/account/index.js +++ b/packages/account/index.js @@ -1,7 +1,7 @@ import {getAddress as toChecksumAddress} from '@ethersproject/address' import {computeAddress} from '@ethersproject/transactions' import {Wallet} from '@ethersproject/wallet' -import {randomInt, addHexPrefix} from '@fluent-wallet/utils' +import {randomInt, addHexPrefix, isHexString} from '@fluent-wallet/utils' import { NULL_HEX_ADDRESS, INTERNAL_CONTRACTS_HEX_ADDRESS, @@ -121,6 +121,9 @@ export const randomPrivateKey = () => { export const validatePrivateKey = privateKey => { let valid = false try { + // If the string is not a 64-character hex string, then it is an invalid private key. + if (!isHexString(addHexPrefix(privateKey), 32)) return false + const rst = fromPrivate(privateKey) valid = Boolean(rst.address) } catch (err) { diff --git a/packages/account/package.json b/packages/account/package.json index d14330fec..c0c02b7af 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -1,6 +1,6 @@ { "name": "@fluent-wallet/account", - "version": "1.0.1", + "version": "1.0.3", "type": "module", "main": "index.js", "dependencies": { diff --git a/packages/addr-by-network/package.json b/packages/addr-by-network/package.json index 1b5e0c9bd..7d0761a89 100644 --- a/packages/addr-by-network/package.json +++ b/packages/addr-by-network/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/addr-by-network", "type": "module", "main": "index.js", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/base32-address": "workspace:packages/base32-address", diff --git a/packages/background/package.json b/packages/background/package.json index 9c5462a72..dfd22d5df 100644 --- a/packages/background/package.json +++ b/packages/background/package.json @@ -1,6 +1,6 @@ { "name": "helios-background", - "version": "0.0.15", + "version": "0.0.30", "type": "module", "main": "src/index.js", "private": true, @@ -13,7 +13,9 @@ "@fluent-wallet/cfx_check-balance-against-transaction": "workspace:packages/rpcs/cfx_checkBalanceAgainstTransaction", "@fluent-wallet/cfx_client-version": "workspace:packages/rpcs/cfx_clientVersion", "@fluent-wallet/cfx_epoch-number": "workspace:packages/rpcs/cfx_epochNumber", + "@fluent-wallet/cfx_estimate-1559-fee": "workspace:packages/rpcs/cfx_estimate1559Fee", "@fluent-wallet/cfx_estimate-gas-and-collateral": "workspace:packages/rpcs/cfx_estimateGasAndCollateral", + "@fluent-wallet/cfx_fee-history": "workspace:packages/rpcs/cfx_feeHistory", "@fluent-wallet/cfx_gas-price": "workspace:packages/rpcs/cfx_gasPrice", "@fluent-wallet/cfx_get-account": "workspace:packages/rpcs/cfx_getAccount", "@fluent-wallet/cfx_get-account-pending-info": "workspace:*", @@ -30,6 +32,7 @@ "@fluent-wallet/cfx_get-code": "workspace:packages/rpcs/cfx_getCode", "@fluent-wallet/cfx_get-collateral-for-storage": "workspace:packages/rpcs/cfx_getCollateralForStorage", "@fluent-wallet/cfx_get-confirmation-risk-by-hash": "workspace:packages/rpcs/cfx_getConfirmationRiskByHash", + "@fluent-wallet/cfx_get-fee-burnt": "workspace:packages/rpcs/cfx_getFeeBurnt", "@fluent-wallet/cfx_get-interest-rate": "workspace:*", "@fluent-wallet/cfx_get-logs": "workspace:packages/rpcs/cfx_getLogs", "@fluent-wallet/cfx_get-max-gas-limit": "workspace:*", @@ -46,6 +49,7 @@ "@fluent-wallet/cfx_get-transaction-by-hash": "workspace:packages/rpcs/cfx_getTransactionByHash", "@fluent-wallet/cfx_get-transaction-receipt": "workspace:packages/rpcs/cfx_getTransactionReceipt", "@fluent-wallet/cfx_get-vote-list": "workspace:packages/rpcs/cfx_getVoteList", + "@fluent-wallet/cfx_max-priority-fee-per-gas": "workspace:packages/rpcs/cfx_maxPriorityFeePerGas", "@fluent-wallet/cfx_net-version": "workspace:packages/rpcs/cfx_netVersion", "@fluent-wallet/cfx_opened-method-groups": "workspace:*", "@fluent-wallet/cfx_request-accounts": "workspace:packages/rpcs/cfx_requestAccounts", diff --git a/packages/background/src/index.integration.test.js b/packages/background/src/index.integration.test.js index 3c132c7dd..22f62f094 100644 --- a/packages/background/src/index.integration.test.js +++ b/packages/background/src/index.integration.test.js @@ -160,6 +160,34 @@ describe('integration test', () => { }) describe('rpcs', () => { + describe('cfx_getFeeBurnt', async () => { + test('cfx_getFeeBurnt', async () => { + const result = await request({method: 'cfx_getFeeBurnt'}) + expect(result.result.startsWith('0x')).toBeTruthy() + }) + }) + + describe('cfx_maxPriorityFeePerGas', async () => { + test('cfx_maxPriorityFeePerGas', async () => { + const result = await request({method: 'cfx_maxPriorityFeePerGas'}) + expect(result.result.startsWith('0x')).toBeTruthy() + }) + }) + + describe('cfx_feeHistory', async () => { + test('cfx_feeHistory', async () => { + const result = await request({ + method: 'cfx_feeHistory', + params: ['0x5', 'latest_state', [20, 30]], + }) + console.log(result) + expect(result.result.baseFeePerGas.length).toBe(6) + expect(result.result.gasUsedRatio.length).toBe(5) + expect(result.result.oldestEpoch).toBeDefined() + expect(result.result.reward.length).toBe(5) + }) + }) + describe('cfx_getStatus', () => { test('cfx_getStatus', async () => { const stat = await request({method: 'cfx_getStatus'}) @@ -251,8 +279,40 @@ describe('integration test', () => { ).toBe('1337') }) }) + + describe('cfx_call', async () => { + test('cfx_call', async () => { + const {token1} = await deployCRC20() + await request({ + method: 'wallet_importMnemonic', + params: {mnemonic: MNEMONIC, password}, + }) + expect( + ( + await request({ + method: 'cfx_call', + params: [ + { + to: token1.contractAddress, + data: '0x06fdde03', + maxPriorityFeePerGas: '0x4a817c800', + maxFeePerGas: '0x4a817c800', + type: '0x2', + }, + ], + }) + ).result.startsWith('0x'), + ).toBe(true) + }) + }) + describe('cfx_estimateGasAndCollateral', () => { test('cfx_estimateGasAndCollateral', async () => { + const {token1} = await deployCRC20() + await request({ + method: 'wallet_importMnemonic', + params: {mnemonic: MNEMONIC, password}, + }) res = await request({ method: 'cfx_estimateGasAndCollateral', params: [{}], @@ -261,6 +321,23 @@ describe('integration test', () => { expect(res.result.gasLimit).toBeDefined() expect(res.result.gasUsed).toBeDefined() expect(res.result.storageCollateralized).toBeDefined() + + const estimateRes = await request({ + method: 'cfx_estimateGasAndCollateral', + params: [ + { + type: '0x2', + to: token1.contractAddress, + data: '0x06fdde03', + maxPriorityFeePerGas: '0x4a817c800', + maxFeePerGas: '0x4a817c800', + }, + ], + }) + expect(estimateRes?.result).toBeDefined() + expect(estimateRes.result.gasLimit).toBeDefined() + expect(estimateRes.result.gasUsed).toBeDefined() + expect(estimateRes.result.storageCollateralized).toBeDefined() }) }) describe('eth_estimateGas', () => { @@ -322,7 +399,10 @@ describe('integration test', () => { ( await request({ method: 'wallet_deleteNetwork', - params: {password, networkId: db.getNetworkByType('eth')[0].eid}, + params: { + password, + networkId: db.getNetworkByType('eth')[0].eid, + }, }) ).result, ).toBe(true) @@ -352,7 +432,10 @@ describe('integration test', () => { ( await request({ method: 'wallet_deleteNetwork', - params: {password, networkId: db.getNetworkByName('foo')[0].eid}, + params: { + password, + networkId: db.getNetworkByName('foo')[0].eid, + }, }) ).error.message, ).toMatch(/Not allowed to delete builtin network/) @@ -1135,7 +1218,11 @@ describe('integration test', () => { expect(authReq.site.origin).toBe('foo.site') expect(authReq.req.method).toBe('wallet_requestPermissions') expect(authReq.req.params).toStrictEqual([ - {wallet_basic: {}, wallet_accounts: {}}, + { + wallet_basic: {}, + wallet_accounts: {}, + wallet_crossNetworkTypeGetConfluxBase32Address: {}, + }, ]) const res2 = await request({ @@ -1185,7 +1272,11 @@ describe('integration test', () => { expect(authReq.site.origin).toBe('foo.site') expect(authReq.req.method).toBe('wallet_requestPermissions') expect(authReq.req.params).toStrictEqual([ - {wallet_basic: {}, wallet_accounts: {}}, + { + wallet_basic: {}, + wallet_accounts: {}, + wallet_crossNetworkTypeGetConfluxBase32Address: {}, + }, ]) expect(db.getApp().length).toBe(0) @@ -1208,7 +1299,11 @@ describe('integration test', () => { // app is from the right site expect(app.site.eid).toBe(db.getSite()[0].eid) // app has the right permissions - expect(app.perms).toStrictEqual({wallet_accounts: {}, wallet_basic: {}}) + expect(app.perms).toStrictEqual({ + wallet_accounts: {}, + wallet_basic: {}, + wallet_crossNetworkTypeGetEthereumHexAddress: {}, + }) // app has the right authed accounts expect( app.account.map(a => [a1.eid, a2.eid].includes(a.eid)), @@ -1228,6 +1323,7 @@ describe('integration test', () => { 'wallet_accounts', 'cfx_accounts', 'eth_accounts', + 'wallet_crossNetworkTypeGetEthereumHexAddress', ]) res = await request({ method: 'wallet_getPermissions', @@ -1241,6 +1337,7 @@ describe('integration test', () => { true, true, true, + true, ]) expect(res.result.map(({invoker}) => invoker === 'foo.site')).toEqual([ true, @@ -1249,6 +1346,7 @@ describe('integration test', () => { true, true, true, + true, ]) }) test('from popup', async () => { @@ -1282,7 +1380,11 @@ describe('integration test', () => { // app is from the right site expect(app.site.eid).toBe(db.getSite()[0].eid) // app has the right permissions - expect(app.perms).toStrictEqual({wallet_accounts: {}, wallet_basic: {}}) + expect(app.perms).toStrictEqual({ + wallet_accounts: {}, + wallet_basic: {}, + wallet_crossNetworkTypeGetEthereumHexAddress: {}, + }) // app has the right authed accounts expect( app.account.map(a => [a1.eid, a2.eid].includes(a.eid)), @@ -1299,6 +1401,7 @@ describe('integration test', () => { 'wallet_accounts', 'cfx_accounts', 'eth_accounts', + 'wallet_crossNetworkTypeGetEthereumHexAddress', ]) }) }) @@ -1622,7 +1725,10 @@ describe('integration test', () => { ( await request({ method: 'wallet_getAddressPrivateKey', - params: {address: addr.value, accountId: db.getAccount()[0].eid}, + params: { + address: addr.value, + accountId: db.getAccount()[0].eid, + }, _internal: true, }) ).error.message, @@ -2753,6 +2859,36 @@ describe('integration test', () => { from: CFX_ACCOUNTS[0].base32, to: CFX_ACCOUNTS[1].base32, value: '0x1', + type: '0x0', + }, + ], + _popup: true, + }) + expect(res.result).toBeDefined() + expect(res.result.startsWith('0x')).toBe(true) + + res = await request({ + method: 'cfx_sendTransaction', + params: [ + { + from: CFX_ACCOUNTS[0].base32, + to: CFX_ACCOUNTS[1].base32, + value: '0x1', + type: '0x1', + }, + ], + _popup: true, + }) + expect(res.result).toBeDefined() + expect(res.result.startsWith('0x')).toBe(true) + res = await request({ + method: 'cfx_sendTransaction', + params: [ + { + from: CFX_ACCOUNTS[0].base32, + to: CFX_ACCOUNTS[1].base32, + value: '0x1', + type: '0x2', }, ], _popup: true, @@ -2776,6 +2912,22 @@ describe('integration test', () => { to: CFX_ACCOUNTS[1].base32, data: '0x10', value: '0x1', + type: '0x0', + }, + ], + _popup: true, + }) + expect(res.result).toBeDefined() + expect(res.result.startsWith('0x')).toBe(true) + res = await request({ + method: 'cfx_sendTransaction', + params: [ + { + from: CFX_ACCOUNTS[0].base32, + to: CFX_ACCOUNTS[1].base32, + data: '0x10', + value: '0x1', + type: '0x2', }, ], _popup: true, diff --git a/packages/background/src/init-db.js b/packages/background/src/init-db.js index 4f475eeab..ec06ab3ca 100644 --- a/packages/background/src/init-db.js +++ b/packages/background/src/init-db.js @@ -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, }, }, diff --git a/packages/background/src/rpc-engine-opts.js b/packages/background/src/rpc-engine-opts.js index 1a11ffda9..1eb585044 100644 --- a/packages/background/src/rpc-engine-opts.js +++ b/packages/background/src/rpc-engine-opts.js @@ -91,6 +91,10 @@ import * as cfxSendRawTransaction from '@fluent-wallet/cfx_send-raw-transaction' import * as cfxSendTransaction from '@fluent-wallet/cfx_send-transaction' import * as cfxSignTransaction from '@fluent-wallet/cfx_sign-transaction' import * as cfxTypedSignV4 from '@fluent-wallet/cfx_sign-typed-data_v4' +import * as cfxMaxPriorityFeePerGas from '@fluent-wallet/cfx_max-priority-fee-per-gas' +import * as cfxFeeHistory from '@fluent-wallet/cfx_fee-history' +import * as cfxGetFeeBurnt from '@fluent-wallet/cfx_get-fee-burnt' +import * as cfxEstimate1559Fee from '@fluent-wallet/cfx_estimate-1559-fee' import * as ethAccounts from '@fluent-wallet/eth_accounts' import * as ethBlockNumber from '@fluent-wallet/eth_block-number' import * as ethCall from '@fluent-wallet/eth_call' @@ -320,6 +324,10 @@ export const rpcEngineOpts = { cfxSendTransaction, cfxSignTxWithLedgerNanoS, cfxGetMaxGasLimit, + cfxMaxPriorityFeePerGas, + cfxFeeHistory, + cfxGetFeeBurnt, + cfxEstimate1559Fee, // eth ethGetCode, diff --git a/packages/base32-address/package.json b/packages/base32-address/package.json index c85ff7c58..9cf973b27 100644 --- a/packages/base32-address/package.json +++ b/packages/base32-address/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/base32-address", "type": "module", "main": "index.js", - "version": "0.1.3", + "version": "0.1.4", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/consts": "workspace:packages/consts", diff --git a/packages/browser-extension/package.json b/packages/browser-extension/package.json index e0d89939d..ae72d3ad8 100644 --- a/packages/browser-extension/package.json +++ b/packages/browser-extension/package.json @@ -1,6 +1,6 @@ { "name": "browser-extension", - "version": "0.0.13", + "version": "0.0.30", "main": "index.js", "author": "yqrashawn ", "license": "MIT", diff --git a/packages/conflux-tx-error/index.js b/packages/conflux-tx-error/index.js index d0a33a7fd..2bcc53649 100644 --- a/packages/conflux-tx-error/index.js +++ b/packages/conflux-tx-error/index.js @@ -1,3 +1,5 @@ +import {ERROR} from '@fluent-wallet/json-rpc-error' + // shouldDiscard means should stop tracking this tx export function processError(err) { if (typeof err?.data === 'string') { @@ -32,6 +34,10 @@ export function processError(err) { if (err.data?.includes?.('Can not recover pubkey')) return {errorType: 'canNotRecoverPubKey', shouldDiscard: true} } + // network error + if (err?.code === ERROR.SERVER.code) { + return {errorType: ERROR.SERVER.name, shouldDiscard: false} + } return {errorType: 'unknownError', shouldDiscard: true} } diff --git a/packages/conflux-tx-error/package.json b/packages/conflux-tx-error/package.json index 31a480c9e..720df51c0 100644 --- a/packages/conflux-tx-error/package.json +++ b/packages/conflux-tx-error/package.json @@ -3,5 +3,8 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.6" + "version": "1.0.0", + "dependencies": { + "@fluent-wallet/json-rpc-error": "workspace:packages/json-rpc-error" + } } diff --git a/packages/consts/index.js b/packages/consts/index.js index 96afa308c..20291dd6b 100644 --- a/packages/consts/index.js +++ b/packages/consts/index.js @@ -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' diff --git a/packages/consts/package.json b/packages/consts/package.json index 1f0c3dac6..16720f3f6 100644 --- a/packages/consts/package.json +++ b/packages/consts/package.json @@ -2,5 +2,5 @@ "name": "@fluent-wallet/consts", "type": "module", "main": "index.js", - "version": "0.0.23" + "version": "0.0.24" } diff --git a/packages/contract-method-name/package.json b/packages/contract-method-name/package.json index 95c3e7b54..b3e5efd13 100644 --- a/packages/contract-method-name/package.json +++ b/packages/contract-method-name/package.json @@ -1,7 +1,7 @@ { "name": "@fluent-wallet/contract-method-name", "type": "module", - "version": "2.0.1", + "version": "2.0.2", "main": "index.js", "dependencies": { "@ethersproject/abi": "5.6.3", diff --git a/packages/db/package.json b/packages/db/package.json index 6c4abdc57..136450467 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@fluent-wallet/db", - "version": "1.0.71", + "version": "1.0.77", "main": "index.js", "type": "module", "files": [ diff --git a/packages/db/src/main/cfxjs/db/migrations/core.cljs b/packages/db/src/main/cfxjs/db/migrations/core.cljs index 9bd67fb43..e6962dd8c 100644 --- a/packages/db/src/main/cfxjs/db/migrations/core.cljs +++ b/packages/db/src/main/cfxjs/db/migrations/core.cljs @@ -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] @@ -26,5 +27,4 @@ cfxjs.db.migrations.m11/data cfxjs.db.migrations.m12/data cfxjs.db.migrations.m13/data - ] - ) + cfxjs.db.migrations.m14/data]) diff --git a/packages/db/src/main/cfxjs/db/migrations/m14.cljs b/packages/db/src/main/cfxjs/db/migrations/m14.cljs new file mode 100644 index 000000000..e3144dfa2 --- /dev/null +++ b/packages/db/src/main/cfxjs/db/migrations/m14.cljs @@ -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}) \ No newline at end of file diff --git a/packages/db/src/main/cfxjs/db/queries.cljs b/packages/db/src/main/cfxjs/db/queries.cljs index 1d1538c11..2e3095a1b 100644 --- a/packages/db/src/main/cfxjs/db/queries.cljs +++ b/packages/db/src/main/cfxjs/db/queries.cljs @@ -642,57 +642,42 @@ return [txs sideeffects] to handle the hidden account" [{:keys [accountId]}] (let [apps-data - (q '[:find ?app (count-distinct ?all-acc) ?current-acc + (q '[:find ?app (distinct ?available-acc) ?current-acc :in $ ?acc :where [?app :app/account ?acc] - [?app :app/account ?all-acc] [?app :app/currentAccount ?curacc] - [(= ?curacc ?acc) ?current-acc]] + [(= ?curacc ?acc) ?current-acc] + [?app :app/account ?available-acc] + ;; make sure available acc has addr in current net + [?available-acc :account/address ?addr] + [?addr :address/network ?net] + [?net :network/selected true]] accountId) ->txs ;; txs: transactions send to db ;; sideeffects: methods to call in js to notify app - (fn [[txs sideeffects] [app-id authed-acc-count current-acc?]] + (fn [[txs sideeffects] [app-id available-acc-ids current-acc?]] (bc/cond - ;; hidden acc is the only and current authed acc of app + :let + [next-available-acc + (some #(when (not= % accountId) %) available-acc-ids)] + ;; hidden acc is the only available and current acc of app ;; delete the app - (and current-acc? (= authed-acc-count 1)) + (and current-acc? (nil? next-available-acc)) [txs (conj sideeffects [:wallet_deleteApp {:appId app-id}])] - ;; hidden acc is not current acc of dapp (more than 1 authed acc) + ;; hidden acc is not current acc of dapp (more than 1 available acc) ;; unauth acc (not current-acc?) [(conj txs [:db/retract app-id :app/account accountId]) sideeffects] - ;; hidden acc is current acc of app and app has multiple authed acc + ;; hidden acc is current acc of app and app has multiple available acc ;; switch current acc, unauth acc - :let - [app-switch-acc-data - (q '[:find ?app (distinct ?next-acc) - :in $ ?acc - :where - [?app :app/currentAccount ?acc] - [?app :app/account ?next-acc] - (not [(= ?next-acc ?acc)]) - ;; make sure next acc has addr in current net - [?next-acc :account/address ?addr] - [?addr :address/network ?net] - [?net :network/selected true]] - accountId) - - ->txs - (fn [[txs sideeffects] [app-id next-acc-ids]] - (if (first next-acc-ids) - ;; has next acc - [(conj txs [:db/retract app-id :app/account accountId]) - (conj sideeffects [:wallet_setAppCurrentAccount {:appId app-id :accountId (first next-acc-ids)}])] - ;; no next acc (next authed acc is hw acc and no addr under current net) - [txs (conj sideeffects [:wallet_deleteApp {:appId app-id}])]))] - :else - (reduce ->txs [txs sideeffects] app-switch-acc-data)))] + [(conj txs [:db/retract app-id :app/account accountId]) + (conj sideeffects [:wallet_setAppCurrentAccount {:appId app-id :accountId next-available-acc}])]))] (reduce ->txs [[] []] apps-data))) (defn update-account [{:keys [accountId nickname hidden offline]}] @@ -1159,6 +1144,68 @@ txs (map (fn [eid] [:db.fn/retractEntity eid]) tokens)] (t txs))) +(defn get-deleted-group-apps + "Given to-delete groupId, find apps which authed with accounts in this group, + return [txs sideeffects] to handle the deleted group" + [{:keys [groupId]}] + (let [accounts-in-group + (q '[:find [?acc ...] + :in $ ?g + :where + [?g :accountGroup/account ?acc]] + groupId) + apps-data + (q '[:find ?app (distinct ?available-acc) ?current-acc + :in $ [?acc ...] + :where + [?app :app/account ?acc] + [?app :app/currentAccount ?curacc] + [(= ?curacc ?acc) ?current-acc] + [?app :app/account ?available-acc] + ;; make sure available acc has addr in current net + [?available-acc :account/address ?addr] + [?addr :address/network ?net] + [?net :network/selected true]] + accounts-in-group) + + ->merge-and-deduplicate + (fn [result item] + (let [[appid accounts bool] item] + (if (contains? result appid) + (update result appid (fn [[deleted-accounts next-account current-group?]] [deleted-accounts next-account (or current-group? bool)])) + (assoc result appid [(filter #(contains? (set accounts-in-group) %) accounts) (some #(when (not (contains? (set accounts-in-group) %)) %) accounts) bool])))) + + ;; format apps-data to {appid [deleted-accounts next-account current-group?]} + processed-data (reduce ->merge-and-deduplicate {} apps-data) + ;; format processed-data to [[appid deleted-accounts next-account current-group?]] + final-data (into [] (mapv (fn [[k v]] (into [k] v)) processed-data)) + + ->txs + ;; txs: transactions send to db + ;; sideeffects: methods to call in js to notify app + ;; deleted-accounts is accounts that need to unauth in app + ;; next-account is next available account in app, nil if no available account + ;; current-group? is true if app's current account is in deleted group + (fn [[txs sideeffects] [app-id deleted-accounts next-account current-group?]] + (bc/cond + :let + [unauth-txs + (mapv #(vector :db/retract app-id :app/account %) deleted-accounts)] + ;; deleted group is current group of app and next-account is null + ;; delete the app + (and current-group? (nil? next-account)) + [txs (conj sideeffects [:wallet_deleteApp {:appId app-id}])] + ;; deleted group is not current group of dapp and has available account in other group + ;; unauth acc + (not current-group?) + [(concat txs unauth-txs) sideeffects] + + ;; deleted group is current group of app and app has available account in other group + ;; switch current acc, unauth acc + :else + [(concat txs unauth-txs) (conj sideeffects [:wallet_setAppCurrentAccount {:appId app-id :accountId next-account}])]))] + (reduce ->txs [[] []] final-data))) + (defn retract-group "used to retract account group" [{:keys [groupId]}] @@ -1180,10 +1227,12 @@ groupId) addrs-to-delete (filter #(not (some #{%} addrs-has-accs-not-in-group)) addrs-in-group) txs (mapv #(vector :db.fn/retractEntity %) addrs-to-delete) - txs (conj txs [:db.fn/retractEntity groupId])] + txs (conj txs [:db.fn/retractEntity groupId]) + [apps-txs apps-sideeffects] (get-deleted-group-apps {:groupId groupId}) + txs (concat txs apps-txs)] (t txs) (cleanup-token-list-after-delete-address) - true)) + apps-sideeffects)) (defn retract-account "used to retract accounts" @@ -1205,6 +1254,7 @@ addrs-to-delete (filter #(not (some #{%} addrs-has-other-accs)) addrs-in-account) txs (mapv #(vector :db.fn/retractEntity %) addrs-to-delete) txs (conj txs [:db.fn/retractEntity accountId]) + [apps-txs apps-sideeffects] (get-hidden-account-apps {:accountId accountId}) vault (when hwVaultData (q '[:find ?vault . @@ -1213,10 +1263,11 @@ [?group :accountGroup/account ?acc] [?group :accountGroup/vault ?vault]] accountId)) - txs (enc/conj-when txs (and vault {:db/id vault :vault/data hwVaultData}))] + txs (enc/conj-when txs (and vault {:db/id vault :vault/data hwVaultData})) + txs (concat txs apps-txs)] (t txs) (cleanup-token-list-after-delete-address) - true)) + apps-sideeffects)) (defn retract-network [{:keys [networkId]}] (let [addrs (q '[:find [?addr ...] @@ -2075,6 +2126,23 @@ (assoc :app (and app-id (e :app app-id))) (assoc :token (and token-id (e :token token-id)))))) +(defn get-tx-with-same-nonce [{:keys [hash]}] + (let [txs + (q '[:find [?txs ...] + :in $ ?tx + :where + [?address :address/tx ?tx] + [?tx :tx/txPayload ?payload] + [?payload :txPayload/nonce ?nonce] + [?address :address/tx ?txs] + [?txs :tx/txPayload ?tx-payload] + [?tx-payload :txPayload/nonce ?nonce] + [?address :address/value ?addrv] + [?tx-payload :txPayload/from ?addrv]] + [:tx/hash hash])] + (when txs + (mapv tx-id->data txs)))) + (defn get-tx [{:keys [hash]}] (let [tx (q '[:find ?tx . :in $ ?tx @@ -2264,6 +2332,7 @@ :upsertMemo upsert-memo :queryNonceGapTxs query-nonce-gap-txs :insertExternalTx insert-external-tx + :queryTxWithSameNonce get-tx-with-same-nonce :queryqueryRecentInterestingAddress get-recent-interesting-address-from-tx :queryqueryApp get-apps diff --git a/packages/detect-address-type/package.json b/packages/detect-address-type/package.json index a7ec800ca..6b9cd7d28 100644 --- a/packages/detect-address-type/package.json +++ b/packages/detect-address-type/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/base32-address": "workspace:packages/base32-address", "@fluent-wallet/checks": "workspace:packages/checks" diff --git a/packages/did/package.json b/packages/did/package.json index 168fabdff..fe5194a27 100644 --- a/packages/did/package.json +++ b/packages/did/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/did", "main": "index.js", "type": "module", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@ensdomains/eth-ens-namehash": "2.0.15", "@fluent-wallet/base32-address": "workspace:packages/base32-address", diff --git a/packages/estimate-tx/cfx.js b/packages/estimate-tx/cfx.js index 328aed32b..ee9d07fa1 100644 --- a/packages/estimate-tx/cfx.js +++ b/packages/estimate-tx/cfx.js @@ -1,6 +1,7 @@ import BN from 'bn.js' import {bn16, pre0x} from './util.js' - +import {ETH_TX_TYPES} from '@fluent-wallet/consts' +import Big from 'big.js' async function cfxEstimateGasAndCollateralAdvance(request, tx) { try { const estimateRst = await request({ @@ -98,8 +99,19 @@ export const cfxEstimate = async ( nonce: customNonce, data, value, + type, + maxPriorityFeePerGas: customMaxPriorityFeePerGas, + maxFeePerGas: customMaxFeePerGas, } = newTx - let gasPrice, nonce + let gasPrice, nonce, maxPriorityFeePerGas, maxFeePerGas, gasInfoEip1559 + + const network1559Compatible = await request({ + method: 'wallet_network1559Compatible', + }) + + // If the network support EIP1559 transaction, we will send EIP1559-type tx first. + const isTxTreatedAsEIP1559 = + network1559Compatible && (!type || type === ETH_TX_TYPES.EIP1559) if (!from) throw new Error(`Invalid from ${from}`) // if (networkId !== undefined && !Number.isInteger(networkId)) @@ -145,9 +157,34 @@ export const cfxEstimate = async ( ) // get gasPrice - await request({method: 'cfx_gasPrice'}).then(r => { - gasPrice = r - }) + if (!isTxTreatedAsEIP1559) { + await request({method: 'cfx_gasPrice'}).then(r => { + gasPrice = r + }) + } + + //fetch maxPriorityFeePerGas and maxFeePerGas + + if (isTxTreatedAsEIP1559) { + await request({method: 'cfx_estimate1559Fee'}).then(gasInfo => { + gasInfoEip1559 = gasInfo + const {suggestedMaxPriorityFeePerGas, suggestedMaxFeePerGas} = + gasInfo?.medium || {} + maxPriorityFeePerGas = pre0x( + new BN( + new Big(suggestedMaxPriorityFeePerGas) + .round(9) + .times('1e9') + .toString(10), + ).toString(16), + ) + maxFeePerGas = pre0x( + new BN( + new Big(suggestedMaxFeePerGas).round(9).times('1e9').toString(10), + ).toString(16), + ) + }) + } // get nonce, since it may affect estimateGasAndCollateral result if (!nonce) { @@ -166,14 +203,15 @@ export const cfxEstimate = async ( // simple send tx, gas is 21000, storageLimit is 0 if (to && (!data || data === '0x')) { - const clcGasPrice = customGasPrice || gasPrice - const clcGasLimit = customGasLimit || '0x5208' /* 21000 */ - const clcStorageLimit = customStorageLimit || '0x0' + const calcGasPrice = customGasPrice || gasPrice + const calcGasLimit = customGasLimit || '0x5208' /* 21000 */ + const calcStorageLimit = customStorageLimit || '0x0' + const calcMaxFeePerGas = customMaxFeePerGas || maxFeePerGas const cfxFeeData = cfxGetFeeData( { - gasPrice: clcGasPrice, - gas: clcGasLimit, - storageLimit: clcStorageLimit, + gasPrice: isTxTreatedAsEIP1559 ? calcMaxFeePerGas : calcGasPrice, + gas: calcGasLimit, + storageLimit: calcStorageLimit, value, }, {balance: balances['0x0']}, @@ -188,8 +226,13 @@ export const cfxEstimate = async ( nonce, customGasPrice, customGasLimit, - customStorageLimit, customNonce, + customStorageLimit, + customMaxPriorityFeePerGas, + maxFeePerGas, + maxPriorityFeePerGas, + customMaxFeePerGas, + gasInfoEip1559, willPayCollateral: true, willPayTxFee: true, } @@ -200,14 +243,17 @@ export const cfxEstimate = async ( delete newTx.gas delete newTx.storageLimit delete newTx.gasPrice + delete newTx.maxFeePerGas + delete newTx.maxPriorityFeePerGas newTx.nonce = nonce // run estimate let rst = await cfxEstimateGasAndCollateralAdvance(request, newTx) const {gasLimit, storageCollateralized} = rst - const clcGasPrice = customGasPrice || gasPrice - const clcGasLimit = customGasLimit || gasLimit - const clcStorageLimit = customStorageLimit || storageCollateralized + const calcGasPrice = customGasPrice || gasPrice + const calcMaxFeePerGas = customMaxFeePerGas || maxFeePerGas + const calcGasLimit = customGasLimit || gasLimit + const calcStorageLimit = customStorageLimit || storageCollateralized rst = { ...rst, @@ -221,17 +267,17 @@ export const cfxEstimate = async ( from, to, // prioritiz custom value so that user can adjust them for sponsorship - clcGasLimit, - clcGasPrice, - clcStorageLimit, + calcGasLimit, + isTxTreatedAsEIP1559 ? calcMaxFeePerGas : calcGasPrice, + calcStorageLimit, 'latest_state', ], }) const cfxFeeData = cfxGetFeeData( { - gasPrice: clcGasPrice, - gas: clcGasLimit, - storageLimit: clcStorageLimit, + gasPrice: isTxTreatedAsEIP1559 ? calcMaxFeePerGas : calcGasPrice, + gas: calcGasLimit, + storageLimit: calcStorageLimit, value, tokensAmount, }, @@ -247,9 +293,9 @@ export const cfxEstimate = async ( } else { const cfxFeeData = cfxGetFeeData( { - gasPrice: clcGasPrice, - gas: clcGasLimit, - storageLimit: clcStorageLimit, + gasPrice: isTxTreatedAsEIP1559 ? calcMaxFeePerGas : calcGasPrice, + gas: calcGasLimit, + storageLimit: calcStorageLimit, value, }, {balance: balances['0x0']}, @@ -268,6 +314,11 @@ export const cfxEstimate = async ( rst.customGasLimit = customGasLimit rst.customStorageLimit = customStorageLimit rst.customNonce = customNonce + rst.maxPriorityFeePerGas = maxPriorityFeePerGas + rst.customMaxPriorityFeePerGas = customMaxPriorityFeePerGas + rst.maxFeePerGas = maxFeePerGas + rst.customMaxFeePerGas = customMaxFeePerGas + rst.gasInfoEip1559 = gasInfoEip1559 return rst } diff --git a/packages/estimate-tx/eth.js b/packages/estimate-tx/eth.js index 763e01270..4359af6f5 100644 --- a/packages/estimate-tx/eth.js +++ b/packages/estimate-tx/eth.js @@ -184,13 +184,13 @@ export const ethEstimate = async ( // simple send tx, gas is 21000 if (to && (!data || data === '0x')) { - const clcGasPrice = customGasPrice || gasPrice - const clcGasLimit = customGasLimit || '0x5208' /* 21000 */ - const clcMaxFeePerGas = customMaxFeePerGas || maxFeePerGas + const calcGasPrice = customGasPrice || gasPrice + const calcGasLimit = customGasLimit || '0x5208' /* 21000 */ + const calcMaxFeePerGas = customMaxFeePerGas || maxFeePerGas const ethFeeData = ethGetFeeData( { - gasPrice: isTxTreatedAsEIP1559 ? clcMaxFeePerGas : clcGasPrice, - gas: clcGasLimit, + gasPrice: isTxTreatedAsEIP1559 ? calcMaxFeePerGas : calcGasPrice, + gas: calcGasLimit, value, }, {balance: balances['0x0']}, @@ -229,9 +229,9 @@ export const ethEstimate = async ( request({method: 'eth_chainId'}), ]) const {gasLimit} = rst - const clcGasPrice = customGasPrice || gasPrice - const clcMaxFeePerGas = customMaxFeePerGas || maxFeePerGas - const clcGasLimit = + const calcGasPrice = customGasPrice || gasPrice + const calcMaxFeePerGas = customMaxFeePerGas || maxFeePerGas + const calcGasLimit = customGasLimit || pre0x( bn16(gasLimit) @@ -245,8 +245,8 @@ export const ethEstimate = async ( if (toAddressType === 'contract') { const ethFeeData = ethGetFeeData( { - gasPrice: isTxTreatedAsEIP1559 ? clcMaxFeePerGas : clcGasPrice, - gas: clcGasLimit, + gasPrice: isTxTreatedAsEIP1559 ? calcMaxFeePerGas : calcGasPrice, + gas: calcGasLimit, value, tokensAmount, }, @@ -259,8 +259,8 @@ export const ethEstimate = async ( } else { const ethFeeData = ethGetFeeData( { - gasPrice: isTxTreatedAsEIP1559 ? clcMaxFeePerGas : clcGasPrice, - gas: clcGasLimit, + gasPrice: isTxTreatedAsEIP1559 ? calcMaxFeePerGas : calcGasPrice, + gas: calcGasLimit, value, }, {balance: balances['0x0']}, diff --git a/packages/estimate-tx/package.json b/packages/estimate-tx/package.json index c4ab6a201..47ff65426 100644 --- a/packages/estimate-tx/package.json +++ b/packages/estimate-tx/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.2.3", + "version": "0.2.5", "dependencies": { "@fluent-wallet/consts": "workspace:*", "@fluent-wallet/detect-address-type": "workspace:packages/detect-address-type", diff --git a/packages/ethereum-tx-error/index.js b/packages/ethereum-tx-error/index.js index 0de8de1ab..5271fc867 100644 --- a/packages/ethereum-tx-error/index.js +++ b/packages/ethereum-tx-error/index.js @@ -1,3 +1,5 @@ +import {ERROR} from '@fluent-wallet/json-rpc-error' + // shouldDiscard means should stop tracking this tx // error from geth txpool error // https://github.com/ethereum/go-ethereum/blob/2d20fed893faa894f50af709349b13b6ad9b45db/core/tx_pool.go#L56 @@ -67,6 +69,10 @@ export function processError(err) { if (/invalid chainid/i.test(errstr)) return {errorType: 'chainIdMismatch', shouldDiscard: true} } + // network error + if (err?.code === ERROR.SERVER.code) { + return {errorType: ERROR.SERVER.name, shouldDiscard: false} + } return {errorType: 'unknownError', shouldDiscard: true} } diff --git a/packages/ethereum-tx-error/package.json b/packages/ethereum-tx-error/package.json index e2cb7de80..30d6e5284 100644 --- a/packages/ethereum-tx-error/package.json +++ b/packages/ethereum-tx-error/package.json @@ -3,5 +3,8 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "1.0.2" + "version": "1.0.3", + "dependencies": { + "@fluent-wallet/json-rpc-error": "workspace:packages/json-rpc-error" + } } diff --git a/packages/inner-utils/env.js b/packages/inner-utils/env.js index fc664cb2d..ff57e05a1 100644 --- a/packages/inner-utils/env.js +++ b/packages/inner-utils/env.js @@ -7,3 +7,6 @@ export const IS_PROD_MODE = MODE === 'production' export const IS_CI = process.env.CI === 'true' export const PACKAGE_VERSION = process.env.PACKAGE_VERSION +// this version is use by view, it include the version suffix e.g v1.0.0.rc-1 +export const VIEW_PACKAGE_VERSION = + process.env.VIEW_PACKAGE_VERSION || PACKAGE_VERSION diff --git a/packages/inner-utils/package.json b/packages/inner-utils/package.json index 48ec6f095..4233b551d 100644 --- a/packages/inner-utils/package.json +++ b/packages/inner-utils/package.json @@ -3,5 +3,5 @@ "type": "module", "main": "index.js", "private": true, - "version": "0.0.5" + "version": "0.0.7" } diff --git a/packages/inpage/eip-6963.js b/packages/inpage/eip-6963.js new file mode 100644 index 000000000..20db045bb --- /dev/null +++ b/packages/inpage/eip-6963.js @@ -0,0 +1,18 @@ +export const EIP6963EventNames = { + Announce: 'eip6963:announceProvider', + Request: 'eip6963:requestProvider', +} + +export function announceProvider(providerDetail) { + const _announceProvider = () => + window.dispatchEvent( + new CustomEvent(EIP6963EventNames.Announce, { + detail: Object.freeze(providerDetail), + }), + ) + + _announceProvider() + window.addEventListener(EIP6963EventNames.Request, _announceProvider) + return () => + window.removeEventListener(EIP6963EventNames.Request, _announceProvider) +} diff --git a/packages/inpage/package.json b/packages/inpage/package.json index 5e4111f84..517626673 100644 --- a/packages/inpage/package.json +++ b/packages/inpage/package.json @@ -1,7 +1,7 @@ { "name": "helios-inpage", "type": "module", - "version": "4.0.4", + "version": "4.0.5", "main": "index.js", "author": "yqrashawn ", "private": true, @@ -10,6 +10,7 @@ "@fluent-wallet/extension-runtime": "workspace:packages/extension-runtime", "@fluent-wallet/provider-api": "workspace:packages/ui/provider-api", "@thi.ng/rstream": "6.0.21", + "uuid": "^8.3.2", "webextension-polyfill": "0.8.0" } } diff --git a/packages/inpage/setup-inpage-provider.js b/packages/inpage/setup-inpage-provider.js index fdb6d4d44..f9475aae9 100644 --- a/packages/inpage/setup-inpage-provider.js +++ b/packages/inpage/setup-inpage-provider.js @@ -1,6 +1,11 @@ import {rpcStream} from '@fluent-wallet/extension-runtime/rpc-stream.js' import {initProvider} from '@fluent-wallet/provider-api' import {takeOver} from './take-over-portal' +import {announceProvider} from './eip-6963' +import {v4 as uuid} from 'uuid' + +const FLUENT_SVG = + 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTYiIGhlaWdodD0iOTYiIHZpZXdCb3g9IjAgMCA5NiA5NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfMTAwMV8yKSI+PHBhdGggZmlsbD0iI0YwRjBGMCIgZD0iTTAgMGg5NnY5NkgweiIvPjxwYXRoIGQ9Ik03NSAyMXY4LjY4OGMwIDEwLTguMDMyIDE4LjEyNS0xOC4wMDIgMTguMjg3bC0uMzAzLjAwMkg0OHY4LjcxQzQ4IDY2Ljk3NSAzOS44MzIgNzUgMjkuNzcgNzVIMjF2LTguOTQ1LTE5LjQ1QzIxIDMyLjQ2NCAzMi40NzQgMjEgNDYuNjI3IDIxSDc1eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNjMuNDA4IDIxSDc1djguNjg3Qzc1IDM5Ljk3NSA2Ni44MzIgNDggNTYuNzcgNDhINDh2LTguOTM4QzQ4IDI5Ljk0NiA1NC42NzUgMjIuMzg4IDYzLjQwOCAyMXoiIGZpbGw9IiMyNDIyNjUiIGZpbGwtb3BhY2l0eT0iLjgiLz48cGF0aCBkPSJNNzUgMjF2OC42ODhjMCAxMC04LjAzMiAxOC4xMjUtMTguMDAyIDE4LjI4N2wtLjMwMy4wMDJINDh2OC43MUM0OCA2Ni45NzUgMzkuODMyIDc1IDI5Ljc3IDc1SDIxdi04Ljk0NS0xOS40NUMyMSAzMi40NjQgMzIuNDc0IDIxIDQ2LjYyNyAyMUg3NXoiIGZpbGw9IiM2MTZFRTEiIGZpbGwtb3BhY2l0eT0iLjgiLz48L2c+PGRlZnM+PGNsaXBQYXRoIGlkPSJjbGlwMF8xMDAxXzIiPjxwYXRoIGZpbGw9IiNmZmYiIGQ9Ik0wIDBoOTZ2OTZIMHoiLz48L2NsaXBQYXRoPjwvZGVmcz48L3N2Zz4=' let PROVIDER = null @@ -74,6 +79,15 @@ function setupProvider() { }) PROVIDER = initProvider(stream, sendToBg) + announceProvider({ + info: { + uuid: uuid(), + name: 'Fluent', + icon: FLUENT_SVG, + rdns: 'com.fluentwallet', + }, + provider: PROVIDER, + }) window.fluent = PROVIDER if (!window.ethereum) window.ethereum = PROVIDER @@ -81,11 +95,15 @@ function setupProvider() { takeOver(PROVIDER, 'cfx') if (window.localStorage.getItem(FLUENT_OVERRIDE_WINDOW_DOT_ETHEREUM)) { - Object.defineProperty(window, 'ethereum', { - value: PROVIDER, - writable: false, - }) - takeOver(PROVIDER, 'eth') + try { + Object.defineProperty(window, 'ethereum', { + value: PROVIDER, + writable: false, + }) + takeOver(PROVIDER, 'eth') + } catch (error) { + console.log('Failed to override window.ethereum', error) + } } return PROVIDER } diff --git a/packages/inpage/setup-inpage-provider.test.js b/packages/inpage/setup-inpage-provider.test.js index 39a028dea..68ea03a8e 100644 --- a/packages/inpage/setup-inpage-provider.test.js +++ b/packages/inpage/setup-inpage-provider.test.js @@ -1,16 +1,19 @@ import {expect, describe, it, vi} from 'vitest' +import {EIP6963EventNames} from './eip-6963.js' describe('inpage', () => { describe('setupProvider', () => { it('should setup the provider on window.conflux', async () => { - let listener, eventName + let listeners = [], + eventNames = [] window.addEventListener = vi.fn((e, l) => { - eventName = e - listener = l + eventNames.push(e) + listeners.push(l) }) expect(window.conflux).toBe(undefined) await import('./index.js') - expect(typeof listener).toBe('function') - expect(eventName).toBe('message') + listeners.forEach(l => expect(typeof l).toBe('function')) + expect(eventNames[0]).toBe('message') + expect(eventNames[1]).toBe(EIP6963EventNames.Request) expect(window.conflux).toBeDefined() }) diff --git a/packages/ledger/conflux.js b/packages/ledger/conflux.js index c812d4a44..dd1de13fa 100644 --- a/packages/ledger/conflux.js +++ b/packages/ledger/conflux.js @@ -1,4 +1,4 @@ -import TransportWebUSB from '@ledgerhq/hw-transport-webusb' +import TransportWebHID from '@ledgerhq/hw-transport-webhid' import {decode} from '@fluent-wallet/base32-address' import {LEDGER_APP_NAME, LEDGER_CLA, INS, HDPATH, ERROR} from './const.js' import {handleName} from './index.js' @@ -20,12 +20,17 @@ export default class Conflux { this.transport = null } + async createApp(transport) { + const App = await import('@fluent-wallet/hw-app-conflux') + this.app = new App.default(transport) + this.transport = transport + } + async setApp() { if (!this.app) { try { - this.transport = await TransportWebUSB.create() - const App = await import('@fluent-wallet/hw-app-conflux') - this.app = new App.default(this.transport) + const transport = await TransportWebHID.create() + await this.createApp(transport) } catch (error) { console.warn(error) } @@ -85,7 +90,7 @@ export default class Conflux { } async isDeviceAuthed() { - const devices = await TransportWebUSB.list() + const devices = await TransportWebHID.list() return Boolean(devices.length) } @@ -123,7 +128,10 @@ export default class Conflux { */ async requestAuth() { try { - await TransportWebUSB?.request() + const transport = await TransportWebHID?.request() + if (!this.app) { + await this.createApp(transport) + } return true } catch (error) { return false @@ -154,7 +162,7 @@ export default class Conflux { } async getDeviceInfo() { - const devices = await TransportWebUSB.list() + const devices = await TransportWebHID.list() if (devices.length > 0) { const device = devices[0] return { diff --git a/packages/ledger/ethereum.js b/packages/ledger/ethereum.js index 2b5759f0d..ac60d506c 100644 --- a/packages/ledger/ethereum.js +++ b/packages/ledger/ethereum.js @@ -1,4 +1,4 @@ -import TransportWebUSB from '@ledgerhq/hw-transport-webusb' +import TransportWebHID from '@ledgerhq/hw-transport-webhid' import {LEDGER_APP_NAME, LEDGER_CLA, INS, HDPATH, ERROR} from './const.js' import {handleName} from './index.js' @@ -19,13 +19,17 @@ export default class Ethereum { this.app = null this.transport = null } + async createApp(transport) { + const App = await import('@ledgerhq/hw-app-eth') + this.app = new App.default(transport) + this.transport = transport + } async setApp() { if (!this.app) { try { - this.transport = await TransportWebUSB.create() - const App = await import('@ledgerhq/hw-app-eth') - this.app = new App.default(this.transport) + const transport = await TransportWebHID.create() + await this.createApp(transport) } catch (error) { console.warn(error) } @@ -103,7 +107,7 @@ export default class Ethereum { } async isDeviceAuthed() { - const devices = await TransportWebUSB.list() + const devices = await TransportWebHID.list() return Boolean(devices.length) } @@ -155,7 +159,10 @@ export default class Ethereum { */ async requestAuth() { try { - await TransportWebUSB?.request() + const transport = await TransportWebHID?.request() + if (!this.app) { + await this.createApp(transport) + } return true } catch (error) { return false @@ -185,7 +192,7 @@ export default class Ethereum { } async getDeviceInfo() { - const devices = await TransportWebUSB.list() + const devices = await TransportWebHID.list() if (devices.length > 0) { const device = devices[0] return { diff --git a/packages/ledger/package.json b/packages/ledger/package.json index 3455d1cbc..929ee840e 100644 --- a/packages/ledger/package.json +++ b/packages/ledger/package.json @@ -2,11 +2,11 @@ "name": "@fluent-wallet/ledger", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.1.1", "dependencies": { "@fluent-wallet/base32-address": "workspace:packages/base32-address", - "@fluent-wallet/hw-app-conflux": "0.0.8", + "@fluent-wallet/hw-app-conflux": "0.1.1", "@ledgerhq/hw-app-eth": "6.24.1", - "@ledgerhq/hw-transport-webusb": "6.29.2" + "@ledgerhq/hw-transport-webhid": "6.29.4" } } diff --git a/packages/manifest/manifestv2.json b/packages/manifest/manifestv2.json index 94bdb3e0e..f3d3a1236 100644 --- a/packages/manifest/manifestv2.json +++ b/packages/manifest/manifestv2.json @@ -1,6 +1,8 @@ { - "name": "__MSG_extensionNAME__", - "short_name": "__MSG_extensionNAME__", + "__dev__name": "AFluent", + "__prod__name": "__MSG_extensionNAME__", + "__dev__short_name": "AFluent", + "__prod__short_name": "__MSG_extensionNAME__", "version": "", "version_name": "", "manifest_version": 2, diff --git a/packages/manifest/manifestv3.json b/packages/manifest/manifestv3.json index d95d495a2..c7c6389b6 100644 --- a/packages/manifest/manifestv3.json +++ b/packages/manifest/manifestv3.json @@ -1,6 +1,8 @@ { - "name": "__MSG_extensionNAME__", - "short_name": "__MSG_extensionNAME__", + "__dev__name": "AFluent", + "__prod__name": "__MSG_extensionNAME__", + "__dev__short_name": "AFluent", + "__prod__short_name": "__MSG_extensionNAME__", "version": "", "version_name": "", "manifest_version": 3, diff --git a/packages/popup/package.json b/packages/popup/package.json index a8ef7d261..4e181bdcc 100644 --- a/packages/popup/package.json +++ b/packages/popup/package.json @@ -2,7 +2,7 @@ "private": true, "name": "helios-popup", "type": "module", - "version": "0.1.8", + "version": "0.1.14", "main": "index.js", "author": "yqrashawn ", "license": "MIT", diff --git a/packages/popup/src/hooks/index.js b/packages/popup/src/hooks/index.js index 00b87cf74..7cd0837f1 100644 --- a/packages/popup/src/hooks/index.js +++ b/packages/popup/src/hooks/index.js @@ -452,7 +452,7 @@ export const useDecodeDisplay = ({ displayToAddress = toAddress displayValue = sendAmount } else { - if (isSendNativeToken) { + if (isSendNativeToken || !!value) { displayToken = nativeToken displayFromAddress = from displayToAddress = to diff --git a/packages/popup/src/hooks/useApi.js b/packages/popup/src/hooks/useApi.js index 8e067e93a..7e76703ef 100644 --- a/packages/popup/src/hooks/useApi.js +++ b/packages/popup/src/hooks/useApi.js @@ -678,6 +678,7 @@ export const useWalletVersion = () => { const {data} = useRPC([WALLET_GET_FLUENT_METADATA], undefined, { fallbackData: { version: '', + view_version: '', }, }) return data diff --git a/packages/popup/src/index.js b/packages/popup/src/index.js index 6fd893c9f..02deefc2d 100644 --- a/packages/popup/src/index.js +++ b/packages/popup/src/index.js @@ -7,7 +7,7 @@ import {SWRConfig} from 'swr' import {ROUTES} from './constants' import {IS_PROD_MODE, PACKAGE_VERSION} from '@fluent-wallet/inner-utils' -const {ERROR} = ROUTES +const {ERROR, WALLET_UNLOCK} = ROUTES // import reportWebVitals from './reportWebVitals' // Fix chrome extension render problem in external screen @@ -68,7 +68,13 @@ ReactDOM.render( onError: error => { if (error && location) { if (!IS_PROD_MODE) console.error(error) - const prevPath = window?.location?.hash === '#/' ? 'home' : '' + if ( + location.href.includes(`#${ERROR}`) || + location.href.includes(`#${WALLET_UNLOCK}`) + ) { + return + } + const prevPath = location?.hash === '#/' ? 'home' : '' location.href = `${location.origin}${ location.pathname }#${ERROR}?errorMsg=${ diff --git a/packages/popup/src/pages/About/index.js b/packages/popup/src/pages/About/index.js index 9a7841222..432ab5c9d 100644 --- a/packages/popup/src/pages/About/index.js +++ b/packages/popup/src/pages/About/index.js @@ -47,7 +47,7 @@ AboutItem.propTypes = { function About() { const {t, i18n} = useTranslation() - const {version} = useWalletVersion() + const {view_version} = useWalletVersion() return ( @@ -65,7 +65,7 @@ function About() { {`${t( 'version', - )} v${version}`} + )} v${view_version}`} diff --git a/packages/popup/src/pages/ConfirmTransaction/components/AddressCard.js b/packages/popup/src/pages/ConfirmTransaction/components/AddressCard.js index bd2079481..e0af2c0fa 100644 --- a/packages/popup/src/pages/ConfirmTransaction/components/AddressCard.js +++ b/packages/popup/src/pages/ConfirmTransaction/components/AddressCard.js @@ -226,7 +226,7 @@ function AddressCard({ : 'signTransaction', )} - {isSendToken && ( + {(isSendToken || !!value) && ( {isTxTreatedAsEIP1559 ? t('maxFeePerGas') : t('gasPrice')} {isTxTreatedAsEIP1559 && + !resendType && gasArray.map((level, index) => ( ))} - {!isTxTreatedAsEIP1559 && ( + {(!isTxTreatedAsEIP1559 || !!resendType) && ( { + if (isLocked && location) { + location.href = `${location.origin}${location.pathname}#${WALLET_UNLOCK}` + } + }, [isLocked]) + const onClickFeedback = () => { const timer = setTimeout(() => { zendeskTimer && clearTimeout(zendeskTimer) diff --git a/packages/popup/src/pages/ResendTransaction/index.js b/packages/popup/src/pages/ResendTransaction/index.js index 0a7db4ce0..cafc642f4 100644 --- a/packages/popup/src/pages/ResendTransaction/index.js +++ b/packages/popup/src/pages/ResendTransaction/index.js @@ -1,10 +1,12 @@ -import {useState, useEffect} from 'react' +import {useState, useEffect, useMemo} from 'react' import {useTranslation} from 'react-i18next' import {useHistory} from 'react-router-dom' import { Big, formatDecimalToHex, formatHexToDecimal, + convertDecimal, + GWEI_DECIMALS, } from '@fluent-wallet/data-format' import EditGasFee from '../EditGasFee' import { @@ -85,13 +87,16 @@ function ResendTransaction() { to, nonce, value, - gasPrice: lastGasPrice, + gasPrice, + maxFeePerGas, type: eipVersionType, } = txPayload const reSendTxStatus = formatStatus(status) const isTxTreatedAsEIP1559 = useIsTxTreatedAsEIP1559(eipVersionType) + const lastGasPrice = isTxTreatedAsEIP1559 ? maxFeePerGas : gasPrice + // decode erc20 data const {decodeData} = useDecodeData( resendType === 'speedup' @@ -142,6 +147,30 @@ function ResendTransaction() { const originEstimateRst = useEstimateTx({...originParams}, token20Params) || {} + const { + gasPrice: estimateGasPrice, + gasInfoEip1559 = {}, + loading, + } = originEstimateRst + + const originEstimateGasPrice = useMemo(() => { + if ( + loading || + (!isTxTreatedAsEIP1559 && !estimateGasPrice) || + (isTxTreatedAsEIP1559 && !gasInfoEip1559?.['medium']) + ) + return null + return !isTxTreatedAsEIP1559 + ? estimateGasPrice + : convertDecimal( + new Big(gasInfoEip1559?.['medium']?.suggestedMaxFeePerGas) + .round(9) + .toString(10), + 'multiply', + GWEI_DECIMALS, + ) + }, [isTxTreatedAsEIP1559, estimateGasPrice, gasInfoEip1559, loading]) + const resendTransaction = async params => { try { await request(WALLET_SEND_TRANSACTION_WITH_ACTION, { @@ -168,7 +197,7 @@ function ResendTransaction() { } const onResend = async feeParams => { - if (originEstimateRst?.loading || !accountType) { + if (loading || !accountType) { return } @@ -220,11 +249,9 @@ function ResendTransaction() { // set default gas price (legacy tx) useEffect(() => { - if (lastGasPrice && originEstimateRst?.gasPrice) { + if (lastGasPrice && originEstimateGasPrice) { const decimalGasPrice = formatHexToDecimal(lastGasPrice) - const decimalEstimateGasPrice = formatHexToDecimal( - originEstimateRst.gasPrice, - ) + const decimalEstimateGasPrice = formatHexToDecimal(originEstimateGasPrice) const biggerGasPrice = new Big(decimalGasPrice).times(1.1) @@ -238,7 +265,7 @@ function ResendTransaction() { setSuggestedGasPrice(formatDecimalToHex(recommendGasPrice)) } - }, [originEstimateRst.gasPrice, lastGasPrice]) + }, [originEstimateGasPrice, lastGasPrice]) //cancel resend tx when tx status is not pending useEffect(() => { diff --git a/packages/rpc-engine/middlewares/validate-rpc-params.js b/packages/rpc-engine/middlewares/validate-rpc-params.js index d07b6257d..80f184c60 100644 --- a/packages/rpc-engine/middlewares/validate-rpc-params.js +++ b/packages/rpc-engine/middlewares/validate-rpc-params.js @@ -34,8 +34,13 @@ export default defMiddleware(({tx: {map, comp}}) => ({ const {params, method} = req const {schemas, Err} = rpcStore[method] // TODO: add a preprocess middleware to transform req params for more compatibilities - if (method === 'eth_sendTransaction' && isArray(params)) + if ( + (method === 'eth_sendTransaction' || + method === 'cfx_sendTransaction') && + isArray(params) + ) { params[0] = preprocessTx(params[0]) + } if (schemas.input) { if (!validate(schemas.input, params, {netId: req.network.netId})) { throw Err.InvalidParams( diff --git a/packages/rpc-engine/package.json b/packages/rpc-engine/package.json index 363b5a2a0..901dd2ec1 100644 --- a/packages/rpc-engine/package.json +++ b/packages/rpc-engine/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/rpc-engine", "type": "module", "main": "index.js", - "version": "2.0.6", + "version": "2.0.8", "dependencies": { "@fluent-wallet/associative": "workspace:packages/associative", "@fluent-wallet/cache-rpc": "workspace:packages/cache-rpc", diff --git a/packages/rpcs/cfx_accounts/package.json b/packages/rpcs/cfx_accounts/package.json index 3a9b87986..94554b9ad 100644 --- a/packages/rpcs/cfx_accounts/package.json +++ b/packages/rpcs/cfx_accounts/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_accounts", "type": "module", "main": "index.js", - "version": "3.0.0", + "version": "3.0.1", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_call/index.js b/packages/rpcs/cfx_call/index.js index 0f77299f9..aeb44350b 100644 --- a/packages/rpcs/cfx_call/index.js +++ b/packages/rpcs/cfx_call/index.js @@ -6,6 +6,9 @@ import { base32ContractAddress, Uint, Bytes, + catn, + Hash32, + base32Address, } from '@fluent-wallet/spec' export const NAME = 'cfx_call' @@ -32,6 +35,29 @@ export const schemas = { ['value', {optional: true}, Uint], ['data', {optional: true}, Bytes], ['nonce', {optional: true}, Uint], + ['type', {optional: true}, Uint], + ['maxPriorityFeePerGas', {optional: true}, Uint], + ['maxFeePerGas', {optional: true}, Uint], + [ + 'accessList', + {optional: true}, + [ + catn, + [ + 'AccessListEntry', + [ + map, + {closed: true}, + ['address', {optional: true}, base32Address], + [ + 'storageKeys', + {optional: true}, + [catn, ['32BtyeHexValue', Hash32]], + ], + ], + ], + ], + ], ], epochRef, ], diff --git a/packages/rpcs/cfx_call/package.json b/packages/rpcs/cfx_call/package.json index d3e2a72ec..17be6c969 100644 --- a/packages/rpcs/cfx_call/package.json +++ b/packages/rpcs/cfx_call/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.6", + "version": "0.0.8", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_chainId/package.json b/packages/rpcs/cfx_chainId/package.json index ec60621a0..b8140866d 100644 --- a/packages/rpcs/cfx_chainId/package.json +++ b/packages/rpcs/cfx_chainId/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_chain-id", "type": "module", "main": "index.js", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_checkBalanceAgainstTransaction/package.json b/packages/rpcs/cfx_checkBalanceAgainstTransaction/package.json index b07ba0167..c46de7019 100644 --- a/packages/rpcs/cfx_checkBalanceAgainstTransaction/package.json +++ b/packages/rpcs/cfx_checkBalanceAgainstTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.5", + "version": "0.0.6", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_clientVersion/package.json b/packages/rpcs/cfx_clientVersion/package.json index f519219cf..3d903e55f 100644 --- a/packages/rpcs/cfx_clientVersion/package.json +++ b/packages/rpcs/cfx_clientVersion/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_epochNumber/package.json b/packages/rpcs/cfx_epochNumber/package.json index 47e216c3f..36e51d981 100644 --- a/packages/rpcs/cfx_epochNumber/package.json +++ b/packages/rpcs/cfx_epochNumber/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_epoch-number", "type": "module", "main": "index.js", - "version": "0.0.11", + "version": "0.0.12", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_estimate1559Fee/README.md b/packages/rpcs/cfx_estimate1559Fee/README.md new file mode 100644 index 000000000..7e0bb8420 --- /dev/null +++ b/packages/rpcs/cfx_estimate1559Fee/README.md @@ -0,0 +1 @@ +# @fluent-wallet/eth_estimate-1559-fee diff --git a/packages/rpcs/cfx_estimate1559Fee/doc.js b/packages/rpcs/cfx_estimate1559Fee/doc.js new file mode 100644 index 000000000..7c6fac91f --- /dev/null +++ b/packages/rpcs/cfx_estimate1559Fee/doc.js @@ -0,0 +1,4 @@ +export default { + metadata: {standard: true}, + en: 'A Gas Fee Estimator using EIP-1559', +} diff --git a/packages/rpcs/cfx_estimate1559Fee/index.js b/packages/rpcs/cfx_estimate1559Fee/index.js new file mode 100644 index 000000000..75ef98ae8 --- /dev/null +++ b/packages/rpcs/cfx_estimate1559Fee/index.js @@ -0,0 +1,146 @@ +import {optParam} from '@fluent-wallet/spec' +import BN from 'bn.js' +import {formatUnits} from '@ethersproject/units' + +export const NAME = 'cfx_estimate1559Fee' + +export const schemas = { + input: optParam, +} + +export const permissions = { + external: ['popup', 'inpage'], + locked: true, + methods: [ + 'eth_getBlockByNumber', + 'wallet_network1559Compatible', + 'cfx_feeHistory', + 'cfx_getBlockByEpochNumber', + ], + db: [], +} + +const FEE_HISTORY_BLOCKS = '0x5' +const PRIORITY_LEVELS = ['low', 'medium', 'high'] +const MIN_GAS_PRICE = new BN('1000000000') // 1 gwei + +const SETTINGS_BY_PRIORITY_LEVEL = { + low: { + percentile: 10, + baseFeePercentageMultiplier: new BN(90), + // minSuggestedMaxPriorityFeePerGas: new BN(0) + }, + medium: { + percentile: 20, + baseFeePercentageMultiplier: new BN(100), + // minSuggestedMaxPriorityFeePerGas: new BN(0) + }, + high: { + percentile: 30, + baseFeePercentageMultiplier: new BN(120), + // minSuggestedMaxPriorityFeePerGas: new BN(0) + }, +} + +const FEE_HISTORY_PERCENTILES = [ + SETTINGS_BY_PRIORITY_LEVEL.low.percentile, + SETTINGS_BY_PRIORITY_LEVEL.medium.percentile, + SETTINGS_BY_PRIORITY_LEVEL.high.percentile, +] + +/** + * A gas fee estimates based on gas fees that have been used in the recent past tx. + * @param {*} param + */ +export const main = async ({ + Err: {InvalidParams}, + rpcs: { + wallet_network1559Compatible, + cfx_feeHistory, + cfx_getBlockByEpochNumber, + }, + network, +}) => { + const network1559Compatible = await wallet_network1559Compatible() + if (!network1559Compatible) + throw InvalidParams( + `Network ${network.name} don't support 1559 transaction`, + ) + + const latestBlock = await cfx_getBlockByEpochNumber(['latest_state', false]) + const baseFeePerGas = new BN(Number(latestBlock?.baseFeePerGas)) + const feeData = await cfx_feeHistory([ + FEE_HISTORY_BLOCKS, + 'latest_state', + FEE_HISTORY_PERCENTILES, + ]) + + const gasInfo = calculateGasFeeEstimatesForPriorityLevels( + feeData, + baseFeePerGas, + ) + return gasInfo +} + +function calculateGasFeeEstimatesForPriorityLevels(feeData, baseFeePerGas) { + const levelSpecificEstimates = PRIORITY_LEVELS.reduce( + (obj, priorityLevel) => { + const gasEstimatesForPriorityLevel = calculateEstimatesForPriorityLevel( + priorityLevel, + feeData, + baseFeePerGas, + ) + return {...obj, [priorityLevel]: gasEstimatesForPriorityLevel} + }, + {}, + ) + return { + ...levelSpecificEstimates, + estimatedBaseFee: formatUnits(baseFeePerGas.toString(), 'gwei'), + } +} + +function calculateEstimatesForPriorityLevel( + priorityLevel, + feeData, + baseFeePerGas, +) { + const settings = SETTINGS_BY_PRIORITY_LEVEL[priorityLevel] + const adjustedBaseFeePerGas = baseFeePerGas + .mul(settings.baseFeePercentageMultiplier) + .divn(100) + const priorityFees = feeData.reward + ?.map( + rewards => + new BN(Number(rewards[PRIORITY_LEVELS.indexOf(priorityLevel)])), + ) + .filter(BN.isBN) + const adjustedPriorityFee = medianOf(priorityFees) + + // const suggestedMaxPriorityFeePerGas = BN.max( + // adjustedPriorityFee, + // settings.minSuggestedMaxPriorityFeePerGas, + // ) + const suggestedMaxPriorityFeePerGas = adjustedPriorityFee + + const suggestedMaxFeePerGas = adjustedBaseFeePerGas.add( + suggestedMaxPriorityFeePerGas, + ) + return { + suggestedMaxPriorityFeePerGas: formatUnits( + suggestedMaxPriorityFeePerGas.toString(), + 'gwei', + ), + suggestedMaxFeePerGas: formatUnits( + BN.max(suggestedMaxFeePerGas, MIN_GAS_PRICE).toString(), + 'gwei', + ), + } +} + +function medianOf(numbers) { + const sortedNumbers = numbers.slice().sort((a, b) => a.cmp(b)) + const len = sortedNumbers.length + const index = Math.floor((len - 1) / 2) + return sortedNumbers[index] +} diff --git a/packages/rpcs/cfx_estimate1559Fee/package.json b/packages/rpcs/cfx_estimate1559Fee/package.json new file mode 100644 index 000000000..8553508c6 --- /dev/null +++ b/packages/rpcs/cfx_estimate1559Fee/package.json @@ -0,0 +1,11 @@ +{ + "name": "@fluent-wallet/cfx_estimate-1559-fee", + "type": "module", + "main": "index.js", + "version": "0.0.4", + "dependencies": { + "@ethersproject/units": "5.6.1", + "@fluent-wallet/spec": "workspace:packages/spec", + "bn.js": "5.2.0" + } +} diff --git a/packages/rpcs/cfx_estimateGasAndCollateral/index.js b/packages/rpcs/cfx_estimateGasAndCollateral/index.js index e932039a5..5109fd4b0 100644 --- a/packages/rpcs/cfx_estimateGasAndCollateral/index.js +++ b/packages/rpcs/cfx_estimateGasAndCollateral/index.js @@ -7,6 +7,8 @@ import { Bytes, epochRefNoMined, chainId, + catn, + Hash32, } from '@fluent-wallet/spec' export const NAME = 'cfx_estimateGasAndCollateral' @@ -35,6 +37,29 @@ export const schemas = { ['nonce', {optional: true, doc: 'default to 0x0'}, Uint], ['storageLimit', {optional: true}, Uint], ['epochHeight', {optional: true}, Uint], + ['type', {optional: true}, Uint], + ['maxPriorityFeePerGas', {optional: true}, Uint], + ['maxFeePerGas', {optional: true}, Uint], + [ + 'accessList', + {optional: true}, + [ + catn, + [ + 'AccessListEntry', + [ + map, + {closed: true}, + ['address', {optional: true}, base32Address], + [ + 'storageKeys', + {optional: true}, + [catn, ['32BtyeHexValue', Hash32]], + ], + ], + ], + ], + ], ], epochRefNoMined, ], diff --git a/packages/rpcs/cfx_estimateGasAndCollateral/package.json b/packages/rpcs/cfx_estimateGasAndCollateral/package.json index 171fae8d4..01ea5b862 100644 --- a/packages/rpcs/cfx_estimateGasAndCollateral/package.json +++ b/packages/rpcs/cfx_estimateGasAndCollateral/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.8", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_feeHistory/README.md b/packages/rpcs/cfx_feeHistory/README.md new file mode 100644 index 000000000..eb1397983 --- /dev/null +++ b/packages/rpcs/cfx_feeHistory/README.md @@ -0,0 +1 @@ +# @fluent-wallet/cfx_fee-history diff --git a/packages/rpcs/cfx_feeHistory/doc.js b/packages/rpcs/cfx_feeHistory/doc.js new file mode 100644 index 000000000..52fdf31e8 --- /dev/null +++ b/packages/rpcs/cfx_feeHistory/doc.js @@ -0,0 +1,4 @@ +export default { + metadata: {standard: true}, + en: 'No doc available', +} diff --git a/packages/rpcs/cfx_feeHistory/index.js b/packages/rpcs/cfx_feeHistory/index.js new file mode 100644 index 000000000..783b1d20d --- /dev/null +++ b/packages/rpcs/cfx_feeHistory/index.js @@ -0,0 +1,28 @@ +import { + cat, + epochRefNoMined, + number, + schema, + string, + zeroOrMore, +} from '@fluent-wallet/spec' + +export const NAME = 'cfx_feeHistory' + +export const schemas = { + input: [ + cat, + string, + epochRefNoMined, + [schema, [zeroOrMore, [number, {max: 100, min: 1}]]], + ], +} + +export const permissions = { + external: ['popup', 'inpage'], + locked: true, +} + +export const main = ({f, params}) => { + return f(params) +} diff --git a/packages/rpcs/cfx_feeHistory/package.json b/packages/rpcs/cfx_feeHistory/package.json new file mode 100644 index 000000000..0f1a81481 --- /dev/null +++ b/packages/rpcs/cfx_feeHistory/package.json @@ -0,0 +1,9 @@ +{ + "name": "@fluent-wallet/cfx_fee-history", + "type": "module", + "main": "index.js", + "version": "0.0.2", + "dependencies": { + "@fluent-wallet/spec": "workspace:packages/spec" + } +} diff --git a/packages/rpcs/cfx_gasPrice/package.json b/packages/rpcs/cfx_gasPrice/package.json index e1457e040..2311e1f12 100644 --- a/packages/rpcs/cfx_gasPrice/package.json +++ b/packages/rpcs/cfx_gasPrice/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_gas-price", "type": "module", "main": "index.js", - "version": "0.0.15", + "version": "0.0.16", "dependencies": { "@fluent-wallet/consts": "workspace:*", "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/cfx_getAccount/package.json b/packages/rpcs/cfx_getAccount/package.json index d366574e2..4ba02777e 100644 --- a/packages/rpcs/cfx_getAccount/package.json +++ b/packages/rpcs/cfx_getAccount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_get-account", "type": "module", "main": "index.js", - "version": "0.0.11", + "version": "0.0.12", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getAccountPendingInfo/package.json b/packages/rpcs/cfx_getAccountPendingInfo/package.json index 9d1a587af..be3de2ad8 100644 --- a/packages/rpcs/cfx_getAccountPendingInfo/package.json +++ b/packages/rpcs/cfx_getAccountPendingInfo/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getAccountPendingTransactions/package.json b/packages/rpcs/cfx_getAccountPendingTransactions/package.json index ebdda729f..bbd26c97e 100644 --- a/packages/rpcs/cfx_getAccountPendingTransactions/package.json +++ b/packages/rpcs/cfx_getAccountPendingTransactions/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getAccumulateInterestRate/package.json b/packages/rpcs/cfx_getAccumulateInterestRate/package.json index 63bc5d4cb..52eee3d2d 100644 --- a/packages/rpcs/cfx_getAccumulateInterestRate/package.json +++ b/packages/rpcs/cfx_getAccumulateInterestRate/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getAdmin/package.json b/packages/rpcs/cfx_getAdmin/package.json index 51b23de40..3832c7397 100644 --- a/packages/rpcs/cfx_getAdmin/package.json +++ b/packages/rpcs/cfx_getAdmin/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBalance/package.json b/packages/rpcs/cfx_getBalance/package.json index d97ab06c8..dbc4de700 100644 --- a/packages/rpcs/cfx_getBalance/package.json +++ b/packages/rpcs/cfx_getBalance/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_get-balance", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBestBlockHash/package.json b/packages/rpcs/cfx_getBestBlockHash/package.json index c24a284ed..4d5424dd9 100644 --- a/packages/rpcs/cfx_getBestBlockHash/package.json +++ b/packages/rpcs/cfx_getBestBlockHash/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBlockByBlockNumber/package.json b/packages/rpcs/cfx_getBlockByBlockNumber/package.json index 8574d9e09..293b8e4bd 100644 --- a/packages/rpcs/cfx_getBlockByBlockNumber/package.json +++ b/packages/rpcs/cfx_getBlockByBlockNumber/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.1", + "version": "0.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBlockByEpochNumber/package.json b/packages/rpcs/cfx_getBlockByEpochNumber/package.json index 3d0f996ea..164ee9d23 100644 --- a/packages/rpcs/cfx_getBlockByEpochNumber/package.json +++ b/packages/rpcs/cfx_getBlockByEpochNumber/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBlockByHash/package.json b/packages/rpcs/cfx_getBlockByHash/package.json index f8e8e3c6a..8d0689937 100644 --- a/packages/rpcs/cfx_getBlockByHash/package.json +++ b/packages/rpcs/cfx_getBlockByHash/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBlockByHashWithPivotAssumption/package.json b/packages/rpcs/cfx_getBlockByHashWithPivotAssumption/package.json index 55f237fc0..1a5dd4395 100644 --- a/packages/rpcs/cfx_getBlockByHashWithPivotAssumption/package.json +++ b/packages/rpcs/cfx_getBlockByHashWithPivotAssumption/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBlockRewardInfo/package.json b/packages/rpcs/cfx_getBlockRewardInfo/package.json index 0f7a8718d..e482aa06b 100644 --- a/packages/rpcs/cfx_getBlockRewardInfo/package.json +++ b/packages/rpcs/cfx_getBlockRewardInfo/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getBlocksByEpoch/package.json b/packages/rpcs/cfx_getBlocksByEpoch/package.json index 68cfb257d..db5eb4c2e 100644 --- a/packages/rpcs/cfx_getBlocksByEpoch/package.json +++ b/packages/rpcs/cfx_getBlocksByEpoch/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getCode/package.json b/packages/rpcs/cfx_getCode/package.json index bdcff7242..903d8fb88 100644 --- a/packages/rpcs/cfx_getCode/package.json +++ b/packages/rpcs/cfx_getCode/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_get-code", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getCollateralForStorage/package.json b/packages/rpcs/cfx_getCollateralForStorage/package.json index de20e9d0e..da70d2b06 100644 --- a/packages/rpcs/cfx_getCollateralForStorage/package.json +++ b/packages/rpcs/cfx_getCollateralForStorage/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getConfirmationRiskByHash/package.json b/packages/rpcs/cfx_getConfirmationRiskByHash/package.json index b701d96a0..836e5faaa 100644 --- a/packages/rpcs/cfx_getConfirmationRiskByHash/package.json +++ b/packages/rpcs/cfx_getConfirmationRiskByHash/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getDepositList/package.json b/packages/rpcs/cfx_getDepositList/package.json index 8229bf505..5c4a46d88 100644 --- a/packages/rpcs/cfx_getDepositList/package.json +++ b/packages/rpcs/cfx_getDepositList/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getFeeBurnt/README.md b/packages/rpcs/cfx_getFeeBurnt/README.md new file mode 100644 index 000000000..d566ccd1b --- /dev/null +++ b/packages/rpcs/cfx_getFeeBurnt/README.md @@ -0,0 +1 @@ +# @fluent-wallet/cfx_get-fee-burnt diff --git a/packages/rpcs/cfx_getFeeBurnt/doc.js b/packages/rpcs/cfx_getFeeBurnt/doc.js new file mode 100644 index 000000000..52fdf31e8 --- /dev/null +++ b/packages/rpcs/cfx_getFeeBurnt/doc.js @@ -0,0 +1,4 @@ +export default { + metadata: {standard: true}, + en: 'No doc available', +} diff --git a/packages/rpcs/cfx_getFeeBurnt/index.js b/packages/rpcs/cfx_getFeeBurnt/index.js new file mode 100644 index 000000000..53deb09bf --- /dev/null +++ b/packages/rpcs/cfx_getFeeBurnt/index.js @@ -0,0 +1,16 @@ +import {optParam} from '@fluent-wallet/spec' + +export const NAME = 'cfx_getFeeBurnt' + +export const schemas = { + input: optParam, +} + +export const permissions = { + external: ['popup', 'inpage'], + locked: true, +} + +export function main({f}) { + return f() +} diff --git a/packages/rpcs/cfx_getFeeBurnt/package.json b/packages/rpcs/cfx_getFeeBurnt/package.json new file mode 100644 index 000000000..c2cf44f5b --- /dev/null +++ b/packages/rpcs/cfx_getFeeBurnt/package.json @@ -0,0 +1,9 @@ +{ + "name": "@fluent-wallet/cfx_get-fee-burnt", + "type": "module", + "main": "index.js", + "version": "0.0.2", + "dependencies": { + "@fluent-wallet/spec": "workspace:packages/spec" + } +} diff --git a/packages/rpcs/cfx_getInterestRate/package.json b/packages/rpcs/cfx_getInterestRate/package.json index b5cca4ff7..299309a47 100644 --- a/packages/rpcs/cfx_getInterestRate/package.json +++ b/packages/rpcs/cfx_getInterestRate/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getLogs/package.json b/packages/rpcs/cfx_getLogs/package.json index a81ffc89f..a5f98d541 100644 --- a/packages/rpcs/cfx_getLogs/package.json +++ b/packages/rpcs/cfx_getLogs/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.5", + "version": "0.0.6", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getMaxGasLimit/package.json b/packages/rpcs/cfx_getMaxGasLimit/package.json index 908995936..40f9c4371 100644 --- a/packages/rpcs/cfx_getMaxGasLimit/package.json +++ b/packages/rpcs/cfx_getMaxGasLimit/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getNextNonce/package.json b/packages/rpcs/cfx_getNextNonce/package.json index 55ca2a5b9..ca27bb774 100644 --- a/packages/rpcs/cfx_getNextNonce/package.json +++ b/packages/rpcs/cfx_getNextNonce/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_get-next-nonce", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getNextUsableNonce/package.json b/packages/rpcs/cfx_getNextUsableNonce/package.json index b523e5718..2112a94e6 100644 --- a/packages/rpcs/cfx_getNextUsableNonce/package.json +++ b/packages/rpcs/cfx_getNextUsableNonce/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getPoSEconomics/package.json b/packages/rpcs/cfx_getPoSEconomics/package.json index 79836b073..95ad689b2 100644 --- a/packages/rpcs/cfx_getPoSEconomics/package.json +++ b/packages/rpcs/cfx_getPoSEconomics/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getPoSRewardByEpoch/package.json b/packages/rpcs/cfx_getPoSRewardByEpoch/package.json index 5d2df26ff..2c32f2764 100644 --- a/packages/rpcs/cfx_getPoSRewardByEpoch/package.json +++ b/packages/rpcs/cfx_getPoSRewardByEpoch/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.1", + "version": "0.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getSkippedBlocksByEpoch/package.json b/packages/rpcs/cfx_getSkippedBlocksByEpoch/package.json index d7693b0fb..ba5805180 100644 --- a/packages/rpcs/cfx_getSkippedBlocksByEpoch/package.json +++ b/packages/rpcs/cfx_getSkippedBlocksByEpoch/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getSponsorInfo/package.json b/packages/rpcs/cfx_getSponsorInfo/package.json index 83ac6cf71..9ccc3fbd3 100644 --- a/packages/rpcs/cfx_getSponsorInfo/package.json +++ b/packages/rpcs/cfx_getSponsorInfo/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getStakingBalance/package.json b/packages/rpcs/cfx_getStakingBalance/package.json index 04fd451f7..976234aa3 100644 --- a/packages/rpcs/cfx_getStakingBalance/package.json +++ b/packages/rpcs/cfx_getStakingBalance/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getStatus/package.json b/packages/rpcs/cfx_getStatus/package.json index 6b688cc3d..5c7bcd2e3 100644 --- a/packages/rpcs/cfx_getStatus/package.json +++ b/packages/rpcs/cfx_getStatus/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_get-status", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getStorageAt/package.json b/packages/rpcs/cfx_getStorageAt/package.json index 85b180bab..eca3f5da6 100644 --- a/packages/rpcs/cfx_getStorageAt/package.json +++ b/packages/rpcs/cfx_getStorageAt/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getStorageRoot/package.json b/packages/rpcs/cfx_getStorageRoot/package.json index 139aaad33..397f2412d 100644 --- a/packages/rpcs/cfx_getStorageRoot/package.json +++ b/packages/rpcs/cfx_getStorageRoot/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getSupplyInfo/package.json b/packages/rpcs/cfx_getSupplyInfo/package.json index c08436900..b5c681ac1 100644 --- a/packages/rpcs/cfx_getSupplyInfo/package.json +++ b/packages/rpcs/cfx_getSupplyInfo/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getTransactionByHash/package.json b/packages/rpcs/cfx_getTransactionByHash/package.json index 0dd37c639..8fe68bd5a 100644 --- a/packages/rpcs/cfx_getTransactionByHash/package.json +++ b/packages/rpcs/cfx_getTransactionByHash/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getTransactionReceipt/package.json b/packages/rpcs/cfx_getTransactionReceipt/package.json index 0f0f5bbd6..c53cbb9b6 100644 --- a/packages/rpcs/cfx_getTransactionReceipt/package.json +++ b/packages/rpcs/cfx_getTransactionReceipt/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_getVoteList/package.json b/packages/rpcs/cfx_getVoteList/package.json index fba5fdbf3..e590688fc 100644 --- a/packages/rpcs/cfx_getVoteList/package.json +++ b/packages/rpcs/cfx_getVoteList/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_maxPriorityFeePerGas/README.md b/packages/rpcs/cfx_maxPriorityFeePerGas/README.md new file mode 100644 index 000000000..752a81690 --- /dev/null +++ b/packages/rpcs/cfx_maxPriorityFeePerGas/README.md @@ -0,0 +1 @@ +# @fluent-wallet/cfx_max-priority-fee-per-gas diff --git a/packages/rpcs/cfx_maxPriorityFeePerGas/doc.js b/packages/rpcs/cfx_maxPriorityFeePerGas/doc.js new file mode 100644 index 000000000..52fdf31e8 --- /dev/null +++ b/packages/rpcs/cfx_maxPriorityFeePerGas/doc.js @@ -0,0 +1,4 @@ +export default { + metadata: {standard: true}, + en: 'No doc available', +} diff --git a/packages/rpcs/cfx_maxPriorityFeePerGas/index.js b/packages/rpcs/cfx_maxPriorityFeePerGas/index.js new file mode 100644 index 000000000..b90795bf7 --- /dev/null +++ b/packages/rpcs/cfx_maxPriorityFeePerGas/index.js @@ -0,0 +1,16 @@ +import {optParam} from '@fluent-wallet/spec' + +export const NAME = 'cfx_maxPriorityFeePerGas' + +export const schemas = { + input: optParam, +} + +export const permissions = { + locked: true, + external: ['popup', 'inpage'], +} + +export const main = async ({f, params}) => { + return await f(params) +} diff --git a/packages/rpcs/cfx_maxPriorityFeePerGas/package.json b/packages/rpcs/cfx_maxPriorityFeePerGas/package.json new file mode 100644 index 000000000..de83a526e --- /dev/null +++ b/packages/rpcs/cfx_maxPriorityFeePerGas/package.json @@ -0,0 +1,9 @@ +{ + "name": "@fluent-wallet/cfx_max-priority-fee-per-gas", + "type": "module", + "main": "index.js", + "version": "0.0.2", + "dependencies": { + "@fluent-wallet/spec": "workspace:packages/spec" + } +} diff --git a/packages/rpcs/cfx_netVersion/package.json b/packages/rpcs/cfx_netVersion/package.json index b5044cf8b..0377ff555 100644 --- a/packages/rpcs/cfx_netVersion/package.json +++ b/packages/rpcs/cfx_netVersion/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_net-version", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_openedMethodGroups/package.json b/packages/rpcs/cfx_openedMethodGroups/package.json index d5fc57550..7525983b2 100644 --- a/packages/rpcs/cfx_openedMethodGroups/package.json +++ b/packages/rpcs/cfx_openedMethodGroups/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_requestAccounts/index.js b/packages/rpcs/cfx_requestAccounts/index.js index 84d709a82..90ed4797f 100644 --- a/packages/rpcs/cfx_requestAccounts/index.js +++ b/packages/rpcs/cfx_requestAccounts/index.js @@ -24,7 +24,6 @@ export const main = async ({ } const permissionsToRequest = { cfx_accounts: {}, - wallet_crossNetworkTypeGetConfluxBase32Address: {}, } const permsRes = await wallet_requestPermissions([permissionsToRequest]) diff --git a/packages/rpcs/cfx_requestAccounts/package.json b/packages/rpcs/cfx_requestAccounts/package.json index dbe96234c..27b187241 100644 --- a/packages/rpcs/cfx_requestAccounts/package.json +++ b/packages/rpcs/cfx_requestAccounts/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_request-accounts", "type": "module", "main": "index.js", - "version": "2.0.1", + "version": "2.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_sendRawTransaction/package.json b/packages/rpcs/cfx_sendRawTransaction/package.json index 6168ca3c9..eb8d7167d 100644 --- a/packages/rpcs/cfx_sendRawTransaction/package.json +++ b/packages/rpcs/cfx_sendRawTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/cfx_sendTransaction/package.json b/packages/rpcs/cfx_sendTransaction/package.json index b41935f8d..47def1b44 100644 --- a/packages/rpcs/cfx_sendTransaction/package.json +++ b/packages/rpcs/cfx_sendTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.3", + "version": "1.0.8", "dependencies": { "@fluent-wallet/cfx_sign-transaction": "workspace:*", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/cfx_signTransaction/index.js b/packages/rpcs/cfx_signTransaction/index.js index 2741f089b..ab1c8a532 100644 --- a/packages/rpcs/cfx_signTransaction/index.js +++ b/packages/rpcs/cfx_signTransaction/index.js @@ -9,8 +9,12 @@ import { zeroOrOne, map, Uint, + catn, + Hash32, } from '@fluent-wallet/spec' import {cfxSignTransaction} from '@fluent-wallet/signature' +import {ETH_TX_TYPES} from '@fluent-wallet/consts' +import {parseUnits} from '@ethersproject/units' export const NAME = 'cfx_signTransaction' @@ -28,6 +32,25 @@ export const txSchema = [ ['storageLimit', {optional: true}, Uint], ['chainId', {optional: true}, chainId], ['epochHeight', {optional: true}, Uint], + ['type', {optional: true}, Uint], + ['maxPriorityFeePerGas', {optional: true}, Uint], + ['maxFeePerGas', {optional: true}, Uint], + [ + 'accessList', + {optional: true}, + [ + catn, + [ + 'AccessListEntry', + [ + map, + {closed: true}, + ['address', {optional: true}, base32Address], + ['storageKeys', {optional: true}, [catn, ['32BtyeHexValue', Hash32]]], + ], + ], + ], + ], ] export const schemas = { @@ -57,10 +80,24 @@ export const permissions = { 'cfx_epochNumber', 'cfx_estimateGasAndCollateral', 'wallet_detectAddressType', + 'cfx_getBlockByEpochNumber', + 'wallet_network1559Compatible', + 'cfx_maxPriorityFeePerGas', + 'cfx_estimate1559Fee', ], db: ['findAddress'], } +// conflux js sdk +// hex type must be integer +function formatTx(tx) { + const newTx = {...tx} + + if (newTx.type && typeof newTx.type === 'string') { + newTx.type = parseInt(tx.type, 16) + } + return newTx +} export const main = async args => { const { app, @@ -73,6 +110,8 @@ export const main = async args => { cfx_estimateGasAndCollateral, cfx_getNextUsableNonce, wallet_detectAddressType, + wallet_network1559Compatible, + cfx_estimate1559Fee, }, params: [tx, opts = {}], network, @@ -85,6 +124,7 @@ export const main = async args => { tx.from = tx.from.toLowerCase() if (tx.to) tx.to = tx.to.toLowerCase() const newTx = {...tx} + const network1559Compatible = await wallet_network1559Compatible() const fromAddr = findAddress({ appId: app && app.eid, @@ -98,6 +138,38 @@ export const main = async args => { // from address is not belong to wallet if (!fromAddr) throw InvalidParams(`Invalid from address ${newTx.from}`) + /** + * ledger app check, v1.x is is not support 1559 transaction + * so we need check this app version + */ + let isV1LedgerAPP = false + if (fromAddr.account.accountGroup.vault.type === 'hw') { + // is hw wallet, we check is 1.x app version + const {Conflux: LedgerConflux} = await import('@fluent-wallet/ledger') + let ledger = new LedgerConflux() + // this call will establish a connection to the ledger device + const {version} = await ledger.getAppConfiguration() + if (version[0] === '1') { + isV1LedgerAPP = true + } + // disconnect from the ledger, if not disconnect will cause error when re-connect + await ledger.cleanUp() + ledger = null + } + + if (!newTx.type) { + if (network1559Compatible && !isV1LedgerAPP) { + newTx.type = ETH_TX_TYPES.EIP1559 + } else { + newTx.type = ETH_TX_TYPES.LEGACY + } + } else { + // if there has type, we need check is v1.x ledger app + if (isV1LedgerAPP) { + newTx.type = ETH_TX_TYPES.LEGACY + } + } + // tx without to must have data (deploy contract) if (!newTx.to && !newTx.data) throw InvalidParams( @@ -119,6 +191,15 @@ export const main = async args => { newTx.from, ]) } + // EIP-1559 + const is1559Tx = newTx.type === ETH_TX_TYPES.EIP1559 + if (is1559Tx && !network1559Compatible) + throw InvalidParams( + `Network ${network.name} don't support 1559 transaction`, + ) + if (!is1559Tx && !newTx.gasPrice) { + newTx.gasPrice = await cfx_gasPrice() + } if (newTx.to && (!newTx.gas || !newTx.storageLimit)) { const {type} = await wallet_detectAddressType( @@ -131,8 +212,6 @@ export const main = async args => { } } - if (!newTx.gasPrice) newTx.gasPrice = await cfx_gasPrice() - if (!newTx.gas || !newTx.storageLimit) { try { const {gasLimit, storageCollateralized} = @@ -148,11 +227,27 @@ export const main = async args => { } } + if (is1559Tx && network1559Compatible && !isV1LedgerAPP) { + const gasInfoEip1559 = await cfx_estimate1559Fee() + const {suggestedMaxPriorityFeePerGas, suggestedMaxFeePerGas} = + gasInfoEip1559?.medium || {} + if (!newTx.maxPriorityFeePerGas) + newTx.maxPriorityFeePerGas = parseUnits( + suggestedMaxPriorityFeePerGas, + 'gwei', + ).toHexString() + if (!newTx.maxFeePerGas) + newTx.maxFeePerGas = parseUnits( + suggestedMaxFeePerGas, + 'gwei', + ).toHexString() + } + let raw if (fromAddr.account.accountGroup.vault.type === 'hw') { if (dryRun) { raw = cfxSignTransaction( - newTx, + formatTx(newTx), '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', network.netId, ) @@ -160,7 +255,7 @@ export const main = async args => { raw = await signWithHardwareWallet({ args, accountId: fromAddr.account.eid, - tx: newTx, + tx: formatTx(newTx), addressId: fromAddr.eid, device: fromAddr.account.accountGroup.vault.device, }) @@ -173,7 +268,7 @@ export const main = async args => { if (dryRun) pk = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef' - raw = cfxSignTransaction(newTx, pk, network.netId) + raw = cfxSignTransaction(formatTx(newTx), pk, network.netId) } if (returnTxMeta) { diff --git a/packages/rpcs/cfx_signTransaction/package.json b/packages/rpcs/cfx_signTransaction/package.json index 19a7d4572..e1c35af36 100644 --- a/packages/rpcs/cfx_signTransaction/package.json +++ b/packages/rpcs/cfx_signTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.3", + "version": "1.0.8", "dependencies": { "@fluent-wallet/ledger": "workspace:packages/ledger", "@fluent-wallet/signature": "workspace:packages/signature" diff --git a/packages/rpcs/cfx_signTxWithLedgerNanoS/package.json b/packages/rpcs/cfx_signTxWithLedgerNanoS/package.json index 73d0f165c..95c605acd 100644 --- a/packages/rpcs/cfx_signTxWithLedgerNanoS/package.json +++ b/packages/rpcs/cfx_signTxWithLedgerNanoS/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.7", + "version": "0.0.10", "dependencies": { "@fluent-wallet/ledger": "workspace:*", "@fluent-wallet/signature": "workspace:*", diff --git a/packages/rpcs/cfx_signTypedData_v4/package.json b/packages/rpcs/cfx_signTypedData_v4/package.json index 61cb5819f..dc413077f 100644 --- a/packages/rpcs/cfx_signTypedData_v4/package.json +++ b/packages/rpcs/cfx_signTypedData_v4/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/cfx_sign-typed-data_v4", "type": "module", "main": "index.js", - "version": "0.0.16", + "version": "0.0.18", "dependencies": { "@fluent-wallet/signature": "workspace:packages/signature", "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/eth_accounts/package.json b/packages/rpcs/eth_accounts/package.json index c3f7395b7..1987f5d11 100644 --- a/packages/rpcs/eth_accounts/package.json +++ b/packages/rpcs/eth_accounts/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_accounts", "type": "module", "main": "index.js", - "version": "3.0.0", + "version": "3.0.1", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_blockNumber/package.json b/packages/rpcs/eth_blockNumber/package.json index c389991df..643f7c4a8 100644 --- a/packages/rpcs/eth_blockNumber/package.json +++ b/packages/rpcs/eth_blockNumber/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_block-number", "type": "module", "main": "index.js", - "version": "0.0.12", + "version": "0.0.13", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_call/package.json b/packages/rpcs/eth_call/package.json index e355088cf..e22b7995d 100644 --- a/packages/rpcs/eth_call/package.json +++ b/packages/rpcs/eth_call/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/eth-transaction-schema": "workspace:packages/eth-transaction-schema", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/eth_chainId/package.json b/packages/rpcs/eth_chainId/package.json index 99323a750..1630d6cf9 100644 --- a/packages/rpcs/eth_chainId/package.json +++ b/packages/rpcs/eth_chainId/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_chain-id", "type": "module", "main": "index.js", - "version": "0.1.1", + "version": "0.1.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_estimate1559Fee/package.json b/packages/rpcs/eth_estimate1559Fee/package.json index 2949a16dc..a91f6f64f 100644 --- a/packages/rpcs/eth_estimate1559Fee/package.json +++ b/packages/rpcs/eth_estimate1559Fee/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_estimate-1559-fee", "type": "module", "main": "index.js", - "version": "0.1.3", + "version": "0.1.4", "dependencies": { "@ethersproject/units": "5.6.1", "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/eth_estimateGas/package.json b/packages/rpcs/eth_estimateGas/package.json index 414126161..2182d9eff 100644 --- a/packages/rpcs/eth_estimateGas/package.json +++ b/packages/rpcs/eth_estimateGas/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@fluent-wallet/eth-transaction-schema": "workspace:packages/eth-transaction-schema", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/eth_feeHistory/package.json b/packages/rpcs/eth_feeHistory/package.json index 96aaaaa20..37a2746c9 100644 --- a/packages/rpcs/eth_feeHistory/package.json +++ b/packages/rpcs/eth_feeHistory/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_gasPrice/package.json b/packages/rpcs/eth_gasPrice/package.json index d651ffcbd..2ca94e4fa 100644 --- a/packages/rpcs/eth_gasPrice/package.json +++ b/packages/rpcs/eth_gasPrice/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_gas-price", "type": "module", "main": "index.js", - "version": "0.0.7", + "version": "0.0.8", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getBalance/package.json b/packages/rpcs/eth_getBalance/package.json index ccda28344..fe0d846cc 100644 --- a/packages/rpcs/eth_getBalance/package.json +++ b/packages/rpcs/eth_getBalance/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_get-balance", "type": "module", "main": "index.js", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getBlockByHash/package.json b/packages/rpcs/eth_getBlockByHash/package.json index 88702bd98..39765dede 100644 --- a/packages/rpcs/eth_getBlockByHash/package.json +++ b/packages/rpcs/eth_getBlockByHash/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getBlockByNumber/package.json b/packages/rpcs/eth_getBlockByNumber/package.json index 192707b40..ad3b116aa 100644 --- a/packages/rpcs/eth_getBlockByNumber/package.json +++ b/packages/rpcs/eth_getBlockByNumber/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getCode/package.json b/packages/rpcs/eth_getCode/package.json index 4828a60d9..6ec6ddd9e 100644 --- a/packages/rpcs/eth_getCode/package.json +++ b/packages/rpcs/eth_getCode/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_get-code", "type": "module", "main": "index.js", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getLogs/package.json b/packages/rpcs/eth_getLogs/package.json index 21604b4fa..7989ae95e 100644 --- a/packages/rpcs/eth_getLogs/package.json +++ b/packages/rpcs/eth_getLogs/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.1", + "version": "0.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getTransactionByHash/package.json b/packages/rpcs/eth_getTransactionByHash/package.json index 15e694787..f34649331 100644 --- a/packages/rpcs/eth_getTransactionByHash/package.json +++ b/packages/rpcs/eth_getTransactionByHash/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getTransactionCount/package.json b/packages/rpcs/eth_getTransactionCount/package.json index 268b26e64..7992ac2db 100644 --- a/packages/rpcs/eth_getTransactionCount/package.json +++ b/packages/rpcs/eth_getTransactionCount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_get-transaction-count", "type": "module", "main": "index.js", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_getTransactionReceipt/package.json b/packages/rpcs/eth_getTransactionReceipt/package.json index 4e65cfdba..28bf71437 100644 --- a/packages/rpcs/eth_getTransactionReceipt/package.json +++ b/packages/rpcs/eth_getTransactionReceipt/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_maxPriorityFeePerGas/package.json b/packages/rpcs/eth_maxPriorityFeePerGas/package.json index 1f43ab6cc..31db16e74 100644 --- a/packages/rpcs/eth_maxPriorityFeePerGas/package.json +++ b/packages/rpcs/eth_maxPriorityFeePerGas/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_max-priority-fee-per-gas", "type": "module", "main": "index.js", - "version": "0.1.0", + "version": "0.1.1", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_requestAccounts/index.js b/packages/rpcs/eth_requestAccounts/index.js index 28042474b..62c36acf3 100644 --- a/packages/rpcs/eth_requestAccounts/index.js +++ b/packages/rpcs/eth_requestAccounts/index.js @@ -24,7 +24,6 @@ export const main = async ({ } const permissionsToRequest = { eth_accounts: {}, - wallet_crossNetworkTypeGetEthereumHexAddress: {}, } const permsRes = await wallet_requestPermissions([permissionsToRequest]) diff --git a/packages/rpcs/eth_requestAccounts/package.json b/packages/rpcs/eth_requestAccounts/package.json index 724826147..adc0f3390 100644 --- a/packages/rpcs/eth_requestAccounts/package.json +++ b/packages/rpcs/eth_requestAccounts/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_request-accounts", "type": "module", "main": "index.js", - "version": "3.0.1", + "version": "3.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_sendRawTransaction/package.json b/packages/rpcs/eth_sendRawTransaction/package.json index 8978a411d..f42b132f7 100644 --- a/packages/rpcs/eth_sendRawTransaction/package.json +++ b/packages/rpcs/eth_sendRawTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/eth_sendTransaction/package.json b/packages/rpcs/eth_sendTransaction/package.json index c801c7e27..28301f589 100644 --- a/packages/rpcs/eth_sendTransaction/package.json +++ b/packages/rpcs/eth_sendTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "2.0.4", + "version": "2.0.7", "dependencies": { "@fluent-wallet/eth_sign-transaction": "workspace:*", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/eth_signTransaction/package.json b/packages/rpcs/eth_signTransaction/package.json index e0f450931..7c1973138 100644 --- a/packages/rpcs/eth_signTransaction/package.json +++ b/packages/rpcs/eth_signTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "1.0.5", + "version": "1.0.8", "dependencies": { "@ethersproject/units": "5.6.1", "@fluent-wallet/consts": "workspace:*", diff --git a/packages/rpcs/eth_signTxWithLedgerNanoS/package.json b/packages/rpcs/eth_signTxWithLedgerNanoS/package.json index 08b13d69e..0ce67b092 100644 --- a/packages/rpcs/eth_signTxWithLedgerNanoS/package.json +++ b/packages/rpcs/eth_signTxWithLedgerNanoS/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.6", + "version": "0.0.8", "dependencies": { "@ethereumjs/rlp": "5.0.2", "@ethereumjs/tx": "5.3.0", diff --git a/packages/rpcs/eth_signTypedData_v4/package.json b/packages/rpcs/eth_signTypedData_v4/package.json index f5a3e77d4..4bb2f55a2 100644 --- a/packages/rpcs/eth_signTypedData_v4/package.json +++ b/packages/rpcs/eth_signTypedData_v4/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/eth_sign-typed-data_v4", "type": "module", "main": "index.js", - "version": "0.0.15", + "version": "0.0.17", "dependencies": { "@fluent-wallet/cfx_sign-typed-data_v4": "workspace:packages/rpcs/cfx_signTypedData_v4" } diff --git a/packages/rpcs/net_version/package.json b/packages/rpcs/net_version/package.json index 97769ebcc..3ebcf5b2c 100644 --- a/packages/rpcs/net_version/package.json +++ b/packages/rpcs/net_version/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/net_version", "type": "module", "main": "index.js", - "version": "0.2.1", + "version": "0.2.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/personal_sign/package.json b/packages/rpcs/personal_sign/package.json index 2647bed82..a18171a84 100644 --- a/packages/rpcs/personal_sign/package.json +++ b/packages/rpcs/personal_sign/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/personal_sign", "type": "module", "main": "index.js", - "version": "1.0.1", + "version": "1.0.3", "dependencies": { "@fluent-wallet/signature": "workspace:packages/signature", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/txpool_nextNonce/package.json b/packages/rpcs/txpool_nextNonce/package.json index 05f1215b7..092b5de30 100644 --- a/packages/rpcs/txpool_nextNonce/package.json +++ b/packages/rpcs/txpool_nextNonce/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_accounts/package.json b/packages/rpcs/wallet_accounts/package.json index cd2daf4a0..7cd77c3da 100644 --- a/packages/rpcs/wallet_accounts/package.json +++ b/packages/rpcs/wallet_accounts/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_addConfluxChain/package.json b/packages/rpcs/wallet_addConfluxChain/package.json index e7e29cdae..5e2641412 100644 --- a/packages/rpcs/wallet_addConfluxChain/package.json +++ b/packages/rpcs/wallet_addConfluxChain/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_add-conflux-chain", "type": "module", "main": "index.js", - "version": "0.0.19", + "version": "0.0.20", "dependencies": { "@fluent-wallet/wallet_add-ethereum-chain": "workspace:packages/rpcs/wallet_addEthereumChain" } diff --git a/packages/rpcs/wallet_addEthereumChain/package.json b/packages/rpcs/wallet_addEthereumChain/package.json index 48dac0ae6..4652e5599 100644 --- a/packages/rpcs/wallet_addEthereumChain/package.json +++ b/packages/rpcs/wallet_addEthereumChain/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_add-ethereum-chain", "type": "module", "main": "index.js", - "version": "0.0.19", + "version": "0.0.20", "dependencies": { "@fluent-wallet/spec": "1.0.6", "@fluent-wallet/wallet_add-network": "workspace:packages/rpcs/wallet_addNetwork" diff --git a/packages/rpcs/wallet_addHdPath/package.json b/packages/rpcs/wallet_addHdPath/package.json index bf565ddfb..6d4a2ad37 100644 --- a/packages/rpcs/wallet_addHdPath/package.json +++ b/packages/rpcs/wallet_addHdPath/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_add-hd-path", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_addNetwork/package.json b/packages/rpcs/wallet_addNetwork/package.json index 1a226ecf8..eea735699 100644 --- a/packages/rpcs/wallet_addNetwork/package.json +++ b/packages/rpcs/wallet_addNetwork/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_add-network", "type": "module", "main": "index.js", - "version": "1.0.12", + "version": "1.0.13", "dependencies": { "@fluent-wallet/consts": "workspace:packages/consts", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_addPendingUserAuthRequest/package.json b/packages/rpcs/wallet_addPendingUserAuthRequest/package.json index d0adfdefa..40c26d1ba 100644 --- a/packages/rpcs/wallet_addPendingUserAuthRequest/package.json +++ b/packages/rpcs/wallet_addPendingUserAuthRequest/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_add-pending-user-auth-request", "type": "module", "main": "index.js", - "version": "0.0.12", + "version": "0.0.13", "dependencies": { "@fluent-wallet/csp": "workspace:packages/csp", "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/wallet_addVault/package.json b/packages/rpcs/wallet_addVault/package.json index 9ee843661..18a888ef5 100644 --- a/packages/rpcs/wallet_addVault/package.json +++ b/packages/rpcs/wallet_addVault/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_add-vault", "type": "module", "main": "index.js", - "version": "1.1.4", + "version": "1.1.6", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/base32-address": "workspace:packages/base32-address", diff --git a/packages/rpcs/wallet_afterUnlock/package.json b/packages/rpcs/wallet_afterUnlock/package.json index 3158a7bb1..2d9fb2101 100644 --- a/packages/rpcs/wallet_afterUnlock/package.json +++ b/packages/rpcs/wallet_afterUnlock/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.5", + "version": "0.0.6", "dependencies": { "@fluent-wallet/spec": "1.0.6", "ramda": "0.28.0" diff --git a/packages/rpcs/wallet_chainId/package.json b/packages/rpcs/wallet_chainId/package.json index 77fde372f..64725022b 100644 --- a/packages/rpcs/wallet_chainId/package.json +++ b/packages/rpcs/wallet_chainId/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_cleanupTx/package.json b/packages/rpcs/wallet_cleanupTx/package.json index e0ea670b9..f5c9481da 100644 --- a/packages/rpcs/wallet_cleanupTx/package.json +++ b/packages/rpcs/wallet_cleanupTx/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_createAccount/index.js b/packages/rpcs/wallet_createAccount/index.js index 83d6ae8d1..8c7ad75b3 100644 --- a/packages/rpcs/wallet_createAccount/index.js +++ b/packages/rpcs/wallet_createAccount/index.js @@ -44,7 +44,7 @@ export const main = async ({ nickname: 1, }, }) - if (!group) throw InvalidParams('Invalid account group id') + if (!group) throw InvalidParams(`Invalid account group id ${accountGroupId}`) const {vault} = group if (vault.type !== 'hd') @@ -78,8 +78,19 @@ export const main = async ({ only0x1Prefixed: vault.cfxOnly, }), })), - ).then(params => - params.map(({eid, netId, type, addr: {address, privateKey}}) => { + ).then(params => { + const _group = findGroup({ + groupId: accountGroupId, + g: { + account: {nickname: 1}, + vault: {type: 1, ddata: 1, data: 1, cfxOnly: 1}, + nickname: 1, + }, + }) + // check group is deleted or not + if (!_group) + throw InvalidParams(`Invalid account group id ${accountGroupId}`) + return params.map(({eid, netId, type, addr: {address, privateKey}}) => { const accountId = findAccount({ groupId: accountGroupId, @@ -110,8 +121,8 @@ export const main = async ({ ]) return tempids.accountId ?? accountId - }), - ) + }) + }) )[0] if (_popup && select) { diff --git a/packages/rpcs/wallet_createAccount/package.json b/packages/rpcs/wallet_createAccount/package.json index 0d5eb5f44..863233064 100644 --- a/packages/rpcs/wallet_createAccount/package.json +++ b/packages/rpcs/wallet_createAccount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_create-account", "type": "module", "main": "index.js", - "version": "2.0.0", + "version": "2.0.3", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/base32-address": "workspace:packages/base32-address", diff --git a/packages/rpcs/wallet_createAddress/package.json b/packages/rpcs/wallet_createAddress/package.json index 011fe706a..1425ff0eb 100644 --- a/packages/rpcs/wallet_createAddress/package.json +++ b/packages/rpcs/wallet_createAddress/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_create-address", "type": "module", "main": "index.js", - "version": "1.0.6", + "version": "1.0.8", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/base32-address": "workspace:packages/base32-address", diff --git a/packages/rpcs/wallet_dbQuery/package.json b/packages/rpcs/wallet_dbQuery/package.json index eca91ddc6..1cd12f43d 100644 --- a/packages/rpcs/wallet_dbQuery/package.json +++ b/packages/rpcs/wallet_dbQuery/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.5", + "version": "0.0.6", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_deleteAccount/index.js b/packages/rpcs/wallet_deleteAccount/index.js index 1e62df9ac..1ad2c223b 100644 --- a/packages/rpcs/wallet_deleteAccount/index.js +++ b/packages/rpcs/wallet_deleteAccount/index.js @@ -9,16 +9,22 @@ export const schemas = { export const permissions = { external: ['popup'], - methods: ['wallet_validatePassword', 'wallet_deleteAccountGroup'], + methods: [ + 'wallet_validatePassword', + 'wallet_deleteAccountGroup', + 'wallet_deleteApp', + 'wallet_setAppCurrentAccount', + ], db: ['retractAccount', 'findAccount'], } export const main = async ({ Err: {InvalidParams}, db: {findAccount, retractAccount}, - rpcs: {wallet_validatePassword, wallet_deleteAccountGroup}, + rpcs, params: {accountId, password}, }) => { + const {wallet_validatePassword, wallet_deleteAccountGroup} = rpcs if (!(await wallet_validatePassword({password}))) throw InvalidParams('Invalid password') @@ -45,6 +51,10 @@ export const main = async ({ }) } - retractAccount({accountId, hwVaultData: ddata}) + const sideEffects = retractAccount({accountId, hwVaultData: ddata}) + + await Promise.all( + sideEffects?.map(([method, params]) => rpcs[method]?.(params)), + ) return true } diff --git a/packages/rpcs/wallet_deleteAccount/package.json b/packages/rpcs/wallet_deleteAccount/package.json index a336bcac5..290c4fdbf 100644 --- a/packages/rpcs/wallet_deleteAccount/package.json +++ b/packages/rpcs/wallet_deleteAccount/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.2.0", - "version": "0.0.2", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6", "browser-passworder": "2.0.3" diff --git a/packages/rpcs/wallet_deleteAccountGroup/index.js b/packages/rpcs/wallet_deleteAccountGroup/index.js index 61db43335..2414ce518 100644 --- a/packages/rpcs/wallet_deleteAccountGroup/index.js +++ b/packages/rpcs/wallet_deleteAccountGroup/index.js @@ -14,15 +14,20 @@ export const schemas = { export const permissions = { db: ['getAccountGroupById', 'retractGroup'], external: ['popup'], - methods: ['wallet_validatePassword'], + methods: [ + 'wallet_deleteApp', + 'wallet_setAppCurrentAccount', + 'wallet_validatePassword', + ], } export const main = async ({ Err: {InvalidParams}, - rpcs: {wallet_validatePassword}, + rpcs, db: {getAccountGroupById, retractGroup}, params: {accountGroupId, password}, }) => { + const {wallet_validatePassword} = rpcs if (!(await wallet_validatePassword({password}))) throw InvalidParams('Invalid password') @@ -30,6 +35,10 @@ export const main = async ({ if (!group) throw InvalidParams(`Invalid account group id ${accountGroupId}`) - retractGroup({groupId: group.eid}) + const sideEffects = retractGroup({groupId: group.eid}) + + await Promise.all( + sideEffects?.map(([method, params]) => rpcs[method]?.(params)), + ) return true } diff --git a/packages/rpcs/wallet_deleteAccountGroup/package.json b/packages/rpcs/wallet_deleteAccountGroup/package.json index d142f90df..1de6a5542 100644 --- a/packages/rpcs/wallet_deleteAccountGroup/package.json +++ b/packages/rpcs/wallet_deleteAccountGroup/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_delete-account-group", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.11", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_deleteApp/package.json b/packages/rpcs/wallet_deleteApp/package.json index 862230be6..d1b767657 100644 --- a/packages/rpcs/wallet_deleteApp/package.json +++ b/packages/rpcs/wallet_deleteApp/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.6", + "version": "0.0.7", "dependencies": { "@fluent-wallet/checks": "workspace:*", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_deleteMemo/package.json b/packages/rpcs/wallet_deleteMemo/package.json index 35b36f60f..d2f444955 100644 --- a/packages/rpcs/wallet_deleteMemo/package.json +++ b/packages/rpcs/wallet_deleteMemo/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.2.0", - "version": "0.0.1", + "version": "0.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_deleteNetwork/package.json b/packages/rpcs/wallet_deleteNetwork/package.json index 90ce2efe5..c29ada69c 100644 --- a/packages/rpcs/wallet_deleteNetwork/package.json +++ b/packages/rpcs/wallet_deleteNetwork/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_delete-network", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_detectAddressType/package.json b/packages/rpcs/wallet_detectAddressType/package.json index 79f600558..b124ab88c 100644 --- a/packages/rpcs/wallet_detectAddressType/package.json +++ b/packages/rpcs/wallet_detectAddressType/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@fluent-wallet/detect-address-type": "workspace:packages/detect-address-type", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_detectNetworkType/package.json b/packages/rpcs/wallet_detectNetworkType/package.json index 63821fc76..71cf29a9d 100644 --- a/packages/rpcs/wallet_detectNetworkType/package.json +++ b/packages/rpcs/wallet_detectNetworkType/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_detect-network-type", "type": "module", "main": "index.js", - "version": "0.0.11", + "version": "0.0.12", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_discoverAccounts/package.json b/packages/rpcs/wallet_discoverAccounts/package.json index c13d86ebb..0866f5fcb 100644 --- a/packages/rpcs/wallet_discoverAccounts/package.json +++ b/packages/rpcs/wallet_discoverAccounts/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_discover-accounts", "main": "index.js", "type": "module", - "version": "1.0.5", + "version": "1.0.6", "dependencies": { "@fluent-wallet/addr-by-network": "workspace:packages/addr-by-network", "@fluent-wallet/csp": "workspace:packages/csp", diff --git a/packages/rpcs/wallet_enrichConfluxTx/package.json b/packages/rpcs/wallet_enrichConfluxTx/package.json index f43402c41..3ef29d0ab 100644 --- a/packages/rpcs/wallet_enrichConfluxTx/package.json +++ b/packages/rpcs/wallet_enrichConfluxTx/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/base32-address": "workspace:*", "@fluent-wallet/contract-method-name": "workspace:*", diff --git a/packages/rpcs/wallet_enrichEthereumTx/package.json b/packages/rpcs/wallet_enrichEthereumTx/package.json index 0f0e37199..c986bdf4e 100644 --- a/packages/rpcs/wallet_enrichEthereumTx/package.json +++ b/packages/rpcs/wallet_enrichEthereumTx/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.7", + "version": "0.0.8", "dependencies": { "@fluent-wallet/contract-method-name": "workspace:*", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_enrichTxs/package.json b/packages/rpcs/wallet_enrichTxs/package.json index b8cba417f..53cf783ff 100644 --- a/packages/rpcs/wallet_enrichTxs/package.json +++ b/packages/rpcs/wallet_enrichTxs/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_exportAccount/package.json b/packages/rpcs/wallet_exportAccount/package.json index 99b93a3eb..2a6a10667 100644 --- a/packages/rpcs/wallet_exportAccount/package.json +++ b/packages/rpcs/wallet_exportAccount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_export-account", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/hdkey": "workspace:packages/hdkey", "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/wallet_exportAccountGroup/package.json b/packages/rpcs/wallet_exportAccountGroup/package.json index 2d84724ee..9f5ea5474 100644 --- a/packages/rpcs/wallet_exportAccountGroup/package.json +++ b/packages/rpcs/wallet_exportAccountGroup/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_export-account-group", "type": "module", "main": "index.js", - "version": "0.0.7", + "version": "0.0.8", "dependencies": { "@fluent-wallet/base32-address": "workspace:packages/base32-address", "@fluent-wallet/consts": "workspace:packages/consts", diff --git a/packages/rpcs/wallet_exportAll/package.json b/packages/rpcs/wallet_exportAll/package.json index c13c0c815..c10266b47 100644 --- a/packages/rpcs/wallet_exportAll/package.json +++ b/packages/rpcs/wallet_exportAll/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_export-all", "type": "module", "main": "index.js", - "version": "0.0.7", + "version": "0.0.8", "dependencies": { "@fluent-wallet/spec": "1.0.6", "browser-passworder": "2.0.3" diff --git a/packages/rpcs/wallet_generateAddress/package.json b/packages/rpcs/wallet_generateAddress/package.json index 21454ce69..855ae8558 100644 --- a/packages/rpcs/wallet_generateAddress/package.json +++ b/packages/rpcs/wallet_generateAddress/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_generate-address", "type": "module", "main": "index.js", - "version": "0.0.13", + "version": "0.0.15", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/base32-address": "workspace:packages/base32-address", diff --git a/packages/rpcs/wallet_generatePrivateKey/package.json b/packages/rpcs/wallet_generatePrivateKey/package.json index d039ed85b..5c9692679 100644 --- a/packages/rpcs/wallet_generatePrivateKey/package.json +++ b/packages/rpcs/wallet_generatePrivateKey/package.json @@ -1,6 +1,6 @@ { "name": "@fluent-wallet/wallet_generate-private-key", - "version": "0.0.13", + "version": "0.0.15", "type": "module", "main": "index.js", "dependencies": { diff --git a/packages/rpcs/wallet_getAccountAddressByNetwork/package.json b/packages/rpcs/wallet_getAccountAddressByNetwork/package.json index a10a75f37..b3bece799 100644 --- a/packages/rpcs/wallet_getAccountAddressByNetwork/package.json +++ b/packages/rpcs/wallet_getAccountAddressByNetwork/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.6", + "version": "0.0.7", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getAccountGroup/package.json b/packages/rpcs/wallet_getAccountGroup/package.json index 8e352e5c5..a0dcd4601 100644 --- a/packages/rpcs/wallet_getAccountGroup/package.json +++ b/packages/rpcs/wallet_getAccountGroup/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-account-group", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getAccountGroupVaultValue/package.json b/packages/rpcs/wallet_getAccountGroupVaultValue/package.json index 6db2c6a8a..c552c3112 100644 --- a/packages/rpcs/wallet_getAccountGroupVaultValue/package.json +++ b/packages/rpcs/wallet_getAccountGroupVaultValue/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-account-group-vault-value", "type": "module", "main": "index.js", - "version": "0.0.7", + "version": "0.0.8", "dependencies": { "@fluent-wallet/spec": "1.0.6", "browser-passworder": "2.0.3" diff --git a/packages/rpcs/wallet_getAddressPrivateKey/package.json b/packages/rpcs/wallet_getAddressPrivateKey/package.json index f47154596..58ec91078 100644 --- a/packages/rpcs/wallet_getAddressPrivateKey/package.json +++ b/packages/rpcs/wallet_getAddressPrivateKey/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-address-private-key", "type": "module", "main": "index.js", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@fluent-wallet/hdkey": "workspace:packages/hdkey", "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/wallet_getBalance/package.json b/packages/rpcs/wallet_getBalance/package.json index 9dbf45f8d..cb78d3af7 100644 --- a/packages/rpcs/wallet_getBalance/package.json +++ b/packages/rpcs/wallet_getBalance/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-balance", "type": "module", "main": "index.js", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@ethersproject/bytes": "5.6.1", "@fluent-wallet/addr-by-network": "workspace:packages/addr-by-network", diff --git a/packages/rpcs/wallet_getBlockOrEpochNumber/package.json b/packages/rpcs/wallet_getBlockOrEpochNumber/package.json index e0d71c2b1..12f0deb63 100644 --- a/packages/rpcs/wallet_getBlockOrEpochNumber/package.json +++ b/packages/rpcs/wallet_getBlockOrEpochNumber/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.2.0", - "version": "0.0.1", + "version": "0.0.2", "dependencies": { "@fluent-wallet/cfx_epoch-number": "workspace:*", "@fluent-wallet/eth_block-number": "workspace:*", diff --git a/packages/rpcs/wallet_getBlockTime/package.json b/packages/rpcs/wallet_getBlockTime/package.json index 25e00d493..c6e9654d0 100644 --- a/packages/rpcs/wallet_getBlockTime/package.json +++ b/packages/rpcs/wallet_getBlockTime/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.2.0", - "version": "0.0.1", + "version": "0.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getBlockchainExplorerUrl/package.json b/packages/rpcs/wallet_getBlockchainExplorerUrl/package.json index 5968f3e6d..7f706fac4 100644 --- a/packages/rpcs/wallet_getBlockchainExplorerUrl/package.json +++ b/packages/rpcs/wallet_getBlockchainExplorerUrl/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.6", + "version": "0.0.7", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getCurrentAccount/package.json b/packages/rpcs/wallet_getCurrentAccount/package.json index d7e8534b6..7d974c35b 100644 --- a/packages/rpcs/wallet_getCurrentAccount/package.json +++ b/packages/rpcs/wallet_getCurrentAccount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-current-account", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getCurrentNetwork/package.json b/packages/rpcs/wallet_getCurrentNetwork/package.json index fd6f4b805..bbd22eab6 100644 --- a/packages/rpcs/wallet_getCurrentNetwork/package.json +++ b/packages/rpcs/wallet_getCurrentNetwork/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-current-network", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getCurrentViewingApp/package.json b/packages/rpcs/wallet_getCurrentViewingApp/package.json index 575bbe1ed..f8960d32d 100644 --- a/packages/rpcs/wallet_getCurrentViewingApp/package.json +++ b/packages/rpcs/wallet_getCurrentViewingApp/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.10", + "version": "0.0.11", "dependencies": { "@fluent-wallet/spec": "1.0.6", "@fluent-wallet/webextension": "workspace:packages/webextension" diff --git a/packages/rpcs/wallet_getFluentMetadata/index.js b/packages/rpcs/wallet_getFluentMetadata/index.js index 0ca054163..c385f2b6e 100644 --- a/packages/rpcs/wallet_getFluentMetadata/index.js +++ b/packages/rpcs/wallet_getFluentMetadata/index.js @@ -1,5 +1,5 @@ import {optParam} from '@fluent-wallet/spec' -import {PACKAGE_VERSION} from '@fluent-wallet/inner-utils' +import {PACKAGE_VERSION, VIEW_PACKAGE_VERSION} from '@fluent-wallet/inner-utils' export const NAME = 'wallet_getFluentMetadata' @@ -16,6 +16,9 @@ export const permissions = { export const main = () => { return { + // this version is only x.y.z version: PACKAGE_VERSION, + // this version is include the version suffix e.g v1.0.0.rc-1 + view_version: VIEW_PACKAGE_VERSION, } } diff --git a/packages/rpcs/wallet_getFluentMetadata/package.json b/packages/rpcs/wallet_getFluentMetadata/package.json index 4e919deed..6ca8ca1e5 100644 --- a/packages/rpcs/wallet_getFluentMetadata/package.json +++ b/packages/rpcs/wallet_getFluentMetadata/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.3", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getImportHardwareWalletInfo/package.json b/packages/rpcs/wallet_getImportHardwareWalletInfo/package.json index b69b536b7..4fb01d846 100644 --- a/packages/rpcs/wallet_getImportHardwareWalletInfo/package.json +++ b/packages/rpcs/wallet_getImportHardwareWalletInfo/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/spec": "1.0.6", "browser-passworder": "2.0.3" diff --git a/packages/rpcs/wallet_getNetwork/package.json b/packages/rpcs/wallet_getNetwork/package.json index bebfcd620..7cd41ff56 100644 --- a/packages/rpcs/wallet_getNetwork/package.json +++ b/packages/rpcs/wallet_getNetwork/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.3", + "version": "1.0.4", "dependencies": { "@fluent-wallet/checks": "workspace:packages/checks", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_getNextNonce/package.json b/packages/rpcs/wallet_getNextNonce/package.json index b6fcd2fa4..0d49c3238 100644 --- a/packages/rpcs/wallet_getNextNonce/package.json +++ b/packages/rpcs/wallet_getNextNonce/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-next-nonce", "type": "module", "main": "index.js", - "version": "2.0.1", + "version": "2.0.2", "dependencies": { "@fluent-wallet/addr-by-network": "workspace:packages/addr-by-network", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_getNextUsableNonce/package.json b/packages/rpcs/wallet_getNextUsableNonce/package.json index 5e0882a7c..fd24c8bd6 100644 --- a/packages/rpcs/wallet_getNextUsableNonce/package.json +++ b/packages/rpcs/wallet_getNextUsableNonce/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getPendingAuthRequest/package.json b/packages/rpcs/wallet_getPendingAuthRequest/package.json index 969f52daf..5a0560173 100644 --- a/packages/rpcs/wallet_getPendingAuthRequest/package.json +++ b/packages/rpcs/wallet_getPendingAuthRequest/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-pending-auth-request", "type": "module", "main": "index.js", - "version": "0.1.1", + "version": "0.1.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getPermissions/package.json b/packages/rpcs/wallet_getPermissions/package.json index a689f6070..d828a7037 100644 --- a/packages/rpcs/wallet_getPermissions/package.json +++ b/packages/rpcs/wallet_getPermissions/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_get-permissions", "type": "module", "main": "index.js", - "version": "2.0.0", + "version": "2.0.1", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_getPreferences/package.json b/packages/rpcs/wallet_getPreferences/package.json index 3a6d2cdee..3c5de0eb2 100644 --- a/packages/rpcs/wallet_getPreferences/package.json +++ b/packages/rpcs/wallet_getPreferences/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.3", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js b/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js index 2520150e4..6e9bc2a9f 100644 --- a/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js +++ b/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js @@ -11,11 +11,19 @@ import { pluck, } from '@fluent-wallet/transducers' import {processError} from '@fluent-wallet/conflux-tx-error' +import {ETH_TX_TYPES} from '@fluent-wallet/consts' import {BigNumber} from '@ethersproject/bignumber' import {identity} from '@fluent-wallet/compose' export const NAME = 'wallet_handleUnfinishedCFXTx' +function getGasPrice(tx) { + const payload = tx.txPayload + return payload.type === ETH_TX_TYPES.EIP1559 + ? payload.maxFeePerGas + : payload.gasPrice +} + function defs(...args) { const s = stream({ id: args.length === 2 ? args[0] : undefined, @@ -75,6 +83,7 @@ export const permissions = { 'setTxConfirmed', 'setTxUnsent', 'setTxChainSwitched', + 'queryTxWithSameNonce', ], } @@ -102,6 +111,7 @@ export const main = ({ setTxConfirmed, setTxUnsent, setTxChainSwitched, + queryTxWithSameNonce, }, params: {tx, address, okCb, failedCb}, network, @@ -211,12 +221,20 @@ export const main = ({ const isDuplicateTx = errorType === 'duplicateTx' const resendNonceTooStale = tx.resendAt && errorType === 'tooStaleNonce' - + const sameNonceTxs = queryTxWithSameNonce({hash}) || [] + const latestTx = sameNonceTxs.sort((a, b) => + BigNumber.from(getGasPrice(b)).sub(getGasPrice(a)).toNumber(), + )[0] + const disableNotification = latestTx?.hash !== hash const sameAsSuccess = isDuplicateTx || resendNonceTooStale const failed = !sameAsSuccess && shouldDiscard defs({ - failed: failed && {errorType, err}, + failed: failed && { + errorType, + err, + disableNotification, + }, sameAsSuccess, resend: !shouldDiscard && !sameAsSuccess, }) @@ -227,17 +245,18 @@ export const main = ({ ({err}) => typeof failedCb === 'function' && failedCb(err), ), - sideEffect(({errorType}) => { + sideEffect(({errorType, disableNotification}) => { if (setTxFailed({hash, error: errorType})) { - getExt().then(ext => - ext.notifications.create(hash, { - title: 'Failed transaction', - message: `Transaction ${parseInt( - tx.txPayload.nonce, - 16, - )} failed! ${err?.data || err?.message || ''}`, - }), - ) + !disableNotification && + getExt().then(ext => + ext.notifications.create(hash, { + title: 'Failed transaction', + message: `Transaction ${parseInt( + tx.txPayload.nonce, + 16, + )} failed! ${err?.data || err?.message || ''}`, + }), + ) } }), sideEffect(() => { diff --git a/packages/rpcs/wallet_handleUnfinishedCFXTx/index.test.js b/packages/rpcs/wallet_handleUnfinishedCFXTx/index.test.js index 7eb478407..aa38761cd 100644 --- a/packages/rpcs/wallet_handleUnfinishedCFXTx/index.test.js +++ b/packages/rpcs/wallet_handleUnfinishedCFXTx/index.test.js @@ -40,6 +40,20 @@ beforeEach(() => { raw: 'txraw', txPayload: {nonce: 'txnonce', epochHeight: '0x1'}, })), + queryTxWithSameNonce: vi.fn(() => [ + { + eid: 'txeid', + status: 0, + hash: 'txhash', + raw: 'txraw', + txPayload: { + nonce: 'txnonce', + epochHeight: '0x1', + type: '0x2', + maxFeePerGas: '0x5efeb1f00', + }, + }, + ]), setTxSkipped: vi.fn(), setTxFailed: vi.fn(), setTxSending: vi.fn(), diff --git a/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json b/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json index 5110d6311..e8f3033cb 100644 --- a/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json +++ b/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "1.0.9", + "version": "1.0.13", "dependencies": { "@ethersproject/bignumber": "5.6.2", "@fluent-wallet/compose": "workspace:*", diff --git a/packages/rpcs/wallet_handleUnfinishedETHTx/index.js b/packages/rpcs/wallet_handleUnfinishedETHTx/index.js index 7cd39f86e..2aaa06bbe 100644 --- a/packages/rpcs/wallet_handleUnfinishedETHTx/index.js +++ b/packages/rpcs/wallet_handleUnfinishedETHTx/index.js @@ -11,11 +11,19 @@ import { // pluck, } from '@fluent-wallet/transducers' import {processError} from '@fluent-wallet/ethereum-tx-error' +import {ETH_TX_TYPES} from '@fluent-wallet/consts' import {BigNumber} from '@ethersproject/bignumber' import {identity} from '@fluent-wallet/compose' export const NAME = 'wallet_handleUnfinishedETHTx' +function getGasPrice(tx) { + const payload = tx.txPayload + return payload.type === ETH_TX_TYPES.EIP1559 + ? payload.maxFeePerGas + : payload.gasPrice +} + function defs(...args) { const s = stream({ id: args.length === 2 ? args[0] : undefined, @@ -75,6 +83,7 @@ export const permissions = { 'setTxConfirmed', 'setTxUnsent', 'setTxChainSwitched', + 'queryTxWithSameNonce', ], } @@ -102,6 +111,7 @@ export const main = ({ setTxConfirmed, setTxUnsent, setTxChainSwitched, + queryTxWithSameNonce, }, params: {tx, address, okCb, failedCb}, network, @@ -216,13 +226,22 @@ export const main = ({ const resendPriceTooLow = tx.resendAt && errorType === 'replaceUnderpriced' if (resendPriceTooLow) errorType = 'replacedByAnotherTx' - + const sameNonceTxs = queryTxWithSameNonce({hash}) || [] + const latestTx = sameNonceTxs.sort((a, b) => + BigNumber.from(getGasPrice(b)).sub(getGasPrice(a)).toNumber(), + )[0] + const disableNotification = latestTx?.hash !== hash const sameAsSuccess = isDuplicateTx || resendNonceTooStale + const failed = !sameAsSuccess && (shouldDiscard || resendPriceTooLow) defs({ - failed: failed && {errorType, err}, + failed: failed && { + errorType, + err, + disableNotification: disableNotification, + }, sameAsSuccess, resend: !shouldDiscard && !sameAsSuccess, }) @@ -233,17 +252,18 @@ export const main = ({ ({err}) => typeof failedCb === 'function' && failedCb(err), ), - sideEffect(({errorType}) => { + sideEffect(({errorType, disableNotification}) => { if (setTxFailed({hash, error: errorType})) { - getExt().then(ext => - ext.notifications.create(hash, { - title: 'Failed transaction', - message: `Transaction ${parseInt( - tx.txPayload.nonce, - 16, - )} failed! ${err?.data || err?.message || ''}`, - }), - ) + !disableNotification && + getExt().then(ext => + ext.notifications.create(hash, { + title: 'Failed transaction', + message: `Transaction ${parseInt( + tx.txPayload.nonce, + 16, + )} failed! ${err?.data || err?.message || ''}`, + }), + ) } }), sideEffect(() => { diff --git a/packages/rpcs/wallet_handleUnfinishedETHTx/package.json b/packages/rpcs/wallet_handleUnfinishedETHTx/package.json index b1c1a16b1..8fe72f560 100644 --- a/packages/rpcs/wallet_handleUnfinishedETHTx/package.json +++ b/packages/rpcs/wallet_handleUnfinishedETHTx/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "1.0.10", + "version": "1.0.14", "dependencies": { "@ethersproject/bignumber": "5.6.2", "@fluent-wallet/compose": "workspace:*", diff --git a/packages/rpcs/wallet_handleUnfinishedTxs/index.js b/packages/rpcs/wallet_handleUnfinishedTxs/index.js index 29c95ea72..2ebc791c0 100644 --- a/packages/rpcs/wallet_handleUnfinishedTxs/index.js +++ b/packages/rpcs/wallet_handleUnfinishedTxs/index.js @@ -21,11 +21,17 @@ export const main = ({ txs.forEach(({tx, address, network}) => { if (network.type === 'cfx') { try { - wallet_handleUnfinishedCFXTx({network}, {tx, address: address.eid}) + wallet_handleUnfinishedCFXTx( + {network, networkName: network.name}, + {tx, address: address.eid}, + ) } catch (err) {} } else { try { - wallet_handleUnfinishedETHTx({network}, {tx, address: address.eid}) + wallet_handleUnfinishedETHTx( + {network, networkName: network.name}, + {tx, address: address.eid}, + ) } catch (err) {} } }) diff --git a/packages/rpcs/wallet_handleUnfinishedTxs/package.json b/packages/rpcs/wallet_handleUnfinishedTxs/package.json index e0e969bc0..9b08a1793 100644 --- a/packages/rpcs/wallet_handleUnfinishedTxs/package.json +++ b/packages/rpcs/wallet_handleUnfinishedTxs/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.5", + "version": "0.0.7", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_importAddress/package.json b/packages/rpcs/wallet_importAddress/package.json index f68f95592..b84f20a4c 100644 --- a/packages/rpcs/wallet_importAddress/package.json +++ b/packages/rpcs/wallet_importAddress/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_import-address", "type": "module", "main": "index.js", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_importAll/package.json b/packages/rpcs/wallet_importAll/package.json index d41a0262e..e40ef7583 100644 --- a/packages/rpcs/wallet_importAll/package.json +++ b/packages/rpcs/wallet_importAll/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_import-all", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6", "browser-passworder": "2.0.3", diff --git a/packages/rpcs/wallet_importHardwareWalletAccountGroupOrAccount/package.json b/packages/rpcs/wallet_importHardwareWalletAccountGroupOrAccount/package.json index a9934cc9c..06f6e5ac5 100644 --- a/packages/rpcs/wallet_importHardwareWalletAccountGroupOrAccount/package.json +++ b/packages/rpcs/wallet_importHardwareWalletAccountGroupOrAccount/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "3.0.3", + "version": "3.0.5", "dependencies": { "@fluent-wallet/base32-address": "workspace:*", "@fluent-wallet/ledger": "workspace:packages/ledger", diff --git a/packages/rpcs/wallet_importMnemonic/package.json b/packages/rpcs/wallet_importMnemonic/package.json index b689f0b53..7a2f9c96e 100644 --- a/packages/rpcs/wallet_importMnemonic/package.json +++ b/packages/rpcs/wallet_importMnemonic/package.json @@ -1,6 +1,6 @@ { "name": "@fluent-wallet/wallet_import-mnemonic", - "version": "0.0.13", + "version": "0.0.14", "type": "module", "main": "index.js", "dependencies": { diff --git a/packages/rpcs/wallet_importPrivateKey/package.json b/packages/rpcs/wallet_importPrivateKey/package.json index 6102e4f7a..226d07bcb 100644 --- a/packages/rpcs/wallet_importPrivateKey/package.json +++ b/packages/rpcs/wallet_importPrivateKey/package.json @@ -1,6 +1,6 @@ { "name": "@fluent-wallet/wallet_import-private-key", - "version": "0.0.10", + "version": "0.0.11", "type": "module", "main": "index.js", "dependencies": { diff --git a/packages/rpcs/wallet_metadataForPopup/package.json b/packages/rpcs/wallet_metadataForPopup/package.json index 8c7868722..2957ad5bf 100644 --- a/packages/rpcs/wallet_metadataForPopup/package.json +++ b/packages/rpcs/wallet_metadataForPopup/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_network1559Compatible/index.js b/packages/rpcs/wallet_network1559Compatible/index.js index a6530e2b9..e7d042b93 100644 --- a/packages/rpcs/wallet_network1559Compatible/index.js +++ b/packages/rpcs/wallet_network1559Compatible/index.js @@ -9,7 +9,7 @@ export const schemas = { export const permissions = { external: ['popup', 'inpage'], locked: true, - methods: ['eth_getBlockByNumber'], + methods: ['eth_getBlockByNumber', 'cfx_getBlockByEpochNumber'], db: [], } @@ -19,8 +19,14 @@ export const cache = { key: ({network}) => `${NAME}${network.endpoint}`, } -export const main = async ({rpcs: {eth_getBlockByNumber}, network}) => { - if (network.type === 'cfx') return false +export const main = async ({ + rpcs: {eth_getBlockByNumber, cfx_getBlockByEpochNumber}, + network, +}) => { + if (network.type === 'cfx') { + const block = await cfx_getBlockByEpochNumber(['latest_state', false]) + return block && block.baseFeePerGas + } const block = await eth_getBlockByNumber(['latest', false]) if (block && block.baseFeePerGas) return true return false diff --git a/packages/rpcs/wallet_network1559Compatible/package.json b/packages/rpcs/wallet_network1559Compatible/package.json index b402c4548..d4e6c7f72 100644 --- a/packages/rpcs/wallet_network1559Compatible/package.json +++ b/packages/rpcs/wallet_network1559Compatible/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.4", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_refetchBalance/package.json b/packages/rpcs/wallet_refetchBalance/package.json index c7ddaa48d..0ff361b10 100644 --- a/packages/rpcs/wallet_refetchBalance/package.json +++ b/packages/rpcs/wallet_refetchBalance/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.11", + "version": "0.0.12", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_refetchTokenList/package.json b/packages/rpcs/wallet_refetchTokenList/package.json index 40ebb5516..af120babb 100644 --- a/packages/rpcs/wallet_refetchTokenList/package.json +++ b/packages/rpcs/wallet_refetchTokenList/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.6", + "version": "0.0.7", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_refetchTxList/package.json b/packages/rpcs/wallet_refetchTxList/package.json index 60389becb..29b5d372f 100644 --- a/packages/rpcs/wallet_refetchTxList/package.json +++ b/packages/rpcs/wallet_refetchTxList/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.2.0", - "version": "0.0.4", + "version": "0.0.5", "dependencies": { "@fluent-wallet/confluxscan-api": "workspace:*", "@fluent-wallet/consts": "workspace:*", diff --git a/packages/rpcs/wallet_registerSiteMetadata/package.json b/packages/rpcs/wallet_registerSiteMetadata/package.json index deff873f3..efa14a0c3 100644 --- a/packages/rpcs/wallet_registerSiteMetadata/package.json +++ b/packages/rpcs/wallet_registerSiteMetadata/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_register-site-metadata", "type": "module", "main": "index.js", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_requestAccounts/package.json b/packages/rpcs/wallet_requestAccounts/package.json index fa97daf2f..7a4269db3 100644 --- a/packages/rpcs/wallet_requestAccounts/package.json +++ b/packages/rpcs/wallet_requestAccounts/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_requestPermissions/index.js b/packages/rpcs/wallet_requestPermissions/index.js index e228bf6fd..6763bf84f 100644 --- a/packages/rpcs/wallet_requestPermissions/index.js +++ b/packages/rpcs/wallet_requestPermissions/index.js @@ -49,16 +49,22 @@ export const permissions = { } const formatPermissions = perms => { - return perms.map(p => - Object.keys(p).reduce( + return perms.map(p => { + const crossNetwork = {} + const res = Object.keys(p).reduce( (p, key) => { + if (key.startsWith('cfx_')) + crossNetwork.wallet_crossNetworkTypeGetConfluxBase32Address = {} + if (key.startsWith('eth_')) + crossNetwork.wallet_crossNetworkTypeGetEthereumHexAddress = {} if (key === 'cfx_accounts' || key === 'eth_accounts') key = 'wallet_accounts' return {...p, [key]: {}} }, {wallet_basic: {}}, - ), - ) + ) + return {...res, ...crossNetwork} + }) } export const main = async ({ diff --git a/packages/rpcs/wallet_requestPermissions/package.json b/packages/rpcs/wallet_requestPermissions/package.json index 435f0698a..92de98dbf 100644 --- a/packages/rpcs/wallet_requestPermissions/package.json +++ b/packages/rpcs/wallet_requestPermissions/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_request-permissions", "type": "module", "main": "index.js", - "version": "3.0.0", + "version": "3.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6", "@fluent-wallet/wallet-permission": "workspace:packages/wallet-permission" diff --git a/packages/rpcs/wallet_requestUnlockUI/package.json b/packages/rpcs/wallet_requestUnlockUI/package.json index fa83736a8..8b9936a30 100644 --- a/packages/rpcs/wallet_requestUnlockUI/package.json +++ b/packages/rpcs/wallet_requestUnlockUI/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_request-unlock-ui", "type": "module", "main": "index.js", - "version": "0.0.14", + "version": "0.0.15", "dependencies": { "@fluent-wallet/csp": "workspace:packages/csp", "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/wallet_sendTransaction/package.json b/packages/rpcs/wallet_sendTransaction/package.json index 2165f21e2..95d9569dd 100644 --- a/packages/rpcs/wallet_sendTransaction/package.json +++ b/packages/rpcs/wallet_sendTransaction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "3.0.1", + "version": "3.0.6", "dependencies": { "@ethersproject/bignumber": "5.6.2", "@fluent-wallet/cfx_send-transaction": "workspace:*", diff --git a/packages/rpcs/wallet_sendTransactionWithAction/package.json b/packages/rpcs/wallet_sendTransactionWithAction/package.json index 927c632c2..4702180e7 100644 --- a/packages/rpcs/wallet_sendTransactionWithAction/package.json +++ b/packages/rpcs/wallet_sendTransactionWithAction/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.2.0", - "version": "1.0.1", + "version": "1.0.6", "dependencies": { "@fluent-wallet/spec": "1.0.6", "@fluent-wallet/wallet_send-transaction": "workspace:*" diff --git a/packages/rpcs/wallet_setAppCurrentAccount/package.json b/packages/rpcs/wallet_setAppCurrentAccount/package.json index d29786e65..a61980a4a 100644 --- a/packages/rpcs/wallet_setAppCurrentAccount/package.json +++ b/packages/rpcs/wallet_setAppCurrentAccount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_set-app-current-account", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_setAppCurrentNetwork/package.json b/packages/rpcs/wallet_setAppCurrentNetwork/package.json index e2cf946e5..cb4e22c2f 100644 --- a/packages/rpcs/wallet_setAppCurrentNetwork/package.json +++ b/packages/rpcs/wallet_setAppCurrentNetwork/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_set-app-current-network", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_setCurrentAccount/package.json b/packages/rpcs/wallet_setCurrentAccount/package.json index a09a3a5ee..14288b9e4 100644 --- a/packages/rpcs/wallet_setCurrentAccount/package.json +++ b/packages/rpcs/wallet_setCurrentAccount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_set-current-account", "type": "module", "main": "index.js", - "version": "0.0.10", + "version": "0.0.11", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_setCurrentNetwork/package.json b/packages/rpcs/wallet_setCurrentNetwork/package.json index 1de20c544..d0ae52907 100644 --- a/packages/rpcs/wallet_setCurrentNetwork/package.json +++ b/packages/rpcs/wallet_setCurrentNetwork/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_set-current-network", "type": "module", "main": "index.js", - "version": "0.0.15", + "version": "0.0.16", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_setPreferences/package.json b/packages/rpcs/wallet_setPreferences/package.json index 592f26721..3e8077b52 100644 --- a/packages/rpcs/wallet_setPreferences/package.json +++ b/packages/rpcs/wallet_setPreferences/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/checks": "workspace:*", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_switchConfluxChain/package.json b/packages/rpcs/wallet_switchConfluxChain/package.json index 58a0649cd..06d8523b1 100644 --- a/packages/rpcs/wallet_switchConfluxChain/package.json +++ b/packages/rpcs/wallet_switchConfluxChain/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_switch-conflux-chain", "type": "module", "main": "index.js", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@fluent-wallet/wallet_switch-ethereum-chain": "workspace:packages/rpcs/wallet_switchEthereumChain" } diff --git a/packages/rpcs/wallet_switchEthereumChain/package.json b/packages/rpcs/wallet_switchEthereumChain/package.json index 7d90145d9..39c3df95e 100644 --- a/packages/rpcs/wallet_switchEthereumChain/package.json +++ b/packages/rpcs/wallet_switchEthereumChain/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_switch-ethereum-chain", "type": "module", "main": "index.js", - "version": "1.0.2", + "version": "1.0.3", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_unlock/package.json b/packages/rpcs/wallet_unlock/package.json index 1c36437be..614b69021 100644 --- a/packages/rpcs/wallet_unlock/package.json +++ b/packages/rpcs/wallet_unlock/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_unlock", "type": "module", "main": "index.js", - "version": "0.0.18", + "version": "0.0.19", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_unwatchAsset/package.json b/packages/rpcs/wallet_unwatchAsset/package.json index 8c1b21be3..bfb205e7b 100644 --- a/packages/rpcs/wallet_unwatchAsset/package.json +++ b/packages/rpcs/wallet_unwatchAsset/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.5", + "version": "0.0.6", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_updateAccount/package.json b/packages/rpcs/wallet_updateAccount/package.json index fd7283060..be59f26d0 100644 --- a/packages/rpcs/wallet_updateAccount/package.json +++ b/packages/rpcs/wallet_updateAccount/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_update-account", "type": "module", "main": "index.js", - "version": "0.0.11", + "version": "0.0.12", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_updateAccountGroup/package.json b/packages/rpcs/wallet_updateAccountGroup/package.json index 51f5974ca..b420edbd8 100644 --- a/packages/rpcs/wallet_updateAccountGroup/package.json +++ b/packages/rpcs/wallet_updateAccountGroup/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_update-account-group", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/checks": "workspace:packages/checks", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_updateNetwork/package.json b/packages/rpcs/wallet_updateNetwork/package.json index a6cc40f55..d518869d3 100644 --- a/packages/rpcs/wallet_updateNetwork/package.json +++ b/packages/rpcs/wallet_updateNetwork/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.1.0", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6", "@fluent-wallet/wallet_add-network": "workspace:*" diff --git a/packages/rpcs/wallet_updateTokenList/package.json b/packages/rpcs/wallet_updateTokenList/package.json index bb4c98e2c..30cc7cbfe 100644 --- a/packages/rpcs/wallet_updateTokenList/package.json +++ b/packages/rpcs/wallet_updateTokenList/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.1", + "version": "1.0.2", "dependencies": { "@fluent-wallet/spec": "1.0.6", "@fluent-wallet/token-list-schema": "workspace:packages/token-list-schema" diff --git a/packages/rpcs/wallet_upsertMemo/package.json b/packages/rpcs/wallet_upsertMemo/package.json index b25c49acf..653f4ce5f 100644 --- a/packages/rpcs/wallet_upsertMemo/package.json +++ b/packages/rpcs/wallet_upsertMemo/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.2.0", - "version": "1.0.0", + "version": "1.0.1", "dependencies": { "@fluent-wallet/base32-address": "workspace:*", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_userApprovedAuthRequest/package.json b/packages/rpcs/wallet_userApprovedAuthRequest/package.json index 9d350c123..0cbd3ea48 100644 --- a/packages/rpcs/wallet_userApprovedAuthRequest/package.json +++ b/packages/rpcs/wallet_userApprovedAuthRequest/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_user-approved-auth-request", "type": "module", "main": "index.js", - "version": "0.0.9", + "version": "0.0.10", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_userRejectedAuthRequest/package.json b/packages/rpcs/wallet_userRejectedAuthRequest/package.json index cdb05f689..bd3a95f01 100644 --- a/packages/rpcs/wallet_userRejectedAuthRequest/package.json +++ b/packages/rpcs/wallet_userRejectedAuthRequest/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_user-rejected-auth-request", "type": "module", "main": "index.js", - "version": "0.0.10", + "version": "0.0.11", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_validate20Token/package.json b/packages/rpcs/wallet_validate20Token/package.json index 26575f173..d62ac06f7 100644 --- a/packages/rpcs/wallet_validate20Token/package.json +++ b/packages/rpcs/wallet_validate20Token/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "1.0.3", + "version": "1.0.4", "dependencies": { "@fluent-wallet/base32-address": "workspace:packages/base32-address", "@fluent-wallet/contract-abis": "workspace:packages/contract-abis", diff --git a/packages/rpcs/wallet_validateAppPermissions/package.json b/packages/rpcs/wallet_validateAppPermissions/package.json index f125e1a2a..2e4a7f2bc 100644 --- a/packages/rpcs/wallet_validateAppPermissions/package.json +++ b/packages/rpcs/wallet_validateAppPermissions/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_validate-app-permissions", "type": "module", "main": "index.js", - "version": "0.0.7", + "version": "0.0.8", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/rpcs/wallet_validateMnemonic/package.json b/packages/rpcs/wallet_validateMnemonic/package.json index ff6f7a1e4..64ab86821 100644 --- a/packages/rpcs/wallet_validateMnemonic/package.json +++ b/packages/rpcs/wallet_validateMnemonic/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_validate-mnemonic", "type": "module", "main": "index.js", - "version": "0.0.8", + "version": "0.0.9", "dependencies": { "@fluent-wallet/spec": "1.0.6", "bip39": "3.0.4" diff --git a/packages/rpcs/wallet_validatePassword/package.json b/packages/rpcs/wallet_validatePassword/package.json index e4271983a..8dd60634d 100644 --- a/packages/rpcs/wallet_validatePassword/package.json +++ b/packages/rpcs/wallet_validatePassword/package.json @@ -1,7 +1,7 @@ { "name": "@fluent-wallet/wallet_validate-password", "type": "module", - "version": "0.0.12", + "version": "0.0.13", "main": "index.js", "dependencies": { "@fluent-wallet/spec": "1.0.6", diff --git a/packages/rpcs/wallet_validatePrivateKey/package.json b/packages/rpcs/wallet_validatePrivateKey/package.json index 745e9c29d..5134954c3 100644 --- a/packages/rpcs/wallet_validatePrivateKey/package.json +++ b/packages/rpcs/wallet_validatePrivateKey/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_validate-private-key", "type": "module", "main": "index.js", - "version": "0.0.7", + "version": "0.0.9", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_watchAsset/package.json b/packages/rpcs/wallet_watchAsset/package.json index 39a5b99f5..41da7682f 100644 --- a/packages/rpcs/wallet_watchAsset/package.json +++ b/packages/rpcs/wallet_watchAsset/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/wallet_watch-asset", "type": "module", "main": "index.js", - "version": "1.0.1", + "version": "1.0.2", "packageManager": "yarn@3.0.1", "dependencies": { "@fluent-wallet/spec": "1.0.6" diff --git a/packages/rpcs/wallet_zeroAccountGroup/package.json b/packages/rpcs/wallet_zeroAccountGroup/package.json index 281674d0f..6a6caaa28 100644 --- a/packages/rpcs/wallet_zeroAccountGroup/package.json +++ b/packages/rpcs/wallet_zeroAccountGroup/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.10", + "version": "0.0.11", "dependencies": { "@fluent-wallet/spec": "1.0.6" } diff --git a/packages/signature/package.json b/packages/signature/package.json index d2611be75..378f1e79b 100644 --- a/packages/signature/package.json +++ b/packages/signature/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/signature", "type": "module", "main": "index.js", - "version": "0.0.16", + "version": "0.0.18", "dependencies": { "@ethersproject/bytes": "5.6.1", "@ethersproject/hash": "5.6.1", @@ -14,6 +14,6 @@ "@fluent-wallet/utils": "workspace:packages/utils", "cip-23": "0.2.0", "eth-sig-util": "3.0.1", - "js-conflux-sdk": "2.1.2" + "js-conflux-sdk": "2.4.10" } } diff --git a/packages/single-call-balance-tracker/package.json b/packages/single-call-balance-tracker/package.json index 018620d44..3b0491c2b 100644 --- a/packages/single-call-balance-tracker/package.json +++ b/packages/single-call-balance-tracker/package.json @@ -3,7 +3,7 @@ "type": "module", "main": "index.js", "packageManager": "yarn@3.0.1", - "version": "0.0.5", + "version": "0.0.6", "dependencies": { "@ethersproject/abi": "5.6.3", "@ethersproject/bytes": "5.6.1", diff --git a/packages/spec/package.json b/packages/spec/package.json index 0b3eb8cca..e30671099 100644 --- a/packages/spec/package.json +++ b/packages/spec/package.json @@ -1,7 +1,7 @@ { "name": "@fluent-wallet/spec", "type": "module", - "version": "1.0.4", + "version": "1.0.7", "main": "index.js", "scripts": { "build": "shadow-cljs release app" diff --git a/packages/test-helpers/package.json b/packages/test-helpers/package.json index 3f0ba7e57..973e287fd 100644 --- a/packages/test-helpers/package.json +++ b/packages/test-helpers/package.json @@ -1,14 +1,14 @@ { "name": "@fluent-wallet/test-helpers", "main": "index.js", - "version": "0.0.12", + "version": "0.0.13", "dependencies": { "@cfxjs/fullnode": "3.2.0", "ethers": "5.6.8", "js-conflux-sdk": "2.1.2" }, "devDependencies": { - "@xcfx/node": "0.0.7", + "@xcfx/node": "0.3.2", "hardhat": "2.22.10" } } diff --git a/packages/test-helpers/setupNetwork.js b/packages/test-helpers/setupNetwork.js index 05a85d407..7ced722d9 100644 --- a/packages/test-helpers/setupNetwork.js +++ b/packages/test-helpers/setupNetwork.js @@ -28,10 +28,10 @@ beforeAll(async () => { await deployETHBalanceChecker() confluxServer = await createServer({ // silent: false, - dev_block_interval_ms: 100, - mode: 'dev', - chain_id: CFX_LOCALNET_NETID, - genesis_secrets: [GENESIS_PRI_KEY], + devBlockIntervalMs: 100, + chainId: CFX_LOCALNET_NETID, + genesisSecrets: [GENESIS_PRI_KEY.replace(/^0x/, '')], + jsonrpcHttpPort: 12537, }) await confluxServer.start() await new Promise(resolve => setTimeout(resolve, 3000)) diff --git a/packages/tx-history-checker/package.json b/packages/tx-history-checker/package.json index 7f90e0894..522f65db2 100644 --- a/packages/tx-history-checker/package.json +++ b/packages/tx-history-checker/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/tx-history-checker", "type": "module", "main": "index.js", - "version": "0.0.2", + "version": "0.0.3", "dependencies": { "@fluent-wallet/base32-address": "workspace:*", "@fluent-wallet/consts": "workspace:packages/consts" diff --git a/packages/ui/shorten-address/package.json b/packages/ui/shorten-address/package.json index 829021c67..dc120db0b 100644 --- a/packages/ui/shorten-address/package.json +++ b/packages/ui/shorten-address/package.json @@ -2,7 +2,7 @@ "name": "@fluent-wallet/shorten-address", "type": "module", "main": "index.js", - "version": "0.1.3", + "version": "0.1.4", "dependencies": { "@fluent-wallet/account": "workspace:packages/account", "@fluent-wallet/base32-address": "workspace:packages/base32-address", diff --git a/packages/workspace-tools/package.json b/packages/workspace-tools/package.json index e9241ffbd..8c9a5c235 100644 --- a/packages/workspace-tools/package.json +++ b/packages/workspace-tools/package.json @@ -1,7 +1,7 @@ { "name": "workspace-tools", "type": "module", - "version": "0.0.7", + "version": "0.0.8", "private": true, "dependencies": { "@fluent-wallet/spec": "1.0.6" diff --git a/scripts/webpack.config.cjs b/scripts/webpack.config.cjs index 5b65b80a9..3e6739122 100644 --- a/scripts/webpack.config.cjs +++ b/scripts/webpack.config.cjs @@ -132,7 +132,9 @@ const defaultConfig = { 'process.env.SENTRY_DSN': JSON.stringify( process.env.SNOWPACK_PUBLIC_SENTRY_DSN || '', ), - 'process.env.PACKAGE_VERSION': JSON.stringify(packageJson.version), + 'process.env.VIEW_PACKAGE_VERSION': JSON.stringify( + process.env.VIEW_PACKAGE_VERSION, + ), }), // Plugin to not generate js bundle for manifest entry new HtmlWebpackPlugin({ diff --git a/yarn.lock b/yarn.lock index 8e90e80f4..e14c40a38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,6 +12,13 @@ __metadata: languageName: node linkType: hard +"@adraffy/ens-normalize@npm:^1.10.1": + version: 1.11.0 + resolution: "@adraffy/ens-normalize@npm:1.11.0" + checksum: 10/abef75f21470ea43dd6071168e092d2d13e38067e349e76186c78838ae174a46c3e18ca50921d05bea6ec3203074147c9e271f8cb6531d1c2c0e146f3199ddcb + languageName: node + linkType: hard + "@algolia/autocomplete-core@npm:1.9.3": version: 1.9.3 resolution: "@algolia/autocomplete-core@npm:1.9.3" @@ -3752,6 +3759,16 @@ __metadata: languageName: unknown linkType: soft +"@fluent-wallet/cfx_estimate-1559-fee@workspace:packages/rpcs/cfx_estimate1559Fee": + version: 0.0.0-use.local + resolution: "@fluent-wallet/cfx_estimate-1559-fee@workspace:packages/rpcs/cfx_estimate1559Fee" + dependencies: + "@ethersproject/units": "npm:5.6.1" + "@fluent-wallet/spec": "workspace:packages/spec" + bn.js: "npm:5.2.0" + languageName: unknown + linkType: soft + "@fluent-wallet/cfx_estimate-gas-and-collateral@workspace:packages/rpcs/cfx_estimateGasAndCollateral": version: 0.0.0-use.local resolution: "@fluent-wallet/cfx_estimate-gas-and-collateral@workspace:packages/rpcs/cfx_estimateGasAndCollateral" @@ -3760,6 +3777,14 @@ __metadata: languageName: unknown linkType: soft +"@fluent-wallet/cfx_fee-history@workspace:packages/rpcs/cfx_feeHistory": + version: 0.0.0-use.local + resolution: "@fluent-wallet/cfx_fee-history@workspace:packages/rpcs/cfx_feeHistory" + dependencies: + "@fluent-wallet/spec": "workspace:packages/spec" + languageName: unknown + linkType: soft + "@fluent-wallet/cfx_gas-price@workspace:packages/rpcs/cfx_gasPrice": version: 0.0.0-use.local resolution: "@fluent-wallet/cfx_gas-price@workspace:packages/rpcs/cfx_gasPrice" @@ -3906,6 +3931,14 @@ __metadata: languageName: unknown linkType: soft +"@fluent-wallet/cfx_get-fee-burnt@workspace:packages/rpcs/cfx_getFeeBurnt": + version: 0.0.0-use.local + resolution: "@fluent-wallet/cfx_get-fee-burnt@workspace:packages/rpcs/cfx_getFeeBurnt" + dependencies: + "@fluent-wallet/spec": "workspace:packages/spec" + languageName: unknown + linkType: soft + "@fluent-wallet/cfx_get-interest-rate@workspace:*, @fluent-wallet/cfx_get-interest-rate@workspace:packages/rpcs/cfx_getInterestRate": version: 0.0.0-use.local resolution: "@fluent-wallet/cfx_get-interest-rate@workspace:packages/rpcs/cfx_getInterestRate" @@ -4042,6 +4075,14 @@ __metadata: languageName: unknown linkType: soft +"@fluent-wallet/cfx_max-priority-fee-per-gas@workspace:packages/rpcs/cfx_maxPriorityFeePerGas": + version: 0.0.0-use.local + resolution: "@fluent-wallet/cfx_max-priority-fee-per-gas@workspace:packages/rpcs/cfx_maxPriorityFeePerGas" + dependencies: + "@fluent-wallet/spec": "workspace:packages/spec" + languageName: unknown + linkType: soft + "@fluent-wallet/cfx_net-version@workspace:packages/rpcs/cfx_netVersion": version: 0.0.0-use.local resolution: "@fluent-wallet/cfx_net-version@workspace:packages/rpcs/cfx_netVersion" @@ -4300,6 +4341,8 @@ __metadata: "@fluent-wallet/conflux-tx-error@workspace:*, @fluent-wallet/conflux-tx-error@workspace:packages/conflux-tx-error": version: 0.0.0-use.local resolution: "@fluent-wallet/conflux-tx-error@workspace:packages/conflux-tx-error" + dependencies: + "@fluent-wallet/json-rpc-error": "workspace:packages/json-rpc-error" languageName: unknown linkType: soft @@ -4709,6 +4752,8 @@ __metadata: "@fluent-wallet/ethereum-tx-error@workspace:*, @fluent-wallet/ethereum-tx-error@workspace:packages/ethereum-tx-error": version: 0.0.0-use.local resolution: "@fluent-wallet/ethereum-tx-error@workspace:packages/ethereum-tx-error" + dependencies: + "@fluent-wallet/json-rpc-error": "workspace:packages/json-rpc-error" languageName: unknown linkType: soft @@ -4741,18 +4786,13 @@ __metadata: languageName: unknown linkType: soft -"@fluent-wallet/hw-app-conflux@npm:0.0.8": - version: 0.0.8 - resolution: "@fluent-wallet/hw-app-conflux@npm:0.0.8" +"@fluent-wallet/hw-app-conflux@npm:0.1.1": + version: 0.1.1 + resolution: "@fluent-wallet/hw-app-conflux@npm:0.1.1" dependencies: - "@ledgerhq/cryptoassets": "npm:^6.18.0" - "@ledgerhq/errors": "npm:^6.10.0" - "@ledgerhq/hw-transport": "npm:^6.11.2" - "@ledgerhq/logs": "npm:^6.10.0" - axios: "npm:^0.24.0" + "@ledgerhq/hw-transport": "npm:^6.31.4" bip32-path: "npm:^0.4.2" - js-conflux-sdk: "npm:^2.0.7" - checksum: 10/9cbe5af1cd7cc935a7430805d13b6cc28b2e788e861bd7d1a72dc0cd05d3ec19923cab19223388690907f2ccc9da8dd0b73dc29b8f37f5024b36c4bd8a10ebba + checksum: 10/59ad9397b50cc45d9905e8332daae33554c81bd732346c7f513ffc470b8bb60c6af15a9c215f685af0f3c972af82e97fa53e931e497f412f21e9f110303f8d76 languageName: node linkType: hard @@ -4807,9 +4847,9 @@ __metadata: resolution: "@fluent-wallet/ledger@workspace:packages/ledger" dependencies: "@fluent-wallet/base32-address": "workspace:packages/base32-address" - "@fluent-wallet/hw-app-conflux": "npm:0.0.8" + "@fluent-wallet/hw-app-conflux": "npm:0.1.1" "@ledgerhq/hw-app-eth": "npm:6.24.1" - "@ledgerhq/hw-transport-webusb": "npm:6.29.2" + "@ledgerhq/hw-transport-webhid": "npm:6.29.4" languageName: unknown linkType: soft @@ -4934,7 +4974,7 @@ __metadata: "@fluent-wallet/utils": "workspace:packages/utils" cip-23: "npm:0.2.0" eth-sig-util: "npm:3.0.1" - js-conflux-sdk: "npm:2.1.2" + js-conflux-sdk: "npm:2.4.10" languageName: unknown linkType: soft @@ -4987,7 +5027,7 @@ __metadata: resolution: "@fluent-wallet/test-helpers@workspace:packages/test-helpers" dependencies: "@cfxjs/fullnode": "npm:3.2.0" - "@xcfx/node": "npm:0.0.7" + "@xcfx/node": "npm:0.3.2" ethers: "npm:5.6.8" hardhat: "npm:2.22.10" js-conflux-sdk: "npm:2.1.2" @@ -6294,7 +6334,7 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/cryptoassets@npm:^6.18.0, @ledgerhq/cryptoassets@npm:^6.24.1": +"@ledgerhq/cryptoassets@npm:^6.24.1": version: 6.37.0 resolution: "@ledgerhq/cryptoassets@npm:6.37.0" dependencies: @@ -6303,7 +6343,7 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/devices@npm:^8.4.2, @ledgerhq/devices@npm:^8.4.3": +"@ledgerhq/devices@npm:^8.4.3": version: 8.4.3 resolution: "@ledgerhq/devices@npm:8.4.3" dependencies: @@ -6315,13 +6355,32 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/errors@npm:^6.10.0, @ledgerhq/errors@npm:^6.18.0, @ledgerhq/errors@npm:^6.19.0": +"@ledgerhq/devices@npm:^8.4.4": + version: 8.4.4 + resolution: "@ledgerhq/devices@npm:8.4.4" + dependencies: + "@ledgerhq/errors": "npm:^6.19.1" + "@ledgerhq/logs": "npm:^6.12.0" + rxjs: "npm:^7.8.1" + semver: "npm:^7.3.5" + checksum: 10/57136fc45ae2fa42b3cf93eb7cc3542fd84010390b3d0a536d342c7e92f90e475d608b1774f17a547419edddd7df0d0b1b1dbd6d2c778009ebab0fc3ec313f67 + languageName: node + linkType: hard + +"@ledgerhq/errors@npm:^6.10.0, @ledgerhq/errors@npm:^6.19.0": version: 6.19.0 resolution: "@ledgerhq/errors@npm:6.19.0" checksum: 10/944d7a86f4dedd3cac611d704a36667ff66294403ab6e552b8c14ce742574a2b50fa71de89c28827fc442233af68b88ae2971e73cdb03ea98ec4e65239d76d88 languageName: node linkType: hard +"@ledgerhq/errors@npm:^6.19.1": + version: 6.19.1 + resolution: "@ledgerhq/errors@npm:6.19.1" + checksum: 10/8265c6d73c314a4aabbe060ec29e2feebb4e904fe811bf7a9c53cde08e713dcbceded9d927ebb2f0ffc47a7b16524379d4a7e9aa3d61945b8a832be7cd5cf69b + languageName: node + linkType: hard + "@ledgerhq/hw-app-eth@npm:6.24.1": version: 6.24.1 resolution: "@ledgerhq/hw-app-eth@npm:6.24.1" @@ -6338,19 +6397,19 @@ __metadata: languageName: node linkType: hard -"@ledgerhq/hw-transport-webusb@npm:6.29.2": - version: 6.29.2 - resolution: "@ledgerhq/hw-transport-webusb@npm:6.29.2" +"@ledgerhq/hw-transport-webhid@npm:6.29.4": + version: 6.29.4 + resolution: "@ledgerhq/hw-transport-webhid@npm:6.29.4" dependencies: - "@ledgerhq/devices": "npm:^8.4.2" - "@ledgerhq/errors": "npm:^6.18.0" - "@ledgerhq/hw-transport": "npm:^6.31.2" + "@ledgerhq/devices": "npm:^8.4.4" + "@ledgerhq/errors": "npm:^6.19.1" + "@ledgerhq/hw-transport": "npm:^6.31.4" "@ledgerhq/logs": "npm:^6.12.0" - checksum: 10/e6548cfa5618b8ae2430b3b6daa504e87b76ba6ec02476a30d1239d68f4347341c43d7673eb279ca114bdec0b9a8fe5541da464be1105cc9282e1d7fc333bf65 + checksum: 10/48d4a1e84c268682bf3fa59a2e55b0c771861f7c56a9961d3a7eeb38908cb54cdbfd6f9cb6ab9fa0e4e8c5f603894455c53ee85c186c6c9cb0d62453f2d94cce languageName: node linkType: hard -"@ledgerhq/hw-transport@npm:^6.11.2, @ledgerhq/hw-transport@npm:^6.24.1, @ledgerhq/hw-transport@npm:^6.31.2": +"@ledgerhq/hw-transport@npm:^6.24.1": version: 6.31.3 resolution: "@ledgerhq/hw-transport@npm:6.31.3" dependencies: @@ -6362,6 +6421,18 @@ __metadata: languageName: node linkType: hard +"@ledgerhq/hw-transport@npm:^6.31.4": + version: 6.31.4 + resolution: "@ledgerhq/hw-transport@npm:6.31.4" + dependencies: + "@ledgerhq/devices": "npm:^8.4.4" + "@ledgerhq/errors": "npm:^6.19.1" + "@ledgerhq/logs": "npm:^6.12.0" + events: "npm:^3.3.0" + checksum: 10/cf101e5b818e95e59031241d556dbec24658f54104910e414be493bc4b90b0aea50f5d4b3339a237dd0b12845bb2683c845f3a82f2ea9da4e077b68d1e1f7e48 + languageName: node + linkType: hard + "@ledgerhq/logs@npm:^6.10.0, @ledgerhq/logs@npm:^6.12.0": version: 6.12.0 resolution: "@ledgerhq/logs@npm:6.12.0" @@ -6499,6 +6570,24 @@ __metadata: languageName: node linkType: hard +"@noble/curves@npm:1.6.0, @noble/curves@npm:~1.6.0": + version: 1.6.0 + resolution: "@noble/curves@npm:1.6.0" + dependencies: + "@noble/hashes": "npm:1.5.0" + checksum: 10/9090b5a020b7e38c7b6d21506afaacd0c7557129d716a174334c1efc36385bf3ca6de16a543c216db58055e019c6a6c3bea8d9c0b79386e6bacff5c4c6b438a9 + languageName: node + linkType: hard + +"@noble/curves@npm:^1.4.0, @noble/curves@npm:^1.6.0, @noble/curves@npm:~1.7.0": + version: 1.7.0 + resolution: "@noble/curves@npm:1.7.0" + dependencies: + "@noble/hashes": "npm:1.6.0" + checksum: 10/2a11ef4895907d0b241bd3b72f9e6ebe56f0e705949bfd5efe003f25233549f620d287550df2d24ad56a1f953b82ec5f7cf4bd7cb78b1b2e76eb6dd516d44cf8 + languageName: node + linkType: hard + "@noble/hashes@npm:1.2.0, @noble/hashes@npm:~1.2.0": version: 1.2.0 resolution: "@noble/hashes@npm:1.2.0" @@ -6513,13 +6602,27 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.4.0": +"@noble/hashes@npm:1.5.0, @noble/hashes@npm:^1.2.0, @noble/hashes@npm:^1.4.0, @noble/hashes@npm:~1.5.0": version: 1.5.0 resolution: "@noble/hashes@npm:1.5.0" checksum: 10/da7fc7af52af7afcf59810a7eea6155075464ff462ffda2572dc6d57d53e2669b1ea2ec774e814f6273f1697e567f28d36823776c9bf7068cba2a2855140f26e languageName: node linkType: hard +"@noble/hashes@npm:1.6.0": + version: 1.6.0 + resolution: "@noble/hashes@npm:1.6.0" + checksum: 10/b44b043b02adbecd33596adeed97d9f9864c24a2410f7ac3b847986c2ecf1f6f0df76024b3f1b14d6ea954932960d88898fe551fb9d39844a8b870e9f9044ea1 + languageName: node + linkType: hard + +"@noble/hashes@npm:^1.5.0, @noble/hashes@npm:~1.6.0": + version: 1.6.1 + resolution: "@noble/hashes@npm:1.6.1" + checksum: 10/74d9ad7b1437a22ba3b877584add3367587fbf818113152f293025d20d425aa74c191d18d434797312f2270458bc9ab3241c34d14ec6115fb16438b3248f631f + languageName: node + linkType: hard + "@noble/secp256k1@npm:1.7.1, @noble/secp256k1@npm:~1.7.0": version: 1.7.1 resolution: "@noble/secp256k1@npm:1.7.1" @@ -7141,13 +7244,20 @@ __metadata: languageName: node linkType: hard -"@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.6": +"@scure/base@npm:~1.1.0, @scure/base@npm:~1.1.6, @scure/base@npm:~1.1.7, @scure/base@npm:~1.1.8": version: 1.1.9 resolution: "@scure/base@npm:1.1.9" checksum: 10/f0ab7f687bbcdee2a01377fe3cd808bf63977999672751295b6a92625d5322f4754a96d40f6bd579bc367aad48ecf8a4e6d0390e70296e6ded1076f52adb16bb languageName: node linkType: hard +"@scure/base@npm:~1.2.1": + version: 1.2.1 + resolution: "@scure/base@npm:1.2.1" + checksum: 10/f7bdd17618ccae7a74c8cbe410a235e4adbe54aa8afe4e2fb1294338aa92f6fd04b1f1f5dea60552f638b5f5e3e74902b7baf59d3954e5e42c0a36c6baa2ebe0 + languageName: node + linkType: hard + "@scure/bip32@npm:1.1.5": version: 1.1.5 resolution: "@scure/bip32@npm:1.1.5" @@ -7170,6 +7280,28 @@ __metadata: languageName: node linkType: hard +"@scure/bip32@npm:1.5.0": + version: 1.5.0 + resolution: "@scure/bip32@npm:1.5.0" + dependencies: + "@noble/curves": "npm:~1.6.0" + "@noble/hashes": "npm:~1.5.0" + "@scure/base": "npm:~1.1.7" + checksum: 10/17e296a782e09aec18ed27e2e8bb6a76072604c40997ec49a6840f223296421612dbe6b44275f04db9acd6da6cefb0322141110f5ac9dc686eb0c44d5bd868fa + languageName: node + linkType: hard + +"@scure/bip32@npm:^1.5.0": + version: 1.6.0 + resolution: "@scure/bip32@npm:1.6.0" + dependencies: + "@noble/curves": "npm:~1.7.0" + "@noble/hashes": "npm:~1.6.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/2efb81ed9a7b8d5d35233e10abebc114544a3783a2a32b9fb60e1e9a67965b272c9d17910e1649083b69c8ceb80241b05b59dbeb7a5b18ea34e497aed3f16709 + languageName: node + linkType: hard + "@scure/bip39@npm:1.1.1": version: 1.1.1 resolution: "@scure/bip39@npm:1.1.1" @@ -7190,6 +7322,26 @@ __metadata: languageName: node linkType: hard +"@scure/bip39@npm:1.4.0": + version: 1.4.0 + resolution: "@scure/bip39@npm:1.4.0" + dependencies: + "@noble/hashes": "npm:~1.5.0" + "@scure/base": "npm:~1.1.8" + checksum: 10/f86e0e79768c95bc684ed6de92892b1a6f228db0f8fab836f091c0ec0f6d1e291b8c4391cfbeaa9ea83f41045613535b1940cd10e7d780a5b73db163b1e7f151 + languageName: node + linkType: hard + +"@scure/bip39@npm:^1.4.0": + version: 1.5.0 + resolution: "@scure/bip39@npm:1.5.0" + dependencies: + "@noble/hashes": "npm:~1.6.0" + "@scure/base": "npm:~1.2.1" + checksum: 10/b795ee31ac4c10603bf3b726cc0e5cf43834a68f05a535e0baf2162772bac100de470b4c6cf7ddbecb95d7a3fb82b8a959badced406c329ab696cd89104194bc + languageName: node + linkType: hard + "@sentry/browser@npm:7.4.1": version: 7.4.1 resolution: "@sentry/browser@npm:7.4.1" @@ -9690,32 +9842,53 @@ __metadata: languageName: node linkType: hard -"@xcfx/node-darwin-arm64@npm:0.0.7": - version: 0.0.7 - resolution: "@xcfx/node-darwin-arm64@npm:0.0.7" +"@xcfx/node-darwin-arm64@npm:0.3.1": + version: 0.3.1 + resolution: "@xcfx/node-darwin-arm64@npm:0.3.1" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@xcfx/node-linux-x64@npm:0.0.7": - version: 0.0.7 - resolution: "@xcfx/node-linux-x64@npm:0.0.7" +"@xcfx/node-darwin-x64@npm:0.3.1": + version: 0.3.1 + resolution: "@xcfx/node-darwin-x64@npm:0.3.1" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@xcfx/node-linux-x64-gnu@npm:0.3.1": + version: 0.3.1 + resolution: "@xcfx/node-linux-x64-gnu@npm:0.3.1" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@xcfx/node@npm:0.0.7": - version: 0.0.7 - resolution: "@xcfx/node@npm:0.0.7" +"@xcfx/node-win32-x64-msvc@npm:0.3.1": + version: 0.3.1 + resolution: "@xcfx/node-win32-x64-msvc@npm:0.3.1" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + +"@xcfx/node@npm:0.3.2": + version: 0.3.2 + resolution: "@xcfx/node@npm:0.3.2" dependencies: - "@xcfx/node-darwin-arm64": "npm:0.0.7" - "@xcfx/node-linux-x64": "npm:0.0.7" + "@xcfx/node-darwin-arm64": "npm:0.3.1" + "@xcfx/node-darwin-x64": "npm:0.3.1" + "@xcfx/node-linux-x64-gnu": "npm:0.3.1" + "@xcfx/node-win32-x64-msvc": "npm:0.3.1" + cive: "npm:0.7.0" dependenciesMeta: "@xcfx/node-darwin-arm64": optional: true - "@xcfx/node-linux-x64": + "@xcfx/node-darwin-x64": + optional: true + "@xcfx/node-linux-x64-gnu": + optional: true + "@xcfx/node-win32-x64-msvc": optional: true - checksum: 10/3bf1d9f31db97ad0747fc6ac75a3d7ccf6979930b63eebf88d906f8d114e9771c7a0db947ca6c2ec7a87ffa6838005e385aebbff8ab869b19be9a705991cbfb0 + checksum: 10/69b63a5f481e7edcfc9cdca97b60eccf5487b72adafe4916a36cfb9a6b55cc7b0d0c759fbe851b7cdf39873ee1423d21eb5a065443b32142cc0e1e4c69ea42b9 languageName: node linkType: hard @@ -9859,6 +10032,21 @@ __metadata: languageName: node linkType: hard +"abitype@npm:1.0.6, abitype@npm:^1.0.6": + version: 1.0.6 + resolution: "abitype@npm:1.0.6" + peerDependencies: + typescript: ">=5.0.4" + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + checksum: 10/d04d58f90405c29a3c68353508502d7e870feb27418a6281ba9a13e6aaee42c26b2c5f08f648f058b8eaffac32927194b33f396d2451d18afeccfb654c7285c2 + languageName: node + linkType: hard + "abort-controller@npm:^3.0.0": version: 3.0.0 resolution: "abort-controller@npm:3.0.0" @@ -12150,6 +12338,20 @@ __metadata: languageName: node linkType: hard +"cive@npm:0.7.0": + version: 0.7.0 + resolution: "cive@npm:0.7.0" + dependencies: + "@noble/curves": "npm:^1.6.0" + "@noble/hashes": "npm:^1.5.0" + "@scure/bip32": "npm:^1.5.0" + "@scure/bip39": "npm:^1.4.0" + viem: "npm:^2.20.0" + zod: "npm:^3.23.8" + checksum: 10/7ba9752b9e3c7cea87ea3b064613a688bcdf9a750a4adf955a160587b3a20063e99fc87078c6aad81813cd511e7b48c941437960d728245ad74e58fecafb4920 + languageName: node + linkType: hard + "cjs-module-lexer@npm:^1.0.0, cjs-module-lexer@npm:^1.2.2": version: 1.4.1 resolution: "cjs-module-lexer@npm:1.4.1" @@ -16123,6 +16325,13 @@ __metadata: languageName: node linkType: hard +"eventemitter3@npm:5.0.1, eventemitter3@npm:^5.0.1": + version: 5.0.1 + resolution: "eventemitter3@npm:5.0.1" + checksum: 10/ac6423ec31124629c84c7077eed1e6987f6d66c31cf43c6fcbf6c87791d56317ce808d9ead483652436df171b526fc7220eccdc9f3225df334e81582c3cf7dd5 + languageName: node + linkType: hard + "eventemitter3@npm:^4.0.0, eventemitter3@npm:^4.0.4": version: 4.0.7 resolution: "eventemitter3@npm:4.0.7" @@ -16130,13 +16339,6 @@ __metadata: languageName: node linkType: hard -"eventemitter3@npm:^5.0.1": - version: 5.0.1 - resolution: "eventemitter3@npm:5.0.1" - checksum: 10/ac6423ec31124629c84c7077eed1e6987f6d66c31cf43c6fcbf6c87791d56317ce808d9ead483652436df171b526fc7220eccdc9f3225df334e81582c3cf7dd5 - languageName: node - linkType: hard - "events@npm:^3.0.0, events@npm:^3.2.0, events@npm:^3.3.0": version: 3.3.0 resolution: "events@npm:3.3.0" @@ -17913,7 +18115,9 @@ __metadata: "@fluent-wallet/cfx_check-balance-against-transaction": "workspace:packages/rpcs/cfx_checkBalanceAgainstTransaction" "@fluent-wallet/cfx_client-version": "workspace:packages/rpcs/cfx_clientVersion" "@fluent-wallet/cfx_epoch-number": "workspace:packages/rpcs/cfx_epochNumber" + "@fluent-wallet/cfx_estimate-1559-fee": "workspace:packages/rpcs/cfx_estimate1559Fee" "@fluent-wallet/cfx_estimate-gas-and-collateral": "workspace:packages/rpcs/cfx_estimateGasAndCollateral" + "@fluent-wallet/cfx_fee-history": "workspace:packages/rpcs/cfx_feeHistory" "@fluent-wallet/cfx_gas-price": "workspace:packages/rpcs/cfx_gasPrice" "@fluent-wallet/cfx_get-account": "workspace:packages/rpcs/cfx_getAccount" "@fluent-wallet/cfx_get-account-pending-info": "workspace:*" @@ -17930,6 +18134,7 @@ __metadata: "@fluent-wallet/cfx_get-code": "workspace:packages/rpcs/cfx_getCode" "@fluent-wallet/cfx_get-collateral-for-storage": "workspace:packages/rpcs/cfx_getCollateralForStorage" "@fluent-wallet/cfx_get-confirmation-risk-by-hash": "workspace:packages/rpcs/cfx_getConfirmationRiskByHash" + "@fluent-wallet/cfx_get-fee-burnt": "workspace:packages/rpcs/cfx_getFeeBurnt" "@fluent-wallet/cfx_get-interest-rate": "workspace:*" "@fluent-wallet/cfx_get-logs": "workspace:packages/rpcs/cfx_getLogs" "@fluent-wallet/cfx_get-max-gas-limit": "workspace:*" @@ -17946,6 +18151,7 @@ __metadata: "@fluent-wallet/cfx_get-transaction-by-hash": "workspace:packages/rpcs/cfx_getTransactionByHash" "@fluent-wallet/cfx_get-transaction-receipt": "workspace:packages/rpcs/cfx_getTransactionReceipt" "@fluent-wallet/cfx_get-vote-list": "workspace:packages/rpcs/cfx_getVoteList" + "@fluent-wallet/cfx_max-priority-fee-per-gas": "workspace:packages/rpcs/cfx_maxPriorityFeePerGas" "@fluent-wallet/cfx_net-version": "workspace:packages/rpcs/cfx_netVersion" "@fluent-wallet/cfx_opened-method-groups": "workspace:*" "@fluent-wallet/cfx_request-accounts": "workspace:packages/rpcs/cfx_requestAccounts" @@ -18088,6 +18294,7 @@ __metadata: "@fluent-wallet/extension-runtime": "workspace:packages/extension-runtime" "@fluent-wallet/provider-api": "workspace:packages/ui/provider-api" "@thi.ng/rstream": "npm:6.0.21" + uuid: "npm:^8.3.2" webextension-polyfill: "npm:0.8.0" languageName: unknown linkType: soft @@ -19678,6 +19885,15 @@ __metadata: languageName: node linkType: hard +"isows@npm:1.0.6": + version: 1.0.6 + resolution: "isows@npm:1.0.6" + peerDependencies: + ws: "*" + checksum: 10/ab9e85b50bcc3d70aa5ec875aa2746c5daf9321cb376ed4e5434d3c2643c5d62b1f466d93a05cd2ad0ead5297224922748c31707cb4fbd68f5d05d0479dce99c + languageName: node + linkType: hard + "isstream@npm:~0.1.2": version: 0.1.2 resolution: "isstream@npm:0.1.2" @@ -20328,27 +20544,6 @@ __metadata: languageName: node linkType: hard -"js-conflux-sdk@npm:2.0.7": - version: 2.0.7 - resolution: "js-conflux-sdk@npm:2.0.7" - dependencies: - "@conflux-dev/conflux-address-js": "npm:^1.3.10" - abi-util-lite: "npm:^0.1.0" - big.js: "npm:^5.2.2" - commander: "npm:^8.0.0" - keccak: "npm:^2.0.0" - lodash: "npm:^4.17.19" - rlp: "npm:^2.2.7" - scrypt-js: "npm:^3.0.1" - secp256k1: "npm:^3.7.1" - superagent: "npm:^6.1.0" - websocket: "npm:^1.0.31" - bin: - cfxjs: bin/cfxjs.js - checksum: 10/51af708525879bab6e4d6f4281d34e9dc3370ebd69e7ac339d0c95e09b42daf6d97106953e1b907b8ba325a5a5b26af10433ddc11abee99f6fc2ae583becef79 - languageName: node - linkType: hard - "js-conflux-sdk@npm:^2.1.9": version: 2.4.10 resolution: "js-conflux-sdk@npm:2.4.10" @@ -23528,6 +23723,26 @@ __metadata: languageName: node linkType: hard +"ox@npm:0.1.2": + version: 0.1.2 + resolution: "ox@npm:0.1.2" + dependencies: + "@adraffy/ens-normalize": "npm:^1.10.1" + "@noble/curves": "npm:^1.6.0" + "@noble/hashes": "npm:^1.5.0" + "@scure/bip32": "npm:^1.5.0" + "@scure/bip39": "npm:^1.4.0" + abitype: "npm:^1.0.6" + eventemitter3: "npm:5.0.1" + peerDependencies: + typescript: ">=5.4.0" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/cba00f13289599ff03cee3dbc19167c1d0f01829379d119f962b4e951ee2bf0d14491c7a45974e6a2a745117b13b22e9e4131d285e1f5247ea4e1cbc43c5c3d8 + languageName: node + linkType: hard + "p-cancelable@npm:^1.0.0": version: 1.1.0 resolution: "p-cancelable@npm:1.1.0" @@ -30207,6 +30422,28 @@ __metadata: languageName: node linkType: hard +"viem@npm:^2.20.0": + version: 2.21.50 + resolution: "viem@npm:2.21.50" + dependencies: + "@noble/curves": "npm:1.6.0" + "@noble/hashes": "npm:1.5.0" + "@scure/bip32": "npm:1.5.0" + "@scure/bip39": "npm:1.4.0" + abitype: "npm:1.0.6" + isows: "npm:1.0.6" + ox: "npm:0.1.2" + webauthn-p256: "npm:0.0.10" + ws: "npm:8.18.0" + peerDependencies: + typescript: ">=5.0.4" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/6525c7dfa679d48759d50a31751b1d608f055e4396506c4f48550b81655b75b53978bd2dbe39099ac200f549c7429261d3478810dbd63b36df6a0afd77f69931 + languageName: node + linkType: hard + "vite-node@npm:2.0.5": version: 2.0.5 resolution: "vite-node@npm:2.0.5" @@ -30651,6 +30888,16 @@ __metadata: languageName: node linkType: hard +"webauthn-p256@npm:0.0.10": + version: 0.0.10 + resolution: "webauthn-p256@npm:0.0.10" + dependencies: + "@noble/curves": "npm:^1.4.0" + "@noble/hashes": "npm:^1.4.0" + checksum: 10/dde2b6313b6a0f20996f7ee90181258fc7685bfff401df7d904578da75b374f25d5b9c1189cd2fcec30625b1f276b393188d156d49783f0611623cd713bb5b09 + languageName: node + linkType: hard + "webextension-polyfill@npm:0.8.0": version: 0.8.0 resolution: "webextension-polyfill@npm:0.8.0" @@ -30932,7 +31179,7 @@ __metadata: languageName: node linkType: hard -"websocket@npm:^1.0.31, websocket@npm:^1.0.32, websocket@npm:^1.0.35": +"websocket@npm:^1.0.32, websocket@npm:^1.0.35": version: 1.0.35 resolution: "websocket@npm:1.0.35" dependencies: @@ -31269,24 +31516,24 @@ __metadata: languageName: node linkType: hard -"ws@npm:8.7.0": - version: 8.7.0 - resolution: "ws@npm:8.7.0" +"ws@npm:8.18.0, ws@npm:^8.11.0, ws@npm:^8.13.0": + version: 8.18.0 + resolution: "ws@npm:8.18.0" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 + utf-8-validate: ">=5.0.2" peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 10/ec85bd9c1fb304d34fa6ca319726859f8209094618ec09b1f6ad4f274d1c5561bf633319c0166551e3ca6d8ae2cf860e73262782c32afadc52539a3e5cb00346 + checksum: 10/70dfe53f23ff4368d46e4c0b1d4ca734db2c4149c6f68bc62cb16fc21f753c47b35fcc6e582f3bdfba0eaeb1c488cddab3c2255755a5c3eecb251431e42b3ff6 languageName: node linkType: hard -"ws@npm:^7.3.0, ws@npm:^7.3.1, ws@npm:^7.4.5, ws@npm:^7.4.6": - version: 7.5.10 - resolution: "ws@npm:7.5.10" +"ws@npm:8.7.0": + version: 8.7.0 + resolution: "ws@npm:8.7.0" peerDependencies: bufferutil: ^4.0.1 utf-8-validate: ^5.0.2 @@ -31295,22 +31542,22 @@ __metadata: optional: true utf-8-validate: optional: true - checksum: 10/9c796b84ba80ffc2c2adcdfc9c8e9a219ba99caa435c9a8d45f9ac593bba325563b3f83edc5eb067cc6d21b9a6bf2c930adf76dd40af5f58a5ca6859e81858f0 + checksum: 10/ec85bd9c1fb304d34fa6ca319726859f8209094618ec09b1f6ad4f274d1c5561bf633319c0166551e3ca6d8ae2cf860e73262782c32afadc52539a3e5cb00346 languageName: node linkType: hard -"ws@npm:^8.11.0, ws@npm:^8.13.0": - version: 8.18.0 - resolution: "ws@npm:8.18.0" +"ws@npm:^7.3.0, ws@npm:^7.3.1, ws@npm:^7.4.5, ws@npm:^7.4.6": + version: 7.5.10 + resolution: "ws@npm:7.5.10" peerDependencies: bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" + utf-8-validate: ^5.0.2 peerDependenciesMeta: bufferutil: optional: true utf-8-validate: optional: true - checksum: 10/70dfe53f23ff4368d46e4c0b1d4ca734db2c4149c6f68bc62cb16fc21f753c47b35fcc6e582f3bdfba0eaeb1c488cddab3c2255755a5c3eecb251431e42b3ff6 + checksum: 10/9c796b84ba80ffc2c2adcdfc9c8e9a219ba99caa435c9a8d45f9ac593bba325563b3f83edc5eb067cc6d21b9a6bf2c930adf76dd40af5f58a5ca6859e81858f0 languageName: node linkType: hard @@ -31546,7 +31793,7 @@ __metadata: languageName: node linkType: hard -"zod@npm:^3.17.3": +"zod@npm:^3.17.3, zod@npm:^3.23.8": version: 3.23.8 resolution: "zod@npm:3.23.8" checksum: 10/846fd73e1af0def79c19d510ea9e4a795544a67d5b34b7e1c4d0425bf6bfd1c719446d94cdfa1721c1987d891321d61f779e8236fde517dc0e524aa851a6eff1