@dynamic-labs/ethereum 4.0.0-alpha.38 → 4.0.0-alpha.39
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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/ethProviderHelper.cjs +7 -13
- package/src/ethProviderHelper.d.ts +3 -5
- package/src/ethProviderHelper.js +7 -13
- package/src/injected/InjectedWalletBase.cjs +12 -23
- package/src/injected/InjectedWalletBase.d.ts +2 -74
- package/src/injected/InjectedWalletBase.js +12 -23
- package/src/injected/PhantomEvm.cjs +1 -1
- package/src/injected/PhantomEvm.js +1 -1
- package/src/injected/fetchInjectedWalletConnectors.cjs +0 -3
- package/src/injected/fetchInjectedWalletConnectors.js +0 -3
- package/src/metaMask/MetaMaskConnector.cjs +7 -29
- package/src/metaMask/MetaMaskConnector.d.ts +3 -9
- package/src/metaMask/MetaMaskConnector.js +8 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.39](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.38...v4.0.0-alpha.39) (2024-12-02)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* remove usages of findWalletBookWallet when possible (#7455)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* sdkHasLoaded always false in cookie enabled env ([#7516](https://github.com/dynamic-labs/dynamic-auth/issues/7516)) ([1c3335c](https://github.com/dynamic-labs/dynamic-auth/commit/1c3335c13930e9bffe60cf1c09bc9c9584a59ef7))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* remove usages of findWalletBookWallet when possible ([#7455](https://github.com/dynamic-labs/dynamic-auth/issues/7455)) ([0ce977d](https://github.com/dynamic-labs/dynamic-auth/commit/0ce977d5d4d591c371c6ea2edfb252ba7acff5d2))
|
|
15
|
+
|
|
2
16
|
## [4.0.0-alpha.38](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.37...v4.0.0-alpha.38) (2024-11-27)
|
|
3
17
|
|
|
4
18
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.39",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"eventemitter3": "5.0.1",
|
|
25
25
|
"buffer": "6.0.3",
|
|
26
26
|
"@metamask/sdk": "0.30.1",
|
|
27
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/embedded-wallet-evm": "4.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/ethereum-core": "4.0.0-alpha.
|
|
30
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
31
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
32
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
33
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
27
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.39",
|
|
28
|
+
"@dynamic-labs/embedded-wallet-evm": "4.0.0-alpha.39",
|
|
29
|
+
"@dynamic-labs/ethereum-core": "4.0.0-alpha.39",
|
|
30
|
+
"@dynamic-labs/logger": "4.0.0-alpha.39",
|
|
31
|
+
"@dynamic-labs/types": "4.0.0-alpha.39",
|
|
32
|
+
"@dynamic-labs/utils": "4.0.0-alpha.39",
|
|
33
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.39",
|
|
34
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.39"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"viem": "^2.7.6"
|
|
@@ -6,19 +6,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
7
|
var viem = require('viem');
|
|
8
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
10
|
var utils = require('@dynamic-labs/utils');
|
|
10
11
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
11
12
|
|
|
12
13
|
class EthProviderHelper {
|
|
13
|
-
constructor(
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
}
|
|
17
|
-
get connector() {
|
|
18
|
-
if (!this._connector) {
|
|
19
|
-
throw new Error('Connect not provided to EthProviderHelper');
|
|
20
|
-
}
|
|
21
|
-
return this._connector;
|
|
14
|
+
constructor(connector) {
|
|
15
|
+
this.walletBookWallet = walletBook.findWalletBookWallet(connector.walletBook, connector.key);
|
|
16
|
+
this.connector = connector;
|
|
22
17
|
}
|
|
23
18
|
getInstalledProvider() {
|
|
24
19
|
const eip6963Provider = this.getEip6963Provider();
|
|
@@ -43,10 +38,9 @@ class EthProviderHelper {
|
|
|
43
38
|
return this.eip6963ProviderLookup(rdns);
|
|
44
39
|
}
|
|
45
40
|
getInjectedConfig() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return injectedConfig.find((c) => c.chain === 'evm');
|
|
41
|
+
var _a;
|
|
42
|
+
const injectedConfig = (_a = this.walletBookWallet) === null || _a === void 0 ? void 0 : _a.injectedConfig;
|
|
43
|
+
return injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.find((c) => c.chain === 'evm');
|
|
50
44
|
}
|
|
51
45
|
installedProviders() {
|
|
52
46
|
const config = this.getInjectedConfig();
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Hex, WalletClient, Account, Transport, Chain as ViemChain } from 'viem';
|
|
2
2
|
import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
4
3
|
import { IEthereum, ExtensionLocator } from './types';
|
|
5
4
|
import { InjectedWalletBase } from './injected/InjectedWalletBase';
|
|
6
5
|
export declare class EthProviderHelper {
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
constructor(
|
|
10
|
-
private get connector();
|
|
6
|
+
private walletBookWallet;
|
|
7
|
+
private connector;
|
|
8
|
+
constructor(connector: InjectedWalletBase);
|
|
11
9
|
getInstalledProvider(): IEthereum | undefined;
|
|
12
10
|
getInjectedProvider(): IEthereum | undefined;
|
|
13
11
|
getEip6963Provider(): IEthereum | undefined;
|
package/src/ethProviderHelper.js
CHANGED
|
@@ -2,19 +2,14 @@
|
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
3
|
import { createWalletClient, custom, getAddress } from 'viem';
|
|
4
4
|
import { ProviderLookup, logger, eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
6
|
import { getProvidersFromWindow, Eip6963ProviderSingleton } from '@dynamic-labs/utils';
|
|
6
7
|
import { chainsMap } from '@dynamic-labs/ethereum-core';
|
|
7
8
|
|
|
8
9
|
class EthProviderHelper {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
}
|
|
13
|
-
get connector() {
|
|
14
|
-
if (!this._connector) {
|
|
15
|
-
throw new Error('Connect not provided to EthProviderHelper');
|
|
16
|
-
}
|
|
17
|
-
return this._connector;
|
|
10
|
+
constructor(connector) {
|
|
11
|
+
this.walletBookWallet = findWalletBookWallet(connector.walletBook, connector.key);
|
|
12
|
+
this.connector = connector;
|
|
18
13
|
}
|
|
19
14
|
getInstalledProvider() {
|
|
20
15
|
const eip6963Provider = this.getEip6963Provider();
|
|
@@ -39,10 +34,9 @@ class EthProviderHelper {
|
|
|
39
34
|
return this.eip6963ProviderLookup(rdns);
|
|
40
35
|
}
|
|
41
36
|
getInjectedConfig() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return injectedConfig.find((c) => c.chain === 'evm');
|
|
37
|
+
var _a;
|
|
38
|
+
const injectedConfig = (_a = this.walletBookWallet) === null || _a === void 0 ? void 0 : _a.injectedConfig;
|
|
39
|
+
return injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.find((c) => c.chain === 'evm');
|
|
46
40
|
}
|
|
47
41
|
installedProviders() {
|
|
48
42
|
const config = this.getInjectedConfig();
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
7
|
var utils = require('@dynamic-labs/utils');
|
|
9
8
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
10
9
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
@@ -15,18 +14,11 @@ class InjectedWalletBase extends ethereumCore.EthereumWalletConnector {
|
|
|
15
14
|
super(...arguments);
|
|
16
15
|
this.walletConnectorFallback = false;
|
|
17
16
|
}
|
|
18
|
-
get
|
|
19
|
-
if (!this.
|
|
20
|
-
this.
|
|
17
|
+
get ethProviderHelper() {
|
|
18
|
+
if (!this._ethProviderHelper) {
|
|
19
|
+
this._ethProviderHelper = new ethProviderHelper.EthProviderHelper(this);
|
|
21
20
|
}
|
|
22
|
-
return this.
|
|
23
|
-
}
|
|
24
|
-
getEthProviderHelper() {
|
|
25
|
-
if (this.wallet && !this.ethProviderHelper) {
|
|
26
|
-
this.ethProviderHelper = new ethProviderHelper.EthProviderHelper(this.wallet, this);
|
|
27
|
-
}
|
|
28
|
-
// this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
|
|
29
|
-
return this.ethProviderHelper;
|
|
21
|
+
return this._ethProviderHelper;
|
|
30
22
|
}
|
|
31
23
|
getMobileOrInstalledWallet() {
|
|
32
24
|
var _a;
|
|
@@ -50,33 +42,30 @@ class InjectedWalletBase extends ethereumCore.EthereumWalletConnector {
|
|
|
50
42
|
return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
51
43
|
}
|
|
52
44
|
findProvider() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return;
|
|
56
|
-
return ethProviderHelper.getInstalledProvider();
|
|
45
|
+
var _a;
|
|
46
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getInstalledProvider();
|
|
57
47
|
}
|
|
58
48
|
setupEventListeners() {
|
|
59
49
|
const provider = this.getWalletClient();
|
|
60
50
|
if (!provider)
|
|
61
51
|
return;
|
|
62
|
-
|
|
63
|
-
if (!ethProviderHelper)
|
|
52
|
+
if (!this.ethProviderHelper)
|
|
64
53
|
return;
|
|
65
|
-
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
54
|
+
const { tearDownEventListeners } = this.ethProviderHelper._setupEventListeners(this);
|
|
66
55
|
this.teardownEventListeners = tearDownEventListeners;
|
|
67
56
|
}
|
|
68
57
|
getWalletClient(chainId) {
|
|
69
58
|
var _a;
|
|
70
|
-
return (_a = this.
|
|
59
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
71
60
|
}
|
|
72
61
|
isInstalledOnBrowser() {
|
|
73
62
|
var _a;
|
|
74
|
-
return ((_a = this.
|
|
63
|
+
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
75
64
|
}
|
|
76
65
|
getAddress() {
|
|
77
66
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
78
67
|
var _a;
|
|
79
|
-
return (_a = this.
|
|
68
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
80
69
|
});
|
|
81
70
|
}
|
|
82
71
|
connect() {
|
|
@@ -87,7 +76,7 @@ class InjectedWalletBase extends ethereumCore.EthereumWalletConnector {
|
|
|
87
76
|
signMessage(messageToSign) {
|
|
88
77
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
89
78
|
var _a;
|
|
90
|
-
return (_a = this.
|
|
79
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
91
80
|
});
|
|
92
81
|
}
|
|
93
82
|
proveOwnership(address, messageToSign) {
|
|
@@ -1,85 +1,13 @@
|
|
|
1
1
|
import { WalletClient, Transport, Account, Chain as ViemChain } from 'viem';
|
|
2
2
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
3
|
-
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
4
3
|
import { EthereumWalletConnector } from '@dynamic-labs/ethereum-core';
|
|
5
4
|
import { EthProviderHelper } from '../ethProviderHelper';
|
|
6
5
|
import { IEthereum } from '../types';
|
|
7
6
|
export declare abstract class InjectedWalletBase extends EthereumWalletConnector {
|
|
8
7
|
publicAddress: string | undefined;
|
|
9
8
|
walletConnectorFallback: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
get wallet(): {
|
|
13
|
-
name: string;
|
|
14
|
-
brand?: {
|
|
15
|
-
alt?: string | undefined;
|
|
16
|
-
primaryColor?: string | undefined;
|
|
17
|
-
spriteId?: string | undefined;
|
|
18
|
-
} | undefined;
|
|
19
|
-
chainGroup?: string | undefined;
|
|
20
|
-
chains?: string[] | undefined;
|
|
21
|
-
desktop?: {
|
|
22
|
-
chromeId?: string | undefined;
|
|
23
|
-
edgeId?: string | undefined;
|
|
24
|
-
firefoxId?: string | undefined;
|
|
25
|
-
native?: string | undefined;
|
|
26
|
-
operaId?: string | undefined;
|
|
27
|
-
safariId?: string | undefined;
|
|
28
|
-
universal?: string | undefined;
|
|
29
|
-
} | undefined;
|
|
30
|
-
eip6963Config?: {
|
|
31
|
-
rdns: string;
|
|
32
|
-
} | undefined;
|
|
33
|
-
filterFromWalletConnect?: boolean | undefined;
|
|
34
|
-
group?: string | undefined;
|
|
35
|
-
hardwareWallets?: string[] | undefined;
|
|
36
|
-
injectedConfig?: {
|
|
37
|
-
chain: string;
|
|
38
|
-
extensionLocators: {
|
|
39
|
-
value: boolean;
|
|
40
|
-
flag: string;
|
|
41
|
-
}[];
|
|
42
|
-
providerInterface?: string | undefined;
|
|
43
|
-
walletStandard?: {
|
|
44
|
-
features: string[];
|
|
45
|
-
name: string;
|
|
46
|
-
providerId?: string | undefined;
|
|
47
|
-
} | undefined;
|
|
48
|
-
walletStandardLocators?: {
|
|
49
|
-
name: string;
|
|
50
|
-
locator: string;
|
|
51
|
-
}[] | undefined;
|
|
52
|
-
windowLocations?: string[] | undefined;
|
|
53
|
-
}[] | undefined;
|
|
54
|
-
mobile?: {
|
|
55
|
-
android?: string | null | undefined;
|
|
56
|
-
androidId?: string | undefined;
|
|
57
|
-
inAppBrowser?: string | null | undefined;
|
|
58
|
-
ios?: string | null | undefined;
|
|
59
|
-
iosId?: string | undefined;
|
|
60
|
-
native?: string | undefined;
|
|
61
|
-
universal?: string | undefined;
|
|
62
|
-
} | undefined;
|
|
63
|
-
mobileExperience?: "in-app-browser" | "redirect" | undefined;
|
|
64
|
-
shortName?: string | undefined;
|
|
65
|
-
showOnlyIfInstalled?: boolean | undefined;
|
|
66
|
-
switchNetworkOnlyFromWallet?: boolean | undefined;
|
|
67
|
-
walletConnect?: {
|
|
68
|
-
sdks?: string[] | undefined;
|
|
69
|
-
} | undefined;
|
|
70
|
-
walletGroup?: string | undefined;
|
|
71
|
-
walletLimitations?: {
|
|
72
|
-
browserExtension?: {
|
|
73
|
-
unsupportedEvents?: string[] | undefined;
|
|
74
|
-
unsupportedMethods?: string[] | undefined;
|
|
75
|
-
} | undefined;
|
|
76
|
-
mobile?: {
|
|
77
|
-
unsupportedEvents?: string[] | undefined;
|
|
78
|
-
unsupportedMethods?: string[] | undefined;
|
|
79
|
-
} | undefined;
|
|
80
|
-
} | undefined;
|
|
81
|
-
} | undefined;
|
|
82
|
-
getEthProviderHelper(): EthProviderHelper | undefined;
|
|
9
|
+
_ethProviderHelper: EthProviderHelper | undefined;
|
|
10
|
+
get ethProviderHelper(): EthProviderHelper | undefined;
|
|
83
11
|
getMobileOrInstalledWallet(): InjectedWalletBase;
|
|
84
12
|
findProvider(): IEthereum | undefined;
|
|
85
13
|
setupEventListeners(): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
-
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
4
3
|
import { isMobile } from '@dynamic-labs/utils';
|
|
5
4
|
import { EthereumWalletConnector } from '@dynamic-labs/ethereum-core';
|
|
6
5
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
@@ -11,18 +10,11 @@ class InjectedWalletBase extends EthereumWalletConnector {
|
|
|
11
10
|
super(...arguments);
|
|
12
11
|
this.walletConnectorFallback = false;
|
|
13
12
|
}
|
|
14
|
-
get
|
|
15
|
-
if (!this.
|
|
16
|
-
this.
|
|
13
|
+
get ethProviderHelper() {
|
|
14
|
+
if (!this._ethProviderHelper) {
|
|
15
|
+
this._ethProviderHelper = new EthProviderHelper(this);
|
|
17
16
|
}
|
|
18
|
-
return this.
|
|
19
|
-
}
|
|
20
|
-
getEthProviderHelper() {
|
|
21
|
-
if (this.wallet && !this.ethProviderHelper) {
|
|
22
|
-
this.ethProviderHelper = new EthProviderHelper(this.wallet, this);
|
|
23
|
-
}
|
|
24
|
-
// this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
|
|
25
|
-
return this.ethProviderHelper;
|
|
17
|
+
return this._ethProviderHelper;
|
|
26
18
|
}
|
|
27
19
|
getMobileOrInstalledWallet() {
|
|
28
20
|
var _a;
|
|
@@ -46,33 +38,30 @@ class InjectedWalletBase extends EthereumWalletConnector {
|
|
|
46
38
|
return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
47
39
|
}
|
|
48
40
|
findProvider() {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
return ethProviderHelper.getInstalledProvider();
|
|
41
|
+
var _a;
|
|
42
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getInstalledProvider();
|
|
53
43
|
}
|
|
54
44
|
setupEventListeners() {
|
|
55
45
|
const provider = this.getWalletClient();
|
|
56
46
|
if (!provider)
|
|
57
47
|
return;
|
|
58
|
-
|
|
59
|
-
if (!ethProviderHelper)
|
|
48
|
+
if (!this.ethProviderHelper)
|
|
60
49
|
return;
|
|
61
|
-
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
50
|
+
const { tearDownEventListeners } = this.ethProviderHelper._setupEventListeners(this);
|
|
62
51
|
this.teardownEventListeners = tearDownEventListeners;
|
|
63
52
|
}
|
|
64
53
|
getWalletClient(chainId) {
|
|
65
54
|
var _a;
|
|
66
|
-
return (_a = this.
|
|
55
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
67
56
|
}
|
|
68
57
|
isInstalledOnBrowser() {
|
|
69
58
|
var _a;
|
|
70
|
-
return ((_a = this.
|
|
59
|
+
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
71
60
|
}
|
|
72
61
|
getAddress() {
|
|
73
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
63
|
var _a;
|
|
75
|
-
return (_a = this.
|
|
64
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
76
65
|
});
|
|
77
66
|
}
|
|
78
67
|
connect() {
|
|
@@ -83,7 +72,7 @@ class InjectedWalletBase extends EthereumWalletConnector {
|
|
|
83
72
|
signMessage(messageToSign) {
|
|
84
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
74
|
var _a;
|
|
86
|
-
return (_a = this.
|
|
75
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.signMessage(messageToSign);
|
|
87
76
|
});
|
|
88
77
|
}
|
|
89
78
|
proveOwnership(address, messageToSign) {
|
|
@@ -32,7 +32,7 @@ class PhantomEvm extends InjectedWalletBase.InjectedWalletBase {
|
|
|
32
32
|
}
|
|
33
33
|
canGetChainAddress() {
|
|
34
34
|
var _a, _b;
|
|
35
|
-
return Boolean((_b = (_a = this.
|
|
35
|
+
return Boolean((_b = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) === null || _b === void 0 ? void 0 : _b.selectedAddress);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -28,7 +28,7 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
28
28
|
}
|
|
29
29
|
canGetChainAddress() {
|
|
30
30
|
var _a, _b;
|
|
31
|
-
return Boolean((_b = (_a = this.
|
|
31
|
+
return Boolean((_b = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) === null || _b === void 0 ? void 0 : _b.selectedAddress);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -42,9 +42,6 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
42
42
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
43
43
|
this.overrideKey = key;
|
|
44
44
|
}
|
|
45
|
-
get wallet() {
|
|
46
|
-
return wallet;
|
|
47
|
-
}
|
|
48
45
|
getAddress() {
|
|
49
46
|
const _super = Object.create(null, {
|
|
50
47
|
getAddress: { get: () => super.getAddress }
|
|
@@ -38,9 +38,6 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
38
38
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
39
39
|
this.overrideKey = key;
|
|
40
40
|
}
|
|
41
|
-
get wallet() {
|
|
42
|
-
return wallet;
|
|
43
|
-
}
|
|
44
41
|
getAddress() {
|
|
45
42
|
const _super = Object.create(null, {
|
|
46
43
|
getAddress: { get: () => super.getAddress }
|
|
@@ -9,9 +9,8 @@ var viem = require('viem');
|
|
|
9
9
|
var ethereumCore = require('@dynamic-labs/ethereum-core');
|
|
10
10
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
11
11
|
var utils = require('@dynamic-labs/utils');
|
|
12
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
13
12
|
var logger = require('../utils/logger.cjs');
|
|
14
|
-
var
|
|
13
|
+
var InjectedWalletBase = require('../injected/InjectedWalletBase.cjs');
|
|
15
14
|
var createMetaMaskSDKDisplayUriState = require('./utils/createMetaMaskSDKDisplayUriState.cjs');
|
|
16
15
|
var waitForConnection = require('./utils/waitForConnection.cjs');
|
|
17
16
|
var isPendingWalletRequestPermissionError = require('./utils/isPendingWalletRequestPermissionError.cjs');
|
|
@@ -23,7 +22,7 @@ var isPendingWalletRequestPermissionError = require('./utils/isPendingWalletRequ
|
|
|
23
22
|
let _metaMaskSDK = null;
|
|
24
23
|
let _metaMaskSDKDisplayUriState = null;
|
|
25
24
|
const eventTimeline = utils.createEventTimeline();
|
|
26
|
-
class MetaMaskConnector extends
|
|
25
|
+
class MetaMaskConnector extends InjectedWalletBase.InjectedWalletBase {
|
|
27
26
|
constructor(props) {
|
|
28
27
|
super(props);
|
|
29
28
|
this.name = 'MetaMask';
|
|
@@ -54,9 +53,6 @@ class MetaMaskConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
54
53
|
return this.evmNetworks.map((network) => network.chainId.toString());
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
|
-
get ethProviderHelper() {
|
|
58
|
-
return new ethProviderHelper.EthProviderHelper(walletBook.getWalletBookWallet(this.walletBook, this.key));
|
|
59
|
-
}
|
|
60
56
|
get metaMaskSDK() {
|
|
61
57
|
if (!_metaMaskSDK)
|
|
62
58
|
throw new Error('MetaMaskSDK not initialized');
|
|
@@ -114,7 +110,6 @@ class MetaMaskConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
114
110
|
getAddress(opts) {
|
|
115
111
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
116
112
|
return new Promise((resolve, reject) => {
|
|
117
|
-
var _a, _b, _c, _d;
|
|
118
113
|
// QR Code flow
|
|
119
114
|
if (!utils.isMobile() && Boolean(opts === null || opts === void 0 ? void 0 : opts.onDisplayUri)) {
|
|
120
115
|
this.metaMaskSDKDisplayUriState
|
|
@@ -130,9 +125,9 @@ class MetaMaskConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
130
125
|
}
|
|
131
126
|
// Deep link to MetaMask app in-app browser
|
|
132
127
|
if (this.shouldDeepLinkToMetaMaskInAppBrowser() &&
|
|
133
|
-
|
|
128
|
+
this.metadata.inAppBrowserUrl) {
|
|
134
129
|
// Redirect to the in-app browser and append the current url
|
|
135
|
-
window.location.href = `${
|
|
130
|
+
window.location.href = `${this.metadata.inAppBrowserUrl}/${window.location.href}`;
|
|
136
131
|
resolve(undefined);
|
|
137
132
|
return;
|
|
138
133
|
}
|
|
@@ -248,12 +243,6 @@ class MetaMaskConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
248
243
|
}
|
|
249
244
|
return rdns;
|
|
250
245
|
}
|
|
251
|
-
isInstalledOnBrowser() {
|
|
252
|
-
var _a;
|
|
253
|
-
const metaMaskEip6963Provider = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.eip6963ProviderLookup(this.rdns);
|
|
254
|
-
const isInstalled = Boolean(metaMaskEip6963Provider);
|
|
255
|
-
return isInstalled;
|
|
256
|
-
}
|
|
257
246
|
setupEventListeners() {
|
|
258
247
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
259
248
|
yield this.metaMaskSDK.sdkInitPromise;
|
|
@@ -355,15 +344,11 @@ class MetaMaskConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
355
344
|
* on a mobile device
|
|
356
345
|
*/
|
|
357
346
|
getIsInAppBrowser() {
|
|
358
|
-
var _a, _b;
|
|
359
347
|
if (!utils.isMobile())
|
|
360
348
|
return false;
|
|
361
|
-
|
|
362
|
-
((_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b.getInjectedProvider());
|
|
363
|
-
return Boolean(provider);
|
|
349
|
+
return this.isInstalledOnBrowser();
|
|
364
350
|
}
|
|
365
351
|
shouldDeepLinkToMetaMaskInAppBrowser() {
|
|
366
|
-
var _a;
|
|
367
352
|
// Not in an in-app browser
|
|
368
353
|
if (this.isInAppBrowser)
|
|
369
354
|
return false;
|
|
@@ -373,18 +358,11 @@ class MetaMaskConnector extends ethereumCore.EthereumWalletConnector {
|
|
|
373
358
|
// SDK is configured to use the in-app browser
|
|
374
359
|
if (this.mobileExperience !== 'in-app-browser')
|
|
375
360
|
return false;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (!isAppBrowserLinkPresent)
|
|
361
|
+
// Wallet does not have an in-app browser link
|
|
362
|
+
if (!this.metadata.inAppBrowserUrl)
|
|
379
363
|
return false;
|
|
380
364
|
return true;
|
|
381
365
|
}
|
|
382
|
-
/**
|
|
383
|
-
* Get wallet book wallet information
|
|
384
|
-
*/
|
|
385
|
-
get wallet() {
|
|
386
|
-
return walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
387
|
-
}
|
|
388
366
|
}
|
|
389
367
|
// Utils
|
|
390
368
|
const getReadonlyRPCMap = (evmNetworkRpcMap) => Object.keys(evmNetworkRpcMap).reduce((acc, chainId) => (Object.assign(Object.assign({}, acc), { [viem.toHex(parseInt(chainId))]: evmNetworkRpcMap[chainId] })), {});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { MetaMaskSDK } from '@metamask/sdk';
|
|
2
2
|
import { Account, Transport, WalletClient, Chain as ViemChain } from 'viem';
|
|
3
|
-
import {
|
|
3
|
+
import { EthereumWalletConnectorOpts } from '@dynamic-labs/ethereum-core';
|
|
4
4
|
import { GetAddressOpts, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import {
|
|
5
|
+
import { InjectedWalletBase } from '../injected/InjectedWalletBase';
|
|
6
6
|
import { MetaMaskSDKDisplayUriState } from './utils/createMetaMaskSDKDisplayUriState';
|
|
7
7
|
export type MetaMaskConnectorProps = EthereumWalletConnectorOpts & {
|
|
8
8
|
appName: string;
|
|
9
9
|
appLogoUrl: string;
|
|
10
10
|
};
|
|
11
11
|
export declare const clearMetaMaskSdk: () => void;
|
|
12
|
-
export declare class MetaMaskConnector extends
|
|
12
|
+
export declare class MetaMaskConnector extends InjectedWalletBase implements IWalletConnectConnector {
|
|
13
13
|
name: string;
|
|
14
14
|
overrideKey: string;
|
|
15
15
|
canConnectViaQrCode: boolean;
|
|
@@ -18,7 +18,6 @@ export declare class MetaMaskConnector extends EthereumWalletConnector implement
|
|
|
18
18
|
private isInAppBrowser;
|
|
19
19
|
constructor(props: MetaMaskConnectorProps);
|
|
20
20
|
getSupportedNetworks(): Promise<string[]>;
|
|
21
|
-
get ethProviderHelper(): EthProviderHelper | undefined;
|
|
22
21
|
get metaMaskSDK(): MetaMaskSDK;
|
|
23
22
|
set metaMaskSDK(metaMaskSDK: MetaMaskSDK);
|
|
24
23
|
get metaMaskSDKDisplayUriState(): MetaMaskSDKDisplayUriState;
|
|
@@ -31,7 +30,6 @@ export declare class MetaMaskConnector extends EthereumWalletConnector implement
|
|
|
31
30
|
chooseAccountsToConnect(): Promise<never[]>;
|
|
32
31
|
getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
|
|
33
32
|
get rdns(): string;
|
|
34
|
-
isInstalledOnBrowser(): boolean;
|
|
35
33
|
setupEventListeners(): Promise<void>;
|
|
36
34
|
/**
|
|
37
35
|
* This override is necessary to wait for the MetaMask SDK to initialize
|
|
@@ -51,8 +49,4 @@ export declare class MetaMaskConnector extends EthereumWalletConnector implement
|
|
|
51
49
|
*/
|
|
52
50
|
private getIsInAppBrowser;
|
|
53
51
|
private shouldDeepLinkToMetaMaskInAppBrowser;
|
|
54
|
-
/**
|
|
55
|
-
* Get wallet book wallet information
|
|
56
|
-
*/
|
|
57
|
-
private get wallet();
|
|
58
52
|
}
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { MetaMaskSDK } from '@metamask/sdk';
|
|
4
4
|
import { createWalletClient, custom, isHex, toHex } from 'viem';
|
|
5
|
-
import {
|
|
5
|
+
import { getOrMapViemChain } from '@dynamic-labs/ethereum-core';
|
|
6
6
|
import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import { createEventTimeline, PlatformService, isMobile, retryableFn } from '@dynamic-labs/utils';
|
|
8
|
-
import { getWalletBookWallet, findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
9
8
|
import { logger } from '../utils/logger.js';
|
|
10
|
-
import {
|
|
9
|
+
import { InjectedWalletBase } from '../injected/InjectedWalletBase.js';
|
|
11
10
|
import { createMetaMaskSDKDisplayUriState } from './utils/createMetaMaskSDKDisplayUriState.js';
|
|
12
11
|
import { waitForConnection } from './utils/waitForConnection.js';
|
|
13
12
|
import { isPendingWalletRequestPermissionError } from './utils/isPendingWalletRequestPermissionError.js';
|
|
@@ -19,7 +18,7 @@ import { isPendingWalletRequestPermissionError } from './utils/isPendingWalletRe
|
|
|
19
18
|
let _metaMaskSDK = null;
|
|
20
19
|
let _metaMaskSDKDisplayUriState = null;
|
|
21
20
|
const eventTimeline = createEventTimeline();
|
|
22
|
-
class MetaMaskConnector extends
|
|
21
|
+
class MetaMaskConnector extends InjectedWalletBase {
|
|
23
22
|
constructor(props) {
|
|
24
23
|
super(props);
|
|
25
24
|
this.name = 'MetaMask';
|
|
@@ -50,9 +49,6 @@ class MetaMaskConnector extends EthereumWalletConnector {
|
|
|
50
49
|
return this.evmNetworks.map((network) => network.chainId.toString());
|
|
51
50
|
});
|
|
52
51
|
}
|
|
53
|
-
get ethProviderHelper() {
|
|
54
|
-
return new EthProviderHelper(getWalletBookWallet(this.walletBook, this.key));
|
|
55
|
-
}
|
|
56
52
|
get metaMaskSDK() {
|
|
57
53
|
if (!_metaMaskSDK)
|
|
58
54
|
throw new Error('MetaMaskSDK not initialized');
|
|
@@ -110,7 +106,6 @@ class MetaMaskConnector extends EthereumWalletConnector {
|
|
|
110
106
|
getAddress(opts) {
|
|
111
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
108
|
return new Promise((resolve, reject) => {
|
|
113
|
-
var _a, _b, _c, _d;
|
|
114
109
|
// QR Code flow
|
|
115
110
|
if (!isMobile() && Boolean(opts === null || opts === void 0 ? void 0 : opts.onDisplayUri)) {
|
|
116
111
|
this.metaMaskSDKDisplayUriState
|
|
@@ -126,9 +121,9 @@ class MetaMaskConnector extends EthereumWalletConnector {
|
|
|
126
121
|
}
|
|
127
122
|
// Deep link to MetaMask app in-app browser
|
|
128
123
|
if (this.shouldDeepLinkToMetaMaskInAppBrowser() &&
|
|
129
|
-
|
|
124
|
+
this.metadata.inAppBrowserUrl) {
|
|
130
125
|
// Redirect to the in-app browser and append the current url
|
|
131
|
-
window.location.href = `${
|
|
126
|
+
window.location.href = `${this.metadata.inAppBrowserUrl}/${window.location.href}`;
|
|
132
127
|
resolve(undefined);
|
|
133
128
|
return;
|
|
134
129
|
}
|
|
@@ -244,12 +239,6 @@ class MetaMaskConnector extends EthereumWalletConnector {
|
|
|
244
239
|
}
|
|
245
240
|
return rdns;
|
|
246
241
|
}
|
|
247
|
-
isInstalledOnBrowser() {
|
|
248
|
-
var _a;
|
|
249
|
-
const metaMaskEip6963Provider = (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.eip6963ProviderLookup(this.rdns);
|
|
250
|
-
const isInstalled = Boolean(metaMaskEip6963Provider);
|
|
251
|
-
return isInstalled;
|
|
252
|
-
}
|
|
253
242
|
setupEventListeners() {
|
|
254
243
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
244
|
yield this.metaMaskSDK.sdkInitPromise;
|
|
@@ -351,15 +340,11 @@ class MetaMaskConnector extends EthereumWalletConnector {
|
|
|
351
340
|
* on a mobile device
|
|
352
341
|
*/
|
|
353
342
|
getIsInAppBrowser() {
|
|
354
|
-
var _a, _b;
|
|
355
343
|
if (!isMobile())
|
|
356
344
|
return false;
|
|
357
|
-
|
|
358
|
-
((_b = this.ethProviderHelper) === null || _b === void 0 ? void 0 : _b.getInjectedProvider());
|
|
359
|
-
return Boolean(provider);
|
|
345
|
+
return this.isInstalledOnBrowser();
|
|
360
346
|
}
|
|
361
347
|
shouldDeepLinkToMetaMaskInAppBrowser() {
|
|
362
|
-
var _a;
|
|
363
348
|
// Not in an in-app browser
|
|
364
349
|
if (this.isInAppBrowser)
|
|
365
350
|
return false;
|
|
@@ -369,18 +354,11 @@ class MetaMaskConnector extends EthereumWalletConnector {
|
|
|
369
354
|
// SDK is configured to use the in-app browser
|
|
370
355
|
if (this.mobileExperience !== 'in-app-browser')
|
|
371
356
|
return false;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (!isAppBrowserLinkPresent)
|
|
357
|
+
// Wallet does not have an in-app browser link
|
|
358
|
+
if (!this.metadata.inAppBrowserUrl)
|
|
375
359
|
return false;
|
|
376
360
|
return true;
|
|
377
361
|
}
|
|
378
|
-
/**
|
|
379
|
-
* Get wallet book wallet information
|
|
380
|
-
*/
|
|
381
|
-
get wallet() {
|
|
382
|
-
return findWalletBookWallet(this.walletBook, this.key);
|
|
383
|
-
}
|
|
384
362
|
}
|
|
385
363
|
// Utils
|
|
386
364
|
const getReadonlyRPCMap = (evmNetworkRpcMap) => Object.keys(evmNetworkRpcMap).reduce((acc, chainId) => (Object.assign(Object.assign({}, acc), { [toHex(parseInt(chainId))]: evmNetworkRpcMap[chainId] })), {});
|