@dynamic-labs/ethereum 0.19.0-alpha.9 → 0.19.0
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 +292 -0
- package/package.json +14 -11
- package/src/EthWalletConnector.cjs +189 -193
- package/src/EthWalletConnector.d.ts +298 -41
- package/src/EthWalletConnector.js +190 -194
- package/src/coinbase/client/client.cjs +78 -0
- package/src/coinbase/client/client.d.ts +6 -0
- package/src/coinbase/client/client.js +71 -0
- package/src/coinbase/client/index.d.ts +2 -0
- package/src/coinbase/client/types.d.ts +14 -0
- package/src/coinbase/coinbase.cjs +71 -0
- package/src/coinbase/coinbase.d.ts +535 -0
- package/src/coinbase/coinbase.js +67 -0
- package/src/coinbase/index.d.ts +3 -0
- package/src/constants.d.ts +1 -1
- package/src/ethProviderHelper.cjs +129 -127
- package/src/ethProviderHelper.d.ts +28 -27
- package/src/ethProviderHelper.js +130 -128
- package/src/index.cjs +10 -8
- package/src/index.d.ts +9 -9
- package/src/index.js +10 -7
- package/src/injected/BloctoInjected.cjs +5 -5
- package/src/injected/BloctoInjected.d.ts +4 -4
- package/src/injected/BloctoInjected.js +5 -5
- package/src/injected/BraveEvm.cjs +5 -5
- package/src/injected/BraveEvm.d.ts +4 -4
- package/src/injected/BraveEvm.js +5 -5
- package/src/injected/Dawn.cjs +5 -5
- package/src/injected/Dawn.d.ts +4 -4
- package/src/injected/Dawn.js +5 -5
- package/src/injected/ExodusEvm.cjs +6 -6
- package/src/injected/ExodusEvm.d.ts +5 -5
- package/src/injected/ExodusEvm.js +6 -6
- package/src/injected/Frame.cjs +5 -5
- package/src/injected/Frame.d.ts +4 -4
- package/src/injected/Frame.js +5 -5
- package/src/injected/GameStop.cjs +5 -5
- package/src/injected/GameStop.d.ts +4 -4
- package/src/injected/GameStop.js +5 -5
- package/src/injected/InjectedWalletBase.cjs +86 -78
- package/src/injected/InjectedWalletBase.d.ts +29 -29
- package/src/injected/InjectedWalletBase.js +86 -78
- package/src/injected/LegacyInjectedWalletBase.cjs +71 -65
- package/src/injected/LegacyInjectedWalletBase.d.ts +24 -24
- package/src/injected/LegacyInjectedWalletBase.js +71 -65
- package/src/injected/Opera.cjs +5 -5
- package/src/injected/Opera.d.ts +4 -4
- package/src/injected/Opera.js +5 -5
- package/src/injected/PhantomEvm.cjs +27 -27
- package/src/injected/PhantomEvm.d.ts +5 -5
- package/src/injected/PhantomEvm.js +27 -27
- package/src/injected/Rabby.cjs +6 -6
- package/src/injected/Rabby.d.ts +5 -5
- package/src/injected/Rabby.js +6 -6
- package/src/injected/Superb.cjs +5 -5
- package/src/injected/Superb.d.ts +4 -4
- package/src/injected/Superb.js +5 -5
- package/src/injected/Trust.cjs +6 -6
- package/src/injected/Trust.d.ts +5 -5
- package/src/injected/Trust.js +6 -6
- package/src/injected/Zerion.cjs +6 -6
- package/src/injected/Zerion.d.ts +5 -5
- package/src/injected/Zerion.js +6 -6
- package/src/injected/fetchInjectedWalletConnectors.cjs +23 -22
- package/src/injected/fetchInjectedWalletConnectors.d.ts +6 -6
- package/src/injected/fetchInjectedWalletConnectors.js +23 -22
- package/src/injected/index.d.ts +13 -14
- package/src/injected/legacyInjectedWallets.cjs +27 -30
- package/src/injected/legacyInjectedWallets.d.ts +3 -3
- package/src/injected/legacyInjectedWallets.js +27 -30
- package/src/legacyEthProviderHelper.cjs +175 -181
- package/src/legacyEthProviderHelper.d.ts +34 -33
- package/src/legacyEthProviderHelper.js +175 -181
- package/src/polyfills.cjs +11 -11
- package/src/polyfills.d.ts +1 -1
- package/src/polyfills.js +11 -11
- package/src/types.d.ts +37 -35
- package/src/utils/eventListenerHandlers.cjs +25 -25
- package/src/utils/eventListenerHandlers.d.ts +8 -8
- package/src/utils/eventListenerHandlers.js +25 -25
- package/src/utils/findEvmNetwork.cjs +13 -13
- package/src/utils/findEvmNetwork.d.ts +6 -6
- package/src/utils/findEvmNetwork.js +13 -13
- package/src/utils/isString.d.ts +1 -1
- package/src/utils/isUnsupportedProviderError/index.d.ts +1 -1
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.cjs +6 -6
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.d.ts +6 -6
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.js +6 -6
- package/src/utils/last.d.ts +1 -1
- package/src/utils/parseIntSafe.cjs +13 -13
- package/src/utils/parseIntSafe.d.ts +1 -1
- package/src/utils/parseIntSafe.js +13 -13
- package/src/walletConnect/client/client.cjs +179 -175
- package/src/walletConnect/client/client.d.ts +17 -17
- package/src/walletConnect/client/client.js +179 -175
- package/src/walletConnect/client/index.d.ts +1 -1
- package/src/walletConnect/client/types.d.ts +4 -4
- package/src/walletConnect/fetchWalletConnectWallets.cjs +37 -37
- package/src/walletConnect/fetchWalletConnectWallets.d.ts +9 -9
- package/src/walletConnect/fetchWalletConnectWallets.js +37 -37
- package/src/walletConnect/index.d.ts +3 -3
- package/src/walletConnect/walletConnect.cjs +131 -129
- package/src/walletConnect/walletConnect.d.ts +52 -52
- package/src/walletConnect/walletConnect.js +131 -129
- package/src/walletConnect/walletConnectV2.cjs +419 -387
- package/src/walletConnect/walletConnectV2.d.ts +326 -64
- package/src/walletConnect/walletConnectV2.js +420 -388
- package/src/injected/MetaMask.cjs +0 -15
- package/src/injected/MetaMask.d.ts +0 -5
- package/src/injected/MetaMask.js +0 -11
|
@@ -1,189 +1,183 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
-
import {
|
|
2
|
+
import { createWalletClient, custom, getAddress } from 'viem';
|
|
3
3
|
import { ProviderLookup, normalizeWalletName, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { isUnsupportedProviderError } from './utils/isUnsupportedProviderError/isUnsupportedProviderError.js';
|
|
5
5
|
import { eventListenerHandlers } from './utils/eventListenerHandlers.js';
|
|
6
6
|
|
|
7
|
-
var _a;
|
|
8
|
-
class LegacyEthProviderHelper {
|
|
9
|
-
static installedProviderLookup(providerFlags) {
|
|
10
|
-
const allInstalledProviders = this.allInstalledProviders();
|
|
11
|
-
return ProviderLookup(allInstalledProviders, providerFlags);
|
|
12
|
-
}
|
|
13
|
-
static allInstalledProviders() {
|
|
14
|
-
var _b;
|
|
15
|
-
const ethereumProviders = [];
|
|
16
|
-
if (window.ethereum) {
|
|
17
|
-
if (!window.ethereum.providers) {
|
|
18
|
-
ethereumProviders.push(window.ethereum);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
window.ethereum.providers.forEach((provider) => {
|
|
22
|
-
ethereumProviders.push(provider);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if ((_b = window.phantom) === null || _b === void 0 ? void 0 : _b.ethereum) {
|
|
27
|
-
ethereumProviders.push(window.phantom.ethereum);
|
|
28
|
-
}
|
|
29
|
-
if (window.zerionWallet) {
|
|
30
|
-
ethereumProviders.push(window.zerionWallet);
|
|
31
|
-
}
|
|
32
|
-
if (window.coinbaseWalletExtension) {
|
|
33
|
-
ethereumProviders.push(window.coinbaseWalletExtension);
|
|
34
|
-
}
|
|
35
|
-
if (window.superb) {
|
|
36
|
-
ethereumProviders.push(window.superb);
|
|
37
|
-
}
|
|
38
|
-
return ethereumProviders;
|
|
39
|
-
}
|
|
40
|
-
static isInstalledHelper(walletName) {
|
|
41
|
-
return this.findProvider(walletName) !== undefined;
|
|
42
|
-
}
|
|
43
|
-
static findProvider(walletName) {
|
|
44
|
-
var _b, _c;
|
|
45
|
-
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
]);
|
|
143
|
-
LegacyEthProviderHelper.
|
|
144
|
-
LegacyEthProviderHelper.
|
|
145
|
-
LegacyEthProviderHelper.
|
|
146
|
-
LegacyEthProviderHelper.
|
|
147
|
-
LegacyEthProviderHelper.
|
|
148
|
-
LegacyEthProviderHelper.
|
|
149
|
-
LegacyEthProviderHelper.
|
|
150
|
-
LegacyEthProviderHelper.
|
|
151
|
-
LegacyEthProviderHelper.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
{ flag: '
|
|
158
|
-
{ flag: '
|
|
159
|
-
{ flag: '
|
|
160
|
-
{ flag: '
|
|
161
|
-
{ flag: '
|
|
162
|
-
{ flag: '
|
|
163
|
-
{ flag: '
|
|
164
|
-
{ flag: '
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
opera: _a.OperaProvider,
|
|
182
|
-
phantomevm: _a.PhantomProvider,
|
|
183
|
-
rabby: _a.RabbyProvider,
|
|
184
|
-
superb: _a.SuperbProvider,
|
|
185
|
-
trust: _a.TrustWalletProvider,
|
|
186
|
-
zerion: _a.ZerionProvider,
|
|
7
|
+
var _a;
|
|
8
|
+
class LegacyEthProviderHelper {
|
|
9
|
+
static installedProviderLookup(providerFlags) {
|
|
10
|
+
const allInstalledProviders = this.allInstalledProviders();
|
|
11
|
+
return ProviderLookup(allInstalledProviders, providerFlags);
|
|
12
|
+
}
|
|
13
|
+
static allInstalledProviders() {
|
|
14
|
+
var _b;
|
|
15
|
+
const ethereumProviders = [];
|
|
16
|
+
if (window.ethereum) {
|
|
17
|
+
if (!window.ethereum.providers) {
|
|
18
|
+
ethereumProviders.push(window.ethereum);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
window.ethereum.providers.forEach((provider) => {
|
|
22
|
+
ethereumProviders.push(provider);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if ((_b = window.phantom) === null || _b === void 0 ? void 0 : _b.ethereum) {
|
|
27
|
+
ethereumProviders.push(window.phantom.ethereum);
|
|
28
|
+
}
|
|
29
|
+
if (window.zerionWallet) {
|
|
30
|
+
ethereumProviders.push(window.zerionWallet);
|
|
31
|
+
}
|
|
32
|
+
if (window.coinbaseWalletExtension) {
|
|
33
|
+
ethereumProviders.push(window.coinbaseWalletExtension);
|
|
34
|
+
}
|
|
35
|
+
if (window.superb) {
|
|
36
|
+
ethereumProviders.push(window.superb);
|
|
37
|
+
}
|
|
38
|
+
return ethereumProviders;
|
|
39
|
+
}
|
|
40
|
+
static isInstalledHelper(walletName) {
|
|
41
|
+
return this.findProvider(walletName) !== undefined;
|
|
42
|
+
}
|
|
43
|
+
static findProvider(walletName) {
|
|
44
|
+
var _b, _c;
|
|
45
|
+
try {
|
|
46
|
+
return (_c = (_b = this.providers)[normalizeWalletName(walletName)]) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (isUnsupportedProviderError(err)) {
|
|
50
|
+
logger.error(`ETH Provider is not supported ${err.value}`, err);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
logger.error(`Could not find provider for ${walletName}`, err);
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
static findWalletClient(walletName) {
|
|
58
|
+
const provider = this.findProvider(walletName);
|
|
59
|
+
if (!provider) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return createWalletClient({
|
|
63
|
+
transport: custom(provider),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
static fetchPublicAddressWithName(name) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const client = this.findWalletClient(name);
|
|
69
|
+
if (!client) {
|
|
70
|
+
return Promise.resolve(undefined);
|
|
71
|
+
}
|
|
72
|
+
return this.fetchPublicAddressWithProvider(client);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
static fetchPublicAddressWithProvider(client) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
try {
|
|
78
|
+
const [lowercaseAddress] = yield client.requestAddresses();
|
|
79
|
+
const publicAddress = getAddress(lowercaseAddress);
|
|
80
|
+
return publicAddress;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
logger.error(err);
|
|
84
|
+
return Promise.reject(err);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
static signMessageWithName(messageToSign, name) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const walletAddress = yield this.fetchPublicAddressWithName(name);
|
|
91
|
+
if (!walletAddress) {
|
|
92
|
+
return Promise.resolve(undefined);
|
|
93
|
+
}
|
|
94
|
+
const client = this.findWalletClient(name);
|
|
95
|
+
if (!client) {
|
|
96
|
+
return Promise.resolve(undefined);
|
|
97
|
+
}
|
|
98
|
+
const signedMessage = yield client.signMessage({
|
|
99
|
+
account: walletAddress,
|
|
100
|
+
message: messageToSign,
|
|
101
|
+
});
|
|
102
|
+
return signedMessage;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
static _setupEventListeners(walletName, walletConnector, publicClient) {
|
|
106
|
+
const web3Provider = this.findProvider(walletName);
|
|
107
|
+
if (!web3Provider) {
|
|
108
|
+
return {
|
|
109
|
+
tearDownEventListeners: () => { },
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const { handleAccountChange, handleChainChange, handleDisconnect } = eventListenerHandlers(walletConnector, publicClient);
|
|
113
|
+
web3Provider.on('accountsChanged', handleAccountChange);
|
|
114
|
+
web3Provider.on('chainChanged', handleChainChange);
|
|
115
|
+
web3Provider.on('disconnect', handleDisconnect);
|
|
116
|
+
const tearDownEventListeners = () => {
|
|
117
|
+
const web3Provider = this.findProvider(walletName);
|
|
118
|
+
if (!web3Provider) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (handleAccountChange) {
|
|
122
|
+
web3Provider.removeListener('accountsChanged', handleAccountChange);
|
|
123
|
+
}
|
|
124
|
+
if (handleChainChange) {
|
|
125
|
+
web3Provider.removeListener('chainChanged', handleChainChange);
|
|
126
|
+
}
|
|
127
|
+
if (handleDisconnect) {
|
|
128
|
+
web3Provider.removeListener('disconnect', handleDisconnect);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
tearDownEventListeners,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
_a = LegacyEthProviderHelper;
|
|
137
|
+
LegacyEthProviderHelper.BraveProvider = () => _a.installedProviderLookup([{ flag: 'isBraveWallet', value: true }]);
|
|
138
|
+
LegacyEthProviderHelper.DawnProvider = () => _a.installedProviderLookup([{ flag: 'isDawn', value: true }]);
|
|
139
|
+
LegacyEthProviderHelper.FrameProvider = () => _a.installedProviderLookup([{ flag: 'isFrame', value: true }]);
|
|
140
|
+
LegacyEthProviderHelper.CoinbaseProvider = () => _a.installedProviderLookup([{ flag: 'isCoinbaseWallet', value: true }]);
|
|
141
|
+
LegacyEthProviderHelper.OperaProvider = () => _a.installedProviderLookup([{ flag: 'isOpera', value: true }]);
|
|
142
|
+
LegacyEthProviderHelper.GameStopProvider = () => _a.installedProviderLookup([{ flag: 'isGamestop', value: true }]);
|
|
143
|
+
LegacyEthProviderHelper.ExodusProvider = () => _a.installedProviderLookup([{ flag: 'isExodus', value: true }]);
|
|
144
|
+
LegacyEthProviderHelper.BloctoProvider = () => _a.installedProviderLookup([{ flag: 'isBlocto', value: true }]);
|
|
145
|
+
LegacyEthProviderHelper.TrustWalletProvider = () => _a.installedProviderLookup([{ flag: 'isTrustWallet', value: true }]);
|
|
146
|
+
LegacyEthProviderHelper.PhantomProvider = () => _a.installedProviderLookup([{ flag: 'isPhantom', value: true }]);
|
|
147
|
+
LegacyEthProviderHelper.ZerionProvider = () => _a.installedProviderLookup([{ flag: 'isZerion', value: true }]);
|
|
148
|
+
LegacyEthProviderHelper.SuperbProvider = () => _a.installedProviderLookup([{ flag: 'isSuperb', value: true }]);
|
|
149
|
+
LegacyEthProviderHelper.RabbyProvider = () => _a.installedProviderLookup([{ flag: 'isRabby', value: true }]);
|
|
150
|
+
LegacyEthProviderHelper.OKXProvider = () => _a.installedProviderLookup([{ flag: 'isOkxWallet', value: true }]);
|
|
151
|
+
LegacyEthProviderHelper.UnknownInjectedProvider = () => _a.installedProviderLookup([
|
|
152
|
+
{ flag: 'isMetaMask', value: false },
|
|
153
|
+
{ flag: 'isExodus', value: false },
|
|
154
|
+
{ flag: 'isCoinbaseWallet', value: false },
|
|
155
|
+
{ flag: 'isBraveWallet', value: false },
|
|
156
|
+
{ flag: 'isGamestop', value: false },
|
|
157
|
+
{ flag: 'isFrame', value: false },
|
|
158
|
+
{ flag: 'isOpera', value: false },
|
|
159
|
+
{ flag: 'isBlocto', value: false },
|
|
160
|
+
{ flag: 'isTrustWallet', value: false },
|
|
161
|
+
{ flag: 'isPhantom', value: false },
|
|
162
|
+
{ flag: 'isZerion', value: false },
|
|
163
|
+
{ flag: 'isSuperb', value: false },
|
|
164
|
+
{ flag: 'isRabby', value: false },
|
|
165
|
+
]);
|
|
166
|
+
LegacyEthProviderHelper.providers = {
|
|
167
|
+
bloctoinjected: _a.BloctoProvider,
|
|
168
|
+
braveevm: _a.BraveProvider,
|
|
169
|
+
coinbase: _a.CoinbaseProvider,
|
|
170
|
+
dawn: _a.DawnProvider,
|
|
171
|
+
exodusevm: _a.ExodusProvider,
|
|
172
|
+
frame: _a.FrameProvider,
|
|
173
|
+
gamestop: _a.GameStopProvider,
|
|
174
|
+
injectedwallet: _a.UnknownInjectedProvider,
|
|
175
|
+
opera: _a.OperaProvider,
|
|
176
|
+
phantomevm: _a.PhantomProvider,
|
|
177
|
+
rabby: _a.RabbyProvider,
|
|
178
|
+
superb: _a.SuperbProvider,
|
|
179
|
+
trust: _a.TrustWalletProvider,
|
|
180
|
+
zerion: _a.ZerionProvider,
|
|
187
181
|
};
|
|
188
182
|
|
|
189
183
|
export { LegacyEthProviderHelper };
|
package/src/polyfills.cjs
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
var _ = require('buffer/');
|
|
4
4
|
|
|
5
|
-
/* eslint-disable */
|
|
6
|
-
/**
|
|
7
|
-
* @walletconnect/client and @walletconnect/qrcode-modal use `global` and `Buffer`, respectively.
|
|
8
|
-
* This issue is captured here: https://github.com/WalletConnect/walletconnect-monorepo/issues/341
|
|
9
|
-
* Here are some GH issues of others facing the same problem:
|
|
10
|
-
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/734
|
|
11
|
-
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/748
|
|
12
|
-
*/
|
|
13
|
-
if (typeof window !== 'undefined') {
|
|
14
|
-
window.global = globalThis;
|
|
15
|
-
Object.assign(window, { Buffer: _.Buffer });
|
|
5
|
+
/* eslint-disable */
|
|
6
|
+
/**
|
|
7
|
+
* @walletconnect/client and @walletconnect/qrcode-modal use `global` and `Buffer`, respectively.
|
|
8
|
+
* This issue is captured here: https://github.com/WalletConnect/walletconnect-monorepo/issues/341
|
|
9
|
+
* Here are some GH issues of others facing the same problem:
|
|
10
|
+
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/734
|
|
11
|
+
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/748
|
|
12
|
+
*/
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
window.global = globalThis;
|
|
15
|
+
Object.assign(window, { Buffer: _.Buffer });
|
|
16
16
|
}
|
package/src/polyfills.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/src/polyfills.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Buffer } from 'buffer/index.js';
|
|
2
2
|
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
/**
|
|
5
|
-
* @walletconnect/client and @walletconnect/qrcode-modal use `global` and `Buffer`, respectively.
|
|
6
|
-
* This issue is captured here: https://github.com/WalletConnect/walletconnect-monorepo/issues/341
|
|
7
|
-
* Here are some GH issues of others facing the same problem:
|
|
8
|
-
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/734
|
|
9
|
-
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/748
|
|
10
|
-
*/
|
|
11
|
-
if (typeof window !== 'undefined') {
|
|
12
|
-
window.global = globalThis;
|
|
13
|
-
Object.assign(window, { Buffer });
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* @walletconnect/client and @walletconnect/qrcode-modal use `global` and `Buffer`, respectively.
|
|
6
|
+
* This issue is captured here: https://github.com/WalletConnect/walletconnect-monorepo/issues/341
|
|
7
|
+
* Here are some GH issues of others facing the same problem:
|
|
8
|
+
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/734
|
|
9
|
+
* * https://github.com/WalletConnect/walletconnect-monorepo/issues/748
|
|
10
|
+
*/
|
|
11
|
+
if (typeof window !== 'undefined') {
|
|
12
|
+
window.global = globalThis;
|
|
13
|
+
Object.assign(window, { Buffer });
|
|
14
14
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export type
|
|
27
|
-
export type
|
|
28
|
-
export type
|
|
29
|
-
export type
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'stream';
|
|
3
|
+
import { PublicClient } from 'viem';
|
|
4
|
+
import { ProviderCondition } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
declare global {
|
|
6
|
+
interface IWindowPhantom {
|
|
7
|
+
ethereum: IEthereum;
|
|
8
|
+
}
|
|
9
|
+
interface Window {
|
|
10
|
+
ethereum?: IEthereum;
|
|
11
|
+
phantom?: IWindowPhantom;
|
|
12
|
+
zerionWallet?: IEthereum;
|
|
13
|
+
coinbaseWalletExtension?: IEthereum;
|
|
14
|
+
superb?: IEthereum;
|
|
15
|
+
okxwallet?: IEthereum;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export type IEthereum = {
|
|
19
|
+
[key in ProviderFlag]: boolean;
|
|
20
|
+
} & {
|
|
21
|
+
providers?: object[];
|
|
22
|
+
request: <T extends string>(params: {
|
|
23
|
+
method: T;
|
|
24
|
+
} | object) => Promise<T extends 'eth_requestAccounts' ? [string] : object>;
|
|
25
|
+
} & EventEmitter;
|
|
26
|
+
export type ProviderFlag = 'isDawn' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isFrame' | 'isGamestop' | 'isMetaMask' | 'isExodus' | 'isOpera' | 'isBlocto' | 'isTrustWallet' | 'isZerion' | 'isPhantom' | 'isSuperb' | 'isRabby' | 'isOkxWallet';
|
|
27
|
+
export type EthProviderCondition = ProviderCondition<ProviderFlag>;
|
|
28
|
+
export type Provider = () => PublicClient | undefined;
|
|
29
|
+
export type AccountChangeEventHandler = (accounts: string[]) => Promise<void>;
|
|
30
|
+
export type ChainChangeEventHandler = (chainId: string | number) => Promise<void>;
|
|
31
|
+
export type DisconnectEventHandler = (error?: {
|
|
32
|
+
code: number;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
export type ExternalProviderEventEmitter = PublicClient & {
|
|
35
|
+
on: (event: string, listener: (...args: Array<any>) => unknown) => void;
|
|
36
|
+
removeListener: (event: string, listener: (...args: Array<any>) => unknown) => void;
|
|
37
|
+
};
|
|
@@ -4,31 +4,31 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
6
6
|
|
|
7
|
-
const eventListenerHandlers = (walletConnector,
|
|
8
|
-
const handleAccountChange = (accounts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
-
if (accounts.length === 0) {
|
|
10
|
-
walletConnector.emit('disconnect');
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
walletConnector.emit('accountChange', { accounts });
|
|
14
|
-
});
|
|
15
|
-
const handleChainChange = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const
|
|
17
|
-
walletConnector.emit('chainChange', {
|
|
18
|
-
chain:
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
const handleDisconnect = (error) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
walletConnector.emit('disconnect');
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
handleAccountChange,
|
|
29
|
-
handleChainChange,
|
|
30
|
-
handleDisconnect,
|
|
31
|
-
};
|
|
7
|
+
const eventListenerHandlers = (walletConnector, publicClient) => {
|
|
8
|
+
const handleAccountChange = (accounts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
if (accounts.length === 0) {
|
|
10
|
+
walletConnector.emit('disconnect');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
walletConnector.emit('accountChange', { accounts });
|
|
14
|
+
});
|
|
15
|
+
const handleChainChange = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const chainId = yield publicClient.getChainId();
|
|
17
|
+
walletConnector.emit('chainChange', {
|
|
18
|
+
chain: chainId.toString(),
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
const handleDisconnect = (error) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
walletConnector.emit('disconnect');
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
handleAccountChange,
|
|
29
|
+
handleChainChange,
|
|
30
|
+
handleDisconnect,
|
|
31
|
+
};
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
exports.eventListenerHandlers = eventListenerHandlers;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler } from '../types';
|
|
4
|
-
export declare const eventListenerHandlers: (walletConnector: WalletConnector,
|
|
5
|
-
handleAccountChange: AccountChangeEventHandler;
|
|
6
|
-
handleChainChange: ChainChangeEventHandler;
|
|
7
|
-
handleDisconnect: DisconnectEventHandler;
|
|
8
|
-
};
|
|
1
|
+
import { PublicClient } from 'viem';
|
|
2
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { AccountChangeEventHandler, ChainChangeEventHandler, DisconnectEventHandler } from '../types';
|
|
4
|
+
export declare const eventListenerHandlers: (walletConnector: WalletConnector, publicClient: PublicClient) => {
|
|
5
|
+
handleAccountChange: AccountChangeEventHandler;
|
|
6
|
+
handleChainChange: ChainChangeEventHandler;
|
|
7
|
+
handleDisconnect: DisconnectEventHandler;
|
|
8
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
2
|
|
|
3
|
-
const eventListenerHandlers = (walletConnector,
|
|
4
|
-
const handleAccountChange = (accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
-
if (accounts.length === 0) {
|
|
6
|
-
walletConnector.emit('disconnect');
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
walletConnector.emit('accountChange', { accounts });
|
|
10
|
-
});
|
|
11
|
-
const handleChainChange = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
-
const
|
|
13
|
-
walletConnector.emit('chainChange', {
|
|
14
|
-
chain:
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
const handleDisconnect = (error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
walletConnector.emit('disconnect');
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
handleAccountChange,
|
|
25
|
-
handleChainChange,
|
|
26
|
-
handleDisconnect,
|
|
27
|
-
};
|
|
3
|
+
const eventListenerHandlers = (walletConnector, publicClient) => {
|
|
4
|
+
const handleAccountChange = (accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
+
if (accounts.length === 0) {
|
|
6
|
+
walletConnector.emit('disconnect');
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
walletConnector.emit('accountChange', { accounts });
|
|
10
|
+
});
|
|
11
|
+
const handleChainChange = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const chainId = yield publicClient.getChainId();
|
|
13
|
+
walletConnector.emit('chainChange', {
|
|
14
|
+
chain: chainId.toString(),
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
const handleDisconnect = (error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
if ((error === null || error === void 0 ? void 0 : error.code) === 1013) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
walletConnector.emit('disconnect');
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
handleAccountChange,
|
|
25
|
+
handleChainChange,
|
|
26
|
+
handleDisconnect,
|
|
27
|
+
};
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export { eventListenerHandlers };
|