Skip to content

Commit

Permalink
feat: upgrade to latest version of starknet-react & starknetkit
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Sep 13, 2024
1 parent 3cf64b3 commit ecabbbd
Show file tree
Hide file tree
Showing 31 changed files with 262 additions and 130 deletions.
4 changes: 2 additions & 2 deletions components/UI/modalProfilePic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ClickableAction from "./iconsComponents/clickableAction";
import theme from "../../styles/theme";
import DoneFilledIcon from "./iconsComponents/icons/doneFilledIcon";
import ArrowLeftIcon from "./iconsComponents/icons/arrowLeftIcon";
import { useContractWrite } from "@starknet-react/core";
import { useSendTransaction } from "@starknet-react/core";
import { Call } from "starknet";
import identityChangeCalls from "../../utils/callData/identityChangeCalls";
import { hexToDecimal, toUint256 } from "../../utils/feltService";
Expand All @@ -32,7 +32,7 @@ const ModalProfilePic: FunctionComponent<ModalProfilePicProps> = ({
}) => {
const [callData, setCallData] = useState<Call[]>([]);
const { addTransaction } = useNotificationManager();
const { writeAsync: execute, data: updateData } = useContractWrite({
const { sendAsync: execute, data: updateData } = useSendTransaction({
calls: callData,
});

Expand Down
4 changes: 2 additions & 2 deletions components/discount/freeRenewalCheckout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { FunctionComponent, useEffect, useState } from "react";
import Button from "../UI/button";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import {
formatHexString,
isValidEmail,
Expand Down Expand Up @@ -83,7 +83,7 @@ const FreeRenewalCheckout: FunctionComponent<FreeRenewalCheckoutProps> = ({
const [selectedDomains, setSelectedDomains] =
useState<Record<string, boolean>>();
const { address } = useAccount();
const { writeAsync: execute, data: renewData } = useContractWrite({
const { sendAsync: execute, data: renewData } = useSendTransaction({
calls: callData,
});
const [domainsMinting, setDomainsMinting] =
Expand Down
4 changes: 2 additions & 2 deletions components/discount/registerDiscount.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { FunctionComponent, useEffect, useState } from "react";
import Button from "../UI/button";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import { utils } from "starknetid.js";
import {
formatHexString,
Expand Down Expand Up @@ -86,7 +86,7 @@ const RegisterDiscount: FunctionComponent<RegisterDiscountProps> = ({
const [renewalBox, setRenewalBox] = useState<boolean>(false);
const [metadataHash, setMetadataHash] = useState<string | undefined>();
const { account, address } = useAccount();
const { writeAsync: execute, data: registerData } = useContractWrite({
const { sendAsync: execute, data: registerData } = useSendTransaction({
calls: callData,
});
const hasMainDomain = !useDisplayName(address ?? "", false).startsWith("0x");
Expand Down
4 changes: 2 additions & 2 deletions components/domains/autorenewal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { FunctionComponent, useEffect, useState } from "react";
import Button from "../UI/button";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import {
formatHexString,
isValidEmail,
Expand Down Expand Up @@ -74,7 +74,7 @@ const Subscription: FunctionComponent<SubscriptionProps> = ({ groups }) => {
const [selectedDomains, setSelectedDomains] =
useState<Record<string, boolean>>();
const { address } = useAccount();
const { writeAsync: execute, data: autorenewData } = useContractWrite({
const { sendAsync: execute, data: autorenewData } = useSendTransaction({
calls: callData,
});
const [domainsMinting, setDomainsMinting] =
Expand Down
4 changes: 2 additions & 2 deletions components/domains/externalDomainActions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { FunctionComponent, useEffect, useState } from "react";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import styles from "../../styles/components/identityMenu.module.css";
import { utils } from "starknetid.js";
import ClickableAction from "../UI/iconsComponents/clickableAction";
Expand Down Expand Up @@ -42,7 +42,7 @@ const ExternalDomainActions: FunctionComponent<ExternalDomainActionsProps> = ({
});

//Set as main domain execute
const { writeAsync: set_address_to_domain } = useContractWrite({
const { sendAsync: set_address_to_domain } = useSendTransaction({
calls: [resolverCalls.setAddresstoDomain(callDataEncodedDomain)],
});

Expand Down
4 changes: 2 additions & 2 deletions components/domains/externalDomainTransferModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useContext,
} from "react";
import { TextField, InputAdornment } from "@mui/material";
import { useContractWrite } from "@starknet-react/core";
import { useSendTransaction } from "@starknet-react/core";
import { useRouter } from "next/router";
import { isHexString, minifyAddress } from "../../utils/stringService";
import { utils } from "starknetid.js";
Expand Down Expand Up @@ -45,7 +45,7 @@ const ExternalDomainsTransferModal: FunctionComponent<
const [isSendingTx, setIsSendingTx] = useState(false);
const [callData, setCallData] = useState<Call[]>([]);

const { writeAsync: transfer_name, data: transferData } = useContractWrite({
const { sendAsync: transfer_name, data: transferData } = useSendTransaction({
calls: callData,
});

Expand Down
4 changes: 2 additions & 2 deletions components/domains/steps/checkoutCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
NotificationType,
TransactionType,
} from "@/utils/constants";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import Button from "@/components/UI/button";
import RegisterSummary from "../registerSummary";
import { useNotificationManager } from "@/hooks/useNotificationManager";
Expand Down Expand Up @@ -52,7 +52,7 @@ const CheckoutCard: FunctionComponent<CheckoutCardProps> = ({
const { addTransaction } = useNotificationManager();
const tokenBalances = useBalances(address); // fetch the user balances for all whitelisted tokens
const [callData, setCallData] = useState<Call[]>([]);
const { writeAsync: execute, data: checkoutData } = useContractWrite({
const { sendAsync: execute, data: checkoutData } = useSendTransaction({
calls: callData,
});

Expand Down
4 changes: 2 additions & 2 deletions components/identities/actions/addEvmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Modal,
TextField,
} from "@mui/material";
import { useContractWrite } from "@starknet-react/core";
import { useSendTransaction } from "@starknet-react/core";
import React, { FunctionComponent, useEffect, useRef, useState } from "react";
import styles from "../../../styles/components/evmModalMessage.module.css";
import Button from "../../UI/button";
Expand Down Expand Up @@ -42,7 +42,7 @@ const AddEvmModal: FunctionComponent<AddEvmModalProps> = ({
const abortControllerRef = useRef<AbortController | null>(null);
const [isSendingTx, setIsSendingTx] = useState(false);

const { writeAsync: set_user_data, data: userData } = useContractWrite({
const { sendAsync: set_user_data, data: userData } = useSendTransaction({
calls:
identity && isValid
? [
Expand Down
6 changes: 3 additions & 3 deletions components/identities/actions/changeAddressModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FunctionComponent, useEffect, useState } from "react";
import { TextField } from "@mui/material";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import { isHexString, minifyAddress } from "../../../utils/stringService";
import { hexToDecimal } from "../../../utils/feltService";
import { useNotificationManager } from "../../../hooks/useNotificationManager";
Expand Down Expand Up @@ -30,8 +30,8 @@ const ChangeAddressModal: FunctionComponent<ChangeAddressModalProps> = ({
const [isTxSent, setIsTxSent] = useState(false);
const [isSendingTx, setIsSendingTx] = useState(false);

const { writeAsync: set_domain_to_address, data: domainToAddressData } =
useContractWrite({
const { sendAsync: set_domain_to_address, data: domainToAddressData } =
useSendTransaction({
calls: identity
? identityChangeCalls.setStarknetAddress(
identity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from "@anima-protocol/personhood-sdk-react";
import { useAccount } from "@starknet-react/core";
import { Call, TypedData } from "starknet";
import { useContractWrite } from "@starknet-react/core";
import { useSendTransaction } from "@starknet-react/core";
import { hexToDecimal } from "../../../../utils/feltService";
import {
bigintToStringHex,
Expand Down Expand Up @@ -46,7 +46,7 @@ const ClickablePersonhoodIcon: FunctionComponent<
const [isLoading, setIsLoading] = useState<boolean>(false);
const [callData, setCallData] = useState<Call>();
const { addTransaction } = useNotificationManager();
const { writeAsync: execute, data: verifierData } = useContractWrite({
const { sendAsync: execute, data: verifierData } = useSendTransaction({
calls: [callData as Call],
});
const network =
Expand Down
8 changes: 4 additions & 4 deletions components/identities/actions/identityActions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext, useMemo } from "react";
import { FunctionComponent, useEffect, useState } from "react";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import ChangeAddressModal from "./changeAddressModal";
import TransferFormModal from "./transferFormModal";
import SubdomainModal from "./subdomainModal";
Expand Down Expand Up @@ -66,8 +66,8 @@ const IdentityActions: FunctionComponent<IdentityActionsProps> = ({
const [disableRenewalCalldata, setDisableRenewalCalldata] = useState<Call[]>(
[]
);
const { writeAsync: disableRenewal, data: disableRenewalData } =
useContractWrite({
const { sendAsync: disableRenewal, data: disableRenewalData } =
useSendTransaction({
calls: disableRenewalCalldata,
});

Expand Down Expand Up @@ -102,7 +102,7 @@ const IdentityActions: FunctionComponent<IdentityActionsProps> = ({
callDataEncodedDomain.push(domain.toString(10));
});

const { writeAsync: setMainId, data: mainDomainData } = useContractWrite({
const { sendAsync: setMainId, data: mainDomainData } = useSendTransaction({
calls: identity
? identityChangeCalls.setAsMainId(
identity,
Expand Down
6 changes: 3 additions & 3 deletions components/identities/actions/subdomainModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FunctionComponent, useEffect, useState } from "react";
import { TextField } from "@mui/material";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import { useIsValid } from "../../../hooks/naming";
import { numberToString } from "../../../utils/stringService";
import SelectIdentity from "../../domains/selectIdentity";
Expand Down Expand Up @@ -32,8 +32,8 @@ const SubdomainModal: FunctionComponent<SubdomainModalProps> = ({
const [callData, setCallData] = useState<Call[]>([]);
const { address } = useAccount();
const { addTransaction } = useNotificationManager();
const { writeAsync: transfer_domain, data: transferDomainData } =
useContractWrite({
const { sendAsync: transfer_domain, data: transferDomainData } =
useSendTransaction({
calls: callData,
});
const [isTxSent, setIsTxSent] = useState(false);
Expand Down
6 changes: 3 additions & 3 deletions components/identities/actions/transferFormModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useContext,
} from "react";
import { TextField, InputAdornment } from "@mui/material";
import { useContractWrite } from "@starknet-react/core";
import { useSendTransaction } from "@starknet-react/core";
import { useRouter } from "next/router";
import { isHexString, minifyAddress } from "../../../utils/stringService";
import { utils } from "starknetid.js";
Expand Down Expand Up @@ -36,8 +36,8 @@ const TransferFormModal: FunctionComponent<TransferFormModalProps> = ({
const [isTxSent, setIsTxSent] = useState(false);
const [isSendingTx, setIsSendingTx] = useState(false);

const { writeAsync: transfer_identity_and_set_domain, data: transferData } =
useContractWrite({
const { sendAsync: transfer_identity_and_set_domain, data: transferData } =
useSendTransaction({
calls: identity
? identityChangeCalls.transfer(identity, targetAddress)
: [],
Expand Down
4 changes: 2 additions & 2 deletions components/solana/changeAddressModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Modal, TextField } from "@mui/material";
import { useAccount, useContractWrite } from "@starknet-react/core";
import { useAccount, useSendTransaction } from "@starknet-react/core";
import React, { FunctionComponent, useEffect, useState } from "react";
import { isHexString, minifyAddress } from "../../utils/stringService";
import styles from "../../styles/components/modalMessage.module.css";
Expand Down Expand Up @@ -30,7 +30,7 @@ const ChangeAddressModal: FunctionComponent<ChangeAddressModalProps> = ({
const { addTransaction } = useNotificationManager();
const [isTxSent, setIsTxSent] = useState(false);
const [callData, setCallData] = useState<Call[]>([]);
const { writeAsync: setResolving, data: resolvingData } = useContractWrite({
const { sendAsync: setResolving, data: resolvingData } = useSendTransaction({
calls: callData,
});

Expand Down
12 changes: 6 additions & 6 deletions components/solana/domainActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import styles from "../../styles/solana.module.css";
import { Abi, Call } from "starknet";
import {
useAccount,
useContractRead,
useContractWrite,
useReadContract,
useSendTransaction,
} from "@starknet-react/core";
import SolanaCalls from "../../utils/callData/solanaCalls";
import { utils } from "starknetid.js";
Expand All @@ -36,16 +36,16 @@ const DomainActions: FunctionComponent<DomainActionsProps> = ({ name }) => {
const { addTransaction } = useNotificationManager();
const [isTxSent, setIsTxSent] = useState(false);
const [mainDomainCalldata, setMainDomainCalldata] = useState<Call[]>([]);
const { writeAsync: executeMainDomain, data: mainDomainData } =
useContractWrite({
const { sendAsync: executeMainDomain, data: mainDomainData } =
useSendTransaction({
calls: mainDomainCalldata,
});
const { contract } = useNamingContract();
const encodedDomain = utils
.encodeDomain(`${name}.sol.stark`)
.map((x) => x.toString());
const { data: resolveData } = useContractRead({
address: contract?.address as string,
const { data: resolveData } = useReadContract({
address: contract?.address as HexString,
abi: contract?.abi as Abi,
functionName: "domain_to_address",
args: [encodedDomain, []],
Expand Down
6 changes: 3 additions & 3 deletions hooks/naming.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractRead } from "@starknet-react/core";
import { useReadContract } from "@starknet-react/core";
import { useNamingContract } from "./contracts";
import { useContext, useEffect, useState } from "react";
import { utils } from "starknetid.js";
Expand Down Expand Up @@ -105,8 +105,8 @@ export function useDataFromDomain(domain: string): FullDomainData {
? utils.encodeDomain(domain).map((elem) => elem.toString()) // remove when dapp uses starknet.js v5
: [];

const { data, error } = useContractRead({
address: contract?.address as string,
const { data, error } = useReadContract({
address: contract?.address as HexString,
abi: contract?.abi as Abi,
functionName: "domain_to_data",
args: [encoded],
Expand Down
4 changes: 2 additions & 2 deletions hooks/paymaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
useProvider,
useAccount,
useConnect,
useContractWrite,
useSendTransaction,
} from "@starknet-react/core";
import {
AccountInterface,
Expand Down Expand Up @@ -49,7 +49,7 @@ const usePaymaster = (
);
const [gasTokenPrice, setGasTokenPrice] = useState<GasTokenPrice>();
const [loadingGas, setLoadingGas] = useState<boolean>(false);
const { writeAsync: execute, data } = useContractWrite({
const { sendAsync: execute, data } = useSendTransaction({
calls: callData,
});
const { connector } = useConnect();
Expand Down
4 changes: 2 additions & 2 deletions hooks/useAllowanceCheck.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractRead } from "@starknet-react/core";
import { useReadContract } from "@starknet-react/core";
import { useEtherContract } from "./contracts";
import { Abi } from "starknet";
import { useEffect, useState } from "react";
Expand All @@ -17,7 +17,7 @@ export default function useAllowanceCheck(
const [currentAllowance, setCurrentAllowance] = useState<bigint>(BigInt(0));
const { contract: etherContract } = useEtherContract();
const { data: erc20AllowanceData, error: erc20AllowanceError } =
useContractRead({
useReadContract({
address: ERC20Contract[erc20],
abi: etherContract?.abi as Abi,
functionName: "allowance",
Expand Down
6 changes: 3 additions & 3 deletions hooks/useBalances.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractRead } from "@starknet-react/core";
import { useReadContract } from "@starknet-react/core";
import { useMulticallContract } from "./contracts";
import { Abi, BlockTag, CairoCustomEnum, Call, RawArgs, hash } from "starknet";
import { useEffect, useState } from "react";
Expand All @@ -9,8 +9,8 @@ export default function useBalances(address?: string) {
const [balances, setBalances] = useState<TokenBalance>({});
const [callData, setCallData] = useState<Call[]>([]);
const { contract: multicallContract } = useMulticallContract();
const { data: erc20BalanceData, error: erc20BalanceError } = useContractRead({
address: multicallContract?.address as string,
const { data: erc20BalanceData, error: erc20BalanceError } = useReadContract({
address: multicallContract?.address as HexString,
abi: multicallContract?.abi as Abi,
functionName: "aggregate",
args: callData,
Expand Down
6 changes: 3 additions & 3 deletions hooks/useHasClaimSolSubdomain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractRead } from "@starknet-react/core";
import { useReadContract } from "@starknet-react/core";
import { useSolSubdomainContract } from "./contracts";
import { Abi } from "starknet";
import { useEffect, useState } from "react";
Expand All @@ -11,8 +11,8 @@ export default function useHasClaimSolSubdomain(
) {
const [claimedDomains, setClaimedDomains] = useState<string[]>([]);
const { contract } = useSolSubdomainContract();
const { data: claimedData, error: claimedError } = useContractRead({
address: contract?.address as string,
const { data: claimedData, error: claimedError } = useReadContract({
address: contract?.address as HexString,
abi: contract?.abi as Abi,
functionName: "were_claimed",
args: [
Expand Down
6 changes: 3 additions & 3 deletions hooks/useNeedAllowances.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContractRead } from "@starknet-react/core";
import { useReadContract } from "@starknet-react/core";
import { useMulticallContract } from "./contracts";
import { Abi, BlockTag, CairoCustomEnum, Call, RawArgs, hash } from "starknet";
import { useEffect, useState, useMemo } from "react";
Expand All @@ -24,8 +24,8 @@ export default function useNeedsAllowances(
const [callData, setCallData] = useState<Call[]>([]);
const { contract: multicallContract } = useMulticallContract();
const { data: erc20AllowanceData, error: erc20AllowanceError } =
useContractRead({
address: multicallContract?.address as string,
useReadContract({
address: multicallContract?.address as HexString,
abi: multicallContract?.abi as Abi,
functionName: "aggregate",
args: callData,
Expand Down
Loading

0 comments on commit ecabbbd

Please sign in to comment.