-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #772 from vultisig/feat/custom-msg
Start custom message keysign
- Loading branch information
Showing
33 changed files
with
351 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const SignatureIcon = () => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="1em" | ||
height="1em" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
className="lucide lucide-signature" | ||
> | ||
<path d="m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284" /> | ||
<path d="M3 21h18" /> | ||
</svg> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { getRecordKeys } from './record/getRecordKeys'; | ||
|
||
export function getRecordUnionValue<U, K extends string>( | ||
value: U, | ||
key: K | ||
): Extract<U, Record<K, unknown>>[K] { | ||
const keys = getRecordKeys(value as Record<string, unknown>); | ||
|
||
if (!keys.includes(key)) { | ||
throw new Error(`Key "${key}" not found in record union`); | ||
} | ||
|
||
return (value as Extract<U, Record<K, unknown>>)[key]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
frontend/src/vault/keysign/customMessage/SignCustomMessagePage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { useMemo, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { CustomMessagePayload } from '../../../gen/vultisig/keysign/v1/custom_message_payload_pb'; | ||
import { Button } from '../../../lib/ui/buttons/Button'; | ||
import { getFormProps } from '../../../lib/ui/form/utils/getFormProps'; | ||
import { TextInput } from '../../../lib/ui/inputs/TextInput'; | ||
import { VStack } from '../../../lib/ui/layout/Stack'; | ||
import { useAppNavigate } from '../../../navigation/hooks/useAppNavigate'; | ||
import { FlowPageHeader } from '../../../ui/flow/FlowPageHeader'; | ||
import { PageContent } from '../../../ui/page/PageContent'; | ||
import { WithProgressIndicator } from '../shared/WithProgressIndicator'; | ||
|
||
export const SignCustomMessagePage = () => { | ||
const { t } = useTranslation(); | ||
|
||
const navigate = useAppNavigate(); | ||
|
||
const [method, setMethod] = useState(''); | ||
const [message, setMessage] = useState(''); | ||
|
||
const isDisabled = useMemo(() => { | ||
if (!method) return t('method_required'); | ||
if (!message) return t('message_required'); | ||
}, [method, message, t]); | ||
|
||
return ( | ||
<> | ||
<FlowPageHeader title={t('sign_message')} /> | ||
<PageContent | ||
as="form" | ||
{...getFormProps({ | ||
onSubmit: () => { | ||
navigate('keysign', { | ||
state: { | ||
keysignPayload: { | ||
custom: new CustomMessagePayload({ | ||
method, | ||
message, | ||
}), | ||
}, | ||
}, | ||
}); | ||
}, | ||
isDisabled, | ||
})} | ||
> | ||
<WithProgressIndicator value={0.2}> | ||
<VStack gap={20}> | ||
<TextInput | ||
label={t('method')} | ||
value={method} | ||
onValueChange={setMethod} | ||
placeholder={t('signing_method')} | ||
/> | ||
<TextInput | ||
label={t('message')} | ||
value={message} | ||
onValueChange={setMessage} | ||
placeholder={t('message_to_sign')} | ||
/> | ||
</VStack> | ||
</WithProgressIndicator> | ||
<Button isDisabled={isDisabled} type="submit"> | ||
{t('sign')} | ||
</Button> | ||
</PageContent> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { TssKeysignType } from '../../../chain/keysign/TssKeysignType'; | ||
import { Chain } from '../../../model/chain'; | ||
|
||
const tssType: TssKeysignType = 'ecdsa'; | ||
|
||
export const customMessageConfig = { | ||
chain: Chain.Ethereum, | ||
tssType, | ||
}; |
Oops, something went wrong.