diff --git a/apps/cic-eth/cic_eth/api/api_task.py b/apps/cic-eth/cic_eth/api/api_task.py index 52aedee5..93a4d1bf 100644 --- a/apps/cic-eth/cic_eth/api/api_task.py +++ b/apps/cic-eth/cic_eth/api/api_task.py @@ -62,6 +62,18 @@ class Api: ) + def default_token(self): + s_token = celery.signature( + 'cic_eth.admin.token.default_token', + [], + queue=self.queue, + ) + if self.callback_param != None: + s_token.link(self.callback_success) + + return s_token.apply_async() + + def convert_transfer(self, from_address, to_address, target_return, minimum_return, from_token_symbol, to_token_symbol): """Executes a chain of celery tasks that performs conversion between two ERC20 tokens, and transfers to a specified receipient after convert has completed. diff --git a/apps/cic-eth/cic_eth/runnable/daemons/tasker.py b/apps/cic-eth/cic_eth/runnable/daemons/tasker.py index 2d9d0434..3c63b1a6 100644 --- a/apps/cic-eth/cic_eth/runnable/daemons/tasker.py +++ b/apps/cic-eth/cic_eth/runnable/daemons/tasker.py @@ -28,6 +28,7 @@ from cic_eth.eth import ( from cic_eth.admin import ( debug, ctrl, + token, ) from cic_eth.queue import ( query, @@ -52,6 +53,7 @@ from cic_eth.registry import ( connect_declarator, connect_token_registry, ) +from cic_eth.task import BaseTask logging.basicConfig(level=logging.WARNING) @@ -64,6 +66,7 @@ argparser.add_argument('-p', '--provider', dest='p', type=str, help='rpc provide argparser.add_argument('-c', type=str, default=config_dir, help='config file') argparser.add_argument('-q', type=str, default='cic-eth', help='queue name for worker tasks') argparser.add_argument('-r', type=str, help='CIC registry address') +argparser.add_argument('--default-token-symbol', dest='default_token_symbol', type=str, help='Symbol of default token to use') argparser.add_argument('--abi-dir', dest='abi_dir', type=str, help='Directory containing bytecode and abi') argparser.add_argument('--trace-queue-status', default=None, dest='trace_queue_status', action='store_true', help='set to perist all queue entry status changes to storage') argparser.add_argument('-i', '--chain-spec', dest='i', type=str, help='chain spec') @@ -83,6 +86,7 @@ config.process() args_override = { 'CIC_CHAIN_SPEC': getattr(args, 'i'), 'CIC_REGISTRY_ADDRESS': getattr(args, 'r'), + 'CIC_DEFAULT_TOKEN_SYMBOL': getattr(args, 'default_token_symbol'), 'ETH_PROVIDER': getattr(args, 'p'), 'TASKS_TRACE_QUEUE_STATUS': getattr(args, 'trace_queue_status'), } @@ -166,7 +170,7 @@ def main(): rpc = RPCConnection.connect(chain_spec, 'default') - connect_registry(rpc, chain_spec, config.get('CIC_REGISTRY_ADDRESS')) + registry = connect_registry(rpc, chain_spec, config.get('CIC_REGISTRY_ADDRESS')) trusted_addresses_src = config.get('CIC_TRUST_ADDRESS') if trusted_addresses_src == None: @@ -177,6 +181,10 @@ def main(): logg.info('using trusted address {}'.format(address)) connect_declarator(rpc, chain_spec, trusted_addresses) connect_token_registry(rpc, chain_spec) + + BaseTask.default_token_symbol = config.get('CIC_DEFAULT_TOKEN_SYMBOL') + BaseTask.default_token_address = registry.by_name(BaseTask.default_token_symbol) + logg.info('default token set to {} {}'.format(BaseTask.default_token_symbol, BaseTask.default_token_address)) liveness.linux.set() current_app.worker_main(argv) diff --git a/apps/cic-eth/cic_eth/task.py b/apps/cic-eth/cic_eth/task.py index e95f482f..db315ac8 100644 --- a/apps/cic-eth/cic_eth/task.py +++ b/apps/cic-eth/cic_eth/task.py @@ -29,6 +29,8 @@ class BaseTask(celery.Task): call_address = ZERO_ADDRESS create_nonce_oracle = RPCNonceOracle create_gas_oracle = RPCGasOracle + default_token_address = None + default_token_symbol = None def create_session(self): return BaseTask.session_func() diff --git a/apps/cic-eth/cic_eth/version.py b/apps/cic-eth/cic_eth/version.py index 1624e647..4740b580 100644 --- a/apps/cic-eth/cic_eth/version.py +++ b/apps/cic-eth/cic_eth/version.py @@ -10,7 +10,7 @@ version = ( 0, 11, 0, - 'beta.7', + 'beta.8', ) version_object = semver.VersionInfo( diff --git a/apps/cic-eth/config/cic.ini b/apps/cic-eth/config/cic.ini index 10ec9cdc..68a40270 100644 --- a/apps/cic-eth/config/cic.ini +++ b/apps/cic-eth/config/cic.ini @@ -4,3 +4,4 @@ chain_spec = evm:bloxberg:8996 tx_retry_delay = trust_address = health_modules = cic_eth.k8s.db +default_token_symbol = GFT diff --git a/apps/cic-eth/config/docker/cic.ini b/apps/cic-eth/config/docker/cic.ini index 50032aa9..ec5cfb8d 100644 --- a/apps/cic-eth/config/docker/cic.ini +++ b/apps/cic-eth/config/docker/cic.ini @@ -3,3 +3,4 @@ registry_address = chain_spec = evm:bloxberg:8996 trust_address = 0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C tx_retry_delay = 20 +default_token_symbol = GFT diff --git a/apps/cic-eth/setup.cfg b/apps/cic-eth/setup.cfg index cc0d5549..f7e652e4 100644 --- a/apps/cic-eth/setup.cfg +++ b/apps/cic-eth/setup.cfg @@ -53,6 +53,7 @@ console_scripts = cic-eth-create = cic_eth.runnable.create:main cic-eth-inspect = cic_eth.runnable.view:main cic-eth-ctl = cic_eth.runnable.ctrl:main + cic-eth-info = cic_eth.runnable.info:main # TODO: Merge this with ctl when subcmds sorted to submodules cic-eth-tag = cic_eth.runnable.tag:main cic-eth-resend = cic_eth.runnable.resend:main diff --git a/apps/contract-migration/reset.sh b/apps/contract-migration/reset.sh index 57011010..4ecf2fba 100755 --- a/apps/contract-migration/reset.sh +++ b/apps/contract-migration/reset.sh @@ -3,7 +3,7 @@ set -a CIC_CHAIN_SPEC=${CIC_CHAIN_SPEC:-evm:bloxberg:8995} -DEV_TOKEN_TYPE=${DEV_TOKEN_TYPE:-GFT} +CIC_DEFAULT_TOKEN_SYMBOL=${CIC_DEFAULT_TOKEN_SYMBOL:-GFT} DEV_ETH_ACCOUNT_RESERVE_MINTER=${DEV_ETH_ACCOUNT_RESERVE_MINTER:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER} DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER=${DEV_ETH_ACCOUNT_RESERVE_MINTER:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER} DEV_RESERVE_AMOUNT=${DEV_ETH_RESERVE_AMOUNT:-""10000000000000000000000000000000000} @@ -19,8 +19,8 @@ if [ ! -z $DEV_ETH_GAS_PRICE ]; then >&2 echo using static gas price $DEV_ETH_GAS_PRICE fi -if [[ $DEV_TOKEN_TYPE != 'GFT' && $DEV_TOKEN_TYPE != 'SRF' ]]; then - >&2 echo DEV_TOKEN_TYPE must be one of [GFT,SRF], but was $DEV_TOKEN_TYPE +if [[ $CIC_DEFAULT_TOKEN_SYMBOL != 'GFT' && $CIC_DEFAULT_TOKEN_SYMBOL != 'SRF' ]]; then + >&2 echo CIC_DEFAULT_TOKEN_SYMBOL must be one of [GFT,SRF], but was $CIC_DEFAULT_TOKEN_SYMBOL exit 1 fi @@ -60,7 +60,7 @@ if [[ -n "${ETH_PROVIDER}" ]]; then ./wait-for-it.sh "${ETH_PROVIDER_HOST}:${ETH_PROVIDER_PORT}" fi - if [ $DEV_TOKEN_TYPE == 'GFT' ]; then + if [ $CIC_DEFAULT_TOKEN_SYMBOL == 'GFT' ]; then >&2 echo "deploying 'giftable token'" DEV_RESERVE_ADDRESS=`giftable-token-deploy $gas_price_arg -p $ETH_PROVIDER -y $DEV_ETH_KEYSTORE_FILE -i $CIC_CHAIN_SPEC -vv -w --name "Giftable Token" --symbol "GFT" --decimals 6 -vv` else diff --git a/apps/contract-migration/seed_cic_eth.sh b/apps/contract-migration/seed_cic_eth.sh index 5df672ad..01dd93af 100755 --- a/apps/contract-migration/seed_cic_eth.sh +++ b/apps/contract-migration/seed_cic_eth.sh @@ -33,11 +33,11 @@ set -a # get required addresses from registries DEV_TOKEN_INDEX_ADDRESS=`eth-contract-registry-list -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -r $CIC_REGISTRY_ADDRESS -f brief TokenRegistry` DEV_ACCOUNT_INDEX_ADDRESS=`eth-contract-registry-list -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -r $CIC_REGISTRY_ADDRESS -f brief AccountRegistry` -DEV_RESERVE_ADDRESS=`eth-token-index-list -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -a $DEV_TOKEN_INDEX_ADDRESS -f brief $DEV_TOKEN_TYPE` +DEV_RESERVE_ADDRESS=`eth-token-index-list -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -a $DEV_TOKEN_INDEX_ADDRESS -f brief $CIC_DEFAULT_TOKEN_SYMBOL` cat <&2 echo "create account for gas gifter" diff --git a/docker-compose.yml b/docker-compose.yml index 71681073..26681d8f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -104,7 +104,7 @@ services: DEV_PIP_EXTRA_INDEX_URL: ${DEV_PIP_EXTRA_INDEX_URL:-https://pip.grassrootseconomics.net:8433} RUN_MASK: ${RUN_MASK:-0} # bit flags; 1: contract migrations 2: seed data DEV_FAUCET_AMOUNT: ${DEV_FAUCET_AMOUNT:-0} - DEV_TOKEN_TYPE: ${DEV_TOKEN_TYPE:-GFT} + CIC_DEFAULT_TOKEN_SYMBOL: ${CIC_DEFAULT_TOKEN_SYMBOL:-GFT} DEV_SARAFU_DEMURRAGE_LEVEL: ${DEV_SARAFU_DEMURRAGE_LEVEL:-196454828847045000000000000000000} DEV_ETH_GAS_PRICE: ${DEV_ETH_GAS_PRICE:-1} command: ["./run_job.sh"] @@ -249,6 +249,7 @@ services: SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef} ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER: ${DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER:-0xACB0BC74E1686D62dE7DC6414C999EA60C09F0eA} TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1} + CIC_DEFAULT_TOKEN_SYMBOL: ${CIC_DEFAULT_TOKEN_SYMBOL:-GFT} depends_on: - eth - postgres