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

blockcoders / kuma-wallet / ebbd3c69-fda1-4bf1-80ea-77bef87d3d87

pending completion
ebbd3c69-fda1-4bf1-80ea-77bef87d3d87

Pull #8

circleci

Ruben
fix tests
Pull Request #8: Milestone 2

876 of 1103 branches covered (79.42%)

Branch coverage included in aggregate %.

3452 of 3452 new or added lines in 44 files covered. (100.0%)

6647 of 7185 relevant lines covered (92.51%)

6.69 hits per line

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

96.06
/src/pages/signMessage/SignMessage.tsx
1
import { FC } from "react";
2✔
2
import { LoadingButton, PageWrapper } from "@src/components/common";
2✔
3
import { useAccountContext, useNetworkContext } from "@src/providers";
2✔
4
import { useTranslation } from "react-i18next";
2✔
5
import Extension from "@src/Extension";
2✔
6
import { ethers } from "ethers";
2✔
7
import { Keyring } from "@polkadot/keyring";
2✔
8
import { u8aToHex } from "@polkadot/util";
2✔
9
import { getWebAPI } from "@src/utils/env";
2✔
10
import { useToast } from "@src/hooks";
2✔
11

2✔
12
const WebAPI = getWebAPI();
2✔
13

2✔
14
interface SignMessageProps {
2✔
15
  params?: {
2✔
16
    message: string;
2✔
17
  };
2✔
18
  onClose?: () => void;
2✔
19
  metadata?: Record<string, string>;
2✔
20
}
2✔
21

2✔
22
export const SignMessage: FC<SignMessageProps> = ({
2✔
23
  params,
4✔
24
  metadata,
4✔
25
  onClose,
4✔
26
}) => {
4✔
27
  const { message } = params as { message: string };
4✔
28

4✔
29
  const { t } = useTranslation("sign_message");
4✔
30

4✔
31
  const {
4✔
32
    state: { api, type },
4✔
33
  } = useNetworkContext();
4✔
34
  const {
4✔
35
    state: { selectedAccount },
4✔
36
  } = useAccountContext();
4✔
37

4✔
38
  const { showErrorToast } = useToast();
4✔
39

4✔
40
  const sign = async () => {
4✔
41
    try {
4✔
42
      let signedMessage = "";
4✔
43
      if (type.toLowerCase() === "wasm") {
4✔
44
        const mnemonic = await Extension.showSeed();
2✔
45
        const keyring = new Keyring({ type: "sr25519" });
2✔
46

2✔
47
        const signer = keyring.addFromMnemonic(mnemonic as string);
2✔
48
        const _message = await signer.sign(message);
2✔
49
        signedMessage = u8aToHex(_message);
2✔
50
      }
2✔
51

4✔
52
      if (type.toLowerCase() === "evm") {
4✔
53
        const pk = await Extension.showPrivateKey();
2✔
54

2✔
55
        const signer = new ethers.Wallet(
2✔
56
          pk as string,
2✔
57
          api as ethers.providers.JsonRpcProvider
2✔
58
        );
2✔
59

2✔
60
        signedMessage = await signer.signMessage(message);
2✔
61
      }
2✔
62

4✔
63
      const { id } = await WebAPI.windows.getCurrent();
4✔
64

4✔
65
      await WebAPI.runtime.sendMessage({
4✔
66
        from: "popup",
4✔
67
        origin: metadata?.origin,
4✔
68
        method: `${metadata?.method}_response`,
4✔
69
        fromWindowId: id,
4✔
70
        toTabId: metadata?.tabId,
4✔
71
        response: {
4✔
72
          message: signedMessage,
4✔
73
        },
4✔
74
      });
4✔
75
    } catch (error) {
4!
76
      showErrorToast(error);
×
77
    }
×
78
  };
4✔
79

4✔
80
  return (
4✔
81
    <PageWrapper contentClassName="h-full">
4✔
82
      <div className="flex flex-col mx-auto h-full py-3">
4✔
83
        <div className="flex-1">
4✔
84
          <div className="flex gap-3 items-center mb-7">
4✔
85
            <p className="text-xl">{t("title")}</p>
4✔
86
          </div>
4✔
87
          <div className="mb-4">
4✔
88
            <label htmlFor="account" className="block text-sm font-medium mb-1">
4✔
89
              {t("account")}:
4✔
90
            </label>
4✔
91
            <input
4✔
92
              id="account"
4✔
93
              className="border text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 pr-8 bg-gray-700 border-gray-600 placeholder-gray-400 text-white"
4✔
94
              readOnly
4✔
95
              aria-disabled
4✔
96
              value={selectedAccount?.value?.address || ""}
4!
97
            />
4✔
98
          </div>
4✔
99
          <div>
4✔
100
            <label htmlFor="message" className="block text-sm font-medium mb-1">
4✔
101
              {t("message")}:
4✔
102
            </label>
4✔
103
            <textarea
4✔
104
              id="message"
4✔
105
              className="border text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 pr-8 bg-gray-700 border-gray-600 placeholder-gray-400 text-white resize-none"
4✔
106
              readOnly
4✔
107
              aria-disabled
4✔
108
              value={message || ""}
4!
109
            />
4✔
110
          </div>
4✔
111
        </div>
4✔
112
        <div className="flex gap-2 justify-end">
4✔
113
          <LoadingButton onClick={onClose}>{t("cancel")}</LoadingButton>
4✔
114
          <LoadingButton onClick={sign}>{t("sign")}</LoadingButton>
4✔
115
        </div>
4✔
116
      </div>
4✔
117
    </PageWrapper>
4✔
118
  );
4✔
119
};
4✔
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