remove flask and graphql servers

This commit is contained in:
William Luke 2021-11-23 15:17:13 +03:00
parent 421e1cbf32
commit ea7fa28b61
21 changed files with 15 additions and 1824 deletions

View File

@ -1,31 +0,0 @@
import os
import cic_eth.cli
from cic_eth.graphql.config import config
from flask import Flask
from flask_graphql import GraphQLView
from cic_eth.graphql.schema import schema
app = cic_eth.cli.CeleryApp.from_config(config)
app.set_default()
print(app)
def create_app():
flask_app = Flask(__name__)
flask_app.add_url_rule(
'/graphql',
view_func=GraphQLView.as_view(
'graphql',
schema=schema,
graphiql=True
)
)
@flask_app.route("/")
def test():
return "Test ok!"
return flask_app
if __name__ == "__main__":
flask_app = create_app()
flask_app.run(host='0.0.0.0', port=5000, debug=True)

View File

@ -1,10 +0,0 @@
import cic_eth.cli
arg_flags = cic_eth.cli.argflag_std_base
local_arg_flags = cic_eth.cli.argflag_local_taskcallback
argparser = cic_eth.cli.ArgumentParser(arg_flags)
argparser.process_local_flags(local_arg_flags)
args = argparser.parse_args()
config = cic_eth.cli.Config.from_args(args, arg_flags, local_arg_flags)

View File

@ -1,88 +0,0 @@
from cic_eth.graphql.schema import schema
query_with_argument = """
{
defaultToken{
symbol
}
}
"""
# result = schema.execute(query_with_argument)
# print(result)
mutation_with_argument = """
mutation {
createAccount(password:"test"){
address
}
}
"""
m_result = schema.execute(mutation_with_argument)
print(m_result)
mutation_with_argument = """
mutation {
createAccount(password:"test"){
address
}
}
"""
m_result = schema.execute(mutation_with_argument)
print(m_result)
balance_query = """
query {
balance(address:"0x643c99d5ab51b5e06d55a68e6b24fd36e9d6b1c9", tokenSymbols:["GFT", "COFE"]){
balanceNetwork
balanceIncoming
balanceOutgoing
balanceAvailable
}
}
"""
balance_query_result = schema.execute(balance_query)
print(balance_query_result)
transfer_mutation = """
mutation {
transfer(fromAddress :"0xcf41bd087b71c72d748fe2b8b4c88b2367c37df3",
toAddress: "0x63474da1a315f9abe0999b6adb61ae8a9ea19a76"
value: 20
tokenSymbol: "COFE" ){
test
}
}
"""
# transfer_mutation_result = schema.execute(transfer_mutation)
# print(transfer_mutation_result)
balance_query = """
query {
balance(address:"0x63474da1a315f9abe0999b6adb61ae8a9ea19a76", tokenSymbols:["GFT"]){
balanceNetwork
balanceIncoming
balanceOutgoing
balanceAvailable
}
}
"""
# balance_query_result = schema.execute(balance_query)
# print(balance_query_result)
transactions_query = """
query {
transactions(address:"0xcf41bd087b71c72d748fe2b8b4c88b2367c37df3")
}
"""
# transactions_query_result = schema.execute(transactions_query)
# print(transactions_query_result)

View File

@ -1,299 +0,0 @@
# standard imports
import json
import logging
import sys
import uuid
import redis
from cic_eth.api.api_task import Api
from cic_eth.graphql.config import config
from graphene import (Boolean, Field, Float, Int, List, Mutation, ObjectType,
Schema, String)
chain_spec = config.get('CHAIN_SPEC')
redis_host = config.get('REDIS_HOST')
redis_port = config.get('REDIS_PORT')
redis_db = config.get('REDIS_DB')
celery_queue = config.get('CELERY_QUEUE')
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
def call(method, *args):
redis_channel = str(uuid.uuid4())
r = redis.Redis(redis_host, redis_port, redis_db)
ps = r.pubsub()
ps.subscribe(redis_channel)
ps.get_message() # Subscription Object
print(f"Channel init {redis_channel}")
print(args)
api = Api(
chain_spec,
queue=celery_queue,
callback_param='{}:{}:{}:{}'.format(
redis_host, redis_port, redis_db, redis_channel),
callback_task='cic_eth.callbacks.redis.redis',
callback_queue=celery_queue,
)
getattr(api, method)(*args)
ps.get_message() # returns None !?
try:
o = ps.get_message(timeout=config.get('REDIS_TIMEOUT'))
except TimeoutError as e:
sys.stderr.write(
'got no new address from cic-eth before timeout: {}\n'.format(e))
sys.exit(1)
ps.unsubscribe()
print(o)
m = json.loads(o['data'])
return m["result"]
class Token(ObjectType):
symbol = String()
address = String()
name = String()
decimals = Int()
class TokenBalance(ObjectType):
address = String()
converters = List(String)
balance_network = String(default_value="0")
balance_incoming = String(default_value="0")
balance_outgoing = String(default_value="0")
balance_available = String(default_value="0")
def resolve_balance_available(parent, info):
print(parent)
return str(int(parent.balance_network) + int(parent.balance_incoming) - int(parent.balance_outgoing))
class Query(ObjectType):
default_token = Field(Token)
def resolve_default_token(parent, info):
# always pass an object for `me` field
api = Api(
chain_spec,
queue=celery_queue,
)
task = api.default_token()
data = task.get()
print(data)
return Token(**data)
balance = Field(List(TokenBalance), address=String(),
token_symbol=String(), include_pending=Boolean())
def resolve_balance(root, info, address, token_symbol, include_pending=True):
api = Api(
chain_spec,
queue=celery_queue,
)
task = api.balance(address=address, token_symbol=token_symbol, include_pending=include_pending)
data = task.get() #api call('balance', address, token_symbol, include_pending)
log.debug(data)
print(data, file=sys.stdout)
#[{'address': '3ff776b6f888980def9d4220858803f9dc5e341e', 'converters': [], 'balance_network': 0}]
return map(lambda token: TokenBalance(
address=token.get("address"),
converters=token.get("converters"),
balance_network=str(token.get("balance_network") or "0"),
balance_incoming=str(token.get("balance_incoming") or "0"),
balance_outgoing=str(token.get("balance_outgoing") or "0"),
balance_available=str(token.get("balance_available" or "0"))
), data)
transactions = Field(String, address=String(
required=True), limit=Int(default_value=10))
def resolve_transactions(root, info, address, limit):
api = Api(
chain_spec,
queue=celery_queue,
)
task = api.list(address=address, limit=limit)
data = task.get()
print(data)
#[{'address': '3ff776b6f888980def9d4220858803f9dc5e341e', 'converters': [], 'balance_network': 0}]
return "test"
class CreateAccount(Mutation):
address = String()
class Arguments:
password = String(required=True)
register = Boolean()
def mutate(root, info, password, register=True):
print(password, register)
api = Api(
chain_spec,
queue=celery_queue,
)
address = call('create_account',password, register)
return CreateAccount(address=f"0x{address}")
class Transfer(Mutation):
test = String(default_value="test")
class Arguments:
from_address = String(required=True)
to_address = String(required=True)
value = Int(required=True)
token_symbol = String(required=True)
def mutate(root, info, from_address,
to_address,
value,
token_symbol):
print(from_address, to_address, value, token_symbol)
api = Api(
chain_spec,
queue=celery_queue,
)
t = api.transfer(from_address, to_address,
int(value * (10**6)), token_symbol)
print(f"t {t}")
print(f"transfer {t.get_leaf()}")
print(f"transfer {t.successful()}")
return t.get()
# 0x0000000000000000000000000000000000000000
class TransferFrom(Mutation):
address = String()
class Arguments:
from_address = String(required=True)
to_address = String(required=True)
value = Int(required=True)
token_symbol = String(required=True)
spender_address = String(required=True)
def mutate(root, info, from_address,
to_address,
value,
token_symbol, spender_address):
api = Api(
chain_spec,
queue=celery_queue,
)
task = api.transfer_from(from_address=from_address,
to_address=to_address,
value=value,
token_symbol=token_symbol, spender_address=spender_address)
return task.get()
class MyMutations(ObjectType):
create_account = CreateAccount.Field()
transfer = Transfer.Field()
schema = Schema(query=Query, mutation=MyMutations)
query_with_argument = """
{
defaultToken{
symbol
}
}
"""
# result = schema.execute(query_with_argument)
# print(result)
mutation_with_argument = """
mutation {
createAccount(password:"test"){
address
}
}
"""
m_result = schema.execute(mutation_with_argument)
print(m_result.data)
address_1 = "0xde82da08c816865c24a2c9c76a2bcd44b5b94531" #m_result.data['createAccount']['address']
mutation_with_argument = """
mutation {
createAccount(password:"test"){
address
}
}
"""
m_result = schema.execute(mutation_with_argument)
print(m_result)
address_2 = "0xaee24c8af3249b2d0a26769286623fff00556788" #m_result.data['createAccount']['address']
balance_query = """
query getBalance($address:String){
balance(address: $address, tokenSymbols:["COFE"]){
balanceNetwork
balanceIncoming
balanceOutgoing
balanceAvailable
}
}
"""
balance_query_result = schema.execute(
balance_query, variables={"address": "address_1"})
# print(balance_query_result)
transfer_mutation = """
mutation transfer($from: String, $to: String) {
transfer(fromAddress : $from,
toAddress: $to
value: 20
tokenSymbol: "COFE" ){
test
}
}
"""
transfer_mutation_result = schema.execute(transfer_mutation, variables={
"from": address_1, "to": address_2})
print(transfer_mutation_result)
balance_query = """
query {
balance(address:"0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C", tokenSymbols:["GFT"]){
balanceNetwork
balanceIncoming
balanceOutgoing
balanceAvailable
}
}
"""
# balance_query_result = schema.execute(balance_query)
# print(balance_query_result)
transactions_query = """
query {
transactions(address:"0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C")
}
"""
# transactions_query_result = schema.execute(transactions_query)
# print(transactions_query_result)

View File

@ -45,7 +45,6 @@ def application(env, start_response):
if path == '/transactions': if path == '/transactions':
address = params.pop('address') address = params.pop('address')
print('address', address, )
# address, limit=10 # address, limit=10
data = call('list', address, **params) data = call('list', address, **params)
@ -95,7 +94,7 @@ def application(env, start_response):
elif path == '/default_token': elif path == '/default_token':
data = call('default_token') data = call('default_token')
else: else:
start_response('404 Seems like you are lost', []) start_response('404 This is not the path you\'re looking for', [])
return [] return []
json_data = json.dumps(data) json_data = json.dumps(data)
content = json_data.encode('utf-8') content = json_data.encode('utf-8')

View File

@ -1,24 +0,0 @@
#!/usr/bin/env python3
import cic_eth.cli
import connexion
from cic_eth.graphql.config import config
from cic_eth.server import encoder
celery_app = cic_eth.cli.CeleryApp.from_config(config)
celery_app.set_default()
def create_app(test_config=None):
app = connexion.App(__name__, specification_dir='./openapi/')
if test_config:
app.app.config.update(test_config)
app.app.json_encoder = encoder.JSONEncoder
app.add_api('server.yaml', arguments={
'title': 'Grassroots Economics'}, pythonic_params=True)
return app
if __name__ == '__main__':
app = create_app()
app.run(port=5000)

View File

@ -38,17 +38,18 @@ def call(method, *args, **kwargs):
callback_task='cic_eth.callbacks.redis.redis', callback_task='cic_eth.callbacks.redis.redis',
callback_queue=celery_queue, callback_queue=celery_queue,
) )
getattr(api, method)(*args) getattr(api, method)(*args, **kwargs)
ps.get_message() ps.get_message()
try: try:
o = ps.get_message(timeout=config.get('REDIS_TIMEOUT')) o = ps.get_message(timeout=config.get('REDIS_TIMEOUT'))
except TimeoutError as e: except TimeoutError as e:
sys.stderr.write( sys.stderr.write(
f'cic_eth.api.{method}({args}, {kwargs}) timed out:\n {e}') f"cic_eth.api.{method}({', '.join(args)}, {', '.join(f'{key}={value}' for key, value in kwargs.items())}) timed out:\n {e}")
sys.exit(1) sys.exit(1)
log.debug(f"cic_eth.api.{method}({args}, {kwargs})\n {o}") log.debug(
f"cic_eth.api.{method}({', '.join(args)}, {', '.join(f'{key}={value}' for key, value in kwargs.items())})\n {o}")
ps.unsubscribe() ps.unsubscribe()
try: try:
@ -58,4 +59,4 @@ def call(method, *args, **kwargs):
except Exception as e: except Exception as e:
sys.stderr.write( sys.stderr.write(
f'Unable to parse Data:\n{o}\n Error:\n{e}') f'Unable to parse Data:\n{o}\n Error:\n{e}')
sys.exit(1) return None

View File

@ -1,112 +0,0 @@
import logging
from cic_eth.server.celery_helper import call
from cic_eth.server.models import TokenBalance, Transaction
log = logging.getLogger(__name__)
def account_balance(address, token_symbol, include_pending=True):
"""account_balance
Retrieve Address Balance
:param address:
:type address: dict | bytes
:param token_symbol:
:type token_symbol: str
:param include_pending:
:type include_pending: bool
:rtype: [TokenBalance]
"""
balance = call("balance", address, token_symbol, include_pending)
log.debug(balance)
#[{'address': '3ff776b6f888980def9d4220858803f9dc5e341e', 'converters': [], 'balance_network': 0}]
return list(map(lambda b: TokenBalance(**b), balance))
def create_account_post(password="", register=True):
"""create_account_post
Creates a new blockchain address
:param password:
:type password: str
:param register:
:type register: bool
:return: Address of the new account
:rtype: string
"""
data = call("create_account", password, register)
return data
def list_transactions(address, limit=10):
"""list_transactions
Retrieve Address Balance
:param address:
:type address: dict | bytes
:param limit:
:type limit: int
:rtype: [Transaction]
"""
data = call('list', address, limit)
# data = task.get()
log.debug(data)
transactions = list(map(lambda t: Transaction(**t), data))
log.debug(transactions)
return transactions
def transfer(from_address, to_address, value, token_symbol):
"""transfer
Performs a transfer of ERC20 tokens from one address to another.
:param from_address:
:type from_address: dict | bytes
:param to_address:
:type to_address: dict | bytes
:param value:
:type value: int
:param token_symbol:
:type token_symbol: str
:return: Transaction hash for tranfer operation
:rtype: str, 0x-hex
"""
data = call('transfer', from_address, to_address,
int(value * (10**6)), token_symbol)
return data
def transfer_from(from_address, to_address, value, token_symbol, spender_address):
"""transfer_from
Performs a transfer of ERC20 tokens by one address on behalf of another address to a third party.
:param from_address: Ethereum address of sender
:type from_address: dict | bytes
:param to_address: Ethereum address of recipient
:type to_address: dict | bytes
:param value: Estimated return from conversion
:type value: int
:param token_symbol: ERC20 token symbol of token to send
:type token_symbol: str
:param spender_address: Ethereum address of recipient
:type spender_address: dict | bytes
:return: Transaction hash for transfer operation
:rtype: str, 0x-hex
"""
data = call("transfer_from", from_address, to_address, int(
value * (10**6)), token_symbol, spender_address)
return data

View File

@ -1,6 +0,0 @@
from typing import List
"""
controller generated to handled auth operation described at:
https://connexion.readthedocs.io/en/latest/security.html
"""

View File

@ -1,17 +0,0 @@
import logging
from cic_eth.server.celery_helper import call
from cic_eth.server.models import Token
log = logging.getLogger(__name__)
def get_default_token():
"""Retrieves the default fallback token of the custodial network
:rtype: Token
"""
data = call("default_token")
log.debug(data)
return Token(address=data['address'], symbol=data['symbol'], decimals=data['decimals'], name=data['name'])

View File

@ -1,20 +0,0 @@
from connexion.apps.flask_app import FlaskJSONEncoder
import six
from cic_eth.server.models.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder):
include_nulls = False
def default(self, o):
if isinstance(o, Model):
dikt = {}
for attr, _ in six.iteritems(o.swagger_types):
value = getattr(o, attr)
if value is None and not self.include_nulls:
continue
attr = o.attribute_map[attr]
dikt[attr] = value
return dikt
return FlaskJSONEncoder.default(self, o)

View File

@ -1,8 +0,0 @@
# coding: utf-8
# flake8: noqa
from __future__ import absolute_import
# import models into model package
from cic_eth.server.models.token import Token
from cic_eth.server.models.token_balance import TokenBalance
from cic_eth.server.models.transaction import Transaction

View File

@ -1,70 +0,0 @@
import pprint
import six
import typing
from cic_eth.server import util
T = typing.TypeVar('T')
class Model(object):
# swaggerTypes: The key is attribute name and the
# value is attribute type.
swagger_types = {}
# attributeMap: The key is attribute name and the
# value is json key in definition.
attribute_map = {}
@classmethod
def from_dict(cls: typing.Type[T], dikt) -> T:
"""Returns the dict as a model"""
return util.deserialize_model(dikt, cls)
def to_dict(self):
"""Returns the model properties as a dict
:rtype: dict
"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model
:rtype: str
"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other

View File

@ -1,149 +0,0 @@
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from cic_eth.server.models.base_model_ import Model
from cic_eth.server import util
class Token(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, symbol: str = None, address: str = None, name: str = None, decimals: str = None):
"""Token - a model defined in Swagger
:param symbol: The symbol of this Token.
:type symbol: str
:param address: The address of this Token.
:type address: str
:param name: The name of this Token.
:type name: str
:param decimals: The decimals of this Token.
:type decimals: str
"""
self.swagger_types = {
'symbol': str,
'address': str,
'name': str,
'decimals': str
}
self.attribute_map = {
'symbol': 'symbol',
'address': 'address',
'name': 'name',
'decimals': 'decimals'
}
self._symbol = symbol
self._address = address
self._name = name
self._decimals = decimals
@classmethod
def from_dict(cls, dikt) -> 'Token':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Token of this Token.
:rtype: Token
"""
return util.deserialize_model(dikt, cls)
@property
def symbol(self) -> str:
"""Gets the symbol of this Token.
Token Symbol
:return: The symbol of this Token.
:rtype: str
"""
return self._symbol
@symbol.setter
def symbol(self, symbol: str):
"""Sets the symbol of this Token.
Token Symbol
:param symbol: The symbol of this Token.
:type symbol: str
"""
self._symbol = symbol
@property
def address(self) -> str:
"""Gets the address of this Token.
Token Address
:return: The address of this Token.
:rtype: str
"""
return self._address
@address.setter
def address(self, address: str):
"""Sets the address of this Token.
Token Address
:param address: The address of this Token.
:type address: str
"""
self._address = address
@property
def name(self) -> str:
"""Gets the name of this Token.
Token Name
:return: The name of this Token.
:rtype: str
"""
return self._name
@name.setter
def name(self, name: str):
"""Sets the name of this Token.
Token Name
:param name: The name of this Token.
:type name: str
"""
self._name = name
@property
def decimals(self) -> str:
"""Gets the decimals of this Token.
Decimals
:return: The decimals of this Token.
:rtype: str
"""
return self._decimals
@decimals.setter
def decimals(self, decimals: str):
"""Sets the decimals of this Token.
Decimals
:param decimals: The decimals of this Token.
:type decimals: str
"""
self._decimals = decimals

View File

@ -1,194 +0,0 @@
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from cic_eth.server.models.base_model_ import Model
from cic_eth.server import util
class TokenBalance(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, address: str = None, converters: List[str] = None, balance_network: int = None, balance_incoming: int = None, balance_outgoing: int = None):
"""TokenBalance - a model defined in Swagger
:param address: The address of this TokenBalance.
:type address: str
:param converters: The converters of this TokenBalance.
:type converters: List[str]
:param balance_network: The balance_network of this TokenBalance.
:type balance_network: int
:param balance_incoming: The balance_incoming of this TokenBalance.
:type balance_incoming: int
:param balance_outgoing: The balance_outgoing of this TokenBalance.
:type balance_outgoing: int
:param balance_available: The balance_available of this TokenBalance.
:type balance_available: int
"""
self.swagger_types = {
'address': str,
'converters': List[str],
'balance_network': int,
'balance_incoming': int,
'balance_outgoing': int,
'balance_available': int
}
self.attribute_map = {
'address': 'address',
'converters': 'converters',
'balance_network': 'balance_network',
'balance_incoming': 'balance_incoming',
'balance_outgoing': 'balance_outgoing',
'balance_available': 'balance_available'
}
self._address = address
self._converters = converters
self._balance_network = balance_network
self._balance_incoming = balance_incoming
self._balance_outgoing = balance_outgoing
self._balance_available = int(
balance_network) + int(balance_incoming) - int(balance_outgoing)
@classmethod
def from_dict(cls, dikt) -> 'TokenBalance':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The TokenBalance of this TokenBalance.
:rtype: TokenBalance
"""
return util.deserialize_model(dikt, cls)
@property
def address(self) -> str:
"""Gets the address of this TokenBalance.
:return: The address of this TokenBalance.
:rtype: str
"""
return self._address
@address.setter
def address(self, address: str):
"""Sets the address of this TokenBalance.
:param address: The address of this TokenBalance.
:type address: str
"""
self._address = address
@property
def converters(self) -> List[str]:
"""Gets the converters of this TokenBalance.
:return: The converters of this TokenBalance.
:rtype: List[str]
"""
return self._converters
@converters.setter
def converters(self, converters: List[str]):
"""Sets the converters of this TokenBalance.
:param converters: The converters of this TokenBalance.
:type converters: List[str]
"""
self._converters = converters
@property
def balance_network(self) -> int:
"""Gets the balance_network of this TokenBalance.
:return: The balance_network of this TokenBalance.
:rtype: int
"""
return self._balance_network
@balance_network.setter
def balance_network(self, balance_network: int):
"""Sets the balance_network of this TokenBalance.
:param balance_network: The balance_network of this TokenBalance.
:type balance_network: int
"""
self._balance_network = balance_network
@property
def balance_incoming(self) -> int:
"""Gets the balance_incoming of this TokenBalance.
:return: The balance_incoming of this TokenBalance.
:rtype: int
"""
return self._balance_incoming
@balance_incoming.setter
def balance_incoming(self, balance_incoming: int):
"""Sets the balance_incoming of this TokenBalance.
:param balance_incoming: The balance_incoming of this TokenBalance.
:type balance_incoming: int
"""
self._balance_incoming = balance_incoming
@property
def balance_outgoing(self) -> int:
"""Gets the balance_outgoing of this TokenBalance.
:return: The balance_outgoing of this TokenBalance.
:rtype: int
"""
return self._balance_outgoing
@balance_outgoing.setter
def balance_outgoing(self, balance_outgoing: int):
"""Sets the balance_outgoing of this TokenBalance.
:param balance_outgoing: The balance_outgoing of this TokenBalance.
:type balance_outgoing: int
"""
self._balance_outgoing = balance_outgoing
@property
def balance_available(self) -> int:
"""Gets the balance_available of this TokenBalance.
:return: The balance_available of this TokenBalance.
:rtype: int
"""
return self._balance_available
@balance_available.setter
def balance_available(self, balance_available: int):
"""Sets the balance_available of this TokenBalance.
:param balance_available: The balance_available of this TokenBalance.
:type balance_available: int
"""
self._balance_available = balance_available

View File

@ -1,609 +0,0 @@
# coding: utf-8
from __future__ import absolute_import
from datetime import date, datetime
from typing import Dict, List
from cic_eth.server import util
from cic_eth.server.models.base_model_ import Model
class Transaction(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, block_number: int = None, date_checked: str = None, date_created: str = None, date_updated: str = None, destination_token: str = None, destination_token_decimals: int = None, destination_token_symbol: str = None, from_value: int = None, hash: str = None, nonce: int = None, recipient: str = None, sender: str = None, signed_tx: str = None, source_token: str = None, source_token_decimals: int = None, source_token_symbol: str = None, status: str = None, status_code: int = None, timestamp: int = None, to_value: int = None, tx_hash: str = None, tx_index: int = None):
"""Transaction - a model defined in Swagger
:param block_number: The block_number of this Transaction.
:type block_number: int
:param date_checked: The date_checked of this Transaction.
:type date_checked: str
:param date_created: The date_created of this Transaction.
:type date_created: str
:param date_updated: The date_updated of this Transaction.
:type date_updated: str
:param destination_token: The destination_token of this Transaction.
:type destination_token: str
:param destination_token_decimals: The destination_token_decimals of this Transaction.
:type destination_token_decimals: int
:param destination_token_symbol: The destination_token_symbol of this Transaction.
:type destination_token_symbol: str
:param from_value: The from_value of this Transaction.
:type from_value: int
:param hash: The hash of this Transaction.
:type hash: str
:param nonce: The nonce of this Transaction.
:type nonce: int
:param recipient: The recipient of this Transaction.
:type recipient: str
:param sender: The sender of this Transaction.
:type sender: str
:param signed_tx: The signed_tx of this Transaction.
:type signed_tx: str
:param source_token: The source_token of this Transaction.
:type source_token: str
:param source_token_decimals: The source_token_decimals of this Transaction.
:type source_token_decimals: int
:param source_token_symbol: The source_token_symbol of this Transaction.
:type source_token_symbol: str
:param status: The status of this Transaction.
:type status: str
:param status_code: The status_code of this Transaction.
:type status_code: int
:param timestamp: The timestamp of this Transaction.
:type timestamp: int
:param to_value: The to_value of this Transaction.
:type to_value: int
:param tx_hash: The tx_hash of this Transaction.
:type tx_hash: str
:param tx_index: The tx_index of this Transaction.
:type tx_index: int
"""
self.swagger_types = {
'block_number': int,
'date_checked': str,
'date_created': str,
'date_updated': str,
'destination_token': str,
'destination_token_decimals': int,
'destination_token_symbol': str,
'from_value': int,
'hash': str,
'nonce': int,
'recipient': str,
'sender': str,
'signed_tx': str,
'source_token': str,
'source_token_decimals': int,
'source_token_symbol': str,
'status': str,
'status_code': int,
'timestamp': int,
'to_value': int,
'tx_hash': str,
'tx_index': int
}
self.attribute_map = {
'block_number': 'block_number',
'date_checked': 'date_checked',
'date_created': 'date_created',
'date_updated': 'date_updated',
'destination_token': 'destination_token',
'destination_token_decimals': 'destination_token_decimals',
'destination_token_symbol': 'destination_token_symbol',
'from_value': 'from_value',
'hash': 'hash',
'nonce': 'nonce',
'recipient': 'recipient',
'sender': 'sender',
'signed_tx': 'signed_tx',
'source_token': 'source_token',
'source_token_decimals': 'source_token_decimals',
'source_token_symbol': 'source_token_symbol',
'status': 'status',
'status_code': 'status_code',
'timestamp': 'timestamp',
'to_value': 'to_value',
'tx_hash': 'tx_hash',
'tx_index': 'tx_index'
}
self._block_number = block_number
self._date_checked = date_checked
self._date_created = date_created
self._date_updated = date_updated
self._destination_token = destination_token
self._destination_token_decimals = destination_token_decimals
self._destination_token_symbol = destination_token_symbol
self._from_value = from_value
self._hash = hash
self._nonce = nonce
self._recipient = recipient
self._sender = sender
self._signed_tx = signed_tx
self._source_token = source_token
self._source_token_decimals = source_token_decimals
self._source_token_symbol = source_token_symbol
self._status = status
self._status_code = status_code
self._timestamp = timestamp
self._to_value = to_value
self._tx_hash = tx_hash
self._tx_index = tx_index
@classmethod
def from_dict(cls, dikt) -> 'Transaction':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The Transaction of this Transaction.
:rtype: Transaction
"""
return util.deserialize_model(dikt, cls)
@property
def block_number(self) -> int:
"""Gets the block_number of this Transaction.
:return: The block_number of this Transaction.
:rtype: int
"""
return self._block_number
@block_number.setter
def block_number(self, block_number: int):
"""Sets the block_number of this Transaction.
:param block_number: The block_number of this Transaction.
:type block_number: int
"""
self._block_number = block_number
@property
def date_checked(self) -> str:
"""Gets the date_checked of this Transaction.
:return: The date_checked of this Transaction.
:rtype: str
"""
return self._date_checked
@date_checked.setter
def date_checked(self, date_checked: str):
"""Sets the date_checked of this Transaction.
:param date_checked: The date_checked of this Transaction.
:type date_checked: str
"""
self._date_checked = date_checked
@property
def date_created(self) -> str:
"""Gets the date_created of this Transaction.
:return: The date_created of this Transaction.
:rtype: str
"""
return self._date_created
@date_created.setter
def date_created(self, date_created: str):
"""Sets the date_created of this Transaction.
:param date_created: The date_created of this Transaction.
:type date_created: str
"""
self._date_created = date_created
@property
def date_updated(self) -> str:
"""Gets the date_updated of this Transaction.
:return: The date_updated of this Transaction.
:rtype: str
"""
return self._date_updated
@date_updated.setter
def date_updated(self, date_updated: str):
"""Sets the date_updated of this Transaction.
:param date_updated: The date_updated of this Transaction.
:type date_updated: str
"""
self._date_updated = date_updated
@property
def destination_token(self) -> str:
"""Gets the destination_token of this Transaction.
:return: The destination_token of this Transaction.
:rtype: str
"""
return self._destination_token
@destination_token.setter
def destination_token(self, destination_token: str):
"""Sets the destination_token of this Transaction.
:param destination_token: The destination_token of this Transaction.
:type destination_token: str
"""
self._destination_token = destination_token
@property
def destination_token_decimals(self) -> int:
"""Gets the destination_token_decimals of this Transaction.
:return: The destination_token_decimals of this Transaction.
:rtype: int
"""
return self._destination_token_decimals
@destination_token_decimals.setter
def destination_token_decimals(self, destination_token_decimals: int):
"""Sets the destination_token_decimals of this Transaction.
:param destination_token_decimals: The destination_token_decimals of this Transaction.
:type destination_token_decimals: int
"""
self._destination_token_decimals = destination_token_decimals
@property
def destination_token_symbol(self) -> str:
"""Gets the destination_token_symbol of this Transaction.
:return: The destination_token_symbol of this Transaction.
:rtype: str
"""
return self._destination_token_symbol
@destination_token_symbol.setter
def destination_token_symbol(self, destination_token_symbol: str):
"""Sets the destination_token_symbol of this Transaction.
:param destination_token_symbol: The destination_token_symbol of this Transaction.
:type destination_token_symbol: str
"""
self._destination_token_symbol = destination_token_symbol
@property
def from_value(self) -> int:
"""Gets the from_value of this Transaction.
:return: The from_value of this Transaction.
:rtype: int
"""
return self._from_value
@from_value.setter
def from_value(self, from_value: int):
"""Sets the from_value of this Transaction.
:param from_value: The from_value of this Transaction.
:type from_value: int
"""
self._from_value = from_value
@property
def hash(self) -> str:
"""Gets the hash of this Transaction.
:return: The hash of this Transaction.
:rtype: str
"""
return self._hash
@hash.setter
def hash(self, hash: str):
"""Sets the hash of this Transaction.
:param hash: The hash of this Transaction.
:type hash: str
"""
self._hash = hash
@property
def nonce(self) -> int:
"""Gets the nonce of this Transaction.
:return: The nonce of this Transaction.
:rtype: int
"""
return self._nonce
@nonce.setter
def nonce(self, nonce: int):
"""Sets the nonce of this Transaction.
:param nonce: The nonce of this Transaction.
:type nonce: int
"""
self._nonce = nonce
@property
def recipient(self) -> str:
"""Gets the recipient of this Transaction.
:return: The recipient of this Transaction.
:rtype: str
"""
return self._recipient
@recipient.setter
def recipient(self, recipient: str):
"""Sets the recipient of this Transaction.
:param recipient: The recipient of this Transaction.
:type recipient: str
"""
self._recipient = recipient
@property
def sender(self) -> str:
"""Gets the sender of this Transaction.
:return: The sender of this Transaction.
:rtype: str
"""
return self._sender
@sender.setter
def sender(self, sender: str):
"""Sets the sender of this Transaction.
:param sender: The sender of this Transaction.
:type sender: str
"""
self._sender = sender
@property
def signed_tx(self) -> str:
"""Gets the signed_tx of this Transaction.
:return: The signed_tx of this Transaction.
:rtype: str
"""
return self._signed_tx
@signed_tx.setter
def signed_tx(self, signed_tx: str):
"""Sets the signed_tx of this Transaction.
:param signed_tx: The signed_tx of this Transaction.
:type signed_tx: str
"""
self._signed_tx = signed_tx
@property
def source_token(self) -> str:
"""Gets the source_token of this Transaction.
:return: The source_token of this Transaction.
:rtype: str
"""
return self._source_token
@source_token.setter
def source_token(self, source_token: str):
"""Sets the source_token of this Transaction.
:param source_token: The source_token of this Transaction.
:type source_token: str
"""
self._source_token = source_token
@property
def source_token_decimals(self) -> int:
"""Gets the source_token_decimals of this Transaction.
:return: The source_token_decimals of this Transaction.
:rtype: int
"""
return self._source_token_decimals
@source_token_decimals.setter
def source_token_decimals(self, source_token_decimals: int):
"""Sets the source_token_decimals of this Transaction.
:param source_token_decimals: The source_token_decimals of this Transaction.
:type source_token_decimals: int
"""
self._source_token_decimals = source_token_decimals
@property
def source_token_symbol(self) -> str:
"""Gets the source_token_symbol of this Transaction.
:return: The source_token_symbol of this Transaction.
:rtype: str
"""
return self._source_token_symbol
@source_token_symbol.setter
def source_token_symbol(self, source_token_symbol: str):
"""Sets the source_token_symbol of this Transaction.
:param source_token_symbol: The source_token_symbol of this Transaction.
:type source_token_symbol: str
"""
self._source_token_symbol = source_token_symbol
@property
def status(self) -> str:
"""Gets the status of this Transaction.
:return: The status of this Transaction.
:rtype: str
"""
return self._status
@status.setter
def status(self, status: str):
"""Sets the status of this Transaction.
:param status: The status of this Transaction.
:type status: str
"""
self._status = status
@property
def status_code(self) -> int:
"""Gets the status_code of this Transaction.
:return: The status_code of this Transaction.
:rtype: int
"""
return self._status_code
@status_code.setter
def status_code(self, status_code: int):
"""Sets the status_code of this Transaction.
:param status_code: The status_code of this Transaction.
:type status_code: int
"""
self._status_code = status_code
@property
def timestamp(self) -> int:
"""Gets the timestamp of this Transaction.
:return: The timestamp of this Transaction.
:rtype: int
"""
return self._timestamp
@timestamp.setter
def timestamp(self, timestamp: int):
"""Sets the timestamp of this Transaction.
:param timestamp: The timestamp of this Transaction.
:type timestamp: int
"""
self._timestamp = timestamp
@property
def to_value(self) -> int:
"""Gets the to_value of this Transaction.
:return: The to_value of this Transaction.
:rtype: int
"""
return self._to_value
@to_value.setter
def to_value(self, to_value: int):
"""Sets the to_value of this Transaction.
:param to_value: The to_value of this Transaction.
:type to_value: int
"""
self._to_value = to_value
@property
def tx_hash(self) -> str:
"""Gets the tx_hash of this Transaction.
:return: The tx_hash of this Transaction.
:rtype: str
"""
return self._tx_hash
@tx_hash.setter
def tx_hash(self, tx_hash: str):
"""Sets the tx_hash of this Transaction.
:param tx_hash: The tx_hash of this Transaction.
:type tx_hash: str
"""
self._tx_hash = tx_hash
@property
def tx_index(self) -> int:
"""Gets the tx_index of this Transaction.
:return: The tx_index of this Transaction.
:rtype: int
"""
return self._tx_index
@tx_index.setter
def tx_index(self, tx_index: int):
"""Sets the tx_index of this Transaction.
:param tx_index: The tx_index of this Transaction.
:type tx_index: int
"""
self._tx_index = tx_index

View File

@ -1,32 +0,0 @@
# coding: utf-8
import sys
if sys.version_info < (3, 7):
import typing
def is_generic(klass):
""" Determine whether klass is a generic class """
return type(klass) == typing.GenericMeta
def is_dict(klass):
""" Determine whether klass is a Dict """
return klass.__extra__ == dict
def is_list(klass):
""" Determine whether klass is a List """
return klass.__extra__ == list
else:
def is_generic(klass):
""" Determine whether klass is a generic class """
return hasattr(klass, '__origin__')
def is_dict(klass):
""" Determine whether klass is a Dict """
return klass.__origin__ == dict
def is_list(klass):
""" Determine whether klass is a List """
return klass.__origin__ == list

View File

@ -1,142 +0,0 @@
import datetime
import six
import typing
from cic_eth.server import type_util
def _deserialize(data, klass):
"""Deserializes dict, list, str into an object.
:param data: dict, list or str.
:param klass: class literal, or string of class name.
:return: object.
"""
if data is None:
return None
if klass in six.integer_types or klass in (float, str, bool, bytearray):
return _deserialize_primitive(data, klass)
elif klass == object:
return _deserialize_object(data)
elif klass == datetime.date:
return deserialize_date(data)
elif klass == datetime.datetime:
return deserialize_datetime(data)
elif type_util.is_generic(klass):
if type_util.is_list(klass):
return _deserialize_list(data, klass.__args__[0])
if type_util.is_dict(klass):
return _deserialize_dict(data, klass.__args__[1])
else:
return deserialize_model(data, klass)
def _deserialize_primitive(data, klass):
"""Deserializes to primitive type.
:param data: data to deserialize.
:param klass: class literal.
:return: int, long, float, str, bool.
:rtype: int | long | float | str | bool
"""
try:
value = klass(data)
except UnicodeEncodeError:
value = six.u(data)
except TypeError:
value = data
return value
def _deserialize_object(value):
"""Return an original value.
:return: object.
"""
return value
def deserialize_date(string):
"""Deserializes string to date.
:param string: str.
:type string: str
:return: date.
:rtype: date
"""
try:
from dateutil.parser import parse
return parse(string).date()
except ImportError:
return string
def deserialize_datetime(string):
"""Deserializes string to datetime.
The string should be in iso8601 datetime format.
:param string: str.
:type string: str
:return: datetime.
:rtype: datetime
"""
try:
from dateutil.parser import parse
return parse(string)
except ImportError:
return string
def deserialize_model(data, klass):
"""Deserializes list or dict to model.
:param data: dict, list.
:type data: dict | list
:param klass: class literal.
:return: model object.
"""
instance = klass()
if not instance.swagger_types:
return data
for attr, attr_type in six.iteritems(instance.swagger_types):
if data is not None \
and instance.attribute_map[attr] in data \
and isinstance(data, (list, dict)):
value = data[instance.attribute_map[attr]]
setattr(instance, attr, _deserialize(value, attr_type))
return instance
def _deserialize_list(data, boxed_type):
"""Deserializes a list and its elements.
:param data: list to deserialize.
:type data: list
:param boxed_type: class literal.
:return: deserialized list.
:rtype: list
"""
return [_deserialize(sub_data, boxed_type)
for sub_data in data]
def _deserialize_dict(data, boxed_type):
"""Deserializes a dict and its elements.
:param data: dict to deserialize.
:type data: dict
:param boxed_type: class literal.
:return: deserialized dict.
:rtype: dict
"""
return {k: _deserialize(v, boxed_type)
for k, v in six.iteritems(data)}

View File

@ -3,9 +3,6 @@ chainlib-eth>=0.0.10a16,<0.1.0
semver==2.13.0 semver==2.13.0
crypto-dev-signer>=0.4.15rc2,<0.5.0 crypto-dev-signer>=0.4.15rc2,<0.5.0
uwsgi==2.0.19.1 uwsgi==2.0.19.1
flask>=2.0.2
connexion[swagger-ui] == 2.6.0
python_dateutil == 2.6.0
setuptools >= 21.0.0 setuptools >= 21.0.0
openapi-core >= 0.14.2 openapi-core >= 0.14.2
openapi-spec-validator >= 0.3.1 openapi-spec-validator >= 0.3.1

View File

@ -6,6 +6,9 @@ volumes:
bloxberg-data: {} bloxberg-data: {}
contract-config: {} contract-config: {}
networks:
default:
name: cic-network
services: services:
evm: evm:
@ -220,8 +223,10 @@ services:
set -a set -a
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
set +a set +a
pip install -r test_requirements.txt /usr/local/bin/uwsgi \
tail -F ./requirements.txt --wsgi-file /root/cic_eth/runnable/daemons/server.py \
--http :5000 \
--pyargv "-vv"
cic-eth-tracker: cic-eth-tracker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}