hardhat#artifacts TypeScript Examples
The following examples show how to use
hardhat#artifacts.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: report-rename-retype.test.ts From openzeppelin-upgrades with MIT License | 6 votes |
test.before(async t => {
const contracts: Record<string, ContractDefinition> = {};
const deref: Record<string, ASTDereferencer> = {};
const storageLayout: Record<string, StorageLayout> = {};
for (const contract of testContracts) {
const buildInfo = await artifacts.getBuildInfo(contract);
if (buildInfo === undefined) {
throw new Error(`Build info not found for contract ${contract}`);
}
const solcOutput = buildInfo.output;
for (const def of findAll('ContractDefinition', solcOutput.sources['contracts/test/RenamedRetyped.sol'].ast)) {
contracts[def.name] = def;
deref[def.name] = astDereferencer(solcOutput);
storageLayout[def.name] = (
solcOutput.contracts['contracts/test/RenamedRetyped.sol'][def.name] as any
).storageLayout;
}
}
t.context.extractStorageLayout = name =>
extractStorageLayout(contracts[name], dummyDecodeSrc, deref[name], storageLayout[name]);
});
Example #2
Source File: MetaTxGatewaySpec.ts From perpetual-protocol with GNU General Public License v3.0 | 6 votes |
async before(): Promise<void> {
const accounts = await web3.eth.getAccounts()
this.admin = accounts[0]
this.alice = accounts[1]
this.relayer = accounts[2]
this.l1ChainId = 1234
const MetaTxRecipientMockArtifact = await artifacts.readArtifact(
"src/mock/mocks/MetaTxRecipientMock.sol:MetaTxRecipientMock",
)
this.metaTxGateway = await deployMetaTxGateway("Test", "1", this.l1ChainId)
this.metaTxRecipientMock = ((await new web3.eth.Contract(MetaTxRecipientMockArtifact.abi)
.deploy({
data: MetaTxRecipientMockArtifact.bytecode,
arguments: [this.metaTxGateway.address],
})
.send({
from: this.admin,
})) as unknown) as MetaTxRecipientMock
await this.metaTxGateway.addToWhitelists(this.metaTxRecipientMock.options.address)
this.domain = {
name: "Test",
version: "1",
chainId: this.l1ChainId,
verifyingContract: this.metaTxGateway.address,
}
}
Example #3
Source File: standalone.test.ts From openzeppelin-upgrades with MIT License | 5 votes |
test.before(async t => {
const buildInfo = await artifacts.getBuildInfo('contracts/test/Standalone.sol:StandaloneV1');
if (buildInfo === undefined) {
throw new Error('Build info not found');
}
t.context.solcInput = buildInfo.input;
t.context.solcOutput = buildInfo.output;
});
Example #4
Source File: check-chainlink.ts From perpetual-protocol with GNU General Public License v3.0 | 5 votes |
export async function checkChainlink(address: string, env: HardhatRuntimeEnvironment): Promise<void> {
const AGGREGATOR_ABI = [
"function decimals() view returns (uint8)",
"function description() view returns (string memory)",
"function latestAnswer() external view returns (int256)",
]
const aggregator = await env.ethers.getContractAt(AGGREGATOR_ABI, address)
const chainlinkL1Artifact = await artifacts.readArtifact(ContractFullyQualifiedName.ChainlinkL1)
const chainlinkInterface = new Interface(chainlinkL1Artifact.abi)
const l2PriceFeedArtifact = await artifacts.readArtifact(ContractFullyQualifiedName.L2PriceFeed)
const l2PriceFeedInterface = new Interface(l2PriceFeedArtifact.abi)
const [decimals, pair, latestPrice] = await Promise.all([
aggregator.decimals(),
aggregator.description(),
aggregator.latestAnswer(),
])
const [baseSymbol, quoteSymbol] = pair.split("/").map((symbol: string) => symbol.trim())
const priceFeedKey = formatBytes32String(baseSymbol)
const functionDataL1 = chainlinkInterface.encodeFunctionData("addAggregator", [priceFeedKey, address])
const functionDataL2 = l2PriceFeedInterface.encodeFunctionData("addAggregator", [priceFeedKey])
const metadataSet = await getContractMetadataSet(env.network.name)
const filename = `addAggregator_${env.network.name}.txt`
const latestPriceNum = Number.parseFloat(formatUnits(latestPrice, decimals))
const lines = [
`pair: ${pair}`,
`base symbol: ${baseSymbol}`,
`quote symbol: ${quoteSymbol}`,
`latest price: ${latestPriceNum}`,
`maxHoldingBaseAsset (personal): ${100_000 / latestPriceNum}`,
`openInterestNotionalCap (total): 2_000_000`,
``,
`price feed key: ${priceFeedKey}`,
`aggregator address: ${address}`,
`functionData(ChainlinkL1,ChainlinkPriceFeed): ${functionDataL1}`,
`functionData(L2PriceFeed): ${functionDataL2}`,
"",
"Copy lines below to setup environment variables:",
`export ${env.network.name.toUpperCase()}_TOKEN_SYMBOL=${baseSymbol}`,
`export ${env.network.name.toUpperCase()}_PRICE_FEED_KEY=${priceFeedKey}`,
"",
`ABI information for gnosis safe is saved to ${filename}`,
]
const aggregatorInfoLines = [
`ChainlinkL1 abi: ${metadataSet.ChainlinkL1.abi}`,
`ChainlinkL1 proxy address: ${metadataSet.ChainlinkL1.proxy}`,
"",
`L2PriceFeed abi: ${metadataSet.L2PriceFeed.abi}`,
`L2PriceFeed proxy address: ${metadataSet.L2PriceFeed.proxy}`,
"",
`InsuranceFund abi: ${metadataSet.InsuranceFund.abi}`,
`InsuranceFund proxy address: ${metadataSet.InsuranceFund.proxy}`,
]
await fs.promises.writeFile(filename, aggregatorInfoLines.join("\n"))
console.log(lines.join("\n"))
}
Example #5
Source File: manifest-storage-layout.test.ts From openzeppelin-upgrades with MIT License | 5 votes |
test.before(async t => {
const buildInfo = await artifacts.getBuildInfo('contracts/test/ManifestMigrate.sol:ManifestMigrateUnique');
assert(buildInfo !== undefined, 'Build info not found');
const decodeSrc = solcInputOutputDecoder(buildInfo.input, buildInfo.output);
t.context.validationRun = validate(buildInfo.output, decodeSrc);
t.context.validationData = normalizeValidationData([t.context.validationRun]);
});
Example #6
Source File: contract.ts From perpetual-protocol with GNU General Public License v3.0 | 5 votes |
RootBridge = artifacts.require("RootBridge") as RootBridgeContract