-
Notifications
You must be signed in to change notification settings - Fork 27
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
Showing
7 changed files
with
197 additions
and
4 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,15 @@ | ||
import { useQuery } from "react-query"; | ||
|
||
export const STARKNET_ID_API_URL = "https://api.starknet.id/domain_to_addr"; | ||
|
||
export const useStarkAddress = ({ name }: { name: string }) => { | ||
const { data, isFetching } = useQuery({ | ||
enabled: !!name && name.includes(".stark"), | ||
staleTime: 5 * 60 * 1000, // 5 minutes | ||
queryKey: ["starknetid", name], | ||
queryFn: () => | ||
fetch(`${STARKNET_ID_API_URL}?domain=${name}`).then((res) => res.json()), | ||
}); | ||
|
||
return { address: data?.addr ?? "", isFetching }; | ||
}; |
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 { useQuery } from "react-query"; | ||
import { useConnection } from "./context"; | ||
import { useMemo } from "react"; | ||
|
||
const ARGENT_CLASS_HASH = BigInt( | ||
"0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f", | ||
); | ||
const BRAAVOS_BASE_ACCOUNT_CLASS_HASH: BigInt = BigInt( | ||
"0x013bfe114fb1cf405bfc3a7f8dbe2d91db146c17521d40dcf57e16d6b59fa8e6", | ||
); | ||
const BRAAVOS_ACCOUNT_CLASS_HASH: BigInt = BigInt( | ||
"0x00816dd0297efc55dc1e7559020a3a825e81ef734b558f03c83325d4da7e6253", | ||
); | ||
const OZ_ACCOUNT_CLASS_HASH: BigInt = BigInt( | ||
"0x04a444ef8caf8fa0db05da60bf0ad9bae264c73fa7e32c61d245406f5523174b", | ||
); | ||
const CONTROLLER_CLASS_HASH: BigInt = BigInt( | ||
"0x511dd75da368f5311134dee2356356ac4da1538d2ad18aa66d57c47e3757d59", | ||
); | ||
|
||
export type Wallet = "Controller" | "ArgentX" | "Braavos" | "OpenZeppelin"; | ||
|
||
export function useWallet({ address }: { address: string }) { | ||
const { provider } = useConnection(); | ||
|
||
const { data, isFetching } = useQuery({ | ||
enabled: !!address && address.startsWith("0x"), | ||
staleTime: 5 * 60 * 1000, // 5 minutes | ||
queryKey: ["classhash", address], | ||
queryFn: async () => { | ||
try { | ||
return await provider.getClassHashAt(BigInt(address)); | ||
} catch (error) { | ||
return null; | ||
} | ||
}, | ||
}); | ||
|
||
const wallet: Wallet | null = useMemo(() => { | ||
console.log("data", data); | ||
if (!data) return null; | ||
const classHash = BigInt(data); | ||
if (classHash === ARGENT_CLASS_HASH) { | ||
return "ArgentX"; | ||
} | ||
if ( | ||
classHash === BRAAVOS_BASE_ACCOUNT_CLASS_HASH || | ||
classHash === BRAAVOS_ACCOUNT_CLASS_HASH | ||
) { | ||
return "Braavos"; | ||
} | ||
if (classHash === OZ_ACCOUNT_CLASS_HASH) { | ||
return "OpenZeppelin"; | ||
} | ||
if (classHash === CONTROLLER_CLASS_HASH) { | ||
return "Controller"; | ||
} | ||
return null; | ||
}, [data]); | ||
|
||
return { wallet, isFetching }; | ||
} |
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
26 changes: 26 additions & 0 deletions
26
packages/ui-next/src/components/icons/brand/open-zeppelin.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,26 @@ | ||
import { forwardRef, memo } from "react"; | ||
import { iconVariants } from "../utils"; | ||
import { IconProps } from "../types"; | ||
|
||
export const OpenZeppelinIcon = memo( | ||
forwardRef<SVGSVGElement, IconProps>( | ||
({ className, size, ...props }, forwardedRef) => ( | ||
<svg | ||
viewBox="0 0 24 24" | ||
className={iconVariants({ size, className })} | ||
ref={forwardedRef} | ||
{...props} | ||
> | ||
<path d="M4.9735 4H19.0474L16.6426 8.06041H4.9735V4Z" fill="currentColor"/> | ||
<path d="M4.95129 19.9997C5.41539 19.2221 5.86184 18.479 6.30195 17.7464C7.60132 15.5835 8.84544 13.5126 10.3253 10.9176C11.025 9.74535 12.2342 9.01693 13.7269 9.01693H16.0724L9.52236 19.9997H4.95129Z" fill="currentColor"/> | ||
<path d="M14.5933 16.0019C13.4017 16.0019 12.551 16.5648 12.0218 17.4709C11.5804 18.2264 11.1743 18.9005 10.7277 19.6416C10.6569 19.7592 10.585 19.8784 10.5119 20H19.0487V15.9901L14.5933 16.0019Z" fill="currentColor"/> | ||
|
||
|
||
</svg> | ||
), | ||
), | ||
); | ||
|
||
OpenZeppelinIcon.displayName = "OpenZeppelinIcon"; | ||
|
||
|