revert api_task:balance changes

This commit is contained in:
William Luke 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

View File

@ -6,6 +6,7 @@ volumes:
bloxberg-data: {}
contract-config: {}
services:
evm:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/bloxberg-node:${TAG:-latest}
@ -38,13 +39,14 @@ services:
- ${DEV_REDIS_PORT:-63379}:6379
command: "--loglevel verbose"
bootstrap:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/contract-migration:${TAG:-latest}
build:
context: apps/contract-migration
dockerfile: docker/Dockerfile
args:
DOCKER_REGISTRY: $DEV_DOCKER_REGISTRY
DOCKER_REGISTRY: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.org/simple}
EXTRA_PIP_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
@ -85,8 +87,10 @@ services:
volumes:
- contract-config:/tmp/cic/config
cic-signer:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/funga-eth:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/funga-eth:${TAG:-latest}
build:
context: apps/cic-signer
dockerfile: Dockerfile
@ -116,7 +120,9 @@ services:
# queue handling for outgoing transactions and incoming transactions
cic-eth-tasker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-eth:${TAG:-latest}
ports:
- 5000:5000
build:
context: apps/cic-eth
dockerfile: docker/Dockerfile
@ -147,8 +153,6 @@ services:
SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef}
TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1}
restart: unless-stopped
ports:
- 5000:5000
depends_on:
- evm
- postgres
@ -164,10 +168,11 @@ services:
set -a
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
set +a
./start_tasker.sh --aux-all -q cic-eth -vv & python /root/cic_eth/graphql/app.py
./start_tasker.sh --aux-all -q cic-eth -vv
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-eth:${TAG:-latest}
build:
context: apps/cic-eth
dockerfile: docker/Dockerfile
@ -213,8 +218,9 @@ services:
set +a
./start_tracker.sh -vv
cic-eth-dispatcher:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-eth:${TAG:-latest}
build:
context: apps/cic-eth
dockerfile: docker/Dockerfile
@ -256,8 +262,9 @@ services:
set +a
./start_dispatcher.sh -vv
cic-eth-retrier:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-eth:${TAG:-latest}
build:
context: apps/cic-eth
dockerfile: docker/Dockerfile
@ -301,8 +308,10 @@ services:
set +a
./start_retry.sh -vv
cic-cache-tracker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-cache:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-cache:${TAG:-latest}
build:
context: apps/cic-cache
dockerfile: docker/Dockerfile
@ -348,8 +357,9 @@ services:
set +a
./start_tracker.sh -vv
cic-cache-tasker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-cache:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-cache:${TAG:-latest}
build:
context: apps/cic-cache
dockerfile: docker/Dockerfile
@ -395,8 +405,9 @@ services:
# --http :8000 \
# --pyargv "-vv"
cic-cache-server:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-cache:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-cache:${TAG:-latest}
build:
context: apps/cic-cache
dockerfile: docker/Dockerfile
@ -437,6 +448,7 @@ services:
volumes:
- contract-config:/tmp/cic/config/:ro
# metadata replacement server for swarm
cic-meta-server:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-meta:${TAG:-latest}
@ -475,6 +487,7 @@ services:
volumes:
- ./apps/contract-migration/testdata/pgp/:/tmp/cic/pgp
cic-user-tasker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest}
build:
@ -510,6 +523,7 @@ services:
- ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/
command: "/root/start_cic_user_tasker.sh -q cic-ussd -vv"
cic-user-server:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest}
build:
@ -538,6 +552,7 @@ services:
- redis
command: "/root/start_cic_user_server.sh -vv"
cic-user-ussd-server:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest}
build:
@ -575,6 +590,7 @@ services:
- ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/
command: "/root/start_cic_user_ussd_server.sh -vv"
cic-notify-tasker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-notify:${TAG:-latest}
build:
@ -607,7 +623,7 @@ services:
command: "/root/start_tasker.sh -q cic-notify -vv"
data-seeding:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/data-seeding:${TAG:-latest}
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/data-seeding:${TAG:-latest}
build:
context: apps/data-seeding
dockerfile: docker/Dockerfile
@ -635,7 +651,8 @@ services:
CONFIG: config
CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
TOKEN_SYMBOL: GFT
KEYSTORE_PATH: keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c
#KEYSTORE_PATH: keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c
WALLET_KEY_FILE: ${WALLET_KEY_FILE:-/root/keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c}
USSD_HOST: cic-user-ussd-server
USSD_PORT: 9000
INCLUDE_BALANCES: y