mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
refactored scripts/*
This commit is contained in:
parent
632318e69a
commit
c2dfae6438
|
@ -1,13 +1,23 @@
|
|||
import { ethers } from "hardhat";
|
||||
|
||||
import { addresses } from "../constant/addresses";
|
||||
const network = String(process.env.networkType);
|
||||
|
||||
import { addressesPolygon } from "./polygon/addressesPolygon";
|
||||
import { addresses } from "./mainnet/addresses";
|
||||
import { abis } from "../constant/abis";
|
||||
import { abi } from "../../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json";
|
||||
|
||||
function getAddress(network: string | undefined) {
|
||||
if (network === "polygon") return addressesPolygon.core.instaIndex;
|
||||
// else if (network === "arbitrum") return addressesPolygon.core.instaIndex;
|
||||
// else if (network === "avalanche") return addressesPolygon.core.instaIndex;
|
||||
else return addresses.core.instaIndex;
|
||||
}
|
||||
|
||||
export async function buildDSAv2(owner: any) {
|
||||
const instaIndex = await ethers.getContractAt(
|
||||
abis.core.instaIndex,
|
||||
addresses.core.instaIndex
|
||||
getAddress(String(process.env.networkType))
|
||||
);
|
||||
|
||||
const tx = await instaIndex.build(owner, 2, owner);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { addresses } from "../constant/addresses";
|
||||
import { addressesPolygon } from "./polygon/addressesPolygon";
|
||||
import { addresses } from "./mainnet/addresses";
|
||||
import { abis } from "../constant/abis";
|
||||
|
||||
// const { deployContract } = waffle;
|
||||
|
@ -6,6 +7,13 @@ import { abis } from "../constant/abis";
|
|||
// import { promises as fs } from "fs";
|
||||
// import { deployContract } from "ethereum-waffle";
|
||||
|
||||
function getAddress(network: string | undefined) {
|
||||
if (network === "polygon") return addressesPolygon;
|
||||
// else if (network === "arbitrum") return addressesPolygon;
|
||||
// else if (network === "avalanche") return addressesPolygon;
|
||||
else return addresses;
|
||||
}
|
||||
|
||||
export async function deployAndEnableConnector({
|
||||
connectorName,
|
||||
contractArtifact,
|
||||
|
@ -19,7 +27,8 @@ export async function deployAndEnableConnector({
|
|||
.connect(signer)
|
||||
.addConnectors([connectorName], [connectorInstanace.address]);
|
||||
|
||||
addresses.connectors[connectorName] = connectorInstanace.address;
|
||||
getAddress(String(process.env.networkType)).connectors[connectorName] =
|
||||
connectorInstanace.address;
|
||||
abis.connectors[connectorName] = contractArtifact.abi;
|
||||
|
||||
return connectorInstanace;
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
import { ethers, network } from "hardhat";
|
||||
import { addresses } from "../constant/addresses";
|
||||
import { addressesPolygon } from "./polygon/addressesPolygon";
|
||||
import { addresses } from "./mainnet/addresses";
|
||||
import { abis } from "../constant/abis";
|
||||
|
||||
function getAddress(network: string | undefined) {
|
||||
if (network === "polygon") return addressesPolygon.core.instaIndex;
|
||||
// else if (network === "arbitrum") return addressesPolygon.core.instaIndex;
|
||||
// else if (network === "avalanche") return addressesPolygon.core.instaIndex;
|
||||
else return addresses.core.instaIndex;
|
||||
}
|
||||
|
||||
export async function getMasterSigner() {
|
||||
const [_, __, ___, wallet3] = await ethers.getSigners();
|
||||
const instaIndex = new ethers.Contract(
|
||||
addresses.core.instaIndex,
|
||||
getAddress(String(process.env.networkType)),
|
||||
abis.core.instaIndex,
|
||||
wallet3
|
||||
);
|
||||
|
|
11
scripts/tests/mainnet/addresses.ts
Normal file
11
scripts/tests/mainnet/addresses.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
export const addresses = {
|
||||
connectors: {
|
||||
basic: "0xe5398f279175962E56fE4c5E0b62dc7208EF36c6",
|
||||
auth: "0xd1aff9f2acf800c876c409100d6f39aea93fc3d9",
|
||||
"INSTAPOOL-A": "0x5806af7ab22e2916fa582ff05731bf7c682387b2",
|
||||
},
|
||||
core: {
|
||||
connectorsV2: "0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11",
|
||||
instaIndex: "0x2971AdFa57b20E5a416aE5a708A8655A9c74f723",
|
||||
},
|
||||
};
|
6
scripts/tests/mainnet/constant.ts
Normal file
6
scripts/tests/mainnet/constant.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export const constants = {
|
||||
address_zero: "0x0000000000000000000000000000000000000000",
|
||||
native_address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
||||
max_value:
|
||||
"115792089237316195423570985008687907853269984665640564039457584007913129639935",
|
||||
};
|
23
scripts/tests/mainnet/tokens.ts
Normal file
23
scripts/tests/mainnet/tokens.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
export const tokens = {
|
||||
eth: {
|
||||
type: "token",
|
||||
symbol: "ETH",
|
||||
name: "Ethereum",
|
||||
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
||||
decimals: 18,
|
||||
},
|
||||
dai: {
|
||||
type: "token",
|
||||
symbol: "DAI",
|
||||
name: "DAI Stable",
|
||||
address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
||||
decimals: 18,
|
||||
},
|
||||
usdc: {
|
||||
type: "token",
|
||||
symbol: "USDC",
|
||||
name: "USD Coin",
|
||||
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
||||
decimals: 6,
|
||||
},
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
export const addresses = {
|
||||
export const addressesPolygon = {
|
||||
connectors: {
|
||||
basic: "0x1cAF5EC802ca602E98139AD96A8f2B7BC524264E",
|
||||
auth: "0xf6474aD0dA75A0dE15D2c915e601D9f754B9e6fe",
|
|
@ -1,19 +0,0 @@
|
|||
import { ethers } from "hardhat";
|
||||
|
||||
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) {
|
||||
const instaIndex = await ethers.getContractAt(
|
||||
abis.core.instaIndex,
|
||||
addresses.core.instaIndex
|
||||
);
|
||||
|
||||
const tx = await instaIndex.build(owner, 2, owner);
|
||||
const receipt = await tx.wait();
|
||||
const event = receipt.events.find(
|
||||
(a: { event: string }) => a.event === "LogAccountCreated"
|
||||
);
|
||||
return await ethers.getContractAt(abi, event.args.account);
|
||||
};
|
|
@ -1,26 +0,0 @@
|
|||
import "@nomiclabs/hardhat-waffle";
|
||||
|
||||
import { addresses } from "./constant/addresses";
|
||||
import { abis } from "../../constant/abis";
|
||||
|
||||
import * as hre from "hardhat";
|
||||
const { ethers, waffle } = hre;
|
||||
const { deployContract } = waffle;
|
||||
|
||||
module.exports = async function({
|
||||
connectorName,
|
||||
contractArtifact,
|
||||
signer,
|
||||
connectors,
|
||||
}) {
|
||||
const connectorInstanace = await deployContract(signer, contractArtifact, []);
|
||||
|
||||
await connectors
|
||||
.connect(signer)
|
||||
.addConnectors([connectorName], [connectorInstanace.address]);
|
||||
|
||||
addresses.connectors[connectorName] = connectorInstanace.address;
|
||||
abis.connectors[connectorName] = contractArtifact.abi;
|
||||
|
||||
return connectorInstanace;
|
||||
};
|
|
@ -1,17 +0,0 @@
|
|||
import { abis } from "../../constant/abis";
|
||||
import { web3 } from "hardhat";
|
||||
|
||||
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: { name: any }) => {
|
||||
return b.name === functionName;
|
||||
});
|
||||
// console.log(functionName)
|
||||
if (!abi) throw new Error("Couldn't find function");
|
||||
return web3.eth.abi.encodeFunctionCall(abi, a.args);
|
||||
});
|
||||
return [targets, calldatas];
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
const { ethers, network } = "hardhat";
|
||||
import { addresses } from "./constant/addresses";
|
||||
import { abis } from "../../constant/abis";
|
||||
|
||||
module.exports = async function() {
|
||||
const [_, __, ___, wallet3] = await ethers.getSigners();
|
||||
const instaIndex = new ethers.Contract(
|
||||
addresses.core.instaIndex,
|
||||
abis.core.instaIndex,
|
||||
wallet3
|
||||
);
|
||||
|
||||
const masterAddress = await instaIndex.master(); // TODO: make it constant?
|
||||
await network.provider.request({
|
||||
method: "hardhat_impersonateAccount",
|
||||
params: [masterAddress],
|
||||
});
|
||||
await wallet3.sendTransaction({
|
||||
to: masterAddress,
|
||||
value: ethers.utils.parseEther("10"),
|
||||
});
|
||||
|
||||
return await ethers.getSigner(masterAddress);
|
||||
};
|
Loading…
Reference in New Issue
Block a user