forked from Avelous/Eth-Splitter
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migreate to wagmiV1 and viem and daisy v3
- Loading branch information
1 parent
8b20603
commit f23ba1a
Showing
86 changed files
with
3,640 additions
and
2,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/dist/esm/useLocalStorage/useLocalStorage.js b/dist/esm/useLocalStorage/useLocalStorage.js | ||
index b0d584d4df29953551dfcf8febac002f89fa7acd..920ae5c52d28af73e3a892bdb935a7805a0f8224 100644 | ||
--- a/dist/esm/useLocalStorage/useLocalStorage.js | ||
+++ b/dist/esm/useLocalStorage/useLocalStorage.js | ||
@@ -14,7 +14,7 @@ function useLocalStorage(key, initialValue) { | ||
return initialValue; | ||
} | ||
}, [initialValue, key]); | ||
- const [storedValue, setStoredValue] = useState(readValue); | ||
+ const [storedValue, setStoredValue] = useState(initialValue); | ||
const setValue = useEventCallback(value => { | ||
if (typeof window === 'undefined') { | ||
console.warn(`Tried setting localStorage key “${key}” even though environment is not a client`); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* DON'T MODIFY OR DELETE THIS SCRIPT (unless you know what you're doing) | ||
* | ||
* This script generates the file containing the contracts Abi definitions. | ||
* These definitions are used to derive the types needed in the custom scaffold-eth hooks, for example. | ||
* This script should run as the last deploy script. | ||
* */ | ||
|
||
import * as fs from "fs"; | ||
import prettier from "prettier"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
|
||
function getDirectories(path: string) { | ||
return fs | ||
.readdirSync(path, { withFileTypes: true }) | ||
.filter(dirent => dirent.isDirectory()) | ||
.map(dirent => dirent.name); | ||
} | ||
|
||
function getContractNames(path: string) { | ||
return fs | ||
.readdirSync(path, { withFileTypes: true }) | ||
.filter(dirent => dirent.isFile() && dirent.name.endsWith(".json")) | ||
.map(dirent => dirent.name.split(".")[0]); | ||
} | ||
|
||
const DEPLOYMENTS_DIR = "./deployments"; | ||
|
||
function getContractDataFromDeployments() { | ||
if (!fs.existsSync(DEPLOYMENTS_DIR)) { | ||
throw Error("At least one other deployment script should exist to generate an actual contract."); | ||
} | ||
const output = {} as Record<string, any>; | ||
for (const chainName of getDirectories(DEPLOYMENTS_DIR)) { | ||
const chainId = fs.readFileSync(`${DEPLOYMENTS_DIR}/${chainName}/.chainId`).toString(); | ||
const contracts = {} as Record<string, any>; | ||
for (const contractName of getContractNames(`${DEPLOYMENTS_DIR}/${chainName}`)) { | ||
const { abi, address } = JSON.parse( | ||
fs.readFileSync(`${DEPLOYMENTS_DIR}/${chainName}/${contractName}.json`).toString(), | ||
); | ||
contracts[contractName] = { address, abi }; | ||
} | ||
output[chainId] = [ | ||
{ | ||
chainId, | ||
name: chainName, | ||
contracts, | ||
}, | ||
]; | ||
} | ||
return output; | ||
} | ||
|
||
/** | ||
* Generates the TypeScript contract definition file based on the json output of the contract deployment scripts | ||
* This script should be run last. | ||
*/ | ||
const generateTsAbis: DeployFunction = async function () { | ||
const TARGET_DIR = "../nextjs/generated/"; | ||
const allContractsData = getContractDataFromDeployments(); | ||
|
||
const fileContent = Object.entries(allContractsData).reduce((content, [chainId, chainConfig]) => { | ||
return `${content}${parseInt(chainId).toFixed(0)}:${JSON.stringify(chainConfig, null, 2)},`; | ||
}, ""); | ||
|
||
if (!fs.existsSync(TARGET_DIR)) { | ||
fs.mkdirSync(TARGET_DIR); | ||
} | ||
fs.writeFileSync( | ||
`${TARGET_DIR}deployedContracts.ts`, | ||
prettier.format(`const contracts = {${fileContent}} as const; \n\n export default contracts`, { | ||
parser: "typescript", | ||
}), | ||
); | ||
|
||
console.log(`📝 Updated TypeScript contract definition file on ${TARGET_DIR}deployedContracts.ts`); | ||
}; | ||
|
||
export default generateTsAbis; | ||
|
||
// Tags are useful if you have multiple deploy files and only want to run one of them. | ||
// e.g. yarn deploy --tags generateTsAbis | ||
generateTsAbis.tags = ["generateTsAbis"]; | ||
|
||
generateTsAbis.runAtTheEnd = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.