-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Centrifuge App: Operational Security for Pools (#1313)
- Loading branch information
1 parent
c7dbac4
commit 0a7ce8f
Showing
97 changed files
with
3,408 additions
and
1,434 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
66 changes: 66 additions & 0 deletions
66
centrifuge-app/src/components/Dialogs/ShareMultisigDialog.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,66 @@ | ||
import { Multisig } from '@centrifuge/centrifuge-js' | ||
import { Button, Dialog, IconCopy, IconSend, Shelf, Stack, Text, TextInput } from '@centrifuge/fabric' | ||
import { copyToClipboard } from '../../utils/copyToClipboard' | ||
import { ButtonGroup } from '../ButtonGroup' | ||
|
||
export type ShareMultisigDialogProps = { | ||
multisig: Multisig | ||
hash: string | ||
callData?: string | ||
open: boolean | ||
onClose: () => void | ||
} | ||
|
||
export function ShareMultisigDialog({ multisig, hash, callData, open, onClose }: ShareMultisigDialogProps) { | ||
const shareUrl = getMultisigShareUrl({ multisig, hash, callData }) | ||
|
||
const shareData: ShareData = { | ||
title: 'Approve Transaction', | ||
text: 'Approve a multisig transaction on the Centrifuge App', | ||
url: shareUrl, | ||
} | ||
|
||
return ( | ||
<Dialog isOpen={open} onClose={onClose} title="Share link with other multisig signers"> | ||
<Stack gap={2}> | ||
<Text variant="body2">Share the link below with the other multisig signers to finalize the transaction</Text> | ||
<Shelf gap={1}> | ||
<TextInput | ||
style={{ | ||
cursor: 'copy', | ||
}} | ||
onClick={(e: any) => { | ||
copyToClipboard(shareUrl) | ||
e.target.select() | ||
}} | ||
value={shareUrl} | ||
readOnly | ||
/> | ||
<ButtonGroup> | ||
<Button variant="tertiary" icon={IconCopy} onClick={() => copyToClipboard(shareUrl)} /> | ||
{navigator.share && ( | ||
<Button variant="tertiary" icon={IconSend} onClick={() => navigator.share(shareData)} /> | ||
)} | ||
</ButtonGroup> | ||
</Shelf> | ||
</Stack> | ||
</Dialog> | ||
) | ||
} | ||
|
||
export function getMultisigShareUrl({ | ||
multisig, | ||
hash, | ||
callData, | ||
}: Pick<ShareMultisigDialogProps, 'multisig' | 'hash' | 'callData'>) { | ||
const params = new URLSearchParams({ | ||
hash, | ||
signers: multisig.signers.join(','), | ||
threshold: multisig.threshold.toString(), | ||
data: callData || '', | ||
}) | ||
const url = new URL(`/multisig-approval`, window.location.origin) | ||
url.search = params as any | ||
const shareUrl = url.toString() | ||
return shareUrl | ||
} |
Oops, something went wrong.