-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* get quote * small refactor * execute * execute, track progress * show explorer links * narrower Progress type * clean up * link
- Loading branch information
1 parent
769f7f7
commit a73f39c
Showing
16 changed files
with
641 additions
and
234 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { LoadingIndicator, Status } from "@/components/LoadingIndicator"; | ||
import { cn } from "@/lib/utils"; | ||
import { ExecutionProgress } from "@across-toolkit/sdk"; | ||
|
||
export type ProgressProps = { | ||
progress: ExecutionProgress; | ||
error?: Error | null; | ||
className?: string; | ||
}; | ||
|
||
// TODO: make more fully featured | ||
export function Progress({ progress, error, className }: ProgressProps) { | ||
if (progress.status === "idle") { | ||
return; | ||
} | ||
|
||
const status = (() => { | ||
if ( | ||
progress.status === "txError" || | ||
progress.status === "simulationError" || | ||
progress.status === "error" | ||
) { | ||
return Status.ERROR; | ||
} | ||
if (progress.status === "txSuccess" && progress.step === "fill") { | ||
return Status.SUCCESS; | ||
} | ||
return Status.PENDING; | ||
})(); | ||
|
||
const label = (() => { | ||
if ( | ||
progress.status === "txError" || | ||
progress.status === "simulationError" || | ||
progress.status === "error" | ||
) { | ||
return progress.error.name; | ||
} | ||
if (progress.step === "approve") { | ||
return "Approving ERC20 spend..."; | ||
} | ||
if (progress.step === "deposit") { | ||
return "Depositing on origin chain..."; | ||
} | ||
if (progress.step === "fill" && progress.status === "txSuccess") { | ||
return "Bridge complete!"; | ||
} | ||
|
||
if (progress.step === "fill" && progress.status === "txPending") { | ||
return "Filling on destination chain..."; | ||
} | ||
})(); | ||
|
||
return ( | ||
<div | ||
className={cn("px-2 w-full flex flex-col items-center gap-2", className)} | ||
> | ||
<p className="text-text/75 text-sm">{label}</p> | ||
<LoadingIndicator status={status} /> | ||
</div> | ||
); | ||
} |
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,39 @@ | ||
import { cn } from "@/lib/utils"; | ||
import { Button, ButtonProps } from "./ui"; | ||
import Link from "next/link"; | ||
import { Icon } from "./Icon"; | ||
|
||
export type ExternalLinkProps = { | ||
href: string; | ||
variant?: ButtonProps["variant"]; | ||
icon?: boolean; | ||
className?: string; | ||
children?: React.ReactNode; | ||
}; | ||
|
||
export function ExternalLink({ | ||
href, | ||
icon = false, | ||
className, | ||
variant, | ||
children, | ||
...props | ||
}: ExternalLinkProps) { | ||
return ( | ||
<Button | ||
variant={variant} | ||
asChild | ||
className={cn( | ||
"text-text/75 hover:text-text hover:border-text border border-border-secondary rounded-md px-3 py-2 flex gap-2 items-center", | ||
className, | ||
)} | ||
> | ||
<Link target="_blank" href={href} {...props}> | ||
{children} | ||
{icon && ( | ||
<Icon className="w-[1em] h-[1em] text-inherit" name="link-external" /> | ||
)} | ||
</Link> | ||
</Button> | ||
); | ||
} |
Oops, something went wrong.