@portal-hq/connect 4.2.9 → 4.2.12

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.
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ConnectionStates = exports.ConnectError = void 0;
13
13
  const provider_1 = require("@portal-hq/provider");
14
+ const utils_1 = require("@portal-hq/utils");
14
15
  class PortalConnect {
15
16
  get address() {
16
17
  return this.provider.address;
@@ -21,7 +22,7 @@ class PortalConnect {
21
22
  }
22
23
  constructor({ apiKey, keychain, gatewayConfig, chainId,
23
24
  // Optional
24
- isSimulator = false, autoApprove = false, version = 'v6', apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', webSocketServer = 'connect.portalhq.io', }) {
25
+ isSimulator = false, autoApprove = false, version = 'v6', apiHost = utils_1.DEFAULT_HOSTS.API, mpcHost = utils_1.DEFAULT_HOSTS.MPC, webSocketServer = utils_1.DEFAULT_HOSTS.WEBSOCKET, enclaveMPCHost, }) {
25
26
  this.connectionState = ConnectionStates.DISCONNECTED;
26
27
  this.handleSigningRejected = (data) => {
27
28
  var _a;
@@ -49,6 +50,7 @@ class PortalConnect {
49
50
  version,
50
51
  apiHost,
51
52
  mpcHost,
53
+ enclaveMPCHost,
52
54
  });
53
55
  // Inbound from the Provider
54
56
  this.on('portalConnect_signingRequested', (data) => {
@@ -102,7 +104,7 @@ class PortalConnect {
102
104
  */
103
105
  setChainId(chainId) {
104
106
  return __awaiter(this, void 0, void 0, function* () {
105
- yield this.provider.setChainId(`eip155:${chainId}`, this);
107
+ yield this.provider.setChainId(`${utils_1.CHAIN_NAMESPACES.EIP155}:${chainId}`, this);
106
108
  });
107
109
  }
108
110
  /**
@@ -202,13 +204,13 @@ class PortalConnect {
202
204
  // Get chains from gatewayConfig with 'eip155:' prefix, but only if they're not already in the proposal
203
205
  const existingChains = proposal.params.requiredNamespaces.eip155.chains;
204
206
  const newChains = Object.keys(this.gatewayConfig)
205
- .filter((chain) => !chain.includes('solana:')) // Remove chains that include 'solana:'
207
+ .filter((chain) => !chain.includes(`${utils_1.CHAIN_NAMESPACES.SOLANA}:`)) // Remove chains that include 'solana:'
206
208
  .reduce((acc, chain) => {
207
- if (chain.includes('eip155')) {
209
+ if (chain.includes(utils_1.CHAIN_NAMESPACES.EIP155)) {
208
210
  acc.push(chain);
209
211
  }
210
212
  else {
211
- acc.push(`eip155:${chain}`);
213
+ acc.push(`${utils_1.CHAIN_NAMESPACES.EIP155}:${chain}`);
212
214
  }
213
215
  return acc;
214
216
  }, [])
@@ -336,7 +338,7 @@ class PortalConnect {
336
338
  yield this.provider.request({
337
339
  method,
338
340
  params,
339
- chainId: `eip155:${chainId}`,
341
+ chainId: `${utils_1.CHAIN_NAMESPACES.EIP155}:${chainId}`,
340
342
  connect: this,
341
343
  });
342
344
  });
package/lib/esm/index.js CHANGED
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { Provider } from '@portal-hq/provider';
11
+ import { CHAIN_NAMESPACES, DEFAULT_HOSTS, } from '@portal-hq/utils';
11
12
  class PortalConnect {
12
13
  get address() {
13
14
  return this.provider.address;
@@ -18,7 +19,7 @@ class PortalConnect {
18
19
  }
19
20
  constructor({ apiKey, keychain, gatewayConfig, chainId,
20
21
  // Optional
21
- isSimulator = false, autoApprove = false, version = 'v6', apiHost = 'api.portalhq.io', mpcHost = 'mpc.portalhq.io', webSocketServer = 'connect.portalhq.io', }) {
22
+ isSimulator = false, autoApprove = false, version = 'v6', apiHost = DEFAULT_HOSTS.API, mpcHost = DEFAULT_HOSTS.MPC, webSocketServer = DEFAULT_HOSTS.WEBSOCKET, enclaveMPCHost, }) {
22
23
  this.connectionState = ConnectionStates.DISCONNECTED;
23
24
  this.handleSigningRejected = (data) => {
24
25
  var _a;
@@ -46,6 +47,7 @@ class PortalConnect {
46
47
  version,
47
48
  apiHost,
48
49
  mpcHost,
50
+ enclaveMPCHost,
49
51
  });
50
52
  // Inbound from the Provider
51
53
  this.on('portalConnect_signingRequested', (data) => {
@@ -99,7 +101,7 @@ class PortalConnect {
99
101
  */
100
102
  setChainId(chainId) {
101
103
  return __awaiter(this, void 0, void 0, function* () {
102
- yield this.provider.setChainId(`eip155:${chainId}`, this);
104
+ yield this.provider.setChainId(`${CHAIN_NAMESPACES.EIP155}:${chainId}`, this);
103
105
  });
104
106
  }
105
107
  /**
@@ -199,13 +201,13 @@ class PortalConnect {
199
201
  // Get chains from gatewayConfig with 'eip155:' prefix, but only if they're not already in the proposal
200
202
  const existingChains = proposal.params.requiredNamespaces.eip155.chains;
201
203
  const newChains = Object.keys(this.gatewayConfig)
202
- .filter((chain) => !chain.includes('solana:')) // Remove chains that include 'solana:'
204
+ .filter((chain) => !chain.includes(`${CHAIN_NAMESPACES.SOLANA}:`)) // Remove chains that include 'solana:'
203
205
  .reduce((acc, chain) => {
204
- if (chain.includes('eip155')) {
206
+ if (chain.includes(CHAIN_NAMESPACES.EIP155)) {
205
207
  acc.push(chain);
206
208
  }
207
209
  else {
208
- acc.push(`eip155:${chain}`);
210
+ acc.push(`${CHAIN_NAMESPACES.EIP155}:${chain}`);
209
211
  }
210
212
  return acc;
211
213
  }, [])
@@ -333,7 +335,7 @@ class PortalConnect {
333
335
  yield this.provider.request({
334
336
  method,
335
337
  params,
336
- chainId: `eip155:${chainId}`,
338
+ chainId: `${CHAIN_NAMESPACES.EIP155}:${chainId}`,
337
339
  connect: this,
338
340
  });
339
341
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/connect",
3
- "version": "4.2.9",
3
+ "version": "4.2.12",
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": "f661ab7847d1616e9305c5f44cf1b808be47338c"
35
+ "gitHead": "990c67a28fca39b09001ac0a1aae254c6fafed82"
36
36
  }
package/src/index.ts CHANGED
@@ -3,7 +3,11 @@ import {
3
3
  GatewayConfig,
4
4
  SwitchEthereumChainParameter,
5
5
  } from '@portal-hq/provider/types'
6
- import { IPortalProvider } from '@portal-hq/utils'
6
+ import {
7
+ IPortalProvider,
8
+ CHAIN_NAMESPACES,
9
+ DEFAULT_HOSTS,
10
+ } from '@portal-hq/utils'
7
11
 
8
12
  import type {
9
13
  ErrorResult,
@@ -49,9 +53,10 @@ class PortalConnect {
49
53
  isSimulator = false,
50
54
  autoApprove = false,
51
55
  version = 'v6',
52
- apiHost = 'api.portalhq.io',
53
- mpcHost = 'mpc.portalhq.io',
54
- webSocketServer = 'connect.portalhq.io',
56
+ apiHost = DEFAULT_HOSTS.API,
57
+ mpcHost = DEFAULT_HOSTS.MPC,
58
+ webSocketServer = DEFAULT_HOSTS.WEBSOCKET,
59
+ enclaveMPCHost,
55
60
  }: PortalConnectOptions) {
56
61
  this.apiKey = apiKey
57
62
  this.events = {}
@@ -68,6 +73,7 @@ class PortalConnect {
68
73
  version,
69
74
  apiHost,
70
75
  mpcHost,
76
+ enclaveMPCHost,
71
77
  })
72
78
 
73
79
  // Inbound from the Provider
@@ -132,7 +138,10 @@ class PortalConnect {
132
138
  * @param chainId The number of the chainId to switch to
133
139
  */
134
140
  public async setChainId(chainId: number): Promise<void> {
135
- await this.provider.setChainId(`eip155:${chainId}`, this)
141
+ await this.provider.setChainId(
142
+ `${CHAIN_NAMESPACES.EIP155}:${chainId}`,
143
+ this,
144
+ )
136
145
  }
137
146
 
138
147
  /**
@@ -252,12 +261,12 @@ class PortalConnect {
252
261
  // Get chains from gatewayConfig with 'eip155:' prefix, but only if they're not already in the proposal
253
262
  const existingChains = proposal.params.requiredNamespaces.eip155.chains
254
263
  const newChains = Object.keys(this.gatewayConfig)
255
- .filter((chain) => !chain.includes('solana:')) // Remove chains that include 'solana:'
264
+ .filter((chain) => !chain.includes(`${CHAIN_NAMESPACES.SOLANA}:`)) // Remove chains that include 'solana:'
256
265
  .reduce<string[]>((acc, chain) => {
257
- if (chain.includes('eip155')) {
266
+ if (chain.includes(CHAIN_NAMESPACES.EIP155)) {
258
267
  acc.push(chain)
259
268
  } else {
260
- acc.push(`eip155:${chain}`)
269
+ acc.push(`${CHAIN_NAMESPACES.EIP155}:${chain}`)
261
270
  }
262
271
  return acc
263
272
  }, [])
@@ -420,7 +429,7 @@ class PortalConnect {
420
429
  await this.provider.request({
421
430
  method,
422
431
  params,
423
- chainId: `eip155:${chainId}`,
432
+ chainId: `${CHAIN_NAMESPACES.EIP155}:${chainId}`,
424
433
  connect: this,
425
434
  })
426
435
  }
package/types.d.ts CHANGED
@@ -62,6 +62,7 @@ export interface PortalConnectOptions {
62
62
  apiHost?: string
63
63
  mpcHost?: string
64
64
  version?: string
65
+ enclaveMPCHost?: string
65
66
  }
66
67
 
67
68
  export interface ProtocolOptions {