-
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.
put back address tmpfiles, change addresses path
- Loading branch information
Showing
8 changed files
with
144 additions
and
122 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 |
---|---|---|
|
@@ -13,5 +13,4 @@ broadcast/ | |
|
||
# Code Editors | ||
.vscode | ||
deployments/**/ | ||
|
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,35 @@ | ||
{ | ||
"printWidth": 100, | ||
"useTabs": false, | ||
"bracketSpacing": true, | ||
"overrides": [ | ||
{ | ||
"files": "*.js", | ||
"options": { | ||
"semi": true, | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"singleQuote": false, | ||
"explicitTypes": "always" | ||
} | ||
}, | ||
{ | ||
"files": "*.ts", | ||
"options": { | ||
"semi": true, | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"singleQuote": false, | ||
"explicitTypes": "always" | ||
} | ||
}, | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"tabWidth": 4, | ||
"singleQuote": false, | ||
"explicitTypes": "always" | ||
} | ||
} | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,105 +1,108 @@ | ||
import { SignatureParam, DeployParams, MasterAddresses, Networks, CommandParams, AddressParams } from "./types"; | ||
import {exec} from "child_process"; | ||
import { | ||
SignatureParam, | ||
DeployParams, | ||
MasterAddresses, | ||
Networks, | ||
CommandParams, | ||
AddressParams, | ||
} from "./types"; | ||
import { exec } from "child_process"; | ||
import addresses from "../addresses_master.json"; | ||
import { writeFileSync, readdirSync, lstatSync } from "fs"; | ||
import { writeFileSync, readdirSync, lstatSync } from "fs"; | ||
import * as networks from "./networks.json"; | ||
import { copyFile } from "fs/promises"; | ||
import path from "path"; | ||
|
||
export function getNetworkRPC(network: string): string { | ||
let n: Networks = networks; | ||
return n[network]; | ||
let n: Networks = networks; | ||
return n[network]; | ||
} | ||
|
||
export async function generateSignature(params: SignatureParam[], ): Promise<string> { | ||
let typeString: string = ""; | ||
let valueString: string = ""; | ||
|
||
if (params.length == 0) { | ||
return "0xc0406226"; | ||
} | ||
export async function generateSignature(params: SignatureParam[]): Promise<string> { | ||
let typeString: string = ""; | ||
let valueString: string = ""; | ||
|
||
params.forEach((param: SignatureParam, i: number) => { | ||
let { type, value } = param; | ||
typeString += type; | ||
valueString += type == "string" ? `"${value}"` : value; | ||
if (i+1 != params.length) { | ||
typeString += ","; | ||
valueString += " "; | ||
} | ||
}) | ||
if (params.length == 0) { | ||
return "0xc0406226"; | ||
} | ||
|
||
let command: string = `cast calldata "run(${typeString})" ${valueString}`; | ||
return await execute(command); | ||
params.forEach((param: SignatureParam, i: number) => { | ||
let { type, value } = param; | ||
typeString += type; | ||
valueString += type == "string" ? `"${value}"` : value; | ||
if (i + 1 != params.length) { | ||
typeString += ","; | ||
valueString += " "; | ||
} | ||
}); | ||
|
||
let command: string = `cast calldata "run(${typeString})" ${valueString}`; | ||
return await execute(command); | ||
} | ||
|
||
export async function execute(command: string): Promise<any> { | ||
return new Promise((resolve) => { | ||
exec(command, (e, r) => { | ||
if (e) { | ||
console.log(e); | ||
return; | ||
} | ||
let res: string = r.replace(/^\s+|\s+$/g, '') | ||
resolve(res); | ||
}); | ||
}) | ||
return new Promise((resolve) => { | ||
exec(command, (e, r) => { | ||
if (e) { | ||
console.log(e); | ||
return; | ||
} | ||
let res: string = r.replace(/^\s+|\s+$/g, ""); | ||
resolve(res); | ||
}); | ||
}); | ||
} | ||
|
||
export function generateForgeCommand(p: CommandParams): string { | ||
return `forge script scripts/${p.contractName}.s.sol:${p.contractName} --fork-url ${p.forkUrl} --private-key ${p.privateKey} --sig ${p.sig} --broadcast -vvvv`; | ||
return `forge script scripts/${p.contractName}.s.sol:${p.contractName} --fork-url ${p.forkUrl} --private-key ${p.privateKey} --sig ${p.sig} --broadcast -vvvv`; | ||
} | ||
|
||
export async function updateAddresses(p: AddressParams): Promise<void> { | ||
await copyFile( | ||
"deployments/addresses_last.example.json", | ||
"deployments/addresses_last.json", | ||
0 | ||
) | ||
let tempAddresses: {[key:string]: string} = require("../../deployments/addresses_last.json"); | ||
let updated: MasterAddresses = addresses; | ||
return new Promise<{ | ||
updated: MasterAddresses, | ||
tempAddresses: {[key:string]: string} | ||
}>(((resolve) => { | ||
let latestLog: string | undefined = getMostRecentFile(`broadcast/${p.contractName}.s.sol/1/`); | ||
if (!latestLog) return; | ||
let json = require(`../../broadcast/${p.contractName}.s.sol/1/${latestLog}`); | ||
json.transactions.forEach((trx: any) => { | ||
if (p.contractName == "DeployCurvePool") { | ||
let { transactionType, address } = trx.additionalContracts[0]; | ||
if (transactionType == "CREATE") { | ||
updated[p.network].core.CurvePool = address; | ||
tempAddresses.CurvePool = address; | ||
} | ||
} else { | ||
if (trx.transactionType == "CREATE") { | ||
let cl = p.contractLabel || trx.contractName; | ||
if (p.isCore) { | ||
updated[p.network].core[cl] = trx.contractAddress; | ||
} else { | ||
updated[p.network].modules[cl] = trx.contractAddress; | ||
} | ||
tempAddresses[cl] = trx.contractAddress; | ||
} | ||
} | ||
}); | ||
resolve({ updated, tempAddresses }) | ||
})).then((res) => { | ||
let { updated, tempAddresses } = res; | ||
writeFileSync("addresses_master.json", JSON.stringify(updated), { flag: "w+" }); | ||
writeFileSync("deployments/addresses_last.json", JSON.stringify(tempAddresses), { flag: "w+" }); | ||
}) | ||
await copyFile("deployments/addresses_last.example.json", "deployments/addresses_last.json", 0); | ||
let tempAddresses: { [key: string]: string } = require("../../deployments/addresses_last.json"); | ||
let updated: MasterAddresses = addresses; | ||
return new Promise<{ | ||
updated: MasterAddresses; | ||
tempAddresses: { [key: string]: string }; | ||
}>((resolve) => { | ||
let latestLog: string | undefined = getMostRecentFile(`broadcast/${p.contractName}.s.sol/1/`); | ||
if (!latestLog) return; | ||
let json = require(`../../broadcast/${p.contractName}.s.sol/1/${latestLog}`); | ||
json.transactions.forEach((trx: any) => { | ||
if (p.contractName == "DeployCurvePool") { | ||
let { transactionType, address } = trx.additionalContracts[0]; | ||
if (transactionType == "CREATE") { | ||
updated[p.network].core.CurvePool = address; | ||
tempAddresses.CurvePool = address; | ||
} | ||
} else { | ||
if (trx.transactionType == "CREATE") { | ||
let cl = p.contractLabel || trx.contractName; | ||
if (p.isCore) { | ||
updated[p.network].core[cl] = trx.contractAddress; | ||
} else { | ||
updated[p.network].modules[cl] = trx.contractAddress; | ||
} | ||
tempAddresses[cl] = trx.contractAddress; | ||
} | ||
} | ||
}); | ||
resolve({ updated, tempAddresses }); | ||
}).then((res) => { | ||
let { updated, tempAddresses } = res; | ||
writeFileSync("addresses.json", JSON.stringify(updated), { flag: "w+" }); | ||
writeFileSync("deployments/addresses_last.json", JSON.stringify(tempAddresses), { flag: "w+" }); | ||
}); | ||
} | ||
|
||
function getMostRecentFile(dir: string): string | undefined { | ||
const files = orderRecentFiles(dir); | ||
return files.length ? files[0].file : undefined; | ||
} | ||
|
||
function getMostRecentFile(dir: string): string | undefined{ | ||
const files = orderRecentFiles(dir); | ||
return files.length ? files[0].file : undefined; | ||
}; | ||
|
||
function orderRecentFiles(dir: string): {file: string, mtime: Date}[] { | ||
return readdirSync(dir) | ||
.filter((file) => lstatSync(path.join(dir, file)).isFile()) | ||
.map((file) => ({ file, mtime: lstatSync(path.join(dir, file)).mtime })) | ||
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime()); | ||
}; | ||
function orderRecentFiles(dir: string): { file: string; mtime: Date }[] { | ||
return readdirSync(dir) | ||
.filter((file) => lstatSync(path.join(dir, file)).isFile()) | ||
.map((file) => ({ file, mtime: lstatSync(path.join(dir, file)).mtime })) | ||
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime()); | ||
} |
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,4 @@ | ||
{ | ||
"phoGovernance": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
"tonGovernance": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" | ||
} |
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,16 @@ | ||
{ | ||
"phoGovernance": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
"tonGovernance": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
"PHO": "0xb9A62F59F8c1359E24830e4FD209954E21B7DF37", | ||
"TON": "0x8e32b3a6D82DdD3a5d9E327eBAe8FE1e8a5Ba61e", | ||
"Kernel": "0xB5D6528752d60E23137fe088380dA24BDe347eb3", | ||
"ModuleManager": "0xd3aAA70197b22116c6732a964edC09C853AaC941", | ||
"ChainlinkPriceFeed": "0x72b46c86aA67f2aBa435414f410bb48300C064Bf", | ||
"CurvePool": "0xC61557C5d177bd7DC889A3b621eEC333e168f68A", | ||
"PriceController": "0xCDa53a4bCEefbB873581d2206316a439a7498172", | ||
"StablecoinDepositModuleUSDC": "0x6d824682aA66da4e6738c6f3e16cC15fe9ce6F79", | ||
"StablecoinDepositModuleFRAX": "0x81D0043Fa848D07A36899388E46765aeA0e11a6b", | ||
"StablecoinDepositModuleLUSD": "0xc9fb11FEEbf439cEb7E04D94FDd4A0314F01c597", | ||
"MapleDepositModuleUSDC": "0x406e5D7dDaA4029eB8B957aD7677c63e15c28AC7", | ||
"ZCBModuleUSDC": "0x2EeA9517B018B2f63072a9729ceC3EE524809460" | ||
} |
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