[#185] *: Use neo-go's interop
constants instead of local
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
f78a0e32b8
commit
23d9799e51
10 changed files with 21 additions and 21 deletions
|
@ -48,7 +48,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(args.addrNetmap) != 20 || !args.notaryDisabled && len(args.addrProxy) != 20 {
|
if len(args.addrNetmap) != interop.Hash160Len || !args.notaryDisabled && len(args.addrProxy) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(args.addrNetmap) != 20 {
|
if len(args.addrNetmap) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(args.addrNetmap) != 20 || len(args.addrContainer) != 20 {
|
if len(args.addrNetmap) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ func NewEpoch(epochNum int) {
|
||||||
it := storage.Find(ctx, []byte{}, storage.KeysOnly)
|
it := storage.Find(ctx, []byte{}, storage.KeysOnly)
|
||||||
for iterator.Next(it) {
|
for iterator.Next(it) {
|
||||||
addr := iterator.Value(it).(interop.Hash160) // it MUST BE `storage.KeysOnly`
|
addr := iterator.Value(it).(interop.Hash160) // it MUST BE `storage.KeysOnly`
|
||||||
if len(addr) != 20 {
|
if len(addr) != interop.Hash160Len {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ func (t Token) canTransfer(ctx storage.Context, from, to interop.Hash160, amount
|
||||||
)
|
)
|
||||||
|
|
||||||
if !innerRing {
|
if !innerRing {
|
||||||
if len(to) != 20 || !isUsableAddress(from) {
|
if len(to) != interop.Hash160Len || !isUsableAddress(from) {
|
||||||
runtime.Log("bad script hashes")
|
runtime.Log("bad script hashes")
|
||||||
return emptyAcc, false
|
return emptyAcc, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,9 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args.addrNetmap) != 20 || len(args.addrBalance) != 20 || len(args.addrID) != 20 {
|
if len(args.addrNetmap) != interop.Hash160Len ||
|
||||||
|
len(args.addrBalance) != interop.Hash160Len ||
|
||||||
|
len(args.addrID) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,6 @@ const (
|
||||||
|
|
||||||
processingContractKey = "processingScriptHash"
|
processingContractKey = "processingScriptHash"
|
||||||
|
|
||||||
publicKeySize = 33
|
|
||||||
|
|
||||||
maxBalanceAmount = 9000 // Max integer of Fixed12 in JSON bound (2**53-1)
|
maxBalanceAmount = 9000 // Max integer of Fixed12 in JSON bound (2**53-1)
|
||||||
maxBalanceAmountGAS = maxBalanceAmount * 1_0000_0000
|
maxBalanceAmountGAS = maxBalanceAmount * 1_0000_0000
|
||||||
|
|
||||||
|
@ -75,13 +73,13 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
panic("at least one alphabet key must be provided")
|
panic("at least one alphabet key must be provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args.addrProc) != 20 {
|
if len(args.addrProc) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(args.keys); i++ {
|
for i := 0; i < len(args.keys); i++ {
|
||||||
pub := args.keys[i]
|
pub := args.keys[i]
|
||||||
if len(pub) != publicKeySize {
|
if len(pub) != interop.PublicKeyCompressedLen {
|
||||||
panic("incorrect public key length")
|
panic("incorrect public key length")
|
||||||
}
|
}
|
||||||
irList = append(irList, common.IRNode{PublicKey: pub})
|
irList = append(irList, common.IRNode{PublicKey: pub})
|
||||||
|
@ -381,7 +379,7 @@ func Bind(user []byte, keys []interop.PublicKey) {
|
||||||
|
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(keys); i++ {
|
||||||
pubKey := keys[i]
|
pubKey := keys[i]
|
||||||
if len(pubKey) != publicKeySize {
|
if len(pubKey) != interop.PublicKeyCompressedLen {
|
||||||
panic("incorrect public key size")
|
panic("incorrect public key size")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,7 +399,7 @@ func Unbind(user []byte, keys []interop.PublicKey) {
|
||||||
|
|
||||||
for i := 0; i < len(keys); i++ {
|
for i := 0; i < len(keys); i++ {
|
||||||
pubKey := keys[i]
|
pubKey := keys[i]
|
||||||
if len(pubKey) != publicKeySize {
|
if len(pubKey) != interop.PublicKeyCompressedLen {
|
||||||
panic("incorrect public key size")
|
panic("incorrect public key size")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,7 +440,7 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) {
|
||||||
|
|
||||||
for i := 0; i < len(args); i++ {
|
for i := 0; i < len(args); i++ {
|
||||||
pubKey := args[i]
|
pubKey := args[i]
|
||||||
if len(pubKey) != publicKeySize {
|
if len(pubKey) != interop.PublicKeyCompressedLen {
|
||||||
panic("invalid public key in alphabet list")
|
panic("invalid public key in alphabet list")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
addrContainer interop.Hash160
|
addrContainer interop.Hash160
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(args.addrNetmap) != 20 || len(args.addrContainer) != 20 {
|
if len(args.addrNetmap) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ func AddKey(owner []byte, keys []interop.PublicKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range keys {
|
for i := range keys {
|
||||||
if len(keys[i]) != 33 {
|
if len(keys[i]) != interop.PublicKeyCompressedLen {
|
||||||
panic("incorrect public key")
|
panic("incorrect public key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ func RemoveKey(owner []byte, keys []interop.PublicKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range keys {
|
for i := range keys {
|
||||||
if len(keys[i]) != 33 {
|
if len(keys[i]) != interop.PublicKeyCompressedLen {
|
||||||
panic("incorrect public key")
|
panic("incorrect public key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args.addrBalance) != 20 || len(args.addrContainer) != 20 {
|
if len(args.addrBalance) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ func AddPeer(nodeInfo []byte) {
|
||||||
//
|
//
|
||||||
// Method panics when invoked with unsupported states.
|
// Method panics when invoked with unsupported states.
|
||||||
func UpdateState(state int, publicKey interop.PublicKey) {
|
func UpdateState(state int, publicKey interop.PublicKey) {
|
||||||
if len(publicKey) != 33 {
|
if len(publicKey) != interop.PublicKeyCompressedLen {
|
||||||
panic("incorrect public key")
|
panic("incorrect public key")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -666,7 +666,7 @@ func getIdRecordKey(tokenId []byte, name string, typ RecordType, id byte) []byte
|
||||||
|
|
||||||
// isValid returns true if the provided address is a valid Uint160.
|
// isValid returns true if the provided address is a valid Uint160.
|
||||||
func isValid(address interop.Hash160) bool {
|
func isValid(address interop.Hash160) bool {
|
||||||
return address != nil && len(address) == 20
|
return address != nil && len(address) == interop.Hash160Len
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkCommittee panics if the script container is not signed by the committee.
|
// checkCommittee panics if the script container is not signed by the committee.
|
||||||
|
|
|
@ -37,7 +37,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(args.addrNeoFS) != 20 {
|
if len(args.addrNeoFS) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if len(args.addrNetmap) != 20 {
|
if len(args.addrNetmap) != interop.Hash160Len {
|
||||||
panic("incorrect length of contract script hash")
|
panic("incorrect length of contract script hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue