in resdb_driver/offchain.py [0:0]
def prepare_create_transaction(*, signers, recipients=None, asset=None, metadata=None):
"""! Prepares a ``"CREATE"`` transaction payload, ready to be
fulfilled.
@param signers (:obj:`list` | :obj:`tuple` | :obj:`str`):
One or more public keys representing
the issuer(s) of the asset being created.
@param recipients (:obj:`list` | :obj:`tuple` | :obj:`str`, optional):
One or more public keys representing
the new recipients(s) of the asset being created. Defaults to ``None``.
@param asset (:obj:`dict`, optional): The asset to be created. Defaults to ``None``.
@param metadata (:obj:`dict`, optional): Metadata associated with the transaction. Defaults to ``None``.
@return The prepared ``"CREATE"`` transaction.
.. important::
* If ``asset`` is set, it MUST be in the form of::
{
'data': {
...
}
}
* If ``recipients`` is not given, or evaluates to
``False``, it will be set equal to ``signers``::
if not recipients:
recipients = signers
"""
if not isinstance(signers, (list, tuple)):
signers = [signers]
# NOTE: Needed for the time being. See
# https://github.com/bigchaindb/bigchaindb/issues/797
elif isinstance(signers, tuple):
signers = list(signers)
if not recipients:
recipients = [(signers, 1)]
elif not isinstance(recipients, (list, tuple)):
recipients = [([recipients], 1)]
# NOTE: Needed for the time being. See
# https://github.com/bigchaindb/bigchaindb/issues/797
elif isinstance(recipients, tuple):
recipients = [(list(recipients), 1)]
transaction = Transaction.create(
signers,
recipients,
metadata=metadata,
asset=asset["data"] if asset else None,
)
return transaction.to_dict()