You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+12-11
Original file line number
Diff line number
Diff line change
@@ -20,12 +20,12 @@ This repository contains the logic for decoding a `raw_log_event` of a transacti
20
20
21
21
## Knowledge Primer
22
22
23
-
1.**Config**: A `config` is a mapping of a contract address, network, and protocol name to create a unique configuration for every protocol on all the networks across all the chains for all the contracts. A protocol can have a collection of configs in an array. It looks like
23
+
1.**Config**: A `config` is a mapping of a contract address, chain name, and protocol name to create a unique configuration for every protocol across all the chains for all the contracts. A protocol can have a collection of configs in an array. It looks like
24
24
25
25
```ts
26
26
exporttypeConfigs= {
27
27
protocol_name:string;
28
-
network:Chain;
28
+
chain_name:Chain;
29
29
address:string;
30
30
is_factory:boolean;
31
31
}[];
@@ -34,12 +34,12 @@ This repository contains the logic for decoding a `raw_log_event` of a transacti
2.**Networks**: Anarrayofallthenetworksthedefineddecodingfunction will run for.
53
+
2.**ChainNames**: Anarrayofallthechainsthedefineddecodingfunction will run for.
54
54
3. **ABI**: The ABI of the contract on which the event exists.
55
55
4. **Decoding Function**: The actual decoding function, it has 3 arguments passed to it:
56
56
1. `log_event`: The raw log event that is being decoded.
57
57
2. `tx`: The transaction object that generated this log.
58
-
3. `chain_name`: Network to which the log belongs to.
58
+
3. `chain_name`: Name of the chain to which the log belongs to.
59
59
4. `covalent_client`: The covalent client created with your covalent API key.
60
60
61
61
3.`fallback`: Createsafallbackfunction for the specified event name. This function is not linked to any chain or contract. Its declaration is:
@@ -77,7 +77,7 @@ This repository contains the logic for decoding a `raw_log_event` of a transacti
77
77
3.**DecodingFunction**: Theactualdecodingfunction, it has 3 arguments passed to it:
78
78
1. `log_event`: The raw log event that is being decoded.
79
79
2. `tx`: The transaction object that generated this log.
80
-
3. `chain_name`: Network to which the log belongs to.
80
+
3. `chain_name`: Name of the chain to which the log belongs to.
81
81
4. `covalent_client`: The covalent client created with your covalent API key.
82
82
83
83
4.`decode`: Thefunction that chooses which decoding function needs to be called for which log event. It collects all the decoded events for a transaction and returns them in an array of structured data. It is run when the API server receives a request.
@@ -106,19 +106,19 @@ Follow the following steps to start the development server of the **GoldRush Dec
106
106
107
107
1.`/api/v1`: Thedefaultendpointforthev1oftheserver. Aheaderofthekey`x-covalent-api-key`withthevalueasthe [CovalentAPIkey](https://www.covalenthq.com/platform/apikey/) is **mandatory** for the Decoder to work.
constdecodersContent: string=`import{GoldRushDecoder}from"../../decoder";import{type EventType}from"../../decoder.types";import{DECODED_ACTION,DECODED_EVENT_CATEGORY}from"../../decoder.constants";import{decodeEventLog,type Abi}from"viem";import ABI from "./abis/${protocol_name}.abi.json";\n\nGoldRushDecoder.on("${protocol_name}:${eventName}",["${network}"],ABI as Abi,async(log_event,tx,chain_name,covalent_client):Promise<EventType> =>{const{raw_log_data,raw_log_topics}=log_event;\n\nconst{args:decoded}=decodeEventLog({abi:ABI,topics:raw_log_topics as[],data:raw_log_data as \`0x\${string}\`,eventName:"${eventName}"})as{eventName:"${eventName}";args:{}};\n\nreturn{action:DECODED_ACTION.SWAPPED,category:DECODED_EVENT_CATEGORY.DEX,name:"${eventName}",protocol:{logo:log_event.sender_logo_url as string,name:log_event.sender_name as string}};});`;
152
-
consttestContent: string=`import request from"supertest";import app from"../../../../api";import{type EventType}from"../../decoder.types";\n\ndescribe("${protocol_name}",()=>{test("${network}:${eventName}",async()=>{const res=await request(app).post("/api/v1/tx/decode").set({"x-covalent-api-key":process.env.TEST_COVALENT_API_KEY}).send({network:"${network}",tx_hash:"<ENTER TX HASH FOR TESTING>"});const{events}=res.body as{events:EventType[]};const event=events.find(({name})=>name==="${eventName}");if(!event){throw Error("Event not found")}const testAdded:boolean=false;expect(testAdded).toEqual(true)})});`;
constdecodersContent: string=`import{GoldRushDecoder}from"../../decoder";import{type EventType}from"../../decoder.types";import{DECODED_ACTION,DECODED_EVENT_CATEGORY}from"../../decoder.constants";import{decodeEventLog,type Abi}from"viem";import ABI from "./abis/${protocol_name}.abi.json";\n\nGoldRushDecoder.on("${protocol_name}:${eventName}",["${chain_name}"],ABI as Abi,async(log_event,tx,chain_name,covalent_client):Promise<EventType> =>{const{raw_log_data,raw_log_topics}=log_event;\n\nconst{args:decoded}=decodeEventLog({abi:ABI,topics:raw_log_topics as[],data:raw_log_data as \`0x\${string}\`,eventName:"${eventName}"})as{eventName:"${eventName}";args:{}};\n\nreturn{action:DECODED_ACTION.SWAPPED,category:DECODED_EVENT_CATEGORY.DEX,name:"${eventName}",protocol:{logo:log_event.sender_logo_url as string,name:log_event.sender_name as string}};});`;
152
+
consttestContent: string=`import request from"supertest";import app from"../../../../api";import{type EventType}from"../../decoder.types";\n\ndescribe("${protocol_name}",()=>{test("${chain_name}:${eventName}",async()=>{const res=await request(app).post("/api/v1/tx/decode").set({"x-covalent-api-key":process.env.TEST_COVALENT_API_KEY}).send({chain_name:"${chain_name}",tx_hash:"<ENTER TX HASH FOR TESTING>"});const{events}=res.body as{events:EventType[]};const event=events.find(({name})=>name==="${eventName}");if(!event){throw Error("Event not found")}const testAdded:boolean=false;expect(testAdded).toEqual(true)})});`;
0 commit comments