mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 15:05:49 +00:00
minor changes to get_transaction
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
86c4a9e55e
commit
f7a57a5915
@ -89,7 +89,7 @@ def get_transactions(connection, transaction_ids):
|
|||||||
|
|
||||||
@singledispatch
|
@singledispatch
|
||||||
def get_asset(connection, asset_id):
|
def get_asset(connection, asset_id):
|
||||||
"""Get a transaction from the transactions table.
|
"""Get an asset from the assets table.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
asset_id (str): the id of the asset
|
asset_id (str): the id of the asset
|
||||||
@ -100,6 +100,18 @@ def get_asset(connection, asset_id):
|
|||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@singledispatch
|
||||||
|
def get_assets(connection, asset_ids):
|
||||||
|
"""Get assets from the assets table.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
asset_ids (list): list of asset ids to fetch
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The result of the operation.
|
||||||
|
"""
|
||||||
|
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
@singledispatch
|
@singledispatch
|
||||||
def get_spent(connection, transaction_id, condition_id):
|
def get_spent(connection, transaction_id, condition_id):
|
||||||
|
|||||||
@ -244,10 +244,13 @@ class Planetmint(object):
|
|||||||
# NOTE: Read up on localmongodb setup and how the connection calls are actually loaded => implementation shows NotImplementError
|
# NOTE: Read up on localmongodb setup and how the connection calls are actually loaded => implementation shows NotImplementError
|
||||||
|
|
||||||
if transaction:
|
if transaction:
|
||||||
asset = backend.query.get_asset(self.connection, transaction_id)
|
# asset = backend.query.get_asset(self.connection, transaction_id)
|
||||||
|
assets = backend.query.get_assets(self.connection, [transaction_id])
|
||||||
metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
||||||
if asset:
|
if assets:
|
||||||
transaction['assets'] = asset
|
# NOTE: THIS IS A HACK TO SEE IF THE TX HASH IS CORRECT FOR TESTS, NEEDS TO BE REPLACED AFTER backend.query.get_assets_for_tx is finished
|
||||||
|
# transaction['assets'] = [asset]
|
||||||
|
transaction['assets'] = assets
|
||||||
|
|
||||||
if 'metadata' not in transaction:
|
if 'metadata' not in transaction:
|
||||||
metadata = metadata[0] if metadata else None
|
metadata = metadata[0] if metadata else None
|
||||||
|
|||||||
@ -48,7 +48,6 @@ def test_get_asset_id_transfer_transaction(b, signed_create_tx, user_pk):
|
|||||||
assert asset_ids[0] == tx_transfer.assets[0]['id']
|
assert asset_ids[0] == tx_transfer.assets[0]['id']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_valid_divisible_asset(b, user_pk, user_sk):
|
def test_create_valid_divisible_asset(b, user_pk, user_sk):
|
||||||
|
|
||||||
tx = Create.generate([user_pk], [([user_pk], 2)])
|
tx = Create.generate([user_pk], [([user_pk], 2)])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user