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

Refactor: types/interfaces #627

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions packages/nextjs/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Bars3Icon, BugAntIcon } from "@heroicons/react/24/outline";
import { FaucetButton, RainbowKitCustomConnectButton } from "~~/components/scaffold-eth";
import { useOutsideClick } from "~~/hooks/scaffold-eth";

interface HeaderMenuLink {
type HeaderMenuLink = {
label: string;
href: string;
icon?: React.ReactNode;
}
};

export const menuLinks: HeaderMenuLink[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/components/blockexplorer/PaginationButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ArrowLeftIcon, ArrowRightIcon } from "@heroicons/react/24/outline";

interface PaginationButtonProps {
type PaginationButtonProps = {
currentPage: number;
totalItems: number;
setCurrentPage: (page: number) => void;
}
};

const ITEMS_PER_PAGE = 20;

Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/components/scaffold-eth/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outl
import { BlockieAvatar } from "~~/components/scaffold-eth";
import { getBlockExplorerAddressLink, getTargetNetwork } from "~~/utils/scaffold-eth";

type TAddressProps = {
type AddressProps = {
address?: string;
disableAddressLink?: boolean;
format?: "short" | "long";
Expand All @@ -28,7 +28,7 @@ const blockieSizeMap = {
/**
* Displays an address (or ENS) with a Blockie image and option to copy address.
*/
export const Address = ({ address, disableAddressLink, format, size = "base" }: TAddressProps) => {
export const Address = ({ address, disableAddressLink, format, size = "base" }: AddressProps) => {
const [ens, setEns] = useState<string | null>();
const [ensAvatar, setEnsAvatar] = useState<string | null>();
const [addressCopied, setAddressCopied] = useState(false);
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/components/scaffold-eth/Balance.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useAccountBalance } from "~~/hooks/scaffold-eth";
import { getTargetNetwork } from "~~/utils/scaffold-eth";

type TBalanceProps = {
type BalanceProps = {
address?: string;
className?: string;
};

/**
* Display (ETH & USD) balance of an ETH address.
*/
export const Balance = ({ address, className = "" }: TBalanceProps) => {
export const Balance = ({ address, className = "" }: BalanceProps) => {
const configuredNetwork = getTargetNetwork();
const { balance, price, isError, isLoading, onToggleBalance, isEthBalance } = useAccountBalance(address);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
} from "~~/components/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";

type TReadOnlyFunctionFormProps = {
type ReadOnlyFunctionFormProps = {
contractAddress: Address;
abiFunction: AbiFunction;
inheritedFrom?: string;
};

export const ReadOnlyFunctionForm = ({ contractAddress, abiFunction, inheritedFrom }: TReadOnlyFunctionFormProps) => {
export const ReadOnlyFunctionForm = ({ contractAddress, abiFunction, inheritedFrom }: ReadOnlyFunctionFormProps) => {
const [form, setForm] = useState<Record<string, any>>(() => getInitialFormState(abiFunction));
const [result, setResult] = useState<unknown>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { AbiFunction, AbiParameter } from "abitype";
import { BaseError as BaseViemError } from "viem";

/**
* @dev utility function to generate key corresponding to function metaData
* Generates a key based on function metadata
* @param {AbiFunction} functionName
technophile-04 marked this conversation as resolved.
Show resolved Hide resolved
* @param {utils.ParamType} input - object containing function name and input type corresponding to index
* @param {AbiParameter} input - object containing function name and input type corresponding to index
* @param {number} inputIndex
* @returns {string} key
*/
Expand All @@ -14,7 +14,7 @@ const getFunctionInputKey = (functionName: string, input: AbiParameter, inputInd
};

/**
* @dev utility function to parse error
* Parses an error to get a displayable string
* @param e - error object
* @returns {string} parsed error string
*/
Expand All @@ -38,8 +38,9 @@ const getParsedError = (e: any | BaseViemError): string => {

// This regex is used to identify array types in the form of `type[size]`
const ARRAY_TYPE_REGEX = /\[.*\]$/;

/**
* @dev Parse form input with array support
* Parses form input with array support
* @param {Record<string,any>} form - form object containing key value pairs
* @returns parsed error string
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/components/scaffold-eth/Input/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export interface CommonInputProps<T = string> {
export type CommonInputProps<T = string> = {
value: T;
onChange: (newValue: T) => void;
name?: string;
placeholder?: string;
disabled?: boolean;
}
};

export enum IntegerVariant {
UINT8 = "uint8",
Expand Down
63 changes: 13 additions & 50 deletions packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { WalletClient, usePublicClient } from "wagmi";
const burnerStorageKey = "scaffoldEth2.burnerWallet.sk";

/**
* Is the private key valid
* @internal
* @param pk
* @returns
* Checks if the private key is valid
*/
const isValidSk = (pk: Hex | string | undefined | null): boolean => {
return pk?.length === 64 || pk?.length === 66;
Expand All @@ -19,13 +16,10 @@ const isValidSk = (pk: Hex | string | undefined | null): boolean => {
/**
* If no burner is found in localstorage, we will generate a random private key
*/
const newDefaultPriaveKey = generatePrivateKey();
const newDefaultPrivateKey = generatePrivateKey();

/**
* Save the current burner private key from storage
* Can be used outside of react. Used by the burnerConnector.
* @internal
* @returns
* Save the current burner private key to local storage
*/
export const saveBurnerSK = (privateKey: Hex): void => {
if (typeof window != "undefined" && window != null) {
Expand All @@ -34,10 +28,7 @@ export const saveBurnerSK = (privateKey: Hex): void => {
};

/**
* Gets the current burner private key from storage
* Can be used outside of react. Used by the burnerConnector.
* @internal
* @returns
* Gets the current burner private key from local storage
*/
export const loadBurnerSK = (): Hex => {
let currentSk: Hex = "0x";
Expand All @@ -48,64 +39,36 @@ export const loadBurnerSK = (): Hex => {
if (!!currentSk && isValidSk(currentSk)) {
return currentSk;
} else {
saveBurnerSK(newDefaultPriaveKey);
return newDefaultPriaveKey;
saveBurnerSK(newDefaultPrivateKey);
return newDefaultPrivateKey;
}
};

/**
* #### Summary
* Return type of useBurnerSigner:
*
* ##### ✏️ Notes
* - provides signer
* - methods of interacting with burner signer
* - methods to save and loadd signer from local storage
*
* @category Hooks
*/
export type TBurnerSigner = {
type BurnerAccount = {
walletClient: WalletClient | undefined;
account: PrivateKeyAccount | undefined;
/**
* create a new burner signer
*/
// creates a new burner account
generateNewBurner: () => void;
/**
* explicitly save burner to storage
*/
// explicitly save burner to storage
saveBurner: () => void;
};

/**
* #### Summary
* A hook that creates a burner signer/address and provides ways of interacting with
* and updating the signer
*
* @category Hooks
*
* @param localProvider localhost provider
* @returns IBurnerSigner
* Creates a burner wallet
*/
export const useBurnerWallet = (): TBurnerSigner => {
const [burnerSk, setBurnerSk] = useLocalStorage<Hex>(burnerStorageKey, newDefaultPriaveKey);
export const useBurnerWallet = (): BurnerAccount => {
const [burnerSk, setBurnerSk] = useLocalStorage<Hex>(burnerStorageKey, newDefaultPrivateKey);

const publicClient = usePublicClient();
const [walletClient, setWalletClient] = useState<WalletClient<HttpTransport, Chain, PrivateKeyAccount>>();
const [generatedPrivateKey, setGeneratedPrivateKey] = useState<Hex>("0x");
const [account, setAccount] = useState<PrivateKeyAccount>();
const isCreatingNewBurnerRef = useRef(false);

/**
* callback to save current wallet sk
*/
const saveBurner = useCallback(() => {
setBurnerSk(generatedPrivateKey);
}, [setBurnerSk, generatedPrivateKey]);

/**
* create a new burnerkey
*/
const generateNewBurner = useCallback(() => {
if (publicClient && !isCreatingNewBurnerRef.current) {
console.log("🔑 Create new burner wallet...");
Expand All @@ -125,7 +88,7 @@ export const useBurnerWallet = (): TBurnerSigner => {
setAccount(randomAccount);

setBurnerSk(() => {
console.log("🔥 ...Save new burner wallet");
console.log("🔥 Saving new burner wallet");
isCreatingNewBurnerRef.current = false;
return randomPrivateKey;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
} from "~~/utils/scaffold-eth/contract";

/**
* @dev wrapper for wagmi's useContractRead hook which loads in deployed contract contract abi, address automatically
* Wrapper for wagmi's useContractRead hook which automatically loads (by name)
* the contract ABI and address from the deployed contracts
* @param config - The config settings, including extra wagmi configuration
* @param config.contractName - deployed contract name
* @param config.functionName - name of the function to be called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { ContractAbi, ContractName, UseScaffoldWriteConfig } from "~~/utils/scaf
type UpdatedArgs = Parameters<ReturnType<typeof useContractWrite<Abi, string, undefined>>["writeAsync"]>[0];

/**
* @dev wrapper for wagmi's useContractWrite hook(with config prepared by usePrepareContractWrite hook) which loads in deployed contract abi and address automatically
* Wrapper for wagmi's useContractWrite hook (with config prepared by usePrepareContractWrite hook)
* which automatically loads (by name) the contract ABI and address from the deployed contracts
* @param config - The config settings, including extra wagmi configuration
* @param config.contractName - deployed contract name
* @param config.functionName - name of the function to be called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "~~/utils/scaffold-eth/contract";

/**
* @dev reads events from a deployed contract
* Reads events from a deployed contract
* @param config - The config settings
* @param config.contractName - deployed contract name
* @param config.eventName - name of the event to listen for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { getTargetNetwork } from "~~/utils/scaffold-eth";
import { ContractAbi, ContractName, UseScaffoldEventConfig } from "~~/utils/scaffold-eth/contract";

/**
* @dev wrapper for wagmi's useContractEvent
* Wrapper for wagmi's useContractEvent which automatically loads (by name)
* the contract ABI and address from the deployed contracts.
* @param config - The config settings
* @param config.contractName - deployed contract name
* @param config.eventName - name of the event to listen for
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/services/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import create from "zustand";
* Think about it as a global useState.
*/

type TGlobalState = {
type GlobalState = {
nativeCurrencyPrice: number;
setNativeCurrencyPrice: (newNativeCurrencyPriceState: number) => void;
};

export const useGlobalState = create<TGlobalState>(set => ({
export const useGlobalState = create<GlobalState>(set => ({
nativeCurrencyPrice: 0,
setNativeCurrencyPrice: (newValue: number): void => set(() => ({ nativeCurrencyPrice: newValue })),
}));
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ export const BurnerConnectorErrorList = {
couldNotConnect: "Could not connect to network",
unsupportedBurnerChain: "This network is not supported for burner connector",
chainIdNotResolved: "Cound not resolve chainId",
signerNotResolved: "Cound not resolve signer",
chainNotSupported: "Chain is not supported, check burner wallet config",
} as const;

/**
* A union of all the BurnerConnectorErrorList
*/
export type BurnerConnectorErrorTypes = typeof BurnerConnectorErrorList[keyof typeof BurnerConnectorErrorList];
export type BurnerConnectorErrorTypes = (typeof BurnerConnectorErrorList)[keyof typeof BurnerConnectorErrorList];

export class BurnerConnectorError extends Error {
constructor(errorType: BurnerConnectorErrorTypes, message?: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { getTargetNetwork } from "~~/utils/scaffold-eth";

const { onlyLocalBurnerWallet } = scaffoldConfig;
const targetNetwork = getTargetNetwork();
export interface BurnerWalletOptions {
export type BurnerWalletOptions = {
chains: Chain[];
}
};

const burnerWalletIconBase64 =
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzUzIiBoZWlnaHQ9IjM1MiIgdmlld0JveD0iMCAwIDM1MyAzNTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjAuNzE2MzA5IiB5PSIwLjMxNzEzOSIgd2lkdGg9IjM1MS4zOTQiIGhlaWdodD0iMzUxLjM5NC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VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDIxOC4wNDggMjQ5LjM0Nykgcm90YXRlKDEyNC4wMTgpIHNjYWxlKDg5LjI5NTUgMjY0LjgwOSkiPgo8c3RvcCBvZmZzZXQ9IjAuNjQwODUiIHN0b3AtY29sb3I9IiNGRjY2MEEiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRkZCRTE1Ii8+CjwvcmFkaWFsR3JhZGllbnQ+CjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQyX2xpbmVhcl8zXzE1MSIgeDE9IjE3Ni40ODIiIHkxPSI0MC4xODQxIiB4Mj0iMTc2LjQ4MiIgeTI9IjMxNy4yNzgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agb2Zmc2V0PSIwLjMzODU0MiIgc3RvcC1jb2xvcj0iI0ZGOEYzRiIvPgo8c3RvcCBvZmZzZXQ9IjAuNjU2MjUiIHN0b3AtY29sb3I9IiNGRjcwMjAiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRkYzRDAwIi8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+Cg==";
Expand Down
8 changes: 4 additions & 4 deletions packages/nextjs/utils/scaffold-eth/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export type TransactionWithFunction = Transaction & {
functionArgTypes?: string[];
};

interface TransactionReceipts {
type TransactionReceipts = {
[key: string]: TransactionReceipt;
}
};

export interface TransactionsTableProps {
export type TransactionsTableProps = {
blocks: Block[];
transactionReceipts: TransactionReceipts;
}
};
17 changes: 6 additions & 11 deletions packages/nextjs/utils/scaffold-eth/networks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as chains from "viem/chains";
import scaffoldConfig from "~~/scaffold.config";

export type TChainAttributes = {
type ChainAttributes = {
// color | [lightThemeColor, darkThemeColor]
color: string | [string, string];
// Used to fetch price by providing mainnet token address
// for networks having native currency other than ETH
nativeCurrencyTokenAddress?: string;
};

export const NETWORKS_EXTRA_DATA: Record<string, TChainAttributes> = {
const NETWORKS_EXTRA_DATA: Record<string, ChainAttributes> = {
[chains.hardhat.id]: {
color: "#b8af0c",
},
Expand Down Expand Up @@ -58,9 +58,7 @@ export const NETWORKS_EXTRA_DATA: Record<string, TChainAttributes> = {

/**
* Gives the block explorer transaction URL.
* @param network
* @param txnHash
* @dev returns empty string if the network is localChain
* Returns empty string if the network is a local chain
*/
export function getBlockExplorerTxLink(chainId: number, txnHash: string) {
const chainNames = Object.keys(chains);
Expand All @@ -86,10 +84,8 @@ export function getBlockExplorerTxLink(chainId: number, txnHash: string) {
}

/**
* Gives the block explorer Address URL.
* @param network - wagmi chain object
* @param address
* @returns block explorer address URL and etherscan URL if block explorer URL is not present for wagmi network
* Gives the block explorer URL for a given address.
* Defaults to Etherscan if no (wagmi) block explorer is configured for the network.
*/
export function getBlockExplorerAddressLink(network: chains.Chain, address: string) {
const blockExplorerBaseURL = network.blockExplorers?.default?.url;
Expand All @@ -107,8 +103,7 @@ export function getBlockExplorerAddressLink(network: chains.Chain, address: stri
/**
* @returns targetNetwork object consisting targetNetwork from scaffold.config and extra network metadata
*/

export function getTargetNetwork(): chains.Chain & Partial<TChainAttributes> {
export function getTargetNetwork(): chains.Chain & Partial<ChainAttributes> {
const configuredNetwork = scaffoldConfig.targetNetwork;

return {
Expand Down
Loading