-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrender.tsx
More file actions
61 lines (53 loc) · 1.67 KB
/
Copy pathrender.tsx
File metadata and controls
61 lines (53 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { assert } from '@metamask/superstruct';
import { getBase64Codec, getUtf8Codec } from '@solana/kit';
import type { SolanaKeyringRequest } from '../../../../core/handlers/onKeyringRequest/structs';
import { SolanaSignMessageRequestStruct } from '../../../../core/services/wallet/structs';
import { SOL_IMAGE_SVG } from '../../../../core/test/mocks/solana-image-svg';
import { FALLBACK_LANGUAGE } from '../../../../core/utils/i18n';
import {
createInterface,
getPreferences,
showDialog,
} from '../../../../core/utils/interface';
import type { SolanaKeyringAccount } from '../../../../domain';
import { ConfirmSignMessage } from './ConfirmSignMessage';
/**
* Renders the confirmation dialog for a sign message.
*
* @param request - The request to confirm.
* @param account - The account that the request is for.
* @returns The confirmation dialog.
*/
export async function render(
request: SolanaKeyringRequest,
account: SolanaKeyringAccount,
) {
assert(request.request, SolanaSignMessageRequestStruct);
const {
request: {
params: { message: messageBase64 },
},
scope,
origin,
} = request;
const messageBytes = getBase64Codec().encode(messageBase64);
const messageUtf8 = getUtf8Codec().decode(messageBytes);
const locale = await getPreferences()
.then((preferences) => {
return preferences.locale;
})
.catch(() => FALLBACK_LANGUAGE);
const id = await createInterface(
<ConfirmSignMessage
message={messageUtf8}
account={account}
scope={scope}
locale={locale}
networkImage={SOL_IMAGE_SVG}
origin={origin}
/>,
{},
);
const dialogPromise = showDialog(id);
return dialogPromise;
}