-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[indexer.api.supply_view] add withdrawal suppply calculations
- Loading branch information
Ethen Pociask
committed
Nov 8, 2023
1 parent
6841e79
commit fd47aec
Showing
7 changed files
with
61 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package routes | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/ethereum-optimism/optimism/indexer/api/models" | ||
) | ||
|
||
// SupplyView ... Handles /api/v0/supply GET requests | ||
func (h Routes) SupplyView(w http.ResponseWriter, r *http.Request) { | ||
|
||
depositSum, err := h.view.L1BridgeDepositSum() | ||
if err != nil { | ||
http.Error(w, "internal server error reading deposits", http.StatusInternalServerError) | ||
h.logger.Error("unable to read deposits from DB", "err", err.Error()) | ||
return | ||
} | ||
|
||
withdrawalSum, err := h.view.L2BridgeWithdrawalSum() | ||
if err != nil { | ||
http.Error(w, "internal server error reading withdrawals", http.StatusInternalServerError) | ||
h.logger.Error("unable to read withdrawals from DB", "err", err.Error()) | ||
return | ||
} | ||
|
||
view := models.BridgeSupplyView{ | ||
L1DepositSum: depositSum, | ||
L2WithdrawalSum: withdrawalSum, | ||
} | ||
|
||
err = jsonResponse(w, view, http.StatusOK) | ||
if err != nil { | ||
h.logger.Error("error writing response", "err", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters