From be994c98da61c88c4f70559d69cdf17944ff04fe Mon Sep 17 00:00:00 2001 From: ice-hermes <83634377+ice-hermes@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:51:21 +0200 Subject: [PATCH] Apply rebranding changes (#2) --- .dockerignore | 2 +- .github/workflows/build-docker.yml | 10 +- .github/workflows/build-wheel.yml | 22 ++-- .gitignore | 4 +- README.md | 92 ++++++------- configure.py | 36 ++--- docker-compose.yaml | 40 +++--- .../.docker/Dockerfile | 0 ion-http-api/.docker/entrypoint.sh | 9 ++ {ton-http-api => ion-http-api}/README.md | 80 +++++------ .../pyTON => ion-http-api/pyION}/__init__.py | 0 .../pyTON => ion-http-api/pyION}/__main__.py | 34 ++--- .../pyTON => ion-http-api/pyION}/cache.py | 2 +- .../pyTON => ion-http-api/pyION}/main.py | 124 +++++++++--------- .../pyTON => ion-http-api/pyION}/manager.py | 8 +- .../pyTON => ion-http-api/pyION}/models.py | 6 +- .../pyTON => ion-http-api/pyION}/settings.py | 32 ++--- .../pyTON => ion-http-api/pyION}/worker.py | 4 +- .../requirements.txt | 0 {ton-http-api => ion-http-api}/setup.py | 10 +- scripts/deploy.sh | 2 +- scripts/setup.sh | 4 +- scripts/update_init_block.sh | 4 +- ton-http-api/.docker/entrypoint.sh | 9 -- 24 files changed, 267 insertions(+), 267 deletions(-) rename {ton-http-api => ion-http-api}/.docker/Dockerfile (100%) create mode 100644 ion-http-api/.docker/entrypoint.sh rename {ton-http-api => ion-http-api}/README.md (63%) rename {ton-http-api/pyTON => ion-http-api/pyION}/__init__.py (100%) rename {ton-http-api/pyTON => ion-http-api/pyION}/__main__.py (70%) rename {ton-http-api/pyTON => ion-http-api/pyION}/cache.py (96%) rename {ton-http-api/pyTON => ion-http-api/pyION}/main.py (88%) rename {ton-http-api/pyTON => ion-http-api/pyION}/manager.py (99%) rename {ton-http-api/pyTON => ion-http-api/pyION}/models.py (89%) rename {ton-http-api/pyTON => ion-http-api/pyION}/settings.py (77%) rename {ton-http-api/pyTON => ion-http-api/pyION}/worker.py (98%) rename {ton-http-api => ion-http-api}/requirements.txt (100%) rename {ton-http-api => ion-http-api}/setup.py (83%) delete mode 100644 ton-http-api/.docker/entrypoint.sh diff --git a/.dockerignore b/.dockerignore index c9c37be..2c5574d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -110,7 +110,7 @@ venv.bak/ .idea/inspectionProfiles/ .idea/misc.xml .idea/modules.xml -.idea/ton_client.iml +.idea/ion_client.iml .idea/vcs.xml ## tonlib chaotically created temp blkstate files diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 67b1de3..eaea212 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -50,7 +50,7 @@ jobs: - name: Prepare id: prepare run: | - DOCKER_IMAGE=toncenter/ton-http-api + DOCKER_IMAGE=ice-blockchain/ion-http-api if ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} then @@ -65,7 +65,7 @@ jobs: echo ::set-output name=docker_image::${DOCKER_IMAGE} echo ::set-output name=version::${VERSION} echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ - ${TAGS} --file ton-http-api/.docker/Dockerfile ton-http-api \ + ${TAGS} --file ion-http-api/.docker/Dockerfile ion-http-api \ --cache-from=${DOCKER_IMAGE}:latest echo "Pulling latest image for cache" @@ -79,16 +79,16 @@ jobs: run: | docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} - name: Login to DockerHub - if: success() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' + if: success() && github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Docker Buildx (push) - if: success() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' + if: success() && github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' run: | docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} - name: Inspect image - if: always() && github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' + if: always() && github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' run: | docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} diff --git a/.github/workflows/build-wheel.yml b/.github/workflows/build-wheel.yml index 4fa0919..c841143 100644 --- a/.github/workflows/build-wheel.yml +++ b/.github/workflows/build-wheel.yml @@ -39,27 +39,27 @@ jobs: python-version: 3.8 - name: Install build dependencies shell: bash -l {0} - working-directory: ./ton-http-api/ + working-directory: ./ion-http-api/ run: | python -m pip install build wheel python -m pip install -r requirements.txt - name: Build distributions shell: bash -l {0} - working-directory: ./ton-http-api/ - run: TON_HTTP_API_VERSION=${{ needs.set_version.outputs.version }} python setup.py sdist bdist_wheel + working-directory: ./ion-http-api/ + run: ION_HTTP_API_VERSION=${{ needs.set_version.outputs.version }} python setup.py sdist bdist_wheel - name: Check distributions shell: bash -l {0} - working-directory: ./ton-http-api/ + working-directory: ./ion-http-api/ run: | echo $(pwd) ls $(pwd)/ - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: ton-http-api-package + name: ion-http-api-package path: | - ton-http-api/dist/*.whl - ton-http-api/dist/*.tar.gz + ion-http-api/dist/*.whl + ion-http-api/dist/*.tar.gz upload-pypi: runs-on: ubuntu-20.04 needs: [ set_version, build_wheel ] @@ -67,13 +67,13 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - name: ton-http-api-package + name: ion-http-api-package path: dist - name: Check distributions shell: bash -l {0} run: ls -la dist/ - name: Create release tag - if: ${{ github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }} + if: ${{ github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: actions/github-script@v3 with: github-token: ${{ github.token }} @@ -85,14 +85,14 @@ jobs: sha: context.sha }) - name: Publish package to test PyPI - if: ${{ github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' }} + if: ${{ github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' }} uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.TEST_PYPI_PASSWORD }} repository_url: https://test.pypi.org/legacy/ - name: Publish package to PyPI - if: ${{ github.repository == 'toncenter/ton-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }} + if: ${{ github.repository == 'ice-blockchain/ion-http-api' && github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ diff --git a/.gitignore b/.gitignore index c68d663..cab421b 100644 --- a/.gitignore +++ b/.gitignore @@ -111,7 +111,7 @@ venv.bak/ .idea/inspectionProfiles/ .idea/misc.xml .idea/modules.xml -.idea/ton_client.iml +.idea/ion_client.iml .idea/vcs.xml ## tonlib chaotically created temp blkstate files @@ -125,4 +125,4 @@ venv.bak/ .DS_Store /sandbox -/ton_keystore +/ion_keystore diff --git a/README.md b/README.md index 27e0093..6a3d12f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ ![splash_http_api](https://user-images.githubusercontent.com/1449561/154847286-989a6c51-1615-45e1-b40f-aec7c13014fa.png) -# HTTP API for [The Open Network](https://ton.org) +# HTTP API for [Ice Open Network](https://ion.org) -[![PyPI](https://img.shields.io/pypi/v/ton-http-api?color=blue)](https://pypi.org/project/ton-http-api/) -[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ton-http-api)](https://pypi.org/project/ton-http-api/) -[![Docker - Image Version](https://img.shields.io/docker/v/toncenter/ton-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/toncenter/ton-http-api) -[![Docker - Image Size](https://img.shields.io/docker/image-size/toncenter/ton-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/toncenter/ton-http-api) -![Github last commit](https://img.shields.io/github/last-commit/toncenter/ton-http-api) +[![PyPI](https://img.shields.io/pypi/v/ion-http-api?color=blue)](https://pypi.org/project/ion-http-api/) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ion-http-api)](https://pypi.org/project/ion-http-api/) +[![Docker - Image Version](https://img.shields.io/docker/v/ice-blockchain/ion-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/ice-blockchain/ion-http-api) +[![Docker - Image Size](https://img.shields.io/docker/image-size/ice-blockchain/ion-http-api?label=docker&sort=semver)](https://hub.docker.com/repository/docker/ice-blockchain/ion-http-api) +![Github last commit](https://img.shields.io/github/last-commit/ice-blockchain/ion-http-api) -Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection. +Since ION nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection. -TON HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the TON network using `tonlibjson`. +ION HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the ION network using `tonlibjson`. -You can use the ready-made [toncenter.com](https://toncenter.com) service or start your own instance. +You can use the ready-made [ice-blockchain.com](https://ice-blockchain.com) service or start your own instance. ## Building and running @@ -21,27 +21,27 @@ Recommended hardware: - HTTP API only: 1 vCPU, 2 GB RAM. - HTTP API with cache enabled: 2 vCPUs, 4 GB RAM. -There are two main ways to run TON HTTP API: +There are two main ways to run ION HTTP API: - __Local__ *(experimental)*: works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64). - __Docker Compose__: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available. ### Local run *(experimental)* **Note:** It is simple but not stable way to run the service. We do not recommend to use it in production. - (Windows only, first time) Install OpenSSL v1.1.1 for win64 from [here](https://slproweb.com/products/Win32OpenSSL.html). - - Install package: `pip install ton-http-api`. - - Run service with `ton-http-api`. This command will run service with [mainnet](https://ton.org/global-config.json) configuration. - - Run `ton-http-api --help` to show parameters list. + - Install package: `pip install ion-http-api`. + - Run service with `ion-http-api`. This command will run service with [mainnet](https://cdn.ice.io/mainnet/global.config.json) configuration. + - Run `ion-http-api --help` to show parameters list. ### Docker Compose - (First time) Install required tools: `docker`, `docker-compose`, `curl`. - For Ubuntu: run `scripts/setup.sh` from the root of the repo. - For MacOS and Windows: install [Docker Desktop](https://www.docker.com/products/docker-desktop/). - **Note:** we recommend to use Docker Compose V2. - - Download TON configuration files to private folder: + - Download ION configuration files to private folder: ```bash mkdir private - curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json - curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json + curl -sL https://cdn.ice.io/mainnet/global.config.json > private/mainnet.json + curl -sL https://cdn.ice.io/testnet/testnet-global.config.json > private/testnet.json ``` - Run `./configure.py` to create `.env` file with necessary environment variables (see [Configuration](#Configuration) for details). - Build services: `docker-compose build`. @@ -53,79 +53,79 @@ There are two main ways to run TON HTTP API: You should specify environment parameters and run `./configure.py` to create `.env` file. ```bash - export TON_API_LITESERVER_CONFIG=private/testnet.json + export ION_API_LITESERVER_CONFIG=private/testnet.json ./configure.py ``` The service supports the following environment variables: #### Webserver settings -- `TON_API_HTTP_PORT` *(default: 80)* +- `ION_API_HTTP_PORT` *(default: 80)* Port for HTTP connections of API service. -- `TON_API_ROOT_PATH` *(default: /)* +- `ION_API_ROOT_PATH` *(default: /)* If you use a proxy server such as Nginx or Traefik you might change the default API path prefix (e.g. `/api/v2`). If so you have to pass the path prefix to the API service in this variable. -- `TON_API_WEBSERVERS_WORKERS` *(default: 1)* +- `ION_API_WEBSERVERS_WORKERS` *(default: 1)* Number of webserver processes. If your server is under high load try increase this value to increase RPS. We recommend setting it to number of CPU cores / 2. -- `TON_API_GET_METHODS_ENABLED` *(default: 1)* +- `ION_API_GET_METHODS_ENABLED` *(default: 1)* Enables `runGetMethod` endpoint. -- `TON_API_JSON_RPC_ENABLED` *(default: 1)* +- `ION_API_JSON_RPC_ENABLED` *(default: 1)* Enables `jsonRPC` endpoint. -- `TON_API_LOGS_JSONIFY` *(default: 0)* +- `ION_API_LOGS_JSONIFY` *(default: 0)* Enables printing all logs in json format. -- `TON_API_LOGS_LEVEL` *(default: ERROR)* +- `ION_API_LOGS_LEVEL` *(default: ERROR)* Defines log verbosity level. Values allowed: `DEBUG`,`INFO`,`WARNING`,`ERROR`,`CRITICAL`. -- `TON_API_GUNICORN_FLAGS` *(default: empty)* +- `ION_API_GUNICORN_FLAGS` *(default: empty)* Additional Gunicorn [command line arguments](https://docs.gunicorn.org/en/stable/settings.html). #### Tonlib settings -- `TON_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://ton.org/global-config.json)* +- `ION_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://cdn.ice.io/mainnet/global.config.json)* Path to config file with lite servers information. In case of native run you can pass URL to download config. Docker support only path to file. -- `TON_API_TONLIB_KEYSTORE` *(default docker: /tmp/ton_keystore local: ./ton_keystore/)* +- `ION_API_TONLIB_KEYSTORE` *(default docker: /tmp/ion_keystore local: ./ion_keystore/)* Path to tonlib keystore. -- `TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)* +- `ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)* Number of maximum parallel requests count per worker. -- `TON_API_TONLIB_CDLL_PATH` *(default: empty)* +- `ION_API_TONLIB_CDLL_PATH` *(default: empty)* Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the `libtonlibjson` library manually. -- `TON_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)* +- `ION_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)* Timeout for liteserver requests. #### Cache configuration -- `TON_API_CACHE_ENABLED` *(default: 0)* +- `ION_API_CACHE_ENABLED` *(default: 0)* Enables caching lite server responses with Redis. -- `TON_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)* +- `ION_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)* Redis cache service host. -- `TON_API_CACHE_REDIS_PORT` *(default: 6379)* +- `ION_API_CACHE_REDIS_PORT` *(default: 6379)* Redis cache service port. -- `TON_API_CACHE_REDIS_TIMEOUT` *(default: 1)* +- `ION_API_CACHE_REDIS_TIMEOUT` *(default: 1)* Redis cache timeout. @@ -133,33 +133,33 @@ The service supports the following environment variables: ## FAQ #### How to point the service to my own lite server? -To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server. +To point the HTTP API to your own lite server you should set `ION_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server. -- If you use MyTonCtrl on your node you can generate config file with these commands: +- If you use MyIonCtrl on your node you can generate config file with these commands: ``` - $ mytonctrl - MyTonCtrl> installer - MyTonInstaller> clcf + $ myionctrl + MyIonCtrl> installer + MyIonInstaller> clcf ``` - Config file will be saved at `/usr/bin/ton/local.config.json`. -- If you don't use MyTonCtrl: copy `private/mainnet.json` and overwrite section `liteservers` with your liteservers ip, port and public key. To get public key from `liteserver.pub` file use the following script: + Config file will be saved at `/usr/bin/ion/local.config.json`. +- If you don't use MyIonCtrl: copy `private/mainnet.json` and overwrite section `liteservers` with your liteservers ip, port and public key. To get public key from `liteserver.pub` file use the following script: ``` python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))' ``` -- The config generated with `mytonctrl` > `installer` > `clcf` adds the public IP of your server in the config file. If there's an active firewall on your server, `ton-http-api` won't be able to connect to the local lite server. In that case, replace the value of lite server's `ip` in `local.config.json` with `2130706433`, which is the integer equivalent of `127.0.0.1` / `localhost`. -- Once config file is created assign variable `TON_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project. +- The config generated with `myionctrl` > `installer` > `clcf` adds the public IP of your server in the config file. If there's an active firewall on your server, `ion-http-api` won't be able to connect to the local lite server. In that case, replace the value of lite server's `ip` in `local.config.json` with `2130706433`, which is the integer equivalent of `127.0.0.1` / `localhost`. +- Once config file is created assign variable `ION_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project. #### How to run multiple API instances on single machine? - Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict). -- Configure each instance to use unique port (env variable `TON_API_HTTP_PORT`) +- Configure each instance to use unique port (env variable `ION_API_HTTP_PORT`) - Build and run every instance. #### How to update tonlibjson library? -Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib). +Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/ice-blockchain/pytonlib). - Docker Compose: `docker-compose build --no-cache`. -- Local run: `pip install -U ton-http-api`. +- Local run: `pip install -U ion-http-api`. ### No working liteservers error. diff --git a/configure.py b/configure.py index bbec739..20aae37 100755 --- a/configure.py +++ b/configure.py @@ -5,23 +5,23 @@ LOCAL_ENV = { - 'TON_API_CACHE_ENABLED': '0', - 'TON_API_CACHE_REDIS_ENDPOINT': 'cache_redis', - 'TON_API_CACHE_REDIS_PORT': '6379', - 'TON_API_CACHE_REDIS_TIMEOUT': '1', - 'TON_API_LOGS_JSONIFY': '0', - 'TON_API_LOGS_LEVEL': 'ERROR', - 'TON_API_GET_METHODS_ENABLED': '1', - 'TON_API_HTTP_PORT': '80', - 'TON_API_JSON_RPC_ENABLED': '1', - 'TON_API_ROOT_PATH': '/', - 'TON_API_WEBSERVERS_WORKERS': '1', - 'TON_API_TONLIB_LITESERVER_CONFIG': 'private/mainnet.json', - 'TON_API_TONLIB_KEYSTORE': '/tmp/ton_keystore/', - 'TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER': '50', - 'TON_API_TONLIB_CDLL_PATH': '', - 'TON_API_TONLIB_REQUEST_TIMEOUT': '10', - 'TON_API_GUNICORN_FLAGS': '' + 'ION_API_CACHE_ENABLED': '0', + 'ION_API_CACHE_REDIS_ENDPOINT': 'cache_redis', + 'ION_API_CACHE_REDIS_PORT': '6379', + 'ION_API_CACHE_REDIS_TIMEOUT': '1', + 'ION_API_LOGS_JSONIFY': '0', + 'ION_API_LOGS_LEVEL': 'ERROR', + 'ION_API_GET_METHODS_ENABLED': '1', + 'ION_API_HTTP_PORT': '80', + 'ION_API_JSON_RPC_ENABLED': '1', + 'ION_API_ROOT_PATH': '/', + 'ION_API_WEBSERVERS_WORKERS': '1', + 'ION_API_TONLIB_LITESERVER_CONFIG': 'private/mainnet.json', + 'ION_API_TONLIB_KEYSTORE': '/tmp/ion_keystore/', + 'ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER': '50', + 'ION_API_TONLIB_CDLL_PATH': '', + 'ION_API_TONLIB_REQUEST_TIMEOUT': '10', + 'ION_API_GUNICORN_FLAGS': '' } @@ -41,7 +41,7 @@ def main(): compose_file = 'docker-compose.yaml' - cache_enabled = strtobool(default_env['TON_API_CACHE_ENABLED']) + cache_enabled = strtobool(default_env['ION_API_CACHE_ENABLED']) if cache_enabled: compose_file += ':docker-compose.cache.yaml' default_env['COMPOSE_FILE'] = compose_file diff --git a/docker-compose.yaml b/docker-compose.yaml index 1e19b87..d00d90d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,40 +1,40 @@ version: '3.7' services: main: - image: toncenter/ton-http-api + image: ice-blockchain/ion-http-api build: - context: ton-http-api + context: ion-http-api dockerfile: .docker/Dockerfile ports: - - ${TON_API_HTTP_PORT:-8081}:8081 + - ${ION_API_HTTP_PORT:-8081}:8081 environment: - - TON_API_CACHE_ENABLED - - TON_API_CACHE_REDIS_ENDPOINT - - TON_API_CACHE_REDIS_PORT - - TON_API_CACHE_REDIS_TIMEOUT - - TON_API_LOGS_JSONIFY - - TON_API_LOGS_LEVEL - - TON_API_TONLIB_LITESERVER_CONFIG=/run/secrets/liteserver_config - - TON_API_TONLIB_KEYSTORE - - TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER - - TON_API_TONLIB_CDLL_PATH - - TON_API_TONLIB_REQUEST_TIMEOUT - - TON_API_GET_METHODS_ENABLED - - TON_API_JSON_RPC_ENABLED - - TON_API_ROOT_PATH + - ION_API_CACHE_ENABLED + - ION_API_CACHE_REDIS_ENDPOINT + - ION_API_CACHE_REDIS_PORT + - ION_API_CACHE_REDIS_TIMEOUT + - ION_API_LOGS_JSONIFY + - ION_API_LOGS_LEVEL + - ION_API_TONLIB_LITESERVER_CONFIG=/run/secrets/liteserver_config + - ION_API_TONLIB_KEYSTORE + - ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER + - ION_API_TONLIB_CDLL_PATH + - ION_API_TONLIB_REQUEST_TIMEOUT + - ION_API_GET_METHODS_ENABLED + - ION_API_JSON_RPC_ENABLED + - ION_API_ROOT_PATH restart: unless-stopped networks: - internal secrets: - liteserver_config - command: -c "gunicorn -k uvicorn.workers.UvicornWorker -w ${TON_API_WEBSERVERS_WORKERS} --bind 0.0.0.0:8081 ${TON_API_GUNICORN_FLAGS} pyTON.main:app" + command: -c "gunicorn -k uvicorn.workers.UvicornWorker -w ${ION_API_WEBSERVERS_WORKERS} --bind 0.0.0.0:8081 ${ION_API_GUNICORN_FLAGS} pyION.main:app" healthcheck: - test: curl -sS http://127.0.0.1:8081${TON_API_ROOT_PATH}/healthcheck || echo 1 + test: curl -sS http://127.0.0.1:8081${ION_API_ROOT_PATH}/healthcheck || echo 1 interval: 15s timeout: 3s retries: 12 secrets: liteserver_config: - file: ${TON_API_TONLIB_LITESERVER_CONFIG:-./private/mainnet.json} + file: ${ION_API_TONLIB_LITESERVER_CONFIG:-./private/mainnet.json} networks: internal: diff --git a/ton-http-api/.docker/Dockerfile b/ion-http-api/.docker/Dockerfile similarity index 100% rename from ton-http-api/.docker/Dockerfile rename to ion-http-api/.docker/Dockerfile diff --git a/ion-http-api/.docker/entrypoint.sh b/ion-http-api/.docker/entrypoint.sh new file mode 100644 index 0000000..5948e9a --- /dev/null +++ b/ion-http-api/.docker/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +echo "Running api with ${ION_API_WEBSERVERS_WORKERS:-1} workers" +echo "ENVIRONMENT:" +printenv + +gunicorn -k uvicorn.workers.UvicornWorker -w ${ION_API_WEBSERVERS_WORKERS:-1} --bind 0.0.0.0:8081 pyION.main:app diff --git a/ton-http-api/README.md b/ion-http-api/README.md similarity index 63% rename from ton-http-api/README.md rename to ion-http-api/README.md index ad40066..d772697 100644 --- a/ton-http-api/README.md +++ b/ion-http-api/README.md @@ -1,12 +1,12 @@ ![splash_http_api](https://user-images.githubusercontent.com/1449561/154847286-989a6c51-1615-45e1-b40f-aec7c13014fa.png) -# HTTP API for [The Open Network](https://ton.org) +# HTTP API for [Ice Open Network](https://ion.org) -Since TON nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection. +Since ION nodes uses its own ADNL binary transport protocol, a intermediate service is needed for an HTTP connection. -TON HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the TON network using `tonlibjson`. +ION HTTP API is such a intermediate service, receiving requests via HTTP, it accesses the lite servers of the ION network using `tonlibjson`. -You can use the ready-made [toncenter.com](https://toncenter.com) service or start your own instance. +You can use the ready-made [ice-blockchain.com](https://ice-blockchain.com) service or start your own instance. ## Building and running @@ -15,27 +15,27 @@ Recommended hardware: - HTTP API only: 1 vCPU, 2 GB RAM. - HTTP API with cache enabled: 2 vCPUs, 4 GB RAM. -There are two main ways to run TON HTTP API: +There are two main ways to run ION HTTP API: - __Local__ *(experimental)*: works on following platforms: Ubuntu Linux (x86_64, arm64), MacOSX (Intel x86_64, Apple M1 arm64) and Windows (x86_64). - __Docker Compose__: flexible configuration, recommended for production environments, works on any x86_64 and arm64 OS with Docker available. ### Local run *(experimental)* **Note:** It is simple but not stable way to run the service. We do not recommend to use it in production. - (Windows only, first time) Install OpenSSL v1.1.1 for win64 from [here](https://slproweb.com/products/Win32OpenSSL.html). - - Install package: `pip install ton-http-api`. - - Run service with `ton-http-api`. This command will run service with [mainnet](https://ton.org/global-config.json) configuration. - - Run `ton-http-api --help` to show parameters list. + - Install package: `pip install ion-http-api`. + - Run service with `ion-http-api`. This command will run service with [mainnet](https://cdn.ice.io/mainnet/global.config.json) configuration. + - Run `ion-http-api --help` to show parameters list. ### Docker Compose - (First time) Install required tools: `docker`, `docker-compose`, `curl`. - For Ubuntu: run `scripts/setup.sh` from the root of the repo. - For MacOS and Windows: install [Docker Desktop](https://www.docker.com/products/docker-desktop/). - **Note:** we recommend to use Docker Compose V2. - - Download TON configuration files to private folder: + - Download ION configuration files to private folder: ```bash mkdir private - curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json - curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json + curl -sL https://cdn.ice.io/mainnet/global.config.json > private/mainnet.json + curl -sL https://cdn.ice.io/testnet/testnet-global.config.json > private/testnet.json ``` - Run `./configure.py` to create `.env` file with necessary environment variables (see [Configuration](#Configuration) for details). - Build services: `docker-compose build`. @@ -47,79 +47,79 @@ There are two main ways to run TON HTTP API: You should specify environment parameters and run `./configure.py` to create `.env` file. ```bash - export TON_API_LITESERVER_CONFIG=private/testnet.json + export ION_API_LITESERVER_CONFIG=private/testnet.json ./configure.py ``` The service supports the following environment variables: #### Webserver settings -- `TON_API_HTTP_PORT` *(default: 80)* +- `ION_API_HTTP_PORT` *(default: 80)* Port for HTTP connections of API service. -- `TON_API_ROOT_PATH` *(default: /)* +- `ION_API_ROOT_PATH` *(default: /)* If you use a proxy server such as Nginx or Traefik you might change the default API path prefix (e.g. `/api/v2`). If so you have to pass the path prefix to the API service in this variable. -- `TON_API_WEBSERVERS_WORKERS` *(default: 1)* +- `ION_API_WEBSERVERS_WORKERS` *(default: 1)* Number of webserver processes. If your server is under high load try increase this value to increase RPS. We recommend setting it to number of CPU cores / 2. -- `TON_API_GET_METHODS_ENABLED` *(default: 1)* +- `ION_API_GET_METHODS_ENABLED` *(default: 1)* Enables `runGetMethod` endpoint. -- `TON_API_JSON_RPC_ENABLED` *(default: 1)* +- `ION_API_JSON_RPC_ENABLED` *(default: 1)* Enables `jsonRPC` endpoint. -- `TON_API_LOGS_JSONIFY` *(default: 0)* +- `ION_API_LOGS_JSONIFY` *(default: 0)* Enables printing all logs in json format. -- `TON_API_LOGS_LEVEL` *(default: ERROR)* +- `ION_API_LOGS_LEVEL` *(default: ERROR)* Defines log verbosity level. Values allowed: `DEBUG`,`INFO`,`WARNING`,`ERROR`,`CRITICAL`. -- `TON_API_GUNICORN_FLAGS` *(default: empty)* +- `ION_API_GUNICORN_FLAGS` *(default: empty)* Additional Gunicorn [command line arguments](https://docs.gunicorn.org/en/stable/settings.html). #### Tonlib settings -- `TON_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://ton.org/global-config.json)* +- `ION_API_TONLIB_LITESERVER_CONFIG` *(default docker: private/mainnet.json local: https://cdn.ice.io/mainnet/global.config.json)* Path to config file with lite servers information. In case of native run you can pass URL to download config. Docker support only path to file. -- `TON_API_TONLIB_KEYSTORE` *(default docker: /tmp/ton_keystore local: ./ton_keystore/)* +- `ION_API_TONLIB_KEYSTORE` *(default docker: /tmp/ion_keystore local: ./ion_keystore/)* Path to tonlib keystore. -- `TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)* +- `ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER` *(default: 50)* Number of maximum parallel requests count per worker. -- `TON_API_TONLIB_CDLL_PATH` *(default: empty)* +- `ION_API_TONLIB_CDLL_PATH` *(default: empty)* Path to tonlibjson binary. It could be useful if you want to run service on unsupported platform and have built the `libtonlibjson` library manually. -- `TON_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)* +- `ION_API_TONLIB_REQUEST_TIMEOUT` *(default: 10)* Timeout for liteserver requests. #### Cache configuration -- `TON_API_CACHE_ENABLED` *(default: 0)* +- `ION_API_CACHE_ENABLED` *(default: 0)* Enables caching lite server responses with Redis. -- `TON_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)* +- `ION_API_CACHE_REDIS_ENDPOINT` *(default: localhost, docker: cache_redis)* Redis cache service host. -- `TON_API_CACHE_REDIS_PORT` *(default: 6379)* +- `ION_API_CACHE_REDIS_PORT` *(default: 6379)* Redis cache service port. -- `TON_API_CACHE_REDIS_TIMEOUT` *(default: 1)* +- `ION_API_CACHE_REDIS_TIMEOUT` *(default: 1)* Redis cache service port. @@ -127,29 +127,29 @@ The service supports the following environment variables: ## FAQ #### How to point the service to my own lite server? -To point the HTTP API to your own lite server you should set `TON_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server. +To point the HTTP API to your own lite server you should set `ION_API_TONLIB_LITESERVER_CONFIG` to config file with your only lite server. -- If you use MyTonCtrl on your node you can generate config file with these commands: +- If you use MyIonCtrl on your node you can generate config file with these commands: ``` - $ mytonctrl - MyTonCtrl> installer - MyTonInstaller> clcf + $ myionctrl + MyIonCtrl> installer + MyIonInstaller> clcf ``` - Config file will be saved at `/usr/bin/ton/local.config.json`. -- If you don't use MyTonCtrl: copy `private/mainnet.json` and overwrite section `liteservers` with your liteservers ip, port and public key. To get public key from `liteserver.pub` file use the following script: + Config file will be saved at `/usr/bin/ion/local.config.json`. +- If you don't use MyIonCtrl: copy `private/mainnet.json` and overwrite section `liteservers` with your liteservers ip, port and public key. To get public key from `liteserver.pub` file use the following script: ``` python -c 'import codecs; f=open("liteserver.pub", "rb+"); pub=f.read()[4:]; print(str(codecs.encode(pub,"base64")).replace("\n",""))' ``` -- Once config file is created assign variable `TON_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project. +- Once config file is created assign variable `ION_API_TONLIB_LITESERVER_CONFIG` to its path, run `./configure.py` and rebuild the project. #### How to run multiple API instances on single machine? - Clone the repo as many times as many instances you need to the folders with different names (otherwise docker compose containers will conflict). -- Configure each instance to use unique port (env variable `TON_API_HTTP_PORT`) +- Configure each instance to use unique port (env variable `ION_API_HTTP_PORT`) - Build and run every instance. #### How to update tonlibjson library? -Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/toncenter/pytonlib). +Binary file `libtonlibjson` now moved to [pytonlib](https://github.com/ice-blockchain/pytonlib). - Docker Compose: `docker-compose build --no-cache`. -- Local run: `pip install -U ton-http-api`. +- Local run: `pip install -U ion-http-api`. diff --git a/ton-http-api/pyTON/__init__.py b/ion-http-api/pyION/__init__.py similarity index 100% rename from ton-http-api/pyTON/__init__.py rename to ion-http-api/pyION/__init__.py diff --git a/ton-http-api/pyTON/__main__.py b/ion-http-api/pyION/__main__.py similarity index 70% rename from ton-http-api/pyTON/__main__.py rename to ion-http-api/pyION/__main__.py index 55fcbce..a52c0e1 100644 --- a/ton-http-api/pyTON/__main__.py +++ b/ion-http-api/pyION/__main__.py @@ -4,27 +4,27 @@ def setup_environment(args): - os.environ['TON_API_CACHE_ENABLED'] = ('1' if args.cache else '0') - os.environ['TON_API_CACHE_REDIS_ENDPOINT'] = args.cache_redis_endpoint - os.environ['TON_API_CACHE_REDIS_PORT'] = str(args.cache_redis_port) + os.environ['ION_API_CACHE_ENABLED'] = ('1' if args.cache else '0') + os.environ['ION_API_CACHE_REDIS_ENDPOINT'] = args.cache_redis_endpoint + os.environ['ION_API_CACHE_REDIS_PORT'] = str(args.cache_redis_port) - os.environ['TON_API_LOGS_LEVEL'] = args.logs_level - os.environ['TON_API_LOGS_JSONIFY'] = ('1' if args.logs_jsonify else '0') + os.environ['ION_API_LOGS_LEVEL'] = args.logs_level + os.environ['ION_API_LOGS_JSONIFY'] = ('1' if args.logs_jsonify else '0') - os.environ['TON_API_ROOT_PATH'] = args.root - os.environ['TON_API_GET_METHODS_ENABLED'] = ('1' if args.get_methods else '0') - os.environ['TON_API_JSON_RPC_ENABLED'] = ('1' if args.json_rpc else '0') + os.environ['ION_API_ROOT_PATH'] = args.root + os.environ['ION_API_GET_METHODS_ENABLED'] = ('1' if args.get_methods else '0') + os.environ['ION_API_JSON_RPC_ENABLED'] = ('1' if args.json_rpc else '0') - os.environ['TON_API_TONLIB_LITESERVER_CONFIG'] = args.liteserver_config - os.environ['TON_API_TONLIB_KEYSTORE'] = args.tonlib_keystore - os.environ['TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER'] = str(args.parallel_requests_per_liteserver) + os.environ['ION_API_TONLIB_LITESERVER_CONFIG'] = args.liteserver_config + os.environ['ION_API_TONLIB_KEYSTORE'] = args.tonlib_keystore + os.environ['ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER'] = str(args.parallel_requests_per_liteserver) if args.cdll_path is not None: - os.environ['TON_API_TONLIB_CDLL_PATH'] = args.cdll_path + os.environ['ION_API_TONLIB_CDLL_PATH'] = args.cdll_path return def main(): - parser = argparse.ArgumentParser('ton-http-api') + parser = argparse.ArgumentParser('ion-http-api') webserver_args = parser.add_argument_group('webserver') webserver_args.add_argument('--host', type=str, default='0.0.0.0', help='HTTP API host') @@ -34,8 +34,8 @@ def main(): webserver_args.add_argument('--no-json-rpc', action='store_false', default=True, dest='json_rpc', help='Disable jsonRPC endpoint') tonlib_args = parser.add_argument_group('tonlib') - tonlib_args.add_argument('--liteserver-config', type=str, default='https://ton.org/global-config.json', help='Liteserver config JSON path') - tonlib_args.add_argument('--tonlib-keystore', type=str, default='./ton_keystore/', help='Keystore path for tonlibjson') + tonlib_args.add_argument('--liteserver-config', type=str, default='https://cdn.ice.io/mainnet/global.config.json', help='Liteserver config JSON path') + tonlib_args.add_argument('--tonlib-keystore', type=str, default='./ion_keystore/', help='Keystore path for tonlibjson') tonlib_args.add_argument('--parallel-requests-per-liteserver', type=int, default=50, help='Maximum parallel requests per liteserver') tonlib_args.add_argument('--cdll-path', type=str, default=None, help='Path to tonlibjson binary') @@ -54,13 +54,13 @@ def main(): args = parser.parse_args() if args.version: - os.system('pip3 show ton-http-api') + os.system('pip3 show ion-http-api') return # running web app setup_environment(args) - from pyTON.main import app + from pyION.main import app uvicorn.run(app, host=args.host, port=args.port, log_level=args.logs_level.lower()) diff --git a/ton-http-api/pyTON/cache.py b/ion-http-api/pyION/cache.py similarity index 96% rename from ton-http-api/pyTON/cache.py rename to ion-http-api/pyION/cache.py index ca92bd1..fa2b4e5 100644 --- a/ton-http-api/pyTON/cache.py +++ b/ion-http-api/pyION/cache.py @@ -2,7 +2,7 @@ import ring from ring.func.asyncio import Aioredis2Storage -from pyTON.settings import RedisCacheSettings +from pyION.settings import RedisCacheSettings class TonlibResultRedisStorage(Aioredis2Storage): diff --git a/ton-http-api/pyTON/main.py b/ion-http-api/pyION/main.py similarity index 88% rename from ton-http-api/pyTON/main.py rename to ion-http-api/pyION/main.py index 40b85e2..125e215 100644 --- a/ton-http-api/pyTON/main.py +++ b/ion-http-api/pyION/main.py @@ -22,10 +22,10 @@ from tvm_valuetypes.cell import deserialize_cell_from_object -from pyTON.models import TonResponse, TonResponseJsonRPC, TonRequestJsonRPC -from pyTON.manager import TonlibManager -from pyTON.cache import CacheManager, RedisCacheManager, DisabledCacheManager -from pyTON.settings import Settings, RedisCacheSettings +from pyION.models import IonResponse, IonResponseJsonRPC, IonRequestJsonRPC +from pyION.manager import TonlibManager +from pyION.cache import CacheManager, RedisCacheManager, DisabledCacheManager +from pyION.settings import Settings, RedisCacheSettings from pytonlib.utils.address import detect_address as __detect_address, prepare_address as _prepare_address from pytonlib.utils.wallet import wallets as known_wallets, sha256 @@ -58,7 +58,7 @@ def main_config(binder): # main service description = """ -This API enables HTTP access to TON blockchain - getting accounts and wallets information, looking up blocks and transactions, sending messages to the blockchain, calling get methods of smart contracts, and more. +This API enables HTTP access to ION blockchain - getting accounts and wallets information, looking up blocks and transactions, sending messages to the blockchain, calling get methods of smart contracts, and more. In addition to REST API, all methods are available through [JSON-RPC endpoint](#json%20rpc) with `method` equal to method name and `params` passed as a dictionary. @@ -101,7 +101,7 @@ def main_config(binder): settings = inject.instance(Settings) app = FastAPI( - title="TON HTTP API", + title="ION HTTP API", description=description, version='2.0.0', docs_url='/', @@ -140,31 +140,31 @@ async def shutdown_event(): # Exception handlers @app.exception_handler(StarletteHTTPException) async def http_exception_handler(request, exc): - res = TonResponse(ok=False, error=str(exc.detail), code=exc.status_code) + res = IonResponse(ok=False, error=str(exc.detail), code=exc.status_code) return JSONResponse(res.dict(exclude_none=True), status_code=res.code) @app.exception_handler(RequestValidationError) async def validation_exception_handler(request, exc): - res = TonResponse(ok=False, error=f"Validation error: {exc}", code=status.HTTP_422_UNPROCESSABLE_ENTITY) + res = IonResponse(ok=False, error=f"Validation error: {exc}", code=status.HTTP_422_UNPROCESSABLE_ENTITY) return JSONResponse(res.dict(exclude_none=True), status_code=status.HTTP_422_UNPROCESSABLE_ENTITY) @app.exception_handler(asyncio.TimeoutError) async def timeout_exception_handler(request, exc): - res = TonResponse(ok=False, error="Liteserver timeout", code=status.HTTP_504_GATEWAY_TIMEOUT) + res = IonResponse(ok=False, error="Liteserver timeout", code=status.HTTP_504_GATEWAY_TIMEOUT) return JSONResponse(res.dict(exclude_none=True), status_code=status.HTTP_504_GATEWAY_TIMEOUT) @app.exception_handler(TonlibException) async def tonlib_error_result_exception_handler(request, exc): - res = TonResponse(ok=False, error=str(exc), code=status.HTTP_500_INTERNAL_SERVER_ERROR) + res = IonResponse(ok=False, error=str(exc), code=status.HTTP_500_INTERNAL_SERVER_ERROR) return JSONResponse(res.dict(exclude_none=True), status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) @app.exception_handler(Exception) async def fastapi_generic_exception_handler(request, exc): - res = TonResponse(ok=False, error=str(exc), code=status.HTTP_503_SERVICE_UNAVAILABLE) + res = IonResponse(ok=False, error=str(exc), code=status.HTTP_503_SERVICE_UNAVAILABLE) return JSONResponse(res.dict(exclude_none=True), status_code=status.HTTP_503_SERVICE_UNAVAILABLE) @@ -193,7 +193,7 @@ def wrap_result(func): @wraps(func) async def wrapper(*args, **kwargs): result = await asyncio.wait_for(func(*args, **kwargs), settings.tonlib.request_timeout) - return TonResponse(ok=True, result=result) + return IonResponse(ok=True, result=result) return wrapper json_rpc_methods = {} @@ -235,17 +235,17 @@ async def healthcheck(): return 'OK' -@app.get('/getWorkerState', response_model=TonResponse, include_in_schema=False) +@app.get('/getWorkerState', response_model=IonResponse, include_in_schema=False) @wrap_result async def get_worker_state(): return tonlib.get_workers_state() -@app.get('/getAddressInformation', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/getAddressInformation', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('getAddressInformation') @wrap_result async def get_address_information( - address: str = Query(..., description="Identifier of target TON account in any form.") + address: str = Query(..., description="Identifier of target ION account in any form.") ): """ Get basic information about the address: balance, code, data, last_transaction_id. @@ -257,11 +257,11 @@ async def get_address_information( result["balance"] = 0 return result -@app.get('/getExtendedAddressInformation', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/getExtendedAddressInformation', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('getExtendedAddressInformation') @wrap_result async def get_extended_address_information( - address: str = Query(..., description="Identifier of target TON account in any form.") + address: str = Query(..., description="Identifier of target ION account in any form.") ): """ Similar to previous one but tries to parse additional information for known contract types. This method is based on tonlib's function *getAccountState*. For detecting wallets we recommend to use *getWalletInformation*. @@ -270,11 +270,11 @@ async def get_extended_address_information( result = await tonlib.generic_get_account_state(address) return result -@app.get('/getWalletInformation', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/getWalletInformation', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('getWalletInformation') @wrap_result async def get_wallet_information( - address: str = Query(..., description="Identifier of target TON account in any form.") + address: str = Query(..., description="Identifier of target ION account in any form.") ): """ Retrieve wallet information. This method parses contract state and currently supports more wallet types than getExtendedAddressInformation: simple wallet, standart wallet, v3 wallet, v4 wallet. @@ -294,11 +294,11 @@ async def get_wallet_information( wallet_handler["data_extractor"](res, result) return res -@app.get('/getTransactions', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts', 'transactions']) +@app.get('/getTransactions', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts', 'transactions']) @json_rpc('getTransactions') @wrap_result async def get_transactions( - address: str = Query(..., description="Identifier of target TON account in any form."), + address: str = Query(..., description="Identifier of target ION account in any form."), limit: Optional[int] = Query(default=10, description="Maximum number of transactions in response.", gt=0, le=100), lt: Optional[int] = Query(default=None, description="Logical time of transaction to start with, must be sent with *hash*."), hash: Optional[str] = Query(default=None, description="Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*."), @@ -311,14 +311,14 @@ async def get_transactions( address = prepare_address(address) return await tonlib.get_transactions(address, from_transaction_lt=lt, from_transaction_hash=hash, to_transaction_lt=to_lt, limit=limit, archival=archival) -@app.get('/getAddressBalance', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/getAddressBalance', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('getAddressBalance') @wrap_result async def get_address_balance( - address: str = Query(..., description="Identifier of target TON account in any form.") + address: str = Query(..., description="Identifier of target ION account in any form.") ): """ - Get balance (in nanotons) of a given address. + Get balance (in nanoions) of a given address. """ address = prepare_address(address) result = await tonlib.raw_get_account_state(address) @@ -326,11 +326,11 @@ async def get_address_balance( result["balance"] = 0 return result["balance"] -@app.get('/getAddressState', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/getAddressState', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('getAddressState') @wrap_result async def get_address( - address: str = Query(..., description="Identifier of target TON account in any form.") + address: str = Query(..., description="Identifier of target ION account in any form.") ): """ Get state of a given address. State can be either *unitialized*, *active* or *frozen*. @@ -339,29 +339,29 @@ async def get_address( result = await tonlib.raw_get_account_state(address) return address_state(result) -@app.get('/packAddress', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/packAddress', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('packAddress') @wrap_result async def pack_address( - address: str = Query(..., description="Identifier of target TON account in raw form.", example="0:83DFD552E63729B472FCBCC8C45EBCC6691702558B68EC7527E1BA403A0F31A8") + address: str = Query(..., description="Identifier of target ION account in raw form.", example="0:83DFD552E63729B472FCBCC8C45EBCC6691702558B68EC7527E1BA403A0F31A8") ): """ Convert an address from raw to human-readable format. """ return prepare_address(address) -@app.get('/unpackAddress', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/unpackAddress', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('unpackAddress') @wrap_result async def unpack_address( - address: str = Query(..., description="Identifier of target TON account in user-friendly form", example="EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N") + address: str = Query(..., description="Identifier of target ION account in user-friendly form", example="EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N") ): """ Convert an address from human-readable to raw format. """ return _detect_address(address)["raw_form"] -@app.get('/getMasterchainInfo', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks']) +@app.get('/getMasterchainInfo', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks']) @json_rpc('getMasterchainInfo') @wrap_result async def get_masterchain_info(): @@ -370,7 +370,7 @@ async def get_masterchain_info(): """ return await tonlib.getMasterchainInfo() -@app.get('/getMasterchainBlockSignatures', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks']) +@app.get('/getMasterchainBlockSignatures', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks']) @json_rpc('getMasterchainBlockSignatures') @wrap_result async def get_masterchain_block_signatures( @@ -381,7 +381,7 @@ async def get_masterchain_block_signatures( """ return await tonlib.getMasterchainBlockSignatures(seqno) -@app.get('/getShardBlockProof', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks']) +@app.get('/getShardBlockProof', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks']) @json_rpc('getShardBlockProof') @wrap_result async def get_shard_block_proof( @@ -395,7 +395,7 @@ async def get_shard_block_proof( """ return await tonlib.getShardBlockProof(workchain, shard, seqno, from_seqno) -@app.get('/getConsensusBlock', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks']) +@app.get('/getConsensusBlock', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks']) @json_rpc('getConsensusBlock') @wrap_result async def get_consensus_block(): @@ -404,7 +404,7 @@ async def get_consensus_block(): """ return await tonlib.getConsensusBlock() -@app.get('/lookupBlock', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks']) +@app.get('/lookupBlock', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks']) @json_rpc('lookupBlock') @wrap_result async def lookup_block( @@ -419,7 +419,7 @@ async def lookup_block( """ return await tonlib.lookupBlock(workchain, shard, seqno, lt, unixtime) -@app.get('/shards', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks']) +@app.get('/shards', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks']) @json_rpc('shards') @wrap_result async def shards( @@ -430,7 +430,7 @@ async def shards( """ return await tonlib.getShards(seqno) -@app.get('/getBlockTransactions', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks','transactions']) +@app.get('/getBlockTransactions', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks','transactions']) @json_rpc('getBlockTransactions') @wrap_result async def get_block_transactions( @@ -448,7 +448,7 @@ async def get_block_transactions( """ return await tonlib.getBlockTransactions(workchain, shard, seqno, count, root_hash, file_hash, after_lt, after_hash) -@app.get('/getBlockTransactionsExt', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks','transactions']) +@app.get('/getBlockTransactionsExt', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks','transactions']) @json_rpc('getBlockTransactionsExt') @wrap_result async def get_block_transactions_ext( @@ -466,7 +466,7 @@ async def get_block_transactions_ext( """ return await tonlib.getBlockTransactionsExt(workchain, shard, seqno, count, root_hash, file_hash, after_lt, after_hash) -@app.get('/getBlockHeader', response_model=TonResponse, response_model_exclude_none=True, tags=['blocks']) +@app.get('/getBlockHeader', response_model=IonResponse, response_model_exclude_none=True, tags=['blocks']) @json_rpc('getBlockHeader') @wrap_result async def get_block_header( @@ -481,7 +481,7 @@ async def get_block_header( """ return await tonlib.getBlockHeader(workchain, shard, seqno, root_hash, file_hash) -@app.get('/getConfigParam', response_model=TonResponse, response_model_exclude_none=True, tags=['get config']) +@app.get('/getConfigParam', response_model=IonResponse, response_model_exclude_none=True, tags=['get config']) @json_rpc('getConfigParam') @wrap_result async def get_config_param( @@ -493,19 +493,19 @@ async def get_config_param( """ return await tonlib.get_config_param(config_id, seqno) -@app.get('/getTokenData', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/getTokenData', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('getTokenData') @wrap_result async def get_token_data( - address: str = Query(..., description="Address of NFT collection/item or Jetton master/wallet smart contract") + address: str = Query(..., description="Address of NFT collection/item or Jetion master/wallet smart contract") ): """ - Get NFT or Jetton information. + Get NFT or Jetion information. """ address = prepare_address(address) return await tonlib.get_token_data(address) -@app.get('/tryLocateTx', response_model=TonResponse, response_model_exclude_none=True, tags=['transactions']) +@app.get('/tryLocateTx', response_model=IonResponse, response_model_exclude_none=True, tags=['transactions']) @json_rpc('tryLocateTx') @wrap_result async def get_try_locate_tx( @@ -518,7 +518,7 @@ async def get_try_locate_tx( """ return await tonlib.tryLocateTxByIncomingMessage(source, destination, created_lt) -@app.get('/tryLocateResultTx', response_model=TonResponse, response_model_exclude_none=True, tags=['transactions']) +@app.get('/tryLocateResultTx', response_model=IonResponse, response_model_exclude_none=True, tags=['transactions']) @json_rpc('tryLocateResultTx') @wrap_result async def get_try_locate_result_tx( @@ -531,7 +531,7 @@ async def get_try_locate_result_tx( """ return await tonlib.tryLocateTxByIncomingMessage(source, destination, created_lt) -@app.get('/tryLocateSourceTx', response_model=TonResponse, response_model_exclude_none=True, tags=['transactions']) +@app.get('/tryLocateSourceTx', response_model=IonResponse, response_model_exclude_none=True, tags=['transactions']) @json_rpc('tryLocateSourceTx') @wrap_result async def get_try_locate_source_tx( @@ -544,18 +544,18 @@ async def get_try_locate_source_tx( """ return await tonlib.tryLocateTxByOutcomingMessage(source, destination, created_lt) -@app.get('/detectAddress', response_model=TonResponse, response_model_exclude_none=True, tags=['accounts']) +@app.get('/detectAddress', response_model=IonResponse, response_model_exclude_none=True, tags=['accounts']) @json_rpc('detectAddress') @wrap_result async def detect_address( - address: str = Query(..., description="Identifier of target TON account in any form.") + address: str = Query(..., description="Identifier of target ION account in any form.") ): """ Get all possible address forms. """ return _detect_address(address) -@app.post('/sendBoc', response_model=TonResponse, response_model_exclude_none=True, tags=['send']) +@app.post('/sendBoc', response_model=IonResponse, response_model_exclude_none=True, tags=['send']) @json_rpc('sendBoc') @wrap_result async def send_boc( @@ -567,7 +567,7 @@ async def send_boc( boc = base64.b64decode(boc) return await tonlib.raw_send_message(boc) -@app.post('/sendBocReturnHash', response_model=TonResponse, response_model_exclude_none=True, tags=['send']) +@app.post('/sendBocReturnHash', response_model=IonResponse, response_model_exclude_none=True, tags=['send']) @json_rpc('sendBocReturnHash') @wrap_result async def send_boc_return_hash( @@ -589,7 +589,7 @@ async def send_boc_unsafe_task(boc_bytes: bytes): pass await asyncio.sleep(send_interval) -@app.post('/sendBocUnsafe', response_model=TonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) +@app.post('/sendBocUnsafe', response_model=IonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) @json_rpc('sendBocUnsafe') @wrap_result async def send_boc_unsafe( @@ -604,7 +604,7 @@ async def send_boc_unsafe( background_tasks.add_task(send_boc_unsafe_task, boc) return {'@type': 'ok', '@extra': '0:0:0'} -@app.post('/sendCellSimple', response_model=TonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) +@app.post('/sendCellSimple', response_model=IonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) @json_rpc('sendCellSimple') @wrap_result async def send_cell( @@ -620,7 +620,7 @@ async def send_cell( raise HTTPException(status_code=400, detail="Error while parsing cell") return await tonlib.raw_send_message(boc) -@app.post('/sendQuery', response_model=TonResponse, response_model_exclude_none=True, tags=['send']) +@app.post('/sendQuery', response_model=IonResponse, response_model_exclude_none=True, tags=['send']) @json_rpc('sendQuery') @wrap_result async def send_query( @@ -638,7 +638,7 @@ async def send_query( data = codecs.decode(codecs.encode(init_data, "utf-8"), 'base64') return await tonlib.raw_create_and_send_query(address, body, init_code=code, init_data=data) -@app.post('/sendQuerySimple', response_model=TonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) +@app.post('/sendQuerySimple', response_model=IonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) @json_rpc('sendQuerySimple') @wrap_result async def send_query_cell( @@ -662,7 +662,7 @@ async def send_query_cell( raise HTTPException(status_code=400, detail="Error while parsing cell object") return await tonlib.raw_create_and_send_query(address, body, init_code=qcode, init_data=qdata) -@app.post('/estimateFee', response_model=TonResponse, response_model_exclude_none=True, tags=['send']) +@app.post('/estimateFee', response_model=IonResponse, response_model_exclude_none=True, tags=['send']) @json_rpc('estimateFee') @wrap_result async def estimate_fee( @@ -681,7 +681,7 @@ async def estimate_fee( data = codecs.decode(codecs.encode(init_data, "utf-8"), 'base64') return await tonlib.raw_estimate_fees(address, body, init_code=code, init_data=data, ignore_chksig=ignore_chksig) -@app.post('/estimateFeeSimple', response_model=TonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) +@app.post('/estimateFeeSimple', response_model=IonResponse, response_model_exclude_none=True, include_in_schema=False, tags=['send']) @json_rpc('estimateFeeSimple') @wrap_result async def estimate_fee_cell( @@ -708,7 +708,7 @@ async def estimate_fee_cell( if settings.webserver.get_methods: - @app.post('/runGetMethod', response_model=TonResponse, response_model_exclude_none=True, tags=["run method"]) + @app.post('/runGetMethod', response_model=IonResponse, response_model_exclude_none=True, tags=["run method"]) @json_rpc('runGetMethod') @wrap_result async def run_get_method( @@ -724,8 +724,8 @@ async def run_get_method( if settings.webserver.json_rpc: - @app.post('/jsonRPC', response_model=TonResponseJsonRPC, response_model_exclude_none=True, tags=['json rpc']) - async def jsonrpc_handler(json_rpc: TonRequestJsonRPC, request: Request, response: Response, background_tasks: BackgroundTasks): + @app.post('/jsonRPC', response_model=IonResponseJsonRPC, response_model_exclude_none=True, tags=['json rpc']) + async def jsonrpc_handler(json_rpc: IonRequestJsonRPC, request: Request, response: Response, background_tasks: BackgroundTasks): """ All methods in the API are available through JSON-RPC protocol ([spec](https://www.jsonrpc.org/specification)). """ @@ -735,7 +735,7 @@ async def jsonrpc_handler(json_rpc: TonRequestJsonRPC, request: Request, respons if not method in json_rpc_methods: response.status_code = status.HTTP_422_UNPROCESSABLE_ENTITY - return TonResponseJsonRPC(ok=False, error='Unknown method', id=_id) + return IonResponseJsonRPC(ok=False, error='Unknown method', id=_id) handler = json_rpc_methods[method] try: @@ -747,6 +747,6 @@ async def jsonrpc_handler(json_rpc: TonRequestJsonRPC, request: Request, respons result = await handler(**params) except TypeError as e: response.status_code = status.HTTP_422_UNPROCESSABLE_ENTITY - return TonResponseJsonRPC(ok=False, error=f'TypeError: {e}', id=_id) + return IonResponseJsonRPC(ok=False, error=f'TypeError: {e}', id=_id) - return TonResponseJsonRPC(ok=result.ok, result=result.result, error=result.error, code=result.code, id=_id) + return IonResponseJsonRPC(ok=result.ok, result=result.result, error=result.error, code=result.code, id=_id) diff --git a/ton-http-api/pyTON/manager.py b/ion-http-api/pyION/manager.py similarity index 99% rename from ton-http-api/pyTON/manager.py rename to ion-http-api/pyION/manager.py index 6ce9594..f4d3b27 100644 --- a/ton-http-api/pyTON/manager.py +++ b/ion-http-api/pyION/manager.py @@ -9,10 +9,10 @@ from copy import deepcopy from concurrent.futures import ThreadPoolExecutor -from pyTON.worker import TonlibWorker -from pyTON.models import TonlibWorkerMsgType, TonlibClientResult, ConsensusBlock -from pyTON.cache import CacheManager, DisabledCacheManager -from pyTON.settings import TonlibSettings +from pyION.worker import TonlibWorker +from pyION.models import TonlibWorkerMsgType, TonlibClientResult, ConsensusBlock +from pyION.cache import CacheManager, DisabledCacheManager +from pyION.settings import TonlibSettings from pytonlib import TonlibError diff --git a/ton-http-api/pyTON/models.py b/ion-http-api/pyION/models.py similarity index 89% rename from ton-http-api/pyTON/models.py rename to ion-http-api/pyION/models.py index 6cdcf88..9d09942 100644 --- a/ton-http-api/pyTON/models.py +++ b/ion-http-api/pyION/models.py @@ -28,19 +28,19 @@ class ConsensusBlock: timestamp: int = 0 -class TonResponse(BaseModel): +class IonResponse(BaseModel): ok: bool result: Union[str, list, dict, None] = None error: Optional[str] = None code: Optional[int] = None -class TonResponseJsonRPC(TonResponse): +class IonResponseJsonRPC(IonResponse): jsonrpc: str = "2.0" id: Optional[str] = None -class TonRequestJsonRPC(BaseModel): +class IonRequestJsonRPC(BaseModel): method: str params: dict = {} id: Optional[str] = None diff --git a/ton-http-api/pyTON/settings.py b/ion-http-api/pyION/settings.py similarity index 77% rename from ton-http-api/pyTON/settings.py rename to ion-http-api/pyION/settings.py index 1f6c3f0..50c7697 100644 --- a/ton-http-api/pyTON/settings.py +++ b/ion-http-api/pyION/settings.py @@ -37,13 +37,13 @@ def liteserver_config(self): @classmethod def from_environment(cls): verbosity_level = 0 - if os.environ.get('TON_API_LOGS_LEVEL') == 'DEBUG': + if os.environ.get('ION_API_LOGS_LEVEL') == 'DEBUG': verbosity_level = 4 - return TonlibSettings(parallel_requests_per_liteserver=int(os.environ.get('TON_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER', '50')), - keystore=os.environ.get('TON_API_TONLIB_KEYSTORE', './ton_keystore/'), - liteserver_config_path=os.environ.get('TON_API_TONLIB_LITESERVER_CONFIG', 'https://ton.org/global-config.json'), - cdll_path=os.environ.get('TON_API_TONLIB_CDLL_PATH', None), - request_timeout=int(os.environ.get('TON_API_TONLIB_REQUEST_TIMEOUT', '10')), + return TonlibSettings(parallel_requests_per_liteserver=int(os.environ.get('ION_API_TONLIB_PARALLEL_REQUESTS_PER_LITESERVER', '50')), + keystore=os.environ.get('ION_API_TONLIB_KEYSTORE', './ion_keystore/'), + liteserver_config_path=os.environ.get('ION_API_TONLIB_LITESERVER_CONFIG', 'https://cdn.ice.io/mainnet/global.config.json'), + cdll_path=os.environ.get('ION_API_TONLIB_CDLL_PATH', None), + request_timeout=int(os.environ.get('ION_API_TONLIB_REQUEST_TIMEOUT', '10')), verbosity_level=verbosity_level) @@ -56,9 +56,9 @@ class RedisSettings: @classmethod def from_environment(cls, settings_type): if settings_type == 'cache': - return RedisSettings(endpoint=os.environ.get('TON_API_CACHE_REDIS_ENDPOINT', 'localhost'), - port=int(os.environ.get('TON_API_CACHE_REDIS_PORT', '6379')), - timeout=int(os.environ.get('TON_API_CACHE_REDIS_TIMEOUT', '1'))) + return RedisSettings(endpoint=os.environ.get('ION_API_CACHE_REDIS_ENDPOINT', 'localhost'), + port=int(os.environ.get('ION_API_CACHE_REDIS_PORT', '6379')), + timeout=int(os.environ.get('ION_API_CACHE_REDIS_TIMEOUT', '1'))) @dataclass @@ -68,8 +68,8 @@ class LoggingSettings: @classmethod def from_environment(cls): - return LoggingSettings(jsonify=strtobool(os.environ.get('TON_API_LOGS_JSONIFY', '0')), - level=os.environ.get('TON_API_LOGS_LEVEL', 'WARNING')) + return LoggingSettings(jsonify=strtobool(os.environ.get('ION_API_LOGS_JSONIFY', '0')), + level=os.environ.get('ION_API_LOGS_LEVEL', 'WARNING')) @dataclass @@ -87,7 +87,7 @@ class RedisCacheSettings(CacheSettings): @classmethod def from_environment(cls): - return RedisCacheSettings(enabled=strtobool(os.environ.get('TON_API_CACHE_ENABLED', '0')), + return RedisCacheSettings(enabled=strtobool(os.environ.get('ION_API_CACHE_ENABLED', '0')), redis=RedisSettings.from_environment('cache')) @@ -99,9 +99,9 @@ class WebServerSettings: @classmethod def from_environment(cls): - return WebServerSettings(api_root_path=os.environ.get('TON_API_ROOT_PATH', '/'), - get_methods=strtobool(os.environ.get('TON_API_GET_METHODS_ENABLED', '1')), - json_rpc=strtobool(os.environ.get('TON_API_JSON_RPC_ENABLED', '1'))) + return WebServerSettings(api_root_path=os.environ.get('ION_API_ROOT_PATH', '/'), + get_methods=strtobool(os.environ.get('ION_API_GET_METHODS_ENABLED', '1')), + json_rpc=strtobool(os.environ.get('ION_API_JSON_RPC_ENABLED', '1'))) @dataclass @@ -113,7 +113,7 @@ class Settings: @classmethod def from_environment(cls): - cache_enabled = strtobool(os.environ.get('TON_API_CACHE_ENABLED', '0')) + cache_enabled = strtobool(os.environ.get('ION_API_CACHE_ENABLED', '0')) logging = LoggingSettings.from_environment() cache = (RedisCacheSettings if cache_enabled else CacheSettings).from_environment() return Settings(tonlib=TonlibSettings.from_environment(), diff --git a/ton-http-api/pyTON/worker.py b/ion-http-api/pyION/worker.py similarity index 98% rename from ton-http-api/pyTON/worker.py rename to ion-http-api/pyION/worker.py index 3bc78c8..a0d305c 100644 --- a/ton-http-api/pyTON/worker.py +++ b/ion-http-api/pyION/worker.py @@ -5,8 +5,8 @@ import queue import multiprocessing as mp -from pyTON.settings import TonlibSettings -from pyTON.models import TonlibWorkerMsgType, TonlibClientResult +from pyION.settings import TonlibSettings +from pyION.models import TonlibWorkerMsgType, TonlibClientResult from pytonlib import TonlibClient, TonlibException, BlockNotFound from datetime import datetime from concurrent.futures import ThreadPoolExecutor diff --git a/ton-http-api/requirements.txt b/ion-http-api/requirements.txt similarity index 100% rename from ton-http-api/requirements.txt rename to ion-http-api/requirements.txt diff --git a/ton-http-api/setup.py b/ion-http-api/setup.py similarity index 83% rename from ton-http-api/setup.py rename to ion-http-api/setup.py index d85bfcb..3cfdc17 100644 --- a/ton-http-api/setup.py +++ b/ion-http-api/setup.py @@ -7,12 +7,12 @@ with open(join(dirname(__file__), "README.md"), "r") as f: long_description = f.read() -version = os.environ.get('TON_HTTP_API_VERSION', '0.0.0') +version = os.environ.get('ION_HTTP_API_VERSION', '0.0.0') setup( author='K-Dimentional Tree', author_email='kdimentionaltree@gmail.com', - name='ton-http-api', + name='ion-http-api', version=version, packages=find_packages('.', exclude=['tests']), install_requires=[ @@ -39,13 +39,13 @@ "License :: Other/Proprietary License", "Topic :: Software Development :: Libraries" ], - url="https://github.com/toncenter/ton-http-api", - description="HTTP API for TON (The Open Network)", + url="https://github.com/ice-blockchain/ion-http-api", + description="HTTP API for ION (Ice Open Network)", long_description_content_type="text/markdown", long_description=long_description, entry_points={ 'console_scripts': [ - 'ton-http-api = pyTON.__main__:main' + 'ion-http-api = pyION.__main__:main' ] } ) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 7b51d84..8782309 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,4 +1,4 @@ #!/bin/bash set -e -docker stack deploy -c <(scripts/swarm_config.sh) ton-http-api +docker stack deploy -c <(scripts/swarm_config.sh) ion-http-api diff --git a/scripts/setup.sh b/scripts/setup.sh index 91fc029..6ad40c6 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -13,5 +13,5 @@ chmod +x /usr/local/bin/docker-compose # Download the latest version of config.json mkdir private -curl -sL https://ton-blockchain.github.io/global.config.json > private/mainnet.json -curl -sL https://ton-blockchain.github.io/testnet-global.config.json > private/testnet.json +curl -sL https://cdn.ice.io/mainnet/global.config.json > private/mainnet.json +curl -sL https://cdn.ice.io/testnet/testnet-global.config.json > private/testnet.json diff --git a/scripts/update_init_block.sh b/scripts/update_init_block.sh index be15d85..a1c7ee0 100755 --- a/scripts/update_init_block.sh +++ b/scripts/update_init_block.sh @@ -1,6 +1,6 @@ #!/bin/bash -ENDPOINT=https://toncenter.com/api/v2 +ENDPOINT=https://api.mainnet.ice.io/http/v2 function usage() { @@ -18,7 +18,7 @@ while [[ $# -gt 0 ]]; do exit 1 ;; --testnet) - ENDPOINT=https://testnet.toncenter.com/api/v2 + ENDPOINT=https://api.testnet.ice.io/http/v2 shift ;; -*|--*) diff --git a/ton-http-api/.docker/entrypoint.sh b/ton-http-api/.docker/entrypoint.sh deleted file mode 100644 index 6b7ee76..0000000 --- a/ton-http-api/.docker/entrypoint.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -e - -echo "Running api with ${TON_API_WEBSERVERS_WORKERS:-1} workers" -echo "ENVIRONMENT:" -printenv - -gunicorn -k uvicorn.workers.UvicornWorker -w ${TON_API_WEBSERVERS_WORKERS:-1} --bind 0.0.0.0:8081 pyTON.main:app