Skip to content

Commit

Permalink
Merge 6453e9e into a330c8b
Browse files Browse the repository at this point in the history
  • Loading branch information
Defi-Moses authored Oct 31, 2024
2 parents a330c8b + 6453e9e commit ecd0523
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 55 deletions.
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
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
11 changes: 6 additions & 5 deletions services/explorer/consumer/parser/rfqparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,26 @@ func (p *RFQParser) MatureLogs(ctx context.Context, rfqEvent *model.RFQEvent, iF
}

// 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"):
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"):
rfqEvent.TokenSymbol = "WLD"
rfqEvent.TokenDecimal = new(uint8)
*rfqEvent.TokenDecimal = 18
curCoinGeckoID = "worldchain"
} else {
// Assuming any other token is USDC
curCoinGeckoID = "worldcoin"
default:
rfqEvent.TokenSymbol = "USDC"
rfqEvent.TokenDecimal = new(uint8)
*rfqEvent.TokenDecimal = 6
Expand Down
28 changes: 17 additions & 11 deletions services/explorer/graphql/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions services/explorer/graphql/client/queries/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ query GetBridgeTransactions($chainIDTo: [Int],$chainIDFrom: [Int], $addressTo: S
kappa
pending
swapSuccess
bridgeModule
}
}

Expand Down Expand Up @@ -303,6 +304,7 @@ query GetOriginBridgeTx($chainID: Int!, $txnHash: String!, $bridgeType: BridgeTy
type
kappa
kappaStatus
bridgeModule
}
}
query GetDestinationBridgeTx($chainID: Int!, $kappa: String!, $address: String!, $timestamp: Int!, $bridgeType: BridgeType!, $historical: Boolean) {
Expand Down Expand Up @@ -332,5 +334,6 @@ query GetDestinationBridgeTx($chainID: Int!, $kappa: String!, $address: String!,
type
kappa
kappaStatus
bridgeModule
}
}
22 changes: 12 additions & 10 deletions services/explorer/graphql/server/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 34 additions & 15 deletions services/explorer/graphql/server/graph/queryutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,14 @@ func GetPartialInfoFromBridgeEventHybrid(bridgeEvent sql.HybridBridgeEvent, incl
if kappa == "" {
kappa = bridgeEvent.TKappa.String
}
bridgeModule := getBridgeModule(int(bridgeEvent.FEventType))
bridgeTx = model.BridgeTransaction{
FromInfo: fromInfos,
ToInfo: toInfos,
Kappa: &kappa,
Pending: &pending,
SwapSuccess: &swapSuccess,
FromInfo: fromInfos,
ToInfo: toInfos,
Kappa: &kappa,
Pending: &pending,
SwapSuccess: &swapSuccess,
BridgeModule: &bridgeModule,
}
return &bridgeTx, nil
}
Expand Down Expand Up @@ -1775,12 +1777,14 @@ func bwBridgeMVToBWTxOrigin(bridgeEvent *sql.HybridBridgeEvent, txType model.Bri
Time: &timestamp,
FormattedTime: &timeStampFormatted,
}
bridgeModule := getBridgeModule(int(bridgeEvent.FEventType))
result := &model.BridgeWatcherTx{
BridgeTx: &bridgeTx,
Pending: &isPending,
Type: &txType,
Kappa: &kappa,
KappaStatus: &kappaStatus,
BridgeTx: &bridgeTx,
Pending: &isPending,
Type: &txType,
Kappa: &kappa,
KappaStatus: &kappaStatus,
BridgeModule: &bridgeModule,
}
return result, nil
}
Expand Down Expand Up @@ -1823,12 +1827,14 @@ func bwBridgeMVToBWTxDestination(bridgeEvent *sql.HybridBridgeEvent, txType mode
Time: &timestamp,
FormattedTime: &timeStampFormatted,
}
bridgeModule := getBridgeModule(int(bridgeEvent.TEventType))
result := &model.BridgeWatcherTx{
BridgeTx: &bridgeTx,
Pending: &isPending,
Type: &txType,
Kappa: &kappa,
KappaStatus: &kappaStatus,
BridgeTx: &bridgeTx,
Pending: &isPending,
Type: &txType,
Kappa: &kappa,
KappaStatus: &kappaStatus,
BridgeModule: &bridgeModule,
}
return result, nil
}
Expand Down Expand Up @@ -1865,3 +1871,16 @@ func (r *queryResolver) getContractAddressFromType(chainID uint32, contractType
return "", fmt.Errorf("contract type not supported")
}
}

func getBridgeModule(eventType int) string {
switch {
case eventType < 10:
return "SynapseBridge"
case eventType == 10:
return "SynapseCCTP"
case eventType == 12:
return "SynapseRFQ"
default:
return ""
}
}
Loading

0 comments on commit ecd0523

Please sign in to comment.