frostfs-contract/common/transfer.go
Evgenii Stratonikov d890a7eba4
All checks were successful
DCO action / DCO (pull_request) Successful in 1m6s
Tests / Tests (1.19) (pull_request) Successful in 1m17s
Tests / Tests (1.20) (pull_request) Successful in 1m12s
[#50] Replace interface{} with any
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-11-07 15:18:48 +03:00

47 lines
1.1 KiB
Go

package common
import (
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/interop/util"
)
var (
mintPrefix = []byte{0x01}
burnPrefix = []byte{0x02}
lockPrefix = []byte{0x03}
unlockPrefix = []byte{0x04}
containerFeePrefix = []byte{0x10}
)
func WalletToScriptHash(wallet []byte) []byte {
// V2 format
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 {
var buf any = epoch
return append(unlockPrefix, buf.([]byte)...)
}
func ContainerFeeTransferDetails(cid []byte) []byte {
return append(containerFeePrefix, cid...)
}
// AbortWithMessage calls `runtime.Log` with the passed message
// and calls `ABORT` opcode.
func AbortWithMessage(msg string) {
runtime.Log(msg)
util.Abort()
}