File tree Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Expand file tree Collapse file tree 4 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 1
1
PROVIDER_URLS = "https://eth-mainnet.alchemyapi.io/v2/YOUR_ALCHEMY_ID" # your provider URLS seperated by comma
2
- PRIVATE_KEY = "" ## Optional: Only needed if you wish to create a task from the CLI instead of the UI
2
+ PRIVATE_KEY = "" ## Optional: Only needed if you wish to create a task from the CLI instead of the UI
3
+ RPC = "" ## PRC FOR ANVIL FORK
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ Web3Function.onRun(async (context: Web3FunctionContext) => {
129
129
130
130
- Example:<br/> ` npx w3f test web3 - functions / oracle / index .ts -- show - logs `
131
131
- Output:
132
- ` ` `
132
+ ` ` `
133
133
Web3Function Build result :
134
134
✓ Schema : web3 - functions / oracle / schema .json
135
135
✓ Built file : / Users / chuahsonglin / Documents / GitHub / Gelato / backend / js - resolver - template / .tmp / index .js
Original file line number Diff line number Diff line change 12
12
"create-task:event" : " ts-node scripts/create-task-event-listener.ts" ,
13
13
"create-task:oracle" : " ts-node scripts/create-task-oracle.ts" ,
14
14
"create-task:secrets" : " ts-node scripts/create-task-with-secrets.ts" ,
15
- "create-task:ad-board" : " ts-node scripts/create-task-ad-board.ts"
15
+ "create-task:ad-board" : " ts-node scripts/create-task-ad-board.ts" ,
16
+ "forkAnvil" : " ts-node scripts/forkAnvil.ts"
16
17
},
17
18
"keywords" : [],
18
19
"author" : " " ,
Original file line number Diff line number Diff line change
1
+
2
+ import * as dotenv from 'dotenv' ;
3
+ dotenv . config ( ) ;
4
+
5
+ const forkChain = async ( ) => {
6
+
7
+ const { spawn } = await import ( "child_process" ) ;
8
+
9
+ const RPC = process . env [ 'RPC' ] !
10
+ let params = [ "-f" , RPC ]
11
+
12
+ let blockNumber ;
13
+
14
+ if ( blockNumber ) {
15
+ params . push ( `--fork-block-number=${ blockNumber } ` )
16
+ }
17
+
18
+ /// You can add as much customs params as wanted
19
+ const childProcess = spawn ( 'anvil' , params , {
20
+ stdio : "inherit" ,
21
+ } ) ;
22
+
23
+ childProcess . once ( "close" , ( status ) => {
24
+ childProcess . removeAllListeners ( "error" ) ;
25
+
26
+ if ( status === 0 ) {
27
+ console . log ( 'ok' )
28
+ } else {
29
+ console . log ( 'error' )
30
+ }
31
+
32
+ } ) ;
33
+
34
+ childProcess . once ( "error" , ( _status ) => {
35
+ childProcess . removeAllListeners ( "close" ) ;
36
+ console . log ( 'error' )
37
+ } ) ;
38
+ }
39
+
40
+ forkChain ( )
You can’t perform that action at this time.
0 commit comments