• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-core-sdk / 10524884658

23 Aug 2024 11:24AM UTC coverage: 77.534% (+0.3%) from 77.282%
10524884658

push

github

web-flow
Passkey support (#808)

* Add passkey support

* Add support for passkeys to 4337

* verificationGasLimit adjustment

* feat(relay-kit): add dummy signature as a passkey signature (#857)

* feat(relay-kit): Tests for using passkey with 4337 (#846)

261 of 410 branches covered (63.66%)

Branch coverage included in aggregate %.

55 of 59 new or added lines in 3 files covered. (93.22%)

5 existing lines in 1 file now uncovered.

978 of 1188 relevant lines covered (82.32%)

3.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.82
/packages/onramp-kit/src/lib/errors.ts
1
type ErrorWithMessage = {
2
  message: string
3
}
4

5
function isErrorWithMessage(error: unknown): error is ErrorWithMessage {
6
  return (
8✔
7
    typeof error === 'object' &&
28✔
8
    error !== null &&
9
    'message' in error &&
10
    typeof (error as Record<string, unknown>).message === 'string'
11
  )
12
}
13

14
function toErrorWithMessage(maybeError: unknown): ErrorWithMessage {
15
  if (isErrorWithMessage(maybeError)) return maybeError
8✔
16

17
  try {
2✔
18
    return new Error(JSON.stringify(maybeError))
2✔
19
  } catch {
20
    // fallback in case there's an error stringifying the maybeError
21
    // like with circular references for example.
22
    return new Error(String(maybeError))
×
23
  }
24
}
25

26
export function getErrorMessage(error: unknown) {
6✔
27
  return toErrorWithMessage(error).message
8✔
28
}
29
type GnosisChainSignatureError = { info: { error: { data: string | { data: string } } } }
30
type EthersSignatureError = { data: string }
31
type SignatureError = Error & EthersSignatureError & GnosisChainSignatureError
32

33
/**
34
 * Parses the isValidSignature call response from different providers.
35
 * It extracts and decodes the signature value from the Error object.
36
 *
37
 * @param {ProviderSignatureError} error - The error object with the signature data.
38
 * @returns {string} The signature value.
39
 * @throws It Will throw an error if the signature cannot be parsed.
40
 */
41
export function parseIsValidSignatureErrorResponse(error: SignatureError): string {
6✔
42
  // Ethers v6
43
  const ethersData = error?.data
5✔
44
  if (ethersData) {
5✔
45
    return decodeSignatureData(ethersData)
5✔
46
  }
47

48
  // gnosis-chain
49
  const gnosisChainProviderData = error?.info?.error?.data
×
50

51
  if (gnosisChainProviderData) {
×
52
    const isString = typeof gnosisChainProviderData === 'string'
×
53

54
    const encodedDataResponse = isString ? gnosisChainProviderData : gnosisChainProviderData.data
×
55
    return decodeSignatureData(encodedDataResponse)
×
56
  }
57

58
  // Error message
59
  const isEncodedDataPresent = error?.message?.includes('0x')
×
60

61
  if (isEncodedDataPresent) {
×
62
    return decodeSignatureData(error?.message)
×
63
  }
64

65
  throw new Error('Could not parse Signature from Error response, Details: ' + error?.message)
×
66
}
67

68
export function decodeSignatureData(encodedSignatureData: string): string {
6✔
69
  const [, encodedSignature] = encodedSignatureData.split('0x')
10✔
70
  const data = '0x' + encodedSignature
10✔
71

72
  return data.slice(0, 10).toLowerCase()
10✔
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc