Scaffold-Move
diff --git a/packages/nextjs/components/scaffold-eth/Balance.tsx b/packages/nextjs/components/scaffold-eth/Balance.tsx
deleted file mode 100644
index 87b2fc5..0000000
--- a/packages/nextjs/components/scaffold-eth/Balance.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-"use client";
-
-import { Address, formatEther } from "viem";
-import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
-import { useWatchBalance } from "~~/hooks/scaffold-eth/useWatchBalance";
-
-type BalanceProps = {
- address?: Address;
- className?: string;
- usdMode?: boolean;
-};
-
-/**
- * Display APT balance of an APT address.
- */
-export const Balance = ({ address }: BalanceProps) => {
- const { targetNetwork } = useTargetNetwork();
-
- const {
- data: balance,
- isError,
- isLoading,
- } = useWatchBalance({
- address,
- });
-
- if (!address || isLoading || balance === null) {
- return (
-
- );
- }
-
- if (isError) {
- return (
-
- );
- }
-
- const formattedBalance = balance ? Number(formatEther(balance.value)) : 0;
-
- return (
-
- <>
- {formattedBalance.toFixed(4)}
- {targetNetwork.nativeCurrency.symbol}
- >
-
- );
-};
diff --git a/packages/nextjs/components/scaffold-eth/Faucet.tsx b/packages/nextjs/components/scaffold-eth/Faucet.tsx
deleted file mode 100644
index a55e7fb..0000000
--- a/packages/nextjs/components/scaffold-eth/Faucet.tsx
+++ /dev/null
@@ -1,129 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import { Address as AddressType, createWalletClient, http, parseEther } from "viem";
-import { hardhat } from "viem/chains";
-import { useAccount } from "wagmi";
-import { BanknotesIcon } from "@heroicons/react/24/outline";
-import { Address, AddressInput, Balance, EtherInput } from "~~/components/scaffold-eth";
-import { useTransactor } from "~~/hooks/scaffold-eth";
-import { notification } from "~~/utils/scaffold-eth";
-
-// Account index to use from generated hardhat accounts.
-const FAUCET_ACCOUNT_INDEX = 0;
-
-const localWalletClient = createWalletClient({
- chain: hardhat,
- transport: http(),
-});
-
-/**
- * Faucet modal which lets you send ETH to any address.
- */
-export const Faucet = () => {
- const [loading, setLoading] = useState(false);
- const [inputAddress, setInputAddress] = useState
();
- const [faucetAddress, setFaucetAddress] = useState();
- const [sendValue, setSendValue] = useState("");
-
- const { chain: ConnectedChain } = useAccount();
-
- const faucetTxn = useTransactor(localWalletClient);
-
- useEffect(() => {
- const getFaucetAddress = async () => {
- try {
- const accounts = await localWalletClient.getAddresses();
- setFaucetAddress(accounts[FAUCET_ACCOUNT_INDEX]);
- } catch (error) {
- notification.error(
- <>
- Cannot connect to local provider
-
- - Did you forget to run yarn chain
?
-
-
- - Or you can change targetNetwork
in{" "}
- scaffold.config.ts
-
- >,
- );
- console.error("⚡️ ~ file: Faucet.tsx:getFaucetAddress ~ error", error);
- }
- };
- getFaucetAddress();
- }, []);
-
- const sendETH = async () => {
- if (!faucetAddress || !inputAddress) {
- return;
- }
- try {
- setLoading(true);
- await faucetTxn({
- to: inputAddress,
- value: parseEther(sendValue as `${number}`),
- account: faucetAddress,
- });
- setLoading(false);
- setInputAddress(undefined);
- setSendValue("");
- } catch (error) {
- console.error("⚡️ ~ file: Faucet.tsx:sendETH ~ error", error);
- setLoading(false);
- }
- };
-
- // Render only on local chain
- if (ConnectedChain?.id !== hardhat.id) {
- return null;
- }
-
- return (
-
-
-
- Faucet
-
-
-
-
- {/* dummy input to capture event onclick on modal box */}
-
- Local Faucet
-
- ✕
-
-
-
-
-
setInputAddress(value as AddressType)}
- />
- setSendValue(value)} />
-
- {!loading ? (
-
- ) : (
-
- )}
- Send
-
-
-
-
-
-
- );
-};
diff --git a/packages/nextjs/components/scaffold-eth/FaucetButton.tsx b/packages/nextjs/components/scaffold-eth/FaucetButton.tsx
deleted file mode 100644
index 440b70b..0000000
--- a/packages/nextjs/components/scaffold-eth/FaucetButton.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { createWalletClient, http, parseEther } from "viem";
-import { hardhat } from "viem/chains";
-import { useAccount } from "wagmi";
-import { BanknotesIcon } from "@heroicons/react/24/outline";
-import { useTransactor } from "~~/hooks/scaffold-eth";
-import { useWatchBalance } from "~~/hooks/scaffold-eth/useWatchBalance";
-
-// Number of ETH faucet sends to an address
-const NUM_OF_ETH = "1";
-const FAUCET_ADDRESS = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
-
-const localWalletClient = createWalletClient({
- chain: hardhat,
- transport: http(),
-});
-
-/**
- * FaucetButton button which lets you grab eth.
- */
-export const FaucetButton = () => {
- const { address, chain: ConnectedChain } = useAccount();
-
- const { data: balance } = useWatchBalance({ address });
-
- const [loading, setLoading] = useState(false);
-
- const faucetTxn = useTransactor(localWalletClient);
-
- const sendETH = async () => {
- if (!address) return;
- try {
- setLoading(true);
- await faucetTxn({
- account: FAUCET_ADDRESS,
- to: address,
- value: parseEther(NUM_OF_ETH),
- });
- setLoading(false);
- } catch (error) {
- console.error("⚡️ ~ file: FaucetButton.tsx:sendETH ~ error", error);
- setLoading(false);
- }
- };
-
- // Render only on local chain
- if (ConnectedChain?.id !== hardhat.id) {
- return null;
- }
-
- const isBalanceZero = balance && balance.value === 0n;
-
- return (
-
-
- {!loading ? (
-
- ) : (
-
- )}
-
-
- );
-};
diff --git a/packages/nextjs/components/scaffold-eth/index.tsx b/packages/nextjs/components/scaffold-eth/index.tsx
index d4776a1..5475153 100644
--- a/packages/nextjs/components/scaffold-eth/index.tsx
+++ b/packages/nextjs/components/scaffold-eth/index.tsx
@@ -1,6 +1,3 @@
export * from "./Address";
-export * from "./Balance";
export * from "./BlockieAvatar";
-export * from "./Faucet";
-export * from "./FaucetButton";
export * from "./Input";
diff --git a/packages/nextjs/components/scaffold-move/Address.tsx b/packages/nextjs/components/scaffold-move/Address.tsx
index 24101ab..298c489 100644
--- a/packages/nextjs/components/scaffold-move/Address.tsx
+++ b/packages/nextjs/components/scaffold-move/Address.tsx
@@ -30,8 +30,8 @@ const blockieSizeMap = {
* Displays an address (or ENS) with a Blockie image and option to copy address.
*/
export const Address = ({ address, disableAddressLink, format, size = "base" }: AddressProps) => {
- const [ens, setEns] = useState();
- const [ensAvatar, setEnsAvatar] = useState();
+ // const [ens, setEns] = useState();
+ // const [ensAvatar, setEnsAvatar] = useState();
const [addressCopied, setAddressCopied] = useState(false);
const { targetNetwork } = useTargetNetwork();
@@ -77,9 +77,10 @@ export const Address = ({ address, disableAddressLink, format, size = "base" }:
const blockExplorerAddressLink = getBlockExplorerAddressLink(targetNetwork, address);
let displayAddress = address?.slice(0, 6) + "..." + address?.slice(-4);
- if (ens) {
- displayAddress = ens;
- } else if (format === "long") {
+ // if (ens) {
+ // displayAddress = ens;
+ // } else
+ if (format === "long") {
displayAddress = address;
}
@@ -88,7 +89,7 @@ export const Address = ({ address, disableAddressLink, format, size = "base" }:
diff --git a/packages/nextjs/components/scaffold-move/Balance.tsx b/packages/nextjs/components/scaffold-move/Balance.tsx
index e9a7064..e533712 100644
--- a/packages/nextjs/components/scaffold-move/Balance.tsx
+++ b/packages/nextjs/components/scaffold-move/Balance.tsx
@@ -1,8 +1,5 @@
"use client";
-import { Address, formatEther } from "viem";
-import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
-import { useWatchBalance } from "~~/hooks/scaffold-eth/useWatchBalance";
import {useGetAccountAPTBalance} from "~~/hooks/scaffold-move/useGetAccountAPTBalance";
import {getFormattedBalanceStr} from "../../utils/scaffold-move/ContentValue/CurrencyValue"
diff --git a/packages/nextjs/contracts/deployedModules.ts b/packages/nextjs/contracts/deployedModules.ts
index 6396ffa..f2ed370 100644
--- a/packages/nextjs/contracts/deployedModules.ts
+++ b/packages/nextjs/contracts/deployedModules.ts
@@ -1,20 +1,250 @@
import { GenericContractsDeclaration } from "~~/utils/scaffold-move/contract";
const deployedContracts = {
- "devnet": {
- "onchain_bio": {
- "bytecode": "0xa11ceb0b060000000a010006020608030e0f051d1307304a087a4010ba01220adc01090ce501340d99020200000101010200030e0002040700000500010000060203000109050000010501080103060c080108010001080001060c0b6f6e636861696e5f62696f067369676e657206737472696e670342696f06537472696e67076765745f62696f087265676973746572046e616d650362696f0a616464726573735f6f664295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c0000000000000000000000000000000000000000000000000000000000000001126170746f733a3a6d657461646174615f76310e000001076765745f62696f010100000202070801080801000100010003050b002b0010001402010104010004100a001102290004080a0011022c00010b010b0212000c030b000b032d0002000100",
- "abi": {"address":"0x4295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c","name":"onchain_bio","friends":[],"exposed_functions":[{"name":"get_bio","visibility":"public","is_entry":false,"is_view":true,"generic_type_params":[],"params":["address"],"return":["0x1::string::String"]},{"name":"register","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String"],"return":[]}],"structs":[{"name":"Bio","is_native":false,"abilities":["drop","store","key"],"generic_type_params":[],"fields":[{"name":"name","type":"0x1::string::String"},{"name":"bio","type":"0x1::string::String"}]}]}
- },
-"onchain_poems": {
- "bytecode": "0xa11ceb0b060000000b010004020408030c0a05161207284c08744006b4010a10be013a0af8010c0c8402260daa02020000010100020e000103070000040001000005020300010501080104060c080108010801000108000d6f6e636861696e5f706f656d7306737472696e670b496e736372697074696f6e06537472696e67086765745f706f656d08726567697374657204706f656d057469746c6506617574686f724295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f7631260101000000000000000d455f414c52454144595f484153000001086765745f706f656d010100000203060801070801080801000100010003050b002b00100014020101040004090b010b020b0312000c040b000b042d0002000000",
- "abi": {"address":"0x4295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c","name":"onchain_poems","friends":[],"exposed_functions":[{"name":"get_poem","visibility":"public","is_entry":false,"is_view":true,"generic_type_params":[],"params":["address"],"return":["0x1::string::String"]},{"name":"register","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String"],"return":[]}],"structs":[{"name":"Inscription","is_native":false,"abilities":["drop","store","key"],"generic_type_params":[],"fields":[{"name":"poem","type":"0x1::string::String"},{"name":"title","type":"0x1::string::String"},{"name":"author","type":"0x1::string::String"}]}]}
- },
-"onchain_poems_with_table": {
- "bytecode": "0xa11ceb0b060000000c01000a020a14031e23044106054739078001bb0108bb024006fb020a1085033a0abf031c0cdb036f0dca0404000001010102010301040005070000060800030707000410040203010001000800010000090201000212020400041306010203020114080101060415010a02030403050407050504060c0802080208020001060c040308000708010501050203080003070b03020900090109000901010800010900010801010b030209000901186f6e636861696e5f706f656d735f776974685f7461626c65056576656e74067369676e657206737472696e67057461626c6504506f656d08506f656d4c69737406537472696e670b6372656174655f706f656d106372656174655f706f656d5f6c69737407706f656d5f6964076164647265737304706f656d057469746c6506617574686f7205706f656d73055461626c650c706f656d5f636f756e7465720a616464726573735f6f660675707365727404656d6974036e65774295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f76312601010000000000000011455f4e4f545f494e495449414c495a4544000104506f656d010400000002050a030b050c08020d08020e08020102020f0b03020308001103000104010103250b0011020c070a072901040705090700270a072a010c060a06100014060100000000000000160c040a040b070b010b020b0312000c050a060f010a040a0538000b040b060f00150b05380102010104000908380206000000000000000012010c010b000b012d01020101010000",
- "abi": {"address":"0x4295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c","name":"onchain_poems_with_table","friends":[],"exposed_functions":[{"name":"create_poem","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String"],"return":[]},{"name":"create_poem_list","visibility":"public","is_entry":true,"is_view":false,"generic_type_params":[],"params":["&signer"],"return":[]}],"structs":[{"name":"Poem","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"poem_id","type":"u64"},{"name":"address","type":"address"},{"name":"poem","type":"0x1::string::String"},{"name":"title","type":"0x1::string::String"},{"name":"author","type":"0x1::string::String"}]},{"name":"PoemList","is_native":false,"abilities":["key"],"generic_type_params":[],"fields":[{"name":"poems","type":"0x1::table::Table"},{"name":"poem_counter","type":"u64"}]}]}
- }
- }
+ "devnet":{
+ "onchain_bio":{
+ "bytecode":"0xa11ceb0b060000000a010006020608030e0f051d1307304a087a4010ba01220adc01090ce501340d99020200000101010200030e0002040700000500010000060203000109050000010501080103060c080108010001080001060c0b6f6e636861696e5f62696f067369676e657206737472696e670342696f06537472696e67076765745f62696f087265676973746572046e616d650362696f0a616464726573735f6f664295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c0000000000000000000000000000000000000000000000000000000000000001126170746f733a3a6d657461646174615f76310e000001076765745f62696f010100000202070801080801000100010003050b002b0010001402010104010004100a001102290004080a0011022c00010b010b0212000c030b000b032d0002000100",
+ "abi":{
+ "address":"0x4295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c",
+ "name":"onchain_bio",
+ "friends":[
+
+ ],
+ "exposed_functions":[
+ {
+ "name":"get_bio",
+ "visibility":"public",
+ "is_entry":false,
+ "is_view":true,
+ "generic_type_params":[
+
+ ],
+ "params":[
+ "address"
+ ],
+ "return":[
+ "0x1::string::String"
+ ]
+ },
+ {
+ "name":"register",
+ "visibility":"public",
+ "is_entry":true,
+ "is_view":false,
+ "generic_type_params":[
+
+ ],
+ "params":[
+ "&signer",
+ "0x1::string::String",
+ "0x1::string::String"
+ ],
+ "return":[
+
+ ]
+ }
+ ],
+ "structs":[
+ {
+ "name":"Bio",
+ "is_native":false,
+ "abilities":[
+ "drop",
+ "store",
+ "key"
+ ],
+ "generic_type_params":[
+
+ ],
+ "fields":[
+ {
+ "name":"name",
+ "type":"0x1::string::String"
+ },
+ {
+ "name":"bio",
+ "type":"0x1::string::String"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ "onchain_poems":{
+ "bytecode":"0xa11ceb0b060000000b010004020408030c0a05161207284c08744006b4010a10be013a0af8010c0c8402260daa02020000010100020e000103070000040001000005020300010501080104060c080108010801000108000d6f6e636861696e5f706f656d7306737472696e670b496e736372697074696f6e06537472696e67086765745f706f656d08726567697374657204706f656d057469746c6506617574686f724295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f7631260101000000000000000d455f414c52454144595f484153000001086765745f706f656d010100000203060801070801080801000100010003050b002b00100014020101040004090b010b020b0312000c040b000b042d0002000000",
+ "abi":{
+ "address":"0x4295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c",
+ "name":"onchain_poems",
+ "friends":[
+
+ ],
+ "exposed_functions":[
+ {
+ "name":"get_poem",
+ "visibility":"public",
+ "is_entry":false,
+ "is_view":true,
+ "generic_type_params":[
+
+ ],
+ "params":[
+ "address"
+ ],
+ "return":[
+ "0x1::string::String"
+ ]
+ },
+ {
+ "name":"register",
+ "visibility":"public",
+ "is_entry":true,
+ "is_view":false,
+ "generic_type_params":[
+
+ ],
+ "params":[
+ "&signer",
+ "0x1::string::String",
+ "0x1::string::String",
+ "0x1::string::String"
+ ],
+ "return":[
+
+ ]
+ }
+ ],
+ "structs":[
+ {
+ "name":"Inscription",
+ "is_native":false,
+ "abilities":[
+ "drop",
+ "store",
+ "key"
+ ],
+ "generic_type_params":[
+
+ ],
+ "fields":[
+ {
+ "name":"poem",
+ "type":"0x1::string::String"
+ },
+ {
+ "name":"title",
+ "type":"0x1::string::String"
+ },
+ {
+ "name":"author",
+ "type":"0x1::string::String"
+ }
+ ]
+ }
+ ]
+ }
+ },
+ "onchain_poems_with_table":{
+ "bytecode":"0xa11ceb0b060000000c01000a020a14031e23044106054739078001bb0108bb024006fb020a1085033a0abf031c0cdb036f0dca0404000001010102010301040005070000060800030707000410040203010001000800010000090201000212020400041306010203020114080101060415010a02030403050407050504060c0802080208020001060c040308000708010501050203080003070b03020900090109000901010800010900010801010b030209000901186f6e636861696e5f706f656d735f776974685f7461626c65056576656e74067369676e657206737472696e67057461626c6504506f656d08506f656d4c69737406537472696e670b6372656174655f706f656d106372656174655f706f656d5f6c69737407706f656d5f6964076164647265737304706f656d057469746c6506617574686f7205706f656d73055461626c650c706f656d5f636f756e7465720a616464726573735f6f660675707365727404656d6974036e65774295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c000000000000000000000000000000000000000000000000000000000000000103080100000000000000126170746f733a3a6d657461646174615f76312601010000000000000011455f4e4f545f494e495449414c495a4544000104506f656d010400000002050a030b050c08020d08020e08020102020f0b03020308001103000104010103250b0011020c070a072901040705090700270a072a010c060a06100014060100000000000000160c040a040b070b010b020b0312000c050a060f010a040a0538000b040b060f00150b05380102010104000908380206000000000000000012010c010b000b012d01020101010000",
+ "abi":{
+ "address":"0x4295cca96321b2807473c0df06fa0ec4b1e22e612f8577cc36406d8c0e67630c",
+ "name":"onchain_poems_with_table",
+ "friends":[
+
+ ],
+ "exposed_functions":[
+ {
+ "name":"create_poem",
+ "visibility":"public",
+ "is_entry":true,
+ "is_view":false,
+ "generic_type_params":[
+
+ ],
+ "params":[
+ "&signer",
+ "0x1::string::String",
+ "0x1::string::String",
+ "0x1::string::String"
+ ],
+ "return":[
+
+ ]
+ },
+ {
+ "name":"create_poem_list",
+ "visibility":"public",
+ "is_entry":true,
+ "is_view":false,
+ "generic_type_params":[
+
+ ],
+ "params":[
+ "&signer"
+ ],
+ "return":[
+
+ ]
+ }
+ ],
+ "structs":[
+ {
+ "name":"Poem",
+ "is_native":false,
+ "abilities":[
+ "copy",
+ "drop",
+ "store"
+ ],
+ "generic_type_params":[
+
+ ],
+ "fields":[
+ {
+ "name":"poem_id",
+ "type":"u64"
+ },
+ {
+ "name":"address",
+ "type":"address"
+ },
+ {
+ "name":"poem",
+ "type":"0x1::string::String"
+ },
+ {
+ "name":"title",
+ "type":"0x1::string::String"
+ },
+ {
+ "name":"author",
+ "type":"0x1::string::String"
+ }
+ ]
+ },
+ {
+ "name":"PoemList",
+ "is_native":false,
+ "abilities":[
+ "key"
+ ],
+ "generic_type_params":[
+
+ ],
+ "fields":[
+ {
+ "name":"poems",
+ "type":"0x1::table::Table"
+ },
+ {
+ "name":"poem_counter",
+ "type":"u64"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
} as const;
export default deployedContracts satisfies GenericContractsDeclaration;
\ No newline at end of file
diff --git a/packages/nextjs/global-config/GlobalConfig.tsx b/packages/nextjs/global-config/GlobalConfig.tsx
deleted file mode 100644
index 727037d..0000000
--- a/packages/nextjs/global-config/GlobalConfig.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-import {AptosClient, IndexerClient} from "aptos";
-import React, {useMemo} from "react";
-import {
- FeatureName,
- NetworkName,
- defaultNetworkName,
- networks,
-} from "../constants";
-import {
- getSelectedFeatureFromLocalStorage,
- useFeatureSelector,
-} from "./feature-selection";
-import {useNetworkSelector} from "./network-selection";
-import {getGraphqlURI} from "../hooks/scaffold-move/useGraphqlClient";
-import {Aptos, AptosConfig, NetworkToNetworkName} from "@aptos-labs/ts-sdk";
-
-const HEADERS = {
- "x-indexer-client": "aptos-explorer",
-};
-
-export type GlobalState = {
- /** actual state */
- readonly feature_name: FeatureName;
- /** derived from external state ?network= query parameter - e.g. devnet */
- readonly network_name: NetworkName;
- /** derived from network_name - url to connect to network */
- readonly network_value: string;
- /** derived from network_value */
- readonly aptos_client: AptosClient;
- /** derived from network_value */
- readonly indexer_client?: IndexerClient;
- /** derived from network_value */
- readonly sdk_v2_client?: Aptos;
-};
-
-type GlobalActions = {
- selectFeature: ReturnType[1];
- selectNetwork: ReturnType[1];
-};
-
-function deriveGlobalState({
- feature_name,
- network_name,
-}: {
- feature_name: FeatureName;
- network_name: NetworkName;
-}): GlobalState {
- const indexerUri = getGraphqlURI(network_name);
- let indexerClient = undefined;
- if (indexerUri) {
- indexerClient = new IndexerClient(indexerUri, {HEADERS});
- }
- return {
- feature_name,
- network_name,
- network_value: networks[network_name],
- aptos_client: new AptosClient(networks[network_name], {
- HEADERS,
- }),
- indexer_client: indexerClient,
- sdk_v2_client: new Aptos(
- new AptosConfig({
- network: NetworkToNetworkName[network_name],
- clientConfig: {
- HEADERS,
- },
- }),
- ),
- };
-}
-
-const initialGlobalState = deriveGlobalState({
- feature_name: getSelectedFeatureFromLocalStorage(),
- network_name: defaultNetworkName,
-});
-
-export const GlobalStateContext = React.createContext(initialGlobalState);
-export const GlobalActionsContext = React.createContext({} as GlobalActions);
-
-export const GlobalStateProvider = ({
- children,
-}: {
- children: React.ReactNode;
-}) => {
- const [selectedFeature, selectFeature] = useFeatureSelector();
- const [selectedNetwork, selectNetwork] = useNetworkSelector();
- const globalState: GlobalState = useMemo(
- () =>
- deriveGlobalState({
- feature_name: selectedFeature,
- network_name: selectedNetwork,
- }),
- [selectedFeature, selectedNetwork],
- );
-
- const globalActions = useMemo(
- () => ({
- selectFeature,
- selectNetwork,
- }),
- [selectFeature, selectNetwork],
- );
-
- return (
-
-
- {children}
-
-
- );
-};
-
-export const useGlobalState = () =>
- [
- React.useContext(GlobalStateContext),
- React.useContext(GlobalActionsContext),
- ] as const;
diff --git a/packages/nextjs/global-config/feature-selection.ts b/packages/nextjs/global-config/feature-selection.ts
deleted file mode 100644
index 9241779..0000000
--- a/packages/nextjs/global-config/feature-selection.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import {useSearchParams} from "react-router-dom";
-import {
- FeatureName,
- defaultFeatureName,
- features,
- isValidFeatureName,
-} from "../constants";
-import {useCallback, useEffect, useState} from "react";
-
-export function getSelectedFeatureFromLocalStorage(): FeatureName {
- let selected_feature = localStorage.getItem("selected_feature");
- if (selected_feature) {
- selected_feature = selected_feature.toLowerCase();
- if (selected_feature in features) {
- return selected_feature as FeatureName;
- }
- }
- return defaultFeatureName;
-}
-
-// This is a custom hook that allows us to select a feature
-// The feature is stored in local storage across sessions and also in the url as a query param during the session lifetime.
-// don't use this hook directly in components, rather use: const [useGlobalState, {selectFeature}] = useGlobalState();
-export function useFeatureSelector() {
- const [searchParams, setSearchParams] = useSearchParams();
- const [selectedFeature, setSelectedFeature] = useState(
- getSelectedFeatureFromLocalStorage,
- );
-
- const featureQueryParam = searchParams.get("feature");
-
- const selectFeature = useCallback(
- (feature_name: FeatureName) => {
- if (!isValidFeatureName(feature_name)) return;
- localStorage.setItem("selected_feature", feature_name);
- // only show the "feature" param in the url when it's not "prod"
- // we don't want the users to know the existence of the "feature" param
- if (feature_name === defaultFeatureName) {
- setSearchParams((prev) => {
- const newParams = new URLSearchParams(prev);
- newParams.delete("feature");
- return newParams;
- });
- } else {
- setSearchParams((prev) => {
- const newParams = new URLSearchParams(prev);
- newParams.set("feature", feature_name);
- return newParams;
- });
- }
- setSelectedFeature(feature_name);
- },
- [setSearchParams],
- );
-
- useEffect(() => {
- if (featureQueryParam) {
- selectFeature(featureQueryParam as FeatureName);
- }
- }, [featureQueryParam, selectFeature]);
-
- return [selectedFeature, selectFeature] as const;
-}
diff --git a/packages/nextjs/global-config/network-selection.ts b/packages/nextjs/global-config/network-selection.ts
deleted file mode 100644
index cf1a6ec..0000000
--- a/packages/nextjs/global-config/network-selection.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-import {useSearchParams} from "react-router-dom";
-import {
- NetworkName,
- isValidNetworkName,
- defaultNetworkName,
-} from "../constants";
-import {useEffect} from "react";
-
-const SELECTED_NETWORK_LOCAL_STORAGE_KEY = "selected_network";
-
-function getUserSelectedNetworkFromLocalStorageWithDefault(): NetworkName {
- const network = localStorage.getItem(SELECTED_NETWORK_LOCAL_STORAGE_KEY);
- if (!isValidNetworkName(network ?? "")) {
- return defaultNetworkName;
- }
- return network as NetworkName;
-}
-
-function writeSelectedNetworkToLocalStorage(network: NetworkName) {
- const currentLocalStorageNetwork = localStorage.getItem(
- SELECTED_NETWORK_LOCAL_STORAGE_KEY,
- );
- if (network === defaultNetworkName && currentLocalStorageNetwork != null) {
- // if network selection is default network (i.e. mainnet) we remove the local storage entry
- localStorage.removeItem(SELECTED_NETWORK_LOCAL_STORAGE_KEY);
- } else if (currentLocalStorageNetwork !== network) {
- localStorage.setItem(SELECTED_NETWORK_LOCAL_STORAGE_KEY, network);
- }
-}
-
-// This is a custom hook that allows us to read and write the selectedNetwork.
-// Note that this hook implements essentially 3 things:
-// 1. The hook will return the currently selected network, which is essentially whatever is contained in the URL query param "network".
-// 2. If the URL query param "network" is not present, the hook will perform this on initialization:
-// 1. check localStorage for a previously selected network. If no previously selected network is found, it will default to the defaultNetworkName.
-// 2. set the URL query param "network" to the result of 1.
-// 3. Lastly, the hook provides a function to explicitly select/switch a network. This function will update the URL query param "network" and also store the selected network in local storage.
-// This is aimed to be used by the network selection dropdown in the header.
-// WARNING: don't use this hook directly in components, rather use: const [useGlobalState, {selectNetwork}] = useGlobalState();
-export function useNetworkSelector() {
- const [searchParams, setSearchParams] = useSearchParams();
-
- const selectedNetworkQueryParam = searchParams.get("network") ?? "";
-
- function selectNetwork(
- network: NetworkName,
- {replace = false}: {replace?: boolean} = {},
- ) {
- if (!isValidNetworkName(network)) return;
- setSearchParams(
- (prev) => {
- const newParams = new URLSearchParams(prev);
- newParams.set("network", network);
- return newParams;
- },
- {replace},
- );
- writeSelectedNetworkToLocalStorage(network);
- }
-
- // on init check for existence of network query param, if not present, check local storage for a previously selected network. Then set query param to the network defined in local storage.
- useEffect(
- () => {
- const currentNetworkSearchParam = searchParams.get("network");
- if (!isValidNetworkName(currentNetworkSearchParam ?? "")) {
- selectNetwork(getUserSelectedNetworkFromLocalStorageWithDefault(), {
- replace: true,
- });
- }
- },
- // eslint-disable-next-line react-hooks/exhaustive-deps
- [], // empty [] makes this effect only run once (on mount)
- );
-
- if (isValidNetworkName(selectedNetworkQueryParam)) {
- return [selectedNetworkQueryParam, selectNetwork] as const;
- } else {
- return [defaultNetworkName, selectNetwork] as const;
- }
-}
diff --git a/packages/nextjs/hooks/scaffold-eth/index.ts b/packages/nextjs/hooks/scaffold-eth/index.ts
index 72771f1..6f79f41 100644
--- a/packages/nextjs/hooks/scaffold-eth/index.ts
+++ b/packages/nextjs/hooks/scaffold-eth/index.ts
@@ -1,15 +1,15 @@
export * from "./useAnimationConfig";
-export * from "./useBurnerWallet";
-export * from "./useContractLogs";
-export * from "./useDeployedContractInfo";
-export * from "./useFetchBlocks";
-export * from "./useNetworkColor";
-export * from "./useOutsideClick";
-export * from "./useScaffoldContract";
-export * from "./useScaffoldEventHistory";
-export * from "./useScaffoldReadContract";
-export * from "./useScaffoldWatchContractEvent";
-export * from "./useScaffoldWriteContract";
+// export * from "./useBurnerWallet";
+// export * from "./useContractLogs";
+// export * from "./useDeployedContractInfo";
+// export * from "./useFetchBlocks";
+// export * from "./useNetworkColor";
+// export * from "./useOutsideClick";
+// // export * from "./useScaffoldContract";
+// // export * from "./useScaffoldEventHistory";
+// export * from "./useScaffoldReadContract";
+// // export * from "./useScaffoldWatchContractEvent";
+// export * from "./useScaffoldWriteContract";
export * from "./useTargetNetwork";
-export * from "./useTransactor";
-export * from "./useWatchBalance";
+// export * from "./useTransactor";
+// export * from "./useWatchBalance";
diff --git a/packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts b/packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts
deleted file mode 100644
index 2b8cf88..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts
+++ /dev/null
@@ -1,146 +0,0 @@
-import { useCallback, useEffect, useRef, useState } from "react";
-import { useTargetNetwork } from "./useTargetNetwork";
-import { useLocalStorage } from "usehooks-ts";
-import { Chain, Hex, HttpTransport, PrivateKeyAccount, createWalletClient, http } from "viem";
-import { WalletClient } from "viem";
-import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
-import { usePublicClient } from "wagmi";
-
-const burnerStorageKey = "scaffoldEth2.burnerWallet.sk";
-
-/**
- * Checks if the private key is valid
- */
-const isValidSk = (pk: Hex | string | undefined | null): boolean => {
- return pk?.length === 64 || pk?.length === 66;
-};
-
-/**
- * If no burner is found in localstorage, we will generate a random private key
- */
-const newDefaultPrivateKey = generatePrivateKey();
-
-/**
- * Save the current burner private key to local storage
- */
-export const saveBurnerSK = (privateKey: Hex): void => {
- if (typeof window != "undefined" && window != null) {
- window?.localStorage?.setItem(burnerStorageKey, privateKey);
- }
-};
-
-/**
- * Gets the current burner private key from local storage
- */
-export const loadBurnerSK = (): Hex => {
- let currentSk: Hex = "0x";
- if (typeof window != "undefined" && window != null) {
- currentSk = (window?.localStorage?.getItem?.(burnerStorageKey)?.replaceAll('"', "") ?? "0x") as Hex;
- }
-
- if (!!currentSk && isValidSk(currentSk)) {
- return currentSk;
- } else {
- saveBurnerSK(newDefaultPrivateKey);
- return newDefaultPrivateKey;
- }
-};
-
-type BurnerAccount = {
- walletClient: WalletClient | undefined;
- account: PrivateKeyAccount | undefined;
- // creates a new burner account
- generateNewBurner: () => void;
- // explicitly save burner to storage
- saveBurner: () => void;
-};
-
-/**
- * Creates a burner wallet
- */
-export const useBurnerWallet = (): BurnerAccount => {
- const [burnerSk, setBurnerSk] = useLocalStorage(burnerStorageKey, newDefaultPrivateKey, {
- initializeWithValue: false,
- });
-
- const { targetNetwork } = useTargetNetwork();
- const publicClient = usePublicClient({ chainId: targetNetwork.id });
- const [walletClient, setWalletClient] = useState>();
- const [generatedPrivateKey, setGeneratedPrivateKey] = useState("0x");
- const [account, setAccount] = useState();
- const isCreatingNewBurnerRef = useRef(false);
-
- const saveBurner = useCallback(() => {
- setBurnerSk(generatedPrivateKey);
- }, [setBurnerSk, generatedPrivateKey]);
-
- const generateNewBurner = useCallback(() => {
- if (publicClient && !isCreatingNewBurnerRef.current) {
- console.log("🔑 Create new burner wallet...");
- isCreatingNewBurnerRef.current = true;
-
- const randomPrivateKey = generatePrivateKey();
- const randomAccount = privateKeyToAccount(randomPrivateKey);
-
- const client = createWalletClient({
- chain: publicClient.chain,
- account: randomAccount,
- transport: http(),
- });
-
- setWalletClient(client);
- setGeneratedPrivateKey(randomPrivateKey);
- setAccount(randomAccount);
-
- setBurnerSk(() => {
- console.log("🔥 Saving new burner wallet");
- isCreatingNewBurnerRef.current = false;
- return randomPrivateKey;
- });
- return client;
- } else {
- console.log("⚠ Could not create burner wallet");
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [publicClient?.chain.id]);
-
- /**
- * Load wallet with burnerSk
- * connect and set wallet, once we have burnerSk and valid provider
- */
- useEffect(() => {
- if (burnerSk && publicClient?.chain.id) {
- let wallet: WalletClient | undefined = undefined;
- if (isValidSk(burnerSk)) {
- const randomAccount = privateKeyToAccount(burnerSk);
-
- wallet = createWalletClient({
- chain: publicClient.chain,
- account: randomAccount,
- transport: http(),
- });
-
- setGeneratedPrivateKey(burnerSk);
- setAccount(randomAccount);
- } else {
- wallet = generateNewBurner();
- }
-
- if (wallet == null) {
- throw "Error: Could not create burner wallet";
- }
-
- setWalletClient(wallet);
- saveBurner();
- }
-
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [burnerSk, publicClient?.chain.id]);
-
- return {
- walletClient,
- account,
- generateNewBurner,
- saveBurner,
- };
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts b/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts
deleted file mode 100644
index 27775d5..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { useEffect, useState } from "react";
-import { useTargetNetwork } from "./useTargetNetwork";
-import { Address, Log } from "viem";
-import { usePublicClient } from "wagmi";
-
-export const useContractLogs = (address: Address) => {
- const [logs, setLogs] = useState([]);
- const { targetNetwork } = useTargetNetwork();
- const client = usePublicClient({ chainId: targetNetwork.id });
-
- useEffect(() => {
- const fetchLogs = async () => {
- if (!client) return console.error("Client not found");
- try {
- const existingLogs = await client.getLogs({
- address: address,
- fromBlock: 0n,
- toBlock: "latest",
- });
- setLogs(existingLogs);
- } catch (error) {
- console.error("Failed to fetch logs:", error);
- }
- };
- fetchLogs();
-
- return client?.watchBlockNumber({
- onBlockNumber: async (_blockNumber, prevBlockNumber) => {
- const newLogs = await client.getLogs({
- address: address,
- fromBlock: prevBlockNumber,
- toBlock: "latest",
- });
- setLogs(prevLogs => [...prevLogs, ...newLogs]);
- },
- });
- }, [address, client]);
-
- return logs;
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts b/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts
deleted file mode 100644
index 7e490ad..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useFetchBlocks.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import { useCallback, useEffect, useState } from "react";
-import {
- Block,
- Hash,
- Transaction,
- TransactionReceipt,
- createTestClient,
- publicActions,
- walletActions,
- webSocket,
-} from "viem";
-import { hardhat } from "viem/chains";
-import { decodeTransactionData } from "~~/utils/scaffold-eth";
-
-const BLOCKS_PER_PAGE = 20;
-
-export const testClient = createTestClient({
- chain: hardhat,
- mode: "hardhat",
- transport: webSocket("ws://127.0.0.1:8545"),
-})
- .extend(publicActions)
- .extend(walletActions);
-
-export const useFetchBlocks = () => {
- const [blocks, setBlocks] = useState([]);
- const [transactionReceipts, setTransactionReceipts] = useState<{
- [key: string]: TransactionReceipt;
- }>({});
- const [currentPage, setCurrentPage] = useState(0);
- const [totalBlocks, setTotalBlocks] = useState(0n);
- const [error, setError] = useState(null);
-
- const fetchBlocks = useCallback(async () => {
- setError(null);
-
- try {
- const blockNumber = await testClient.getBlockNumber();
- setTotalBlocks(blockNumber);
-
- const startingBlock = blockNumber - BigInt(currentPage * BLOCKS_PER_PAGE);
- const blockNumbersToFetch = Array.from(
- { length: Number(BLOCKS_PER_PAGE < startingBlock + 1n ? BLOCKS_PER_PAGE : startingBlock + 1n) },
- (_, i) => startingBlock - BigInt(i),
- );
-
- const blocksWithTransactions = blockNumbersToFetch.map(async blockNumber => {
- try {
- return testClient.getBlock({ blockNumber, includeTransactions: true });
- } catch (err) {
- setError(err instanceof Error ? err : new Error("An error occurred."));
- throw err;
- }
- });
- const fetchedBlocks = await Promise.all(blocksWithTransactions);
-
- fetchedBlocks.forEach(block => {
- block.transactions.forEach(tx => decodeTransactionData(tx as Transaction));
- });
-
- const txReceipts = await Promise.all(
- fetchedBlocks.flatMap(block =>
- block.transactions.map(async tx => {
- try {
- const receipt = await testClient.getTransactionReceipt({ hash: (tx as Transaction).hash });
- return { [(tx as Transaction).hash]: receipt };
- } catch (err) {
- setError(err instanceof Error ? err : new Error("An error occurred."));
- throw err;
- }
- }),
- ),
- );
-
- setBlocks(fetchedBlocks);
- setTransactionReceipts(prevReceipts => ({ ...prevReceipts, ...Object.assign({}, ...txReceipts) }));
- } catch (err) {
- setError(err instanceof Error ? err : new Error("An error occurred."));
- }
- }, [currentPage]);
-
- useEffect(() => {
- fetchBlocks();
- }, [fetchBlocks]);
-
- useEffect(() => {
- const handleNewBlock = async (newBlock: any) => {
- try {
- if (currentPage === 0) {
- if (newBlock.transactions.length > 0) {
- const transactionsDetails = await Promise.all(
- newBlock.transactions.map((txHash: string) => testClient.getTransaction({ hash: txHash as Hash })),
- );
- newBlock.transactions = transactionsDetails;
- }
-
- newBlock.transactions.forEach((tx: Transaction) => decodeTransactionData(tx as Transaction));
-
- const receipts = await Promise.all(
- newBlock.transactions.map(async (tx: Transaction) => {
- try {
- const receipt = await testClient.getTransactionReceipt({ hash: (tx as Transaction).hash });
- return { [(tx as Transaction).hash]: receipt };
- } catch (err) {
- setError(err instanceof Error ? err : new Error("An error occurred fetching receipt."));
- throw err;
- }
- }),
- );
-
- setBlocks(prevBlocks => [newBlock, ...prevBlocks.slice(0, BLOCKS_PER_PAGE - 1)]);
- setTransactionReceipts(prevReceipts => ({ ...prevReceipts, ...Object.assign({}, ...receipts) }));
- }
- if (newBlock.number) {
- setTotalBlocks(newBlock.number);
- }
- } catch (err) {
- setError(err instanceof Error ? err : new Error("An error occurred."));
- }
- };
-
- return testClient.watchBlocks({ onBlock: handleNewBlock, includeTransactions: true });
- }, [currentPage]);
-
- return {
- blocks,
- transactionReceipts,
- currentPage,
- totalBlocks,
- setCurrentPage,
- error,
- };
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts b/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts
deleted file mode 100644
index ec9c770..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { useTargetNetwork } from "./useTargetNetwork";
-import { useTheme } from "next-themes";
-import { ChainWithAttributes } from "~~/utils/scaffold-eth";
-
-export const DEFAULT_NETWORK_COLOR: [string, string] = ["#666666", "#bbbbbb"];
-
-export function getNetworkColor(network: ChainWithAttributes, isDarkMode: boolean) {
- const colorConfig = network.color ?? DEFAULT_NETWORK_COLOR;
- return Array.isArray(colorConfig) ? (isDarkMode ? colorConfig[1] : colorConfig[0]) : colorConfig;
-}
-
-/**
- * Gets the color of the target network
- */
-export const useNetworkColor = () => {
- const { resolvedTheme } = useTheme();
- const { targetNetwork } = useTargetNetwork();
-
- const isDarkMode = resolvedTheme === "dark";
-
- return getNetworkColor(targetNetwork, isDarkMode);
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useOutsideClick.ts b/packages/nextjs/hooks/scaffold-eth/useOutsideClick.ts
deleted file mode 100644
index d7f2e0e..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useOutsideClick.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import React, { useEffect } from "react";
-
-/**
- * Handles clicks outside of passed ref element
- * @param ref - react ref of the element
- * @param callback - callback function to call when clicked outside
- */
-export const useOutsideClick = (ref: React.RefObject, callback: { (): void }) => {
- useEffect(() => {
- function handleOutsideClick(event: MouseEvent) {
- if (!(event.target instanceof Element)) {
- return;
- }
-
- if (ref.current && !ref.current.contains(event.target)) {
- callback();
- }
- }
-
- document.addEventListener("click", handleOutsideClick);
- return () => document.removeEventListener("click", handleOutsideClick);
- }, [ref, callback]);
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts
deleted file mode 100644
index 1add8cb..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { useTargetNetwork } from "./useTargetNetwork";
-import { Account, Address, Chain, Client, Transport, getContract } from "viem";
-import { usePublicClient } from "wagmi";
-import { GetWalletClientReturnType } from "wagmi/actions";
-import { useDeployedContractInfo } from "~~/hooks/scaffold-eth";
-import { Contract, ContractName } from "~~/utils/scaffold-eth/contract";
-
-/**
- * Gets a viem instance of the contract present in deployedContracts.ts or externalContracts.ts corresponding to
- * targetNetworks configured in scaffold.config.ts. Optional walletClient can be passed for doing write transactions.
- * @param config - The config settings for the hook
- * @param config.contractName - deployed contract name
- * @param config.walletClient - optional walletClient from wagmi useWalletClient hook can be passed for doing write transactions
- */
-export const useScaffoldContract = <
- TContractName extends ContractName,
- TWalletClient extends Exclude | undefined,
->({
- contractName,
- walletClient,
-}: {
- contractName: TContractName;
- walletClient?: TWalletClient | null;
-}) => {
- const { data: deployedContractData, isLoading: deployedContractLoading } = useDeployedContractInfo(contractName);
- const { targetNetwork } = useTargetNetwork();
- const publicClient = usePublicClient({ chainId: targetNetwork.id });
-
- let contract = undefined;
- if (deployedContractData && publicClient) {
- contract = getContract<
- Transport,
- Address,
- Contract["abi"],
- TWalletClient extends Exclude
- ? {
- public: Client;
- wallet: TWalletClient;
- }
- : { public: Client },
- Chain,
- Account
- >({
- address: deployedContractData.address,
- abi: deployedContractData.abi as Contract["abi"],
- client: {
- public: publicClient,
- wallet: walletClient ? walletClient : undefined,
- } as any,
- });
- }
-
- return {
- data: contract,
- isLoading: deployedContractLoading,
- };
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts
deleted file mode 100644
index 48f8ed6..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts
+++ /dev/null
@@ -1,170 +0,0 @@
-import { useEffect, useState } from "react";
-import { useTargetNetwork } from "./useTargetNetwork";
-import { useInfiniteQuery } from "@tanstack/react-query";
-import { Abi, AbiEvent, ExtractAbiEventNames } from "abitype";
-import { BlockNumber, GetLogsParameters } from "viem";
-import { Config, UsePublicClientReturnType, useBlockNumber, usePublicClient } from "wagmi";
-import { useDeployedContractInfo } from "~~/hooks/scaffold-eth";
-import {
- ContractAbi,
- ContractName,
- UseScaffoldEventHistoryConfig,
- UseScaffoldEventHistoryData,
-} from "~~/utils/scaffold-eth/contract";
-
-const getEvents = async (
- getLogsParams: GetLogsParameters,
- publicClient?: UsePublicClientReturnType,
- Options?: {
- blockData?: boolean;
- transactionData?: boolean;
- receiptData?: boolean;
- },
-) => {
- const logs = await publicClient?.getLogs({
- address: getLogsParams.address,
- fromBlock: getLogsParams.fromBlock,
- args: getLogsParams.args,
- event: getLogsParams.event,
- });
- if (!logs) return undefined;
-
- const finalEvents = await Promise.all(
- logs.map(async log => {
- return {
- ...log,
- blockData:
- Options?.blockData && log.blockHash ? await publicClient?.getBlock({ blockHash: log.blockHash }) : null,
- transactionData:
- Options?.transactionData && log.transactionHash
- ? await publicClient?.getTransaction({ hash: log.transactionHash })
- : null,
- receiptData:
- Options?.receiptData && log.transactionHash
- ? await publicClient?.getTransactionReceipt({ hash: log.transactionHash })
- : null,
- };
- }),
- );
-
- return finalEvents;
-};
-
-/**
- * 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
- * @param config.fromBlock - the block number to start reading events from
- * @param config.filters - filters to be applied to the event (parameterName: value)
- * @param config.blockData - if set to true it will return the block data for each event (default: false)
- * @param config.transactionData - if set to true it will return the transaction data for each event (default: false)
- * @param config.receiptData - if set to true it will return the receipt data for each event (default: false)
- * @param config.watch - if set to true, the events will be updated every pollingInterval milliseconds set at scaffoldConfig (default: false)
- * @param config.enabled - set this to false to disable the hook from running (default: true)
- */
-export const useScaffoldEventHistory = <
- TContractName extends ContractName,
- TEventName extends ExtractAbiEventNames>,
- TBlockData extends boolean = false,
- TTransactionData extends boolean = false,
- TReceiptData extends boolean = false,
->({
- contractName,
- eventName,
- fromBlock,
- filters,
- blockData,
- transactionData,
- receiptData,
- watch,
- enabled = true,
-}: UseScaffoldEventHistoryConfig) => {
- const { targetNetwork } = useTargetNetwork();
- const publicClient = usePublicClient({
- chainId: targetNetwork.id,
- });
- const [isFirstRender, setIsFirstRender] = useState(true);
-
- const { data: blockNumber } = useBlockNumber({ watch: watch, chainId: targetNetwork.id });
-
- const { data: deployedContractData } = useDeployedContractInfo(contractName);
-
- const event =
- deployedContractData &&
- ((deployedContractData.abi as Abi).find(part => part.type === "event" && part.name === eventName) as AbiEvent);
-
- const isContractAddressAndClientReady = Boolean(deployedContractData?.address) && Boolean(publicClient);
-
- const query = useInfiniteQuery({
- queryKey: [
- "eventHistory",
- {
- contractName,
- address: deployedContractData?.address,
- eventName,
- fromBlock: fromBlock.toString(),
- chainId: targetNetwork.id,
- },
- ],
- queryFn: async ({ pageParam }) => {
- if (!isContractAddressAndClientReady) return undefined;
- const data = await getEvents(
- { address: deployedContractData?.address, event, fromBlock: pageParam, args: filters },
- publicClient,
- { blockData, transactionData, receiptData },
- );
-
- return data;
- },
- enabled: enabled && isContractAddressAndClientReady,
- initialPageParam: fromBlock,
- getNextPageParam: () => {
- return blockNumber;
- },
- select: data => {
- const events = data.pages.flat();
- const eventHistoryData = events?.map(addIndexedArgsToEvent) as UseScaffoldEventHistoryData<
- TContractName,
- TEventName,
- TBlockData,
- TTransactionData,
- TReceiptData
- >;
- return {
- pages: eventHistoryData?.reverse(),
- pageParams: data.pageParams,
- };
- },
- });
-
- useEffect(() => {
- const shouldSkipEffect = !blockNumber || !watch || isFirstRender;
- if (shouldSkipEffect) {
- // skipping on first render, since on first render we should call queryFn with
- // fromBlock value, not blockNumber
- if (isFirstRender) setIsFirstRender(false);
- return;
- }
-
- query.fetchNextPage();
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [blockNumber, watch]);
-
- return {
- data: query.data?.pages,
- status: query.status,
- error: query.error,
- isLoading: query.isLoading,
- isFetchingNewEvent: query.isFetchingNextPage,
- refetch: query.refetch,
- };
-};
-
-export const addIndexedArgsToEvent = (event: any) => {
- if (event.args && !Array.isArray(event.args)) {
- return { ...event, args: { ...event.args, ...Object.values(event.args) } };
- }
-
- return event;
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts
deleted file mode 100644
index 9d9e8f0..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import { useEffect } from "react";
-import { useTargetNetwork } from "./useTargetNetwork";
-import { QueryObserverResult, RefetchOptions, useQueryClient } from "@tanstack/react-query";
-import type { ExtractAbiFunctionNames } from "abitype";
-import { ReadContractErrorType } from "viem";
-import { useBlockNumber, useReadContract } from "wagmi";
-import { useDeployedContractInfo } from "~~/hooks/scaffold-eth";
-import {
- AbiFunctionReturnType,
- ContractAbi,
- ContractName,
- UseScaffoldReadConfig,
-} from "~~/utils/scaffold-eth/contract";
-
-/**
- * Wrapper around wagmi's useContractRead hook which automatically loads (by name) the contract ABI and address from
- * the contracts present in deployedContracts.ts & externalContracts.ts corresponding to targetNetworks configured in scaffold.config.ts
- * @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
- * @param config.args - args to be passed to the function call
- */
-export const useScaffoldReadContract = <
- TContractName extends ContractName,
- TFunctionName extends ExtractAbiFunctionNames, "pure" | "view">,
->({
- contractName,
- functionName,
- args,
- ...readConfig
-}: UseScaffoldReadConfig) => {
- const { data: deployedContract } = useDeployedContractInfo(contractName);
- const { targetNetwork } = useTargetNetwork();
- const { query: queryOptions, watch, ...readContractConfig } = readConfig;
- // set watch to true by default
- const defaultWatch = watch ?? true;
-
- const readContractHookRes = useReadContract({
- chainId: targetNetwork.id,
- functionName,
- address: deployedContract?.address,
- abi: deployedContract?.abi,
- args,
- ...(readContractConfig as any),
- query: {
- enabled: !Array.isArray(args) || !args.some(arg => arg === undefined),
- ...queryOptions,
- },
- }) as Omit, "data" | "refetch"> & {
- data: AbiFunctionReturnType | undefined;
- refetch: (
- options?: RefetchOptions | undefined,
- ) => Promise, ReadContractErrorType>>;
- };
-
- const queryClient = useQueryClient();
- const { data: blockNumber } = useBlockNumber({
- watch: defaultWatch,
- chainId: targetNetwork.id,
- query: {
- enabled: defaultWatch,
- },
- });
-
- useEffect(() => {
- if (defaultWatch) {
- queryClient.invalidateQueries({ queryKey: readContractHookRes.queryKey });
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [blockNumber]);
-
- return readContractHookRes;
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts
deleted file mode 100644
index 844b4a0..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { useTargetNetwork } from "./useTargetNetwork";
-import { Abi, ExtractAbiEventNames } from "abitype";
-import { Log } from "viem";
-import { useWatchContractEvent } from "wagmi";
-import { addIndexedArgsToEvent, useDeployedContractInfo } from "~~/hooks/scaffold-eth";
-import { ContractAbi, ContractName, UseScaffoldEventConfig } from "~~/utils/scaffold-eth/contract";
-
-/**
- * Wrapper around wagmi's useEventSubscriber hook which automatically loads (by name) the contract ABI and
- * address from the contracts present in deployedContracts.ts & externalContracts.ts
- * @param config - The config settings
- * @param config.contractName - deployed contract name
- * @param config.eventName - name of the event to listen for
- * @param config.onLogs - the callback that receives events.
- */
-export const useScaffoldWatchContractEvent = <
- TContractName extends ContractName,
- TEventName extends ExtractAbiEventNames>,
->({
- contractName,
- eventName,
- onLogs,
-}: UseScaffoldEventConfig) => {
- const { data: deployedContractData } = useDeployedContractInfo(contractName);
- const { targetNetwork } = useTargetNetwork();
-
- const addIndexedArgsToLogs = (logs: Log[]) => logs.map(addIndexedArgsToEvent);
- const listenerWithIndexedArgs = (logs: Log[]) => onLogs(addIndexedArgsToLogs(logs) as Parameters[0]);
-
- return useWatchContractEvent({
- address: deployedContractData?.address,
- abi: deployedContractData?.abi as Abi,
- chainId: targetNetwork.id,
- onLogs: listenerWithIndexedArgs,
- eventName,
- });
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts
deleted file mode 100644
index 4bd903f..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-import { useState } from "react";
-import { useTargetNetwork } from "./useTargetNetwork";
-import { MutateOptions } from "@tanstack/react-query";
-import { Abi, ExtractAbiFunctionNames } from "abitype";
-import { Config, UseWriteContractParameters, useAccount, useWriteContract } from "wagmi";
-import { WriteContractErrorType, WriteContractReturnType } from "wagmi/actions";
-import { WriteContractVariables } from "wagmi/query";
-import { useDeployedContractInfo, useTransactor } from "~~/hooks/scaffold-eth";
-import { notification } from "~~/utils/scaffold-eth";
-import {
- ContractAbi,
- ContractName,
- ScaffoldWriteContractOptions,
- ScaffoldWriteContractVariables,
-} from "~~/utils/scaffold-eth/contract";
-
-/**
- * Wrapper around wagmi's useWriteContract hook which automatically loads (by name) the contract ABI and address from
- * the contracts present in deployedContracts.ts & externalContracts.ts corresponding to targetNetworks configured in scaffold.config.ts
- * @param contractName - name of the contract to be written to
- * @param writeContractParams - wagmi's useWriteContract parameters
- */
-export const useScaffoldWriteContract = (
- contractName: TContractName,
- writeContractParams?: UseWriteContractParameters,
-) => {
- const { chain } = useAccount();
- const writeTx = useTransactor();
- const [isMining, setIsMining] = useState(false);
- const { targetNetwork } = useTargetNetwork();
-
- const wagmiContractWrite = useWriteContract(writeContractParams);
-
- const { data: deployedContractData } = useDeployedContractInfo(contractName);
-
- const sendContractWriteAsyncTx = async <
- TFunctionName extends ExtractAbiFunctionNames, "nonpayable" | "payable">,
- >(
- variables: ScaffoldWriteContractVariables,
- options?: ScaffoldWriteContractOptions,
- ) => {
- if (!deployedContractData) {
- notification.error("Target Contract is not deployed, did you forget to run `yarn deploy`?");
- return;
- }
-
- if (!chain?.id) {
- notification.error("Please connect your wallet");
- return;
- }
- if (chain?.id !== targetNetwork.id) {
- notification.error("You are on the wrong network");
- return;
- }
-
- try {
- setIsMining(true);
- const { blockConfirmations, onBlockConfirmation, ...mutateOptions } = options || {};
- const makeWriteWithParams = () =>
- wagmiContractWrite.writeContractAsync(
- {
- abi: deployedContractData.abi as Abi,
- address: deployedContractData.address,
- ...variables,
- } as WriteContractVariables,
- mutateOptions as
- | MutateOptions<
- WriteContractReturnType,
- WriteContractErrorType,
- WriteContractVariables,
- unknown
- >
- | undefined,
- );
- const writeTxResult = await writeTx(makeWriteWithParams, { blockConfirmations, onBlockConfirmation });
-
- return writeTxResult;
- } catch (e: any) {
- throw e;
- } finally {
- setIsMining(false);
- }
- };
-
- const sendContractWriteTx = <
- TContractName extends ContractName,
- TFunctionName extends ExtractAbiFunctionNames, "nonpayable" | "payable">,
- >(
- variables: ScaffoldWriteContractVariables,
- options?: Omit,
- ) => {
- if (!deployedContractData) {
- notification.error("Target Contract is not deployed, did you forget to run `yarn deploy`?");
- return;
- }
- if (!chain?.id) {
- notification.error("Please connect your wallet");
- return;
- }
- if (chain?.id !== targetNetwork.id) {
- notification.error("You are on the wrong network");
- return;
- }
-
- wagmiContractWrite.writeContract(
- {
- abi: deployedContractData.abi as Abi,
- address: deployedContractData.address,
- ...variables,
- } as WriteContractVariables,
- options as
- | MutateOptions<
- WriteContractReturnType,
- WriteContractErrorType,
- WriteContractVariables,
- unknown
- >
- | undefined,
- );
- };
-
- return {
- ...wagmiContractWrite,
- isMining,
- // Overwrite wagmi's writeContactAsync
- writeContractAsync: sendContractWriteAsyncTx,
- // Overwrite wagmi's writeContract
- writeContract: sendContractWriteTx,
- };
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useTransactor.tsx b/packages/nextjs/hooks/scaffold-eth/useTransactor.tsx
deleted file mode 100644
index 0d14e14..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useTransactor.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import { getPublicClient } from "@wagmi/core";
-import { Hash, SendTransactionParameters, WalletClient } from "viem";
-import { Config, useWalletClient } from "wagmi";
-import { SendTransactionMutate } from "wagmi/query";
-import { wagmiConfig } from "~~/services/web3/wagmiConfig";
-import { getBlockExplorerTxLink, getParsedError, notification } from "~~/utils/scaffold-eth";
-import { TransactorFuncOptions } from "~~/utils/scaffold-eth/contract";
-
-type TransactionFunc = (
- tx: (() => Promise) | Parameters>[0],
- options?: TransactorFuncOptions,
-) => Promise;
-
-/**
- * Custom notification content for TXs.
- */
-const TxnNotification = ({ message, blockExplorerLink }: { message: string; blockExplorerLink?: string }) => {
- return (
-
- );
-};
-
-/**
- * Runs Transaction passed in to returned function showing UI feedback.
- * @param _walletClient - Optional wallet client to use. If not provided, will use the one from useWalletClient.
- * @returns function that takes in transaction function as callback, shows UI feedback for transaction and returns a promise of the transaction hash
- */
-export const useTransactor = (_walletClient?: WalletClient): TransactionFunc => {
- let walletClient = _walletClient;
- const { data } = useWalletClient();
- if (walletClient === undefined && data) {
- walletClient = data;
- }
-
- const result: TransactionFunc = async (tx, options) => {
- if (!walletClient) {
- notification.error("Cannot access account");
- console.error("⚡️ ~ file: useTransactor.tsx ~ error");
- return;
- }
-
- let notificationId = null;
- let transactionHash: Hash | undefined = undefined;
- try {
- const network = await walletClient.getChainId();
- // Get full transaction from public client
- const publicClient = getPublicClient(wagmiConfig);
-
- notificationId = notification.loading( );
- if (typeof tx === "function") {
- // Tx is already prepared by the caller
- const result = await tx();
- transactionHash = result;
- } else if (tx != null) {
- transactionHash = await walletClient.sendTransaction(tx as SendTransactionParameters);
- } else {
- throw new Error("Incorrect transaction passed to transactor");
- }
- notification.remove(notificationId);
-
- const blockExplorerTxURL = network ? getBlockExplorerTxLink(network, transactionHash) : "";
-
- notificationId = notification.loading(
- ,
- );
-
- const transactionReceipt = await publicClient.waitForTransactionReceipt({
- hash: transactionHash,
- confirmations: options?.blockConfirmations,
- });
- notification.remove(notificationId);
-
- notification.success(
- ,
- {
- icon: "🎉",
- },
- );
-
- if (options?.onBlockConfirmation) options.onBlockConfirmation(transactionReceipt);
- } catch (error: any) {
- if (notificationId) {
- notification.remove(notificationId);
- }
- console.error("⚡️ ~ file: useTransactor.ts ~ error", error);
- const message = getParsedError(error);
- notification.error(message);
- throw error;
- }
-
- return transactionHash;
- };
-
- return result;
-};
diff --git a/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts b/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts
deleted file mode 100644
index 26acda9..0000000
--- a/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useEffect } from "react";
-import { useTargetNetwork } from "./useTargetNetwork";
-import { useQueryClient } from "@tanstack/react-query";
-import { UseBalanceParameters, useBalance, useBlockNumber } from "wagmi";
-
-/**
- * Wrapper around wagmi's useBalance hook. Updates data on every block change.
- */
-export const useWatchBalance = (useBalanceParameters: UseBalanceParameters) => {
- const { targetNetwork } = useTargetNetwork();
- const queryClient = useQueryClient();
- const { data: blockNumber } = useBlockNumber({ watch: true, chainId: targetNetwork.id });
- const { queryKey, ...restUseBalanceReturn } = useBalance(useBalanceParameters);
-
- useEffect(() => {
- queryClient.invalidateQueries({ queryKey });
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [blockNumber]);
-
- return restUseBalanceReturn;
-};
diff --git a/packages/nextjs/hooks/scaffold-move/index.ts b/packages/nextjs/hooks/scaffold-move/index.ts
new file mode 100644
index 0000000..b7333f3
--- /dev/null
+++ b/packages/nextjs/hooks/scaffold-move/index.ts
@@ -0,0 +1 @@
+export * from "./useDeployedContractInfo";
\ No newline at end of file
diff --git a/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts b/packages/nextjs/hooks/scaffold-move/useDeployedContractInfo.ts
similarity index 95%
rename from packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts
rename to packages/nextjs/hooks/scaffold-move/useDeployedContractInfo.ts
index 7b41c69..6e96446 100644
--- a/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts
+++ b/packages/nextjs/hooks/scaffold-move/useDeployedContractInfo.ts
@@ -1,7 +1,5 @@
import { useEffect, useState } from "react";
-import { useTargetNetwork } from "./useTargetNetwork";
import { useIsMounted } from "usehooks-ts";
-import { usePublicClient } from "wagmi";
import { Contract, ContractCodeStatus, ContractName, contracts } from "~~/utils/scaffold-move/contract";
/**
diff --git a/packages/nextjs/hooks/scaffold-move/useGetAccountAPTBalance.ts b/packages/nextjs/hooks/scaffold-move/useGetAccountAPTBalance.ts
index c8d65d6..52d7151 100644
--- a/packages/nextjs/hooks/scaffold-move/useGetAccountAPTBalance.ts
+++ b/packages/nextjs/hooks/scaffold-move/useGetAccountAPTBalance.ts
@@ -8,7 +8,6 @@ interface CoinStore {
}
export function useGetAccountAPTBalance(address: string) {
- console.log("useGetAccountAPTBalance", address);
const {isLoading, data, error} = useGetAccountResources(address);
if (isLoading || error || !data) {
diff --git a/packages/nextjs/hooks/scaffold-move/useGetAccountModules.ts b/packages/nextjs/hooks/scaffold-move/useGetAccountModules.ts
index 395a14d..6120659 100644
--- a/packages/nextjs/hooks/scaffold-move/useGetAccountModules.ts
+++ b/packages/nextjs/hooks/scaffold-move/useGetAccountModules.ts
@@ -2,12 +2,14 @@ import {Types} from "aptos";
import {useQuery, UseQueryResult} from "@tanstack/react-query";
import {getAccountModules} from "..";
import {ResponseError} from "../client";
-import {useGlobalState} from "../../global-config/GlobalConfig";
+// import {useGlobalState} from "../../global-config/GlobalConfig";
export function useGetAccountModules(
address: string,
): UseQueryResult {
- const [state] = useGlobalState();
+ // const [state] = useGlobalState();
+ const state = {network_value: "https://aptos.devnet.m1.movementlabs.xyz"}
+
return useQuery, ResponseError>({
queryKey: ["accountModules", {address}, state.network_value],
diff --git a/packages/nextjs/hooks/scaffold-move/useGetAccountResources.ts b/packages/nextjs/hooks/scaffold-move/useGetAccountResources.ts
index b6c7b3e..aaf53c3 100644
--- a/packages/nextjs/hooks/scaffold-move/useGetAccountResources.ts
+++ b/packages/nextjs/hooks/scaffold-move/useGetAccountResources.ts
@@ -10,7 +10,9 @@ export function useGetAccountResources(
retry?: number | boolean;
},
): UseQueryResult {
- const [state] = useGlobalState();
+ // const [state] = useGlobalState();
+ const state = {network_value: "https://aptos.devnet.m1.movementlabs.xyz"}
+
const test = useQuery, ResponseError>({
queryKey: ["accountResources", {address}, state.network_value],
queryFn: () => getAccountResources({address}, state.network_value),
diff --git a/packages/nextjs/hooks/scaffold-move/useGraphqlClient.tsx b/packages/nextjs/hooks/scaffold-move/useGraphqlClient.tsx
index 8b196eb..0a131c7 100644
--- a/packages/nextjs/hooks/scaffold-move/useGraphqlClient.tsx
+++ b/packages/nextjs/hooks/scaffold-move/useGraphqlClient.tsx
@@ -7,8 +7,8 @@ import {
NormalizedCacheObject,
} from "@apollo/client";
import {useEffect, useState} from "react";
-import {NetworkName} from "../../constants";
-import {useGlobalState} from "../../global-config/GlobalConfig";
+import {Network, NetworkName} from "../../constants";
+// import {useGlobalState} from "../../global-config/GlobalConfig";
function getIsGraphqlClientSupportedFor(networkName: NetworkName): boolean {
const graphqlUri = getGraphqlURI(networkName);
@@ -44,7 +44,9 @@ function getGraphqlClient(
}
export function useGetGraphqlClient() {
- const [state] = useGlobalState();
+ // const [state] = useGlobalState();
+ const state = {network_name: Network.DEVNET, network_value: "https://aptos.devnet.m1.movementlabs.xyz"}
+
const [graphqlClient, setGraphqlClient] = useState<
ApolloClient
>(getGraphqlClient(state.network_name));
@@ -67,7 +69,9 @@ export function GraphqlClientProvider({children}: GraphqlClientProviderProps) {
}
export function useGetIsGraphqlClientSupported(): boolean {
- const [state] = useGlobalState();
+ // const [state] = useGlobalState();
+ const state = {network_name: Network.DEVNET, network_value: "https://aptos.devnet.m1.movementlabs.xyz"}
+
const [isGraphqlClientSupported, setIsGraphqlClientSupported] =
useState(getIsGraphqlClientSupportedFor(state.network_name));
diff --git a/packages/nextjs/hooks/scaffold-move/useSubmitTransaction.ts b/packages/nextjs/hooks/scaffold-move/useSubmitTransaction.ts
index eab968d..b29904b 100644
--- a/packages/nextjs/hooks/scaffold-move/useSubmitTransaction.ts
+++ b/packages/nextjs/hooks/scaffold-move/useSubmitTransaction.ts
@@ -4,7 +4,9 @@ import {
useWallet,
InputTransactionData,
} from "@aptos-labs/wallet-adapter-react";
-import {useGlobalState} from "../../global-config/GlobalConfig";
+// import {useGlobalState} from "../../global-config/GlobalConfig";
+import {Aptos, AptosConfig, Network} from "@aptos-labs/ts-sdk";
+
export type TransactionResponse =
| TransactionResponseOnSubmission
@@ -29,8 +31,18 @@ const useSubmitTransaction = () => {
useState(null);
const [transactionInProcess, setTransactionInProcess] =
useState(false);
- const [state] = useGlobalState();
- const {signAndSubmitTransaction, network} = useWallet();
+ // const [state] = useGlobalState();
+
+ const aptosConfig = new AptosConfig({
+ network: Network.CUSTOM,
+ fullnode: 'https://aptos.devnet.m1.movementlabs.xyz',
+ indexer: 'https://indexer.devnet.m1.movementlabs.xyz/',
+ faucet: 'https://faucet2.movementlabs.xyz'
+ });
+ const aptos = new Aptos(aptosConfig);
+ const state = {network_value: "https://aptos.devnet.m1.movementlabs.xyz", aptos_client: aptos}
+
+ const {signAndSubmitTransaction} = useWallet();
useEffect(() => {
if (transactionResponse !== null) {
@@ -39,19 +51,7 @@ const useSubmitTransaction = () => {
}, [transactionResponse]);
async function submitTransaction(transaction: InputTransactionData) {
- console.log("network", network?.name, state.network_name);
- // if (
- // network?.name.toLocaleLowerCase() !==
- // (state.network_name === "local" ? "localhost" : state.network_name)
- // ) {
- // setTransactionResponse({
- // transactionSubmitted: false,
- // message:
- // "Wallet and Explorer should use the same network to submit a transaction",
- // });
- // return;
- // }
-
+
setTransactionInProcess(true);
console.log("submitting transaction", transaction);
@@ -62,7 +62,6 @@ const useSubmitTransaction = () => {
transactionSubmitted: false,
message: "Unknown Error",
};
-
let response;
try {
response = await signAndSubmitTransaction(transaction);
@@ -70,9 +69,12 @@ const useSubmitTransaction = () => {
// transaction submit succeed
if ("hash" in response) {
- await state.aptos_client.waitForTransaction(response["hash"], {
- checkSuccess: true,
- });
+ // await state.aptos_client.waitForTransaction(response["hash"], {
+ // checkSuccess: true,
+ // });
+
+ await state.aptos_client.waitForTransaction(response["hash"]);
+
return {
transactionSubmitted: true,
transactionHash: response["hash"],
diff --git a/packages/nextjs/public/favicon.png b/packages/nextjs/public/favicon.png
deleted file mode 100644
index 4bef7f2..0000000
Binary files a/packages/nextjs/public/favicon.png and /dev/null differ
diff --git a/packages/nextjs/public/logo.png b/packages/nextjs/public/logo.png
new file mode 100644
index 0000000..7c0a2d3
Binary files /dev/null and b/packages/nextjs/public/logo.png differ
diff --git a/packages/nextjs/public/logo.svg b/packages/nextjs/public/logo.svg
deleted file mode 100644
index 93e4b40..0000000
--- a/packages/nextjs/public/logo.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/nextjs/public/manifest.json b/packages/nextjs/public/manifest.json
index bb1c96d..7cc06d6 100644
--- a/packages/nextjs/public/manifest.json
+++ b/packages/nextjs/public/manifest.json
@@ -1,5 +1,5 @@
{
- "name": "Scaffold-ETH 2 DApp",
- "description": "A DApp built with Scaffold-ETH",
- "iconPath": "logo.svg"
+ "name": "Scaffold-Move DApp",
+ "description": "A DApp built with Scaffold-Move",
+ "iconPath": "logo.png"
}
diff --git a/packages/nextjs/scaffold.config.ts b/packages/nextjs/scaffold.config.ts
index 86c737a..6485373 100644
--- a/packages/nextjs/scaffold.config.ts
+++ b/packages/nextjs/scaffold.config.ts
@@ -1,4 +1,6 @@
import * as chains from "viem/chains";
+import {Aptos, AptosConfig, NetworkToNetworkName} from "@aptos-labs/ts-sdk";
+
export type ScaffoldConfig = {
targetNetworks: readonly chains.Chain[];
@@ -10,7 +12,7 @@ export type ScaffoldConfig = {
const scaffoldConfig = {
// The networks on which your DApp is live
- targetNetworks: [chains.hardhat],
+ targetNetworks: [chains.sepolia],
// The interval at which your front-end polls the RPC servers for new data
// it has no effect if you only target the local network (default is 4000)
diff --git a/packages/nextjs/tailwind.config.js b/packages/nextjs/tailwind.config.js
index 2a80f21..9232baa 100644
--- a/packages/nextjs/tailwind.config.js
+++ b/packages/nextjs/tailwind.config.js
@@ -52,7 +52,7 @@ module.exports = {
yellow: "#ffd016",
"base-100": "#1b1f1e",
"base-200": "#121615",
- "base-300": "#121615",
+ "base-300": "#ffd016",
"base-content": "#ffffff",
info: "#385183",
success: "#34EEB6",
diff --git a/packages/nextjs/utils/scaffold-eth/getMetadata.ts b/packages/nextjs/utils/scaffold-eth/getMetadata.ts
index ad531ae..1328064 100644
--- a/packages/nextjs/utils/scaffold-eth/getMetadata.ts
+++ b/packages/nextjs/utils/scaffold-eth/getMetadata.ts
@@ -44,7 +44,7 @@ export const getMetadata = ({
images: [imageUrl],
},
icons: {
- icon: [{ url: "/favicon.png", sizes: "32x32", type: "image/png" }],
+ icon: [{ url: "/logo.png", sizes: "32x32", type: "image/png" }],
},
};
};
diff --git a/packages/nextjs/utils/scaffold-move/contract.ts b/packages/nextjs/utils/scaffold-move/contract.ts
index 4238042..c2b2ef6 100644
--- a/packages/nextjs/utils/scaffold-move/contract.ts
+++ b/packages/nextjs/utils/scaffold-move/contract.ts
@@ -2,6 +2,7 @@ import type { MergeDeepRecord } from "type-fest/source/merge-deep";
import deployedContractsData from "~~/contracts/deployedModules";
import externalContractsData from "~~/contracts/externalModules";
import scaffoldConfig from "~~/scaffold.config";
+import { Types } from "aptos";
type AddExternalFlag = {
@@ -60,7 +61,7 @@ type MoveStruct = {
export type GenericContract = {
bytecode: string;
abi?: GenericContractAbi;
- external?: true;
+ external?: boolean;
};
export type GenericContractAbi = {
@@ -70,7 +71,6 @@ export type GenericContractAbi = {
exposed_functions: MoveFunction[];
structs: MoveStruct[];
}
-
export type GenericContractsDeclaration = {
[chainId: string]: {
[contractName: string]: GenericContract;