ethers/lib/utils#FormatTypes TypeScript Examples
The following examples show how to use
ethers/lib/utils#FormatTypes.
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: deploy-impl.ts From openzeppelin-upgrades with MIT License | 6 votes |
async function deployImpl(
deployData: DeployData,
ImplFactory: ContractFactory,
opts: UpgradeProxyOptions,
currentImplAddress?: string,
): Promise<any> {
assertUpgradeSafe(deployData.validations, deployData.version, deployData.fullOpts);
const layout = deployData.layout;
if (currentImplAddress !== undefined) {
const manifest = await Manifest.forNetwork(deployData.provider);
const currentLayout = await getStorageLayoutForAddress(manifest, deployData.validations, currentImplAddress);
if (opts.unsafeSkipStorageCheck !== true) {
assertStorageUpgradeSafe(currentLayout, deployData.layout, deployData.fullOpts);
}
}
const impl = await fetchOrDeploy(
deployData.version,
deployData.provider,
async () => {
const abi = ImplFactory.interface.format(FormatTypes.minimal) as string[];
const deployment = Object.assign({ abi }, await deploy(ImplFactory, ...deployData.fullOpts.constructorArgs));
return { ...deployment, layout };
},
opts,
);
return { impl, kind: opts.kind };
}
Example #2
Source File: simulate-deploy.ts From openzeppelin-upgrades with MIT License | 6 votes |
/**
* Gets data for a simulated deployment of the given contract to the given address.
*/
async function getSimulatedData(
hre: HardhatRuntimeEnvironment,
ImplFactory: ContractFactory,
opts: Options,
implAddress: string,
) {
const deployData = await getDeployData(hre, ImplFactory, opts);
const simulateDeploy = async () => {
return {
abi: ImplFactory.interface.format(FormatTypes.minimal) as string[],
layout: deployData.layout,
address: implAddress,
};
};
return { deployData, simulateDeploy };
}
Example #3
Source File: propose-upgrade.ts From openzeppelin-upgrades with MIT License | 5 votes |
export function makeProposeUpgrade(hre: HardhatRuntimeEnvironment): ProposeUpgradeFunction {
return async function proposeUpgrade(proxyAddress, ImplFactory, opts = {}) {
if (!hre.config.defender) {
throw new Error(`Missing Defender API key and secret in hardhat config`);
}
const client = new AdminClient(hre.config.defender);
const chainId = await getChainId(hre.network.provider);
const network = fromChainId(chainId);
if (network === undefined) {
throw new Error(`Network ${chainId} is not supported in Defender Admin`);
}
const { title, description, proxyAdmin, multisig, multisigType, ...moreOpts } = opts;
if (await isBeaconProxy(hre.network.provider, proxyAddress)) {
throw new Error(`Beacon proxy is not currently supported with defender.proposeUpgrade()`);
} else if (await isBeacon(hre.network.provider, proxyAddress)) {
throw new Error(`Beacon is not currently supported with defender.proposeUpgrade()`);
} else if (
!multisig &&
(await isTransparentOrUUPSProxy(hre.network.provider, proxyAddress)) &&
!(await isTransparentProxy(hre.network.provider, proxyAddress))
) {
throw new Error(`Multisig address is a required property for UUPS proxies`);
} else {
// try getting the implementation address so that it will give an error if it's not a transparent/uups proxy
await getImplementationAddress(hre.network.provider, proxyAddress);
}
const newImplementation = await hre.upgrades.prepareUpgrade(proxyAddress, ImplFactory, moreOpts);
const contract = { address: proxyAddress, network, abi: ImplFactory.interface.format(FormatTypes.json) as string };
return client.proposeUpgrade(
{
newImplementation,
title,
description,
proxyAdmin,
via: multisig,
viaType: multisigType,
},
contract,
);
};
}