Skip to content

Commit 6b3ddc4

Browse files
committed
fix: update deprecated WalletConnect integration
1 parent 30c148c commit 6b3ddc4

9 files changed

Lines changed: 5132 additions & 1444 deletions

File tree

.github/workflows/publish-new-version.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ jobs:
99
test:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
1313

1414
- uses: actions/setup-node@v1
1515
with:
16-
node-version: 14
16+
node-version: 20
1717

1818
- run: yarn
1919
- run: yarn build
@@ -24,15 +24,17 @@ jobs:
2424
if: "!contains(github.event.head_commit.message, 'Publish') && !contains(github.event.head_commit.message, '[SKIP-CI]') && !contains(github.event.head_commit.message, '[SKIP CI]')"
2525
needs: test
2626
runs-on: ubuntu-latest
27+
permissions:
28+
contents: write
2729
steps:
28-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v4
2931
with:
30-
token: ${{ secrets.ACCESS_TOKEN }}
32+
token: ${{ secrets.GITHUB_TOKEN }}
3133
- uses: fregante/setup-git-user@v1
3234

3335
- uses: actions/setup-node@v1
3436
with:
35-
node-version: 14
37+
node-version: 20
3638
registry-url: https://registry.npmjs.org/
3739

3840
- name: Install dependencies
@@ -67,3 +69,4 @@ jobs:
6769
run: HUSKY_SKIP_HOOKS=1 npx lerna version --yes --conventional-commits --create-release github
6870
env:
6971
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"workspaces": [
2525
"packages/*"
2626
],
27+
"resolutions": {
28+
"node-gyp": "^10.0.0"
29+
},
2730
"repository": {
2831
"type": "git",
2932
"url": "git+https://github.com/akropolisio/web3-wallets-kit.git"
@@ -48,7 +51,7 @@
4851
"@commitlint/cli": "^8.2.0",
4952
"@commitlint/config-conventional": "^8.2.0",
5053
"@types/jest": "^24.0.23",
51-
"@types/node": "12.12.14",
54+
"@types/node": "^20.19.27",
5255
"@typescript-eslint/eslint-plugin": "^2.34.0",
5356
"@typescript-eslint/parser": "^2.34.0",
5457
"commitizen": "^4.0.3",
@@ -69,7 +72,7 @@
6972
"prettier": "^2.1.1",
7073
"ts-jest": "^24.1.0",
7174
"ts-node": "^8.5.0",
72-
"tsdx": "^0.12.3",
73-
"typescript": "^3.9.7"
75+
"tsdx": "0.14.1",
76+
"typescript": "^4.9.5"
7477
}
75-
}
78+
}

packages/connect-wallet-connector/README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,31 @@
1010
import { ConnectWalletConnector } from '@web3-wallets-kit/connect-wallet-connector';
1111

1212
const connector = new ConnectWalletConnector({
13-
infuraId: 'INFURA_API_KEY',
14-
chainId: 42,
13+
projectId: 'YOUR_WALLETCONNECT_PROJECT_ID', // Get from https://cloud.walletconnect.com
14+
chains: [1], // Ethereum Mainnet
15+
showQrModal: true,
16+
metadata: {
17+
name: 'My App',
18+
description: 'My App Description',
19+
url: 'https://myapp.com',
20+
icons: ['https://myapp.com/icon.png'],
21+
},
1522
});
1623
```
24+
25+
## Configuration
26+
27+
WalletConnect v2 requires a `projectId` that you can get from [WalletConnect Cloud](https://cloud.walletconnect.com).
28+
29+
### Required Parameters
30+
31+
- `projectId`: Your WalletConnect Cloud project ID
32+
- `chains`: Array of chain IDs (e.g., `[1]` for Ethereum Mainnet, `[42]` for Kovan)
33+
34+
### Optional Parameters
35+
36+
- `showQrModal`: Show QR code modal (default: `true`)
37+
- `optionalChains`: Array of optional chain IDs
38+
- `rpcMap`: Custom RPC endpoints mapping (e.g., `{ 1: 'https://mainnet.infura.io/v3/YOUR_KEY' }`)
39+
- `metadata`: App metadata (name, description, url, icons)
40+
- `qrModalOptions`: QR modal customization (themeMode, themeVariables)

packages/connect-wallet-connector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"access": "public"
3737
},
3838
"dependencies": {
39-
"@walletconnect/web3-provider": "^1.6.6",
39+
"@walletconnect/ethereum-provider": "^2.11.0",
4040
"@web3-wallets-kit/abstract-connector": "^0.3.9",
4141
"@web3-wallets-kit/types": "^0.5.9"
4242
}
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1-
describe('Web3WalletsManager', (): void => {
2-
it('TODO write test', (): void => {
3-
expect('0').toEqual('0');
1+
import { ConnectWalletConnector } from '../index';
2+
3+
describe('ConnectWalletConnector', (): void => {
4+
it('should create connector with required config', (): void => {
5+
const connector = new ConnectWalletConnector({
6+
projectId: 'test-project-id',
7+
chains: [1],
8+
showQrModal: true,
9+
});
10+
expect(connector).toBeDefined();
11+
});
12+
13+
it('should create connector with full config', (): void => {
14+
const connector = new ConnectWalletConnector({
15+
projectId: 'test-project-id',
16+
chains: [1],
17+
showQrModal: true,
18+
optionalChains: [42, 5],
19+
metadata: {
20+
name: 'Test App',
21+
description: 'Test Description',
22+
url: 'https://test.com',
23+
icons: ['https://test.com/icon.png'],
24+
},
25+
});
26+
expect(connector).toBeDefined();
427
});
528
});

packages/connect-wallet-connector/src/index.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-disable import/no-duplicates */
22
import { AbstractConnector } from '@web3-wallets-kit/abstract-connector';
33
import { DefaultConnectionPayload } from '@web3-wallets-kit/types';
4-
import type WalletConnectProvider from '@walletconnect/web3-provider';
5-
import type { IWalletConnectProviderOptions } from '@walletconnect/types';
4+
import type EthereumProvider from '@walletconnect/ethereum-provider';
5+
import type { EthereumProviderOptions } from '@walletconnect/ethereum-provider';
66

7-
export type ConnectWalletConnectorConfig = IWalletConnectProviderOptions;
7+
export type ConnectWalletConnectorConfig = EthereumProviderOptions;
88

99
export interface ConnectWalletConnectionPayload extends DefaultConnectionPayload {
10-
provider: WalletConnectProvider;
10+
provider: EthereumProvider;
1111
}
1212

1313
export class ConnectWalletConnector extends AbstractConnector<ConnectWalletConnectionPayload> {
@@ -16,11 +16,13 @@ export class ConnectWalletConnector extends AbstractConnector<ConnectWalletConne
1616
}
1717

1818
public async connect(): Promise<ConnectWalletConnectionPayload> {
19-
const WalletConnectLibrary = await import('@walletconnect/web3-provider');
20-
const Provider = WalletConnectLibrary.default;
21-
const provider = new Provider(this.config);
19+
const { EthereumProvider: WalletConnectProvider } = await import(
20+
'@walletconnect/ethereum-provider'
21+
);
2222

23-
await provider.enable();
23+
const provider = await WalletConnectProvider.init(this.config);
24+
25+
await provider.connect();
2426

2527
this.payload = {
2628
provider,
@@ -31,11 +33,7 @@ export class ConnectWalletConnector extends AbstractConnector<ConnectWalletConne
3133

3234
public async disconnect() {
3335
if (this.payload) {
34-
const walletConnector = await this.payload.provider.getWalletConnector({
35-
disableSessionCreation: true,
36-
});
37-
await walletConnector.killSession();
38-
await this.payload.provider.stop();
36+
await this.payload.provider.disconnect();
3937
}
4038
super.disconnect();
4139
}

packages/unstoppable-connector/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ const connector = new UnstoppableConnector({
2626
connectors: {
2727
web3: new InpageConnector(),
2828
walletconnect: new ConnectWalletConnector({
29-
chainId: 1,
30-
rpc: {
31-
1: 'https://mainnet.mycustomnode.com',
29+
projectId: 'YOUR_WALLETCONNECT_PROJECT_ID',
30+
chains: [1],
31+
metadata: {
32+
name: 'My App',
33+
description: 'My App Description',
34+
url: 'https://myapp.com',
35+
icons: ['https://myapp.com/icon.png'],
3236
},
3337
}),
3438
},

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"lib": ["dom", "ESNext"], /* Specify library files to be included in the compilation. */
88
// "allowJs": true, /* Allow javascript files to be compiled. */
99
// "checkJs": true, /* Report errors in .js files. */
10+
"skipLibCheck": false,
1011
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
1112
"declaration": true, /* Generates corresponding '.d.ts' file. */
1213
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */

0 commit comments

Comments
 (0)