Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmanaa committed Dec 14, 2023
1 parent 4a21678 commit 7290f57
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/content/chainlink-functions/tutorials/importing-packages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,31 @@ This tutorial demonstrates how to import modules and use them with your Function
- Up to 20 imports total are supported.
- Deno supports [ESM compatible NPM imports](https://docs.deno.com/runtime/manual/node/npm_specifiers) and some [standard Node modules](https://docs.deno.com/runtime/manual/node/node_specifiers). See the [Compatability List](https://docs.deno.com/runtime/manual/node/compatibility) for details.
- Third-party modules are imported at runtime, so import statements must use asynchronous logic like the following examples:
- Importing from `deno.land`: `const { escape } = await import("https://deno.land/std/regexp/mod.ts");`
- ESM-compatible packages: `const { format } = await import("npm:date-fns");`
- Standard Node modules: `const path = await import("node:path");`
- CDN imports: `const lodash = await import("http://cdn.skypack.dev/lodash");`

- Importing from `deno.land`:

```javascript
const { escape } = await import("https://deno.land/std/regexp/mod.ts")
```

- ESM-compatible packages:

```javascript
const { format } = await import("npm:date-fns")
```

- Standard Node modules:

```javascript
const path = await import("node:path")
```

- CDN imports:

```javascript
const lodash = await import("http://cdn.skypack.dev/lodash")
```

- Imported modules abide by all sandbox restrictions and do not have access to the file system, environment variables, or any other Deno permissions.

<Aside type="caution">
Expand Down Expand Up @@ -124,7 +145,7 @@ class FunctionsJsonRpcProvider extends ethers.JsonRpcProvider {
super(url)
this.url = url
}
async _send(payload: ethers.JsonRpcPayload | Array<ethers.JsonRpcPayload>): Promise<Array<ethers.JsonRpcResult>> {
async _send(payload) {
let resp = await fetch(this.url, {
method: "POST",
headers: { "Content-Type": "application/json" },
Expand Down
1 change: 1 addition & 0 deletions src/content/chainlink-functions/tutorials/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ import { Aside } from "@components"
- [Encode request data off-chain](/chainlink-functions/tutorials/encode-request-offchain)
- [Automate your Functions (Time-based Automation)](/chainlink-functions/tutorials/automate-functions)
- [Automate your Functions (Custom Logic Automation)](/chainlink-functions/tutorials/automate-functions-custom-logic)
- [Using Imports with Functions](/chainlink-functions/tutorials/importing-packages)

0 comments on commit 7290f57

Please sign in to comment.