Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add metamask #936

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/UI/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ const Navbar: FunctionComponent = () => {

const connectWallet = async (connector: Connector) => {
try {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
await connectAsync({ connector });
localStorage.setItem("SID-connectedWallet", connector.id);
localStorage.setItem("SID-lastUsedConnector", connector.id);
Expand Down
13 changes: 10 additions & 3 deletions components/UI/walletConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getConnectorName,
sortConnectors,
} from "@/utils/connectorWrapper";
import { isInArgentMobileAppBrowser } from 'starknetkit/argentMobile';
import { isInArgentMobileAppBrowser } from "starknetkit/argentMobile";

type WalletConnectProps = {
closeModal: () => void;
Expand All @@ -36,7 +36,10 @@ const WalletConnect: FunctionComponent<WalletConnectProps> = ({
if (isInArgentMobileAppBrowser()) {
// Filter connectors and remove duplicates
const uniqueConnectors = connectors
.filter((connector) => connector.id === "argentMobile" || connector.id === "argentX")
.filter(
(connector) =>
connector.id === "argentMobile" || connector.id === "argentX"
)
.reduce((map, connector) => map.set(connector.id, connector), new Map())
.values();

Expand Down Expand Up @@ -102,7 +105,11 @@ const WalletConnect: FunctionComponent<WalletConnectProps> = ({
onClick={() => tryConnect(connector, isAvailable)}
>
<img
src={isInArgentMobileAppBrowser() ? getConnectorIcon('argentMobile') : getConnectorIcon(connector.id)}
src={
isInArgentMobileAppBrowser()
? getConnectorIcon("argentMobile")
: getConnectorIcon(connector.id)
}
className={styles.walletIcon}
/>
<div className={styles.walletName}>
Expand Down
2 changes: 1 addition & 1 deletion components/domains/externalDomainActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ExternalDomainActions: FunctionComponent<ExternalDomainActionsProps> = ({

// Add all subdomains to the parameters
const encodedDomains = utils.encodeDomain(domain);
const callDataEncodedDomain: (number | string)[] = [encodedDomains.length];
const callDataEncodedDomain: string[] = [encodedDomains.length.toString()];
encodedDomains.forEach((domain) => {
callDataEncodedDomain.push(domain.toString(10));
});
Expand Down
2 changes: 1 addition & 1 deletion components/identities/actions/changeAddressModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import TransactionModal from "@/components/UI/transactionModal";
type ChangeAddressModalProps = {
handleClose: () => void;
isModalOpen: boolean;
callDataEncodedDomain: (number | string)[];
callDataEncodedDomain: string[];
identity?: Identity;
currentTargetAddress?: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ const ClickablePersonhoodIcon: FunctionComponent<
const hexSessionId = "0x" + (sessionId as string).replace(/-/g, "");
setCallData([
identityChangeCalls.writeVerifierData(
process.env.NEXT_PUBLIC_VERIFIER_POP_CONTRACT as string,
hexToDecimal(
process.env.NEXT_PUBLIC_VERIFIER_POP_CONTRACT as string
),
tokenId,
Math.floor(Date.now() / 1000 + 15 * 60),
"proof_of_personhood",
Expand Down
10 changes: 5 additions & 5 deletions components/identities/actions/identityActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const IdentityActions: FunctionComponent<IdentityActionsProps> = ({
const encodedDomains = utils.encodeDomain(identity?.domain);
const { addTransaction } = useNotificationManager();
const [isTxModalOpen, setIsTxModalOpen] = useState(false);
const [txHash, setTxHash] = useState<string>('');
const [txHash, setTxHash] = useState<string>("");
const [viewMoreClicked, setViewMoreClicked] = useState<boolean>(false);
const [isMainDomain, setIsMainDomain] = useState<boolean>(
identity ? identity.isMain : false
Expand Down Expand Up @@ -98,7 +98,7 @@ const IdentityActions: FunctionComponent<IdentityActionsProps> = ({
}, [identity]);

// Add all subdomains to the parameters
const callDataEncodedDomain: (number | string)[] = [encodedDomains.length];
const callDataEncodedDomain: string[] = [encodedDomains.length.toString()];
encodedDomains.forEach((domain) => {
callDataEncodedDomain.push(domain.toString(10));
});
Expand Down Expand Up @@ -247,7 +247,7 @@ const IdentityActions: FunctionComponent<IdentityActionsProps> = ({
)}
{identity && isOwner && address && (
<div className={styles.identityActions}>
{callDataEncodedDomain[0] === 1 && !isAutoRenewalEnabled ? (
{callDataEncodedDomain[0] === "1" && !isAutoRenewalEnabled ? (
<ClickableAction
title="ENABLE SUBSCRIPTION"
description={nextAutoRenew}
Expand All @@ -256,7 +256,7 @@ const IdentityActions: FunctionComponent<IdentityActionsProps> = ({
onClick={() => router.push("/subscription")}
/>
) : null}
{callDataEncodedDomain[0] === 1 ? (
{callDataEncodedDomain[0] === "1" ? (
<ClickableAction
title="RENEW YOUR DOMAIN"
style="primary"
Expand Down Expand Up @@ -316,7 +316,7 @@ const IdentityActions: FunctionComponent<IdentityActionsProps> = ({
}
onClick={() => setIsSubdomainFormOpen(true)}
/>
{callDataEncodedDomain[0] === 1 && isAutoRenewalEnabled ? (
{callDataEncodedDomain[0] === "1" && isAutoRenewalEnabled ? (
<ClickableAction
title="DISABLE SUBSCRIPTION"
description={nextAutoRenew}
Expand Down
10 changes: 5 additions & 5 deletions components/identities/actions/subdomainModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import TransactionModal from "@/components/UI/transactionModal";
type SubdomainModalProps = {
handleClose: () => void;
isModalOpen: boolean;
callDataEncodedDomain: (number | string)[];
callDataEncodedDomain: string[];
domain?: string;
};

Expand Down Expand Up @@ -56,10 +56,10 @@ const SubdomainModal: FunctionComponent<SubdomainModalProps> = ({
contractAddress: process.env.NEXT_PUBLIC_NAMING_CONTRACT as string,
entrypoint: "transfer_domain",
calldata: [
Number(callDataEncodedDomain[0]) + 1,
numberToString(Number(callDataEncodedDomain[0]) + 1),
encodedSubdomain,
...callDataEncodedDomain.slice(1),
targetTokenId,
numberToString(targetTokenId),
],
},
]);
Expand All @@ -74,10 +74,10 @@ const SubdomainModal: FunctionComponent<SubdomainModalProps> = ({
contractAddress: process.env.NEXT_PUBLIC_NAMING_CONTRACT as string,
entrypoint: "transfer_domain",
calldata: [
Number(callDataEncodedDomain[0]) + 1,
numberToString(Number(callDataEncodedDomain[0]) + 1),
encodedSubdomain,
...callDataEncodedDomain.slice(1),
newTokenId,
numberToString(newTokenId),
],
},
]);
Expand Down
2 changes: 1 addition & 1 deletion hooks/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import renewal_abi from "../abi/starknet/renewal.sierra.json";
import nft_pp_verifier_abi from "../abi/starknet/nft_pp_verifier_abi.json";
import sol_subdomain_abi from "../abi/starknet/sol_subdomain_abi.json";
import multicall_abi from "../abi/starknet/multicall_abi.json";
import { Abi } from "starknet";
import type { Abi } from "starknet";

export function useStarknetIdContract() {
return useContract({
Expand Down
Loading
Loading