@dynamic-labs/ethereum 1.3.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/package.json +9 -10
- package/src/coinbase/coinbase.cjs +22 -3
- package/src/coinbase/coinbase.d.ts +1 -0
- package/src/coinbase/coinbase.js +22 -3
- package/src/index.cjs +3 -9
- package/src/index.js +3 -9
- package/src/injected/Zerion.cjs +38 -0
- package/src/injected/Zerion.d.ts +23 -0
- package/src/injected/Zerion.js +34 -0
- package/src/injected/fetchInjectedWalletConnectors.cjs +3 -0
- package/src/injected/fetchInjectedWalletConnectors.js +3 -0
- package/src/walletConnect/walletConnect.cjs +2 -136
- package/src/walletConnect/walletConnect.d.ts +3 -42
- package/src/walletConnect/walletConnect.js +3 -133
- package/src/walletConnect/walletConnectV2.cjs +97 -61
- package/src/walletConnect/walletConnectV2.d.ts +17 -14
- package/src/walletConnect/walletConnectV2.js +96 -60
- package/src/walletConnect/client/client.cjs +0 -201
- package/src/walletConnect/client/client.js +0 -187
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
|
|
2
|
+
### [1.4.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.4.0...v1.4.1) (2024-03-22)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* validate user session whenever user is connected/authenticated ([#5079](https://github.com/dynamic-labs/DynamicAuth/issues/5079)) ([d346cef](https://github.com/dynamic-labs/DynamicAuth/commit/d346cefb027305e43020b2a3b48a83bafeae4131))
|
|
8
|
+
|
|
9
|
+
## [1.4.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.3.1...v1.4.0) (2024-03-21)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add sign-in with farcaster ([#5059](https://github.com/dynamic-labs/DynamicAuth/issues/5059)) ([83245aa](https://github.com/dynamic-labs/DynamicAuth/commit/83245aa9f973ca349abcbaccf5d150b4a31beb0e)), closes [#4947](https://github.com/dynamic-labs/DynamicAuth/issues/4947)
|
|
15
|
+
* add prop to hide embedded wallet transaction UIs ([#4928](https://github.com/dynamic-labs/DynamicAuth/issues/4928)) ([b0ad954](https://github.com/dynamic-labs/DynamicAuth/commit/b0ad95494ebf991e61f09a23999c3526498f2db9)), closes [#4924](https://github.com/dynamic-labs/DynamicAuth/issues/4924)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* multiple wallet improvements
|
|
21
|
+
* multiple ui/ux improvements
|
|
22
|
+
* miscellaneous copy and localization updates
|
|
23
|
+
* add missing css variables for DynamicConnectButton
|
|
24
|
+
|
|
2
25
|
### [1.3.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.3.0...v1.3.1) (2024-03-08)
|
|
3
26
|
|
|
4
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -28,17 +28,16 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@coinbase/wallet-sdk": "3.9.2",
|
|
30
30
|
"@walletconnect/client": "1.8.0",
|
|
31
|
-
"@walletconnect/ethereum-provider": "
|
|
32
|
-
"@walletconnect/universal-provider": "2.10.6",
|
|
31
|
+
"@walletconnect/ethereum-provider": "2.11.2",
|
|
33
32
|
"eventemitter3": "5.0.1",
|
|
34
33
|
"buffer": "6.0.3",
|
|
35
|
-
"@dynamic-labs/rpc-providers": "1.
|
|
36
|
-
"@dynamic-labs/turnkey": "1.
|
|
37
|
-
"@dynamic-labs/types": "1.
|
|
38
|
-
"@dynamic-labs/utils": "1.
|
|
39
|
-
"@dynamic-labs/viem-utils": "1.
|
|
40
|
-
"@dynamic-labs/wallet-book": "1.
|
|
41
|
-
"@dynamic-labs/wallet-connector-core": "1.
|
|
34
|
+
"@dynamic-labs/rpc-providers": "1.4.1",
|
|
35
|
+
"@dynamic-labs/turnkey": "1.4.1",
|
|
36
|
+
"@dynamic-labs/types": "1.4.1",
|
|
37
|
+
"@dynamic-labs/utils": "1.4.1",
|
|
38
|
+
"@dynamic-labs/viem-utils": "1.4.1",
|
|
39
|
+
"@dynamic-labs/wallet-book": "1.4.1",
|
|
40
|
+
"@dynamic-labs/wallet-connector-core": "1.4.1",
|
|
42
41
|
"stream": "0.0.2"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
@@ -5,15 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
6
|
var viem = require('viem');
|
|
7
7
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
9
|
require('../polyfills.cjs');
|
|
9
10
|
require('@dynamic-labs/turnkey');
|
|
10
11
|
require('@dynamic-labs/utils');
|
|
11
12
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
12
13
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
13
14
|
require('../walletConnect/walletConnectV2.cjs');
|
|
14
|
-
require('@walletconnect/ethereum-provider');
|
|
15
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
16
|
-
require('@walletconnect/client');
|
|
17
15
|
var client = require('./client/client.cjs');
|
|
18
16
|
|
|
19
17
|
class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
@@ -36,6 +34,10 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
36
34
|
}
|
|
37
35
|
setupEventListeners() {
|
|
38
36
|
var _a, _b, _c;
|
|
37
|
+
if (!this.isInstalledOnBrowser()) {
|
|
38
|
+
this.setupCoinbaseProviderEventListeners();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
39
41
|
const provider = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider();
|
|
40
42
|
if (!provider) {
|
|
41
43
|
return;
|
|
@@ -85,6 +87,23 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
85
87
|
client.killCoinbaseSession();
|
|
86
88
|
});
|
|
87
89
|
}
|
|
90
|
+
setupCoinbaseProviderEventListeners() {
|
|
91
|
+
const provider = client.getCoinbaseProvider({
|
|
92
|
+
opts: this.coinbaseProviderOpts,
|
|
93
|
+
});
|
|
94
|
+
if (!provider) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const { handleAccountChange, handleChainChange, handleDisconnect } = walletConnectorCore.eventListenerHandlers(this);
|
|
98
|
+
provider.on('accountsChanged', handleAccountChange);
|
|
99
|
+
provider.on('chainChanged', handleChainChange);
|
|
100
|
+
provider.on('disconnect', handleDisconnect);
|
|
101
|
+
this.teardownEventListeners = () => {
|
|
102
|
+
provider.removeListener('accountsChanged', handleAccountChange);
|
|
103
|
+
provider.removeListener('chainChanged', handleChainChange);
|
|
104
|
+
provider.removeListener('disconnect', handleDisconnect);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
88
107
|
}
|
|
89
108
|
|
|
90
109
|
exports.Coinbase = Coinbase;
|
|
@@ -533,5 +533,6 @@ export declare class Coinbase extends EthWalletConnector {
|
|
|
533
533
|
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
|
|
534
534
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
535
535
|
endSession(): Promise<void>;
|
|
536
|
+
private setupCoinbaseProviderEventListeners;
|
|
536
537
|
}
|
|
537
538
|
export {};
|
package/src/coinbase/coinbase.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { __rest, __awaiter } from '../../_virtual/_tslib.js';
|
|
2
2
|
import { createWalletClient, custom } from 'viem';
|
|
3
3
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
4
|
+
import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
4
5
|
import '../polyfills.js';
|
|
5
6
|
import '@dynamic-labs/turnkey';
|
|
6
7
|
import '@dynamic-labs/utils';
|
|
7
8
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
8
9
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
9
10
|
import '../walletConnect/walletConnectV2.js';
|
|
10
|
-
import '@walletconnect/ethereum-provider';
|
|
11
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
12
|
-
import '@walletconnect/client';
|
|
13
11
|
import { getCoinbaseProvider, fetchPublicAddress, signMessage, killCoinbaseSession } from './client/client.js';
|
|
14
12
|
|
|
15
13
|
class Coinbase extends EthWalletConnector {
|
|
@@ -32,6 +30,10 @@ class Coinbase extends EthWalletConnector {
|
|
|
32
30
|
}
|
|
33
31
|
setupEventListeners() {
|
|
34
32
|
var _a, _b, _c;
|
|
33
|
+
if (!this.isInstalledOnBrowser()) {
|
|
34
|
+
this.setupCoinbaseProviderEventListeners();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
35
37
|
const provider = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider();
|
|
36
38
|
if (!provider) {
|
|
37
39
|
return;
|
|
@@ -81,6 +83,23 @@ class Coinbase extends EthWalletConnector {
|
|
|
81
83
|
killCoinbaseSession();
|
|
82
84
|
});
|
|
83
85
|
}
|
|
86
|
+
setupCoinbaseProviderEventListeners() {
|
|
87
|
+
const provider = getCoinbaseProvider({
|
|
88
|
+
opts: this.coinbaseProviderOpts,
|
|
89
|
+
});
|
|
90
|
+
if (!provider) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const { handleAccountChange, handleChainChange, handleDisconnect } = eventListenerHandlers(this);
|
|
94
|
+
provider.on('accountsChanged', handleAccountChange);
|
|
95
|
+
provider.on('chainChanged', handleChainChange);
|
|
96
|
+
provider.on('disconnect', handleDisconnect);
|
|
97
|
+
this.teardownEventListeners = () => {
|
|
98
|
+
provider.removeListener('accountsChanged', handleAccountChange);
|
|
99
|
+
provider.removeListener('chainChanged', handleChainChange);
|
|
100
|
+
provider.removeListener('disconnect', handleDisconnect);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
84
103
|
}
|
|
85
104
|
|
|
86
105
|
export { Coinbase };
|
package/src/index.cjs
CHANGED
|
@@ -9,23 +9,17 @@ var ExodusEvm = require('./injected/ExodusEvm.cjs');
|
|
|
9
9
|
var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
|
|
10
10
|
require('./walletConnect/walletConnectV2.cjs');
|
|
11
11
|
require('../_virtual/_tslib.cjs');
|
|
12
|
-
require('@walletconnect/ethereum-provider');
|
|
13
|
-
require('viem');
|
|
14
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
15
|
-
require('@dynamic-labs/wallet-book');
|
|
16
|
-
require('@dynamic-labs/utils');
|
|
17
12
|
var EthWalletConnector = require('./EthWalletConnector.cjs');
|
|
18
|
-
var constants = require('./constants.cjs');
|
|
19
|
-
require('@walletconnect/client');
|
|
20
13
|
var fetchWalletConnectWallets = require('./walletConnect/fetchWalletConnectWallets.cjs');
|
|
21
14
|
var coinbase = require('./coinbase/coinbase.cjs');
|
|
22
15
|
var ethProviderHelper = require('./ethProviderHelper.cjs');
|
|
16
|
+
var constants = require('./constants.cjs');
|
|
23
17
|
|
|
24
18
|
const EthereumWalletConnectors = (props) => [
|
|
25
19
|
...fetchInjectedWalletConnectors.injectedWalletOverrides,
|
|
26
20
|
...fetchInjectedWalletConnectors.fetchInjectedWalletConnector(props),
|
|
27
21
|
...fetchWalletConnectWallets.fetchWalletConnectWallets(props),
|
|
28
|
-
...turnkey.
|
|
22
|
+
...turnkey.TurnkeyEVMWalletConnectors(props),
|
|
29
23
|
coinbase.Coinbase,
|
|
30
24
|
fetchWalletConnectWallets.getWalletConnectConnector(props),
|
|
31
25
|
];
|
|
@@ -35,6 +29,6 @@ exports.ExodusEvm = ExodusEvm.ExodusEvm;
|
|
|
35
29
|
exports.fetchInjectedWalletConnector = fetchInjectedWalletConnectors.fetchInjectedWalletConnector;
|
|
36
30
|
exports.injectedWalletOverrides = fetchInjectedWalletConnectors.injectedWalletOverrides;
|
|
37
31
|
exports.EthWalletConnector = EthWalletConnector.EthWalletConnector;
|
|
38
|
-
exports.INFURA_ID = constants.INFURA_ID;
|
|
39
32
|
exports.EthProviderHelper = ethProviderHelper.EthProviderHelper;
|
|
33
|
+
exports.INFURA_ID = constants.INFURA_ID;
|
|
40
34
|
exports.EthereumWalletConnectors = EthereumWalletConnectors;
|
package/src/index.js
CHANGED
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import './polyfills.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TurnkeyEVMWalletConnectors } from '@dynamic-labs/turnkey';
|
|
3
3
|
export { PhantomEvm } from './injected/PhantomEvm.js';
|
|
4
4
|
export { ExodusEvm } from './injected/ExodusEvm.js';
|
|
5
5
|
import { injectedWalletOverrides, fetchInjectedWalletConnector } from './injected/fetchInjectedWalletConnectors.js';
|
|
6
6
|
export { fetchInjectedWalletConnector, injectedWalletOverrides } from './injected/fetchInjectedWalletConnectors.js';
|
|
7
7
|
import './walletConnect/walletConnectV2.js';
|
|
8
8
|
import '../_virtual/_tslib.js';
|
|
9
|
-
import '@walletconnect/ethereum-provider';
|
|
10
|
-
import 'viem';
|
|
11
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
12
|
-
import '@dynamic-labs/wallet-book';
|
|
13
|
-
import '@dynamic-labs/utils';
|
|
14
9
|
export { EthWalletConnector } from './EthWalletConnector.js';
|
|
15
|
-
export { INFURA_ID } from './constants.js';
|
|
16
|
-
import '@walletconnect/client';
|
|
17
10
|
import { fetchWalletConnectWallets, getWalletConnectConnector } from './walletConnect/fetchWalletConnectWallets.js';
|
|
18
11
|
import { Coinbase } from './coinbase/coinbase.js';
|
|
19
12
|
export { EthProviderHelper } from './ethProviderHelper.js';
|
|
13
|
+
export { INFURA_ID } from './constants.js';
|
|
20
14
|
|
|
21
15
|
const EthereumWalletConnectors = (props) => [
|
|
22
16
|
...injectedWalletOverrides,
|
|
23
17
|
...fetchInjectedWalletConnector(props),
|
|
24
18
|
...fetchWalletConnectWallets(props),
|
|
25
|
-
...
|
|
19
|
+
...TurnkeyEVMWalletConnectors(props),
|
|
26
20
|
Coinbase,
|
|
27
21
|
getWalletConnectConnector(props),
|
|
28
22
|
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
6
|
+
|
|
7
|
+
// on desktop, we use EIP-6963 to connect to the wallet so the injectedConfig
|
|
8
|
+
// is not needed.
|
|
9
|
+
const zerionWalletBookConfig = {
|
|
10
|
+
eip6963Config: {
|
|
11
|
+
rdns: 'io.zerion.wallet',
|
|
12
|
+
},
|
|
13
|
+
filterFromWalletConnect: true,
|
|
14
|
+
injectedConfig: [
|
|
15
|
+
{
|
|
16
|
+
chain: 'evm',
|
|
17
|
+
// adds isMetaMask flag to the wallet connector so that the window provider works
|
|
18
|
+
// in the zerion in-app browser.
|
|
19
|
+
extensionLocators: [{ flag: 'isMetaMask', value: true }],
|
|
20
|
+
windowLocations: ['zerionWallet', 'zerionwallet.ethereum'],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
name: 'Zerion',
|
|
24
|
+
};
|
|
25
|
+
class Zerion extends InjectedWalletBase {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.name = 'Zerion';
|
|
29
|
+
this.overrideKey = 'zerion';
|
|
30
|
+
this.wallet = zerionWalletBookConfig;
|
|
31
|
+
}
|
|
32
|
+
isInstalledOnBrowser() {
|
|
33
|
+
var _a;
|
|
34
|
+
return Boolean(window.zerionWallet || ((_a = window.zerionwallet) === null || _a === void 0 ? void 0 : _a.ethereum));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.Zerion = Zerion;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
2
|
+
import InjectedWalletBase from './InjectedWalletBase';
|
|
3
|
+
export declare class Zerion extends InjectedWalletBase {
|
|
4
|
+
name: string;
|
|
5
|
+
overrideKey: string;
|
|
6
|
+
wallet: {
|
|
7
|
+
eip6963Config: {
|
|
8
|
+
rdns: string;
|
|
9
|
+
};
|
|
10
|
+
filterFromWalletConnect: boolean;
|
|
11
|
+
injectedConfig: {
|
|
12
|
+
chain: string;
|
|
13
|
+
extensionLocators: {
|
|
14
|
+
flag: string;
|
|
15
|
+
value: boolean;
|
|
16
|
+
}[];
|
|
17
|
+
windowLocations: string[];
|
|
18
|
+
}[];
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
constructor(props: EthWalletConnectorOpts);
|
|
22
|
+
isInstalledOnBrowser(): boolean;
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import InjectedWalletBase from './InjectedWalletBase.js';
|
|
2
|
+
|
|
3
|
+
// on desktop, we use EIP-6963 to connect to the wallet so the injectedConfig
|
|
4
|
+
// is not needed.
|
|
5
|
+
const zerionWalletBookConfig = {
|
|
6
|
+
eip6963Config: {
|
|
7
|
+
rdns: 'io.zerion.wallet',
|
|
8
|
+
},
|
|
9
|
+
filterFromWalletConnect: true,
|
|
10
|
+
injectedConfig: [
|
|
11
|
+
{
|
|
12
|
+
chain: 'evm',
|
|
13
|
+
// adds isMetaMask flag to the wallet connector so that the window provider works
|
|
14
|
+
// in the zerion in-app browser.
|
|
15
|
+
extensionLocators: [{ flag: 'isMetaMask', value: true }],
|
|
16
|
+
windowLocations: ['zerionWallet', 'zerionwallet.ethereum'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
name: 'Zerion',
|
|
20
|
+
};
|
|
21
|
+
class Zerion extends InjectedWalletBase {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.name = 'Zerion';
|
|
25
|
+
this.overrideKey = 'zerion';
|
|
26
|
+
this.wallet = zerionWalletBookConfig;
|
|
27
|
+
}
|
|
28
|
+
isInstalledOnBrowser() {
|
|
29
|
+
var _a;
|
|
30
|
+
return Boolean(window.zerionWallet || ((_a = window.zerionwallet) === null || _a === void 0 ? void 0 : _a.ethereum));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { Zerion };
|
|
@@ -5,15 +5,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
6
6
|
var PhantomEvm = require('./PhantomEvm.cjs');
|
|
7
7
|
var ExodusEvm = require('./ExodusEvm.cjs');
|
|
8
|
+
var Zerion = require('./Zerion.cjs');
|
|
8
9
|
|
|
9
10
|
const injectedWalletOverrides = [
|
|
10
11
|
PhantomEvm.PhantomEvm,
|
|
11
12
|
ExodusEvm.ExodusEvm,
|
|
13
|
+
Zerion.Zerion,
|
|
12
14
|
];
|
|
13
15
|
const filteredInjectedWalletKeysOverrides = [
|
|
14
16
|
'phantomevm',
|
|
15
17
|
'coinbase',
|
|
16
18
|
'exodusevm',
|
|
19
|
+
'zerion',
|
|
17
20
|
];
|
|
18
21
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
19
22
|
var _a;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import InjectedWalletBase from './InjectedWalletBase.js';
|
|
2
2
|
import { PhantomEvm } from './PhantomEvm.js';
|
|
3
3
|
import { ExodusEvm } from './ExodusEvm.js';
|
|
4
|
+
import { Zerion } from './Zerion.js';
|
|
4
5
|
|
|
5
6
|
const injectedWalletOverrides = [
|
|
6
7
|
PhantomEvm,
|
|
7
8
|
ExodusEvm,
|
|
9
|
+
Zerion,
|
|
8
10
|
];
|
|
9
11
|
const filteredInjectedWalletKeysOverrides = [
|
|
10
12
|
'phantomevm',
|
|
11
13
|
'coinbase',
|
|
12
14
|
'exodusevm',
|
|
15
|
+
'zerion',
|
|
13
16
|
];
|
|
14
17
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
15
18
|
var _a;
|
|
@@ -3,153 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
|
-
var WalletConnectProvider = require('@walletconnect/ethereum-provider');
|
|
7
|
-
var viem = require('viem');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
10
|
-
var utils = require('@dynamic-labs/utils');
|
|
11
6
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
12
|
-
var constants = require('../constants.cjs');
|
|
13
|
-
var client = require('./client/client.cjs');
|
|
14
|
-
|
|
15
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
-
|
|
17
|
-
var WalletConnectProvider__default = /*#__PURE__*/_interopDefaultLegacy(WalletConnectProvider);
|
|
18
7
|
|
|
19
8
|
class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
20
9
|
constructor(_a) {
|
|
21
|
-
var {
|
|
10
|
+
var { walletName } = _a, props = _tslib.__rest(_a, ["walletName"]);
|
|
22
11
|
super(props);
|
|
23
12
|
this.supportedChains = ['EVM', 'ETH'];
|
|
24
13
|
this.connectedChain = 'EVM';
|
|
25
14
|
this.bridge = 'https://bridge.walletconnect.org';
|
|
26
|
-
this.canConnectViaQrCode = true;
|
|
27
|
-
this.isWalletConnect = true;
|
|
28
|
-
this.switchNetworkOnlyFromWallet = false;
|
|
29
15
|
this.name = walletName;
|
|
30
|
-
if (walletConnectV1Bridge) {
|
|
31
|
-
this.bridge = walletConnectV1Bridge;
|
|
32
|
-
}
|
|
33
|
-
this.deepLinkPreference = props.deepLinkPreference || 'native';
|
|
34
|
-
}
|
|
35
|
-
getClient() {
|
|
36
|
-
if (this.client) {
|
|
37
|
-
return this.client;
|
|
38
|
-
}
|
|
39
|
-
this.client = client.initClient(this.key, this.bridge, this.clientOptions);
|
|
40
|
-
return this.client;
|
|
41
|
-
}
|
|
42
|
-
supportsNetworkSwitching() {
|
|
43
|
-
if (this.connectedChain === 'EVM') {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
const client = this.getClient();
|
|
48
|
-
return Boolean(client === null || client === void 0 ? void 0 : client.chainId);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
setupEventListeners() {
|
|
52
|
-
client.setupWalletConnectEventListeners(this, this.getClient());
|
|
53
|
-
}
|
|
54
|
-
teardownEventListeners() {
|
|
55
|
-
client.teardownWalletConnectEventListeners(this.getClient());
|
|
56
16
|
}
|
|
57
17
|
getWalletClient() {
|
|
58
|
-
|
|
59
|
-
return client
|
|
60
|
-
? viem.createWalletClient({
|
|
61
|
-
transport: viem.custom(new WalletConnectProvider__default["default"]({
|
|
62
|
-
connector: client,
|
|
63
|
-
infuraId: constants.INFURA_ID,
|
|
64
|
-
rpc: this.evmNetworkRpcMap(),
|
|
65
|
-
})),
|
|
66
|
-
})
|
|
67
|
-
: undefined;
|
|
68
|
-
}
|
|
69
|
-
fetchPublicAddress(opts) {
|
|
70
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
return client.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference, Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
|
|
72
|
-
var _a, _b;
|
|
73
|
-
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
74
|
-
this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
|
|
75
|
-
if ((_b = payload.params[0].accounts) === null || _b === void 0 ? void 0 : _b.length) {
|
|
76
|
-
this.emit('accountChange', {
|
|
77
|
-
accounts: payload.params[0].accounts,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
} }));
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
getDeepLink() {
|
|
84
|
-
var _a;
|
|
85
|
-
const wallet = walletBook.getWalletBookWallet(this.walletBook, this.key);
|
|
86
|
-
if (!utils.isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
return walletConnectorCore.getDeepLink({
|
|
90
|
-
metadata: wallet,
|
|
91
|
-
mode: 'regular',
|
|
92
|
-
preference: this.deepLinkPreference,
|
|
93
|
-
uri: this.getClient().uri,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
signMessage(messageToSign) {
|
|
97
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
return client.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.walletBook, this.key), this.getClient(), this.deepLinkPreference,
|
|
99
|
-
// don't call getPublicClient until we really need to
|
|
100
|
-
() => _tslib.__awaiter(this, void 0, void 0, function* () { return this.getPublicClient(); }));
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
endSession() {
|
|
104
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
client.killWalletConnectSession(this.getClient());
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
providerSwitchNetwork({ network, provider, }) {
|
|
109
|
-
const _super = Object.create(null, {
|
|
110
|
-
providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
|
|
111
|
-
});
|
|
112
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const client = this.getClient();
|
|
114
|
-
const currentNetworkId = yield this.getNetwork();
|
|
115
|
-
if (currentNetworkId && currentNetworkId === network.chainId) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (this.switchNetworkOnlyFromWallet !== undefined &&
|
|
119
|
-
this.switchNetworkOnlyFromWallet) {
|
|
120
|
-
throw new utils.DynamicError('Network switching is only supported through the wallet');
|
|
121
|
-
}
|
|
122
|
-
if (!this.supportsNetworkSwitching()) {
|
|
123
|
-
throw new utils.DynamicError('Network switching not supported');
|
|
124
|
-
}
|
|
125
|
-
if (!client) {
|
|
126
|
-
throw new utils.DynamicError('Client not found');
|
|
127
|
-
}
|
|
128
|
-
if (utils.isMobile()) {
|
|
129
|
-
const deepLink = walletConnectorCore.getDeepLink({
|
|
130
|
-
metadata: walletBook.getWalletBookWallet(this.walletBook, this.key),
|
|
131
|
-
mode: 'regular',
|
|
132
|
-
preference: this.deepLinkPreference,
|
|
133
|
-
uri: client.uri,
|
|
134
|
-
});
|
|
135
|
-
window.location.href = deepLink;
|
|
136
|
-
}
|
|
137
|
-
return _super.providerSwitchNetwork.call(this, { network, provider });
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
getConnectedAccounts() {
|
|
141
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
const client = this.getClient();
|
|
143
|
-
if (!client.connected)
|
|
144
|
-
return [];
|
|
145
|
-
return client.accounts;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
getSession() {
|
|
149
|
-
var _a;
|
|
150
|
-
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
return (_a = this.client) === null || _a === void 0 ? void 0 : _a.session;
|
|
152
|
-
});
|
|
18
|
+
return undefined;
|
|
153
19
|
}
|
|
154
20
|
}
|
|
155
21
|
|
|
@@ -1,52 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Hex, WalletClient } from 'viem';
|
|
3
|
-
import { Chain, FetchPublicAddressOpts, DeepLinkVariant } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import { EvmNetwork } from '@dynamic-labs/types';
|
|
1
|
+
import { Chain } from '@dynamic-labs/wallet-connector-core';
|
|
5
2
|
import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
6
|
-
type ConnectorSession = {
|
|
7
|
-
connected: boolean;
|
|
8
|
-
accounts: string[];
|
|
9
|
-
chainId: number;
|
|
10
|
-
bridge: string;
|
|
11
|
-
key: string;
|
|
12
|
-
clientId: string;
|
|
13
|
-
clientMeta: any;
|
|
14
|
-
peerId: string;
|
|
15
|
-
peerMeta: any;
|
|
16
|
-
handshakeId: number;
|
|
17
|
-
handshakeTopic: string;
|
|
18
|
-
};
|
|
19
3
|
export type WalletConnectOpts = EthWalletConnectorOpts & {
|
|
20
|
-
walletConnectV1Bridge: string;
|
|
21
4
|
walletName: string;
|
|
22
|
-
deepLinkPreference?: DeepLinkVariant;
|
|
23
5
|
};
|
|
24
6
|
export declare class WalletConnect extends EthWalletConnector {
|
|
25
7
|
supportedChains: Chain[];
|
|
26
8
|
connectedChain: Chain;
|
|
27
9
|
name: string;
|
|
28
10
|
bridge: string;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
switchNetworkOnlyFromWallet: boolean;
|
|
32
|
-
private deepLinkPreference;
|
|
33
|
-
client?: Client;
|
|
34
|
-
clientOptions?: any;
|
|
35
|
-
constructor({ walletConnectV1Bridge, walletName, ...props }: WalletConnectOpts);
|
|
36
|
-
getClient(): Client;
|
|
37
|
-
supportsNetworkSwitching(): boolean;
|
|
38
|
-
setupEventListeners(): void;
|
|
39
|
-
teardownEventListeners(): void;
|
|
40
|
-
getWalletClient(): WalletClient | undefined;
|
|
41
|
-
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
|
|
42
|
-
getDeepLink(): string | undefined;
|
|
43
|
-
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
44
|
-
endSession(): Promise<void>;
|
|
45
|
-
providerSwitchNetwork({ network, provider, }: {
|
|
46
|
-
network: EvmNetwork;
|
|
47
|
-
provider: WalletClient;
|
|
48
|
-
}): Promise<void>;
|
|
49
|
-
getConnectedAccounts(): Promise<Hex[]>;
|
|
50
|
-
getSession(): Promise<ConnectorSession | undefined>;
|
|
11
|
+
constructor({ walletName, ...props }: WalletConnectOpts);
|
|
12
|
+
getWalletClient(): undefined;
|
|
51
13
|
}
|
|
52
|
-
export {};
|