2021-03-19 09:11:48 +00:00
|
|
|
/*
|
|
|
|
Package management provides interface to ContractManagement native contract.
|
|
|
|
It allows to get/deploy/update contracts as well as get/set deployment fee.
|
|
|
|
*/
|
2021-02-08 08:59:25 +00:00
|
|
|
package management
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Hash represents Management contract hash.
|
2021-02-15 13:40:44 +00:00
|
|
|
const Hash = "\xfd\xa3\xfa\x43\x46\xea\x53\x2a\x25\x8f\xc4\x97\xdd\xad\xdb\x64\x37\xc9\xfd\xff"
|
2021-02-08 08:59:25 +00:00
|
|
|
|
|
|
|
// Deploy represents `deploy` method of Management native contract.
|
|
|
|
func Deploy(script, manifest []byte) *Contract {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "deploy",
|
2021-02-25 15:04:46 +00:00
|
|
|
contract.States|contract.AllowNotify, script, manifest).(*Contract)
|
2021-02-08 08:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeployWithData represents `deploy` method of Management native contract.
|
|
|
|
func DeployWithData(script, manifest []byte, data interface{}) *Contract {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "deploy",
|
2021-02-25 15:04:46 +00:00
|
|
|
contract.States|contract.AllowNotify, script, manifest, data).(*Contract)
|
2021-02-08 08:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy represents `destroy` method of Management native contract.
|
|
|
|
func Destroy() {
|
2021-02-25 15:04:46 +00:00
|
|
|
contract.Call(interop.Hash160(Hash), "destroy", contract.States|contract.AllowNotify)
|
2021-02-08 08:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetContract represents `getContract` method of Management native contract.
|
|
|
|
func GetContract(addr interop.Hash160) *Contract {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "getContract", contract.ReadStates, addr).(*Contract)
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetMinimumDeploymentFee represents `getMinimumDeploymentFee` method of Management native contract.
|
|
|
|
func GetMinimumDeploymentFee() int {
|
|
|
|
return contract.Call(interop.Hash160(Hash), "getMinimumDeploymentFee", contract.ReadStates).(int)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMinimumDeploymentFee represents `setMinimumDeploymentFee` method of Management native contract.
|
|
|
|
func SetMinimumDeploymentFee(value int) {
|
2021-02-25 15:04:46 +00:00
|
|
|
contract.Call(interop.Hash160(Hash), "setMinimumDeploymentFee", contract.States, value)
|
2021-02-08 08:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update represents `update` method of Management native contract.
|
|
|
|
func Update(script, manifest []byte) {
|
|
|
|
contract.Call(interop.Hash160(Hash), "update",
|
2021-02-25 15:04:46 +00:00
|
|
|
contract.States|contract.AllowNotify, script, manifest)
|
2021-02-08 08:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateWithData represents `update` method of Management native contract.
|
|
|
|
func UpdateWithData(script, manifest []byte, data interface{}) {
|
|
|
|
contract.Call(interop.Hash160(Hash), "update",
|
2021-02-25 15:04:46 +00:00
|
|
|
contract.States|contract.AllowNotify, script, manifest, data)
|
2021-02-08 08:59:25 +00:00
|
|
|
}
|