segregated scripts

This commit is contained in:
pradyuman-verma 2021-12-06 00:40:22 +05:30 committed by Ishan Jain
parent b74fecff3d
commit 6863f08c5f
41 changed files with 138 additions and 118 deletions

View File

@ -1,6 +1,6 @@
export const constants = {
address_zero: "0x0000000000000000000000000000000000000000",
eth_addr: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
native_address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
max_value:
"115792089237316195423570985008687907853269984665640564039457584007913129639935",
};

View File

@ -1,7 +1,6 @@
import * as hre from "hardhat";
const { ethers } = hre;
const deployConnector = require("./deployConnector");
import { deployConnector } from "./deployConnector";
async function main() {
const address = await deployConnector("ConnectOne"); // Example

View File

@ -1,11 +1,10 @@
import { ethers } from "hardhat";
import { addresses } from "./constant/addresses";
import { addresses } from "../constant/addresses";
import { abis } from "../constant/abis";
import { abi } from "../../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json";
module.exports = async function(owner: any) {
export async function buildDSAv2(owner: any) {
const instaIndex = await ethers.getContractAt(
abis.core.instaIndex,
addresses.core.instaIndex
@ -17,4 +16,4 @@ module.exports = async function(owner: any) {
(a: { event: string }) => a.event === "LogAccountCreated"
);
return await ethers.getContractAt(abi, event.args.account);
};
}

View File

@ -1,10 +1,10 @@
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
import { addresses } from "../constant/addresses";
import { abis } from "../constant/abis";
// const { deployContract } = waffle;
import { ethers } from "hardhat";
import { promises as fs } from "fs";
import { deployContract } from "ethereum-waffle";
// import { ethers } from "hardhat";
// import { promises as fs } from "fs";
// import { deployContract } from "ethereum-waffle";
export async function deployAndEnableConnector({
connectorName,
@ -12,7 +12,8 @@ export async function deployAndEnableConnector({
signer,
connectors,
}) {
const connectorInstanace = await deployContract(signer, contractArtifact, []);
const deployer = new contractArtifact(signer);
const connectorInstanace = await deployer.deploy();
await connectors
.connect(signer)

View File

@ -1,5 +1,3 @@
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
import * as hre from "hardhat";
const { web3 } = hre;

View File

@ -1,8 +1,7 @@
import { addresses } from "./constant/addresses";
import { abis } from "../constant/abis";
import { web3 } from "hardhat";
import { abis } from "../constant/abis";
module.exports = function(spells: any[]) {
export function encodeSpells(spells: any[]) {
const targets = spells.map((a) => a.connector);
const calldatas = spells.map((a) => {
const functionName = a.method;
@ -15,4 +14,4 @@ module.exports = function(spells: any[]) {
return web3.eth.abi.encodeFunctionCall(abi, a.args);
});
return [targets, calldatas];
};
}

View File

@ -1,6 +1,6 @@
import { ethers, network } from "hardhat";
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
import { addresses } from "../constant/addresses";
import { abis } from "../constant/abis";
export async function getMasterSigner() {
const [_, __, ___, wallet3] = await ethers.getSigners();

View File

@ -1,10 +1,10 @@
import { ethers } from "hardhat";
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
import { abi } from "../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json";
import { abis } from "../../constant/abis";
import { abi } from "../../../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json";
export async function buildDSAv2(owner: any) {
module.exports = async function(owner: any) {
const instaIndex = await ethers.getContractAt(
abis.core.instaIndex,
addresses.core.instaIndex
@ -16,4 +16,4 @@ export async function buildDSAv2(owner: any) {
(a: { event: string }) => a.event === "LogAccountCreated"
);
return await ethers.getContractAt(abi, event.args.account);
}
};

View File

@ -1,7 +1,7 @@
import "@nomiclabs/hardhat-waffle";
import { addresses } from "./constant/addresses";
import { abis } from "../constant/abis";
import { abis } from "../../constant/abis";
import * as hre from "hardhat";
const { ethers, waffle } = hre;

View File

@ -1,13 +1,12 @@
import { abis } from "../../constant/abis";
import { web3 } from "hardhat";
import { addresses } from "./constant/addresses";
import { abis } from "./constant/abis";
export function encodeSpells(spells: any[]) {
const targets = spells.map((a) => a.connector);
const calldatas = spells.map((a) => {
const functionName = a.method;
// console.log(functionName)
const abi = abis.connectors[a.connector].find((b) => {
const abi = abis.connectors[a.connector].find((b: { name: any }) => {
return b.name === functionName;
});
// console.log(functionName)

View File

@ -1,6 +1,6 @@
const { ethers, network } = "hardhat";
import { addresses } from "./constant/addresses";
import { abis } from "../constant/abis";
import { abis } from "../../constant/abis";
module.exports = async function() {
const [_, __, ___, wallet3] = await ethers.getSigners();

View File

@ -1,4 +1,3 @@
# Check run
use

View File

@ -2,16 +2,16 @@ import { expect } from "chai";
import "hardhat";
import { abis } from "../../../scripts/constant/abis";
import { addresses } from "../../../scripts/constant/addresses";
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector";
import { getMasterSigner } from "../../../scripts/getMasterSigner";
import { buildDSAv2 } from "../../../scripts/buildDSAv2";
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector";
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import ConnectV2AaveV1 from "../../artifacts/contracts/mainnet/connectors/aave/v1/main.sol/ConnectV2AaveV1.json";
import { parseEther } from "@ethersproject/units";
import { encodeSpells } from "../../../scripts/encodeSpells";
import { encodeSpells } from "../../../scripts/tests/encodeSpells";
import { tokens } from "../../../scripts/constant/tokens";
import { constants } from "../../../scripts/constant/constant";
import { addLiquidity } from "../../../scripts/addLiquidity";
import { addLiquidity } from "../../../scripts/tests/addLiquidity";
// const { ethers } = hre;
const ALCHEMY_ID = process.env.ALCHEMY_ID;

View File

@ -2,38 +2,37 @@ import { expect } from "chai";
import hre from "hardhat";
import { abis } from "../../../scripts/constant/abis";
import { addresses } from "../../../scripts/constant/addresses";
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector";
import { getMasterSigner } from "../../../scripts/getMasterSigner";
import { buildDSAv2 } from "../../../scripts/buildDSAv2";
import { ConnectV2AaveV2 } from "../../artifacts/contracts/mainnet/connectors/aave/v2/main.sol/ConnectV2AaveV2.json";
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector";
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { ConnectV2AaveV2, ConnectV2AaveV2__factory } from "../../../typechain";
import { parseEther } from "@ethersproject/units";
import { encodeSpells } from "../../../scripts/encodeSpells";
import { encodeSpells } from "../../../scripts/tests/encodeSpells";
import { tokens } from "../../../scripts/constant/tokens";
import { constants } from "../../../scripts/constant/constant";
import { addLiquidity } from "../../../scripts/addLiquidity";
// const { ethers } = hre;
import { addLiquidity } from "../../../scripts/tests/addLiquidity";
const { ethers } = hre;
describe("Aave V2", function () {
const connectorName = "AAVEV2-TEST-A";
let connector: ConnectV2AaveV2;
let wallet0: any, wallet1: any;
let wallet0: any, wallet1: { address: any; };
let dsaWallet0: any;
let instaConnectorsV2: any;
let connector: any;
let masterSigner: any;
let instaConnectorsV2: { address: any; };
let masterSigner: { address: any; };
before(async () => {
await hre.network.provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: hre.config.networks.hardhat.forking.url,
blockNumber: 12796965,
},
},
],
});
// await hre.network.provider.request({
// method: "hardhat_reset",
// params: [
// {
// forking: {
// jsonRpcUrl: hre.config.networks.hardhat.forking.url,
// blockNumber: 12796965,
// },
// },
// ],
// });
[wallet0, wallet1] = await ethers.getSigners();
masterSigner = await getMasterSigner();
instaConnectorsV2 = await ethers.getContractAt(
@ -42,7 +41,7 @@ describe("Aave V2", function () {
);
connector = await deployAndEnableConnector({
connectorName,
contractArtifact: ConnectV2AaveV2,
contractArtifact: ConnectV2AaveV2__factory,
signer: masterSigner,
connectors: instaConnectorsV2,
});

View File

@ -3,10 +3,10 @@ import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre; //check
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";

View File

@ -3,10 +3,10 @@ import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre; //check
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";
import { constants } from "../../../scripts/constant/constant";

View File

@ -4,10 +4,10 @@ const { web3, deployments, waffle, ethers } = hre;
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";
import { constants } from "../../../scripts/constant/constant";

View File

@ -4,10 +4,10 @@ const { web3, deployments, waffle, ethers } = hre;
const { provider, deployContract } = waffle
import { abi: implementationsABI } from "../../../scripts/constant/abi/core/InstaImplementations.json"
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses"
import { abis } from "../../../scripts/constant/abis"

View File

@ -5,10 +5,10 @@ const { provider, deployContract } = waffle
import { abi : implementationsABI } from "../../../scripts/constant/abi/core/InstaImplementations.json"
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses"

View File

@ -3,10 +3,10 @@ import hre from "hardhat";
import { web3, deployments, waffle, ethers } = hre;
import { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";

View File

@ -3,11 +3,11 @@ import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre;
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { encodeFlashcastData } from "../../../scripts/encodeFlashcastData.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { encodeFlashcastData } from "../../../scripts/tests/encodeFlashcastData.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";

View File

@ -2,10 +2,10 @@ import hre from "hardhat";
import hardhatConfig from "../../../hardhat.config";
// Instadapp deployment and testing helpers
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
// Instadapp instadappAddresses/ABIs
import { instadappAddresses } from "../../../scripts/important/addresses";

View File

@ -2,8 +2,8 @@ import hre from "hardhat";
import { expect } from "chai";
// Instadapp deployment and testing helpers
import { buildDSAv2 } from "../../../scripts/buildDSAv2";
import { encodeSpells } from "../../../scripts/encodeSpells.js";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js";
// Liquity smart contracts
import contracts from "./liquity.contracts";

View File

@ -5,10 +5,10 @@ const { provider, deployContract } = waffle
const ALCHEMY_ID = process.env.ALCHEMY_ID;
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses"

View File

@ -3,10 +3,10 @@ import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre;
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses"
import { abis } from "../../../scripts/constant/abis"

View File

@ -3,12 +3,12 @@ import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre;
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js";
import { buildDSAv2 } from "../../../scripts/buildDSAv2";
import { encodeSpells } from "../../../scripts/encodeSpells.js";
import { encodeFlashcastData } from "../../../scripts/encodeFlashcastData.js";
import { getMasterSigner } from "../../../scripts/getMasterSigner";
import { addLiquidity } from "../../../scripts/addLiquidity";
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js";
import { encodeFlashcastData } from "../../../scripts/tests/encodeFlashcastData.js";
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { addLiquidity } from "../../../scripts/tests/addLiquidity";
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";

View File

@ -3,11 +3,11 @@ import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre;
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js";
import { buildDSAv2 } from "../../../scripts/buildDSAv2";
import { encodeSpells } from "../../../scripts/encodeSpells.js";
import { getMasterSigner } from "../../../scripts/getMasterSigner";
import { addLiquidity } from "../../../scripts/addLiquidity";
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js";
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2";
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js";
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner";
import { addLiquidity } from "../../../scripts/tests/addLiquidity";
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";

View File

@ -3,10 +3,10 @@ import hre from "hardhat";
const { web3, deployments, waffle, ethers } = hre;
const { provider, deployContract } = waffle
import { deployAndEnableConnector } from "../../../scripts/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/buildDSAv2"
import { encodeSpells } from "../../../scripts/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/getMasterSigner"
import { deployAndEnableConnector } from "../../../scripts/tests/deployAndEnableConnector.js"
import { buildDSAv2 } from "../../../scripts/tests/buildDSAv2"
import { encodeSpells } from "../../../scripts/tests/encodeSpells.js"
import { getMasterSigner } from "../../../scripts/tests/getMasterSigner"
import { addresses } from "../../../scripts/constant/addresses";
import { abis } from "../../../scripts/constant/abis";

27
tsconfig.json Normal file
View File

@ -0,0 +1,27 @@
// tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es5", "es6"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"outDir": "dist",
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"target": "es5",
},
"exclude": ["artifacts", "node_modules"],
"files": ["./hardhat.config.ts"],
"include": [
"artifacts/**/*",
"artifacts/**/*.json",
"scripts/**/*",
"tasks/**/*",
"test/**/*",
"typechain/**/*",
"types/**/*"
]
}