feat: ETC support and notifications tests
- Add ETC to the list of supported coins. A new `coin` setting can be configured to avoid conflict with `eth`. Mind the lowercase. By default, flexassitant will try to deduce the coin from the miner's address (with eth by default, not etc). (#5) - Add `test` (true/false) to `notifications` section to test notifications with random values fetched from the Flexpool API - Fix typo in the configuration example (#6) BREAKING CHANGE: `notification-templates` configuration settings have been renamed to `notifications`, with sections to configure balance, payment, block and offline workers notifications, with `template` and `test` settings. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
b519770922
commit
d2d1503779
8 changed files with 289 additions and 53 deletions
6
utils.go
6
utils.go
|
|
@ -14,6 +14,8 @@ const MojoToXCHDivider = 1000000000000
|
|||
// Example: for "eth", convert from Weis to ETH
|
||||
func ConvertCurrency(coin string, value float64) (float64, error) {
|
||||
switch coin {
|
||||
case "etc":
|
||||
return ConvertWeis(value), nil
|
||||
case "eth":
|
||||
return ConvertWeis(value), nil
|
||||
case "xch":
|
||||
|
|
@ -36,6 +38,8 @@ func ConvertMojo(value float64) float64 {
|
|||
// FormatBlockURL returns the URL on the respective blockchain explorer given the coin and the block hash
|
||||
func FormatBlockURL(coin string, hash string) (string, error) {
|
||||
switch coin {
|
||||
case "etc":
|
||||
return fmt.Sprintf("https://etcblockexplorer.com/block/%s", hash), nil
|
||||
case "eth":
|
||||
return fmt.Sprintf("https://etherscan.io/block/%s", hash), nil
|
||||
case "xch":
|
||||
|
|
@ -47,6 +51,8 @@ func FormatBlockURL(coin string, hash string) (string, error) {
|
|||
// FormatTransactionURL returns the URL on the respective blockchain explorer given the coin and the transaction hash
|
||||
func FormatTransactionURL(coin string, hash string) (string, error) {
|
||||
switch coin {
|
||||
case "etc":
|
||||
return fmt.Sprintf("https://etcblockexplorer.com/address/%s", hash), nil
|
||||
case "eth":
|
||||
return fmt.Sprintf("https://etherscan.io/tx/%s", hash), nil
|
||||
case "xch":
|
||||
|
|
|
|||
Reference in a new issue