Compare commits
82 Commits
bvander/in
...
lash/build
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6f89c5eda
|
||
|
|
6b59c87f68 | ||
|
|
9ee42b908d | ||
| 3343c4163e | |||
|
|
f5bfc8ace2 | ||
| 8a9d2ee0be | |||
| 3608fd1fc7 | |||
| 0d275f358b | |||
|
3aef2aa65f
|
|||
| 5644baefb2 | |||
|
1a7c4deab6
|
|||
| 0389d8623d | |||
|
cf64387d81
|
|||
| 79bcc8a9f1 | |||
| 7b57f1b4c2 | |||
| 76b8519637 | |||
| e89aec76fa | |||
| a138a0ec75 | |||
| 5128c7828c | |||
| 2f005195e5 | |||
| fb8db3ffd2 | |||
| b5f647c4aa | |||
| 6019143ba1 | |||
| 610440b722 | |||
|
|
d65455fc29 | ||
| 43f8d1c30c | |||
| b855211eed | |||
| 1e0c475f39 | |||
|
|
3e6cf594e3 | ||
| b8f79a2dd1 | |||
| 540c2fd950 | |||
| b9b06eced8 | |||
| 949bb29379 | |||
|
|
0468906601 | ||
|
|
471243488e
|
||
| 3c4acd82ff | |||
| e07f992c5a | |||
| 17e95cb19c | |||
| 3c3a97ce15 | |||
| a492be4927 | |||
|
|
1f555748b0 | ||
| 8aa4d20eea | |||
|
|
90cf24dcee | ||
|
|
75b711dbd5 | ||
| c21c1eb2ef | |||
| eb5e612105 | |||
| e017d11770 | |||
| e327af68e1 | |||
| 92cc6a3f27 | |||
| f42bf7754a | |||
|
|
7342927e91
|
||
| 17333af88f | |||
| 6a68d2ed32 | |||
|
|
ef77f4c99a | ||
|
|
56dbe8a502 | ||
|
|
2dc8ac6a12 | ||
|
|
0ced68e224 | ||
| 2afb20e715 | |||
| 3b0113d0e4 | |||
|
|
ebf4743a84 | ||
|
|
3bf92e7a8a | ||
| f0b4c42c68 | |||
|
|
b62d00180c | ||
|
|
a49978cc36 | ||
| 1b0ee269d0 | |||
| aa2f363b27 | |||
| 2a24ce6938 | |||
| 938a10b5c3 | |||
|
|
76e33e578b | ||
|
|
2ec4262734 | ||
|
|
7684fe3883 | ||
|
|
995a148c6a | ||
|
|
511e099689 | ||
|
|
f877218c55 | ||
| 8ac9a1e99a | |||
| c4cb095a29 | |||
| 05b8bbbbca | |||
| 1ce32fbbe0 | |||
| 3fd5e77e2c | |||
| e27a49ef33 | |||
|
|
fffb2bc3f4 | ||
|
|
8910fb0759 |
40
.env
40
.env
@@ -1,40 +0,0 @@
|
||||
DOMAIN=localhost
|
||||
|
||||
STACK_NAME=cic-net
|
||||
|
||||
TRAEFIK_PUBLIC_NETWORK=traefik-public
|
||||
TRAEFIK_TAG=cic.net
|
||||
TRAEFIK_PUBLIC_TAG=traefik-public
|
||||
|
||||
TAG=localhost
|
||||
FRONTEND_ENV=dev
|
||||
|
||||
# Flower
|
||||
FLOWER_BASIC_AUTH=admin:changethis
|
||||
|
||||
# Postgres
|
||||
DATABASE_HOST=postgres
|
||||
DATABASE_PORT=5432
|
||||
DATABASE_ENGINE=postgresql
|
||||
DATABASE_DRIVER=psycopg2
|
||||
|
||||
DATABASE_USER=postgres
|
||||
DATABASE_NAME=cic_eth
|
||||
|
||||
# Redis
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
REDIS_DB=0
|
||||
|
||||
# Celery Broker
|
||||
CELERY_BROKER_URL=redis://redis:6379
|
||||
CELERY_RESULT_URL=redis://redis:6379
|
||||
|
||||
# Blockchain node
|
||||
ETH_PROVIDER=http://eth:8545
|
||||
CIC_CHAIN_SPEC=evm:bloxberg:8996
|
||||
|
||||
# PgAdmin
|
||||
PGADMIN_LISTEN_PORT=5050
|
||||
PGADMIN_DEFAULT_EMAIL=admin@cic.net
|
||||
PGADMIN_DEFAULT_PASSWORD=changethis
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,4 +14,4 @@ build/
|
||||
**/.venv
|
||||
.idea
|
||||
**/.vim
|
||||
docker-stack.yml
|
||||
**/*secret.yaml
|
||||
|
||||
@@ -1,99 +1,43 @@
|
||||
include:
|
||||
# - local: 'ci_templates/.cic-template.yml'
|
||||
# - local: 'apps/contract-migration/.gitlab-ci.yml'
|
||||
#- local: 'ci_templates/.cic-template.yml' #kaniko build templates
|
||||
# these includes are app specific unit tests
|
||||
- local: 'apps/cic-eth/.gitlab-ci.yml'
|
||||
- local: 'apps/cic-ussd/.gitlab-ci.yml'
|
||||
- local: 'apps/cic-notify/.gitlab-ci.yml'
|
||||
- local: 'apps/cic-meta/.gitlab-ci.yml'
|
||||
- local: 'apps/cic-cache/.gitlab-ci.yml'
|
||||
# - local: 'apps/data-seeding/.gitlab-ci.yml'
|
||||
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/docker-with-compose:latest
|
||||
|
||||
#- local: 'apps/contract-migration/.gitlab-ci.yml'
|
||||
#- local: 'apps/data-seeding/.gitlab-ci.yml'
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/docker-with-compose:latest
|
||||
|
||||
variables:
|
||||
DOCKER_BUILDKIT: "1"
|
||||
COMPOSE_DOCKER_CLI_BUILD: "1"
|
||||
MR_IMAGE_TAG: mr-$CI_COMMIT_SHORT_SHA
|
||||
COMPOSE_DOCKER_CLI_BUILD: "1"
|
||||
CI_DEBUG_TRACE: "true"
|
||||
|
||||
# todo you can probably just build the single image w/o docker-compose
|
||||
build-merge-request:
|
||||
before_script:
|
||||
before_script:
|
||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||
|
||||
# runs on protected branches and pushes to repo
|
||||
build-push:
|
||||
stage: build
|
||||
tags:
|
||||
- integration
|
||||
variables:
|
||||
CI_DEBUG_TRACE: "true"
|
||||
#script:
|
||||
# - TAG=$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA sh ./scripts/build-push.sh
|
||||
script:
|
||||
- TAG=$MR_IMAGE_TAG FRONTEND_ENV=dev sh ./scripts/build-push.sh
|
||||
- TAG=latest sh ./scripts/build-push.sh
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
- if: $CI_COMMIT_REF_PROTECTED == "true"
|
||||
when: always
|
||||
|
||||
build-staging:
|
||||
before_script:
|
||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||
tags:
|
||||
- integration
|
||||
#- blocal
|
||||
variables:
|
||||
CI_DEBUG_TRACE: "true"
|
||||
stage: build
|
||||
script:
|
||||
- TAG=stag FRONTEND_ENV=staging sh ./scripts/build-push.sh
|
||||
only:
|
||||
- staging
|
||||
|
||||
deploy-staging:
|
||||
before_script:
|
||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||
- pip install docker-auto-labels
|
||||
tags:
|
||||
- integration
|
||||
deploy-dev:
|
||||
stage: deploy
|
||||
script:
|
||||
- >
|
||||
DOMAIN=stag.grassrootseconomics.net
|
||||
TRAEFIK_TAG=grassrootseconomics.net
|
||||
STACK_NAME=stag-cic-net
|
||||
TAG=stag
|
||||
sh ./scripts/deploy.sh
|
||||
environment:
|
||||
name: staging
|
||||
url: https://stag.grassrootseconomics.net
|
||||
only:
|
||||
- staging
|
||||
|
||||
#build-prod:
|
||||
# stage: build
|
||||
# script:
|
||||
# - TAG=prod FRONTEND_ENV=production sh ./scripts/build-push.sh
|
||||
# only:
|
||||
# - production
|
||||
# tags:
|
||||
# - build
|
||||
# - test
|
||||
#
|
||||
#deploy-prod:
|
||||
# stage: deploy
|
||||
# script:
|
||||
# - >
|
||||
# DOMAIN=demo1.com
|
||||
# TRAEFIK_TAG=demo1.com
|
||||
# STACK_NAME=demo1-com
|
||||
# TAG=prod
|
||||
# sh ./scripts/deploy.sh
|
||||
# environment:
|
||||
# name: production
|
||||
# url: https://demo1.com
|
||||
# only:
|
||||
# - production
|
||||
# tags:
|
||||
# - swarm
|
||||
# - prod
|
||||
trigger: grassrootseconomics/devops
|
||||
when: manual
|
||||
|
||||
104
README.md
104
README.md
@@ -1,104 +1,40 @@
|
||||
# cic-internal-integration
|
||||
|
||||
## Backend Requirements
|
||||
## Getting started
|
||||
|
||||
* [Docker](https://www.docker.com/).
|
||||
* [Docker Compose](https://docs.docker.com/compose/install/).
|
||||
This repo uses docker-compose and docker buildkit. Set the following environment variables to get started:
|
||||
|
||||
## Backend local development
|
||||
```
|
||||
export COMPOSE_DOCKER_CLI_BUILD=1
|
||||
export DOCKER_BUILDKIT=1
|
||||
```
|
||||
|
||||
* Start the stack with Docker Compose:
|
||||
|
||||
```bash
|
||||
start services, database, redis and local ethereum node
|
||||
```
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
* Now you can open your browser and interact with these URLs:
|
||||
|
||||
Frontend (CICADA), built with Docker, with routes handled based on the path: http://localhost
|
||||
|
||||
PGAdmin, PostgreSQL web administration: http://localhost:5050
|
||||
|
||||
Flower, administration of Celery tasks: http://localhost:5555
|
||||
|
||||
Traefik UI, to see how the routes are being handled by the proxy: http://localhost:8090
|
||||
|
||||
**Note**: The first time you start your stack, it might take a minute for it to be ready. While the backend waits for the database to be ready and configures everything. You can check the logs to monitor it.
|
||||
|
||||
To check the logs, run:
|
||||
|
||||
```bash
|
||||
docker-compose logs
|
||||
Run app/contract-migration to deploy contracts
|
||||
```
|
||||
RUN_MASK=3 docker-compose up contract-migration
|
||||
```
|
||||
|
||||
To check the logs of a specific service, add the name of the service, e.g.:
|
||||
|
||||
```bash
|
||||
docker-compose logs backend
|
||||
stop cluster
|
||||
```
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
If your Docker is not running in `localhost` (the URLs above wouldn't work) check the sections below on **Development with Docker Toolbox** and **Development with a custom IP**.
|
||||
|
||||
#### Deploy the stack locally
|
||||
|
||||
If you want to run the docker stack locally on swarm
|
||||
|
||||
stop cluster and delete data
|
||||
```
|
||||
docker-compose -f docker-compose.yml -f docker-compose.override.yml config > docker-stack.yml
|
||||
docker-compose down -v --remove-orphans
|
||||
```
|
||||
|
||||
rebuild an images
|
||||
```
|
||||
docker node update z1ehkrw1mvqlxc2udwt4xpype --label-add cic-net.app-db-data=true
|
||||
docker stack deploy -c docker-stack.yml cic-net
|
||||
docker-compose up --build <service_name>
|
||||
```
|
||||
|
||||
|
||||
## Backend local development, additional details
|
||||
|
||||
**fill me in**
|
||||
|
||||
### Docker Compose Override
|
||||
|
||||
During development, you can change Docker Compose settings that will only affect the local development environment, in the file `docker-compose.override.yml`.
|
||||
|
||||
The changes to that file only affect the local development environment, not the production environment. So, you can add "temporary" changes that help the development workflow.
|
||||
|
||||
For example, the directory with the backend code is mounted as a Docker "host volume", mapping the code you change live to the directory inside the container. That allows you to test your changes right away, without having to build the Docker image again. It should only be done during development, for production, you should build the Docker image with a recent version of the backend code. But during development, it allows you to iterate very fast.
|
||||
|
||||
There is also a command override that runs `/start-reload.sh` (included in the base image) instead of the default `/start.sh` (also included in the base image). It starts a single server process (instead of multiple, as would be for production) and reloads the process whenever the code changes. Have in mind that if you have a syntax error and save the Python file, it will break and exit, and the container will stop. After that, you can restart the container by fixing the error and running again:
|
||||
|
||||
```console
|
||||
$ docker-compose up -d
|
||||
to delete the buildkit cache
|
||||
```
|
||||
|
||||
There is also a commented out `command` override, you can uncomment it and comment the default one. It makes the backend container run a process that does "nothing", but keeps the container alive. That allows you to get inside your running container and execute commands inside, for example a Python interpreter to test installed dependencies, or start the development server that reloads when it detects changes, or start a Jupyter Notebook session.
|
||||
|
||||
To get inside the container with a `bash` session you can start the stack with:
|
||||
|
||||
```console
|
||||
$ docker-compose up -d
|
||||
docker builder prune --filter type=exec.cachemount
|
||||
```
|
||||
|
||||
and then `exec` inside the running container:
|
||||
|
||||
```console
|
||||
$ docker-compose exec backend bash
|
||||
```
|
||||
|
||||
You should see an output like:
|
||||
|
||||
```console
|
||||
root@7f2607af31c3:/app#
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Test running stack
|
||||
|
||||
If your stack is already up and you just want to run the tests, you can use:
|
||||
|
||||
```bash
|
||||
docker-compose exec data-seeding /script/run_ussd_user_imports.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
.git
|
||||
.cache
|
||||
.dot
|
||||
**/doc
|
||||
**/node_modules/
|
||||
**/doc
|
||||
@@ -1,41 +1,17 @@
|
||||
.cic_cache_variables:
|
||||
variables:
|
||||
APP_NAME: cic-cache
|
||||
|
||||
#build-mr-cic-cache:
|
||||
# extends:
|
||||
# - .py_build_merge_request
|
||||
# - .cic_cache_variables
|
||||
# rules:
|
||||
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
# changes:
|
||||
# - apps/cic-cache/**/*
|
||||
# when: always
|
||||
|
||||
test-mr-cic-cache:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
extends:
|
||||
- .cic_cache_variables
|
||||
cache:
|
||||
key:
|
||||
files:
|
||||
- test_requirements.txt
|
||||
paths:
|
||||
- /root/.cache/pip
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/$APP_NAME:$MR_IMAGE_TAG
|
||||
script:
|
||||
- cd apps/$APP_NAME/
|
||||
- >
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
|
||||
-r test_requirements.txt
|
||||
- export PYTHONPATH=. && pytest -x --cov=cic_cache --cov-fail-under=90 --cov-report term-missing tests
|
||||
allow_failure: true
|
||||
needs: ["build-merge-request"]
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- apps/$APP_NAME/**/*
|
||||
when: always
|
||||
build-test-cic-cache:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
variables:
|
||||
APP_NAME: cic-cache
|
||||
MR_IMAGE_TAG: mr-$APP_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
|
||||
script:
|
||||
- cd apps/cic-cache
|
||||
- docker build -t $MR_IMAGE_TAG -f docker/Dockerfile .
|
||||
- docker run $MR_IMAGE_TAG sh docker/run_tests.sh
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- apps/$APP_NAME/**/*
|
||||
when: always
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# CIC-CACHE
|
||||
|
||||
@@ -27,11 +27,11 @@ class RPC:
|
||||
@staticmethod
|
||||
def from_config(config):
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
RPCConnection.register_location(config.get('RPC_HTTP_PROVIDER'), chain_spec, 'default')
|
||||
RPCConnection.register_location(config.get('RPC_PROVIDER'), chain_spec, 'default')
|
||||
if config.get('SIGNER_PROVIDER'):
|
||||
RPCConnection.register_constructor(ConnType.UNIX, EthUnixSignerConnection, tag='signer')
|
||||
RPCConnection.register_location(config.get('SIGNER_PROVIDER'), chain_spec, 'signer')
|
||||
rpc = RPC(chain_spec, config.get('RPC_HTTP_PROVIDER'), signer_provider=config.get('SIGNER_PROVIDER'))
|
||||
rpc = RPC(chain_spec, config.get('RPC_PROVIDER'), signer_provider=config.get('SIGNER_PROVIDER'))
|
||||
logg.info('set up rpc: {}'.format(rpc))
|
||||
return rpc
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ version = (
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
'alpha.1',
|
||||
'alpha.2',
|
||||
)
|
||||
|
||||
version_object = semver.VersionInfo(
|
||||
|
||||
@@ -10,9 +10,10 @@ COPY requirements.txt .
|
||||
|
||||
ARG EXTRA_INDEX_URL="https://pip.grassrootseconomics.net:8433"
|
||||
ARG GITLAB_PYTHON_REGISTRY="https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple"
|
||||
ARG EXTRA_PIP_ARGS=""
|
||||
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
|
||||
pip install --index-url https://pypi.org/simple \
|
||||
--extra-index-url $GITLAB_PYTHON_REGISTRY --extra-index-url $EXTRA_INDEX_URL \
|
||||
--extra-index-url $GITLAB_PYTHON_REGISTRY --extra-index-url $EXTRA_INDEX_URL $EXTRA_PIP_ARGS \
|
||||
-r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
10
apps/cic-cache/docker/run_tests.sh
Normal file
10
apps/cic-cache/docker/run_tests.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433 \
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple \
|
||||
-r test_requirements.txt
|
||||
|
||||
export PYTHONPATH=. && pytest -x --cov=cic_cache --cov-fail-under=90 --cov-report term-missing tests
|
||||
|
||||
@@ -2,16 +2,13 @@ alembic==1.4.2
|
||||
confini>=0.3.6rc4,<0.5.0
|
||||
uwsgi==2.0.19.1
|
||||
moolb~=0.1.1b2
|
||||
cic-eth-registry~=0.5.8a1
|
||||
cic-eth-registry~=0.6.1a1
|
||||
SQLAlchemy==1.3.20
|
||||
semver==2.13.0
|
||||
psycopg2==2.8.6
|
||||
celery==4.4.7
|
||||
redis==3.5.3
|
||||
chainsyncer[sql]>=0.0.6a1,<0.1.0
|
||||
erc20-faucet>=0.2.4a2, <0.3.0
|
||||
#chainlib-eth==0.0.7a5,<0.1.0
|
||||
chainlib-eth==0.0.7a5
|
||||
#chainlib==0.0.7a4,<0.1.0
|
||||
chainlib==0.0.7a4
|
||||
eth-address-index>=0.1.4a1,<0.2.0
|
||||
chainsyncer[sql]>=0.0.6a3,<0.1.0
|
||||
erc20-faucet>=0.3.2a2, <0.4.0
|
||||
chainlib-eth>=0.0.9a14,<0.1.0
|
||||
eth-address-index>=0.2.3a4,<0.3.0
|
||||
|
||||
@@ -6,5 +6,5 @@ sqlparse==0.4.1
|
||||
pytest-celery==0.0.0a1
|
||||
eth_tester==0.5.0b3
|
||||
py-evm==0.3.0a20
|
||||
sarafu-faucet~=0.0.5a2
|
||||
erc20-transfer-authorization>=0.3.4a1,<0.4.0
|
||||
sarafu-faucet~=0.0.7a1
|
||||
erc20-transfer-authorization>=0.3.5a1,<0.4.0
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
celery==4.4.7
|
||||
erc20-demurrage-token~=0.0.3a1
|
||||
cic-eth-registry~=0.5.8a1
|
||||
chainlib~=0.0.7a1
|
||||
cic_eth~=0.12.2a4
|
||||
cic-eth-registry>=0.6.1a2,<0.7.0
|
||||
cic-eth[services]~=0.12.4a8
|
||||
|
||||
@@ -1,53 +1,16 @@
|
||||
.cic_eth_variables:
|
||||
variables:
|
||||
APP_NAME: cic-eth
|
||||
|
||||
#build-mr-cic-eth:
|
||||
# extends:
|
||||
# - .cic_eth_variables
|
||||
# - .py_build_target_dev
|
||||
# rules:
|
||||
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
# changes:
|
||||
# - apps/cic-eth/**/*
|
||||
# when: always
|
||||
|
||||
test-mr-cic-eth:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
extends:
|
||||
- .cic_eth_variables
|
||||
cache:
|
||||
key:
|
||||
files:
|
||||
- test_requirements.txt
|
||||
paths:
|
||||
- /root/.cache/pip
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/$APP_NAME:$MR_IMAGE_TAG
|
||||
script:
|
||||
- cd apps/$APP_NAME/
|
||||
- >
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
|
||||
-r admin_requirements.txt
|
||||
-r services_requirements.txt
|
||||
-r test_requirements.txt
|
||||
- export PYTHONPATH=. && pytest -x --cov=cic_eth --cov-fail-under=90 --cov-report term-missing tests
|
||||
allow_failure: true
|
||||
needs: ["build-merge-request"]
|
||||
rules:
|
||||
build-test-cic-eth:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
variables:
|
||||
APP_NAME: cic-eth
|
||||
MR_IMAGE_TAG: mr-$APP_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
|
||||
script:
|
||||
- cd apps/cic-eth
|
||||
- docker build -t $MR_IMAGE_TAG -f docker/Dockerfile .
|
||||
- docker run $MR_IMAGE_TAG sh docker/run_tests.sh
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- apps/$APP_NAME/**/*
|
||||
when: always
|
||||
|
||||
#build-push-cic-eth:
|
||||
# extends:
|
||||
# - .py_build_push
|
||||
# - .cic_eth_variables
|
||||
# rules:
|
||||
# - if: $CI_COMMIT_BRANCH == "master"
|
||||
# changes:
|
||||
# - apps/cic-eth/**/*
|
||||
# when: always
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SQLAlchemy==1.3.20
|
||||
cic-eth-registry>=0.5.6a2,<0.6.0
|
||||
hexathon~=0.0.1a7
|
||||
chainqueue>=0.0.3a1,<0.1.0
|
||||
eth-erc20>=0.0.10a3,<0.1.0
|
||||
cic-eth-registry>=0.6.1a3,<0.7.0
|
||||
hexathon~=0.0.1a8
|
||||
chainqueue>=0.0.4a6,<0.1.0
|
||||
eth-erc20>=0.1.2a2,<0.2.0
|
||||
|
||||
@@ -4,7 +4,6 @@ import logging
|
||||
|
||||
# external imports
|
||||
import celery
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainlib.chain import ChainSpec
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
@@ -20,18 +19,17 @@ from cic_eth.task import (
|
||||
CriticalSQLAlchemyTask,
|
||||
)
|
||||
from cic_eth.error import LockedError
|
||||
from cic_eth.encode import (
|
||||
tx_normalize,
|
||||
ZERO_ADDRESS_NORMAL,
|
||||
)
|
||||
|
||||
celery_app = celery.current_app
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
def normalize_address(a):
|
||||
if a == None:
|
||||
return None
|
||||
return add_0x(hex_uniform(strip_0x(a)))
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def lock(chained_input, chain_spec_dict, address=ZERO_ADDRESS, flags=LockEnum.ALL, tx_hash=None):
|
||||
def lock(chained_input, chain_spec_dict, address=ZERO_ADDRESS_NORMAL, flags=LockEnum.ALL, tx_hash=None):
|
||||
"""Task wrapper to set arbitrary locks
|
||||
|
||||
:param chain_str: Chain spec string representation
|
||||
@@ -43,7 +41,7 @@ def lock(chained_input, chain_spec_dict, address=ZERO_ADDRESS, flags=LockEnum.AL
|
||||
:returns: New lock state for address
|
||||
:rtype: number
|
||||
"""
|
||||
address = normalize_address(address)
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_str = '::'
|
||||
if chain_spec_dict != None:
|
||||
chain_str = str(ChainSpec.from_dict(chain_spec_dict))
|
||||
@@ -53,7 +51,7 @@ def lock(chained_input, chain_spec_dict, address=ZERO_ADDRESS, flags=LockEnum.AL
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def unlock(chained_input, chain_spec_dict, address=ZERO_ADDRESS, flags=LockEnum.ALL):
|
||||
def unlock(chained_input, chain_spec_dict, address=ZERO_ADDRESS_NORMAL, flags=LockEnum.ALL):
|
||||
"""Task wrapper to reset arbitrary locks
|
||||
|
||||
:param chain_str: Chain spec string representation
|
||||
@@ -65,7 +63,7 @@ def unlock(chained_input, chain_spec_dict, address=ZERO_ADDRESS, flags=LockEnum.
|
||||
:returns: New lock state for address
|
||||
:rtype: number
|
||||
"""
|
||||
address = normalize_address(address)
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_str = '::'
|
||||
if chain_spec_dict != None:
|
||||
chain_str = str(ChainSpec.from_dict(chain_spec_dict))
|
||||
@@ -75,7 +73,7 @@ def unlock(chained_input, chain_spec_dict, address=ZERO_ADDRESS, flags=LockEnum.
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def lock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS, tx_hash=None):
|
||||
def lock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS_NORMAL, tx_hash=None):
|
||||
"""Task wrapper to set send lock
|
||||
|
||||
:param chain_str: Chain spec string representation
|
||||
@@ -85,7 +83,7 @@ def lock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS, tx_hash=None
|
||||
:returns: New lock state for address
|
||||
:rtype: number
|
||||
"""
|
||||
address = normalize_address(address)
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_str = str(ChainSpec.from_dict(chain_spec_dict))
|
||||
r = Lock.set(chain_str, LockEnum.SEND, address=address, tx_hash=tx_hash)
|
||||
logg.debug('Send locked for {}, flag now {}'.format(address, r))
|
||||
@@ -93,7 +91,7 @@ def lock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS, tx_hash=None
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def unlock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS):
|
||||
def unlock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS_NORMAL):
|
||||
"""Task wrapper to reset send lock
|
||||
|
||||
:param chain_str: Chain spec string representation
|
||||
@@ -103,7 +101,7 @@ def unlock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS):
|
||||
:returns: New lock state for address
|
||||
:rtype: number
|
||||
"""
|
||||
address = normalize_address(address)
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_str = str(ChainSpec.from_dict(chain_spec_dict))
|
||||
r = Lock.reset(chain_str, LockEnum.SEND, address=address)
|
||||
logg.debug('Send unlocked for {}, flag now {}'.format(address, r))
|
||||
@@ -111,7 +109,7 @@ def unlock_send(chained_input, chain_spec_dict, address=ZERO_ADDRESS):
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def lock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS, tx_hash=None):
|
||||
def lock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS_NORMAL, tx_hash=None):
|
||||
"""Task wrapper to set queue direct lock
|
||||
|
||||
:param chain_str: Chain spec string representation
|
||||
@@ -121,7 +119,7 @@ def lock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS, tx_hash=Non
|
||||
:returns: New lock state for address
|
||||
:rtype: number
|
||||
"""
|
||||
address = normalize_address(address)
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_str = str(ChainSpec.from_dict(chain_spec_dict))
|
||||
r = Lock.set(chain_str, LockEnum.QUEUE, address=address, tx_hash=tx_hash)
|
||||
logg.debug('Queue direct locked for {}, flag now {}'.format(address, r))
|
||||
@@ -129,7 +127,7 @@ def lock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS, tx_hash=Non
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def unlock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS):
|
||||
def unlock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS_NORMAL):
|
||||
"""Task wrapper to reset queue direct lock
|
||||
|
||||
:param chain_str: Chain spec string representation
|
||||
@@ -139,7 +137,7 @@ def unlock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS):
|
||||
:returns: New lock state for address
|
||||
:rtype: number
|
||||
"""
|
||||
address = normalize_address(address)
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_str = str(ChainSpec.from_dict(chain_spec_dict))
|
||||
r = Lock.reset(chain_str, LockEnum.QUEUE, address=address)
|
||||
logg.debug('Queue direct unlocked for {}, flag now {}'.format(address, r))
|
||||
@@ -148,12 +146,13 @@ def unlock_queue(chained_input, chain_spec_dict, address=ZERO_ADDRESS):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def check_lock(chained_input, chain_spec_dict, lock_flags, address=None):
|
||||
address = normalize_address(address)
|
||||
if address != None:
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_str = '::'
|
||||
if chain_spec_dict != None:
|
||||
chain_str = str(ChainSpec.from_dict(chain_spec_dict))
|
||||
session = SessionBase.create_session()
|
||||
r = Lock.check(chain_str, lock_flags, address=ZERO_ADDRESS, session=session)
|
||||
r = Lock.check(chain_str, lock_flags, address=ZERO_ADDRESS_NORMAL, session=session)
|
||||
if address != None:
|
||||
r |= Lock.check(chain_str, lock_flags, address=address, session=session)
|
||||
if r > 0:
|
||||
|
||||
@@ -33,6 +33,7 @@ from cic_eth.admin.ctrl import (
|
||||
from cic_eth.queue.tx import queue_create
|
||||
from cic_eth.eth.gas import create_check_gas_task
|
||||
from cic_eth.task import BaseTask
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
logg = logging.getLogger()
|
||||
@@ -73,7 +74,7 @@ def shift_nonce(self, chainspec_dict, tx_hash_orig_hex, delta=1):
|
||||
|
||||
set_cancel(chain_spec, strip_0x(tx['hash']), manual=True, session=session)
|
||||
|
||||
query_address = add_0x(hex_uniform(strip_0x(address))) # aaaaargh
|
||||
query_address = tx_normalize.wallet_address(address)
|
||||
q = session.query(Otx)
|
||||
q = q.join(TxCache)
|
||||
q = q.filter(TxCache.sender==query_address)
|
||||
|
||||
@@ -32,7 +32,6 @@ from chainqueue.db.enum import (
|
||||
status_str,
|
||||
)
|
||||
from chainqueue.error import TxStateChangeError
|
||||
from chainqueue.sql.query import get_tx
|
||||
from eth_erc20 import ERC20
|
||||
|
||||
# local imports
|
||||
@@ -40,6 +39,7 @@ from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.db.models.role import AccountRole
|
||||
from cic_eth.db.models.nonce import Nonce
|
||||
from cic_eth.error import InitializationError
|
||||
from cic_eth.queue.query import get_tx_local
|
||||
|
||||
app = celery.current_app
|
||||
|
||||
@@ -284,7 +284,7 @@ class AdminApi:
|
||||
tx_hash_hex = None
|
||||
session = SessionBase.create_session()
|
||||
for k in txs.keys():
|
||||
tx_dict = get_tx(chain_spec, k, session=session)
|
||||
tx_dict = get_tx_local(chain_spec, k, session=session)
|
||||
if tx_dict['nonce'] == nonce:
|
||||
tx_hash_hex = k
|
||||
session.close()
|
||||
|
||||
@@ -9,6 +9,7 @@ import logging
|
||||
# external imports
|
||||
import celery
|
||||
from chainlib.chain import ChainSpec
|
||||
from hexathon import strip_0x
|
||||
|
||||
# local imports
|
||||
from cic_eth.api.base import ApiBase
|
||||
@@ -254,6 +255,8 @@ class Api(ApiBase):
|
||||
:returns: uuid of root task
|
||||
:rtype: celery.Task
|
||||
"""
|
||||
#from_address = strip_0x(from_address)
|
||||
#to_address = strip_0x(to_address)
|
||||
s_check = celery.signature(
|
||||
'cic_eth.admin.ctrl.check_lock',
|
||||
[
|
||||
|
||||
@@ -35,14 +35,14 @@ class RPC:
|
||||
def from_config(config, use_signer=False, default_label='default', signer_label='signer'):
|
||||
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
||||
|
||||
RPCConnection.register_location(config.get('RPC_HTTP_PROVIDER'), chain_spec, default_label)
|
||||
RPCConnection.register_location(config.get('RPC_PROVIDER'), chain_spec, default_label)
|
||||
if use_signer:
|
||||
|
||||
RPCConnection.register_constructor(ConnType.UNIX, EthUnixSignerConnection, signer_label)
|
||||
RPCConnection.register_constructor(ConnType.HTTP, EthHTTPSignerConnection, signer_label)
|
||||
RPCConnection.register_constructor(ConnType.HTTP_SSL, EthHTTPSignerConnection, signer_label)
|
||||
RPCConnection.register_location(config.get('SIGNER_PROVIDER'), chain_spec, signer_label)
|
||||
rpc = RPC(chain_spec, config.get('RPC_HTTP_PROVIDER'), signer_provider=config.get('SIGNER_PROVIDER'))
|
||||
rpc = RPC(chain_spec, config.get('RPC_PROVIDER'), signer_provider=config.get('SIGNER_PROVIDER'))
|
||||
logg.info('set up rpc: {}'.format(rpc))
|
||||
return rpc
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ Create Date: 2021-04-02 18:41:20.864265
|
||||
import datetime
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.encode import ZERO_ADDRESS_NORMAL
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@@ -30,7 +30,7 @@ def upgrade():
|
||||
sa.Column("otx_id", sa.Integer, sa.ForeignKey('otx.id'), nullable=True),
|
||||
)
|
||||
op.create_index('idx_chain_address', 'lock', ['blockchain', 'address'], unique=True)
|
||||
op.execute("INSERT INTO lock (address, date_created, blockchain, flags) VALUES('{}', '{}', '::', {})".format(ZERO_ADDRESS, datetime.datetime.utcnow(), LockEnum.INIT | LockEnum.SEND | LockEnum.QUEUE))
|
||||
op.execute("INSERT INTO lock (address, date_created, blockchain, flags) VALUES('{}', '{}', '::', {})".format(ZERO_ADDRESS_NORMAL, datetime.datetime.utcnow(), LockEnum.INIT | LockEnum.SEND | LockEnum.QUEUE))
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
||||
@@ -4,12 +4,12 @@ import logging
|
||||
|
||||
# third-party imports
|
||||
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainqueue.db.models.tx import TxCache
|
||||
from chainqueue.db.models.otx import Otx
|
||||
|
||||
# local imports
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.encode import ZERO_ADDRESS_NORMAL
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
@@ -37,7 +37,7 @@ class Lock(SessionBase):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def set(chain_str, flags, address=ZERO_ADDRESS, session=None, tx_hash=None):
|
||||
def set(chain_str, flags, address=ZERO_ADDRESS_NORMAL, session=None, tx_hash=None):
|
||||
"""Sets flags associated with the given address and chain.
|
||||
|
||||
If a flags entry does not exist it is created.
|
||||
@@ -90,7 +90,7 @@ class Lock(SessionBase):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def reset(chain_str, flags, address=ZERO_ADDRESS, session=None):
|
||||
def reset(chain_str, flags, address=ZERO_ADDRESS_NORMAL, session=None):
|
||||
"""Resets flags associated with the given address and chain.
|
||||
|
||||
If the resulting flags entry value is 0, the entry will be deleted.
|
||||
@@ -134,7 +134,7 @@ class Lock(SessionBase):
|
||||
|
||||
|
||||
@staticmethod
|
||||
def check(chain_str, flags, address=ZERO_ADDRESS, session=None):
|
||||
def check(chain_str, flags, address=ZERO_ADDRESS_NORMAL, session=None):
|
||||
"""Checks whether all given flags are set for given address and chain.
|
||||
|
||||
Does not validate the address against any other tables or components.
|
||||
|
||||
16
apps/cic-eth/cic_eth/encode.py
Normal file
16
apps/cic-eth/cic_eth/encode.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# external imports
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainqueue.encode import TxHexNormalizer
|
||||
from chainlib.eth.tx import unpack
|
||||
|
||||
tx_normalize = TxHexNormalizer()
|
||||
|
||||
ZERO_ADDRESS_NORMAL = tx_normalize.wallet_address(ZERO_ADDRESS)
|
||||
|
||||
|
||||
def unpack_normal(signed_tx_bytes, chain_spec):
|
||||
tx = unpack(signed_tx_bytes, chain_spec)
|
||||
tx['hash'] = tx_normalize.tx_hash(tx['hash'])
|
||||
tx['from'] = tx_normalize.wallet_address(tx['from'])
|
||||
tx['to'] = tx_normalize.wallet_address(tx['to'])
|
||||
return tx
|
||||
@@ -13,11 +13,8 @@ from chainlib.eth.sign import (
|
||||
new_account,
|
||||
sign_message,
|
||||
)
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
from chainlib.eth.tx import (
|
||||
TxFormat,
|
||||
unpack,
|
||||
)
|
||||
from chainlib.eth.address import to_checksum_address, is_address
|
||||
from chainlib.eth.tx import TxFormat
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.error import JSONRPCException
|
||||
from eth_accounts_index.registry import AccountRegistry
|
||||
@@ -34,6 +31,7 @@ from cic_eth.eth.gas import (
|
||||
from cic_eth.db.models.nonce import Nonce
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.db.models.role import AccountRole
|
||||
from cic_eth.encode import tx_normalize
|
||||
from cic_eth.error import (
|
||||
RoleMissingError,
|
||||
SignerError,
|
||||
@@ -49,6 +47,11 @@ from cic_eth.eth.nonce import (
|
||||
from cic_eth.queue.tx import (
|
||||
register_tx,
|
||||
)
|
||||
from cic_eth.encode import (
|
||||
unpack_normal,
|
||||
ZERO_ADDRESS_NORMAL,
|
||||
tx_normalize,
|
||||
)
|
||||
|
||||
logg = logging.getLogger()
|
||||
celery_app = celery.current_app
|
||||
@@ -83,7 +86,7 @@ def create(self, password, chain_spec_dict):
|
||||
# TODO: It seems infeasible that a can be None in any case, verify
|
||||
if a == None:
|
||||
raise SignerError('create account')
|
||||
|
||||
a = tx_normalize.wallet_address(a)
|
||||
logg.debug('created account {}'.format(a))
|
||||
|
||||
# Initialize nonce provider record for account
|
||||
@@ -174,6 +177,9 @@ def gift(self, account_address, chain_spec_dict):
|
||||
"""
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
|
||||
if is_address(account_address):
|
||||
account_address = tx_normalize.wallet_address(account_address)
|
||||
|
||||
logg.debug('gift account address {} to index'.format(account_address))
|
||||
queue = self.request.delivery_info.get('routing_key')
|
||||
|
||||
@@ -247,8 +253,9 @@ def have(self, account, chain_spec_dict):
|
||||
|
||||
@celery_app.task(bind=True, base=CriticalSQLAlchemyTask)
|
||||
def set_role(self, tag, address, chain_spec_dict):
|
||||
if not to_checksum_address(address):
|
||||
raise ValueError('invalid checksum address {}'.format(address))
|
||||
if not is_address(address):
|
||||
raise ValueError('invalid address {}'.format(address))
|
||||
address = tx_normalize.wallet_address(address)
|
||||
session = SessionBase.create_session()
|
||||
role = AccountRole.set(tag, address, session=session)
|
||||
session.add(role)
|
||||
@@ -295,17 +302,19 @@ def cache_gift_data(
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
|
||||
tx_signed_raw_bytes = bytes.fromhex(strip_0x(tx_signed_raw_hex))
|
||||
tx = unpack(tx_signed_raw_bytes, chain_spec)
|
||||
tx = unpack_normal(tx_signed_raw_bytes, chain_spec)
|
||||
tx_data = Faucet.parse_give_to_request(tx['data'])
|
||||
sender_address = tx_normalize.wallet_address(tx['from'])
|
||||
recipient_address = tx_normalize.wallet_address(tx['to'])
|
||||
|
||||
session = self.create_session()
|
||||
|
||||
tx_dict = {
|
||||
'hash': tx_hash_hex,
|
||||
'from': tx['from'],
|
||||
'to': tx['to'],
|
||||
'source_token': ZERO_ADDRESS,
|
||||
'destination_token': ZERO_ADDRESS,
|
||||
'hash': tx['hash'],
|
||||
'from': sender_address,
|
||||
'to': recipient_address,
|
||||
'source_token': ZERO_ADDRESS_NORMAL,
|
||||
'destination_token': ZERO_ADDRESS_NORMAL,
|
||||
'from_value': 0,
|
||||
'to_value': 0,
|
||||
}
|
||||
@@ -334,17 +343,19 @@ def cache_account_data(
|
||||
:rtype: tuple
|
||||
"""
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
tx_signed_raw_bytes = bytes.fromhex(tx_signed_raw_hex[2:])
|
||||
tx = unpack(tx_signed_raw_bytes, chain_spec)
|
||||
tx_signed_raw_bytes = bytes.fromhex(strip_0x(tx_signed_raw_hex))
|
||||
tx = unpack_normal(tx_signed_raw_bytes, chain_spec)
|
||||
tx_data = AccountsIndex.parse_add_request(tx['data'])
|
||||
sender_address = tx_normalize.wallet_address(tx['from'])
|
||||
recipient_address = tx_normalize.wallet_address(tx['to'])
|
||||
|
||||
session = SessionBase.create_session()
|
||||
tx_dict = {
|
||||
'hash': tx_hash_hex,
|
||||
'from': tx['from'],
|
||||
'to': tx['to'],
|
||||
'source_token': ZERO_ADDRESS,
|
||||
'destination_token': ZERO_ADDRESS,
|
||||
'hash': tx['hash'],
|
||||
'from': sender_address,
|
||||
'to': recipient_address,
|
||||
'source_token': ZERO_ADDRESS_NORMAL,
|
||||
'destination_token': ZERO_ADDRESS_NORMAL,
|
||||
'from_value': 0,
|
||||
'to_value': 0,
|
||||
}
|
||||
|
||||
@@ -12,7 +12,10 @@ from chainlib.eth.tx import (
|
||||
)
|
||||
from cic_eth_registry import CICRegistry
|
||||
from cic_eth_registry.erc20 import ERC20Token
|
||||
from hexathon import strip_0x
|
||||
from hexathon import (
|
||||
strip_0x,
|
||||
add_0x,
|
||||
)
|
||||
from chainqueue.error import NotLocalTxError
|
||||
from eth_erc20 import ERC20
|
||||
from chainqueue.sql.tx import cache_tx_dict
|
||||
@@ -38,6 +41,7 @@ from cic_eth.task import (
|
||||
CriticalSQLAlchemyAndSignerTask,
|
||||
)
|
||||
from cic_eth.eth.nonce import CustodialTaskNonceOracle
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
logg = logging.getLogger()
|
||||
@@ -62,7 +66,8 @@ def balance(tokens, holder_address, chain_spec_dict):
|
||||
|
||||
for t in tokens:
|
||||
address = t['address']
|
||||
token = ERC20Token(chain_spec, rpc, address)
|
||||
logg.debug('address {} {}'.format(address, holder_address))
|
||||
token = ERC20Token(chain_spec, rpc, add_0x(address))
|
||||
c = ERC20(chain_spec)
|
||||
o = c.balance_of(address, holder_address, sender_address=caller_address)
|
||||
r = rpc.do(o)
|
||||
@@ -371,13 +376,15 @@ def cache_transfer_data(
|
||||
tx = unpack(tx_signed_raw_bytes, chain_spec)
|
||||
|
||||
tx_data = ERC20.parse_transfer_request(tx['data'])
|
||||
recipient_address = tx_data[0]
|
||||
sender_address = tx_normalize.wallet_address(tx['from'])
|
||||
recipient_address = tx_normalize.wallet_address(tx_data[0])
|
||||
token_value = tx_data[1]
|
||||
|
||||
|
||||
session = SessionBase.create_session()
|
||||
tx_dict = {
|
||||
'hash': tx_hash_hex,
|
||||
'from': tx['from'],
|
||||
'from': sender_address,
|
||||
'to': recipient_address,
|
||||
'source_token': tx['to'],
|
||||
'destination_token': tx['to'],
|
||||
@@ -448,13 +455,14 @@ def cache_approve_data(
|
||||
tx = unpack(tx_signed_raw_bytes, chain_spec)
|
||||
|
||||
tx_data = ERC20.parse_approve_request(tx['data'])
|
||||
recipient_address = tx_data[0]
|
||||
sender_address = tx_normalize.wallet_address(tx['from'])
|
||||
recipient_address = tx_normalize.wallet_address(tx_data[0])
|
||||
token_value = tx_data[1]
|
||||
|
||||
session = SessionBase.create_session()
|
||||
tx_dict = {
|
||||
'hash': tx_hash_hex,
|
||||
'from': tx['from'],
|
||||
'from': sender_address,
|
||||
'to': recipient_address,
|
||||
'source_token': tx['to'],
|
||||
'destination_token': tx['to'],
|
||||
|
||||
@@ -3,10 +3,17 @@ import logging
|
||||
|
||||
# external imports
|
||||
import celery
|
||||
from hexathon import strip_0x
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from hexathon import (
|
||||
strip_0x,
|
||||
add_0x,
|
||||
)
|
||||
#from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.eth.address import is_checksum_address
|
||||
from chainlib.eth.address import (
|
||||
is_checksum_address,
|
||||
to_checksum_address,
|
||||
is_address
|
||||
)
|
||||
from chainlib.connection import RPCConnection
|
||||
from chainqueue.db.enum import StatusBits
|
||||
from chainqueue.sql.tx import cache_tx_dict
|
||||
@@ -21,7 +28,6 @@ from chainlib.eth.error import (
|
||||
from chainlib.eth.tx import (
|
||||
TxFactory,
|
||||
TxFormat,
|
||||
unpack,
|
||||
)
|
||||
from chainlib.eth.contract import (
|
||||
abi_decode_single,
|
||||
@@ -45,6 +51,7 @@ from cic_eth.eth.nonce import CustodialTaskNonceOracle
|
||||
from cic_eth.queue.tx import (
|
||||
queue_create,
|
||||
register_tx,
|
||||
unpack,
|
||||
)
|
||||
from cic_eth.queue.query import get_tx
|
||||
from cic_eth.task import (
|
||||
@@ -53,6 +60,11 @@ from cic_eth.task import (
|
||||
CriticalSQLAlchemyAndSignerTask,
|
||||
CriticalWeb3AndSignerTask,
|
||||
)
|
||||
from cic_eth.encode import (
|
||||
tx_normalize,
|
||||
ZERO_ADDRESS_NORMAL,
|
||||
unpack_normal,
|
||||
)
|
||||
|
||||
celery_app = celery.current_app
|
||||
logg = logging.getLogger()
|
||||
@@ -130,16 +142,16 @@ def cache_gas_data(
|
||||
"""
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
tx_signed_raw_bytes = bytes.fromhex(strip_0x(tx_signed_raw_hex))
|
||||
tx = unpack(tx_signed_raw_bytes, chain_spec)
|
||||
tx = unpack_normal(tx_signed_raw_bytes, chain_spec)
|
||||
|
||||
session = SessionBase.create_session()
|
||||
|
||||
tx_dict = {
|
||||
'hash': tx_hash_hex,
|
||||
'hash': tx['hash'],
|
||||
'from': tx['from'],
|
||||
'to': tx['to'],
|
||||
'source_token': ZERO_ADDRESS,
|
||||
'destination_token': ZERO_ADDRESS,
|
||||
'source_token': ZERO_ADDRESS_NORMAL,
|
||||
'destination_token': ZERO_ADDRESS_NORMAL,
|
||||
'from_value': tx['value'],
|
||||
'to_value': tx['value'],
|
||||
}
|
||||
@@ -150,7 +162,7 @@ def cache_gas_data(
|
||||
|
||||
|
||||
@celery_app.task(bind=True, throws=(OutOfGasError), base=CriticalSQLAlchemyAndWeb3Task)
|
||||
def check_gas(self, tx_hashes, chain_spec_dict, txs=[], address=None, gas_required=MAXIMUM_FEE_UNITS):
|
||||
def check_gas(self, tx_hashes_hex, chain_spec_dict, txs_hex=[], address=None, gas_required=MAXIMUM_FEE_UNITS):
|
||||
"""Check the gas level of the sender address of a transaction.
|
||||
|
||||
If the account balance is not sufficient for the required gas, gas refill is requested and OutOfGasError raiser.
|
||||
@@ -170,8 +182,23 @@ def check_gas(self, tx_hashes, chain_spec_dict, txs=[], address=None, gas_requir
|
||||
:return: Signed raw transaction data list
|
||||
:rtype: param txs, unchanged
|
||||
"""
|
||||
rpc_format_address = None
|
||||
if address != None:
|
||||
if not is_address(address):
|
||||
raise ValueError('invalid address {}'.format(address))
|
||||
address = tx_normalize.wallet_address(address)
|
||||
address = add_0x(address)
|
||||
|
||||
tx_hashes = []
|
||||
txs = []
|
||||
for tx_hash in tx_hashes_hex:
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
tx_hashes.append(tx_hash)
|
||||
for tx in txs_hex:
|
||||
tx = tx_normalize.tx_wire(tx)
|
||||
txs.append(tx)
|
||||
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
logg.debug('txs {} tx_hashes {}'.format(txs, tx_hashes))
|
||||
|
||||
addresspass = None
|
||||
if len(txs) == 0:
|
||||
@@ -187,8 +214,7 @@ def check_gas(self, tx_hashes, chain_spec_dict, txs=[], address=None, gas_requir
|
||||
raise ValueError('txs passed to check gas must all have same sender; had {} got {}'.format(address, tx['from']))
|
||||
addresspass.append(address)
|
||||
|
||||
if not is_checksum_address(address):
|
||||
raise ValueError('invalid address {}'.format(address))
|
||||
rpc_format_address = add_0x(to_checksum_address(address))
|
||||
|
||||
queue = self.request.delivery_info.get('routing_key')
|
||||
|
||||
@@ -196,7 +222,7 @@ def check_gas(self, tx_hashes, chain_spec_dict, txs=[], address=None, gas_requir
|
||||
|
||||
gas_balance = 0
|
||||
try:
|
||||
o = balance(address)
|
||||
o = balance(rpc_format_address)
|
||||
r = conn.do(o)
|
||||
conn.disconnect()
|
||||
gas_balance = abi_decode_single(ABIContractType.UINT256, r)
|
||||
@@ -304,6 +330,7 @@ def refill_gas(self, recipient_address, chain_spec_dict):
|
||||
# Determine value of gas tokens to send
|
||||
# if an uncompleted gas refill for the same recipient already exists, we still need to spend the nonce
|
||||
# however, we will perform a 0-value transaction instead
|
||||
recipient_address = tx_normalize.wallet_address(recipient_address)
|
||||
zero_amount = False
|
||||
session = SessionBase.create_session()
|
||||
status_filter = StatusBits.FINAL | StatusBits.NODE_ERROR | StatusBits.NETWORK_ERROR | StatusBits.UNKNOWN_ERROR
|
||||
@@ -378,6 +405,7 @@ def resend_with_higher_gas(self, txold_hash_hex, chain_spec_dict, gas=None, defa
|
||||
:returns: Transaction hash
|
||||
:rtype: str, 0x-hex
|
||||
"""
|
||||
txold_hash_hex = tx_normalize.tx_hash(txold_hash_hex)
|
||||
session = SessionBase.create_session()
|
||||
|
||||
otx = Otx.load(txold_hash_hex, session)
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainlib.status import Status as TxStatus
|
||||
from cic_eth_registry.erc20 import ERC20Token
|
||||
from hexathon import add_0x
|
||||
|
||||
# local imports
|
||||
# local impor:ts
|
||||
from cic_eth.ext.address import translate_address
|
||||
|
||||
|
||||
@@ -44,8 +45,8 @@ class ExtendedTx:
|
||||
destination = source
|
||||
if destination_value == None:
|
||||
destination_value = source_value
|
||||
st = ERC20Token(self.chain_spec, self.rpc, source)
|
||||
dt = ERC20Token(self.chain_spec, self.rpc, destination)
|
||||
st = ERC20Token(self.chain_spec, self.rpc, add_0x(source))
|
||||
dt = ERC20Token(self.chain_spec, self.rpc, add_0x(destination))
|
||||
self.source_token = source
|
||||
self.source_token_symbol = st.symbol
|
||||
self.source_token_name = st.name
|
||||
|
||||
@@ -3,11 +3,12 @@ import logging
|
||||
|
||||
# external imports
|
||||
import celery
|
||||
from chainlib.eth.address import is_checksum_address
|
||||
from chainlib.eth.address import is_checksum_address, is_address, strip_0x
|
||||
|
||||
# local imports
|
||||
from cic_eth.db.models.role import AccountRole
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.encode import tx_normalize
|
||||
from cic_eth.task import CriticalSQLAlchemyTask
|
||||
from cic_eth.db.models.nonce import (
|
||||
Nonce,
|
||||
@@ -42,7 +43,8 @@ class CustodialTaskNonceOracle():
|
||||
:returns: Nonce
|
||||
:rtype: number
|
||||
"""
|
||||
r = NonceReservation.release(self.address, self.uuid, session=self.session)
|
||||
address = tx_normalize.wallet_address(self.address)
|
||||
r = NonceReservation.release(address, self.uuid, session=self.session)
|
||||
return r[1]
|
||||
|
||||
|
||||
@@ -58,17 +60,18 @@ def reserve_nonce(self, chained_input, chain_spec_dict, signer_address=None):
|
||||
address = chained_input
|
||||
logg.debug('non-explicit address for reserve nonce, using arg head {}'.format(chained_input))
|
||||
else:
|
||||
if is_checksum_address(signer_address):
|
||||
if is_address(signer_address):
|
||||
address = signer_address
|
||||
logg.debug('explicit address for reserve nonce {}'.format(signer_address))
|
||||
else:
|
||||
address = AccountRole.get_address(signer_address, session=session)
|
||||
logg.debug('role for reserve nonce {} -> {}'.format(signer_address, address))
|
||||
|
||||
if not is_checksum_address(address):
|
||||
if not is_address(address):
|
||||
raise ValueError('invalid result when resolving address for nonce {}'.format(address))
|
||||
|
||||
root_id = self.request.root_id
|
||||
address = tx_normalize.wallet_address(address)
|
||||
r = NonceReservation.next(address, root_id, session=session)
|
||||
logg.debug('nonce {} reserved for address {} task {}'.format(r[1], address, r[0]))
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ from potaahto.symbols import snake_and_camel
|
||||
from cic_eth.queue.time import tx_times
|
||||
from cic_eth.task import BaseTask
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
logg = logging.getLogger()
|
||||
@@ -134,7 +135,7 @@ def list_tx_by_bloom(self, bloomspec, address, chain_spec_dict):
|
||||
tx_address = transfer_data[0]
|
||||
tx_token_value = transfer_data[1]
|
||||
|
||||
if address == tx_address:
|
||||
if tx_normalize.wallet_address(address) == tx_normalize.wallet_address(tx_address):
|
||||
status = StatusEnum.SENT
|
||||
try:
|
||||
o = receipt(tx['hash'])
|
||||
@@ -152,8 +153,8 @@ def list_tx_by_bloom(self, bloomspec, address, chain_spec_dict):
|
||||
times = tx_times(tx['hash'], chain_spec)
|
||||
tx_r = {
|
||||
'hash': tx['hash'],
|
||||
'sender': tx['from'],
|
||||
'recipient': tx_address,
|
||||
'sender': tx_normalize.wallet_address(tx['from']),
|
||||
'recipient': tx_normalize.wallet_address(tx_address),
|
||||
'source_value': tx_token_value,
|
||||
'destination_value': tx_token_value,
|
||||
'source_token': tx['to'],
|
||||
@@ -164,10 +165,10 @@ def list_tx_by_bloom(self, bloomspec, address, chain_spec_dict):
|
||||
tx_r['date_created'] = times['queue']
|
||||
else:
|
||||
tx_r['date_created'] = times['network']
|
||||
txs[tx['hash']] = tx_r
|
||||
txs[strip_0x(tx['hash'])] = tx_r
|
||||
break
|
||||
return txs
|
||||
|
||||
return txs
|
||||
|
||||
|
||||
# TODO: Surely it must be possible to optimize this
|
||||
@@ -230,6 +231,8 @@ def tx_collate(self, tx_batches, chain_spec_dict, offset, limit, newest_first=Tr
|
||||
except UnknownContractError:
|
||||
logg.error('verify failed on tx {}, skipping'.format(tx['hash']))
|
||||
continue
|
||||
tx['recipient'] = tx_normalize.wallet_address(tx['recipient'])
|
||||
tx['sender'] = tx_normalize.wallet_address(tx['sender'])
|
||||
txs.append(tx)
|
||||
|
||||
return txs
|
||||
|
||||
@@ -15,6 +15,7 @@ from chainqueue.db.enum import (
|
||||
# local imports
|
||||
from cic_eth.db import SessionBase
|
||||
from cic_eth.task import CriticalSQLAlchemyTask
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
|
||||
@@ -22,6 +23,9 @@ logg = logging.getLogger()
|
||||
|
||||
|
||||
def __balance_outgoing_compatible(token_address, holder_address):
|
||||
token_address = tx_normalize.executable_address(token_address)
|
||||
holder_address = tx_normalize.wallet_address(holder_address)
|
||||
|
||||
session = SessionBase.create_session()
|
||||
q = session.query(TxCache.from_value)
|
||||
q = q.join(Otx)
|
||||
@@ -58,6 +62,9 @@ def balance_outgoing(tokens, holder_address, chain_spec_dict):
|
||||
|
||||
|
||||
def __balance_incoming_compatible(token_address, receiver_address):
|
||||
token_address = tx_normalize.executable_address(token_address)
|
||||
receiver_address = tx_normalize.wallet_address(receiver_address)
|
||||
|
||||
session = SessionBase.create_session()
|
||||
q = session.query(TxCache.to_value)
|
||||
q = q.join(Otx)
|
||||
@@ -110,7 +117,7 @@ def assemble_balances(balances_collection):
|
||||
logg.debug('received collection {}'.format(balances_collection))
|
||||
for c in balances_collection:
|
||||
for b in c:
|
||||
address = b['address']
|
||||
address = tx_normalize.executable_address(b['address'])
|
||||
if tokens.get(address) == None:
|
||||
tokens[address] = {
|
||||
'address': address,
|
||||
|
||||
@@ -6,6 +6,7 @@ import celery
|
||||
from cic_eth.task import CriticalSQLAlchemyTask
|
||||
from cic_eth.db import SessionBase
|
||||
from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
|
||||
@@ -21,6 +22,9 @@ def get_lock(address=None):
|
||||
:returns: List of locks
|
||||
:rtype: list of dicts
|
||||
"""
|
||||
if address != None:
|
||||
address = tx_normalize.wallet_address(address)
|
||||
|
||||
session = SessionBase.create_session()
|
||||
q = session.query(
|
||||
Lock.date_created,
|
||||
|
||||
@@ -4,8 +4,8 @@ import datetime
|
||||
# external imports
|
||||
import celery
|
||||
from chainlib.chain import ChainSpec
|
||||
from chainlib.eth.tx import unpack
|
||||
import chainqueue.sql.query
|
||||
from chainlib.eth.tx import unpack
|
||||
from chainqueue.db.enum import (
|
||||
StatusEnum,
|
||||
is_alive,
|
||||
@@ -20,6 +20,10 @@ from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.task import CriticalSQLAlchemyTask
|
||||
from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.encode import (
|
||||
tx_normalize,
|
||||
unpack_normal,
|
||||
)
|
||||
|
||||
celery_app = celery.current_app
|
||||
|
||||
@@ -27,49 +31,77 @@ celery_app = celery.current_app
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def get_tx_cache(chain_spec_dict, tx_hash):
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
return get_tx_cache_local(chain_spec, tx_hash)
|
||||
|
||||
|
||||
def get_tx_cache_local(chain_spec, tx_hash, session=None):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
session = SessionBase.bind_session(session)
|
||||
r = chainqueue.sql.query.get_tx_cache(chain_spec, tx_hash, session=session)
|
||||
session.close()
|
||||
SessionBase.release_session(session)
|
||||
return r
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def get_tx(chain_spec_dict, tx_hash):
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
return get_tx_local(chain_spec, tx_hash)
|
||||
|
||||
|
||||
def get_tx_local(chain_spec, tx_hash, session=None):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
session = SessionBase.bind_session(session)
|
||||
r = chainqueue.sql.query.get_tx(chain_spec, tx_hash, session=session)
|
||||
session.close()
|
||||
SessionBase.release_session(session)
|
||||
return r
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def get_account_tx(chain_spec_dict, address, as_sender=True, as_recipient=True, counterpart=None):
|
||||
address = tx_normalize.wallet_address(address)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
return get_account_tx_local(chain_spec, address, as_sender=as_sender, as_recipient=as_recipient, counterpart=counterpart)
|
||||
|
||||
|
||||
def get_account_tx_local(chain_spec, address, as_sender=True, as_recipient=True, counterpart=None, session=None):
|
||||
address = tx_normalize.wallet_address(address)
|
||||
session = SessionBase.bind_session(session)
|
||||
r = chainqueue.sql.query.get_account_tx(chain_spec, address, as_sender=True, as_recipient=True, counterpart=None, session=session)
|
||||
session.close()
|
||||
SessionBase.release_session(session)
|
||||
return r
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def get_upcoming_tx_nolock(chain_spec_dict, status=StatusEnum.READYSEND, not_status=None, recipient=None, before=None, limit=0, session=None):
|
||||
def get_upcoming_tx_nolock(chain_spec_dict, status=StatusEnum.READYSEND, not_status=None, recipient=None, before=None, limit=0):
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
return get_upcoming_tx_nolock_local(chain_spec, status=status, not_status=not_status, recipient=recipient, before=before, limit=limit)
|
||||
|
||||
|
||||
def get_upcoming_tx_nolock_local(chain_spec, status=StatusEnum.READYSEND, not_status=None, recipient=None, before=None, limit=0, session=None):
|
||||
recipient = tx_normalize.wallet_address(recipient)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.query.get_upcoming_tx(chain_spec, status, not_status=not_status, recipient=recipient, before=before, limit=limit, session=session, decoder=unpack)
|
||||
r = chainqueue.sql.query.get_upcoming_tx(chain_spec, status, not_status=not_status, recipient=recipient, before=before, limit=limit, session=session, decoder=unpack_normal)
|
||||
session.close()
|
||||
return r
|
||||
|
||||
|
||||
def get_status_tx(chain_spec, status, not_status=None, before=None, exact=False, limit=0, session=None):
|
||||
return chainqueue.sql.query.get_status_tx_cache(chain_spec, status, not_status=not_status, before=before, exact=exact, limit=limit, session=session, decoder=unpack)
|
||||
return chainqueue.sql.query.get_status_tx_cache(chain_spec, status, not_status=not_status, before=before, exact=exact, limit=limit, session=session, decoder=unpack_normal)
|
||||
|
||||
|
||||
def get_paused_tx(chain_spec, status=None, sender=None, session=None, decoder=None):
|
||||
return chainqueue.sql.query.get_paused_tx_cache(chain_spec, status=status, sender=sender, session=session, decoder=unpack)
|
||||
sender = tx_normalize.wallet_address(sender)
|
||||
return chainqueue.sql.query.get_paused_tx_cache(chain_spec, status=status, sender=sender, session=session, decoder=unpack_normal)
|
||||
|
||||
|
||||
def get_nonce_tx(chain_spec, nonce, sender):
|
||||
return get_nonce_tx_cache(chain_spec, nonce, sender, decoder=unpack)
|
||||
sender = tx_normalize.wallet_address(sender)
|
||||
return get_nonce_tx_local(chain_spec, nonce, sender)
|
||||
|
||||
|
||||
def get_nonce_tx_local(chain_spec, nonce, sender, session=None):
|
||||
sender = tx_normalize.wallet_address(sender)
|
||||
return chainqueue.sql.query.get_nonce_tx_cache(chain_spec, nonce, sender, decoder=unpack_normal, session=session)
|
||||
|
||||
|
||||
def get_upcoming_tx(chain_spec, status=StatusEnum.READYSEND, not_status=None, recipient=None, before=None, limit=0, session=None):
|
||||
@@ -91,6 +123,8 @@ def get_upcoming_tx(chain_spec, status=StatusEnum.READYSEND, not_status=None, re
|
||||
:returns: Transactions
|
||||
:rtype: dict, with transaction hash as key, signed raw transaction as value
|
||||
"""
|
||||
if recipient != None:
|
||||
recipient = tx_normalize.wallet_address(recipient)
|
||||
session = SessionBase.bind_session(session)
|
||||
q_outer = session.query(
|
||||
TxCache.sender,
|
||||
|
||||
@@ -6,12 +6,14 @@ import chainqueue.sql.state
|
||||
import celery
|
||||
from cic_eth.task import CriticalSQLAlchemyTask
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_sent(chain_spec_dict, tx_hash, fail=False):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_sent(chain_spec, tx_hash, fail, session=session)
|
||||
@@ -21,6 +23,7 @@ def set_sent(chain_spec_dict, tx_hash, fail=False):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_final(chain_spec_dict, tx_hash, block=None, tx_index=None, fail=False):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_final(chain_spec, tx_hash, block=block, tx_index=tx_index, fail=fail, session=session)
|
||||
@@ -30,6 +33,7 @@ def set_final(chain_spec_dict, tx_hash, block=None, tx_index=None, fail=False):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_cancel(chain_spec_dict, tx_hash, manual=False):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_cancel(chain_spec, tx_hash, manual, session=session)
|
||||
@@ -39,6 +43,7 @@ def set_cancel(chain_spec_dict, tx_hash, manual=False):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_rejected(chain_spec_dict, tx_hash):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_rejected(chain_spec, tx_hash, session=session)
|
||||
@@ -48,6 +53,7 @@ def set_rejected(chain_spec_dict, tx_hash):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_fubar(chain_spec_dict, tx_hash):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_fubar(chain_spec, tx_hash, session=session)
|
||||
@@ -57,6 +63,7 @@ def set_fubar(chain_spec_dict, tx_hash):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_manual(chain_spec_dict, tx_hash):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_manual(chain_spec, tx_hash, session=session)
|
||||
@@ -66,6 +73,7 @@ def set_manual(chain_spec_dict, tx_hash):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_ready(chain_spec_dict, tx_hash):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_ready(chain_spec, tx_hash, session=session)
|
||||
@@ -75,6 +83,7 @@ def set_ready(chain_spec_dict, tx_hash):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_reserved(chain_spec_dict, tx_hash):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_reserved(chain_spec, tx_hash, session=session)
|
||||
@@ -84,6 +93,7 @@ def set_reserved(chain_spec_dict, tx_hash):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def set_waitforgas(chain_spec_dict, tx_hash):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.set_waitforgas(chain_spec, tx_hash, session=session)
|
||||
@@ -93,6 +103,7 @@ def set_waitforgas(chain_spec_dict, tx_hash):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def get_state_log(chain_spec_dict, tx_hash):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.get_state_log(chain_spec, tx_hash, session=session)
|
||||
@@ -102,6 +113,7 @@ def get_state_log(chain_spec_dict, tx_hash):
|
||||
|
||||
@celery_app.task(base=CriticalSQLAlchemyTask)
|
||||
def obsolete(chain_spec_dict, tx_hash, final):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
chain_spec = ChainSpec.from_dict(chain_spec_dict)
|
||||
session = SessionBase.create_session()
|
||||
r = chainqueue.sql.state.obsolete_by_cache(chain_spec, tx_hash, final, session=session)
|
||||
|
||||
@@ -13,6 +13,7 @@ from chainqueue.error import NotLocalTxError
|
||||
# local imports
|
||||
from cic_eth.task import CriticalSQLAlchemyAndWeb3Task
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
|
||||
@@ -20,6 +21,7 @@ logg = logging.getLogger()
|
||||
|
||||
|
||||
def tx_times(tx_hash, chain_spec, session=None):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
|
||||
session = SessionBase.bind_session(session)
|
||||
|
||||
|
||||
@@ -32,12 +32,16 @@ from cic_eth.db import SessionBase
|
||||
from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.task import CriticalSQLAlchemyTask
|
||||
from cic_eth.error import LockedError
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
celery_app = celery.current_app
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
def queue_create(chain_spec, nonce, holder_address, tx_hash, signed_tx, session=None):
|
||||
tx_hash = tx_normalize.tx_hash(tx_hash)
|
||||
signed_tx = tx_normalize.tx_hash(signed_tx)
|
||||
holder_address = tx_normalize.wallet_address(holder_address)
|
||||
session = SessionBase.bind_session(session)
|
||||
|
||||
lock = Lock.check_aggregate(str(chain_spec), LockEnum.QUEUE, holder_address, session=session)
|
||||
@@ -67,6 +71,8 @@ def register_tx(tx_hash_hex, tx_signed_raw_hex, chain_spec, queue, cache_task=No
|
||||
:returns: Tuple; Transaction hash, signed raw transaction data
|
||||
:rtype: tuple
|
||||
"""
|
||||
tx_hash_hex = tx_normalize.tx_hash(tx_hash_hex)
|
||||
tx_signed_raw_hex = tx_normalize.tx_hash(tx_signed_raw_hex)
|
||||
logg.debug('adding queue tx {}:{} -> {}'.format(chain_spec, tx_hash_hex, tx_signed_raw_hex))
|
||||
tx_signed_raw = bytes.fromhex(strip_0x(tx_signed_raw_hex))
|
||||
tx = unpack(tx_signed_raw, chain_spec)
|
||||
|
||||
@@ -101,14 +101,14 @@ class DispatchSyncer:
|
||||
LockEnum.QUEUE,
|
||||
tx['from'],
|
||||
],
|
||||
queue=queue,
|
||||
queue=config.get('CELERY_QUEUE'),
|
||||
)
|
||||
s_send = celery.signature(
|
||||
'cic_eth.eth.tx.send',
|
||||
[
|
||||
self.chain_spec.asdict(),
|
||||
],
|
||||
queue=queue,
|
||||
queue=config.get('CELERY_QUEUE'),
|
||||
)
|
||||
s_check.link(s_send)
|
||||
t = s_check.apply_async()
|
||||
|
||||
@@ -21,6 +21,7 @@ from erc20_faucet import Faucet
|
||||
# local imports
|
||||
from .base import SyncFilter
|
||||
from cic_eth.eth.meta import ExtendedTx
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
logg = logging.getLogger().getChild(__name__)
|
||||
|
||||
@@ -42,9 +43,9 @@ class CallbackFilter(SyncFilter):
|
||||
return (None, None)
|
||||
r = ERC20.parse_transfer_request(tx.payload)
|
||||
transfer_data = {}
|
||||
transfer_data['to'] = r[0]
|
||||
transfer_data['to'] = tx_normalize.wallet_address(r[0])
|
||||
transfer_data['value'] = r[1]
|
||||
transfer_data['from'] = tx.outputs[0]
|
||||
transfer_data['from'] = tx_normalize.wallet_address(tx.outputs[0])
|
||||
transfer_data['token_address'] = tx.inputs[0]
|
||||
return ('transfer', transfer_data)
|
||||
|
||||
@@ -54,8 +55,8 @@ class CallbackFilter(SyncFilter):
|
||||
return (None, None)
|
||||
r = ERC20.parse_transfer_from_request(tx.payload)
|
||||
transfer_data = {}
|
||||
transfer_data['from'] = r[0]
|
||||
transfer_data['to'] = r[1]
|
||||
transfer_data['from'] = tx_normalize.wallet_address(r[0])
|
||||
transfer_data['to'] = tx_normalize.wallet_address(r[1])
|
||||
transfer_data['value'] = r[2]
|
||||
transfer_data['token_address'] = tx.inputs[0]
|
||||
return ('transferfrom', transfer_data)
|
||||
@@ -66,9 +67,9 @@ class CallbackFilter(SyncFilter):
|
||||
return (None, None)
|
||||
r = Faucet.parse_give_to_request(tx.payload)
|
||||
transfer_data = {}
|
||||
transfer_data['to'] = r[0]
|
||||
transfer_data['to'] = tx_normalize.wallet_address(r[0])
|
||||
transfer_data['value'] = tx.value
|
||||
transfer_data['from'] = tx.outputs[0]
|
||||
transfer_data['from'] = tx_normalize.wallet_address(tx.outputs[0])
|
||||
#transfer_data['token_address'] = tx.inputs[0]
|
||||
faucet_contract = tx.inputs[0]
|
||||
|
||||
|
||||
@@ -10,15 +10,14 @@ from chainlib.eth.tx import unpack
|
||||
from chainqueue.db.enum import StatusBits
|
||||
from chainqueue.db.models.tx import TxCache
|
||||
from chainqueue.db.models.otx import Otx
|
||||
from chainqueue.sql.query import get_paused_tx_cache as get_paused_tx
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
|
||||
# local imports
|
||||
from cic_eth.db.models.base import SessionBase
|
||||
from cic_eth.eth.gas import create_check_gas_task
|
||||
from cic_eth.queue.query import get_paused_tx
|
||||
from .base import SyncFilter
|
||||
|
||||
#logg = logging.getLogger().getChild(__name__)
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ from hexathon import (
|
||||
# local imports
|
||||
from .base import SyncFilter
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
#logg = logging.getLogger(__name__)
|
||||
logg = logging.getLogger()
|
||||
|
||||
account_registry_add_log_hash = '0x9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c9430'
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ from cic_eth_registry import CICRegistry
|
||||
from erc20_transfer_authorization import TransferAuthorization
|
||||
|
||||
# local imports
|
||||
from cic_eth.encode import tx_normalize
|
||||
from .base import SyncFilter
|
||||
|
||||
|
||||
@@ -52,9 +53,9 @@ class TransferAuthFilter(SyncFilter):
|
||||
|
||||
r = TransferAuthorization.parse_create_request_request(tx.payload)
|
||||
|
||||
sender = r[0]
|
||||
recipient = r[1]
|
||||
token = r[2]
|
||||
sender = tx_normalize.wallet_address(r[0])
|
||||
recipient = tx_normalize.wallet_address(r[1])
|
||||
token = tx_normalize.executable_address(r[2])
|
||||
value = r[3]
|
||||
|
||||
token_data = {
|
||||
|
||||
@@ -69,7 +69,6 @@ from cic_eth.registry import (
|
||||
)
|
||||
from cic_eth.task import BaseTask
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
@@ -207,7 +206,7 @@ def main():
|
||||
|
||||
BaseTask.default_token_symbol = config.get('CIC_DEFAULT_TOKEN_SYMBOL')
|
||||
BaseTask.default_token_address = registry.by_name(BaseTask.default_token_symbol)
|
||||
default_token = ERC20Token(chain_spec, conn, BaseTask.default_token_address)
|
||||
default_token = ERC20Token(chain_spec, conn, add_0x(BaseTask.default_token_address))
|
||||
default_token.load(conn)
|
||||
BaseTask.default_token_decimals = default_token.decimals
|
||||
BaseTask.default_token_name = default_token.name
|
||||
|
||||
@@ -18,7 +18,7 @@ from cic_eth.db.models.base import SessionBase
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
arg_flags = cic_eth.cli.argflag_std_base
|
||||
arg_flags = cic_eth.cli.argflag_std_base | cic_eth.cli.Flag.UNSAFE | cic_eth.cli.Flag.CHAIN_SPEC
|
||||
local_arg_flags = cic_eth.cli.argflag_local_taskcallback
|
||||
argparser = cic_eth.cli.ArgumentParser(arg_flags)
|
||||
argparser.add_positional('tag', type=str, help='address tag')
|
||||
|
||||
@@ -13,7 +13,6 @@ from chainlib.eth.nonce import RPCNonceOracle
|
||||
from chainlib.eth.gas import RPCGasOracle
|
||||
from cic_eth_registry import CICRegistry
|
||||
from cic_eth_registry.error import UnknownContractError
|
||||
import liveness.linux
|
||||
|
||||
# local imports
|
||||
from cic_eth.error import SeppukuError
|
||||
@@ -48,6 +47,7 @@ class BaseTask(celery.Task):
|
||||
|
||||
def on_failure(self, exc, task_id, args, kwargs, einfo):
|
||||
if isinstance(exc, SeppukuError):
|
||||
import liveness.linux
|
||||
liveness.linux.reset(rundir=self.run_dir)
|
||||
logg.critical(einfo)
|
||||
msg = 'received critical exception {}, calling shutdown'.format(str(exc))
|
||||
|
||||
@@ -9,8 +9,8 @@ import semver
|
||||
version = (
|
||||
0,
|
||||
12,
|
||||
2,
|
||||
'alpha.4',
|
||||
4,
|
||||
'alpha.8',
|
||||
)
|
||||
|
||||
version_object = semver.VersionInfo(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
@node cic-eth configuration
|
||||
@section Configuration
|
||||
|
||||
(refer to @code{cic-base} for a general overview of the config pipeline)
|
||||
|
||||
Configuration parameters are grouped by configuration filename.
|
||||
|
||||
|
||||
@@ -40,7 +38,26 @@ Boolean value. If set, the amount of available context for a task in the result
|
||||
|
||||
@subsection database
|
||||
|
||||
See ref cic-base when ready
|
||||
@table @var
|
||||
@item host
|
||||
Database host
|
||||
@item port
|
||||
Database port
|
||||
@item name
|
||||
Database name
|
||||
@item user
|
||||
Database user
|
||||
@item password
|
||||
Database password
|
||||
@item engine
|
||||
The engine part of the dsn connection string (@code{postgresql} in @code{postgresql+psycopg2})
|
||||
@item driver
|
||||
The driver part of the dsn connection string (@code{psycopg2} in @code{postgresql+psycopg2})
|
||||
@item pool_size
|
||||
Connection pool size for database drivers that provide connection pooling
|
||||
@item debug
|
||||
Output actual sql queries to logs. Potentially very verbose
|
||||
@end table
|
||||
|
||||
|
||||
@subsection eth
|
||||
|
||||
@@ -8,30 +8,44 @@ FROM registry.gitlab.com/grassrootseconomics/cic-base-images:python-3.8.6-dev-55
|
||||
|
||||
ARG EXTRA_INDEX_URL="https://pip.grassrootseconomics.net:8433"
|
||||
ARG GITLAB_PYTHON_REGISTRY="https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple"
|
||||
ARG EXTRA_PIP_ARGS=""
|
||||
#RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
|
||||
# pip install --index-url https://pypi.org/simple \
|
||||
# --force-reinstall \
|
||||
# --extra-index-url $GITLAB_PYTHON_REGISTRY --extra-index-url $EXTRA_INDEX_URL \
|
||||
# -r requirements.txt
|
||||
# -r requirements.txt
|
||||
|
||||
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
|
||||
pip install --index-url https://pypi.org/simple \
|
||||
--extra-index-url $GITLAB_PYTHON_REGISTRY \
|
||||
--extra-index-url $EXTRA_INDEX_URL \
|
||||
$EXTRA_PIP_ARGS \
|
||||
cic-eth-aux-erc20-demurrage-token~=0.0.2a6
|
||||
|
||||
|
||||
COPY *requirements.txt ./
|
||||
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
|
||||
pip install --index-url https://pypi.org/simple \
|
||||
--extra-index-url $GITLAB_PYTHON_REGISTRY \
|
||||
--extra-index-url $EXTRA_INDEX_URL \
|
||||
$EXTRA_PIP_ARGS \
|
||||
-r requirements.txt \
|
||||
-r services_requirements.txt \
|
||||
-r admin_requirements.txt
|
||||
|
||||
-r admin_requirements.txt
|
||||
|
||||
# always install the latest signer
|
||||
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
|
||||
pip install --index-url https://pypi.org/simple \
|
||||
--extra-index-url $GITLAB_PYTHON_REGISTRY \
|
||||
--extra-index-url $EXTRA_INDEX_URL \
|
||||
$EXTRA_PIP_ARGS \
|
||||
crypto-dev-signer
|
||||
|
||||
COPY . .
|
||||
RUN python setup.py install
|
||||
|
||||
ENV PYTHONPATH .
|
||||
|
||||
RUN --mount=type=cache,mode=0755,target=/root/.cache/pip \
|
||||
pip install --index-url https://pypi.org/simple \
|
||||
--extra-index-url $GITLAB_PYTHON_REGISTRY \
|
||||
--extra-index-url $EXTRA_INDEX_URL \
|
||||
cic-eth-aux-erc20-demurrage-token~=0.0.2a6
|
||||
|
||||
COPY docker/entrypoints/* ./
|
||||
RUN chmod 755 *.sh
|
||||
|
||||
@@ -5,27 +5,27 @@ set -e
|
||||
|
||||
# set CONFINI_ENV_PREFIX to override the env prefix to override env vars
|
||||
|
||||
echo "!!! starting signer"
|
||||
python /usr/local/bin/crypto-dev-daemon -c /usr/local/etc/crypto-dev-signer -vv 2> /tmp/signer.log &
|
||||
#echo "!!! starting signer"
|
||||
#python /usr/local/bin/crypto-dev-daemon -c /usr/local/etc/crypto-dev-signer -vv 2> /tmp/signer.log &
|
||||
|
||||
echo "!!! starting taskerd"
|
||||
/usr/local/bin/cic-eth-taskerd $@
|
||||
|
||||
# thanks! https://docs.docker.com/config/containers/multi-service_container/
|
||||
sleep 1;
|
||||
echo "!!! entering monitor loop"
|
||||
while true; do
|
||||
ps aux | grep crypto-dev-daemon | grep -q -v grep
|
||||
PROCESS_1_STATUS=$?
|
||||
ps aux | grep cic-eth-tasker |grep -q -v grep
|
||||
PROCESS_2_STATUS=$?
|
||||
# If the greps above find anything, they exit with 0 status
|
||||
# If they are not both 0, then something is wrong
|
||||
if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
|
||||
echo "One of the processes has already exited."
|
||||
exit 1
|
||||
fi
|
||||
sleep 15;
|
||||
done
|
||||
|
||||
#sleep 1;
|
||||
#echo "!!! entering monitor loop"
|
||||
#while true; do
|
||||
# ps aux | grep crypto-dev-daemon | grep -q -v grep
|
||||
# PROCESS_1_STATUS=$?
|
||||
# ps aux | grep cic-eth-tasker |grep -q -v grep
|
||||
# PROCESS_2_STATUS=$?
|
||||
# # If the greps above find anything, they exit with 0 status
|
||||
# # If they are not both 0, then something is wrong
|
||||
# if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then
|
||||
# echo "One of the processes has already exited."
|
||||
# exit 1
|
||||
# fi
|
||||
# sleep 15;
|
||||
#done
|
||||
#
|
||||
set +e
|
||||
|
||||
11
apps/cic-eth/docker/run_tests.sh
Normal file
11
apps/cic-eth/docker/run_tests.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433 --extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple \
|
||||
-r admin_requirements.txt \
|
||||
-r services_requirements.txt \
|
||||
-r test_requirements.txt
|
||||
|
||||
export PYTHONPATH=. && pytest -x --cov=cic_eth --cov-fail-under=90 --cov-report term-missing tests
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
celery==4.4.7
|
||||
chainlib-eth>=0.0.7a7,<0.1.0
|
||||
chainlib-eth>=0.0.9rc2,<0.1.0
|
||||
semver==2.13.0
|
||||
crypto-dev-signer>=0.4.15rc2,<0.5.0
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
chainqueue>=0.0.3a2,<0.1.0
|
||||
chainsyncer[sql]>=0.0.6a1,<0.1.0
|
||||
chainqueue>=0.0.5a1,<0.1.0
|
||||
chainsyncer[sql]>=0.0.6a3,<0.1.0
|
||||
alembic==1.4.2
|
||||
confini>=0.3.6rc4,<0.5.0
|
||||
redis==3.5.3
|
||||
hexathon~=0.0.1a7
|
||||
hexathon~=0.0.1a8
|
||||
pycryptodome==3.10.1
|
||||
liveness~=0.0.1a7
|
||||
eth-address-index>=0.1.4a1,<0.2.0
|
||||
eth-accounts-index>=0.0.14a1,<0.1.0
|
||||
cic-eth-registry>=0.5.8a1,<0.6.0
|
||||
erc20-faucet>=0.2.4a2,<0.3.0
|
||||
erc20-transfer-authorization>=0.3.4a1,<0.4.0
|
||||
sarafu-faucet>=0.0.5a2,<0.1.0
|
||||
eth-address-index>=0.2.3a4,<0.3.0
|
||||
eth-accounts-index>=0.1.2a3,<0.2.0
|
||||
cic-eth-registry>=0.6.1a3,<0.7.0
|
||||
erc20-faucet>=0.3.2a2,<0.4.0
|
||||
erc20-transfer-authorization>=0.3.5a2,<0.4.0
|
||||
sarafu-faucet>=0.0.7a2,<0.1.0
|
||||
moolb~=0.1.1b2
|
||||
|
||||
@@ -6,4 +6,4 @@ pytest-redis==2.0.0
|
||||
redis==3.5.3
|
||||
eth-tester==0.5.0b3
|
||||
py-evm==0.3.0a20
|
||||
eth-erc20~=0.0.12a1
|
||||
eth-erc20~=0.1.2a2
|
||||
|
||||
@@ -18,7 +18,10 @@ from eth_erc20 import ERC20
|
||||
from sarafu_faucet import MinterFaucet
|
||||
from eth_accounts_index.registry import AccountRegistry
|
||||
from potaahto.symbols import snake_and_camel
|
||||
from hexathon import add_0x
|
||||
from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
|
||||
# local imports
|
||||
from cic_eth.runnable.daemons.filters.callback import CallbackFilter
|
||||
@@ -160,7 +163,7 @@ def test_faucet_gift_to_tx(
|
||||
assert transfer_data['token_address'] == foo_token
|
||||
|
||||
|
||||
def test_callback_filter(
|
||||
def test_callback_filter_filter(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
eth_rpc,
|
||||
@@ -200,6 +203,7 @@ def test_callback_filter(
|
||||
assert r['status'] == 1
|
||||
|
||||
rcpt = snake_and_camel(r)
|
||||
tx.block.hash = rcpt['block_hash']
|
||||
tx.apply_receipt(rcpt)
|
||||
|
||||
fltr = CallbackFilter(default_chain_spec, None, None, caller_address=contract_roles['CONTRACT_DEPLOYER'])
|
||||
@@ -212,6 +216,7 @@ def test_callback_filter(
|
||||
|
||||
def call_back(self, transfer_type, result):
|
||||
self.results[transfer_type] = result
|
||||
logg.debug('result {}'.format(result))
|
||||
return self
|
||||
|
||||
mock = CallbackMock()
|
||||
@@ -220,4 +225,4 @@ def test_callback_filter(
|
||||
fltr.filter(eth_rpc, mockblock, tx, init_database)
|
||||
|
||||
assert mock.results.get('transfer') != None
|
||||
assert mock.results['transfer']['destination_token'] == foo_token
|
||||
assert mock.results['transfer']['destination_token'] == strip_0x(foo_token)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# external imports
|
||||
from chainlib.connection import RPCConnection
|
||||
from chainlib.eth.nonce import OverrideNonceOracle
|
||||
from chainqueue.sql.tx import create as queue_create
|
||||
from chainlib.eth.tx import (
|
||||
TxFormat,
|
||||
unpack,
|
||||
@@ -26,6 +25,8 @@ from chainqueue.db.enum import StatusBits
|
||||
# local imports
|
||||
from cic_eth.runnable.daemons.filters.gas import GasFilter
|
||||
from cic_eth.eth.gas import cache_gas_data
|
||||
from cic_eth.encode import tx_normalize
|
||||
from cic_eth.queue.tx import queue_create
|
||||
|
||||
|
||||
def test_filter_gas(
|
||||
|
||||
@@ -17,15 +17,18 @@ from chainlib.eth.block import (
|
||||
block_by_number,
|
||||
Block,
|
||||
)
|
||||
from chainlib.eth.address import (
|
||||
to_checksum_address,
|
||||
)
|
||||
from erc20_faucet import Faucet
|
||||
from hexathon import (
|
||||
strip_0x,
|
||||
add_0x,
|
||||
)
|
||||
from chainqueue.sql.query import get_account_tx
|
||||
|
||||
# local imports
|
||||
from cic_eth.runnable.daemons.filters.register import RegistrationFilter
|
||||
from cic_eth.queue.query import get_account_tx_local
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
@@ -69,17 +72,18 @@ def test_register_filter(
|
||||
tx = Tx(tx_src, block=block, rcpt=rcpt)
|
||||
tx.apply_receipt(rcpt)
|
||||
|
||||
fltr = RegistrationFilter(default_chain_spec, add_0x(os.urandom(20).hex()), queue=None)
|
||||
fltr = RegistrationFilter(default_chain_spec, to_checksum_address(os.urandom(20).hex()), queue=None)
|
||||
t = fltr.filter(eth_rpc, block, tx, db_session=init_database)
|
||||
assert t == None
|
||||
|
||||
fltr = RegistrationFilter(default_chain_spec, account_registry, queue=None)
|
||||
fltr = RegistrationFilter(default_chain_spec, to_checksum_address(account_registry), queue=None)
|
||||
t = fltr.filter(eth_rpc, block, tx, db_session=init_database)
|
||||
logg.debug('t {}'.format(t))
|
||||
|
||||
t.get_leaf()
|
||||
assert t.successful()
|
||||
|
||||
gift_txs = get_account_tx(default_chain_spec.asdict(), agent_roles['ALICE'], as_sender=True, session=init_database)
|
||||
gift_txs = get_account_tx_local(default_chain_spec, agent_roles['ALICE'], as_sender=True, session=init_database)
|
||||
ks = list(gift_txs.keys())
|
||||
assert len(ks) == 1
|
||||
|
||||
@@ -88,4 +92,4 @@ def test_register_filter(
|
||||
gift_tx = unpack(tx_raw_signed_bytes, default_chain_spec)
|
||||
|
||||
gift = Faucet.parse_give_to_request(gift_tx['data'])
|
||||
assert gift[0] == agent_roles['ALICE']
|
||||
assert add_0x(gift[0]) == agent_roles['ALICE']
|
||||
|
||||
@@ -19,6 +19,7 @@ from chainqueue.sql.query import get_account_tx
|
||||
|
||||
# local imports
|
||||
from cic_eth.runnable.daemons.filters.transferauth import TransferAuthFilter
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
|
||||
def test_filter_transferauth(
|
||||
@@ -66,7 +67,8 @@ def test_filter_transferauth(
|
||||
t.get_leaf()
|
||||
assert t.successful()
|
||||
|
||||
approve_txs = get_account_tx(default_chain_spec.asdict(), agent_roles['ALICE'], as_sender=True, session=init_database)
|
||||
#approve_txs = get_account_tx(default_chain_spec.asdict(), agent_roles['ALICE'], as_sender=True, session=init_database)
|
||||
approve_txs = get_account_tx(default_chain_spec.asdict(), tx_normalize.wallet_address(agent_roles['ALICE']), as_sender=True, session=init_database)
|
||||
ks = list(approve_txs.keys())
|
||||
assert len(ks) == 1
|
||||
|
||||
@@ -76,4 +78,4 @@ def test_filter_transferauth(
|
||||
|
||||
c = ERC20(default_chain_spec)
|
||||
approve = c.parse_approve_request(approve_tx['data'])
|
||||
assert approve[0] == agent_roles['BOB']
|
||||
assert approve[0] == strip_0x(agent_roles['BOB'])
|
||||
|
||||
10
apps/cic-eth/tests/run_tests.sh
Normal file
10
apps/cic-eth/tests/run_tests.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433 --extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
|
||||
-r admin_requirements.txt
|
||||
-r services_requirements.txt
|
||||
-r test_requirements.txt
|
||||
|
||||
export PYTHONPATH=. && pytest -x --cov=cic_eth --cov-fail-under=90 --cov-report term-missing tests
|
||||
@@ -34,10 +34,6 @@ from chainqueue.sql.state import (
|
||||
set_ready,
|
||||
set_reserved,
|
||||
)
|
||||
from chainqueue.sql.query import (
|
||||
get_tx,
|
||||
get_nonce_tx_cache,
|
||||
)
|
||||
|
||||
# local imports
|
||||
from cic_eth.api.admin import AdminApi
|
||||
@@ -46,6 +42,11 @@ from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.error import InitializationError
|
||||
from cic_eth.eth.gas import cache_gas_data
|
||||
from cic_eth.queue.tx import queue_create
|
||||
from cic_eth.queue.query import (
|
||||
get_tx,
|
||||
get_nonce_tx_local,
|
||||
)
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
@@ -109,8 +110,8 @@ def test_tag_account(
|
||||
t = api.tag_account('bar', agent_roles['CAROL'], default_chain_spec)
|
||||
t.get()
|
||||
|
||||
assert AccountRole.get_address('foo', init_database) == agent_roles['ALICE']
|
||||
assert AccountRole.get_address('bar', init_database) == agent_roles['CAROL']
|
||||
assert AccountRole.get_address('foo', init_database) == tx_normalize.wallet_address(agent_roles['ALICE'])
|
||||
assert AccountRole.get_address('bar', init_database) == tx_normalize.wallet_address(agent_roles['CAROL'])
|
||||
|
||||
|
||||
def test_tx(
|
||||
@@ -286,13 +287,15 @@ def test_fix_nonce(
|
||||
assert t.successful()
|
||||
|
||||
init_database.commit()
|
||||
|
||||
txs = get_nonce_tx_cache(default_chain_spec, 3, agent_roles['ALICE'], session=init_database)
|
||||
|
||||
logg.debug('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
txs = get_nonce_tx_local(default_chain_spec, 3, agent_roles['ALICE'], session=init_database)
|
||||
ks = txs.keys()
|
||||
assert len(ks) == 2
|
||||
|
||||
for k in ks:
|
||||
hsh = add_0x(k)
|
||||
#hsh = add_0x(k)
|
||||
hsh = tx_normalize.tx_hash(k)
|
||||
otx = Otx.load(hsh, session=init_database)
|
||||
init_database.refresh(otx)
|
||||
logg.debug('checking nonce {} tx {} status {}'.format(3, otx.tx_hash, otx.status))
|
||||
|
||||
@@ -30,7 +30,6 @@ from chainqueue.sql.state import (
|
||||
)
|
||||
from chainqueue.db.models.otx import Otx
|
||||
from chainqueue.db.enum import StatusBits
|
||||
from chainqueue.sql.query import get_nonce_tx_cache
|
||||
from eth_erc20 import ERC20
|
||||
from cic_eth_registry import CICRegistry
|
||||
|
||||
@@ -38,6 +37,7 @@ from cic_eth_registry import CICRegistry
|
||||
from cic_eth.api.admin import AdminApi
|
||||
from cic_eth.eth.gas import cache_gas_data
|
||||
from cic_eth.eth.erc20 import cache_transfer_data
|
||||
from cic_eth.queue.query import get_nonce_tx_local
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
@@ -312,7 +312,7 @@ def test_resend_inplace(
|
||||
otx = Otx.load(tx_hash_hex, session=init_database)
|
||||
assert otx.status & StatusBits.OBSOLETE == StatusBits.OBSOLETE
|
||||
|
||||
txs = get_nonce_tx_cache(default_chain_spec, otx.nonce, agent_roles['ALICE'], session=init_database)
|
||||
txs = get_nonce_tx_local(default_chain_spec, otx.nonce, agent_roles['ALICE'], session=init_database)
|
||||
assert len(txs) == 2
|
||||
|
||||
|
||||
@@ -363,10 +363,10 @@ def test_resend_clone(
|
||||
assert otx.status & StatusBits.IN_NETWORK == StatusBits.IN_NETWORK
|
||||
assert otx.status & StatusBits.OBSOLETE == StatusBits.OBSOLETE
|
||||
|
||||
txs = get_nonce_tx_cache(default_chain_spec, otx.nonce, agent_roles['ALICE'], session=init_database)
|
||||
txs = get_nonce_tx_local(default_chain_spec, otx.nonce, agent_roles['ALICE'], session=init_database)
|
||||
assert len(txs) == 1
|
||||
|
||||
txs = get_nonce_tx_cache(default_chain_spec, otx.nonce + 1, agent_roles['ALICE'], session=init_database)
|
||||
txs = get_nonce_tx_local(default_chain_spec, otx.nonce + 1, agent_roles['ALICE'], session=init_database)
|
||||
assert len(txs) == 1
|
||||
|
||||
otx = Otx.load(txs[0], session=init_database)
|
||||
|
||||
@@ -10,6 +10,7 @@ from cic_eth_registry.erc20 import ERC20Token
|
||||
from chainlib.chain import ChainSpec
|
||||
from eth_accounts_index import AccountsIndex
|
||||
from chainlib.eth.tx import (
|
||||
receipt,
|
||||
transaction,
|
||||
)
|
||||
from chainqueue.sql.state import (
|
||||
@@ -29,6 +30,7 @@ def test_account_api(
|
||||
init_database,
|
||||
init_eth_rpc,
|
||||
account_registry,
|
||||
cic_registry,
|
||||
custodial_roles,
|
||||
celery_session_worker,
|
||||
):
|
||||
@@ -49,6 +51,7 @@ def test_account_api_register(
|
||||
eth_rpc,
|
||||
celery_session_worker,
|
||||
):
|
||||
|
||||
api = Api(str(default_chain_spec), callback_param='accounts', callback_task='cic_eth.callbacks.noop.noop', queue=None)
|
||||
t = api.create_account('')
|
||||
register_tx_hash = t.get_leaf()
|
||||
@@ -69,12 +72,18 @@ def test_account_api_register(
|
||||
r = t.get_leaf()
|
||||
assert t.successful()
|
||||
|
||||
o = receipt(register_tx_hash)
|
||||
r = eth_rpc.do(o)
|
||||
assert r['status'] == 1
|
||||
|
||||
o = transaction(register_tx_hash)
|
||||
tx_src = eth_rpc.do(o)
|
||||
|
||||
c = AccountsIndex(default_chain_spec)
|
||||
address = c.parse_add_request(tx_src['data'])
|
||||
logg.debug('address {} '.format(address))
|
||||
o = c.have(account_registry, address[0], sender_address=custodial_roles['CONTRACT_DEPLOYER'])
|
||||
logg.debug('o {}'.format(o))
|
||||
r = eth_rpc.do(o)
|
||||
assert c.parse_have(r)
|
||||
|
||||
|
||||
@@ -3,18 +3,22 @@ import os
|
||||
import logging
|
||||
|
||||
# external imports
|
||||
import pytest
|
||||
from chainlib.eth.address import to_checksum_address
|
||||
from hexathon import add_0x
|
||||
|
||||
# local imports
|
||||
from cic_eth.api.api_task import Api
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
def test_balance_simple_api(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
cic_registry,
|
||||
foo_token,
|
||||
register_lookups,
|
||||
register_tokens,
|
||||
api,
|
||||
celery_session_worker,
|
||||
@@ -22,7 +26,7 @@ def test_balance_simple_api(
|
||||
|
||||
chain_str = str(default_chain_spec)
|
||||
|
||||
a = to_checksum_address('0x' + os.urandom(20).hex())
|
||||
a = add_0x(to_checksum_address(os.urandom(20).hex()))
|
||||
t = api.balance(a, 'FOO', include_pending=False)
|
||||
r = t.get_leaf()
|
||||
assert t.successful()
|
||||
@@ -36,6 +40,7 @@ def test_balance_complex_api(
|
||||
init_database,
|
||||
cic_registry,
|
||||
foo_token,
|
||||
register_lookups,
|
||||
register_tokens,
|
||||
api,
|
||||
celery_session_worker,
|
||||
@@ -43,7 +48,7 @@ def test_balance_complex_api(
|
||||
|
||||
chain_str = str(default_chain_spec)
|
||||
|
||||
a = to_checksum_address('0x' + os.urandom(20).hex())
|
||||
a = add_0x(to_checksum_address(os.urandom(20).hex()))
|
||||
t = api.balance(a, 'FOO', include_pending=True)
|
||||
r = t.get_leaf()
|
||||
assert t.successful()
|
||||
|
||||
@@ -6,6 +6,7 @@ import pytest
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
from eth_erc20 import ERC20
|
||||
from chainlib.eth.tx import receipt
|
||||
from hexathon import strip_0x
|
||||
|
||||
# local imports
|
||||
from cic_eth.api.api_task import Api
|
||||
@@ -23,7 +24,6 @@ from cic_eth.pytest.mock.filter import (
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
@pytest.mark.xfail()
|
||||
def test_list_tx(
|
||||
default_chain_spec,
|
||||
init_database,
|
||||
@@ -34,8 +34,10 @@ def test_list_tx(
|
||||
agent_roles,
|
||||
foo_token,
|
||||
register_tokens,
|
||||
register_lookups,
|
||||
init_eth_tester,
|
||||
celery_session_worker,
|
||||
init_celery_tasks,
|
||||
):
|
||||
|
||||
tx_hashes = []
|
||||
@@ -63,13 +65,16 @@ def test_list_tx(
|
||||
o = receipt(tx_hash_hex)
|
||||
r = eth_rpc.do(o)
|
||||
assert r['status'] == 1
|
||||
|
||||
a = r['block_number']
|
||||
block_filter.add(a.to_bytes(4, 'big'))
|
||||
ab = a.to_bytes(4, 'big')
|
||||
block_filter.add(ab)
|
||||
|
||||
a = r['block_number'] + r['transaction_index']
|
||||
tx_filter.add(a.to_bytes(4, 'big'))
|
||||
bb = r['transaction_index'].to_bytes(4, 'big')
|
||||
cb = ab + bb
|
||||
tx_filter.add(cb)
|
||||
|
||||
tx_hashes.append(tx_hash_hex)
|
||||
tx_hashes.append(strip_0x(tx_hash_hex))
|
||||
|
||||
# external tx two
|
||||
Nonce.next(agent_roles['ALICE'], 'foo', session=init_database)
|
||||
@@ -83,26 +88,29 @@ def test_list_tx(
|
||||
o = receipt(tx_hash_hex)
|
||||
r = eth_rpc.do(o)
|
||||
assert r['status'] == 1
|
||||
|
||||
a = r['block_number']
|
||||
block_filter.add(a.to_bytes(4, 'big'))
|
||||
ab = a.to_bytes(4, 'big')
|
||||
block_filter.add(ab)
|
||||
|
||||
a = r['block_number'] + r['transaction_index']
|
||||
tx_filter.add(a.to_bytes(4, 'big'))
|
||||
bb = r['transaction_index'].to_bytes(4, 'big')
|
||||
cb = ab + bb
|
||||
tx_filter.add(cb)
|
||||
|
||||
tx_hashes.append(tx_hash_hex)
|
||||
tx_hashes.append(strip_0x(tx_hash_hex))
|
||||
|
||||
init_eth_tester.mine_blocks(28)
|
||||
|
||||
# custodial tx 1
|
||||
api = Api(str(default_chain_spec), queue=None)
|
||||
t = api.transfer(agent_roles['ALICE'], agent_roles['CAROL'], 64, 'FOO') #, 'blinky')
|
||||
t = api.transfer(agent_roles['ALICE'], agent_roles['CAROL'], 64, 'FOO')
|
||||
r = t.get_leaf()
|
||||
assert t.successful()
|
||||
tx_hashes.append(r)
|
||||
|
||||
# custodial tx 2
|
||||
api = Api(str(default_chain_spec), queue=None)
|
||||
t = api.transfer(agent_roles['ALICE'], agent_roles['DAVE'], 16, 'FOO') #, 'blinky')
|
||||
t = api.transfer(agent_roles['ALICE'], agent_roles['DAVE'], 16, 'FOO')
|
||||
r = t.get_leaf()
|
||||
assert t.successful()
|
||||
tx_hashes.append(r)
|
||||
@@ -117,7 +125,8 @@ def test_list_tx(
|
||||
assert len(r) == 3
|
||||
logg.debug('rrrr {}'.format(r))
|
||||
|
||||
logg.debug('testing against hashes {}'.format(tx_hashes))
|
||||
for tx in r:
|
||||
logg.debug('have tx {}'.format(tx))
|
||||
tx_hashes.remove(tx['hash'])
|
||||
tx_hashes.remove(strip_0x(tx['hash']))
|
||||
assert len(tx_hashes) == 1
|
||||
|
||||
@@ -10,6 +10,7 @@ from chainlib.eth.tx import (
|
||||
)
|
||||
from eth_erc20 import ERC20
|
||||
from chainlib.eth.nonce import RPCNonceOracle
|
||||
from hexathon import add_0x
|
||||
|
||||
# local imports
|
||||
from cic_eth.db.models.nonce import (
|
||||
@@ -91,5 +92,5 @@ def test_filter_process(
|
||||
|
||||
assert len(r) == 2
|
||||
for tx_hash in r.keys():
|
||||
tx_hashes.remove(tx_hash)
|
||||
tx_hashes.remove(add_0x(tx_hash))
|
||||
assert len(tx_hashes) == 0
|
||||
|
||||
@@ -21,7 +21,6 @@ from chainlib.eth.constant import (
|
||||
MINIMUM_FEE_UNITS,
|
||||
MINIMUM_FEE_PRICE,
|
||||
)
|
||||
from chainqueue.sql.tx import create as queue_create
|
||||
from chainqueue.sql.query import get_tx
|
||||
from chainqueue.db.enum import StatusBits
|
||||
from chainqueue.sql.state import (
|
||||
@@ -35,6 +34,7 @@ from hexathon import strip_0x
|
||||
# local imports
|
||||
from cic_eth.eth.gas import cache_gas_data
|
||||
from cic_eth.error import OutOfGasError
|
||||
from cic_eth.queue.tx import queue_create
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
@@ -75,7 +75,7 @@ def test_task_check_gas_ok(
|
||||
'cic_eth.eth.gas.check_gas',
|
||||
[
|
||||
[
|
||||
tx_hash_hex,
|
||||
strip_0x(tx_hash_hex),
|
||||
],
|
||||
default_chain_spec.asdict(),
|
||||
[],
|
||||
@@ -283,4 +283,3 @@ def test_task_resend_explicit(
|
||||
tx_after = unpack(bytes.fromhex(strip_0x(otx.signed_tx)), default_chain_spec)
|
||||
logg.debug('gasprices before {} after {}'.format(tx_before['gasPrice'], tx_after['gasPrice']))
|
||||
assert tx_after['gasPrice'] > tx_before['gasPrice']
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ def test_ext_tx_collate(
|
||||
tx_hash_hex,
|
||||
tx_signed_raw_hex,
|
||||
)
|
||||
otx.block = 666
|
||||
init_database.add(otx)
|
||||
init_database.commit()
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ def test_set(
|
||||
tx_hash_hex,
|
||||
tx_signed_raw_hex,
|
||||
)
|
||||
otx.block = 666
|
||||
init_database.add(otx)
|
||||
init_database.commit()
|
||||
|
||||
@@ -74,7 +75,6 @@ def test_set(
|
||||
assert (tx_stored.destination_token_address == ZERO_ADDRESS)
|
||||
assert (tx_stored.from_value == tx['value'])
|
||||
assert (tx_stored.to_value == to_value)
|
||||
assert (tx_stored.block_number == 666)
|
||||
assert (tx_stored.tx_index == 13)
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from cic_eth.queue.balance import (
|
||||
balance_incoming,
|
||||
assemble_balances,
|
||||
)
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
logg = logging.getLogger()
|
||||
|
||||
@@ -51,8 +52,8 @@ def test_assemble():
|
||||
r = assemble_balances(b)
|
||||
logg.debug('r {}'.format(r))
|
||||
|
||||
assert r[0]['address'] == token_foo
|
||||
assert r[1]['address'] == token_bar
|
||||
assert r[0]['address'] == tx_normalize.executable_address(token_foo)
|
||||
assert r[1]['address'] == tx_normalize.executable_address(token_bar)
|
||||
assert r[0].get('balance_foo') != None
|
||||
assert r[0].get('balance_bar') != None
|
||||
assert r[1].get('balance_baz') != None
|
||||
@@ -74,11 +75,11 @@ def test_outgoing_balance(
|
||||
token_address = '0x' + os.urandom(20).hex()
|
||||
sender = '0x' + os.urandom(20).hex()
|
||||
txc = TxCache(
|
||||
tx_hash,
|
||||
sender,
|
||||
recipient,
|
||||
token_address,
|
||||
token_address,
|
||||
tx_normalize.tx_hash(tx_hash),
|
||||
tx_normalize.wallet_address(sender),
|
||||
tx_normalize.wallet_address(recipient),
|
||||
tx_normalize.executable_address(token_address),
|
||||
tx_normalize.executable_address(token_address),
|
||||
1000,
|
||||
1000,
|
||||
session=init_database,
|
||||
@@ -125,11 +126,11 @@ def test_incoming_balance(
|
||||
token_address = '0x' + os.urandom(20).hex()
|
||||
sender = '0x' + os.urandom(20).hex()
|
||||
txc = TxCache(
|
||||
tx_hash,
|
||||
sender,
|
||||
recipient,
|
||||
token_address,
|
||||
token_address,
|
||||
tx_normalize.tx_hash(tx_hash),
|
||||
tx_normalize.wallet_address(sender),
|
||||
tx_normalize.wallet_address(recipient),
|
||||
tx_normalize.executable_address(token_address),
|
||||
tx_normalize.executable_address(token_address),
|
||||
1000,
|
||||
1000,
|
||||
session=init_database,
|
||||
|
||||
@@ -21,6 +21,7 @@ from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.queue.query import get_upcoming_tx
|
||||
from cic_eth.queue.tx import register_tx
|
||||
from cic_eth.eth.gas import cache_gas_data
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
# test imports
|
||||
from tests.util.nonce import StaticNonceOracle
|
||||
@@ -39,8 +40,8 @@ def test_upcoming_with_lock(
|
||||
gas_oracle = RPCGasOracle(eth_rpc)
|
||||
c = Gas(default_chain_spec, signer=eth_signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
|
||||
|
||||
alice_normal = add_0x(hex_uniform(strip_0x(agent_roles['ALICE'])))
|
||||
bob_normal = add_0x(hex_uniform(strip_0x(agent_roles['BOB'])))
|
||||
alice_normal = tx_normalize.wallet_address(agent_roles['ALICE'])
|
||||
bob_normal = tx_normalize.wallet_address(agent_roles['BOB'])
|
||||
|
||||
(tx_hash_hex, tx_rpc) = c.create(alice_normal, bob_normal, 100 * (10 ** 6))
|
||||
tx_signed_raw_hex = tx_rpc['params'][0]
|
||||
|
||||
@@ -9,7 +9,7 @@ from cic_eth.db.models.lock import Lock
|
||||
from cic_eth.db.enum import LockEnum
|
||||
from cic_eth.error import LockedError
|
||||
from cic_eth.queue.tx import queue_create
|
||||
|
||||
from cic_eth.encode import tx_normalize
|
||||
|
||||
def test_queue_lock(
|
||||
init_database,
|
||||
@@ -21,6 +21,8 @@ def test_queue_lock(
|
||||
address = '0x' + os.urandom(20).hex()
|
||||
tx_hash = '0x' + os.urandom(32).hex()
|
||||
tx_raw = '0x' + os.urandom(128).hex()
|
||||
address_normal = tx_normalize.wallet_address(address)
|
||||
tx_hash_normal = tx_normalize.tx_hash(tx_hash)
|
||||
|
||||
Lock.set(chain_str, LockEnum.QUEUE)
|
||||
with pytest.raises(LockedError):
|
||||
@@ -32,7 +34,7 @@ def test_queue_lock(
|
||||
tx_raw,
|
||||
)
|
||||
|
||||
Lock.set(chain_str, LockEnum.QUEUE, address=address)
|
||||
Lock.set(chain_str, LockEnum.QUEUE, address=address_normal)
|
||||
with pytest.raises(LockedError):
|
||||
queue_create(
|
||||
default_chain_spec,
|
||||
@@ -52,7 +54,7 @@ def test_queue_lock(
|
||||
tx_raw,
|
||||
)
|
||||
|
||||
Lock.set(chain_str, LockEnum.QUEUE, address=address, tx_hash=tx_hash)
|
||||
Lock.set(chain_str, LockEnum.QUEUE, address=address_normal, tx_hash=tx_hash_normal)
|
||||
with pytest.raises(LockedError):
|
||||
queue_create(
|
||||
default_chain_spec,
|
||||
@@ -61,5 +63,3 @@ def test_queue_lock(
|
||||
tx_hash,
|
||||
tx_raw,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
crypto-dev-signer>=0.4.14b7,<=0.4.14
|
||||
chainqueue>=0.0.3a1,<0.1.0
|
||||
confini>=0.3.6rc4,<0.5.0
|
||||
cic-eth-registry>=0.5.8a1,<0.6.0
|
||||
crypto-dev-signer>=0.4.15a7,<=0.4.15
|
||||
chainqueue>=0.0.5a1,<0.1.0
|
||||
cic-eth-registry>=0.6.1a3,<0.7.0
|
||||
redis==3.5.3
|
||||
hexathon~=0.0.1a7
|
||||
hexathon~=0.0.1a8
|
||||
pycryptodome==3.10.1
|
||||
pyxdg==0.27
|
||||
|
||||
@@ -1,35 +1,15 @@
|
||||
|
||||
.cic_meta_variables:
|
||||
variables:
|
||||
APP_NAME: cic-meta
|
||||
DOCKERFILE_PATH: docker/Dockerfile_ci
|
||||
CONTEXT: apps/$APP_NAME
|
||||
|
||||
#build-mr-cic-meta:
|
||||
# extends:
|
||||
# - .py_build_merge_request
|
||||
# - .cic_meta_variables
|
||||
# rules:
|
||||
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
# changes:
|
||||
# - apps/cic-meta/**/*
|
||||
# when: always
|
||||
|
||||
test-mr-cic-meta:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
extends:
|
||||
- .cic_meta_variables
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/$APP_NAME:$MR_IMAGE_TAG
|
||||
script:
|
||||
- cd /root
|
||||
- npm install --dev
|
||||
- npm run test
|
||||
- npm run test:coverage
|
||||
allow_failure: true
|
||||
needs: ["build-merge-request"]
|
||||
rules:
|
||||
build-test-cic-meta:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
variables:
|
||||
APP_NAME: cic-meta
|
||||
MR_IMAGE_TAG: mr-$APP_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
|
||||
script:
|
||||
- cd apps/cic-meta
|
||||
- docker build -t $MR_IMAGE_TAG -f docker/Dockerfile .
|
||||
- docker run --entrypoint=sh $MR_IMAGE_TAG docker/run_tests.sh
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- apps/$APP_NAME/**/*
|
||||
|
||||
1
apps/cic-meta/README.md
Normal file
1
apps/cic-meta/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# CIC-Meta
|
||||
@@ -15,11 +15,10 @@ RUN --mount=type=cache,mode=0755,target=/root/.npm \
|
||||
COPY webpack.config.js .
|
||||
COPY tsconfig.json .
|
||||
## required to build the cic-client-meta module
|
||||
COPY src/ src/
|
||||
COPY scripts/ scripts/
|
||||
COPY tests/ tests/
|
||||
COPY . .
|
||||
COPY tests/*.asc /root/pgp/
|
||||
|
||||
|
||||
## copy runtime configs
|
||||
COPY .config/ /usr/local/etc/cic-meta/
|
||||
#
|
||||
|
||||
7
apps/cic-meta/docker/run_tests.sh
Normal file
7
apps/cic-meta/docker/run_tests.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
npm install --dev
|
||||
npm run test
|
||||
npm run test:coverage
|
||||
@@ -1,41 +1,17 @@
|
||||
.cic_notify_variables:
|
||||
variables:
|
||||
APP_NAME: cic-notify
|
||||
|
||||
#build-mr-cic-notify:
|
||||
# extends:
|
||||
# - .py_build_merge_request
|
||||
# - .cic_notify_variables
|
||||
# rules:
|
||||
# - if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
# changes:
|
||||
# - apps/cic-notify/**/*
|
||||
# when: always
|
||||
|
||||
test-mr-cic-notify:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
extends:
|
||||
- .cic_notify_variables
|
||||
cache:
|
||||
key:
|
||||
files:
|
||||
- test_requirements.txt
|
||||
paths:
|
||||
- /root/.cache/pip
|
||||
image: registry.gitlab.com/grassrootseconomics/cic-internal-integration/$APP_NAME:$MR_IMAGE_TAG
|
||||
script:
|
||||
- cd apps/$APP_NAME/
|
||||
- >
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple
|
||||
-r test_requirements.txt
|
||||
- export PYTHONPATH=. && pytest -x --cov=cic_notify --cov-fail-under=90 --cov-report term-missing tests
|
||||
allow_failure: true
|
||||
needs: ["build-merge-request"]
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- apps/$APP_NAME/**/*
|
||||
when: always
|
||||
build-test-cic-notify:
|
||||
stage: test
|
||||
tags:
|
||||
- integration
|
||||
variables:
|
||||
APP_NAME: cic-notify
|
||||
MR_IMAGE_TAG: mr-$APP_NAME-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
|
||||
script:
|
||||
- cd apps/cic-notify
|
||||
- docker build -t $MR_IMAGE_TAG -f docker/Dockerfile .
|
||||
- docker run $MR_IMAGE_TAG sh docker/run_tests.sh
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
changes:
|
||||
- apps/$APP_NAME/**/*
|
||||
when: always
|
||||
|
||||
@@ -11,12 +11,12 @@ celery_app = celery.current_app
|
||||
|
||||
|
||||
@celery_app.task
|
||||
def persist_notification(recipient, message):
|
||||
def persist_notification(message, recipient):
|
||||
"""
|
||||
:param recipient:
|
||||
:type recipient:
|
||||
:param message:
|
||||
:type message:
|
||||
:param recipient:
|
||||
:type recipient:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
@@ -11,12 +11,13 @@ local_logg = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@celery_app.task
|
||||
def log(recipient, message):
|
||||
def log(message, recipient):
|
||||
"""
|
||||
:param recipient:
|
||||
:type recipient:
|
||||
|
||||
:param message:
|
||||
:type message:
|
||||
:param recipient:
|
||||
:type recipient:
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
|
||||
9
apps/cic-notify/docker/run_tests.sh
Normal file
9
apps/cic-notify/docker/run_tests.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
pip install --extra-index-url https://pip.grassrootseconomics.net:8433 \
|
||||
--extra-index-url https://gitlab.com/api/v4/projects/27624814/packages/pypi/simple \
|
||||
-r test_requirements.txt
|
||||
|
||||
export PYTHONPATH=. && pytest -x --cov=cic_notify --cov-fail-under=90 --cov-report term-missing tests
|
||||
@@ -1,18 +0,0 @@
|
||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
||||
# For additional information regarding the format and rule options, please see:
|
||||
# https://github.com/browserslist/browserslist#queries
|
||||
|
||||
# For the full list of supported browsers by the Angular framework, please see:
|
||||
# https://angular.io/guide/browser-support
|
||||
|
||||
# You can see what browsers were selected by your queries by running:
|
||||
# npx browserslist
|
||||
|
||||
last 1 Chrome version
|
||||
last 1 Firefox version
|
||||
last 2 Edge major versions
|
||||
last 2 Safari major versions
|
||||
last 2 iOS major versions
|
||||
Firefox ESR
|
||||
not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
|
||||
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
||||
@@ -1,3 +0,0 @@
|
||||
.idea/
|
||||
dist/
|
||||
node_modules/
|
||||
@@ -1,16 +0,0 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
||||
@@ -1,12 +0,0 @@
|
||||
# Logging levels => TRACE = 0|DEBUG = 1|INFO = 2|LOG = 3|WARN = 4|ERROR = 5|FATAL = 6|OFF = 7
|
||||
LOG_LEVEL=
|
||||
SERVER_LOG_LEVEL=
|
||||
CIC_CHAIN_ID=
|
||||
CIC_LOGGING_URL=
|
||||
CIC_META_URL=
|
||||
CIC_KEYS_URL=
|
||||
CIC_CACHE_URL=
|
||||
CIC_WEB3_PROVIDER=
|
||||
CIC_USSD_URL=
|
||||
CIC_REGISTRY_ADDRESS=
|
||||
CIC_TRUSTED_ADDRESS=
|
||||
51
apps/cic-staff-client/.gitignore
vendored
51
apps/cic-staff-client/.gitignore
vendored
@@ -1,51 +0,0 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
/tests
|
||||
# Only exists if Bazel was run
|
||||
/bazel-out
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# profiling files
|
||||
chrome-profiler-events*.json
|
||||
speed-measure-plugin*.json
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
/.husky
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Configuration Files
|
||||
.env
|
||||
@@ -1,134 +0,0 @@
|
||||
stages:
|
||||
- build
|
||||
# - test
|
||||
# - package
|
||||
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:debug
|
||||
entrypoint: [""]
|
||||
|
||||
variables:
|
||||
KANIKO_CACHE_ARGS: "--cache=true --cache-copy-layers=true --cache-ttl=24h"
|
||||
|
||||
ng_build_merge_request:
|
||||
stage: build
|
||||
variables:
|
||||
script:
|
||||
- mkdir -p /kaniko/.docker
|
||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > "/kaniko/.docker/config.json"
|
||||
- /kaniko/executor --context . $KANIKO_CACHE_ARGS --cache-repo $CI_REGISTRY_IMAGE --no-push
|
||||
rules:
|
||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
||||
when: always
|
||||
|
||||
ng_build:
|
||||
stage: build
|
||||
variables:
|
||||
IMAGE_TAG_BASE: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
|
||||
LATEST_TAG: $CI_REGISTRY_IMAGE:latest
|
||||
script:
|
||||
- export IMAGE_TAG="$IMAGE_TAG_BASE-$(date +%s)"
|
||||
- mkdir -p /kaniko/.docker
|
||||
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > "/kaniko/.docker/config.json"
|
||||
- /kaniko/executor --context . $KANIKO_CACHE_ARGS --destination $IMAGE_TAG --destination $CI_REGISTRY_IMAGE:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "master"
|
||||
when: always
|
||||
|
||||
|
||||
# cache:
|
||||
# key:
|
||||
# files:
|
||||
# - package-lock.json
|
||||
# paths:
|
||||
# - node_modules/
|
||||
# policy: pull
|
||||
|
||||
# image: node:alpine
|
||||
|
||||
# variables:
|
||||
# PROJECT_PATH: "$CI_PROJECT_DIR"
|
||||
# APP_OUTPUT_PATH: "$CI_PROJECT_DIR/dist/cic-staff-client"
|
||||
# OUTPUT_PATH: "$CI_PROJECT_DIR/dist"
|
||||
# CLI_VERSION: 10.2.0
|
||||
|
||||
# install_dependencies:
|
||||
# stage: install
|
||||
# tags:
|
||||
# - docker
|
||||
# script:
|
||||
# - npm install -g @angular/cli@$CLI_VERSION
|
||||
# - npm install
|
||||
# only:
|
||||
# refs:
|
||||
# - merge_requests
|
||||
# - master
|
||||
# changes:
|
||||
# - package-lock.json
|
||||
|
||||
# build:
|
||||
# stage: build
|
||||
# tags:
|
||||
# - docker
|
||||
# script:
|
||||
# - npm ng build --prod
|
||||
# after_script:
|
||||
# - mv $PROJECT_PATH/nginx.conf $PROJECT_PATH/default.conf
|
||||
# - cp $PROJECT_PATH/default.conf $APP_OUTPUT_PATH
|
||||
# - cp $PROJECT_PATH/Dockerfile $APP_OUTPUT_PATH
|
||||
# artifacts:
|
||||
# name: "cic-staff-client-pipeline"
|
||||
# expire_in: 1 days
|
||||
# paths:
|
||||
# - $APP_OUTPUT_PATH
|
||||
|
||||
# test:karma:
|
||||
# stage: test
|
||||
# allow_failure: false
|
||||
# tags:
|
||||
# - docker
|
||||
# before_script:
|
||||
# - apk add chromium
|
||||
# - export CHROME_BIN=/usr/bin/chromium-browser
|
||||
# script:
|
||||
# - npm ng test --code-coverage --progress false --watch false --browsers=GitlabChromeHeadless
|
||||
# coverage: '/Statements\s+:\s\d+.\d+%/'
|
||||
# artifacts:
|
||||
# name: "tests-and-coverage"
|
||||
# reports:
|
||||
# junit:
|
||||
# - $OUTPUT_PATH/tests/junit-test-results.xml
|
||||
# cobertura:
|
||||
# - $OUTPUT_PATH/coverage/cobetura-coverage.xml
|
||||
# paths:
|
||||
# - coverage/
|
||||
|
||||
# test:e2e:
|
||||
# stage: test
|
||||
# allow_failure: false
|
||||
# tags:
|
||||
# - docker
|
||||
# script:
|
||||
# - npm ng e2e
|
||||
|
||||
# test:nglint:
|
||||
# stage: test
|
||||
# tags:
|
||||
# - docker
|
||||
# script:
|
||||
# - npm ng lint
|
||||
|
||||
# docker-build:
|
||||
# stage: package
|
||||
# image: docker:latest
|
||||
# services:
|
||||
# - docker:dind
|
||||
# variables:
|
||||
# IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA"
|
||||
# before_script:
|
||||
# - docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY
|
||||
# script:
|
||||
# - docker build -t $IMAGE_TAG -f Dockerfile .
|
||||
# - docker push $IMAGE_TAG
|
||||
# only:
|
||||
# - master
|
||||
@@ -1,4 +0,0 @@
|
||||
package.json
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
dist
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"useTabs": false,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always"
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
# defining version of the base image
|
||||
FROM node:alpine as build
|
||||
|
||||
# defining work directory
|
||||
WORKDIR /app
|
||||
|
||||
# copying the json files into the image
|
||||
COPY package*.json .
|
||||
COPY patch-webpack.js .
|
||||
|
||||
# copying rest of project
|
||||
RUN --mount=type=cache,target=/app/.npm \
|
||||
npm set cache /app/.npm && \
|
||||
npm ci
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG FRONTEND_ENV=prod
|
||||
# running build script
|
||||
RUN npm run build:${FRONTEND_ENV}
|
||||
|
||||
### STAGE 2: Setup ###
|
||||
# defining nginx image version
|
||||
FROM nginx:alpine
|
||||
|
||||
## Remove default nginx website
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
# copy dist output from our first image
|
||||
COPY --from=build /app/dist/cic-staff-client /usr/share/nginx/html
|
||||
|
||||
# copy nginx configuration file
|
||||
COPY nginx.conf /etc/nginx/
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD [ "nginx", "-g", "daemon off;" ]
|
||||
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
CIC Staff Client
|
||||
Copyright (C) 2021 Grassroots Economics
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) 2021 Grassroots Economics
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,65 +0,0 @@
|
||||
# CICADA
|
||||
|
||||
An angular admin web client for managing users and transactions in the CIC network.
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.2.0.
|
||||
|
||||
## Angular CLI
|
||||
|
||||
Run `npm install -g @angular/cli` to install the angular CLI.
|
||||
|
||||
## Development server
|
||||
|
||||
Run `ng serve` for a local server, `npm run start:dev` for a dev server and `npm run start:prod` for a prod server..
|
||||
|
||||
Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
|
||||
## Lazy-loading feature modules
|
||||
|
||||
Run `ng generate module module-name --route module-name --module app.module` to generate a new module on route `/module-name` in the app module.
|
||||
|
||||
## Build
|
||||
|
||||
Run `ng build` to build the project using local configurations.
|
||||
The build artifacts will be stored in the `dist/` directory.
|
||||
|
||||
Use the `npm run build:dev` script for a development build and the `npm run build:prod` script for a production build.
|
||||
|
||||
## PWA
|
||||
|
||||
The app supports Progressive Web App capabilities.
|
||||
|
||||
Run `npm run start:pwa` to run the project in PWA mode.
|
||||
PWA mode works using production configurations.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
||||
|
||||
## Environment variables
|
||||
|
||||
Default environment variables are located in the `src/environments/` directory.
|
||||
Custom environment variables are contained in the `.env` file. See `.env.example` for a template.
|
||||
|
||||
Custom environment variables are set via the `set-env.ts` file.
|
||||
Once loaded they will be populated in the directory `src/environments/`.
|
||||
It contains environment variables for development on `environment.dev.ts` and production on `environment.prod.ts`.
|
||||
|
||||
## Code formatting
|
||||
|
||||
The system has automated code formatting using [Prettier](https://prettier.io/) and [TsLint](https://palantir.github.io/tslint/).
|
||||
To view the styling rules set, check out `.prettierrc` and `tslint.json`.
|
||||
|
||||
Run `npm run format:lint` To perform formatting and linting of the codebase.
|
||||
|
||||
## Further help
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
||||
@@ -1,155 +0,0 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"cic-staff-client": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "scss",
|
||||
"changeDetection": "OnPush"
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist/cic-staff-client",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"aot": true,
|
||||
"assets": ["src/favicon.ico", "src/assets", "src/manifest.webmanifest"],
|
||||
"styles": [
|
||||
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
|
||||
"src/styles.scss",
|
||||
"node_modules/bootstrap/dist/css/bootstrap.min.css"
|
||||
],
|
||||
"scripts": [
|
||||
"node_modules/jquery/dist/jquery.js",
|
||||
"node_modules/bootstrap/dist/js/bootstrap.js"
|
||||
],
|
||||
"webWorkerTsConfig": "tsconfig.worker.json"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "2mb",
|
||||
"maximumError": "5mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "6kb",
|
||||
"maximumError": "10kb"
|
||||
}
|
||||
],
|
||||
"serviceWorker": true,
|
||||
"ngswConfigPath": "ngsw-config.json"
|
||||
},
|
||||
"dev": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.dev.ts"
|
||||
}
|
||||
]
|
||||
},
|
||||
"staging": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.staging.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "cic-staff-client:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "cic-staff-client:build:production"
|
||||
},
|
||||
"dev": {
|
||||
"browserTarget": "cic-staff-client:build:dev"
|
||||
},
|
||||
"staging": {
|
||||
"browserTarget": "cic-staff-client:build:staging"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "cic-staff-client:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "src/test.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"karmaConfig": "karma.conf.js",
|
||||
"codeCoverage": true,
|
||||
"assets": ["src/favicon.ico", "src/assets", "src/manifest.webmanifest"],
|
||||
"styles": [
|
||||
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"tsconfig.app.json",
|
||||
"tsconfig.spec.json",
|
||||
"e2e/tsconfig.json",
|
||||
"tsconfig.worker.json"
|
||||
],
|
||||
"exclude": ["**/node_modules/**"]
|
||||
}
|
||||
},
|
||||
"e2e": {
|
||||
"builder": "@angular-devkit/build-angular:protractor",
|
||||
"options": {
|
||||
"protractorConfig": "e2e/protractor.conf.js",
|
||||
"devServerTarget": "cic-staff-client:serve"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"devServerTarget": "cic-staff-client:serve:production"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "cic-staff-client"
|
||||
}
|
||||
@@ -1,866 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>CICADA</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">CICADA</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>AccountIndex</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>src/app/_eth/accountIndex.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Provides an instance of the accounts registry contract.
|
||||
Allows querying of accounts that have been registered as valid accounts in the network.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<p class="comment">
|
||||
<h3>Example</h3>
|
||||
</p>
|
||||
<div class="io-description">
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Properties</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<a href="#contract">contract</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#contractAddress">contractAddress</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#signerAddress">signerAddress</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Methods</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
<a href="#addToAccountRegistry">addToAccountRegistry</a>
|
||||
</li>
|
||||
<li>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
<a href="#haveAccount">haveAccount</a>
|
||||
</li>
|
||||
<li>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
<a href="#last">last</a>
|
||||
</li>
|
||||
<li>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
<a href="#totalAccounts">totalAccounts</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3 id="constructor">Constructor</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<code>constructor(contractAddress: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>, signerAddress?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="26" class="link-to-prism">src/app/_eth/accountIndex.ts:26</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Create a connection to the deployed account registry contract.</p>
|
||||
</div>
|
||||
<div>
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>contractAddress</td>
|
||||
|
||||
<td>
|
||||
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The deployed account registry contract's address.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>signerAddress</td>
|
||||
|
||||
<td>
|
||||
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
Yes
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The account address of the account that deployed the account registry contract.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="inputs">
|
||||
Properties
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="contract"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
contract</b>
|
||||
<a href="#contract"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="22" class="link-to-prism">src/app/_eth/accountIndex.ts:22</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The instance of the account registry contract. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="contractAddress"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
contractAddress</b>
|
||||
<a href="#contractAddress"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="24" class="link-to-prism">src/app/_eth/accountIndex.ts:24</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The deployed account registry contract's address. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="signerAddress"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
signerAddress</b>
|
||||
<a href="#signerAddress"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="26" class="link-to-prism">src/app/_eth/accountIndex.ts:26</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The account address of the account that deployed the account registry contract. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="methods">
|
||||
Methods
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="addToAccountRegistry"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
addToAccountRegistry
|
||||
</b>
|
||||
<a href="#addToAccountRegistry"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<span class="modifier-icon icon ion-ios-reset"></span>
|
||||
<code>addToAccountRegistry(address: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="58"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:58</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Registers an account to the accounts registry.
|
||||
Requires availability of the signer address.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>address</td>
|
||||
<td>
|
||||
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The account address to be registered to the accounts registry contract.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints &quot;true&quot; for registration of &#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await addToAccountRegistry(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<boolean></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>true - If registration is successful or account had already been registered.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="haveAccount"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
haveAccount
|
||||
</b>
|
||||
<a href="#haveAccount"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<span class="modifier-icon icon ion-ios-reset"></span>
|
||||
<code>haveAccount(address: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="79"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:79</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Checks whether a specific account address has been registered in the accounts registry.
|
||||
Returns "true" for available and "false" otherwise.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>address</td>
|
||||
<td>
|
||||
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The account address to be validated.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints &quot;true&quot; or &quot;false&quot; depending on whether &#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39; has been registered:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await haveAccount(&#39;0xc0ffee254729296a45a3885639AC7E10F9d54979&#39;));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<boolean></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>true - If the address has been registered in the accounts registry.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="last"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
last
|
||||
</b>
|
||||
<a href="#last"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<span class="modifier-icon icon ion-ios-reset"></span>
|
||||
<code>last(numberOfAccounts: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="96"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:96</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns a specified number of the most recently registered accounts.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>numberOfAccounts</td>
|
||||
<td>
|
||||
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The number of accounts to return from the accounts registry.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints an array of accounts:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await last(5));</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<Array<string>></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>An array of registered account addresses.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="totalAccounts"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Public</span>
|
||||
<span class="modifier">Async</span>
|
||||
totalAccounts
|
||||
</b>
|
||||
<a href="#totalAccounts"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<span class="modifier-icon icon ion-ios-reset"></span>
|
||||
<code>totalAccounts()</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="122"
|
||||
class="link-to-prism">src/app/_eth/accountIndex.ts:122</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns the total number of accounts that have been registered in the network.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<b>Example :</b>
|
||||
<div>
|
||||
<pre class="line-numbers"><code class="language-html">Prints the total number of registered accounts:</p>
|
||||
<p>```typescript</p>
|
||||
<ul>
|
||||
<li>console.log(await totalAccounts());</li>
|
||||
<li>```</li>
|
||||
</ul></code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<number></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>The total number of registered accounts.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import Web3 from 'web3';
|
||||
|
||||
// Application imports
|
||||
import { Web3Service } from '@app/_services/web3.service';
|
||||
import { environment } from '@src/environments/environment';
|
||||
|
||||
/** Fetch the account registry contract's ABI. */
|
||||
const abi: Array<any> = require('@src/assets/js/block-sync/data/AccountsIndex.json');
|
||||
/** Establish a connection to the blockchain network. */
|
||||
const web3: Web3 = Web3Service.getInstance();
|
||||
|
||||
/**
|
||||
* Provides an instance of the accounts registry contract.
|
||||
* Allows querying of accounts that have been registered as valid accounts in the network.
|
||||
*
|
||||
* @remarks
|
||||
* This is our interface to the accounts registry contract.
|
||||
*/
|
||||
export class AccountIndex {
|
||||
/** The instance of the account registry contract. */
|
||||
contract: any;
|
||||
/** The deployed account registry contract's address. */
|
||||
contractAddress: string;
|
||||
/** The account address of the account that deployed the account registry contract. */
|
||||
signerAddress: string;
|
||||
|
||||
/**
|
||||
* Create a connection to the deployed account registry contract.
|
||||
*
|
||||
* @param contractAddress - The deployed account registry contract's address.
|
||||
* @param signerAddress - The account address of the account that deployed the account registry contract.
|
||||
*/
|
||||
constructor(contractAddress: string, signerAddress?: string) {
|
||||
this.contractAddress = contractAddress;
|
||||
this.contract = new web3.eth.Contract(abi, this.contractAddress);
|
||||
if (signerAddress) {
|
||||
this.signerAddress = signerAddress;
|
||||
} else {
|
||||
this.signerAddress = web3.eth.accounts[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an account to the accounts registry.
|
||||
* Requires availability of the signer address.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints "true" for registration of '0xc0ffee254729296a45a3885639AC7E10F9d54979':
|
||||
* ```typescript
|
||||
* console.log(await addToAccountRegistry('0xc0ffee254729296a45a3885639AC7E10F9d54979'));
|
||||
* ```
|
||||
*
|
||||
* @param address - The account address to be registered to the accounts registry contract.
|
||||
* @returns true - If registration is successful or account had already been registered.
|
||||
*/
|
||||
public async addToAccountRegistry(address: string): Promise<boolean> {
|
||||
if (!(await this.haveAccount(address))) {
|
||||
return await this.contract.methods.add(address).send({ from: this.signerAddress });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a specific account address has been registered in the accounts registry.
|
||||
* Returns "true" for available and "false" otherwise.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints "true" or "false" depending on whether '0xc0ffee254729296a45a3885639AC7E10F9d54979' has been registered:
|
||||
* ```typescript
|
||||
* console.log(await haveAccount('0xc0ffee254729296a45a3885639AC7E10F9d54979'));
|
||||
* ```
|
||||
*
|
||||
* @param address - The account address to be validated.
|
||||
* @returns true - If the address has been registered in the accounts registry.
|
||||
*/
|
||||
public async haveAccount(address: string): Promise<boolean> {
|
||||
return (await this.contract.methods.have(address).call()) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a specified number of the most recently registered accounts.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints an array of accounts:
|
||||
* ```typescript
|
||||
* console.log(await last(5));
|
||||
* ```
|
||||
*
|
||||
* @param numberOfAccounts - The number of accounts to return from the accounts registry.
|
||||
* @returns An array of registered account addresses.
|
||||
*/
|
||||
public async last(numberOfAccounts: number): Promise<Array<string>> {
|
||||
const count: number = await this.totalAccounts();
|
||||
let lowest: number = count - numberOfAccounts;
|
||||
if (lowest < 0) {
|
||||
lowest = 0;
|
||||
}
|
||||
const accounts: Array<string> = [];
|
||||
for (let i = count - 1; i >= lowest; i--) {
|
||||
const account: string = await this.contract.methods.entry(i).call();
|
||||
accounts.push(account);
|
||||
}
|
||||
return accounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of accounts that have been registered in the network.
|
||||
*
|
||||
* @async
|
||||
* @example
|
||||
* Prints the total number of registered accounts:
|
||||
* ```typescript
|
||||
* console.log(await totalAccounts());
|
||||
* ```
|
||||
*
|
||||
* @returns The total number of registered accounts.
|
||||
*/
|
||||
public async totalAccounts(): Promise<number> {
|
||||
return await this.contract.methods.entryCount().call();
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'AccountIndex.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,412 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>CICADA</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">CICADA</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>ActivatedRouteStub</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>src/testing/activated-route-stub.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>An ActivateRoute test double with a <code>paramMap</code> observable.
|
||||
Use the <code>setParamMap()</code> method to add the next <code>paramMap</code> value.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Properties</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<span class="modifier">Readonly</span>
|
||||
<a href="#paramMap">paramMap</a>
|
||||
</li>
|
||||
<li>
|
||||
<span class="modifier">Private</span>
|
||||
<a href="#subject">subject</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Methods</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<a href="#setParamMap">setParamMap</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3 id="constructor">Constructor</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<code>constructor(initialParams?: <a href="https://angular.io/api/router/Params" target="_blank">Params</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="11" class="link-to-prism">src/testing/activated-route-stub.ts:11</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div>
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>initialParams</td>
|
||||
|
||||
<td>
|
||||
<code><a href="https://angular.io/api/router/Params" target="_blank" >Params</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
Yes
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="inputs">
|
||||
Properties
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="paramMap"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Readonly</span>
|
||||
paramMap</b>
|
||||
<a href="#paramMap"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Default value : </i><code>this.subject.asObservable()</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="18" class="link-to-prism">src/testing/activated-route-stub.ts:18</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The mock paramMap observable </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="subject"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Private</span>
|
||||
subject</b>
|
||||
<a href="#subject"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Default value : </i><code>new ReplaySubject<ParamMap>()</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="11" class="link-to-prism">src/testing/activated-route-stub.ts:11</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="methods">
|
||||
Methods
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="setParamMap"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
setParamMap
|
||||
</b>
|
||||
<a href="#setParamMap"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<code>setParamMap(params?: <a href="https://angular.io/api/router/Params" target="_blank">Params</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="21"
|
||||
class="link-to-prism">src/testing/activated-route-stub.ts:21</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Set the paramMap observables's next value </p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>params</td>
|
||||
<td>
|
||||
<code><a href="https://angular.io/api/router/Params" target="_blank" >Params</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
Yes
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { convertToParamMap, ParamMap, Params } from '@angular/router';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
|
||||
/**
|
||||
* An ActivateRoute test double with a `paramMap` observable.
|
||||
* Use the `setParamMap()` method to add the next `paramMap` value.
|
||||
*/
|
||||
export class ActivatedRouteStub {
|
||||
// Use a ReplaySubject to share previous values with subscribers
|
||||
// and pump new values into the `paramMap` observable
|
||||
private subject = new ReplaySubject<ParamMap>();
|
||||
|
||||
constructor(initialParams?: Params) {
|
||||
this.setParamMap(initialParams);
|
||||
}
|
||||
|
||||
/** The mock paramMap observable */
|
||||
readonly paramMap = this.subject.asObservable();
|
||||
|
||||
/** Set the paramMap observables's next value */
|
||||
setParamMap(params?: Params): void {
|
||||
this.subject.next(convertToParamMap(params));
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'ActivatedRouteStub.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,267 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>cic-staff-client documentation</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">cic-staff-client documentation</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>AppPage</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>e2e/src/app.po.ts</code>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Methods</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<a href="#getTitleText">getTitleText</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#navigateTo">navigateTo</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="methods">
|
||||
Methods
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="getTitleText"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
getTitleText
|
||||
</b>
|
||||
<a href="#getTitleText"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<code>getTitleText()</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="8"
|
||||
class="link-to-prism">e2e/src/app.po.ts:8</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<string></code>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="navigateTo"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
navigateTo
|
||||
</b>
|
||||
<a href="#navigateTo"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<code>navigateTo()</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="4"
|
||||
class="link-to-prism">e2e/src/app.po.ts:4</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>Promise<unknown></code>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { browser, by, element } from 'protractor';
|
||||
|
||||
export class AppPage {
|
||||
navigateTo(): Promise<unknown> {
|
||||
return browser.get(browser.baseUrl) as Promise<unknown>;
|
||||
}
|
||||
|
||||
getTitleText(): Promise<string> {
|
||||
return element(by.css('app-root .content span')).getText() as Promise<string>;
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'AppPage.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,369 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>CICADA</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">CICADA</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>BlocksBloom</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>src/app/_models/transaction.ts</code>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Properties</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<a href="#alg">alg</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#blockFilter">blockFilter</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#blocktxFilter">blocktxFilter</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#filterRounds">filterRounds</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#low">low</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="inputs">
|
||||
Properties
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="alg"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
alg</b>
|
||||
<a href="#alg"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="7" class="link-to-prism">src/app/_models/transaction.ts:7</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="blockFilter"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
blockFilter</b>
|
||||
<a href="#blockFilter"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="5" class="link-to-prism">src/app/_models/transaction.ts:5</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="blocktxFilter"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
blocktxFilter</b>
|
||||
<a href="#blocktxFilter"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="6" class="link-to-prism">src/app/_models/transaction.ts:6</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="filterRounds"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
filterRounds</b>
|
||||
<a href="#filterRounds"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="8" class="link-to-prism">src/app/_models/transaction.ts:8</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="low"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
low</b>
|
||||
<a href="#low"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="4" class="link-to-prism">src/app/_models/transaction.ts:4</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { AccountDetails } from '@app/_models/account';
|
||||
|
||||
class BlocksBloom {
|
||||
low: number;
|
||||
blockFilter: string;
|
||||
blocktxFilter: string;
|
||||
alg: string;
|
||||
filterRounds: number;
|
||||
}
|
||||
|
||||
class TxToken {
|
||||
address: string;
|
||||
name: string;
|
||||
symbol: string;
|
||||
}
|
||||
|
||||
class Tx {
|
||||
block: number;
|
||||
success: boolean;
|
||||
timestamp: number;
|
||||
txHash: string;
|
||||
txIndex: number;
|
||||
}
|
||||
|
||||
class Transaction {
|
||||
from: string;
|
||||
sender: AccountDetails;
|
||||
to: string;
|
||||
recipient: AccountDetails;
|
||||
token: TxToken;
|
||||
tx: Tx;
|
||||
value: number;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
class Conversion {
|
||||
destinationToken: TxToken;
|
||||
fromValue: number;
|
||||
sourceToken: TxToken;
|
||||
toValue: number;
|
||||
trader: string;
|
||||
user: AccountDetails;
|
||||
tx: Tx;
|
||||
}
|
||||
|
||||
export { BlocksBloom, TxToken, Tx, Transaction, Conversion };
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'BlocksBloom.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,429 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>CICADA</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">CICADA</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>Conversion</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>src/app/_models/transaction.ts</code>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Properties</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<a href="#destinationToken">destinationToken</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#fromValue">fromValue</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#sourceToken">sourceToken</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#toValue">toValue</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#trader">trader</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#tx">tx</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#user">user</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="inputs">
|
||||
Properties
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="destinationToken"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
destinationToken</b>
|
||||
<a href="#destinationToken"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="../interfaces/Token.html" target="_self" >TxToken</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="37" class="link-to-prism">src/app/_models/transaction.ts:37</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="fromValue"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
fromValue</b>
|
||||
<a href="#fromValue"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="38" class="link-to-prism">src/app/_models/transaction.ts:38</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="sourceToken"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
sourceToken</b>
|
||||
<a href="#sourceToken"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="../interfaces/Token.html" target="_self" >TxToken</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="39" class="link-to-prism">src/app/_models/transaction.ts:39</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="toValue"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
toValue</b>
|
||||
<a href="#toValue"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="40" class="link-to-prism">src/app/_models/transaction.ts:40</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="trader"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
trader</b>
|
||||
<a href="#trader"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="41" class="link-to-prism">src/app/_models/transaction.ts:41</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="tx"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
tx</b>
|
||||
<a href="#tx"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="../classes/Tx.html" target="_self" >Tx</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="43" class="link-to-prism">src/app/_models/transaction.ts:43</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="user"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
user</b>
|
||||
<a href="#user"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="../interfaces/AccountDetails.html" target="_self" >AccountDetails</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="42" class="link-to-prism">src/app/_models/transaction.ts:42</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { AccountDetails } from '@app/_models/account';
|
||||
|
||||
class BlocksBloom {
|
||||
low: number;
|
||||
blockFilter: string;
|
||||
blocktxFilter: string;
|
||||
alg: string;
|
||||
filterRounds: number;
|
||||
}
|
||||
|
||||
class TxToken {
|
||||
address: string;
|
||||
name: string;
|
||||
symbol: string;
|
||||
}
|
||||
|
||||
class Tx {
|
||||
block: number;
|
||||
success: boolean;
|
||||
timestamp: number;
|
||||
txHash: string;
|
||||
txIndex: number;
|
||||
}
|
||||
|
||||
class Transaction {
|
||||
from: string;
|
||||
sender: AccountDetails;
|
||||
to: string;
|
||||
recipient: AccountDetails;
|
||||
token: TxToken;
|
||||
tx: Tx;
|
||||
value: number;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
class Conversion {
|
||||
destinationToken: TxToken;
|
||||
fromValue: number;
|
||||
sourceToken: TxToken;
|
||||
toValue: number;
|
||||
trader: string;
|
||||
user: AccountDetails;
|
||||
tx: Tx;
|
||||
}
|
||||
|
||||
export { BlocksBloom, TxToken, Tx, Transaction, Conversion };
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'Conversion.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,306 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>CICADA</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">CICADA</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>CustomErrorStateMatcher</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>src/app/_helpers/custom-error-state-matcher.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Custom provider that defines how form controls behave with regards to displaying error messages.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<p class="comment">
|
||||
<h3>Implements</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>ErrorStateMatcher</code>
|
||||
</p>
|
||||
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Methods</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<a href="#isErrorState">isErrorState</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="methods">
|
||||
Methods
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="isErrorState"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
isErrorState
|
||||
</b>
|
||||
<a href="#isErrorState"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<code>isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null)</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="17"
|
||||
class="link-to-prism">src/app/_helpers/custom-error-state-matcher.ts:17</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Checks whether an invalid input has been made and an error should be made.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>control</td>
|
||||
<td>
|
||||
<code>FormControl | null</code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Tracks the value and validation status of an individual form control.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>form</td>
|
||||
<td>
|
||||
<code>FormGroupDirective | NgForm | null</code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Binding of an existing FormGroup to a DOM element.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>true - If an invalid input has been made to the form control.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { ErrorStateMatcher } from '@angular/material/core';
|
||||
import { FormControl, FormGroupDirective, NgForm } from '@angular/forms';
|
||||
|
||||
/**
|
||||
* Custom provider that defines how form controls behave with regards to displaying error messages.
|
||||
*
|
||||
*/
|
||||
export class CustomErrorStateMatcher implements ErrorStateMatcher {
|
||||
/**
|
||||
* Checks whether an invalid input has been made and an error should be made.
|
||||
*
|
||||
* @param control - Tracks the value and validation status of an individual form control.
|
||||
* @param form - Binding of an existing FormGroup to a DOM element.
|
||||
* @returns true - If an invalid input has been made to the form control.
|
||||
*/
|
||||
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||
const isSubmitted: boolean = form && form.submitted;
|
||||
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'CustomErrorStateMatcher.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,405 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>CICADA</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">CICADA</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>CustomValidator</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>src/app/_helpers/custom.validator.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Provides methods to perform custom validation to form inputs.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Methods</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<span class="modifier">Static</span>
|
||||
<a href="#passwordMatchValidator">passwordMatchValidator</a>
|
||||
</li>
|
||||
<li>
|
||||
<span class="modifier">Static</span>
|
||||
<a href="#patternValidator">patternValidator</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="methods">
|
||||
Methods
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="passwordMatchValidator"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Static</span>
|
||||
passwordMatchValidator
|
||||
</b>
|
||||
<a href="#passwordMatchValidator"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<span class="modifier-icon icon ion-ios-reset"></span>
|
||||
<code>passwordMatchValidator(control: <a href="https://angular.io/api/forms/AbstractControl" target="_blank">AbstractControl</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="13"
|
||||
class="link-to-prism">src/app/_helpers/custom.validator.ts:13</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Sets errors to the confirm password input field if it does not match with the value in the password input field.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>control</td>
|
||||
<td>
|
||||
<code><a href="https://angular.io/api/forms/AbstractControl" target="_blank" >AbstractControl</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The control object of the form being validated.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="patternValidator"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Static</span>
|
||||
patternValidator
|
||||
</b>
|
||||
<a href="#patternValidator"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<span class="modifier-icon icon ion-ios-reset"></span>
|
||||
<code>patternValidator(regex: RegExp, error: <a href="https://angular.io/api/forms/ValidationErrors" target="_blank">ValidationErrors</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="28"
|
||||
class="link-to-prism">src/app/_helpers/custom.validator.ts:28</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Sets errors to a form field if it does not match with the regular expression given.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>regex</td>
|
||||
<td>
|
||||
<code>RegExp</code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>The regular expression to match with the form field.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>error</td>
|
||||
<td>
|
||||
<code><a href="https://angular.io/api/forms/ValidationErrors" target="_blank" >ValidationErrors</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Defines the map of errors to return from failed validation checks.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<b>Returns : </b> <code>ValidationErrors | null</code>
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
<p>The map of errors returned from failed validation checks.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { AbstractControl, ValidationErrors } from '@angular/forms';
|
||||
|
||||
/**
|
||||
* Provides methods to perform custom validation to form inputs.
|
||||
*/
|
||||
export class CustomValidator {
|
||||
/**
|
||||
* Sets errors to the confirm password input field if it does not match with the value in the password input field.
|
||||
*
|
||||
* @param control - The control object of the form being validated.
|
||||
*/
|
||||
static passwordMatchValidator(control: AbstractControl): void {
|
||||
const password: string = control.get('password').value;
|
||||
const confirmPassword: string = control.get('confirmPassword').value;
|
||||
if (password !== confirmPassword) {
|
||||
control.get('confirmPassword').setErrors({ NoPasswordMatch: true });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets errors to a form field if it does not match with the regular expression given.
|
||||
*
|
||||
* @param regex - The regular expression to match with the form field.
|
||||
* @param error - Defines the map of errors to return from failed validation checks.
|
||||
* @returns The map of errors returned from failed validation checks.
|
||||
*/
|
||||
static patternValidator(regex: RegExp, error: ValidationErrors): ValidationErrors | null {
|
||||
return (control: AbstractControl): { [key: string]: any } => {
|
||||
if (!control.value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const valid: boolean = regex.test(control.value);
|
||||
return valid ? null : error;
|
||||
};
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'CustomValidator.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,444 +0,0 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>CICADA</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
||||
<link rel="stylesheet" href="../styles/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
||||
<a href="../" class="navbar-brand">CICADA</a>
|
||||
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
||||
</div>
|
||||
|
||||
<div class="xs-menu menu" id="mobile-menu">
|
||||
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid main">
|
||||
<div class="row main">
|
||||
<div class="hidden-xs menu">
|
||||
<compodoc-menu mode="normal"></compodoc-menu>
|
||||
</div>
|
||||
<!-- START CONTENT -->
|
||||
<div class="content class">
|
||||
<div class="content-data">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ol class="breadcrumb">
|
||||
<li>Classes</li>
|
||||
<li>HttpError</li>
|
||||
</ol>
|
||||
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="active">
|
||||
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
||||
</li>
|
||||
<li >
|
||||
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade active in" id="c-info">
|
||||
<p class="comment">
|
||||
<h3>File</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>src/app/_helpers/global-error-handler.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>A generalized http response error.</p>
|
||||
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Extends</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<code>Error</code>
|
||||
</p>
|
||||
|
||||
|
||||
<p class="comment">
|
||||
<h3>Example</h3>
|
||||
</p>
|
||||
<div class="io-description">
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
<table class="table table-sm table-bordered index-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<h6><b>Properties</b></h6>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<ul class="index-list">
|
||||
<li>
|
||||
<span class="modifier">Public</span>
|
||||
<a href="#status">status</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3 id="constructor">Constructor</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<code>constructor(message: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank">string</a>, status: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank">number</a>)</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="16" class="link-to-prism">src/app/_helpers/global-error-handler.ts:16</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Initialize the HttpError class.</p>
|
||||
</div>
|
||||
<div>
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>message</td>
|
||||
|
||||
<td>
|
||||
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string" target="_blank" >string</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The message given by the error.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>status</td>
|
||||
|
||||
<td>
|
||||
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
No
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>The status code given by the error.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
||||
<h3 id="inputs">
|
||||
Properties
|
||||
</h3>
|
||||
<table class="table table-sm table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<a name="status"></a>
|
||||
<span class="name">
|
||||
<b>
|
||||
<span class="modifier">Public</span>
|
||||
status</b>
|
||||
<a href="#status"><span class="icon ion-ios-link"></span></a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="16" class="link-to-prism">src/app/_helpers/global-error-handler.ts:16</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>The error's status code. </p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { ErrorHandler, Injectable } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
// Application imports
|
||||
import { LoggingService } from '@app/_services/logging.service';
|
||||
|
||||
/**
|
||||
* A generalized http response error.
|
||||
*
|
||||
* @extends Error
|
||||
*/
|
||||
export class HttpError extends Error {
|
||||
/** The error's status code. */
|
||||
public status: number;
|
||||
|
||||
/**
|
||||
* Initialize the HttpError class.
|
||||
*
|
||||
* @param message - The message given by the error.
|
||||
* @param status - The status code given by the error.
|
||||
*/
|
||||
constructor(message: string, status: number) {
|
||||
super(message);
|
||||
this.status = status;
|
||||
this.name = 'HttpError';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a hook for centralized exception handling.
|
||||
*
|
||||
* @extends ErrorHandler
|
||||
*/
|
||||
@Injectable()
|
||||
export class GlobalErrorHandler extends ErrorHandler {
|
||||
/**
|
||||
* An array of sentence sections that denote warnings.
|
||||
*/
|
||||
private sentencesForWarningLogging: Array<string> = [];
|
||||
|
||||
/**
|
||||
* Initialization of the Global Error Handler.
|
||||
*
|
||||
* @param loggingService - A service that provides logging capabilities.
|
||||
* @param router - A service that provides navigation among views and URL manipulation capabilities.
|
||||
*/
|
||||
constructor(private loggingService: LoggingService, private router: Router) {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles different types of errors.
|
||||
*
|
||||
* @param error - An error objects thrown when a runtime errors occurs.
|
||||
*/
|
||||
handleError(error: Error): void {
|
||||
this.logError(error);
|
||||
const message: string = error.message ? error.message : error.toString();
|
||||
|
||||
// if (error.status) {
|
||||
// error = new Error(message);
|
||||
// }
|
||||
|
||||
const errorTraceString: string = `Error message:\n${message}.\nStack trace: ${error.stack}`;
|
||||
|
||||
const isWarning: boolean = this.isWarning(errorTraceString);
|
||||
if (isWarning) {
|
||||
this.loggingService.sendWarnLevelMessage(errorTraceString, { error });
|
||||
} else {
|
||||
this.loggingService.sendErrorLevelMessage(errorTraceString, this, { error });
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an error is of type warning.
|
||||
*
|
||||
* @param errorTraceString - A description of the error and it's stack trace.
|
||||
* @returns true - If the error is of type warning.
|
||||
*/
|
||||
private isWarning(errorTraceString: string): boolean {
|
||||
let isWarning: boolean = true;
|
||||
if (errorTraceString.includes('/src/app/')) {
|
||||
isWarning = false;
|
||||
}
|
||||
|
||||
this.sentencesForWarningLogging.forEach((whiteListSentence: string) => {
|
||||
if (errorTraceString.includes(whiteListSentence)) {
|
||||
isWarning = true;
|
||||
}
|
||||
});
|
||||
|
||||
return isWarning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write appropriate logs according to the type of error.
|
||||
*
|
||||
* @param error - An error objects thrown when a runtime errors occurs.
|
||||
*/
|
||||
logError(error: any): void {
|
||||
const route: string = this.router.url;
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`There was an HTTP error on route ${route}.\n${error.message}.\nStatus code: ${
|
||||
(error as HttpErrorResponse).status
|
||||
}`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
} else if (error instanceof TypeError) {
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`There was a Type error on route ${route}.\n${error.message}`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
} else if (error instanceof Error) {
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`There was a general error on route ${route}.\n${error.message}`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
} else {
|
||||
this.loggingService.sendErrorLevelMessage(
|
||||
`Nobody threw an error but something happened on route ${route}!`,
|
||||
this,
|
||||
{ error }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function rejectBody(error): { status: any; statusText: any } {
|
||||
return {
|
||||
status: error.status,
|
||||
statusText: error.statusText,
|
||||
};
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div><div class="search-results">
|
||||
<div class="has-results">
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
</div>
|
||||
<div class="no-results">
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END CONTENT -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
||||
var COMPODOC_CURRENT_PAGE_CONTEXT = 'class';
|
||||
var COMPODOC_CURRENT_PAGE_URL = 'HttpError.html';
|
||||
var MAX_SEARCH_RESULTS = 15;
|
||||
</script>
|
||||
|
||||
<script src="../js/libs/custom-elements.min.js"></script>
|
||||
<script src="../js/libs/lit-html.js"></script>
|
||||
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
||||
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
||||
<script src="../js/menu-wc.js" defer></script>
|
||||
|
||||
<script src="../js/libs/bootstrap-native.js"></script>
|
||||
|
||||
<script src="../js/libs/es6-shim.min.js"></script>
|
||||
<script src="../js/libs/EventDispatcher.js"></script>
|
||||
<script src="../js/libs/promise.min.js"></script>
|
||||
<script src="../js/libs/zepto.min.js"></script>
|
||||
|
||||
<script src="../js/compodoc.js"></script>
|
||||
|
||||
<script src="../js/tabs.js"></script>
|
||||
<script src="../js/menu.js"></script>
|
||||
<script src="../js/libs/clipboard.min.js"></script>
|
||||
<script src="../js/libs/prism.js"></script>
|
||||
<script src="../js/sourceCode.js"></script>
|
||||
<script src="../js/search/search.js"></script>
|
||||
<script src="../js/search/lunr.min.js"></script>
|
||||
<script src="../js/search/search-lunr.js"></script>
|
||||
<script src="../js/search/search_index.js"></script>
|
||||
<script src="../js/lazy-load-graphs.js"></script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user