@dynamic-labs/ethereum 2.0.0-alpha.10 → 2.0.0-alpha.12
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 +39 -0
- package/package.json +8 -7
- 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 +5 -5
- package/src/coinbase/coinbase.d.ts +3 -3
- package/src/coinbase/coinbase.js +6 -6
- package/src/ethProviderHelper.cjs +10 -5
- package/src/ethProviderHelper.d.ts +4 -3
- package/src/ethProviderHelper.js +10 -5
- package/src/injected/InjectedWalletBase.cjs +5 -5
- package/src/injected/InjectedWalletBase.d.ts +2 -2
- package/src/injected/InjectedWalletBase.js +5 -5
- package/src/injected/PhantomEvm.cjs +3 -3
- package/src/injected/PhantomEvm.d.ts +1 -1
- package/src/injected/PhantomEvm.js +3 -3
- package/src/walletConnect/walletConnect.cjs +6 -2
- package/src/walletConnect/walletConnect.d.ts +13 -13
- package/src/walletConnect/walletConnect.js +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.0.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.11...v2.0.0-alpha.12) (2024-03-13)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add sign-in with farcaster ([#4947](https://github.com/dynamic-labs/DynamicAuth/issues/4947)) ([3927d24](https://github.com/dynamic-labs/DynamicAuth/commit/3927d24392a8944997ca05431c6ab54757be62d9))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* wallet connect links with query params ([#4948](https://github.com/dynamic-labs/DynamicAuth/issues/4948)) ([0738130](https://github.com/dynamic-labs/DynamicAuth/commit/0738130f82473a197e035b8dd74d996bdbb24c11))
|
|
13
|
+
|
|
14
|
+
## [2.0.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.10...v2.0.0-alpha.11) (2024-03-12)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### ⚠ BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
* rename FetchPublicAddressOpts to GetAddressOpts (#4910)
|
|
20
|
+
* remove use effect in useWalletEventListeners (#4843)
|
|
21
|
+
* rename fetchPublicAddress to getAddress (#4851)
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* Add farcaster to iconic ([#4925](https://github.com/dynamic-labs/DynamicAuth/issues/4925)) ([ab282dc](https://github.com/dynamic-labs/DynamicAuth/commit/ab282dc9cdcc0fe11f014d002b056ef4d3b34234))
|
|
26
|
+
* use transaction confirmation ui on signAndSendTransaction for solana embedded wallets ([#4909](https://github.com/dynamic-labs/DynamicAuth/issues/4909)) ([d77e89e](https://github.com/dynamic-labs/DynamicAuth/commit/d77e89ecff9dfc67ed48537f541a9995b2662e1e))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* add back connect button css variables ([#4922](https://github.com/dynamic-labs/DynamicAuth/issues/4922)) ([1119d62](https://github.com/dynamic-labs/DynamicAuth/commit/1119d62c2db6504952393060930524c3823e4a00))
|
|
32
|
+
* keep adaptive wallet list height ([#4916](https://github.com/dynamic-labs/DynamicAuth/issues/4916)) ([62aa54e](https://github.com/dynamic-labs/DynamicAuth/commit/62aa54e81d563082f7aa519f2ff2b5132e7dd83d))
|
|
33
|
+
* pass account and chain to walletClient ([#4865](https://github.com/dynamic-labs/DynamicAuth/issues/4865)) ([17a143f](https://github.com/dynamic-labs/DynamicAuth/commit/17a143f87a77e56227b2517038c20cf67f8e08bf))
|
|
34
|
+
* update walletbook to fix zerion in-app browser detection issue ([#4917](https://github.com/dynamic-labs/DynamicAuth/issues/4917)) ([48b05d7](https://github.com/dynamic-labs/DynamicAuth/commit/48b05d78e4f7add09787b64505723d4eca34d3e0))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
* remove use effect in useWalletEventListeners ([#4843](https://github.com/dynamic-labs/DynamicAuth/issues/4843)) ([2e948bb](https://github.com/dynamic-labs/DynamicAuth/commit/2e948bbca0dbdceab7460a844d0988eacd47f581))
|
|
38
|
+
* rename fetchPublicAddress to getAddress ([#4851](https://github.com/dynamic-labs/DynamicAuth/issues/4851)) ([668e7dd](https://github.com/dynamic-labs/DynamicAuth/commit/668e7dd62e1f323dbe64209b5c59c2cd0ee45d61))
|
|
39
|
+
* rename FetchPublicAddressOpts to GetAddressOpts ([#4910](https://github.com/dynamic-labs/DynamicAuth/issues/4910)) ([e5e4b1b](https://github.com/dynamic-labs/DynamicAuth/commit/e5e4b1b08a4e010afa44f8abb0bf6af7f236a86a))
|
|
40
|
+
|
|
2
41
|
## [2.0.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.9...v2.0.0-alpha.10) (2024-03-08)
|
|
3
42
|
|
|
4
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/ethereum",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -30,12 +30,13 @@
|
|
|
30
30
|
"@walletconnect/universal-provider": "2.10.6",
|
|
31
31
|
"eventemitter3": "5.0.1",
|
|
32
32
|
"buffer": "6.0.3",
|
|
33
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/turnkey": "2.0.0-alpha.
|
|
35
|
-
"@dynamic-labs/types": "2.0.0-alpha.
|
|
36
|
-
"@dynamic-labs/utils": "2.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/
|
|
38
|
-
"@dynamic-labs/wallet-
|
|
33
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.0.0-alpha.12",
|
|
34
|
+
"@dynamic-labs/turnkey": "2.0.0-alpha.12",
|
|
35
|
+
"@dynamic-labs/types": "2.0.0-alpha.12",
|
|
36
|
+
"@dynamic-labs/utils": "2.0.0-alpha.12",
|
|
37
|
+
"@dynamic-labs/viem-utils": "2.0.0-alpha.12",
|
|
38
|
+
"@dynamic-labs/wallet-book": "2.0.0-alpha.12",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.12",
|
|
39
40
|
"stream": "0.0.2"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
@@ -36,7 +36,7 @@ const killCoinbaseSession = () => _tslib.__awaiter(void 0, void 0, void 0, funct
|
|
|
36
36
|
// were set in the SDK reset, and they need to be initialized again.
|
|
37
37
|
coinbaseProvider = undefined;
|
|
38
38
|
});
|
|
39
|
-
const
|
|
39
|
+
const getAddress = (coinbaseProviderOpts, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
var _a;
|
|
41
41
|
const provider = getCoinbaseProvider({ opts: coinbaseProviderOpts });
|
|
42
42
|
const { qrUrl } = provider;
|
|
@@ -66,7 +66,7 @@ const signMessage = (coinbaseProviderOpts, messageToSign) => _tslib.__awaiter(vo
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
exports.
|
|
69
|
+
exports.getAddress = getAddress;
|
|
70
70
|
exports.getCoinbaseProvider = getCoinbaseProvider;
|
|
71
71
|
exports.killCoinbaseSession = killCoinbaseSession;
|
|
72
72
|
exports.signMessage = signMessage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GetAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
import { GetCoinbaseProvider, GetCoinbaseProviderOpts } from './types';
|
|
3
3
|
export declare const getCoinbaseProvider: GetCoinbaseProvider;
|
|
4
4
|
export declare const killCoinbaseSession: () => Promise<void>;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const getAddress: (coinbaseProviderOpts: GetCoinbaseProviderOpts, opts?: GetAddressOpts) => Promise<string | undefined>;
|
|
6
6
|
export declare const signMessage: (coinbaseProviderOpts: GetCoinbaseProviderOpts, messageToSign: string) => Promise<string | undefined>;
|
|
@@ -32,7 +32,7 @@ const killCoinbaseSession = () => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
32
32
|
// were set in the SDK reset, and they need to be initialized again.
|
|
33
33
|
coinbaseProvider = undefined;
|
|
34
34
|
});
|
|
35
|
-
const
|
|
35
|
+
const getAddress = (coinbaseProviderOpts, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
var _a;
|
|
37
37
|
const provider = getCoinbaseProvider({ opts: coinbaseProviderOpts });
|
|
38
38
|
const { qrUrl } = provider;
|
|
@@ -62,4 +62,4 @@ const signMessage = (coinbaseProviderOpts, messageToSign) => __awaiter(void 0, v
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
export {
|
|
65
|
+
export { getAddress, getCoinbaseProvider, killCoinbaseSession, signMessage };
|
|
@@ -44,10 +44,10 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
44
44
|
return;
|
|
45
45
|
this.teardownEventListeners = setupResponse.tearDownEventListeners;
|
|
46
46
|
}
|
|
47
|
-
getWalletClient() {
|
|
47
|
+
getWalletClient(chainId) {
|
|
48
48
|
var _a;
|
|
49
49
|
if (this.isInstalledOnBrowser()) {
|
|
50
|
-
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient();
|
|
50
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
51
51
|
}
|
|
52
52
|
return viem.createWalletClient({
|
|
53
53
|
transport: viem.custom(client.getCoinbaseProvider({
|
|
@@ -59,13 +59,13 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
59
59
|
var _a;
|
|
60
60
|
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
getAddress(opts) {
|
|
63
63
|
var _a;
|
|
64
64
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
65
65
|
if (this.isInstalledOnBrowser()) {
|
|
66
|
-
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.
|
|
66
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
67
67
|
}
|
|
68
|
-
return client.
|
|
68
|
+
return client.getAddress(this.coinbaseProviderOpts, opts);
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
signMessage(messageToSign) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain,
|
|
1
|
+
import { Chain, GetAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
import { EthProviderHelper } from '..';
|
|
3
3
|
import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
4
4
|
type CoinbaseOpts = EthWalletConnectorOpts & {
|
|
@@ -15,7 +15,7 @@ export declare class Coinbase extends EthWalletConnector {
|
|
|
15
15
|
ethProviderHelper: EthProviderHelper | undefined;
|
|
16
16
|
constructor({ appName, appLogoUrl, evmNetworks, ...props }: CoinbaseOpts);
|
|
17
17
|
setupEventListeners(): void;
|
|
18
|
-
getWalletClient(): {
|
|
18
|
+
getWalletClient(chainId?: string): {
|
|
19
19
|
account: import("viem").Account | undefined;
|
|
20
20
|
batch?: {
|
|
21
21
|
multicall?: boolean | {
|
|
@@ -531,7 +531,7 @@ export declare class Coinbase extends EthWalletConnector {
|
|
|
531
531
|
} & Partial<Pick<import("viem").PublicActions<import("viem").CustomTransport, undefined, undefined>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<undefined, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client_1) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K_1 in keyof client_1]: client_1[K_1]; } & import("viem").WalletActions<undefined, undefined>>;
|
|
532
532
|
} | undefined;
|
|
533
533
|
isInstalledOnBrowser(): boolean;
|
|
534
|
-
|
|
534
|
+
getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
|
|
535
535
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
536
536
|
endSession(): Promise<void>;
|
|
537
537
|
}
|
package/src/coinbase/coinbase.js
CHANGED
|
@@ -7,7 +7,7 @@ import '@dynamic-labs/utils';
|
|
|
7
7
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
8
8
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
9
9
|
import '../walletConnect/walletConnect.js';
|
|
10
|
-
import { getCoinbaseProvider,
|
|
10
|
+
import { getCoinbaseProvider, getAddress, signMessage, killCoinbaseSession } from './client/client.js';
|
|
11
11
|
import '@dynamic-labs/rpc-provider-ethereum';
|
|
12
12
|
|
|
13
13
|
class Coinbase extends EthWalletConnector {
|
|
@@ -40,10 +40,10 @@ class Coinbase extends EthWalletConnector {
|
|
|
40
40
|
return;
|
|
41
41
|
this.teardownEventListeners = setupResponse.tearDownEventListeners;
|
|
42
42
|
}
|
|
43
|
-
getWalletClient() {
|
|
43
|
+
getWalletClient(chainId) {
|
|
44
44
|
var _a;
|
|
45
45
|
if (this.isInstalledOnBrowser()) {
|
|
46
|
-
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);
|
|
47
47
|
}
|
|
48
48
|
return createWalletClient({
|
|
49
49
|
transport: custom(getCoinbaseProvider({
|
|
@@ -55,13 +55,13 @@ class Coinbase extends EthWalletConnector {
|
|
|
55
55
|
var _a;
|
|
56
56
|
return ((_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
getAddress(opts) {
|
|
59
59
|
var _a;
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
61
|
if (this.isInstalledOnBrowser()) {
|
|
62
|
-
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.
|
|
62
|
+
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
63
63
|
}
|
|
64
|
-
return
|
|
64
|
+
return getAddress(this.coinbaseProviderOpts, opts);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
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
|
}
|
|
@@ -43,23 +43,23 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
43
43
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
44
44
|
this.teardownEventListeners = tearDownEventListeners;
|
|
45
45
|
}
|
|
46
|
-
getWalletClient() {
|
|
46
|
+
getWalletClient(chainId) {
|
|
47
47
|
var _a;
|
|
48
|
-
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);
|
|
49
49
|
}
|
|
50
50
|
isInstalledOnBrowser() {
|
|
51
51
|
var _a;
|
|
52
52
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
getAddress() {
|
|
55
55
|
var _a;
|
|
56
56
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.
|
|
57
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
connect() {
|
|
61
61
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
yield this.
|
|
62
|
+
yield this.getAddress();
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
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>;
|
|
@@ -41,23 +41,23 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
41
41
|
const { tearDownEventListeners } = ethProviderHelper._setupEventListeners(this);
|
|
42
42
|
this.teardownEventListeners = tearDownEventListeners;
|
|
43
43
|
}
|
|
44
|
-
getWalletClient() {
|
|
44
|
+
getWalletClient(chainId) {
|
|
45
45
|
var _a;
|
|
46
|
-
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);
|
|
47
47
|
}
|
|
48
48
|
isInstalledOnBrowser() {
|
|
49
49
|
var _a;
|
|
50
50
|
return ((_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.findProvider()) !== undefined;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
getAddress() {
|
|
53
53
|
var _a;
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.
|
|
55
|
+
return (_a = this.getEthProviderHelper()) === null || _a === void 0 ? void 0 : _a.getAddress();
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
connect() {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
yield this.
|
|
60
|
+
yield this.getAddress();
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
signMessage(messageToSign) {
|
|
@@ -14,13 +14,13 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
14
14
|
this.overrideKey = 'phantomevm';
|
|
15
15
|
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
getAddress() {
|
|
18
18
|
const _super = Object.create(null, {
|
|
19
|
-
|
|
19
|
+
getAddress: { get: () => super.getAddress }
|
|
20
20
|
});
|
|
21
21
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
if (this.isInstalledOnBrowser()) {
|
|
23
|
-
return _super.
|
|
23
|
+
return _super.getAddress.call(this);
|
|
24
24
|
}
|
|
25
25
|
if (utils.isMobile()) {
|
|
26
26
|
utils.handleMobileWalletRedirect({
|
|
@@ -10,13 +10,13 @@ class PhantomEvm extends InjectedWalletBase {
|
|
|
10
10
|
this.overrideKey = 'phantomevm';
|
|
11
11
|
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
getAddress() {
|
|
14
14
|
const _super = Object.create(null, {
|
|
15
|
-
|
|
15
|
+
getAddress: { get: () => super.getAddress }
|
|
16
16
|
});
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
if (this.isInstalledOnBrowser()) {
|
|
19
|
-
return _super.
|
|
19
|
+
return _super.getAddress.call(this);
|
|
20
20
|
}
|
|
21
21
|
if (isMobile()) {
|
|
22
22
|
handleMobileWalletRedirect({
|
|
@@ -6,9 +6,11 @@ var _tslib = require('../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var Provider = require('@walletconnect/universal-provider');
|
|
7
7
|
var EventEmitter = require('eventemitter3');
|
|
8
8
|
var viem = require('viem');
|
|
9
|
+
var accounts = require('viem/accounts');
|
|
9
10
|
var utils = require('@dynamic-labs/utils');
|
|
10
11
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
11
12
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
13
|
+
var viemUtils = require('@dynamic-labs/viem-utils');
|
|
12
14
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
13
15
|
var parseIntSafe = require('../utils/parseIntSafe.cjs');
|
|
14
16
|
|
|
@@ -221,15 +223,17 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
221
223
|
WalletConnect.provider.client.removeAllListeners('session_event');
|
|
222
224
|
WalletConnect.provider.client.removeAllListeners('session_delete');
|
|
223
225
|
}
|
|
224
|
-
getWalletClient() {
|
|
226
|
+
getWalletClient(chainId) {
|
|
225
227
|
if (!WalletConnect.provider) {
|
|
226
228
|
return;
|
|
227
229
|
}
|
|
228
230
|
return viem.createWalletClient({
|
|
231
|
+
account: this.activeAccount ? accounts.toAccount(this.activeAccount) : undefined,
|
|
232
|
+
chain: chainId ? viemUtils.chainsMap[chainId] : undefined,
|
|
229
233
|
transport: viem.custom(WalletConnect.provider),
|
|
230
234
|
});
|
|
231
235
|
}
|
|
232
|
-
|
|
236
|
+
getAddress(opts) {
|
|
233
237
|
var _a, _b;
|
|
234
238
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
235
239
|
if (this.activeAccount) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SessionTypes } from '@walletconnect/types';
|
|
2
2
|
import { Hex, WalletClient } from 'viem';
|
|
3
3
|
import { EvmNetwork } from '@dynamic-labs/types';
|
|
4
|
-
import { Chain, DeepLinkVariant,
|
|
4
|
+
import { Chain, DeepLinkVariant, GetAddressOpts, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { EthWalletConnector, EthWalletConnectorOpts } from '../EthWalletConnector';
|
|
6
6
|
export type WalletConnectOpts = EthWalletConnectorOpts & {
|
|
7
7
|
projectId?: string;
|
|
@@ -44,8 +44,8 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
|
|
|
44
44
|
supportsNetworkSwitching(): boolean;
|
|
45
45
|
setupEventListeners(): void;
|
|
46
46
|
teardownEventListeners(): void;
|
|
47
|
-
getWalletClient(): {
|
|
48
|
-
account: undefined;
|
|
47
|
+
getWalletClient(chainId?: string): {
|
|
48
|
+
account: import("viem").JsonRpcAccount | undefined;
|
|
49
49
|
batch?: {
|
|
50
50
|
multicall?: boolean | {
|
|
51
51
|
batchSize?: number | undefined;
|
|
@@ -53,7 +53,7 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
|
|
|
53
53
|
} | undefined;
|
|
54
54
|
} | undefined;
|
|
55
55
|
cacheTime: number;
|
|
56
|
-
chain: undefined;
|
|
56
|
+
chain: import("viem").Chain | undefined;
|
|
57
57
|
key: string;
|
|
58
58
|
name: string;
|
|
59
59
|
pollingInterval: number;
|
|
@@ -62,20 +62,20 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
|
|
|
62
62
|
type: string;
|
|
63
63
|
uid: string;
|
|
64
64
|
addChain: (args: import("viem").AddChainParameters) => Promise<void>;
|
|
65
|
-
deployContract: <const abi extends import("viem").Abi | readonly unknown[], chainOverride extends import("viem").Chain | undefined>(args: import("viem").DeployContractParameters<abi, undefined, undefined, chainOverride>) => Promise<`0x${string}`>;
|
|
65
|
+
deployContract: <const abi extends import("viem").Abi | readonly unknown[], chainOverride extends import("viem").Chain | undefined>(args: import("viem").DeployContractParameters<abi, import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined, chainOverride>) => Promise<`0x${string}`>;
|
|
66
66
|
getAddresses: () => Promise<import("viem").GetAddressesReturnType>;
|
|
67
67
|
getChainId: () => Promise<number>;
|
|
68
68
|
getPermissions: () => Promise<import("viem").GetPermissionsReturnType>;
|
|
69
|
-
prepareTransactionRequest: <TParameterType extends import("viem").PrepareTransactionRequestParameterType, TChainOverride extends import("viem").Chain | undefined = undefined, TAccountOverride extends `0x${string}` | import("viem").Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<undefined, undefined, TChainOverride, TAccountOverride, TParameterType>) => Promise<import("viem").PrepareTransactionRequestReturnType<import("viem").Chain, undefined, TChainOverride, TAccountOverride, TParameterType>>;
|
|
69
|
+
prepareTransactionRequest: <TParameterType extends import("viem").PrepareTransactionRequestParameterType, TChainOverride extends import("viem").Chain | undefined = undefined, TAccountOverride extends `0x${string}` | import("viem").Account | undefined = undefined>(args: import("viem").PrepareTransactionRequestParameters<import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined, TChainOverride, TAccountOverride, TParameterType>) => Promise<import("viem").PrepareTransactionRequestReturnType<import("viem").Chain, import("viem").JsonRpcAccount | undefined, TChainOverride, TAccountOverride, TParameterType>>;
|
|
70
70
|
requestAddresses: () => Promise<import("viem").RequestAddressesReturnType>;
|
|
71
71
|
requestPermissions: (args: {
|
|
72
72
|
[x: string]: Record<string, any>;
|
|
73
73
|
eth_accounts: Record<string, any>;
|
|
74
74
|
}) => Promise<import("viem").RequestPermissionsReturnType>;
|
|
75
75
|
sendRawTransaction: (args: import("viem").SendRawTransactionParameters) => Promise<`0x${string}`>;
|
|
76
|
-
sendTransaction: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<undefined, undefined, TChainOverride_1>) => Promise<`0x${string}`>;
|
|
77
|
-
signMessage: (args: import("viem").SignMessageParameters<undefined>) => Promise<`0x${string}`>;
|
|
78
|
-
signTransaction: <TChainOverride_2 extends import("viem").Chain | undefined>(args: import("viem").SignTransactionParameters<undefined, undefined, TChainOverride_2>) => Promise<`0x${string}`>;
|
|
76
|
+
sendTransaction: <TChainOverride_1 extends import("viem").Chain | undefined = undefined>(args: import("viem").SendTransactionParameters<import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined, TChainOverride_1>) => Promise<`0x${string}`>;
|
|
77
|
+
signMessage: (args: import("viem").SignMessageParameters<import("viem").JsonRpcAccount | undefined>) => Promise<`0x${string}`>;
|
|
78
|
+
signTransaction: <TChainOverride_2 extends import("viem").Chain | undefined>(args: import("viem").SignTransactionParameters<import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined, TChainOverride_2>) => Promise<`0x${string}`>;
|
|
79
79
|
signTypedData: <const TTypedData extends {
|
|
80
80
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
81
81
|
[x: `string[${string}]`]: undefined;
|
|
@@ -283,10 +283,10 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
|
|
|
283
283
|
uint256?: undefined;
|
|
284
284
|
} | {
|
|
285
285
|
[key: string]: unknown;
|
|
286
|
-
}, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, undefined>) => Promise<`0x${string}`>;
|
|
286
|
+
}, TPrimaryType extends string>(args: import("viem").SignTypedDataParameters<TTypedData, TPrimaryType, import("viem").JsonRpcAccount | undefined>) => Promise<`0x${string}`>;
|
|
287
287
|
switchChain: (args: import("viem").SwitchChainParameters) => Promise<void>;
|
|
288
288
|
watchAsset: (args: import("viem").WatchAssetParams) => Promise<boolean>;
|
|
289
|
-
writeContract: <const abi_1 extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi_1, "nonpayable" | "payable">, args extends import("viem").ContractFunctionArgs<abi_1, "pure" | "view", functionName>, TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_1, functionName, args, undefined, undefined, TChainOverride_3>) => Promise<`0x${string}`>;
|
|
289
|
+
writeContract: <const abi_1 extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi_1, "nonpayable" | "payable">, args extends import("viem").ContractFunctionArgs<abi_1, "pure" | "view", functionName>, TChainOverride_3 extends import("viem").Chain | undefined = undefined>(args: import("viem").WriteContractParameters<abi_1, functionName, args, import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined, TChainOverride_3>) => Promise<`0x${string}`>;
|
|
290
290
|
extend: <const client extends {
|
|
291
291
|
[x: string]: unknown;
|
|
292
292
|
account?: undefined;
|
|
@@ -300,9 +300,9 @@ export declare class WalletConnect extends EthWalletConnector implements IWallet
|
|
|
300
300
|
transport?: undefined;
|
|
301
301
|
type?: undefined;
|
|
302
302
|
uid?: undefined;
|
|
303
|
-
} & Partial<Pick<import("viem").PublicActions<import("viem").CustomTransport, undefined, undefined>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<undefined, undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<undefined, undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, undefined, undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<undefined, undefined>>;
|
|
303
|
+
} & Partial<Pick<import("viem").PublicActions<import("viem").CustomTransport, import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined>, "getChainId" | "prepareTransactionRequest" | "sendRawTransaction" | "call" | "createContractEventFilter" | "createEventFilter" | "estimateContractGas" | "estimateGas" | "getBlock" | "getBlockNumber" | "getContractEvents" | "getEnsText" | "getFilterChanges" | "getGasPrice" | "getLogs" | "getTransaction" | "getTransactionCount" | "getTransactionReceipt" | "readContract" | "simulateContract" | "uninstallFilter" | "watchBlockNumber" | "watchContractEvent"> & Pick<import("viem").WalletActions<import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined>, "sendTransaction" | "writeContract">>>(fn: (client: import("viem").Client<import("viem").CustomTransport, import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined, import("viem").WalletRpcSchema, import("viem").WalletActions<import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined>>) => client) => import("viem").Client<import("viem").CustomTransport, import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined, import("viem").WalletRpcSchema, { [K in keyof client]: client[K]; } & import("viem").WalletActions<import("viem").Chain | undefined, import("viem").JsonRpcAccount | undefined>>;
|
|
304
304
|
} | undefined;
|
|
305
|
-
|
|
305
|
+
getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
|
|
306
306
|
/**
|
|
307
307
|
* WalletConnect V2 will fail to send the sign message request if the chainId
|
|
308
308
|
* is not the same as the one in the session. This method will wait for the
|
|
@@ -2,9 +2,11 @@ import { __awaiter } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import Provider from '@walletconnect/universal-provider';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
import { createWalletClient, custom } from 'viem';
|
|
5
|
+
import { toAccount } from 'viem/accounts';
|
|
5
6
|
import { DynamicError, sleep, isMobile } from '@dynamic-labs/utils';
|
|
6
7
|
import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
7
8
|
import { logger, performPlatformSpecificConnectionMethod, getDeepLink } from '@dynamic-labs/wallet-connector-core';
|
|
9
|
+
import { chainsMap } from '@dynamic-labs/viem-utils';
|
|
8
10
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
9
11
|
import { parseIntSafe } from '../utils/parseIntSafe.js';
|
|
10
12
|
|
|
@@ -212,15 +214,17 @@ class WalletConnect extends EthWalletConnector {
|
|
|
212
214
|
WalletConnect.provider.client.removeAllListeners('session_event');
|
|
213
215
|
WalletConnect.provider.client.removeAllListeners('session_delete');
|
|
214
216
|
}
|
|
215
|
-
getWalletClient() {
|
|
217
|
+
getWalletClient(chainId) {
|
|
216
218
|
if (!WalletConnect.provider) {
|
|
217
219
|
return;
|
|
218
220
|
}
|
|
219
221
|
return createWalletClient({
|
|
222
|
+
account: this.activeAccount ? toAccount(this.activeAccount) : undefined,
|
|
223
|
+
chain: chainId ? chainsMap[chainId] : undefined,
|
|
220
224
|
transport: custom(WalletConnect.provider),
|
|
221
225
|
});
|
|
222
226
|
}
|
|
223
|
-
|
|
227
|
+
getAddress(opts) {
|
|
224
228
|
var _a, _b;
|
|
225
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
226
230
|
if (this.activeAccount) {
|