mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
(no commit message provided)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package coins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/bech32"
|
||||
)
|
||||
|
||||
type coin struct {
|
||||
Name string `json:"name"`
|
||||
Symbol string `json:"symbol"`
|
||||
Hrp string `json:"hrp"`
|
||||
Method string `json:"method"`
|
||||
Index int64 `json:"index"`
|
||||
Path uint32 `json:"path"`
|
||||
}
|
||||
|
||||
// FormatAddress formats the address based on the coin
|
||||
func (c *coin) FormatAddress(pubKey []byte) (string, error) {
|
||||
if c.Hrp != "" {
|
||||
return bech32.ConvertAndEncode(c.Hrp, pubKey)
|
||||
}
|
||||
return "", fmt.Errorf("unsupported coin")
|
||||
}
|
||||
|
||||
// GetIndex returns the coin index
|
||||
func (c *coin) GetIndex() int64 {
|
||||
return c.Index
|
||||
}
|
||||
|
||||
// GetName returns the coin name
|
||||
func (c *coin) GetName() string {
|
||||
return c.Name
|
||||
}
|
||||
|
||||
// GetSymbol returns the coin symbol
|
||||
func (c *coin) GetSymbol() string {
|
||||
return c.Symbol
|
||||
}
|
||||
|
||||
// GetHrp returns the coin hrp
|
||||
func (c *coin) GetHrp() string {
|
||||
return c.Hrp
|
||||
}
|
||||
|
||||
// GetPath returns the coin path
|
||||
func (c *coin) GetPath() uint32 {
|
||||
return c.Path
|
||||
}
|
||||
|
||||
// GetMethod returns the DID method for the coin
|
||||
func (c *coin) GetMethod() string {
|
||||
return c.Method
|
||||
}
|
||||
Reference in New Issue
Block a user