mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
_save_keys_order, changes behaviour
This commit is contained in:
parent
cead415f01
commit
72157f1607
@ -3,6 +3,12 @@ import copy
|
||||
from planetmint.common.memoize import HDict
|
||||
|
||||
|
||||
def get_items(_list):
|
||||
for item in _list:
|
||||
if type(item) is dict:
|
||||
yield item
|
||||
|
||||
|
||||
def _save_keys_order(dictionary):
|
||||
filter_keys = ["asset", "metadata"]
|
||||
if type(dictionary) is dict or type(dictionary) is HDict:
|
||||
@ -13,14 +19,14 @@ def _save_keys_order(dictionary):
|
||||
|
||||
return _map
|
||||
elif type(dictionary) is list:
|
||||
dictionary = next(iter(dictionary), None)
|
||||
if dictionary is not None and type(dictionary) is dict:
|
||||
_maps = []
|
||||
for _item in get_items(_list=dictionary):
|
||||
_map = {}
|
||||
keys = list(dictionary.keys())
|
||||
keys = list(_item.keys())
|
||||
for key in keys:
|
||||
_map[key] = _save_keys_order(dictionary=dictionary[key]) if key not in filter_keys else None
|
||||
|
||||
return _map
|
||||
_map[key] = _save_keys_order(dictionary=_item[key]) if key not in filter_keys else None
|
||||
_maps.append(_map)
|
||||
return _maps
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -80,7 +86,6 @@ class TransactionDecompose:
|
||||
for _output in self._transaction["outputs"]:
|
||||
# print(f"\noutput: {_output}")
|
||||
output_id = self.__create_hash(7)
|
||||
tmp_output = None
|
||||
if _output["condition"]["details"].get("subconditions") is None:
|
||||
tmp_output = (self._transaction["id"],
|
||||
_output["amount"],
|
||||
@ -104,7 +109,6 @@ class TransactionDecompose:
|
||||
output_index
|
||||
)
|
||||
|
||||
# print(f"\noutput: {tmp_output}")
|
||||
_outputs.append(tmp_output)
|
||||
output_index = output_index + 1
|
||||
key_index = 0
|
||||
|
||||
@ -1308,7 +1308,7 @@ class Transaction(object):
|
||||
for input_ in self.inputs:
|
||||
input_txid = input_.fulfills.txid
|
||||
input_tx = planet.get_transaction(input_txid)
|
||||
|
||||
print(f"\ninput_tx ------ {input_tx.to_dict()} -------")
|
||||
if input_tx is None:
|
||||
for ctxn in current_transactions:
|
||||
if ctxn.id == input_txid:
|
||||
|
||||
@ -35,7 +35,6 @@ from planetmint.tendermint_utils import encode_transaction, merkleroot
|
||||
from planetmint import exceptions as core_exceptions
|
||||
from planetmint.validation import BaseValidationRules
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -246,7 +245,7 @@ class Planetmint(object):
|
||||
|
||||
def get_transaction(self, transaction_id):
|
||||
transaction = backend.query.get_transaction(self.connection, transaction_id)
|
||||
|
||||
print(f"transaction_from_db ::::::: {transaction} :::::::::")
|
||||
# if transaction:
|
||||
# asset = backend.query.get_asset(self.connection, transaction_id)
|
||||
# metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
||||
|
||||
@ -402,14 +402,14 @@ def test_muiltiple_in_mix_own_multiple_out_mix_own_transfer(alice, b, user_pk,
|
||||
tx_create = Transaction.create([alice.public_key], [([user_pk], 50), ([user_pk, alice.public_key], 50)],
|
||||
asset={'name': random.random()})
|
||||
tx_create_signed = tx_create.sign([alice.private_key])
|
||||
|
||||
print(f"\ninit_tx_create ======= {tx_create_signed.to_dict()} ========")
|
||||
# TRANSFER
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(),
|
||||
[([alice.public_key], 50), ([alice.public_key, user_pk], 50)],
|
||||
asset_id=tx_create.id)
|
||||
tx_transfer_signed = tx_transfer.sign([alice.private_key, user_sk])
|
||||
|
||||
b.store_bulk_transactions([tx_create_signed])
|
||||
print(f"\ntx_transfer====== {tx_transfer_signed.to_dict()} ======")
|
||||
|
||||
assert tx_transfer_signed.validate(b) == tx_transfer_signed
|
||||
assert len(tx_transfer_signed.outputs) == 2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user