Skip to content

Commit

Permalink
chore: use sepolia instead of goerli as default testnet (#99)
Browse files Browse the repository at this point in the history
* chore: use sepolia instead of goerli as default testnet

* chore: add changeset
  • Loading branch information
goums authored Mar 25, 2024
1 parent 4375479 commit caa853d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-dolphins-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gelatonetwork/web3-functions-sdk": patch
---

chore: use sepolia instead of goerli as default testnet
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PROVIDER_URLS=https://rpc.ankr.com/eth_goerli,https://rpc.ankr.com/polygon_mumbai
PROVIDER_URLS=https://rpc.ankr.com/eth_sepolia,https://rpc.ankr.com/polygon_amoy
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ cp .env.example .env

- Complete your `.env` file with your private settings

3. Build project locally

```
yarn build
```

### Write a Web3Function

- Create a new file in `src/web3-functions`
Expand Down Expand Up @@ -113,7 +119,7 @@ Web3Function.onRun(async (context: Web3FunctionEventContext) => {
- `--logs` Show internal Web3Function logs
- `--runtime=thread|docker` Use `thread` if you don't have `docker`set up locally (default: `thread`)
- `--debug` Show Runtime debug messages
- `--chain-id=[number]` Specify the chainId to be used for your Web3Function (default: `5`)
- `--chain-id=[number]` Specify the chainId to be used for your Web3Function (default: `11155111` sepolia)
- `--onFail` Run `onFail` callback of the function
- `--onSuccess` Run `onSuccess` callback of the function
Expand All @@ -127,7 +133,7 @@ Web3Function.onRun(async (context: Web3FunctionEventContext) => {
Build time: 109.93ms

Web3Function running logs:
> ChainId: 5
> ChainId: 11155111
> Last oracle update: 1665512172
> Next oracle update: 1665512472
> Updating price: 1586
Expand Down Expand Up @@ -307,7 +313,7 @@ const config: HardhatUserConfig = {
w3f: {
rootDir: "./web3-functions", //where your Web3 Function is located
debug: false,
networks: ["mumbai", "goerli", "baseGoerli"], //(multiChainProvider) injects provider for these networks
networks: ["sepolia", "baseSepolia"], //(multiChainProvider) injects provider for these networks
},
};
```
Expand Down
4 changes: 2 additions & 2 deletions src/lib/binaries/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ export default async function test(callConfig?: Partial<CallConfig>) {
const defaultCallConfig: CallConfig = {
operation: "onRun",
userArgs: {},
chainId: 5,
chainId: 11155111,
multiChainProviderConfig: {
5: new StaticJsonRpcProvider("https://eth-goerli.public.blastapi.io"),
11155111: new StaticJsonRpcProvider("https://rpc.ankr.com/eth_sepolia"),
},
runtime: "thread",
debug: false,
Expand Down
22 changes: 13 additions & 9 deletions src/lib/provider/Web3FunctionMultiChainProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Web3FunctionProxyProvider } from "./Web3FunctionProxyProvider";

describe("Web3FunctionMultiChainProvider", () => {
enum TestChainIds {
Goerli = 5,
Mumbai = 80001,
Sepolia = 11155111,
Amoy = 80002,
}
enum TestChainProviders {
Goerli = "https://rpc.ankr.com/eth_goerli",
Mumbai = "https://rpc.ankr.com/polygon_mumbai",
Sepolia = "https://rpc.ankr.com/eth_sepolia",
Amoy = "https://rpc.ankr.com/polygon_amoy",
}

let proxyProvider: Web3FunctionProxyProvider;
Expand All @@ -23,14 +23,16 @@ describe("Web3FunctionMultiChainProvider", () => {
const proxyProviderPort = 3000;

const multiChainProviderConfig = {
5: new StaticJsonRpcProvider(TestChainProviders.Goerli),
80001: new StaticJsonRpcProvider(TestChainProviders.Mumbai),
[TestChainIds.Sepolia]: new StaticJsonRpcProvider(
TestChainProviders.Sepolia
),
[TestChainIds.Amoy]: new StaticJsonRpcProvider(TestChainProviders.Amoy),
};

proxyProvider = new Web3FunctionProxyProvider(
proxyProviderHost,
rpcLimit,
TestChainIds.Goerli,
TestChainIds.Sepolia,
multiChainProviderConfig,
false
);
Expand All @@ -39,7 +41,7 @@ describe("Web3FunctionMultiChainProvider", () => {

multichainProvider = new Web3FunctionMultiChainProvider(
proxyProvider.getProxyUrl(),
5,
TestChainIds.Sepolia,
() => {
rateLimitInvoked = true;
}
Expand All @@ -51,7 +53,9 @@ describe("Web3FunctionMultiChainProvider", () => {
});

test("should get default provider with chainId", async () => {
const chainNetwork = await multichainProvider.chainId(5).getNetwork();
const chainNetwork = await multichainProvider
.chainId(11155111)
.getNetwork();
const mainChainNetwork = await multichainProvider.default().getNetwork();

expect(chainNetwork.chainId).toEqual(mainChainNetwork.chainId);
Expand Down
22 changes: 12 additions & 10 deletions src/lib/provider/Web3FunctionProxyProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { Agent, request } from "undici";

describe("Web3FunctionProxyProvider", () => {
enum TestChainIds {
Goerli = 5,
Mumbai = 80001,
Sepolia = 11155111,
Amoy = 80002,
}
enum TestChainProviders {
Goerli = "https://rpc.ankr.com/eth_goerli",
Mumbai = "https://rpc.ankr.com/polygon_mumbai",
Sepolia = "https://rpc.ankr.com/eth_sepolia",
Amoy = "https://rpc.ankr.com/polygon_amoy",
}

let proxyProvider: Web3FunctionProxyProvider;
Expand All @@ -26,16 +26,18 @@ describe("Web3FunctionProxyProvider", () => {
proxyProviderPort = 3000;

multiChainProviderConfig = {
5: new StaticJsonRpcProvider(TestChainProviders.Goerli),
80001: new StaticJsonRpcProvider(TestChainProviders.Mumbai),
[TestChainIds.Sepolia]: new StaticJsonRpcProvider(
TestChainProviders.Sepolia
),
[TestChainIds.Amoy]: new StaticJsonRpcProvider(TestChainProviders.Amoy),
};
});

beforeEach(async () => {
proxyProvider = new Web3FunctionProxyProvider(
proxyProviderHost,
rpcLimit,
TestChainIds.Goerli,
TestChainIds.Sepolia,
multiChainProviderConfig,
false
);
Expand Down Expand Up @@ -190,7 +192,7 @@ describe("Web3FunctionProxyProvider", () => {
const mainChainIdResponse = (await body.json()) as any;

const { body: body2 } = await request(
`${proxyProvider.getProxyUrl()}/${TestChainIds.Mumbai}`,
`${proxyProvider.getProxyUrl()}/${TestChainIds.Amoy}`,
{
method: "POST",
headers: { "content-type": "application/json" },
Expand All @@ -211,8 +213,8 @@ describe("Web3FunctionProxyProvider", () => {
);
const parsedChainId = parseInt(chainIdResponse.result.substring(2), 16);

expect(parsedMainChainId).toEqual(TestChainIds.Goerli);
expect(parsedChainId).toEqual(TestChainIds.Mumbai);
expect(parsedMainChainId).toEqual(TestChainIds.Sepolia);
expect(parsedChainId).toEqual(TestChainIds.Amoy);
});

test("should report RPC calls correctly", async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/runtime/Web3FunctionRunnerPool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("Web3FunctionRunnerPool", () => {

if (buildRes.success) {
const multiChainProviderConfig = {
5: new StaticJsonRpcProvider("https://eth-goerli.public.blastapi.io"),
11155111: new StaticJsonRpcProvider("https://rpc.ankr.com/eth_sepolia"),
};

const runner = new Web3FunctionRunnerPool(2, true);
Expand All @@ -54,7 +54,7 @@ describe("Web3FunctionRunnerPool", () => {
secrets: {},
storage: {},
gelatoArgs: {
chainId: 5,
chainId: 11155111,
gasPrice: "10",
},
userArgs: {},
Expand Down

0 comments on commit caa853d

Please sign in to comment.