minting and getting eth address works
This commit is contained in:
51
tools/getDeployedContracts.mjs
Normal file
51
tools/getDeployedContracts.mjs
Normal file
@ -0,0 +1,51 @@
|
||||
import { runInputOutputs } from "./util.mjs";
|
||||
|
||||
/** ==================== Main ==================== */
|
||||
const INPUT_ROOT =
|
||||
"https://raw.githubusercontent.com/LIT-Protocol/LitNodeContracts/main/";
|
||||
const OUTPUT_FOLDER = "./src/abis/";
|
||||
|
||||
// -- explorer.litprotocol.com
|
||||
const SERRANO = "deployed_contracts_serrano.json";
|
||||
|
||||
// -- mumbai.explorer.litprotocol.com
|
||||
const COLLABLAND = "deployed_contracts_mumbai.json";
|
||||
|
||||
// -- CURRENT USING:
|
||||
const CURRENT = SERRANO;
|
||||
|
||||
runInputOutputs({
|
||||
IOs: [
|
||||
{
|
||||
input: `${INPUT_ROOT}${CURRENT}`,
|
||||
output: `${OUTPUT_FOLDER}deployed-contracts.json`,
|
||||
mappedKey: null,
|
||||
},
|
||||
{
|
||||
input: `${INPUT_ROOT}deployments/mumbai_80001/PKPHelper.json`,
|
||||
output: `${OUTPUT_FOLDER}PKPHelper.json`,
|
||||
mappedKey: "pkpHelperContractAddress",
|
||||
},
|
||||
{
|
||||
input: `${INPUT_ROOT}deployments/mumbai_80001/PKPNFT.json`,
|
||||
output: `${OUTPUT_FOLDER}PKPNFT.json`,
|
||||
mappedKey: "pkpNftContractAddress",
|
||||
},
|
||||
{
|
||||
input: `${INPUT_ROOT}deployments/mumbai_80001/PKPPermissions.json`,
|
||||
output: `${OUTPUT_FOLDER}PKPPermissions.json`,
|
||||
mappedKey: "pkpPermissionsContractAddress",
|
||||
},
|
||||
{
|
||||
input: `${INPUT_ROOT}deployments/mumbai_80001/PubkeyRouter.json`,
|
||||
output: `${OUTPUT_FOLDER}PubKeyRouter.json`,
|
||||
mappedKey: "pubkeyRouterContractAddress",
|
||||
},
|
||||
{
|
||||
input: `${INPUT_ROOT}deployments/mumbai_80001/RateLimitNFT.json`,
|
||||
output: `${OUTPUT_FOLDER}RateLimitNFT.json`,
|
||||
mappedKey: "rateLimitNftContractAddress",
|
||||
},
|
||||
],
|
||||
ignoreProperties: ["metadata", "bytecode", "deployedBytecode"],
|
||||
});
|
47
tools/util.mjs
Normal file
47
tools/util.mjs
Normal file
@ -0,0 +1,47 @@
|
||||
import fs from "fs";
|
||||
import fetch from "node-fetch";
|
||||
|
||||
/** ==================== Helper ==================== */
|
||||
export const writeToFile = (data, filename) => {
|
||||
fs.writeFile(filename, data, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log(`Wrote to ${filename}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const asyncForEach = async (array, callback) => {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
};
|
||||
|
||||
export const runInputOutputs = async ({ IOs, ignoreProperties }) => {
|
||||
let deployedContracts = {};
|
||||
|
||||
await asyncForEach(IOs, async (item, i) => {
|
||||
const { input, output, mappedKey } = item;
|
||||
|
||||
const data = await fetch(input).then((res) => res.text());
|
||||
|
||||
const json = JSON.parse(data);
|
||||
|
||||
if (i <= 0) {
|
||||
deployedContracts = json;
|
||||
}
|
||||
|
||||
await asyncForEach(Object.keys(json), async (key) => {
|
||||
if (ignoreProperties.includes(key)) {
|
||||
delete json[key];
|
||||
}
|
||||
});
|
||||
|
||||
if (mappedKey !== null) {
|
||||
json.address = deployedContracts[mappedKey];
|
||||
}
|
||||
|
||||
writeToFile(JSON.stringify(json, null, 2), output);
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user