From 9f4e12a11464f7e90d4b2a9214610e4472760173 Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Tue, 9 Jan 2024 18:19:03 +0100 Subject: [PATCH 1/5] explain _send override --- .../chainlink-functions/tutorials/importing-packages.mdx | 4 +++- src/features/chainlink-functions/common/DenoImportNotes.mdx | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/content/chainlink-functions/tutorials/importing-packages.mdx b/src/content/chainlink-functions/tutorials/importing-packages.mdx index 83d6f3409ae..64169dd9eb0 100644 --- a/src/content/chainlink-functions/tutorials/importing-packages.mdx +++ b/src/content/chainlink-functions/tutorials/importing-packages.mdx @@ -135,7 +135,9 @@ The Decentralized Oracle Network will run the [JavaScript code](https://github.c -The example `source.js` file uses an Ethers JSON RPC call to the [`latestRoundData()` function](/data-feeds/api-reference#latestrounddata) of a [Chainlink Data Feed](/data-feeds). The request requires a few modifications to work in the Chainlink Functions environment. For example, the `JsonRpcProvider` class must be modified to handle the request asynchronously. +The example `source.js` file uses anJSON RPC call to the [`latestRoundData()` function](/data-feeds/api-reference#latestrounddata) of a [Chainlink Data Feed](/data-feeds). + +The request requires a few modifications to work in the Chainlink Functions environment. For example, the `JsonRpcProvider` class must be inherited to override the JsonRpcProvider [`_send` method](https://docs.ethers.org/v6/api/providers/jsonrpc/#JsonRpcProvider). This customization is necessary because Deno does not natively support Node.js modules like [http](https://nodejs.org/api/http.html) or [https](https://nodejs.org/api/https.html). We override the `_send` method to use the [fetch API](https://deno.land/api@v1.39.2?s=fetch), which is the standard way to make HTTP(s) requests in Deno. ```javascript // Chainlink Functions compatible Ethers JSON RPC provider class diff --git a/src/features/chainlink-functions/common/DenoImportNotes.mdx b/src/features/chainlink-functions/common/DenoImportNotes.mdx index 64decf6cc76..1cc628abbcc 100644 --- a/src/features/chainlink-functions/common/DenoImportNotes.mdx +++ b/src/features/chainlink-functions/common/DenoImportNotes.mdx @@ -3,4 +3,7 @@ import { Aside } from "@components" From fbcd999637ff569a0cdbcb5893d1b73345092291 Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Tue, 9 Jan 2024 18:25:34 +0100 Subject: [PATCH 2/5] explain _send override --- .../chainlink-functions/tutorials/importing-packages.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/chainlink-functions/tutorials/importing-packages.mdx b/src/content/chainlink-functions/tutorials/importing-packages.mdx index 64169dd9eb0..d7cd1739088 100644 --- a/src/content/chainlink-functions/tutorials/importing-packages.mdx +++ b/src/content/chainlink-functions/tutorials/importing-packages.mdx @@ -135,7 +135,7 @@ The Decentralized Oracle Network will run the [JavaScript code](https://github.c -The example `source.js` file uses anJSON RPC call to the [`latestRoundData()` function](/data-feeds/api-reference#latestrounddata) of a [Chainlink Data Feed](/data-feeds). +The example `source.js` file uses a JSON RPC call to the [`latestRoundData()` function](/data-feeds/api-reference#latestrounddata) of a [Chainlink Data Feed](/data-feeds). The request requires a few modifications to work in the Chainlink Functions environment. For example, the `JsonRpcProvider` class must be inherited to override the JsonRpcProvider [`_send` method](https://docs.ethers.org/v6/api/providers/jsonrpc/#JsonRpcProvider). This customization is necessary because Deno does not natively support Node.js modules like [http](https://nodejs.org/api/http.html) or [https](https://nodejs.org/api/https.html). We override the `_send` method to use the [fetch API](https://deno.land/api@v1.39.2?s=fetch), which is the standard way to make HTTP(s) requests in Deno. From 464ce8417e25324f7128fcda527d2b3bac7a6481 Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Thu, 11 Jan 2024 15:31:08 +0100 Subject: [PATCH 3/5] fix disclaimer --- .../chainlink-functions/tutorials/importing-packages.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/chainlink-functions/tutorials/importing-packages.mdx b/src/content/chainlink-functions/tutorials/importing-packages.mdx index 99204f5a922..78fbc78f064 100644 --- a/src/content/chainlink-functions/tutorials/importing-packages.mdx +++ b/src/content/chainlink-functions/tutorials/importing-packages.mdx @@ -51,7 +51,7 @@ This tutorial demonstrates how to import modules and use them with your Function From 707d9f5c0041d44eebc9d44211675ddb70e45c7a Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Thu, 11 Jan 2024 15:42:14 +0100 Subject: [PATCH 4/5] fix disclaimer --- .../chainlink-functions/tutorials/importing-packages.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/chainlink-functions/tutorials/importing-packages.mdx b/src/content/chainlink-functions/tutorials/importing-packages.mdx index 78fbc78f064..b6ab3a7e3c0 100644 --- a/src/content/chainlink-functions/tutorials/importing-packages.mdx +++ b/src/content/chainlink-functions/tutorials/importing-packages.mdx @@ -137,7 +137,7 @@ The Decentralized Oracle Network will run the [JavaScript code](https://github.c The example `source.js` file uses a JSON RPC call to the [`latestRoundData()` function](/data-feeds/api-reference#latestrounddata) of a [Chainlink Data Feed](/data-feeds). -The request requires a few modifications to work in the Chainlink Functions environment. For example, the `JsonRpcProvider` class must be inherited to override the JsonRpcProvider [`_send` method](https://docs.ethers.org/v6/api/providers/jsonrpc/#JsonRpcProvider). This customization is necessary because Deno does not natively support Node.js modules like [http](https://nodejs.org/api/http.html) or [https](https://nodejs.org/api/https.html). We override the `_send` method to use the [fetch API](https://deno.land/api@v1.39.2?s=fetch), which is the standard way to make HTTP(s) requests in Deno. +The request requires a few modifications to work in the Chainlink Functions environment. For example, the `JsonRpcProvider` class must be inherited to override the JsonRpcProvider [`_send` method](https://docs.ethers.org/v6/api/providers/jsonrpc/#JsonRpcProvider). This customization is necessary because Deno does not natively support Node.js modules like [http](https://nodejs.org/api/http.html) or [https](https://nodejs.org/api/https.html). We override the `_send` method to use the [fetch API](https://deno.land/api@v1.39.2?s=fetch), which is the standard way to make HTTP(s) requests in Deno. **Note**: The `url` passed in the constructor is the URL of the JSON RPC provider. ```javascript // Chainlink Functions compatible Ethers JSON RPC provider class @@ -158,7 +158,7 @@ class FunctionsJsonRpcProvider extends ethers.JsonRpcProvider { } ``` -After the class is extended, you can initialize the provider object and await the response. +After the class is extended, you can initialize the provider object with the `RPC_URL` and await the response. ```javascript const provider = new FunctionsJsonRpcProvider(RPC_URL) From 723437525d3d82ffc73512fab1aa94fd7c9f0af4 Mon Sep 17 00:00:00 2001 From: aelmanaa Date: Fri, 12 Jan 2024 21:51:29 +0100 Subject: [PATCH 5/5] support imports on mainnet --- .../chainlink-functions/resources/release-notes.mdx | 4 ++++ .../chainlink-functions/tutorials/importing-packages.mdx | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/content/chainlink-functions/resources/release-notes.mdx b/src/content/chainlink-functions/resources/release-notes.mdx index ba2b22ff71f..f0bb5b0469c 100644 --- a/src/content/chainlink-functions/resources/release-notes.mdx +++ b/src/content/chainlink-functions/resources/release-notes.mdx @@ -6,6 +6,10 @@ title: "Chainlink Functions Release Notes" import { Aside } from "@components" +## Module imports supported on mainnet - 2024-01-12 + +- You can use external module imports with Chainlink Functions source code on mainnet networks. See the [Using Imports with Functions](/chainlink-functions/tutorials/importing-packages) tutorial to see an example of how to import and use imported modules with your Functions source code. This feature requires the [Functions Toolkit NPM package](https://www.npmjs.com/package/@chainlink/functions-toolkit/v/0.2.7) `v0.2.7` or later. + ## Arbitrum Mainnet support - 2024-01-10 Chainlink Functions is available on [Arbitrum Mainnet](/chainlink-functions/supported-networks#arbitrum-mainnet). diff --git a/src/content/chainlink-functions/tutorials/importing-packages.mdx b/src/content/chainlink-functions/tutorials/importing-packages.mdx index b6ab3a7e3c0..e0beee82bb0 100644 --- a/src/content/chainlink-functions/tutorials/importing-packages.mdx +++ b/src/content/chainlink-functions/tutorials/importing-packages.mdx @@ -49,10 +49,11 @@ This tutorial demonstrates how to import modules and use them with your Function - Imported modules abide by all sandbox restrictions and do not have access to the file system, environment variables, or any other Deno permissions.