@dynamic-labs-wallet/browser-wallet-client 0.0.71 → 0.0.75-preview

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/index.cjs.js CHANGED
@@ -46,20 +46,18 @@ const setupMessageTransportBridge = (messageTransport$1, iframe, iframeOrigin)=>
46
46
  };
47
47
 
48
48
  class iframeMessageHandler {
49
- async getWallets() {
50
- return this.requestChannel.request('getWallets');
49
+ async getWallets(request) {
50
+ return this.requestChannel.request('getWallets', request);
51
51
  }
52
- async getWallet({ accountAddress, walletOperation }) {
52
+ async getWallet({ chainName, accountAddress, walletOperation }) {
53
53
  return this.requestChannel.request('getWallet', {
54
+ chainName,
54
55
  accountAddress,
55
56
  walletOperation
56
57
  });
57
58
  }
58
- async createWalletAccount(thresholdSignatureScheme, password) {
59
- return this.requestChannel.request('createWalletAccount', {
60
- thresholdSignatureScheme,
61
- password
62
- });
59
+ async createWalletAccount(request) {
60
+ return this.requestChannel.request('createWalletAccount', request);
63
61
  }
64
62
  async requiresPasswordForOperation(request) {
65
63
  return this.requestChannel.request('requiresPasswordForOperation', request);
@@ -125,10 +123,10 @@ class DynamicWalletClient {
125
123
  * this is called on class construction time
126
124
  * @returns {Promise<void>} that resolves when the iframe is loaded and the message transport and iframe storage are initialized
127
125
  */ initializeIframeCommunication() {
128
- if (!this.iframeLoadPromise) {
129
- this.iframeLoadPromise = this.doInitializeIframeCommunication();
126
+ if (!DynamicWalletClient.iframeLoadPromise) {
127
+ DynamicWalletClient.iframeLoadPromise = this.doInitializeIframeCommunication();
130
128
  }
131
- return this.iframeLoadPromise;
129
+ return DynamicWalletClient.iframeLoadPromise;
132
130
  }
133
131
  /**
134
132
  * initialize the iframe communication by awaiting the iframe load promise
@@ -136,8 +134,6 @@ class DynamicWalletClient {
136
134
  */ async doInitializeIframeCommunication() {
137
135
  try {
138
136
  await this.loadIframe();
139
- this.initializeMessageTransport();
140
- await this.initAuthToken();
141
137
  } catch (error) {
142
138
  this.logger.error('Error initializing iframe:', error);
143
139
  throw error;
@@ -145,7 +141,8 @@ class DynamicWalletClient {
145
141
  }
146
142
  /**
147
143
  * initialize the message transport after iframe is successfully loaded
148
- */ initializeMessageTransport() {
144
+ */ async initializeMessageTransport() {
145
+ await this.initializeIframeCommunication();
149
146
  const transport = messageTransport.applyDefaultMessageOrigin({
150
147
  defaultOrigin: 'host',
151
148
  messageTransport: messageTransport.createMessageTransport()
@@ -156,6 +153,7 @@ class DynamicWalletClient {
156
153
  }
157
154
  setupMessageTransportBridge(this.messageTransport, this.iframe, this.iframeDomain);
158
155
  this.iframeMessageHandler = new iframeMessageHandler(this.messageTransport);
156
+ await this.initAuthToken();
159
157
  }
160
158
  /**
161
159
  * securely exchange the auth token with iframe securely
@@ -170,8 +168,21 @@ class DynamicWalletClient {
170
168
  throw new Error('Failed to establish secure token exchange: ' + error);
171
169
  }
172
170
  }
173
- loadIframe() {
174
- return new Promise((resolve, reject)=>{
171
+ async loadIframe() {
172
+ // If the iframe is already loaded, just assign and resolve
173
+ if (DynamicWalletClient.sharedIframe) {
174
+ this.iframe = DynamicWalletClient.sharedIframe;
175
+ DynamicWalletClient.iframeInstanceCount++;
176
+ return Promise.resolve();
177
+ }
178
+ // If a load is in progress, wait for it, then assign
179
+ if (DynamicWalletClient.iframeLoadPromise) {
180
+ return DynamicWalletClient.iframeLoadPromise.then(()=>{
181
+ this.iframe = DynamicWalletClient.sharedIframe;
182
+ DynamicWalletClient.iframeInstanceCount++;
183
+ });
184
+ }
185
+ DynamicWalletClient.iframeLoadPromise = new Promise((resolve, reject)=>{
175
186
  const iframe = document.createElement('iframe');
176
187
  const iframeTimeoutId = setTimeout(()=>{
177
188
  reject(new Error('Iframe load timeout'));
@@ -193,15 +204,16 @@ class DynamicWalletClient {
193
204
  hostOrigin: window.location.origin,
194
205
  environmentId: this.environmentId,
195
206
  baseApiUrl: this.baseApiUrl,
196
- baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
197
- chain: this.chainName
207
+ baseMPCRelayApiUrl: this.baseMPCRelayApiUrl
198
208
  });
199
209
  iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
200
210
  this.logger.debug('Creating iframe with src:', iframe.src);
201
211
  document.body.appendChild(iframe);
202
212
  iframe.onload = ()=>{
203
213
  clearTimeout(iframeTimeoutId);
214
+ DynamicWalletClient.sharedIframe = iframe;
204
215
  this.iframe = iframe;
216
+ DynamicWalletClient.iframeInstanceCount++;
205
217
  resolve();
206
218
  };
207
219
  iframe.onerror = (error)=>{
@@ -210,6 +222,7 @@ class DynamicWalletClient {
210
222
  reject(new Error('Failed to load iframe'));
211
223
  };
212
224
  });
225
+ return DynamicWalletClient.iframeLoadPromise;
213
226
  }
214
227
  /**
215
228
  * Load an iframe for a specific container
@@ -285,65 +298,76 @@ class DynamicWalletClient {
285
298
  }
286
299
  }
287
300
  async getWallets() {
288
- await this.initializeIframeCommunication();
301
+ await this.initializeMessageTransport();
289
302
  if (!this.iframeMessageHandler) {
290
303
  throw new Error('Iframe message handler not initialized');
291
304
  }
292
- return this.iframeMessageHandler.getWallets();
305
+ return this.iframeMessageHandler.getWallets({
306
+ chainName: this.chainName
307
+ });
293
308
  }
294
309
  async getWallet({ accountAddress, walletOperation = core.WalletOperation.NO_OPERATION }) {
295
- await this.initializeIframeCommunication();
310
+ await this.initializeMessageTransport();
296
311
  if (!this.iframeMessageHandler) {
297
312
  throw new Error('Iframe message handler not initialized');
298
313
  }
299
314
  return this.iframeMessageHandler.getWallet({
315
+ chainName: this.chainName,
300
316
  accountAddress,
301
317
  walletOperation
302
318
  });
303
319
  }
304
320
  async createWalletAccount({ thresholdSignatureScheme, password = undefined }) {
305
- await this.initializeIframeCommunication();
321
+ await this.initializeMessageTransport();
306
322
  if (!this.iframeMessageHandler) {
307
323
  throw new Error('Iframe message handler not initialized');
308
324
  }
309
- return this.iframeMessageHandler.createWalletAccount(thresholdSignatureScheme, password);
325
+ return this.iframeMessageHandler.createWalletAccount({
326
+ chainName: this.chainName,
327
+ thresholdSignatureScheme,
328
+ password
329
+ });
310
330
  }
311
331
  async requiresPasswordForOperation({ accountAddress, walletOperation = core.WalletOperation.REACH_THRESHOLD }) {
312
- await this.initializeIframeCommunication();
332
+ await this.initializeMessageTransport();
313
333
  if (!this.iframeMessageHandler) {
314
334
  throw new Error('Iframe message handler not initialized');
315
335
  }
316
336
  return this.iframeMessageHandler.requiresPasswordForOperation({
337
+ chainName: this.chainName,
317
338
  accountAddress,
318
339
  walletOperation
319
340
  });
320
341
  }
321
342
  async isPasswordEncrypted({ accountAddress }) {
322
- await this.initializeIframeCommunication();
343
+ await this.initializeMessageTransport();
323
344
  if (!this.iframeMessageHandler) {
324
345
  throw new Error('Iframe message handler not initialized');
325
346
  }
326
347
  return this.iframeMessageHandler.isPasswordEncrypted({
348
+ chainName: this.chainName,
327
349
  accountAddress
328
350
  });
329
351
  }
330
352
  async signMessage({ message, accountAddress, password = undefined }) {
331
- await this.initializeIframeCommunication();
353
+ await this.initializeMessageTransport();
332
354
  if (!this.iframeMessageHandler) {
333
355
  throw new Error('Iframe message handler not initialized');
334
356
  }
335
357
  return this.iframeMessageHandler.signMessage({
358
+ chainName: this.chainName,
336
359
  message,
337
360
  accountAddress,
338
361
  password
339
362
  });
340
363
  }
341
364
  async signRawMessage({ message, accountAddress, password = undefined }) {
342
- await this.initializeIframeCommunication();
365
+ await this.initializeMessageTransport();
343
366
  if (!this.iframeMessageHandler) {
344
367
  throw new Error('Iframe message handler not initialized');
345
368
  }
346
369
  return this.iframeMessageHandler.signRawMessage({
370
+ chainName: this.chainName,
347
371
  message,
348
372
  accountAddress,
349
373
  password
@@ -360,22 +384,27 @@ class DynamicWalletClient {
360
384
  * const txBytes = await txb.build({ client });
361
385
  * const txString = Buffer.from(txBytes).toString("hex");
362
386
  */ async signTransaction({ senderAddress, transaction, password = undefined }) {
363
- await this.initializeIframeCommunication();
387
+ await this.initializeMessageTransport();
364
388
  if (!this.iframeMessageHandler) {
365
389
  throw new Error('Iframe message handler not initialized');
366
390
  }
367
391
  return this.iframeMessageHandler.signTransaction({
392
+ chainName: this.chainName,
368
393
  senderAddress,
369
394
  transaction,
370
395
  password
371
396
  });
372
397
  }
373
- async backupKeySharesToGoogleDrive(request) {
374
- await this.initializeIframeCommunication();
398
+ async backupKeySharesToGoogleDrive({ accountAddress, password = undefined }) {
399
+ await this.initializeMessageTransport();
375
400
  if (!this.iframeMessageHandler) {
376
401
  throw new Error('Iframe message handler not initialized');
377
402
  }
378
- return this.iframeMessageHandler.backupKeySharesToGoogleDrive(request);
403
+ return this.iframeMessageHandler.backupKeySharesToGoogleDrive({
404
+ chainName: this.chainName,
405
+ accountAddress,
406
+ password
407
+ });
379
408
  }
380
409
  async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password }) {
381
410
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
@@ -385,23 +414,34 @@ class DynamicWalletClient {
385
414
  throw new Error('Failed to initialize iframe handler with display functionality');
386
415
  }
387
416
  return iframeDisplay.restoreBackupFromGoogleDrive({
417
+ chainName: this.chainName,
388
418
  accountAddress,
389
419
  password
390
420
  });
391
421
  }
392
- async refreshWalletAccountShares(request) {
393
- await this.initializeIframeCommunication();
422
+ async refreshWalletAccountShares({ accountAddress, password }) {
423
+ await this.initializeMessageTransport();
394
424
  if (!this.iframeMessageHandler) {
395
425
  throw new Error('Iframe message handler not initialized');
396
426
  }
397
- return this.iframeMessageHandler.refreshWalletAccountShares(request);
427
+ return this.iframeMessageHandler.refreshWalletAccountShares({
428
+ chainName: this.chainName,
429
+ accountAddress: accountAddress,
430
+ password: password
431
+ });
398
432
  }
399
- async reshare(request) {
400
- await this.initializeIframeCommunication();
433
+ async reshare({ accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password }) {
434
+ await this.initializeMessageTransport();
401
435
  if (!this.iframeMessageHandler) {
402
436
  throw new Error('Iframe message handler not initialized');
403
437
  }
404
- return this.iframeMessageHandler.reshare(request);
438
+ return this.iframeMessageHandler.reshare({
439
+ chainName: this.chainName,
440
+ accountAddress,
441
+ oldThresholdSignatureScheme,
442
+ newThresholdSignatureScheme,
443
+ password
444
+ });
405
445
  }
406
446
  async exportPrivateKey({ accountAddress, displayContainer, password }) {
407
447
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
@@ -411,55 +451,59 @@ class DynamicWalletClient {
411
451
  throw new Error('Failed to initialize iframe handler with display functionality');
412
452
  }
413
453
  return iframeDisplay.exportPrivateKey({
454
+ chainName: this.chainName,
414
455
  accountAddress,
415
456
  password
416
457
  });
417
458
  }
418
459
  async verifyPassword({ accountAddress, password, walletOperation = core.WalletOperation.NO_OPERATION }) {
419
- await this.initializeIframeCommunication();
460
+ await this.initializeMessageTransport();
420
461
  if (!this.iframeMessageHandler) {
421
462
  throw new Error('Iframe message handler not initialized');
422
463
  }
423
464
  return this.iframeMessageHandler.verifyPassword({
465
+ chainName: this.chainName,
424
466
  accountAddress,
425
467
  password,
426
468
  walletOperation
427
469
  });
428
470
  }
429
471
  async updatePassword({ accountAddress, existingPassword, newPassword }) {
430
- await this.initializeIframeCommunication();
472
+ await this.initializeMessageTransport();
431
473
  if (!this.iframeMessageHandler) {
432
474
  throw new Error('Iframe message handler not initialized');
433
475
  }
434
476
  return this.iframeMessageHandler.updatePassword({
477
+ chainName: this.chainName,
435
478
  accountAddress,
436
479
  existingPassword,
437
480
  newPassword
438
481
  });
439
482
  }
440
- async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme }) {
441
- await this.initializeIframeCommunication();
483
+ async importPrivateKey({ privateKey, thresholdSignatureScheme }) {
484
+ await this.initializeMessageTransport();
442
485
  if (!this.iframeMessageHandler) {
443
486
  throw new Error('Iframe message handler not initialized');
444
487
  }
445
488
  return this.iframeMessageHandler.importPrivateKey({
489
+ chainName: this.chainName,
446
490
  privateKey,
447
- chainName,
448
491
  thresholdSignatureScheme
449
492
  });
450
493
  }
451
494
  async exportClientKeyshares({ accountAddress, password }) {
452
- await this.initializeIframeCommunication();
495
+ await this.initializeMessageTransport();
453
496
  if (!this.iframeMessageHandler) {
454
497
  throw new Error('Iframe message handler not initialized');
455
498
  }
456
499
  return this.iframeMessageHandler.exportClientKeyshares({
500
+ chainName: this.chainName,
457
501
  accountAddress,
458
502
  password
459
503
  });
460
504
  }
461
505
  async offlineExportPrivateKey({ keyShares, derivationPath }) {
462
- await this.initializeIframeCommunication();
506
+ await this.initializeMessageTransport();
463
507
  if (!this.iframeMessageHandler) {
464
508
  throw new Error('Iframe message handler not initialized');
465
509
  }
@@ -472,16 +516,27 @@ class DynamicWalletClient {
472
516
  const argsBuffer = new TextEncoder().encode(serializedArgs);
473
517
  const base64Args = Buffer.from(argsBuffer).toString('base64');
474
518
  return this.iframeMessageHandler.offlineExportPrivateKey({
519
+ chainName: this.chainName,
475
520
  base64Args
476
521
  });
477
522
  }
523
+ cleanup() {
524
+ if (this.iframe) {
525
+ DynamicWalletClient.iframeInstanceCount--;
526
+ if (DynamicWalletClient.sharedIframe && DynamicWalletClient.iframeInstanceCount === 0) {
527
+ document.body.removeChild(DynamicWalletClient.sharedIframe);
528
+ DynamicWalletClient.sharedIframe = null;
529
+ DynamicWalletClient.iframeLoadPromise = null;
530
+ }
531
+ this.iframe = null;
532
+ }
533
+ }
478
534
  constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, chainName, debug }){
479
535
  this.logger = logger;
480
536
  this.instanceId = null;
481
537
  this.iframeDomain = null;
482
538
  this.messageTransport = null;
483
539
  this.iframeMessageHandler = null;
484
- this.iframeLoadPromise = null;
485
540
  this.iframe = null;
486
541
  this.environmentId = environmentId;
487
542
  this.authToken = authToken;
@@ -498,6 +553,9 @@ class DynamicWalletClient {
498
553
  this.initialize();
499
554
  }
500
555
  }
556
+ DynamicWalletClient.iframeLoadPromise = null;
557
+ DynamicWalletClient.sharedIframe = null;
558
+ DynamicWalletClient.iframeInstanceCount = 0;
501
559
 
502
560
  Object.defineProperty(exports, "MPC_RELAY_PREPROD_API_URL", {
503
561
  enumerable: true,
package/index.esm.js CHANGED
@@ -45,20 +45,18 @@ const setupMessageTransportBridge = (messageTransport, iframe, iframeOrigin)=>{
45
45
  };
46
46
 
47
47
  class iframeMessageHandler {
48
- async getWallets() {
49
- return this.requestChannel.request('getWallets');
48
+ async getWallets(request) {
49
+ return this.requestChannel.request('getWallets', request);
50
50
  }
51
- async getWallet({ accountAddress, walletOperation }) {
51
+ async getWallet({ chainName, accountAddress, walletOperation }) {
52
52
  return this.requestChannel.request('getWallet', {
53
+ chainName,
53
54
  accountAddress,
54
55
  walletOperation
55
56
  });
56
57
  }
57
- async createWalletAccount(thresholdSignatureScheme, password) {
58
- return this.requestChannel.request('createWalletAccount', {
59
- thresholdSignatureScheme,
60
- password
61
- });
58
+ async createWalletAccount(request) {
59
+ return this.requestChannel.request('createWalletAccount', request);
62
60
  }
63
61
  async requiresPasswordForOperation(request) {
64
62
  return this.requestChannel.request('requiresPasswordForOperation', request);
@@ -124,10 +122,10 @@ class DynamicWalletClient {
124
122
  * this is called on class construction time
125
123
  * @returns {Promise<void>} that resolves when the iframe is loaded and the message transport and iframe storage are initialized
126
124
  */ initializeIframeCommunication() {
127
- if (!this.iframeLoadPromise) {
128
- this.iframeLoadPromise = this.doInitializeIframeCommunication();
125
+ if (!DynamicWalletClient.iframeLoadPromise) {
126
+ DynamicWalletClient.iframeLoadPromise = this.doInitializeIframeCommunication();
129
127
  }
130
- return this.iframeLoadPromise;
128
+ return DynamicWalletClient.iframeLoadPromise;
131
129
  }
132
130
  /**
133
131
  * initialize the iframe communication by awaiting the iframe load promise
@@ -135,8 +133,6 @@ class DynamicWalletClient {
135
133
  */ async doInitializeIframeCommunication() {
136
134
  try {
137
135
  await this.loadIframe();
138
- this.initializeMessageTransport();
139
- await this.initAuthToken();
140
136
  } catch (error) {
141
137
  this.logger.error('Error initializing iframe:', error);
142
138
  throw error;
@@ -144,7 +140,8 @@ class DynamicWalletClient {
144
140
  }
145
141
  /**
146
142
  * initialize the message transport after iframe is successfully loaded
147
- */ initializeMessageTransport() {
143
+ */ async initializeMessageTransport() {
144
+ await this.initializeIframeCommunication();
148
145
  const transport = applyDefaultMessageOrigin({
149
146
  defaultOrigin: 'host',
150
147
  messageTransport: createMessageTransport()
@@ -155,6 +152,7 @@ class DynamicWalletClient {
155
152
  }
156
153
  setupMessageTransportBridge(this.messageTransport, this.iframe, this.iframeDomain);
157
154
  this.iframeMessageHandler = new iframeMessageHandler(this.messageTransport);
155
+ await this.initAuthToken();
158
156
  }
159
157
  /**
160
158
  * securely exchange the auth token with iframe securely
@@ -169,8 +167,21 @@ class DynamicWalletClient {
169
167
  throw new Error('Failed to establish secure token exchange: ' + error);
170
168
  }
171
169
  }
172
- loadIframe() {
173
- return new Promise((resolve, reject)=>{
170
+ async loadIframe() {
171
+ // If the iframe is already loaded, just assign and resolve
172
+ if (DynamicWalletClient.sharedIframe) {
173
+ this.iframe = DynamicWalletClient.sharedIframe;
174
+ DynamicWalletClient.iframeInstanceCount++;
175
+ return Promise.resolve();
176
+ }
177
+ // If a load is in progress, wait for it, then assign
178
+ if (DynamicWalletClient.iframeLoadPromise) {
179
+ return DynamicWalletClient.iframeLoadPromise.then(()=>{
180
+ this.iframe = DynamicWalletClient.sharedIframe;
181
+ DynamicWalletClient.iframeInstanceCount++;
182
+ });
183
+ }
184
+ DynamicWalletClient.iframeLoadPromise = new Promise((resolve, reject)=>{
174
185
  const iframe = document.createElement('iframe');
175
186
  const iframeTimeoutId = setTimeout(()=>{
176
187
  reject(new Error('Iframe load timeout'));
@@ -192,15 +203,16 @@ class DynamicWalletClient {
192
203
  hostOrigin: window.location.origin,
193
204
  environmentId: this.environmentId,
194
205
  baseApiUrl: this.baseApiUrl,
195
- baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
196
- chain: this.chainName
206
+ baseMPCRelayApiUrl: this.baseMPCRelayApiUrl
197
207
  });
198
208
  iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
199
209
  this.logger.debug('Creating iframe with src:', iframe.src);
200
210
  document.body.appendChild(iframe);
201
211
  iframe.onload = ()=>{
202
212
  clearTimeout(iframeTimeoutId);
213
+ DynamicWalletClient.sharedIframe = iframe;
203
214
  this.iframe = iframe;
215
+ DynamicWalletClient.iframeInstanceCount++;
204
216
  resolve();
205
217
  };
206
218
  iframe.onerror = (error)=>{
@@ -209,6 +221,7 @@ class DynamicWalletClient {
209
221
  reject(new Error('Failed to load iframe'));
210
222
  };
211
223
  });
224
+ return DynamicWalletClient.iframeLoadPromise;
212
225
  }
213
226
  /**
214
227
  * Load an iframe for a specific container
@@ -284,65 +297,76 @@ class DynamicWalletClient {
284
297
  }
285
298
  }
286
299
  async getWallets() {
287
- await this.initializeIframeCommunication();
300
+ await this.initializeMessageTransport();
288
301
  if (!this.iframeMessageHandler) {
289
302
  throw new Error('Iframe message handler not initialized');
290
303
  }
291
- return this.iframeMessageHandler.getWallets();
304
+ return this.iframeMessageHandler.getWallets({
305
+ chainName: this.chainName
306
+ });
292
307
  }
293
308
  async getWallet({ accountAddress, walletOperation = WalletOperation.NO_OPERATION }) {
294
- await this.initializeIframeCommunication();
309
+ await this.initializeMessageTransport();
295
310
  if (!this.iframeMessageHandler) {
296
311
  throw new Error('Iframe message handler not initialized');
297
312
  }
298
313
  return this.iframeMessageHandler.getWallet({
314
+ chainName: this.chainName,
299
315
  accountAddress,
300
316
  walletOperation
301
317
  });
302
318
  }
303
319
  async createWalletAccount({ thresholdSignatureScheme, password = undefined }) {
304
- await this.initializeIframeCommunication();
320
+ await this.initializeMessageTransport();
305
321
  if (!this.iframeMessageHandler) {
306
322
  throw new Error('Iframe message handler not initialized');
307
323
  }
308
- return this.iframeMessageHandler.createWalletAccount(thresholdSignatureScheme, password);
324
+ return this.iframeMessageHandler.createWalletAccount({
325
+ chainName: this.chainName,
326
+ thresholdSignatureScheme,
327
+ password
328
+ });
309
329
  }
310
330
  async requiresPasswordForOperation({ accountAddress, walletOperation = WalletOperation.REACH_THRESHOLD }) {
311
- await this.initializeIframeCommunication();
331
+ await this.initializeMessageTransport();
312
332
  if (!this.iframeMessageHandler) {
313
333
  throw new Error('Iframe message handler not initialized');
314
334
  }
315
335
  return this.iframeMessageHandler.requiresPasswordForOperation({
336
+ chainName: this.chainName,
316
337
  accountAddress,
317
338
  walletOperation
318
339
  });
319
340
  }
320
341
  async isPasswordEncrypted({ accountAddress }) {
321
- await this.initializeIframeCommunication();
342
+ await this.initializeMessageTransport();
322
343
  if (!this.iframeMessageHandler) {
323
344
  throw new Error('Iframe message handler not initialized');
324
345
  }
325
346
  return this.iframeMessageHandler.isPasswordEncrypted({
347
+ chainName: this.chainName,
326
348
  accountAddress
327
349
  });
328
350
  }
329
351
  async signMessage({ message, accountAddress, password = undefined }) {
330
- await this.initializeIframeCommunication();
352
+ await this.initializeMessageTransport();
331
353
  if (!this.iframeMessageHandler) {
332
354
  throw new Error('Iframe message handler not initialized');
333
355
  }
334
356
  return this.iframeMessageHandler.signMessage({
357
+ chainName: this.chainName,
335
358
  message,
336
359
  accountAddress,
337
360
  password
338
361
  });
339
362
  }
340
363
  async signRawMessage({ message, accountAddress, password = undefined }) {
341
- await this.initializeIframeCommunication();
364
+ await this.initializeMessageTransport();
342
365
  if (!this.iframeMessageHandler) {
343
366
  throw new Error('Iframe message handler not initialized');
344
367
  }
345
368
  return this.iframeMessageHandler.signRawMessage({
369
+ chainName: this.chainName,
346
370
  message,
347
371
  accountAddress,
348
372
  password
@@ -359,22 +383,27 @@ class DynamicWalletClient {
359
383
  * const txBytes = await txb.build({ client });
360
384
  * const txString = Buffer.from(txBytes).toString("hex");
361
385
  */ async signTransaction({ senderAddress, transaction, password = undefined }) {
362
- await this.initializeIframeCommunication();
386
+ await this.initializeMessageTransport();
363
387
  if (!this.iframeMessageHandler) {
364
388
  throw new Error('Iframe message handler not initialized');
365
389
  }
366
390
  return this.iframeMessageHandler.signTransaction({
391
+ chainName: this.chainName,
367
392
  senderAddress,
368
393
  transaction,
369
394
  password
370
395
  });
371
396
  }
372
- async backupKeySharesToGoogleDrive(request) {
373
- await this.initializeIframeCommunication();
397
+ async backupKeySharesToGoogleDrive({ accountAddress, password = undefined }) {
398
+ await this.initializeMessageTransport();
374
399
  if (!this.iframeMessageHandler) {
375
400
  throw new Error('Iframe message handler not initialized');
376
401
  }
377
- return this.iframeMessageHandler.backupKeySharesToGoogleDrive(request);
402
+ return this.iframeMessageHandler.backupKeySharesToGoogleDrive({
403
+ chainName: this.chainName,
404
+ accountAddress,
405
+ password
406
+ });
378
407
  }
379
408
  async restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password }) {
380
409
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
@@ -384,23 +413,34 @@ class DynamicWalletClient {
384
413
  throw new Error('Failed to initialize iframe handler with display functionality');
385
414
  }
386
415
  return iframeDisplay.restoreBackupFromGoogleDrive({
416
+ chainName: this.chainName,
387
417
  accountAddress,
388
418
  password
389
419
  });
390
420
  }
391
- async refreshWalletAccountShares(request) {
392
- await this.initializeIframeCommunication();
421
+ async refreshWalletAccountShares({ accountAddress, password }) {
422
+ await this.initializeMessageTransport();
393
423
  if (!this.iframeMessageHandler) {
394
424
  throw new Error('Iframe message handler not initialized');
395
425
  }
396
- return this.iframeMessageHandler.refreshWalletAccountShares(request);
426
+ return this.iframeMessageHandler.refreshWalletAccountShares({
427
+ chainName: this.chainName,
428
+ accountAddress: accountAddress,
429
+ password: password
430
+ });
397
431
  }
398
- async reshare(request) {
399
- await this.initializeIframeCommunication();
432
+ async reshare({ accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password }) {
433
+ await this.initializeMessageTransport();
400
434
  if (!this.iframeMessageHandler) {
401
435
  throw new Error('Iframe message handler not initialized');
402
436
  }
403
- return this.iframeMessageHandler.reshare(request);
437
+ return this.iframeMessageHandler.reshare({
438
+ chainName: this.chainName,
439
+ accountAddress,
440
+ oldThresholdSignatureScheme,
441
+ newThresholdSignatureScheme,
442
+ password
443
+ });
404
444
  }
405
445
  async exportPrivateKey({ accountAddress, displayContainer, password }) {
406
446
  const { iframeDisplay } = await this.initializeIframeDisplayForContainer({
@@ -410,55 +450,59 @@ class DynamicWalletClient {
410
450
  throw new Error('Failed to initialize iframe handler with display functionality');
411
451
  }
412
452
  return iframeDisplay.exportPrivateKey({
453
+ chainName: this.chainName,
413
454
  accountAddress,
414
455
  password
415
456
  });
416
457
  }
417
458
  async verifyPassword({ accountAddress, password, walletOperation = WalletOperation.NO_OPERATION }) {
418
- await this.initializeIframeCommunication();
459
+ await this.initializeMessageTransport();
419
460
  if (!this.iframeMessageHandler) {
420
461
  throw new Error('Iframe message handler not initialized');
421
462
  }
422
463
  return this.iframeMessageHandler.verifyPassword({
464
+ chainName: this.chainName,
423
465
  accountAddress,
424
466
  password,
425
467
  walletOperation
426
468
  });
427
469
  }
428
470
  async updatePassword({ accountAddress, existingPassword, newPassword }) {
429
- await this.initializeIframeCommunication();
471
+ await this.initializeMessageTransport();
430
472
  if (!this.iframeMessageHandler) {
431
473
  throw new Error('Iframe message handler not initialized');
432
474
  }
433
475
  return this.iframeMessageHandler.updatePassword({
476
+ chainName: this.chainName,
434
477
  accountAddress,
435
478
  existingPassword,
436
479
  newPassword
437
480
  });
438
481
  }
439
- async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme }) {
440
- await this.initializeIframeCommunication();
482
+ async importPrivateKey({ privateKey, thresholdSignatureScheme }) {
483
+ await this.initializeMessageTransport();
441
484
  if (!this.iframeMessageHandler) {
442
485
  throw new Error('Iframe message handler not initialized');
443
486
  }
444
487
  return this.iframeMessageHandler.importPrivateKey({
488
+ chainName: this.chainName,
445
489
  privateKey,
446
- chainName,
447
490
  thresholdSignatureScheme
448
491
  });
449
492
  }
450
493
  async exportClientKeyshares({ accountAddress, password }) {
451
- await this.initializeIframeCommunication();
494
+ await this.initializeMessageTransport();
452
495
  if (!this.iframeMessageHandler) {
453
496
  throw new Error('Iframe message handler not initialized');
454
497
  }
455
498
  return this.iframeMessageHandler.exportClientKeyshares({
499
+ chainName: this.chainName,
456
500
  accountAddress,
457
501
  password
458
502
  });
459
503
  }
460
504
  async offlineExportPrivateKey({ keyShares, derivationPath }) {
461
- await this.initializeIframeCommunication();
505
+ await this.initializeMessageTransport();
462
506
  if (!this.iframeMessageHandler) {
463
507
  throw new Error('Iframe message handler not initialized');
464
508
  }
@@ -471,16 +515,27 @@ class DynamicWalletClient {
471
515
  const argsBuffer = new TextEncoder().encode(serializedArgs);
472
516
  const base64Args = Buffer.from(argsBuffer).toString('base64');
473
517
  return this.iframeMessageHandler.offlineExportPrivateKey({
518
+ chainName: this.chainName,
474
519
  base64Args
475
520
  });
476
521
  }
522
+ cleanup() {
523
+ if (this.iframe) {
524
+ DynamicWalletClient.iframeInstanceCount--;
525
+ if (DynamicWalletClient.sharedIframe && DynamicWalletClient.iframeInstanceCount === 0) {
526
+ document.body.removeChild(DynamicWalletClient.sharedIframe);
527
+ DynamicWalletClient.sharedIframe = null;
528
+ DynamicWalletClient.iframeLoadPromise = null;
529
+ }
530
+ this.iframe = null;
531
+ }
532
+ }
477
533
  constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, chainName, debug }){
478
534
  this.logger = logger;
479
535
  this.instanceId = null;
480
536
  this.iframeDomain = null;
481
537
  this.messageTransport = null;
482
538
  this.iframeMessageHandler = null;
483
- this.iframeLoadPromise = null;
484
539
  this.iframe = null;
485
540
  this.environmentId = environmentId;
486
541
  this.authToken = authToken;
@@ -497,5 +552,8 @@ class DynamicWalletClient {
497
552
  this.initialize();
498
553
  }
499
554
  }
555
+ DynamicWalletClient.iframeLoadPromise = null;
556
+ DynamicWalletClient.sharedIframe = null;
557
+ DynamicWalletClient.iframeInstanceCount = 0;
500
558
 
501
559
  export { DynamicWalletClient };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/browser-wallet-client",
3
- "version": "0.0.71",
3
+ "version": "0.0.75-preview",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
- "@dynamic-labs-wallet/core": "0.0.71",
6
+ "@dynamic-labs-wallet/core": "0.0.75-preview",
7
7
  "@dynamic-labs/message-transport": "^4.9.9",
8
8
  "@dynamic-labs/logger": "^4.9.9",
9
9
  "@noble/hashes": "1.7.1"
@@ -1,6 +1,6 @@
1
1
  import { type MessageTransportWithDefaultOrigin } from '@dynamic-labs/message-transport';
2
2
  import { iframeMessageHandler } from '../services/iframeMessageHandler';
3
- import type { ThresholdSignatureScheme, GetWalletResponse, CreateWalletAccountResponse, RequiresPasswordForOperationRequest, SignMessageRequest, IsPasswordEncryptedRequest, BackupKeySharesToGoogleDriveRequest, RefreshWalletAccountSharesRequest, ReshareRequest, VerifyPasswordRequest, UpdatePasswordRequest, ImportPrivateKeyRequest, ExportClientKeysharesRequest, OfflineExportPrivateKeyResponse, SignRawMessageRequest } from '@dynamic-labs-wallet/core';
3
+ import type { GetWalletResponse, CreateWalletAccountResponse, RequiresPasswordForOperationRequest, SignMessageRequest, IsPasswordEncryptedRequest, BackupKeySharesToGoogleDriveRequest, VerifyPasswordRequest, UpdatePasswordRequest, ImportPrivateKeyRequest, ExportClientKeysharesRequest, OfflineExportPrivateKeyResponse, SignRawMessageRequest, CreateWalletAccountRequest, SignTransactionRequest, RefreshWalletAccountSharesRequest, ReshareRequest } from '@dynamic-labs-wallet/core';
4
4
  import { WalletOperation } from '@dynamic-labs-wallet/core';
5
5
  import { EcdsaKeygenResult, Ed25519KeygenResult } from '../../../internal/web';
6
6
  export declare class DynamicWalletClient {
@@ -9,14 +9,16 @@ export declare class DynamicWalletClient {
9
9
  instanceId: string | null;
10
10
  iframeDomain: string | null;
11
11
  environmentId: string;
12
- authToken: string;
12
+ private authToken;
13
13
  baseApiUrl: string;
14
14
  baseMPCRelayApiUrl: string;
15
15
  protected messageTransport: MessageTransportWithDefaultOrigin | null;
16
16
  protected iframeMessageHandler: iframeMessageHandler | null;
17
- private iframeLoadPromise;
17
+ private static iframeLoadPromise;
18
18
  protected iframe: HTMLIFrameElement | null;
19
19
  private debug;
20
+ private static sharedIframe;
21
+ private static iframeInstanceCount;
20
22
  constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, chainName, debug, }: {
21
23
  environmentId: string;
22
24
  authToken: string;
@@ -72,14 +74,11 @@ export declare class DynamicWalletClient {
72
74
  accountAddress: string;
73
75
  walletOperation?: WalletOperation;
74
76
  }): Promise<GetWalletResponse>;
75
- createWalletAccount({ thresholdSignatureScheme, password, }: {
76
- thresholdSignatureScheme: ThresholdSignatureScheme;
77
- password?: string;
78
- }): Promise<CreateWalletAccountResponse>;
79
- requiresPasswordForOperation({ accountAddress, walletOperation, }: RequiresPasswordForOperationRequest): Promise<boolean>;
80
- isPasswordEncrypted({ accountAddress, }: IsPasswordEncryptedRequest): Promise<boolean>;
81
- signMessage({ message, accountAddress, password, }: SignMessageRequest): Promise<string>;
82
- signRawMessage({ message, accountAddress, password, }: SignRawMessageRequest): Promise<string>;
77
+ createWalletAccount({ thresholdSignatureScheme, password, }: Omit<CreateWalletAccountRequest, 'chainName'>): Promise<CreateWalletAccountResponse>;
78
+ requiresPasswordForOperation({ accountAddress, walletOperation, }: Omit<RequiresPasswordForOperationRequest, 'chainName'>): Promise<boolean>;
79
+ isPasswordEncrypted({ accountAddress, }: Omit<IsPasswordEncryptedRequest, 'chainName'>): Promise<boolean>;
80
+ signMessage({ message, accountAddress, password, }: Omit<SignMessageRequest, 'chainName'>): Promise<string>;
81
+ signRawMessage({ message, accountAddress, password, }: Omit<SignRawMessageRequest, 'chainName'>): Promise<string>;
83
82
  /**
84
83
  * Signs a transaction and returns the signature, @transaction is a string of the serialized transaction
85
84
  * EVM:
@@ -91,31 +90,28 @@ export declare class DynamicWalletClient {
91
90
  * const txBytes = await txb.build({ client });
92
91
  * const txString = Buffer.from(txBytes).toString("hex");
93
92
  */
94
- signTransaction({ senderAddress, transaction, password, }: {
95
- senderAddress: string;
96
- transaction: string;
97
- password?: string;
98
- }): Promise<string>;
99
- backupKeySharesToGoogleDrive(request: BackupKeySharesToGoogleDriveRequest): Promise<void>;
93
+ signTransaction({ senderAddress, transaction, password, }: Omit<SignTransactionRequest, 'chainName'>): Promise<string>;
94
+ backupKeySharesToGoogleDrive({ accountAddress, password, }: Omit<BackupKeySharesToGoogleDriveRequest, 'chainName'>): Promise<void>;
100
95
  restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password, }: {
101
96
  accountAddress: string;
102
97
  displayContainer: HTMLElement;
103
98
  password?: string;
104
99
  }): Promise<void>;
105
- refreshWalletAccountShares(request: RefreshWalletAccountSharesRequest): Promise<void>;
106
- reshare(request: ReshareRequest): Promise<void>;
100
+ refreshWalletAccountShares({ accountAddress, password, }: Omit<RefreshWalletAccountSharesRequest, 'chainName'>): Promise<void>;
101
+ reshare({ accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, }: Omit<ReshareRequest, 'chainName'>): Promise<void>;
107
102
  exportPrivateKey({ accountAddress, displayContainer, password, }: {
108
103
  accountAddress: string;
109
104
  displayContainer: HTMLElement;
110
105
  password?: string;
111
106
  }): Promise<void>;
112
- verifyPassword({ accountAddress, password, walletOperation, }: VerifyPasswordRequest): Promise<void>;
113
- updatePassword({ accountAddress, existingPassword, newPassword, }: UpdatePasswordRequest): Promise<void>;
114
- importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, }: ImportPrivateKeyRequest): Promise<CreateWalletAccountResponse>;
115
- exportClientKeyshares({ accountAddress, password, }: ExportClientKeysharesRequest): Promise<void>;
107
+ verifyPassword({ accountAddress, password, walletOperation, }: Omit<VerifyPasswordRequest, 'chainName'>): Promise<void>;
108
+ updatePassword({ accountAddress, existingPassword, newPassword, }: Omit<UpdatePasswordRequest, 'chainName'>): Promise<void>;
109
+ importPrivateKey({ privateKey, thresholdSignatureScheme, }: Omit<ImportPrivateKeyRequest, 'chainName'>): Promise<CreateWalletAccountResponse>;
110
+ exportClientKeyshares({ accountAddress, password, }: Omit<ExportClientKeysharesRequest, 'chainName'>): Promise<void>;
116
111
  offlineExportPrivateKey({ keyShares, derivationPath, }: {
117
112
  keyShares: (EcdsaKeygenResult | Ed25519KeygenResult)[];
118
113
  derivationPath?: string;
119
114
  }): Promise<OfflineExportPrivateKeyResponse>;
115
+ cleanup(): void;
120
116
  }
121
117
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iCAAiC,EACvC,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,KAAK,EACV,wBAAwB,EACxB,iBAAiB,EACjB,2BAA2B,EAC3B,mCAAmC,EACnC,kBAAkB,EAClB,0BAA0B,EAC1B,mCAAmC,EACnC,iCAAiC,EACjC,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,+BAA+B,EAC/B,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEvE,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,wCAAU;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,gBAAgB,EAAE,iCAAiC,GAAG,IAAI,CAAQ;IAC5E,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAQ;IACnE,O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ACD,SAAS,EAAE,CAAC,iBAAiB,GAAG,mBAAmB,CAAC,EAAE,CAAC;QACvD,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,+BAA+B,CAAC;IAqBrC,OAAO;CAcf"}
@@ -1,14 +1,15 @@
1
1
  import { type MessageTransportWithDefaultOrigin, type RequestChannel } from '@dynamic-labs/message-transport';
2
- import type { ThresholdSignatureScheme, IframeRequestMessages, WalletOperation, GetWalletResponse, CreateWalletAccountResponse, SignMessageRequest, RequiresPasswordForOperationRequest, SignTransactionRequest, IsPasswordEncryptedRequest, BackupKeySharesToGoogleDriveRequest, RestoreBackupFromGoogleDriveRequest, RefreshWalletAccountSharesRequest, ReshareRequest, ExportPrivateKeyRequest, VerifyPasswordRequest, UpdatePasswordRequest, ImportPrivateKeyRequest, ExportClientKeysharesRequest, OfflineExportPrivateKeyRequest, OfflineExportPrivateKeyResponse, SignRawMessageRequest } from '@dynamic-labs-wallet/core';
2
+ import type { IframeRequestMessages, WalletOperation, GetWalletResponse, CreateWalletAccountResponse, SignMessageRequest, RequiresPasswordForOperationRequest, SignTransactionRequest, IsPasswordEncryptedRequest, BackupKeySharesToGoogleDriveRequest, RestoreBackupFromGoogleDriveRequest, RefreshWalletAccountSharesRequest, ReshareRequest, ExportPrivateKeyRequest, VerifyPasswordRequest, UpdatePasswordRequest, ImportPrivateKeyRequest, ExportClientKeysharesRequest, OfflineExportPrivateKeyRequest, OfflineExportPrivateKeyResponse, SignRawMessageRequest, GetWalletsRequest, CreateWalletAccountRequest } from '@dynamic-labs-wallet/core';
3
3
  export declare class iframeMessageHandler {
4
4
  requestChannel: RequestChannel<IframeRequestMessages>;
5
5
  constructor(messageTransport: MessageTransportWithDefaultOrigin);
6
- getWallets(): Promise<GetWalletResponse[]>;
7
- getWallet({ accountAddress, walletOperation, }: {
6
+ getWallets(request: GetWalletsRequest): Promise<GetWalletResponse[]>;
7
+ getWallet({ chainName, accountAddress, walletOperation, }: {
8
+ chainName: string;
8
9
  accountAddress: string;
9
10
  walletOperation: WalletOperation;
10
11
  }): Promise<GetWalletResponse>;
11
- createWalletAccount(thresholdSignatureScheme: ThresholdSignatureScheme, password?: string): Promise<CreateWalletAccountResponse>;
12
+ createWalletAccount(request: CreateWalletAccountRequest): Promise<CreateWalletAccountResponse>;
12
13
  requiresPasswordForOperation(request: RequiresPasswordForOperationRequest): Promise<boolean>;
13
14
  signMessage(request: SignMessageRequest): Promise<string>;
14
15
  signRawMessage(request: SignRawMessageRequest): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"iframeMessageHandler.d.ts","sourceRoot":"","sources":["../../src/services/iframeMessageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,mCAAmC,EACnC,sBAAsB,EACtB,0BAA0B,EAC1B,mCAAmC,EACnC,mCAAmC,EACnC,iCAAiC,EACjC,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,oBAAoB;IAC/B,cAAc,EAAE,cAAc,CAAC,qBAAqB,CAAC,CAAC;gBAE1C,gBAAgB,EAAE,iCAAiC;IAKzD,UAAU,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAI1C,SAAS,CAAC,EACd,cAAc,EACd,eAAe,GAChB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,eAAe,CAAC;KAClC;IAOK,mBAAmB,CACvB,wBAAwB,EAAE,wBAAwB,EAClD,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,2BAA2B,CAAC;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