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

input-output-hk / lace / 8322986573

15 Mar 2024 03:15PM UTC coverage: 53.421% (-0.4%) from 53.839%
8322986573

push

github

0d1d68
web-flow
enable multi-wallet/account + fix e2e tests (#959)

* test(extension): run e2e tests for multiwallet

* test(extension): address review comments

2291 of 5273 branches covered (43.45%)

Branch coverage included in aggregate %.

5228 of 8802 relevant lines covered (59.4%)

54.4 hits per line

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

0.0
/apps/browser-extension-wallet/src/lib/scripts/background/api-consumers.ts
1
import {
×
2
  RemoteAuthenticator,
3
  RemoteAuthenticatorMethod,
4
  ApiError,
5
  DataSignError,
6
  PaginateError,
7
  TxSendError,
8
  TxSignError,
9
  WalletApi,
10
  WalletApiMethodNames
11
} from '@cardano-sdk/dapp-connector';
12
import { Shutdown } from '@cardano-sdk/util';
13
import {
×
14
  consumeRemoteApi,
15
  MessengerDependencies,
16
  RemoteApiProperties,
17
  RemoteApiPropertyType
18
} from '@cardano-sdk/web-extension';
19
import fromPairs from 'lodash/fromPairs';
×
20

21
export const RemoteAuthenticatorMethodNames: Array<RemoteAuthenticatorMethod> = [
×
22
  'haveAccess',
23
  'requestAccess',
24
  'revokeAccess'
25
];
26

27
export interface RemoteAuthenticatorApiProps {
28
  walletName: string;
29
}
30

31
export interface ConsumeRemoteWalletApiProps {
32
  walletName: string;
33
}
34

35
const authenticatorChannel = (walletName: string) => `authenticator-${walletName}`;
×
36
const walletApiChannel = (walletName: string) => `wallet-api-${walletName}`;
×
37

38
const cip30errorTypes = [ApiError, DataSignError, PaginateError, TxSendError, TxSignError];
×
39

40
// copied from sdk
41
export const consumeRemoteAuthenticatorApi = (
×
42
  { walletName }: RemoteAuthenticatorApiProps,
43
  dependencies: MessengerDependencies
44
): RemoteAuthenticator & Shutdown =>
45
  consumeRemoteApi<RemoteAuthenticator>(
×
46
    {
47
      baseChannel: authenticatorChannel(walletName),
48
      properties: fromPairs(
49
        RemoteAuthenticatorMethodNames.map((prop) => [prop, RemoteApiPropertyType.MethodReturningPromise])
×
50
      ) as RemoteApiProperties<RemoteAuthenticator>
51
    },
52
    dependencies
53
  );
54

55
// copied from sdk
56
export const consumeRemoteWalletApi = (
×
57
  { walletName }: ConsumeRemoteWalletApiProps,
58
  dependencies: MessengerDependencies
59
): WalletApi =>
60
  consumeRemoteApi(
×
61
    {
62
      baseChannel: walletApiChannel(walletName),
63
      errorTypes: cip30errorTypes,
64
      properties: fromPairs(
65
        WalletApiMethodNames.map((prop) => [prop, RemoteApiPropertyType.MethodReturningPromise])
×
66
      ) as RemoteApiProperties<WalletApi>
67
    },
68
    dependencies
69
  );
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