2021-04-07 06:17:00 +00:00
|
|
|
package common
|
|
|
|
|
2021-11-30 09:44:05 +00:00
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
|
|
|
)
|
|
|
|
|
2021-04-07 06:17:00 +00:00
|
|
|
var (
|
|
|
|
mintPrefix = []byte{0x01}
|
|
|
|
burnPrefix = []byte{0x02}
|
|
|
|
lockPrefix = []byte{0x03}
|
|
|
|
unlockPrefix = []byte{0x04}
|
|
|
|
containerFeePrefix = []byte{0x10}
|
|
|
|
)
|
|
|
|
|
|
|
|
func WalletToScriptHash(wallet []byte) []byte {
|
2021-11-29 17:58:27 +00:00
|
|
|
// V2 format
|
2021-04-07 06:17:00 +00:00
|
|
|
return wallet[1 : len(wallet)-4]
|
|
|
|
}
|
|
|
|
|
|
|
|
func MintTransferDetails(txDetails []byte) []byte {
|
|
|
|
return append(mintPrefix, txDetails...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BurnTransferDetails(txDetails []byte) []byte {
|
|
|
|
return append(burnPrefix, txDetails...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func LockTransferDetails(txDetails []byte) []byte {
|
|
|
|
return append(lockPrefix, txDetails...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func UnlockTransferDetails(epoch int) []byte {
|
2023-11-07 12:18:48 +00:00
|
|
|
var buf any = epoch
|
2021-04-07 06:17:00 +00:00
|
|
|
return append(unlockPrefix, buf.([]byte)...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ContainerFeeTransferDetails(cid []byte) []byte {
|
|
|
|
return append(containerFeePrefix, cid...)
|
|
|
|
}
|
2021-11-30 09:44:05 +00:00
|
|
|
|
2022-04-14 11:56:51 +00:00
|
|
|
// AbortWithMessage calls `runtime.Log` with the passed message
|
2021-11-30 09:44:05 +00:00
|
|
|
// and calls `ABORT` opcode.
|
|
|
|
func AbortWithMessage(msg string) {
|
|
|
|
runtime.Log(msg)
|
|
|
|
util.Abort()
|
|
|
|
}
|