-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(opbot): transaction age textblock #2890
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,6 +6,14 @@ | |||||
"context" | ||||||
"errors" | ||||||
"fmt" | ||||||
"log" | ||||||
"math/big" | ||||||
"regexp" | ||||||
"strings" | ||||||
"sync" | ||||||
"time" | ||||||
|
||||||
"github.com/dustin/go-humanize" | ||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||||||
"github.com/ethereum/go-ethereum/common" | ||||||
"github.com/ethereum/go-ethereum/core/types" | ||||||
|
@@ -17,12 +25,6 @@ | |||||
rfqClient "github.com/synapsecns/sanguine/services/rfq/api/client" | ||||||
"github.com/synapsecns/sanguine/services/rfq/contracts/fastbridge" | ||||||
"github.com/synapsecns/sanguine/services/rfq/relayer/relapi" | ||||||
"log" | ||||||
"math/big" | ||||||
"regexp" | ||||||
"strings" | ||||||
"sync" | ||||||
"time" | ||||||
) | ||||||
|
||||||
func (b *Bot) requiresSignoz(definition *slacker.CommandDefinition) *slacker.CommandDefinition { | ||||||
|
@@ -138,7 +140,7 @@ | |||||
}) | ||||||
} | ||||||
|
||||||
func (b *Bot) rfqLookupCommand() *slacker.CommandDefinition { | ||||||
return &slacker.CommandDefinition{ | ||||||
Command: "rfq <tx>", | ||||||
Description: "find a rfq transaction by either tx hash or txid on all configured relayers", | ||||||
|
@@ -204,7 +206,26 @@ | |||||
} | ||||||
|
||||||
var slackBlocks []slack.Block | ||||||
|
||||||
for _, status := range statuses { | ||||||
|
||||||
// TODO: add CreatedAt field to GetQuoteRequestStatusResponse so we don't need to make network calls? | ||||||
client, err := b.rpcClient.GetChainClient(ctx.Context(), int(status.OriginChainID)) | ||||||
if err != nil { | ||||||
log.Printf("error getting chain client: %v\n", err) | ||||||
} | ||||||
|
||||||
receipt, err := client.TransactionReceipt(ctx.Context(), common.HexToHash(status.OriginTxHash)) | ||||||
if err != nil { | ||||||
log.Printf("error getting transaction receipt: %v\n", err) | ||||||
} | ||||||
txBlock, err := client.BlockByHash(ctx.Context(), receipt.BlockHash) | ||||||
if err != nil { | ||||||
log.Printf("error getting block by hash: %v\n", err) | ||||||
} | ||||||
|
||||||
txTime := time.Unix(int64(txBlock.Time()), 0) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimize timestamp conversion. The timestamp conversion to - txTime := time.Unix(int64(txBlock.Time()), 0)
+ txTime := time.Unix(txBlock.Time().Int64(), 0) Committable suggestion
Suggested change
|
||||||
|
||||||
objects := []*slack.TextBlockObject{ | ||||||
{ | ||||||
Type: slack.MarkdownType, | ||||||
|
@@ -222,6 +243,10 @@ | |||||
Type: slack.MarkdownType, | ||||||
Text: fmt.Sprintf("*OriginTxHash*: %s", toTXSlackLink(status.OriginTxHash, status.OriginChainID)), | ||||||
}, | ||||||
{ | ||||||
Type: slack.MarkdownType, | ||||||
Text: fmt.Sprintf("*Estimated Tx Age*: %s", humanize.Time(txTime)), | ||||||
}, | ||||||
} | ||||||
|
||||||
if status.DestTxHash == (common.Hash{}).String() { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary leading newline.
There is an unnecessary leading newline at line 209.
- for _, status := range statuses {