forked from greenpill-dev-guild/camp-green
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:greenpill-dev-guild/green-goods int…
…o contracts/attestations
- Loading branch information
Showing
16 changed files
with
400 additions
and
61 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,9 @@ | ||
{ | ||
"[solidity]": { | ||
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity" | ||
}, | ||
"[toml]": { | ||
"editor.defaultFormatter": "tamasfe.even-better-toml" | ||
}, | ||
"solidity.formatter": "forge" | ||
} |
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 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,19 @@ | ||
# EditorConfig http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# All files | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.sol] | ||
indent_size = 4 | ||
|
||
[*.tree] | ||
indent_size = 1 |
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,5 @@ | ||
export API_KEY_ALCHEMY="YOUR_API_KEY_ALCHEMY" | ||
export API_KEY_ARBISCAN="YOUR_API_KEY_ARBISCAN" | ||
export API_KEY_INFURA="YOUR_API_KEY_INFURA" | ||
export PRIVATE_KEY="YOUR_MNEMONIC" | ||
export FOUNDRY_PROFILE="default" |
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 |
---|---|---|
@@ -1,35 +1,24 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
|
||
# directories | ||
cache | ||
coverage | ||
node_modules | ||
dist | ||
dev-dist | ||
.DS_Store | ||
DS_Store | ||
|
||
node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
out | ||
|
||
# production | ||
|
||
build | ||
|
||
# local env files | ||
|
||
.env\*.local | ||
.env | ||
# files | ||
*.env | ||
*.log | ||
.DS_Store | ||
.pnp.* | ||
lcov.info | ||
package-lock.json | ||
pnpm-lock.yaml | ||
yarn.lock | ||
|
||
# forge | ||
out/ | ||
cache/ | ||
cache_hardhat/ | ||
node_modules/ | ||
bindings/ | ||
artifacts/ | ||
# broadcasts | ||
!broadcast | ||
broadcast/* | ||
broadcast/*/31337/ | ||
|
||
# Ignore MUD deploy artifacts | ||
deploys/**/*.json | ||
|
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 |
---|---|---|
@@ -1,5 +1,17 @@ | ||
dist | ||
node_modules | ||
contracts/out | ||
contracts/cache | ||
# directories | ||
broadcast | ||
cache | ||
coverage | ||
node_modules | ||
out | ||
|
||
# files | ||
*.env | ||
*.log | ||
.DS_Store | ||
.pnp.* | ||
bun.lockb | ||
lcov.info | ||
package-lock.json | ||
pnpm-lock.yaml | ||
yarn.lock |
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
{ | ||
"bracketSpacing": true, | ||
"printWidth": 120, | ||
"proseWrap": "always", | ||
"singleQuote": false, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"trailingComma": "all" | ||
"trailingComma": "all", | ||
"useTabs": false | ||
} |
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 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
ds-test=./node_modules/ds-test/src/ | ||
forge-std=./node_modules/forge-std/src/ | ||
@openzeppelin/contracts=./node_modules/@openzeppelin/contracts/ | ||
@openzeppelin/contracts-upgradeable=./node_modules/@openzeppelin/contracts-upgradeable/ | ||
eas-contracts=./node_modules/@ethereum-attestation-service/eas-contracts/contracts/ | ||
forge-std=./node_modules/forge-std/src/ | ||
ds-test=./node_modules/ds-test/src/ | ||
tokenbound=./lib/tokenbound/src/ | ||
@eas=./node_modules/@ethereum-attestation-service/eas-contracts/contracts/ | ||
@tokenbound=./lib/tokenbound/src/ |
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,68 @@ | ||
const dotenv = require("dotenv"); | ||
dotenv.config(); | ||
const path = require("path"); | ||
const { ethers, Wallet } = require("ethers"); | ||
const QRCode = require("qrcode"); | ||
const fs = require("fs"); | ||
const toml = require("toml"); | ||
|
||
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY || "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF"; | ||
|
||
async function getBalanceForEachNetwork(address) { | ||
try { | ||
// Read the foundry.toml file | ||
const foundryTomlPath = path.join(__dirname, "..", "foundry.toml"); | ||
const tomlString = fs.readFileSync(foundryTomlPath, "utf-8"); | ||
|
||
// Parse the tomlString to get the JS object representation | ||
const parsedToml = toml.parse(tomlString); | ||
|
||
// Extract rpc_endpoints from parsedToml | ||
const rpcEndpoints = parsedToml.rpc_endpoints; | ||
|
||
// Replace placeholders in the rpc_endpoints section | ||
function replaceENVAlchemyKey(input) { | ||
return input.replace("${ALCHEMY_API_KEY}", ALCHEMY_API_KEY); | ||
} | ||
|
||
for (const networkName in rpcEndpoints) { | ||
if (networkName === "localhost" || networkName === "default_network") continue; | ||
|
||
const networkUrl = replaceENVAlchemyKey(rpcEndpoints[networkName]); | ||
|
||
try { | ||
const provider = new ethers.providers.JsonRpcProvider(networkUrl); | ||
const balance = await provider.getBalance(address); | ||
console.log("--", networkName, "-- 📡"); | ||
console.log(" balance:", +ethers.utils.formatEther(balance)); | ||
console.log(" nonce:", +(await provider.getTransactionCount(address))); | ||
} catch (e) { | ||
console.log("Can't connect to network", networkName); | ||
console.log(); | ||
} | ||
} | ||
} catch (error) { | ||
console.error("Error reading foundry.toml:", error); | ||
} | ||
} | ||
async function main() { | ||
const privateKey = process.env.DEPLOYER_PRIVATE_KEY; | ||
|
||
if (!privateKey) { | ||
console.log("🚫️ You don't have a deployer account. Run `yarn generate` first"); | ||
return; | ||
} | ||
|
||
// Get account from private key. | ||
const wallet = new Wallet(privateKey); | ||
const address = wallet.address; | ||
console.log(await QRCode.toString(address, { type: "terminal", small: true })); | ||
console.log("Public address:", address, "\n"); | ||
|
||
await getBalanceForEachNetwork(address); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
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,49 @@ | ||
const ethers = require("ethers"); | ||
const { parse, stringify } = require("envfile"); | ||
const fs = require("fs"); | ||
|
||
const envFilePath = "./.env"; | ||
|
||
/** | ||
* Generate a new random private key and write it to the .env file | ||
* @param existingEnvConfig | ||
*/ | ||
const setNewEnvConfig = (existingEnvConfig = {}) => { | ||
console.log("👛 Generating new Wallet"); | ||
const randomWallet = ethers.Wallet.createRandom(); | ||
|
||
const newEnvConfig = { | ||
...existingEnvConfig, | ||
DEPLOYER_PRIVATE_KEY: randomWallet.privateKey, | ||
}; | ||
|
||
// Store in .env | ||
fs.writeFileSync(envFilePath, stringify(newEnvConfig)); | ||
console.log("📄 Private Key saved to packages/foundry/.env file"); | ||
console.log("🪄 Generated wallet address:", randomWallet.address); | ||
}; | ||
|
||
async function main() { | ||
if (!fs.existsSync(envFilePath)) { | ||
console.log("entered here"); | ||
// No .env file yet. | ||
setNewEnvConfig(); | ||
return; | ||
} | ||
|
||
// .env file exists | ||
const existingEnvConfig = parse(fs.readFileSync(envFilePath).toString()); | ||
if (existingEnvConfig.DEPLOYER_PRIVATE_KEY) { | ||
console.log( | ||
"⚠️ You already have a deployer account. Check the packages/foundry/.env file" | ||
); | ||
return; | ||
} | ||
|
||
setNewEnvConfig(existingEnvConfig); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
Oops, something went wrong.