From 189a83d9d60effb8dcc4b8bcbd1494d661bf47fa Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 10 Dec 2020 17:45:45 +0300 Subject: [PATCH] [#23] *: Replace engine.AppCall with contract.Call --- alphabet/alphabet.tpl | 13 ++++++------- alphabet/az/az_contract.go | 13 ++++++------- alphabet/buky/buky_contract.go | 13 ++++++------- alphabet/dobro/dobro_contract.go | 13 ++++++------- alphabet/glagoli/glagoli_contract.go | 13 ++++++------- alphabet/jest/jest_contract.go | 13 ++++++------- alphabet/vedi/vedi_contract.go | 13 ++++++------- alphabet/zhivete/zhivete_contract.go | 13 ++++++------- audit/audit_contract.go | 9 ++++----- balance/balance_contract.go | 12 ++++++------ container/container_contract.go | 17 ++++++++--------- neofs/neofs_contract.go | 7 +++---- neofsid/neofsid_contract.go | 6 +++--- 13 files changed, 72 insertions(+), 83 deletions(-) diff --git a/alphabet/alphabet.tpl b/alphabet/alphabet.tpl index 0753850..265093f 100644 --- a/alphabet/alphabet.tpl +++ b/alphabet/alphabet.tpl @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/alphabet/az/az_contract.go b/alphabet/az/az_contract.go index 5fabb17..00a7719 100644 --- a/alphabet/az/az_contract.go +++ b/alphabet/az/az_contract.go @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/alphabet/buky/buky_contract.go b/alphabet/buky/buky_contract.go index 5fb1974..2e7c599 100644 --- a/alphabet/buky/buky_contract.go +++ b/alphabet/buky/buky_contract.go @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/alphabet/dobro/dobro_contract.go b/alphabet/dobro/dobro_contract.go index 91bd198..4d3a020 100644 --- a/alphabet/dobro/dobro_contract.go +++ b/alphabet/dobro/dobro_contract.go @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/alphabet/glagoli/glagoli_contract.go b/alphabet/glagoli/glagoli_contract.go index 0ec7c33..a7e5440 100644 --- a/alphabet/glagoli/glagoli_contract.go +++ b/alphabet/glagoli/glagoli_contract.go @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/alphabet/jest/jest_contract.go b/alphabet/jest/jest_contract.go index 3e9b8fa..f2a6676 100644 --- a/alphabet/jest/jest_contract.go +++ b/alphabet/jest/jest_contract.go @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/alphabet/vedi/vedi_contract.go b/alphabet/vedi/vedi_contract.go index 9ad5311..b17408b 100644 --- a/alphabet/vedi/vedi_contract.go +++ b/alphabet/vedi/vedi_contract.go @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/alphabet/zhivete/zhivete_contract.go b/alphabet/zhivete/zhivete_contract.go index d7d9dd6..d6a18cc 100644 --- a/alphabet/zhivete/zhivete_contract.go +++ b/alphabet/zhivete/zhivete_contract.go @@ -4,7 +4,6 @@ import ( "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/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/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" @@ -79,18 +78,18 @@ func Neo() 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) } func irList() []irNode { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + return contract.Call(netmapContractAddr, "innerRingList").([]irNode) } func currentEpoch() int { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - return engine.AppCall(netmapContractAddr, "epoch").(int) + return contract.Call(netmapContractAddr, "epoch").(int) } func checkPermission(ir []irNode) bool { @@ -126,7 +125,7 @@ func Emit() bool { contractHash := runtime.GetExecutingScriptHash() neo := balance(neoHash, contractHash) - _ = engine.AppCall([]byte(neoHash), "transfer", contractHash, contractHash, neo) + _ = contract.Call([]byte(neoHash), "transfer", contractHash, contractHash, neo) gas := balance(gasHash, contractHash) gasPerNode := gas * 7 / 8 / len(innerRingKeys) @@ -140,7 +139,7 @@ func Emit() bool { node := innerRingKeys[i] 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") @@ -167,7 +166,7 @@ func Vote(epoch int, candidates [][]byte) { candidate := candidates[index%len(candidates)] address := runtime.GetExecutingScriptHash() - ok := engine.AppCall([]byte(neoHash), "vote", address, candidate).(bool) + ok := contract.Call([]byte(neoHash), "vote", address, candidate).(bool) if ok { runtime.Log(name + ": successfully voted for validator") removeVotes(ctx, id) diff --git a/audit/audit_contract.go b/audit/audit_contract.go index c624f22..422420f 100644 --- a/audit/audit_contract.go +++ b/audit/audit_contract.go @@ -3,7 +3,6 @@ package auditcontract import ( "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/engine" "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/util" @@ -88,7 +87,7 @@ func Init(addrNetmap, addrBalance, addrContainer []byte) { func Put(rawAuditResult []byte) bool { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) auditResult, err := newAuditResult(rawAuditResult) if err { @@ -122,7 +121,7 @@ func Put(rawAuditResult []byte) bool { containerContract := storage.Get(ctx, containerContractKey).([]byte) // 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 { 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) irScriptHash := contract.CreateStandardAccount(auditResult.InnerRingNode) - tx := engine.AppCall(balanceContract, "transferX", + tx := contract.Call(balanceContract, "transferX", ownerScriptHash, irScriptHash, auditFee, @@ -149,7 +148,7 @@ func Put(rawAuditResult []byte) bool { node := auditResult.Nodes[i] nodeScriptHash := contract.CreateStandardAccount(node.Key) - tx := engine.AppCall(balanceContract, "transferX", + tx := contract.Call(balanceContract, "transferX", ownerScriptHash, nodeScriptHash, node.Reward, diff --git a/balance/balance_contract.go b/balance/balance_contract.go index 5ba60fe..5f9bd33 100644 --- a/balance/balance_contract.go +++ b/balance/balance_contract.go @@ -3,8 +3,8 @@ package balancecontract import ( "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/contract" "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/runtime" "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) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 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 { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 irKey := innerRingInvoker(innerRing) @@ -206,7 +206,7 @@ func Lock(txID, from, to []byte, amount, until int) bool { func NewEpoch(epochNum int) bool { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 irKey := innerRingInvoker(innerRing) @@ -245,7 +245,7 @@ func NewEpoch(epochNum int) bool { func Mint(to []byte, amount int, details []byte) bool { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 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 { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 irKey := innerRingInvoker(innerRing) diff --git a/container/container_contract.go b/container/container_contract.go index fd87b2d..42cc0d4 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -5,7 +5,6 @@ import ( "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/engine" "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/storage" @@ -78,7 +77,7 @@ func Init(addrNetmap, addrBalance, addrID []byte) { func Put(container, signature, publicKey []byte) bool { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 offset := int(container[1]) @@ -94,7 +93,7 @@ func Put(container, signature, publicKey []byte) bool { // check provided key if !isSignedByOwnerKey(container, signature, ownerID, publicKey) { // check keys from NeoFSID - keys := engine.AppCall(neofsIDContractAddr, "key", ownerID).([][]byte) + keys := contract.Call(neofsIDContractAddr, "key", ownerID).([][]byte) if !verifySignature(container, signature, keys) { panic("put: invalid owner signature") } @@ -107,7 +106,7 @@ func Put(container, signature, publicKey []byte) bool { from := walletToScripHash(ownerID) 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")) n := vote(ctx, hashCandidate, irKey) @@ -119,7 +118,7 @@ func Put(container, signature, publicKey []byte) bool { node := innerRing[i] to := contract.CreateStandardAccount(node.key) - tx := engine.AppCall(balanceContractAddr, "transferX", + tx := contract.Call(balanceContractAddr, "transferX", from, to, containerFee, @@ -133,7 +132,7 @@ func Put(container, signature, publicKey []byte) bool { addContainer(ctx, containerID, ownerID, container) // 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") } else { @@ -145,7 +144,7 @@ func Put(container, signature, publicKey []byte) bool { func Delete(containerID, signature []byte) bool { netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 ownerID := getOwnerByID(ctx, containerID) @@ -159,7 +158,7 @@ func Delete(containerID, signature []byte) bool { if len(irKey) == 0 { // check provided key 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) { panic("delete: invalid owner signature") @@ -228,7 +227,7 @@ func SetEACL(eACL, signature []byte) bool { } 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) { panic("setEACL: invalid eACL signature") diff --git a/neofs/neofs_contract.go b/neofs/neofs_contract.go index e6835a0..7c2dbca 100644 --- a/neofs/neofs_contract.go +++ b/neofs/neofs_contract.go @@ -36,7 +36,6 @@ import ( "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/engine" "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/storage" @@ -184,7 +183,7 @@ func InnerRingCandidateAdd(key []byte) bool { to := runtime.GetExecutingScriptHash() 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 { panic("irCandidateAdd: failed to transfer funds, aborting") } @@ -212,7 +211,7 @@ func Deposit(from []byte, amount int, rcv []byte) bool { 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 { panic("deposit: failed to transfer funds, aborting") } @@ -278,7 +277,7 @@ func Cheque(id, user []byte, amount int, lockAcc []byte) bool { 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 { panic("cheque: failed to transfer funds, aborting") } diff --git a/neofsid/neofsid_contract.go b/neofsid/neofsid_contract.go index 3c7d51f..4708271 100644 --- a/neofsid/neofsid_contract.go +++ b/neofsid/neofsid_contract.go @@ -3,8 +3,8 @@ package neofsidcontract import ( "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/contract" "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/storage" "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) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 irKey := innerRingInvoker(innerRing) @@ -128,7 +128,7 @@ func RemoveKey(owner []byte, keys [][]byte) bool { } netmapContractAddr := storage.Get(ctx, netmapContractKey).([]byte) - innerRing := engine.AppCall(netmapContractAddr, "innerRingList").([]irNode) + innerRing := contract.Call(netmapContractAddr, "innerRingList").([]irNode) threshold := len(innerRing)/3*2 + 1 irKey := innerRingInvoker(innerRing)