Skip to content

Commit

Permalink
Provider connection not being recognized.
Browse files Browse the repository at this point in the history
  • Loading branch information
zeuslawyer committed Dec 21, 2023
1 parent adafbac commit 20b5b4d
Show file tree
Hide file tree
Showing 8 changed files with 1,842 additions and 249 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ return Functions.encodeString(escape("$hello*world?"));
**_NOTE:_** The `simulateScript` function is a debugging tool and hence is not a perfect representation of the actual Chainlink oracle execution environment. Therefore, it is important to make a Functions request on a supported testnet blockchain before mainnet usage.

### Local Functions Testnet
> **Note**
> Anvil is required to use `localFunctionsTestnet`. Please refer to the [foundry book](https://book.getfoundry.sh) for Anvil [installation instructions](https://book.getfoundry.sh/getting-started/installation).
For debugging smart contracts and the end-to-end request flow on your local machine, you can use the `localFunctionsTestnet` function. This creates a local testnet RPC node with a mock Chainlink Functions contracts. You can then deploy your own Functions consumer contract to this local network, create and manage subscriptions, and send requests. Request processing will simulate the behavior of an actual DON where the request is executed 4 times and the discrete median response is transmitted back to the consumer contract. (Note that Chainlink Functions uses the following calculation to select the discrete median response: `const medianResponse = responses[responses.length - 1) / 2]`).

Expand All @@ -596,11 +598,12 @@ The `localFunctionsTestnet` function takes the following values as arguments.
```
const localFunctionsTestnet = await startLocalFunctionsTestnet(
simulationConfigPath?: string // Absolute path to config file which exports simulation config parameters
options?: ServerOptions, // Ganache server options
port?: number, // Defaults to 8545
options?: ServerOptions, // Anvil server options (See: https://www.npmjs.com/package/@viem/anvil#api and https://book.getfoundry.sh/reference/anvil/)
)
```

`ServerOptions` is optional, and ships with a default `port` of 8545 and the default `test test test...junk` BIP39 mnemonic.

Observe that `localFunctionsTestnet` takes in a `simulationConfigPath` string as an optional argument. The primary reason for this is because the local testnet does not have the ability to access or decrypt encrypted secrets provided within request transactions. Instead, you can export an object named `secrets` from a TypeScript or JavaScript file and provide the absolute path to that file as the `simulationConfigPath` argument. When the JavaScript code is executed during the request, secrets specified in that file will be made accessible within the JavaScript code regardless of the `secretsLocation` or `encryptedSecretsReference` values sent in the request transaction. This config file can also contain other simulation config parameters. An example of this config file is shown below.

```
Expand All @@ -619,7 +622,7 @@ export const maxQueryResponseBytes = 2097152 // Maximum size of incoming HTTP re

```
{
server: Server // Ganache server
server: Server // Anvil server
adminWallet: { address: string, privateKey: string } // Funded admin wallet
getFunds: (address: string, { weiAmount, juelsAmount }: { weiAmount?: BigInt | string; juelsAmount?: BigInt | string }) => Promise<void> // Method which can be called to send funds to any address
close: () => Promise<void> // Method to close the server
Expand Down
Binary file added chainlink-functions-toolkit-0.2.8.tgz
Binary file not shown.
188 changes: 174 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
"@types/jest": "^29.5.1",
"@types/node": "^18.16.3",
"@types/prettier": "^2.7.3",
"babel-loader": "9.1.2",
"browserify": "17.0.0",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"babel-loader": "9.1.2",
"browserify": "17.0.0",
"cpy-cli": "^5.0.0",
"esmify": "2.1.1",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"esmify": "2.1.1",
"jest": "^29.5.0",
"nock": "^13.3.1",
"prettier": "^3.0.3",
Expand All @@ -72,6 +72,7 @@
"proseWrap": "preserve"
},
"dependencies": {
"@viem/anvil": "^0.0.7",
"axios": "^1.4.0",
"bcrypto": "^5.4.0",
"cbor": "^9.0.1",
Expand Down
Loading

0 comments on commit 20b5b4d

Please sign in to comment.