-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d5a662
commit a72756c
Showing
23 changed files
with
1,369 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { useDataPolling } from "@umami/data-polling"; | ||
|
||
import { Home as HomeScreen } from "../../screens/Home"; | ||
|
||
export default function Home() { | ||
useDataPolling(); | ||
|
||
return <HomeScreen />; | ||
} |
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
21 changes: 21 additions & 0 deletions
21
apps/mobile/components/ModalCloseButton/ModalCloseButton.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,21 @@ | ||
import { X } from "@tamagui/lucide-icons"; | ||
import { Button, styled } from "tamagui"; | ||
|
||
import { useModal } from "../../providers/ModalProvider"; | ||
|
||
export const ModalCloseButton = () => { | ||
const { hideModal } = useModal(); | ||
|
||
return <CloseButton icon={<X />} onPress={hideModal} />; | ||
}; | ||
|
||
const CloseButton = styled(Button, { | ||
position: "absolute", | ||
top: 0, | ||
right: 0, | ||
zIndex: 1000, | ||
borderRadius: 100, | ||
width: "auto", | ||
height: "auto", | ||
padding: 10, | ||
}); |
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 @@ | ||
export * from "./ModalCloseButton"; |
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,156 @@ | ||
import { type TezosToolkit } from "@taquito/taquito"; | ||
import type { BatchWalletOperation } from "@taquito/taquito/dist/types/wallet/batch-operation"; | ||
import { | ||
type ImplicitAccount, | ||
type LedgerAccount, | ||
type MnemonicAccount, | ||
type SecretKeyAccount, | ||
type SocialAccount, | ||
} from "@umami/core"; | ||
import { useAsyncActionHandler, useGetSecretKey, useSelectedNetwork } from "@umami/state"; | ||
import { type Network, makeToolkit } from "@umami/tezos"; | ||
import { useCustomToast } from "@umami/utils"; | ||
import { FormProvider, useForm, useFormContext } from "react-hook-form"; | ||
import { Button, Input, Label, Text, View, YStack } from "tamagui"; | ||
|
||
import { forIDP } from "../../services/auth"; | ||
|
||
export const SignButton = ({ | ||
signer, | ||
onSubmit, | ||
isLoading: externalIsLoading, | ||
isDisabled, | ||
text = "Confirm Transaction", | ||
network: preferredNetwork, | ||
}: { | ||
onSubmit: (tezosToolkit: TezosToolkit) => Promise<BatchWalletOperation | void>; | ||
signer: ImplicitAccount; | ||
isLoading?: boolean; | ||
isDisabled?: boolean; | ||
text?: string; // TODO: after FillStep migration change to the header value from SignPage | ||
network?: Network; | ||
}) => { | ||
const form = useForm<{ password: string }>({ mode: "onBlur", defaultValues: { password: "" } }); | ||
const { | ||
handleSubmit, | ||
formState: { errors, isValid: isPasswordValid }, | ||
} = form; | ||
let network = useSelectedNetwork(); | ||
if (preferredNetwork) { | ||
network = preferredNetwork; | ||
} | ||
|
||
const { | ||
formState: { isValid: isOuterFormValid }, | ||
} = useFormContext(); | ||
|
||
const isButtonDisabled = isDisabled || !isPasswordValid || !isOuterFormValid; | ||
|
||
const getSecretKey = useGetSecretKey(); | ||
const toast = useCustomToast(); | ||
const { isLoading: internalIsLoading, handleAsyncAction } = useAsyncActionHandler(); | ||
const isLoading = internalIsLoading || externalIsLoading; | ||
|
||
const onMnemonicSign = async ({ password }: { password: string }) => | ||
handleAsyncAction(async () => { | ||
const secretKey = await getSecretKey(signer as MnemonicAccount, password); | ||
return onSubmit(await makeToolkit({ type: "mnemonic", secretKey, network })); | ||
}); | ||
|
||
const onSecretKeySign = async ({ password }: { password: string }) => | ||
handleAsyncAction(async () => { | ||
const secretKey = await getSecretKey(signer as SecretKeyAccount, password); | ||
return onSubmit(await makeToolkit({ type: "secret_key", secretKey, network })); | ||
}); | ||
|
||
const onSocialSign = async () => | ||
handleAsyncAction(async () => { | ||
const { secretKey } = await forIDP((signer as SocialAccount).idp).getCredentials(); | ||
return onSubmit(await makeToolkit({ type: "social", secretKey, network })); | ||
}); | ||
|
||
const onLedgerSign = async () => | ||
handleAsyncAction( | ||
async () => { | ||
toast({ | ||
id: "ledger-sign-toast", | ||
description: "Please approve the operation on your Ledger", | ||
status: "info", | ||
duration: 60000, | ||
isClosable: true, | ||
}); | ||
return onSubmit( | ||
await makeToolkit({ | ||
type: "ledger", | ||
account: signer as LedgerAccount, | ||
network, | ||
}) | ||
); | ||
}, | ||
(error: any) => ({ | ||
description: `${error.message} Please connect your ledger, open Tezos app and try submitting transaction again`, | ||
status: "error", | ||
}) | ||
).finally(() => toast.close("ledger-sign-toast")); | ||
|
||
switch (signer.type) { | ||
case "secret_key": | ||
case "mnemonic": | ||
return ( | ||
<View width="full"> | ||
<FormProvider {...form}> | ||
<YStack alignItems="start" spacing="30px"> | ||
<YStack isInvalid={!!errors.password}> | ||
<Label>Password</Label> | ||
<Input | ||
data-testid="password" | ||
type="password" | ||
{...form.register("password", { required: "Password is required" })} | ||
/> | ||
{errors.password && <Text>{errors.password.message}</Text>} | ||
</YStack> | ||
<Button | ||
width="full" | ||
isDisabled={isButtonDisabled} | ||
isLoading={isLoading} | ||
onClick={handleSubmit( | ||
signer.type === "mnemonic" ? onMnemonicSign : onSecretKeySign | ||
)} | ||
size="lg" | ||
type="submit" | ||
variant="primary" | ||
> | ||
{text} | ||
</Button> | ||
</YStack> | ||
</FormProvider> | ||
</View> | ||
); | ||
case "social": | ||
return ( | ||
<Button | ||
width="full" | ||
isDisabled={isDisabled} | ||
isLoading={isLoading} | ||
onPress={onSocialSign} | ||
size="lg" | ||
variant="primary" | ||
> | ||
{text} | ||
</Button> | ||
); | ||
case "ledger": | ||
return ( | ||
<Button | ||
width="full" | ||
isDisabled={isDisabled} | ||
isLoading={isLoading} | ||
onClick={onLedgerSign} | ||
size="lg" | ||
variant="primary" | ||
> | ||
{text} | ||
</Button> | ||
); | ||
} | ||
}; |
67 changes: 67 additions & 0 deletions
67
apps/mobile/components/SendFlow/SuccessStep/SuccessStep.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,67 @@ | ||
import { Check, ExternalLink } from "@tamagui/lucide-icons"; | ||
import { useSelectedNetwork } from "@umami/state"; | ||
import * as Linking from "expo-linking"; | ||
import { useRouter } from "expo-router"; | ||
import { Button, Dialog, Text, YStack } from "tamagui"; | ||
|
||
type SuccessStepProps = { | ||
open: boolean; | ||
onOpenChange: (open: boolean) => void; | ||
hash: string; | ||
}; | ||
|
||
export const SuccessStep = ({ open, onOpenChange, hash }: SuccessStepProps) => { | ||
const network = useSelectedNetwork(); | ||
const router = useRouter(); | ||
const tzktUrl = `${network.tzktExplorerUrl}/${hash}`; | ||
|
||
const handleViewOperations = () => { | ||
onOpenChange(false); | ||
router.push("/home"); | ||
}; | ||
|
||
const handleViewInTzkt = async () => { | ||
await Linking.openURL(tzktUrl); | ||
}; | ||
|
||
return ( | ||
<Dialog modal onOpenChange={onOpenChange} open={open}> | ||
<Dialog.Portal> | ||
<Dialog.Overlay key="overlay" /> | ||
|
||
<Dialog.Content | ||
key="content" | ||
padding="$4" | ||
animation="quick" | ||
bordered | ||
elevate | ||
enterStyle={{ opacity: 0, scale: 0.95 }} | ||
exitStyle={{ opacity: 0, scale: 0.95 }} | ||
> | ||
<YStack alignItems="center" space="$4"> | ||
<Check color="$green10" size={24} /> | ||
|
||
<Dialog.Title textAlign="center" size="$8"> | ||
Operation Submitted | ||
</Dialog.Title> | ||
|
||
<Text color="$gray11" textAlign="center" size="$5"> | ||
You can follow this operation's progress in the Operations section.{"\n"} | ||
It may take up to 30 seconds to appear. | ||
</Text> | ||
|
||
<YStack width="100%" space="$3"> | ||
<Button onPress={handleViewOperations} size="$4" theme="active"> | ||
See all Operations | ||
</Button> | ||
|
||
<Button icon={ExternalLink} onPress={handleViewInTzkt} size="$4" variant="outlined"> | ||
View in TzKT | ||
</Button> | ||
</YStack> | ||
</YStack> | ||
</Dialog.Content> | ||
</Dialog.Portal> | ||
</Dialog> | ||
); | ||
}; |
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 @@ | ||
export * from "./SuccessStep"; |
Oops, something went wrong.
a72756c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.