frostfs-contract/common/witness.go
Elizaveta Chichindaeva 335b04d9a6 [#240] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-04-26 23:22:06 +03:00

39 lines
1.3 KiB
Go

package common
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
var (
// ErrAlphabetWitnessFailed appears when the method must be
// called by the Alphabet but was not.
ErrAlphabetWitnessFailed = "alphabet witness check failed"
// ErrOwnerWitnessFailed appears when the method must be called
// by an owner of some assets but was not.
ErrOwnerWitnessFailed = "owner witness check failed"
// ErrWitnessFailed appears when the method must be called
// using certain public key but was not.
ErrWitnessFailed = "witness check failed"
)
// CheckAlphabetWitness checks witness of the passed caller.
// It panics with ErrAlphabetWitnessFailed message on fail.
func CheckAlphabetWitness(caller []byte) {
checkWitnessWithPanic(caller, ErrAlphabetWitnessFailed)
}
// CheckOwnerWitness checks witness of the passed caller.
// It panics with ErrOwnerWitnessFailed message on fail.
func CheckOwnerWitness(caller []byte) {
checkWitnessWithPanic(caller, ErrOwnerWitnessFailed)
}
// CheckWitness checks witness of the passed caller.
// It panics with ErrWitnessFailed message on fail.
func CheckWitness(caller []byte) {
checkWitnessWithPanic(caller, ErrWitnessFailed)
}
func checkWitnessWithPanic(caller []byte, panicMsg string) {
if !runtime.CheckWitness(caller) {
panic(panicMsg)
}
}