Skip to content

Commit

Permalink
Chainlink Contracts v1 update (#1762)
Browse files Browse the repository at this point in the history
* Update docs for contracts NPM 1-0-0

* Update URLs update imports and update function names

* Functions: correct links

* pin versions to solidity files at the end of the build (#1763)

* Update package-lock.json

* Re-update paths

* Update Automation example import

* Remove outdated Functions example

* Use OwnerIsCreator to align with project's OZ version

* Update other packages

* Fix imports for new Data Streams contracts

* Update contracts to beta.1

* Update other packages

* Restore LinkToken.json import

* Resolve compile issue?

* StreamsUpkeep update

* StreamsUpkeep update

* General package updates

* Update Streams for beta.1 contracts (#1829)

* Update @chainlink/contracts to 1.0.0 latest version

* Update all

---------

Co-authored-by: aelmanaa <aelmanaa@gmail.com>
Co-authored-by: Amine E <aelmanaa@users.noreply.github.com>
Co-authored-by: Karim <98668332+khadni@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 25, 2024
1 parent 0b489d7 commit 34fab72
Show file tree
Hide file tree
Showing 63 changed files with 2,335 additions and 924 deletions.
2,618 changes: 2,032 additions & 586 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@11ty/eleventy-fetch": "^4.0.0",
"@11ty/eleventy-fetch": "^4.0.1",
"@astro-community/astro-embed-youtube": "^0.4.4",
"@astrojs/mdx": "^2.1.1",
"@astrojs/mdx": "^2.2.1",
"@astrojs/partytown": "^2.0.4",
"@astrojs/preact": "^3.1.1",
"@astrojs/prism": "^3.0.0",
"@astrojs/react": "^3.0.10",
"@astrojs/react": "^3.1.0",
"@astrojs/sitemap": "^3.1.1",
"@chainlink/components": "^0.4.14",
"@chainlink/contracts": "0.8.0",
"@chainlink/contracts-ccip": "1.4.0",
"@chainlink/components": "^0.4.15",
"@chainlink/contracts": "^1.0.0",
"@chainlink/contracts-ccip": "^1.4.0",
"@chainlink/design-system": "^0.1.50",
"@chainlink/solana-sdk": "^0.2.2",
"@metamask/detect-provider": "^2.0.0",
"@metamask/providers": "^10.2.1",
"@nanostores/preact": "^0.5.1",
"@nanostores/react": "^0.7.2",
"@openzeppelin/contracts": "^4.9.6",
"astro": "^4.4.8",
"astro": "^4.5.9",
"bignumber.js": "^9.1.2",
"clipboard": "^2.0.11",
"dotenv": "^16.4.5",
Expand All @@ -56,7 +56,7 @@
"github-slugger": "^2.0.0",
"lodash": "^4.17.21",
"nanostores": "^0.9.5",
"preact": "^10.19.6",
"preact": "^10.20.1",
"react-instantsearch": "^7.7.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",
Expand All @@ -67,8 +67,8 @@
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@project-serum/anchor": "^0.26.0",
"@types/node": "^20.11.24",
"@types/react": "^18.2.61",
"@types/node": "^20.11.30",
"@types/react": "^18.2.70",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.57.0",
Expand All @@ -78,7 +78,7 @@
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"hardhat": "^2.20.1",
"hardhat": "^2.22.2",
"husky": "^8.0.3",
"lint-staged": "^13.3.0",
"prettier": "^2.8.8",
Expand All @@ -89,7 +89,7 @@
"solhint-plugin-prettier": "^0.0.5",
"ts-jest": "^29.1.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.3.3"
"typescript": "^5.4.3"
},
"lint-staged": {
"*.{css,md,mdx,yml,yaml,astro}": "prettier --write",
Expand Down
Binary file not shown.
16 changes: 8 additions & 8 deletions public/samples/APIRequests/APIConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ contract APIConsumer is ChainlinkClient, ConfirmedOwner {
*
*/
constructor() ConfirmedOwner(msg.sender) {
setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
_setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
_setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
jobId = "ca98366cc7314957b8c012c72f05aeeb";
fee = (1 * LINK_DIVISIBILITY) / 10; // 0,1 * 10**18 (Varies by network and job)
}
Expand All @@ -46,14 +46,14 @@ contract APIConsumer is ChainlinkClient, ConfirmedOwner {
* data, then multiply by 1000000000000000000 (to remove decimal places from data).
*/
function requestVolumeData() public returns (bytes32 requestId) {
Chainlink.Request memory req = buildChainlinkRequest(
Chainlink.Request memory req = _buildChainlinkRequest(
jobId,
address(this),
this.fulfill.selector
);

// Set the URL to perform the GET request on
req.add(
req._add(
"get",
"https://min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=USD"
);
Expand All @@ -69,14 +69,14 @@ contract APIConsumer is ChainlinkClient, ConfirmedOwner {
// }
// }
// request.add("path", "RAW.ETH.USD.VOLUME24HOUR"); // Chainlink nodes prior to 1.0.0 support this format
req.add("path", "RAW,ETH,USD,VOLUME24HOUR"); // Chainlink nodes 1.0.0 and later support this format
req._add("path", "RAW,ETH,USD,VOLUME24HOUR"); // Chainlink nodes 1.0.0 and later support this format

// Multiply the result by 1000000000000000000 to remove decimals
int256 timesAmount = 10 ** 18;
req.addInt("times", timesAmount);
req._addInt("times", timesAmount);

// Sends the request
return sendChainlinkRequest(req, fee);
return _sendChainlinkRequest(req, fee);
}

/**
Expand All @@ -94,7 +94,7 @@ contract APIConsumer is ChainlinkClient, ConfirmedOwner {
* Allow withdraw of Link tokens from the contract
*/
function withdrawLink() public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress());
require(
link.transfer(msg.sender, link.balanceOf(address(this))),
"Unable to transfer"
Expand Down
26 changes: 13 additions & 13 deletions public/samples/APIRequests/APIConsumerForwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ contract APIConsumerForwarder is ChainlinkClient, ConfirmedOwner {
* @dev Check https://docs.chain.link/docs/link-token-contracts/ for LINK address for the right network
*/
constructor() ConfirmedOwner(msg.sender) {
setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
_setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
}

function requestEthereumPrice(
address _oracle,
string memory _jobId
) public onlyOwner {
Chainlink.Request memory req = buildChainlinkRequest(
Chainlink.Request memory req = _buildChainlinkRequest(
stringToBytes32(_jobId),
address(this),
this.fulfillEthereumPrice.selector
);
req.add(
req._add(
"get",
"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD"
);
req.add("path", "USD");
req.addInt("times", 100);
sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
req._add("path", "USD");
req._addInt("times", 100);
_sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
}

/**
Expand All @@ -58,15 +58,15 @@ contract APIConsumerForwarder is ChainlinkClient, ConfirmedOwner {
address _oracle,
string memory _jobId
) public onlyOwner {
Chainlink.Request memory req = buildChainlinkRequest(
Chainlink.Request memory req = _buildChainlinkRequest(
stringToBytes32(_jobId),
address(this),
this.fulfillFirstId.selector
);

// Set the URL to perform the GET request on
// API docs: https://www.coingecko.com/en/api/documentation?
req.add(
req._add(
"get",
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&per_page=10"
);
Expand All @@ -81,9 +81,9 @@ contract APIConsumerForwarder is ChainlinkClient, ConfirmedOwner {
// ...
// .. }]
// request.add("path", "0.id"); // Chainlink nodes prior to 1.0.0 support this format
req.add("path", "0,id"); // Chainlink nodes 1.0.0 and later support this format
req._add("path", "0,id"); // Chainlink nodes 1.0.0 and later support this format
// Sends the request
sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
_sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
}

function fulfillEthereumPrice(
Expand All @@ -106,11 +106,11 @@ contract APIConsumerForwarder is ChainlinkClient, ConfirmedOwner {
}

function getChainlinkToken() public view returns (address) {
return chainlinkTokenAddress();
return _chainlinkTokenAddress();
}

function withdrawLink() public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress());
require(
link.transfer(msg.sender, link.balanceOf(address(this))),
"Unable to transfer"
Expand All @@ -123,7 +123,7 @@ contract APIConsumerForwarder is ChainlinkClient, ConfirmedOwner {
bytes4 _callbackFunctionId,
uint256 _expiration
) public onlyOwner {
cancelChainlinkRequest(
_cancelChainlinkRequest(
_requestId,
_payment,
_callbackFunctionId,
Expand Down
18 changes: 9 additions & 9 deletions public/samples/APIRequests/ATestnetConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ contract ATestnetConsumer is ChainlinkClient, ConfirmedOwner {
* @dev Check https://docs.chain.link/docs/link-token-contracts/ for LINK address for the right network
*/
constructor() ConfirmedOwner(msg.sender) {
setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
_setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
}

function requestEthereumPrice(
address _oracle,
string memory _jobId
) public onlyOwner {
Chainlink.Request memory req = buildChainlinkRequest(
Chainlink.Request memory req = _buildChainlinkRequest(
stringToBytes32(_jobId),
address(this),
this.fulfillEthereumPrice.selector
);
req.add(
req._add(
"get",
"https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD"
);
req.add("path", "USD");
req.addInt("times", 100);
sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
req._add("path", "USD");
req._addInt("times", 100);
_sendChainlinkRequestTo(_oracle, req, ORACLE_PAYMENT);
}

function fulfillEthereumPrice(
Expand All @@ -57,11 +57,11 @@ contract ATestnetConsumer is ChainlinkClient, ConfirmedOwner {
}

function getChainlinkToken() public view returns (address) {
return chainlinkTokenAddress();
return _chainlinkTokenAddress();
}

function withdrawLink() public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress());
require(
link.transfer(msg.sender, link.balanceOf(address(this))),
"Unable to transfer"
Expand All @@ -74,7 +74,7 @@ contract ATestnetConsumer is ChainlinkClient, ConfirmedOwner {
bytes4 _callbackFunctionId,
uint256 _expiration
) public onlyOwner {
cancelChainlinkRequest(
_cancelChainlinkRequest(
_requestId,
_payment,
_callbackFunctionId,
Expand Down
14 changes: 7 additions & 7 deletions public/samples/APIRequests/FetchFromArray.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ contract FetchFromArray is ChainlinkClient, ConfirmedOwner {
*
*/
constructor() ConfirmedOwner(msg.sender) {
setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
_setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
_setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
jobId = "7d80a6386ef543a3abb52817f6707e3b";
fee = (1 * LINK_DIVISIBILITY) / 10; // 0,1 * 10**18 (Varies by network and job)
}
Expand All @@ -47,15 +47,15 @@ contract FetchFromArray is ChainlinkClient, ConfirmedOwner {
* data which is located in a list
*/
function requestFirstId() public returns (bytes32 requestId) {
Chainlink.Request memory req = buildChainlinkRequest(
Chainlink.Request memory req = _buildChainlinkRequest(
jobId,
address(this),
this.fulfill.selector
);

// Set the URL to perform the GET request on
// API docs: https://www.coingecko.com/en/api/documentation?
req.add(
req._add(
"get",
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&per_page=10"
);
Expand All @@ -70,9 +70,9 @@ contract FetchFromArray is ChainlinkClient, ConfirmedOwner {
// ...
// .. }]
// request.add("path", "0.id"); // Chainlink nodes prior to 1.0.0 support this format
req.add("path", "0,id"); // Chainlink nodes 1.0.0 and later support this format
req._add("path", "0,id"); // Chainlink nodes 1.0.0 and later support this format
// Sends the request
return sendChainlinkRequest(req, fee);
return _sendChainlinkRequest(req, fee);
}

/**
Expand All @@ -90,7 +90,7 @@ contract FetchFromArray is ChainlinkClient, ConfirmedOwner {
* Allow withdraw of Link tokens from the contract
*/
function withdrawLink() public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress());
require(
link.transfer(msg.sender, link.balanceOf(address(this))),
"Unable to transfer"
Expand Down
14 changes: 7 additions & 7 deletions public/samples/APIRequests/GenericBigWord.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ contract GenericLargeResponse is ChainlinkClient, ConfirmedOwner {
*
*/
constructor() ConfirmedOwner(msg.sender) {
setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
_setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
_setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
jobId = "7da2702f37fd48e5b1b9a5715e3509b6";
fee = (1 * LINK_DIVISIBILITY) / 10; // 0,1 * 10**18 (Varies by network and job)
}
Expand All @@ -48,17 +48,17 @@ contract GenericLargeResponse is ChainlinkClient, ConfirmedOwner {
* @notice Request variable bytes from the oracle
*/
function requestBytes() public {
Chainlink.Request memory req = buildChainlinkRequest(
Chainlink.Request memory req = _buildChainlinkRequest(
jobId,
address(this),
this.fulfillBytes.selector
);
req.add(
req._add(
"get",
"https://ipfs.io/ipfs/QmZgsvrA1o1C8BGCrx6mHTqR1Ui1XqbCrtbMVrRLHtuPVD?filename=big-api-response.json"
);
req.add("path", "image");
sendChainlinkRequest(req, fee);
req._add("path", "image");
_sendChainlinkRequest(req, fee);
}

event RequestFulfilled(bytes32 indexed requestId, bytes indexed data);
Expand All @@ -80,7 +80,7 @@ contract GenericLargeResponse is ChainlinkClient, ConfirmedOwner {
* Allow withdraw of Link tokens from the contract
*/
function withdrawLink() public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress());
require(
link.transfer(msg.sender, link.balanceOf(address(this))),
"Unable to transfer"
Expand Down
10 changes: 5 additions & 5 deletions public/samples/APIRequests/GetGasPrice.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ contract GetGasPrice is ChainlinkClient, ConfirmedOwner {
*
*/
constructor() ConfirmedOwner(msg.sender) {
setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
_setChainlinkToken(0x779877A7B0D9E8603169DdbD7836e478b4624789);
_setChainlinkOracle(0x6090149792dAAeE9D1D568c9f9a6F6B46AA29eFD);
jobId = "7223acbd01654282865b678924126013";
fee = (1 * LINK_DIVISIBILITY) / 10; // 0,1 * 10**18 (Varies by network and job)
}
Expand All @@ -53,13 +53,13 @@ contract GetGasPrice is ChainlinkClient, ConfirmedOwner {
* Create a Chainlink request the gas price from Etherscan
*/
function requestGasPrice() public returns (bytes32 requestId) {
Chainlink.Request memory req = buildChainlinkRequest(
Chainlink.Request memory req = _buildChainlinkRequest(
jobId,
address(this),
this.fulfill.selector
);
// No need extra parameters for this job. Send the request
return sendChainlinkRequest(req, fee);
return _sendChainlinkRequest(req, fee);
}

/**
Expand All @@ -86,7 +86,7 @@ contract GetGasPrice is ChainlinkClient, ConfirmedOwner {
* Allow withdraw of Link tokens from the contract
*/
function withdrawLink() public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
LinkTokenInterface link = LinkTokenInterface(_chainlinkTokenAddress());
require(
link.transfer(msg.sender, link.balanceOf(address(this))),
"Unable to transfer"
Expand Down
Loading

0 comments on commit 34fab72

Please sign in to comment.