[#185] *: Cast args of _deploy
method to struct
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
b2559857f6
commit
f78a0e32b8
10 changed files with 114 additions and 104 deletions
|
@ -37,34 +37,35 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
addrNetmap := args[1].(interop.Hash160)
|
addrNetmap interop.Hash160
|
||||||
addrProxy := args[2].(interop.Hash160)
|
addrProxy interop.Hash160
|
||||||
name := args[3].(string)
|
name string
|
||||||
index := args[4].(int)
|
index int
|
||||||
total := args[5].(int)
|
total int
|
||||||
|
})
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || !notaryDisabled && len(addrProxy) != 20 {
|
if len(args.addrNetmap) != 20 || !args.notaryDisabled && len(args.addrProxy) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, netmapKey, addrNetmap)
|
storage.Put(ctx, netmapKey, args.addrNetmap)
|
||||||
storage.Put(ctx, proxyKey, addrProxy)
|
storage.Put(ctx, proxyKey, args.addrProxy)
|
||||||
storage.Put(ctx, nameKey, name)
|
storage.Put(ctx, nameKey, args.name)
|
||||||
storage.Put(ctx, indexKey, index)
|
storage.Put(ctx, indexKey, args.index)
|
||||||
storage.Put(ctx, totalKey, total)
|
storage.Put(ctx, totalKey, args.total)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
common.InitVote(ctx)
|
common.InitVote(ctx)
|
||||||
runtime.Log(name + " notary disabled")
|
runtime.Log(args.name + " notary disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log(name + " contract initialized")
|
runtime.Log(args.name + " contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
|
|
|
@ -47,21 +47,22 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
addrNetmap := args[1].(interop.Hash160)
|
addrNetmap interop.Hash160
|
||||||
|
})
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(addrNetmap) != 20 {
|
if len(args.addrNetmap) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
runtime.Log("audit contract notary disabled")
|
runtime.Log("audit contract notary disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,23 +63,24 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
addrNetmap := args[1].(interop.Hash160)
|
addrNetmap interop.Hash160
|
||||||
addrContainer := args[2].(interop.Hash160)
|
addrContainer interop.Hash160
|
||||||
|
})
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
|
if len(args.addrNetmap) != 20 || len(args.addrContainer) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
storage.Put(ctx, containerContractKey, args.addrContainer)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
common.InitVote(ctx)
|
common.InitVote(ctx)
|
||||||
runtime.Log("balance contract notary disabled")
|
runtime.Log("balance contract notary disabled")
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,40 +84,41 @@ func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{}) {
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data interface{}, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
addrNetmap := args[1].(interop.Hash160)
|
addrNetmap interop.Hash160
|
||||||
addrBalance := args[2].(interop.Hash160)
|
addrBalance interop.Hash160
|
||||||
addrID := args[3].(interop.Hash160)
|
addrID interop.Hash160
|
||||||
addrNNS := args[4].(interop.Hash160)
|
addrNNS interop.Hash160
|
||||||
nnsRoot := args[5].(string)
|
nnsRoot string
|
||||||
|
})
|
||||||
|
|
||||||
if isUpdate {
|
if isUpdate {
|
||||||
storage.Put(ctx, nnsContractKey, addrNNS)
|
storage.Put(ctx, nnsContractKey, args.addrNNS)
|
||||||
storage.Put(ctx, nnsRootKey, nnsRoot)
|
storage.Put(ctx, nnsRootKey, args.nnsRoot)
|
||||||
registerNiceNameTLD(addrNNS, nnsRoot)
|
registerNiceNameTLD(args.addrNNS, args.nnsRoot)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || len(addrBalance) != 20 || len(addrID) != 20 {
|
if len(args.addrNetmap) != 20 || len(args.addrBalance) != 20 || len(args.addrID) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
||||||
storage.Put(ctx, balanceContractKey, addrBalance)
|
storage.Put(ctx, balanceContractKey, args.addrBalance)
|
||||||
storage.Put(ctx, neofsIDContractKey, addrID)
|
storage.Put(ctx, neofsIDContractKey, args.addrID)
|
||||||
storage.Put(ctx, nnsContractKey, addrNNS)
|
storage.Put(ctx, nnsContractKey, args.addrNNS)
|
||||||
storage.Put(ctx, nnsRootKey, nnsRoot)
|
storage.Put(ctx, nnsRootKey, args.nnsRoot)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
common.InitVote(ctx)
|
common.InitVote(ctx)
|
||||||
runtime.Log("container contract notary disabled")
|
runtime.Log("container contract notary disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
// add NNS root for container alias domains
|
// add NNS root for container alias domains
|
||||||
registerNiceNameTLD(addrNNS, nnsRoot)
|
registerNiceNameTLD(args.addrNNS, args.nnsRoot)
|
||||||
|
|
||||||
runtime.Log("container contract initialized")
|
runtime.Log("container contract initialized")
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,26 +60,27 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
addrProc := args[1].(interop.Hash160)
|
addrProc interop.Hash160
|
||||||
keys := args[2].([]interop.PublicKey)
|
keys []interop.PublicKey
|
||||||
config := args[3].([][]byte)
|
config [][]byte
|
||||||
|
})
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
var irList []common.IRNode
|
var irList []common.IRNode
|
||||||
|
|
||||||
if len(keys) == 0 {
|
if len(args.keys) == 0 {
|
||||||
panic("at least one alphabet key must be provided")
|
panic("at least one alphabet key must be provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(addrProc) != 20 {
|
if len(args.addrProc) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(args.keys); i++ {
|
||||||
pub := keys[i]
|
pub := args.keys[i]
|
||||||
if len(pub) != publicKeySize {
|
if len(pub) != publicKeySize {
|
||||||
panic("incorrect public key length")
|
panic("incorrect public key length")
|
||||||
}
|
}
|
||||||
|
@ -89,23 +90,23 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
// initialize all storage slices
|
// initialize all storage slices
|
||||||
common.SetSerialized(ctx, alphabetKey, irList)
|
common.SetSerialized(ctx, alphabetKey, irList)
|
||||||
|
|
||||||
storage.Put(ctx, processingContractKey, addrProc)
|
storage.Put(ctx, processingContractKey, args.addrProc)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
common.InitVote(ctx)
|
common.InitVote(ctx)
|
||||||
runtime.Log("neofs contract notary disabled")
|
runtime.Log("neofs contract notary disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
ln := len(config)
|
ln := len(args.config)
|
||||||
if ln%2 != 0 {
|
if ln%2 != 0 {
|
||||||
panic("bad configuration")
|
panic("bad configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < ln/2; i++ {
|
for i := 0; i < ln/2; i++ {
|
||||||
key := config[i*2]
|
key := args.config[i*2]
|
||||||
val := config[i*2+1]
|
val := args.config[i*2+1]
|
||||||
|
|
||||||
setConfig(ctx, key, val)
|
setConfig(ctx, key, val)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,21 +45,22 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
addrNetmap := args[1].(interop.Hash160)
|
addrNetmap interop.Hash160
|
||||||
addrContainer := args[2].(interop.Hash160)
|
addrContainer interop.Hash160
|
||||||
|
})
|
||||||
|
|
||||||
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
|
if len(args.addrNetmap) != 20 || len(args.addrContainer) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
storage.Put(ctx, containerContractKey, args.addrContainer)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
common.InitVote(ctx)
|
common.InitVote(ctx)
|
||||||
runtime.Log("neofsid contract notary disabled")
|
runtime.Log("neofsid contract notary disabled")
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,21 +62,22 @@ var (
|
||||||
func _deploy(data interface{}, isUpdate bool) {
|
func _deploy(data interface{}, isUpdate bool) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
args := data.([]interface{})
|
var args = data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
addrBalance := args[1].(interop.Hash160)
|
addrBalance interop.Hash160
|
||||||
addrContainer := args[2].(interop.Hash160)
|
addrContainer interop.Hash160
|
||||||
keys := args[3].([]interop.PublicKey)
|
keys []interop.PublicKey
|
||||||
config := args[4].([][]byte)
|
config [][]byte
|
||||||
|
})
|
||||||
|
|
||||||
ln := len(config)
|
ln := len(args.config)
|
||||||
if ln%2 != 0 {
|
if ln%2 != 0 {
|
||||||
panic("bad configuration")
|
panic("bad configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < ln/2; i++ {
|
for i := 0; i < ln/2; i++ {
|
||||||
key := config[i*2]
|
key := args.config[i*2]
|
||||||
val := config[i*2+1]
|
val := args.config[i*2+1]
|
||||||
|
|
||||||
setConfig(ctx, key, val)
|
setConfig(ctx, key, val)
|
||||||
}
|
}
|
||||||
|
@ -85,7 +86,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(addrBalance) != 20 || len(addrContainer) != 20 {
|
if len(args.addrBalance) != 20 || len(args.addrContainer) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,16 +97,16 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
common.SetSerialized(ctx, snapshot0Key, []netmapNode{})
|
common.SetSerialized(ctx, snapshot0Key, []netmapNode{})
|
||||||
common.SetSerialized(ctx, snapshot1Key, []netmapNode{})
|
common.SetSerialized(ctx, snapshot1Key, []netmapNode{})
|
||||||
|
|
||||||
storage.Put(ctx, balanceContractKey, addrBalance)
|
storage.Put(ctx, balanceContractKey, args.addrBalance)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
storage.Put(ctx, containerContractKey, args.addrContainer)
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
var irList []common.IRNode
|
var irList []common.IRNode
|
||||||
|
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(args.keys); i++ {
|
||||||
key := keys[i]
|
key := args.keys[i]
|
||||||
irList = append(irList, common.IRNode{PublicKey: key})
|
irList = append(irList, common.IRNode{PublicKey: key})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,17 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
arr := data.([]interop.Hash160)
|
args := data.(struct {
|
||||||
addrNeoFS := arr[0]
|
addrNeoFS interop.Hash160
|
||||||
|
})
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(addrNeoFS) != 20 {
|
if len(args.addrNeoFS) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, neofsContractKey, addrNeoFS)
|
storage.Put(ctx, neofsContractKey, args.addrNeoFS)
|
||||||
|
|
||||||
runtime.Log("processing contract initialized")
|
runtime.Log("processing contract initialized")
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,16 +28,17 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
addrNetmap := args[0].(interop.Hash160)
|
addrNetmap interop.Hash160
|
||||||
|
})
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(addrNetmap) != 20 {
|
if len(args.addrNetmap) != 20 {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, args.addrNetmap)
|
||||||
|
|
||||||
runtime.Log("proxy contract initialized")
|
runtime.Log("proxy contract initialized")
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,12 +43,13 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
args := data.([]interface{})
|
args := data.(struct {
|
||||||
notaryDisabled := args[0].(bool)
|
notaryDisabled bool
|
||||||
|
})
|
||||||
|
|
||||||
// initialize the way to collect signatures
|
// initialize the way to collect signatures
|
||||||
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
storage.Put(ctx, notaryDisabledKey, args.notaryDisabled)
|
||||||
if notaryDisabled {
|
if args.notaryDisabled {
|
||||||
common.InitVote(ctx)
|
common.InitVote(ctx)
|
||||||
runtime.Log("reputation contract notary disabled")
|
runtime.Log("reputation contract notary disabled")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue