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

View File

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

View File

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

View File

@ -2,7 +2,6 @@ celery==4.4.7
chainlib-eth>=0.0.10a16,<0.1.0 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
graphene>=2.0 graphene>=2.0
flask>=2.0.2 flask>=2.0.2
Flask-GraphQL>=2.0.1 Flask-GraphQL>=2.0.1

View File

@ -6,6 +6,7 @@ volumes:
bloxberg-data: {} bloxberg-data: {}
contract-config: {} contract-config: {}
services: services:
evm: evm:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/bloxberg-node:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/bloxberg-node:${TAG:-latest}
@ -27,7 +28,7 @@ services:
# PGDATA: /tmp/cic/postgres # PGDATA: /tmp/cic/postgres
ports: ports:
- ${DEV_POSTGRES_PORT:-63432}:5432 - ${DEV_POSTGRES_PORT:-63432}:5432
command: ["-c", "max_connections=200"] command: [ "-c", "max_connections=200" ]
volumes: volumes:
- ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql - ./scripts/initdb/create_db.sql:/docker-entrypoint-initdb.d/1-create_all_db.sql
- postgres-db:/var/lib/postgresql/data - postgres-db:/var/lib/postgresql/data
@ -38,13 +39,14 @@ services:
- ${DEV_REDIS_PORT:-63379}:6379 - ${DEV_REDIS_PORT:-63379}:6379
command: "--loglevel verbose" command: "--loglevel verbose"
bootstrap: bootstrap:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/contract-migration:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/contract-migration:${TAG:-latest}
build: build:
context: apps/contract-migration context: apps/contract-migration
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
args: 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} 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_INDEX_URL: ${EXTRA_PIP_INDEX_URL:-https://pip.grassrootseconomics.net:8433}
EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS EXTRA_PIP_ARGS: $EXTRA_PIP_ARGS
@ -85,8 +87,10 @@ services:
volumes: volumes:
- contract-config:/tmp/cic/config - contract-config:/tmp/cic/config
cic-signer: 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: build:
context: apps/cic-signer context: apps/cic-signer
dockerfile: Dockerfile dockerfile: Dockerfile
@ -116,7 +120,9 @@ services:
# queue handling for outgoing transactions and incoming transactions # queue handling for outgoing transactions and incoming transactions
cic-eth-tasker: 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: build:
context: apps/cic-eth context: apps/cic-eth
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -147,8 +153,6 @@ services:
SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef} SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef}
TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1} TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1}
restart: unless-stopped restart: unless-stopped
ports:
- 5000:5000
depends_on: depends_on:
- evm - evm
- postgres - postgres
@ -164,10 +168,11 @@ 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
./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: 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: build:
context: apps/cic-eth context: apps/cic-eth
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -213,8 +218,9 @@ services:
set +a set +a
./start_tracker.sh -vv ./start_tracker.sh -vv
cic-eth-dispatcher: 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: build:
context: apps/cic-eth context: apps/cic-eth
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -256,8 +262,9 @@ services:
set +a set +a
./start_dispatcher.sh -vv ./start_dispatcher.sh -vv
cic-eth-retrier: 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: build:
context: apps/cic-eth context: apps/cic-eth
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -301,8 +308,10 @@ services:
set +a set +a
./start_retry.sh -vv ./start_retry.sh -vv
cic-cache-tracker: 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: build:
context: apps/cic-cache context: apps/cic-cache
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -348,8 +357,9 @@ services:
set +a set +a
./start_tracker.sh -vv ./start_tracker.sh -vv
cic-cache-tasker: 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: build:
context: apps/cic-cache context: apps/cic-cache
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -390,13 +400,14 @@ services:
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
/usr/local/bin/cic-cache-taskerd -vv /usr/local/bin/cic-cache-taskerd -vv
# "/usr/local/bin/uwsgi" \ # "/usr/local/bin/uwsgi" \
# --wsgi-file /root/cic_cache/runnable/daemons/server.py \ # --wsgi-file /root/cic_cache/runnable/daemons/server.py \
# --http :8000 \ # --http :8000 \
# --pyargv "-vv" # --pyargv "-vv"
cic-cache-server: 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: build:
context: apps/cic-cache context: apps/cic-cache
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -437,6 +448,7 @@ services:
volumes: volumes:
- contract-config:/tmp/cic/config/:ro - contract-config:/tmp/cic/config/:ro
# metadata replacement server for swarm # metadata replacement server for swarm
cic-meta-server: cic-meta-server:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-meta:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-meta:${TAG:-latest}
@ -475,6 +487,7 @@ services:
volumes: volumes:
- ./apps/contract-migration/testdata/pgp/:/tmp/cic/pgp - ./apps/contract-migration/testdata/pgp/:/tmp/cic/pgp
cic-user-tasker: cic-user-tasker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest}
build: build:
@ -510,6 +523,7 @@ services:
- ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/ - ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/
command: "/root/start_cic_user_tasker.sh -q cic-ussd -vv" command: "/root/start_cic_user_tasker.sh -q cic-ussd -vv"
cic-user-server: cic-user-server:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest}
build: build:
@ -538,6 +552,7 @@ services:
- redis - redis
command: "/root/start_cic_user_server.sh -vv" command: "/root/start_cic_user_server.sh -vv"
cic-user-ussd-server: cic-user-ussd-server:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-user:${TAG:-latest}
build: build:
@ -575,6 +590,7 @@ services:
- ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/ - ./apps/contract-migration/testdata/pgp/:/usr/src/secrets/
command: "/root/start_cic_user_ussd_server.sh -vv" command: "/root/start_cic_user_ussd_server.sh -vv"
cic-notify-tasker: cic-notify-tasker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-notify:${TAG:-latest} image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-notify:${TAG:-latest}
build: build:
@ -607,7 +623,7 @@ services:
command: "/root/start_tasker.sh -q cic-notify -vv" command: "/root/start_tasker.sh -q cic-notify -vv"
data-seeding: 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: build:
context: apps/data-seeding context: apps/data-seeding
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
@ -635,7 +651,8 @@ services:
CONFIG: config CONFIG: config
CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg} CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
TOKEN_SYMBOL: GFT 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_HOST: cic-user-ussd-server
USSD_PORT: 9000 USSD_PORT: 9000
INCLUDE_BALANCES: y INCLUDE_BALANCES: y