Skip to content

Commit 88032a3

Browse files
authored
Merge pull request #81 from smartcontractkit/only-webpack-and-anvil
DEVSVCS-1213: replace Ganache with Anvil and upgrade webpack and remove esmify
2 parents 743f0d3 + 4a7a60c commit 88032a3

12 files changed

+2518
-8618
lines changed

.github/workflows/test-package.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
with:
1919
node-version: 18
2020

21+
- name: setup-foundry
22+
uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c # v1.3.1
23+
2124
- name: Install dependencies
2225
run: npm install # npm install instead of npm ci is used to prevent unsupported platform errors due to the fsevents sub-dependency --no-optional
2326

.github/workflows/test.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
with:
2222
node-version: 18
2323

24+
- name: setup-foundry
25+
uses: foundry-rs/foundry-toolchain@de808b1eea699e761c404bda44ba8f21aba30b2c # v1.3.1
26+
2427
- name: Install dependencies
2528
run: npm install # npm install instead of npm ci is used to prevent unsupported platform errors due to the fsevents sub-dependency
2629

Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Makefile
2+
3+
# Define the default target
4+
.PHONY: all
5+
all: install
6+
7+
# Install Foundry and npm packages
8+
.PHONY: install
9+
install:
10+
@echo "Installing Foundry..."
11+
curl -L https://foundry.paradigm.xyz | bash
12+
@echo "Installing npm packages..."
13+
npm install
14+
15+
# Clean up the project
16+
.PHONY: clean
17+
clean:
18+
@echo "Cleaning up..."
19+
rm -rf node_modules
20+
rm -rf dist

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Up-to-date documentation on Chainlink Functions can be found [here](https://docs
3838

3939
Install Node.js version `18.18.0` or higher _and_ Deno version `1.36.0` or higher.
4040

41+
For version 0.3.2 and above of this functions-toolkit package, Anvil is required to run local tests. A `Makefile` is included to automate the installation and build process. Simply run `make install` to install Anvil and all npm packages.
42+
If you already have anvil and/or foundry (the Foundry toolchain) installed, you would not need to run this. But you may want to run `foundryup` to update your version and `npm install` to install packages.
43+
4144
Chainlink Functions requires signing a terms of service agreement before creating a billing subscription. See this [getting started](https://docs.chain.link/chainlink-functions/getting-started) section in the docs.
4245

4346
## Functions Billing Subscription Management
@@ -593,14 +596,16 @@ return Functions.encodeString(escape("$hello*world?"));
593596

594597
### Local Functions Testnet
595598

599+
> **Note**
600+
> For version 0.3.2 and above of this functions-toolkit package, Anvil is REQUIRED to use `localFunctionsTestnet`. Please run `make install` to install Anvil and all the necessary dependencies. If you already have anvil and/or foundry (the Foundry toolchain) installed, you would not need to run this. But you may want to run `foundryup` to update your version and `npm install` to install packages.
601+
596602
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]`).
597603

598604
The `localFunctionsTestnet` function takes the following values as arguments.
599605

600606
```
601607
const localFunctionsTestnet = await startLocalFunctionsTestnet(
602608
simulationConfigPath?: string // Absolute path to config file which exports simulation config parameters
603-
options?: ServerOptions, // Ganache server options
604609
port?: number, // Defaults to 8545
605610
)
606611
```
@@ -623,10 +628,10 @@ export const maxQueryResponseBytes = 2097152 // Maximum size of incoming HTTP re
623628

624629
```
625630
{
626-
server: Server // Ganache server
631+
anvil: Anvil // Anvil instance
627632
adminWallet: { address: string, privateKey: string } // Funded admin wallet
628633
getFunds: (address: string, { weiAmount, juelsAmount }: { weiAmount?: BigInt | string; juelsAmount?: BigInt | string }) => Promise<void> // Method which can be called to send funds to any address
629-
close: () => Promise<void> // Method to close the server
634+
close: () => Promise<void> // Method to stop the Anvil instance
630635
donId: string // DON ID for simulated DON
631636
// The following values are all Ethers.js contract types: https://docs.ethers.org/v5/api/contract/contract/
632637
linkTokenContract: Contract // Mock LINK token contract

0 commit comments

Comments
 (0)