mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Add: Initial copy of test files for mainnet
This commit is contained in:
parent
b8aab9db5a
commit
e503aac91c
15
scripts/polygon/buildDSAv2.js
Normal file
15
scripts/polygon/buildDSAv2.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
const hre = require("hardhat");
|
||||
const { ethers } = hre;
|
||||
const addresses = require("./constant/addresses");
|
||||
const abis = require("./constant/abis");
|
||||
|
||||
const instaImplementations_m1 = require("../deployements/mainnet/Implementation_m1.sol/InstaImplementationM1.json")
|
||||
|
||||
module.exports = async function (owner) {
|
||||
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 => a.event === "LogAccountCreated")
|
||||
return await ethers.getContractAt(instaImplementations_m1.abi, event.args.account)
|
||||
};
|
11
scripts/polygon/constant/addresses.js
Normal file
11
scripts/polygon/constant/addresses.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
module.exports = {
|
||||
connectors: {
|
||||
basic: "0xe5398f279175962E56fE4c5E0b62dc7208EF36c6",
|
||||
auth: "0xd1aff9f2acf800c876c409100d6f39aea93fc3d9",
|
||||
"INSTAPOOL-A": "0x5806af7ab22e2916fa582ff05731bf7c682387b2",
|
||||
},
|
||||
core: {
|
||||
connectorsV2: "0x97b0B3A8bDeFE8cB9563a3c610019Ad10DB8aD11",
|
||||
instaIndex: "0x2971AdFa57b20E5a416aE5a708A8655A9c74f723",
|
||||
},
|
||||
};
|
5
scripts/polygon/constant/constant.js
Normal file
5
scripts/polygon/constant/constant.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
address_zero: "0x0000000000000000000000000000000000000000",
|
||||
eth_addr: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
||||
max_value: "115792089237316195423570985008687907853269984665640564039457584007913129639935"
|
||||
};
|
23
scripts/polygon/constant/tokens.js
Normal file
23
scripts/polygon/constant/tokens.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
"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
|
||||
}
|
||||
}
|
19
scripts/polygon/deployAndEnableConnector.js
Normal file
19
scripts/polygon/deployAndEnableConnector.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const abis = require("./constant/abis");
|
||||
const addresses = require("./constant/addresses");
|
||||
|
||||
const hre = require("hardhat");
|
||||
const { ethers, waffle } = hre;
|
||||
const { deployContract } = waffle;
|
||||
const fs = require("fs")
|
||||
|
||||
|
||||
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;
|
||||
};
|
18
scripts/polygon/encodeSpells.js
Normal file
18
scripts/polygon/encodeSpells.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
const abis = require("./constant/abis");
|
||||
const addresses = require("./constant/addresses");
|
||||
const { web3 } = hre;
|
||||
|
||||
module.exports = function (spells) {
|
||||
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 => {
|
||||
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]
|
||||
};
|
25
scripts/polygon/getMasterSigner.js
Normal file
25
scripts/polygon/getMasterSigner.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const hre = require("hardhat");
|
||||
const { ethers } = hre;
|
||||
const addresses = require("./constant/addresses");
|
||||
const abis = require("./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 hre.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