@dynamic-labs/ethereum 2.0.0-alpha.25 → 2.0.0-alpha.27

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,34 @@
1
1
 
2
+ ## [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)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * coinbase improvements ([#5268](https://github.com/dynamic-labs/DynamicAuth/issues/5268)) ([c10a6de](https://github.com/dynamic-labs/DynamicAuth/commit/c10a6debcacff6cd97f2436fbde387f85faa5682))
8
+ * 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))
9
+ * 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))
10
+
11
+ ## [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)
12
+
13
+
14
+ ### ⚠ BREAKING CHANGES
15
+
16
+ * add onWalletAdded/onWalletRemoved callbacks and removed onConnect/onDisconnect/onLinkSuccess/onUnlinkSuccess (#5194)
17
+ * note:
18
+ - use "events" in favour of "eventsCallbacks"
19
+ - use "handlers.handleConnectedWallet" in favour of "eventsCallbacks.onBeforeConnectSuccessConfirmation"
20
+
21
+ ### Bug Fixes
22
+
23
+ * coinbase wallet settings ([#5233](https://github.com/dynamic-labs/DynamicAuth/issues/5233)) ([1b04411](https://github.com/dynamic-labs/DynamicAuth/commit/1b04411eb90db438f3eacf622d9c28db4c7cf532))
24
+ * remove local storage settings on logout ([#5212](https://github.com/dynamic-labs/DynamicAuth/issues/5212)) ([e686628](https://github.com/dynamic-labs/DynamicAuth/commit/e686628f602a44cd13083e7bb9afb4f50304390e))
25
+ * show app name or logo in sign message modal ([#5225](https://github.com/dynamic-labs/DynamicAuth/issues/5225)) ([a77b6ba](https://github.com/dynamic-labs/DynamicAuth/commit/a77b6ba9b5646b400ebf933949dabe06a35d1c81))
26
+ * user wallets not being cleared immediately when logout is called ([#5211](https://github.com/dynamic-labs/DynamicAuth/issues/5211)) ([a649c46](https://github.com/dynamic-labs/DynamicAuth/commit/a649c462d171cf6f8d67159df9f5f2144f315e5c))
27
+
28
+
29
+ * add onWalletAdded/onWalletRemoved callbacks and removed onConnect/onDisconnect/onLinkSuccess/onUnlinkSuccess ([#5194](https://github.com/dynamic-labs/DynamicAuth/issues/5194)) ([fdec78c](https://github.com/dynamic-labs/DynamicAuth/commit/fdec78c1c32c58c8f7dc7ffd9b877320aa4d90e0))
30
+ * rename eventsCallbacks to events ([#5196](https://github.com/dynamic-labs/DynamicAuth/issues/5196)) ([5797185](https://github.com/dynamic-labs/DynamicAuth/commit/5797185c18fa091032ef27043b63a1d5201b5e23))
31
+
2
32
  ## [2.0.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.24...v2.0.0-alpha.25) (2024-04-04)
3
33
 
4
34
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "2.0.0-alpha.25",
3
+ "version": "2.0.0-alpha.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,17 +26,17 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@coinbase/wallet-sdk": "3.9.2",
29
+ "@coinbase/wallet-sdk": "3.9.3",
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.25",
34
- "@dynamic-labs/turnkey": "2.0.0-alpha.25",
35
- "@dynamic-labs/types": "2.0.0-alpha.25",
36
- "@dynamic-labs/utils": "2.0.0-alpha.25",
37
- "@dynamic-labs/viem-utils": "2.0.0-alpha.25",
38
- "@dynamic-labs/wallet-book": "2.0.0-alpha.25",
39
- "@dynamic-labs/wallet-connector-core": "2.0.0-alpha.25",
33
+ "@dynamic-labs/rpc-provider-ethereum": "2.0.0-alpha.27",
34
+ "@dynamic-labs/turnkey": "2.0.0-alpha.27",
35
+ "@dynamic-labs/types": "2.0.0-alpha.27",
36
+ "@dynamic-labs/utils": "2.0.0-alpha.27",
37
+ "@dynamic-labs/viem-utils": "2.0.0-alpha.27",
38
+ "@dynamic-labs/wallet-book": "2.0.0-alpha.27",
39
+ "@dynamic-labs/wallet-connector-core": "2.0.0-alpha.27",
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 getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
18
+ const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
15
19
  var _a, _b;
16
20
  if (!coinbaseProvider) {
17
- const coinbaseWalletSDK = new walletSdk.CoinbaseWalletSDK({
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 = coinbaseWalletSDK.makeWeb3Provider(rpcUrl, chainId);
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 = getCoinbaseProvider({ opts: coinbaseProviderOpts });
42
- const { qrUrl } = provider;
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 = getCoinbaseProvider({ opts: coinbaseProviderOpts });
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.getCoinbaseProvider = getCoinbaseProvider;
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 { GetCoinbaseProvider, GetCoinbaseProviderOpts } from './types';
3
- export declare const getCoinbaseProvider: GetCoinbaseProvider;
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 getCoinbaseProvider = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
14
+ const getCoinbaseClient = ({ opts: { appLogoUrl, appName = '', evmNetworks = [] } = {}, }) => {
11
15
  var _a, _b;
12
16
  if (!coinbaseProvider) {
13
- const coinbaseWalletSDK = new CoinbaseWalletSDK({
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 = coinbaseWalletSDK.makeWeb3Provider(rpcUrl, chainId);
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 = getCoinbaseProvider({ opts: coinbaseProviderOpts });
38
- const { qrUrl } = provider;
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 = getCoinbaseProvider({ opts: coinbaseProviderOpts });
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, getCoinbaseProvider, killCoinbaseSession, signMessage };
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 GetCoinbaseProvider = (args: {
11
+ export type GetCoinbaseClient = (args: {
12
12
  handlers?: CoinbaseProviderHandlerOpts;
13
13
  opts?: GetCoinbaseProviderOpts;
14
- }) => CoinbaseWalletProvider;
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.getCoinbaseProvider({
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.getCoinbaseProvider({
88
+ const { provider } = client.getCoinbaseClient({
89
89
  opts: this.coinbaseProviderOpts,
90
90
  });
91
91
  if (!provider) {
@@ -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 { getCoinbaseProvider, getAddress, signMessage, killCoinbaseSession } from './client/client.js';
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(getCoinbaseProvider({
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 = getCoinbaseProvider({
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