Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Explorer Updates #3353

Merged
merged 31 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2ef3bbf
explorer UI updated
Defi-Moses Oct 10, 2024
6cf146a
rfq-indexer update
Defi-Moses Oct 10, 2024
451a2d7
explorer backend update
Defi-Moses Oct 10, 2024
6c02517
[goreleaser] trigger explorer version bump
Defi-Moses Oct 10, 2024
a932e29
rfq indexer with the right contracts
Defi-Moses Oct 10, 2024
3e90715
[goreleaser] adding catch
Defi-Moses Oct 10, 2024
8724af9
Merge branch 'master' into feat/explorer-w
Defi-Moses Oct 12, 2024
9bd0038
response error fixes and wld decimals
Defi-Moses Oct 14, 2024
a7d5072
Merge branch 'master' into feat/explorer-w
Defi-Moses Oct 14, 2024
1dbcd96
adding address
Defi-Moses Oct 15, 2024
6b4c78e
feat(rfq-indexer): add `request` column to `BridgeRequested` for refu…
golangisfun123 Oct 16, 2024
21443fb
merge master
Defi-Moses Oct 27, 2024
684462f
fix api docs
Defi-Moses Oct 27, 2024
0a11fbb
Merge branch 'master' into feat/explorer-w
Defi-Moses Oct 28, 2024
e9861d6
Merge branch 'master' into feat/explorer-w
Defi-Moses Oct 29, 2024
c535f93
linting fixes
Defi-Moses Oct 29, 2024
24fbf3e
fixing irrelavent files
Defi-Moses Oct 29, 2024
9afe2b4
Merge branch 'master' into feat/explorer-w
Defi-Moses Oct 30, 2024
78489b2
wc fixes and tests solved
Defi-Moses Oct 30, 2024
5bc0071
fix linting errors
Defi-Moses Oct 30, 2024
ed08415
[goreleaser]
Defi-Moses Oct 30, 2024
0b201d8
refining tests
Defi-Moses Oct 30, 2024
434d1d9
adding bridge Module to graphql
Defi-Moses Oct 30, 2024
6b9ec9d
Adding to all bridge watcher queries
Defi-Moses Oct 30, 2024
6453e9e
adding worldchain to the chart
Defi-Moses Oct 31, 2024
e128d37
adding other rfq events to the rfq events db
Defi-Moses Oct 31, 2024
8e2e6f2
fixing wld coingecko ticker [goreleaser]
Defi-Moses Oct 31, 2024
cfe785b
[goreleaser] coingecko update and new topic parsing
Defi-Moses Oct 31, 2024
6542250
small lint fix
Defi-Moses Oct 31, 2024
c69026a
[goreleaser] linting fixes
Defi-Moses Oct 31, 2024
2341eac
fix(rfq-indexer): add missing fields (#3309)
golangisfun123 Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/explorer-ui/graphql/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export const DAILY_STATISTICS_BY_CHAIN = gql`
blast
scroll
linea
worldchain
total
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/rfq-indexer/api/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export interface BridgeProofDisputedEvents {
transactionHash: ColumnType<string>
chainId: ColumnType<number>
chain: ColumnType<string>
originChainId: ColumnType<number>
originChain: ColumnType<string>
}
// Add any other shared types used across the API
export type EventType =
Expand Down
9 changes: 5 additions & 4 deletions services/explorer/backfill/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ func (b *BackfillSuite) TestBackfill() {
redeemLog, err := b.storeTestLog(bridgeTx, uint32(testChainID.Uint64()), 2)
Nil(b.T(), err)

bridgeTx, err = bridgeRef.TestWithdraw(transactOpts.TransactOpts, common.BigToAddress(big.NewInt(gofakeit.Int64())), common.HexToAddress(testTokens[0].TokenAddress), big.NewInt(int64(gofakeit.Uint32())), big.NewInt(int64(gofakeit.Uint32())), [32]byte{byte(gofakeit.Uint64())})
baseNum := gofakeit.Uint32()
bridgeTx, err = bridgeRef.TestWithdraw(transactOpts.TransactOpts, common.BigToAddress(big.NewInt(gofakeit.Int64())), common.HexToAddress(testTokens[0].TokenAddress), big.NewInt(int64(baseNum)), big.NewInt(int64(float64(baseNum)*0.01)), [32]byte{byte(gofakeit.Uint64())})
Nil(b.T(), err)
b.storeEthTx(bridgeTx, testChainID, big.NewInt(int64(2)), 3)
withdrawLog, err := b.storeTestLog(bridgeTx, uint32(testChainID.Uint64()), 2)
Expand Down Expand Up @@ -203,7 +204,7 @@ func (b *BackfillSuite) TestBackfill() {
redeemV1Log, err := b.storeTestLog(bridgeTx, uint32(testChainID.Uint64()), 3)
Nil(b.T(), err)

bridgeTx, err = bridgeV1Ref.TestWithdraw(transactOpts.TransactOpts, common.BigToAddress(big.NewInt(gofakeit.Int64())), common.HexToAddress(testTokens[0].TokenAddress), big.NewInt(int64(gofakeit.Uint32())), big.NewInt(int64(gofakeit.Uint32())), [32]byte{byte(gofakeit.Uint64())})
bridgeTx, err = bridgeV1Ref.TestWithdraw(transactOpts.TransactOpts, common.BigToAddress(big.NewInt(gofakeit.Int64())), common.HexToAddress(testTokens[0].TokenAddress), big.NewInt(int64(baseNum)), big.NewInt(int64(float64(baseNum)*0.01)), [32]byte{byte(gofakeit.Uint64())})
Nil(b.T(), err)
b.storeEthTx(bridgeTx, testChainID, big.NewInt(int64(3)), 3)
withdrawV1Log, err := b.storeTestLog(bridgeTx, uint32(testChainID.Uint64()), 3)
Expand Down Expand Up @@ -878,7 +879,7 @@ func (b *BackfillSuite) withdrawParity(log *types.Log, parser *parser.BridgePars
BlockNumber: log.BlockNumber,
TxHash: log.TxHash.String(),
Token: parsedLog.Token.String(),
Amount: parsedLog.Amount,
Amount: new(big.Int).Sub(parsedLog.Amount, parsedLog.Fee),

Recipient: recipient,
Fee: parsedLog.Fee,
Expand Down Expand Up @@ -911,7 +912,7 @@ func (b *BackfillSuite) withdrawParity(log *types.Log, parser *parser.BridgePars
BlockNumber: log.BlockNumber,
TxHash: log.TxHash.String(),
Token: parsedLog.Token.String(),
Amount: parsedLog.Amount,
Amount: new(big.Int).Sub(parsedLog.Amount, parsedLog.Fee),

Recipient: recipient,
Fee: parsedLog.Fee,
Expand Down
63 changes: 40 additions & 23 deletions services/explorer/consumer/parser/rfqparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"context"
"database/sql"
"errors"
"fmt"
"strings"
"time"
Expand All @@ -23,7 +24,7 @@

const ethCoinGeckoID = "ethereum"

// RFQParser parsers rfq logs.
// RFQParser parsers all rfq logs.
type RFQParser struct {
// consumerDB is the database to store parsed data in
consumerDB db.ConsumerDB
Expand Down Expand Up @@ -63,25 +64,32 @@
func (p *RFQParser) ParseLog(log ethTypes.Log, chainID uint32) (*model.RFQEvent, rfqTypes.EventLog, error) {
logTopic := log.Topics[0]
iFace, err := func(log ethTypes.Log) (rfqTypes.EventLog, error) {
switch logTopic {
case fastbridge.Topic(rfqTypes.BridgeRequestedEvent):
iFace, err := p.Filterer.ParseBridgeRequested(log)
if err != nil {
return nil, fmt.Errorf("could not parse fastbridge bridge requested : %w", err)
}
return iFace, nil
case fastbridge.Topic(rfqTypes.BridgeRelayedEvent):
iFace, err := p.Filterer.ParseBridgeRelayed(log)
if err != nil {
return nil, fmt.Errorf("could not parse fastbridge bridge relayed: %w", err)
}
return iFace, nil

default:
logger.Warnf("ErrUnknownTopic in rfq: %s %s chain: %d address: %s", log.TxHash, logTopic.String(), chainID, log.Address.Hex())
// Get the topic hash safely
bridgeRequestedTopic, err := fastbridge.Topic(rfqTypes.BridgeRequestedEvent)
if err == nil && logTopic == bridgeRequestedTopic {
return p.Filterer.ParseBridgeRequested(log)
}

Check warning on line 71 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L67-L71

Added lines #L67 - L71 were not covered by tests

return nil, fmt.Errorf(ErrUnknownTopic)
bridgeRelayedTopic, err := fastbridge.Topic(rfqTypes.BridgeRelayedEvent)
if err == nil && logTopic == bridgeRelayedTopic {
return p.Filterer.ParseBridgeRelayed(log)
}
bridgeProofProvidedTopic, err := fastbridge.Topic(rfqTypes.BridgeProvenEvent)
if err == nil && logTopic == bridgeProofProvidedTopic {
return p.Filterer.ParseBridgeProofProvided(log)

Check warning on line 79 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L73-L79

Added lines #L73 - L79 were not covered by tests
}
bridgeDepositClaimedTopic, err := fastbridge.Topic(rfqTypes.BridgeClaimedEvent)
if err == nil && logTopic == bridgeDepositClaimedTopic {
return p.Filterer.ParseBridgeDepositClaimed(log)
}
bridgeDepositRefundedTopic, err := fastbridge.Topic(rfqTypes.BridgeRefundedEvent)
if err == nil && logTopic == bridgeDepositRefundedTopic {
return p.Filterer.ParseBridgeDepositRefunded(log)
}

Check warning on line 88 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L81-L88

Added lines #L81 - L88 were not covered by tests

logger.Warnf("ErrUnknownTopic in rfq: %s %s chain: %d address: %s",
log.TxHash, logTopic.String(), chainID, log.Address.Hex())
return nil, errors.New("unknown topic")

Check warning on line 92 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L90-L92

Added lines #L90 - L92 were not covered by tests
}(log)

if err != nil {
Expand All @@ -108,25 +116,26 @@
}

// If we have a timestamp, populate the following attributes of rfqEvent.
// This logic will have to be generalized as we support more tokens (we need to programatically find coingecko id based on token address)
timeStampBig := uint64(*timeStamp)
rfqEvent.TimeStamp = &timeStampBig

var curCoinGeckoID string
tokenAddressStr := common.HexToAddress(rfqEvent.OriginToken).Hex()
const ethAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"

if strings.EqualFold(tokenAddressStr, ethAddress) {
switch {
case strings.EqualFold(tokenAddressStr, ethAddress) || strings.EqualFold(tokenAddressStr, "0x2170Ed0880ac9A755fd29B2688956BD959F933F8"):

Check warning on line 128 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L127-L128

Added lines #L127 - L128 were not covered by tests
rfqEvent.TokenSymbol = "ETH"
rfqEvent.TokenDecimal = new(uint8)
*rfqEvent.TokenDecimal = 18
curCoinGeckoID = ethCoinGeckoID
} else if strings.EqualFold(tokenAddressStr, "0x2cFc85d8E48F8EAB294be644d9E25C3030863003") || strings.EqualFold(tokenAddressStr, "0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1") {
case strings.EqualFold(tokenAddressStr, "0x2cFc85d8E48F8EAB294be644d9E25C3030863003") || strings.EqualFold(tokenAddressStr, "0xdC6fF44d5d932Cbd77B52E5612Ba0529DC6226F1"):

Check warning on line 133 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L133

Added line #L133 was not covered by tests
rfqEvent.TokenSymbol = "WLD"
rfqEvent.TokenDecimal = new(uint8)
*rfqEvent.TokenDecimal = 18
curCoinGeckoID = "worldchain"
} else {
// Assuming any other token is USDC
curCoinGeckoID = "worldcoin-wld"
default:

Check warning on line 138 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L137-L138

Added lines #L137 - L138 were not covered by tests
rfqEvent.TokenSymbol = "USDC"
rfqEvent.TokenDecimal = new(uint8)
*rfqEvent.TokenDecimal = 6
Expand Down Expand Up @@ -232,6 +241,14 @@
}

func rfqEventToBridgeEvent(rfqEvent model.RFQEvent) model.BridgeEvent {
// Only convert BridgeRequestedEvent and BridgeRelayedEvent to bridge events
// Exclude BridgeDepositRefunded, BridgeProofProvided, and BridgeDepositClaimed
eventType := rfqEvent.EventType
if eventType != rfqTypes.BridgeRequestedEvent.Int() &&
eventType != rfqTypes.BridgeRelayedEvent.Int() {
return model.BridgeEvent{}
}

Check warning on line 250 in services/explorer/consumer/parser/rfqparser.go

View check run for this annotation

Codecov / codecov/patch

services/explorer/consumer/parser/rfqparser.go#L244-L250

Added lines #L244 - L250 were not covered by tests

bridgeType := bridgeTypes.BridgeRequestedEvent
token := rfqEvent.OriginToken
amount := rfqEvent.OriginAmount
Expand Down
Loading
Loading