Skip to content

Commit

Permalink
get minter from contract (#153)
Browse files Browse the repository at this point in the history
* get actual minter from contract
  • Loading branch information
alexcos20 authored Jun 9, 2021
1 parent 9b4ed7f commit 26f67c3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.10
current_version = 0.4.11
commit = True
tag = True

Expand Down
4 changes: 1 addition & 3 deletions ocean_provider/routes/consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,13 @@ def initialize():
)
return jsonify(error="Asset URL not found or not available."), 400

minter = get_datatoken_minter(asset, token_address)

# Prepare the `transfer` tokens transaction with the appropriate number
# of tokens required for this service
# The consumer must sign and execute this transaction in order to be
# able to consume the service
approve_params = {
"from": consumer_address,
"to": minter,
"to": get_datatoken_minter(token_address),
"numTokens": service.get_cost(),
"dataToken": token_address,
"nonce": get_nonce(consumer_address),
Expand Down
11 changes: 2 additions & 9 deletions ocean_provider/utils/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@ def get_provider_wallet():
return Wallet(Web3Provider.get_web3(), private_key=pk)


def get_datatoken_minter(asset, datatoken_address):
publisher = Web3Provider.get_web3().toChecksumAddress(asset.publisher)
def get_datatoken_minter(datatoken_address):
dt = DataToken(datatoken_address)

assertion_message = (
f"ddo publisher {publisher} is not the current "
f"minter for the DataToken contract at {datatoken_address}."
)
assert dt.contract_concise.isMinter(publisher), assertion_message

publisher = dt.minter()
return publisher


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
url="https://github.com/oceanprotocol/provider-py",
# fmt: off
# bumpversion needs single quotes
version='0.4.10',
version='0.4.11',
# fmt: on
zip_safe=False,
)
2 changes: 1 addition & 1 deletion tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def send_order(client, ddo, datatoken, service, cons_wallet, expect_failure=Fals
nonce = tx_params.get("nonce")
receiver = tx_params["to"]
assert tx_params["from"] == cons_wallet.address
assert receiver == get_datatoken_minter(ddo, datatoken.address)
assert receiver == get_datatoken_minter(datatoken.address)
assert tx_params["dataToken"] == ddo.as_dictionary()["dataToken"]
assert nonce is not None, f"expecting a `nonce` value in the response, got {nonce}"
# Transfer tokens to provider account
Expand Down

0 comments on commit 26f67c3

Please sign in to comment.