forked from TrueCloudLab/frostfs-contract
[#23] *: Replace engine.AppCall with contract.Call
This commit is contained in:
parent
e17d0f4d97
commit
189a83d9d6
13 changed files with 72 additions and 83 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -79,18 +78,18 @@ func Neo() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func balance(hash string, addr []byte) int {
|
func balance(hash string, addr []byte) int {
|
||||||
balance := engine.AppCall([]byte(hash), "balanceOf", addr)
|
balance := contract.Call([]byte(hash), "balanceOf", addr)
|
||||||
return balance.(int)
|
return balance.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func irList() []irNode {
|
func irList() []irNode {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
return contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func currentEpoch() int {
|
func currentEpoch() int {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
return engine.AppCall(netmapContractAddr, "epoch").(int)
|
return contract.Call(netmapContractAddr, "epoch").(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkPermission(ir []irNode) bool {
|
func checkPermission(ir []irNode) bool {
|
||||||
|
@ -126,7 +125,7 @@ func Emit() bool {
|
||||||
contractHash := runtime.GetExecutingScriptHash()
|
contractHash := runtime.GetExecutingScriptHash()
|
||||||
neo := balance(neoHash, contractHash)
|
neo := balance(neoHash, contractHash)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
_ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo)
|
||||||
|
|
||||||
gas := balance(gasHash, contractHash)
|
gas := balance(gasHash, contractHash)
|
||||||
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
gasPerNode := gas * 7 / 8 / len(innerRingKeys)
|
||||||
|
@ -140,7 +139,7 @@ func Emit() bool {
|
||||||
node := innerRingKeys[i]
|
node := innerRingKeys[i]
|
||||||
address := contract.CreateStandardAccount(node.key)
|
address := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
_ = engine.AppCall([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
_ = contract.Call([]byte(gasHash), "transfer", contractHash, address, gasPerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.Log("utility token has been emitted to inner ring nodes")
|
runtime.Log("utility token has been emitted to inner ring nodes")
|
||||||
|
@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) {
|
||||||
candidate := candidates[index%len(candidates)]
|
candidate := candidates[index%len(candidates)]
|
||||||
address := runtime.GetExecutingScriptHash()
|
address := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool)
|
ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool)
|
||||||
if ok {
|
if ok {
|
||||||
runtime.Log(name + ": successfully voted for validator")
|
runtime.Log(name + ": successfully voted for validator")
|
||||||
removeVotes(ctx, id)
|
removeVotes(ctx, id)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package auditcontract
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -88,7 +87,7 @@ func Init(addrNetmap, addrBalance, addrContainer []byte) {
|
||||||
|
|
||||||
func Put(rawAuditResult []byte) bool {
|
func Put(rawAuditResult []byte) bool {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
|
|
||||||
auditResult, err := newAuditResult(rawAuditResult)
|
auditResult, err := newAuditResult(rawAuditResult)
|
||||||
if err {
|
if err {
|
||||||
|
@ -122,7 +121,7 @@ func Put(rawAuditResult []byte) bool {
|
||||||
containerContract := storage.Get(ctx, containerContractKey).([]byte)
|
containerContract := storage.Get(ctx, containerContractKey).([]byte)
|
||||||
|
|
||||||
// todo: implement easy way to get owner from the container id
|
// todo: implement easy way to get owner from the container id
|
||||||
ownerID := engine.AppCall(containerContract, "owner", auditResult.ContainerID).([]byte)
|
ownerID := contract.Call(containerContract, "owner", auditResult.ContainerID).([]byte)
|
||||||
if len(ownerID) != ownerIDLength {
|
if len(ownerID) != ownerIDLength {
|
||||||
runtime.Log("put: can't get owner id of the container")
|
runtime.Log("put: can't get owner id of the container")
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ func Put(rawAuditResult []byte) bool {
|
||||||
balanceContract := storage.Get(ctx, balanceContractKey).([]byte)
|
balanceContract := storage.Get(ctx, balanceContractKey).([]byte)
|
||||||
irScriptHash := contract.CreateStandardAccount(auditResult.InnerRingNode)
|
irScriptHash := contract.CreateStandardAccount(auditResult.InnerRingNode)
|
||||||
|
|
||||||
tx := engine.AppCall(balanceContract, "transferX",
|
tx := contract.Call(balanceContract, "transferX",
|
||||||
ownerScriptHash,
|
ownerScriptHash,
|
||||||
irScriptHash,
|
irScriptHash,
|
||||||
auditFee,
|
auditFee,
|
||||||
|
@ -149,7 +148,7 @@ func Put(rawAuditResult []byte) bool {
|
||||||
node := auditResult.Nodes[i]
|
node := auditResult.Nodes[i]
|
||||||
nodeScriptHash := contract.CreateStandardAccount(node.Key)
|
nodeScriptHash := contract.CreateStandardAccount(node.Key)
|
||||||
|
|
||||||
tx := engine.AppCall(balanceContract, "transferX",
|
tx := contract.Call(balanceContract, "transferX",
|
||||||
ownerScriptHash,
|
ownerScriptHash,
|
||||||
nodeScriptHash,
|
nodeScriptHash,
|
||||||
node.Reward,
|
node.Reward,
|
||||||
|
|
|
@ -3,8 +3,8 @@ package balancecontract
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
|
@ -132,7 +132,7 @@ func TransferX(from, to []byte, amount int, details []byte) bool {
|
||||||
)
|
)
|
||||||
|
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
irKey := innerRingInvoker(innerRing)
|
irKey := innerRingInvoker(innerRing)
|
||||||
|
@ -168,7 +168,7 @@ func TransferX(from, to []byte, amount int, details []byte) bool {
|
||||||
|
|
||||||
func Lock(txID, from, to []byte, amount, until int) bool {
|
func Lock(txID, from, to []byte, amount, until int) bool {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
irKey := innerRingInvoker(innerRing)
|
irKey := innerRingInvoker(innerRing)
|
||||||
|
@ -206,7 +206,7 @@ func Lock(txID, from, to []byte, amount, until int) bool {
|
||||||
|
|
||||||
func NewEpoch(epochNum int) bool {
|
func NewEpoch(epochNum int) bool {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
irKey := innerRingInvoker(innerRing)
|
irKey := innerRingInvoker(innerRing)
|
||||||
|
@ -245,7 +245,7 @@ func NewEpoch(epochNum int) bool {
|
||||||
|
|
||||||
func Mint(to []byte, amount int, details []byte) bool {
|
func Mint(to []byte, amount int, details []byte) bool {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
irKey := innerRingInvoker(innerRing)
|
irKey := innerRingInvoker(innerRing)
|
||||||
|
@ -276,7 +276,7 @@ func Mint(to []byte, amount int, details []byte) bool {
|
||||||
|
|
||||||
func Burn(from []byte, amount int, details []byte) bool {
|
func Burn(from []byte, amount int, details []byte) bool {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
irKey := innerRingInvoker(innerRing)
|
irKey := innerRingInvoker(innerRing)
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
|
@ -78,7 +77,7 @@ func Init(addrNetmap, addrBalance, addrID []byte) {
|
||||||
|
|
||||||
func Put(container, signature, publicKey []byte) bool {
|
func Put(container, signature, publicKey []byte) bool {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
offset := int(container[1])
|
offset := int(container[1])
|
||||||
|
@ -94,7 +93,7 @@ func Put(container, signature, publicKey []byte) bool {
|
||||||
// check provided key
|
// check provided key
|
||||||
if !isSignedByOwnerKey(container, signature, ownerID, publicKey) {
|
if !isSignedByOwnerKey(container, signature, ownerID, publicKey) {
|
||||||
// check keys from NeoFSID
|
// check keys from NeoFSID
|
||||||
keys := engine.AppCall(neofsIDContractAddr, "key", ownerID).([][]byte)
|
keys := contract.Call(neofsIDContractAddr, "key", ownerID).([][]byte)
|
||||||
if !verifySignature(container, signature, keys) {
|
if !verifySignature(container, signature, keys) {
|
||||||
panic("put: invalid owner signature")
|
panic("put: invalid owner signature")
|
||||||
}
|
}
|
||||||
|
@ -107,7 +106,7 @@ func Put(container, signature, publicKey []byte) bool {
|
||||||
|
|
||||||
from := walletToScripHash(ownerID)
|
from := walletToScripHash(ownerID)
|
||||||
balanceContractAddr := storage.Get(ctx, balanceContractKey).([]byte)
|
balanceContractAddr := storage.Get(ctx, balanceContractKey).([]byte)
|
||||||
containerFee := engine.AppCall(netmapContractAddr, "config", containerFeeKey).(int)
|
containerFee := contract.Call(netmapContractAddr, "config", containerFeeKey).(int)
|
||||||
hashCandidate := invokeID([]interface{}{container, signature, publicKey}, []byte("put"))
|
hashCandidate := invokeID([]interface{}{container, signature, publicKey}, []byte("put"))
|
||||||
|
|
||||||
n := vote(ctx, hashCandidate, irKey)
|
n := vote(ctx, hashCandidate, irKey)
|
||||||
|
@ -119,7 +118,7 @@ func Put(container, signature, publicKey []byte) bool {
|
||||||
node := innerRing[i]
|
node := innerRing[i]
|
||||||
to := contract.CreateStandardAccount(node.key)
|
to := contract.CreateStandardAccount(node.key)
|
||||||
|
|
||||||
tx := engine.AppCall(balanceContractAddr, "transferX",
|
tx := contract.Call(balanceContractAddr, "transferX",
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
containerFee,
|
containerFee,
|
||||||
|
@ -133,7 +132,7 @@ func Put(container, signature, publicKey []byte) bool {
|
||||||
|
|
||||||
addContainer(ctx, containerID, ownerID, container)
|
addContainer(ctx, containerID, ownerID, container)
|
||||||
// try to remove underscore at v0.92.0
|
// try to remove underscore at v0.92.0
|
||||||
_ = engine.AppCall(neofsIDContractAddr, "addKey", ownerID, [][]byte{publicKey})
|
_ = contract.Call(neofsIDContractAddr, "addKey", ownerID, [][]byte{publicKey})
|
||||||
|
|
||||||
runtime.Log("put: added new container")
|
runtime.Log("put: added new container")
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,7 +144,7 @@ func Put(container, signature, publicKey []byte) bool {
|
||||||
|
|
||||||
func Delete(containerID, signature []byte) bool {
|
func Delete(containerID, signature []byte) bool {
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
ownerID := getOwnerByID(ctx, containerID)
|
ownerID := getOwnerByID(ctx, containerID)
|
||||||
|
@ -159,7 +158,7 @@ func Delete(containerID, signature []byte) bool {
|
||||||
if len(irKey) == 0 {
|
if len(irKey) == 0 {
|
||||||
// check provided key
|
// check provided key
|
||||||
neofsIDContractAddr := storage.Get(ctx, neofsIDContractKey).([]byte)
|
neofsIDContractAddr := storage.Get(ctx, neofsIDContractKey).([]byte)
|
||||||
keys := engine.AppCall(neofsIDContractAddr, "key", ownerID).([][]byte)
|
keys := contract.Call(neofsIDContractAddr, "key", ownerID).([][]byte)
|
||||||
|
|
||||||
if !verifySignature(containerID, signature, keys) {
|
if !verifySignature(containerID, signature, keys) {
|
||||||
panic("delete: invalid owner signature")
|
panic("delete: invalid owner signature")
|
||||||
|
@ -228,7 +227,7 @@ func SetEACL(eACL, signature []byte) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
neofsIDContractAddr := storage.Get(ctx, neofsIDContractKey).([]byte)
|
neofsIDContractAddr := storage.Get(ctx, neofsIDContractKey).([]byte)
|
||||||
keys := engine.AppCall(neofsIDContractAddr, "key", ownerID).([][]byte)
|
keys := contract.Call(neofsIDContractAddr, "key", ownerID).([][]byte)
|
||||||
|
|
||||||
if !verifySignature(eACL, signature, keys) {
|
if !verifySignature(eACL, signature, keys) {
|
||||||
panic("setEACL: invalid eACL signature")
|
panic("setEACL: invalid eACL signature")
|
||||||
|
|
|
@ -36,7 +36,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
|
@ -184,7 +183,7 @@ func InnerRingCandidateAdd(key []byte) bool {
|
||||||
to := runtime.GetExecutingScriptHash()
|
to := runtime.GetExecutingScriptHash()
|
||||||
fee := getConfig(ctx, candidateFeeConfigKey).(int)
|
fee := getConfig(ctx, candidateFeeConfigKey).(int)
|
||||||
|
|
||||||
transferred := engine.AppCall([]byte(tokenHash), "transfer", from, to, fee).(bool)
|
transferred := contract.Call([]byte(tokenHash), "transfer", from, to, fee).(bool)
|
||||||
if !transferred {
|
if !transferred {
|
||||||
panic("irCandidateAdd: failed to transfer funds, aborting")
|
panic("irCandidateAdd: failed to transfer funds, aborting")
|
||||||
}
|
}
|
||||||
|
@ -212,7 +211,7 @@ func Deposit(from []byte, amount int, rcv []byte) bool {
|
||||||
|
|
||||||
to := runtime.GetExecutingScriptHash()
|
to := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
transferred := engine.AppCall([]byte(tokenHash), "transfer", from, to, amount).(bool)
|
transferred := contract.Call([]byte(tokenHash), "transfer", from, to, amount).(bool)
|
||||||
if !transferred {
|
if !transferred {
|
||||||
panic("deposit: failed to transfer funds, aborting")
|
panic("deposit: failed to transfer funds, aborting")
|
||||||
}
|
}
|
||||||
|
@ -278,7 +277,7 @@ func Cheque(id, user []byte, amount int, lockAcc []byte) bool {
|
||||||
|
|
||||||
from := runtime.GetExecutingScriptHash()
|
from := runtime.GetExecutingScriptHash()
|
||||||
|
|
||||||
transferred := engine.AppCall([]byte(tokenHash), "transfer", from, user, amount).(bool)
|
transferred := contract.Call([]byte(tokenHash), "transfer", from, user, amount).(bool)
|
||||||
if !transferred {
|
if !transferred {
|
||||||
panic("cheque: failed to transfer funds, aborting")
|
panic("cheque: failed to transfer funds, aborting")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package neofsidcontract
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
"github.com/nspcc-dev/neo-go/pkg/interop/binary"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
"github.com/nspcc-dev/neo-go/pkg/interop/blockchain"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/interop/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/engine"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||||
|
@ -74,7 +74,7 @@ func AddKey(owner []byte, keys [][]byte) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
irKey := innerRingInvoker(innerRing)
|
irKey := innerRingInvoker(innerRing)
|
||||||
|
@ -128,7 +128,7 @@ func RemoveKey(owner []byte, keys [][]byte) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte)
|
||||||
innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode)
|
innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode)
|
||||||
threshold := len(innerRing)/3*2 + 1
|
threshold := len(innerRing)/3*2 + 1
|
||||||
|
|
||||||
irKey := innerRingInvoker(innerRing)
|
irKey := innerRingInvoker(innerRing)
|
||||||
|
|
Loading…
Reference in a new issue