revert api_task:balance changes

This commit is contained in:
2021-11-01 13:56:12 +03:00
parent 7c73c8b30f
commit f28ba1098f
5 changed files with 127 additions and 110 deletions

View File

@@ -16,7 +16,6 @@ from cic_eth.api.base import ApiBase
from cic_eth.enum import LockEnum
app = celery.current_app
#logg = logging.getLogger(__name__)
logg = logging.getLogger()
@@ -430,13 +429,13 @@ class Api(ApiBase):
return t
def balance(self, address, token_symbols, include_pending=True):
def balance(self, address, token_symbol, include_pending=True):
"""Calls the provided callback with the current token balance of the given address.
:param address: Ethereum address of holder
:type address: str, 0x-hex
:param token_symbols: ERC20 token symbols of tokens to send
:type token_symbols: list[str]
:param token_symbol: ERC20 token symbol of tokens to send
:type token_symbol: str
:param include_pending: If set, will include transactions that have not yet been fully processed
:type include_pending: bool
:returns: uuid of root task
@@ -448,7 +447,7 @@ class Api(ApiBase):
s_tokens = celery.signature(
'cic_eth.eth.erc20.resolve_tokens_by_symbol',
[
token_symbols,
[token_symbol],
self.chain_spec.asdict(),
],
queue=self.queue,

View File

@@ -1,3 +1,4 @@
from cic_eth.graphql.schema import schema
query_with_argument = """
{
@@ -34,7 +35,7 @@ print(m_result)
balance_query = """
query {
balance(address:"0xcf41bd087b71c72d748fe2b8b4c88b2367c37df3", tokenSymbols:["GFT", "COFE"]){
balance(address:"0x643c99d5ab51b5e06d55a68e6b24fd36e9d6b1c9", tokenSymbols:["GFT", "COFE"]){
balanceNetwork
balanceIncoming
balanceOutgoing
@@ -43,8 +44,8 @@ query {
}
"""
# balance_query_result = schema.execute(balance_query)
# print(balance_query_result)
balance_query_result = schema.execute(balance_query)
print(balance_query_result)
transfer_mutation = """
@@ -58,8 +59,8 @@ tokenSymbol: "COFE" ){
}
"""
transfer_mutation_result = schema.execute(transfer_mutation)
print(transfer_mutation_result)
# transfer_mutation_result = schema.execute(transfer_mutation)
# print(transfer_mutation_result)
balance_query = """

View File

@@ -3,6 +3,7 @@ import json
import sys
import uuid
import celery
import cic_eth.cli
import redis
from cic_eth.api.api_task import Api
@@ -17,7 +18,7 @@ argparser.process_local_flags(local_arg_flags)
args = argparser.parse_args()
config = cic_eth.cli.Config.from_args(args, arg_flags, local_arg_flags)
celery_app = cic_eth.cli.CeleryApp.from_config(config)
celery_app = celery.Celery(backend=config.get('CELERY_RESULT_URL'), broker=config.get('CELERY_BROKER_URL'))
chain_spec = config.get('CHAIN_SPEC')
redis_host = config.get('REDIS_HOST')
redis_port = config.get('REDIS_PORT')
@@ -43,7 +44,7 @@ def call(method, *args):
ps = r.pubsub()
ps.subscribe(redis_channel)
ps.get_message() # Subscription Object
print(f"Channel init {redis_channel}")
api = init_api(redis_channel)
print(args)
@@ -91,10 +92,10 @@ class Query(ObjectType):
return Token(**data)
balance = Field(List(TokenBalance), address=String(),
token_symbols=List(String), include_pending=Boolean())
token_symbol=String(), include_pending=Boolean())
def resolve_balance(root, info, address, token_symbols, include_pending=True):
data = call('balance', address, token_symbols, include_pending)
def resolve_balance(root, info, address, token_symbol, include_pending=True):
data = call('balance', address, token_symbol, include_pending)
print(data)
#[{'address': '3ff776b6f888980def9d4220858803f9dc5e341e', 'converters': [], 'balance_network': 0}]
return map(lambda token: TokenBalance(

View File

@@ -2,7 +2,6 @@ celery==4.4.7
chainlib-eth>=0.0.10a16,<0.1.0
semver==2.13.0
crypto-dev-signer>=0.4.15rc2,<0.5.0
uwsgi==2.0.19.1
graphene>=2.0
flask>=2.0.2
Flask-GraphQL>=2.0.1