@dynamic-labs/ethereum 0.18.0-RC.19 → 0.18.0-RC.20

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,20 @@
1
1
 
2
+ ## [0.18.0-RC.20](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.19...v0.18.0-RC.20) (2023-07-27)
3
+
4
+
5
+ ### Features
6
+
7
+ * **QNTM-56:** add onBeforeConnectSuccessConfirmation callback ([#2753](https://github.com/dynamic-labs/DynamicAuth/issues/2753)) ([b174396](https://github.com/dynamic-labs/DynamicAuth/commit/b174396ab341cbcf11c6940e54931c0db3954d0d))
8
+ * **QNTM-72:** add backpack wallet ([#2702](https://github.com/dynamic-labs/DynamicAuth/issues/2702)) ([0d0ce9c](https://github.com/dynamic-labs/DynamicAuth/commit/0d0ce9c0d92118a78b5e40f64c5530246523712a))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * bump sdk version and change sdksettings api ([#2760](https://github.com/dynamic-labs/DynamicAuth/issues/2760)) ([6e3e205](https://github.com/dynamic-labs/DynamicAuth/commit/6e3e2050ed63d2df2d88d9169bc89d5f17870847))
14
+ * check funding enabled based on enabled onramp providers instead of onrampFunding settings ([#2662](https://github.com/dynamic-labs/DynamicAuth/issues/2662)) ([d542a9b](https://github.com/dynamic-labs/DynamicAuth/commit/d542a9b2950640e473afe378c857f4d2dd1926ff))
15
+ * ensure metamask auto-redirect upon message signing ([#2757](https://github.com/dynamic-labs/DynamicAuth/issues/2757)) ([a590f4b](https://github.com/dynamic-labs/DynamicAuth/commit/a590f4b054cd1de7ad400763d769b0daf4fcaad2))
16
+ * **QNTM-123:** use `linkedWallets` after signing the first message ([#2741](https://github.com/dynamic-labs/DynamicAuth/issues/2741)) ([7f26151](https://github.com/dynamic-labs/DynamicAuth/commit/7f26151db69b50102fd4b09ec470c8f19ce7b68f))
17
+
2
18
  ## [0.18.0-RC.19](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.18...v0.18.0-RC.19) (2023-07-25)
3
19
 
4
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/ethereum",
3
- "version": "0.18.0-RC.19",
3
+ "version": "0.18.0-RC.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -32,11 +32,12 @@
32
32
  "ethers": "5.7.2",
33
33
  "eventemitter3": "5.0.1",
34
34
  "buffer": "6.0.3",
35
- "@dynamic-labs/rpc-providers": "0.18.0-RC.19",
36
- "@dynamic-labs/types": "0.18.0-RC.19",
37
- "@dynamic-labs/utils": "0.18.0-RC.19",
38
- "@dynamic-labs/wallet-book": "0.18.0-RC.19",
39
- "@dynamic-labs/wallet-connector-core": "0.18.0-RC.19"
35
+ "@dynamic-labs/rpc-providers": "0.18.0-RC.20",
36
+ "@dynamic-labs/types": "0.18.0-RC.20",
37
+ "@dynamic-labs/utils": "0.18.0-RC.20",
38
+ "@dynamic-labs/wallet-book": "0.18.0-RC.20",
39
+ "@dynamic-labs/wallet-connector-core": "0.18.0-RC.20",
40
+ "@ethersproject/providers": "5.7.2"
40
41
  },
41
42
  "peerDependencies": {}
42
43
  }
@@ -161,6 +161,7 @@ _a.installedProviderLookup([
161
161
  { flag: 'isMetaMask', value: true },
162
162
  { flag: 'isSuperb', value: false },
163
163
  { flag: 'isRabby', value: false },
164
+ { flag: 'isBackpack', value: false },
164
165
  ]);
165
166
  EthProviderHelper.BraveProvider = () => _a.installedProviderLookup([{ flag: 'isBraveWallet', value: true }]);
166
167
  EthProviderHelper.DawnProvider = () => _a.installedProviderLookup([{ flag: 'isDawn', value: true }]);
@@ -175,6 +176,7 @@ EthProviderHelper.PhantomProvider = () => _a.installedProviderLookup([{ flag: 'i
175
176
  EthProviderHelper.ZerionProvider = () => _a.installedProviderLookup([{ flag: 'isZerion', value: true }]);
176
177
  EthProviderHelper.SuperbProvider = () => _a.installedProviderLookup([{ flag: 'isSuperb', value: true }]);
177
178
  EthProviderHelper.RabbyProvider = () => _a.installedProviderLookup([{ flag: 'isRabby', value: true }]);
179
+ EthProviderHelper.BackpackProvider = () => _a.installedProviderLookup([{ flag: 'isBackpack', value: true }]);
178
180
  EthProviderHelper.UnknownInjectedProvider = () => _a.installedProviderLookup([
179
181
  { flag: 'isMetaMask', value: false },
180
182
  { flag: 'isExodus', value: false },
@@ -189,8 +191,10 @@ EthProviderHelper.UnknownInjectedProvider = () => _a.installedProviderLookup([
189
191
  { flag: 'isZerion', value: false },
190
192
  { flag: 'isSuperb', value: false },
191
193
  { flag: 'isRabby', value: false },
194
+ { flag: 'isBackpack', value: false },
192
195
  ]);
193
196
  EthProviderHelper.providers = {
197
+ backpack: _a.BackpackProvider,
194
198
  bloctoinjected: _a.BloctoProvider,
195
199
  braveevm: _a.BraveProvider,
196
200
  coinbase: _a.CoinbaseProvider,
@@ -17,6 +17,7 @@ export declare class EthProviderHelper {
17
17
  static ZerionProvider: Provider;
18
18
  static SuperbProvider: Provider;
19
19
  static RabbyProvider: Provider;
20
+ static BackpackProvider: Provider;
20
21
  static UnknownInjectedProvider: Provider;
21
22
  static providers: {
22
23
  [wallet: string]: Provider;
@@ -157,6 +157,7 @@ _a.installedProviderLookup([
157
157
  { flag: 'isMetaMask', value: true },
158
158
  { flag: 'isSuperb', value: false },
159
159
  { flag: 'isRabby', value: false },
160
+ { flag: 'isBackpack', value: false },
160
161
  ]);
161
162
  EthProviderHelper.BraveProvider = () => _a.installedProviderLookup([{ flag: 'isBraveWallet', value: true }]);
162
163
  EthProviderHelper.DawnProvider = () => _a.installedProviderLookup([{ flag: 'isDawn', value: true }]);
@@ -171,6 +172,7 @@ EthProviderHelper.PhantomProvider = () => _a.installedProviderLookup([{ flag: 'i
171
172
  EthProviderHelper.ZerionProvider = () => _a.installedProviderLookup([{ flag: 'isZerion', value: true }]);
172
173
  EthProviderHelper.SuperbProvider = () => _a.installedProviderLookup([{ flag: 'isSuperb', value: true }]);
173
174
  EthProviderHelper.RabbyProvider = () => _a.installedProviderLookup([{ flag: 'isRabby', value: true }]);
175
+ EthProviderHelper.BackpackProvider = () => _a.installedProviderLookup([{ flag: 'isBackpack', value: true }]);
174
176
  EthProviderHelper.UnknownInjectedProvider = () => _a.installedProviderLookup([
175
177
  { flag: 'isMetaMask', value: false },
176
178
  { flag: 'isExodus', value: false },
@@ -185,8 +187,10 @@ EthProviderHelper.UnknownInjectedProvider = () => _a.installedProviderLookup([
185
187
  { flag: 'isZerion', value: false },
186
188
  { flag: 'isSuperb', value: false },
187
189
  { flag: 'isRabby', value: false },
190
+ { flag: 'isBackpack', value: false },
188
191
  ]);
189
192
  EthProviderHelper.providers = {
193
+ backpack: _a.BackpackProvider,
190
194
  bloctoinjected: _a.BloctoProvider,
191
195
  braveevm: _a.BraveProvider,
192
196
  coinbase: _a.CoinbaseProvider,
package/src/index.cjs CHANGED
@@ -28,6 +28,7 @@ var Trust = require('./injected/Trust.cjs');
28
28
  var UnknownInjectedWallet = require('./injected/UnknownInjectedWallet.cjs');
29
29
  var Zerion = require('./injected/Zerion.cjs');
30
30
  var Rabby = require('./injected/Rabby.cjs');
31
+ var BackpackEvm = require('./injected/BackpackEvm.cjs');
31
32
 
32
33
  const EthereumWalletConnectors = (props) => [
33
34
  ...index.injectedWallets,
@@ -52,4 +53,5 @@ exports.Trust = Trust.Trust;
52
53
  exports.UnknownInjectedWallet = UnknownInjectedWallet.UnknownInjectedWallet;
53
54
  exports.Zerion = Zerion.Zerion;
54
55
  exports.Rabby = Rabby.Rabby;
56
+ exports.BackpackEvm = BackpackEvm.BackpackEvm;
55
57
  exports.EthereumWalletConnectors = EthereumWalletConnectors;
package/src/index.js CHANGED
@@ -25,6 +25,7 @@ export { Trust } from './injected/Trust.js';
25
25
  export { UnknownInjectedWallet } from './injected/UnknownInjectedWallet.js';
26
26
  export { Zerion } from './injected/Zerion.js';
27
27
  export { Rabby } from './injected/Rabby.js';
28
+ export { BackpackEvm } from './injected/BackpackEvm.js';
28
29
 
29
30
  const EthereumWalletConnectors = (props) => [
30
31
  ...injectedWallets,
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../_virtual/_tslib.cjs');
6
+ var ethProviderHelper = require('../ethProviderHelper.cjs');
7
+ var InjectedWalletBase = require('./InjectedWalletBase.cjs');
8
+
9
+ class BackpackEvm extends InjectedWalletBase {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.name = 'Backpack';
13
+ }
14
+ getConnectedAccounts() {
15
+ var _a;
16
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
17
+ const provider = ethProviderHelper.EthProviderHelper.findProvider(this.name);
18
+ if (!provider)
19
+ return [];
20
+ return (_a = (yield provider.send('eth_requestAccounts', []))) !== null && _a !== void 0 ? _a : [];
21
+ });
22
+ }
23
+ }
24
+
25
+ exports.BackpackEvm = BackpackEvm;
@@ -0,0 +1,5 @@
1
+ import InjectedWalletBase from './InjectedWalletBase';
2
+ export declare class BackpackEvm extends InjectedWalletBase {
3
+ name: string;
4
+ getConnectedAccounts(): Promise<string[]>;
5
+ }
@@ -0,0 +1,21 @@
1
+ import { __awaiter } from '../../_virtual/_tslib.js';
2
+ import { EthProviderHelper } from '../ethProviderHelper.js';
3
+ import InjectedWalletBase from './InjectedWalletBase.js';
4
+
5
+ class BackpackEvm extends InjectedWalletBase {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.name = 'Backpack';
9
+ }
10
+ getConnectedAccounts() {
11
+ var _a;
12
+ return __awaiter(this, void 0, void 0, function* () {
13
+ const provider = EthProviderHelper.findProvider(this.name);
14
+ if (!provider)
15
+ return [];
16
+ return (_a = (yield provider.send('eth_requestAccounts', []))) !== null && _a !== void 0 ? _a : [];
17
+ });
18
+ }
19
+ }
20
+
21
+ export { BackpackEvm };
@@ -16,6 +16,7 @@ var UnknownInjectedWallet = require('./UnknownInjectedWallet.cjs');
16
16
  var Zerion = require('./Zerion.cjs');
17
17
  var Superb = require('./Superb.cjs');
18
18
  var Rabby = require('./Rabby.cjs');
19
+ var BackpackEvm = require('./BackpackEvm.cjs');
19
20
 
20
21
  const injectedWallets = [
21
22
  BloctoInjected.BloctoInjected,
@@ -32,6 +33,7 @@ const injectedWallets = [
32
33
  Zerion.Zerion,
33
34
  Superb.Superb,
34
35
  Rabby.Rabby,
36
+ BackpackEvm.BackpackEvm,
35
37
  ];
36
38
 
37
39
  exports.BloctoInjected = BloctoInjected.BloctoInjected;
@@ -47,4 +49,5 @@ exports.Trust = Trust.Trust;
47
49
  exports.UnknownInjectedWallet = UnknownInjectedWallet.UnknownInjectedWallet;
48
50
  exports.Zerion = Zerion.Zerion;
49
51
  exports.Rabby = Rabby.Rabby;
52
+ exports.BackpackEvm = BackpackEvm.BackpackEvm;
50
53
  exports.injectedWallets = injectedWallets;
@@ -12,4 +12,5 @@ export * from './Trust';
12
12
  export * from './UnknownInjectedWallet';
13
13
  export * from './Zerion';
14
14
  export * from './Rabby';
15
+ export * from './BackpackEvm';
15
16
  export declare const injectedWallets: WalletConnectorConstructor[];
@@ -25,6 +25,8 @@ export { Zerion } from './Zerion.js';
25
25
  import { Superb } from './Superb.js';
26
26
  import { Rabby } from './Rabby.js';
27
27
  export { Rabby } from './Rabby.js';
28
+ import { BackpackEvm } from './BackpackEvm.js';
29
+ export { BackpackEvm } from './BackpackEvm.js';
28
30
 
29
31
  const injectedWallets = [
30
32
  BloctoInjected,
@@ -41,6 +43,7 @@ const injectedWallets = [
41
43
  Zerion,
42
44
  Superb,
43
45
  Rabby,
46
+ BackpackEvm,
44
47
  ];
45
48
 
46
49
  export { injectedWallets };
package/src/types.d.ts CHANGED
@@ -19,5 +19,5 @@ export type IEthereum = {
19
19
  method: T;
20
20
  } | object) => Promise<T extends 'eth_requestAccounts' ? [string] : object>;
21
21
  };
22
- export type ProviderFlag = 'isDawn' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isFrame' | 'isGamestop' | 'isMetaMask' | 'isExodus' | 'isOpera' | 'isBlocto' | 'isTrustWallet' | 'isZerion' | 'isPhantom' | 'isSuperb' | 'isRabby';
22
+ export type ProviderFlag = 'isDawn' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isFrame' | 'isGamestop' | 'isMetaMask' | 'isExodus' | 'isOpera' | 'isBlocto' | 'isTrustWallet' | 'isZerion' | 'isPhantom' | 'isSuperb' | 'isRabby' | 'isBackpack';
23
23
  export type EthProviderCondition = ProviderCondition<ProviderFlag>;
@@ -15,6 +15,7 @@ const filteredWalletConnectWallets = [
15
15
  'Keplr',
16
16
  'Zerion',
17
17
  'Rabby',
18
+ 'Backpack',
18
19
  ];
19
20
  const fetchWalletConnectWallets = ({ isWalletConnectV2Enabled, walletBook, }) => {
20
21
  var _a;
@@ -11,6 +11,7 @@ const filteredWalletConnectWallets = [
11
11
  'Keplr',
12
12
  'Zerion',
13
13
  'Rabby',
14
+ 'Backpack',
14
15
  ];
15
16
  const fetchWalletConnectWallets = ({ isWalletConnectV2Enabled, walletBook, }) => {
16
17
  var _a;
@@ -125,6 +125,17 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
125
125
  get activeAccountKey() {
126
126
  return activeAccountKey(this.key);
127
127
  }
128
+ getDeepLink() {
129
+ var _a;
130
+ const wallet = walletBook.getWalletBookWallet(this.walletBook, this.name);
131
+ if (!utils.isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
132
+ return undefined;
133
+ }
134
+ return walletConnectorCore.getDeepLink({
135
+ metadata: wallet,
136
+ mode: 'regular',
137
+ });
138
+ }
128
139
  supportsNetworkSwitching() {
129
140
  return true;
130
141
  }
@@ -202,6 +213,11 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
202
213
  }
203
214
  }
204
215
  const metadata = walletBook.getWalletBookWallet(this.walletBook, this.name);
216
+ if (utils.isMobile()) {
217
+ // eslint-disable-next-line max-len
218
+ // see: https://dynamiclabsgroup.slack.com/archives/C04J69TS3JR/p1689918262752199?thread_ts=1689633771.128409&cid=C04J69TS3JR
219
+ localStorage.setItem('WALLETCONNECT_DEEPLINK_CHOICE', JSON.stringify({ href: this.getDeepLink(), name: metadata.name }));
220
+ }
205
221
  walletConnectorCore.performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
206
222
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
207
223
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
@@ -306,6 +322,7 @@ class WalletConnectV2 extends EthWalletConnector.EthWalletConnector {
306
322
  endSession() {
307
323
  var _a;
308
324
  return _tslib.__awaiter(this, void 0, void 0, function* () {
325
+ localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE');
309
326
  this.clearActiveAccount();
310
327
  this.clearSession();
311
328
  if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.session)) {
@@ -27,6 +27,7 @@ export declare class WalletConnectV2 extends EthWalletConnector {
27
27
  init(): Promise<void>;
28
28
  get sessionTopicKey(): string;
29
29
  get activeAccountKey(): string;
30
+ getDeepLink(): string | undefined;
30
31
  supportsNetworkSwitching(): boolean;
31
32
  setupEventListeners(listeners: WalletEventListeners): void;
32
33
  teardownEventListeners(): void;
@@ -2,7 +2,7 @@ import { __awaiter } from '../../_virtual/_tslib.js';
2
2
  import Provider from '@walletconnect/universal-provider';
3
3
  import { ethers } from 'ethers';
4
4
  import EventEmitter from 'eventemitter3';
5
- import { logger, performPlatformSpecificConnectionMethod, utf8ToHex } from '@dynamic-labs/wallet-connector-core';
5
+ import { logger, getDeepLink, performPlatformSpecificConnectionMethod, utf8ToHex } from '@dynamic-labs/wallet-connector-core';
6
6
  import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
7
7
  import { DynamicError, isMobile } from '@dynamic-labs/utils';
8
8
  import { EthWalletConnector } from '../EthWalletConnector.js';
@@ -116,6 +116,17 @@ class WalletConnectV2 extends EthWalletConnector {
116
116
  get activeAccountKey() {
117
117
  return activeAccountKey(this.key);
118
118
  }
119
+ getDeepLink() {
120
+ var _a;
121
+ const wallet = getWalletBookWallet(this.walletBook, this.name);
122
+ if (!isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
123
+ return undefined;
124
+ }
125
+ return getDeepLink({
126
+ metadata: wallet,
127
+ mode: 'regular',
128
+ });
129
+ }
119
130
  supportsNetworkSwitching() {
120
131
  return true;
121
132
  }
@@ -193,6 +204,11 @@ class WalletConnectV2 extends EthWalletConnector {
193
204
  }
194
205
  }
195
206
  const metadata = getWalletBookWallet(this.walletBook, this.name);
207
+ if (isMobile()) {
208
+ // eslint-disable-next-line max-len
209
+ // see: https://dynamiclabsgroup.slack.com/archives/C04J69TS3JR/p1689918262752199?thread_ts=1689633771.128409&cid=C04J69TS3JR
210
+ localStorage.setItem('WALLETCONNECT_DEEPLINK_CHOICE', JSON.stringify({ href: this.getDeepLink(), name: metadata.name }));
211
+ }
196
212
  performPlatformSpecificConnectionMethod(WalletConnectV2.provider.uri, metadata, {
197
213
  onDesktopUri: opts === null || opts === void 0 ? void 0 : opts.onDesktopUri,
198
214
  onDisplayUri: opts === null || opts === void 0 ? void 0 : opts.onDisplayUri,
@@ -297,6 +313,7 @@ class WalletConnectV2 extends EthWalletConnector {
297
313
  endSession() {
298
314
  var _a;
299
315
  return __awaiter(this, void 0, void 0, function* () {
316
+ localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE');
300
317
  this.clearActiveAccount();
301
318
  this.clearSession();
302
319
  if (!((_a = WalletConnectV2.provider) === null || _a === void 0 ? void 0 : _a.session)) {