Skip to content

Commit

Permalink
fix: deployment script with ERC20Conversion v2 and Swap (#751)
Browse files Browse the repository at this point in the history
* fix: deployment script with ERC20Conversion v2 and Swap
* chore: Erc20ConversionProxy 0.1.1 abi and deployment
* chore: edit ERC20SwapToConversion ABI for early deployment compatibility
* feat: deployment artifact ERC20Conversion arbitrum
  • Loading branch information
yomarion committed Feb 1, 2022
1 parent 942a134 commit 3b97506
Show file tree
Hide file tree
Showing 13 changed files with 529 additions and 172 deletions.
4 changes: 4 additions & 0 deletions packages/smart-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ const setExplorerApiKey = (hre: HardhatRuntimeEnvironment) => {
hre.config.etherscan.apiKey = process.env.FTMSCAN_API_KEY;
return;
}
case 'arbitrum-one': {
hre.config.etherscan.apiKey = process.env.ARBISCAN_API_KEY;
return;
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default async function deploy(
...args,
conversionProxyAddress: erc20ConversionAddress,
swapProxyAddress: localSwapRouterAddress,
chainlinkConversionPathAddress: conversionPathInstance.address,
},
hre,
);
Expand Down
19 changes: 15 additions & 4 deletions packages/smart-contracts/scripts/conversion-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { HardhatRuntimeEnvironment } from 'hardhat/types';
// eslint-disable-next-line
// @ts-ignore Cannot find module
import { Erc20ConversionProxy } from '../src/types/Erc20ConversionProxy';
import {
erc20ConversionProxy as erc20ConversionProxyArtifact,
ethConversionArtifact,
} from '../src/lib';
import { DeploymentResult, deployOne } from './deploy-one';
import { deployOne } from './deploy-one';
import { CurrencyManager } from '@requestnetwork/currency';
import { RequestLogicTypes } from '@requestnetwork/types';

export async function deployERC20ConversionProxy(
args: { chainlinkConversionPathAddress?: string; erc20FeeProxyAddress?: string },
args: {
chainlinkConversionPathAddress?: string;
erc20FeeProxyAddress?: string;
nonceCondition?: number;
},
hre: HardhatRuntimeEnvironment,
): Promise<DeploymentResult | undefined> {
) {
const contractName = 'Erc20ConversionProxy';

if (!args.chainlinkConversionPathAddress) {
Expand All @@ -26,16 +33,19 @@ export async function deployERC20ConversionProxy(
return undefined;
}

return deployOne(args, hre, contractName, {
return deployOne<Erc20ConversionProxy>(args, hre, contractName, {
constructorArguments: [args.erc20FeeProxyAddress, args.chainlinkConversionPathAddress],
artifact: erc20ConversionProxyArtifact,
nonceCondition: args.nonceCondition,
version: '0.1.1',
});
}

export async function deployETHConversionProxy(
args: {
chainlinkConversionPathAddress?: string;
ethFeeProxyAddress?: string;
nonceCondition?: number;
},
hre: HardhatRuntimeEnvironment,
) {
Expand Down Expand Up @@ -74,5 +84,6 @@ export async function deployETHConversionProxy(
nativeTokenHash,
],
artifact: ethConversionArtifact,
nonceCondition: args.nonceCondition,
});
}
10 changes: 8 additions & 2 deletions packages/smart-contracts/scripts/deploy-one.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const SKIPPED_DEPLOYMENT: DeploymentResult<unknown> = {
* @options
* - options.verify: set false to prevent verification on live networks
* - options.nonceCondition: only proceeds with the deployment if the nonce matches
* - options.version: to deploy or map a version different from the last version
* @returns a deployment result with address =
* - The address if the contract is deployed or attached
* - 'simulated' if args.simulate === true (no deployment/)
Expand All @@ -48,6 +49,7 @@ export async function deployOne<TContract extends Contract>(
artifact?: ContractArtifact<Contract>;
verify?: boolean;
nonceCondition?: number;
version?: string;
},
): Promise<DeploymentResult<TContract>> {
const [deployer] = await hre.ethers.getSigners();
Expand All @@ -56,9 +58,13 @@ export async function deployOne<TContract extends Contract>(
const constructorArguments = options?.constructorArguments ?? [];
if (options?.artifact) {
try {
address = options.artifact.getAddress(hre.network.name);
address = options.artifact.getAddress(hre.network.name, options.version);
const action = args.force ? '(forcing deployment)' : '(skipping)';
console.log(`Found ${contractName} on ${hre.network.name} at address: ${address} ${action}`);
console.log(
`Found ${contractName}${options.version ? ` v${options.version}` : ''} on ${
hre.network.name
} at address: ${address} ${action}`,
);
if (!args.force) {
return {
address,
Expand Down
Loading

0 comments on commit 3b97506

Please sign in to comment.