@portal-hq/connect 2.1.2 → 3.0.0

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.
@@ -24,7 +24,7 @@ class PortalConnect {
24
24
  }
25
25
  constructor({ apiKey, chainId, keychain, gatewayConfig,
26
26
  // Optional
27
- isSimulator = false, autoApprove = false, version = 'v5', apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', webSocketServer = 'connect.portalhq.io', }) {
27
+ isSimulator = false, autoApprove = false, version = 'v6', apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', webSocketServer = 'connect.portalhq.io', }) {
28
28
  this.connectionState = ConnectionStates.DISCONNECTED;
29
29
  this.handleSigningRejected = (data) => {
30
30
  var _a;
package/lib/esm/index.js CHANGED
@@ -21,7 +21,7 @@ class PortalConnect {
21
21
  }
22
22
  constructor({ apiKey, chainId, keychain, gatewayConfig,
23
23
  // Optional
24
- isSimulator = false, autoApprove = false, version = 'v5', apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', webSocketServer = 'connect.portalhq.io', }) {
24
+ isSimulator = false, autoApprove = false, version = 'v6', apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', webSocketServer = 'connect.portalhq.io', }) {
25
25
  this.connectionState = ConnectionStates.DISCONNECTED;
26
26
  this.handleSigningRejected = (data) => {
27
27
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/connect",
3
- "version": "2.1.2",
3
+ "version": "3.0.0",
4
4
  "main": "lib/commonjs/index",
5
5
  "module": "lib/esm/index",
6
6
  "source": "src/index",
@@ -32,5 +32,5 @@
32
32
  "react": "*",
33
33
  "react-native": "*"
34
34
  },
35
- "gitHead": "17a0445191c1399577154042e09fa8759edf194f"
35
+ "gitHead": "1f49bc43f0778a40089e1d736fbb63eb952b6001"
36
36
  }
package/src/index.ts CHANGED
@@ -51,7 +51,7 @@ class PortalConnect {
51
51
  // Optional
52
52
  isSimulator = false,
53
53
  autoApprove = false,
54
- version = 'v5',
54
+ version = 'v6',
55
55
  apiHost = 'api.portalhq.io',
56
56
  mpcHost = 'mpc.portalhq.io',
57
57
  webSocketServer = 'connect.portalhq.io',
@@ -114,7 +114,7 @@ class PortalConnect {
114
114
  headers: {
115
115
  Authorization: `Bearer ${this.apiKey}`,
116
116
  },
117
- }
117
+ },
118
118
  )
119
119
  this.uri = uri
120
120
  this.bindToSocketEvents(this.socket, uri)
@@ -210,7 +210,7 @@ class PortalConnect {
210
210
 
211
211
  public removeEventListener(
212
212
  event: string,
213
- listenerToRemove?: EventHandler
213
+ listenerToRemove?: EventHandler,
214
214
  ): void {
215
215
  if (!this.events[event]) {
216
216
  return
@@ -220,7 +220,7 @@ class PortalConnect {
220
220
  this.events[event] = []
221
221
  } else {
222
222
  const filterEventHandlers = (
223
- registeredEventHandler: RegisteredEventHandler
223
+ registeredEventHandler: RegisteredEventHandler,
224
224
  ) => {
225
225
  return registeredEventHandler.handler !== listenerToRemove
226
226
  }
@@ -235,7 +235,7 @@ class PortalConnect {
235
235
  * @returns session proposal with chains from gateway config added
236
236
  */
237
237
  public addChainsToProposal(
238
- proposal: SessionProposalOrMetadata
238
+ proposal: SessionProposalOrMetadata,
239
239
  ): SessionProposalOrMetadata {
240
240
  if (!('params' in proposal) || !('requiredNamespaces' in proposal.params)) {
241
241
  throw new Error('Invalid proposal structure.')
@@ -292,7 +292,7 @@ class PortalConnect {
292
292
  chainId,
293
293
  uri,
294
294
  },
295
- })
295
+ }),
296
296
  )
297
297
  }
298
298
 
@@ -306,7 +306,7 @@ class PortalConnect {
306
306
  uri: this.uri,
307
307
  chainId: (data as SwitchEthereumChainParameter).chainId,
308
308
  },
309
- })
309
+ }),
310
310
  )
311
311
  })
312
312
 
@@ -334,7 +334,7 @@ class PortalConnect {
334
334
  */
335
335
  socket.onmessage = async (messageEvent: WebSocketMessageEvent) => {
336
336
  const message = JSON.parse(
337
- messageEvent.data as string
337
+ messageEvent.data as string,
338
338
  ) as WebsocketMessage
339
339
 
340
340
  switch (message.event) {
@@ -361,7 +361,7 @@ class PortalConnect {
361
361
  params.request.method,
362
362
  params.request.params,
363
363
  params.chainId,
364
- request
364
+ request,
365
365
  )
366
366
  break
367
367
  }
@@ -374,7 +374,7 @@ class PortalConnect {
374
374
  break
375
375
  default:
376
376
  console.log(
377
- `Received unsupported event "${message.event}". Ignoring.`
377
+ `Received unsupported event "${message.event}". Ignoring.`,
378
378
  )
379
379
  break
380
380
  }
@@ -393,7 +393,7 @@ class PortalConnect {
393
393
  method: string,
394
394
  params: any,
395
395
  chainId: string,
396
- request: SessionRequest
396
+ request: SessionRequest,
397
397
  ): Promise<void> {
398
398
  // Bind to potential signing rejection events
399
399
  this.provider.on('portal_signingRejected', this.handleSigningRejected)
@@ -408,7 +408,7 @@ class PortalConnect {
408
408
  ) {
409
409
  this.handleSignatureReceived(request, signature)
410
410
  }
411
- }
411
+ },
412
412
  )
413
413
 
414
414
  // Pass the request along to the provider
@@ -417,7 +417,7 @@ class PortalConnect {
417
417
 
418
418
  private async handleSessionApproved(
419
419
  data: SessionProposalOrMetadata,
420
- request: SessionRequest
420
+ request: SessionRequest,
421
421
  ): Promise<void> {
422
422
  const address = await this.address
423
423
 
@@ -432,13 +432,13 @@ class PortalConnect {
432
432
  id: request.id,
433
433
  params: data,
434
434
  },
435
- } as WebsocketMessage)
435
+ } as WebsocketMessage),
436
436
  )
437
437
  }
438
438
 
439
439
  private async handleSessionRejected(
440
440
  data: SessionProposalOrMetadata,
441
- request: SessionRequest
441
+ request: SessionRequest,
442
442
  ): Promise<void> {
443
443
  const address = await this.address
444
444
 
@@ -453,7 +453,7 @@ class PortalConnect {
453
453
  id: request.id,
454
454
  params: data,
455
455
  },
456
- } as WebsocketMessage)
456
+ } as WebsocketMessage),
457
457
  )
458
458
  }
459
459
 
@@ -461,16 +461,16 @@ class PortalConnect {
461
461
  const request = message.data as SessionRequest
462
462
  // Bind to potential session approval/rejection events
463
463
  this.on('portal_dappSessionApproved', (data) =>
464
- this.handleSessionApproved(data as SessionProposalOrMetadata, request)
464
+ this.handleSessionApproved(data as SessionProposalOrMetadata, request),
465
465
  )
466
466
  this.on('portal_dappSessionRejected', (data) =>
467
- this.handleSessionRejected(data as SessionProposalOrMetadata, request)
467
+ this.handleSessionRejected(data as SessionProposalOrMetadata, request),
468
468
  )
469
469
 
470
470
  // Emit the session request event
471
471
  this.emit(
472
472
  'portal_dappSessionRequested',
473
- request.params as SessionProposalOrMetadata
473
+ request.params as SessionProposalOrMetadata,
474
474
  )
475
475
  }
476
476
 
@@ -486,7 +486,7 @@ class PortalConnect {
486
486
  transactionHash: txHash,
487
487
  transactionId: id,
488
488
  },
489
- })
489
+ }),
490
490
  )
491
491
 
492
492
  // Let the SDK consumer know the transaction hash
@@ -503,7 +503,7 @@ class PortalConnect {
503
503
  transactionHash: '',
504
504
  transactionId: data.id,
505
505
  },
506
- } as WebsocketMessage)
506
+ } as WebsocketMessage),
507
507
  )
508
508
  }
509
509
 
@@ -517,7 +517,7 @@ class PortalConnect {
517
517
  id: '',
518
518
  topic: this.topic,
519
519
  },
520
- } as WebsocketMessage)
520
+ } as WebsocketMessage),
521
521
  )
522
522
 
523
523
  this.topic = undefined