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 126 of 126+ 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": "Aggregator",
"compilerOutput": {
"abi": [
{
"constant": false,
"inputs": [
{
"name": "_requestId",
"type": "bytes32"
},
{
"name": "_payment",
"type": "uint256"
},
{
"name": "_expiration",
"type": "uint256"
}
],
"name": "cancelRequest",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "address"
}
],
"name": "authorizedRequesters",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"name": "jobIds",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "latestAnswer",
"outputs": [
{
"name": "",
"type": "int256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "minimumResponses",
"outputs": [
{
"name": "",
"type": "uint128"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"name": "oracles",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_recipient",
"type": "address"
},
{
"name": "_amount",
"type": "uint256"
}
],
"name": "transferLINK",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "latestRound",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_clRequestId",
"type": "bytes32"
},
{
"name": "_response",
"type": "int256"
}
],
"name": "chainlinkCallback",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_paymentAmount",
"type": "uint128"
},
{
"name": "_minimumResponses",
"type": "uint128"
},
{
"name": "_oracles",
"type": "address[]"
},
{
"name": "_jobIds",
"type": "bytes32[]"
}
],
"name": "updateRequestDetails",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "latestTimestamp",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "destroy",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "owner",
"outputs": [
{
"name": "",
"type": "address"
}
],
"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"
},
{
"constant": true,
"inputs": [],
"name": "paymentAmount",
"outputs": [
{
"name": "",
"type": "uint128"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "requestRateUpdate",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_requester",
"type": "address"
},
{
"name": "_allowed",
"type": "bool"
}
],
"name": "setAuthorization",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"name": "_link",
"type": "address"
},
{
"name": "_paymentAmount",
"type": "uint128"
},
{
"name": "_minimumResponses",
"type": "uint128"
},
{
"name": "_oracles",
"type": "address[]"
},
{
"name": "_jobIds",
"type": "bytes32[]"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "response",
"type": "int256"
},
{
"indexed": true,
"name": "answerId",
"type": "uint256"
},
{
"indexed": true,
"name": "sender",
"type": "address"
}
],
"name": "ResponseReceived",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
}
],
"name": "OwnershipRenounced",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,