@dynamic-labs/ethereum 3.9.6 → 3.9.8
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 +16 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/walletConnect/walletConnect.cjs +33 -33
- package/src/walletConnect/walletConnect.d.ts +3039 -3
- package/src/walletConnect/walletConnect.js +33 -33
|
@@ -41,10 +41,7 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
41
41
|
: undefined;
|
|
42
42
|
}
|
|
43
43
|
getMappedChains() {
|
|
44
|
-
return
|
|
45
|
-
// Filters out palm that crashes Trust Wallet
|
|
46
|
-
.filter((network) => network.chainId !== 11297108109)
|
|
47
|
-
.map((network) => `eip155:${network.chainId}`));
|
|
44
|
+
return this.evmNetworks.map((network) => `eip155:${network.chainId}`);
|
|
48
45
|
}
|
|
49
46
|
getMappedChainsByPreferredOrder() {
|
|
50
47
|
const allChains = this.getMappedChains();
|
|
@@ -91,15 +88,19 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
91
88
|
});
|
|
92
89
|
});
|
|
93
90
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
getWalletClient(chainId) {
|
|
92
|
+
const walletConnect = this.createProvider();
|
|
93
|
+
const walletClient = createWalletClient({
|
|
94
|
+
account: this.getActiveAccount(),
|
|
95
|
+
chain: chainsMap[chainId !== null && chainId !== void 0 ? chainId : String(this.currentChainId)],
|
|
96
|
+
transport: custom({
|
|
97
|
+
request: (args) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const provider = yield walletConnect;
|
|
99
|
+
return provider.request(args);
|
|
100
|
+
}),
|
|
101
|
+
}),
|
|
102
102
|
});
|
|
103
|
+
return walletClient;
|
|
103
104
|
}
|
|
104
105
|
createInitProviderPromise() {
|
|
105
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -123,14 +124,23 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
126
|
refreshSession() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
var _a, _b, _c, _d, _e;
|
|
129
|
+
if ((_b = (_a = WalletConnect.provider) === null || _a === void 0 ? void 0 : _a.session) === null || _b === void 0 ? void 0 : _b.topic) {
|
|
130
|
+
if (localStorage.getItem(this.sessionTopicKey) ===
|
|
131
|
+
((_d = (_c = WalletConnect.provider) === null || _c === void 0 ? void 0 : _c.session) === null || _d === void 0 ? void 0 : _d.topic)) {
|
|
132
|
+
this.session = WalletConnect.provider.session;
|
|
133
|
+
this.setActiveAccount(((_e = localStorage.getItem(this.activeAccountKey)) !== null && _e !== void 0 ? _e : undefined));
|
|
134
|
+
}
|
|
132
135
|
}
|
|
133
|
-
|
|
136
|
+
const walletClient = this.getWalletClient();
|
|
137
|
+
const walletChainId = yield walletClient.getChainId();
|
|
138
|
+
logger.debug('checking selected chain in refreshSession', this.name, walletChainId, this.currentChainId);
|
|
139
|
+
if (this.currentChainId && this.currentChainId !== walletChainId) {
|
|
140
|
+
logger.debug('switching to selected chain', this.currentChainId);
|
|
141
|
+
yield walletClient.switchChain({ id: this.currentChainId });
|
|
142
|
+
}
|
|
143
|
+
});
|
|
134
144
|
}
|
|
135
145
|
init() {
|
|
136
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -230,16 +240,6 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
230
240
|
WalletConnect.provider.off('session_event', this.sessionEventHandler);
|
|
231
241
|
WalletConnect.provider.off('session_delete', this.sessionDeleteHandler);
|
|
232
242
|
}
|
|
233
|
-
getWalletClient(chainId) {
|
|
234
|
-
if (!WalletConnect.provider) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
return createWalletClient({
|
|
238
|
-
account: this.getActiveAccount(),
|
|
239
|
-
chain: chainsMap[chainId !== null && chainId !== void 0 ? chainId : String(this.currentChainId)],
|
|
240
|
-
transport: custom(WalletConnect.provider),
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
243
|
getAddress(opts) {
|
|
244
244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
245
245
|
var _a, _b;
|
|
@@ -376,7 +376,7 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
376
376
|
if (!activeAccount) {
|
|
377
377
|
return;
|
|
378
378
|
}
|
|
379
|
-
const walletClient = yield this.
|
|
379
|
+
const walletClient = yield this.getWalletClient();
|
|
380
380
|
return walletClient.signMessage({
|
|
381
381
|
account: activeAccount,
|
|
382
382
|
message: messageToSign,
|
|
@@ -457,7 +457,7 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
457
457
|
if (!this.supportsNetworkSwitching()) {
|
|
458
458
|
throw new DynamicError('Network switching not supported');
|
|
459
459
|
}
|
|
460
|
-
const walletClient = yield this.
|
|
460
|
+
const walletClient = yield this.getWalletClient();
|
|
461
461
|
if (this.isMetaMask()) {
|
|
462
462
|
const deepLink = this.getDeepLink();
|
|
463
463
|
if (deepLink) {
|
|
@@ -474,7 +474,7 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
474
474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
475
475
|
if (this.isInitialized === false) {
|
|
476
476
|
yield this.initProvider();
|
|
477
|
-
this.refreshSession();
|
|
477
|
+
yield this.refreshSession();
|
|
478
478
|
this.isInitialized = true;
|
|
479
479
|
}
|
|
480
480
|
const activeAccount = this.getActiveAccount();
|
|
@@ -492,7 +492,7 @@ class WalletConnect extends EthereumWalletConnector {
|
|
|
492
492
|
return __awaiter(this, void 0, void 0, function* () {
|
|
493
493
|
var _a;
|
|
494
494
|
yield this.initProvider();
|
|
495
|
-
this.refreshSession();
|
|
495
|
+
yield this.refreshSession();
|
|
496
496
|
if (this.isMetaMask()) {
|
|
497
497
|
if (this.hasSwitchedNetwork) {
|
|
498
498
|
return [String(this.currentChainId)];
|