Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Update wc modal (#65)
Browse files Browse the repository at this point in the history
## Purpose

Deep linking does not work with the deprecated
`@walletconnect/qrcode-modal`. This PR aims to update the dependency.
  • Loading branch information
soerenbf authored Apr 15, 2024
1 parent 55cfd5a commit 3f6885a
Show file tree
Hide file tree
Showing 7 changed files with 509 additions and 238 deletions.
12 changes: 12 additions & 0 deletions packages/wallet-connectors/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- Added `createWalletConnectModalConfig` to create a configuration the modal shown when connecting to a walletconnect compatible wallet. The value returned can be passed to `WalletConnectConnector.create`.
- Added `CRYPTO_X_WALLET_MAINNET` and `CONCORDIUM_WALLET_MAINNET` exports, which can be passed `createWalletConnectModalConfig` for more control over which wallets are shown.
- Added option to specify the methods and events to request permission for by walletconnect

### Changed

- Changed the wallet connect modal dependency from `@walletconnect/qrcode-modal` (which is deprecated) to `@walletconnect/modal`.

## [0.5.1] - 2024-03-22

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion packages/wallet-connectors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
},
"dependencies": {
"@concordium/browser-wallet-api-helpers": "^3.0.0",
"@walletconnect/qrcode-modal": "^1.8.0",
"@walletconnect/modal": "^2.6.2",
"@walletconnect/modal-core": "^2.6.2",
"@walletconnect/sign-client": "^2.1.4"
},
"peerDependencies": {
Expand Down
219 changes: 198 additions & 21 deletions packages/wallet-connectors/src/WalletConnect.ts

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion samples/contractupdate/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {
BrowserWalletConnector,
CONCORDIUM_WALLET_CONNECT_PROJECT_ID,
WalletConnectConnector,
WalletConnectEvent,
WalletConnectMethod,
WalletConnectNamespaceConfig,
ephemeralConnectorType,
} from '@concordium/react-components';
import { SignClientTypes } from '@walletconnect/types';
Expand All @@ -16,5 +19,12 @@ const WALLET_CONNECT_OPTS: SignClientTypes.Options = {
},
};

const WALLET_CONNECT_NS_CONFIG: WalletConnectNamespaceConfig = {
methods: [WalletConnectMethod.SignAndSendTransaction],
events: [WalletConnectEvent.AccountsChanged, WalletConnectEvent.ChainChanged],
};

export const BROWSER_WALLET = ephemeralConnectorType(BrowserWalletConnector.create);
export const WALLET_CONNECT = ephemeralConnectorType(WalletConnectConnector.create.bind(this, WALLET_CONNECT_OPTS));
export const WALLET_CONNECT = ephemeralConnectorType((delegate, network) =>
WalletConnectConnector.create(WALLET_CONNECT_OPTS, delegate, network, WALLET_CONNECT_NS_CONFIG)
);
12 changes: 11 additions & 1 deletion samples/proofs/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {
BrowserWalletConnector,
CONCORDIUM_WALLET_CONNECT_PROJECT_ID,
WalletConnectConnector,
WalletConnectEvent,
WalletConnectMethod,
WalletConnectNamespaceConfig,
ephemeralConnectorType,
} from '@concordium/react-components';
import { SignClientTypes } from '@walletconnect/types';
Expand All @@ -16,5 +19,12 @@ const WALLET_CONNECT_OPTS: SignClientTypes.Options = {
},
};

const WALLET_CONNECT_SCOPE: WalletConnectNamespaceConfig = {
methods: [WalletConnectMethod.RequestVerifiablePresentation],
events: [WalletConnectEvent.AccountsChanged, WalletConnectEvent.ChainChanged],
};

export const BROWSER_WALLET = ephemeralConnectorType(BrowserWalletConnector.create);
export const WALLET_CONNECT = ephemeralConnectorType(WalletConnectConnector.create.bind(this, WALLET_CONNECT_OPTS));
export const WALLET_CONNECT = ephemeralConnectorType((delegate, network) =>
WalletConnectConnector.create(WALLET_CONNECT_OPTS, delegate, network, WALLET_CONNECT_SCOPE)
);
12 changes: 11 additions & 1 deletion samples/sign-message/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {
BrowserWalletConnector,
CONCORDIUM_WALLET_CONNECT_PROJECT_ID,
WalletConnectConnector,
WalletConnectEvent,
WalletConnectMethod,
WalletConnectNamespaceConfig,
ephemeralConnectorType,
} from '@concordium/react-components';
import { SignClientTypes } from '@walletconnect/types';
Expand All @@ -16,5 +19,12 @@ const WALLET_CONNECT_OPTS: SignClientTypes.Options = {
},
};

const WALLET_CONNECT_SCOPE: WalletConnectNamespaceConfig = {
methods: [WalletConnectMethod.SignMessage],
events: [WalletConnectEvent.AccountsChanged, WalletConnectEvent.ChainChanged],
};

export const BROWSER_WALLET = ephemeralConnectorType(BrowserWalletConnector.create);
export const WALLET_CONNECT = ephemeralConnectorType(WalletConnectConnector.create.bind(this, WALLET_CONNECT_OPTS));
export const WALLET_CONNECT = ephemeralConnectorType((delegate, network) =>
WalletConnectConnector.create(WALLET_CONNECT_OPTS, delegate, network, WALLET_CONNECT_SCOPE)
);
Loading

0 comments on commit 3f6885a

Please sign in to comment.