mirror of
https://github.com/planetmint/planetmint.git
synced 2025-06-11 16:46:37 +00:00
removed depricated or unused code (#311)
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
3cb9424a35
commit
87506ff4a1
@ -1,56 +0,0 @@
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
# NOTE: only here temporarily
|
||||
from planetmint.backend.models import Asset, MetaData, Input
|
||||
from planetmint.backend.models import Output
|
||||
|
||||
|
||||
@dataclass
|
||||
class Block:
|
||||
id: str = None
|
||||
app_hash: str = None
|
||||
height: int = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class Script:
|
||||
id: str = None
|
||||
script = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class UTXO:
|
||||
id: str = None
|
||||
output_index: int = None
|
||||
utxo: dict = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class Transaction:
|
||||
id: str = None
|
||||
assets: list[Asset] = None
|
||||
metadata: MetaData = None
|
||||
version: str = None # TODO: make enum
|
||||
operation: str = None # TODO: make enum
|
||||
inputs: list[Input] = None
|
||||
outputs: list[Output] = None
|
||||
script: str = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class Validator:
|
||||
id: str = None
|
||||
height: int = None
|
||||
validators = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class ABCIChain:
|
||||
height: str = None
|
||||
is_synced: bool = None
|
||||
chain_id: str = None
|
@ -7,10 +7,9 @@
|
||||
|
||||
from functools import singledispatch
|
||||
|
||||
from planetmint.backend.models import Asset, MetaData, Output, Input, Script
|
||||
from planetmint.backend.models import Asset, Block, MetaData, Output, Input, Script
|
||||
|
||||
from planetmint.backend.exceptions import OperationError
|
||||
from planetmint.backend.interfaces import Block
|
||||
from planetmint.backend.models.dbtransaction import DbTransaction
|
||||
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
from planetmint.backend.tarantool.transaction import tools
|
@ -1,89 +0,0 @@
|
||||
from transactions.common.memoize import HDict
|
||||
|
||||
from planetmint.backend.tarantool.const import (
|
||||
TARANT_TABLE_META_DATA,
|
||||
TARANT_TABLE_ASSETS,
|
||||
TARANT_TABLE_KEYS,
|
||||
TARANT_TABLE_TRANSACTION,
|
||||
TARANT_TABLE_INPUT,
|
||||
TARANT_TABLE_OUTPUT,
|
||||
TARANT_TABLE_SCRIPT,
|
||||
)
|
||||
|
||||
|
||||
def get_items(_list):
|
||||
for item in _list:
|
||||
if type(item) is dict:
|
||||
yield item
|
||||
|
||||
|
||||
def _save_keys_order(dictionary):
|
||||
filter_keys = ["asset", TARANT_TABLE_META_DATA]
|
||||
if type(dictionary) is dict or type(dictionary) is HDict:
|
||||
keys = list(dictionary.keys())
|
||||
_map = {}
|
||||
for key in keys:
|
||||
_map[key] = _save_keys_order(dictionary=dictionary[key]) if key not in filter_keys else None
|
||||
return _map
|
||||
elif type(dictionary) is list:
|
||||
_maps = []
|
||||
for _item in get_items(_list=dictionary):
|
||||
_map = {}
|
||||
keys = list(_item.keys())
|
||||
for key in keys:
|
||||
_map[key] = _save_keys_order(dictionary=_item[key]) if key not in filter_keys else None
|
||||
_maps.append(_map)
|
||||
return _maps
|
||||
return None
|
||||
|
||||
|
||||
class TransactionDecompose:
|
||||
def __init__(self, _transaction):
|
||||
self._transaction = _transaction
|
||||
self._tuple_transaction = {
|
||||
TARANT_TABLE_TRANSACTION: (),
|
||||
TARANT_TABLE_INPUT: [],
|
||||
TARANT_TABLE_OUTPUT: [],
|
||||
TARANT_TABLE_KEYS: [],
|
||||
TARANT_TABLE_SCRIPT: None,
|
||||
TARANT_TABLE_META_DATA: None,
|
||||
TARANT_TABLE_ASSETS: None,
|
||||
}
|
||||
|
||||
def get_map(self, dictionary: dict = None):
|
||||
|
||||
return (
|
||||
_save_keys_order(dictionary=dictionary)
|
||||
if dictionary is not None
|
||||
else _save_keys_order(dictionary=self._transaction)
|
||||
)
|
||||
|
||||
def __prepare_transaction(self):
|
||||
_map = self.get_map()
|
||||
return (self._transaction["id"], self._transaction["operation"], self._transaction["version"], _map)
|
||||
|
||||
def convert_to_tuple(self):
|
||||
self._tuple_transaction[TARANT_TABLE_TRANSACTION] = self.__prepare_transaction()
|
||||
return self._tuple_transaction
|
||||
|
||||
|
||||
class TransactionCompose:
|
||||
def __init__(self, db_results):
|
||||
self.db_results = db_results
|
||||
self._map = self.db_results[TARANT_TABLE_TRANSACTION][3]
|
||||
|
||||
def _get_transaction_operation(self):
|
||||
return self.db_results[TARANT_TABLE_TRANSACTION][1]
|
||||
|
||||
def _get_transaction_version(self):
|
||||
return self.db_results[TARANT_TABLE_TRANSACTION][2]
|
||||
|
||||
def _get_transaction_id(self):
|
||||
return self.db_results[TARANT_TABLE_TRANSACTION][0]
|
||||
|
||||
def convert_to_dict(self):
|
||||
transaction = {k: None for k in list(self._map.keys())}
|
||||
transaction["id"] = self._get_transaction_id()
|
||||
transaction["version"] = self._get_transaction_version()
|
||||
transaction["operation"] = self._get_transaction_operation()
|
||||
return transaction
|
@ -1,13 +0,0 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
def run_cmd(commands: list, config: dict):
|
||||
ret = subprocess.Popen(
|
||||
["%s %s:%s < %s" % ("tarantoolctl connect", "localhost", "3303", "planetmint/backend/tarantool/init.lua")],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
bufsize=0,
|
||||
shell=True,
|
||||
)
|
||||
return True if ret >= 0 else False
|
@ -32,8 +32,6 @@ from planetmint.commands.election_types import elections
|
||||
from planetmint.version import __tm_supported_versions__
|
||||
from planetmint.config import Config
|
||||
|
||||
from planetmint.backend.tarantool.const import TARANT_TABLE_GOVERNANCE
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -44,7 +44,7 @@ from transactions.common.output import Output as TransactionOutput
|
||||
from transactions.types.elections.election import Election
|
||||
from transactions.types.elections.validator_utils import election_id_to_public_key
|
||||
|
||||
from planetmint.backend.models import Output, DbTransaction
|
||||
from planetmint.backend.models import Output, DbTransaction, Asset, MetaData
|
||||
from planetmint.backend.tarantool.const import (
|
||||
TARANT_TABLE_GOVERNANCE,
|
||||
TARANT_TABLE_TRANSACTION,
|
||||
@ -59,9 +59,7 @@ from planetmint.tendermint_utils import (
|
||||
encode_validator,
|
||||
new_validator_set,
|
||||
)
|
||||
from planetmint import exceptions as core_exceptions
|
||||
from planetmint.validation import BaseValidationRules
|
||||
from planetmint.backend.interfaces import Asset, MetaData
|
||||
from planetmint.const import GOVERNANCE_TRANSACTION_TYPES
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -1,23 +0,0 @@
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
||||
class FastTransaction:
|
||||
"""A minimal wrapper around a transaction dictionary. This is useful for
|
||||
when validation is not required but a routine expects something that looks
|
||||
like a transaction, for example during block creation.
|
||||
|
||||
Note: immutability could also be provided
|
||||
"""
|
||||
|
||||
def __init__(self, tx_dict):
|
||||
self.data = tx_dict
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self.data["id"]
|
||||
|
||||
def to_dict(self):
|
||||
return self.data
|
@ -3,15 +3,8 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
import pytest
|
||||
import json
|
||||
from transactions.common.transaction import Transaction
|
||||
from transactions.types.assets.create import Create
|
||||
from transactions.types.assets.transfer import Transfer
|
||||
from planetmint.backend.interfaces import Asset, MetaData
|
||||
from planetmint.backend.models import DbTransaction
|
||||
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
@ -7,7 +7,6 @@ import pytest
|
||||
import codecs
|
||||
|
||||
from planetmint.tendermint_utils import public_key_to_base64
|
||||
from planetmint.backend.tarantool.const import TARANT_TABLE_GOVERNANCE
|
||||
|
||||
from transactions.types.elections.validator_election import ValidatorElection
|
||||
from transactions.common.exceptions import AmountError
|
||||
|
Loading…
x
Reference in New Issue
Block a user