From 19db32b6549face968969f7047a16abf32a13141 Mon Sep 17 00:00:00 2001 From: alexvanin Date: Fri, 29 May 2020 11:44:15 +0300 Subject: [PATCH] Add tx hash for "Deposit" and "Withdraw" notifications As the user can invoke several deposit or withdraw calls inner ring nodes should be able to differ them even if they have the same arguments. To do that neofs-contract notifies about tx hash, which can be used as unique identifier of withdraw or deposit operation. --- neofs_contract.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/neofs_contract.go b/neofs_contract.go index d033a36..6d70638 100644 --- a/neofs_contract.go +++ b/neofs_contract.go @@ -5,6 +5,7 @@ import ( "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/transaction" "github.com/nspcc-dev/neo-go/pkg/interop/util" ) @@ -152,7 +153,10 @@ func Main(op string, args []interface{}) interface{} { rcv = args[2].([]byte) // todo: check if rcv value is valid } - runtime.Notify("Deposit", pk, amount, rcv) + tx := engine.GetScriptContainer() + txHash := transaction.GetHash(tx) + + runtime.Notify("Deposit", pk, amount, rcv, txHash) return true case "Withdraw": @@ -171,7 +175,10 @@ func Main(op string, args []interface{}) interface{} { amount = amount * 100000000 } - runtime.Notify("Withdraw", user, amount) + tx := engine.GetScriptContainer() + txHash := transaction.GetHash(tx) + + runtime.Notify("Withdraw", user, amount, txHash) return true case "Cheque":