@dynamic-labs/ethereum 2.0.0-alpha.26 → 2.0.0-alpha.28
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.json +8 -8
- package/src/coinbase/client/client.cjs +12 -12
- package/src/coinbase/client/client.d.ts +3 -2
- package/src/coinbase/client/client.js +12 -12
- package/src/coinbase/client/types.d.ts +6 -3
- package/src/coinbase/coinbase.cjs +3 -3
- package/src/coinbase/coinbase.js +4 -4
- package/src/injected/InjectedWalletBase.cjs +6 -1
- package/src/injected/InjectedWalletBase.js +6 -1
- package/src/walletConnect/walletConnect.cjs +1 -1
- package/src/walletConnect/walletConnect.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.0.0-alpha.28](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.27...v2.0.0-alpha.28) (2024-04-10)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* improve bridge connect experience on mobile ([#5283](https://github.com/dynamic-labs/DynamicAuth/issues/5283)) ([155e4a9](https://github.com/dynamic-labs/DynamicAuth/commit/155e4a99e2cf5f78a1a5e91e774acbf170d6b083))
|
|
8
|
+
|
|
9
|
+
## [2.0.0-alpha.27](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.26...v2.0.0-alpha.27) (2024-04-09)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* coinbase improvements ([#5268](https://github.com/dynamic-labs/DynamicAuth/issues/5268)) ([c10a6de](https://github.com/dynamic-labs/DynamicAuth/commit/c10a6debcacff6cd97f2436fbde387f85faa5682))
|
|
15
|
+
* show qr code for metamask on desktop when not installed ([#5262](https://github.com/dynamic-labs/DynamicAuth/issues/5262)) ([1dcb4d9](https://github.com/dynamic-labs/DynamicAuth/commit/1dcb4d98de8a95f6b11d7bad90b9059110087385))
|
|
16
|
+
* update title of hardware wallet select screen ([#5270](https://github.com/dynamic-labs/DynamicAuth/issues/5270)) ([6e8fe17](https://github.com/dynamic-labs/DynamicAuth/commit/6e8fe17306677786ccf528b97ab673b9ae6b57b9))
|
|
17
|
+
|
|
2
18
|
## [2.0.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.25...v2.0.0-alpha.26) (2024-04-08)
|
|
3
19
|
|
|
4
20
|
|
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.28",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"@walletconnect/ethereum-provider": "2.11.2",
|
|
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/viem-utils": "2.0.0-alpha.
|
|
38
|
-
"@dynamic-labs/wallet-book": "2.0.0-alpha.
|
|
39
|
-
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.
|
|
33
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.0.0-alpha.28",
|
|
34
|
+
"@dynamic-labs/turnkey": "2.0.0-alpha.28",
|
|
35
|
+
"@dynamic-labs/types": "2.0.0-alpha.28",
|
|
36
|
+
"@dynamic-labs/utils": "2.0.0-alpha.28",
|
|
37
|
+
"@dynamic-labs/viem-utils": "2.0.0-alpha.28",
|
|
38
|
+
"@dynamic-labs/wallet-book": "2.0.0-alpha.28",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "2.0.0-alpha.28",
|
|
40
40
|
"stream": "0.0.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -10,11 +10,15 @@ var constants = require('../../constants.cjs');
|
|
|
10
10
|
|
|
11
11
|
const jsonRpcUrl = `https://mainnet.infura.io/v3/${constants.INFURA_ID}`;
|
|
12
12
|
const chainId = 1;
|
|
13
|
+
// storing a reference to the coinbase sdk so that we can call getQrUrl on it when we need a fresh qr code
|
|
14
|
+
let coinbaseSdk;
|
|
15
|
+
// storing a reference to the coinbase provider because the provider methods work better when
|
|
16
|
+
// they are called on the same instance
|
|
13
17
|
let coinbaseProvider;
|
|
14
|
-
const
|
|
18
|
+
const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
|
|
15
19
|
var _a, _b;
|
|
16
20
|
if (!coinbaseProvider) {
|
|
17
|
-
|
|
21
|
+
coinbaseSdk = new walletSdk.CoinbaseWalletSDK({
|
|
18
22
|
appLogoUrl,
|
|
19
23
|
appName,
|
|
20
24
|
enableMobileWalletLink: true,
|
|
@@ -25,21 +29,17 @@ const getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [
|
|
|
25
29
|
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
26
30
|
((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
27
31
|
jsonRpcUrl;
|
|
28
|
-
coinbaseProvider =
|
|
32
|
+
coinbaseProvider = coinbaseSdk.makeWeb3Provider(rpcUrl, chainId);
|
|
29
33
|
}
|
|
30
|
-
return coinbaseProvider;
|
|
34
|
+
return { provider: coinbaseProvider, sdk: coinbaseSdk };
|
|
31
35
|
};
|
|
32
36
|
const killCoinbaseSession = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
37
|
yield (coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.close());
|
|
34
|
-
coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.disconnect();
|
|
35
|
-
// We needed to remove the provider, because after a disconnect the initial settings that
|
|
36
|
-
// were set in the SDK reset, and they need to be initialized again.
|
|
37
|
-
coinbaseProvider = undefined;
|
|
38
38
|
});
|
|
39
39
|
const getAddress = (coinbaseProviderOpts, opts) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
40
|
var _a;
|
|
41
|
-
const provider =
|
|
42
|
-
const
|
|
41
|
+
const { provider, sdk } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
42
|
+
const qrUrl = sdk.getQrUrl();
|
|
43
43
|
if (!qrUrl) {
|
|
44
44
|
throw new utils.DynamicError('no qr url available');
|
|
45
45
|
}
|
|
@@ -50,7 +50,7 @@ const getAddress = (coinbaseProviderOpts, opts) => _tslib.__awaiter(void 0, void
|
|
|
50
50
|
return address;
|
|
51
51
|
});
|
|
52
52
|
const signMessage = (coinbaseProviderOpts, messageToSign) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
const provider =
|
|
53
|
+
const { provider } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
54
54
|
const [address] = yield provider.request({
|
|
55
55
|
method: 'eth_requestAccounts',
|
|
56
56
|
});
|
|
@@ -67,6 +67,6 @@ const signMessage = (coinbaseProviderOpts, messageToSign) => _tslib.__awaiter(vo
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
exports.getAddress = getAddress;
|
|
70
|
-
exports.
|
|
70
|
+
exports.getCoinbaseClient = getCoinbaseClient;
|
|
71
71
|
exports.killCoinbaseSession = killCoinbaseSession;
|
|
72
72
|
exports.signMessage = signMessage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GetAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
2
|
+
import { GetCoinbaseClient, GetCoinbaseProviderOpts } from './types';
|
|
3
|
+
export declare const clearClientVariables: () => void;
|
|
4
|
+
export declare const getCoinbaseClient: GetCoinbaseClient;
|
|
4
5
|
export declare const killCoinbaseSession: () => Promise<void>;
|
|
5
6
|
export declare const getAddress: (coinbaseProviderOpts: GetCoinbaseProviderOpts, opts?: GetAddressOpts) => Promise<string | undefined>;
|
|
6
7
|
export declare const signMessage: (coinbaseProviderOpts: GetCoinbaseProviderOpts, messageToSign: string) => Promise<string | undefined>;
|
|
@@ -6,11 +6,15 @@ import { INFURA_ID } from '../../constants.js';
|
|
|
6
6
|
|
|
7
7
|
const jsonRpcUrl = `https://mainnet.infura.io/v3/${INFURA_ID}`;
|
|
8
8
|
const chainId = 1;
|
|
9
|
+
// storing a reference to the coinbase sdk so that we can call getQrUrl on it when we need a fresh qr code
|
|
10
|
+
let coinbaseSdk;
|
|
11
|
+
// storing a reference to the coinbase provider because the provider methods work better when
|
|
12
|
+
// they are called on the same instance
|
|
9
13
|
let coinbaseProvider;
|
|
10
|
-
const
|
|
14
|
+
const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
|
|
11
15
|
var _a, _b;
|
|
12
16
|
if (!coinbaseProvider) {
|
|
13
|
-
|
|
17
|
+
coinbaseSdk = new CoinbaseWalletSDK({
|
|
14
18
|
appLogoUrl,
|
|
15
19
|
appName,
|
|
16
20
|
enableMobileWalletLink: true,
|
|
@@ -21,21 +25,17 @@ const getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [
|
|
|
21
25
|
const rpcUrl = ((_a = network === null || network === void 0 ? void 0 : network.privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
22
26
|
((_b = network === null || network === void 0 ? void 0 : network.rpcUrls) === null || _b === void 0 ? void 0 : _b[0]) ||
|
|
23
27
|
jsonRpcUrl;
|
|
24
|
-
coinbaseProvider =
|
|
28
|
+
coinbaseProvider = coinbaseSdk.makeWeb3Provider(rpcUrl, chainId);
|
|
25
29
|
}
|
|
26
|
-
return coinbaseProvider;
|
|
30
|
+
return { provider: coinbaseProvider, sdk: coinbaseSdk };
|
|
27
31
|
};
|
|
28
32
|
const killCoinbaseSession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
33
|
yield (coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.close());
|
|
30
|
-
coinbaseProvider === null || coinbaseProvider === void 0 ? void 0 : coinbaseProvider.disconnect();
|
|
31
|
-
// We needed to remove the provider, because after a disconnect the initial settings that
|
|
32
|
-
// were set in the SDK reset, and they need to be initialized again.
|
|
33
|
-
coinbaseProvider = undefined;
|
|
34
34
|
});
|
|
35
35
|
const getAddress = (coinbaseProviderOpts, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
36
|
var _a;
|
|
37
|
-
const provider =
|
|
38
|
-
const
|
|
37
|
+
const { provider, sdk } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
38
|
+
const qrUrl = sdk.getQrUrl();
|
|
39
39
|
if (!qrUrl) {
|
|
40
40
|
throw new DynamicError('no qr url available');
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ const getAddress = (coinbaseProviderOpts, opts) => __awaiter(void 0, void 0, voi
|
|
|
46
46
|
return address;
|
|
47
47
|
});
|
|
48
48
|
const signMessage = (coinbaseProviderOpts, messageToSign) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
const provider =
|
|
49
|
+
const { provider } = getCoinbaseClient({ opts: coinbaseProviderOpts });
|
|
50
50
|
const [address] = yield provider.request({
|
|
51
51
|
method: 'eth_requestAccounts',
|
|
52
52
|
});
|
|
@@ -62,4 +62,4 @@ const signMessage = (coinbaseProviderOpts, messageToSign) => __awaiter(void 0, v
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
export { getAddress,
|
|
65
|
+
export { getAddress, getCoinbaseClient, killCoinbaseSession, signMessage };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
|
|
1
|
+
import CoinbaseWalletSDK, { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
|
|
2
2
|
import { GenericNetwork } from '@dynamic-labs/types';
|
|
3
3
|
export type GetCoinbaseProviderOpts = {
|
|
4
4
|
appLogoUrl?: string;
|
|
@@ -8,7 +8,10 @@ export type GetCoinbaseProviderOpts = {
|
|
|
8
8
|
export type CoinbaseProviderHandlerOpts = {
|
|
9
9
|
onDisconnect(): Promise<void>;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type GetCoinbaseClient = (args: {
|
|
12
12
|
handlers?: CoinbaseProviderHandlerOpts;
|
|
13
13
|
opts?: GetCoinbaseProviderOpts;
|
|
14
|
-
}) =>
|
|
14
|
+
}) => {
|
|
15
|
+
provider: CoinbaseWalletProvider;
|
|
16
|
+
sdk: CoinbaseWalletSDK;
|
|
17
|
+
};
|
|
@@ -50,9 +50,9 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
50
50
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
51
51
|
}
|
|
52
52
|
return viem.createWalletClient({
|
|
53
|
-
transport: viem.custom(client.
|
|
53
|
+
transport: viem.custom(client.getCoinbaseClient({
|
|
54
54
|
opts: this.coinbaseProviderOpts,
|
|
55
|
-
})),
|
|
55
|
+
}).provider),
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
isInstalledOnBrowser() {
|
|
@@ -85,7 +85,7 @@ class Coinbase extends EthWalletConnector.EthWalletConnector {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
setupCoinbaseProviderEventListeners() {
|
|
88
|
-
const provider = client.
|
|
88
|
+
const { provider } = client.getCoinbaseClient({
|
|
89
89
|
opts: this.coinbaseProviderOpts,
|
|
90
90
|
});
|
|
91
91
|
if (!provider) {
|
package/src/coinbase/coinbase.js
CHANGED
|
@@ -4,7 +4,7 @@ import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
|
4
4
|
import { eventListenerHandlers } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
6
6
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getCoinbaseClient, getAddress, signMessage, killCoinbaseSession } from './client/client.js';
|
|
8
8
|
|
|
9
9
|
class Coinbase extends EthWalletConnector {
|
|
10
10
|
constructor(_a) {
|
|
@@ -46,9 +46,9 @@ class Coinbase extends EthWalletConnector {
|
|
|
46
46
|
return (_a = this.ethProviderHelper) === null || _a === void 0 ? void 0 : _a.findWalletClient(chainId);
|
|
47
47
|
}
|
|
48
48
|
return createWalletClient({
|
|
49
|
-
transport: custom(
|
|
49
|
+
transport: custom(getCoinbaseClient({
|
|
50
50
|
opts: this.coinbaseProviderOpts,
|
|
51
|
-
})),
|
|
51
|
+
}).provider),
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
isInstalledOnBrowser() {
|
|
@@ -81,7 +81,7 @@ class Coinbase extends EthWalletConnector {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
setupCoinbaseProviderEventListeners() {
|
|
84
|
-
const provider =
|
|
84
|
+
const { provider } = getCoinbaseClient({
|
|
85
85
|
opts: this.coinbaseProviderOpts,
|
|
86
86
|
});
|
|
87
87
|
if (!provider) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
4
4
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
5
|
+
var utils = require('@dynamic-labs/utils');
|
|
5
6
|
var ethProviderHelper = require('../ethProviderHelper.cjs');
|
|
6
7
|
var EthWalletConnector = require('../EthWalletConnector.cjs');
|
|
7
8
|
var walletConnect = require('../walletConnect/walletConnect.cjs');
|
|
@@ -33,8 +34,12 @@ class InjectedWalletBase extends EthWalletConnector.EthWalletConnector {
|
|
|
33
34
|
if (this.isInstalledOnBrowser()) {
|
|
34
35
|
return this;
|
|
35
36
|
}
|
|
37
|
+
// this is to handle the case where the user is in a webview.
|
|
38
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
39
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
36
40
|
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
37
|
-
this.constructorProps.deepLinkPreference !== 'universal'
|
|
41
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
42
|
+
utils.isMobile()) {
|
|
38
43
|
return this;
|
|
39
44
|
}
|
|
40
45
|
// this is the case where the wallet is not installed on the browser and
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
2
2
|
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
|
+
import { isMobile } from '@dynamic-labs/utils';
|
|
3
4
|
import { EthProviderHelper } from '../ethProviderHelper.js';
|
|
4
5
|
import { EthWalletConnector } from '../EthWalletConnector.js';
|
|
5
6
|
import { WalletConnect } from '../walletConnect/walletConnect.js';
|
|
@@ -31,8 +32,12 @@ class InjectedWalletBase extends EthWalletConnector {
|
|
|
31
32
|
if (this.isInstalledOnBrowser()) {
|
|
32
33
|
return this;
|
|
33
34
|
}
|
|
35
|
+
// this is to handle the case where the user is in a webview.
|
|
36
|
+
// when the user is in a webview, customers should set the deepLinkPreference prop to universal,
|
|
37
|
+
// in which case this condition will be false, and the SDK will use WalletConnect (if available)
|
|
34
38
|
if (((_b = (_a = this.wallet) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.inAppBrowser) &&
|
|
35
|
-
this.constructorProps.deepLinkPreference !== 'universal'
|
|
39
|
+
this.constructorProps.deepLinkPreference !== 'universal' &&
|
|
40
|
+
isMobile()) {
|
|
36
41
|
return this;
|
|
37
42
|
}
|
|
38
43
|
// this is the case where the wallet is not installed on the browser and
|
|
@@ -271,7 +271,7 @@ class WalletConnect extends EthWalletConnector.EthWalletConnector {
|
|
|
271
271
|
throw new utils.DynamicError('No provider found');
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key);
|
|
274
|
+
const metadata = walletBook.getWalletBookWallet(this.walletBook, this.key, this.walletFallback);
|
|
275
275
|
walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri, metadata, {
|
|
276
276
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
277
277
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|
|
@@ -262,7 +262,7 @@ class WalletConnect extends EthWalletConnector {
|
|
|
262
262
|
throw new DynamicError('No provider found');
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
const metadata = getWalletBookWallet(this.walletBook, this.key);
|
|
265
|
+
const metadata = getWalletBookWallet(this.walletBook, this.key, this.walletFallback);
|
|
266
266
|
performPlatformSpecificConnectionMethod(WalletConnect.provider.signer.uri, metadata, {
|
|
267
267
|
onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
|
|
268
268
|
onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
|