mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Fixed automated contracts verification at Polygon
This commit is contained in:
parent
d673d54f75
commit
7b757e340a
|
@ -42,6 +42,6 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
|
|||
[eEthereumNetwork.buidlerevm]: 65 * GWEI,
|
||||
[eEthereumNetwork.tenderlyMain]: 0.01 * GWEI,
|
||||
[ePolygonNetwork.mumbai]: 1 * GWEI,
|
||||
[ePolygonNetwork.matic]: 2 * GWEI,
|
||||
[ePolygonNetwork.matic]: 1 * GWEI,
|
||||
[eXDaiNetwork.xdai]: 1 * GWEI,
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|||
import { source } from 'lowdb/adapters/FileSync';
|
||||
import { file } from 'tmp-promise';
|
||||
import { DRE } from './misc-utils';
|
||||
import { ePolygonNetwork } from './types';
|
||||
import { eEthereumNetwork, ePolygonNetwork, EthereumNetworkNames } from './types';
|
||||
|
||||
const TASK_FLATTEN_GET_FLATTENED_SOURCE = 'flatten:get-flattened-sources';
|
||||
const TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS = 'compile:solidity:get-source-paths';
|
||||
|
@ -20,6 +20,10 @@ const SOLIDITY_PRAGMA = 'pragma solidity';
|
|||
const LICENSE_IDENTIFIER = 'License-Identifier';
|
||||
const EXPERIMENTAL_ABIENCODER = 'pragma experimental ABIEncoderV2;';
|
||||
|
||||
const encodeDeployParams = (instance: Contract, args: (string | string[])[]) => {
|
||||
return instance.interface.encodeDeploy(args).replace('0x', '');
|
||||
};
|
||||
|
||||
// Remove lines at "text" that includes "matcher" string, but keeping first "keep" lines
|
||||
const removeLines = (text: string, matcher: string, keep = 0): string => {
|
||||
let counter = keep;
|
||||
|
@ -73,8 +77,11 @@ export const verifyAtPolygon = async (
|
|||
&contractSourceCode={contractSourceCode}
|
||||
*/
|
||||
try {
|
||||
const net = (DRE as HardhatRuntimeEnvironment).network.name;
|
||||
const network = (DRE as HardhatRuntimeEnvironment).network.name;
|
||||
const net = network === EthereumNetworkNames.matic ? 'mainnet' : network;
|
||||
|
||||
const filePath = await findPath(id);
|
||||
const encodedConstructorParams = encodeDeployParams(instance, args);
|
||||
const flattenSourceCode = await hardhatFlattener(filePath);
|
||||
|
||||
// Remove pragmas and license identifier after first match, required by block explorers like explorer-mainnet.maticgivil.com or Etherscan
|
||||
|
@ -83,19 +90,38 @@ export const verifyAtPolygon = async (
|
|||
EXPERIMENTAL_ABIENCODER,
|
||||
1
|
||||
);
|
||||
const response = await axios.get(`https://explorer-${net}.maticvigil.com/api`, {
|
||||
params: {
|
||||
module: 'contract',
|
||||
action: 'verify',
|
||||
console.log(
|
||||
`[Polygon Verify] Verifying ${id} with address ${instance.address} at Matic ${net} network`
|
||||
);
|
||||
const response = await axios.post(
|
||||
`https://explorer-${net}.maticvigil.com/api`,
|
||||
{
|
||||
addressHash: instance.address,
|
||||
name: id,
|
||||
compilerVersion: 'v0.6.12+commit.27d51765',
|
||||
optimization: 'true',
|
||||
contractSourceCode: cleanedSourceCode,
|
||||
constructorArguments: encodedConstructorParams,
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
console.log(JSON.stringify(response, null, 2));
|
||||
{
|
||||
params: {
|
||||
module: 'contract',
|
||||
action: 'verify',
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Referer: 'aavematic-42e1f6da',
|
||||
},
|
||||
}
|
||||
);
|
||||
if (response.status === 200 && response.data.message === 'OK') {
|
||||
console.log(`[Polygon Verify] Verified contract at Matic ${net} network.`);
|
||||
console.log(
|
||||
`[Polygon Verify] You can check at https://explorer-${net}.maticvigil.com/address/${instance.address}/contracts) \n`
|
||||
);
|
||||
return;
|
||||
}
|
||||
throw Error(JSON.stringify(response.data, null, 2));
|
||||
} catch (error) {
|
||||
console.error('[Polygon Verify] Error:', error.toString());
|
||||
throw error;
|
||||
|
|
Loading…
Reference in New Issue
Block a user