oceanprotocol / ocean.py

🦑 Ocean Protocol's Python library to privately & securely publish, exchange, and consume data.
https://oceanprotocol.com
Apache License 2.0
170 stars 79 forks source link

Consume onchain datasets fail if the view function called has input parameters #1041

Closed jfdelgad closed 1 year ago

jfdelgad commented 1 year ago

Describe the bug Creating function call datasets fail if the function has input parameters. This is because the connectivity_check under pay_for_access_service fails with error AssetNonConsumable with code 2. This error can be traced to the call to the provider that responds with "missing parameters". This error does not happens if the function call is made to a function without parameters. Please note that the error is not at the moment of consuming but when an attempt to pay for access is done

To Reproduce

Steps to reproduce the behavior: Using: GORLI Create two wallets alice_wallet and bob_wallet

 name = "Uniswap v2 function call"
contract_address = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"
contract_abi = {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "amountIn",
                "type": "uint256"
            },
            {
                "internalType": "address[]",
                "name": "path",
                "type": "address[]"
            }
        ],
        "name": "getAmountsOut",
        "outputs": [
            {
                "internalType": "uint256[]",
                "name": "amounts",
                "type": "uint256[]"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }

# #create asset
(data_nft, datatoken, asset) = ocean.assets.create_onchain_asset(name, contract_address, contract_abi, alice_wallet)
print(f"Just published asset, with did={asset.did}")

to_address = bob_wallet.address
amt_tokens = ocean.to_wei(10)  # just need 1, send more for spare
datatoken.mint(to_address, amt_tokens, alice_wallet)

order_tx_id = ocean.assets.pay_for_access_service(
    asset,
    bob_wallet,
    service,
    consume_market_order_fee_address=bob_wallet.address,
    consume_market_order_fee_token=datatoken.address,
    consume_market_order_fee_amount=0,
)

This will produce the following error:

raise AssetNotConsumable(consumable_result)
ocean_lib.agreements.consumable.AssetNotConsumable: 2

Expected behavior Access to the asset should be granted, the call should not fail

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

alexcos20 commented 1 year ago

To summarize: