@dynamic-labs/wallet-connector-core 3.0.0-alpha.3 → 3.0.0-alpha.30

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.
@@ -6,6 +6,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  var _tslib = require('../../_virtual/_tslib.cjs');
7
7
  var EventEmitter = require('eventemitter3');
8
8
  var walletBook = require('@dynamic-labs/wallet-book');
9
+ var utils = require('@dynamic-labs/utils');
10
+ var logger = require('../utils/logger.cjs');
11
+ var getMobileExperience = require('../utils/getMobileExperience/getMobileExperience.cjs');
9
12
  var WalletBookSingleton = require('./WalletBookSingleton.cjs');
10
13
 
11
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -77,21 +80,11 @@ class WalletConnectorBase extends EventEmitter__default["default"] {
77
80
  */
78
81
  this.canConnectViaSocial = false;
79
82
  /**
80
- * @deprecated getWeb3Provider has been renamed to getWalletClient
81
- * If you would like to still get the ethers web3Provider,
82
- * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
83
+ * Flag if connector/provider is available
83
84
  *
84
- * Get the wallet provider
85
- */
86
- this.getWeb3Provider = this.getWalletClient;
87
- /**
88
- * @deprecated getRpcProvider has been renamed to getPublicClient
89
- * If you would like to still get the ethers rpcProvider,
90
- * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
91
- *
92
- * Get the rpc provider
85
+ * @default true
93
86
  */
94
- this.getRpcProvider = this.getPublicClient;
87
+ this.isAvailable = true;
95
88
  /**
96
89
  * If the wallet generated by a valid embedded wallet provider
97
90
  * For example: magic wallets
@@ -134,6 +127,11 @@ class WalletConnectorBase extends EventEmitter__default["default"] {
134
127
  if (_tslib.__classPrivateFieldGet(this, _WalletConnectorBase_registeredExtensions, "f").includes(extension.name)) {
135
128
  throw new Error(`You can only register a single extension of: ${extension.name}`);
136
129
  }
130
+ if (extension.name === 'global-wallet-extension') {
131
+ // only allow global wallet extension for evm embedded wallets
132
+ if (!this.isEmbeddedWallet || !this.supportedChains.includes('EVM'))
133
+ return;
134
+ }
137
135
  _tslib.__classPrivateFieldGet(this, _WalletConnectorBase_registeredExtensions, "f").push(extension.name);
138
136
  extension.extend(this);
139
137
  }
@@ -159,6 +157,13 @@ class WalletConnectorBase extends EventEmitter__default["default"] {
159
157
  return false;
160
158
  }
161
159
  }
160
+ get mobileExperience() {
161
+ return getMobileExperience.getMobileExperience({
162
+ mobileExperienceProp: this.constructorProps.mobileExperience,
163
+ walletBook: this.walletBook,
164
+ walletKey: this.key,
165
+ });
166
+ }
162
167
  connect() {
163
168
  return _tslib.__awaiter(this, void 0, void 0, function* () {
164
169
  yield this.getAddress();
@@ -182,6 +187,25 @@ class WalletConnectorBase extends EventEmitter__default["default"] {
182
187
  getAddress(opts) {
183
188
  return Promise.resolve(undefined);
184
189
  }
190
+ /**
191
+ * Parses a public address to ensure it follows a correct format.
192
+ *
193
+ * For instance, with EVM wallets, this might ensure it follows the EIP 55 format.
194
+ *
195
+ * @default string
196
+ */
197
+ parseAddress(address) {
198
+ return address;
199
+ }
200
+ /**
201
+ * Whether this wallet connector is targeting a testnet.
202
+ * So far only supported for EVM connectors.
203
+ *
204
+ * @default Promise<false>
205
+ */
206
+ isTestnet() {
207
+ return Promise.resolve(false);
208
+ }
185
209
  /**
186
210
  * Gets the additional addresses of the wallet, given the main address
187
211
  *
@@ -203,7 +227,7 @@ class WalletConnectorBase extends EventEmitter__default["default"] {
203
227
  *
204
228
  * @default Promise<undefined>
205
229
  */
206
- getBalance() {
230
+ getBalance(address) {
207
231
  return Promise.resolve(undefined);
208
232
  }
209
233
  /**
@@ -230,7 +254,7 @@ class WalletConnectorBase extends EventEmitter__default["default"] {
230
254
  *
231
255
  * @default Promise<undefined>
232
256
  */
233
- getNameService() {
257
+ getNameService(address) {
234
258
  return Promise.resolve(undefined);
235
259
  }
236
260
  getPublicClient() {
@@ -327,6 +351,41 @@ class WalletConnectorBase extends EventEmitter__default["default"] {
327
351
  setVerifiedCredentials(verifiedCredentials) {
328
352
  return;
329
353
  }
354
+ /**
355
+ * Validates if the address is connected and active in the wallet app
356
+ *
357
+ * @throws {WalletAddressMismatchError} If the active address does not match the expected address.
358
+ * @returns {Promise<void>} A promise that resolves if the active address matches the expected address,
359
+ * otherwise rejects with an error.
360
+ */
361
+ validateActiveWallet(expectedAddress) {
362
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
363
+ var _a, _b;
364
+ const [activeAddress] = yield this.getConnectedAccounts();
365
+ const isWalletActive = activeAddress === expectedAddress;
366
+ logger.logger.debug(`validateActiveWallet - wallet ${isWalletActive ? 'is' : 'is not'} active`, {
367
+ activeAddress,
368
+ expectedAddress,
369
+ });
370
+ const walletUiUtils = this.constructorProps
371
+ .walletUiUtils;
372
+ if (isWalletActive) {
373
+ return;
374
+ }
375
+ if (!walletUiUtils) {
376
+ throw new utils.WalletAddressMismatchError(`Wallet ${expectedAddress !== null && expectedAddress !== void 0 ? expectedAddress : ''} is not currently active in ${(_a = this.name) !== null && _a !== void 0 ? _a : this.key}.`, {
377
+ activeAddress,
378
+ expectedAddress,
379
+ walletName: (_b = this.name) !== null && _b !== void 0 ? _b : this.key,
380
+ });
381
+ }
382
+ return walletUiUtils.syncWallet({
383
+ activeAddress,
384
+ expectedAddress,
385
+ walletConnector: this,
386
+ });
387
+ });
388
+ }
330
389
  }
331
390
  _WalletConnectorBase_registeredExtensions = new WeakMap();
332
391
 
@@ -2,6 +2,7 @@ import EventEmitter from 'eventemitter3';
2
2
  import { WalletBookSchema, WalletSchema } from '@dynamic-labs/wallet-book';
3
3
  import type { JwtVerifiedCredential, WalletAdditionalAddress } from '@dynamic-labs/sdk-api-core';
4
4
  import { IChainRpcProviders } from '@dynamic-labs/rpc-providers';
5
+ import { MobileExperience } from '@dynamic-labs/types';
5
6
  import { WalletBookSingleton } from './WalletBookSingleton';
6
7
  import { WalletConnectorExtension } from './WalletConnectorExtension';
7
8
  import { WalletConnectorCore } from './types';
@@ -70,6 +71,7 @@ export declare abstract class WalletConnectorBase extends EventEmitter<WalletCon
70
71
  initEventListener(): void;
71
72
  get walletBook(): WalletBookSchema;
72
73
  filter(): boolean;
74
+ get mobileExperience(): MobileExperience | undefined;
73
75
  /**
74
76
  * This flag corresponds to whether this wallet connector also requires its own email otp outside dynamic
75
77
  * @default false
@@ -120,6 +122,21 @@ export declare abstract class WalletConnectorBase extends EventEmitter<WalletCon
120
122
  * @default Promise<undefined>
121
123
  */
122
124
  getAddress(opts?: GetAddressOpts): Promise<string | undefined>;
125
+ /**
126
+ * Parses a public address to ensure it follows a correct format.
127
+ *
128
+ * For instance, with EVM wallets, this might ensure it follows the EIP 55 format.
129
+ *
130
+ * @default string
131
+ */
132
+ parseAddress(address: string): string;
133
+ /**
134
+ * Whether this wallet connector is targeting a testnet.
135
+ * So far only supported for EVM connectors.
136
+ *
137
+ * @default Promise<false>
138
+ */
139
+ isTestnet(): Promise<boolean>;
123
140
  /**
124
141
  * Gets the additional addresses of the wallet, given the main address
125
142
  *
@@ -137,7 +154,7 @@ export declare abstract class WalletConnectorBase extends EventEmitter<WalletCon
137
154
  *
138
155
  * @default Promise<undefined>
139
156
  */
140
- getBalance(): Promise<string | undefined>;
157
+ getBalance(address: string): Promise<string | undefined>;
141
158
  /**
142
159
  * Get the address silently
143
160
  *
@@ -161,7 +178,7 @@ export declare abstract class WalletConnectorBase extends EventEmitter<WalletCon
161
178
  *
162
179
  * @default Promise<undefined>
163
180
  */
164
- getNameService(): Promise<NameServiceData | undefined>;
181
+ getNameService(address: string): Promise<NameServiceData | undefined>;
165
182
  /**
166
183
  * Get the RPC provider for the wallet
167
184
  *
@@ -169,28 +186,6 @@ export declare abstract class WalletConnectorBase extends EventEmitter<WalletCon
169
186
  */
170
187
  getPublicClient(): Promise<unknown>;
171
188
  getPublicClient<T>(): Promise<T>;
172
- /**
173
- * @deprecated getWeb3Provider has been renamed to getWalletClient
174
- * If you would like to still get the ethers web3Provider,
175
- * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
176
- *
177
- * Get the wallet provider
178
- */
179
- getWeb3Provider: {
180
- (chainId?: string): unknown;
181
- <T>(chainId?: string): T;
182
- };
183
- /**
184
- * @deprecated getRpcProvider has been renamed to getPublicClient
185
- * If you would like to still get the ethers rpcProvider,
186
- * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
187
- *
188
- * Get the rpc provider
189
- */
190
- getRpcProvider: {
191
- (): Promise<unknown>;
192
- <T>(): Promise<T>;
193
- };
194
189
  /**
195
190
  * Get the session for the wallet
196
191
  * @default Promise<undefined>
@@ -217,6 +212,12 @@ export declare abstract class WalletConnectorBase extends EventEmitter<WalletCon
217
212
  * @default Promise<void>
218
213
  */
219
214
  init(): Promise<void>;
215
+ /**
216
+ * Flag if connector/provider is available
217
+ *
218
+ * @default true
219
+ */
220
+ isAvailable: boolean;
220
221
  /**
221
222
  * If the wallet generated by a valid embedded wallet provider
222
223
  * For example: magic wallets
@@ -316,4 +317,12 @@ export declare abstract class WalletConnectorBase extends EventEmitter<WalletCon
316
317
  * Receive the user verified credentials
317
318
  */
318
319
  setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): void;
320
+ /**
321
+ * Validates if the address is connected and active in the wallet app
322
+ *
323
+ * @throws {WalletAddressMismatchError} If the active address does not match the expected address.
324
+ * @returns {Promise<void>} A promise that resolves if the active address matches the expected address,
325
+ * otherwise rejects with an error.
326
+ */
327
+ validateActiveWallet(expectedAddress: string): Promise<void>;
319
328
  }
@@ -2,6 +2,9 @@
2
2
  import { __classPrivateFieldGet, __awaiter } from '../../_virtual/_tslib.js';
3
3
  import EventEmitter from 'eventemitter3';
4
4
  import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
5
+ import { WalletAddressMismatchError } from '@dynamic-labs/utils';
6
+ import { logger } from '../utils/logger.js';
7
+ import { getMobileExperience } from '../utils/getMobileExperience/getMobileExperience.js';
5
8
  import { WalletBookSingleton } from './WalletBookSingleton.js';
6
9
 
7
10
  /* eslint-disable @typescript-eslint/triple-slash-reference */
@@ -69,21 +72,11 @@ class WalletConnectorBase extends EventEmitter {
69
72
  */
70
73
  this.canConnectViaSocial = false;
71
74
  /**
72
- * @deprecated getWeb3Provider has been renamed to getWalletClient
73
- * If you would like to still get the ethers web3Provider,
74
- * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
75
+ * Flag if connector/provider is available
75
76
  *
76
- * Get the wallet provider
77
- */
78
- this.getWeb3Provider = this.getWalletClient;
79
- /**
80
- * @deprecated getRpcProvider has been renamed to getPublicClient
81
- * If you would like to still get the ethers rpcProvider,
82
- * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
83
- *
84
- * Get the rpc provider
77
+ * @default true
85
78
  */
86
- this.getRpcProvider = this.getPublicClient;
79
+ this.isAvailable = true;
87
80
  /**
88
81
  * If the wallet generated by a valid embedded wallet provider
89
82
  * For example: magic wallets
@@ -126,6 +119,11 @@ class WalletConnectorBase extends EventEmitter {
126
119
  if (__classPrivateFieldGet(this, _WalletConnectorBase_registeredExtensions, "f").includes(extension.name)) {
127
120
  throw new Error(`You can only register a single extension of: ${extension.name}`);
128
121
  }
122
+ if (extension.name === 'global-wallet-extension') {
123
+ // only allow global wallet extension for evm embedded wallets
124
+ if (!this.isEmbeddedWallet || !this.supportedChains.includes('EVM'))
125
+ return;
126
+ }
129
127
  __classPrivateFieldGet(this, _WalletConnectorBase_registeredExtensions, "f").push(extension.name);
130
128
  extension.extend(this);
131
129
  }
@@ -151,6 +149,13 @@ class WalletConnectorBase extends EventEmitter {
151
149
  return false;
152
150
  }
153
151
  }
152
+ get mobileExperience() {
153
+ return getMobileExperience({
154
+ mobileExperienceProp: this.constructorProps.mobileExperience,
155
+ walletBook: this.walletBook,
156
+ walletKey: this.key,
157
+ });
158
+ }
154
159
  connect() {
155
160
  return __awaiter(this, void 0, void 0, function* () {
156
161
  yield this.getAddress();
@@ -174,6 +179,25 @@ class WalletConnectorBase extends EventEmitter {
174
179
  getAddress(opts) {
175
180
  return Promise.resolve(undefined);
176
181
  }
182
+ /**
183
+ * Parses a public address to ensure it follows a correct format.
184
+ *
185
+ * For instance, with EVM wallets, this might ensure it follows the EIP 55 format.
186
+ *
187
+ * @default string
188
+ */
189
+ parseAddress(address) {
190
+ return address;
191
+ }
192
+ /**
193
+ * Whether this wallet connector is targeting a testnet.
194
+ * So far only supported for EVM connectors.
195
+ *
196
+ * @default Promise<false>
197
+ */
198
+ isTestnet() {
199
+ return Promise.resolve(false);
200
+ }
177
201
  /**
178
202
  * Gets the additional addresses of the wallet, given the main address
179
203
  *
@@ -195,7 +219,7 @@ class WalletConnectorBase extends EventEmitter {
195
219
  *
196
220
  * @default Promise<undefined>
197
221
  */
198
- getBalance() {
222
+ getBalance(address) {
199
223
  return Promise.resolve(undefined);
200
224
  }
201
225
  /**
@@ -222,7 +246,7 @@ class WalletConnectorBase extends EventEmitter {
222
246
  *
223
247
  * @default Promise<undefined>
224
248
  */
225
- getNameService() {
249
+ getNameService(address) {
226
250
  return Promise.resolve(undefined);
227
251
  }
228
252
  getPublicClient() {
@@ -319,6 +343,41 @@ class WalletConnectorBase extends EventEmitter {
319
343
  setVerifiedCredentials(verifiedCredentials) {
320
344
  return;
321
345
  }
346
+ /**
347
+ * Validates if the address is connected and active in the wallet app
348
+ *
349
+ * @throws {WalletAddressMismatchError} If the active address does not match the expected address.
350
+ * @returns {Promise<void>} A promise that resolves if the active address matches the expected address,
351
+ * otherwise rejects with an error.
352
+ */
353
+ validateActiveWallet(expectedAddress) {
354
+ return __awaiter(this, void 0, void 0, function* () {
355
+ var _a, _b;
356
+ const [activeAddress] = yield this.getConnectedAccounts();
357
+ const isWalletActive = activeAddress === expectedAddress;
358
+ logger.debug(`validateActiveWallet - wallet ${isWalletActive ? 'is' : 'is not'} active`, {
359
+ activeAddress,
360
+ expectedAddress,
361
+ });
362
+ const walletUiUtils = this.constructorProps
363
+ .walletUiUtils;
364
+ if (isWalletActive) {
365
+ return;
366
+ }
367
+ if (!walletUiUtils) {
368
+ throw new WalletAddressMismatchError(`Wallet ${expectedAddress !== null && expectedAddress !== void 0 ? expectedAddress : ''} is not currently active in ${(_a = this.name) !== null && _a !== void 0 ? _a : this.key}.`, {
369
+ activeAddress,
370
+ expectedAddress,
371
+ walletName: (_b = this.name) !== null && _b !== void 0 ? _b : this.key,
372
+ });
373
+ }
374
+ return walletUiUtils.syncWallet({
375
+ activeAddress,
376
+ expectedAddress,
377
+ walletConnector: this,
378
+ });
379
+ });
380
+ }
322
381
  }
323
382
  _WalletConnectorBase_registeredExtensions = new WeakMap();
324
383
 
@@ -13,3 +13,4 @@ export * from './IWalletConnectConnector';
13
13
  export * from './ISendBalanceWalletConnector';
14
14
  export * from './ISessionKeyCompatibleWalletConnector';
15
15
  export * from './ISMSWalletConnector';
16
+ export * from './wallets';
@@ -0,0 +1,160 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
7
+ var types = require('@dynamic-labs/types');
8
+ var logger = require('../../../utils/logger.cjs');
9
+ require('@dynamic-labs/utils');
10
+ require('@dynamic-labs/wallet-book');
11
+
12
+ var _Wallet_connector;
13
+ class Wallet extends types.BaseWallet {
14
+ constructor(_a) {
15
+ var { connector } = _a, props = _tslib.__rest(_a, ["connector"]);
16
+ super(props);
17
+ _Wallet_connector.set(this, void 0);
18
+ _tslib.__classPrivateFieldSet(this, _Wallet_connector, connector, "f");
19
+ }
20
+ /**
21
+ * Gets the wallet connector.
22
+ */
23
+ get connector() {
24
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f");
25
+ }
26
+ /**
27
+ * Retrieves the balance of the wallet.
28
+ * @returns A promise that resolves to the balance of the wallet as a string,
29
+ * or undefined if the balance cannot be retrieved.
30
+ */
31
+ getBalance() {
32
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
33
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").getBalance(this.address);
34
+ });
35
+ }
36
+ /**
37
+ * Retrieves the name service data associated with the wallet.
38
+ * @returns A promise that resolves to the name service data of the wallet,
39
+ * or undefined if the data cannot be retrieved.
40
+ */
41
+ getNameService() {
42
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
43
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").getNameService(this.address);
44
+ });
45
+ }
46
+ /**
47
+ * Retrieves the network that the wallet is connected to.
48
+ * @returns A promise that resolves to the network value as a string or number,
49
+ * or undefined if the network cannot be retrieved.
50
+ */
51
+ getNetwork() {
52
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
53
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").getNetwork();
54
+ });
55
+ }
56
+ /**
57
+ * Retrieves the rpc provider for the wallet.
58
+ * @returns A promise that resolves to the provider,
59
+ * or undefined if the provider cannot be retrieved.
60
+ */
61
+ getPublicClient() {
62
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
63
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").getPublicClient();
64
+ });
65
+ }
66
+ /**
67
+ * Retrieves the signer for the wallet.
68
+ * @returns A promise that resolves to the signer,
69
+ * or undefined if the signer cannot be retrieved.
70
+ */
71
+ getSigner() {
72
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
73
+ yield this.sync();
74
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").getSigner();
75
+ });
76
+ }
77
+ /**
78
+ * Retrieves the wallet client.
79
+ * @param chainId - (optional) Chain id to be used by the wallet client.
80
+ * @returns A promise that resolves to the wallet client,
81
+ * or undefined if the wallet client cannot be retrieved.
82
+ */
83
+ getWalletClient(chainId) {
84
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
85
+ yield this.sync();
86
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").getWalletClient(chainId);
87
+ });
88
+ }
89
+ /**
90
+ * If the wallet is availble to use. A wallet is available if its provider is available.
91
+ * @returns True if the wallet is available, false otherwise.
92
+ */
93
+ isAvailable() {
94
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").isAvailable;
95
+ }
96
+ /**
97
+ * If the wallet is connected.
98
+ * @returns A promise that resolves to true the wallet is connected or false if it's not connected.
99
+ */
100
+ isConnected() {
101
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
102
+ try {
103
+ const connectedAccounts = yield _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").getConnectedAccounts();
104
+ return connectedAccounts.includes(this.address);
105
+ }
106
+ catch (error) {
107
+ logger.logger.error('[Wallet] isConnected - Error detecting if wallet is connected', error);
108
+ return false;
109
+ }
110
+ });
111
+ }
112
+ /**
113
+ * Proves ownership of the wallet by signing a message.
114
+ * @param messageToSign - The message to sign.
115
+ * @returns A promise that resolves to the signature of the message as a string,
116
+ * or undefined if the message cannot be signed.
117
+ */
118
+ proveOwnership(messageToSign) {
119
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
120
+ yield this.sync();
121
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").proveOwnership(messageToSign);
122
+ });
123
+ }
124
+ /**
125
+ * Signs a message using the wallet.
126
+ * @param messageToSign - The message to sign.
127
+ * @returns A promise that resolves to the signature of the message as a string,
128
+ * or undefined if the message cannot be signed.
129
+ */
130
+ signMessage(messageToSign) {
131
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
132
+ yield this.sync();
133
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").signMessage(messageToSign);
134
+ });
135
+ }
136
+ /**
137
+ * Switches the network that the wallet is connected to.
138
+ * @param networkChainId - The chain id of the network to switch to.
139
+ * @returns A promise that resolves when the network is switched.
140
+ */
141
+ switchNetwork(networkChainId) {
142
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
143
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").switchNetwork({
144
+ networkChainId,
145
+ });
146
+ });
147
+ }
148
+ /**
149
+ * Synchronizes the wallet with the connector.
150
+ * @returns A promise that resolves when the wallet is connected and active.
151
+ */
152
+ sync() {
153
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
154
+ return _tslib.__classPrivateFieldGet(this, _Wallet_connector, "f").validateActiveWallet(this.address);
155
+ });
156
+ }
157
+ }
158
+ _Wallet_connector = new WeakMap();
159
+
160
+ exports.Wallet = Wallet;
@@ -0,0 +1,87 @@
1
+ import type { BaseWalletProps } from '@dynamic-labs/types';
2
+ import { BaseWallet } from '@dynamic-labs/types';
3
+ import { NameServiceData, WalletConnector } from '../../';
4
+ type WalletProps = BaseWalletProps & {
5
+ connector: WalletConnector;
6
+ };
7
+ export declare class Wallet extends BaseWallet {
8
+ #private;
9
+ constructor({ connector, ...props }: WalletProps);
10
+ /**
11
+ * Gets the wallet connector.
12
+ */
13
+ get connector(): WalletConnector;
14
+ /**
15
+ * Retrieves the balance of the wallet.
16
+ * @returns A promise that resolves to the balance of the wallet as a string,
17
+ * or undefined if the balance cannot be retrieved.
18
+ */
19
+ getBalance(): Promise<string | undefined>;
20
+ /**
21
+ * Retrieves the name service data associated with the wallet.
22
+ * @returns A promise that resolves to the name service data of the wallet,
23
+ * or undefined if the data cannot be retrieved.
24
+ */
25
+ getNameService(): Promise<NameServiceData | undefined>;
26
+ /**
27
+ * Retrieves the network that the wallet is connected to.
28
+ * @returns A promise that resolves to the network value as a string or number,
29
+ * or undefined if the network cannot be retrieved.
30
+ */
31
+ getNetwork(): Promise<string | number | undefined>;
32
+ /**
33
+ * Retrieves the rpc provider for the wallet.
34
+ * @returns A promise that resolves to the provider,
35
+ * or undefined if the provider cannot be retrieved.
36
+ */
37
+ getPublicClient<T>(): Promise<T>;
38
+ /**
39
+ * Retrieves the signer for the wallet.
40
+ * @returns A promise that resolves to the signer,
41
+ * or undefined if the signer cannot be retrieved.
42
+ */
43
+ getSigner<T>(): Promise<T>;
44
+ /**
45
+ * Retrieves the wallet client.
46
+ * @param chainId - (optional) Chain id to be used by the wallet client.
47
+ * @returns A promise that resolves to the wallet client,
48
+ * or undefined if the wallet client cannot be retrieved.
49
+ */
50
+ getWalletClient<T>(chainId?: string): Promise<T>;
51
+ /**
52
+ * If the wallet is availble to use. A wallet is available if its provider is available.
53
+ * @returns True if the wallet is available, false otherwise.
54
+ */
55
+ isAvailable(): boolean;
56
+ /**
57
+ * If the wallet is connected.
58
+ * @returns A promise that resolves to true the wallet is connected or false if it's not connected.
59
+ */
60
+ isConnected(): Promise<boolean>;
61
+ /**
62
+ * Proves ownership of the wallet by signing a message.
63
+ * @param messageToSign - The message to sign.
64
+ * @returns A promise that resolves to the signature of the message as a string,
65
+ * or undefined if the message cannot be signed.
66
+ */
67
+ proveOwnership(messageToSign: string): Promise<string | undefined>;
68
+ /**
69
+ * Signs a message using the wallet.
70
+ * @param messageToSign - The message to sign.
71
+ * @returns A promise that resolves to the signature of the message as a string,
72
+ * or undefined if the message cannot be signed.
73
+ */
74
+ signMessage(messageToSign: string): Promise<string | undefined>;
75
+ /**
76
+ * Switches the network that the wallet is connected to.
77
+ * @param networkChainId - The chain id of the network to switch to.
78
+ * @returns A promise that resolves when the network is switched.
79
+ */
80
+ switchNetwork(networkChainId: number | string): Promise<void>;
81
+ /**
82
+ * Synchronizes the wallet with the connector.
83
+ * @returns A promise that resolves when the wallet is connected and active.
84
+ */
85
+ sync(): Promise<void>;
86
+ }
87
+ export {};