2021-02-08 08:06:01 +00:00
|
|
|
package neo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Hash represents NEO contract hash.
|
2021-02-15 13:40:44 +00:00
|
|
|
const Hash = "\xf5\x63\xea\x40\xbc\x28\x3d\x4d\x0e\x05\xc4\x8e\xa3\x05\xb3\xf2\xa0\x73\x40\xef"
|
2021-02-08 08:06:01 +00:00
|
|
|
|
|
|
|
// Symbol represents `symbol` method of NEO native contract.
|
|
|
|
func Symbol() string {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "symbol", contract.NoneFlag).(string)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Decimals represents `decimals` method of NEO native contract.
|
|
|
|
func Decimals() int {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "decimals", contract.NoneFlag).(int)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TotalSupply represents `totalSupply` method of NEO native contract.
|
|
|
|
func TotalSupply() int {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "totalSupply", contract.ReadStates).(int)
|
|
|
|
}
|
|
|
|
|
|
|
|
// BalanceOf represents `balanceOf` method of NEO native contract.
|
|
|
|
func BalanceOf(addr interop.Hash160) int {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "balanceOf", contract.ReadStates, addr).(int)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Transfer represents `transfer` method of NEO native contract.
|
|
|
|
func Transfer(from, to interop.Hash160, amount int, data interface{}) bool {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "transfer",
|
2021-02-12 09:43:44 +00:00
|
|
|
contract.All, from, to, amount, data).(bool)
|
2021-02-08 08:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetCommittee represents `getCommittee` method of NEO native contract.
|
|
|
|
func GetCommittee() []interop.PublicKey {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "getCommittee", contract.ReadStates).([]interop.PublicKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetCandidates represents `getCandidates` method of NEO native contract.
|
|
|
|
func GetCandidates() []interop.PublicKey {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "getCandidates", contract.ReadStates).([]interop.PublicKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetNextBlockValidators represents `getNextBlockValidators` method of NEO native contract.
|
|
|
|
func GetNextBlockValidators() []interop.PublicKey {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "getNextBlockValidators", contract.ReadStates).([]interop.PublicKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetGASPerBlock represents `getGasPerBlock` method of NEO native contract.
|
|
|
|
func GetGASPerBlock() int {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "getGasPerBlock", contract.ReadStates).(int)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetGASPerBlock represents `setGasPerBlock` method of NEO native contract.
|
|
|
|
func SetGASPerBlock(amount int) {
|
2021-02-25 15:04:46 +00:00
|
|
|
contract.Call(interop.Hash160(Hash), "setGasPerBlock", contract.States, amount)
|
2021-02-08 08:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RegisterCandidate represents `registerCandidate` method of NEO native contract.
|
|
|
|
func RegisterCandidate(pub interop.PublicKey) bool {
|
2021-02-25 15:04:46 +00:00
|
|
|
return contract.Call(interop.Hash160(Hash), "registerCandidate", contract.States, pub).(bool)
|
2021-02-08 08:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnregisterCandidate represents `unregisterCandidate` method of NEO native contract.
|
|
|
|
func UnregisterCandidate(pub interop.PublicKey) bool {
|
2021-02-25 15:04:46 +00:00
|
|
|
return contract.Call(interop.Hash160(Hash), "unregisterCandidate", contract.States, pub).(bool)
|
2021-02-08 08:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Vote represents `vote` method of NEO native contract.
|
|
|
|
func Vote(addr interop.Hash160, pub interop.PublicKey) bool {
|
2021-02-25 15:04:46 +00:00
|
|
|
return contract.Call(interop.Hash160(Hash), "vote", contract.States, addr, pub).(bool)
|
2021-02-08 08:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnclaimedGAS represents `unclaimedGas` method of NEO native contract.
|
|
|
|
func UnclaimedGAS(addr interop.Hash160, end int) int {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "unclaimedGas", contract.ReadStates, addr, end).(int)
|
|
|
|
}
|