Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
35f2e3d5
Commit
35f2e3d5
authored
Jul 09, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
standared_bridge code dedup with generics
parent
d93a9a1a
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
117 additions
and
116 deletions
+117
-116
contract_events.go
indexer/processor/contract_events.go
+9
-10
l2_processor.go
indexer/processor/l2_processor.go
+1
-1
standard_bridge.go
indexer/processor/standard_bridge.go
+107
-105
No files found.
indexer/processor/contract_events.go
View file @
35f2e3d5
...
...
@@ -78,20 +78,19 @@ func DecodeFromProcessedEvents[ABI any](p *ProcessedContractEvents, name string,
return
decodedEvents
,
nil
}
func
UnpackLog
[
EventType
any
](
log
*
types
.
Log
,
name
string
,
contractAbi
*
abi
.
ABI
)
(
*
EventType
,
error
)
{
func
UnpackLog
(
out
interface
{},
log
*
types
.
Log
,
name
string
,
contractAbi
*
abi
.
ABI
)
error
{
eventAbi
,
ok
:=
contractAbi
.
Events
[
name
]
if
!
ok
{
return
nil
,
errors
.
New
(
fmt
.
Sprintf
(
"event %s not present in supplied ABI"
,
name
))
return
errors
.
New
(
fmt
.
Sprintf
(
"event %s not present in supplied ABI"
,
name
))
}
else
if
len
(
log
.
Topics
)
==
0
{
return
nil
,
errors
.
New
(
"anonymous events are not supported"
)
return
errors
.
New
(
"anonymous events are not supported"
)
}
else
if
log
.
Topics
[
0
]
!=
eventAbi
.
ID
{
return
nil
,
errors
.
New
(
"event signature mismatch not present in supplied ABI"
)
return
errors
.
New
(
"event signature mismatch not present in supplied ABI"
)
}
var
event
EventType
err
:=
contractAbi
.
UnpackIntoInterface
(
&
event
,
name
,
log
.
Data
)
err
:=
contractAbi
.
UnpackIntoInterface
(
out
,
name
,
log
.
Data
)
if
err
!=
nil
{
return
nil
,
err
return
err
}
// handle topics if present
...
...
@@ -104,11 +103,11 @@ func UnpackLog[EventType any](log *types.Log, name string, contractAbi *abi.ABI)
}
// The first topic (event signature) is ommitted
err
:=
abi
.
ParseTopics
(
&
even
t
,
indexedArgs
,
log
.
Topics
[
1
:
])
err
:=
abi
.
ParseTopics
(
ou
t
,
indexedArgs
,
log
.
Topics
[
1
:
])
if
err
!=
nil
{
return
nil
,
err
return
err
}
}
return
&
event
,
nil
return
nil
}
indexer/processor/l2_processor.go
View file @
35f2e3d5
...
...
@@ -207,7 +207,7 @@ func l2BridgeProcessContractEvents(processLog log.Logger, db *database.DB, ethCl
numFinalizedDeposits
:=
len
(
finalizationBridgeEvents
)
if
numFinalizedDeposits
>
0
{
processLog
.
Info
(
"finalized deposits"
,
"size"
,
numFinalizedDeposits
)
processLog
.
Info
(
"finalized
L1StandardBridge
deposits"
,
"size"
,
numFinalizedDeposits
)
}
// a-ok
...
...
indexer/processor/standard_bridge.go
View file @
35f2e3d5
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment