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 f3323ad27ac..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. @@ -135,7 +136,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 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. **Note**: The `url` passed in the constructor is the URL of the JSON RPC provider. ```javascript // Chainlink Functions compatible Ethers JSON RPC provider class @@ -156,7 +159,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) 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"