Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
localhuman committed Oct 3, 2017
2 parents f2ace15 + 6f3170a commit fce2a78
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
3 changes: 3 additions & 0 deletions neo/Core/TX/Transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def GetHashData(self):
def getAllInputs(self):
return self.inputs

def ResetReferences(self):
self.__references = None

@property
def References(self):

Expand Down
35 changes: 16 additions & 19 deletions neo/Prompt/Commands/Invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -56,7 +60,6 @@ def InvokeContract(wallet, tx):
return True
else:
print("Could not relay tx %s " % tx.Hash.ToString())

else:

print("Incomplete signature")
Expand Down Expand Up @@ -131,7 +134,6 @@ def TestInvokeContract(wallet, args):
script_hash=contract.Code.ScriptHash())

outputs.append(output)


return test_invoke(out, wallet, outputs)

Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion neo/Prompt/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=', '')))
Expand Down
2 changes: 0 additions & 2 deletions neo/SmartContract/ContractParameterContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def Completed(self):

def Add(self, contract, index, parameter):


i = self.GetIndex(contract.ScriptHash)

if i < 0:
Expand All @@ -60,7 +59,6 @@ def AddSignature(self, contract, pubkey, signature):

else:


index = -1
for i, contractParam in enumerate(contract.ParameterList):
if contractParam == ContractParameterType.Signature:
Expand Down
7 changes: 3 additions & 4 deletions neo/Wallets/Wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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

Expand Down

0 comments on commit fce2a78

Please sign in to comment.