@dynamic-labs/ethereum 2.0.0-alpha.1 → 2.0.0-alpha.11
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 +160 -0
- package/package.json +10 -11
- package/src/EthWalletConnector.cjs +1 -20
- package/src/EthWalletConnector.d.ts +9 -10
- package/src/EthWalletConnector.js +3 -22
- package/src/coinbase/client/client.cjs +2 -2
- package/src/coinbase/client/client.d.ts +2 -2
- package/src/coinbase/client/client.js +2 -2
- package/src/coinbase/coinbase.cjs +8 -9
- package/src/coinbase/coinbase.d.ts +18 -17
- package/src/coinbase/coinbase.js +9 -10
- package/src/ethProviderHelper.cjs +10 -5
- package/src/ethProviderHelper.d.ts +4 -3
- package/src/ethProviderHelper.js +10 -5
- package/src/index.cjs +6 -12
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -11
- 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 +6 -14
- package/src/injected/InjectedWalletBase.d.ts +2 -2
- package/src/injected/InjectedWalletBase.js +6 -14
- 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/fetchInjectedWalletConnectors.d.ts +0 -1
- 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 +1 -2
- package/src/walletConnect/walletConnect.cjs +418 -79
- package/src/walletConnect/walletConnect.d.ts +309 -28
- package/src/walletConnect/walletConnect.js +417 -79
- 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
package/src/coinbase/coinbase.js
CHANGED
|
@@ -6,17 +6,16 @@ import '@dynamic-labs/turnkey';
|
|
|
6
6
|
import '@dynamic-labs/utils';
|
|
7
7
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
8
8
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
9
|
-
import '../walletConnect/
|
|
10
|
-
import '
|
|
11
|
-
import '@dynamic-labs/
|
|
12
|
-
import '@walletconnect/client';
|
|
13
|
-
import { getCoinbaseProvider, fetchPublicAddress, signMessage, killCoinbaseSession } from './client/client.js';
|
|
9
|
+
import '../walletConnect/walletConnect.js';
|
|
10
|
+
import { getCoinbaseProvider, getAddress, signMessage, killCoinbaseSession } from './client/client.js';
|
|
11
|
+
import '@dynamic-labs/rpc-provider-ethereum';
|
|
14
12
|
|
|
15
13
|
class Coinbase extends EthWalletConnector {
|
|
16
14
|
constructor(_a) {
|
|
17
15
|
var { appName, appLogoUrl, evmNetworks } = _a, props = __rest(_a, ["appName", "appLogoUrl", "evmNetworks"]);
|
|
18
16
|
super(Object.assign({ evmNetworks }, props));
|
|
19
17
|
this.name = 'Coinbase';
|
|
18
|
+
this.overrideKey = 'coinbase';
|
|
20
19
|
this.supportedChains = ['EVM', 'ETH'];
|
|
21
20
|
this.connectedChain = 'EVM';
|
|
22
21
|
this.canConnectViaQrCode = true;
|
|
@@ -41,10 +40,10 @@ class Coinbase extends EthWalletConnector {
|
|
|
41
40
|
return;
|
|
42
41
|
this.teardownEventListeners = setupResponse.tearDownEventListeners;
|
|
43
42
|
}
|
|
44
|
-
getWalletClient() {
|
|
43
|
+
getWalletClient(chainId) {
|
|
45
44
|
var _a;
|
|
46
45
|
if (this.isInstalledOnBrowser()) {
|
|
47
|
-
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
46
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
48
47
|
}
|
|
49
48
|
return createWalletClient({
|
|
50
49
|
transport: custom(getCoinbaseProvider({
|
|
@@ -56,13 +55,13 @@ class Coinbase extends EthWalletConnector {
|
|
|
56
55
|
var _a;
|
|
57
56
|
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
58
57
|
}
|
|
59
|
-
|
|
58
|
+
getAddress(opts) {
|
|
60
59
|
var _a;
|
|
61
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
61
|
if (this.isInstalledOnBrowser()) {
|
|
63
|
-
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.
|
|
62
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
64
63
|
}
|
|
65
|
-
return
|
|
64
|
+
return getAddress(this.coinbaseProviderOpts, opts);
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
signMessage(messageToSign) {
|
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
6
|
var viem = require('viem');
|
|
7
|
+
var accounts = require('viem/accounts');
|
|
7
8
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
9
|
var utils = require('@dynamic-labs/utils');
|
|
10
|
+
var viemUtils = require('@dynamic-labs/viem-utils');
|
|
9
11
|
var eip6963Provider = require('./eip6963Provider.cjs');
|
|
10
12
|
|
|
11
13
|
class EthProviderHelper {
|
|
@@ -75,29 +77,32 @@ class EthProviderHelper {
|
|
|
75
77
|
findProvider() {
|
|
76
78
|
return this.getInstalledProvider();
|
|
77
79
|
}
|
|
78
|
-
findWalletClient() {
|
|
80
|
+
findWalletClient(chainId) {
|
|
79
81
|
const provider = this.findProvider();
|
|
80
82
|
if (!provider) {
|
|
81
83
|
return undefined;
|
|
82
84
|
}
|
|
83
85
|
return viem.createWalletClient({
|
|
86
|
+
account: this.account,
|
|
87
|
+
chain: chainId ? viemUtils.chainsMap[chainId] : undefined,
|
|
84
88
|
transport: viem.custom(provider),
|
|
85
89
|
});
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
getAddress() {
|
|
88
92
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
89
93
|
const client = this.findWalletClient();
|
|
90
94
|
if (!client) {
|
|
91
95
|
return Promise.resolve(undefined);
|
|
92
96
|
}
|
|
93
|
-
return this.
|
|
97
|
+
return this.getAddressWithProvider(client);
|
|
94
98
|
});
|
|
95
99
|
}
|
|
96
|
-
|
|
100
|
+
getAddressWithProvider(client) {
|
|
97
101
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
98
102
|
try {
|
|
99
103
|
const [lowercaseAddress] = yield client.requestAddresses();
|
|
100
104
|
const publicAddress = viem.getAddress(lowercaseAddress);
|
|
105
|
+
this.account = accounts.toAccount(publicAddress);
|
|
101
106
|
return publicAddress;
|
|
102
107
|
}
|
|
103
108
|
catch (err) {
|
|
@@ -108,7 +113,7 @@ class EthProviderHelper {
|
|
|
108
113
|
}
|
|
109
114
|
signMessage(messageToSign) {
|
|
110
115
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
const walletAddress = yield this.
|
|
116
|
+
const walletAddress = yield this.getAddress();
|
|
112
117
|
if (!walletAddress) {
|
|
113
118
|
return Promise.resolve(undefined);
|
|
114
119
|
}
|
|
@@ -4,6 +4,7 @@ import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
|
4
4
|
import { IEthereum, ProviderFlag } from './types';
|
|
5
5
|
export declare class EthProviderHelper {
|
|
6
6
|
private wallet;
|
|
7
|
+
private account;
|
|
7
8
|
constructor(wallet: WalletSchema);
|
|
8
9
|
getInstalledProvider(): IEthereum | undefined;
|
|
9
10
|
getEip6963Config(): {
|
|
@@ -27,9 +28,9 @@ export declare class EthProviderHelper {
|
|
|
27
28
|
eip6963ProviderLookup(rdns: string): IEthereum | undefined;
|
|
28
29
|
isInstalledHelper(): boolean;
|
|
29
30
|
findProvider(): IEthereum | undefined;
|
|
30
|
-
findWalletClient(): WalletClient | undefined;
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
findWalletClient(chainId?: string): WalletClient | undefined;
|
|
32
|
+
getAddress(): Promise<Hex | undefined>;
|
|
33
|
+
getAddressWithProvider(client: WalletClient): Promise<Hex | undefined>;
|
|
33
34
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
34
35
|
_setupEventListeners(walletConnector: WalletConnector): {
|
|
35
36
|
tearDownEventListeners: () => void;
|
package/src/ethProviderHelper.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
2
|
import { createWalletClient, custom, getAddress } from 'viem';
|
|
3
|
+
import { toAccount } from 'viem/accounts';
|
|
3
4
|
import { ProviderLookup, eventListenerHandlers, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
5
|
import { getProvidersFromWindow } from '@dynamic-labs/utils';
|
|
6
|
+
import { chainsMap } from '@dynamic-labs/viem-utils';
|
|
5
7
|
import { Eip6963ProviderSingleton } from './eip6963Provider.js';
|
|
6
8
|
|
|
7
9
|
class EthProviderHelper {
|
|
@@ -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.account,
|
|
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.account = toAccount(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,19 +7,13 @@ 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');
|
|
23
17
|
|
|
24
18
|
const EthereumWalletConnectors = (props) => [
|
|
25
19
|
...fetchInjectedWalletConnectors.injectedWalletOverrides,
|
|
@@ -27,7 +21,7 @@ const EthereumWalletConnectors = (props) => [
|
|
|
27
21
|
...fetchWalletConnectWallets.fetchWalletConnectWallets(props),
|
|
28
22
|
...turnkey.TurnkeyWalletConnectors(props),
|
|
29
23
|
coinbase.Coinbase,
|
|
30
|
-
fetchWalletConnectWallets.getWalletConnectConnector(
|
|
24
|
+
fetchWalletConnectWallets.getWalletConnectConnector(),
|
|
31
25
|
];
|
|
32
26
|
|
|
33
27
|
exports.PhantomEvm = PhantomEvm.PhantomEvm;
|
|
@@ -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.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -4,19 +4,13 @@ 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';
|
|
20
14
|
|
|
21
15
|
const EthereumWalletConnectors = (props) => [
|
|
22
16
|
...injectedWalletOverrides,
|
|
@@ -24,7 +18,7 @@ const EthereumWalletConnectors = (props) => [
|
|
|
24
18
|
...fetchWalletConnectWallets(props),
|
|
25
19
|
...TurnkeyWalletConnectors(props),
|
|
26
20
|
Coinbase,
|
|
27
|
-
getWalletConnectConnector(
|
|
21
|
+
getWalletConnectConnector(),
|
|
28
22
|
];
|
|
29
23
|
|
|
30
24
|
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
|
}
|
|
@@ -4,7 +4,6 @@ var _tslib = require('../../_virtual/_tslib.cjs');
|
|
|
4
4
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
5
5
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
6
6
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
7
|
-
var walletConnectV2 = require('../walletConnect/walletConnectV2.cjs');
|
|
8
7
|
var walletConnect = require('../walletConnect/walletConnect.cjs');
|
|
9
8
|
|
|
10
9
|
class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
@@ -27,17 +26,10 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
27
26
|
return this.ethProviderHelper;
|
|
28
27
|
}
|
|
29
28
|
getMobileOrInstalledWallet() {
|
|
30
|
-
var _a, _b, _c, _d;
|
|
31
29
|
if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
|
|
32
30
|
if (!this.wallet)
|
|
33
31
|
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
34
|
-
|
|
35
|
-
((_d = (_c = (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.walletConnect) === null || _c === void 0 ? void 0 : _c.sdks) === null || _d === void 0 ? void 0 : _d.includes('sign_v2'))) {
|
|
36
|
-
return new walletConnectV2.WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
40
|
-
}
|
|
32
|
+
return new walletConnect.WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
41
33
|
}
|
|
42
34
|
return this;
|
|
43
35
|
}
|
|
@@ -51,23 +43,23 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
51
43
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
52
44
|
this.teardownEventListeners = tearDownEventListeners;
|
|
53
45
|
}
|
|
54
|
-
getWalletClient() {
|
|
46
|
+
getWalletClient(chainId) {
|
|
55
47
|
var _a;
|
|
56
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
48
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
57
49
|
}
|
|
58
50
|
isInstalledOnBrowser() {
|
|
59
51
|
var _a;
|
|
60
52
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
61
53
|
}
|
|
62
|
-
|
|
54
|
+
getAddress() {
|
|
63
55
|
var _a;
|
|
64
56
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.
|
|
57
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
66
58
|
});
|
|
67
59
|
}
|
|
68
60
|
connect() {
|
|
69
61
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
yield this.
|
|
62
|
+
yield this.getAddress();
|
|
71
63
|
});
|
|
72
64
|
}
|
|
73
65
|
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>;
|
|
@@ -2,7 +2,6 @@ import { __awaiter } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
3
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
4
4
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
5
|
-
import { WalletConnectV2 } from '../walletConnect/walletConnectV2.js';
|
|
6
5
|
import { WalletConnect } from '../walletConnect/walletConnect.js';
|
|
7
6
|
|
|
8
7
|
class InjectedWalletBase extends EthWalletConnector {
|
|
@@ -25,17 +24,10 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
25
24
|
return this.ethProviderHelper;
|
|
26
25
|
}
|
|
27
26
|
getMobileOrInstalledWallet() {
|
|
28
|
-
var _a, _b, _c, _d;
|
|
29
27
|
if (this.walletConnectorFallback && !this.isInstalledOnBrowser()) {
|
|
30
28
|
if (!this.wallet)
|
|
31
29
|
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
32
|
-
|
|
33
|
-
((_d = (_c = (_b = this.wallet) === null || _b === void 0 ? void 0 : _b.walletConnect) === null || _c === void 0 ? void 0 : _c.sdks) === null || _d === void 0 ? void 0 : _d.includes('sign_v2'))) {
|
|
34
|
-
return new WalletConnectV2(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
38
|
-
}
|
|
30
|
+
return new WalletConnect(Object.assign(Object.assign({}, this.constructorProps), { walletName: this.name }));
|
|
39
31
|
}
|
|
40
32
|
return this;
|
|
41
33
|
}
|
|
@@ -49,23 +41,23 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
49
41
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
50
42
|
this.teardownEventListeners = tearDownEventListeners;
|
|
51
43
|
}
|
|
52
|
-
getWalletClient() {
|
|
44
|
+
getWalletClient(chainId) {
|
|
53
45
|
var _a;
|
|
54
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
46
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
55
47
|
}
|
|
56
48
|
isInstalledOnBrowser() {
|
|
57
49
|
var _a;
|
|
58
50
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
59
51
|
}
|
|
60
|
-
|
|
52
|
+
getAddress() {
|
|
61
53
|
var _a;
|
|
62
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.
|
|
55
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
64
56
|
});
|
|
65
57
|
}
|
|
66
58
|
connect() {
|
|
67
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
yield this.
|
|
60
|
+
yield this.getAddress();
|
|
69
61
|
});
|
|
70
62
|
}
|
|
71
63
|
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({
|
|
@@ -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[];
|
|
@@ -2,47 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var walletConnectV2 = require('./walletConnectV2.cjs');
|
|
6
5
|
var walletConnect = require('./walletConnect.cjs');
|
|
7
6
|
|
|
8
|
-
const fetchWalletConnectWallets = ({
|
|
7
|
+
const fetchWalletConnectWallets = ({ walletBook, }) => {
|
|
9
8
|
var _a;
|
|
10
|
-
return Object.
|
|
11
|
-
.filter((wallet) => wallet.walletConnect && !wallet.filterFromWalletConnect)
|
|
12
|
-
.map((wallet) => {
|
|
13
|
-
var _a;
|
|
9
|
+
return Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
10
|
+
.filter(([, wallet]) => wallet.walletConnect && !wallet.filterFromWalletConnect)
|
|
11
|
+
.map(([key, wallet]) => {
|
|
14
12
|
const { shortName } = wallet;
|
|
15
13
|
const name = shortName || wallet.name;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
super(Object.assign(Object.assign({}, props), { walletName: name }));
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return class extends walletConnect.WalletConnect {
|
|
28
|
-
constructor(props) {
|
|
29
|
-
super(Object.assign(Object.assign({}, props), { walletName: name }));
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
14
|
+
return class extends walletConnect.WalletConnect {
|
|
15
|
+
constructor(props) {
|
|
16
|
+
super(Object.assign(Object.assign({}, props), { walletName: name }));
|
|
17
|
+
this.overrideKey = key;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
33
20
|
});
|
|
34
21
|
};
|
|
35
|
-
const getWalletConnectConnector = (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
39
|
-
}
|
|
22
|
+
const getWalletConnectConnector = () => class extends walletConnect.WalletConnect {
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
40
25
|
}
|
|
41
|
-
|
|
42
|
-
constructor(props) {
|
|
43
|
-
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
44
|
-
}
|
|
45
|
-
};
|
|
26
|
+
};
|
|
46
27
|
|
|
47
28
|
exports.fetchWalletConnectWallets = fetchWalletConnectWallets;
|
|
48
29
|
exports.getWalletConnectConnector = getWalletConnectConnector;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
2
2
|
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
export declare const fetchWalletConnectWallets: ({
|
|
4
|
-
isWalletConnectV2Enabled: boolean;
|
|
3
|
+
export declare const fetchWalletConnectWallets: ({ walletBook, }: {
|
|
5
4
|
walletBook: WalletBookSchema;
|
|
6
5
|
}) => Array<WalletConnectorConstructor>;
|
|
7
|
-
export declare const getWalletConnectConnector: (
|
|
8
|
-
isWalletConnectV2Enabled: boolean;
|
|
9
|
-
}) => WalletConnectorConstructor;
|
|
6
|
+
export declare const getWalletConnectConnector: () => WalletConnectorConstructor;
|
|
@@ -1,43 +1,24 @@
|
|
|
1
|
-
import { WalletConnectV2 } from './walletConnectV2.js';
|
|
2
1
|
import { WalletConnect } from './walletConnect.js';
|
|
3
2
|
|
|
4
|
-
const fetchWalletConnectWallets = ({
|
|
3
|
+
const fetchWalletConnectWallets = ({ walletBook, }) => {
|
|
5
4
|
var _a;
|
|
6
|
-
return Object.
|
|
7
|
-
.filter((wallet) => wallet.walletConnect && !wallet.filterFromWalletConnect)
|
|
8
|
-
.map((wallet) => {
|
|
9
|
-
var _a;
|
|
5
|
+
return Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
6
|
+
.filter(([, wallet]) => wallet.walletConnect && !wallet.filterFromWalletConnect)
|
|
7
|
+
.map(([key, wallet]) => {
|
|
10
8
|
const { shortName } = wallet;
|
|
11
9
|
const name = shortName || wallet.name;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
super(Object.assign(Object.assign({}, props), { walletName: name }));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
return class extends WalletConnect {
|
|
24
|
-
constructor(props) {
|
|
25
|
-
super(Object.assign(Object.assign({}, props), { walletName: name }));
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
10
|
+
return class extends WalletConnect {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(Object.assign(Object.assign({}, props), { walletName: name }));
|
|
13
|
+
this.overrideKey = key;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
29
16
|
});
|
|
30
17
|
};
|
|
31
|
-
const getWalletConnectConnector = (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
35
|
-
}
|
|
18
|
+
const getWalletConnectConnector = () => class extends WalletConnect {
|
|
19
|
+
constructor(props) {
|
|
20
|
+
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
36
21
|
}
|
|
37
|
-
|
|
38
|
-
constructor(props) {
|
|
39
|
-
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
40
|
-
}
|
|
41
|
-
};
|
|
22
|
+
};
|
|
42
23
|
|
|
43
24
|
export { fetchWalletConnectWallets, getWalletConnectConnector };
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { WalletConnect } from './walletConnect';
|
|
1
|
+
export { WalletConnect, type WalletConnectOpts } from './walletConnect';
|
|
3
2
|
export { fetchWalletConnectWallets } from './fetchWalletConnectWallets';
|