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
7199ad85
Unverified
Commit
7199ad85
authored
Sep 19, 2023
by
Ethen Pociask
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[indexer.client] Working withdrawal lookup client
parent
6c03aeba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
5 deletions
+33
-5
api.go
indexer/api/api.go
+5
-4
client.go
indexer/client/client.go
+1
-1
client_test.go
indexer/client/client_test.go
+25
-0
main.go
indexer/cmd/indexer/main.go
+2
-0
No files found.
indexer/api/api.go
View file @
7199ad85
...
@@ -30,8 +30,9 @@ type Api struct {
...
@@ -30,8 +30,9 @@ type Api struct {
const
(
const
(
MetricsNamespace
=
"op_indexer"
MetricsNamespace
=
"op_indexer"
DepositsPath
=
"/api/v0/deposits/{address:%s}"
addressParam
=
"{address:%s}"
WithdrawalsPath
=
"/api/v0/withdrawals/{address:%s}"
DepositsPath
=
"/api/v0/deposits/"
WithdrawalsPath
=
"/api/v0/withdrawals/"
)
)
func
chiMetricsMiddleware
(
rec
metrics
.
HTTPRecorder
)
func
(
http
.
Handler
)
http
.
Handler
{
func
chiMetricsMiddleware
(
rec
metrics
.
HTTPRecorder
)
func
(
http
.
Handler
)
http
.
Handler
{
...
@@ -51,8 +52,8 @@ func NewApi(logger log.Logger, bv database.BridgeTransfersView, serverConfig con
...
@@ -51,8 +52,8 @@ func NewApi(logger log.Logger, bv database.BridgeTransfersView, serverConfig con
apiRouter
.
Use
(
middleware
.
Recoverer
)
apiRouter
.
Use
(
middleware
.
Recoverer
)
apiRouter
.
Use
(
middleware
.
Heartbeat
(
"/healthz"
))
apiRouter
.
Use
(
middleware
.
Heartbeat
(
"/healthz"
))
apiRouter
.
Get
(
fmt
.
Sprintf
(
DepositsPath
,
ethereumAddressRegex
),
h
.
L1DepositsHandler
)
apiRouter
.
Get
(
fmt
.
Sprintf
(
DepositsPath
+
addressParam
,
ethereumAddressRegex
),
h
.
L1DepositsHandler
)
apiRouter
.
Get
(
fmt
.
Sprintf
(
WithdrawalsPath
,
ethereumAddressRegex
),
h
.
L2WithdrawalsHandler
)
apiRouter
.
Get
(
fmt
.
Sprintf
(
WithdrawalsPath
+
addressParam
,
ethereumAddressRegex
),
h
.
L2WithdrawalsHandler
)
return
&
Api
{
log
:
logger
,
Router
:
apiRouter
,
metricsRegistry
:
mr
,
serverConfig
:
serverConfig
,
metricsConfig
:
metricsConfig
}
return
&
Api
{
log
:
logger
,
Router
:
apiRouter
,
metricsRegistry
:
mr
,
serverConfig
:
serverConfig
,
metricsConfig
:
metricsConfig
}
}
}
...
...
indexer/client/client.go
View file @
7199ad85
...
@@ -68,7 +68,7 @@ func (ic *IndexerClient) GetAllWithdrawalsByAddress(l2Address string) ([]databas
...
@@ -68,7 +68,7 @@ func (ic *IndexerClient) GetAllWithdrawalsByAddress(l2Address string) ([]databas
func
(
ic
*
IndexerClient
)
GetWithdrawalsByAddress
(
l2Address
string
,
cursor
string
)
(
*
database
.
L2BridgeWithdrawalsResponse
,
error
)
{
func
(
ic
*
IndexerClient
)
GetWithdrawalsByAddress
(
l2Address
string
,
cursor
string
)
(
*
database
.
L2BridgeWithdrawalsResponse
,
error
)
{
var
wResponse
*
database
.
L2BridgeWithdrawalsResponse
var
wResponse
*
database
.
L2BridgeWithdrawalsResponse
endpoint
:=
fmt
.
Sprintf
(
ic
.
cfg
.
URL
+
api
.
WithdrawalsPath
+
urlParams
,
l2Addres
s
,
cursor
,
ic
.
cfg
.
PaginationLimit
)
endpoint
:=
fmt
.
Sprintf
(
ic
.
cfg
.
URL
+
api
.
WithdrawalsPath
+
l2Address
+
urlParam
s
,
cursor
,
ic
.
cfg
.
PaginationLimit
)
resp
,
err
:=
ic
.
c
.
Get
(
endpoint
)
resp
,
err
:=
ic
.
c
.
Get
(
endpoint
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
indexer/client/client_test.go
0 → 100644
View file @
7199ad85
package
client
import
"testing"
func
Test_Client
(
t
*
testing
.
T
)
{
cfg
:=
&
Config
{
PaginationLimit
:
100
,
URL
:
"https://localhost:8080"
,
}
ic
,
err
:=
DialIndexerClient
(
cfg
,
nil
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
// Get all withdrawals by address
withdrawals
,
err
:=
ic
.
GetAllWithdrawalsByAddress
(
"0xC64c9c88F28072F9DAa60d371acc08cB5FDb9952"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
t
.
Logf
(
"withdrawals: %+v"
,
withdrawals
)
}
indexer/cmd/indexer/main.go
View file @
7199ad85
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"context"
"context"
"os"
"os"
oplog
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/opio"
"github.com/ethereum-optimism/optimism/op-service/opio"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/log"
)
)
...
@@ -22,6 +23,7 @@ func main() {
...
@@ -22,6 +23,7 @@ func main() {
cancel
()
cancel
()
}()
}()
oplog
.
SetupDefaults
()
app
:=
newCli
(
GitCommit
,
GitDate
)
app
:=
newCli
(
GitCommit
,
GitDate
)
if
err
:=
app
.
RunContext
(
ctx
,
os
.
Args
);
err
!=
nil
{
if
err
:=
app
.
RunContext
(
ctx
,
os
.
Args
);
err
!=
nil
{
log
.
Error
(
"application failed"
,
"err"
,
err
)
log
.
Error
(
"application failed"
,
"err"
,
err
)
...
...
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