-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Local fork deployment test for andromeda
- Loading branch information
Showing
26 changed files
with
212 additions
and
143 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
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 util = require('util'); | ||
const path = require('path'); | ||
const { ethers } = require('ethers'); | ||
|
||
util.inspect.defaultOptions.depth = null; | ||
util.inspect.defaultOptions.maxArrayLength = null; | ||
|
||
const fgReset = '\x1b[0m'; | ||
const fgRed = '\x1b[31m'; | ||
const fgGreen = '\x1b[32m'; | ||
const fgYellow = '\x1b[33m'; | ||
const fgCyan = '\x1b[36m'; | ||
|
||
ethers.BigNumber.prototype[util.inspect.custom] = function (depth, inspectOptions, inspect) { | ||
return `${fgCyan}BigNumber( ${fgYellow}${fgGreen}${this.toHexString()} ${fgYellow}${this.toString()}${fgCyan} )${fgReset}`; | ||
}; | ||
|
||
const [txnsFile] = process.argv.slice(2); | ||
if (!txnsFile) { | ||
console.error(`${fgRed}ERROR: Expected 1 argument${fgReset}`); | ||
console.error(`Usage: ${fgCyan}node e2e/deploy.js "TXNS_FILE"${fgReset}`); | ||
console.error( | ||
`Example: ${fgGreen}node e2e/deploy.js "./upgrade--base-goerli-andromeda.json"${fgReset}` | ||
); | ||
process.exit(1); | ||
} | ||
console.log(`Loading update transactions from ${fgGreen}"${txnsFile}"${fgReset}`); | ||
const upgrade = require(path.resolve(txnsFile)); | ||
|
||
async function run() { | ||
const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); | ||
for (const { hash, from, to, data, value } of upgrade.txns) { | ||
// console.log(`provider`, provider); | ||
console.log(); | ||
console.log(); | ||
console.log(); | ||
console.log('============================================================================'); | ||
console.log({ hash, from, to, data, value }); | ||
await provider.send('anvil_setBalance', [from, ethers.utils.parseEther('10').toHexString()]); | ||
await provider.send('anvil_impersonateAccount', [from]); | ||
const signer = provider.getSigner(from); | ||
const tx = await signer.sendTransaction({ to, data, value }); | ||
const result = await tx.wait(); | ||
console.log(result); | ||
await provider.send('anvil_stopImpersonatingAccount', [from]); | ||
console.log('============================================================================'); | ||
} | ||
} | ||
run(); |
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,95 @@ | ||
#!/usr/bin/env node | ||
|
||
const os = require('os'); | ||
const path = require('path'); | ||
const fs = require('fs/promises'); | ||
const toml = require('@iarna/toml'); | ||
const { ethers } = require('ethers'); | ||
const { LocalRegistry } = require('@usecannon/cli/dist/src/registry'); | ||
const { CliLoader } = require('@usecannon/cli/dist/src/loader'); | ||
const CANNON_DIRECTORY = path.join(os.homedir(), '.local', 'share', 'cannon'); | ||
|
||
const fgReset = '\x1b[0m'; | ||
const fgRed = '\x1b[31m'; | ||
const fgGreen = '\x1b[32m'; | ||
const fgYellow = '\x1b[33m'; | ||
const fgCyan = '\x1b[36m'; | ||
|
||
const [chainId, deploymentFile] = process.argv.slice(2); | ||
if (!chainId || !deploymentFile) { | ||
console.error(`${fgRed}ERROR: Expected 2 arguments${fgReset}`); | ||
console.error( | ||
`Usage: ${fgGreen}node e2e/fetch-local-deployment.js ${fgYellow}chainId ${fgCyan}deploymentFile${fgReset}` | ||
); | ||
console.error( | ||
`Example: ${fgGreen}node e2e/fetch-local-deployment.js ${fgYellow}84531 ${fgCyan}omnibus-base-goerli-andromeda.toml${fgReset}` | ||
); | ||
process.exit(1); | ||
} | ||
|
||
function readableAbi(abi) { | ||
return new ethers.utils.Interface(abi).format(ethers.utils.FormatTypes.full); | ||
} | ||
|
||
async function run() { | ||
const config = await fs.readFile(deploymentFile, 'utf8'); | ||
const { name, version, setting } = toml.parse(config); | ||
const preset = setting?.target_preset?.defaultValue ?? 'main'; | ||
|
||
console.log('Resolving URL', { | ||
packageRef: `${name}:${version}`, | ||
variant: `${chainId}-${preset}`, | ||
}); | ||
const localRegistry = new LocalRegistry(CANNON_DIRECTORY); | ||
const url = await await localRegistry.getUrl(`${name}:${version}`, `${chainId}-${preset}`); | ||
console.log(`Resolved URL:`, { url }); | ||
|
||
console.log('Fetching deployment state', { url }); | ||
const deployments = JSON.parse( | ||
await fs.readFile(`${CANNON_DIRECTORY}/ipfs_cache/${CliLoader.getCacheHash(url)}.json`, 'utf8') | ||
); | ||
|
||
await fs.mkdir(`${__dirname}/deployments`, { recursive: true }); | ||
|
||
const snxAddress = setting?.snx_address?.defaultValue ?? ethers.constants.AddressZero; | ||
await fs.writeFile( | ||
`${__dirname}/deployments/snx.json`, | ||
JSON.stringify({ address: snxAddress }, null, 2) | ||
); | ||
|
||
const system = deployments.state['provision.system'].artifacts.imports.system; | ||
await fs.writeFile( | ||
`${__dirname}/deployments/CoreProxy.json`, | ||
JSON.stringify( | ||
{ | ||
address: system.contracts.CoreProxy.address, | ||
abi: readableAbi(system.contracts.CoreProxy.abi), | ||
}, | ||
null, | ||
2 | ||
) | ||
); | ||
|
||
async function mintableToken(provisionStep) { | ||
const fakeCollateral = | ||
deployments?.state?.[`provision.${provisionStep}`]?.artifacts?.imports?.[provisionStep]; | ||
if (fakeCollateral) { | ||
const [, ticker] = fakeCollateral.contracts.MintableToken.constructorArgs; | ||
await fs.writeFile( | ||
`${__dirname}/deployments/FakeCollateral${ticker}.json`, | ||
JSON.stringify( | ||
{ | ||
address: fakeCollateral.contracts.MintableToken.address, | ||
abi: readableAbi(fakeCollateral.contracts.MintableToken.abi), | ||
}, | ||
null, | ||
2 | ||
) | ||
); | ||
} | ||
} | ||
await mintableToken('usdc_mock_collateral'); | ||
await mintableToken('mintableToken'); | ||
} | ||
|
||
run(); |
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
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.