Skip to content

Commit

Permalink
Merge pull request #105 from lidofinance/fix/wrong-connector-after-re…
Browse files Browse the repository at this point in the history
…load

Fix: wrong connector after page reload
  • Loading branch information
alx-khramov authored Dec 6, 2023
2 parents 1ce20c7 + d7e0060 commit e6cbbab
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 61 deletions.
6 changes: 6 additions & 0 deletions packages/connect-wallet-modal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-wallet-modal/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
});
Expand Down
8 changes: 8 additions & 0 deletions packages/reef-knot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/reef-knot/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions packages/wallets-list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 6 additions & 6 deletions packages/wallets-list/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions packages/wallets/bitkeep/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/bitkeep/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
23 changes: 15 additions & 8 deletions packages/wallets/bitkeep/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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,
Expand All @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions packages/wallets/brave/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/wallets/brave/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
25 changes: 16 additions & 9 deletions packages/wallets/brave/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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',
Expand All @@ -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),
});
6 changes: 6 additions & 0 deletions packages/wallets/coin98/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/coin98/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
25 changes: 16 additions & 9 deletions packages/wallets/coin98/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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',
Expand All @@ -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),
});
6 changes: 6 additions & 0 deletions packages/wallets/exodus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/exodus/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
27 changes: 17 additions & 10 deletions packages/wallets/exodus/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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',
Expand All @@ -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),
});
6 changes: 6 additions & 0 deletions packages/wallets/okx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/okx/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Loading

0 comments on commit e6cbbab

Please sign in to comment.