Merge branch 'asset-migration' of github.com:planetmint/planetmint into asset-migration

This commit is contained in:
ArpitShukla007 2022-04-12 08:36:02 +00:00
commit 752ebbb0e7
3 changed files with 19 additions and 5 deletions

View File

@ -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):

View File

@ -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

View File

@ -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)])