[#72] Replace Init() methods with _deploy

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-05-12 11:31:07 +03:00 committed by Alex Vanin
parent e4ba936f50
commit dd98bee590
10 changed files with 73 additions and 18 deletions

View file

@ -33,7 +33,16 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
}
}
func Init(notaryDisabled bool, owner interop.Hash160, addrNetmap, addrProxy interop.Hash160, name string, index, total int) {
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrProxy := args[3].(interop.Hash160)
name := args[4].(string)
index := args[5].(int)
total := args[6].(int)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -42,7 +42,12 @@ const (
notaryDisabledKey = "notary"
)
func Init(notaryDisabled bool, owner interop.Hash160, addrNetmap interop.Hash160) {
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -63,7 +63,13 @@ func init() {
token = CreateToken()
}
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrContainer := args[3].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -55,7 +55,14 @@ var (
eACLPrefix = []byte("eACL")
)
func Init(notaryDisabled bool, owner, addrNetmap, addrBalance, addrID interop.Hash160) {
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrBalance := args[3].(interop.Hash160)
addrID := args[4].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -76,8 +76,14 @@ var (
configPrefix = []byte("config")
)
// Init set up initial alphabet node keys.
func Init(notaryDisabled bool, owner, addrProc interop.Hash160, args []interop.PublicKey) bool {
// _deploy sets up initial alphabet node keys.
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrProc := args[2].(interop.Hash160)
keys := args[3].([]interop.PublicKey)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -86,7 +92,7 @@ func Init(notaryDisabled bool, owner, addrProc interop.Hash160, args []interop.P
var irList []common.IRNode
if len(args) == 0 {
if len(keys) == 0 {
panic("neofs: at least one alphabet key must be provided")
}
@ -94,8 +100,8 @@ func Init(notaryDisabled bool, owner, addrProc interop.Hash160, args []interop.P
panic("neofs: incorrect length of contract script hash")
}
for i := 0; i < len(args); i++ {
pub := args[i]
for i := 0; i < len(keys); i++ {
pub := keys[i]
if len(pub) != publicKeySize {
panic("neofs: incorrect public key length")
}
@ -117,8 +123,6 @@ func Init(notaryDisabled bool, owner, addrProc interop.Hash160, args []interop.P
}
runtime.Log("neofs: contract initialized")
return true
}
// Migrate updates smart contract execution script and manifest.

View file

@ -24,7 +24,13 @@ const (
notaryDisabledKey = "notary"
)
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrContainer := args[3].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -58,9 +58,15 @@ var (
configPrefix = []byte("config")
)
// Init function sets up initial list of inner ring public keys and should
// be invoked once at neofs infrastructure setup.
func Init(notaryDisabled bool, owner, addrBalance, addrContainer interop.Hash160, keys []interop.PublicKey) {
// _deploy function sets up initial list of inner ring public keys.
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrBalance := args[2].(interop.Hash160)
addrContainer := args[3].(interop.Hash160)
keys := args[4].([]interop.PublicKey)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -25,7 +25,11 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
}
}
func Init(owner, addrNeoFS interop.Hash160) {
func _deploy(data interface{}, isUpdate bool) {
arr := data.([]interop.Hash160)
owner := arr[0]
addrNeoFS := arr[1]
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -23,7 +23,11 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
}
}
func Init(owner, addrNetmap interop.Hash160) {
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
owner := args[0].(interop.Hash160)
addrNetmap := args[1].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {

View file

@ -16,7 +16,11 @@ const (
version = 1
)
func Init(notaryDisabled bool, owner interop.Hash160) {
func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {