Skip to content

Commit

Permalink
added payments to invoke script transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenmarc committed May 9, 2019
1 parent df8833e commit 19d40ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ __pywaves.Address(address, publicKey, privateKey, seed)__ _Creates a new Address

`setAssetScript(asset, scriptSource, txFee=pywaves.DEFAULT_ASSET_SCRIPT_FEE, timestamp=0)` set a new script for a smart asset

`invokeScript(dappAddress, functionName, params, feeAsset = None, txFee=pywaves.DEFAULT_INVOKE_SCRIPT_FEE)` invoke a script on a given dapp address
`invokeScript(dappAddress, functionName, params, payments, feeAsset = None, txFee=pywaves.DEFAULT_INVOKE_SCRIPT_FEE)` invoke a script on a given dapp address

### Asset Class
__pywaves.Asset(assetId)__ _Creates a new Asset object_
Expand Down Expand Up @@ -386,7 +386,7 @@ import pywaves as pw
pw.setNode(node='<node>', chain='testnet')

address = pw.Address(privateKey = '<private key>')
tx = address.invokeScript('3N5Wq22bLSf3gt5VwHTCRbRnETeSwpuT8kK', 'fundRecipient', [{"type": "integer", "value": 100, }, { "type": "string", "value": "test" }, { "type": "boolean", "value": True }])
tx = address.invokeScript('3N5Wq22bLSf3gt5VwHTCRbRnETeSwpuT8kK', 'fundRecipient', [{"type": "integer", "value": 100, }, { "type": "string", "value": "test" }, { "type": "boolean", "value": True }], [ { "amount": 100, "assetId": "BGNVLgPKLwiBiZ7vWLcy3r92MzpPCU2DuUb4tv9W6gMi" } ])
```

#### Playing with Waves Matcher node (DEX):
Expand Down
11 changes: 4 additions & 7 deletions address.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,10 +1079,7 @@ def issueSmartAsset(self, name, description, quantity, scriptSource, decimals=0,
else:
return req

# def invokeScript(self, dappAddress, functionName, params, payments, feeAsset = None, txFee=pywaves.DEFAULT_INVOKE_SCRIPT_FEE):
def invokeScript(self, dappAddress, functionName, params, feeAsset=None, txFee=pywaves.DEFAULT_INVOKE_SCRIPT_FEE):
# nasty workaround until the bug in the node is fixed
payments = []
def invokeScript(self, dappAddress, functionName, params, payments, feeAsset = None, txFee=pywaves.DEFAULT_INVOKE_SCRIPT_FEE):
if not self.privateKey:
msg = 'Private key required'
logging.error(msg)
Expand Down Expand Up @@ -1121,6 +1118,7 @@ def invokeScript(self, dappAddress, functionName, params, feeAsset=None, txFee=p
crypto.str2bytes(str(pywaves.CHAIN_ID)) + \
base58.b58decode(self.publicKey) + \
base58.b58decode(dappAddress) + \
b'\x01' + \
b'\x09' + \
b'\x01' + \
struct.pack(">L", len(crypto.str2bytes(functionName))) +\
Expand All @@ -1134,16 +1132,15 @@ def invokeScript(self, dappAddress, functionName, params, feeAsset=None, txFee=p
struct.pack(">Q", timestamp)

signature = crypto.sign(self.privateKey, sData)

data = json.dumps({
"type": 16,
"senderPublicKey": self.publicKey,
"version": 1,
"timestamp": timestamp,
"fee": txFee,
"proofs": [ signature ],
"proofs": [signature],
"feeAssetId": feeAsset,
"dappAddress": dappAddress,
"dApp": dappAddress,
"call": {
"function": functionName,
"args": params
Expand Down

0 comments on commit 19d40ef

Please sign in to comment.