diff --git a/VERSION b/VERSION index 541e90a8e..c6cd196e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.44.7 +0.44.8 diff --git a/pkg/vm/api/asset/asset.go b/pkg/vm/api/asset/asset.go new file mode 100644 index 000000000..edc4aa99a --- /dev/null +++ b/pkg/vm/api/asset/asset.go @@ -0,0 +1,31 @@ +package asset + +import "github.com/CityOfZion/neo-go/pkg/core" + +// GetAssetID returns the id of the given asset. +func GetAssetID(asset *core.AssetState) []byte { return nil } + +// TODO: Verify if we need to return a uint8 here. +// GetAssetType returns the type of the given asset. +func GetAssetType(asset *core.AssetState) uint8 { return 0x00 } + +// GetAmount returns the amount of the given asset. +func GetAmount(asset *core.AssetState) uint64 { return 0 } + +// GetAvailable returns the available amount of the given asset. +func GetAvailable(asset *core.AssetState) uint64 { return 0 } + +// GetPrecision returns the precision the given asset. +func GetPrecision(asset *core.AssetState) uint8 { return 0 } + +// GetOwner returns the owner the given asset. +func GetOwner(asset *core.AssetState) []byte { return nil } + +// GetIssuer returns the issuer the given asset. +func GetIssuer(asset *core.AssetState) []byte { return nil } + +// Create a new asset specified by the given parameters. +func Create(typ uint8, name string, amount uint64, owner, admin, issuer []byte) {} + +// Renew the given asset for the given x years. +func Renew(asset *core.AssetState, years uint32) {} diff --git a/pkg/vm/api/block/block.go b/pkg/vm/api/block/block.go new file mode 100644 index 000000000..ad3b4d8a1 --- /dev/null +++ b/pkg/vm/api/block/block.go @@ -0,0 +1,41 @@ +package block + +import ( + "github.com/CityOfZion/neo-go/pkg/core" + "github.com/CityOfZion/neo-go/pkg/core/transaction" +) + +// GetTransactionCount returns the number of transactions that are recorded in +// the given block. +func GetTransactionCount(block *core.Block) int { return 0 } + +// GetTransactions returns a list of transactions that are recorded in this block. +func GetTransactions(block *core.Block) []*transaction.Transaction { return nil } + +// GetIndex returns the index of the given block. +func GetIndex(block *core.Block) uint32 { return 0 } + +// GetHash returns the hash of the given block. +func GetHash(block *core.Block) []byte { return nil } + +// GetHash returns the version of the given block. +func GetVersion(block *core.Block) uint32 { return 0 } + +// GetHash returns the previous hash of the given block. +func GetPrevHash(block *core.Block) []byte { return nil } + +// GetHash returns the merkle root of the given block. +func GetMerkleRoot(block *core.Block) []byte { return nil } + +// GetHash returns the timestamp of the given block. +func GetTimestamp(block *core.Block) uint32 { return 0 } + +// GetHash returns the next validator address of the given block. +func GetNextConsensus(block *core.Block) []byte { return nil } + +// GetConsensusData returns the consensus data of the given block. +func GetConsensusData(block *core.Block) uint64 { return 0 } + +// GetTransaction returns a specific transaction that is recorded in the given block +// by the given index. +func GetTransaction(block *core.Block, index int) *transaction.Transaction { return nil } diff --git a/pkg/vm/api/header/header.go b/pkg/vm/api/header/header.go new file mode 100644 index 000000000..c4254bd94 --- /dev/null +++ b/pkg/vm/api/header/header.go @@ -0,0 +1,24 @@ +package header + +import "github.com/CityOfZion/neo-go/pkg/core" + +// GetIndex returns the index of the given header. +func GetIndex(header *core.Header) uint32 { return 0 } + +// GetHash returns the hash of the given header. +func GetHash(header *core.Header) []byte { return nil } + +// GetHash returns the version of the given header. +func GetVersion(header *core.Header) uint32 { return 0 } + +// GetHash returns the previous hash of the given header. +func GetPrevHash(header *core.Header) []byte { return nil } + +// GetHash returns the merkle root of the given header. +func GetMerkleRoot(header *core.Header) []byte { return nil } + +// GetHash returns the timestamp of the given header. +func GetTimestamp(header *core.Header) uint32 { return 0 } + +// GetHash returns the next validator address of the given header. +func GetNextConsensus(header *core.Header) []byte { return nil } diff --git a/pkg/vm/api/runtime/runtime.go b/pkg/vm/api/runtime/runtime.go index 95d1f8c1f..3d8c50a16 100644 --- a/pkg/vm/api/runtime/runtime.go +++ b/pkg/vm/api/runtime/runtime.go @@ -1,15 +1,10 @@ package runtime -import "github.com/CityOfZion/neo-go/pkg/vm/api/types" - // CheckWitness verifies if the invoker is the owner of the contract. func CheckWitness(hash []byte) bool { return true } -// GetCurrentBlock returns the current block. -func GetCurrentBlock() types.Block { return types.Block{} } - // GetTime returns the timestamp of the most recent block. func GetTime() int { return 0 @@ -38,3 +33,13 @@ func Verification() byte { func GetTrigger() interface{} { return 0 } + +// Serialize serializes and item into a bytearray. +func Serialize(item interface{}) []byte { + return nil +} + +// Deserializes an item from a bytearray. +func Deserialize(b []byte) interface{} { + return nil +} diff --git a/pkg/vm/api/storage/storage.go b/pkg/vm/api/storage/storage.go index f253a07fe..d3360d50a 100644 --- a/pkg/vm/api/storage/storage.go +++ b/pkg/vm/api/storage/storage.go @@ -14,3 +14,6 @@ func Get(ctx interface{}, key interface{}) interface{} { return 0 } // Delete removes a stored key value pair. func Delete(ctx interface{}, key interface{}) {} + +// Find entrys somewhat matching the given key. +func Find(ctx interface{}, key interface{}) interface{} { return 0 } diff --git a/pkg/vm/api/transaction/transaction.go b/pkg/vm/api/transaction/transaction.go new file mode 100644 index 000000000..e0744e217 --- /dev/null +++ b/pkg/vm/api/transaction/transaction.go @@ -0,0 +1,27 @@ +package transaction + +import "github.com/CityOfZion/neo-go/pkg/core/transaction" + +// GetType returns the type of the given transaction. +// TODO: Double check if the type returned should be of type uint8. +func GetType(tx *transaction.Transaction) uint8 { return 0x00 } + +// GetTXHash returns the hash of the given transaction. +func GetTXHash(tx *transaction.Transaction) []byte { return nil } + +// GetAttributes returns the attributes of the given transaction. +func GetAttributes(tx *transaction.Transaction) []*transaction.Attribute { return nil } + +// GetInputs returns the inputs of the given transaction. +func GetInputs(tx *transaction.Transaction) []*transaction.Input { return nil } + +// GetOutputs returns the outputs of the given transaction. +func GetOutputs(tx *transaction.Transaction) []*transaction.Output { return nil } + +// TODO: What does this return as data type? +// GetReferences returns the outputs of the given transaction. +// func GetReferences(tx *transaction.Transaction) { } + +// TODO: What does this return as data type? +// GetUnspentCoins returns the unspent coins of the given transaction. +// func GetUnspentCoins(tx *transaction.Transaction) { } diff --git a/pkg/vm/compiler/README.md b/pkg/vm/compiler/README.md index 588630308..3d2cbb44f 100644 --- a/pkg/vm/compiler/README.md +++ b/pkg/vm/compiler/README.md @@ -25,19 +25,24 @@ The neo-go compiler compiles Go programs to bytecode that the NEO virtual machin ### VM API (interop layer) - storage - runtime +- block +- header +- transaction +- asset +- blockchain ### VM utility helper functions - SHA1 - SHA256 - Hash256 - Hash160 +- other.. ### Custom utility functions - `FromAddress(address string) []byte` ## Not yet implemented -- range -- some parts of the interop layer (VM API) +- very small part of the interop layer (VM API) ## Not supported Due to the limitations of the NEO virtual machine, features listed below will not be supported. @@ -152,7 +157,7 @@ type Token struct { func (t Token) AddToCirculation(amount int) bool { ctx := storage.Context() - inCirc := storage.GetInt(ctx, "in_circ") + inCirc := storage.Get(ctx, "in_circ").(int) inCirc += amount storage.Put(ctx, "in_circ", inCirc) return true