2020-03-06 12:58:24 +00:00
|
|
|
package wallet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Token represents imported token contract.
|
|
|
|
type Token struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Hash util.Uint160 `json:"script_hash"`
|
|
|
|
Decimals int64 `json:"decimals"`
|
|
|
|
Symbol string `json:"symbol"`
|
2021-04-23 14:32:48 +00:00
|
|
|
Standard string `json:"standard"`
|
2020-03-06 12:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewToken returns new token contract info.
|
2021-04-23 14:32:48 +00:00
|
|
|
func NewToken(tokenHash util.Uint160, name, symbol string, decimals int64, standardName string) *Token {
|
2020-03-06 12:58:24 +00:00
|
|
|
return &Token{
|
|
|
|
Name: name,
|
|
|
|
Hash: tokenHash,
|
|
|
|
Decimals: decimals,
|
|
|
|
Symbol: symbol,
|
2021-04-23 14:32:48 +00:00
|
|
|
Standard: standardName,
|
2020-03-06 12:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-12 20:17:03 +00:00
|
|
|
// Address returns token address from hash.
|
2020-03-23 09:46:42 +00:00
|
|
|
func (t *Token) Address() string {
|
|
|
|
return address.Uint160ToString(t.Hash)
|
2020-03-06 12:58:24 +00:00
|
|
|
}
|