diff --git a/neo/Core/TX/Transaction.py b/neo/Core/TX/Transaction.py index ef11e4519..d8fc43b99 100644 --- a/neo/Core/TX/Transaction.py +++ b/neo/Core/TX/Transaction.py @@ -184,6 +184,9 @@ def GetHashData(self): def getAllInputs(self): return self.inputs + def ResetReferences(self): + self.__references = None + @property def References(self): diff --git a/neo/Prompt/Commands/Invoke.py b/neo/Prompt/Commands/Invoke.py index 63d5c251d..6d04c1411 100644 --- a/neo/Prompt/Commands/Invoke.py +++ b/neo/Prompt/Commands/Invoke.py @@ -33,19 +33,23 @@ from neo.BigInteger import BigInteger import traceback import pdb +import pdb +import json def InvokeContract(wallet, tx): + wallet_tx = wallet.MakeTransaction(tx=tx) if wallet_tx: context = ContractParametersContext(wallet_tx) + wallet.Sign(context) if context.Completed: - tx.scripts = context.GetScripts() + wallet_tx.scripts = context.GetScripts() wallet.SaveTransaction(wallet_tx) @@ -56,7 +60,6 @@ def InvokeContract(wallet, tx): return True else: print("Could not relay tx %s " % tx.Hash.ToString()) - else: print("Incomplete signature") @@ -131,7 +134,6 @@ def TestInvokeContract(wallet, args): script_hash=contract.Code.ScriptHash()) outputs.append(output) - return test_invoke(out, wallet, outputs) @@ -169,33 +171,27 @@ def test_invoke(script, wallet, outputs): service = StateMachine(accounts, validators, assets, contracts, storages, None) # contract = wallet.GetDefaultContract() - # tx.Attributes = [TransactionAttribute(usage=TransactionAttributeUsage.Script, data=Crypto.ToScriptHash( contract.Script))] - wallet_tx = wallet.MakeTransaction(tx=tx) if wallet_tx: context = ContractParametersContext(wallet_tx) wallet.Sign(context) - if context.Completed: - tx.scripts = context.GetScripts() - - - + wallet_tx.scripts = context.GetScripts() engine = ApplicationEngine( trigger_type=TriggerType.Application, container=wallet_tx, table=script_table, service=service, - gas=tx.Gas, + gas=wallet_tx.Gas, testMode=True ) - engine.LoadScript(tx.Script, False) + engine.LoadScript(wallet_tx.Script, False) try: @@ -213,17 +209,18 @@ def test_invoke(script, wallet, outputs): consumed = Fixed8.One() #set the amount of gas the tx will need - tx.Gas = consumed + wallet_tx.Gas = consumed - #remove the attributes that are used to add a verification script to the tx - tx.Attributes = [] + #reset the wallet outputs + wallet_tx.outputs = outputs - return tx, engine.EvaluationStack.Items + return wallet_tx, engine.EvaluationStack.Items else: print("error executing contract.....") - tx.Gas = Fixed8.One() - tx.Attributes = [] - return tx, [] +# tx.Gas = Fixed8.One() +# tx.Attributes = [] +# return tx, [] + return None,[] except Exception as e: print("COULD NOT EXECUTE %s " % e) diff --git a/neo/Prompt/Utils.py b/neo/Prompt/Utils.py index 09babe277..dd6196871 100644 --- a/neo/Prompt/Utils.py +++ b/neo/Prompt/Utils.py @@ -15,7 +15,7 @@ def get_asset_attachments(params): neo_to_attach = Fixed8.TryParse(int(item.replace('--attach-neo=', ''))) except Exception as e: pass - elif '--attach-gas=' in item: + if '--attach-gas=' in item: to_remove.append(item) try: gas_to_attach = Fixed8.FromDecimal(float(item.replace('--attach-gas=', ''))) diff --git a/neo/SmartContract/ContractParameterContext.py b/neo/SmartContract/ContractParameterContext.py index 68a936ec3..00583b6cd 100644 --- a/neo/SmartContract/ContractParameterContext.py +++ b/neo/SmartContract/ContractParameterContext.py @@ -35,7 +35,6 @@ def Completed(self): def Add(self, contract, index, parameter): - i = self.GetIndex(contract.ScriptHash) if i < 0: @@ -60,7 +59,6 @@ def AddSignature(self, contract, pubkey, signature): else: - index = -1 for i, contractParam in enumerate(contract.ParameterList): if contractParam == ContractParameterType.Signature: diff --git a/neo/Wallets/Wallet.py b/neo/Wallets/Wallet.py index 3c240b6b4..42b2842be 100755 --- a/neo/Wallets/Wallet.py +++ b/neo/Wallets/Wallet.py @@ -499,12 +499,12 @@ def GetContracts(self): def MakeTransaction(self, tx, change_address = None, fee = Fixed8(0)): + + tx.ResetReferences() + if not tx.outputs: tx.outputs = [] if not tx.inputs: tx.inputs = [] -# for o in tx.outputs: -# print("OUTPUT %s " % json.dumps(o.ToJson(), indent=4)) - fee = fee + tx.SystemFee() paytotal = {} @@ -522,7 +522,6 @@ def MakeTransaction(self, tx, change_address = None, fee = Fixed8(0)): if Blockchain.SystemCoin().Hash in paytotal.keys(): paytotal[Blockchain.SystemCoin().Hash] = paytotal[Blockchain.SystemCoin().Hash] + fee - else: paytotal[Blockchain.SystemCoin().Hash] = fee