@dynamic-labs/ethereum-core 3.0.0-alpha.57 → 3.0.0-alpha.59
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
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.0.0-alpha.59](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.58...v3.0.0-alpha.59) (2024-09-05)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* global wallet mobile scanner ([#6801](https://github.com/dynamic-labs/DynamicAuth/issues/6801)) ([8d10661](https://github.com/dynamic-labs/DynamicAuth/commit/8d106615105988f4019f7a320961e94fbe35f6dc))
|
|
8
|
+
|
|
9
|
+
## [3.0.0-alpha.58](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.57...v3.0.0-alpha.58) (2024-09-05)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### ⚠ BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* remove headless prop from DynamicContextProvider ([#6806](https://github.com/dynamic-labs/DynamicAuth/issues/6806)) ([1ab55a1](https://github.com/dynamic-labs/DynamicAuth/commit/1ab55a1cf5d143316617aa88a487bb59446f6f28))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* allow selecting which MetaMask account to connect with when linking new wallet ([#6796](https://github.com/dynamic-labs/DynamicAuth/issues/6796)) ([83e270f](https://github.com/dynamic-labs/DynamicAuth/commit/83e270ffd53d5f6c95464cf570663e1008ffa6fb))
|
|
19
|
+
|
|
2
20
|
## [3.0.0-alpha.57](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.56...v3.0.0-alpha.57) (2024-09-05)
|
|
3
21
|
|
|
4
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum-core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.59",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"viem": "^2.7.6",
|
|
33
|
-
"@dynamic-labs/logger": "3.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/rpc-providers": "3.0.0-alpha.
|
|
35
|
-
"@dynamic-labs/types": "3.0.0-alpha.
|
|
36
|
-
"@dynamic-labs/utils": "3.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/wallet-book": "3.0.0-alpha.
|
|
38
|
-
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.
|
|
33
|
+
"@dynamic-labs/logger": "3.0.0-alpha.59",
|
|
34
|
+
"@dynamic-labs/rpc-providers": "3.0.0-alpha.59",
|
|
35
|
+
"@dynamic-labs/types": "3.0.0-alpha.59",
|
|
36
|
+
"@dynamic-labs/utils": "3.0.0-alpha.59",
|
|
37
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.59",
|
|
38
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.59"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -137,15 +137,44 @@ class EthWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
137
137
|
return this.providerSwitchNetwork({ network, provider });
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
chooseAccountsToConnect() {
|
|
141
141
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
var _a, _b, _c;
|
|
142
143
|
const provider = this.getWalletClient();
|
|
143
144
|
if (!provider)
|
|
144
145
|
return [];
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
const result = yield provider.requestPermissions({ eth_accounts: {} });
|
|
147
|
+
walletConnectorCore.logger.debug('chooseAccountsToConnect - requestPermissions result', result);
|
|
148
|
+
// this should return the connected addresses for MM
|
|
149
|
+
const addresses = (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.find((r) => r.parentCapability === 'eth_accounts')) === null || _a === void 0 ? void 0 : _a.caveats) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value;
|
|
150
|
+
if (typeof addresses === 'string') {
|
|
151
|
+
return [addresses];
|
|
152
|
+
}
|
|
153
|
+
if (Array.isArray(addresses)) {
|
|
154
|
+
return addresses;
|
|
155
|
+
}
|
|
156
|
+
return [];
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
getConnectedAccounts(options) {
|
|
160
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
const provider = this.getWalletClient();
|
|
162
|
+
if (!provider)
|
|
163
|
+
return [];
|
|
164
|
+
let addresses = [];
|
|
165
|
+
// some wallets like MM and Phantom won't return the selected account if
|
|
166
|
+
// it's not connected to the dapp, and the only way we can prompt for a connection in MM
|
|
167
|
+
// is by calling requestPermissions, which wil allow the user to choose the accounts to connect
|
|
168
|
+
if (options === null || options === void 0 ? void 0 : options.chooseAccounts) {
|
|
169
|
+
addresses = yield this.chooseAccountsToConnect();
|
|
170
|
+
walletConnectorCore.logger.debug('getConnectedAccounts - Chosen addresses', addresses);
|
|
171
|
+
}
|
|
172
|
+
if (!addresses.length) {
|
|
173
|
+
addresses = yield utils.retryableFn(provider.getAddresses, {
|
|
174
|
+
fallbackValue: [],
|
|
175
|
+
timeoutMs: 500,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
149
178
|
if (addresses.length) {
|
|
150
179
|
this.setActiveAccount(addresses[0]);
|
|
151
180
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account, Hex, PublicClient, Transport, Chain as ViemChain, WalletClient } from 'viem';
|
|
2
2
|
import { EvmNetwork, GenericNetwork, IUITransaction, TransactionReceipt } from '@dynamic-labs/types';
|
|
3
3
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
4
|
-
import { ISendBalanceWalletConnector, NameServiceData, WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { ISendBalanceWalletConnector, NameServiceData, WalletConnectorBase, GetConnectedAccountsOpts } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { IChainRpcProviders } from '../rpc';
|
|
6
6
|
import { EthereumWallet } from '../wallet';
|
|
7
7
|
export type SwitchNetworkOps = {
|
|
@@ -3069,7 +3069,8 @@ export declare abstract class EthWalletConnector extends WalletConnectorBase<typ
|
|
|
3069
3069
|
getBalance(address: string): Promise<string | undefined>;
|
|
3070
3070
|
supportsNetworkSwitching(): boolean;
|
|
3071
3071
|
switchNetwork({ networkName, networkChainId, }: SwitchNetworkOps): Promise<void>;
|
|
3072
|
-
|
|
3072
|
+
chooseAccountsToConnect(): Promise<string[]>;
|
|
3073
|
+
getConnectedAccounts(options?: GetConnectedAccountsOpts): Promise<string[]>;
|
|
3073
3074
|
providerSwitchNetwork({ network, provider, }: {
|
|
3074
3075
|
network: EvmNetwork;
|
|
3075
3076
|
provider: WalletClient;
|
|
@@ -133,15 +133,44 @@ class EthWalletConnector extends WalletConnectorBase {
|
|
|
133
133
|
return this.providerSwitchNetwork({ network, provider });
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
chooseAccountsToConnect() {
|
|
137
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
var _a, _b, _c;
|
|
138
139
|
const provider = this.getWalletClient();
|
|
139
140
|
if (!provider)
|
|
140
141
|
return [];
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
const result = yield provider.requestPermissions({ eth_accounts: {} });
|
|
143
|
+
logger.debug('chooseAccountsToConnect - requestPermissions result', result);
|
|
144
|
+
// this should return the connected addresses for MM
|
|
145
|
+
const addresses = (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.find((r) => r.parentCapability === 'eth_accounts')) === null || _a === void 0 ? void 0 : _a.caveats) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value;
|
|
146
|
+
if (typeof addresses === 'string') {
|
|
147
|
+
return [addresses];
|
|
148
|
+
}
|
|
149
|
+
if (Array.isArray(addresses)) {
|
|
150
|
+
return addresses;
|
|
151
|
+
}
|
|
152
|
+
return [];
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
getConnectedAccounts(options) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
const provider = this.getWalletClient();
|
|
158
|
+
if (!provider)
|
|
159
|
+
return [];
|
|
160
|
+
let addresses = [];
|
|
161
|
+
// some wallets like MM and Phantom won't return the selected account if
|
|
162
|
+
// it's not connected to the dapp, and the only way we can prompt for a connection in MM
|
|
163
|
+
// is by calling requestPermissions, which wil allow the user to choose the accounts to connect
|
|
164
|
+
if (options === null || options === void 0 ? void 0 : options.chooseAccounts) {
|
|
165
|
+
addresses = yield this.chooseAccountsToConnect();
|
|
166
|
+
logger.debug('getConnectedAccounts - Chosen addresses', addresses);
|
|
167
|
+
}
|
|
168
|
+
if (!addresses.length) {
|
|
169
|
+
addresses = yield retryableFn(provider.getAddresses, {
|
|
170
|
+
fallbackValue: [],
|
|
171
|
+
timeoutMs: 500,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
145
174
|
if (addresses.length) {
|
|
146
175
|
this.setActiveAccount(addresses[0]);
|
|
147
176
|
}
|