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

@ -138,21 +138,59 @@ func (d *Deposit) SlackAttachment() slack.Attachment {
}) })
return slack.Attachment{ return slack.Attachment{
Color: depositStatusSlackColor(d.Status), Color: depositStatusSlackColor(d.Status),
Title: fmt.Sprintf("Deposit %s %s To %s (%s)", d.Amount.String(), d.Asset, d.Address, d.Exchange), Fallback: "",
// TitleLink: "", ID: 0,
Pretext: "", Title: fmt.Sprintf("Deposit %s %s To %s (%s)", d.Amount.String(), d.Asset, d.Address, d.Exchange),
Text: "", TitleLink: getExplorerURL(d.Network, d.TransactionID),
Pretext: "",
Text: "",
ImageURL: "",
ThumbURL: "",
ServiceName: "",
ServiceIcon: "",
FromURL: "",
OriginalURL: "",
// ServiceName: "", // ServiceName: "",
// ServiceIcon: "", // ServiceIcon: "",
// FromURL: "", // FromURL: "",
// OriginalURL: "", // OriginalURL: "",
Fields: fields, Fields: fields,
Actions: nil,
MarkdownIn: nil,
Blocks: slack.Blocks{},
Footer: fmt.Sprintf("Apply Time: %s", d.Time.Time().Format(time.RFC3339)), Footer: fmt.Sprintf("Apply Time: %s", d.Time.Time().Format(time.RFC3339)),
FooterIcon: ExchangeFooterIcon(d.Exchange), 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 { func depositStatusSlackColor(status DepositStatus) string {
switch status { switch status {