@dynamic-labs/ethereum 2.0.0-alpha.3 → 2.0.0-alpha.31
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 +407 -0
- package/package.json +11 -12
- package/src/EthWalletConnector.cjs +13 -21
- package/src/EthWalletConnector.d.ts +16 -14
- package/src/EthWalletConnector.js +15 -23
- package/src/coinbase/client/client.cjs +14 -14
- package/src/coinbase/client/client.d.ts +5 -4
- package/src/coinbase/client/client.js +13 -13
- package/src/coinbase/client/types.d.ts +6 -3
- package/src/coinbase/coinbase.cjs +31 -15
- package/src/coinbase/coinbase.d.ts +20 -18
- package/src/coinbase/coinbase.js +32 -16
- package/src/ethProviderHelper.cjs +11 -6
- package/src/ethProviderHelper.d.ts +6 -4
- package/src/ethProviderHelper.js +11 -6
- package/src/index.cjs +9 -13
- package/src/index.d.ts +2 -0
- package/src/index.js +8 -13
- package/src/injected/ExodusEvm.cjs +1 -0
- package/src/injected/ExodusEvm.d.ts +1 -0
- package/src/injected/ExodusEvm.js +1 -0
- package/src/injected/InjectedWalletBase.cjs +28 -19
- package/src/injected/InjectedWalletBase.d.ts +2 -2
- package/src/injected/InjectedWalletBase.js +28 -19
- package/src/injected/PhantomEvm.cjs +4 -3
- package/src/injected/PhantomEvm.d.ts +2 -1
- package/src/injected/PhantomEvm.js +4 -3
- package/src/injected/Zerion.cjs +38 -0
- package/src/injected/Zerion.d.ts +10 -0
- package/src/injected/Zerion.js +34 -0
- package/src/injected/fetchInjectedWalletConnectors.cjs +25 -0
- package/src/injected/fetchInjectedWalletConnectors.d.ts +0 -1
- package/src/injected/fetchInjectedWalletConnectors.js +25 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/isEthWalletConnector/index.d.ts +1 -0
- package/src/utils/isEthWalletConnector/isEthWalletConnector.cjs +7 -0
- package/src/utils/isEthWalletConnector/isEthWalletConnector.d.ts +3 -0
- package/src/utils/isEthWalletConnector/isEthWalletConnector.js +3 -0
- package/src/walletConnect/fetchWalletConnectWallets.cjs +14 -33
- package/src/walletConnect/fetchWalletConnectWallets.d.ts +2 -5
- package/src/walletConnect/fetchWalletConnectWallets.js +14 -33
- package/src/walletConnect/index.d.ts +0 -1
- package/src/walletConnect/walletConnect.cjs +452 -78
- package/src/walletConnect/walletConnect.d.ts +313 -31
- package/src/walletConnect/walletConnect.js +453 -80
- package/src/walletConnect/client/client.cjs +0 -201
- package/src/walletConnect/client/client.d.ts +0 -17
- package/src/walletConnect/client/client.js +0 -187
- package/src/walletConnect/client/index.d.ts +0 -1
- package/src/walletConnect/client/types.d.ts +0 -4
- package/src/walletConnect/walletConnectV2.cjs +0 -475
- package/src/walletConnect/walletConnectV2.d.ts +0 -333
- package/src/walletConnect/walletConnectV2.js +0 -466
|
@@ -2,9 +2,11 @@ import { Hex, WalletClient } from 'viem';
|
|
|
2
2
|
import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
4
4
|
import { IEthereum, ProviderFlag } from './types';
|
|
5
|
+
import { EthWalletConnector } from '.';
|
|
5
6
|
export declare class EthProviderHelper {
|
|
6
7
|
private wallet;
|
|
7
|
-
|
|
8
|
+
private connector;
|
|
9
|
+
constructor(wallet: WalletSchema, connector: EthWalletConnector);
|
|
8
10
|
getInstalledProvider(): IEthereum | undefined;
|
|
9
11
|
getEip6963Config(): {
|
|
10
12
|
rdns: string;
|
|
@@ -27,9 +29,9 @@ export declare class EthProviderHelper {
|
|
|
27
29
|
eip6963ProviderLookup(rdns: string): IEthereum | undefined;
|
|
28
30
|
isInstalledHelper(): boolean;
|
|
29
31
|
findProvider(): IEthereum | undefined;
|
|
30
|
-
findWalletClient(): WalletClient | undefined;
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
findWalletClient(chainId?: string): WalletClient | undefined;
|
|
33
|
+
getAddress(): Promise<Hex | undefined>;
|
|
34
|
+
getAddressWithProvider(client: WalletClient): Promise<Hex | undefined>;
|
|
33
35
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
34
36
|
_setupEventListeners(walletConnector: WalletConnector): {
|
|
35
37
|
tearDownEventListeners: () => void;
|
package/src/ethProviderHelper.js
CHANGED
|
@@ -2,11 +2,13 @@ import { __awaiter } from '../_virtual/_tslib.js';
|
|
|
2
2
|
import { createWalletClient, custom, getAddress } from 'viem';
|
|
3
3
|
import { ProviderLookup, eventListenerHandlers, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { getProvidersFromWindow } from '@dynamic-labs/utils';
|
|
5
|
+
import { chainsMap } from '@dynamic-labs/viem-utils';
|
|
5
6
|
import { Eip6963ProviderSingleton } from './eip6963Provider.js';
|
|
6
7
|
|
|
7
8
|
class EthProviderHelper {
|
|
8
|
-
constructor(wallet) {
|
|
9
|
+
constructor(wallet, connector) {
|
|
9
10
|
this.wallet = wallet;
|
|
11
|
+
this.connector = connector;
|
|
10
12
|
}
|
|
11
13
|
getInstalledProvider() {
|
|
12
14
|
const eip6963Config = this.getEip6963Config();
|
|
@@ -71,29 +73,32 @@ class EthProviderHelper {
|
|
|
71
73
|
findProvider() {
|
|
72
74
|
return this.getInstalledProvider();
|
|
73
75
|
}
|
|
74
|
-
findWalletClient() {
|
|
76
|
+
findWalletClient(chainId) {
|
|
75
77
|
const provider = this.findProvider();
|
|
76
78
|
if (!provider) {
|
|
77
79
|
return undefined;
|
|
78
80
|
}
|
|
79
81
|
return createWalletClient({
|
|
82
|
+
account: this.connector.getActiveAccount(),
|
|
83
|
+
chain: chainId ? chainsMap[chainId] : undefined,
|
|
80
84
|
transport: custom(provider),
|
|
81
85
|
});
|
|
82
86
|
}
|
|
83
|
-
|
|
87
|
+
getAddress() {
|
|
84
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
89
|
const client = this.findWalletClient();
|
|
86
90
|
if (!client) {
|
|
87
91
|
return Promise.resolve(undefined);
|
|
88
92
|
}
|
|
89
|
-
return this.
|
|
93
|
+
return this.getAddressWithProvider(client);
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
|
-
|
|
96
|
+
getAddressWithProvider(client) {
|
|
93
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
94
98
|
try {
|
|
95
99
|
const [lowercaseAddress] = yield client.requestAddresses();
|
|
96
100
|
const publicAddress = getAddress(lowercaseAddress);
|
|
101
|
+
this.connector.setActiveAccount(publicAddress);
|
|
97
102
|
return publicAddress;
|
|
98
103
|
}
|
|
99
104
|
catch (err) {
|
|
@@ -104,7 +109,7 @@ class EthProviderHelper {
|
|
|
104
109
|
}
|
|
105
110
|
signMessage(messageToSign) {
|
|
106
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
const walletAddress = yield this.
|
|
112
|
+
const walletAddress = yield this.getAddress();
|
|
108
113
|
if (!walletAddress) {
|
|
109
114
|
return Promise.resolve(undefined);
|
|
110
115
|
}
|
package/src/index.cjs
CHANGED
|
@@ -7,27 +7,22 @@ var turnkey = require('@dynamic-labs/turnkey');
|
|
|
7
7
|
var PhantomEvm = require('./injected/PhantomEvm.cjs');
|
|
8
8
|
var ExodusEvm = require('./injected/ExodusEvm.cjs');
|
|
9
9
|
var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
|
|
10
|
-
require('./walletConnect/
|
|
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
|
-
var EthWalletConnector = require('./EthWalletConnector.cjs');
|
|
18
|
-
var constants = require('./constants.cjs');
|
|
19
|
-
require('@walletconnect/client');
|
|
10
|
+
require('./walletConnect/walletConnect.cjs');
|
|
20
11
|
var fetchWalletConnectWallets = require('./walletConnect/fetchWalletConnectWallets.cjs');
|
|
21
12
|
var coinbase = require('./coinbase/coinbase.cjs');
|
|
13
|
+
require('@dynamic-labs/rpc-provider-ethereum');
|
|
14
|
+
var EthWalletConnector = require('./EthWalletConnector.cjs');
|
|
22
15
|
var ethProviderHelper = require('./ethProviderHelper.cjs');
|
|
16
|
+
var constants = require('./constants.cjs');
|
|
17
|
+
var isEthWalletConnector = require('./utils/isEthWalletConnector/isEthWalletConnector.cjs');
|
|
23
18
|
|
|
24
19
|
const EthereumWalletConnectors = (props) => [
|
|
25
20
|
...fetchInjectedWalletConnectors.injectedWalletOverrides,
|
|
26
21
|
...fetchInjectedWalletConnectors.fetchInjectedWalletConnector(props),
|
|
27
22
|
...fetchWalletConnectWallets.fetchWalletConnectWallets(props),
|
|
28
|
-
...turnkey.
|
|
23
|
+
...turnkey.TurnkeyEVMWalletConnectors(props),
|
|
29
24
|
coinbase.Coinbase,
|
|
30
|
-
fetchWalletConnectWallets.getWalletConnectConnector(
|
|
25
|
+
fetchWalletConnectWallets.getWalletConnectConnector(),
|
|
31
26
|
];
|
|
32
27
|
|
|
33
28
|
exports.PhantomEvm = PhantomEvm.PhantomEvm;
|
|
@@ -35,6 +30,7 @@ exports.ExodusEvm = ExodusEvm.ExodusEvm;
|
|
|
35
30
|
exports.fetchInjectedWalletConnector = fetchInjectedWalletConnectors.fetchInjectedWalletConnector;
|
|
36
31
|
exports.injectedWalletOverrides = fetchInjectedWalletConnectors.injectedWalletOverrides;
|
|
37
32
|
exports.EthWalletConnector = EthWalletConnector.EthWalletConnector;
|
|
38
|
-
exports.INFURA_ID = constants.INFURA_ID;
|
|
39
33
|
exports.EthProviderHelper = ethProviderHelper.EthProviderHelper;
|
|
34
|
+
exports.INFURA_ID = constants.INFURA_ID;
|
|
35
|
+
exports.isEthWalletConnector = isEthWalletConnector.isEthWalletConnector;
|
|
40
36
|
exports.EthereumWalletConnectors = EthereumWalletConnectors;
|
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import './polyfills';
|
|
2
2
|
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import '@dynamic-labs/rpc-provider-ethereum';
|
|
3
4
|
export * from './injected';
|
|
4
5
|
export * from './EthWalletConnector';
|
|
5
6
|
export * from './ethProviderHelper';
|
|
6
7
|
export * from './constants';
|
|
7
8
|
export * from './types';
|
|
9
|
+
export * from './utils';
|
|
8
10
|
export declare const EthereumWalletConnectors: (props: any) => WalletConnectorConstructor[];
|
package/src/index.js
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
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
|
-
import './walletConnect/
|
|
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
|
-
export { EthWalletConnector } from './EthWalletConnector.js';
|
|
15
|
-
export { INFURA_ID } from './constants.js';
|
|
16
|
-
import '@walletconnect/client';
|
|
7
|
+
import './walletConnect/walletConnect.js';
|
|
17
8
|
import { fetchWalletConnectWallets, getWalletConnectConnector } from './walletConnect/fetchWalletConnectWallets.js';
|
|
18
9
|
import { Coinbase } from './coinbase/coinbase.js';
|
|
10
|
+
import '@dynamic-labs/rpc-provider-ethereum';
|
|
11
|
+
export { EthWalletConnector } from './EthWalletConnector.js';
|
|
19
12
|
export { EthProviderHelper } from './ethProviderHelper.js';
|
|
13
|
+
export { INFURA_ID } from './constants.js';
|
|
14
|
+
export { isEthWalletConnector } from './utils/isEthWalletConnector/isEthWalletConnector.js';
|
|
20
15
|
|
|
21
16
|
const EthereumWalletConnectors = (props) => [
|
|
22
17
|
...injectedWalletOverrides,
|
|
23
18
|
...fetchInjectedWalletConnector(props),
|
|
24
19
|
...fetchWalletConnectWallets(props),
|
|
25
|
-
...
|
|
20
|
+
...TurnkeyEVMWalletConnectors(props),
|
|
26
21
|
Coinbase,
|
|
27
|
-
getWalletConnectConnector(
|
|
22
|
+
getWalletConnectConnector(),
|
|
28
23
|
];
|
|
29
24
|
|
|
30
25
|
export { EthereumWalletConnectors };
|
|
@@ -10,6 +10,7 @@ class ExodusEvm extends InjectedWalletBase {
|
|
|
10
10
|
constructor(props) {
|
|
11
11
|
super(props);
|
|
12
12
|
this.name = 'ExodusEvm';
|
|
13
|
+
this.overrideKey = 'exodusevm';
|
|
13
14
|
this.walletConnectorFallback = true;
|
|
14
15
|
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
15
16
|
}
|
|
@@ -2,6 +2,7 @@ import { EthWalletConnectorOpts } from '..';
|
|
|
2
2
|
import InjectedWalletBase from './InjectedWalletBase';
|
|
3
3
|
export declare class ExodusEvm extends InjectedWalletBase {
|
|
4
4
|
name: string;
|
|
5
|
+
overrideKey: string;
|
|
5
6
|
walletConnectorFallback: boolean;
|
|
6
7
|
constructor(props: EthWalletConnectorOpts);
|
|
7
8
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
4
4
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
5
|
+
var utils = require('@dynamic-labs/utils');
|
|
5
6
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
6
7
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
7
|
-
var walletConnectV2 = require('../walletConnect/walletConnectV2.cjs');
|
|
8
8
|
var walletConnect = require('../walletConnect/walletConnect.cjs');
|
|
9
9
|
|
|
10
10
|
class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
@@ -21,25 +21,34 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
21
21
|
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
22
22
|
}
|
|
23
23
|
if (this.wallet && !this.ethProviderHelper) {
|
|
24
|
-
this.ethProviderHelper = new ethProviderHelper.EthProviderHelper(this.wallet);
|
|
24
|
+
this.ethProviderHelper = new ethProviderHelper.EthProviderHelper(this.wallet, this);
|
|
25
25
|
}
|
|
26
26
|
// this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
|
|
27
27
|
return this.ethProviderHelper;
|
|
28
28
|
}
|
|
29
29
|
getMobileOrInstalledWallet() {
|
|
30
|
-
var _a, _b
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
var _a, _b;
|
|
31
|
+
if (!this.wallet) {
|
|
32
|
+
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
33
|
+
}
|
|
34
|
+
if (this.isInstalledOnBrowser()) {
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
// this is to handle the case where the user is in a webview.
|
|
38
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
39
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
40
|
+
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
41
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
42
|
+
utils.isMobile()) {
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
// this is the case where the wallet is not installed on the browser and
|
|
46
|
+
// it does not support WalletConnect. in this case, the SDK will instruct
|
|
47
|
+
// the user to download the wallet extension
|
|
48
|
+
if (!this.walletConnectorFallback) {
|
|
49
|
+
return this;
|
|
41
50
|
}
|
|
42
|
-
return this;
|
|
51
|
+
return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
43
52
|
}
|
|
44
53
|
setupEventListeners() {
|
|
45
54
|
const provider = this.getWalletClient();
|
|
@@ -51,23 +60,23 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
51
60
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
52
61
|
this.teardownEventListeners = tearDownEventListeners;
|
|
53
62
|
}
|
|
54
|
-
getWalletClient() {
|
|
63
|
+
getWalletClient(chainId) {
|
|
55
64
|
var _a;
|
|
56
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
65
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
57
66
|
}
|
|
58
67
|
isInstalledOnBrowser() {
|
|
59
68
|
var _a;
|
|
60
69
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
61
70
|
}
|
|
62
|
-
|
|
71
|
+
getAddress() {
|
|
63
72
|
var _a;
|
|
64
73
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.
|
|
74
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
66
75
|
});
|
|
67
76
|
}
|
|
68
77
|
connect() {
|
|
69
78
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
yield this.
|
|
79
|
+
yield this.getAddress();
|
|
71
80
|
});
|
|
72
81
|
}
|
|
73
82
|
signMessage(messageToSign) {
|
|
@@ -14,9 +14,9 @@ declare abstract class InjectedWalletBase extends EthWalletConnector {
|
|
|
14
14
|
getEthProviderHelper(): EthProviderHelper | undefined;
|
|
15
15
|
getMobileOrInstalledWallet(): InjectedWalletBase;
|
|
16
16
|
setupEventListeners(): void;
|
|
17
|
-
getWalletClient(): WalletClient | undefined;
|
|
17
|
+
getWalletClient(chainId?: string): WalletClient | undefined;
|
|
18
18
|
isInstalledOnBrowser(): boolean;
|
|
19
|
-
|
|
19
|
+
getAddress(): Promise<string | undefined>;
|
|
20
20
|
connect(): Promise<void>;
|
|
21
21
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
22
22
|
proveOwnership(messageToSign: string): Promise<string | undefined>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
2
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { isMobile } from '@dynamic-labs/utils';
|
|
3
4
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
4
5
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
5
|
-
import { WalletConnectV2 } from '../walletConnect/walletConnectV2.js';
|
|
6
6
|
import { WalletConnect } from '../walletConnect/walletConnect.js';
|
|
7
7
|
|
|
8
8
|
class InjectedWalletBase extends EthWalletConnector {
|
|
@@ -19,25 +19,34 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
19
19
|
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
20
20
|
}
|
|
21
21
|
if (this.wallet && !this.ethProviderHelper) {
|
|
22
|
-
this.ethProviderHelper = new EthProviderHelper(this.wallet);
|
|
22
|
+
this.ethProviderHelper = new EthProviderHelper(this.wallet, this);
|
|
23
23
|
}
|
|
24
24
|
// this.ethProviderHelper is undefined if the wallet is not installed or found in walletbook
|
|
25
25
|
return this.ethProviderHelper;
|
|
26
26
|
}
|
|
27
27
|
getMobileOrInstalledWallet() {
|
|
28
|
-
var _a, _b
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
var _a, _b;
|
|
29
|
+
if (!this.wallet) {
|
|
30
|
+
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
31
|
+
}
|
|
32
|
+
if (this.isInstalledOnBrowser()) {
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
// this is to handle the case where the user is in a webview.
|
|
36
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
37
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
38
|
+
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
39
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
40
|
+
isMobile()) {
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
// this is the case where the wallet is not installed on the browser and
|
|
44
|
+
// it does not support WalletConnect. in this case, the SDK will instruct
|
|
45
|
+
// the user to download the wallet extension
|
|
46
|
+
if (!this.walletConnectorFallback) {
|
|
47
|
+
return this;
|
|
39
48
|
}
|
|
40
|
-
return this;
|
|
49
|
+
return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
41
50
|
}
|
|
42
51
|
setupEventListeners() {
|
|
43
52
|
const provider = this.getWalletClient();
|
|
@@ -49,23 +58,23 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
49
58
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
50
59
|
this.teardownEventListeners = tearDownEventListeners;
|
|
51
60
|
}
|
|
52
|
-
getWalletClient() {
|
|
61
|
+
getWalletClient(chainId) {
|
|
53
62
|
var _a;
|
|
54
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
63
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
55
64
|
}
|
|
56
65
|
isInstalledOnBrowser() {
|
|
57
66
|
var _a;
|
|
58
67
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
59
68
|
}
|
|
60
|
-
|
|
69
|
+
getAddress() {
|
|
61
70
|
var _a;
|
|
62
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.
|
|
72
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
64
73
|
});
|
|
65
74
|
}
|
|
66
75
|
connect() {
|
|
67
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
yield this.
|
|
77
|
+
yield this.getAddress();
|
|
69
78
|
});
|
|
70
79
|
}
|
|
71
80
|
signMessage(messageToSign) {
|
|
@@ -11,15 +11,16 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
11
11
|
constructor(props) {
|
|
12
12
|
super(props);
|
|
13
13
|
this.name = 'PhantomEvm';
|
|
14
|
+
this.overrideKey = 'phantomevm';
|
|
14
15
|
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
getAddress() {
|
|
17
18
|
const _super = Object.create(null, {
|
|
18
|
-
|
|
19
|
+
getAddress: { get: () => super.getAddress }
|
|
19
20
|
});
|
|
20
21
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
if (this.isInstalledOnBrowser()) {
|
|
22
|
-
return _super.
|
|
23
|
+
return _super.getAddress.call(this);
|
|
23
24
|
}
|
|
24
25
|
if (utils.isMobile()) {
|
|
25
26
|
utils.handleMobileWalletRedirect({
|
|
@@ -2,6 +2,7 @@ import { EthWalletConnectorOpts } from '..';
|
|
|
2
2
|
import InjectedWalletBase from './InjectedWalletBase';
|
|
3
3
|
export declare class PhantomEvm extends InjectedWalletBase {
|
|
4
4
|
name: string;
|
|
5
|
+
overrideKey: string;
|
|
5
6
|
constructor(props: EthWalletConnectorOpts);
|
|
6
|
-
|
|
7
|
+
getAddress(): Promise<string | undefined>;
|
|
7
8
|
}
|
|
@@ -7,15 +7,16 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
7
7
|
constructor(props) {
|
|
8
8
|
super(props);
|
|
9
9
|
this.name = 'PhantomEvm';
|
|
10
|
+
this.overrideKey = 'phantomevm';
|
|
10
11
|
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
getAddress() {
|
|
13
14
|
const _super = Object.create(null, {
|
|
14
|
-
|
|
15
|
+
getAddress: { get: () => super.getAddress }
|
|
15
16
|
});
|
|
16
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
if (this.isInstalledOnBrowser()) {
|
|
18
|
-
return _super.
|
|
19
|
+
return _super.getAddress.call(this);
|
|
19
20
|
}
|
|
20
21
|
if (isMobile()) {
|
|
21
22
|
handleMobileWalletRedirect({
|
|
@@ -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,10 @@
|
|
|
1
|
+
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
3
|
+
import InjectedWalletBase from './InjectedWalletBase';
|
|
4
|
+
export declare class Zerion extends InjectedWalletBase {
|
|
5
|
+
name: string;
|
|
6
|
+
overrideKey: string;
|
|
7
|
+
wallet: WalletSchema;
|
|
8
|
+
constructor(props: EthWalletConnectorOpts);
|
|
9
|
+
isInstalledOnBrowser(): boolean;
|
|
10
|
+
}
|
|
@@ -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 };
|
|
@@ -2,18 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
5
7
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
6
8
|
var PhantomEvm = require('./PhantomEvm.cjs');
|
|
7
9
|
var ExodusEvm = require('./ExodusEvm.cjs');
|
|
10
|
+
var Zerion = require('./Zerion.cjs');
|
|
8
11
|
|
|
9
12
|
const injectedWalletOverrides = [
|
|
10
13
|
PhantomEvm.PhantomEvm,
|
|
11
14
|
ExodusEvm.ExodusEvm,
|
|
15
|
+
Zerion.Zerion,
|
|
12
16
|
];
|
|
13
17
|
const filteredInjectedWalletKeysOverrides = [
|
|
14
18
|
'phantomevm',
|
|
15
19
|
'coinbase',
|
|
16
20
|
'exodusevm',
|
|
21
|
+
'zerion',
|
|
17
22
|
];
|
|
18
23
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
19
24
|
var _a;
|
|
@@ -36,6 +41,26 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
36
41
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
37
42
|
this.overrideKey = key;
|
|
38
43
|
}
|
|
44
|
+
getAddress() {
|
|
45
|
+
const _super = Object.create(null, {
|
|
46
|
+
getAddress: { get: () => super.getAddress }
|
|
47
|
+
});
|
|
48
|
+
var _a;
|
|
49
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
if (this.isInstalledOnBrowser()) {
|
|
51
|
+
return _super.getAddress.call(this);
|
|
52
|
+
}
|
|
53
|
+
const inAppBrowserBase = (_a = this.wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
54
|
+
if (!inAppBrowserBase) {
|
|
55
|
+
const error = new Error(`No inAppBrowserBase found for ${this.name}.`);
|
|
56
|
+
walletConnectorCore.logger.error(error.message);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
const cleanedTargetUrl = window.location.href.replace('https://', '');
|
|
60
|
+
window.location.href = `${inAppBrowserBase}/${cleanedTargetUrl}`;
|
|
61
|
+
return undefined;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
39
64
|
};
|
|
40
65
|
});
|
|
41
66
|
};
|
|
@@ -2,6 +2,5 @@ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core'
|
|
|
2
2
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
3
3
|
export declare const injectedWalletOverrides: WalletConnectorConstructor[];
|
|
4
4
|
export declare const fetchInjectedWalletConnector: ({ walletBook, }: {
|
|
5
|
-
isWalletConnectV2Enabled: boolean;
|
|
6
5
|
walletBook: WalletBookSchema;
|
|
7
6
|
}) => WalletConnectorConstructor[];
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
1
3
|
import InjectedWalletBase from './InjectedWalletBase.js';
|
|
2
4
|
import { PhantomEvm } from './PhantomEvm.js';
|
|
3
5
|
import { ExodusEvm } from './ExodusEvm.js';
|
|
6
|
+
import { Zerion } from './Zerion.js';
|
|
4
7
|
|
|
5
8
|
const injectedWalletOverrides = [
|
|
6
9
|
PhantomEvm,
|
|
7
10
|
ExodusEvm,
|
|
11
|
+
Zerion,
|
|
8
12
|
];
|
|
9
13
|
const filteredInjectedWalletKeysOverrides = [
|
|
10
14
|
'phantomevm',
|
|
11
15
|
'coinbase',
|
|
12
16
|
'exodusevm',
|
|
17
|
+
'zerion',
|
|
13
18
|
];
|
|
14
19
|
const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
15
20
|
var _a;
|
|
@@ -32,6 +37,26 @@ const fetchInjectedWalletConnector = ({ walletBook, }) => {
|
|
|
32
37
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
33
38
|
this.overrideKey = key;
|
|
34
39
|
}
|
|
40
|
+
getAddress() {
|
|
41
|
+
const _super = Object.create(null, {
|
|
42
|
+
getAddress: { get: () => super.getAddress }
|
|
43
|
+
});
|
|
44
|
+
var _a;
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (this.isInstalledOnBrowser()) {
|
|
47
|
+
return _super.getAddress.call(this);
|
|
48
|
+
}
|
|
49
|
+
const inAppBrowserBase = (_a = this.wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
50
|
+
if (!inAppBrowserBase) {
|
|
51
|
+
const error = new Error(`No inAppBrowserBase found for ${this.name}.`);
|
|
52
|
+
logger.error(error.message);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
const cleanedTargetUrl = window.location.href.replace('https://', '');
|
|
56
|
+
window.location.href = `${inAppBrowserBase}/${cleanedTargetUrl}`;
|
|
57
|
+
return undefined;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
35
60
|
};
|
|
36
61
|
});
|
|
37
62
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isEthWalletConnector';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isEthWalletConnector } from './isEthWalletConnector';
|