neo-go/pkg/wallet/token.go
Anna Shaleva 40ae78cb88 wallet: add Standard field to Token
We need to distinguish NEP11 and NEP17 tokens preesnted in the wallet.
2021-04-30 15:58:27 +03:00

31 lines
791 B
Go

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"`
Standard string `json:"standard"`
}
// NewToken returns new token contract info.
func NewToken(tokenHash util.Uint160, name, symbol string, decimals int64, standardName string) *Token {
return &Token{
Name: name,
Hash: tokenHash,
Decimals: decimals,
Symbol: symbol,
Standard: standardName,
}
}
// Address returns token address from hash
func (t *Token) Address() string {
return address.Uint160ToString(t.Hash)
}