@dynamic-labs/wallet-connector-core 0.19.0-alpha.9 → 0.19.1

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +299 -0
  2. package/_virtual/_tslib.cjs +7 -0
  3. package/_virtual/_tslib.js +7 -1
  4. package/package.json +6 -6
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +3 -2
  7. package/src/index.js +1 -0
  8. package/src/lib/IEmailOTPWalletConnector.d.ts +4 -4
  9. package/src/lib/IEmailWalletConnector.d.ts +6 -6
  10. package/src/lib/IPasskeyWalletConnector.d.ts +12 -0
  11. package/src/lib/WalletBookSingleton.cjs +11 -11
  12. package/src/lib/WalletBookSingleton.d.ts +7 -7
  13. package/src/lib/WalletBookSingleton.js +11 -11
  14. package/src/lib/WalletConnector.cjs +306 -271
  15. package/src/lib/WalletConnector.d.ts +313 -277
  16. package/src/lib/WalletConnector.js +307 -272
  17. package/src/lib/WalletConnectorExtension.d.ts +5 -0
  18. package/src/lib/index.d.ts +5 -4
  19. package/src/lib/types.d.ts +8 -7
  20. package/src/utils/PhantomLedgerWalletName.cjs +4 -4
  21. package/src/utils/PhantomLedgerWalletName.d.ts +5 -5
  22. package/src/utils/PhantomLedgerWalletName.js +4 -4
  23. package/src/utils/ProviderLookup/ProviderLookup.cjs +11 -11
  24. package/src/utils/ProviderLookup/ProviderLookup.d.ts +5 -5
  25. package/src/utils/ProviderLookup/ProviderLookup.js +11 -11
  26. package/src/utils/ProviderLookup/index.d.ts +1 -1
  27. package/src/utils/encoding.cjs +9 -9
  28. package/src/utils/encoding.d.ts +4 -4
  29. package/src/utils/encoding.js +9 -9
  30. package/src/utils/getChainInfo/getChainInfo.cjs +53 -52
  31. package/src/utils/getChainInfo/getChainInfo.d.ts +2 -2
  32. package/src/utils/getChainInfo/getChainInfo.js +53 -52
  33. package/src/utils/getChainInfo/index.d.ts +1 -1
  34. package/src/utils/getWalletConnectorByKey.cjs +10 -10
  35. package/src/utils/getWalletConnectorByKey.d.ts +2 -2
  36. package/src/utils/getWalletConnectorByKey.js +10 -10
  37. package/src/utils/index.d.ts +17 -16
  38. package/src/utils/isBloctoConnector/index.d.ts +1 -1
  39. package/src/utils/isBloctoConnector/isBloctoConnector.d.ts +2 -2
  40. package/src/utils/isEmailOTPWalletConnector/index.d.ts +1 -1
  41. package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +2 -2
  42. package/src/utils/isEmailWalletConnector/index.d.ts +1 -1
  43. package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +2 -2
  44. package/src/utils/isEmbeddedConnector/index.d.ts +1 -1
  45. package/src/utils/isEmbeddedConnector/isEmbeddedConnector.cjs +1 -4
  46. package/src/utils/isEmbeddedConnector/isEmbeddedConnector.d.ts +2 -2
  47. package/src/utils/isEmbeddedConnector/isEmbeddedConnector.js +1 -4
  48. package/src/utils/isMagicConnector/index.d.ts +1 -1
  49. package/src/utils/isMagicConnector/isMagicConnector.d.ts +2 -2
  50. package/src/utils/isPasskeyWalletConnector/index.d.ts +1 -0
  51. package/src/utils/isPasskeyWalletConnector/isPasskeyWalletConnector.cjs +7 -0
  52. package/src/utils/isPasskeyWalletConnector/isPasskeyWalletConnector.d.ts +2 -0
  53. package/src/utils/isPasskeyWalletConnector/isPasskeyWalletConnector.js +3 -0
  54. package/src/utils/isSameAddress/index.d.ts +1 -1
  55. package/src/utils/isSameAddress/isSameAddress.d.ts +1 -1
  56. package/src/utils/isSameAddress/utils/index.d.ts +1 -1
  57. package/src/utils/isSameAddress/utils/normalizeAddress/index.d.ts +1 -1
  58. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.cjs +8 -8
  59. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.d.ts +1 -1
  60. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.js +8 -8
  61. package/src/utils/isSocialWalletConnector/index.d.ts +1 -1
  62. package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +2 -2
  63. package/src/utils/logger.d.ts +2 -2
  64. package/src/utils/normalizeWalletName/index.d.ts +1 -1
  65. package/src/utils/normalizeWalletName/normalizeWalletName.d.ts +1 -1
  66. package/src/utils/shouldLowercaseAddress.cjs +4 -4
  67. package/src/utils/shouldLowercaseAddress.d.ts +1 -1
  68. package/src/utils/shouldLowercaseAddress.js +4 -4
  69. package/src/utils/walletConnectDeepLinks/index.d.ts +2 -2
  70. package/src/utils/walletConnectDeepLinks/performPlatformSpecificConnectionMethod.cjs +17 -17
  71. package/src/utils/walletConnectDeepLinks/performPlatformSpecificConnectionMethod.d.ts +4 -4
  72. package/src/utils/walletConnectDeepLinks/performPlatformSpecificConnectionMethod.js +17 -17
  73. package/src/utils/walletConnectDeepLinks/walletConnectDeepLinks.cjs +33 -33
  74. package/src/utils/walletConnectDeepLinks/walletConnectDeepLinks.d.ts +10 -10
  75. package/src/utils/walletConnectDeepLinks/walletConnectDeepLinks.js +33 -33
@@ -11,278 +11,313 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
13
13
 
14
- /* eslint-disable @typescript-eslint/no-unused-vars */
15
- /* eslint-disable @typescript-eslint/no-empty-interface */
16
- const Chains = [
17
- 'ETH',
18
- 'FLOW',
19
- 'SOL',
20
- 'EVM',
21
- 'ALGO',
22
- 'STARK',
23
- 'ATOM',
24
- 'COSMOS',
25
- ];
26
- const socialProviders = [
27
- 'google',
28
- 'facebook',
29
- 'apple',
30
- 'github',
31
- 'bitbucket',
32
- 'gitlab',
33
- 'linkedin',
34
- 'twitter',
35
- 'discord',
36
- 'twitch',
37
- 'microsoft',
38
- ];
39
- class WalletConnectorBase extends EventEmitter__default["default"] {
40
- /**
41
- * We store the constructor props so that we can use them later on
42
- * in getMobileOrInstalledWallet which may fall back to a different class
43
- * but will need the original constructor props.
44
- * @param props - constructor props
45
- */
46
- constructor(props) {
47
- super();
48
- this.chainRpcProviders = undefined;
49
- this.didSetup = false;
50
- /**
51
- * @default false
52
- */
53
- this.canConnectViaEmail = false;
54
- /**
55
- * IF the wallet needs to be connected via a custodial service
56
- * such as Blocto, this will be true.
57
- * @default false
58
- */
59
- this.canConnectViaCustodialService = false;
60
- /**
61
- * If the wallet is not installed, and can be connected via a QR code,
62
- * this will be true.
63
- * @default false
64
- */
65
- this.canConnectViaQrCode = false;
66
- /**
67
- * Whether this connector can be connected via social login.
68
- * @default false
69
- */
70
- this.canConnectViaSocial = false;
71
- /**
72
- * If the wallet generated by a valid embedded wallet provider
73
- * For example: magic wallets
74
- * @default false
75
- */
76
- this.isEmbeddedWallet = false;
77
- /**
78
- * Flag if it is wallet Connect
79
- *
80
- * @default false
81
- */
82
- this.isWalletConnect = false;
83
- /**
84
- * Override key for the wallet (used for injected wallet linking)
85
- */
86
- this.overrideKey = undefined;
87
- /**
88
- * Additional resources to add to the message to be signed
89
- *
90
- * @default undefined
91
- */
92
- this.providerResources = undefined;
93
- /**
94
- * Requires switching network in the wallet itself
95
- * @default undefined
96
- */
97
- this.switchNetworkOnlyFromWallet = undefined;
98
- /**
99
- * Whether the connector has been initialized
100
- * @default true
101
- */
102
- this.isInitialized = true;
103
- this.constructorProps = props;
104
- this._walletBookInstance = WalletBookSingleton.WalletBookSingleton.getOrCreate(props.walletBook);
105
- if (this.walletBook === undefined) {
106
- throw new Error('WalletConnectorBase was not called with super(props) and is missing wallet-book');
107
- }
108
- }
109
- /**
110
- * Add the event listeners for the wallet and connect
111
- * with event emitter.
112
- */
113
- initEventListener() {
114
- if (this.didSetup)
115
- return;
116
- this.didSetup = true;
117
- this.setupEventListeners();
118
- }
119
- get walletBook() {
120
- return this._walletBookInstance.walletBook;
121
- }
122
- filterByWalletBook() {
123
- try {
124
- walletBook.getWalletBookWallet(this.walletBook, this.key);
125
- return true;
126
- }
127
- catch (_a) {
128
- return false;
129
- }
130
- }
131
- connect() {
132
- return _tslib.__awaiter(this, void 0, void 0, function* () {
133
- yield this.fetchPublicAddress();
134
- });
135
- }
136
- /**
137
- * Generic function to close the wallet connection
138
- * Originally implemented for WalletConnect, but it is used
139
- * for anything that needs to be "logged out" or cleaned up
140
- *
141
- * @default Promise<undefined>
142
- */
143
- endSession() {
144
- return Promise.resolve();
145
- }
146
- /**
147
- * Gets the public address of the wallet
148
- *
149
- * @default Promise<undefined>
150
- */
151
- fetchPublicAddress(opts) {
152
- return Promise.resolve(undefined);
153
- }
154
- /**
155
- * Gets the balance of the wallet
156
- *
157
- * @default Promise<undefined>
158
- */
159
- getBalance() {
160
- return Promise.resolve(undefined);
161
- }
162
- /**
163
- * Get the address silently
164
- *
165
- * @default Promise<[]>
166
- */
167
- getConnectedAccounts() {
168
- return Promise.resolve([]);
169
- }
170
- /**
171
- * Gets the deep link of the wallet
172
- *
173
- * @default undefined
174
- */
175
- getDeepLink() {
176
- return undefined;
177
- }
178
- getNetwork() {
179
- return Promise.resolve(undefined);
180
- }
181
- /**
182
- * Gets current network of connected wallet
183
- *
184
- * @default Promise<undefined>
185
- */
186
- getNameService() {
187
- return Promise.resolve(undefined);
188
- }
189
- getRpcProvider() {
190
- return Promise.resolve(undefined);
191
- }
192
- getSession() {
193
- return _tslib.__awaiter(this, void 0, void 0, function* () {
194
- return Promise.resolve();
195
- });
196
- }
197
- getSigner() {
198
- return Promise.resolve(undefined);
199
- }
200
- getWeb3Provider() {
201
- return undefined;
202
- }
203
- /**
204
- * Initialize the wallet connector with any async operations
205
- *
206
- * @default Promise<void>
207
- */
208
- init() {
209
- return Promise.resolve();
210
- }
211
- /**
212
- * Check if the wallet is installed on the browser
213
- *
214
- * @default false
215
- */
216
- isInstalledOnBrowser() {
217
- return false;
218
- }
219
- /**
220
- * Override key or the normalized wallet name if needed
221
- */
222
- get key() {
223
- return this.overrideKey || this.name.replace(/\W/g, '').toLowerCase();
224
- }
225
- /**
226
- * Whether the wallet connector should fall back to a different wallet connector
227
- * This is called after the object is instantiated, so it can't be a static property
228
- * and will return the appropriate instance of the wallet connector
229
- * @returns WalletConnector
230
- * @default this
231
- */
232
- getMobileOrInstalledWallet() {
233
- return this;
234
- }
235
- /**
236
- * In most cases this is an alias for `signMessage`
237
- *
238
- * @default Promise<undefined>
239
- */
240
- proveOwnership(messageToSign) {
241
- return this.signMessage(messageToSign);
242
- }
243
- /**
244
- * Set up event listeners for the wallet
245
- *
246
- * @default void
247
- */
248
- setupEventListeners() {
249
- return;
250
- }
251
- /**
252
- * Sign a message
253
- *
254
- * @default Promise<undefined>
255
- */
256
- signMessage(messageToSign) {
257
- return Promise.resolve(undefined);
258
- }
259
- /**
260
- * Whether the wallet supports network switching
261
- *
262
- * @default false
263
- */
264
- supportsNetworkSwitching() {
265
- return false;
266
- }
267
- switchNetwork({ networkName, networkChainId, }) {
268
- return Promise.resolve(undefined);
269
- }
270
- /**
271
- * Tear down event listeners for the wallet
272
- * @default void
273
- */
274
- teardownEventListeners() {
275
- return;
276
- }
277
- /**
278
- * Sign a message
279
- *
280
- * @default Promise<undefined>
281
- */
282
- getSupportedNetworks() {
283
- return Promise.resolve(undefined);
284
- }
14
+ /* eslint-disable @typescript-eslint/triple-slash-reference */
15
+ /* eslint-disable @typescript-eslint/no-namespace */
16
+ /* eslint-disable prefer-arrow/prefer-arrow-functions */
17
+ /* eslint-disable @typescript-eslint/no-unused-vars */
18
+ var _WalletConnectorBase_registeredExtensions;
19
+ /* eslint-disable @typescript-eslint/no-empty-interface */
20
+ const Chains = [
21
+ 'ETH',
22
+ 'FLOW',
23
+ 'SOL',
24
+ 'EVM',
25
+ 'ALGO',
26
+ 'STARK',
27
+ 'ATOM',
28
+ 'COSMOS',
29
+ ];
30
+ const socialProviders = [
31
+ 'google',
32
+ 'facebook',
33
+ 'apple',
34
+ 'github',
35
+ 'bitbucket',
36
+ 'gitlab',
37
+ 'linkedin',
38
+ 'twitter',
39
+ 'discord',
40
+ 'twitch',
41
+ 'microsoft',
42
+ ];
43
+ class WalletConnectorBase extends EventEmitter__default["default"] {
44
+ /**
45
+ * We store the constructor props so that we can use them later on
46
+ * in getMobileOrInstalledWallet which may fall back to a different class
47
+ * but will need the original constructor props.
48
+ * @param props - constructor props
49
+ */
50
+ constructor(props) {
51
+ super();
52
+ this.chainRpcProviders = undefined;
53
+ _WalletConnectorBase_registeredExtensions.set(this, []);
54
+ this.didSetup = false;
55
+ /**
56
+ * @default false
57
+ */
58
+ this.canConnectViaEmail = false;
59
+ /**
60
+ * IF the wallet needs to be connected via a custodial service
61
+ * such as Blocto, this will be true.
62
+ * @default false
63
+ */
64
+ this.canConnectViaCustodialService = false;
65
+ /**
66
+ * If the wallet is not installed, and can be connected via a QR code,
67
+ * this will be true.
68
+ * @default false
69
+ */
70
+ this.canConnectViaQrCode = false;
71
+ /**
72
+ * Whether this connector can be connected via social login.
73
+ * @default false
74
+ */
75
+ this.canConnectViaSocial = false;
76
+ /**
77
+ * @deprecated getWeb3Provider has been renamed to getWalletClient
78
+ * If you would like to still get the ethers web3Provider,
79
+ * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
80
+ *
81
+ * Get the wallet provider
82
+ */
83
+ this.getWeb3Provider = this.getWalletClient;
84
+ /**
85
+ * @deprecated getRpcProvider has been renamed to getPublicClient
86
+ * If you would like to still get the ethers rpcProvider,
87
+ * see our docs for enabling ethers: https://docs.dynamic.xyz/ethers
88
+ *
89
+ * Get the rpc provider
90
+ */
91
+ this.getRpcProvider = this.getPublicClient;
92
+ /**
93
+ * If the wallet generated by a valid embedded wallet provider
94
+ * For example: magic wallets
95
+ * @default false
96
+ */
97
+ this.isEmbeddedWallet = false;
98
+ /**
99
+ * Flag if it is wallet Connect
100
+ *
101
+ * @default false
102
+ */
103
+ this.isWalletConnect = false;
104
+ /**
105
+ * Override key for the wallet (used for injected wallet linking)
106
+ */
107
+ this.overrideKey = undefined;
108
+ /**
109
+ * Additional resources to add to the message to be signed
110
+ *
111
+ * @default undefined
112
+ */
113
+ this.providerResources = undefined;
114
+ /**
115
+ * Requires switching network in the wallet itself
116
+ * @default undefined
117
+ */
118
+ this.switchNetworkOnlyFromWallet = undefined;
119
+ /**
120
+ * Whether the connector has been initialized
121
+ * @default true
122
+ */
123
+ this.isInitialized = true;
124
+ this.constructorProps = props;
125
+ this._walletBookInstance = WalletBookSingleton.WalletBookSingleton.getOrCreate(props.walletBook);
126
+ if (this.walletBook === undefined) {
127
+ throw new Error('WalletConnectorBase was not called with super(props) and is missing wallet-book');
128
+ }
129
+ }
130
+ extend(extension) {
131
+ if (_tslib.__classPrivateFieldGet(this, _WalletConnectorBase_registeredExtensions, "f").includes(extension.name)) {
132
+ throw new Error(`You can only register a single extension of: ${extension.name}`);
133
+ }
134
+ _tslib.__classPrivateFieldGet(this, _WalletConnectorBase_registeredExtensions, "f").push(extension.name);
135
+ extension.extend(this);
136
+ }
137
+ /**
138
+ * Add the event listeners for the wallet and connect
139
+ * with event emitter.
140
+ */
141
+ initEventListener() {
142
+ if (this.didSetup)
143
+ return;
144
+ this.didSetup = true;
145
+ this.setupEventListeners();
146
+ }
147
+ get walletBook() {
148
+ return this._walletBookInstance.walletBook;
149
+ }
150
+ filterByWalletBook() {
151
+ try {
152
+ walletBook.getWalletBookWallet(this.walletBook, this.key);
153
+ return true;
154
+ }
155
+ catch (_a) {
156
+ return false;
157
+ }
158
+ }
159
+ connect() {
160
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
161
+ yield this.fetchPublicAddress();
162
+ });
163
+ }
164
+ /**
165
+ * Generic function to close the wallet connection
166
+ * Originally implemented for WalletConnect, but it is used
167
+ * for anything that needs to be "logged out" or cleaned up
168
+ *
169
+ * @default Promise<undefined>
170
+ */
171
+ endSession() {
172
+ return Promise.resolve();
173
+ }
174
+ /**
175
+ * Gets the public address of the wallet
176
+ *
177
+ * @default Promise<undefined>
178
+ */
179
+ fetchPublicAddress(opts) {
180
+ return Promise.resolve(undefined);
181
+ }
182
+ /**
183
+ * Gets the balance of the wallet
184
+ *
185
+ * @default Promise<undefined>
186
+ */
187
+ getBalance() {
188
+ return Promise.resolve(undefined);
189
+ }
190
+ /**
191
+ * Get the address silently
192
+ *
193
+ * @default Promise<[]>
194
+ */
195
+ getConnectedAccounts() {
196
+ return Promise.resolve([]);
197
+ }
198
+ /**
199
+ * Gets the deep link of the wallet
200
+ *
201
+ * @default undefined
202
+ */
203
+ getDeepLink() {
204
+ return undefined;
205
+ }
206
+ getNetwork() {
207
+ return Promise.resolve(undefined);
208
+ }
209
+ /**
210
+ * Gets current network of connected wallet
211
+ *
212
+ * @default Promise<undefined>
213
+ */
214
+ getNameService() {
215
+ return Promise.resolve(undefined);
216
+ }
217
+ getPublicClient() {
218
+ return Promise.resolve(undefined);
219
+ }
220
+ getSession() {
221
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
222
+ return Promise.resolve();
223
+ });
224
+ }
225
+ getSigner() {
226
+ return Promise.resolve(undefined);
227
+ }
228
+ getWalletClient() {
229
+ return undefined;
230
+ }
231
+ /**
232
+ * Initialize the wallet connector with any async operations
233
+ *
234
+ * @default Promise<void>
235
+ */
236
+ init() {
237
+ return Promise.resolve();
238
+ }
239
+ /**
240
+ * Check if the wallet is installed on the browser
241
+ *
242
+ * @default false
243
+ */
244
+ isInstalledOnBrowser() {
245
+ return false;
246
+ }
247
+ /**
248
+ * Override key or the normalized wallet name if needed
249
+ */
250
+ get key() {
251
+ return this.overrideKey || this.name.replace(/\W/g, '').toLowerCase();
252
+ }
253
+ /**
254
+ * Whether the wallet connector should fall back to a different wallet connector
255
+ * This is called after the object is instantiated, so it can't be a static property
256
+ * and will return the appropriate instance of the wallet connector
257
+ * @returns WalletConnector
258
+ * @default this
259
+ */
260
+ getMobileOrInstalledWallet() {
261
+ return this;
262
+ }
263
+ /**
264
+ * In most cases this is an alias for `signMessage`
265
+ *
266
+ * @default Promise<undefined>
267
+ */
268
+ proveOwnership(messageToSign) {
269
+ return this.signMessage(messageToSign);
270
+ }
271
+ /**
272
+ * Set up event listeners for the wallet
273
+ *
274
+ * @default void
275
+ */
276
+ setupEventListeners() {
277
+ return;
278
+ }
279
+ /**
280
+ * Sign a message
281
+ *
282
+ * @default Promise<undefined>
283
+ */
284
+ signMessage(messageToSign) {
285
+ return Promise.resolve(undefined);
286
+ }
287
+ /**
288
+ * Whether the wallet supports network switching
289
+ *
290
+ * @default false
291
+ */
292
+ supportsNetworkSwitching() {
293
+ return false;
294
+ }
295
+ switchNetwork({ networkName, networkChainId, }) {
296
+ return Promise.resolve(undefined);
297
+ }
298
+ /**
299
+ * Tear down event listeners for the wallet
300
+ * @default void
301
+ */
302
+ teardownEventListeners() {
303
+ return;
304
+ }
305
+ /**
306
+ * Sign a message
307
+ *
308
+ * @default Promise<undefined>
309
+ */
310
+ getSupportedNetworks() {
311
+ return Promise.resolve(undefined);
312
+ }
313
+ /**
314
+ * Receive the user verified credentials
315
+ */
316
+ setVerifiedCredentials(verifiedCredentials) {
317
+ return;
318
+ }
285
319
  }
320
+ _WalletConnectorBase_registeredExtensions = new WeakMap();
286
321
 
287
322
  exports.Chains = Chains;
288
323
  exports.WalletConnectorBase = WalletConnectorBase;