[#15] Specify type of interface typed arguments

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-08-28 09:42:06 +03:00 committed by Alex Vanin
parent 47eb73ad67
commit 33802137ee

View file

@ -101,7 +101,7 @@ func init() {
} }
// Init set up initial inner ring node keys. // Init set up initial inner ring node keys.
func Init(args []interface{}) bool { func Init(args [][]byte) bool {
if storage.Get(ctx, innerRingKey) != nil { if storage.Get(ctx, innerRingKey) != nil {
panic("neofs: contract already deployed") panic("neofs: contract already deployed")
} }
@ -109,7 +109,7 @@ func Init(args []interface{}) bool {
var irList []node var irList []node
for i := 0; i < len(args); i++ { for i := 0; i < len(args); i++ {
pub := args[i].([]byte) pub := args[i]
irList = append(irList, node{pub: pub}) irList = append(irList, node{pub: pub})
} }
@ -187,19 +187,15 @@ func InnerRingCandidateAdd(key []byte) bool {
} }
// Deposit gas assets to this script-hash address in NeoFS balance contract. // Deposit gas assets to this script-hash address in NeoFS balance contract.
func Deposit(from []byte, args []interface{}) bool { func Deposit(from []byte, amount int, rcv []byte) bool {
if len(args) < 1 || len(args) > 2 {
panic("deposit: bad arguments")
}
if !runtime.CheckWitness(from) { if !runtime.CheckWitness(from) {
panic("deposit: you should be the owner of the wallet") panic("deposit: you should be the owner of the wallet")
} }
amount := args[0].(int) if amount <= 0 {
if amount > 0 { return false
amount = amount * 100000000
} }
amount = amount * 100000000
to := runtime.GetExecutingScriptHash() to := runtime.GetExecutingScriptHash()
@ -210,9 +206,8 @@ func Deposit(from []byte, args []interface{}) bool {
runtime.Log("deposit: funds have been transferred") runtime.Log("deposit: funds have been transferred")
var rcv = from if len(rcv) == 0 {
if len(args) == 2 { rcv = from
rcv = args[1].([]byte) // todo: check if rcv value is valid
} }
tx := runtime.GetScriptContainer() tx := runtime.GetScriptContainer()
@ -281,13 +276,13 @@ func Cheque(id, user []byte, amount int, lockAcc []byte) bool {
} }
// Bind public key with user's account to use it in NeoFS requests. // Bind public key with user's account to use it in NeoFS requests.
func Bind(user []byte, keys []interface{}) bool { func Bind(user []byte, keys [][]byte) bool {
if !runtime.CheckWitness(user) { if !runtime.CheckWitness(user) {
panic("binding: you should be the owner of the wallet") panic("binding: you should be the owner of the wallet")
} }
for i := 0; i < len(keys); i++ { for i := 0; i < len(keys); i++ {
pubKey := keys[i].([]byte) pubKey := keys[i]
if len(pubKey) != publicKeySize { if len(pubKey) != publicKeySize {
panic("binding: incorrect public key size") panic("binding: incorrect public key size")
} }
@ -299,13 +294,13 @@ func Bind(user []byte, keys []interface{}) bool {
} }
// Unbind public key from user's account // Unbind public key from user's account
func Unbind(user []byte, keys []interface{}) bool { func Unbind(user []byte, keys [][]byte) bool {
if !runtime.CheckWitness(user) { if !runtime.CheckWitness(user) {
panic("unbinding: you should be the owner of the wallet") panic("unbinding: you should be the owner of the wallet")
} }
for i := 0; i < len(keys); i++ { for i := 0; i < len(keys); i++ {
pubKey := keys[i].([]byte) pubKey := keys[i]
if len(pubKey) != publicKeySize { if len(pubKey) != publicKeySize {
panic("unbinding: incorrect public key size") panic("unbinding: incorrect public key size")
} }
@ -467,7 +462,7 @@ func ListConfig() []record {
} }
// InitConfig set up initial NeoFS key-value configuration. // InitConfig set up initial NeoFS key-value configuration.
func InitConfig(args []interface{}) bool { func InitConfig(args [][]byte) bool {
if getConfig(ctx, candidateFeeConfigKey) != nil { if getConfig(ctx, candidateFeeConfigKey) != nil {
panic("neofs: configuration already installed") panic("neofs: configuration already installed")
} }