From d5c8a62fdb1d61ab7b6dfc05c9aba0087fc5c1af Mon Sep 17 00:00:00 2001 From: Alexander Khramov Date: Thu, 23 Nov 2023 01:11:11 +0300 Subject: [PATCH 1/2] fix: add custom connectors for injected wallets --- .../WalletsModalForEth/WalletsModalForEth.tsx | 4 ++- packages/wallets/bitkeep/src/index.ts | 23 ++++++++++------ packages/wallets/brave/src/index.ts | 25 ++++++++++------- packages/wallets/coin98/src/index.ts | 25 ++++++++++------- packages/wallets/exodus/src/index.ts | 27 ++++++++++++------- packages/wallets/okx/src/index.ts | 25 ++++++++++------- 6 files changed, 83 insertions(+), 46 deletions(-) diff --git a/packages/connect-wallet-modal/src/components/WalletsModalForEth/WalletsModalForEth.tsx b/packages/connect-wallet-modal/src/components/WalletsModalForEth/WalletsModalForEth.tsx index 744e504e..03a60c0a 100644 --- a/packages/connect-wallet-modal/src/components/WalletsModalForEth/WalletsModalForEth.tsx +++ b/packages/connect-wallet-modal/src/components/WalletsModalForEth/WalletsModalForEth.tsx @@ -17,6 +17,7 @@ import { WalletsModalForEthProps } from './types'; import { WALLET_IDS, WalletId } from '../../constants'; const walletsButtons: { [K in WalletId | string]: React.ComponentType } = { + default: ConnectInjected, injected: ConnectInjected, walletConnect: ConnectWC, [WALLET_IDS.METAMASK]: ConnectMetamask, @@ -32,7 +33,8 @@ function getWalletButton( reactKey: string, props: ButtonsCommonProps, ) { - return React.createElement(walletsButtons[walletId], { + const component = walletsButtons[walletId] ?? walletsButtons.default; + return React.createElement(component, { key: reactKey, ...props, }); diff --git a/packages/wallets/bitkeep/src/index.ts b/packages/wallets/bitkeep/src/index.ts index 8a981edb..b40173ab 100644 --- a/packages/wallets/bitkeep/src/index.ts +++ b/packages/wallets/bitkeep/src/index.ts @@ -1,5 +1,5 @@ import { WalletAdapterType } from '@reef-knot/types'; -import { Ethereum as EthereumTypeWagmi } from '@wagmi/core'; +import { Ethereum as EthereumTypeWagmi, Chain } from '@wagmi/core'; import { InjectedConnector } from 'wagmi/connectors/injected'; import WalletIcon from './icons/bitget.svg'; @@ -11,6 +11,19 @@ declare global { } } +export class BitgetConnector extends InjectedConnector { + readonly id = 'bitget'; + readonly name = 'Bitget'; + constructor(chains: Chain[]) { + super({ + chains, + options: { + getProvider: () => globalThis.window?.bitkeep?.ethereum, + }, + }); + } +} + export const Bitget: WalletAdapterType = ({ chains }) => ({ walletName: 'Bitget', // The current metrics implementation is based on walletId, @@ -21,13 +34,7 @@ export const Bitget: WalletAdapterType = ({ chains }) => ({ downloadURLs: { default: 'https://web3.bitget.com/', }, - connector: new InjectedConnector({ - chains, - options: { - name: 'Bitget', - getProvider: () => globalThis.window?.bitkeep?.ethereum, - }, - }), + connector: new BitgetConnector(chains), }); // BitKeep is the previous name of the wallet. diff --git a/packages/wallets/brave/src/index.ts b/packages/wallets/brave/src/index.ts index c502d455..7174c32f 100644 --- a/packages/wallets/brave/src/index.ts +++ b/packages/wallets/brave/src/index.ts @@ -1,5 +1,5 @@ import { WalletAdapterType } from '@reef-knot/types'; -import { Ethereum as EthereumTypeWagmi } from '@wagmi/core'; +import { Ethereum as EthereumTypeWagmi, Chain } from '@wagmi/core'; import { InjectedConnector } from 'wagmi/connectors/injected'; import { WalletIcon } from './icons/index.js'; @@ -9,6 +9,20 @@ declare global { } } +export class BraveConnector extends InjectedConnector { + readonly id = 'brave'; + readonly name = 'Brave'; + constructor(chains: Chain[]) { + super({ + chains, + options: { + getProvider: () => + globalThis.window?.braveEthereum || globalThis.window?.ethereum, + }, + }); + } +} + export const Brave: WalletAdapterType = ({ chains }) => ({ walletName: 'Brave', walletId: 'brave', @@ -19,12 +33,5 @@ export const Brave: WalletAdapterType = ({ chains }) => ({ downloadURLs: { default: 'https://brave.com/wallet/', }, - connector: new InjectedConnector({ - chains, - options: { - name: 'Brave', - getProvider: () => - globalThis.window?.braveEthereum || globalThis.window?.ethereum, - }, - }), + connector: new BraveConnector(chains), }); diff --git a/packages/wallets/coin98/src/index.ts b/packages/wallets/coin98/src/index.ts index 9ca3622c..b09d3d32 100644 --- a/packages/wallets/coin98/src/index.ts +++ b/packages/wallets/coin98/src/index.ts @@ -1,5 +1,5 @@ import { WalletAdapterType } from '@reef-knot/types'; -import { Ethereum as EthereumTypeWagmi } from '@wagmi/core'; +import { Ethereum as EthereumTypeWagmi, Chain } from '@wagmi/core'; import { InjectedConnector } from 'wagmi/connectors/injected'; import WalletIcon from './icons/coin98.svg'; @@ -17,6 +17,20 @@ declare global { } } +export class Coin98Connector extends InjectedConnector { + readonly id = 'coin98'; + readonly name = 'Coin98'; + constructor(chains: Chain[]) { + super({ + chains, + options: { + getProvider: () => + globalThis.window?.coin98?.provider || globalThis.window?.ethereum, + }, + }); + } +} + export const Coin98: WalletAdapterType = ({ chains }) => ({ walletName: 'Coin98', walletId: 'coin98', @@ -29,12 +43,5 @@ export const Coin98: WalletAdapterType = ({ chains }) => ({ ios: 'https://ios.coin98.com', android: 'https://android.coin98.com', }, - connector: new InjectedConnector({ - chains, - options: { - name: 'Coin98', - getProvider: () => - globalThis.window?.coin98?.provider || globalThis.window?.ethereum, - }, - }), + connector: new Coin98Connector(chains), }); diff --git a/packages/wallets/exodus/src/index.ts b/packages/wallets/exodus/src/index.ts index ec587806..7b06ae6e 100644 --- a/packages/wallets/exodus/src/index.ts +++ b/packages/wallets/exodus/src/index.ts @@ -1,7 +1,7 @@ import { WalletAdapterType } from '@reef-knot/types'; -import { Ethereum as EthereumTypeWagmi } from '@wagmi/core'; -import { InjectedConnector } from 'wagmi/connectors/injected'; import WalletIcon from './icons/exodus.svg'; +import { Ethereum as EthereumTypeWagmi, Chain } from '@wagmi/core'; +import { InjectedConnector } from '@wagmi/connectors/injected'; declare global { interface Ethereum extends EthereumTypeWagmi { @@ -12,6 +12,20 @@ declare global { } } +export class ExodusConnector extends InjectedConnector { + readonly id = 'exodus'; + readonly name = 'Exodus'; + constructor(chains: Chain[]) { + super({ + chains, + options: { + getProvider: () => + globalThis.window?.exodus?.ethereum || globalThis.window?.ethereum, + }, + }); + } +} + export const Exodus: WalletAdapterType = ({ chains }) => ({ walletName: 'Exodus', walletId: 'exodus', @@ -21,12 +35,5 @@ export const Exodus: WalletAdapterType = ({ chains }) => ({ downloadURLs: { default: 'https://www.exodus.com/download/', }, - connector: new InjectedConnector({ - chains, - options: { - name: 'Exodus', - getProvider: () => - globalThis.window?.exodus?.ethereum || globalThis.window?.ethereum, - }, - }), + connector: new ExodusConnector(chains), }); diff --git a/packages/wallets/okx/src/index.ts b/packages/wallets/okx/src/index.ts index e8e89fd7..9cd107a6 100644 --- a/packages/wallets/okx/src/index.ts +++ b/packages/wallets/okx/src/index.ts @@ -1,5 +1,5 @@ import { WalletAdapterType } from '@reef-knot/types'; -import { Ethereum as EthereumTypeWagmi } from '@wagmi/core'; +import { Ethereum as EthereumTypeWagmi, Chain } from '@wagmi/core'; import { InjectedConnector } from 'wagmi/connectors/injected'; import WalletIcon from './icons/okx.svg'; import WalletIconInverted from './icons/okx-inverted.svg'; @@ -16,6 +16,20 @@ declare global { } } +export class OkxConnector extends InjectedConnector { + readonly id = 'okx'; + readonly name = 'OKX Wallet'; + constructor(chains: Chain[]) { + super({ + chains, + options: { + getProvider: () => + globalThis.window?.okxwallet || globalThis.window?.ethereum, + }, + }); + } +} + export const Okx: WalletAdapterType = ({ chains }) => ({ walletName: 'OKX Wallet', walletId: 'okx', @@ -29,12 +43,5 @@ export const Okx: WalletAdapterType = ({ chains }) => ({ downloadURLs: { default: 'https://www.okx.com/download', }, - connector: new InjectedConnector({ - chains, - options: { - name: 'OKX Wallet', - getProvider: () => - globalThis.window?.okxwallet || globalThis.window?.ethereum, - }, - }), + connector: new OkxConnector(chains), }); From d7e0060ba962d13e5f70e0b695b49b1654a79699 Mon Sep 17 00:00:00 2001 From: Alexander Khramov Date: Mon, 27 Nov 2023 15:34:42 +0300 Subject: [PATCH 2/2] chore: reef-knot v1.11.2 --- packages/connect-wallet-modal/CHANGELOG.md | 6 ++++++ packages/connect-wallet-modal/package.json | 2 +- packages/reef-knot/CHANGELOG.md | 8 ++++++++ packages/reef-knot/package.json | 6 +++--- packages/wallets-list/CHANGELOG.md | 11 +++++++++++ packages/wallets-list/package.json | 12 ++++++------ packages/wallets/bitkeep/CHANGELOG.md | 6 ++++++ packages/wallets/bitkeep/package.json | 2 +- packages/wallets/brave/CHANGELOG.md | 7 +++++++ packages/wallets/brave/package.json | 2 +- packages/wallets/coin98/CHANGELOG.md | 6 ++++++ packages/wallets/coin98/package.json | 2 +- packages/wallets/exodus/CHANGELOG.md | 6 ++++++ packages/wallets/exodus/package.json | 2 +- packages/wallets/okx/CHANGELOG.md | 6 ++++++ packages/wallets/okx/package.json | 2 +- 16 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 packages/wallets/brave/CHANGELOG.md diff --git a/packages/connect-wallet-modal/CHANGELOG.md b/packages/connect-wallet-modal/CHANGELOG.md index 76827916..3696ca92 100644 --- a/packages/connect-wallet-modal/CHANGELOG.md +++ b/packages/connect-wallet-modal/CHANGELOG.md @@ -1,5 +1,11 @@ # @reef-knot/connect-wallet-modal +## 1.11.1 + +### Patch Changes + +- Add custom connectors for injected wallets, which fixes an issue with autoconnection after page reload. + ## 1.11.0 ### Minor Changes diff --git a/packages/connect-wallet-modal/package.json b/packages/connect-wallet-modal/package.json index 88abcd91..5f772df9 100644 --- a/packages/connect-wallet-modal/package.json +++ b/packages/connect-wallet-modal/package.json @@ -1,6 +1,6 @@ { "name": "@reef-knot/connect-wallet-modal", - "version": "1.11.0", + "version": "1.11.1", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { diff --git a/packages/reef-knot/CHANGELOG.md b/packages/reef-knot/CHANGELOG.md index 0560fa25..4d7607e0 100644 --- a/packages/reef-knot/CHANGELOG.md +++ b/packages/reef-knot/CHANGELOG.md @@ -1,5 +1,13 @@ # reef-knot +## 1.11.2 + +### Patch Changes + +- Updated dependencies + - @reef-knot/connect-wallet-modal@1.11.1 + - @reef-knot/wallets-list@1.7.1 + ## 1.11.1 ### Patch Changes diff --git a/packages/reef-knot/package.json b/packages/reef-knot/package.json index 67dbf945..471fbffd 100644 --- a/packages/reef-knot/package.json +++ b/packages/reef-knot/package.json @@ -1,6 +1,6 @@ { "name": "reef-knot", - "version": "1.11.1", + "version": "1.11.2", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { @@ -41,12 +41,12 @@ "lint": "eslint --ext ts,tsx,js,mjs ." }, "dependencies": { - "@reef-knot/connect-wallet-modal": "1.11.0", + "@reef-knot/connect-wallet-modal": "1.11.1", "@reef-knot/core-react": "1.7.0", "@reef-knot/web3-react": "1.9.1", "@reef-knot/ui-react": "1.0.7", "@reef-knot/wallets-icons": "1.3.0", - "@reef-knot/wallets-list": "1.7.0", + "@reef-knot/wallets-list": "1.7.1", "@reef-knot/wallets-helpers": "1.1.5", "@reef-knot/types": "1.3.0", "@reef-knot/ledger-connector": "1.1.1" diff --git a/packages/wallets-list/CHANGELOG.md b/packages/wallets-list/CHANGELOG.md index f147f0cc..8ab15b83 100644 --- a/packages/wallets-list/CHANGELOG.md +++ b/packages/wallets-list/CHANGELOG.md @@ -1,5 +1,16 @@ # @reef-knot/wallets-list +## 1.7.1 + +### Patch Changes + +- Updated dependencies + - @reef-knot/wallet-adapter-bitkeep@1.1.1 + - @reef-knot/wallet-adapter-coin98@1.0.1 + - @reef-knot/wallet-adapter-exodus@1.2.4 + - @reef-knot/wallet-adapter-brave@1.0.1 + - @reef-knot/wallet-adapter-okx@1.3.1 + ## 1.7.0 ### Minor Changes diff --git a/packages/wallets-list/package.json b/packages/wallets-list/package.json index d464de02..401a7f03 100644 --- a/packages/wallets-list/package.json +++ b/packages/wallets-list/package.json @@ -1,6 +1,6 @@ { "name": "@reef-knot/wallets-list", - "version": "1.7.0", + "version": "1.7.1", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { @@ -37,18 +37,18 @@ "lint": "eslint --ext ts,tsx,js,mjs ." }, "dependencies": { - "@reef-knot/wallet-adapter-exodus": "1.2.3", + "@reef-knot/wallet-adapter-exodus": "1.2.4", "@reef-knot/wallet-adapter-taho": "1.2.3", - "@reef-knot/wallet-adapter-okx": "1.3.0", + "@reef-knot/wallet-adapter-okx": "1.3.1", "@reef-knot/wallet-adapter-phantom": "1.3.0", "@reef-knot/wallet-adapter-walletconnect": "1.2.4", "@reef-knot/wallet-adapter-blockchaincom": "1.2.4", "@reef-knot/wallet-adapter-zerion": "1.2.4", "@reef-knot/wallet-adapter-zengo": "1.2.4", "@reef-knot/wallet-adapter-ambire": "1.2.4", - "@reef-knot/wallet-adapter-bitkeep": "1.1.0", - "@reef-knot/wallet-adapter-coin98": "1.0.0", - "@reef-knot/wallet-adapter-brave": "1.0.0" + "@reef-knot/wallet-adapter-bitkeep": "1.1.1", + "@reef-knot/wallet-adapter-coin98": "1.0.1", + "@reef-knot/wallet-adapter-brave": "1.0.1" }, "devDependencies": { "@reef-knot/types": "^1.3.0", diff --git a/packages/wallets/bitkeep/CHANGELOG.md b/packages/wallets/bitkeep/CHANGELOG.md index 4fe22156..bfd28387 100644 --- a/packages/wallets/bitkeep/CHANGELOG.md +++ b/packages/wallets/bitkeep/CHANGELOG.md @@ -1,5 +1,11 @@ # @reef-knot/wallet-adapter-bitkeep +## 1.1.1 + +### Patch Changes + +- Add custom connectors for injected wallets, which fixes an issue with autoconnection after page reload. + ## 1.1.0 ### Minor Changes diff --git a/packages/wallets/bitkeep/package.json b/packages/wallets/bitkeep/package.json index 3ce98fed..b24a0bd3 100644 --- a/packages/wallets/bitkeep/package.json +++ b/packages/wallets/bitkeep/package.json @@ -1,6 +1,6 @@ { "name": "@reef-knot/wallet-adapter-bitkeep", - "version": "1.1.0", + "version": "1.1.1", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { diff --git a/packages/wallets/brave/CHANGELOG.md b/packages/wallets/brave/CHANGELOG.md new file mode 100644 index 00000000..61c15efc --- /dev/null +++ b/packages/wallets/brave/CHANGELOG.md @@ -0,0 +1,7 @@ +# @reef-knot/wallet-adapter-brave + +## 1.0.1 + +### Patch Changes + +- Add custom connectors for injected wallets, which fixes an issue with autoconnection after page reload. diff --git a/packages/wallets/brave/package.json b/packages/wallets/brave/package.json index 4bc60e75..1b2a430c 100644 --- a/packages/wallets/brave/package.json +++ b/packages/wallets/brave/package.json @@ -1,6 +1,6 @@ { "name": "@reef-knot/wallet-adapter-brave", - "version": "1.0.0", + "version": "1.0.1", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { diff --git a/packages/wallets/coin98/CHANGELOG.md b/packages/wallets/coin98/CHANGELOG.md index 2f1872ac..94541a80 100644 --- a/packages/wallets/coin98/CHANGELOG.md +++ b/packages/wallets/coin98/CHANGELOG.md @@ -1,5 +1,11 @@ # @reef-knot/wallet-adapter-coin98 +## 1.0.1 + +### Patch Changes + +- Add custom connectors for injected wallets, which fixes an issue with autoconnection after page reload. + ## 1.0.0 ### Minor Changes diff --git a/packages/wallets/coin98/package.json b/packages/wallets/coin98/package.json index 180b0fdd..d6f67a1e 100644 --- a/packages/wallets/coin98/package.json +++ b/packages/wallets/coin98/package.json @@ -1,6 +1,6 @@ { "name": "@reef-knot/wallet-adapter-coin98", - "version": "1.0.0", + "version": "1.0.1", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { diff --git a/packages/wallets/exodus/CHANGELOG.md b/packages/wallets/exodus/CHANGELOG.md index d1aabaa8..b1b6c515 100644 --- a/packages/wallets/exodus/CHANGELOG.md +++ b/packages/wallets/exodus/CHANGELOG.md @@ -1,5 +1,11 @@ # @reef-knot/wallet-adapter-exodus +## 1.2.4 + +### Patch Changes + +- Add custom connectors for injected wallets, which fixes an issue with autoconnection after page reload. + ## 1.2.3 ### Patch Changes diff --git a/packages/wallets/exodus/package.json b/packages/wallets/exodus/package.json index a56847b1..a68fcb84 100644 --- a/packages/wallets/exodus/package.json +++ b/packages/wallets/exodus/package.json @@ -1,6 +1,6 @@ { "name": "@reef-knot/wallet-adapter-exodus", - "version": "1.2.3", + "version": "1.2.4", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": { diff --git a/packages/wallets/okx/CHANGELOG.md b/packages/wallets/okx/CHANGELOG.md index e7e5a7bf..fa34a842 100644 --- a/packages/wallets/okx/CHANGELOG.md +++ b/packages/wallets/okx/CHANGELOG.md @@ -1,5 +1,11 @@ # @reef-knot/wallet-adapter-okx +## 1.3.1 + +### Patch Changes + +- Add custom connectors for injected wallets, which fixes an issue with autoconnection after page reload. + ## 1.3.0 ### Minor Changes diff --git a/packages/wallets/okx/package.json b/packages/wallets/okx/package.json index 349b5105..279d5557 100644 --- a/packages/wallets/okx/package.json +++ b/packages/wallets/okx/package.json @@ -1,6 +1,6 @@ { "name": "@reef-knot/wallet-adapter-okx", - "version": "1.3.0", + "version": "1.3.1", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": {