Merge branch 'cic-eth-server' of https://github.com/williamluke4/cic-internal-integration into cic-eth-server
This commit is contained in:
commit
c48177c78c
1
.envrc
1
.envrc
@ -5,3 +5,4 @@ export TOKEN_NAME=Coffee
|
|||||||
export TOKEN_SYMBOL=COFE
|
export TOKEN_SYMBOL=COFE
|
||||||
export TOKEN_DECIMALS=6
|
export TOKEN_DECIMALS=6
|
||||||
export FAUCET_AMOUNT=30000000000
|
export FAUCET_AMOUNT=30000000000
|
||||||
|
export DATABASE_DEBUG=1
|
||||||
|
@ -10,6 +10,7 @@ include:
|
|||||||
#- local: 'apps/data-seeding/.gitlab-ci.yml'
|
#- local: 'apps/data-seeding/.gitlab-ci.yml'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- version
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
- deploy
|
- deploy
|
||||||
@ -20,9 +21,39 @@ variables:
|
|||||||
DOCKER_BUILDKIT: "1"
|
DOCKER_BUILDKIT: "1"
|
||||||
COMPOSE_DOCKER_CLI_BUILD: "1"
|
COMPOSE_DOCKER_CLI_BUILD: "1"
|
||||||
CI_DEBUG_TRACE: "true"
|
CI_DEBUG_TRACE: "true"
|
||||||
|
SEMVERBOT_VERSION: "0.2.0"
|
||||||
|
|
||||||
before_script:
|
#before_script:
|
||||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
# - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||||
|
|
||||||
|
version:
|
||||||
|
#image: python:3.7-stretch
|
||||||
|
image: registry.gitlab.com/grassrootseconomics/cic-base-images/ci-version:b01318ae
|
||||||
|
stage: version
|
||||||
|
script:
|
||||||
|
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||||
|
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts && chmod 644 ~/.ssh/known_hosts
|
||||||
|
- eval $(ssh-agent -s)
|
||||||
|
- ssh-add <(echo "$SSH_PRIVATE_KEY")
|
||||||
|
- git remote set-url origin git@gitlab.com:grassrootseconomics/cic-internal-integration.git
|
||||||
|
- export TAG=$(sbot predict version -m auto)
|
||||||
|
- |
|
||||||
|
if [[ -z $TAG ]]
|
||||||
|
then
|
||||||
|
echo "tag could not be set $@"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- echo $TAG > version
|
||||||
|
- git tag -a v$TAG -m "ci tagged"
|
||||||
|
- git push origin v$TAG
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- version
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_REF_PROTECTED == "true"
|
||||||
|
when: always
|
||||||
|
- if: $CI_COMMIT_REF_NAME == "master"
|
||||||
|
when: always
|
||||||
|
|
||||||
# runs on protected branches and pushes to repo
|
# runs on protected branches and pushes to repo
|
||||||
build-push:
|
build-push:
|
||||||
@ -30,12 +61,17 @@ build-push:
|
|||||||
tags:
|
tags:
|
||||||
- integration
|
- integration
|
||||||
#script:
|
#script:
|
||||||
# - TAG=$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA sh ./scripts/build-push.sh
|
# - TAG=$CI_Cbefore_script:
|
||||||
|
before_script:
|
||||||
|
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- TAG=latest sh ./scripts/build-push.sh
|
- TAG=latest ./scripts/build-push.sh
|
||||||
|
- TAG=$(cat ./version) ./scripts/build-push.sh
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_REF_PROTECTED == "true"
|
- if: $CI_COMMIT_REF_PROTECTED == "true"
|
||||||
when: always
|
when: always
|
||||||
|
- if: $CI_COMMIT_REF_NAME == "master"
|
||||||
|
when: always
|
||||||
|
|
||||||
deploy-dev:
|
deploy-dev:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
|
16
.semverbot.toml
Normal file
16
.semverbot.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[git]
|
||||||
|
|
||||||
|
[git.config]
|
||||||
|
email = "semverbot@grassroots.org"
|
||||||
|
name = "semvervot"
|
||||||
|
|
||||||
|
[git.tags]
|
||||||
|
prefix = "v"
|
||||||
|
|
||||||
|
[semver]
|
||||||
|
mode = "git-commit"
|
||||||
|
|
||||||
|
[semver.detection]
|
||||||
|
patch = ["fix", "[fix]", "patch", "[patch]"]
|
||||||
|
minor = ["minor", "[minor]", "feat", "[feat]", "release", "[release]", "bump", "[bump]"]
|
||||||
|
major = ["BREAKING CHANGE"]
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
This repo uses docker-compose and docker buildkit. Set the following environment variables to get started:
|
This repo uses docker-compose and docker buildkit. Set the following environment variables to get started:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
export COMPOSE_DOCKER_CLI_BUILD=1
|
export COMPOSE_DOCKER_CLI_BUILD=1
|
||||||
export DOCKER_BUILDKIT=1
|
export DOCKER_BUILDKIT=1
|
||||||
|
@ -9,13 +9,13 @@ import logging
|
|||||||
# external imports
|
# external imports
|
||||||
import celery
|
import celery
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
from hexathon import strip_0x
|
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic_eth.api.base import ApiBase
|
from cic_eth.api.base import ApiBase
|
||||||
from cic_eth.enum import LockEnum
|
from cic_eth.enum import LockEnum
|
||||||
|
from hexathon import strip_0x
|
||||||
|
|
||||||
app = celery.current_app
|
app = celery.current_app
|
||||||
|
print(app.backend)
|
||||||
|
|
||||||
#logg = logging.getLogger(__name__)
|
#logg = logging.getLogger(__name__)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -430,13 +430,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 +448,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,
|
||||||
@ -489,9 +489,9 @@ class Api(ApiBase):
|
|||||||
s_balance_incoming.link(s_balance_outgoing)
|
s_balance_incoming.link(s_balance_outgoing)
|
||||||
last_in_chain = s_balance_outgoing
|
last_in_chain = s_balance_outgoing
|
||||||
|
|
||||||
one = celery.chain(s_tokens, s_balance)
|
one = s_tokens | s_balance
|
||||||
two = celery.chain(s_tokens, s_balance_incoming)
|
two = s_tokens | s_balance_incoming
|
||||||
three = celery.chain(s_tokens, s_balance_outgoing)
|
three = s_tokens | s_balance_outgoing
|
||||||
|
|
||||||
t = None
|
t = None
|
||||||
if self.callback_param != None:
|
if self.callback_param != None:
|
||||||
@ -501,7 +501,7 @@ class Api(ApiBase):
|
|||||||
t = celery.chord([one, two, three])(s_result)
|
t = celery.chord([one, two, three])(s_result)
|
||||||
else:
|
else:
|
||||||
# TODO: Chord is inefficient with only one chain, but assemble_balances must be able to handle different structures in order to avoid chord
|
# TODO: Chord is inefficient with only one chain, but assemble_balances must be able to handle different structures in order to avoid chord
|
||||||
one = celery.chain(s_tokens, s_balance)
|
one = s_tokens | s_balance
|
||||||
if self.callback_param != None:
|
if self.callback_param != None:
|
||||||
s_result.link(self.callback_success).on_error(self.callback_error)
|
s_result.link(self.callback_success).on_error(self.callback_error)
|
||||||
t = celery.chord([one])(s_result)
|
t = celery.chord([one])(s_result)
|
||||||
|
@ -382,6 +382,8 @@ def cache_transfer_data(
|
|||||||
sender_address = tx_normalize.wallet_address(tx['from'])
|
sender_address = tx_normalize.wallet_address(tx['from'])
|
||||||
recipient_address = tx_normalize.wallet_address(tx_data[0])
|
recipient_address = tx_normalize.wallet_address(tx_data[0])
|
||||||
token_value = tx_data[1]
|
token_value = tx_data[1]
|
||||||
|
source_token_address = tx_normalize.executable_address(tx['to'])
|
||||||
|
destination_token_address = source_token_address
|
||||||
|
|
||||||
|
|
||||||
session = SessionBase.create_session()
|
session = SessionBase.create_session()
|
||||||
@ -389,8 +391,8 @@ def cache_transfer_data(
|
|||||||
'hash': tx_hash_hex,
|
'hash': tx_hash_hex,
|
||||||
'from': sender_address,
|
'from': sender_address,
|
||||||
'to': recipient_address,
|
'to': recipient_address,
|
||||||
'source_token': tx['to'],
|
'source_token': source_token_address,
|
||||||
'destination_token': tx['to'],
|
'destination_token': destination_token_address,
|
||||||
'from_value': token_value,
|
'from_value': token_value,
|
||||||
'to_value': token_value,
|
'to_value': token_value,
|
||||||
}
|
}
|
||||||
@ -422,14 +424,16 @@ def cache_transfer_from_data(
|
|||||||
spender_address = tx_data[0]
|
spender_address = tx_data[0]
|
||||||
recipient_address = tx_data[1]
|
recipient_address = tx_data[1]
|
||||||
token_value = tx_data[2]
|
token_value = tx_data[2]
|
||||||
|
source_token_address = tx_normalize.executable_address(tx['to'])
|
||||||
|
destination_token_address = source_token_address
|
||||||
|
|
||||||
session = SessionBase.create_session()
|
session = SessionBase.create_session()
|
||||||
tx_dict = {
|
tx_dict = {
|
||||||
'hash': tx_hash_hex,
|
'hash': tx_hash_hex,
|
||||||
'from': tx['from'],
|
'from': tx['from'],
|
||||||
'to': recipient_address,
|
'to': recipient_address,
|
||||||
'source_token': tx['to'],
|
'source_token': source_token_address,
|
||||||
'destination_token': tx['to'],
|
'destination_token': destination_token_address,
|
||||||
'from_value': token_value,
|
'from_value': token_value,
|
||||||
'to_value': token_value,
|
'to_value': token_value,
|
||||||
}
|
}
|
||||||
@ -461,14 +465,16 @@ def cache_approve_data(
|
|||||||
sender_address = tx_normalize.wallet_address(tx['from'])
|
sender_address = tx_normalize.wallet_address(tx['from'])
|
||||||
recipient_address = tx_normalize.wallet_address(tx_data[0])
|
recipient_address = tx_normalize.wallet_address(tx_data[0])
|
||||||
token_value = tx_data[1]
|
token_value = tx_data[1]
|
||||||
|
source_token_address = tx_normalize.executable_address(tx['to'])
|
||||||
|
destination_token_address = source_token_address
|
||||||
|
|
||||||
session = SessionBase.create_session()
|
session = SessionBase.create_session()
|
||||||
tx_dict = {
|
tx_dict = {
|
||||||
'hash': tx_hash_hex,
|
'hash': tx_hash_hex,
|
||||||
'from': sender_address,
|
'from': sender_address,
|
||||||
'to': recipient_address,
|
'to': recipient_address,
|
||||||
'source_token': tx['to'],
|
'source_token': source_token_address,
|
||||||
'destination_token': tx['to'],
|
'destination_token': destination_token_address,
|
||||||
'from_value': token_value,
|
'from_value': token_value,
|
||||||
'to_value': token_value,
|
'to_value': token_value,
|
||||||
}
|
}
|
||||||
|
31
apps/cic-eth/cic_eth/graphql/app.py
Normal file
31
apps/cic-eth/cic_eth/graphql/app.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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)
|
10
apps/cic-eth/cic_eth/graphql/config.py
Normal file
10
apps/cic-eth/cic_eth/graphql/config.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
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)
|
||||||
|
|
88
apps/cic-eth/cic_eth/graphql/helpers.py
Normal file
88
apps/cic-eth/cic_eth/graphql/helpers.py
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
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)
|
@ -1,40 +1,26 @@
|
|||||||
# standard imports
|
# standard imports
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import cic_eth.cli
|
|
||||||
import redis
|
import redis
|
||||||
from cic_eth.api.api_task import Api
|
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,
|
from graphene import (Boolean, Field, Float, Int, List, Mutation, ObjectType,
|
||||||
Schema, String)
|
Schema, String)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
celery_app = cic_eth.cli.CeleryApp.from_config(config)
|
|
||||||
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')
|
||||||
redis_db = config.get('REDIS_DB')
|
redis_db = config.get('REDIS_DB')
|
||||||
celery_queue = config.get('CELERY_QUEUE')
|
celery_queue = config.get('CELERY_QUEUE')
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def init_api(redis_channel: str):
|
|
||||||
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,
|
|
||||||
)
|
|
||||||
return api
|
|
||||||
|
|
||||||
|
|
||||||
def call(method, *args):
|
def call(method, *args):
|
||||||
@ -43,10 +29,16 @@ 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)
|
|
||||||
print(args)
|
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)
|
getattr(api, method)(*args)
|
||||||
|
|
||||||
ps.get_message() # returns None !?
|
ps.get_message() # returns None !?
|
||||||
@ -57,6 +49,7 @@ def call(method, *args):
|
|||||||
'got no new address from cic-eth before timeout: {}\n'.format(e))
|
'got no new address from cic-eth before timeout: {}\n'.format(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
ps.unsubscribe()
|
ps.unsubscribe()
|
||||||
|
print(o)
|
||||||
m = json.loads(o['data'])
|
m = json.loads(o['data'])
|
||||||
return m["result"]
|
return m["result"]
|
||||||
|
|
||||||
@ -81,21 +74,34 @@ class TokenBalance(ObjectType):
|
|||||||
return str(int(parent.balance_network) + int(parent.balance_incoming) - int(parent.balance_outgoing))
|
return str(int(parent.balance_network) + int(parent.balance_incoming) - int(parent.balance_outgoing))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Query(ObjectType):
|
class Query(ObjectType):
|
||||||
default_token = Field(Token)
|
default_token = Field(Token)
|
||||||
|
|
||||||
def resolve_default_token(parent, info):
|
def resolve_default_token(parent, info):
|
||||||
|
|
||||||
# always pass an object for `me` field
|
# always pass an object for `me` field
|
||||||
data = call('default_token')
|
api = Api(
|
||||||
|
chain_spec,
|
||||||
|
queue=celery_queue,
|
||||||
|
)
|
||||||
|
task = api.default_token()
|
||||||
|
data = task.get()
|
||||||
print(data)
|
print(data)
|
||||||
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)
|
api = Api(
|
||||||
print(data)
|
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}]
|
#[{'address': '3ff776b6f888980def9d4220858803f9dc5e341e', 'converters': [], 'balance_network': 0}]
|
||||||
return map(lambda token: TokenBalance(
|
return map(lambda token: TokenBalance(
|
||||||
address=token.get("address"),
|
address=token.get("address"),
|
||||||
@ -110,7 +116,13 @@ class Query(ObjectType):
|
|||||||
required=True), limit=Int(default_value=10))
|
required=True), limit=Int(default_value=10))
|
||||||
|
|
||||||
def resolve_transactions(root, info, address, limit):
|
def resolve_transactions(root, info, address, limit):
|
||||||
data = call('list', address, limit)
|
|
||||||
|
api = Api(
|
||||||
|
chain_spec,
|
||||||
|
queue=celery_queue,
|
||||||
|
)
|
||||||
|
task = api.list(address=address, limit=limit)
|
||||||
|
data = task.get()
|
||||||
print(data)
|
print(data)
|
||||||
#[{'address': '3ff776b6f888980def9d4220858803f9dc5e341e', 'converters': [], 'balance_network': 0}]
|
#[{'address': '3ff776b6f888980def9d4220858803f9dc5e341e', 'converters': [], 'balance_network': 0}]
|
||||||
return "test"
|
return "test"
|
||||||
@ -125,8 +137,12 @@ class CreateAccount(Mutation):
|
|||||||
|
|
||||||
def mutate(root, info, password, register=True):
|
def mutate(root, info, password, register=True):
|
||||||
print(password, register)
|
print(password, register)
|
||||||
|
api = Api(
|
||||||
|
chain_spec,
|
||||||
|
queue=celery_queue,
|
||||||
|
)
|
||||||
|
|
||||||
address = call('create_account', password, register)
|
address = call('create_account',password, register)
|
||||||
return CreateAccount(address=f"0x{address}")
|
return CreateAccount(address=f"0x{address}")
|
||||||
|
|
||||||
|
|
||||||
@ -144,10 +160,10 @@ class Transfer(Mutation):
|
|||||||
value,
|
value,
|
||||||
token_symbol):
|
token_symbol):
|
||||||
print(from_address, to_address, value, token_symbol)
|
print(from_address, to_address, value, token_symbol)
|
||||||
|
api = Api(
|
||||||
redis_channel = str(uuid.uuid4())
|
chain_spec,
|
||||||
|
queue=celery_queue,
|
||||||
api = init_api(redis_channel)
|
)
|
||||||
t = api.transfer(from_address, to_address,
|
t = api.transfer(from_address, to_address,
|
||||||
int(value * (10**6)), token_symbol)
|
int(value * (10**6)), token_symbol)
|
||||||
print(f"t {t}")
|
print(f"t {t}")
|
||||||
@ -171,12 +187,15 @@ class TransferFrom(Mutation):
|
|||||||
to_address,
|
to_address,
|
||||||
value,
|
value,
|
||||||
token_symbol, spender_address):
|
token_symbol, spender_address):
|
||||||
|
api = Api(
|
||||||
data = call('transfer_from', from_address,
|
chain_spec,
|
||||||
to_address,
|
queue=celery_queue,
|
||||||
value,
|
)
|
||||||
token_symbol, spender_address)
|
task = api.transfer_from(from_address=from_address,
|
||||||
return data
|
to_address=to_address,
|
||||||
|
value=value,
|
||||||
|
token_symbol=token_symbol, spender_address=spender_address)
|
||||||
|
return task.get()
|
||||||
|
|
||||||
|
|
||||||
class MyMutations(ObjectType):
|
class MyMutations(ObjectType):
|
||||||
|
@ -72,7 +72,7 @@ def __balance_incoming_compatible(token_address, receiver_address):
|
|||||||
status_compare = dead()
|
status_compare = dead()
|
||||||
q = q.filter(Otx.status.op('&')(status_compare)==0)
|
q = q.filter(Otx.status.op('&')(status_compare)==0)
|
||||||
# TODO: this can change the result for the recipient if tx is later obsoleted and resubmission is delayed.
|
# TODO: this can change the result for the recipient if tx is later obsoleted and resubmission is delayed.
|
||||||
q = q.filter(Otx.status.op('&')(StatusBits.IN_NETWORK)==StatusBits.IN_NETWORK)
|
#q = q.filter(Otx.status.op('&')(StatusBits.IN_NETWORK)==StatusBits.IN_NETWORK)
|
||||||
q = q.filter(TxCache.destination_token_address==token_address)
|
q = q.filter(TxCache.destination_token_address==token_address)
|
||||||
delta = 0
|
delta = 0
|
||||||
for r in q.all():
|
for r in q.all():
|
||||||
|
@ -8,7 +8,6 @@ from urllib.parse import parse_qsl, urlparse
|
|||||||
|
|
||||||
import cic_eth.cli
|
import cic_eth.cli
|
||||||
import redis
|
import redis
|
||||||
from cic_eth.api.api_task import Api
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
@ -22,6 +21,7 @@ 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 = cic_eth.cli.CeleryApp.from_config(config)
|
||||||
|
from cic_eth.api.api_task import Api
|
||||||
|
|
||||||
# uwsgi application
|
# uwsgi application
|
||||||
|
|
||||||
|
@ -4,3 +4,5 @@ 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
|
||||||
graphene>=2.0
|
graphene>=2.0
|
||||||
|
flask>=2.0.2
|
||||||
|
Flask-GraphQL>=2.0.1
|
@ -193,6 +193,7 @@ async function processRequest(req, res) {
|
|||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
content = '';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'get:automerge:client':
|
case 'get:automerge:client':
|
||||||
@ -251,7 +252,7 @@ async function processRequest(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (content === undefined) {
|
if (content === undefined) {
|
||||||
console.error('empty content', data);
|
console.error('empty content', mod, digest, data);
|
||||||
res.writeHead(404, {"Content-Type": "text/plain"});
|
res.writeHead(404, {"Content-Type": "text/plain"});
|
||||||
res.end();
|
res.end();
|
||||||
return;
|
return;
|
||||||
|
@ -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,6 +39,7 @@ 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:
|
||||||
@ -85,6 +87,8 @@ 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/cic-internal-integration}/funga-eth:${TAG:-latest}
|
||||||
build:
|
build:
|
||||||
@ -147,8 +151,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:
|
|
||||||
- 8080:8000
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- evm
|
- evm
|
||||||
- postgres
|
- postgres
|
||||||
@ -166,6 +168,54 @@ services:
|
|||||||
set +a
|
set +a
|
||||||
./start_tasker.sh --aux-all -q cic-eth -vv
|
./start_tasker.sh --aux-all -q cic-eth -vv
|
||||||
|
|
||||||
|
cic-eth-server:
|
||||||
|
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics}/cic-eth:${TAG:-latest}
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
build:
|
||||||
|
context: apps/cic-eth
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
args:
|
||||||
|
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
|
||||||
|
environment:
|
||||||
|
CIC_REGISTRY_ADDRESS: $CIC_REGISTRY_ADDRESS
|
||||||
|
RPC_PROVIDER: ${RPC_PROVIDER:-http://evm:8545}
|
||||||
|
CHAIN_SPEC: ${CHAIN_SPEC:-evm:byzantium:8996:bloxberg}
|
||||||
|
DATABASE_HOST: ${DATABASE_HOST:-postgres}
|
||||||
|
DATABASE_PORT: ${DATABASE_PORT:-5432}
|
||||||
|
DATABASE_NAME: ${DATABASE_NAME:-cic_eth}
|
||||||
|
DATABASE_PASSWORD: ${DATABASE_PASSWORD:-tralala}
|
||||||
|
DATABASE_USER: ${DATABASE_USER:-grassroots}
|
||||||
|
DATABASE_ENGINE: ${DATABASE_ENGINE:-postgres}
|
||||||
|
DATABASE_DRIVER: ${DATABASE_DRIVER:-psycopg2}
|
||||||
|
DATABASE_DEBUG: ${DATABASE_DEBUG:-0}
|
||||||
|
DATABASE_POOL_SIZE: 0
|
||||||
|
REDIS_PORT: 6379
|
||||||
|
REDIS_HOST: redis
|
||||||
|
CELERY_BROKER_URL: ${CELERY_BROKER_URL:-redis://redis}
|
||||||
|
CELERY_RESULT_URL: ${CELERY_RESULT_URL:-redis://redis}
|
||||||
|
CELERY_DEBUG: ${CELERY_DEBUG:-1}
|
||||||
|
SIGNER_PROVIDER: ${SIGNER_PROVIDER:-http://cic-signer:8000}
|
||||||
|
SIGNER_SECRET: ${SIGNER_SECRET:-deadbeef}
|
||||||
|
TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1}
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
- cic-eth-tasker
|
||||||
|
volumes:
|
||||||
|
- signer-data:/run/crypto-dev-signer
|
||||||
|
- contract-config:/tmp/cic/config/:ro
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -a
|
||||||
|
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
|
||||||
|
set +a
|
||||||
|
python /root/cic_eth/graphql/app.py -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}
|
||||||
build:
|
build:
|
||||||
@ -213,6 +263,7 @@ 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-internal-integration}/cic-eth:${TAG:-latest}
|
||||||
build:
|
build:
|
||||||
@ -256,6 +307,7 @@ 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-internal-integration}/cic-eth:${TAG:-latest}
|
||||||
build:
|
build:
|
||||||
@ -301,6 +353,8 @@ 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-internal-integration}/cic-cache:${TAG:-latest}
|
||||||
build:
|
build:
|
||||||
@ -348,6 +402,7 @@ 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-internal-integration}/cic-cache:${TAG:-latest}
|
||||||
build:
|
build:
|
||||||
@ -390,10 +445,11 @@ 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-internal-integration}/cic-cache:${TAG:-latest}
|
||||||
@ -437,6 +493,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 +532,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 +568,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 +597,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 +635,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:
|
||||||
|
@ -6,4 +6,7 @@ set -e
|
|||||||
TAG=${TAG?Variable not set} \
|
TAG=${TAG?Variable not set} \
|
||||||
docker-compose \
|
docker-compose \
|
||||||
-f docker-compose.yml \
|
-f docker-compose.yml \
|
||||||
build
|
build \
|
||||||
|
--no-cache \
|
||||||
|
--parallel \
|
||||||
|
--progress plain
|
||||||
|
49
test.sh
Normal file
49
test.sh
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# 0000
|
||||||
|
# 0001
|
||||||
|
# 0010
|
||||||
|
# 0011
|
||||||
|
# 0100
|
||||||
|
# 0101
|
||||||
|
# 0111
|
||||||
|
# 1000
|
||||||
|
# 1001
|
||||||
|
# 1010
|
||||||
|
# 1011
|
||||||
|
# 1100
|
||||||
|
# 1101
|
||||||
|
# 1111
|
||||||
|
|
||||||
|
RUN_MASK=31
|
||||||
|
LAST_BIT_POS=5
|
||||||
|
|
||||||
|
RUN_MASK_HIGHEST=0
|
||||||
|
|
||||||
|
for ((i=$LAST_BIT_POS; i>0; i--)); do
|
||||||
|
b=$((2**$((i-1))))
|
||||||
|
if [ $((b & $RUN_MASK)) -gt 0 ]; then
|
||||||
|
RUN_MASK_HIGHEST=$i
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $RUN_MASK_HIGHEST
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bit=1
|
||||||
|
for ((i=0; i<$LAST_BIT_POS; i++)); do
|
||||||
|
runlevel="RUNLEVEL $bit"
|
||||||
|
if [[ $((RUN_MASK & $bit)) -eq ${bit} ]]; then
|
||||||
|
s="$runlevel - ${description[$i]}"
|
||||||
|
>&2 echo -e "\033[;96mRUNNING $s\033[;39m"
|
||||||
|
# source $((i+1))_${files[$i]}.sh
|
||||||
|
if [ $? -ne "0" ]; then
|
||||||
|
>&2 echo -e "\033[;31mFAILED $s\033[;39m"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
>&2 echo -e "\033[;32mSUCCEEDED $s\033[;39m"
|
||||||
|
>&2 echo -e "\033[;96mConfiguration state after $runlevel execution\033[;39m"
|
||||||
|
# confini-dump --schema-dir ./config
|
||||||
|
fi
|
||||||
|
bit=$((bit*2))
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user