-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: explicit links for external services (zyfi, zap, enso) * add: supply modal success & warning
- Loading branch information
Showing
6 changed files
with
189 additions
and
54 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
78 changes: 78 additions & 0 deletions
78
src/components/element/transaction/TransactionOverview.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,78 @@ | ||
import { | ||
Box, | ||
Button, | ||
Checkbox, | ||
Collapsible, | ||
Divider, | ||
Dropdown, | ||
Group, | ||
Icon, | ||
PrimitiveTag, | ||
Space, | ||
Text, | ||
useWalletContext, | ||
} from "dappkit"; | ||
import { type ReactNode, useState } from "react"; | ||
|
||
export interface TransactionOverviewProps { | ||
gas?: number; | ||
allowTxSponsoring?: boolean; | ||
settings?: ReactNode; | ||
children?: ReactNode; | ||
} | ||
|
||
export default function TransactionOverview({ allowTxSponsoring, settings, children }: TransactionOverviewProps) { | ||
const { sponsorTransactions, setSponsorTransactions } = useWalletContext(); | ||
const [settingsCollapsed, setSettingsCollapsed] = useState<boolean>(false); | ||
|
||
return ( | ||
<Box content="sm" className="w-full !gap-0 !bg-main-2" look="base"> | ||
<Group className="w-full flex-nowrap"> | ||
<Group className="grow items-center">{children}</Group> | ||
<PrimitiveTag | ||
onClick={() => setSettingsCollapsed(o => !o)} | ||
size="sm" | ||
look="base" | ||
className="flex flex-nowrap gap-md"> | ||
<Icon remix="RiSettings3Line" /> | ||
<Icon | ||
data-state={!settingsCollapsed ? "closed" : "opened"} | ||
className={"transition duration-150 ease-out data-[state=opened]:rotate-180"} | ||
remix="RiArrowDownSLine" | ||
/> | ||
</PrimitiveTag> | ||
</Group> | ||
<Collapsible state={[settingsCollapsed, setSettingsCollapsed]}> | ||
<Space size="md" /> | ||
{allowTxSponsoring && ( | ||
<Group className="justify-between w-full items-center"> | ||
<Text className="flex flex-nowrap gap-md items-center"> | ||
Sponsor with{" "} | ||
<Dropdown | ||
content={ | ||
<Group className="flex-col max-w-[42ch]"> | ||
<Text size="sm"> | ||
Zyfi leverages ZKSync's native account abstraction to allow dApps simplify gas management for | ||
dApps users. | ||
</Text> | ||
<Divider look="soft" horizontal /> | ||
<Group className="flex-col"> | ||
<Button to={"https://www.zyfi.org/"} size="xs" look="soft"> | ||
<Icon remix="RiArrowRightLine" /> Visit Zyfi | ||
</Button> | ||
</Group> | ||
</Group> | ||
}> | ||
<PrimitiveTag size="sm"> | ||
<Icon src="https://www.zyfi.org/favicon.ico" /> Zyfi | ||
</PrimitiveTag> | ||
</Dropdown> | ||
</Text> | ||
<Checkbox size="sm" state={[sponsorTransactions, setSponsorTransactions]} /> | ||
</Group> | ||
)} | ||
{settings} | ||
</Collapsible> | ||
</Box> | ||
); | ||
} |
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,14 @@ | ||
import { isAddressEqual } from "viem"; | ||
|
||
export abstract class UserService { | ||
/** | ||
* Compares addresses to check if they are equal | ||
* @notice needed because addresse can be checksum or not | ||
* @param a address | ||
* @param b address | ||
*/ | ||
static isSame(a?: string, b?: string): boolean { | ||
if (a?.startsWith("0x") && b.startsWith("0x")) return isAddressEqual(a as `0x${string}`, b as `0x${string}`); | ||
return false; | ||
} | ||
} |