Demonstrate calling contracts with tuple arrays (#1615)
This commit is contained in:
parent
ceb651fdd1
commit
6bcc2064a2
@ -63,3 +63,55 @@ def test_get_order_info():
|
|||||||
|
|
||||||
assert isinstance(order_info.order_taker_asset_filled_amount, int)
|
assert isinstance(order_info.order_taker_asset_filled_amount, int)
|
||||||
assert order_info.order_taker_asset_filled_amount == 0
|
assert order_info.order_taker_asset_filled_amount == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_orders_info():
|
||||||
|
"""Demonstrate Exchange.getOrderInfo()."""
|
||||||
|
order: Order = {
|
||||||
|
"makerAddress": "0x0000000000000000000000000000000000000000",
|
||||||
|
"takerAddress": "0x0000000000000000000000000000000000000000",
|
||||||
|
"feeRecipientAddress": "0x0000000000000000000000000000000000000000",
|
||||||
|
"senderAddress": "0x0000000000000000000000000000000000000000",
|
||||||
|
"makerAssetAmount": 1000000000000000000,
|
||||||
|
"takerAssetAmount": 1000000000000000000,
|
||||||
|
"makerFee": 0,
|
||||||
|
"takerFee": 0,
|
||||||
|
"expirationTimeSeconds": 12345,
|
||||||
|
"salt": 12345,
|
||||||
|
"makerAssetData": (b"\x00") * 20,
|
||||||
|
"takerAssetData": (b"\x00") * 20,
|
||||||
|
}
|
||||||
|
|
||||||
|
web3_instance = Web3(Web3.HTTPProvider("http://127.0.0.1:8545"))
|
||||||
|
|
||||||
|
# false positive from pylint: disable=no-member
|
||||||
|
contract_address = NETWORK_TO_ADDRESSES[
|
||||||
|
NetworkId(int(web3_instance.net.version))
|
||||||
|
].exchange
|
||||||
|
|
||||||
|
assert_valid(
|
||||||
|
order_to_jsdict(order, exchange_address=contract_address),
|
||||||
|
"/orderSchema",
|
||||||
|
)
|
||||||
|
|
||||||
|
# false positive from pylint: disable=no-member
|
||||||
|
exchange: datatypes.Contract = web3_instance.eth.contract(
|
||||||
|
address=to_checksum_address(contract_address),
|
||||||
|
abi=zero_ex.contract_artifacts.abi_by_name("Exchange"),
|
||||||
|
)
|
||||||
|
|
||||||
|
orders_info = exchange.call().getOrdersInfo([order])
|
||||||
|
|
||||||
|
for order_info in orders_info:
|
||||||
|
order_info = OrderInfo(*order_info)
|
||||||
|
assert isinstance(order_info.order_status, int)
|
||||||
|
assert order_info.order_status == 4
|
||||||
|
|
||||||
|
assert isinstance(order_info.order_hash, bytes)
|
||||||
|
assert order_info.order_hash.hex() == generate_order_hash_hex(
|
||||||
|
order,
|
||||||
|
exchange_address=NETWORK_TO_ADDRESSES[NetworkId.GANACHE].exchange,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert isinstance(order_info.order_taker_asset_filled_amount, int)
|
||||||
|
assert order_info.order_taker_asset_filled_amount == 0
|
||||||
|
@ -168,12 +168,12 @@ setup(
|
|||||||
"0x-contract-addresses",
|
"0x-contract-addresses",
|
||||||
"0x-contract-artifacts",
|
"0x-contract-artifacts",
|
||||||
"0x-json-schemas",
|
"0x-json-schemas",
|
||||||
|
"0x-web3",
|
||||||
"eth-abi",
|
"eth-abi",
|
||||||
"eth_utils",
|
"eth_utils",
|
||||||
"hypothesis>=3.31.2", # HACK! this is web3's dependency!
|
"hypothesis>=3.31.2", # HACK! this is web3's dependency!
|
||||||
# above works around https://github.com/ethereum/web3.py/issues/1179
|
# above works around https://github.com/ethereum/web3.py/issues/1179
|
||||||
"mypy_extensions",
|
"mypy_extensions",
|
||||||
"web3",
|
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
"dev": [
|
"dev": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user