types: attach explorer url to the deposit attachment

This commit is contained in:
c9s 2024-11-14 12:15:52 +08:00
parent 86ac4ee673
commit 20f43e4634
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -139,20 +139,58 @@ func (d *Deposit) SlackAttachment() slack.Attachment {
return slack.Attachment{
Color: depositStatusSlackColor(d.Status),
Fallback: "",
ID: 0,
Title: fmt.Sprintf("Deposit %s %s To %s (%s)", d.Amount.String(), d.Asset, d.Address, d.Exchange),
// TitleLink: "",
TitleLink: getExplorerURL(d.Network, d.TransactionID),
Pretext: "",
Text: "",
ImageURL: "",
ThumbURL: "",
ServiceName: "",
ServiceIcon: "",
FromURL: "",
OriginalURL: "",
// ServiceName: "",
// ServiceIcon: "",
// FromURL: "",
// OriginalURL: "",
Fields: fields,
Actions: nil,
MarkdownIn: nil,
Blocks: slack.Blocks{},
Footer: fmt.Sprintf("Apply Time: %s", d.Time.Time().Format(time.RFC3339)),
FooterIcon: ExchangeFooterIcon(d.Exchange),
Ts: "",
}
}
func getExplorerURL(network string, txID string) string {
switch strings.ToUpper(network) {
case "BTC":
return getBitcoinNetworkExplorerURL(txID)
case "BSC":
return getBscNetworkExplorerURL(txID)
case "ETH":
return getEthNetworkExplorerURL(txID)
}
return ""
}
func getEthNetworkExplorerURL(txID string) string {
return "https://etherscan.io/tx/" + txID
}
func getBitcoinNetworkExplorerURL(txID string) string {
return "https://www.blockchain.com/explorer/transactions/btc/" + txID
}
func getBscNetworkExplorerURL(txID string) string {
return "https://bscscan.com/tx/" + txID
}
func depositStatusSlackColor(status DepositStatus) string {
switch status {