mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Initial commit
This commit is contained in:
commit
0ca8e30fb2
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#Buidler files
|
||||||
|
cache
|
||||||
|
artifacts
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
coverage
|
||||||
|
.coverage_artifacts
|
||||||
|
.coverage_cache
|
||||||
|
.coverage_contracts
|
12
.solcover.js
Normal file
12
.solcover.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
const accounts = require(`./test-wallets.js`).accounts;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
client: require("ganache-cli"),
|
||||||
|
skipFiles: [],
|
||||||
|
mocha: {
|
||||||
|
enableTimeouts: false
|
||||||
|
},
|
||||||
|
providerOptions: {
|
||||||
|
accounts
|
||||||
|
}
|
||||||
|
};
|
4
Dockerfile
Normal file
4
Dockerfile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
FROM ethereum/solc:0.6.8 as build-deps
|
||||||
|
|
||||||
|
FROM node:13
|
||||||
|
COPY --from=build-deps /usr/bin/solc /usr/bin/solc
|
12
LICENSE.md
Normal file
12
LICENSE.md
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
Copyright (C) 2020 Aave
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||||
|
for more details
|
90
buidler.config.ts
Normal file
90
buidler.config.ts
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
import { usePlugin, BuidlerConfig } from "@nomiclabs/buidler/config";
|
||||||
|
import path from "path";
|
||||||
|
import fs from "fs";
|
||||||
|
// @ts-ignore
|
||||||
|
import { accounts } from "./test-wallets.js";
|
||||||
|
import { eEthereumNetwork } from "./helpers/types";
|
||||||
|
|
||||||
|
usePlugin("@nomiclabs/buidler-ethers");
|
||||||
|
usePlugin("buidler-typechain");
|
||||||
|
usePlugin("solidity-coverage");
|
||||||
|
usePlugin("@nomiclabs/buidler-waffle");
|
||||||
|
usePlugin("@nomiclabs/buidler-etherscan");
|
||||||
|
|
||||||
|
["misc", "deployments", "migrations"].forEach((folder) => {
|
||||||
|
const tasksPath = path.join(__dirname, "tasks", folder);
|
||||||
|
fs.readdirSync(tasksPath).forEach((task) => require(`${tasksPath}/${task}`));
|
||||||
|
});
|
||||||
|
|
||||||
|
const DEFAULT_BLOCK_GAS_LIMIT = 9500000;
|
||||||
|
const DEFAULT_GAS_PRICE = 10;
|
||||||
|
const HARDFORK = "istanbul";
|
||||||
|
const INFURA_KEY = "";
|
||||||
|
const ETHERSCAN_KEY = "";
|
||||||
|
const MNEMONIC_PATH = "m/44'/60'/0'/0";
|
||||||
|
const MNEMONICS: { [network: string]: string } = {
|
||||||
|
[eEthereumNetwork.kovan]: "",
|
||||||
|
[eEthereumNetwork.ropsten]: "",
|
||||||
|
[eEthereumNetwork.main]: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCommonNetworkConfig = (
|
||||||
|
networkName: eEthereumNetwork,
|
||||||
|
networkId: number
|
||||||
|
) => {
|
||||||
|
return {
|
||||||
|
url: `https://${networkName}.infura.io/v3/${INFURA_KEY}`,
|
||||||
|
hardfork: HARDFORK,
|
||||||
|
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
|
||||||
|
gasMultiplier: DEFAULT_GAS_PRICE,
|
||||||
|
chainId: networkId,
|
||||||
|
accounts: {
|
||||||
|
mnemonic: MNEMONICS[networkName],
|
||||||
|
path: MNEMONIC_PATH,
|
||||||
|
initialIndex: 0,
|
||||||
|
count: 20,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const config: BuidlerConfig = {
|
||||||
|
solc: {
|
||||||
|
version: "0.6.8",
|
||||||
|
optimizer: { enabled: false, runs: 200 },
|
||||||
|
evmVersion: "istanbul",
|
||||||
|
},
|
||||||
|
typechain: {
|
||||||
|
outDir: "types",
|
||||||
|
target: "ethers-v4",
|
||||||
|
},
|
||||||
|
etherscan: {
|
||||||
|
url: "https://api-kovan.etherscan.io/api",
|
||||||
|
apiKey: ETHERSCAN_KEY,
|
||||||
|
},
|
||||||
|
defaultNetwork: "buidlerevm",
|
||||||
|
mocha: {
|
||||||
|
enableTimeouts: false,
|
||||||
|
},
|
||||||
|
networks: {
|
||||||
|
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan, 42),
|
||||||
|
ropsten: getCommonNetworkConfig(eEthereumNetwork.ropsten, 3),
|
||||||
|
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
|
||||||
|
buidlerevm: {
|
||||||
|
hardfork: "istanbul",
|
||||||
|
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
|
||||||
|
gas: DEFAULT_BLOCK_GAS_LIMIT,
|
||||||
|
gasPrice: 8000000000,
|
||||||
|
chainId: 31337,
|
||||||
|
throwOnTransactionFailures: true,
|
||||||
|
throwOnCallFailures: true,
|
||||||
|
accounts: accounts.map(
|
||||||
|
({ secretKey, balance }: { secretKey: string; balance: string }) => ({
|
||||||
|
privateKey: secretKey,
|
||||||
|
balance,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
15
contracts/Example.sol
Normal file
15
contracts/Example.sol
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
pragma solidity ^0.6.8;
|
||||||
|
|
||||||
|
// "SPDX-License-Identifier: AGPL-3.0-only"
|
||||||
|
|
||||||
|
contract Example {
|
||||||
|
uint256 public _n;
|
||||||
|
|
||||||
|
constructor() public {
|
||||||
|
_n = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
function test() external view returns(uint256 n) {
|
||||||
|
n = _n;
|
||||||
|
}
|
||||||
|
}
|
8
deployed-contracts.json
Normal file
8
deployed-contracts.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"Example": {
|
||||||
|
"buidlerevm": {
|
||||||
|
"address": "0x7c2C195CD6D34B8F845992d380aADB2730bB9C6F",
|
||||||
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
docker-compose.yml
Normal file
10
docker-compose.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
version: "3.5"
|
||||||
|
|
||||||
|
services:
|
||||||
|
contracts-env:
|
||||||
|
build:
|
||||||
|
context: ./
|
||||||
|
working_dir: /src
|
||||||
|
command: npm run run-env
|
||||||
|
volumes:
|
||||||
|
- ./:/src
|
9
helpers/constants.ts
Normal file
9
helpers/constants.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { eEthereumNetwork, tEthereumAddress } from "./types";
|
||||||
|
|
||||||
|
export const ZERO_ADDRESS: tEthereumAddress =
|
||||||
|
"0x0000000000000000000000000000000000000000";
|
||||||
|
export const ONE_ADDRESS = "0x0000000000000000000000000000000000000001";
|
||||||
|
export const MAX_UINT_AMOUNT =
|
||||||
|
"115792089237316195423570985008687907853269984665640564039457584007913129639935";
|
||||||
|
export const MOCK_ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
||||||
|
export const WAD = Math.pow(10, 18).toString();
|
78
helpers/contracts-helpers.ts
Normal file
78
helpers/contracts-helpers.ts
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
import { Contract, Signer, utils } from "ethers";
|
||||||
|
|
||||||
|
import { getDb, BRE } from "./misc-utils";
|
||||||
|
import { tEthereumAddress, eContractid } from "./types";
|
||||||
|
|
||||||
|
export const registerContractInJsonDb = async (
|
||||||
|
contractId: string,
|
||||||
|
contractInstance: Contract
|
||||||
|
) => {
|
||||||
|
const currentNetwork = BRE.network.name;
|
||||||
|
if (
|
||||||
|
currentNetwork !== "buidlerevm" &&
|
||||||
|
currentNetwork !== "soliditycoverage"
|
||||||
|
) {
|
||||||
|
console.log(`*** ${contractId} ***\n`);
|
||||||
|
console.log(`Network: ${currentNetwork}`);
|
||||||
|
console.log(`tx: ${contractInstance.deployTransaction.hash}`);
|
||||||
|
console.log(`contract address: ${contractInstance.address}`);
|
||||||
|
console.log(`deployer address: ${contractInstance.deployTransaction.from}`);
|
||||||
|
console.log(`gas price: ${contractInstance.deployTransaction.gasPrice}`);
|
||||||
|
console.log(`gas used: ${contractInstance.deployTransaction.gasLimit}`);
|
||||||
|
console.log(`\n******`);
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
|
||||||
|
await getDb()
|
||||||
|
.set(`${contractId}.${currentNetwork}`, {
|
||||||
|
address: contractInstance.address,
|
||||||
|
deployer: contractInstance.deployTransaction.from,
|
||||||
|
})
|
||||||
|
.write();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEthersSigners = async (): Promise<Signer[]> =>
|
||||||
|
await Promise.all(await BRE.ethers.signers());
|
||||||
|
|
||||||
|
export const getEthersSignersAddresses = async (): Promise<tEthereumAddress[]> =>
|
||||||
|
await Promise.all(
|
||||||
|
(await BRE.ethers.signers()).map((signer) => signer.getAddress())
|
||||||
|
);
|
||||||
|
|
||||||
|
export const getCurrentBlock = async () => {
|
||||||
|
return BRE.ethers.provider.getBlockNumber();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const decodeAbiNumber = (data: string): number =>
|
||||||
|
parseInt(utils.defaultAbiCoder.decode(["uint256"], data).toString());
|
||||||
|
|
||||||
|
const deployContract = async <ContractType extends Contract>(
|
||||||
|
contractName: string,
|
||||||
|
args: any[]
|
||||||
|
): Promise<ContractType> =>
|
||||||
|
(await (await BRE.ethers.getContract(contractName)).deploy(
|
||||||
|
...args
|
||||||
|
)) as ContractType;
|
||||||
|
|
||||||
|
const getContract = async <ContractType extends Contract>(
|
||||||
|
contractName: string,
|
||||||
|
address: string
|
||||||
|
): Promise<ContractType> =>
|
||||||
|
(await (await BRE.ethers.getContract(contractName)).attach(
|
||||||
|
address
|
||||||
|
)) as ContractType;
|
||||||
|
|
||||||
|
export const deployExampleContract = async () =>
|
||||||
|
await deployContract<any>(eContractid.Example, []);
|
||||||
|
|
||||||
|
export const getExampleContract = async (address?: tEthereumAddress) => {
|
||||||
|
return await getContract<any>(
|
||||||
|
eContractid.Example,
|
||||||
|
address ||
|
||||||
|
(
|
||||||
|
await getDb()
|
||||||
|
.get(`${eContractid.Example}.${BRE.network.name}`)
|
||||||
|
.value()
|
||||||
|
).address
|
||||||
|
);
|
||||||
|
};
|
25
helpers/misc-utils.ts
Normal file
25
helpers/misc-utils.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import BigNumber from "bignumber.js";
|
||||||
|
import BN = require("bn.js");
|
||||||
|
import low from "lowdb";
|
||||||
|
import FileSync from "lowdb/adapters/FileSync";
|
||||||
|
import { WAD } from "./constants";
|
||||||
|
import { BuidlerRuntimeEnvironment } from "@nomiclabs/buidler/types";
|
||||||
|
|
||||||
|
export const toWad = (value: string | number) =>
|
||||||
|
new BigNumber(value).times(WAD).toFixed();
|
||||||
|
|
||||||
|
export const bnToBigNumber = (amount: BN): BigNumber =>
|
||||||
|
new BigNumber(<any>amount);
|
||||||
|
export const stringToBigNumber = (amount: string): BigNumber =>
|
||||||
|
new BigNumber(amount);
|
||||||
|
|
||||||
|
export const getDb = () => low(new FileSync("./deployed-contracts.json"));
|
||||||
|
|
||||||
|
export let BRE: BuidlerRuntimeEnvironment = {} as BuidlerRuntimeEnvironment;
|
||||||
|
export const setBRE = (_BRE: BuidlerRuntimeEnvironment) => {
|
||||||
|
BRE = _BRE;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const sleep = (milliseconds: number) => {
|
||||||
|
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||||
|
};
|
18
helpers/types.ts
Normal file
18
helpers/types.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import BigNumber from "bignumber.js";
|
||||||
|
|
||||||
|
export enum eEthereumNetwork {
|
||||||
|
buidlerevm = "buidlerevm",
|
||||||
|
kovan = "kovan",
|
||||||
|
ropsten = "ropsten",
|
||||||
|
main = "main"
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum eContractid {
|
||||||
|
Example = "Example"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type tEthereumAddress = string;
|
||||||
|
export type tStringTokenBigUnits = string; // 1 ETH, or 10e6 USDC or 10e18 DAI
|
||||||
|
export type tBigNumberTokenBigUnits = BigNumber;
|
||||||
|
export type tStringTokenSmallUnits = string; // 1 wei, or 1 basic unit of USDC, or 1 basic unit of DAI
|
||||||
|
export type tBigNumberTokenSmallUnits = BigNumber;
|
24312
package-lock.json
generated
Normal file
24312
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
62
package.json
Normal file
62
package.json
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
"name": "aave-protocol-v2",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Aave Protocol V2 smart contracts",
|
||||||
|
"scripts": {
|
||||||
|
"run-env": "npm i && tail -f /dev/null",
|
||||||
|
"buidler": "buidler",
|
||||||
|
"buidler-kovan": "buidler --network kovan",
|
||||||
|
"buidler-ropsten": "buidler --network ropsten",
|
||||||
|
"buidler-main": "buidler --network main",
|
||||||
|
"buidler help": "buidler help",
|
||||||
|
"compile": "buidler compile",
|
||||||
|
"types-gen": "buidler typechain",
|
||||||
|
"test": "buidler test",
|
||||||
|
"dev:coverage": "buidler coverage",
|
||||||
|
"dev:deployment": "buidler dev-deployment",
|
||||||
|
"dev:deployExample": "buidler deploy-Example"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nomiclabs/buidler": "1.3.5",
|
||||||
|
"@nomiclabs/buidler-ethers": "1.3.3",
|
||||||
|
"@nomiclabs/buidler-etherscan": "1.3.3",
|
||||||
|
"@nomiclabs/buidler-waffle": "1.3.4",
|
||||||
|
"@openzeppelin/contracts": "3.0.1",
|
||||||
|
"@typechain/ethers-v4": "1.0.0",
|
||||||
|
"@typechain/truffle-v4": "2.0.2",
|
||||||
|
"@typechain/truffle-v5": "2.0.2",
|
||||||
|
"@typechain/web3-v1": "1.0.0",
|
||||||
|
"@types/chai": "4.2.11",
|
||||||
|
"@types/lowdb": "1.0.9",
|
||||||
|
"@types/mocha": "7.0.2",
|
||||||
|
"@types/node": "14.0.5",
|
||||||
|
"bignumber.js": "9.0.0",
|
||||||
|
"chai": "4.2.0",
|
||||||
|
"typechain": "2.0.0",
|
||||||
|
"buidler-typechain": "0.1.1",
|
||||||
|
"ethereum-waffle": "2.5.1",
|
||||||
|
"solidity-coverage": "0.7.5",
|
||||||
|
"ethers": "4.0.47",
|
||||||
|
"lowdb": "1.0.0",
|
||||||
|
"ts-generator": "0.0.8",
|
||||||
|
"ganache-cli": "6.9.1",
|
||||||
|
"ts-node": "8.10.2",
|
||||||
|
"typescript": "3.9.3"
|
||||||
|
},
|
||||||
|
"author": "Aave",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Ernesto Boado",
|
||||||
|
"email": "ernesto@aave.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Emilio Frangella",
|
||||||
|
"email": "emilio@aave.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andrey Kozlov",
|
||||||
|
"email": "andrey@aave.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "AGPLv3"
|
||||||
|
}
|
23
tasks/deployments/deploy-Example.ts
Normal file
23
tasks/deployments/deploy-Example.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { task } from "@nomiclabs/buidler/config";
|
||||||
|
import { eContractid } from "../../helpers/types";
|
||||||
|
import {
|
||||||
|
registerContractInJsonDb,
|
||||||
|
deployExampleContract,
|
||||||
|
} from "../../helpers/contracts-helpers";
|
||||||
|
|
||||||
|
const { Example } = eContractid;
|
||||||
|
|
||||||
|
task(`deploy-${Example}`, `Deploys the ${Example} contract`).setAction(
|
||||||
|
async ({}, localBRE) => {
|
||||||
|
await localBRE.run("set-bre");
|
||||||
|
|
||||||
|
console.log(`Deploying ${Example} ...\n`);
|
||||||
|
|
||||||
|
const example = await deployExampleContract();
|
||||||
|
await example.deployTransaction.wait();
|
||||||
|
|
||||||
|
await registerContractInJsonDb(`${Example}`, example);
|
||||||
|
|
||||||
|
return example;
|
||||||
|
}
|
||||||
|
);
|
18
tasks/migrations/dev-deployment.ts
Normal file
18
tasks/migrations/dev-deployment.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import { task } from "@nomiclabs/buidler/config";
|
||||||
|
import { eContractid } from "../../helpers/types";
|
||||||
|
import { expect } from "chai";
|
||||||
|
import { BuidlerRuntimeEnvironment } from "@nomiclabs/buidler/types";
|
||||||
|
import { Example } from "../../types/Example";
|
||||||
|
|
||||||
|
task("dev-deployment", "Deployment in buidlerevm").setAction(
|
||||||
|
async (_, localBRE) => {
|
||||||
|
const BRE: BuidlerRuntimeEnvironment = await localBRE.run("set-bre");
|
||||||
|
|
||||||
|
const example = (await BRE.run(`deploy-${eContractid.Example}`)) as Example;
|
||||||
|
|
||||||
|
expect((await example.test()).toString()).to.equal(
|
||||||
|
"5",
|
||||||
|
"INVALID_TEST_VALUE"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
10
tasks/misc/set-bre.ts
Normal file
10
tasks/misc/set-bre.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { task } from "@nomiclabs/buidler/config";
|
||||||
|
import { setBRE } from "../../helpers/misc-utils";
|
||||||
|
|
||||||
|
task(
|
||||||
|
`set-bre`,
|
||||||
|
`Inits the BRE, to have access to all the plugins' objects`
|
||||||
|
).setAction(async (_, _BRE) => {
|
||||||
|
setBRE(_BRE);
|
||||||
|
return _BRE;
|
||||||
|
});
|
21
test-wallets.js
Normal file
21
test-wallets.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
const toWad = require("./helpers/misc-utils").toWad;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
accounts: [
|
||||||
|
{
|
||||||
|
secretKey:
|
||||||
|
"0xc5e8f61d1ab959b397eecc0a37a6517b8e67a0e7cf1f4bce5591f3ed80199122",
|
||||||
|
balance: toWad(1_000_000),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
secretKey:
|
||||||
|
"0xd49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb",
|
||||||
|
balance: toWad(1_000_000),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
secretKey:
|
||||||
|
"0x23c601ae397441f3ef6f1075dcb0031ff17fb079837beadaf3c84d96c6f3e569",
|
||||||
|
balance: toWad(1_000_000),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
25
test/basic.spec.ts
Normal file
25
test/basic.spec.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import rawBRE from "@nomiclabs/buidler";
|
||||||
|
import { expect } from "chai";
|
||||||
|
import { MockProvider } from "ethereum-waffle";
|
||||||
|
import { BuidlerRuntimeEnvironment } from "@nomiclabs/buidler/types";
|
||||||
|
import { deployExampleContract } from "../helpers/contracts-helpers";
|
||||||
|
import { Example } from "../types/Example";
|
||||||
|
|
||||||
|
describe("Example test", () => {
|
||||||
|
const [wallet] = new MockProvider().getWallets();
|
||||||
|
let BRE: BuidlerRuntimeEnvironment;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
console.log("To execute once per 'describe'");
|
||||||
|
BRE = await rawBRE.run("set-bre");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("test()", async () => {
|
||||||
|
const example = (await deployExampleContract()) as Example;
|
||||||
|
|
||||||
|
expect((await example.test()).toString()).to.equal(
|
||||||
|
"5",
|
||||||
|
"INVALID_TEST_VALUE"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
0
test/helpers/test-helpers.ts
Normal file
0
test/helpers/test-helpers.ts
Normal file
19
tsconfig.json
Normal file
19
tsconfig.json
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"outDir": "dist",
|
||||||
|
"resolveJsonModule": true
|
||||||
|
},
|
||||||
|
"include": ["./**/*"],
|
||||||
|
"files": [
|
||||||
|
"./buidler.config.ts",
|
||||||
|
"node_modules/@nomiclabs/buidler-ethers/src/type-extensions.d.ts",
|
||||||
|
"node_modules/buidler-typechain/src/type-extensions.d.ts",
|
||||||
|
"node_modules/@nomiclabs/buidler-waffle/src/type-extensions.d.ts",
|
||||||
|
"node_modules/@nomiclabs/buidler-etherscan/src/type-extensions.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
53
types/Example.d.ts
vendored
Normal file
53
types/Example.d.ts
vendored
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/* Generated by ts-generator ver. 0.0.8 */
|
||||||
|
/* tslint:disable */
|
||||||
|
|
||||||
|
import { Contract, ContractTransaction, EventFilter, Signer } from "ethers";
|
||||||
|
import { Listener, Provider } from "ethers/providers";
|
||||||
|
import { Arrayish, BigNumber, BigNumberish, Interface } from "ethers/utils";
|
||||||
|
import {
|
||||||
|
TransactionOverrides,
|
||||||
|
TypedEventDescription,
|
||||||
|
TypedFunctionDescription
|
||||||
|
} from ".";
|
||||||
|
|
||||||
|
interface ExampleInterface extends Interface {
|
||||||
|
functions: {
|
||||||
|
_n: TypedFunctionDescription<{ encode([]: []): string }>;
|
||||||
|
|
||||||
|
test: TypedFunctionDescription<{ encode([]: []): string }>;
|
||||||
|
};
|
||||||
|
|
||||||
|
events: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Example extends Contract {
|
||||||
|
connect(signerOrProvider: Signer | Provider | string): Example;
|
||||||
|
attach(addressOrName: string): Example;
|
||||||
|
deployed(): Promise<Example>;
|
||||||
|
|
||||||
|
on(event: EventFilter | string, listener: Listener): Example;
|
||||||
|
once(event: EventFilter | string, listener: Listener): Example;
|
||||||
|
addListener(eventName: EventFilter | string, listener: Listener): Example;
|
||||||
|
removeAllListeners(eventName: EventFilter | string): Example;
|
||||||
|
removeListener(eventName: any, listener: Listener): Example;
|
||||||
|
|
||||||
|
interface: ExampleInterface;
|
||||||
|
|
||||||
|
functions: {
|
||||||
|
_n(): Promise<BigNumber>;
|
||||||
|
|
||||||
|
test(): Promise<BigNumber>;
|
||||||
|
};
|
||||||
|
|
||||||
|
_n(): Promise<BigNumber>;
|
||||||
|
|
||||||
|
test(): Promise<BigNumber>;
|
||||||
|
|
||||||
|
filters: {};
|
||||||
|
|
||||||
|
estimate: {
|
||||||
|
_n(): Promise<BigNumber>;
|
||||||
|
|
||||||
|
test(): Promise<BigNumber>;
|
||||||
|
};
|
||||||
|
}
|
71
types/ExampleFactory.ts
Normal file
71
types/ExampleFactory.ts
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/* Generated by ts-generator ver. 0.0.8 */
|
||||||
|
/* tslint:disable */
|
||||||
|
|
||||||
|
import { Contract, ContractFactory, Signer } from "ethers";
|
||||||
|
import { Provider } from "ethers/providers";
|
||||||
|
import { UnsignedTransaction } from "ethers/utils/transaction";
|
||||||
|
|
||||||
|
import { TransactionOverrides } from ".";
|
||||||
|
import { Example } from "./Example";
|
||||||
|
|
||||||
|
export class ExampleFactory extends ContractFactory {
|
||||||
|
constructor(signer?: Signer) {
|
||||||
|
super(_abi, _bytecode, signer);
|
||||||
|
}
|
||||||
|
|
||||||
|
deploy(overrides?: TransactionOverrides): Promise<Example> {
|
||||||
|
return super.deploy(overrides) as Promise<Example>;
|
||||||
|
}
|
||||||
|
getDeployTransaction(overrides?: TransactionOverrides): UnsignedTransaction {
|
||||||
|
return super.getDeployTransaction(overrides);
|
||||||
|
}
|
||||||
|
attach(address: string): Example {
|
||||||
|
return super.attach(address) as Example;
|
||||||
|
}
|
||||||
|
connect(signer: Signer): ExampleFactory {
|
||||||
|
return super.connect(signer) as ExampleFactory;
|
||||||
|
}
|
||||||
|
static connect(
|
||||||
|
address: string,
|
||||||
|
signerOrProvider: Signer | Provider
|
||||||
|
): Example {
|
||||||
|
return new Contract(address, _abi, signerOrProvider) as Example;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _abi = [
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "constructor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
name: "_n",
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "",
|
||||||
|
type: "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
stateMutability: "view",
|
||||||
|
type: "function"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
name: "test",
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "n",
|
||||||
|
type: "uint256"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
stateMutability: "view",
|
||||||
|
type: "function"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const _bytecode =
|
||||||
|
"0x608060405234801561001057600080fd5b50600560008190555060b4806100276000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80631aadff81146037578063f8a8fd6d146053575b600080fd5b603d606f565b6040518082815260200191505060405180910390f35b60596075565b6040518082815260200191505060405180910390f35b60005481565b6000805490509056fea264697066735822122057a64b654e079499c1bcb7323ed02df7274732301ad598f3679f40351bdb288464736f6c63430006080033";
|
27
types/index.d.ts
vendored
Normal file
27
types/index.d.ts
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* Generated by ts-generator ver. 0.0.8 */
|
||||||
|
/* tslint:disable */
|
||||||
|
import {
|
||||||
|
BigNumberish,
|
||||||
|
EventDescription,
|
||||||
|
FunctionDescription
|
||||||
|
} from "ethers/utils";
|
||||||
|
|
||||||
|
export class TransactionOverrides {
|
||||||
|
nonce?: BigNumberish | Promise<BigNumberish>;
|
||||||
|
gasLimit?: BigNumberish | Promise<BigNumberish>;
|
||||||
|
gasPrice?: BigNumberish | Promise<BigNumberish>;
|
||||||
|
value?: BigNumberish | Promise<BigNumberish>;
|
||||||
|
chainId?: number | Promise<number>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TypedEventDescription<
|
||||||
|
T extends Pick<EventDescription, "encodeTopics">
|
||||||
|
> extends EventDescription {
|
||||||
|
encodeTopics: T["encodeTopics"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TypedFunctionDescription<
|
||||||
|
T extends Pick<FunctionDescription, "encode">
|
||||||
|
> extends FunctionDescription {
|
||||||
|
encode: T["encode"];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user