-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite): minimal walletconnect implementation for evm
- Loading branch information
Showing
13 changed files
with
1,973 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@trezor/suite-walletconnect", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "See LICENSE.md in repo root", | ||
"sideEffects": false, | ||
"main": "src/index", | ||
"scripts": { | ||
"depcheck": "yarn g:depcheck", | ||
"type-check": "yarn g:tsc --build", | ||
"test:unit": "yarn g:jest -c ../../jest.config.base.js", | ||
"test-unit:watch": "yarn g:jest -c ../../jest.config.base.js -o --watch" | ||
}, | ||
"dependencies": { | ||
"@reduxjs/toolkit": "1.9.5", | ||
"@reown/walletkit": "^1.1.1", | ||
"@suite-common/redux-utils": "workspace:*", | ||
"@suite-common/suite-types": "workspace:*", | ||
"@trezor/connect": "workspace:*", | ||
"@walletconnect/core": "^2.17.2", | ||
"@walletconnect/utils": "^2.17.2" | ||
}, | ||
"devDependencies": { | ||
"redux-thunk": "^2.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './walletConnectThunks'; | ||
export * from './walletConnectMiddleware'; |
27 changes: 27 additions & 0 deletions
27
packages/suite-walletconnect/src/walletConnectMiddleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { accountsActions } from '@suite-common/wallet-core'; | ||
import { createMiddlewareWithExtraDeps } from '@suite-common/redux-utils'; | ||
|
||
import * as walletConnectActions from './walletConnectThunks'; | ||
|
||
export const prepareWalletConnectMiddleware = createMiddlewareWithExtraDeps( | ||
async (action, { dispatch, next }) => { | ||
await next(action); | ||
|
||
if (accountsActions.updateSelectedAccount.match(action) && action.payload.account) { | ||
dispatch( | ||
walletConnectActions.switchSelectedAccountThunk({ | ||
account: action.payload.account, | ||
}), | ||
); | ||
} | ||
|
||
if ( | ||
accountsActions.createAccount.match(action) || | ||
accountsActions.removeAccount.match(action) | ||
) { | ||
dispatch(walletConnectActions.updateAccountsThunk()); | ||
} | ||
|
||
return action; | ||
}, | ||
); |
Oops, something went wrong.