From acd3f2eff58e452f6c99ce588d0384fde64c4aba Mon Sep 17 00:00:00 2001 From: DMY <147dmy@gmail.com> Date: Tue, 3 Dec 2024 14:40:30 +0800 Subject: [PATCH 1/5] fix: net version (#2651) * fix: net version * fix: net version compatibility --- src/background/controller/provider/controller.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/background/controller/provider/controller.ts b/src/background/controller/provider/controller.ts index 6f6cfa2bd07..37127b66b0f 100644 --- a/src/background/controller/provider/controller.ts +++ b/src/background/controller/provider/controller.ts @@ -44,6 +44,7 @@ import { KEYRING_CATEGORY_MAP, EVENTS, INTERNAL_REQUEST_SESSION, + INTERNAL_REQUEST_ORIGIN, } from 'consts'; import buildinProvider from 'background/utils/buildinProvider'; import BaseController from '../base'; @@ -165,9 +166,11 @@ class ProviderController extends BaseController { ethRpc = (req, forceChainServerId?: string) => { const { data: { method, params }, - session: { origin }, + session: { origin: _origin }, } = req; + let origin = _origin; + if ( !permissionService.hasPermission(origin) && !SAFE_RPC_METHODS.includes(method) @@ -176,6 +179,14 @@ class ProviderController extends BaseController { } const site = permissionService.getSite(origin); + + if (method === 'net_version') { + if (!site?.isConnected) { + return Promise.resolve('1'); + } + origin = INTERNAL_REQUEST_ORIGIN; + } + let chainServerId = CHAINS[CHAINS_ENUM.ETH].serverId; if (site) { chainServerId = From 04837019bf23b2e0c05a2ab9ceb37a2ff45808c1 Mon Sep 17 00:00:00 2001 From: heisenberg <110591045+heisenberg-2077@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:09:24 +0800 Subject: [PATCH 2/5] chore: update eth-walletconnect-keyring (#2652) --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 85e743c0c28..4626ae6816f 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@rabby-wallet/eth-lattice-keyring": "1.2.1", "@rabby-wallet/eth-simple-keyring": "5.0.1", "@rabby-wallet/eth-trezor-keyring": "2.6.1", - "@rabby-wallet/eth-walletconnect-keyring": "2.1.3", + "@rabby-wallet/eth-walletconnect-keyring": "2.1.5", "@rabby-wallet/eth-watch-keyring": "1.0.0", "@rabby-wallet/gnosis-sdk": "1.3.9", "@rabby-wallet/page-provider": "0.4.2", diff --git a/yarn.lock b/yarn.lock index 4b61b22bdea..c176e983e2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4687,10 +4687,10 @@ ethereumjs-util "^7.1.5" hdkey "0.8.0" -"@rabby-wallet/eth-walletconnect-keyring@2.1.3": - version "2.1.3" - resolved "https://registry.yarnpkg.com/@rabby-wallet/eth-walletconnect-keyring/-/eth-walletconnect-keyring-2.1.3.tgz#8ea63178e2fa4c9369ba2ea1df6940d016d32c2a" - integrity sha512-Yvx1uCC/E8Zv53vx0ZjHpXL+udZLgLfnER37O04i6pN2aRFmh9SFPh9nnNn7+Nh/i/Q2gz4UziCu6AjIdq5I1w== +"@rabby-wallet/eth-walletconnect-keyring@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@rabby-wallet/eth-walletconnect-keyring/-/eth-walletconnect-keyring-2.1.5.tgz#f8a3e6c8c20bc0106583ac501c29fef19c4f2d3d" + integrity sha512-eYvr46YOnuzApgjssdyk7HzG3YXBFBit9eju9QIvE+WmZ0e1oov3/uqqQVNhCVu3WqpSBQ70bma/2tjiFPae9A== dependencies: "@ethereumjs/tx" "^3.5.2" "@rabby-wallet/wc-client" "^1.8.10" From 8b12083351cdb8d918d2857040fb33fe3d37510d Mon Sep 17 00:00:00 2001 From: DMY <147dmy@gmail.com> Date: Tue, 3 Dec 2024 15:33:16 +0800 Subject: [PATCH 3/5] feat: add uninstalled feedback (#2648) * feat: add uninstalled feedback * typo * chore: use production url * fix --- _raw/locales/en/messages.json | 2 +- src/background/controller/wallet.ts | 5 + src/background/index.ts | 4 + src/background/service/index.ts | 1 + src/background/service/keyring/index.ts | 5 + src/background/service/transactionHistory.ts | 3 + src/background/service/uninstalled.ts | 120 +++++++++++++++++++ src/ui/views/NewUserImport/Success.tsx | 7 +- 8 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 src/background/service/uninstalled.ts diff --git a/_raw/locales/en/messages.json b/_raw/locales/en/messages.json index 264e19dd92d..4b8c59a5cde 100644 --- a/_raw/locales/en/messages.json +++ b/_raw/locales/en/messages.json @@ -2323,7 +2323,7 @@ "title": "Welcome to Rabby Wallet", "desc": "The game-changing wallet for Ethereum and all EVM chains", "createNewAddress": "Create a new address", - "importAddress": "I already have a address" + "importAddress": "I already have an address" }, "createNewAddress": { "title": "Create New Seed Phrase", diff --git a/src/background/controller/wallet.ts b/src/background/controller/wallet.ts index ee792908e2d..e36c5ea2885 100644 --- a/src/background/controller/wallet.ts +++ b/src/background/controller/wallet.ts @@ -25,6 +25,7 @@ import { HDKeyRingLastAddAddrTimeService, bridgeService, gasAccountService, + uninstalledService, } from 'background/service'; import buildinProvider, { EthereumProvider, @@ -1492,6 +1493,8 @@ export class WalletController extends BaseController { } else { setPopupIcon(isDefaultWallet ? 'rabby' : 'metamask'); } + + uninstalledService.syncStatus(); }; isUnlocked = () => keyringService.isUnlocked(); @@ -4906,6 +4909,8 @@ export class WalletController extends BaseController { await userGuideService.activeUserGuide(); return true; }; + + uninstalledSyncStatus = uninstalledService.syncStatus; } const wallet = new WalletController(); diff --git a/src/background/index.ts b/src/background/index.ts index 3ce6a9d9c7a..7369c1fba60 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -34,6 +34,7 @@ import { HDKeyRingLastAddAddrTimeService, bridgeService, gasAccountService, + uninstalledService, } from './service'; import { providerController, walletController } from './controller'; import { getOriginFromUrl } from '@/utils'; @@ -105,6 +106,7 @@ async function restoreAppState() { await HDKeyRingLastAddAddrTimeService.init(); await bridgeService.init(); await gasAccountService.init(); + await uninstalledService.init(); await walletController.tryUnlock(); @@ -145,6 +147,8 @@ async function restoreAppState() { }); } }); + + uninstalledService.setUninstalled(); } restoreAppState(); diff --git a/src/background/service/index.ts b/src/background/service/index.ts index 42522933728..fa3c24a9a90 100644 --- a/src/background/service/index.ts +++ b/src/background/service/index.ts @@ -21,3 +21,4 @@ export { default as RabbyPointsService } from './rabbyPoints'; export { default as HDKeyRingLastAddAddrTimeService } from './HDKeyRingLastAddAddrTime'; export { default as bridgeService } from './bridge'; export { default as gasAccountService } from './gasAccount'; +export { default as uninstalledService } from './uninstalled'; diff --git a/src/background/service/keyring/index.ts b/src/background/service/keyring/index.ts index 7fdade1f85d..b46674ebcef 100644 --- a/src/background/service/keyring/index.ts +++ b/src/background/service/keyring/index.ts @@ -45,6 +45,7 @@ import { passwordDecrypt, passwordClearKey, } from 'background/utils/password'; +import uninstalledMetricService from '../uninstalled'; export const KEYRING_SDK_TYPES = { SimpleKeyring, @@ -175,6 +176,9 @@ export class KeyringService extends EventEmitter { name: alias, }); } + uninstalledMetricService.setWalletByKeyringType( + KEYRING_TYPE.SimpleKeyring + ); return this.persistAllKeyrings.bind(this); }) .then(this.setUnlocked.bind(this)) @@ -483,6 +487,7 @@ export class KeyringService extends EventEmitter { return selectedKeyring .addAccounts(1) .then(() => { + uninstalledMetricService.setWalletByKeyringType(selectedKeyring.type); if (selectedKeyring.getAccountsWithBrand) { return selectedKeyring.getAccountsWithBrand(); } else { diff --git a/src/background/service/transactionHistory.ts b/src/background/service/transactionHistory.ts index 97eb79fd347..c8a99433c1c 100644 --- a/src/background/service/transactionHistory.ts +++ b/src/background/service/transactionHistory.ts @@ -23,6 +23,7 @@ import { ActionRequireData, ParsedTransactionActionData, } from '@rabby-wallet/rabby-action'; +import { uninstalledService } from '.'; export interface TransactionHistoryItem { rawTx: Tx; @@ -91,6 +92,8 @@ class TxHistory { private _txHistoryLimit = 100; addSigningTx(tx: Tx) { + uninstalledService.setTx(); + const id = nanoid(); this._signingTxList.push({ diff --git a/src/background/service/uninstalled.ts b/src/background/service/uninstalled.ts new file mode 100644 index 00000000000..7baa22deef3 --- /dev/null +++ b/src/background/service/uninstalled.ts @@ -0,0 +1,120 @@ +import { createPersistStore } from 'background/utils'; +import { keyringService, transactionHistoryService } from '.'; +import { KEYRING_CLASS } from '@/constant'; +import browser from 'webextension-polyfill'; + +export type UninstalledStore = { + imported: boolean; + tx?: boolean; + wallet?: boolean; + local?: boolean; +}; + +class Uninstalled { + store: UninstalledStore = { + imported: false, + tx: false, + wallet: false, + local: false, + }; + + init = async () => { + const storage = await createPersistStore({ + name: 'UninstalledMetric', + template: { + imported: false, + tx: false, + wallet: false, + local: false, + }, + }); + + this.store = storage || this.store; + }; + + syncStatus = async () => { + if ( + !this.store.tx && + transactionHistoryService.store.transactions && + Object.keys(transactionHistoryService.store.transactions).length + ) { + this.setTx(); + this.setImported(); + } + + if (this.store.wallet) { + return; + } + + const typedAccounts = await keyringService.getAllTypedAccounts(); + if (typedAccounts.length) { + typedAccounts.forEach((account) => { + this.setWalletByKeyringType(account.type); + }); + } + }; + + setImported = () => { + this.store.imported = true; + this.setUninstalled(); + }; + + setWallet = () => { + this.store.wallet = true; + this.setUninstalled(); + }; + + setTx = () => { + this.store.tx = true; + this.setUninstalled(); + }; + + setLocal = () => { + this.store.local = true; + this.setUninstalled(); + }; + + setWalletByKeyringType = (keyringType: string) => { + if (this.store.imported && this.store.wallet && this.store.local) { + return; + } + this.setImported(); + let isLocal = false; + let isHardware = false; + isLocal = ([ + KEYRING_CLASS.PRIVATE_KEY, + KEYRING_CLASS.MNEMONIC, + ] as string[]).includes(keyringType); + isHardware = ([ + ...Object.values(KEYRING_CLASS.HARDWARE), + ] as string[]).includes(keyringType); + if (isLocal) { + this.setLocal(); + } + if (isLocal || isHardware) { + this.setWallet(); + } + }; + + setUninstalled = () => { + let search = ''; + if (this.store.imported) { + search = 'i'; + } + if (this.store.wallet) { + search += 'w'; + } + + if (this.store.tx) { + search += 't'; + } + if (this.store.local) { + search += 'l'; + } + browser.runtime.setUninstallURL( + `https://rabby.io/uninstalled?r=${encodeURIComponent(search)}` + ); + }; +} + +export default new Uninstalled(); diff --git a/src/ui/views/NewUserImport/Success.tsx b/src/ui/views/NewUserImport/Success.tsx index 1ee5c8e3fc0..72331ecd505 100644 --- a/src/ui/views/NewUserImport/Success.tsx +++ b/src/ui/views/NewUserImport/Success.tsx @@ -34,6 +34,8 @@ const AccountItem = ({ account }: { account: Account }) => { const [defaultName, setDefaultName] = useState(name || ''); + const wallet = useWallet(); + const updateRef = useRef(null); const update = React.useCallback(() => { @@ -42,7 +44,6 @@ const AccountItem = ({ account }: { account: Account }) => { }, [updateAlias, localName, defaultName]); useClickAway(updateRef, () => { - console.log('edit', edit); if (edit) { update(); } @@ -54,6 +55,10 @@ const AccountItem = ({ account }: { account: Account }) => { } }, [edit]); + useEffect(() => { + wallet.uninstalledSyncStatus(); + }, []); + if (!account) { return null; } From 2e7e0b6a2a3af331957606d621a296a188b407b4 Mon Sep 17 00:00:00 2001 From: vvvvvv1vvvvvv Date: Tue, 3 Dec 2024 16:21:18 +0800 Subject: [PATCH 4/5] 0.93.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4626ae6816f..7d36254b310 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rabby", - "version": "0.93.1", + "version": "0.93.2", "description": "A browser plugin for DeFi users", "scripts": { "clean": "mkdir -p dist && rm -rf dist/*", From 90eb11f55f5db364de1302a73a2bb015d94f2064 Mon Sep 17 00:00:00 2001 From: vvvvvv1vvvvvv Date: Tue, 3 Dec 2024 16:21:18 +0800 Subject: [PATCH 5/5] [release] 0.93.2 --- src/manifest/mv2/manifest.json | 2 +- src/manifest/mv3/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/manifest/mv2/manifest.json b/src/manifest/mv2/manifest.json index a9414e001ba..2a6916e30b4 100644 --- a/src/manifest/mv2/manifest.json +++ b/src/manifest/mv2/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_appName__", "short_name": "__MSG_appName__", - "version": "0.93.1", + "version": "0.93.2", "default_locale": "en", "description": "__MSG_appDescription__", "icons": { diff --git a/src/manifest/mv3/manifest.json b/src/manifest/mv3/manifest.json index 284ece96d57..196938a82f5 100644 --- a/src/manifest/mv3/manifest.json +++ b/src/manifest/mv3/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "__MSG_appName__", "short_name": "__MSG_appName__", - "version": "0.93.1", + "version": "0.93.2", "default_locale": "en", "description": "__MSG_appDescription__", "icons": {