Commit b3c3a7e4 authored by XFT-dev's avatar XFT-dev
Browse files

added hardhat support

parent 6edd2b9c

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
<br/>
<p align="center">
<a href="https://chain.link/" target="_blank" color="#0d2990">
<img src="https://raw.githubusercontent.com/smartcontractkit/chainlink/develop/docs/logo-chainlink-blue.svg" width="225" alt="Chainlink logo">
</a>
</p>
<br/>
[![npm](https://img.shields.io/npm/v/@chainlink/contracts?style=flat-square)](https://www.npmjs.com/package/@chainlink/contracts)
[![GitHub license](https://img.shields.io/github/license/smartcontractkit/chainlink?style=flat-square)](https://github.com/smartcontractkit/chainlink/blob/master/LICENSE)
[![npm downloads](https://img.shields.io/npm/dt/@chainlink/contracts?style=flat-square)](https://npmjs.com/package/@chainlink/contracts)
## ⚠️ Migration Notice
This package stores all of chainlink's smart contracts, previously known as the `evm/` directory. The previous package was called `chainlink`, now it is `@chainlink/contracts`.
## Installation
```sh
# via Yarn
$ yarn add @chainlink/contracts
# via npm
$ npm install @chainlink/contracts --save
```
## Directory Structure
This package makes use of `@chainlink/belt` to output artifacts along with ethers.js and truffle contract abstractions from the smart contracts stored within `src`. The resulting structure of the package when published looks like:
```sh
contracts
├── abi # abi output from src/
│ ├── v0.4
│ ├── v0.5
│ ├── v0.6
│ ├── v0.7
│ └── v0.8
├── ethers # ethers contract abstractions codegenned from abis
│ ├── v0.4
│ ├── v0.5
│ ├── v0.6
│ ├── v0.7
│ └── v0.8
├── src # the contracts themselves, in .sol form
│ ├── v0.4
│ ├── v0.5
│ ├── v0.6
│ ├── v0.7
│ └── v0.8
└── truffle # truffle contract abstractions codegenned from abis
├── v0.4
├── v0.5
├── v0.6
├── v0.7
└── v0.8
```
## Usage
These smart contracts can be imported as a dependency in various ways described below.
### Solidity
The solidity smart contracts themselves can simply be imported via the `src` directory of `@chainlink/contracts`. If you wanted to consume the v0.4.x version of our Oracle smart contract, you could do the following:
```solidity
import "@chainlink/contracts/src/v0.4/Chainlinked.sol";
```
### Artifacts
JSON artifacts generated by [sol-compiler](https://sol-compiler.com/) are available under the `abi` directory. If you wanted to consume the v0.4.x version of our Oracle JSON artifact with Javascript, you could do the following:
```js
const OracleV4Json = require('@chainlink/contracts/abi/v0.4/Oracle.json')
```
### Ethers
This library ships with [ethers.js](https://github.com/ethers-io/ethers.js/) contract abstractions generated by [typechain](https://github.com/ethereum-ts/TypeChain). To use these, make sure you have ethers.js installed as a dependency:
```sh
# via Yarn
$ yarn add [email protected]^4.0.44
# via npm
$ npm install [email protected]^4.0.44 --save
```
If you wanted to consume the v0.4.x version of our Oracle with JavaScript, you could do the following:
```ts
import { OracleFactory } from '@chainlink/contracts/ethers/v0.4/OracleFactory'
```
This gives a fully typed (if using TypeScript) version of a ethers.js contract factory. See the [ethers.js](https://docs.ethers.io/ethers.js/html/api-contract.html) documentation on usage.
### Truffle
This library ships with [@truffle/contract](https://github.com/trufflesuite/truffle/tree/master/packages/contract#readme) abstractions of each of our smart contracts. To use these, make sure you have @truffle/contract as a dependency.
```sh
# via Yarn
$ yarn add @truffle/[email protected]^4.1.8
# via npm
$ npm install @truffle/[email protected]^4.1.8 --save
```
If you wanted to consume the v0.4.x version of our Oracle with JavaScript, you could do the following:
```js
const { Oracle } = require('@chainlink/contracts/truffle/v0.4/Oracle')
```
For usage, see the [@truffle/contract](https://github.com/trufflesuite/truffle/tree/master/packages/contract#readme) documentation.
For ease of use with testing, if the environment variable `NODE_ENV` is set, the imported truffle contract abstraction will automatically set its provider to `web3.currentProvider`, avoiding the need to perform a `setProvider` call before using it during your truffle tests.
```sh
NODE_ENV=true yarn truffle test
```
## Development
Note: Contracts in `src/v0.7/dev` are under active development and not yet stable.
Please use them for testing and development only.
```bash
# Clone Chainlink repository
$ git clone https://github.com/smartcontractkit/chainlink.git
# Continuing via Yarn
$ yarn install
$ yarn setup:contracts
# Continuing via npm
$ npm install
$ npm run setup:contracts
```
## Testing
After completing the above [Development](#Development) commands, run tests with:
```sh
# From this directory, `evm-contracts` via Yarn
$ yarn test
# via npm
$ npm run test
# From project root
$ yarn wsrun @chainlink/contracts test
```
## Contributing
Contributions are welcome! Please refer to
[Chainlink's contributing guidelines](./docs/CONTRIBUTING.md) for detailed
contribution information.
Thank you!
## License
[MIT](https://choosealicense.com/licenses/mit/)
{
"schemaVersion": "2.0.0",
"contractName": "AggregatorInterface",
"compilerOutput": {
"abi": [
{
"constant": true,
"inputs": [],
"name": "latestAnswer",
"outputs": [
{
"name": "",
"type": "int256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "latestRound",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "latestTimestamp",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "roundId",
"type": "uint256"
}
],
"name": "getAnswer",
"outputs": [
{
"name": "",
"type": "int256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "roundId",
"type": "uint256"
}
],
"name": "getTimestamp",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "current",
"type": "int256"
},
{
"indexed": true,
"name": "roundId",
"type": "uint256"
},
{
"indexed": false,
"name": "timestamp",
"type": "uint256"
}
],
"name": "AnswerUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "roundId",
"type": "uint256"
},
{
"indexed": true,
"name": "startedBy",
"type": "address"
},
{
"indexed": false,
"name": "startedAt",
"type": "uint256"
}
],
"name": "NewRound",
"type": "event"
}
],
"devdoc": {
"methods": {}
},
"evm": {
"bytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
},
"deployedBytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
},
"methodIdentifiers": {
"getAnswer(uint256)": "b5ab58dc",
"getTimestamp(uint256)": "b633620c",
"latestAnswer()": "50d25bcd",
"latestRound()": "668a0f02",
"latestTimestamp()": "8205bf6a"
}
},
"metadata": "",
"userdoc": {
"methods": {}
}
},
"sources": {
"interfaces/AggregatorInterface.sol": {
"id": 9
}
},
"sourceCodes": {
"interfaces/AggregatorInterface.sol": "pragma solidity >=0.4.24;\n\ninterface AggregatorInterface {\n function latestAnswer() external view returns (int256);\n function latestTimestamp() external view returns (uint256);\n function latestRound() external view returns (uint256);\n function getAnswer(uint256 roundId) external view returns (int256);\n function getTimestamp(uint256 roundId) external view returns (uint256);\n\n event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 timestamp);\n event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);\n}\n"
},
"sourceTreeHashHex": "0xb21fa756e241d3fbfe7546158a7e1bb4a98f261744751c4e9dfe5f474ea46338",
"compiler": {
"name": "solc",
"version": "soljson-v0.4.24+commit.e67f0147.js",
"settings": {
"optimizer": {
"runs": 1000000,
"enabled": true
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"userdoc",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap",
"evm.methodIdentifiers",
"metadata"
]
}
},
"metadata": {
"bytecodeHash": "none"
},
"remappings": []
}
},
"chains": {}
}
\ No newline at end of file
{
"schemaVersion": "2.0.0",
"contractName": "AggregatorV3Interface",
"compilerOutput": {
"abi": [
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "version",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "description",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "_roundId",
"type": "uint80"
}
],
"name": "getRoundData",
"outputs": [
{
"name": "roundId",
"type": "uint80"
},
{
"name": "answer",
"type": "int256"
},
{
"name": "startedAt",
"type": "uint256"
},
{
"name": "updatedAt",
"type": "uint256"
},
{
"name": "answeredInRound",
"type": "uint80"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "latestRoundData",
"outputs": [
{
"name": "roundId",
"type": "uint80"
},
{
"name": "answer",
"type": "int256"
},
{
"name": "startedAt",
"type": "uint256"
},
{
"name": "updatedAt",
"type": "uint256"
},
{
"name": "answeredInRound",
"type": "uint80"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"devdoc": {
"methods": {}
},
"evm": {
"bytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
},
"deployedBytecode": {
"linkReferences": {},
"object": "0x",
"opcodes": "",
"sourceMap": ""
},
"methodIdentifiers": {
"decimals()": "313ce567",
"description()": "7284e416",
"getRoundData(uint80)": "9a6fc8f5",
"latestRoundData()": "feaf968c",
"version()": "54fd4d50"
}
},
"metadata": "",
"userdoc": {
"methods": {}
}
},
"sources": {
"interfaces/AggregatorV3Interface.sol": {
"id": 10
}
},
"sourceCodes": {
"interfaces/AggregatorV3Interface.sol": "pragma solidity >=0.4.24;\n\ninterface AggregatorV3Interface {\n\n function decimals() external view returns (uint8);\n function description() external view returns (string memory);\n function version() external view returns (uint256);\n\n // getRoundData and latestRoundData should both raise \"No data present\"\n // if they do not have data to report, instead of returning unset values\n // which could be misinterpreted as actual reported values.\n function getRoundData(uint80 _roundId)\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n function latestRoundData()\n external\n view\n returns (\n uint80 roundId,\n int256 answer,\n uint256 startedAt,\n uint256 updatedAt,\n uint80 answeredInRound\n );\n\n}\n"
},
"sourceTreeHashHex": "0xbf26d0dca0e2815b7c0bd09bddc9ceca339b8c9c2319ca74b2555273f5cbc19c",
"compiler": {
"name": "solc",
"version": "soljson-v0.4.24+commit.e67f0147.js",
"settings": {
"optimizer": {
"runs": 1000000,
"enabled": true
},
"outputSelection": {
"*": {
"*": [
"abi",
"devdoc",
"userdoc",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap",
"evm.methodIdentifiers",
"metadata"
]
}
},
"metadata": {
"bytecodeHash": "none"
},
"remappings": []
}
},
"chains": {}
}
\ No newline at end of file
{
"schemaVersion": "2.0.0",
"contractName": "BasicToken",
"compilerOutput": {
"abi": [
{
"constant": true,
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"name": "",
"type": "uint256"
}
],