@dynamic-labs/ethereum 4.8.2-preview.0 → 4.8.2
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 +3 -3
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -9
- package/src/EthereumWalletConnectors.cjs +3 -4
- package/src/EthereumWalletConnectors.js +2 -3
- package/src/injected/InjectedWalletBase.cjs +2 -2
- package/src/injected/InjectedWalletBase.js +2 -2
- package/src/walletConnect/{utils/fetchWalletConnectWallets.cjs → fetchWalletConnectWallets.cjs} +8 -2
- package/src/walletConnect/{utils/fetchWalletConnectWallets.d.ts → fetchWalletConnectWallets.d.ts} +1 -0
- package/src/walletConnect/{utils/fetchWalletConnectWallets.js → fetchWalletConnectWallets.js} +8 -3
- package/src/walletConnect/index.d.ts +2 -2
- package/src/walletConnect/walletConnect.cjs +504 -0
- package/src/walletConnect/{WalletConnectConnector/WalletConnectConnector.d.ts → walletConnect.d.ts} +53 -12
- package/src/walletConnect/walletConnect.js +495 -0
- package/src/walletConnect/WalletConnectConnector/WalletConnectConnector.cjs +0 -286
- package/src/walletConnect/WalletConnectConnector/WalletConnectConnector.js +0 -282
- package/src/walletConnect/WalletConnectConnector/index.d.ts +0 -1
- package/src/walletConnect/WalletConnectProvider/WalletConnectProvider.cjs +0 -169
- package/src/walletConnect/WalletConnectProvider/WalletConnectProvider.d.ts +0 -39
- package/src/walletConnect/WalletConnectProvider/WalletConnectProvider.js +0 -161
- package/src/walletConnect/WalletConnectProvider/index.d.ts +0 -1
- package/src/walletConnect/utils/getWalletConnectConnector.cjs +0 -14
- package/src/walletConnect/utils/getWalletConnectConnector.d.ts +0 -2
- package/src/walletConnect/utils/getWalletConnectConnector.js +0 -10
- package/src/walletConnect/utils/index.d.ts +0 -2
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
-
var EthereumProvider = require('@walletconnect/ethereum-provider');
|
|
8
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
var utils = require('@dynamic-labs/utils');
|
|
10
|
-
var logger = require('../../utils/logger.cjs');
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var EthereumProvider__default = /*#__PURE__*/_interopDefaultLegacy(EthereumProvider);
|
|
15
|
-
|
|
16
|
-
var _a;
|
|
17
|
-
class WalletConnectProvider {
|
|
18
|
-
constructor() {
|
|
19
|
-
throw new Error('WalletConnectProvider is not instantiable');
|
|
20
|
-
}
|
|
21
|
-
static teardownEventListeners() {
|
|
22
|
-
if (!_a.provider ||
|
|
23
|
-
!_a.eventListenersSetup) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
_a.provider.off('accountsChanged', _a.accountChangedHandler);
|
|
27
|
-
_a.provider.off('chainChanged', _a.chainChangedHandler);
|
|
28
|
-
_a.provider.off('session_delete', _a.sessionDeleteHandler);
|
|
29
|
-
_a.eventListenersSetup = false;
|
|
30
|
-
}
|
|
31
|
-
static getMappedChainsByPreferredOrder() {
|
|
32
|
-
const allChains = _a.enabledNetworks.map((network) => `eip155:${network.chainId}`);
|
|
33
|
-
const reorderedChains = _a.preferredChains.filter((chain) => allChains.includes(chain));
|
|
34
|
-
const remainingChains = allChains.filter((chain) => !_a.preferredChains.includes(chain));
|
|
35
|
-
return [...reorderedChains, ...remainingChains].map((chain) => Number(chain.split(':')[1]));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
_a = WalletConnectProvider;
|
|
39
|
-
WalletConnectProvider.isInitialized = false;
|
|
40
|
-
WalletConnectProvider.enabledNetworks = [];
|
|
41
|
-
WalletConnectProvider.preferredChains = [];
|
|
42
|
-
WalletConnectProvider.evmNetworkRpcMap = {};
|
|
43
|
-
WalletConnectProvider.eventListenersSetup = false;
|
|
44
|
-
WalletConnectProvider.accountChangedHandler = () => { };
|
|
45
|
-
WalletConnectProvider.chainChangedHandler = () => { };
|
|
46
|
-
WalletConnectProvider.sessionDeleteHandler = () => { };
|
|
47
|
-
// this method should only be called once
|
|
48
|
-
// it initializes the provider, but does not starts a connection
|
|
49
|
-
WalletConnectProvider.init = (...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* ({ storePrefix = 'dynamic-wc2', } = {}) {
|
|
50
|
-
logger.logger.debug('[WalletConnectProvider] init', {
|
|
51
|
-
isInitialized: _a.isInitialized,
|
|
52
|
-
});
|
|
53
|
-
if (_a.isInitialized) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
_a.isInitialized = true;
|
|
57
|
-
logger.logger.debug('[WalletConnectProvider] initializing');
|
|
58
|
-
_a.provider = yield EthereumProvider__default["default"].init({
|
|
59
|
-
customStoragePrefix: storePrefix,
|
|
60
|
-
disableProviderPing: true,
|
|
61
|
-
optionalChains: _a.getMappedChainsByPreferredOrder(),
|
|
62
|
-
optionalEvents: ['chainChanged', 'accountsChanged'],
|
|
63
|
-
optionalMethods: [
|
|
64
|
-
'eth_chainId',
|
|
65
|
-
'eth_signTypedData',
|
|
66
|
-
'eth_signTransaction',
|
|
67
|
-
'eth_sign',
|
|
68
|
-
'personal_sign',
|
|
69
|
-
'eth_sendTransaction',
|
|
70
|
-
'eth_signTypedData_v4',
|
|
71
|
-
'wallet_switchEthereumChain',
|
|
72
|
-
'wallet_addEthereumChain',
|
|
73
|
-
],
|
|
74
|
-
projectId: _a.projectId,
|
|
75
|
-
rpcMap: _a.evmNetworkRpcMap,
|
|
76
|
-
showQrModal: false,
|
|
77
|
-
});
|
|
78
|
-
logger.logger.debug('[WalletConnectProvider] initialized');
|
|
79
|
-
});
|
|
80
|
-
// this method should be called whenever we need to connect to a wallet
|
|
81
|
-
// when the page is refreshed, if the wallet is already connected,
|
|
82
|
-
// this method does not need to be called
|
|
83
|
-
WalletConnectProvider.connect = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ deepLinks, deepLinkPreference, connectionOpts, }) {
|
|
84
|
-
const handleDisplayURI = (uri) => {
|
|
85
|
-
var _b;
|
|
86
|
-
logger.logger.debug('[WalletConnectProvider] handleDisplayURI', uri);
|
|
87
|
-
_a.connectionUri = uri;
|
|
88
|
-
walletConnectorCore.performPlatformSpecificConnectionMethod(_a.connectionUri, deepLinks, {
|
|
89
|
-
onDesktopUri: connectionOpts === null || connectionOpts === void 0 ? void 0 : connectionOpts.onDesktopUri,
|
|
90
|
-
onDisplayUri: connectionOpts === null || connectionOpts === void 0 ? void 0 : connectionOpts.onDisplayUri,
|
|
91
|
-
}, deepLinkPreference);
|
|
92
|
-
logger.logger.debug('[WalletConnectProvider] removing display_uri event listener');
|
|
93
|
-
(_b = _a.provider) === null || _b === void 0 ? void 0 : _b.off('display_uri', handleDisplayURI);
|
|
94
|
-
};
|
|
95
|
-
if (!_a.provider) {
|
|
96
|
-
throw new utils.DynamicError('WalletConnectProvider is not initialized');
|
|
97
|
-
}
|
|
98
|
-
logger.logger.debug('[WalletConnectProvider] adding display_uri event listener');
|
|
99
|
-
_a.provider.on('display_uri', handleDisplayURI);
|
|
100
|
-
try {
|
|
101
|
-
const result = yield _a.provider.enable();
|
|
102
|
-
logger.logger.debug('[WalletConnectProvider] connected to WalletConnect', result);
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
logger.logger.error('[WalletConnectProvider] Failed to connect to WalletConnect', error);
|
|
107
|
-
const customError = new utils.DynamicError('Connection rejected. Please try again.');
|
|
108
|
-
customError.code = 'connection_rejected';
|
|
109
|
-
throw customError;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
// this method should be called whenever we need to disconnect from a wallet
|
|
113
|
-
// it will kill the connection, but not the provider
|
|
114
|
-
WalletConnectProvider.disconnect = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
115
|
-
if (!_a.provider) {
|
|
116
|
-
logger.logger.debug('[WalletConnectProvider] disconnect - provider is not initialized');
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
logger.logger.debug('[WalletConnectProvider] disconnecting from WalletConnect');
|
|
120
|
-
try {
|
|
121
|
-
yield _a.provider.disconnect();
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
logger.logger.error('[WalletConnectProvider] Failed to disconnect from WalletConnect', error);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
WalletConnectProvider.getProvider = () => _a.provider;
|
|
128
|
-
WalletConnectProvider.handleChainChangedEvent = (chain, onChainChanged) => {
|
|
129
|
-
logger.logger.debug('[WalletConnectProvider] handling chain change event', {
|
|
130
|
-
chain,
|
|
131
|
-
});
|
|
132
|
-
const chainId = utils.parseIntSafe(chain);
|
|
133
|
-
if (!chainId) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
onChainChanged === null || onChainChanged === void 0 ? void 0 : onChainChanged(chainId);
|
|
137
|
-
};
|
|
138
|
-
WalletConnectProvider.handleAccountChangedEvent = (accounts, onAccountChanged) => {
|
|
139
|
-
logger.logger.debug('[WalletConnectProvider] handling account change event', {
|
|
140
|
-
accounts,
|
|
141
|
-
});
|
|
142
|
-
const [account] = accounts;
|
|
143
|
-
const address = account.includes(':') ? account.split(':').pop() : account;
|
|
144
|
-
if (!address) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
onAccountChanged === null || onAccountChanged === void 0 ? void 0 : onAccountChanged(address);
|
|
148
|
-
};
|
|
149
|
-
WalletConnectProvider.setupEventListeners = ({ onChainChanged, onAccountChanged, onDisconnect, }) => {
|
|
150
|
-
if (!_a.provider ||
|
|
151
|
-
_a.eventListenersSetup) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
_a.chainChangedHandler = (chainId) => {
|
|
155
|
-
_a.handleChainChangedEvent(chainId, onChainChanged);
|
|
156
|
-
};
|
|
157
|
-
_a.accountChangedHandler = (account) => {
|
|
158
|
-
_a.handleAccountChangedEvent(account, onAccountChanged);
|
|
159
|
-
};
|
|
160
|
-
_a.sessionDeleteHandler = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
-
onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
|
|
162
|
-
});
|
|
163
|
-
_a.provider.on('accountsChanged', _a.accountChangedHandler);
|
|
164
|
-
_a.provider.on('chainChanged', _a.chainChangedHandler);
|
|
165
|
-
_a.provider.on('session_delete', _a.sessionDeleteHandler);
|
|
166
|
-
_a.eventListenersSetup = true;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
exports.WalletConnectProvider = WalletConnectProvider;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import EthereumProvider from '@walletconnect/ethereum-provider';
|
|
2
|
-
import { ProviderAccounts } from 'node_modules/@walletconnect/ethereum-provider/dist/types/types';
|
|
3
|
-
import { DeepLinkVariant, GetAddressOpts, WalletDeepLinks } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import { GenericNetwork } from '@dynamic-labs/types';
|
|
5
|
-
type ProviderInitOpts = {
|
|
6
|
-
storePrefix?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare class WalletConnectProvider {
|
|
9
|
-
static isInitialized: boolean;
|
|
10
|
-
static projectId: string;
|
|
11
|
-
static enabledNetworks: GenericNetwork[];
|
|
12
|
-
static preferredChains: `eip155:${number}`[];
|
|
13
|
-
static evmNetworkRpcMap: Record<string, string>;
|
|
14
|
-
private static provider;
|
|
15
|
-
static connectionUri: string | undefined;
|
|
16
|
-
private static eventListenersSetup;
|
|
17
|
-
private static accountChangedHandler;
|
|
18
|
-
private static chainChangedHandler;
|
|
19
|
-
private static sessionDeleteHandler;
|
|
20
|
-
private constructor();
|
|
21
|
-
static init: ({ storePrefix, }?: ProviderInitOpts) => Promise<void>;
|
|
22
|
-
static connect: ({ deepLinks, deepLinkPreference, connectionOpts, }: {
|
|
23
|
-
deepLinks?: WalletDeepLinks;
|
|
24
|
-
deepLinkPreference: DeepLinkVariant;
|
|
25
|
-
connectionOpts?: GetAddressOpts;
|
|
26
|
-
}) => Promise<ProviderAccounts>;
|
|
27
|
-
static disconnect: () => Promise<void>;
|
|
28
|
-
static getProvider: () => EthereumProvider | undefined;
|
|
29
|
-
private static handleChainChangedEvent;
|
|
30
|
-
private static handleAccountChangedEvent;
|
|
31
|
-
static setupEventListeners: ({ onChainChanged, onAccountChanged, onDisconnect, }: {
|
|
32
|
-
onChainChanged?: (chainId: number) => void;
|
|
33
|
-
onAccountChanged?: (account: string) => void;
|
|
34
|
-
onDisconnect?: () => void;
|
|
35
|
-
}) => void;
|
|
36
|
-
static teardownEventListeners(): void;
|
|
37
|
-
private static getMappedChainsByPreferredOrder;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
-
import EthereumProvider from '@walletconnect/ethereum-provider';
|
|
4
|
-
import { performPlatformSpecificConnectionMethod } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { parseIntSafe, DynamicError } from '@dynamic-labs/utils';
|
|
6
|
-
import { logger } from '../../utils/logger.js';
|
|
7
|
-
|
|
8
|
-
var _a;
|
|
9
|
-
class WalletConnectProvider {
|
|
10
|
-
constructor() {
|
|
11
|
-
throw new Error('WalletConnectProvider is not instantiable');
|
|
12
|
-
}
|
|
13
|
-
static teardownEventListeners() {
|
|
14
|
-
if (!_a.provider ||
|
|
15
|
-
!_a.eventListenersSetup) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
_a.provider.off('accountsChanged', _a.accountChangedHandler);
|
|
19
|
-
_a.provider.off('chainChanged', _a.chainChangedHandler);
|
|
20
|
-
_a.provider.off('session_delete', _a.sessionDeleteHandler);
|
|
21
|
-
_a.eventListenersSetup = false;
|
|
22
|
-
}
|
|
23
|
-
static getMappedChainsByPreferredOrder() {
|
|
24
|
-
const allChains = _a.enabledNetworks.map((network) => `eip155:${network.chainId}`);
|
|
25
|
-
const reorderedChains = _a.preferredChains.filter((chain) => allChains.includes(chain));
|
|
26
|
-
const remainingChains = allChains.filter((chain) => !_a.preferredChains.includes(chain));
|
|
27
|
-
return [...reorderedChains, ...remainingChains].map((chain) => Number(chain.split(':')[1]));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
_a = WalletConnectProvider;
|
|
31
|
-
WalletConnectProvider.isInitialized = false;
|
|
32
|
-
WalletConnectProvider.enabledNetworks = [];
|
|
33
|
-
WalletConnectProvider.preferredChains = [];
|
|
34
|
-
WalletConnectProvider.evmNetworkRpcMap = {};
|
|
35
|
-
WalletConnectProvider.eventListenersSetup = false;
|
|
36
|
-
WalletConnectProvider.accountChangedHandler = () => { };
|
|
37
|
-
WalletConnectProvider.chainChangedHandler = () => { };
|
|
38
|
-
WalletConnectProvider.sessionDeleteHandler = () => { };
|
|
39
|
-
// this method should only be called once
|
|
40
|
-
// it initializes the provider, but does not starts a connection
|
|
41
|
-
WalletConnectProvider.init = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ storePrefix = 'dynamic-wc2', } = {}) {
|
|
42
|
-
logger.debug('[WalletConnectProvider] init', {
|
|
43
|
-
isInitialized: _a.isInitialized,
|
|
44
|
-
});
|
|
45
|
-
if (_a.isInitialized) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
_a.isInitialized = true;
|
|
49
|
-
logger.debug('[WalletConnectProvider] initializing');
|
|
50
|
-
_a.provider = yield EthereumProvider.init({
|
|
51
|
-
customStoragePrefix: storePrefix,
|
|
52
|
-
disableProviderPing: true,
|
|
53
|
-
optionalChains: _a.getMappedChainsByPreferredOrder(),
|
|
54
|
-
optionalEvents: ['chainChanged', 'accountsChanged'],
|
|
55
|
-
optionalMethods: [
|
|
56
|
-
'eth_chainId',
|
|
57
|
-
'eth_signTypedData',
|
|
58
|
-
'eth_signTransaction',
|
|
59
|
-
'eth_sign',
|
|
60
|
-
'personal_sign',
|
|
61
|
-
'eth_sendTransaction',
|
|
62
|
-
'eth_signTypedData_v4',
|
|
63
|
-
'wallet_switchEthereumChain',
|
|
64
|
-
'wallet_addEthereumChain',
|
|
65
|
-
],
|
|
66
|
-
projectId: _a.projectId,
|
|
67
|
-
rpcMap: _a.evmNetworkRpcMap,
|
|
68
|
-
showQrModal: false,
|
|
69
|
-
});
|
|
70
|
-
logger.debug('[WalletConnectProvider] initialized');
|
|
71
|
-
});
|
|
72
|
-
// this method should be called whenever we need to connect to a wallet
|
|
73
|
-
// when the page is refreshed, if the wallet is already connected,
|
|
74
|
-
// this method does not need to be called
|
|
75
|
-
WalletConnectProvider.connect = (_b) => __awaiter(void 0, [_b], void 0, function* ({ deepLinks, deepLinkPreference, connectionOpts, }) {
|
|
76
|
-
const handleDisplayURI = (uri) => {
|
|
77
|
-
var _b;
|
|
78
|
-
logger.debug('[WalletConnectProvider] handleDisplayURI', uri);
|
|
79
|
-
_a.connectionUri = uri;
|
|
80
|
-
performPlatformSpecificConnectionMethod(_a.connectionUri, deepLinks, {
|
|
81
|
-
onDesktopUri: connectionOpts === null || connectionOpts === void 0 ? void 0 : connectionOpts.onDesktopUri,
|
|
82
|
-
onDisplayUri: connectionOpts === null || connectionOpts === void 0 ? void 0 : connectionOpts.onDisplayUri,
|
|
83
|
-
}, deepLinkPreference);
|
|
84
|
-
logger.debug('[WalletConnectProvider] removing display_uri event listener');
|
|
85
|
-
(_b = _a.provider) === null || _b === void 0 ? void 0 : _b.off('display_uri', handleDisplayURI);
|
|
86
|
-
};
|
|
87
|
-
if (!_a.provider) {
|
|
88
|
-
throw new DynamicError('WalletConnectProvider is not initialized');
|
|
89
|
-
}
|
|
90
|
-
logger.debug('[WalletConnectProvider] adding display_uri event listener');
|
|
91
|
-
_a.provider.on('display_uri', handleDisplayURI);
|
|
92
|
-
try {
|
|
93
|
-
const result = yield _a.provider.enable();
|
|
94
|
-
logger.debug('[WalletConnectProvider] connected to WalletConnect', result);
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
logger.error('[WalletConnectProvider] Failed to connect to WalletConnect', error);
|
|
99
|
-
const customError = new DynamicError('Connection rejected. Please try again.');
|
|
100
|
-
customError.code = 'connection_rejected';
|
|
101
|
-
throw customError;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
// this method should be called whenever we need to disconnect from a wallet
|
|
105
|
-
// it will kill the connection, but not the provider
|
|
106
|
-
WalletConnectProvider.disconnect = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
|
-
if (!_a.provider) {
|
|
108
|
-
logger.debug('[WalletConnectProvider] disconnect - provider is not initialized');
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
logger.debug('[WalletConnectProvider] disconnecting from WalletConnect');
|
|
112
|
-
try {
|
|
113
|
-
yield _a.provider.disconnect();
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
logger.error('[WalletConnectProvider] Failed to disconnect from WalletConnect', error);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
WalletConnectProvider.getProvider = () => _a.provider;
|
|
120
|
-
WalletConnectProvider.handleChainChangedEvent = (chain, onChainChanged) => {
|
|
121
|
-
logger.debug('[WalletConnectProvider] handling chain change event', {
|
|
122
|
-
chain,
|
|
123
|
-
});
|
|
124
|
-
const chainId = parseIntSafe(chain);
|
|
125
|
-
if (!chainId) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
onChainChanged === null || onChainChanged === void 0 ? void 0 : onChainChanged(chainId);
|
|
129
|
-
};
|
|
130
|
-
WalletConnectProvider.handleAccountChangedEvent = (accounts, onAccountChanged) => {
|
|
131
|
-
logger.debug('[WalletConnectProvider] handling account change event', {
|
|
132
|
-
accounts,
|
|
133
|
-
});
|
|
134
|
-
const [account] = accounts;
|
|
135
|
-
const address = account.includes(':') ? account.split(':').pop() : account;
|
|
136
|
-
if (!address) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
onAccountChanged === null || onAccountChanged === void 0 ? void 0 : onAccountChanged(address);
|
|
140
|
-
};
|
|
141
|
-
WalletConnectProvider.setupEventListeners = ({ onChainChanged, onAccountChanged, onDisconnect, }) => {
|
|
142
|
-
if (!_a.provider ||
|
|
143
|
-
_a.eventListenersSetup) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
_a.chainChangedHandler = (chainId) => {
|
|
147
|
-
_a.handleChainChangedEvent(chainId, onChainChanged);
|
|
148
|
-
};
|
|
149
|
-
_a.accountChangedHandler = (account) => {
|
|
150
|
-
_a.handleAccountChangedEvent(account, onAccountChanged);
|
|
151
|
-
};
|
|
152
|
-
_a.sessionDeleteHandler = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
153
|
-
onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect();
|
|
154
|
-
});
|
|
155
|
-
_a.provider.on('accountsChanged', _a.accountChangedHandler);
|
|
156
|
-
_a.provider.on('chainChanged', _a.chainChangedHandler);
|
|
157
|
-
_a.provider.on('session_delete', _a.sessionDeleteHandler);
|
|
158
|
-
_a.eventListenersSetup = true;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export { WalletConnectProvider };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { WalletConnectProvider } from './WalletConnectProvider';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var WalletConnectConnector = require('../WalletConnectConnector/WalletConnectConnector.cjs');
|
|
7
|
-
|
|
8
|
-
const getWalletConnectConnector = () => class extends WalletConnectConnector.WalletConnectConnector {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
exports.getWalletConnectConnector = getWalletConnectConnector;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { WalletConnectConnector } from '../WalletConnectConnector/WalletConnectConnector.js';
|
|
3
|
-
|
|
4
|
-
const getWalletConnectConnector = () => class extends WalletConnectConnector {
|
|
5
|
-
constructor(props) {
|
|
6
|
-
super(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { getWalletConnectConnector };
|