@portal-hq/utils 3.0.4 → 3.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portal-hq/utils",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "main": "lib/commonjs/index",
5
5
  "module": "lib/esm/index",
6
6
  "source": "src/index",
@@ -26,5 +26,5 @@
26
26
  "ts-jest": "^29.0.3",
27
27
  "typescript": "^4.8.4"
28
28
  },
29
- "gitHead": "06ea78f34f46124827901f7a55b9a3dc761a5172"
29
+ "gitHead": "58faddeac81625fcb230357540e7f4663f8c810c"
30
30
  }
@@ -3,12 +3,12 @@ import { countryCodes, currencyCodes } from './countries'
3
3
  export const convert = async (
4
4
  value: number,
5
5
  from = 'ETH',
6
- countryCode?: string
6
+ countryCode?: string,
7
7
  ): Promise<number> => {
8
8
  const country = countryCodes[countryCode || 'US']
9
9
  if (!country) {
10
10
  throw new Error(
11
- `Unable to find country name for country code: ${countryCode}.`
11
+ `Unable to find country name for country code: ${countryCode}.`,
12
12
  )
13
13
  }
14
14
 
@@ -30,12 +30,12 @@ export const convert = async (
30
30
  export const convertCryptoToLocal = async (
31
31
  value: number,
32
32
  from = 'ETH',
33
- countryCode?: string
33
+ countryCode?: string,
34
34
  ): Promise<number> => {
35
35
  const country = countryCodes[countryCode || 'US']
36
36
  if (!country) {
37
37
  throw new Error(
38
- `Unable to find country name for country code: ${countryCode}.`
38
+ `Unable to find country name for country code: ${countryCode}.`,
39
39
  )
40
40
  }
41
41
 
@@ -56,12 +56,12 @@ export const convertCryptoToLocal = async (
56
56
  export const convertLocalToCrypto = async (
57
57
  value: number,
58
58
  to = 'ETH',
59
- countryCode: string
59
+ countryCode: string,
60
60
  ): Promise<number> => {
61
61
  const country = countryCodes[countryCode || 'US']
62
62
  if (!country) {
63
63
  throw new Error(
64
- `Unable to find country name for country code: ${countryCode}.`
64
+ `Unable to find country name for country code: ${countryCode}.`,
65
65
  )
66
66
  }
67
67
 
@@ -1,4 +1,5 @@
1
- import { HttpRequester } from '../requesters'
1
+ import PortalConnect from '@portal-hq/connect'
2
+
2
3
  import type {
3
4
  BackupSharePairMetadata,
4
5
  Balance,
@@ -16,7 +17,7 @@ import type {
16
17
  SimulatedTransaction,
17
18
  Transaction,
18
19
  } from '../../types'
19
- import PortalConnect from '@portal-hq/connect'
20
+ import { HttpRequester } from '../requesters'
20
21
 
21
22
  export type EventHandler = (data: any) => void
22
23
 
@@ -3,7 +3,7 @@ import { type MissingOptionErrorOptions } from '../../types'
3
3
  class MissingOptionError extends Error {
4
4
  constructor({ className, option }: MissingOptionErrorOptions) {
5
5
  super(
6
- `[Portal] Instance option '${option}' is required when instantiating ${className}.`
6
+ `[Portal] Instance option '${option}' is required when instantiating ${className}.`,
7
7
  )
8
8
 
9
9
  // Set the prototype explicitly.
@@ -47,7 +47,7 @@ class ProviderRpcError extends Error {
47
47
 
48
48
  if (!definition) {
49
49
  log.warn(
50
- `[Portal] ProviderRpcError instantiated with unknown error code ${code}. Attempting to continue with limited context.`
50
+ `[Portal] ProviderRpcError instantiated with unknown error code ${code}. Attempting to continue with limited context.`,
51
51
  )
52
52
  }
53
53
 
@@ -1,17 +1,16 @@
1
- import { convert } from '../currency'
2
-
3
1
  import {
4
2
  type MessageData,
5
3
  type OutgoingRequest,
6
4
  type OutgoingRequestData,
7
5
  type SignableTransactionData,
8
6
  } from '../../types'
7
+ import { convert } from '../currency'
9
8
 
10
9
  export const hexStringToByteArray = (hexString: string): Uint8Array => {
11
10
  // Verify the length of the string
12
11
  if (hexString.length % 2 !== 0) {
13
12
  throw Error(
14
- '[Portal] hexStringToByteArray() detected invalid input lenth for hexString.'
13
+ '[Portal] hexStringToByteArray() detected invalid input lenth for hexString.',
15
14
  )
16
15
  }
17
16
 
@@ -55,7 +54,7 @@ export const hexStringToString = (hexInput: string): string => {
55
54
  // Return the accumulator
56
55
  return acc
57
56
  },
58
- [] as string[]
57
+ [] as string[],
59
58
  )
60
59
 
61
60
  // Join the array of characters
@@ -71,7 +70,7 @@ export const numberToHexString = (value: number): string => {
71
70
 
72
71
  export const parseRequest = async (
73
72
  method: string,
74
- params: any
73
+ params: any,
75
74
  ): Promise<OutgoingRequest> => {
76
75
  let requestData: OutgoingRequestData
77
76
 
@@ -45,7 +45,7 @@ class HttpRequest {
45
45
  message: this.request.responseText,
46
46
  status: this.request.status,
47
47
  statusText: this.request.statusText,
48
- })
48
+ }),
49
49
  )
50
50
  } else {
51
51
  // Otherwise, resolve a parsed response object
@@ -1,10 +1,9 @@
1
- import { HttpRequest } from '../index'
2
-
3
1
  import {
4
2
  type HttpOptions,
5
3
  type HttpRequestOptions,
6
4
  type HttpRequesterOptions,
7
5
  } from '../../types'
6
+ import { HttpRequest } from '../index'
8
7
 
9
8
  class HttpRequester {
10
9
  public baseUrl: string
@@ -27,7 +26,7 @@ class HttpRequester {
27
26
  } as HttpRequestOptions
28
27
 
29
28
  requestOptions.headers = this.buildHeaders(
30
- options && options.headers ? options.headers : {}
29
+ options && options.headers ? options.headers : {},
31
30
  )
32
31
 
33
32
  const request = new HttpRequest(requestOptions)
@@ -43,7 +42,7 @@ class HttpRequester {
43
42
  } as HttpRequestOptions
44
43
 
45
44
  requestOptions.headers = this.buildHeaders(
46
- options && options.headers ? options.headers : {}
45
+ options && options.headers ? options.headers : {},
47
46
  )
48
47
 
49
48
  const request = new HttpRequest(requestOptions)
@@ -59,7 +58,7 @@ class HttpRequester {
59
58
  } as HttpRequestOptions
60
59
 
61
60
  requestOptions.headers = this.buildHeaders(
62
- options && options.headers ? options.headers : {}
61
+ options && options.headers ? options.headers : {},
63
62
  )
64
63
 
65
64
  if (options && options.body) {
@@ -79,7 +78,7 @@ class HttpRequester {
79
78
  } as HttpRequestOptions
80
79
 
81
80
  requestOptions.headers = this.buildHeaders(
82
- options && options.headers ? options.headers : {}
81
+ options && options.headers ? options.headers : {},
83
82
  )
84
83
 
85
84
  if (options && options.body) {
package/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BackupMethods } from '@portal-hq/core'
2
+
2
3
  import { MpcStatuses } from './src/definitions'
3
4
 
4
5
  export type MpcMember = 'client' | 'server'