diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..f4b11987f2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git +.github diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 900c2817e3..3726e5872c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -26,7 +26,7 @@ Please describe what you expected to happen. **Operating Environment(s):** - OS: [e.g. Windows/OSX/Linux. If Linux, include distro. ] - OS version: [e.g. 7/10/11, 10.13/10.15, 18.04/20.04 ] - - Komodo Wallet Version: [e.g. 0.7.0] + - Komodo Wallet Desktop Version: [e.g. 0.8.2] - Build branch: [e.g. master/dev] diff --git a/.github/workflows/firodex-desktop-cd.yml b/.github/workflows/firodex-desktop-cd.yml index 2e928193e4..a828130264 100644 --- a/.github/workflows/firodex-desktop-cd.yml +++ b/.github/workflows/firodex-desktop-cd.yml @@ -9,9 +9,8 @@ env: DEX_PROJECT_NAME: "firodex-desktop" DEX_DISPLAY_NAME: "FiroDex Desktop" DEX_COMPANY: "Firo Core Team" - DEX_VERSION: "0.7.0" + DEX_VERSION: "0.7.2" DEX_WEBSITE: "https://firo.org/" - jobs: linux-release: @@ -127,7 +126,7 @@ jobs: zip AtomicDEX-Pro-Installer.zip ./installer/AtomicDEX-Pro-Installer - name: Upload artifacts (Linux) - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: AtomicDEX-Pro-Installer-linux-release path: ./ci_tools_atomic_dex/AtomicDEX-Pro-Installer.zip @@ -239,7 +238,7 @@ jobs: zip AtomicDEX-Pro-Installer.zip ./installer/AtomicDEX-Pro-Installer - name: Upload artifacts (Linux/Debug) - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: AtomicDEX-Pro-Installer-linux-debug path: ./ci_tools_atomic_dex/AtomicDEX-Pro-Installer.zip @@ -303,7 +302,7 @@ jobs: ls bundle-Release/atomicDEX-Pro.dmg - name: Upload artifacts (MacOS/Release) - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: dexpro-mac-release.dmg path: ./ci_tools_atomic_dex/bundle-Release/atomicDEX-Pro.dmg @@ -367,14 +366,14 @@ jobs: ls bundle-Debug/atomicDEX-Pro.dmg - name: Upload artifacts (MacOS/Debug) - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: dexpro-mac-debug.dmg path: ./ci_tools_atomic_dex/bundle-Debug/atomicDEX-Pro.dmg windows-release: name: Win Build/Release - runs-on: windows-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v2 @@ -445,14 +444,14 @@ jobs: ls bundle-Release/bundle.zip - name: Upload artifacts (Win/Release) - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: dexpro-win-release path: ./ci_tools_atomic_dex/bundle-Release/bundle.zip windows-debug: name: Win Build/Debug - runs-on: windows-latest + runs-on: windows-2019 steps: - uses: actions/checkout@v2 @@ -523,7 +522,7 @@ jobs: ls bundle-Debug/bundle.zip - name: Upload artifacts (Windows/Debug) - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: dexpro-win-debug path: ./ci_tools_atomic_dex/bundle-Debug/bundle.zip diff --git a/.github/workflows/firodex-desktop-ci.yml b/.github/workflows/firodex-desktop-ci.yml index 42878ba1ca..d3c1200958 100644 --- a/.github/workflows/firodex-desktop-ci.yml +++ b/.github/workflows/firodex-desktop-ci.yml @@ -9,6 +9,7 @@ on: - master schedule: - cron: '0 0 * * 1' + workflow_dispatch: env: DEX_API: "mm2_firo" @@ -17,7 +18,7 @@ env: DEX_PROJECT_NAME: "firodex" DEX_DISPLAY_NAME: "Firo Dex" DEX_COMPANY: "Firo" - DEX_VERSION: "0.7.0" + DEX_VERSION: "0.7.2" DEX_WEBSITE: "https://firo.org/" VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/b/vcpkg_cache VCPKG_BINARY_SOURCES: clear;x-gha,readwrite @@ -56,25 +57,25 @@ jobs: host: 'linux' - name: osx-release - os: macos-12 + os: macos-13 qt: '5.15.2' type: 'Release' host: 'mac' - name: osx-debug - os: macos-12 + os: macos-13 qt: '5.15.2' type: 'Debug' host: 'mac' - name: windows-release - os: windows-latest + os: windows-2019 qt: '5.15.2' type: 'Release' host: 'windows' - name: windows-debug - os: windows-latest + os: windows-2019 qt: '5.15.2' type: 'Debug' host: 'windows' @@ -117,7 +118,6 @@ jobs: cl /utf-8 /DUSE_ECMULT_STATIC_PRECOMPUTATION /DECMULT_WINDOW_SIZE=15 /DWALLY_CORE_BUILD /DHAVE_CONFIG_H /DSECP256K1_BUILD /I$env:LIBWALLY_DIR\src\wrap_js\windows_config /I$env:LIBWALLY_DIR /I$env:LIBWALLY_DIR\src /I$env:LIBWALLY_DIR\include /I$env:LIBWALLY_DIR\src\ccan /I$env:LIBWALLY_DIR\src\ccan\base64 /I$env:LIBWALLY_DIR\src\secp256k1 /Zi /LD src/aes.c src/anti_exfil.c src/base58.c src/base64.c src/bech32.c src/bip32.c src/bip38.c src/bip39.c src/blech32.c src/ecdh.c src/elements.c src/hex.c src/hmac.c src/internal.c src/mnemonic.c src/pbkdf2.c src/pullpush.c src/psbt.c src/script.c src/scrypt.c src/sign.c src/symmetric.c src/transaction.c src/wif.c src/wordlist.c src/ccan/ccan/crypto/ripemd160/ripemd160.c src/ccan/ccan/crypto/sha256/sha256.c src/ccan/ccan/crypto/sha512/sha512.c src/ccan/ccan/base64/base64_.c src\ccan\ccan\str\hex\hex_.c src/secp256k1/src/secp256k1.c src/secp256k1/src/precomputed_ecmult_gen.c src/secp256k1/src/precomputed_ecmult.c /Fewally.dll Copy-Item "${{ github.workspace }}\libwally-core\wally.dll" -Destination "${{ github.workspace }}\wally\wally.dll" -force - - name: Install QT (macOS) if: runner.os == 'macOS' uses: jurplel/install-qt-action@v3.0.0 @@ -161,13 +161,20 @@ jobs: run: | export DEBIAN_FRONTEND=noninteractive export SHELL=/bin/bash - echo "CHOOSENIM_CHOOSE_VERSION=1.6.10" >> $GITHUB_ENV - export CHOOSENIM_CHOOSE_VERSION=1.6.10 - curl https://nim-lang.org/choosenim/init.sh > choosenim.sh - chmod +x choosenim.sh - ./choosenim.sh -y + echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV + export CHOOSENIM_CHOOSE_VERSION=1.6.2 + ./ci_tools_atomic_dex/ci_scripts/choosenim.sh -y export PATH=/home/runner/.nimble/bin:$PATH - chmod +x /home/runner/.choosenim/toolchains/nim-1.6.10/bin/* + chmod +x /home/runner/.choosenim/toolchains/nim-1.6.2/bin/* + + - name: Install nim (MacOS) + if: runner.os == 'macOS' + run: | + echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV + export CHOOSENIM_CHOOSE_VERSION=1.6.2 + ./ci_tools_atomic_dex/ci_scripts/choosenim.sh -y + export PATH=/Users/runner/.nimble/bin:$PATH + chmod +x /Users/runner/.choosenim/toolchains/nim-1.6.2/bin/* - name: Install deps (Linux) if: runner.os == 'Linux' @@ -200,51 +207,51 @@ jobs: appendedCacheKey: ${{ hashFiles('vcpkg.json') }} vcpkgJsonGlob: 'vcpkg.json' + - name: import code signing certificates (macos) + if: runner.os == 'macOS' && 'KomodoPlatform/komodo-wallet-desktop' == github.repository + uses: Apple-Actions/import-codesign-certs@v3 + with: + keychain: ${{ github.run_id }} + keychain-password: ${{ github.run_id }} + p12-file-base64: ${{ secrets.CERTIFICATES_P12 }} + p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} + + - name: import installer code signing certificates (macos) + if: runner.os == 'macOS' && 'KomodoPlatform/komodo-wallet-desktop' == github.repository + uses: apple-actions/import-codesign-certs@v3 + with: + keychain: ${{ github.run_id }} + keychain-password: ${{ github.run_id }} + create-keychain: false + p12-file-base64: ${{ secrets.CERTIFICATES_INSTALLER_P12 }} + p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} - # - name: import code signing certificates (macos) - # if: runner.os == 'macOS' && 'firoorg/FiroDEX-Desktop' == github.repository - # uses: Apple-Actions/import-codesign-certs@v1 - # with: - # keychain: ${{ github.run_id }} - # keychain-password: ${{ github.run_id }} - # p12-file-base64: ${{ secrets.CERTIFICATES_P12 }} - # p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} - - # - name: import installer code signing certificates (macos) - # if: runner.os == 'macOS' && 'firoorg/FiroDEX-Desktop' == github.repository - # uses: apple-actions/import-codesign-certs@v1 - # with: - # keychain: ${{ github.run_id }} - # keychain-password: ${{ github.run_id }} - # create-keychain: false - # p12-file-base64: ${{ secrets.CERTIFICATES_INSTALLER_P12 }} - # p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} - - - - - name: Build AtomicDEX (MacOS) + - name: Build Komodo Wallet (MacOS) if: runner.os == 'macOS' run: | xcrun --sdk macosx --show-sdk-path export SDK_PATH=$(xcrun --sdk macosx --show-sdk-path) - ls /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs + echo $SDK_PATH + ls $SDK_PATH echo $HOME/sdk - ls $HOME/sdk + ls $HOME/sdk || true + ls $(xcrun --show-sdk-path)/usr/include/c++ export MAC_SIGN_IDENTITY="${{ secrets.MAC_SIGN_IDENTITY }}" - export INSTALLER_MAC_SIGN_IDENTITY="${{ secrets.INSTALLER_MAC_SIGN_IDENTITY }}" + export INSTALLER_MAC_SIGN_IDENTITY="${{ secrets.MAC_SIGN_IDENTITY }}" export APPLE_ATOMICDEX_PASSWORD="${{ secrets.APPLE_ATOMICDEX_PASSWORD }}" export APPLE_ID="${{ secrets.APPLE_ID }}" export ASC_PUBLIC_ID="${{ secrets.ASC_PUBLIC_ID }}" export QT_INSTALL_CMAKE_PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/clang_64/lib/cmake export QT_ROOT=${{ github.workspace }}/Qt/${{ matrix.qt }} - export MACOSX_DEPLOYMENT_TARGET=10.15 + export PATH=/Users/runner/.nimble/bin:$PATH + export MACOSX_DEPLOYMENT_TARGET=14.2 export CC=clang export CXX=clang++ + export CXXFLAGS=-stdlib=libc++ + export LDFLAGS=-stdlib=libc++ cd ci_tools_atomic_dex nimble build -y - ./ci_tools_atomic_dex bundle ${{ matrix.type }} --osx_sdk=$HOME/sdk/MacOSX10.15.sdk --compiler=clang++ - - + ./ci_tools_atomic_dex bundle ${{ matrix.type }} --osx_sdk=$HOME/sdk/MacOSX14.2.sdk --compiler=clang++ - name: Build AtomicDEX (Linux) if: runner.os == 'Linux' @@ -263,7 +270,6 @@ jobs: ./ci_tools_atomic_dex build ${{ matrix.type }} ./ci_tools_atomic_dex bundle ${{ matrix.type }} - - name: Build FiroDEX (Windows) if: runner.os == 'Windows' shell: powershell @@ -281,11 +287,9 @@ jobs: echo "target_name_zip=${{ env.DEX_PROJECT_NAME }}-linux-$(git rev-parse --short HEAD).zip" >> $GITHUB_ENV echo "target_name_appimage=${{ env.DEX_PROJECT_NAME }}-linux-$(git rev-parse --short HEAD)-x86_64.AppImage" >> $GITHUB_ENV - - - name: Upload bundle artifact (Linux ZSTD) if: runner.os == 'Linux' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name_zstd }} path: ./bundled/linux/${{ env.target_name_zstd }} @@ -293,7 +297,7 @@ jobs: - name: Upload bundle artifact (Linux ZIP) if: runner.os == 'Linux' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name_zip }} path: ./bundled/linux/${{ env.target_name_zip }} @@ -301,7 +305,7 @@ jobs: - name: Upload bundle artifact (Linux AppImage) if: runner.os == 'Linux' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name_appimage }} path: ./bundled/linux/${{ env.target_name_appimage }} @@ -315,7 +319,7 @@ jobs: - name: Upload artifacts (MacOS dmg) if: runner.os == 'macOS' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name_dmg }} path: ./bundled/osx/${{ env.DEX_PROJECT_NAME }}.dmg @@ -323,7 +327,7 @@ jobs: - name: Upload artifacts (MacOS installer) if: runner.os == 'macOS' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name_installer }} path: ./bundled/osx/${{ env.DEX_PROJECT_NAME }}_installer.7z @@ -338,7 +342,7 @@ jobs: - name: Upload artifacts (Windows zip) if: runner.os == 'Windows' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name_zip }} path: ./bundled/windows/${{ env.DEX_PROJECT_NAME }}.zip @@ -346,14 +350,12 @@ jobs: - name: Upload artifacts (Windows installer) if: runner.os == 'Windows' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name_installer }} path: ./bundled/windows/${{ env.DEX_PROJECT_NAME }}_installer.exe retention-days: 7 - - - name: Running Tests (Linux) working-directory: ci_tools_atomic_dex continue-on-error: true @@ -379,11 +381,11 @@ jobs: if: runner.os == 'macOS' && 'firoorg/FiroDEX-Desktop' == github.repository run: | export MAC_SIGN_IDENTITY="${{ secrets.MAC_SIGN_IDENTITY }}" - export INSTALLER_MAC_SIGN_IDENTITY="${{ secrets.INSTALLER_MAC_SIGN_IDENTITY }}" + export INSTALLER_MAC_SIGN_IDENTITY="${{ secrets.MAC_SIGN_IDENTITY }}" export APPLE_ATOMICDEX_PASSWORD="${{ secrets.APPLE_ATOMICDEX_PASSWORD }}" export APPLE_ID="${{ secrets.APPLE_ID }}" export ASC_PUBLIC_ID="${{ secrets.ASC_PUBLIC_ID }}" - export MACOSX_DEPLOYMENT_TARGET=10.13 + export MACOSX_DEPLOYMENT_TARGET=14.2 export REPORT_CI_TOKEN=${{ secrets.REPORT_CI_TOKEN_SECRET }} export ATOMICDEX_TEST_SEED=${{ secrets.ATOMICDEX_TEST_SEED }} export ATOMICDEX_PASSWORD=${{ secrets.ATOMICDEX_PASSWORD }} diff --git a/.gitignore b/.gitignore index 93ff04824c..a0ede19677 100644 --- a/.gitignore +++ b/.gitignore @@ -69,7 +69,7 @@ Thumbs.db # -------- *.exe -/assets/tools/mm2/ +/assets/tools/kdf/ /ci_tools_atomic_dex/vcpkg-repo/ /ci_tools_atomic_dex/ci_tools_atomic_dex ci_tools_atomic_dex/build-Release @@ -88,3 +88,11 @@ atomic_legacy_imgui .vscode/settings.json .vscode/tasks.json bundled +build.log +.venv +.venv/* +cmake-3.19.0-rc3-Linux-x86_64 +ci_tools_atomic_dex/cmake-3.19.0-rc3-Linux-x86_64 +ci_tools_atomic_dex/cmake-3.19.0-rc3-Linux-x86_64/* +.venv/* +cmake-3.19.0-rc3-Linux-x86_64/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 1c25541055..0000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,112 +0,0 @@ -image: smk762/qt-ci:latest - -stages: - - build - - upload_linux_zip - - upload_linux_tar - - upload_linux_appimage - - test - -variables: - GIT_SUBMODULE_STRATEGY: recursive - DOCKER_DRIVER: overlay2 - PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" - VCPKG_DEFAULT_BINARY_CACHE: "$CI_PROJECT_DIR/.cache/vcpkg" - QT_VERSION: "5.15.2" - CMAKE_VERSION: "3.20.5" - -cache: - - key: $CI_COMMIT_REF_SLUG - paths: - - komodo-wallet-linux-${CI_COMMIT_SHA::9}.zip - - komodo-wallet-linux-${CI_COMMIT_SHA::9}.tar.zst - - komodo-wallet-${CI_COMMIT_SHA::9}-x86_64.AppImage - - key: $CI_PROJECT_NAME - paths: - - "$CI_PROJECT_DIR/.cache/vcpkg" - - -linux:build: - stage: build - before_script: - - cd $CI_PROJECT_DIR - - mkdir -p .cache/pip - - mkdir -p .cache/vcpkg - - script: - # Job Variables - - echo $CI_COMMIT_REF_SLUG - - echo $CI_COMMIT_AUTHOR - - echo $CI_COMMIT_BRANCH - - echo $CI_COMMIT_SHA - - echo $CI_COMMIT_SHORT_SHA - - echo $CI_PROJECT_PATH - - echo $CI_PROJECT_NAME - - echo $QT_VERSION - - echo $CMAKE_VERSION - - # Job Path/Env variables - - export DEBIAN_FRONTEND=noninteractive - - export QT_INSTALL_CMAKE_PATH=/opt/Qt/$QT_VERSION/gcc_64/lib/cmake - - export QT_ROOT=/opt/Qt/$QT_VERSION - - export Qt5_DIR=/opt/Qt/$QT_VERSION/gcc_64/lib/cmake/Qt5 - - export PATH=/opt/Qt/$QT_VERSION/gcc_64/bin:$PATH - - export PATH=${PATH}:/cmake-$CMAKE_VERSION-linux-x86_64/bin; - - export APPIMAGE_EXTRACT_AND_RUN=1 - - # Update tar - - export FORCE_UNSAFE_CONFIGURE=1 - - wget https://ftp.wayne.edu/gnu/tar/tar-1.34.tar.gz && tar -xvf tar-1.34.tar.gz - - cd tar-1.34 && ./configure && make && make install - - cp src/tar $(which tar) - - # Bootstrap Vcpkg - - cd $CI_PROJECT_DIR; ./ci_tools_atomic_dex/vcpkg-repo/bootstrap-vcpkg.sh - - # NINJA - - cd $CI_PROJECT_DIR - - rm -rf build_ninja || echo "no build_ninja folder to rm" - - mkdir build_ninja && cd $_ - - cmake -DCMAKE_BUILD_TYPE=Release -GNinja ../ - - ninja install - - ninja komodo-wallet - - cd $CI_PROJECT_DIR - - cp $CI_PROJECT_DIR/bundled/linux/komodo-wallet-linux-${CI_COMMIT_SHA::9}.zip . - - cp $CI_PROJECT_DIR/bundled/linux/komodo-wallet-linux-${CI_COMMIT_SHA::9}.tar.zst . - - cp $CI_PROJECT_DIR/bundled/linux/komodo-wallet-${CI_COMMIT_SHA::9}-x86_64.AppImage . - -AtomicDex-linux-zip: - stage: upload_linux_zip - allow_failure: true - script: - - echo "Uploading AppImage..." - artifacts: - name: "AtomicDex-linux-${CI_COMMIT_SHA::9}.zip" - paths: - - $CI_PROJECT_DIR/komodo-wallet-linux-${CI_COMMIT_SHA::9}.zip - when: always - expire_in: 3 days - -AtomicDex-linux-AppImage: - stage: upload_linux_appimage - allow_failure: true - script: - - echo "Uploading AppImage..." - artifacts: - name: "AtomicDex-linux-${CI_COMMIT_SHA::9}-AppImage" - paths: - - $CI_PROJECT_DIR/komodo-wallet-${CI_COMMIT_SHA::9}-x86_64.AppImage - when: always - expire_in: 3 days - -AtomicDex-linux-tar: - stage: upload_linux_tar - allow_failure: true - script: - - echo "Uploading tar..." - artifacts: - name: "AtomicDex-linux-${CI_COMMIT_SHA::9}.tar.zst" - paths: - - $CI_PROJECT_DIR/komodo-wallet-linux-${CI_COMMIT_SHA::9}.tar.zst - when: always - expire_in: 3 days diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d3b3eeb8..f973919956 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(vcpkg_prerequisites) include(qt_prerequisites) include(cfg_hash) -project(${DEX_PROJECT_NAME} LANGUAGES CXX VERSION 0.7.0) +project(${DEX_PROJECT_NAME} LANGUAGES CXX VERSION 0.8.2) message(STATUS "${PROJECT_NAME} is version ${PROJECT_VERSION}") include(cmake_default_options) @@ -59,14 +59,14 @@ endif () ##! We fetch our dependencies if (APPLE) - FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-mac-x86-64.zip) + FetchContent_Declare(kdf + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.3.0-beta/mm2-8206c6ef6-Darwin-Release.zip) elseif (UNIX AND NOT APPLE) - FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-linux-x86-64.zip) + FetchContent_Declare(kdf + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.3.0-beta/mm2-8206c6ef6-Linux-Release.zip) else () - FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-win-x86-64.zip) + FetchContent_Declare(kdf + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.3.0-beta/mm2-8206c6ef6-Win64.zip) endif () #FetchContent_Declare(qmaterial URL https://github.com/KomodoPlatform/Qaterial/archive/last-clang-working-2.zip) @@ -83,20 +83,20 @@ FetchContent_Declare(jl777-coins #FetchContent_Declare(adex-generics-coins # URL https://github.com/KomodoPlatform/komodo-wallet-desktop/archive/main.zip) -FetchContent_MakeAvailable(mm2 jl777-coins qmaterial) +FetchContent_MakeAvailable(kdf jl777-coins qmaterial) ##! Configure our needs. if (UNIX) configure_file(${jl777-coins_SOURCE_DIR}/utils/coins_config_tcp.json ${CMAKE_CURRENT_SOURCE_DIR}/assets/config/${PROJECT_VERSION}-coins.json COPYONLY) - configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/mm2/coins COPYONLY) - configure_file(${mm2_SOURCE_DIR}/mm2 ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/mm2/${DEX_API} COPYONLY) + configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/kdf/coins COPYONLY) + configure_file(${kdf_SOURCE_DIR}/mm2 ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/kdf/${DEX_API} COPYONLY) file(COPY ${jl777-coins_SOURCE_DIR}/icons/ DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/atomic_defi_design/assets/images/coins/) else () configure_file(${jl777-coins_SOURCE_DIR}/utils/coins_config_tcp.json ${CMAKE_BINARY_DIR}/bin/assets/config/${PROJECT_VERSION}-coins.json COPYONLY) - configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/coins COPYONLY) - configure_file(${mm2_SOURCE_DIR}/mm2.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/${DEX_API}.exe COPYONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/msvcp140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/msvcp140.dll COPYONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/vcruntime140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/vcruntime140.dll COPYONLY) + configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/coins COPYONLY) + configure_file(${kdf_SOURCE_DIR}/mm2.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/${DEX_API}.exe COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/msvcp140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/msvcp140.dll COPYONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/vcruntime140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/vcruntime140.dll COPYONLY) endif () diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..79f2a4ba11 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,125 @@ +FROM docker.io/ubuntu:20.04 AS base + +LABEL authors= + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=Etc/UTC +ENV SHELL=/bin/bash +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +WORKDIR /build/komodo-wallet-desktop +COPY . /build/komodo-wallet-desktop +RUN rm -rf .git build logs tmp + +RUN apt-get update -y && \ + apt-get install -y build-essential \ + libgtk-3-dev \ + libgdk-pixbuf2.0-dev \ + libglib2.0-dev \ + autoconf \ + automake \ + libtool \ + libgl1-mesa-dev \ + ca-certificates \ + zip \ + tar \ + sudo \ + python3-dev \ + python3-venv \ + python3-pip \ + python-is-python3 \ + curl \ + wget \ + zstd \ + software-properties-common \ + lsb-release \ + libpulse-dev \ + libtool \ + autoconf \ + unzip \ + fuse \ + libfuse2 \ + libssl-dev \ + libxkbcommon-x11-0 \ + libxcb-icccm4 \ + libxcb-image0 \ + qt5-gtk-platformtheme \ + libxcb1-dev \ + libxcb-keysyms1-dev \ + libxcb-render-util0-dev \ + libxcb-xinerama0 \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxcb-image0-dev \ + libxcb-randr0-dev \ + libxcb-xinerama0-dev \ + libxcb-icccm4-dev \ + libxcb-sync-dev \ + libxcb-present-dev \ + libxcb-dri3-dev \ + libxcb-glx0-dev \ + libxcomposite-dev \ + libxdamage-dev \ + libxrandr-dev \ + libxcursor-dev \ + libxi-dev \ + libxtst-dev \ + libx11-xcb-dev \ + libxrender-dev \ + gtk2-engines-pixbuf \ + libgtk2.0-0 \ + libgtk2.0-dev \ + libgbm-dev \ + git \ + libnss3-dev \ + libnspr4-dev \ + libgstreamer-plugins-base1.0-dev \ + libqt5charts5-dev \ + libqt5webchannel5-dev \ + libasound2-dev + +RUN git config --global --add safe.directory /build/komodo-wallet-desktop +RUN cd /build/komodo-wallet-desktop && ./ci_tools_atomic_dex/ci_scripts/linux_script_docker.sh + + +ENV CXX=clang++-12 +ENV CC=clang-12 +#ENV CXXFLAGS="-stdlib=libc++ -std=c++20" +#ENV LDFLAGS="-stdlib=libc++" + +# Install Qt +RUN python3 -m venv /build/.venv && \ + /build/.venv/bin/pip install aqtinstall && \ + /build/.venv/bin/python -m aqt install-qt linux desktop 5.15.2 -O $HOME/Qt -b https://qt-mirror.dannhauer.de/ -m qtcharts debug_info qtwebengine + + +ENV DEBIAN_FRONTEND=noninteractive +ENV SHELL=/bin/bash +ENV QT_INSTALL_CMAKE_PATH=/root/Qt/5.15.2/gcc_64/lib/cmake +ENV QT_ROOT=/root/Qt/5.15.2 +ENV PATH=/root/Qt/5.15.2/gcc_64/bin:$PATH + + +# Install Nim +ENV CHOOSENIM_CHOOSE_VERSION=1.6.2 +RUN /build/komodo-wallet-desktop/ci_tools_atomic_dex/ci_scripts/choosenim.sh -y && \ + export PATH=/root/.nimble/bin:$PATH && \ + chmod +x /root/.choosenim/toolchains/nim-1.6.2/bin/* +ENV PATH=/root/.nimble/bin:$PATH + +RUN cd /build/komodo-wallet-desktop/ci_tools_atomic_dex/vcpkg-repo && ./bootstrap-vcpkg.sh + + +# USAGE: ### +# +# To build the build container +# docker build -t kw-build-container . --progress=plain --no-cache +# +# To build the app +# ./docker-build-linux.sh +# +# To enter container for debugging +# docker run -it kw-build-container bash +### + +CMD [ "bash" ] diff --git a/assets/config/cfg.json b/assets/config/cfg.json index d6704a8f55..0dc1052fd5 100644 --- a/assets/config/cfg.json +++ b/assets/config/cfg.json @@ -1,6 +1,7 @@ { "notification_enabled": true, "spamfilter_enabled": false, + "postorder_enabled": false, "use_static_rpcpass": false, "current_currency": "USD", "current_fiat": "USD", diff --git a/assets/themes/Binance - Dark/colors.json b/assets/themes/Binance - Dark/colors.json index 96f4325b46..1cf3211a5d 100644 --- a/assets/themes/Binance - Dark/colors.json +++ b/assets/themes/Binance - Dark/colors.json @@ -133,6 +133,10 @@ "arrowUpColor": "#F85757", "arrowDownColor": "#845FEF", + "colorPlaceholderText": "#444444FF", + "colorSelectedText": "#0E1021FF", + "colorSelection": "#14bca6FF", + "lineSeparatorColor": "#161515" diff --git a/assets/themes/Default - Dark/colors.json b/assets/themes/Default - Dark/colors.json index ca49b711c5..8c4fff2889 100644 --- a/assets/themes/Default - Dark/colors.json +++ b/assets/themes/Default - Dark/colors.json @@ -132,6 +132,9 @@ "arrowUpColor": "#F85757FF", "arrowDownColor": "#845FEFFF", + "colorPlaceholderText": "#444444FF", + "colorSelectedText": "#0E1021FF", + "colorSelection": "#14bca6FF", "lineSeparatorColor": "#65656542" } diff --git a/assets/themes/Default - Light/colors.json b/assets/themes/Default - Light/colors.json index ab7012c6c9..015f4377e9 100644 --- a/assets/themes/Default - Light/colors.json +++ b/assets/themes/Default - Light/colors.json @@ -130,6 +130,10 @@ "arrowUpColor": "#F85757FF", "arrowDownColor": "#845FEFFF", + "colorPlaceholderText": "#8E9293FF", + "colorSelectedText": "#F9F9FBFF", + "colorSelection": "#14bca6FF", + "lineSeparatorColor": "#65656542" } diff --git a/assets/tools/.gitignore b/assets/tools/.gitignore index b7e0b1c746..a9ab3e54fd 100644 --- a/assets/tools/.gitignore +++ b/assets/tools/.gitignore @@ -1,2 +1,3 @@ mm2 coins +kdf \ No newline at end of file diff --git a/atomic_defi_design/Dex/Addressbook/AddAddressForm.qml b/atomic_defi_design/Dex/Addressbook/AddAddressForm.qml index 13fc57e432..9922e7c01d 100644 --- a/atomic_defi_design/Dex/Addressbook/AddAddressForm.qml +++ b/atomic_defi_design/Dex/Addressbook/AddAddressForm.qml @@ -134,7 +134,7 @@ Dex.Rectangle Layout.fillHeight: true Layout.leftMargin: 4 } - Dex.DefaultText { + Dex.DexLabel { Layout.minimumWidth: 120 Layout.maximumWidth: 120 text: qsTr("Use standard network address") diff --git a/atomic_defi_design/Dex/Addressbook/Main.qml b/atomic_defi_design/Dex/Addressbook/Main.qml index fba4df4df4..6784d69df3 100644 --- a/atomic_defi_design/Dex/Addressbook/Main.qml +++ b/atomic_defi_design/Dex/Addressbook/Main.qml @@ -120,6 +120,13 @@ Item } } + Dex.Text { + visible: contactTable.count == 0 + Layout.fillWidth: true + Layout.fillHeight: true + text: qsTr("No contacts found.") + } + // Contact table content Dex.DefaultListView { diff --git a/atomic_defi_design/Dex/App.qml b/atomic_defi_design/Dex/App.qml index 47b9735d40..f974b3e4c2 100644 --- a/atomic_defi_design/Dex/App.qml +++ b/atomic_defi_design/Dex/App.qml @@ -140,6 +140,7 @@ DexRectangle function showError(title, content) { if (content === undefined || content === null) return + console.log("Opening error_log_modal for " + title) error_log_modal.open() error_log_modal.item.header = title error_log_modal.item.field.text = content diff --git a/atomic_defi_design/Dex/Components/AddressField.qml b/atomic_defi_design/Dex/Components/AddressField.qml index aa972a1a95..d3c31e8463 100644 --- a/atomic_defi_design/Dex/Components/AddressField.qml +++ b/atomic_defi_design/Dex/Components/AddressField.qml @@ -1,6 +1,6 @@ import QtQuick 2.15 -DefaultTextField { +DexTextField { readonly property int max_length: 50 validator: RegExpValidator { diff --git a/atomic_defi_design/Dex/Components/AmountField.qml b/atomic_defi_design/Dex/Components/AmountField.qml index 1d280a8bc6..ed2ce8d9f8 100644 --- a/atomic_defi_design/Dex/Components/AmountField.qml +++ b/atomic_defi_design/Dex/Components/AmountField.qml @@ -1,6 +1,6 @@ import QtQuick 2.15 -DefaultTextField +DexTextField { validator: RegExpValidator { diff --git a/atomic_defi_design/Dex/Components/AmountFloatField.qml b/atomic_defi_design/Dex/Components/AmountFloatField.qml index 06af631e17..17bc43ef5d 100644 --- a/atomic_defi_design/Dex/Components/AmountFloatField.qml +++ b/atomic_defi_design/Dex/Components/AmountFloatField.qml @@ -1,6 +1,6 @@ import QtQuick 2.15 -DefaultTextField +DexTextField { validator: RegExpValidator { diff --git a/atomic_defi_design/Dex/Components/AmountIntField.qml b/atomic_defi_design/Dex/Components/AmountIntField.qml index 30dce4be62..6a78de3d8a 100644 --- a/atomic_defi_design/Dex/Components/AmountIntField.qml +++ b/atomic_defi_design/Dex/Components/AmountIntField.qml @@ -1,6 +1,6 @@ import QtQuick 2.15 -DefaultTextField +DexTextField { property bool allowFloat: false validator: RegExpValidator diff --git a/atomic_defi_design/Dex/Components/Blank.qml b/atomic_defi_design/Dex/Components/Blank.qml index 0f01f2f377..9908b11cac 100644 --- a/atomic_defi_design/Dex/Components/Blank.qml +++ b/atomic_defi_design/Dex/Components/Blank.qml @@ -66,7 +66,7 @@ Item { anchors.fill: bBox2 source: bBox2 radius: 32 - DefaultText { + DexLabel { anchors.centerIn: parent text: "Jemm" } diff --git a/atomic_defi_design/Dex/Components/CannotEnableCoinModal.qml b/atomic_defi_design/Dex/Components/CannotEnableCoinModal.qml index dad42aa5ac..dc137cc0e4 100644 --- a/atomic_defi_design/Dex/Components/CannotEnableCoinModal.qml +++ b/atomic_defi_design/Dex/Components/CannotEnableCoinModal.qml @@ -13,7 +13,7 @@ MultipageModal MultipageModalContent { titleText: qsTr("Failed to enable %1").arg(coin_to_enable_ticker) - DefaultText + DexLabel { Layout.fillWidth: true text: qsTr("Enabling %1 did not succeed. Limit of enabled coins might have been reached.") diff --git a/atomic_defi_design/Dex/Components/CexInfoModal.qml b/atomic_defi_design/Dex/Components/CexInfoModal.qml index cc7c3725a4..04f4f4889b 100644 --- a/atomic_defi_design/Dex/Components/CexInfoModal.qml +++ b/atomic_defi_design/Dex/Components/CexInfoModal.qml @@ -13,7 +13,7 @@ MultipageModal { MultipageModalContent { titleText: General.cex_icon + " " + qsTr("Market Data") - DefaultText { + DexLabel { Layout.preferredHeight: 200 Layout.fillWidth: true diff --git a/atomic_defi_design/Dex/Components/CheckEye.qml b/atomic_defi_design/Dex/Components/CheckEye.qml index e3bb0bca61..a565a86caf 100644 --- a/atomic_defi_design/Dex/Components/CheckEye.qml +++ b/atomic_defi_design/Dex/Components/CheckEye.qml @@ -32,7 +32,7 @@ Item iconSize: 17 } - DefaultText + DexLabel { id: _label font.pixelSize: 15 diff --git a/atomic_defi_design/Dex/Components/ComboBoxWithSearchBar.qml b/atomic_defi_design/Dex/Components/ComboBoxWithSearchBar.qml index bbd86393f1..7bbf1ae998 100644 --- a/atomic_defi_design/Dex/Components/ComboBoxWithSearchBar.qml +++ b/atomic_defi_design/Dex/Components/ComboBoxWithSearchBar.qml @@ -96,7 +96,7 @@ ComboBox width: control.width highlighted: control.highlightedIndex === index - contentItem: DefaultText + contentItem: DexLabel { width: control.width font: DexTypo.subtitle2 diff --git a/atomic_defi_design/Dex/Components/DatePicker.qml b/atomic_defi_design/Dex/Components/DatePicker.qml index c0ce19742e..bb4826829a 100644 --- a/atomic_defi_design/Dex/Components/DatePicker.qml +++ b/atomic_defi_design/Dex/Components/DatePicker.qml @@ -27,7 +27,7 @@ DefaultMouseArea id: column width: parent.width - DefaultText + DexLabel { id: title text: qsTr("Date") @@ -39,7 +39,7 @@ DefaultMouseArea { width: parent.width - DefaultText + DexLabel { id: label text: selectedDate.toLocaleDateString(Locale.ShortFormat, "yyyy-MM-dd") diff --git a/atomic_defi_design/Dex/Components/DefaultCalendar.qml b/atomic_defi_design/Dex/Components/DefaultCalendar.qml index 54c708c022..31482b6c68 100644 --- a/atomic_defi_design/Dex/Components/DefaultCalendar.qml +++ b/atomic_defi_design/Dex/Components/DefaultCalendar.qml @@ -51,7 +51,7 @@ Calendar onClicked: control.showPreviousMonth() } - DefaultText + DexLabel { id: dateText text: styleData.title @@ -113,7 +113,7 @@ Calendar readonly property color selectedDateTextColor: Dex.CurrentTheme.foregroundColor readonly property color differentMonthDateTextColor: Dex.CurrentTheme.foregroundColor3 readonly property color invalidDateColor: Dex.CurrentTheme.textDisabledColor - DefaultText + DexLabel { id: dayDelegateText text: styleData.hasOwnProperty('date') ? styleData.date.getDate() : "" diff --git a/atomic_defi_design/Dex/Components/DefaultRangeSlider.qml b/atomic_defi_design/Dex/Components/DefaultRangeSlider.qml index 390e62c0fd..e6ada9dc1c 100644 --- a/atomic_defi_design/Dex/Components/DefaultRangeSlider.qml +++ b/atomic_defi_design/Dex/Components/DefaultRangeSlider.qml @@ -99,7 +99,7 @@ RangeSlider } } - DefaultText + DexLabel { id: _left_item anchors.left: parent.left @@ -107,7 +107,7 @@ RangeSlider text_value: qsTr("Min") } - DefaultText + DexLabel { id: _right_item anchors.right: parent.right diff --git a/atomic_defi_design/Dex/Components/DefaultSwitch.qml b/atomic_defi_design/Dex/Components/DefaultSwitch.qml deleted file mode 100644 index 0f6010adf3..0000000000 --- a/atomic_defi_design/Dex/Components/DefaultSwitch.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Controls.Universal 2.15 -import "../Constants" -import App 1.0 - -DexSwitch { - -} diff --git a/atomic_defi_design/Dex/Components/DefaultText.qml b/atomic_defi_design/Dex/Components/DefaultText.qml deleted file mode 100644 index d5ea6215e2..0000000000 --- a/atomic_defi_design/Dex/Components/DefaultText.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.15 -import "../Constants" -import App 1.0 - -DexLabel { - -} diff --git a/atomic_defi_design/Dex/Components/DefaultTextArea.qml b/atomic_defi_design/Dex/Components/DefaultTextArea.qml deleted file mode 100644 index 3a86a18c8b..0000000000 --- a/atomic_defi_design/Dex/Components/DefaultTextArea.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import "../Constants" -import App 1.0 - -TextArea -{ - id: text_field - - font.family: Style.font_family - - placeholderTextColor: DexTheme.textPlaceHolderColor - selectedTextColor: DexTheme.textSelectedColor - selectionColor: DexTheme.textSelectionColor - color: DexTheme.foregroundColor - - Behavior on color { ColorAnimation { duration: Style.animationDuration } } - Behavior on placeholderTextColor { ColorAnimation { duration: Style.animationDuration } } - - property bool remove_newline: true - wrapMode: TextEdit.Wrap - - Keys.onBacktabPressed: nextItemInFocusChain(false).forceActiveFocus(Qt.TabFocusReason) - Keys.onTabPressed: nextItemInFocusChain().forceActiveFocus(Qt.TabFocusReason) - - Keys.onPressed: { - if(event.key === Qt.Key_Return) { - if(onReturn !== undefined) { - onReturn() - } - - // Ignore \n \r stuff - if(remove_newline) event.accepted = true - } - } - - onTextChanged: { - if(remove_newline) { - if(text.indexOf('\r') !== -1 || text.indexOf('\n') !== -1) { - text = text.replace(/[\r\n]/, '') - } - } - } - - // Right click Context Menu - selectByMouse: true - persistentSelection: true - - background: InnerBackground { } - - RightClickMenu { } -} diff --git a/atomic_defi_design/Dex/Components/DefaultTextField.qml b/atomic_defi_design/Dex/Components/DefaultTextField.qml deleted file mode 100644 index a0c57e16c7..0000000000 --- a/atomic_defi_design/Dex/Components/DefaultTextField.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import "../Constants" -import App 1.0 - -DexTextField { - -} diff --git a/atomic_defi_design/Dex/Components/DexCheckBox.qml b/atomic_defi_design/Dex/Components/DexCheckBox.qml index 344df181ad..9f25649c57 100644 --- a/atomic_defi_design/Dex/Components/DexCheckBox.qml +++ b/atomic_defi_design/Dex/Components/DexCheckBox.qml @@ -74,7 +74,7 @@ CheckBox height: _label.height spacing: 0 - DefaultText + DexLabel { id: _label text: control.text diff --git a/atomic_defi_design/Dex/Components/DexComboBox.qml b/atomic_defi_design/Dex/Components/DexComboBox.qml index 38245425d2..560d3c6fd9 100644 --- a/atomic_defi_design/Dex/Components/DexComboBox.qml +++ b/atomic_defi_design/Dex/Components/DexComboBox.qml @@ -30,7 +30,7 @@ ComboBox // Main, selected text contentItem: Item { - DefaultText + DexLabel { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left @@ -108,7 +108,7 @@ ComboBox width: control.width highlighted: control.highlightedIndex === index - contentItem: DefaultText + contentItem: DexLabel { width: control.width font: DexTypo.subtitle2 diff --git a/atomic_defi_design/Dex/Components/DexGradientAppButton.qml b/atomic_defi_design/Dex/Components/DexGradientAppButton.qml index 5624512c13..b4485f7c9a 100644 --- a/atomic_defi_design/Dex/Components/DexGradientAppButton.qml +++ b/atomic_defi_design/Dex/Components/DexGradientAppButton.qml @@ -22,7 +22,6 @@ DexRectangle property bool text_left_align: false - property int minWidth: 90 property real textScale: 1 diff --git a/atomic_defi_design/Dex/Components/DexItemBox.qml b/atomic_defi_design/Dex/Components/DexItemBox.qml index eaec5d467e..a1befac2de 100644 --- a/atomic_defi_design/Dex/Components/DexItemBox.qml +++ b/atomic_defi_design/Dex/Components/DexItemBox.qml @@ -145,7 +145,7 @@ InnerBackground { anchors.fill: parent Layout.rightMargin: 10 Layout.leftMargin: 10 - DefaultText { + DexLabel { id: _texto leftPadding: 10 Layout.alignment: Qt.AlignVCenter @@ -239,7 +239,7 @@ InnerBackground { radius: parent.parent.height < 41 ? parent.parent.radius : 0 color: DexTheme.backgroundDarkColor6 visible: !isVertical && hidden - DefaultText { + DexLabel { id: _texto2 leftPadding: 10 Layout.alignment: Qt.AlignVCenter diff --git a/atomic_defi_design/Dex/Components/DexLabel.qml b/atomic_defi_design/Dex/Components/DexLabel.qml index ef6694978d..603cd5abdc 100644 --- a/atomic_defi_design/Dex/Components/DexLabel.qml +++ b/atomic_defi_design/Dex/Components/DexLabel.qml @@ -20,13 +20,14 @@ Text } } - font: monospace ? Dex.DexTypo.monoSmall : Dex.DexTypo.body2 - color: enabled ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.textDisabledColor - + font: monospace ? Dex.DexTypo.monoSmall : Dex.DexTypo.body2 text: privacy && Dex.General.privacy_mode ? Dex.General.privacy_text : text_value wrapMode: Text.WordWrap onLinkActivated: Qt.openUrlExternally(link) linkColor: color } + +// 90% similar to DexText.qml +// This could be refactored down. diff --git a/atomic_defi_design/Dex/Components/DexRangeSlider.qml b/atomic_defi_design/Dex/Components/DexRangeSlider.qml index b138b4ce81..fad0945162 100644 --- a/atomic_defi_design/Dex/Components/DexRangeSlider.qml +++ b/atomic_defi_design/Dex/Components/DexRangeSlider.qml @@ -83,7 +83,7 @@ RangeSlider { //border.color: "#bdbebf" } - DefaultText { + DexLabel { id: secondTooltip visible: parent.second.pressed anchors.horizontalCenter: parent.second.handle.horizontalCenter @@ -92,7 +92,7 @@ RangeSlider { text_value: parent.second.value font.pixelSize: Constants.Style.textSizeSmall1 } - DefaultText { + DexLabel { id: firstTooltip visible: parent.first.pressed anchors.horizontalCenter: parent.first.handle.horizontalCenter @@ -101,21 +101,21 @@ RangeSlider { text_value: parent.first.value font.pixelSize: Constants.Style.textSizeSmall1 } - DefaultText { + DexLabel { id: _left_item anchors.left: parent.left anchors.top: parent.bottom text_value: qsTr("Min") } - DefaultText { + DexLabel { id: _half_item anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.bottom text_value: qsTr("Half") } - DefaultText { + DexLabel { id: _right_item anchors.right: parent.right anchors.top: parent.bottom diff --git a/atomic_defi_design/Dex/Components/DexSweetComboBox.qml b/atomic_defi_design/Dex/Components/DexSweetComboBox.qml index cc47e64e63..fb818032c2 100644 --- a/atomic_defi_design/Dex/Components/DexSweetComboBox.qml +++ b/atomic_defi_design/Dex/Components/DexSweetComboBox.qml @@ -85,7 +85,7 @@ ComboBox { anchors.rightMargin: 5 - DefaultTextField + DexTextField { id: input_coin_filter placeholderText: qsTr("Search") @@ -172,7 +172,7 @@ ComboBox { width: control.width + 50 highlighted: control.highlightedIndex === index - contentItem: DefaultText + contentItem: DexLabel { text_value: "" + ticker + "" + " %1".arg(General.coinName(ticker)) } diff --git a/atomic_defi_design/Dex/Components/DexSwitch.qml b/atomic_defi_design/Dex/Components/DexSwitch.qml index 10fd5a6090..9333bd37fa 100644 --- a/atomic_defi_design/Dex/Components/DexSwitch.qml +++ b/atomic_defi_design/Dex/Components/DexSwitch.qml @@ -29,9 +29,9 @@ Switch indicator: DefaultRectangle { id: _indicator - width: 52 - height: 28 - radius: 13 + width: 42 + height: 24 + radius: 12 anchors.verticalCenter: control.verticalCenter gradient: Gradient @@ -108,7 +108,7 @@ Switch visible: _label.text != '' - DefaultText + DexLabel { id: _label Layout.fillHeight: true @@ -122,7 +122,7 @@ Switch wrapMode: Label.Wrap } - DefaultText + DexLabel { id: _label2 Layout.fillHeight: true diff --git a/atomic_defi_design/Dex/Components/DexText.qml b/atomic_defi_design/Dex/Components/DexText.qml index 456b18b017..d85ff72da8 100644 --- a/atomic_defi_design/Dex/Components/DexText.qml +++ b/atomic_defi_design/Dex/Components/DexText.qml @@ -1,20 +1,28 @@ +//! Qt Imports. import QtQuick 2.15 -import "../Constants" + +//! Project Imports import App 1.0 +import "../Constants" as Dex +import Dex.Themes 1.0 as Dex Text { property string text_value property bool privacy: false + property bool monospace: false - Behavior on color { - ColorAnimation { + Behavior on color + { + ColorAnimation + { duration: Style.animationDuration } } - font: DexTypo.body1 + color: DexTheme.foregroundColor - text: privacy && General.privacy_mode ? General.privacy_text : text_value + font: DexTypo.body1 + text: privacy && Dex.General.privacy_mode ? Dex.General.privacy_text : text_value wrapMode: Text.WordWrap onLinkActivated: Qt.openUrlExternally(link) @@ -25,4 +33,7 @@ Text { cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor acceptedButtons: Qt.NoButton } -} \ No newline at end of file +} + +// 90% similar to DexLabel.qml +// This could be refactored down. diff --git a/atomic_defi_design/Dex/Components/DexTextArea.qml b/atomic_defi_design/Dex/Components/DexTextArea.qml index 80cf2133b4..ac8642f89b 100644 --- a/atomic_defi_design/Dex/Components/DexTextArea.qml +++ b/atomic_defi_design/Dex/Components/DexTextArea.qml @@ -2,15 +2,18 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import "../Constants" import App 1.0 +import Dex.Components 1.0 as Dex +import Dex.Themes 1.0 as Dex TextArea { id: text_field font.family: Style.font_family - placeholderTextColor: Style.colorPlaceholderText - selectedTextColor: Style.colorSelectedText - selectionColor: Style.colorSelection + color: Dex.CurrentTheme.foregroundColor + placeholderTextColor: Dex.CurrentTheme.colorPlaceholderText + selectedTextColor: Dex.CurrentTheme.colorSelectedText + selectionColor: Dex.CurrentTheme.colorSelection Behavior on color { ColorAnimation { @@ -52,9 +55,7 @@ TextArea { selectByMouse: true persistentSelection: true - background: InnerBackground { - auto_set_size: false - } + background: InnerBackground {} RightClickMenu {} } \ No newline at end of file diff --git a/atomic_defi_design/Dex/Components/DexTextField.qml b/atomic_defi_design/Dex/Components/DexTextField.qml index 1764675b85..1aafddd2e2 100644 --- a/atomic_defi_design/Dex/Components/DexTextField.qml +++ b/atomic_defi_design/Dex/Components/DexTextField.qml @@ -10,6 +10,8 @@ TextField property alias left_text: left_text.text_value property alias right_text: right_text.text_value + property alias left_fontsize: left_text.font.pixelSize + property alias right_fontsize: right_text.font.pixelSize property alias radius: background.radius property color backgroundColor: Dex.CurrentTheme.textFieldBackgroundColor property color backgroundColorActive: Dex.CurrentTheme.textFieldActiveBackgroundColor diff --git a/atomic_defi_design/Dex/Components/DexTradeBox.qml b/atomic_defi_design/Dex/Components/DexTradeBox.qml index baadc04fc0..fdfcfe9f81 100644 --- a/atomic_defi_design/Dex/Components/DexTradeBox.qml +++ b/atomic_defi_design/Dex/Components/DexTradeBox.qml @@ -272,7 +272,7 @@ Rectangle { height: parent.height anchors.right: parent.right visible: !isVertical && hidden - DefaultText + DexLabel { id: _texto2 leftPadding: 10 diff --git a/atomic_defi_design/Dex/Components/ElidableText.qml b/atomic_defi_design/Dex/Components/ElidableText.qml index a3e3682c2d..ab56439344 100644 --- a/atomic_defi_design/Dex/Components/ElidableText.qml +++ b/atomic_defi_design/Dex/Components/ElidableText.qml @@ -1,6 +1,6 @@ import QtQuick 2.12 -DefaultText +DexLabel { elide: Text.ElideRight } diff --git a/atomic_defi_design/Dex/Components/EulaModal.qml b/atomic_defi_design/Dex/Components/EulaModal.qml index ad71f04fab..b09740a73c 100644 --- a/atomic_defi_design/Dex/Components/EulaModal.qml +++ b/atomic_defi_design/Dex/Components/EulaModal.qml @@ -41,7 +41,7 @@ MultipageModal contentWidth: eula_text.width - 10 contentHeight: eula_text.height - DefaultText + DexLabel { id: eula_text font: DexTypo.body1 diff --git a/atomic_defi_design/Dex/Components/GasInfoModal.qml b/atomic_defi_design/Dex/Components/GasInfoModal.qml index be86f0dd52..fdb90c0e0d 100644 --- a/atomic_defi_design/Dex/Components/GasInfoModal.qml +++ b/atomic_defi_design/Dex/Components/GasInfoModal.qml @@ -13,27 +13,27 @@ MultipageModal { MultipageModalContent { titleText: General.cex_icon + " " + qsTr("How do I calculate gas?") - DefaultText { + DexLabel { Layout.fillWidth: true text: qsTr('Gas is measured in gwei. Gwei is just a unit of Ether, and is equal to 0.000000001 ETH (or the equivalent platform coin such as AVAX or BNB). The gas price varies over time depending on network congestion.') } - DefaultText { + DexLabel { Layout.fillWidth: true text: qsTr('The gas limit is how many units of gas (maximum) you allocate to pay for a transaction. The gas required depending on the size of the transaction & data being transmitted.') } - DefaultText { + DexLabel { Layout.fillWidth: true text: qsTr('A standard transaction not involving contracts uses 21,000 gas units, with any of the limit remaining returned to the source address.') } - DefaultText { + DexLabel { Layout.fillWidth: true text: qsTr('Transactions involving contracts may result in the whole limit being consumed, so be careful not to set it too high.') } - DefaultText { + DexLabel { Layout.fillWidth: true text: qsTr('For more information, read the article at https://support.mycrypto.com/how-to/sending/how-to-know-what-gas-limit-to-use') diff --git a/atomic_defi_design/Dex/Components/LogoutModal.qml b/atomic_defi_design/Dex/Components/LogoutModal.qml index 029a275a1f..a068c504de 100644 --- a/atomic_defi_design/Dex/Components/LogoutModal.qml +++ b/atomic_defi_design/Dex/Components/LogoutModal.qml @@ -18,7 +18,7 @@ MultipageModal { titleText: qsTr("Exit %1 or go to login menu?").arg(API.app_name) // Swap in progress warning - DefaultText + DexLabel { visible: orders font.pixelSize: 14 diff --git a/atomic_defi_design/Dex/Components/MinTradeModal.qml b/atomic_defi_design/Dex/Components/MinTradeModal.qml index b81d0a56c0..38de900258 100644 --- a/atomic_defi_design/Dex/Components/MinTradeModal.qml +++ b/atomic_defi_design/Dex/Components/MinTradeModal.qml @@ -13,7 +13,7 @@ MultipageModal { MultipageModalContent { titleText: General.cex_icon + " " + qsTr("Minimum Trading Amount") - DefaultText { + DexLabel { //Layout.preferredHeight: 200 Layout.fillWidth: true wrapMode: Text.Wrap diff --git a/atomic_defi_design/Dex/Components/ModalHeader.qml b/atomic_defi_design/Dex/Components/ModalHeader.qml index 73d178ca73..d146a7a46d 100644 --- a/atomic_defi_design/Dex/Components/ModalHeader.qml +++ b/atomic_defi_design/Dex/Components/ModalHeader.qml @@ -7,7 +7,7 @@ ColumnLayout { property alias title: title.text // Title - DefaultText { + DexLabel { id: title font: DexTypo.head6 } diff --git a/atomic_defi_design/Dex/Components/MultipageModalContent.qml b/atomic_defi_design/Dex/Components/MultipageModalContent.qml index fa900230ff..73eb6f430e 100644 --- a/atomic_defi_design/Dex/Components/MultipageModalContent.qml +++ b/atomic_defi_design/Dex/Components/MultipageModalContent.qml @@ -30,7 +30,7 @@ ColumnLayout Layout.fillHeight: false Layout.maximumHeight: window.height - 50 - DefaultText + DexLabel { id: _title Layout.topMargin: root.titleTopMargin @@ -39,7 +39,7 @@ ColumnLayout visible: text != '' } - DefaultText + DexLabel { id: _subtitle Layout.topMargin: 5 diff --git a/atomic_defi_design/Dex/Components/Pagination.qml b/atomic_defi_design/Dex/Components/Pagination.qml index 7017d7ce82..b4ffb3212e 100644 --- a/atomic_defi_design/Dex/Components/Pagination.qml +++ b/atomic_defi_design/Dex/Components/Pagination.qml @@ -72,7 +72,7 @@ RowLayout popupBackgroundColor: Dex.CurrentTheme.backgroundColor } - DefaultText { + DexLabel { Layout.alignment: Qt.AlignCenter font.pixelSize: 11 text_value: qsTr("items per page") diff --git a/atomic_defi_design/Dex/Components/PairItemBadge.qml b/atomic_defi_design/Dex/Components/PairItemBadge.qml index 4fec7de383..5ceab63666 100644 --- a/atomic_defi_design/Dex/Components/PairItemBadge.qml +++ b/atomic_defi_design/Dex/Components/PairItemBadge.qml @@ -24,11 +24,22 @@ DexRectangle property int padding: 0 property alias middle_text: middle_line.text_value property alias bottom_text: bottom_line.text_value + property bool is_left: false Layout.fillHeight: true Layout.fillWidth: true Layout.leftMargin: 10 Layout.rightMargin: 20 + DexLabel + { + anchors.bottom: parent.top + anchors.bottomMargin: 5 + anchors.horizontalCenter: parent.horizontalCenter + text: is_left ? "Outgoing" : "Incoming" + font: Dex.DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 + } + RowLayout { anchors.fill: parent @@ -36,6 +47,7 @@ DexRectangle Layout.leftMargin: 20 Layout.rightMargin: 20 + // Coin Icon Dex.Image { id: icon @@ -48,49 +60,46 @@ DexRectangle Layout.topMargin: 0 Layout.bottomMargin: 0 } + + // ColumnLayout { spacing: 2 Layout.alignment: Qt.AlignVCenter - Dex.Text + DexLabel { Layout.preferredWidth: parent.width - 15 - text_value: `${ticker}   ${fullname}` - font.pixelSize: Style.textSizeSmall3 + font: Dex.DexTypo.body2 elide: Text.ElideRight wrapMode: Text.NoWrap } - Dex.Text + DexLabel { id: middle_line - property string coin_value: amount - text: coin_value + text_value: coin_value Layout.fillWidth: true elide: Text.ElideRight - color: Dex.CurrentTheme.foregroundColor - font: DexTypo.body2 wrapMode: Label.NoWrap - ToolTip.text: coin_value - Component.onCompleted: font.pixelSize = 11.5 + font: DexTypo.body3 + ToolTip.text: text_value + privacy: true } - Dex.Text + DexLabel { id: bottom_line - property string fiat_value: General.getFiatText(amount, ticker) - text: fiat_value + text_value: fiat_value Layout.fillWidth: true elide: Text.ElideRight - color: Dex.CurrentTheme.foregroundColor - font: DexTypo.body2 + font: DexTypo.body3 wrapMode: Label.NoWrap - ToolTip.text: fiat_value - Component.onCompleted: font.pixelSize = 11.5 + ToolTip.text: text_value + privacy: true } } } diff --git a/atomic_defi_design/Dex/Components/PasswordField.qml b/atomic_defi_design/Dex/Components/PasswordField.qml index 6e7301354e..1f5f581dde 100644 --- a/atomic_defi_design/Dex/Components/PasswordField.qml +++ b/atomic_defi_design/Dex/Components/PasswordField.qml @@ -68,36 +68,36 @@ ColumnLayout { visible: !hide_hint Layout.fillWidth: true - DefaultText { + DexLabel { visible: high_security font.pixelSize: Style.textSizeSmall3 text_value: hintPrefix(hasEnoughLowercaseCharacters()) + qsTr("At least 1 lowercase alphabetical character") color: hintColor(hasEnoughLowercaseCharacters()) } - DefaultText { + DexLabel { visible: high_security font.pixelSize: Style.textSizeSmall3 text_value: hintPrefix(hasEnoughUppercaseCharacters()) + qsTr("At least 1 uppercase alphabetical character") color: hintColor(hasEnoughUppercaseCharacters()) } - DefaultText { + DexLabel { visible: high_security font.pixelSize: Style.textSizeSmall3 text_value: hintPrefix(hasEnoughNumericCharacters()) + qsTr("At least 1 numeric character") color: hintColor(hasEnoughNumericCharacters()) } - DefaultText { + DexLabel { visible: high_security font.pixelSize: Style.textSizeSmall3 text_value: hintPrefix(hasEnoughSpecialCharacters()) + qsTr("At least 1 special character (eg. !@#$%)") color: hintColor(hasEnoughSpecialCharacters()) } - DefaultText { + DexLabel { font.pixelSize: Style.textSizeSmall3 text_value: hintPrefix(hasEnoughCharacters()) + qsTr("Between %1 and %2 character(s)").arg(high_security ? 16 : 1).arg(max_pw_len) color: hintColor(hasEnoughCharacters()) } - DefaultText { + DexLabel { font.pixelSize: Style.textSizeSmall3 text_value: hintPrefix(passwordsDoMatch()) + qsTr(high_security ? "Password and Confirm Password have to be same" : "Password suffix and confirm password suffix must be the same") color: hintColor(passwordsDoMatch()) diff --git a/atomic_defi_design/Dex/Components/RoundComboBox.qml b/atomic_defi_design/Dex/Components/RoundComboBox.qml index 247073ec5b..5801d503b7 100644 --- a/atomic_defi_design/Dex/Components/RoundComboBox.qml +++ b/atomic_defi_design/Dex/Components/RoundComboBox.qml @@ -35,7 +35,7 @@ ComboBox contentItem: Item { anchors.fill: parent - DefaultText + DexLabel { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left diff --git a/atomic_defi_design/Dex/Components/SearchField.qml b/atomic_defi_design/Dex/Components/SearchField.qml index 40bcae12df..34353082e0 100644 --- a/atomic_defi_design/Dex/Components/SearchField.qml +++ b/atomic_defi_design/Dex/Components/SearchField.qml @@ -37,7 +37,7 @@ Rectangle } } - DefaultTextField + DexTextField { id: _textField diff --git a/atomic_defi_design/Dex/Components/TextAreaWithTitle.qml b/atomic_defi_design/Dex/Components/TextAreaWithTitle.qml index 38d85520e8..359556f032 100644 --- a/atomic_defi_design/Dex/Components/TextAreaWithTitle.qml +++ b/atomic_defi_design/Dex/Components/TextAreaWithTitle.qml @@ -66,7 +66,7 @@ ColumnLayout Item { Layout.fillWidth: true Layout.preferredHeight: input_field.height + 5 - DefaultTextArea { + DexTextArea { id: input_field enabled: !saveable width: parent.width - 6 diff --git a/atomic_defi_design/Dex/Components/TextEditWithTitle.qml b/atomic_defi_design/Dex/Components/TextEditWithTitle.qml index 93a0eba3c6..5049c20192 100644 --- a/atomic_defi_design/Dex/Components/TextEditWithTitle.qml +++ b/atomic_defi_design/Dex/Components/TextEditWithTitle.qml @@ -25,7 +25,7 @@ ComponentWithTitle { Layout.fillWidth: true - DefaultText + DexLabel { id: _text diff --git a/atomic_defi_design/Dex/Components/TextFieldWithTitle.qml b/atomic_defi_design/Dex/Components/TextFieldWithTitle.qml index e0bd8aae3f..dafd1bffe3 100644 --- a/atomic_defi_design/Dex/Components/TextFieldWithTitle.qml +++ b/atomic_defi_design/Dex/Components/TextFieldWithTitle.qml @@ -42,7 +42,7 @@ ColumnLayout visible: text !== '' } - DefaultText + DexLabel { visible: required && input_field.text === '' font.pixelSize: Style.textSizeSmall2 @@ -51,7 +51,7 @@ ColumnLayout } } - DefaultTextField + DexTextField { id: input_field diff --git a/atomic_defi_design/Dex/Components/Toast.qml b/atomic_defi_design/Dex/Components/Toast.qml index e67142167d..57d9149fdc 100644 --- a/atomic_defi_design/Dex/Components/Toast.qml +++ b/atomic_defi_design/Dex/Components/Toast.qml @@ -2,8 +2,11 @@ // https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129 import QtQuick 2.15 -import "../Constants" import App 1.0 +import Dex.Components 1.0 as Dex +import "../Components" as Dex +import "../Constants" as Dex +import Dex.Themes 1.0 as Dex AnimatedRectangle { function show(text, duration, info, is_error) { @@ -36,7 +39,7 @@ AnimatedRectangle { radius: margin / 3 opacity: 0 - color: isError ? DexTheme.warningColor : Style.colorTheme1 + color: isError ? Dex.CurrentTheme.warningColor : "#3CC9BF" z: 1000 DexLabel { @@ -50,7 +53,7 @@ AnimatedRectangle { margins: margin / 2 } font.pixelSize: Style.textSizeSmall2 - text_value: title + (General.isFilled(details) ? (" - " + qsTr("Click here to see the details")) : "") + text_value: title + (Dex.General.isFilled(details) ? (" - " + qsTr("Click here to see the details")) : "") } SequentialAnimation on opacity { diff --git a/atomic_defi_design/Dex/Components/Widget.qml b/atomic_defi_design/Dex/Components/Widget.qml index 6b6c01c908..f66b82fd1c 100644 --- a/atomic_defi_design/Dex/Components/Widget.qml +++ b/atomic_defi_design/Dex/Components/Widget.qml @@ -114,7 +114,7 @@ Item RowLayout { - DefaultText { text: root.title; font: DexTypo.subtitle1 } + DexLabel { text: root.title; font: DexTypo.subtitle1 } Item { Layout.fillWidth: true } Qaterial.Icon { diff --git a/atomic_defi_design/Dex/Components/ZcashParamsModal.qml b/atomic_defi_design/Dex/Components/ZcashParamsModal.qml index 30c642674a..969eae7612 100644 --- a/atomic_defi_design/Dex/Components/ZcashParamsModal.qml +++ b/atomic_defi_design/Dex/Components/ZcashParamsModal.qml @@ -20,7 +20,7 @@ Dex.MultipageModal { titleText: qsTr("%1 Activation Failed!").arg(coins.join(' / ')) - Dex.DefaultText + Dex.DexLabel { Layout.fillWidth: true text: qsTr("To activate ZHTLC coins, you need to download the Zcash Params.\nThis might take a few minutes...") diff --git a/atomic_defi_design/Dex/Components/qmldir b/atomic_defi_design/Dex/Components/qmldir index dab8794241..6db7d06958 100644 --- a/atomic_defi_design/Dex/Components/qmldir +++ b/atomic_defi_design/Dex/Components/qmldir @@ -15,8 +15,8 @@ Popup 1.0 DefaultPopup.qml Rectangle 1.0 DefaultRectangle.qml ScrollView 1.0 DefaultScrollView.qml SearchField 1.0 SearchField.qml -Text 1.0 DefaultText.qml -TextField 1.0 DefaultTextField.qml +Text 1.0 DexLabel.qml +TextField 1.0 DexTextField.qml TextFieldWithTitle 1.0 TextFieldWithTitle.qml ToolTip 1.0 DefaultTooltip.qml UserIcon 1.0 UserIcon.qml diff --git a/atomic_defi_design/Dex/Constants/DexTheme.qml b/atomic_defi_design/Dex/Constants/DexTheme.qml index 7653d2e248..2a552837c7 100644 --- a/atomic_defi_design/Dex/Constants/DexTheme.qml +++ b/atomic_defi_design/Dex/Constants/DexTheme.qml @@ -317,9 +317,9 @@ QtObject { readonly property string colorText2: dark_theme ? "#79808C" : "#3C5368" readonly property string colorTextDisabled: dark_theme ? Style.colorWhite8 : "#B5B9C1" - readonly property string colorPlaceholderText: Style.colorWhite9 - readonly property string colorSelectedText: Style.colorTheme9 - readonly property string colorSelection: Style.colorGreen2 + readonly property string colorPlaceholderText: dark_theme ? Style.colorWhite9 : Style.colorWhite9 + readonly property string colorSelectedText: dark_theme ? Style.colorTheme9 : Style.colorTheme9 + readonly property string colorSelection: dark_theme ? Style.colorGreen2 : Style.colorGreen2 readonly property string colorTrendingLine: dark_theme ? Style.colorGreen : "#37a6ef" diff --git a/atomic_defi_design/Dex/Constants/DexTypo.qml b/atomic_defi_design/Dex/Constants/DexTypo.qml index 8df64967c7..1207047e87 100644 --- a/atomic_defi_design/Dex/Constants/DexTypo.qml +++ b/atomic_defi_design/Dex/Constants/DexTypo.qml @@ -154,6 +154,13 @@ QtObject { family: "Courier", weight: Font.Normal }) + property font italic12: Qt.font({ + pixelSize: 12 * fontDensity, + letterSpacing: 0.2, + family: fontFamily, + weight: Font.Normal, + italic: true + }) property font inputFieldFont: Qt.font({ pixelSize: (16 * DexTypo.fontDensity) * (Screen.pixelDensity / 160), letterSpacing: 0.5, diff --git a/atomic_defi_design/Dex/Constants/General.qml b/atomic_defi_design/Dex/Constants/General.qml index d57eeb99de..0d2d23c275 100644 --- a/atomic_defi_design/Dex/Constants/General.qml +++ b/atomic_defi_design/Dex/Constants/General.qml @@ -25,6 +25,14 @@ QtObject { function coinIcon(ticker) { + if (ticker.toLowerCase() == "smart chain") + { + return coin_icons_path + "smart_chain.png" + } + if (ticker.toLowerCase() == "avx") + { + return coin_icons_path + "avax.png" + } if (ticker === "" || ticker === "All" || ticker===undefined) { return "" @@ -88,6 +96,11 @@ QtObject { return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).is_faucet_coin } + function isVoteCoin(ticker) + { + return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).is_vote_coin + } + function isCoinWithMemo(ticker) { return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).has_memos @@ -170,7 +183,7 @@ QtObject { } function coinContractAddress(ticker) { - var cfg = API.app.trading_pg.get_raw_mm2_coin_cfg(ticker) + var cfg = API.app.trading_pg.get_raw_kdf_coin_cfg(ticker) if (cfg.hasOwnProperty('protocol')) { if (cfg.protocol.hasOwnProperty('protocol_data')) { if (cfg.protocol.protocol_data.hasOwnProperty('contract_address')) { @@ -182,7 +195,7 @@ QtObject { } function coinPlatform(ticker) { - var cfg = API.app.trading_pg.get_raw_mm2_coin_cfg(ticker) + var cfg = API.app.trading_pg.get_raw_kdf_coin_cfg(ticker) if (cfg.hasOwnProperty('protocol')) { if (cfg.protocol.hasOwnProperty('protocol_data')) { if (cfg.protocol.protocol_data.hasOwnProperty('platform')) { @@ -414,6 +427,14 @@ QtObject { } function getFeesDetail(fees) { + if (privacy_mode) { + return [ + {"label": privacy_text}, + {"label": privacy_text}, + {"label": privacy_text}, + {"label": privacy_text} + ] + } return [ {"label": qsTr("Taker tx fee: "), "fee": fees.base_transaction_fees, "ticker": fees.base_transaction_fees_ticker}, {"label": qsTr("Dex tx fee: "), "fee": fees.fee_to_send_taker_fee, "ticker": fees.fee_to_send_taker_fee_ticker}, @@ -429,10 +450,23 @@ QtObject { return feetype + " " + amount + " " + ticker + " (" + fiat_text + ")" } + function reducedBignum(text, decimals=8, max_length=12) { + let val = new BigNumber(text).toFixed(decimals) + if (val.length > max_length) + { + return val.substring(0, max_length) + } + return val + } + function getSimpleFromPlaceholder(selectedTicker, selectedOrder, sell_ticker_balance) { + if (privacy_mode) + { + return "0" + } if (sell_ticker_balance == 0) { - return qsTr("%1 balance is zero").arg(selectedTicker) + return qsTr("Balance is zero!") } if (!isZhtlcReady(selectedTicker)) { @@ -484,6 +518,7 @@ QtObject { } function getTxExplorerURL(ticker, txid, add_0x=true) { + if (privacy_mode) return '' if(txid !== '') { const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker) const txid_prefix = (add_0x && coin_info.is_erc_family) ? '0x' : '' @@ -492,6 +527,7 @@ QtObject { } function getAddressExplorerURL(ticker, address) { + if (privacy_mode) return '' if(address !== '') { const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker) return coin_info.explorer_url + addressTxUri(coin_info) + address @@ -500,12 +536,14 @@ QtObject { } function viewTxAtExplorer(ticker, txid, add_0x=true) { + if (privacy_mode) return '' if(txid !== '') { Qt.openUrlExternally(getTxExplorerURL(ticker, txid, add_0x)) } } function viewAddressAtExplorer(ticker, address) { + if (privacy_mode) return '' if(address !== '') { Qt.openUrlExternally(getAddressExplorerURL(ticker, address)) } @@ -550,6 +588,7 @@ QtObject { } function convertUsd(v) { + if (privacy_mode) return '' let rate = API.app.get_rate_conversion("USD", API.app.settings_pg.current_currency) let value = parseFloat(v) / parseFloat(rate) @@ -560,16 +599,18 @@ QtObject { return formatFiat("", value, API.app.settings_pg.current_currency) } - function formatFiat(received, amount, fiat, precision=2) { - if (precision == 2 && fiat == "BTC") { - precision = 8 + function formatFiat(received, amount, fiat, sf=2) { + if (privacy_mode) return '' + if (sf == 2 && fiat == "BTC") { + sf = 8 } return diffPrefix(received) + (fiat === API.app.settings_pg.current_fiat ? API.app.settings_pg.current_fiat_sign : API.app.settings_pg.current_currency_sign) - + " " + (amount < 1E5 ? formatDouble(parseFloat(amount), precision, true) : nFormatter(parseFloat(amount), 2)) + + " " + (amount < 1E5 ? formatDouble(parseFloat(amount), sf, true) : nFormatter(parseFloat(amount), sf)) } function formatPercent(value, show_prefix=true) { + if (privacy_mode) return '' let prefix = '' if(value > 0) prefix = '+ ' else if(value < 0) { @@ -580,7 +621,17 @@ QtObject { return (show_prefix ? prefix : '') + parseFloat(value).toFixed(3) + ' %' } - readonly property int amountPrecision: 8 + + function formatCexRates(value) { + if (value === "0") return "N/A" + if (parseFloat(value) > 0) { + return "+"+formatNumber(value, 2)+"%" + } + return formatNumber(value, 2)+"%" + } + + + readonly property int defaultPrecision: 8 readonly property int sliderDigitLimit: 9 readonly property int recommendedPrecision: -1337 @@ -590,17 +641,58 @@ QtObject { function getRecommendedPrecision(v, limit) { const lim = limit || sliderDigitLimit - return Math.min(Math.max(lim - getDigitCount(v), 0), amountPrecision) + return Math.min(Math.max(lim - getDigitCount(v), 0), defaultPrecision) + } + + /** + * Converts a float into a readable string with K, M, B, etc. + * @param {number} num - The number to format. + * @param {number} decimals - The number of decimal places to include (default is 2). + * @param {number} extra_decimals - The number of decimal places to include if no suffix (default is 8). + * @returns {string} - The formatted string. + */ + function formatNumber(num, decimals = 8) { + let r = "0"; + let suffix = ""; + + if (isNaN(num) || num === null) { + return r; + } + + if (typeof(num) == 'string') { + num = parseFloat(num) + } + + const suffixes = ['', 'K', 'M', 'B', 'T']; // Add more as needed for larger numbers + const tier = Math.floor(Math.log10(Math.abs(num)) / 3); // Determine the tier (e.g., thousands, millions) + + if ([-1, 0].includes(tier)) { + r = num.toFixed(decimals); + return r + } + if (tier <= suffixes.length - 1) { + suffix = suffixes[tier] + if (suffix != '') + { + num = (num / Math.pow(10, tier * 3)); + } + } + else { + suffix = "e" + tier * 3 + num = (num / Math.pow(10, tier * 3)); + } + r = num.toFixed(decimals) + "" + suffix; + return r; } - function formatDouble(v, precision, trail_zeros) { + function formatDouble(v, sf = defaultPrecision, trail_zeros = true) { if(v === '') return "0" - if(precision === recommendedPrecision) precision = getRecommendedPrecision(v) + if(sf === recommendedPrecision) sf = getRecommendedPrecision(v) - if(precision === 0) return parseInt(v).toString() + if(sf === 0) return parseInt(v).toString() // Remove more than n decimals, then convert to string without trailing zeros - const full_double = parseFloat(v).toFixed(precision || amountPrecision) + const full_double = parseFloat(v).toFixed(sf || defaultPrecision) return trail_zeros ? full_double : full_double.replace(/\.?0+$/,"") } @@ -613,8 +705,12 @@ QtObject { return parseFloat(formatDouble(value, 2)) } - function formatCrypto(received, amount, ticker, fiat_amount, fiat, precision, trail_zeros) { - return diffPrefix(received) + ticker + " " + formatDouble(amount, precision, trail_zeros) + (fiat_amount ? " (" + formatFiat("", fiat_amount, fiat) + ")" : "") + function formatCrypto(received, amount, ticker, fiat_amount, fiat, sf, trail_zeros) { + if (privacy_mode) { + return "" + } + const prefix = diffPrefix(received) + return prefix + ticker + " " + formatDouble(amount, sf, trail_zeros) + (fiat_amount ? " (" + formatFiat("", fiat_amount, fiat) + ")" : "") } function formatFullCrypto(received, amount, ticker, fiat_amount, fiat, use_full_ticker) { @@ -772,15 +868,10 @@ QtObject { } function feeText(trade_info, base_ticker, has_info_icon=true, has_limited_space=false) { - - if(!trade_info || !trade_info.trading_fee) return "" - const tx_fee = txFeeText(trade_info, base_ticker, has_info_icon, has_limited_space) const trading_fee = tradingFeeText(trade_info, base_ticker, has_info_icon) const minimum_amount = minimumtradingFeeText(trade_info, base_ticker, has_info_icon) - - return tx_fee + "\n" + trading_fee +"
"+minimum_amount } @@ -799,13 +890,9 @@ QtObject { } function txFeeText(trade_info, base_ticker, has_info_icon=true, has_limited_space=false) { - if(!trade_info || !trade_info.trading_fee) return "" - const has_parent_coin_fees = hasParentCoinFees(trade_info) - var info = qsTr('%1 Transaction Fee'.arg(trade_info.base_transaction_fees_ticker))+': '+ trade_info.base_transaction_fees + " (%1)".arg(getFiatText(trade_info.base_transaction_fees, trade_info.base_transaction_fees_ticker, has_info_icon)) - if (has_parent_coin_fees) { info = info+"
"+qsTr('%1 Transaction Fee'.arg(trade_info.rel_transaction_fees_ticker))+': '+ trade_info.rel_transaction_fees + " (%1)".arg(getFiatText(trade_info.rel_transaction_fees, trade_info.rel_transaction_fees_ticker, has_info_icon)) } diff --git a/atomic_defi_design/Dex/Constants/Style.qml b/atomic_defi_design/Dex/Constants/Style.qml index b94d057492..57337b2561 100644 --- a/atomic_defi_design/Dex/Constants/Style.qml +++ b/atomic_defi_design/Dex/Constants/Style.qml @@ -167,9 +167,9 @@ QtObject { readonly property string colorText2: dark_theme ? "#79808C" : "#3C5368" readonly property string colorTextDisabled: dark_theme ? Style.colorWhite8 : "#B5B9C1" - readonly property string colorPlaceholderText: Style.colorWhite9 - readonly property string colorSelectedText: Style.colorTheme9 - readonly property string colorSelection: Style.colorGreen2 + readonly property string colorPlaceholderText: dark_theme ? Style.colorWhite9 : Style.colorWhite9 + readonly property string colorSelectedText: dark_theme ? Style.colorTheme9 : Style.colorTheme9 + readonly property string colorSelection: dark_theme ? Style.colorGreen2 : Style.colorGreen2 readonly property string colorTrendingLine: dark_theme ? Style.colorGreen : "#37a6ef" diff --git a/atomic_defi_design/Dex/Dashboard/FatalErrorModal.qml b/atomic_defi_design/Dex/Dashboard/FatalErrorModal.qml index 2213fb772f..58eaa863e0 100644 --- a/atomic_defi_design/Dex/Dashboard/FatalErrorModal.qml +++ b/atomic_defi_design/Dex/Dashboard/FatalErrorModal.qml @@ -26,7 +26,7 @@ MultipageModal { MultipageModalContent { titleText: qsTr("Fatal Error") - DefaultText { + DexLabel { text: message === "connection dropped" ? qsTr("Connection has been lost. You have been disconnected.") : message } diff --git a/atomic_defi_design/Dex/Dashboard/NotificationsModal.qml b/atomic_defi_design/Dex/Dashboard/NotificationsModal.qml index 2d2cb5e9c9..4231bbf74f 100644 --- a/atomic_defi_design/Dex/Dashboard/NotificationsModal.qml +++ b/atomic_defi_design/Dex/Dashboard/NotificationsModal.qml @@ -402,7 +402,7 @@ DexPopup anchors.topMargin: 20 spacing: 24 - DefaultText + DexLabel { Layout.fillWidth: true font @@ -428,7 +428,7 @@ DexPopup } - DefaultText + DexLabel { anchors.centerIn: parent visible: !list.visible @@ -517,7 +517,7 @@ DexPopup bottomPadding: 5 spacing: 5 - DefaultText + DexLabel { text: getNotificationTitle(modelData) font: DexTypo.subtitle1 @@ -525,7 +525,7 @@ DexPopup wrapMode: Label.Wrap } - DefaultText + DexLabel { text: getNotificationMsg(modelData) font: DexTypo.subtitle2 @@ -533,7 +533,7 @@ DexPopup wrapMode: Label.Wrap } - DefaultText + DexLabel { text: modelData.human_date font: DexTypo.caption diff --git a/atomic_defi_design/Dex/Exchange/ProView/Chart.qml b/atomic_defi_design/Dex/Exchange/ProView/Chart.qml index 80766a3d06..08b260918b 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/Chart.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/Chart.qml @@ -37,12 +37,14 @@ Item { pair_supported = false selected_testcoin = left_ticker + console.log("no chart, testcoin", selected_testcoin) return } if (General.is_testcoin(right_ticker)) { pair_supported = false selected_testcoin = right_ticker + console.log("no chart, testcoin", selected_testcoin) return } @@ -52,9 +54,13 @@ Item { pair_supported = true symbol = rel_ticker+"-"+base_ticker + console.log("symbol", symbol) + console.log("loaded_symbol", loaded_symbol) + if (symbol === loaded_symbol && !force) { webEngineViewPlaceHolder.visible = true + console.log("symbol === loaded_symbol, ok") return } chart_html = ` @@ -64,13 +70,14 @@ Item transform: scale(${Math.min(scale_x, scale_y)}); transform-origin: top left; } + a { pointer-events: none; }
` } } - // console.log(chart_html) + console.log(chart_html) if (chart_html == "") { @@ -84,6 +91,7 @@ Item if (!symbol) { pair_supported = false + console.log("pair not supported", pair, pair_reversed) return } @@ -162,13 +170,13 @@ Item scale: 0.5 } - DefaultText + DexLabel { visible: pair_supported - text_value: qsTr("Loading market data") + "..." + text_value: qsTr("Loading pair chart data") + "..." } - DefaultText + DexLabel { visible: !pair_supported && selected_testcoin == "" text_value: qsTr("There is no chart data for this pair") @@ -176,7 +184,7 @@ Item Layout.alignment: Qt.AlignCenter } - DefaultText + DexLabel { visible: !pair_supported && selected_testcoin != "" text_value: qsTr("There is no chart data for %1 (testcoin) pairs").arg(selected_testcoin) @@ -190,7 +198,7 @@ Item id: webEngineViewPlaceHolder anchors.fill: parent anchors.centerIn: parent - visible: false + visible: true Component.onCompleted: { @@ -219,6 +227,16 @@ Item } } + MouseArea { + id: chart_mousearea + anchors.fill: webEngineViewPlaceHolder + onClicked: { + if (webEngineView.visible) { + Qt.openUrlExternally("https://www.livecoinwatch.com") + } + } + } + Connections { target: app diff --git a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml index 7c3404f433..0e83f5af8d 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml @@ -78,7 +78,7 @@ RowLayout Layout.preferredWidth: parent.width - 15 text_value: !details ? "" : - `${details.ticker}   ${details.name}` + `${details.ticker}
${details.name}` font.pixelSize: Style.textSizeSmall3 elide: Text.ElideRight wrapMode: Text.NoWrap @@ -87,16 +87,16 @@ RowLayout Dex.Text { id: middle_line - property string coin_value: !details ? "" : details.balance - text: coin_value + text_value: coin_value + privacy: true Layout.fillWidth: true elide: Text.ElideRight color: Dex.CurrentTheme.foregroundColor font: DexTypo.body2 wrapMode: Label.NoWrap ToolTip.text: coin_value - Component.onCompleted: font.pixelSize = 11.5 + Component.onCompleted: font.pixelSize = 11 } Dex.Text @@ -105,14 +105,15 @@ RowLayout property string fiat_value: !details ? "" : General.formatFiat("", details.main_currency_balance, API.app.settings_pg.current_currency) - text: fiat_value + text_value: fiat_value Layout.fillWidth: true elide: Text.ElideRight color: Dex.CurrentTheme.foregroundColor font: DexTypo.body2 wrapMode: Label.NoWrap ToolTip.text: fiat_value - Component.onCompleted: font.pixelSize = 11.5 + privacy: true + Component.onCompleted: font.pixelSize = 11 } } } diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml index ca94aec96e..f89056a9eb 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/Main.qml @@ -11,20 +11,29 @@ import Dex.Components 1.0 as Dex import AtomicDEX.MarketMode 1.0 import AtomicDEX.TradingError 1.0 -Widget +ColumnLayout { - title: qsTr("Place Order") + Layout.preferredWidth: 305 + Layout.fillHeight: true + property alias currentIndex: orderformTabView.currentIndex property int loop_count: 0 property bool show_waiting_for_trade_preimage: false; property var fees: API.app.trading_pg.fees property var preimage_rpc_busy: API.app.trading_pg.preimage_rpc_busy - property string protocolIcon: General.platformIcon(General.coinPlatform(left_ticker)) property var trade_preimage_error: fees.hasOwnProperty('error') ? fees["error"].split("] ").slice(-1) : "" readonly property bool trade_preimage_ready: fees.hasOwnProperty('base_transaction_fees_ticker') - readonly property bool can_submit_trade: last_trading_error === TradingError.None + property int takerOrderform_idx: 0 + property int makerOrderform_idx: 1 - margins: 10 - collapsable: false + function reset_fees_state() + { + show_waiting_for_trade_preimage = false; + check_trade_preimage.stop() + loop_count = 0 + API.app.trading_pg.reset_fees() + takerForm.dexErrors.text_value = "" + makerForm.dexErrors.text_value = "" + } Connections { target: API.app.trading_pg @@ -59,257 +68,135 @@ Widget } } - function reset_fees_state() + Timer { - show_waiting_for_trade_preimage = false; - check_trade_preimage.stop() - loop_count = 0 - API.app.trading_pg.reset_fees() - errors.text_value = "" + id: check_trade_preimage + interval: 500; + running: false; + repeat: true; + triggeredOnStart: true; + onTriggered: { + loop_count++; + console.log("Getting fees info... " + loop_count + "/50") + if (trade_preimage_ready) + { + show_waiting_for_trade_preimage = false + loop_count = 0 + stop() + confirm_trade_modal.open() + } + else if (trade_preimage_error != "") + { + loop_count = 0 + takerForm.dexErrors.text_value = trade_preimage_error.toString() + makerForm.dexErrors.text_value = trade_preimage_error.toString() + show_waiting_for_trade_preimage = false + stop() + } + else if (loop_count > 50) + { + loop_count = 0 + show_waiting_for_trade_preimage = false + trade_preimage_error = "Trade preimage timed out, try again." + stop() + } + } } - // Market mode selector - RowLayout + Qaterial.LatoTabBar { - Layout.topMargin: 5 - Layout.bottomMargin: 2 - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - height: 32 + id: orderformTabView - MarketModeSelector + background: null + Layout.leftMargin: 6 + + Qaterial.LatoTabButton { - Layout.alignment: Qt.AlignLeft - Layout.preferredWidth: (parent.width / 100) * 46 - Layout.preferredHeight: 32 - marketMode: MarketMode.Buy - ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + text: qsTr("Taker Order") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor } - - Item { Layout.fillWidth: true } - - MarketModeSelector + Qaterial.LatoTabButton { - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: (parent.width / 100) * 46 - Layout.preferredHeight: 32 - ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + text: qsTr("Maker Order") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor } } - // Protocol text for platform tokens - Item + Rectangle { - height: 32 - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - visible: protocolIcon != "" + Layout.fillHeight: true + color: Dex.CurrentTheme.floatingBackgroundColor + radius: 10 + Layout.preferredWidth: 305 - ColumnLayout + Qaterial.SwipeView { - spacing: 2 + id: orderformSwipeView + clip: true + interactive: false + currentIndex: orderformTabView.currentIndex anchors.fill: parent - anchors.centerIn: parent - Dex.Text + onCurrentIndexChanged: { - id: protocolTitle - Layout.preferredWidth: parent.width - text_value: "Protocol:" - font.pixelSize: Style.textSizeSmall1 - horizontalAlignment: Text.AlignHCenter - color: Style.colorText2 + API.app.trading_pg.maker_mode = currentIndex === makerOrderform_idx ? true : false + orderformSwipeView.currentItem.update() + API.app.trading_pg.reset_order() + reset_fees_state() } - RowLayout + Item { - id: protocol - Layout.alignment: Qt.AlignHCenter - - DefaultImage - { - id: protocolImg - source: protocolIcon - Layout.preferredHeight: 16 - Layout.preferredWidth: Layout.preferredHeight - } + id: takerOrderform - DexLabel + OrderForm { - id: protocolText - text_value: General.getProtocolText(left_ticker) - wrapMode: DexLabel.NoWrap - font.pixelSize: Style.textSizeSmall1 - color: Style.colorText2 + id: takerForm + width: parent.width + height: 330 + Layout.alignment: Qt.AlignHCenter + swap_btn.enabled: last_trading_error === TradingError.None && !show_waiting_for_trade_preimage && takerForm.dexErrors.text_value == "" + swap_btn.onClicked: + { + console.log("Getting fees info...") + API.app.trading_pg.determine_fees() + show_waiting_for_trade_preimage = true + check_trade_preimage.start() + } + swap_btn_spinner.visible: show_waiting_for_trade_preimage } } - } - } - - // Order selected indicator - Item - { - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: parent.width - height: 32 - - RowLayout - { - id: orderSelection - visible: API.app.trading_pg.preferred_order.price !== undefined - anchors.fill: parent - anchors.verticalCenter: parent.verticalCenter - DefaultText + Item { - Layout.leftMargin: 15 - color: Dex.CurrentTheme.warningColor - text: qsTr("Order Selected") - } - - Item { Layout.fillWidth: true } + id: makerOrderform - Qaterial.FlatButton - { - Layout.preferredHeight: parent.height - Layout.preferredWidth: 30 - Layout.rightMargin: 5 - foregroundColor: Dex.CurrentTheme.warningColor - onClicked: { - API.app.trading_pg.reset_order() - reset_fees_state() - } - - Qaterial.ColorIcon + OrderForm { - anchors.centerIn: parent - iconSize: 16 - color: Dex.CurrentTheme.warningColor - source: Qaterial.Icons.close + id: makerForm + width: parent.width + height: 330 + Layout.alignment: Qt.AlignHCenter + swap_btn.enabled: last_trading_error === TradingError.None && !show_waiting_for_trade_preimage && makerForm.dexErrors.text_value == "" + swap_btn.onClicked: + { + console.log("Getting fees info...") + console.log("API.app.trading_pg.market_mode") + console.log(API.app.trading_pg.market_mode) + // TODO: Apply reduced fees on maker orders + API.app.trading_pg.determine_fees() + show_waiting_for_trade_preimage = true; + check_trade_preimage.start() + } + swap_btn_spinner.visible: show_waiting_for_trade_preimage } } } - - Rectangle - { - visible: API.app.trading_pg.preferred_order.price !== undefined - anchors.fill: parent - radius: 8 - color: 'transparent' - border.color: Dex.CurrentTheme.warningColor - } - } - - OrderForm - { - id: formBase - width: parent.width - height: 330 - Layout.alignment: Qt.AlignHCenter - } - - Item { Layout.fillHeight: true } - - // Error messages - Item - { - height: 55 - Layout.preferredWidth: parent.width - - // Show errors - Dex.Text - { - id: errors - visible: errors.text_value !== "" - anchors.fill: parent - anchors.centerIn: parent - horizontalAlignment: Text.AlignHCenter - font.pixelSize: Style.textSizeSmall4 - color: Dex.CurrentTheme.warningColor - text_value: General.getTradingError( - last_trading_error, - curr_fee_info, - base_ticker, - rel_ticker, left_ticker, right_ticker) - elide: Text.ElideRight - } - } - - TotalView - { - height: 70 - Layout.preferredWidth: parent.width - Layout.alignment: Qt.AlignHCenter - } - - DexGradientAppButton - { - id: swap_btn - height: 32 - Layout.preferredWidth: parent.width - 30 - Layout.alignment: Qt.AlignHCenter - - radius: 16 - text: qsTr("START SWAP") - font.weight: Font.Medium - enabled: can_submit_trade && !show_waiting_for_trade_preimage && errors.text_value == "" - onClicked: - { - console.log("Getting fees info...") - API.app.trading_pg.determine_fees() - show_waiting_for_trade_preimage = true; - check_trade_preimage.start() - } - - Item - { - visible: show_waiting_for_trade_preimage - height: parent.height - 10 - width: parent.width - 10 - anchors.fill: parent - anchors.centerIn: parent - - DefaultBusyIndicator - { - id: preimage_BusyIndicator - anchors.fill: parent - anchors.centerIn: parent - indicatorSize: 32 - indicatorDotSize: 5 - } - } - } - - Timer { - id: check_trade_preimage - interval: 500; - running: false; - repeat: true; - triggeredOnStart: true; - onTriggered: { - loop_count++; - console.log("Getting fees info... " + loop_count + "/50") - if (trade_preimage_ready) - { - show_waiting_for_trade_preimage = false - loop_count = 0 - stop() - confirm_trade_modal.open() - } - else if (trade_preimage_error != "") - { - loop_count = 0 - errors.text_value = trade_preimage_error.toString() - show_waiting_for_trade_preimage = false - stop() - } - else if (loop_count > 50) - { - loop_count = 0 - show_waiting_for_trade_preimage = false - trade_preimage_error = "Trade preimage timed out, try again." - stop() - } - } } -} +} \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml index b4ffbdbf17..acafe43b2e 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/MarketModeSelector.qml @@ -1,4 +1,5 @@ import QtQuick 2.12 +import QtQuick.Layouts 1.15 import App 1.0 import Dex.Themes 1.0 as Dex @@ -9,9 +10,10 @@ Rectangle { property int marketMode: Dex.MarketMode.Sell property string ticker: "" + property string protocolIcon: General.platformIcon(General.coinPlatform(left_ticker)) radius: 18 - opacity: marketMode != API.app.trading_pg.market_mode ? 0.1 : 1 + opacity: marketMode != API.app.trading_pg.market_mode ? 0.25: 1 gradient: Gradient { @@ -32,15 +34,28 @@ Rectangle position: 1 } } - - DefaultText + RowLayout { anchors.centerIn: parent - color: API.app.trading_pg.market_mode == marketMode ? Dex.CurrentTheme.gradientButtonTextEnabledColor : Dex.CurrentTheme.foregroundColor - text: + spacing: 8 + + DexLabel + { + color: API.app.trading_pg.market_mode == marketMode ? Dex.CurrentTheme.gradientButtonTextEnabledColor : Dex.CurrentTheme.foregroundColor + text: + { + if (marketMode == Dex.MarketMode.Sell) qsTr("Sell %1", "TICKER").arg(ticker) + else qsTr("Buy %1", "TICKER").arg(ticker) + } + } + + DefaultImage { - if (marketMode == Dex.MarketMode.Sell) qsTr("Sell %1", "TICKER").arg(ticker) - else qsTr("Buy %1", "TICKER").arg(ticker) + id: protocolImg + visible: protocolIcon != "" + source: protocolIcon + Layout.preferredHeight: protocolIcon != "" ? 16 : 0 + Layout.preferredWidth: Layout.preferredHeight } } diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index 3e508ca18c..35f7749f5a 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -2,14 +2,21 @@ import QtQuick 2.15 import QtQuick.Layouts 1.15 import QtQuick.Controls 2.15 import QtGraphicalEffects 1.0 - +import Qaterial 1.0 as Qaterial import "../../../Components" +import "../../../Constants" import App 1.0 import Dex.Themes 1.0 as Dex +import Dex.Components 1.0 as Dex +import AtomicDEX.TradingError 1.0 +import AtomicDEX.MarketMode 1.0 as Dex ColumnLayout { id: root + anchors.horizontalCenter: parent.horizontalCenter + anchors.fill: parent + anchors.margins: 20 spacing: 8 function focusVolumeField() @@ -20,6 +27,9 @@ ColumnLayout readonly property string total_amount: API.app.trading_pg.total_amount readonly property int input_height: 65 readonly property int subfield_margin: 5 + property alias swap_btn: swap_btn + property alias swap_btn_spinner: swap_btn_spinner + property alias dexErrors: dexErrors // Will move to backend: Minimum Fee @@ -52,6 +62,37 @@ ColumnLayout function onBackend_volumeChanged() { input_volume.text = exchange_trade.backend_volume; } } + // Market mode selector + RowLayout + { + Layout.topMargin: 2 + Layout.bottomMargin: 2 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width + height: 28 + visible: !API.app.trading_pg.maker_mode + + MarketModeSelector + { + Layout.alignment: Qt.AlignLeft + Layout.preferredWidth: 125 + Layout.preferredHeight: 28 + marketMode: Dex.MarketMode.Buy + ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + } + + Item { Layout.fillWidth: true } + + MarketModeSelector + { + marketMode: Dex.MarketMode.Sell + Layout.alignment: Qt.AlignRight + Layout.preferredWidth: 125 + Layout.preferredHeight: 28 + ticker: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + } + } + Item { Layout.preferredWidth: parent.width @@ -62,7 +103,8 @@ ColumnLayout id: input_price left_text: qsTr("Price") - right_text: right_ticker + right_text: General.coinWithoutSuffix(right_ticker) + right_fontsize: 10 enabled: !(API.app.trading_pg.preferred_order.price !== undefined) color: enabled ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 text: backend_price ? backend_price : General.formatDouble(API.app.trading_pg.cex_price) @@ -126,13 +168,15 @@ ColumnLayout height: 36 radius: 18 left_text: sell_mode ? qsTr("Send") : qsTr("Receive") - right_text: left_ticker + right_text: General.coinWithoutSuffix(left_ticker) + right_fontsize: 10 placeholderText: "0" text: API.app.trading_pg.volume onTextChanged: { setVolume(text) reset_fees_state() } + enabled: !General.privacy_mode } OrderFormSubfield @@ -163,9 +207,9 @@ ColumnLayout left_label: "25%" middle_label: "50%" right_label: qsTr("Max") - left_tooltip_text: qsTr("Swap 25% of your tradable balance.") - middle_tooltip_text: qsTr("Swap 50% of your tradable balance.") - right_tooltip_text: qsTr("Swap 100% of your tradable balance.") + left_tooltip_text: General.privacy_mode ? qsTr("Diasble privacy mode to trade") : qsTr("Swap 25% of your tradable balance.") + middle_tooltip_text: General.privacy_mode ? qsTr("Diasble privacy mode to trade") : qsTr("Swap 50% of your tradable balance.") + right_tooltip_text: General.privacy_mode ? qsTr("Diasble privacy mode to trade") : qsTr("Swap 100% of your tradable balance.") } } @@ -225,7 +269,7 @@ ColumnLayout Layout.preferredHeight: 24 visible: !_useCustomMinTradeAmountCheckbox.checked - DefaultText + DexLabel { id: minVolLabel anchors.horizontalCenter: parent.horizontalCenter @@ -251,7 +295,7 @@ ColumnLayout onToggled: setMinimumAmount(0) } - DefaultText + DexLabel { Layout.fillWidth: true height: _useCustomMinTradeAmountCheckbox.height @@ -263,4 +307,122 @@ ColumnLayout font.pixelSize: 13 } } + + + Item { Layout.fillHeight: true } + + // Error messages + // TODO: Move to toasts + Item + { + height: 55 + Layout.preferredWidth: parent.width + + // Show errors + Dex.Text + { + id: dexErrors + visible: dexErrors.text_value !== "" + anchors.fill: parent + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Style.textSizeSmall4 + color: Dex.CurrentTheme.warningColor + text_value: General.getTradingError( + last_trading_error, + curr_fee_info, + base_ticker, + rel_ticker, left_ticker, right_ticker) + elide: Text.ElideRight + } + } + + Item { Layout.fillHeight: true } + + // Order selected indicator + Item + { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width - 16 + height: 28 + + RowLayout + { + id: orderSelection + visible: API.app.trading_pg.preferred_order.price !== undefined + anchors.fill: parent + anchors.verticalCenter: parent.verticalCenter + + DexLabel + { + Layout.leftMargin: 15 + color: Dex.CurrentTheme.warningColor + text: qsTr("Order Selected") + } + + Item { Layout.fillWidth: true } + + Qaterial.FlatButton + { + Layout.preferredHeight: parent.height + Layout.preferredWidth: 30 + Layout.rightMargin: 5 + foregroundColor: Dex.CurrentTheme.warningColor + onClicked: { + API.app.trading_pg.reset_order() + reset_fees_state() + } + + Qaterial.ColorIcon + { + anchors.centerIn: parent + iconSize: 16 + color: Dex.CurrentTheme.warningColor + source: Qaterial.Icons.close + } + } + } + + Rectangle + { + visible: API.app.trading_pg.preferred_order.price !== undefined + anchors.fill: parent + radius: 8 + color: 'transparent' + border.color: Dex.CurrentTheme.warningColor + } + } + + + TotalView + { + height: 70 + Layout.preferredWidth: parent.width + Layout.alignment: Qt.AlignHCenter + } + + DefaultBusyIndicator + { + id: swap_btn_spinner + Layout.alignment: Qt.AlignHCenter + indicatorSize: 28 + indicatorDotSize: 4 + } + Item + { + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: parent.width - 16 + height: 28 + + DexGradientAppButton + { + id: swap_btn + height: 32 + anchors.fill: parent + radius: 16 + text: API.app.trading_pg.maker_mode ? qsTr("CREATE MAKER SWAP") : qsTr("START TAKER SWAP") + font.weight: Font.Medium + enabled: !General.privacy_mode + } + } } \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderFormSubfield.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderFormSubfield.qml index c39c0619c4..b896b048f5 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderFormSubfield.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderFormSubfield.qml @@ -41,7 +41,7 @@ RowLayout color: Dex.CurrentTheme.inputModifierBackgroundColor } - DefaultText + DexLabel { id: _left_label anchors.centerIn: parent @@ -61,7 +61,7 @@ RowLayout anchors.topMargin: 30 color: Dex.CurrentTheme.accentColor - DefaultText + DexLabel { text: left_tooltip_text font: Dex.DexTypo.caption @@ -107,7 +107,7 @@ RowLayout hoverEnabled: true } - DefaultText + DexLabel { id: _middle_label anchors.centerIn: parent @@ -127,7 +127,7 @@ RowLayout anchors.topMargin: 30 color: Dex.CurrentTheme.accentColor - DefaultText + DexLabel { text: middle_tooltip_text font: Dex.DexTypo.caption @@ -162,7 +162,7 @@ RowLayout color: Dex.CurrentTheme.inputModifierBackgroundColor } - DefaultText + DexLabel { id: _right_label anchors.centerIn: parent @@ -183,7 +183,7 @@ RowLayout anchors.topMargin: 30 color: Dex.CurrentTheme.accentColor - DefaultText + DexLabel { text: right_tooltip_text font: Dex.DexTypo.caption @@ -211,7 +211,7 @@ RowLayout Item { Layout.fillWidth: true } - DefaultText + DexLabel { id: _fiat_label font.pixelSize: pixel_size diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/TotalView.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/TotalView.qml index 83d6e8a380..9e0b50f873 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/TotalView.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/TotalView.qml @@ -19,7 +19,7 @@ ColumnLayout Layout.preferredWidth: parent.width Layout.preferredHeight: 30 - DefaultText + DexLabel { Layout.fillWidth: true Layout.alignment: Qt.AlignLeft @@ -31,7 +31,7 @@ ColumnLayout DefaultInfoTrigger { triggerModal: cex_info_modal } } - DefaultText + DexLabel { Layout.fillWidth: true horizontalAlignment: Text.AlignRight @@ -55,7 +55,7 @@ ColumnLayout Layout.preferredWidth: parent.width Layout.preferredHeight: 30 - DefaultText + DexLabel { Layout.fillWidth: true color: Dex.CurrentTheme.foregroundColor3 @@ -66,7 +66,7 @@ ColumnLayout font.weight: Font.Normal } - DefaultText + DexLabel { Layout.fillWidth: true horizontalAlignment: Text.AlignRight diff --git a/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml b/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml index 6bda8f68fe..68b621ef0d 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/SearchableTickerSelector.qml @@ -18,13 +18,13 @@ Dex.ComboBoxWithSearchBar property string ticker property bool index_changed: false - height: 70 + height: 85 enabled: !block_everything textRole: "ticker" valueRole: "ticker" - popupMaxHeight: Math.min(model.rowCount() * 70 + 70, 600) + popupMaxHeight: Math.min(model.rowCount() * 85 + 85, 600) popupForceMaxHeight: true searchBar.visible: true @@ -34,7 +34,7 @@ Dex.ComboBoxWithSearchBar { id: _delegate width: control.width - height: visible ? 70 : 0 + height: visible ? 85 : 0 highlighted: control.highlightedIndex === index contentItem: DexComboBoxLine { details: model } @@ -52,7 +52,7 @@ Dex.ComboBoxWithSearchBar property int update_count: 0 property var prev_details - padding: 10 + padding: 8 function forceUpdateDetails() { diff --git a/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml b/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml index 6c52fed103..8b317cecba 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TickerSelectors.qml @@ -6,9 +6,12 @@ import "../../Components" import "../../Constants" // Ticker selectors. -Row +RowLayout { id: selectors + Layout.topMargin: 8 + Layout.bottomMargin: 2 + Layout.alignment: Qt.AlignHCenter function renewIndex() { @@ -21,9 +24,8 @@ Row SearchableTickerSelector { id: selectorLeft - - width: 210 - height: parent.height + Layout.preferredWidth: 195 + Layout.preferredHeight: 85 left_side: true model: API.app.trading_pg.market_pairs_mdl.left_selection_box @@ -38,10 +40,12 @@ Row } } + Item { Layout.fillWidth: true } + SwapIcon { - width: 25 - anchors.verticalCenter: parent.verticalCenter + Layout.preferredHeight: 25 + Layout.alignment: Qt.AlignVCenter top_arrow_ticker: selectorLeft.ticker bottom_arrow_ticker: selectorRight.ticker hovered: swap_button.containsMouse @@ -59,13 +63,13 @@ Row } } + Item { Layout.fillWidth: true } + SearchableTickerSelector { id: selectorRight - - width: 210 - height: parent.height - + Layout.preferredWidth: 195 + Layout.preferredHeight: 85 left_side: false model: API.app.trading_pg.market_pairs_mdl.right_selection_box ticker: right_ticker diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml index 0c520adfcf..3246d7b555 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml @@ -5,27 +5,19 @@ import QtQuick.Controls 2.15 import Qaterial 1.0 as Qaterial import Dex.Themes 1.0 as Dex +import Dex.Components 1.0 as Dex +import AtomicDEX.MarketMode 1.0 import "../../../Constants" import "../../../Components" import "../../Trade" import "../../ProView" -Widget +ColumnLayout { - width: 450 + Layout.preferredWidth: 450 + Layout.fillHeight: true property alias currentIndex: tabView.currentIndex - title: qsTr("Trading Information") - - background: null - margins: 0 - - Connections - { - target: exchange_trade - function onOrderSelected() { tabView.currentIndex = 0; } - } - Qaterial.LatoTabBar { id: tabView @@ -81,7 +73,19 @@ Widget { Layout.fillHeight: true Layout.fillWidth: true - spacing: 10 + Layout.topMargin: 8 + spacing: 8 + + // Ticker selectors. + TickerSelectors + { + id: selectors + Layout.preferredWidth: 435 + Layout.preferredHeight: 85 + Layout.leftMargin: 8 + Layout.rightMargin: 8 + } + // Chart Chart { @@ -102,6 +106,7 @@ Widget Layout.rightMargin: 5 Layout.fillWidth: true Layout.fillHeight: true + width: 435 } } diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml index 87d5456f62..91eb121226 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml @@ -49,7 +49,7 @@ FloatingBackground Layout.preferredWidth: 24 Layout.alignment: Qt.AlignCenter - DefaultText + DexLabel { id: statusText anchors.centerIn: parent @@ -86,34 +86,34 @@ FloatingBackground clip: true - DefaultText + DexLabel { id: baseAmountLabel anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: + text_value: { - if (!details) return + if (!details) return BigNumber.config({ DECIMAL_PLACES: 6 }) return new BigNumber(details.base_amount).toString(10) } - privacy: is_placed_order + privacy: true elide: Text.ElideRight maximumLineCount: 1 } - DefaultText + DexLabel { anchors.left: baseAmountLabel.right anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: !details ? "" : "(%1 %2)".arg(details.base_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) - privacy: is_placed_order + text_value: !details ? "" : "(%1 %2)".arg(details.base_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) + privacy: true elide: Text.ElideRight maximumLineCount: 1 } @@ -128,14 +128,14 @@ FloatingBackground iconSize: 18 } - DefaultText + DexLabel { anchors.right: relAmountInCurrCurrency.left anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: + text_value: { if (!details) return @@ -143,12 +143,12 @@ FloatingBackground return new BigNumber(details.rel_amount).toString(10) } - privacy: is_placed_order + privacy: true elide: Text.ElideRight maximumLineCount: 1 } - DefaultText + DexLabel { id: relAmountInCurrCurrency @@ -156,8 +156,8 @@ FloatingBackground anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: !details ? "" : "(%1 %2)".arg(details.rel_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) - privacy: is_placed_order + text_value: !details ? "" : "(%1 %2)".arg(details.rel_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) + privacy: true elide: Text.ElideRight maximumLineCount: 1 } @@ -181,7 +181,7 @@ FloatingBackground source: General.coinIcon(!details ? atomic_app_primary_coin : details.base_coin ?? atomic_app_primary_coin) } - DefaultText + DexLabel { anchors.left: baseIcon.right anchors.leftMargin: 2 @@ -189,13 +189,13 @@ FloatingBackground font.weight: Font.Bold font.pixelSize: 12 - text: !details ? "" : details.base_coin - privacy: is_placed_order + text_value: !details ? "" : details.base_coin + privacy: true elide: Text.ElideRight maximumLineCount: 1 } - DefaultText + DexLabel { visible: clickable @@ -209,7 +209,7 @@ FloatingBackground color: Dex.CurrentTheme.foregroundColor2 } - DefaultText + DexLabel { anchors.right: relCoin.left anchors.rightMargin: 2 @@ -217,8 +217,8 @@ FloatingBackground font.weight: Font.Bold font.pixelSize: 12 - text: !details ? "" : details.rel_coin - privacy: is_placed_order + text_value: !details ? "" : details.rel_coin + privacy: true elide: Text.ElideRight maximumLineCount: 1 } @@ -244,7 +244,7 @@ FloatingBackground Layout.preferredWidth: 24 Layout.alignment: Qt.AlignCenter - DefaultText + DexLabel { anchors.centerIn: parent @@ -255,7 +255,7 @@ FloatingBackground DefaultTooltip { - contentItem: DefaultText + contentItem: DexLabel { text_value: qsTr("Funds are recoverable") font.pixelSize: Style.textSizeSmall4 diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderList.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderList.qml index 7aff067cf9..c8fb4183f0 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderList.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderList.qml @@ -102,7 +102,7 @@ Item } } - DefaultText + DexLabel { visible: list.count === 0 anchors.centerIn: parent diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml index 2c0f7854c1..6ba51b0da1 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml @@ -66,6 +66,7 @@ MultipageModal PairItemBadge { + is_left: true ticker: details ? details.base_coin : "" fullname: details ? General.coinName(details.base_coin) : "" amount: details ? details.base_amount : "" @@ -94,7 +95,7 @@ MultipageModal }, - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter visible: text_value != "" @@ -119,6 +120,26 @@ MultipageModal label.font.pixelSize: 13 } + // Min Vol + TextEditWithTitle + { + Layout.fillWidth: true + title: qsTr("Min Volume") + text: details ? details.min_volume + " " + details.base_coin : "" + label.font.pixelSize: 13 + visible: General.exists(details) && details.min_volume != "" + } + + // Max Vol + TextEditWithTitle + { + Layout.fillWidth: true + title: qsTr("Max Volume") + text: details ? details.max_volume + " " + details.base_coin : "" + label.font.pixelSize: 13 + visible: General.exists(details) && details.max_volume != "" + } + // Refund state TextEditWithTitle { diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml index 3629b41dae..673d97ec4f 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml @@ -112,7 +112,7 @@ Item { onClicked: list_model_proxy.apply_all_filtering() } - DefaultText + DexLabel { color: Dex.CurrentTheme.foregroundColor2 font: DexTypo.caption @@ -132,6 +132,7 @@ Item { radius: 7 label.font: DexTypo.body2 text: qsTr("Export CSV") + enabled: list_model.length > 0 && ! General.privacy_mode onClicked: { export_csv_dialog.folder = General.os_file_prefix + API.app.settings_pg.get_export_folder() @@ -142,10 +143,10 @@ Item { DefaultButton { visible: !root.is_history && list_model.length > 0 - enabled: list_model.length > 0 Layout.preferredHeight: 29 radius: 7 label.font: DexTypo.body2 + enabled: list_model.length > 0 && ! General.privacy_mode text: qsTr("Cancel All") iconSource: Qaterial.Icons.close onClicked: API.app.trading_pg.orders.cancel_order(list_model_proxy.get_filtered_ids()) diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml index cab141ecff..daae2d4c8b 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/PriceLine.qml @@ -22,7 +22,7 @@ ColumnLayout spacing: 10 - DefaultText + DexLabel { visible: !price_entered && invalid_cex_price text_value: qsTr("Set swap price for evaluation") @@ -35,7 +35,7 @@ ColumnLayout visible: price_entered Layout.alignment: Qt.AlignCenter - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: qsTr("Exchange rate") + (preferred_order.price !== undefined ? (" (" + qsTr("Selected") + ")") : "") @@ -43,7 +43,7 @@ ColumnLayout } // Price reversed - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: General.formatCrypto("", "1", right_ticker) + " = " + General.formatCrypto("", price_reversed, left_ticker) @@ -52,7 +52,7 @@ ColumnLayout } // Price - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: General.formatCrypto("", price, right_ticker) + " = " + General.formatCrypto("", "1", left_ticker) @@ -66,21 +66,10 @@ ColumnLayout visible: price_entered && !invalid_cex_price Layout.alignment: Qt.AlignCenter - DefaultText - { - id: price_diff_text - Layout.topMargin: 10 - Layout.bottomMargin: Layout.topMargin - Layout.alignment: Qt.AlignHCenter - color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor - text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") - font.pixelSize: fontSize - } - RowLayout { Layout.alignment: Qt.AlignHCenter - DefaultText + DexLabel { text_value: General.formatPercent(lineScale) font.pixelSize: fontSize @@ -103,7 +92,16 @@ ColumnLayout } } - DefaultText + DexLabel + { + id: price_diff_text + anchors.horizontalCenter: parent.horizontalCenter + color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor + text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") + font.pixelSize: fontSizeBigger + } + + DexLabel { text_value: General.formatPercent(-lineScale) font.pixelSize: fontSize @@ -117,7 +115,7 @@ ColumnLayout visible: !invalid_cex_price Layout.alignment: Qt.AlignCenter - DefaultText { + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: General.cex_icon + " " + qsTr("CEXchange rate") font.pixelSize: fontSize @@ -125,7 +123,7 @@ ColumnLayout } // Price reversed - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: General.formatCrypto("", "1", right_ticker) + " = " + General.formatCrypto("", cex_price_reversed, left_ticker) @@ -134,7 +132,7 @@ ColumnLayout } // Price - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: General.formatCrypto("", cex_price, right_ticker) + " = " + General.formatCrypto("", "1", left_ticker) diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/SwapProgress.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/SwapProgress.qml index 3f0963b269..ae11dea1a0 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/SwapProgress.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/SwapProgress.qml @@ -198,7 +198,7 @@ ColumnLayout } // Title - DefaultText + DexLabel { Layout.fillWidth: true text_value: `` + qsTr("Progress details") + `` + @@ -234,7 +234,7 @@ ColumnLayout width: root.width height: 50 - DefaultText { + DexLabel { id: icon text_value: is_active ? "●" : "○" @@ -272,7 +272,7 @@ ColumnLayout anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right - DefaultText + DexLabel { id: name @@ -299,7 +299,7 @@ ColumnLayout } } - DefaultText + DexLabel { visible: bar.visible font.pixelSize: Style.textSizeSmall2 diff --git a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml index 85a7be4ebe..75b9f5b7c1 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/List.qml @@ -14,9 +14,11 @@ import Dex.Components 1.0 as Dex Widget { id: _control - title: qsTr("Best Orders") + title: qsTr("Best Orders for %1").arg(left_ticker) + margins: 10 spacing: 10 + collapsable: false Header { @@ -30,7 +32,7 @@ Widget Layout.preferredWidth: parent.width Layout.preferredHeight: parent.height - DefaultText + DexLabel { text_value: qsTr("Enter volume to see best orders.") anchors.fill: parent diff --git a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml index e5893f2e31..c0e76bf996 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/BestOrder/ListDelegate.qml @@ -14,8 +14,7 @@ import AtomicDEX.MarketMode 1.0 Item { id: _control - - property bool coinEnable: API.app.portfolio_pg.global_cfg_mdl.get_coin_info(coin).is_enabled + property bool _isCoinEnabled: API.app.portfolio_pg.global_cfg_mdl.get_coin_info(coin).is_enabled property bool isAsk AnimatedRectangle @@ -46,7 +45,7 @@ Item height: 24 anchors.verticalCenter: parent.verticalCenter source: General.coinIcon(coin) - opacity: !_control.coinEnable? .1 : 1 + opacity: !_control._isCoinEnabled? .1 : 1 } Dex.Text @@ -125,7 +124,7 @@ Item text_value: !General.isZhtlc(coin) ? qsTr(" %1 is not enabled - Do you want to enable it to be able to select %2 best orders ?
Yes - No").arg(coin).arg(coin) : qsTr(" %1 is not enabled - Please enable it through the coin activation menu").arg(coin) - wrapMode: DefaultText.Wrap + wrapMode: DexLabel.Wrap width: 250 onLinkActivated: { @@ -137,7 +136,7 @@ Item { if (API.app.enable_coins([coin]) === true) { - _control.coinEnable = true; + _control._isCoinEnabled = true; _tooltip.close(); } else { @@ -170,15 +169,22 @@ Item else { placeOrderForm.visible = General.flipFalse(placeOrderForm.visible) - if (API.app.trading_pg.market_mode == MarketMode.Buy) + if (!API.app.trading_pg.maker_mode) { - app.pairChanged(coin, rel_ticker) + if (API.app.trading_pg.market_mode == MarketMode.Buy) + { + app.pairChanged(coin, rel_ticker) + } + else + { + app.pairChanged(base_ticker, coin) + } + API.app.trading_pg.orderbook.select_best_order(uuid) } else { - app.pairChanged(base_ticker, coin) + setPair(false, coin) } - API.app.trading_pg.orderbook.select_best_order(uuid) } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/ConfirmMultiOrderTradeModal.qml b/atomic_defi_design/Dex/Exchange/Trade/ConfirmMultiOrderTradeModal.qml index fece784f8e..4cb78f7717 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ConfirmMultiOrderTradeModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ConfirmMultiOrderTradeModal.qml @@ -70,27 +70,27 @@ MultipageModal { id: warning_texts anchors.centerIn: parent - DefaultText { + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: qsTr("These swaps requests can not be undone and this is the final event!") } - DefaultText { + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: qsTr("These transactions can take up to 60 mins - DO NOT close this application!") font.pixelSize: Style.textSizeSmall4 } - DefaultText { + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: qsTr("Same funds will be used until an order matches.") font.pixelSize: Style.textSizeSmall4 } - DefaultText { + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: qsTr("Note that if one order is filled other will not be cancelled.") diff --git a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml index 4054ef6606..7d431054f3 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ConfirmTradeModal.qml @@ -17,8 +17,9 @@ MultipageModal id: root readonly property var fees: API.app.trading_pg.fees width: 720 - horizontalPadding: 20 - verticalPadding: 20 + height: window.height - 80 + horizontalPadding: 10 + verticalPadding: 10 closePolicy: Popup.NoAutoClose MultipageModalContent @@ -28,7 +29,7 @@ MultipageModal titleAlignment: Qt.AlignHCenter titleTopMargin: 0 topMarginAfterTitle: 10 - flickMax: window.height - 480 + flickMax: window.height - 385 header: [ RowLayout @@ -43,6 +44,7 @@ MultipageModal PairItemBadge { ticker: base_ticker + is_left: true fullname: General.coinName(base_ticker) amount: base_amount Layout.fillHeight: true @@ -75,59 +77,6 @@ MultipageModal { id: price_line Layout.fillWidth: true - }, - - ColumnLayout - { - id: warnings_text - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - - // Large margin warning - FloatingBackground - { - Layout.alignment: Qt.AlignCenter - width: childrenRect.width - height: childrenRect.height - color: Style.colorRed2 - visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 - - RowLayout - { - Layout.fillWidth: true - - Item { width: 3 } - - DefaultCheckBox - { - id: allow_bad_trade - Layout.alignment: Qt.AlignCenter - textColor: Style.colorWhite0 - visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 - spacing: 2 - boxWidth: 16 - boxHeight: 16 - boxRadius: 8 - label.wrapMode: Label.NoWrap - text: qsTr("Trade price is more than 50% different to CEX! Confirm?") - font: DexTypo.caption - } - } - } - - DefaultText - { - Layout.alignment: Qt.AlignHCenter - text_value: qsTr("This swap request can not be undone and is a final event!") - } - - DefaultText - { - id: warnings_tx_time_text - Layout.alignment: Qt.AlignHCenter - text_value: qsTr("This transaction can take up to 60 mins - DO NOT close this application!") - font.pixelSize: Style.textSizeSmall4 - } } ] @@ -135,12 +84,12 @@ MultipageModal { id: config_section - readonly property var default_config: API.app.trading_pg.get_raw_mm2_coin_cfg(rel_ticker) + readonly property var default_config: API.app.trading_pg.get_raw_kdf_coin_cfg(rel_ticker) readonly property bool is_dpow_configurable: config_section.default_config.requires_notarization || false - width: dex_pair_badges.width - 20 + width: dex_pair_badges.width - 40 Layout.alignment: Qt.AlignCenter - Layout.topMargin: 8 + Layout.topMargin: 4 spacing: 5 @@ -167,7 +116,7 @@ MultipageModal scale: 0.8 } - DefaultText + DexLabel { text_value: qsTr("Loading fees...") Layout.bottomMargin: 8 @@ -181,7 +130,7 @@ MultipageModal anchors.centerIn: parent visible: root.fees.hasOwnProperty('error') // Should be handled before this modal, but leaving here as a fallback - DefaultText + DexLabel { width: parent.width text_value: root.fees.hasOwnProperty('error') ? root.fees["error"].split("] ").slice(-1) : "" @@ -200,7 +149,7 @@ MultipageModal Repeater { model: root.fees.hasOwnProperty('base_transaction_fees_ticker') && !API.app.trading_pg.preimage_rpc_busy ? General.getFeesDetail(root.fees) : [] - delegate: DefaultText + delegate: DexLabel { font.pixelSize: Style.textSizeSmall1 text: General.getFeesDetailText(modelData.label, modelData.fee, modelData.ticker) @@ -210,7 +159,7 @@ MultipageModal Repeater { model: root.fees.hasOwnProperty('base_transaction_fees_ticker') && !API.app.trading_pg.preimage_rpc_busy ? root.fees.total_fees : [] - delegate: DefaultText + delegate: DexLabel { text: General.getFeesDetailText( qsTr("Total %1 fees:").arg(modelData.coin), @@ -220,13 +169,13 @@ MultipageModal Layout.alignment: Qt.AlignHCenter } - DefaultText + DexLabel { id: errors visible: text_value != '' Layout.alignment: Qt.AlignHCenter width: parent.width - horizontalAlignment: DefaultText.AlignHCenter + horizontalAlignment: DexLabel.AlignHCenter font: DexTypo.caption color: Dex.CurrentTheme.warningColor text_value: General.getTradingError( @@ -239,7 +188,39 @@ MultipageModal } } - // Custom config checkbox + // Large margin warning + FloatingBackground + { + Layout.alignment: Qt.AlignCenter + width: childrenRect.width + height: childrenRect.height + color: Style.colorRed2 + visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 + + RowLayout + { + Layout.fillWidth: true + + Item { width: 3 } + + DefaultCheckBox + { + id: allow_bad_trade + Layout.alignment: Qt.AlignCenter + textColor: Style.colorWhite0 + visible: Math.abs(parseFloat(API.app.trading_pg.cex_price_diff)) >= 50 + spacing: 2 + boxWidth: 16 + boxHeight: 16 + boxRadius: 8 + label.wrapMode: Label.NoWrap + text: qsTr("Trade price is more than 50% different to CEX! Confirm?") + font: DexTypo.caption + } + } + } + + // Custom config section Item { Layout.alignment: Qt.AlignCenter @@ -251,9 +232,30 @@ MultipageModal { id: use_custom anchors.horizontalCenter: parent.horizontalCenter - spacing: 5 + DefaultCheckBox + { + id: _cancelPreviousCheckbox + visible: API.app.trading_pg.maker_mode + boxWidth: 20 + boxHeight: 20 + checked: true + height: 40 + text: qsTr("Cancel all existing orders for %1/%2?").arg(base_ticker).arg(rel_ticker) + } + + DefaultCheckBox + { + id: _goodUntilCanceledCheckbox + visible: !API.app.trading_pg.maker_mode + boxWidth: 20 + boxHeight: 20 + checked: true + height: 40 + text: qsTr("Good until cancelled (order will remain on orderbook until filled or cancelled)") + } + DefaultCheckBox { id: enable_custom_config @@ -261,13 +263,13 @@ MultipageModal spacing: 2 boxWidth: 20 boxHeight: 20 - height: 50 + height: 40 label.wrapMode: Label.NoWrap text: qsTr("Use custom protection settings for incoming %1 transactions", "TICKER").arg(rel_ticker) } - DefaultSwitch + DexSwitch { id: enable_dpow_confs visible: enable_custom_config.checked && config_section.is_dpow_configurable @@ -287,7 +289,7 @@ MultipageModal Layout.alignment: Qt.AlignCenter spacing: 5 - DefaultText + DexLabel { height: 16 Layout.alignment: Qt.AlignCenter @@ -296,7 +298,7 @@ MultipageModal font.weight: Font.Medium } - DefaultText + DexLabel { height: 12 font: DexTypo.caption @@ -336,7 +338,7 @@ MultipageModal Layout.alignment: Qt.AlignCenter spacing: 3 - DefaultText + DexLabel { height: 30 Layout.alignment: Qt.AlignCenter @@ -376,7 +378,7 @@ MultipageModal enable_custom_config.checked && (config_section.is_dpow_configurable && !enable_dpow_confs.checked) } - DefaultText + DexLabel { id: dpow_off_warning anchors.fill: parent @@ -390,6 +392,31 @@ MultipageModal } } + ColumnLayout + { + id: warnings_text + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + + + DexLabel + { + Layout.alignment: Qt.AlignHCenter + text_value: qsTr("This swap request can not be undone and is a final event!") + font: DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 + } + + DexLabel + { + id: warnings_tx_time_text + Layout.alignment: Qt.AlignHCenter + text_value: qsTr("This transaction can take up to 60 mins - DO NOT close this application!") + font: DexTypo.italic12 + color: Dex.CurrentTheme.foregroundColor2 + } + } + Item { visible: buy_sell_rpc_busy @@ -437,7 +464,9 @@ MultipageModal trade({ enable_custom_config: enable_custom_config.checked, is_dpow_configurable: config_section.is_dpow_configurable, enable_dpow_confs: enable_dpow_confs.checked, - required_confirmation_count: required_confirmation_count.value, }, + required_confirmation_count: required_confirmation_count.value, + cancel_previous: _cancelPreviousCheckbox.checked, + good_until_canceled: _goodUntilCanceledCheckbox.checked}, config_section.default_config) API.app.trading_pg.reset_fees() } diff --git a/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml b/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml index a5f65a9ba9..ec826c19dc 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml @@ -5,7 +5,7 @@ import QtQuick.Controls 2.15 import "../../Components" import "../../Constants" -DefaultText { +DexLabel { property var trade_info property string base @@ -24,12 +24,12 @@ DefaultText { visible: mouse_area.containsMouse contentItem: ColumnLayout { - DefaultText { + DexLabel { id: tx_fee_text text_value: General.txFeeText(trade_info, base, false) font.pixelSize: Style.textSizeSmall4 } - DefaultText { + DexLabel { text_value: General.tradingFeeText(trade_info, base, false) font.pixelSize: tx_fee_text.font.pixelSize } diff --git a/atomic_defi_design/Dex/Exchange/Trade/Market.qml b/atomic_defi_design/Dex/Exchange/Trade/Market.qml new file mode 100644 index 0000000000..3c6af075e6 --- /dev/null +++ b/atomic_defi_design/Dex/Exchange/Trade/Market.qml @@ -0,0 +1,85 @@ +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Controls 2.15 + +import Qaterial 1.0 as Qaterial + +import Dex.Themes 1.0 as Dex +import "../../Components" +import "../../Constants" + +// OrderBook / Component import +import "OrderBook/" as OrderBook + +// Best Order +import "BestOrder/" as BestOrder + + +ColumnLayout +{ + Layout.minimumWidth: 350 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignTop + property alias currentIndex: marketTabView.currentIndex + + Qaterial.LatoTabBar + { + id: marketTabView + property int orderbook: 0 + property int best_orders: 1 + + background: null + Layout.leftMargin: 6 + + Qaterial.LatoTabButton + { + text: qsTr("Orderbook") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor + } + Qaterial.LatoTabButton + { + text: qsTr("Best Orders") + font.pixelSize: 14 + textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 + textSecondaryColor: Dex.CurrentTheme.foregroundColor2 + indicatorColor: Dex.CurrentTheme.foregroundColor + } + } + + Rectangle + { + Layout.fillHeight: true + color: Dex.CurrentTheme.floatingBackgroundColor + radius: 10 + Layout.preferredWidth: 350 + + Qaterial.SwipeView + { + id: marketSwipeView + clip: true + interactive: false + currentIndex: marketTabView.currentIndex + anchors.fill: parent + + onCurrentIndexChanged: + { + marketSwipeView.currentItem.update(); + } + + OrderBook.Vertical + { + id: orderBook + } + + // Best Orders + BestOrder.List + { + id: bestOrders + } + } + } +} diff --git a/atomic_defi_design/Dex/Exchange/Trade/MultiOrder.qml b/atomic_defi_design/Dex/Exchange/Trade/MultiOrder.qml index cf07318749..7a9de1683f 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/MultiOrder.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/MultiOrder.qml @@ -125,7 +125,7 @@ InnerBackground { } // Error - DefaultText { + DexLabel { font.pixelSize: Style.textSizeSmall4 visible: model.multi_ticker_error > 0 anchors.verticalCenter: input_price.verticalCenter @@ -138,7 +138,7 @@ InnerBackground { visible: parent.visible && mouse_area.containsMouse contentItem: ColumnLayout { - DefaultText { + DexLabel { text_value: General.getTradingError(model.multi_ticker_error, model.multi_ticker_fees_info, base_ticker, model.ticker) font.pixelSize: Style.textSizeSmall2 } @@ -164,7 +164,7 @@ InnerBackground { field.enabled: !is_parent_coin } - DefaultSwitch { + DexSwitch { id: enable_ticker anchors.rightMargin: 10 anchors.right: parent.right diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml index 23e54d6606..8807c1a69c 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/List.qml @@ -12,7 +12,6 @@ Item id: _control property bool isAsk - property bool isVertical: false width: parent.width height: parent.height @@ -25,10 +24,15 @@ Item clip: true reuseItems: true spacing: 8 + opacity: API.app.trading_pg.maker_mode ? 0.6 : 1 onContentHeightChanged: { - if (isVertical) _tm.start(); + if (isAsk){ + // Duplication is intended. Sometimes data takes too long to load so slowscroll is a backup. + slowscroll_timer.start(); + quickscroll_timer.start() + } } delegate: Item @@ -46,12 +50,50 @@ Item Timer { - id: _tm - interval: 2000 + id: slowscroll_timer + interval: 1500 onTriggered: { orderbook_list.positionViewAtEnd() } } + Timer + { + id: quickscroll_timer + interval: 500 + onTriggered: + { + orderbook_list.positionViewAtEnd() + } + } + onModelChanged: { + if (isAsk) quickscroll_timer.start() + } + } + + Connections { + target: API.app.trading_pg; + + function onMarketModeChanged() + { + if (isAsk) + { + quickscroll_timer.start() + } + } + function onOrderbookChanged() + { + if (isAsk) + { + quickscroll_timer.start() + } + } + function onMarketPairsChanged() + { + if (isAsk) + { + quickscroll_timer.start() + } + } } } \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index 5ce557fc6b..43b16d0c7b 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml @@ -21,11 +21,11 @@ Item DefaultTooltip { visible: mouse_area.containsMouse && (tooltip_text.text_value != "") - width: 300 + width: 340 contentItem: RowLayout { - width: 290 + width: 330 Qaterial.ColorIcon { @@ -35,6 +35,7 @@ Item color: Qaterial.Colors.amber } + // Insufficient funds tooltip DexLabel { id: tooltip_text @@ -44,6 +45,14 @@ Item { if (mouse_area.containsMouse) { + if (General.privacy_mode) + { + return qsTr("Orderbook is disabled in privacy mode") + } + if (API.app.trading_pg.maker_mode) + { + return qsTr("Orderbook is disabled while creating maker orders") + } let relMaxTakerVol = parseFloat(API.app.trading_pg.orderbook.rel_max_taker_vol.decimal); let baseMaxTakerVol = parseFloat(API.app.trading_pg.orderbook.base_max_taker_vol.decimal); @@ -101,9 +110,12 @@ Item anchors.fill: parent hoverEnabled: true + // Populate form with selected order onClicked: { + if (General.privacy_mode) return if (is_mine) return + if (API.app.trading_pg.maker_mode) return if (enough_funds_to_pay_min_volume ) { @@ -119,6 +131,7 @@ Item } } + // Highlight row on mouseover AnimatedRectangle { visible: mouse_area.containsMouse @@ -128,16 +141,6 @@ Item opacity: 0.1 } - Rectangle - { - anchors.verticalCenter: parent.verticalCenter - width: 6 - height: 6 - radius: width / 2 - visible: is_mine - color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor - } - // Progress bar Rectangle { @@ -161,98 +164,111 @@ Item } } - Row + // Price, Qty & Total text values + RowLayout { id: row anchors.fill: parent - anchors.horizontalCenter: parent.horizontalCenter onWidthChanged: progress.width = ((depth * 100) * (width + 40)) / 100 - spacing: 0 + spacing: 3 + // Dot on the left side of the row to indicate own order + Rectangle + { + Layout.leftMargin: 4 + Layout.alignment: Qt.AlignVCenter + opacity: is_mine ? 1 : 0 + width: 4 + height: 4 + radius: 2 + color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor + } + + // Price Dex.ElidableText { - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.31 - text: { new BigNumber(price).toFixed(8) } + Layout.fillHeight: true + Layout.minimumWidth: 100 + Layout.alignment: Qt.AlignVCenter + text: General.reducedBignum(price, 8) font.family: DexTypo.fontFamily font.pixelSize: 12 color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap } - Item { width: parent.width * 0.01 } - // Quantity Dex.ElidableText { - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.37 - text: { new BigNumber(base_max_volume).toFixed(6) } + Layout.fillHeight: true + Layout.minimumWidth: 100 + Layout.alignment: Qt.AlignVCenter + text: General.reducedBignum(base_max_volume, 6) font.family: DexTypo.fontFamily font.pixelSize: 12 horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter onTextChanged: depth_bar.width = ((depth * 100) * (mouse_area.width + 40)) / 100 wrapMode: Text.NoWrap } - Item { width: parent.width * 0.01 } - // Total Dex.ElidableText { - anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.30 - rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button.containsMouse) ? 30 : 0 + id: total_text + Layout.fillHeight: true + Layout.minimumWidth: 100 + Layout.fillWidth: true + Layout.alignment: Qt.AlignVCenter font.family: DexTypo.fontFamily font.pixelSize: 12 - text: { new BigNumber(total).toFixed(6) } + text: General.reducedBignum(total, 6) horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap - - Behavior on rightPadding { NumberAnimation { duration: 150 } } } - } - } - - Qaterial.ColorIcon - { - id: cancel_button_text - property bool requested_cancel: false - - visible: is_mine && !requested_cancel - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 1 - anchors.right: parent.right - anchors.rightMargin: mouse_area.containsMouse || cancel_button.containsMouse ? 12 : 6 - Behavior on iconSize - { - NumberAnimation + // Cancel button + Item { - duration: 200 - } - } - - iconSize: mouse_area.containsMouse || cancel_button.containsMouse? 16 : 0 + id: cancel_flat_btn + Layout.fillHeight: true + width: 20 + Layout.alignment: Qt.AlignVCenter - color: cancel_button.containsMouse ? - Qaterial.Colors.red : mouse_area.containsMouse ? - DexTheme.foregroundColor: Qaterial.Colors.red + MouseArea + { + id: cancel_mouse_area + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + } - DefaultMouseArea - { - id: cancel_button - anchors.fill: parent - hoverEnabled: true + Qaterial.FlatButton + { + id: cancel_button_orderbook + anchors.centerIn: parent + anchors.fill: parent + opacity: is_mine ? 1 : 0 - onClicked: - { - if (!is_mine) return + onClicked: { + if (uuid) cancelOrder(uuid); + } - cancel_button_text.requested_cancel = true - cancelOrder(uuid) + Qaterial.ColorIcon + { + anchors.centerIn: parent + iconSize: 14 + color: Dex.CurrentTheme.warningColor + source: Qaterial.Icons.close + visible: is_mine + scale: is_mine && mouse_area.containsMouse ? 1 : 0 + Behavior on scale { NumberAnimation { duration: 150 } } + } + } } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml index b73167e100..da3684ff70 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml @@ -11,12 +11,14 @@ import Dex.Themes 1.0 as Dex Widget { - title: qsTr("Order Book") + title: qsTr("%1 Orderbook").arg(left_ticker + "/" + right_ticker) + readonly property string pair_trades_24hr: API.app.trading_pg.pair_trades_24hr readonly property string pair_volume_24hr: API.app.trading_pg.pair_volume_24hr readonly property string pair: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + "/" + atomic_qt_utilities.retrieve_main_ticker(right_ticker) - margins: 8 - spacing: 2 + margins: 8 + spacing: 8 + collapsable: false Header { @@ -27,7 +29,6 @@ Widget List { isAsk: true - isVertical: true Layout.fillHeight: true Layout.fillWidth: true } @@ -53,7 +54,7 @@ Widget Layout.fillWidth: true } - DefaultText + DexLabel { id: volume_text visible: parseFloat(pair_volume_24hr) > 0 @@ -61,7 +62,7 @@ Widget Layout.bottomMargin: 2 Layout.alignment: Qt.AlignHCenter color: Dex.CurrentTheme.foregroundColor2 - text_value: pair + qsTr(" traded 24hrs: %1").arg("" + General.convertUsd(pair_volume_24hr) + "") + text_value: pair + qsTr(" 24hrs | %1 | %2 trades").arg(General.convertUsd(pair_volume_24hr)).arg(pair_trades_24hr) font.pixelSize: Style.textSizeSmall1 } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/Orders/OrderContent.qml b/atomic_defi_design/Dex/Exchange/Trade/Orders/OrderContent.qml index 839700621b..55a4964865 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Orders/OrderContent.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Orders/OrderContent.qml @@ -43,13 +43,13 @@ RowLayout { Layout.fillWidth: true spacing: 5 - DefaultText + DexLabel { Layout.fillWidth: true text: details ? details.base_coin : "" } - DefaultText + DexLabel { Layout.fillWidth: true text: details ? General.coinName(details.base_coin) : "" @@ -59,7 +59,7 @@ RowLayout } } - DefaultText + DexLabel { Layout.fillWidth: true text: details ? details.base_amount : "" @@ -108,13 +108,13 @@ RowLayout { Layout.fillWidth: true spacing: 5 - DefaultText + DexLabel { Layout.fillWidth: true text: details ? details.rel_coin : "" } - DefaultText + DexLabel { Layout.fillWidth: true text: details ? General.coinName(details.rel_coin) : "" @@ -124,7 +124,7 @@ RowLayout } } - DefaultText + DexLabel { Layout.fillWidth: true text: details ? details.rel_amount : "" diff --git a/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml b/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml index abbc8c8125..65d0d6e6b8 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/PriceLineSimplified.qml @@ -22,7 +22,7 @@ ColumnLayout readonly property int fontSizeBigger: Style.textSizeSmall2 readonly property int lineScale: General.getComparisonScale(cexPriceDiff) - spacing: 35 + spacing: 24 RowLayout { @@ -33,7 +33,7 @@ ColumnLayout visible: price_entered Layout.fillWidth: true - DefaultText + DexLabel { Layout.fillWidth: true horizontalAlignment: invalid_cex_price ? Text.AlignHCenter : Text.AlignLeft @@ -42,7 +42,7 @@ ColumnLayout } // Price reversed - DefaultText + DexLabel { Layout.fillWidth: true horizontalAlignment: invalid_cex_price ? Text.AlignHCenter : Text.AlignLeft @@ -51,7 +51,7 @@ ColumnLayout } // Price - DefaultText + DexLabel { visible: price != 1 Layout.fillWidth: true @@ -66,7 +66,7 @@ ColumnLayout visible: !invalid_cex_price Layout.fillWidth: true - DefaultText + DexLabel { Layout.fillWidth: true horizontalAlignment: Text.AlignRight @@ -76,7 +76,7 @@ ColumnLayout } // Price reversed - DefaultText + DexLabel { Layout.fillWidth: true horizontalAlignment: Text.AlignRight @@ -85,7 +85,7 @@ ColumnLayout } // Price - DefaultText + DexLabel { Layout.fillWidth: true horizontalAlignment: Text.AlignRight @@ -122,15 +122,27 @@ ColumnLayout anchors.horizontalCenterOffset: 0.5 * parent.width * Math.min(Math.max(parseFloat(cexPriceDiff) / lineScale, -1), 1) } - DefaultText + DexLabel { text_value: General.formatPercent(lineScale) font.pixelSize: fontSize + anchors.left: parent.left anchors.top: parent.top anchors.topMargin: -15 } - DefaultText + DexLabel + { + id: price_diff_text + anchors.top: parent.top + anchors.topMargin: -15 + anchors.horizontalCenter: parent.horizontalCenter + color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor + text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") + font.pixelSize: fontSizeBigger + } + + DexLabel { text_value: General.formatPercent(-lineScale) font.pixelSize: fontSize @@ -141,14 +153,5 @@ ColumnLayout } } - DefaultText - { - id: price_diff_text - Layout.topMargin: 10 - Layout.alignment: Qt.AlignHCenter - color: parseFloat(cexPriceDiff) <= 0 ? Dex.CurrentTheme.okColor : Dex.CurrentTheme.warningColor - text_value: (parseFloat(cexPriceDiff) > 0 ? qsTr("Expensive") : qsTr("Expedient")) + ":    " + qsTr("%1 compared to CEX", "PRICE_DIFF%").arg("" + General.formatPercent(General.limitDigits(cexPriceDiff)) + "") - font.pixelSize: fontSize - } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml index 0483903ffb..88e66b9641 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/ProView.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/ProView.qml @@ -40,10 +40,8 @@ RowLayout { id: form - property alias tickerSelectors: selectors property alias trInfo: tradingInfo - property alias orderBook: orderBook - property alias bestOrders: bestOrders + property alias marketsOrderBook: marketsOrderBook property alias placeOrderForm: placeOrderForm function selectOrder( @@ -104,77 +102,34 @@ RowLayout General.prettifyJSON(response.result), false) General.prevent_coin_disabling.restart() - tradingInfo.currentIndex = 1 + // Show the orders tab unless settings say otherwise + if (API.app.settings_pg.postorder_enabled) + { + tradingInfo.currentIndex = 1 + } } } } - ColumnLayout + // Trading Informations + TradingInfo.Main { + id: tradingInfo Layout.alignment: Qt.AlignTop - - Layout.minimumWidth: selectors.visible || tradingInfo.visible ? 450 : -1 - Layout.maximumWidth: (!orderBook.visible && !bestOrders.visible) || (!placeOrderForm.visible) ? -1 : 450 - Layout.fillWidth: true - + Layout.minimumWidth: tradingInfo.visible ? 450 : -1 + Layout.maximumWidth: (!marketsOrderBook.visible) || (!placeOrderForm.visible) ? -1 : 450 Layout.fillHeight: true - - spacing: 10 - - // Ticker selectors. - TickerSelectors - { - id: selectors - - Layout.fillWidth: true - Layout.preferredHeight: 70 - } - - // Trading Informations - TradingInfo.Main - { - id: tradingInfo - - Layout.fillWidth: true - Layout.fillHeight: true - - resizable: false - } } - WidgetContainer + // Best Orders & Order Book + Market { - property real _orderBookHeightRatio: 0.65 - property real _bestOrdersHeightRatio: 0.35 - - Layout.minimumWidth: orderBook.visible || bestOrders.visible ? 350 : -1 + id: marketsOrderBook + Layout.maximumWidth: 350 Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignTop spacing: 4 - - onHeightChanged: - { - orderBook.height = getHeight(_orderBookHeightRatio); - bestOrders.height = getHeight(_bestOrdersHeightRatio); - } - - OrderBook.Vertical - { - id: orderBook - - width: parent.width - minHeight: 320 - } - - // Best Orders - BestOrder.List - { - id: bestOrders - - width: parent.width - minHeight: 140 - } } // Place order form. @@ -186,13 +141,11 @@ RowLayout Layout.maximumWidth: 305 Layout.fillWidth: true Layout.fillHeight: true - - resizable: false } ModalLoader { id: confirm_trade_modal - sourceComponent: ConfirmTradeModal {} + sourceComponent: ConfirmTradeModal { } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml index c9ea3a02df..c900b3ca17 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml @@ -27,8 +27,6 @@ DexListView delegate: ClipRRect { property var details: model - readonly property bool is_placed_order: !details ? false : - details.order_id !== '' property bool expanded: order_list_view.currentIndex === index @@ -78,7 +76,7 @@ DexListView height: width anchors.centerIn: parent running: !isSwapDone(details.order_status) && Qt.platform.os != "osx" - DefaultText + DexLabel { anchors.centerIn: parent font.pixelSize: getStatusFontSize(details.order_status) @@ -105,13 +103,13 @@ DexListView anchors.verticalCenter: parent.verticalCenter } - DefaultText + DexLabel { id: base_amount text_value: !details ? "" : General.formatCrypto("", details.base_amount, details.base_coin).replace(" ","
") font: rel_amount.font - privacy: is_placed_order + privacy: true anchors.verticalCenter: parent.verticalCenter } } @@ -150,7 +148,7 @@ DexListView height: width anchors.verticalCenter: parent.verticalCenter } - DefaultText + DexLabel { id: rel_amount text_value: !details ? "" : @@ -162,7 +160,7 @@ DexListView weight: Font.Normal }) anchors.verticalCenter: parent.verticalCenter - privacy: is_placed_order + privacy: true } } @@ -194,8 +192,9 @@ DexListView Layout.fillWidth: true Layout.fillHeight: true verticalAlignment: Label.AlignVCenter - text: !details ? "" : + text_value: !details ? "" : General.formatCrypto("", details.base_amount, details.base_coin) + privacy: true } DexLabel { @@ -203,8 +202,9 @@ DexListView Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Text.AlignRight - text: !details ? "" : + text_value: !details ? "" : General.formatCrypto("", details.rel_amount, details.rel_coin) + privacy: true } } @@ -215,20 +215,22 @@ DexListView anchors.horizontalCenter: parent.horizontalCenter height: 20 opacity: .6 - DefaultText + DexLabel { Layout.fillWidth: true - Layout.fillHeight: true + Layout.fillHeight: true verticalAlignment: Label.AlignVCenter - text: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.base_amount_current_currency) + text_value: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.base_amount_current_currency) + privacy: true } - DefaultText + DexLabel { Layout.fillWidth: true Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Text.AlignRight - text: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.rel_amount_current_currency) + text_value: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.rel_amount_current_currency) + privacy: true } } @@ -244,7 +246,8 @@ DexListView Layout.fillWidth: true Layout.fillHeight: true verticalAlignment: Label.AlignVCenter - text: !details ? "" : details.date?? "" + text_value: !details ? "" : details.date?? "" + privacy: true } Item { @@ -283,7 +286,7 @@ DexListView contentItem: ColumnLayout { - DefaultText { + DexLabel { text_value: qsTr("Funds are recoverable") font.pixelSize: Constants.Style.textSizeSmall4 } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml index 6d52f44351..85a4d2e09b 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Main.qml @@ -29,13 +29,16 @@ Item target: exchange_trade function onOrderPlaced() { - currentSubPage = subPages.Orders + if (API.app.settings_pg.postorder_enabled) + { + currentSubPage = subPages.Orders + } } } Column { - width: root.currentSubPage === subPages.Trade ? _simpleTrade.best ? 600 : 450 : 450 + width: root.currentSubPage === subPages.Trade ? _simpleTrade.best ? 720 : 450 : 450 y: 60 spacing: 30 anchors.horizontalCenter: parent.horizontalCenter @@ -130,7 +133,7 @@ Item id: _swipeSimplifiedView currentIndex: root.currentSubPage anchors.horizontalCenter: parent.horizontalCenter - width: 600 + width: 720 height: 650 clip: true interactive: false @@ -141,7 +144,7 @@ Item { id: subTradePage height: _simpleTrade.height - width: _simpleTrade.best ? 600 : _simpleTrade.coinSelection ? 450 : 380 + width: _simpleTrade.best ? 720 : _simpleTrade.coinSelection ? 450 : 380 anchors.horizontalCenter: parent.horizontalCenter radius: 20 diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml index dc49f96c39..0cec29162b 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/OrderRemovedModal.qml @@ -12,12 +12,12 @@ MultipageModal { titleText: qsTr("Selected Order Removed") - DefaultText + DexLabel { Layout.fillWidth: true wrapMode: Text.WordWrap - text: qsTr("The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available.\nPlease select a new order.") + text: qsTr("The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available.\nPlease select a new order.") } footer: diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubBestOrder.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubBestOrder.qml index d01600f8d6..5a58a1e343 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubBestOrder.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubBestOrder.qml @@ -27,11 +27,11 @@ DexListView property int _rowWidth: width property int _rowHeight: 40 - property int _tokenColumnSize: 90 - property int _quantityColumnSize: 90 + property int _tokenColumnSize: 120 + property int _quantityColumnSize: 95 property int _quantityInBaseColumnSize: 120 - property int _fiatVolumeColumnSize: 80 - property int _cexRateColumnSize: 60 + property int _fiatVolumeColumnSize: 95 + property int _cexRateColumnSize: 75 headerPositioning: ListView.OverlayHeader reuseItems: true @@ -187,7 +187,7 @@ DexListView { Layout.preferredWidth: _quantityColumnSize horizontalAlignment: Text.AlignRight - text_value: parseFloat(General.formatDouble(rel_max_volume, General.amountPrecision, true)).toFixed(8) + text_value: Constants.General.formatNumber(rel_max_volume) font.pixelSize: 14 opacity: !_isCoinEnabled? .3 : 1 } @@ -196,7 +196,7 @@ DexListView { Layout.preferredWidth: _quantityInBaseColumnSize horizontalAlignment: Text.AlignRight - text_value: parseFloat(General.formatDouble(base_max_volume, General.amountPrecision, true)).toFixed(8) + text_value: Constants.General.formatNumber(base_max_volume) font.pixelSize: 14 opacity: !_isCoinEnabled? .3 : 1 } @@ -206,16 +206,16 @@ DexListView Layout.preferredWidth: _fiatVolumeColumnSize horizontalAlignment: Text.AlignRight // TODO: Adjust fiat to left/right sign based on region - text_value: parseFloat(price_fiat).toFixed(2)+Constants.API.app.settings_pg.current_fiat_sign + text_value: Constants.General.formatFiat("", price_fiat, Constants.API.app.settings_pg.current_fiat_sign) opacity: !_isCoinEnabled? .3 : 1 } - DexLabel + DexLabel // Order CEX Rate { Layout.preferredWidth: _cexRateColumnSize horizontalAlignment: Text.AlignRight color: cex_rates=== "0" ? Qt.darker(DexTheme.foregroundColor) : parseFloat(cex_rates)>0? DexTheme.warningColor : DexTheme.okColor - text_value: cex_rates=== "0" ? "N/A" : parseFloat(cex_rates)>0? "+"+parseFloat(cex_rates).toFixed(2)+"%" : parseFloat(cex_rates).toFixed(2)+"%" + text_value: Constants.General.formatCexRates(cex_rates) opacity: !_isCoinEnabled? .3 : 1 } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml index bf1938c322..852291ca5f 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml @@ -174,6 +174,7 @@ DexListView text_value: model.balance.replace(" ","") font.pixelSize: 14 wrapMode: Text.NoWrap + privacy: true } DexLabel @@ -184,6 +185,7 @@ DexListView text_value: "%1".arg(General.getFiatText(model.balance, model.ticker, false)) font.pixelSize: 14 wrapMode: Text.NoWrap + privacy: true } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubHistory.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubHistory.qml index 917e515db6..cafb9814aa 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubHistory.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubHistory.qml @@ -87,7 +87,7 @@ Item leftPadding: 20 topPadding: 20 - DefaultText // Title + DexLabel // Title { text: qsTr("History") font: DexTypo.head6 @@ -160,7 +160,7 @@ Item rightPadding: 15 visible: parent.height > 250 - DefaultText + DexLabel { text: qsTr("Filter settings") topPadding: 10 diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubOrders.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubOrders.qml index 7b26d92157..100770082b 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubOrders.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubOrders.qml @@ -79,7 +79,7 @@ Item leftPadding: 20 topPadding: 20 - DefaultText // Title + DexLabel // Title { text: qsTr("Orders") font: DexTypo.head6 diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml index 6a92ed7e0e..adf8ecb146 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml @@ -47,7 +47,7 @@ ClipRRect // Trade Card Component.onCompleted: _fromValue.forceActiveFocus() onBestChanged: if (best) Constants.API.app.trading_pg.orderbook.refresh_best_orders() - width: bestOrderSimplified.visible ? 600 : coinSelection ? 450 : 380 + width: bestOrderSimplified.visible ? 720 : coinSelection ? 450 : 380 height: swap_card_content.height + 15 radius: 20 @@ -160,7 +160,7 @@ ClipRRect // Trade Card opacity: .85 } - DefaultText // Description + DexLabel // Description { anchors.topMargin: 10 font.pixelSize: Constants.Style.textSizeSmall4 @@ -231,7 +231,7 @@ ClipRRect // Trade Card radius: 20 visible: !coinSelectorSimplified.visible && has_coins_with_balance - DefaultText // From Text + DexLabel // From Text { id: _fromTitle anchors.top: parent.top @@ -242,7 +242,7 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall4 } - Text // Tradable Balance + DexLabel // Tradable Balance { readonly property int _maxWidth: 140 @@ -252,10 +252,11 @@ ClipRRect // Trade Card anchors.verticalCenter: _fromTitle.verticalCenter anchors.right: parent.right anchors.rightMargin: 17 - text: qsTr("%1").arg(max_trade_volume) // This is slow to appear + text_value: qsTr("%1").arg(max_trade_volume) // This is slow to appear font.pixelSize: Constants.Style.textSizeSmall2 elide: Text.ElideRight color: DexTheme.foregroundColorLightColor1 + privacy: true DefaultImage { @@ -282,6 +283,10 @@ ClipRRect // Trade Card visible: parent.containsMouse text: { + if (General.privacy_mode) + { + return qsTr("Balance: ") + qsTr("****") + } let balance = Constants.API.app.portfolio_pg.portfolio_mdl.coin_balance(selectedTicker); return qsTr("Balance: ") + Constants.API.app.portfolio_pg.portfolio_mdl.coin_balance(selectedTicker) + ' (' + parent.parent.text + ' tradable)' } @@ -300,7 +305,7 @@ ClipRRect // Trade Card AmountField // Amount { id: _fromValue - enabled: sell_ticker_balance == 0 ? false : waiting_for_sell_coin_info ? false : true + enabled: sell_ticker_balance == 0 ? false : waiting_for_sell_coin_info ? false : General.privacy_mode ? false : true anchors.bottom: parent.bottom anchors.bottomMargin: 19 anchors.left: parent.left @@ -329,7 +334,7 @@ ClipRRect // Trade Card Component.onCompleted: text = "" } - Text // Amount In Fiat + DexLabel // Amount In Fiat { enabled: _fromValue.text visible: enabled @@ -340,7 +345,8 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall1 color: DexTheme.foregroundColor opacity: .9 - text: enabled ? Constants.General.getFiatText(_fromValue.text, selectedTicker) : "" + text_value: enabled ? Constants.General.getFiatText(_fromValue.text, selectedTicker) : "" + privacy: true } Rectangle // Select ticker button @@ -387,7 +393,7 @@ ClipRRect // Trade Card source: Constants.General.coinIcon(selectedTicker) } - DefaultText + DexLabel { id: _selectedTickerText @@ -403,7 +409,7 @@ ClipRRect // Trade Card wrapMode: Text.NoWrap - DefaultText + DexLabel { id: _selectedTickerTypeText @@ -432,16 +438,13 @@ ClipRRect // Trade Card ClickableText // MAX Button { id: _maxClickableLabel - anchors.right: _selectTickerBut.left anchors.rightMargin: 10 anchors.verticalCenter: _selectTickerBut.verticalCenter - visible: selectedTicker !== "" - text: qsTr("MAX") color: Dex.CurrentTheme.foregroundColor2 - + enabled: !General.privacy_mode onClicked: _fromValue.text = max_trade_volume } @@ -464,7 +467,7 @@ ClipRRect // Trade Card && !coinSelectorSimplified.visible && has_coins_with_balance - DefaultText + DexLabel { anchors.fill: parent anchors.leftMargin: 17 @@ -487,7 +490,7 @@ ClipRRect // Trade Card background: Rectangle { color: swap_from_card.color} } - DefaultText // Amount In Fiat + DexLabel // Amount In Fiat { enabled: parseFloat(_toValue.text) > 0 && _toValue.text != "" anchors.top: _toValue.bottom @@ -533,7 +536,7 @@ ClipRRect // Trade Card } // When no order is currently selected. - DefaultText + DexLabel { id: _bestOrderNoTickerText @@ -567,7 +570,7 @@ ClipRRect // Trade Card } // Ticker (When a best order is currently selected) - DefaultText + DexLabel { id: _bestOrderTickerText @@ -584,7 +587,7 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall2 wrapMode: Text.NoWrap - DefaultText + DexLabel { id: _bestOrderTickerTypeText @@ -623,14 +626,14 @@ ClipRRect // Trade Card && !coinSelectorSimplified.visible && has_coins_with_balance - DefaultText + DexLabel { Layout.rightMargin: 120 font.pixelSize: Constants.Style.textSizeSmall3 text: qsTr("Price") } - DefaultText + DexLabel { Layout.alignment: Qt.AlignRight font.pixelSize: Constants.Style.textSizeSmall3 @@ -714,7 +717,10 @@ ClipRRect // Trade Card function getAlert() { - console.log("_fromValue.text: " + _fromValue.text) + if (Constants.General.privacy_mode) + { + return qsTr("Disable privacy mode to trade.") + } var right_ticker = Constants.API.app.trading_pg.market_pairs_mdl.right_selected_coin var base_ticker = Constants.API.app.trading_pg.market_pairs_mdl.base_selected_coin var rel_ticker = Constants.API.app.trading_pg.market_pairs_mdl.rel_selected_coin @@ -859,7 +865,7 @@ ClipRRect // Trade Card tradeCard: _tradeCard anchors.fill: parent anchors.topMargin: 10 - visible: _tradeCard.width == 600 + visible: _tradeCard.width == 720 onSelectedOrderChanged: { @@ -932,7 +938,7 @@ ClipRRect // Trade Card anchors.fill: parent } - DefaultText + DexLabel { anchors.centerIn: parent text: qsTr("Calculating fee estimate... ") @@ -959,7 +965,7 @@ ClipRRect // Trade Card Component.onCompleted: _feesCard.height += 10 Component.onDestruction: _feesCard.height -= 10 - DefaultText + DexLabel { Layout.alignment: Qt.AlignLeft Layout.leftMargin: 10 @@ -967,7 +973,7 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall3 } - DefaultText + DexLabel { Layout.alignment: Qt.AlignRight Layout.rightMargin: 10 diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml index 1923050189..aba6f1c6ba 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trade.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trade.qml @@ -48,27 +48,32 @@ Item readonly property bool price_is_empty: parseFloat(non_null_price) <= 0 readonly property string backend_price: API.app.trading_pg.price + readonly property int last_trading_error: API.app.trading_pg.last_trading_error + readonly property string max_volume: API.app.trading_pg.max_volume + readonly property string backend_volume: API.app.trading_pg.volume + property bool sell_mode: API.app.trading_pg.market_mode.toString() === "Sell" + readonly property string base_amount: API.app.trading_pg.base_amount + readonly property string rel_amount: API.app.trading_pg.rel_amount + function setPrice(v) { API.app.trading_pg.price = v API.app.trading_pg.determine_error_cases() } - readonly property int last_trading_error: API.app.trading_pg.last_trading_error - readonly property string max_volume: API.app.trading_pg.max_volume - readonly property string backend_volume: API.app.trading_pg.volume + function setVolume(v) { API.app.trading_pg.volume = v API.app.trading_pg.determine_error_cases() } + + function setMakerMode(v) { + API.app.trading_pg.maker_mode = v + } - property bool sell_mode: API.app.trading_pg.market_mode.toString( - ) === "Sell" function setMarketMode(v) { API.app.trading_pg.market_mode = v } - readonly property string base_amount: API.app.trading_pg.base_amount - readonly property string rel_amount: API.app.trading_pg.rel_amount - + Timer { id: swap_cooldown @@ -144,9 +149,20 @@ Item } if (sell_mode) - API.app.trading_pg.place_sell_order(nota, confs) + { + if (API.app.trading_pg.maker_mode) + { + API.app.trading_pg.place_setprice_order(nota, confs, options.cancel_previous) + } + else + { + API.app.trading_pg.place_sell_order(nota, confs, options.good_until_canceled) + } + } else - API.app.trading_pg.place_buy_order(nota, confs) + { + API.app.trading_pg.place_buy_order(nota, confs, options.good_until_canceled) + } orderPlaced() } @@ -170,10 +186,8 @@ Item width: parent.width height: parent.height * 0.06 - proViewTickerSelectors: proView.tickerSelectors proViewTrInfo: proView.trInfo - proViewOrderBook: proView.orderBook - proViewBestOrders: proView.bestOrders + proViewMarketsOrderBook: proView.marketsOrderBook proViewPlaceOrderForm: proView.placeOrderForm } diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trading/Items/FeeInfo.qml b/atomic_defi_design/Dex/Exchange/Trade/Trading/Items/FeeInfo.qml index f8ce4d8bc7..355778d120 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trading/Items/FeeInfo.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trading/Items/FeeInfo.qml @@ -33,7 +33,7 @@ Column Layout.rightMargin: Layout.leftMargin Layout.alignment: Qt.AlignLeft - DefaultText + DexLabel { id: tx_fee_text text_value: General.feeText(curr_fee_info, base_ticker, true, true) @@ -45,7 +45,7 @@ Column } - DefaultText + DexLabel { //visible: !fees.visible visible: false diff --git a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml index 8cc01d06d4..59d2aac4cb 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/Trading/TradeViewHeader.qml @@ -19,10 +19,8 @@ import "../../../Constants" Item { // property var proViewChart - property var proViewTickerSelectors property var proViewTrInfo - property var proViewOrderBook - property var proViewBestOrders + property var proViewMarketsOrderBook property var proViewPlaceOrderForm Item @@ -35,8 +33,8 @@ Item { id: cursorRect width: _simpleLabel.width + 28 - height: _simpleLabel.height + 14 - radius: 16 + height: _simpleLabel.height + 8 + radius: 8 anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: API.app.trading_pg.current_trading_mode == TradingMode.Simple ? _simpleLabel.horizontalCenter : _proLabel.horizontalCenter color: Dex.CurrentTheme.tabSelectedColor @@ -91,11 +89,12 @@ Item outlined: false highlighted: false + padding: 6 foregroundColor: Dex.CurrentTheme.foregroundColor icon.source: Qaterial.Icons.cog text: qsTr("Pro View Settings") - font: DexTypo.subtitle1 + font: DexTypo.subtitle2 onClicked: { @@ -111,19 +110,15 @@ Item contentItem: Item { implicitWidth: 200 - implicitHeight: 240 + implicitHeight: 200 Column { anchors.fill: parent - padding: 10 + padding: 8 spacing: 8 - DefaultText { text: qsTr("Display Settings"); font: DexTypo.body2 } - - HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - - CheckEye { text: qsTr("Ticker Selectors"); target: proViewTickerSelectors } + DexLabel { text: qsTr("Display Settings"); font: DexTypo.body2 } HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } @@ -131,15 +126,11 @@ Item HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - CheckEye { text: qsTr("Order Book"); target: proViewOrderBook } - - HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - - CheckEye { text: qsTr("Best Orders"); target: proViewBestOrders } + CheckEye { text: qsTr("Order Book"); target: proViewMarketsOrderBook } HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 } - CheckEye { text: qsTr("Place Order"); target: proViewPlaceOrderForm } + CheckEye { text: qsTr("Order Form"); target: proViewPlaceOrderForm } } } } diff --git a/atomic_defi_design/Dex/NewUpdateModal.qml b/atomic_defi_design/Dex/NewUpdateModal.qml index fd5121ed3a..cbfb3f04a6 100644 --- a/atomic_defi_design/Dex/NewUpdateModal.qml +++ b/atomic_defi_design/Dex/NewUpdateModal.qml @@ -23,10 +23,17 @@ Dex.MultipageModal Component.onCompleted: { - let status = Dex.API.app.updateCheckerService.updateInfo.status - if ( status === "recommended" || status === "required") + if (Dex.API.app.updateCheckerService.updateInfo) { - root.open() + console.log("init updateInfo.status: " + Dex.API.app.updateCheckerService.updateInfo.status) + console.log("init updateInfo.updateNeeded: " + Dex.API.app.updateCheckerService.updateInfo.updateNeeded) + console.log("init updateInfo.newVersion: " + Dex.API.app.updateCheckerService.updateInfo.newVersion) + console.log("init updateInfo.downloadUrl: " + Dex.API.app.updateCheckerService.updateInfo.downloadUrl) + console.log("init updateInfo.changelog: " + Dex.API.app.updateCheckerService.updateInfo.changelog) + if (Dex.API.app.updateCheckerService.updateInfo.updateNeeded == true) + { + root.open() + } } } @@ -39,7 +46,7 @@ Dex.MultipageModal titleAlignment: Qt.AlignHCenter spacing: 16 - Dex.DefaultText + Dex.DexLabel { Layout.alignment: Qt.AlignHCenter text: qsTr("Fetching...") @@ -69,7 +76,7 @@ Dex.MultipageModal titleAlignment: Qt.AlignHCenter spacing: 16 - Dex.DefaultText + Dex.DexLabel { text: qsTr("Could not check new updates for the following reason: \n%1").arg(Dex.API.app.updateCheckerService.updateInfo.status) } @@ -94,13 +101,13 @@ Dex.MultipageModal titleAlignment: Qt.AlignHCenter spacing: 16 - Dex.DefaultText + Dex.DexLabel { Layout.alignment: Qt.AlignHCenter text: qsTr("%1 %2 is available !").arg(Dex.API.app_name).arg(Dex.API.app.updateCheckerService.updateInfo.newVersion) } - Dex.DefaultText + Dex.DexLabel { visible: Dex.API.app.updateCheckerService.updateInfo.status === "required" Layout.alignment: Qt.AlignHCenter @@ -131,7 +138,7 @@ Dex.MultipageModal titleAlignment: Qt.AlignHCenter spacing: 16 - Dex.DefaultText + Dex.DexLabel { text: qsTr("Your application is up to date!") } @@ -160,8 +167,7 @@ Dex.MultipageModal console.log("updateInfo.changelog: " + Dex.API.app.updateCheckerService.updateInfo.changelog) if (Dex.API.app.updateCheckerService.updateInfo) { - let status = Dex.API.app.updateCheckerService.updateInfo.status - if (status === "recommended" || status === "required") + if (Dex.API.app.updateCheckerService.updateInfo.updateNeeded == true) { root.open() } diff --git a/atomic_defi_design/Dex/NoConnection.qml b/atomic_defi_design/Dex/NoConnection.qml index 3fd59c9ad1..cec990620b 100644 --- a/atomic_defi_design/Dex/NoConnection.qml +++ b/atomic_defi_design/Dex/NoConnection.qml @@ -15,19 +15,19 @@ Rectangle { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - DefaultText { + DexLabel { text_value: qsTr("No connection") Layout.alignment: Qt.AlignHCenter font.pixelSize: Style.textSize3 } - DefaultText { + DexLabel { text_value: qsTr("Please make sure you are connected to the internet") Layout.alignment: Qt.AlignHCenter } - DefaultText { + DexLabel { text_value: qsTr("Will automatically retry in %1 seconds").arg(General.formatDouble(API.app.internet_checker.seconds_left_to_auto_retry, 0)) Layout.alignment: Qt.AlignHCenter } diff --git a/atomic_defi_design/Dex/Portfolio/AssetsList.qml b/atomic_defi_design/Dex/Portfolio/AssetsList.qml index 97bbdfcb0d..3778b29cb3 100644 --- a/atomic_defi_design/Dex/Portfolio/AssetsList.qml +++ b/atomic_defi_design/Dex/Portfolio/AssetsList.qml @@ -283,7 +283,7 @@ Dex.DexListView Dex.DexTooltip { - contentItem: Dex.DefaultText + contentItem: Dex.DexLabel { text: qsTr("Price provider is: %1").arg(DexString.capitalizeFirstLetter(priceProvider)) font: Dex.DexTypo.caption diff --git a/atomic_defi_design/Dex/Portfolio/TradingViewChart.qml b/atomic_defi_design/Dex/Portfolio/TradingViewChart.qml index 72c433c438..ffcdd84993 100644 --- a/atomic_defi_design/Dex/Portfolio/TradingViewChart.qml +++ b/atomic_defi_design/Dex/Portfolio/TradingViewChart.qml @@ -121,12 +121,12 @@ Item { scale: 0.5 } - DefaultText { + DexLabel { text_value: qsTr("Loading market data") + "..." } } - DefaultText { + DexLabel { visible: !ticker_supported text_value: qsTr("There is no chart data for this ticker yet") anchors.centerIn: parent diff --git a/atomic_defi_design/Dex/Screens/Startup/ImportWallet.qml b/atomic_defi_design/Dex/Screens/Startup/ImportWallet.qml index 2abfd27ab4..393add073c 100644 --- a/atomic_defi_design/Dex/Screens/Startup/ImportWallet.qml +++ b/atomic_defi_design/Dex/Screens/Startup/ImportWallet.qml @@ -113,7 +113,7 @@ SetupPage } } - DefaultText + DexLabel { font: DexTypo.head6 Layout.fillWidth: true @@ -199,7 +199,7 @@ SetupPage } } - DefaultText + DexLabel { id: _seedError visible: _seedField.error @@ -263,7 +263,7 @@ SetupPage Layout.preferredWidth: 400 spacing: Style.buttonSpacing - DefaultText + DexLabel { text_value: text_error color: Dex.CurrentTheme.warningColor @@ -359,7 +359,7 @@ SetupPage } } - DefaultText + DexLabel { text_value: text_error color: Dex.CurrentTheme.warningColor diff --git a/atomic_defi_design/Dex/Screens/Startup/Logging.qml b/atomic_defi_design/Dex/Screens/Startup/Logging.qml index 81c63ff6d0..128c45e949 100644 --- a/atomic_defi_design/Dex/Screens/Startup/Logging.qml +++ b/atomic_defi_design/Dex/Screens/Startup/Logging.qml @@ -30,16 +30,16 @@ SetupPage scale: 0.8 } - DefaultText + DexLabel { text_value: qsTr("Loading, please wait") Layout.bottomMargin: 10 } - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter - text_value: (current_status === "initializing_mm2" ? qsTr("Initializing MM2") : + text_value: (current_status === "initializing_kdf" ? qsTr("Initializing KDF") : current_status === "enabling_coins" ? qsTr("Enabling assets") : qsTr("Getting ready")) + "..." } } diff --git a/atomic_defi_design/Dex/Screens/Startup/NewWallet.qml b/atomic_defi_design/Dex/Screens/Startup/NewWallet.qml index ef22a5bbd6..f663d2fca7 100644 --- a/atomic_defi_design/Dex/Screens/Startup/NewWallet.qml +++ b/atomic_defi_design/Dex/Screens/Startup/NewWallet.qml @@ -349,7 +349,7 @@ SetupPage spacing: 10 - DefaultText + DexLabel { width: parent.width - 40 color: Style.colorWhite0 @@ -358,7 +358,7 @@ SetupPage text_value: qsTr("Important: Back up your seed phrase before proceeding!") } - DefaultText + DexLabel { width: parent.width - 40 color: Style.colorWhite0 @@ -384,7 +384,7 @@ SetupPage RowLayout { width: parent.width - DefaultText + DexLabel { text: qsTr("Generated Seed") font: DexTypo.body1 @@ -431,7 +431,7 @@ SetupPage radius: 10 opacity: .8 color: Dex.CurrentTheme.backgroundColor - DefaultText + DexLabel { id: _insideLabel text: (index + 1) + ". " + modelData @@ -455,7 +455,7 @@ SetupPage Layout.preferredWidth: 400 spacing: Style.buttonSpacing - DefaultText + DexLabel { text_value: text_error color: Dex.CurrentTheme.warningColor @@ -523,7 +523,7 @@ SetupPage spacing: 5 - DefaultText + DexLabel { width: parent.width - 40 anchors.horizontalCenter: parent.horizontalCenter @@ -534,7 +534,7 @@ SetupPage text_value: qsTr("Let's double check your seed phrase") } - DefaultText + DexLabel { width: parent.width - 40 anchors.horizontalCenter: parent.horizontalCenter @@ -616,7 +616,7 @@ SetupPage color: Dex.CurrentTheme.inputLeftIconBackgroundColor anchors.verticalCenter: parent.verticalCenter - DefaultText + DexLabel { anchors.centerIn: parent font: DexTypo.body1 @@ -663,7 +663,7 @@ SetupPage { Layout.fillWidth: true Layout.preferredHeight: 20 - DefaultText + DexLabel { text_value: guess_text_error color: Dex.CurrentTheme.warningColor @@ -742,7 +742,7 @@ SetupPage } } - DefaultText + DexLabel { text_value: text_error color: Dex.CurrentTheme.warningColor diff --git a/atomic_defi_design/Dex/Screens/Startup/WalletsView.qml b/atomic_defi_design/Dex/Screens/Startup/WalletsView.qml index 32b0c85929..ebdc623cee 100644 --- a/atomic_defi_design/Dex/Screens/Startup/WalletsView.qml +++ b/atomic_defi_design/Dex/Screens/Startup/WalletsView.qml @@ -79,7 +79,7 @@ SetupPage visible: wallet_count > 0 // Searchbar - DefaultTextField + DexTextField { id: wallet_search visible: wallet_count > 5 @@ -198,7 +198,7 @@ SetupPage } } - DefaultText + DexLabel { anchors.left: parent.left anchors.leftMargin: 40 diff --git a/atomic_defi_design/Dex/Settings/AddCustomCoinModal.qml b/atomic_defi_design/Dex/Settings/AddCustomCoinModal.qml index d48dffbc28..af8cadadc6 100644 --- a/atomic_defi_design/Dex/Settings/AddCustomCoinModal.qml +++ b/atomic_defi_design/Dex/Settings/AddCustomCoinModal.qml @@ -44,7 +44,7 @@ MultipageModal onCustom_token_dataChanged: { const data = custom_token_data - if(!data.mm2_cfg) return + if(!data.kdf_cfg) return var fields = General.clone(config_fields) @@ -221,7 +221,7 @@ MultipageModal left_text: currentType.prefix } - DefaultText + DexLabel { visible: input_contract_address.visible Layout.fillWidth: true @@ -335,7 +335,7 @@ MultipageModal { titleText: qsTr("Configuration") - DefaultText + DexLabel { visible: has_contract_address Layout.fillWidth: true @@ -360,7 +360,7 @@ MultipageModal field.placeholderText: qsTr("Enter the Coingecko ID") } - DefaultText + DexLabel { visible: input_coingecko_id.visible Layout.fillWidth: true @@ -427,7 +427,7 @@ MultipageModal MultipageModalContent { titleText: qsTr("Preview Token Configuration") - DefaultText { + DexLabel { id: warning_message visible: coin_name.visible Layout.fillWidth: true @@ -449,7 +449,7 @@ MultipageModal source: input_logo.path } - DefaultText { + DexLabel { id: error_text Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true @@ -460,7 +460,7 @@ MultipageModal color: Style.colorRed } - DefaultText { + DexLabel { id: coin_name Layout.alignment: Qt.AlignHCenter visible: has_contract_address && !error_text.visible diff --git a/atomic_defi_design/Dex/Settings/CamouflagePasswordModal.qml b/atomic_defi_design/Dex/Settings/CamouflagePasswordModal.qml index a798ff68dc..06b3e42532 100644 --- a/atomic_defi_design/Dex/Settings/CamouflagePasswordModal.qml +++ b/atomic_defi_design/Dex/Settings/CamouflagePasswordModal.qml @@ -34,7 +34,7 @@ MultipageModal width: parent.width spacing: 10 - DefaultText + DexLabel { width: parent.width - 40 horizontalAlignment: Text.AlignHCenter @@ -44,7 +44,7 @@ MultipageModal font: DexTypo.subtitle2 } - DefaultText + DexLabel { width: parent.width - 40 horizontalAlignment: Text.AlignHCenter @@ -53,7 +53,7 @@ MultipageModal text_value: qsTr("Using it to login will display your balance lower than it actually is.") } - DefaultText + DexLabel { width: parent.width - 40 horizontalAlignment: Text.AlignHCenter diff --git a/atomic_defi_design/Dex/Settings/DeleteWalletModal.qml b/atomic_defi_design/Dex/Settings/DeleteWalletModal.qml index c19c6854f9..6d88bf3c6f 100644 --- a/atomic_defi_design/Dex/Settings/DeleteWalletModal.qml +++ b/atomic_defi_design/Dex/Settings/DeleteWalletModal.qml @@ -36,7 +36,7 @@ MultipageModal { width: parent.width spacing: 10 - DefaultText { + DexLabel { width: parent.width - 40 horizontalAlignment: Text.AlignHCenter anchors.horizontalCenter: parent.horizontalCenter @@ -45,7 +45,7 @@ MultipageModal { font.pixelSize: Style.textSize2 } - DefaultText { + DexLabel { width: parent.width - 40 horizontalAlignment: Text.AlignHCenter anchors.horizontalCenter: parent.horizontalCenter @@ -62,7 +62,7 @@ MultipageModal { field.placeholderText: qsTr("Enter your wallet password") } - DefaultText { + DexLabel { text_value: qsTr("Wrong Password") color: Style.colorRed visible: wrong_password diff --git a/atomic_defi_design/Dex/Settings/RecoverSeedModal.qml b/atomic_defi_design/Dex/Settings/RecoverSeedModal.qml index 39253a7786..c7d12523e5 100644 --- a/atomic_defi_design/Dex/Settings/RecoverSeedModal.qml +++ b/atomic_defi_design/Dex/Settings/RecoverSeedModal.qml @@ -56,7 +56,7 @@ MultipageModal { titleText: qsTr("View seed and private keys") - DefaultText + DexLabel { text_value: qsTr("Please enter your password to view the seed.") } @@ -188,14 +188,14 @@ MultipageModal ColumnLayout { - DefaultText + DexLabel { text: qsTr("Backup Seed") font.pixelSize: Style.textSizeSmall2 color: Dex.CurrentTheme.foregroundColor2 } - DefaultText + DexLabel { id: seedLabel Layout.fillWidth: true @@ -241,13 +241,13 @@ MultipageModal ColumnLayout { - DefaultText + DexLabel { text: qsTr("RPC Password") font.pixelSize: Style.textSizeSmall2 color: Dex.CurrentTheme.foregroundColor2 } - DefaultText + DexLabel { id: rpcPwLabel Layout.fillWidth: true @@ -262,7 +262,7 @@ MultipageModal HorizontalLine { Layout.fillWidth: true } - DefaultTextField + DexTextField { visible: coinsList.visible enabled: coinsList.enabled @@ -314,7 +314,7 @@ MultipageModal Layout.alignment: Qt.AlignCenter } - DefaultText + DexLabel { text: model.name font.pixelSize: Style.textSizeSmall4 @@ -362,14 +362,14 @@ MultipageModal { spacing: 5 Layout.fillWidth: true - DefaultText + DexLabel { text: qsTr("Public Address") font.pixelSize: Style.textSizeSmall2 color: Dex.CurrentTheme.foregroundColor2 } - DefaultText + DexLabel { id: publicAddress text: model.public_address != 'Invalid Ticker' ? model.public_address : "Please wait for " + model.name + " to fully activate..." @@ -415,14 +415,14 @@ MultipageModal spacing: 5 Layout.fillWidth: true - DefaultText + DexLabel { text: qsTr("Private Key") font.pixelSize: Style.textSizeSmall2 color: Dex.CurrentTheme.foregroundColor2 } - DefaultText + DexLabel { id: privateKey font: DexTypo.body3 diff --git a/atomic_defi_design/Dex/Settings/SettingModal.qml b/atomic_defi_design/Dex/Settings/SettingModal.qml index 332e245c6b..61a67be74e 100644 --- a/atomic_defi_design/Dex/Settings/SettingModal.qml +++ b/atomic_defi_design/Dex/Settings/SettingModal.qml @@ -482,6 +482,32 @@ Qaterial.Dialog } } } + + // Post-order placement toggle + RowLayout + { + width: parent.width - 30 + anchors.horizontalCenter: parent.horizontalCenter + height: 50 + + DexLabel + { + Layout.alignment: Qt.AlignVCenter + Layout.fillWidth: true + font: DexTypo.subtitle1 + text: qsTr("Show orders after placement") + } + + Item { Layout.fillWidth: true } + + DexSwitch + { + Layout.alignment: Qt.AlignVCenter + Component.onCompleted: checked = API.app.settings_pg.postorder_enabled + onCheckedChanged: API.app.settings_pg.postorder_enabled = checked + } + } + } } Item @@ -532,7 +558,7 @@ Qaterial.Dialog text: qsTr("Ask system's password before sending coins ? (2FA)") } - DefaultSwitch + DexSwitch { checked: parseInt(atomic_settings2.value("2FA")) === 1 onCheckedChanged: @@ -699,15 +725,15 @@ Qaterial.Dialog { Layout.alignment: Qt.AlignVCenter Layout.fillWidth: true - text: qsTr("MM2 version") + text: qsTr("KDF version") } DexCopyableLabel { Layout.alignment: Qt.AlignVCenter - text: API.app.settings_pg.get_mm2_version() - onCopyNotificationTitle: qsTr("MM2 Version") - onCopyNotificationMsg: qsTr("MM2 Version copied to clipboard.") + text: API.app.settings_pg.get_kdf_version() + onCopyNotificationTitle: qsTr("KDF Version") + onCopyNotificationMsg: qsTr("KDF Version copied to clipboard.") } } diff --git a/atomic_defi_design/Dex/Sidebar/Bottom.qml b/atomic_defi_design/Dex/Sidebar/Bottom.qml index af9829b03a..838b2eddb7 100644 --- a/atomic_defi_design/Dex/Sidebar/Bottom.qml +++ b/atomic_defi_design/Dex/Sidebar/Bottom.qml @@ -154,7 +154,7 @@ MouseArea } } - DefaultSwitch + DexSwitch { id: privacySwitch diff --git a/atomic_defi_design/Dex/Sidebar/Center.qml b/atomic_defi_design/Dex/Sidebar/Center.qml index 89ab94df97..6783ec284f 100644 --- a/atomic_defi_design/Dex/Sidebar/Center.qml +++ b/atomic_defi_design/Dex/Sidebar/Center.qml @@ -12,9 +12,28 @@ MouseArea signal lineSelected(var lineType) - height: lineHeight * 5 + height: lineHeight * 4 hoverEnabled: true + Connections + { + target: API.app.timesyncCheckerService + + function onTimesyncInfoChanged() + { + if (!API.app.timesyncCheckerService.timesyncInfo) + { + _dexLine.timesyncInfo = false + if (currentLineType === Main.LineType.DEX) currentLineType = Main.LineType.Portfolio + root.lineSelected(Main.LineType.Portfolio); + } + else + { + _dexLine.timesyncInfo = true + } + } + } + Connections { target: parent.parent @@ -84,12 +103,15 @@ MouseArea FigurativeLine { id: _dexLine + property var timesyncInfo: API.app.timesyncCheckerService.timesyncInfo Layout.fillWidth: true type: Main.LineType.DEX + label.color: timesyncInfo ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.textDisabledColor label.text: qsTr("DEX") // isExpanded ? qsTr("DEX") : "" icon.source: General.image_path + "menu-exchange-white.svg" - onClicked: lineSelected(type) + onClicked: timesyncInfo ? lineSelected(type) : null + disabled_tt_text: timesyncInfo ? "" : qsTr("DEX is disabled due to system clock synchronization issues. Please check your device time settings.") } FigurativeLine @@ -106,7 +128,6 @@ MouseArea FigurativeLine { id: _fiatLine - label.enabled: false icon.enabled: false Layout.fillWidth: true diff --git a/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml b/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml index 540ca6e11b..a747a36e7f 100644 --- a/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml +++ b/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml @@ -1,12 +1,14 @@ import QtQuick 2.12 import "../Components" +import "../Constants" import Dex.Themes 1.0 as Dex // FigurativeLine acts the same as Line but contains a figurative icon on the left of its label Line { property alias icon: _icon + property string disabled_tt_text: "" DefaultImage { @@ -26,4 +28,13 @@ Line currentLineType === type && type != Main.LineType.Support ? Dex.CurrentTheme.sidebarLineTextSelected : Dex.CurrentTheme.foregroundColor } + + DexTooltip + { + visible: mouseArea.containsMouse && disabled_tt_text + delay: 500 + timeout: 5000 + text: disabled_tt_text + font.pixelSize: Style.textSizeSmall4 + } } diff --git a/atomic_defi_design/Dex/Sidebar/Top.qml b/atomic_defi_design/Dex/Sidebar/Top.qml index b73aebbc77..6b65331a55 100644 --- a/atomic_defi_design/Dex/Sidebar/Top.qml +++ b/atomic_defi_design/Dex/Sidebar/Top.qml @@ -70,7 +70,7 @@ MouseArea } } - DefaultText + DexLabel { id: versionLabel anchors.horizontalCenter: dexLogo.horizontalCenter diff --git a/atomic_defi_design/Dex/Themes/CurrentTheme.qml b/atomic_defi_design/Dex/Themes/CurrentTheme.qml index 94ef9960d9..809c3ccf99 100644 --- a/atomic_defi_design/Dex/Themes/CurrentTheme.qml +++ b/atomic_defi_design/Dex/Themes/CurrentTheme.qml @@ -212,7 +212,6 @@ ThemeData { addressBookTagColors[i] = Dex.Color.argbStrFromRgbaStr(addressBookTagColors[i]) } - okColor = Dex.Color.argbStrFromRgbaStr(themeData.okColor || defaultTheme.okColor); warningColor = Dex.Color.argbStrFromRgbaStr(themeData.warningColor || defaultTheme.warningColor); swapIconColor = Dex.Color.argbStrFromRgbaStr(themeData.swapIconColor || defaultTheme.swapIconColor); @@ -221,6 +220,7 @@ ThemeData receiverColorStart = Dex.Color.argbStrFromRgbaStr(themeData.receiverColorStart || defaultTheme.receiverColorStart); lineSeparatorColor = Dex.Color.argbStrFromRgbaStr(themeData.lineSeparatorColor || defaultTheme.lineSeparatorColor); + colorPlaceholderText = Dex.Color.argbStrFromRgbaStr(themeData.colorPlaceholderText || defaultTheme.colorPlaceholderText); } function loadLogo(themeName) @@ -341,6 +341,7 @@ ThemeData console.info("Dex.Themes.CurrentTheme.printValues.receiverColorStart : %1".arg(receiverColorStart)); console.info("Dex.Themes.CurrentTheme.printValues.lineSeparatorColor : %1".arg(lineSeparatorColor)); + console.info("Dex.Themes.CurrentTheme.printValues.colorPlaceholderText : %1".arg(colorPlaceholderText)); console.info("Dex.Themes.CurrentTheme.printValues.logoPath : %1".arg(logoPath)); console.info("Dex.Themes.CurrentTheme.printValues.bigLogoPath : %1".arg(bigLogoPath)); diff --git a/atomic_defi_design/Dex/Themes/DefaultTheme.js b/atomic_defi_design/Dex/Themes/DefaultTheme.js index 07467a9850..5582448551 100644 --- a/atomic_defi_design/Dex/Themes/DefaultTheme.js +++ b/atomic_defi_design/Dex/Themes/DefaultTheme.js @@ -127,6 +127,7 @@ function getHardcoded() okColor: "#00C058FF", warningColor: "#E52167FF", + colorTheme1: "#3CC9BFFF", senderColorStart: "#F85757FF", receiverColorStart: "#845FEFFF", @@ -134,6 +135,11 @@ function getHardcoded() arrowUpColor: "#F85757FF", arrowDownColor: "#845FEFFF", - lineSeparatorColor: "#CDD3DCFF" + lineSeparatorColor: "#CDD3DCFF", + + colorPlaceholderText: "#444444FF", + colorSelectedText: "#0E1021FF", + colorSelection: "#14bca6FF" + } } diff --git a/atomic_defi_design/Dex/Themes/ThemeData.qml b/atomic_defi_design/Dex/Themes/ThemeData.qml index a138eb816c..7c3bc69d5c 100644 --- a/atomic_defi_design/Dex/Themes/ThemeData.qml +++ b/atomic_defi_design/Dex/Themes/ThemeData.qml @@ -138,6 +138,9 @@ QtObject property color receiverColorStart property color lineSeparatorColor + property color colorPlaceholderText + property color colorSelectedText + property color colorSelection // Logos property string logoPath diff --git a/atomic_defi_design/Dex/Wallet/ClaimFaucetResultModal.qml b/atomic_defi_design/Dex/Wallet/ClaimFaucetResultModal.qml index 203658f13b..4a2af7fbd6 100644 --- a/atomic_defi_design/Dex/Wallet/ClaimFaucetResultModal.qml +++ b/atomic_defi_design/Dex/Wallet/ClaimFaucetResultModal.qml @@ -18,7 +18,7 @@ MultipageModal { titleText: claiming_faucet_rpc_result && claiming_faucet_rpc_result.status ? claiming_faucet_rpc_result.status : "" - DefaultText { + DexLabel { id: message width: parent.width text_value: claiming_faucet_rpc_result && claiming_faucet_rpc_result.message ? diff --git a/atomic_defi_design/Dex/Wallet/EnableCoinModal.qml b/atomic_defi_design/Dex/Wallet/EnableCoinModal.qml index d8f53a2d3f..711087996c 100644 --- a/atomic_defi_design/Dex/Wallet/EnableCoinModal.qml +++ b/atomic_defi_design/Dex/Wallet/EnableCoinModal.qml @@ -52,7 +52,7 @@ MultipageModal Layout.fillWidth: true Layout.fillHeight: true - DefaultText + DexLabel { id: _title Layout.topMargin: 5 @@ -175,7 +175,7 @@ MultipageModal Layout.preferredHeight: 18 } - DefaultText + DexLabel { Layout.leftMargin: 4 Layout.alignment: Qt.AlignVCenter @@ -225,7 +225,7 @@ MultipageModal Layout.topMargin: 6 Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - DefaultText + DexLabel { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter diff --git a/atomic_defi_design/Dex/Wallet/Main.qml b/atomic_defi_design/Dex/Wallet/Main.qml index 497e117274..dc90d3a153 100644 --- a/atomic_defi_design/Dex/Wallet/Main.qml +++ b/atomic_defi_design/Dex/Wallet/Main.qml @@ -124,7 +124,7 @@ Item } } - DefaultText + DexLabel { id: ticker_name Layout.topMargin: 0 @@ -143,7 +143,7 @@ Item Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter spacing: 2 - DefaultText + DexLabel { id: balance_title Layout.alignment: Qt.AlignHCenter @@ -152,7 +152,7 @@ Item color: headerTitleColor } - DefaultText + DexLabel { id: name_value Layout.alignment: Qt.AlignHCenter @@ -182,7 +182,7 @@ Item Layout.rightMargin: 10 spacing: 5 - DefaultText + DexLabel { id: price text_value: qsTr("Price") @@ -191,7 +191,7 @@ Item font.pixelSize: headerTitleFont } - DefaultText + DexLabel { text_value: { @@ -212,7 +212,7 @@ Item Layout.rightMargin: 10 spacing: 5 - DefaultText + DexLabel { id: change_24hr text_value: qsTr("Change 24hr") @@ -221,7 +221,7 @@ Item font.pixelSize: headerTitleFont } - DefaultText + DexLabel { id: change_24hr_value Layout.alignment: Qt.AlignHCenter @@ -243,7 +243,7 @@ Item Layout.rightMargin: 10 spacing: 5 - DefaultText + DexLabel { id: portfolio_title text_value: qsTr("Portfolio") @@ -252,7 +252,7 @@ Item font.pixelSize: headerTitleFont } - DefaultText + DexLabel { Layout.alignment: Qt.AlignHCenter text_value: @@ -300,7 +300,7 @@ Item Layout.preferredWidth: Layout.preferredHeight } - DefaultText + DexLabel { id: contract_address_title text_value: General.coinPlatform(api_wallet_page.ticker) + qsTr(" Contract Address") @@ -317,7 +317,7 @@ Item Layout.preferredHeight: General.coinContractAddress(api_wallet_page.ticker) ? headerSmallFont : 0 visible: General.coinContractAddress(api_wallet_page.ticker) !== "" - DefaultText + DexLabel { id: contract_address text_value: General.coinContractAddress(api_wallet_page.ticker) @@ -657,6 +657,53 @@ Item } } + // Proposals Button + Item + { + Layout.preferredWidth: 165 + Layout.preferredHeight: 40 + visible: current_ticker_infos.is_vote_coin + + DefaultButton + { + enabled: activation_pct == 100 + anchors.fill: parent + radius: 18 + label.text: qsTr("Vote Info") + label.font.pixelSize: 16 + content.anchors.left: content.parent.left + content.anchors.leftMargin: enabled ? 23 : 48 + content.anchors.rightMargin: 23 + + onClicked: { + let url = "https://vote.komodoplatform.com/" + api_wallet_page.ticker.toLowerCase() + "/"; + Qt.openUrlExternally(url); + } + + Row + { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 23 + + Qaterial.Icon + { + icon: Qaterial.Icons.vote + size: 24 + anchors.verticalCenter: parent.verticalCenter + color: "#2c87b9" + } + } + } + + // Faucet button error icon + DefaultAlertIcon + { + visible: activation_pct != 100 + tooltipText: api_wallet_page.ticker + qsTr(" Activation: " + activation_pct + "%") + } + } + Component.onCompleted: api_wallet_page.claimingFaucetRpcDataChanged.connect(onClaimFaucetRpcResultChanged) Component.onDestruction: api_wallet_page.claimingFaucetRpcDataChanged.disconnect(onClaimFaucetRpcResultChanged) function onClaimFaucetRpcResultChanged() { claimFaucetResultModal.open() } @@ -726,7 +773,7 @@ Item { Layout.fillWidth: true - DefaultText + DexLabel { Layout.fillWidth: true visible: !API.app.settings_pg.fetchingPublicKey @@ -930,13 +977,13 @@ Item scale: 0.5 } - DefaultText + DexLabel { - text_value: qsTr("Loading market data") + "..." + text_value: qsTr("Loading ticker chart data") + "..." } } - DefaultText + DexLabel { visible: !parent.ticker_supported text_value: qsTr("There is no chart data for this ticker yet") @@ -990,7 +1037,7 @@ Item anchors.centerIn: parent spacing: 24 - DefaultText + DexLabel { id: fetching_text_row Layout.topMargin: 24 diff --git a/atomic_defi_design/Dex/Wallet/SendModal.qml b/atomic_defi_design/Dex/Wallet/SendModal.qml index 2fcd8effc9..071cad3f17 100644 --- a/atomic_defi_design/Dex/Wallet/SendModal.qml +++ b/atomic_defi_design/Dex/Wallet/SendModal.qml @@ -47,7 +47,7 @@ MultipageModal function getCryptoAmount() { return _preparePage.cryptoSendMode ? input_amount.text : equivalentAmount.value } - function prepareSendCoin(address, amount, with_fees, fees_amount, is_special_token, gas_limit, gas_price, memo="") { + function prepareSendCoin(address, amount, with_fees, fees_amount, is_special_token, gas_limit, gas_price, memo="", ibc_source_channel="") { let max = parseFloat(current_ticker_infos.balance) === parseFloat(amount) // Save for later check async_param_max = max @@ -60,7 +60,7 @@ MultipageModal gas_price, gas_limit: gas_limit === "" ? 0 : parseInt(gas_limit) } - api_wallet_page.send(address, amount, max, with_fees, fees_info, memo) + api_wallet_page.send(address, amount, max, with_fees, fees_info, memo, ibc_source_channel) } function sendCoin() { @@ -168,6 +168,7 @@ MultipageModal if (result.error_code) { + console.log("Error code: " + result.error_code) root.close() toast.show(qsTr("Failed to send"), General.time_toast_important_error, result.error_message) } @@ -198,6 +199,7 @@ MultipageModal if(root.visible && broadcast_result !== "") { if(broadcast_result.indexOf("error") !== -1) { + console.log("Broadcast error: " + JSON.stringify(broadcast_result)) reset() showError(qsTr("Failed to Broadcast"), General.prettifyJSON(broadcast_result)) } @@ -256,19 +258,19 @@ MultipageModal { enabled: !root.is_send_busy - Layout.preferredWidth: 500 - Layout.preferredHeight: 44 + width: 500 + Layout.preferredHeight: 36 Layout.alignment: Qt.AlignHCenter color: input_address.background.color radius: input_address.background.radius - DefaultTextField + DexTextField { id: input_address width: 470 - height: 44 + height: 36 placeholderText: qsTr("Address of the recipient") forceFocus: true font: General.isZhtlc(api_wallet_page.ticker) ? DexTypo.body3 : DexTypo.body2 @@ -328,7 +330,7 @@ MultipageModal Item { Layout.fillWidth: true } - DefaultText + DexLabel { id: reason @@ -355,142 +357,90 @@ MultipageModal Item { Layout.fillWidth: true } } - // Amount to send - AmountField + RowLayout { - id: input_amount - - enabled: !root.is_send_busy - - Layout.alignment: Qt.AlignHCenter Layout.preferredWidth: 500 - Layout.preferredHeight: 44 - Layout.topMargin: 32 - - placeholderText: qsTr("Amount to send") - - onTextEdited: - { - if (text.length === 0) - { - text = ""; - return; - } - } - - DefaultText + Layout.preferredHeight: 36 + Layout.topMargin: 8 + Layout.alignment: Qt.AlignHCenter + + // Amount to send + AmountField { - anchors.right: maxBut.left - anchors.rightMargin: 10 - anchors.verticalCenter: parent.verticalCenter - - text: _preparePage.cryptoSendMode ? API.app.wallet_pg.ticker : API.app.settings_pg.current_currency - font.pixelSize: 16 - } + id: input_amount - Rectangle - { - id: maxBut - anchors.right: parent.right - anchors.rightMargin: 11 - anchors.verticalCenter: parent.verticalCenter - width: 46 - height: 23 - radius: 7 - color: maxButMouseArea.containsMouse ? Dex.CurrentTheme.buttonColorHovered : Dex.CurrentTheme.buttonColorEnabled + enabled: !root.is_send_busy + Layout.preferredWidth: equivalentAmount.visible ? 340 : 500 + Layout.preferredHeight: 36 - DefaultText - { - anchors.centerIn: parent - text: qsTr("MAX") - } + placeholderText: qsTr("Amount to send") - DefaultMouseArea + onTextEdited: { - id: maxButMouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: + if (text.length === 0) { - if (_preparePage.cryptoSendMode) - { - input_amount.text = API.app.get_balance_info_qstr(api_wallet_page.ticker); - } - else - { - let cryptoBalance = new BigNumber(API.app.get_balance_info_qstr(api_wallet_page.ticker)); - input_amount.text = cryptoBalance.multipliedBy(current_ticker_infos.current_currency_ticker_price).toFixed(8); - } + text = ""; + return; } } - } - } - - // Crypto/fiat switch - RowLayout - { - Layout.topMargin: 10 - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: 380 - - DefaultText - { - id: equivalentAmount - - property string value: "0" - enabled: !(new BigNumber(current_ticker_infos.current_currency_ticker_price).isLessThanOrEqualTo(0)) - visible: enabled - - text: + DexLabel { - if (!enabled) - { - return qsTr("Fiat amount: Unavailable"); - } - else if (_preparePage.cryptoSendMode) - { - return qsTr("Fiat amount: %1").arg(General.formatFiat('', value, API.app.settings_pg.current_fiat_sign)); - } - else - { - return qsTr("%1 amount: %2").arg(API.app.wallet_pg.ticker).arg(value); - } + anchors.right: maxBut.left + anchors.rightMargin: 10 + anchors.verticalCenter: parent.verticalCenter + + text: _preparePage.cryptoSendMode ? API.app.wallet_pg.ticker : API.app.settings_pg.current_currency + font.pixelSize: 16 } - Connections + Rectangle { - target: input_amount + id: maxBut + anchors.right: parent.right + anchors.rightMargin: 11 + anchors.verticalCenter: parent.verticalCenter + width: 46 + height: 23 + radius: 7 + color: maxButMouseArea.containsMouse ? Dex.CurrentTheme.buttonColorHovered : Dex.CurrentTheme.buttonColorEnabled - function onTextEdited() + DexLabel { - let imputAmount = new BigNumber(input_amount.text); - if (input_amount.text === "" || imputAmount.isLessThanOrEqualTo(0)) - equivalentAmount.value = "0" - else if (_preparePage.cryptoSendMode) - equivalentAmount.value = imputAmount.multipliedBy(current_ticker_infos.current_currency_ticker_price).toFixed(8); - else - equivalentAmount.value = imputAmount.dividedBy(current_ticker_infos.current_currency_ticker_price).toFixed(8); + anchors.centerIn: parent + text: qsTr("MAX") } - function onTextChanged() + DefaultMouseArea { - onTextEdited() + id: maxButMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: + { + if (_preparePage.cryptoSendMode) + { + input_amount.text = API.app.get_balance_info_qstr(api_wallet_page.ticker); + } + else + { + let cryptoBalance = new BigNumber(API.app.get_balance_info_qstr(api_wallet_page.ticker)); + input_amount.text = cryptoBalance.multipliedBy(current_ticker_infos.current_currency_ticker_price).toFixed(8); + } + } } } } - Item { } Rectangle { enabled: equivalentAmount.enabled visible: equivalentAmount.visible - Layout.alignment: Qt.AlignRight - Layout.preferredWidth: cryptoFiatSwitchText.width + cryptoFiatSwitchIcon.width + 20 - Layout.preferredHeight: 32 radius: 16 + Layout.preferredWidth: 150 + Layout.preferredHeight: 36 color: cryptoFiatSwitchMouseArea.containsMouse ? Dex.CurrentTheme.buttonColorHovered : Dex.CurrentTheme.buttonColorEnabled @@ -505,11 +455,11 @@ MultipageModal anchors.verticalCenter: parent.verticalCenter color: Dex.CurrentTheme.backgroundColor - DefaultText + DexLabel { id: fiat_symbol visible: _preparePage.cryptoSendMode && API.app.settings_pg.current_currency_sign != "KMD" - font.pixelSize: 18 + font.pixelSize: API.app.settings_pg.current_currency_sign.length == 1 ? 18 : 18 - API.app.settings_pg.current_currency_sign.length * 2 anchors.centerIn: parent text: API.app.settings_pg.current_currency_sign } @@ -518,13 +468,14 @@ MultipageModal { visible: !fiat_symbol.visible anchors.centerIn: parent - width: 18 - height: 18 - source: General.coinIcon(API.app.wallet_pg.ticker) + width: 16 + height: 16 + source: _preparePage.cryptoSendMode ? General.coinIcon(API.app.settings_pg.current_currency_sign) : General.coinIcon(API.app.wallet_pg.ticker) } } - DefaultText + // Crypto/fiat switch + DexLabel { id: cryptoFiatSwitchText anchors.left: cryptoFiatSwitchIcon.right @@ -547,12 +498,68 @@ MultipageModal { _preparePage.cryptoSendMode = !_preparePage.cryptoSendMode let temp = input_amount.text - input_amount.text = equivalentAmount.value; - equivalentAmount.value = temp; + input_amount.text = equivalentAmount.value + equivalentAmount.value = temp == "" ? "0" : temp } } } } + // Crypto/fiat values + RowLayout + { + Layout.topMargin: 3 + Layout.bottomMargin: 6 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: 400 + + DexLabel + { + id: equivalentAmount + + property string value: "0" + enabled: !(new BigNumber(current_ticker_infos.current_currency_ticker_price).isLessThanOrEqualTo(0)) + visible: enabled + color: Dex.CurrentTheme.textPlaceholderColor + + text: + { + if (!enabled) + { + return qsTr("Fiat amount: Unavailable"); + } + else if (_preparePage.cryptoSendMode) + { + return qsTr("Fiat amount: %1").arg(General.formatFiat('', value, API.app.settings_pg.current_fiat_sign)); + } + else + { + return qsTr("%1 amount: %2").arg(API.app.wallet_pg.ticker).arg(value); + } + } + + Connections + { + target: input_amount + + function onTextEdited() + { + let inputAmount = new BigNumber(input_amount.text); + if (input_amount.text === "" || inputAmount.isLessThanOrEqualTo(0)) + equivalentAmount.value = "0" + else if (_preparePage.cryptoSendMode) + equivalentAmount.value = inputAmount.multipliedBy(current_ticker_infos.current_currency_ticker_price).toFixed(8); + else + equivalentAmount.value = inputAmount.dividedBy(current_ticker_infos.current_currency_ticker_price).toFixed(8); + } + + function onTextChanged() + { + onTextEdited() + } + } + } + + } // Memo DefaultRectangle @@ -561,35 +568,96 @@ MultipageModal enabled: !root.is_send_busy Layout.preferredWidth: 500 - Layout.preferredHeight: 44 + Layout.preferredHeight: 36 Layout.alignment: Qt.AlignHCenter color: input_memo.background.color radius: input_memo.background.radius - DefaultTextField + DexTextField { id: input_memo width: 470 - height: 44 - placeholderText: qsTr("Enter memo") + height: 36 + placeholderText: qsTr("Enter memo (optional)") forceFocus: true font: General.isZhtlc(api_wallet_page.ticker) ? DexTypo.body3 : DexTypo.body2 } } + // Custom IBC Channel switch + ColumnLayout + { + visible: (["TENDERMINT", "TENDERMINTTOKEN"].includes(current_ticker_infos.type)) + Layout.preferredWidth: 400 + Layout.alignment: Qt.AlignHCenter + Layout.topMargin: 12 + + RowLayout + { + DexSwitch + { + id: custom_ibc_switch + visible: (["TENDERMINT", "TENDERMINTTOKEN"].includes(current_ticker_infos.type)) + font.pixelSize: 14 + enabled: !root.is_send_busy + Layout.preferredWidth: 220 + onCheckedChanged: input_ibc_channel_id.text = "" + labelWidth: 200 + label.text: qsTr("Use Custom IBC Channel") + label.wrapMode: Label.NoWrap + } + + DexTextField + { + id: input_ibc_channel_id + visible: custom_ibc_switch.checked + Layout.preferredWidth: 170 + Layout.preferredHeight: 36 + placeholderText: qsTr("Enter channel ID") + forceFocus: true + font: DexTypo.body3 + } + } + + // Add `?` icon here + // https://komodoplatform.com/en/docs/komodo-wallet/guides/how-to-find-the-right-ibc-channel-for-transfers/ + + // Custom IBC warning + DexLabel + { + font.pixelSize: 12 + visible: custom_ibc_switch.checked + Layout.alignment: Qt.AlignHCenter + horizontalAlignment: DexLabel.AlignHCenter + color: Dex.CurrentTheme.warningColor + text_value: qsTr("Only use custom IBC channel if you know what you are doing! ") + } + + // CEX memo warning + DexLabel + { + font.pixelSize: 12 + Layout.alignment: Qt.AlignHCenter + horizontalAlignment: DexLabel.AlignHCenter + color: Dex.CurrentTheme.warningColor + text_value: qsTr("Avoid IBC transfers to centralized exchanges, as assets may be lost.") + } + } + ColumnLayout { visible: General.getCustomFeeType(current_ticker_infos) - Layout.preferredWidth: 380 + Layout.preferredWidth: 400 Layout.alignment: Qt.AlignHCenter - Layout.topMargin: 32 + Layout.topMargin: 12 // Custom fees switch - DefaultSwitch + DexSwitch { id: custom_fees_switch + font.pixelSize: 14 visible: !General.isZhtlc(api_wallet_page.ticker) enabled: !root.is_send_busy Layout.preferredWidth: 260 @@ -598,40 +666,6 @@ MultipageModal label.text: qsTr("Enable Custom Fees") label.wrapMode: Label.NoWrap } - - RowLayout - { - visible: custom_fees_switch.checked - // Custom fees warning - DefaultText - { - font.pixelSize: 14 - Layout.alignment: Qt.AlignHCenter - horizontalAlignment: DefaultText.AlignHCenter - color: Dex.CurrentTheme.warningColor - } - - DefaultText - { - visible: input_custom_fees.visible - font.pixelSize: 14 - Layout.alignment: Qt.AlignHCenter - horizontalAlignment: DefaultText.AlignHCenter - color: Dex.CurrentTheme.warningColor - text_value: qsTr("Only use custom fees if you know what you are doing! ") - } - - DefaultText - { - visible: input_custom_fees_gas.visible - font.pixelSize: 14 - Layout.alignment: Qt.AlignHCenter - horizontalAlignment: DefaultText.AlignHCenter - color: Dex.CurrentTheme.warningColor - text_value: qsTr("Only use custom fees if you know what you are doing! ") + General.cex_icon - DefaultInfoTrigger { triggerModal: gas_info_modal } - } - } } // Custom Fees section @@ -652,11 +686,11 @@ MultipageModal enabled: !root.is_send_busy - Layout.preferredWidth: 380 - Layout.preferredHeight: 38 + Layout.preferredWidth: 400 + Layout.preferredHeight: 36 Layout.alignment: Qt.AlignHCenter - placeholderText: qsTr("Enter the custom fee") + " [" + api_wallet_page.ticker + "]" + placeholderText: qsTr("Enter the custom fee") + " (" + api_wallet_page.ticker + "/kb)" } // Token coins @@ -673,8 +707,8 @@ MultipageModal enabled: !root.is_send_busy - Layout.preferredWidth: 380 - Layout.preferredHeight: 38 + Layout.preferredWidth: 400 + Layout.preferredHeight: 36 placeholderText: qsTr("Gas Limit") } @@ -687,35 +721,66 @@ MultipageModal enabled: !root.is_send_busy - Layout.preferredWidth: 380 - Layout.preferredHeight: 38 + Layout.preferredWidth: 400 + Layout.preferredHeight: 36 placeholderText: qsTr("Gas price") + " [" + General.tokenUnitName(current_ticker_infos) + "]" } } + + // Custom fees warning + DexLabel + { + visible: input_custom_fees.visible + + color: Dex.CurrentTheme.warningColor + font.pixelSize: 12 + horizontalAlignment: DexLabel.AlignHCenter + Layout.alignment: Qt.AlignHCenter + wrapMode: Label.Wrap + + text_value: qsTr("Only use custom fees if you know what you are doing! ") + } + + // Custom gas fees warning + DexLabel + { + visible: input_custom_fees_gas.visible + + color: Dex.CurrentTheme.warningColor + font.pixelSize: 12 + horizontalAlignment: DexLabel.AlignHCenter + Layout.alignment: Qt.AlignHCenter + wrapMode: Label.Wrap + + text_value: qsTr("Only use custom fees if you know what you are doing! ") + General.cex_icon + DefaultInfoTrigger { triggerModal: gas_info_modal } + } + // Fee is higher than amount error - DefaultText + DexLabel { id: fee_error visible: feeIsHigherThanAmount() + color: Dex.CurrentTheme.warningColor + font.pixelSize: 12 + horizontalAlignment: DexLabel.AlignHCenter Layout.alignment: Qt.AlignHCenter - horizontalAlignment: DefaultText.AlignHCenter - wrapMode: Label.Wrap - color: Style.colorRed + text_value: qsTr("Custom Fee can't be higher than the amount") + "\n" + qsTr("You have %1", "AMT TICKER").arg(General.formatCrypto("", API.app.get_balance_info_qstr(General.getFeesTicker(current_ticker_infos)), General.getFeesTicker(current_ticker_infos))) } } // Not enough funds error - DefaultText + DexLabel { - Layout.topMargin: 16 + Layout.topMargin: 12 Layout.alignment: Qt.AlignHCenter - horizontalAlignment: DefaultText.AlignHCenter + horizontalAlignment: DexLabel.AlignHCenter wrapMode: Label.Wrap visible: !fee_error.visible && !hasFunds() @@ -735,11 +800,11 @@ MultipageModal } // Withdraw status - DefaultText + DexLabel { - Layout.topMargin: 16 + Layout.topMargin: 12 Layout.alignment: Qt.AlignHCenter - horizontalAlignment: DefaultText.AlignHCenter + horizontalAlignment: DexLabel.AlignHCenter wrapMode: Label.Wrap visible: General.isZhtlc(api_wallet_page.ticker) && withdraw_status != "Complete" color: Dex.CurrentTheme.foregroundColor @@ -751,15 +816,15 @@ MultipageModal RowLayout { Layout.alignment: Qt.AlignHCenter - Layout.topMargin: 20 + Layout.topMargin: 16 CancelButton { text: qsTr("Cancel") Layout.alignment: Qt.AlignLeft - Layout.preferredWidth: parent.width / 100 * 48 - Layout.preferredHeight: 48 + Layout.preferredWidth: parent.width / 100 * 42 + Layout.preferredHeight: 42 label.font.pixelSize: 16 radius: 18 @@ -774,7 +839,7 @@ MultipageModal enabled: fieldAreFilled() && hasFunds() && !errorView && !root.is_send_busy Layout.alignment: Qt.AlignRight - Layout.preferredWidth: parent.width / 100 * 48 + Layout.preferredWidth: parent.width / 100 * 42 text: qsTr("Prepare") @@ -786,7 +851,8 @@ MultipageModal General.isSpecialToken(current_ticker_infos), input_custom_fees_gas.text, input_custom_fees_gas_price.text, - input_memo.text + input_memo.text, + input_ibc_channel_id.text ) } } diff --git a/atomic_defi_design/Dex/Wallet/SendModalContactList.qml b/atomic_defi_design/Dex/Wallet/SendModalContactList.qml index 9e9bbd58aa..5008db9633 100644 --- a/atomic_defi_design/Dex/Wallet/SendModalContactList.qml +++ b/atomic_defi_design/Dex/Wallet/SendModalContactList.qml @@ -26,7 +26,7 @@ MultipageModal titleText: qsTr("Select a contact with an %1 address").arg(ticker) // Searchbar - DefaultTextField + DexTextField { Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true @@ -71,7 +71,7 @@ MultipageModal } } - DefaultText // Contact Name + DexLabel // Contact Name { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left @@ -81,7 +81,7 @@ MultipageModal elide: Qt.ElideRight } - DefaultText // Contact Addresses Count + DexLabel // Contact Addresses Count { anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right @@ -138,7 +138,7 @@ MultipageModal Layout.fillWidth: true spacing: 0 - DefaultText + DexLabel { Layout.leftMargin: addressesView.columnsMargin Layout.preferredWidth: addressesView.nameColumnWidth @@ -146,7 +146,7 @@ MultipageModal color: Dex.CurrentTheme.foregroundColor2 } - DefaultText + DexLabel { Layout.leftMargin: addressesView.columnsMargin text: qsTr("Address") @@ -179,7 +179,7 @@ MultipageModal } } - DefaultText + DexLabel { id: addressKeyLabel width: addressesView.nameColumnWidth @@ -190,7 +190,7 @@ MultipageModal elide: Qt.ElideRight } - DefaultText + DexLabel { anchors.verticalCenter: parent.verticalCenter anchors.left: addressKeyLabel.right diff --git a/atomic_defi_design/Dex/Wallet/SendResult.qml b/atomic_defi_design/Dex/Wallet/SendResult.qml index 8ac93c37a5..c7db8ebd8f 100644 --- a/atomic_defi_design/Dex/Wallet/SendResult.qml +++ b/atomic_defi_design/Dex/Wallet/SendResult.qml @@ -16,7 +16,7 @@ MultipageModalContent property string custom_amount property alias tx_hash: tx_hash.text_value - titleText: qsTr("Transaction Complete!") + titleText: qsTr("Transaction Broadcast!") // Transaction Hash TitleText diff --git a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml index ab69b7cba4..dc4b12ed63 100644 --- a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml +++ b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml @@ -31,7 +31,7 @@ MultipageModal titleText: qsTr("Transaction Details") // Warning for spam/poison transactions - DefaultText + DexLabel { id: warning_text visible: is_spam @@ -43,7 +43,7 @@ MultipageModal } // Warning for spam/poison transactions - DefaultText + DexLabel { id: warning_text2 visible: is_spam @@ -124,7 +124,7 @@ MultipageModal TextEditWithTitle { title: qsTr("Date") - text: !details ? "" : details.timestamp === 0 ? qsTr("Unconfirmed"): details.date + text: !details ? "" : details.timestamp === 0 ? qsTr("Awaiting confirmation"): details.timestamp label.font.pixelSize: 13 } diff --git a/atomic_defi_design/Dex/main.qml b/atomic_defi_design/Dex/main.qml index 81bea29475..d11a417ade 100644 --- a/atomic_defi_design/Dex/main.qml +++ b/atomic_defi_design/Dex/main.qml @@ -207,7 +207,7 @@ DexWindow anchors.verticalCenter: parent.verticalCenter } - DefaultText + DexLabel { id: _label text: API.app.wallet_mgr.wallet_default_name ?? "" diff --git a/atomic_defi_design/assets/languages/atomic_defi_de.ts b/atomic_defi_design/assets/languages/atomic_defi_de.ts index bc1f6fc053..f85da88fbd 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_de.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_de.ts @@ -242,7 +242,7 @@ App - + Recover Funds Result Ergebnis der Rückerstattung der Geldmittel @@ -475,27 +475,32 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 Center - + Portfolio Portfolio - + Wallet Brieftasche - + DEX DEX - + + DEX is disabled due to system clock synchronization issues. Please check your device time settings. + + + + Address Book Adressbuch - + Fiat Fiat @@ -516,17 +521,17 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 Chart - - Loading market data - Laden von Marktdaten + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -760,83 +765,93 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 ConfirmTradeModal - + Confirm Exchange Details Bestätigen Sie die Austausch-Details - + Trade price is more than 50% different to CEX! Confirm? Der Handelspreis unterscheidet sich um mehr als 50% vom CEX-Preis. Bestätigen? - + This swap request can not be undone and is a final event! Diese Tauschanfrage kann nicht rückgängig gemacht werden und ist ein endgültiges Ereignis! - + This transaction can take up to 60 mins - DO NOT close this application! Diese Transaktion kann bis zu 60 Minuten dauern - schließen Sie diese Anwendung NICHT! - + Loading fees... Lade Gebühren... - + <b>Total %1 fees:</b> <b>Gesamt %1 Gebühren:</b> - + Security configuration Sicherheitskonfiguration - + %1 confirmations for incoming %2 transactions %1 Bestätigungen für eingehende %2 Transaktionen - + Read more about dPoW Lesen Sie mehr über dPoW - + + Cancel all existing orders for %1/%2? + + + + + Good until cancelled (order will remain on orderbook until filled or cancelled) + + + + Use custom protection settings for incoming %1 transactions TICKER Benutzerdefinierte Schutzeinstellungen für eingehende %1 Transaktionen verwenden - + Enable Komodo dPoW security Komodo dPoW-Sicherheit aktivieren - + dPoW protected dPoW-gesichert - + Required Confirmations Erforderliche Bestätigungen - + Warning, this atomic swap is not dPoW protected! Achtung, dieser Atomic Swap ist nicht dPoW-geschützt! - + Cancel Abbrechen - + Confirm Bestätigen @@ -1412,7 +1427,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 General - + %n day(s) @@ -1420,7 +1435,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nd day @@ -1429,7 +1444,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nh hours @@ -1438,7 +1453,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nm minutes @@ -1447,7 +1462,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %ns seconds @@ -1456,7 +1471,7 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + %nms milliseconds @@ -1465,117 +1480,117 @@ Beispiel: Kennwort = 1234 Suffix=56 Eingabe beim Login=123456 - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - - %1 balance is zero + + Balance is zero! - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Mindesthandelsbetrag - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1754,17 +1769,17 @@ Try again or select 'Allow custom seed' to continue. List - + Funds are recoverable Geldmittel sind erstattungsfähig - Best Orders - Die günstigsten Order + Best Orders for %1 + - + Enter volume to see best orders. @@ -1772,17 +1787,27 @@ Try again or select 'Allow custom seed' to continue. ListDelegate - + %1 is not enabled - Do you want to enable it to be able to select %2 best orders ?<br><a href='#'>Yes</a> - <a href='#no'>No</a> %1 ist nicht aktiviert - Möchten Sie es aktivieren, um die günstigsten Order von %2 auswählen zu können? <br><a href='#'>Ja</a> - <a href='#no'>Nein</a> - + %1 is not enabled - Please enable it through the coin activation menu - + + Orderbook is disabled in privacy mode + + + + + Orderbook is disabled while creating maker orders + + + + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 Für diese Order ist ein Mindestbetrag von %1 %2 erforderlich. <br>Ihr Guthaben reicht nicht aus.<br> %3 @@ -1804,8 +1829,8 @@ Try again or select 'Allow custom seed' to continue. - Initializing MM2 - MM2 initialisieren + Initializing KDF + @@ -1914,7 +1939,7 @@ They will be removed from the orderbook until you log in again. Empfangen - + Swap Tausch @@ -1940,92 +1965,77 @@ They will be removed from the orderbook until you log in again. Faucet - - - + + Vote Info + + + + + + Public Key Öffentlicher Schlüssel - + Copied to Clipboard In die Zwischenablage kopiert - + Explore - - Loading market data - Laden von Marktdaten - - - + There is no chart data for this ticker yet Für diesen Ticker liegen noch keine Chartdaten vor - + Fetching transactions... Transaktionen werden abgerufen... - + No transactions available. - + Please wait, %1 is %2 - - % activated... + + Loading ticker chart data - - Trading Information - Handelsinformationen + + % activated... + - + Chart Chart - - + + Orders Order - - + + History Historie - - - Place Order - Order platzieren - - - - Order Selected - Order ausgewählt - - - - START SWAP - TAUSCH STARTEN - - + Address Book Adressbuch @@ -2050,36 +2060,64 @@ They will be removed from the orderbook until you log in again. Schlagworte - + + No contacts found. + + + + Edit Bearbeiten - + Delete Löschen - + address copied to clipboard Adresse in die Zwischenablage kopiert - + This contact does not have any registered address. Dieser Kontakt hat keine registrierte Adresse. + + + Taker Order + Taker-Order + + + + Maker Order + Maker-Order + + + + Market + + + Orderbook + + + + + Best Orders + Die günstigsten Order + MarketModeSelector - + Sell %1 TICKER %1 Verkaufen - + Buy %1 TICKER %1 Kaufen @@ -2513,95 +2551,117 @@ They will be removed from the orderbook until you log in again. OrderForm - + Price Preis - + Reduce 1% relative to CEX market price. - + Use CEX market price. - + Increase 1% relative to CEX market price. - + Send Senden - + Receive Empfangen - + Max Max - + Swap 25% of your tradable balance. - + + + + Diasble privacy mode to trade + + + + Swap 50% of your tradable balance. - + Swap 100% of your tradable balance. - + Min Volume - + Min amount to sell - + Min amount to receive - + Minimum accepted trade equals 10% of order volume. - + Minimum accepted trade equals 25% of order volume. - + Minimum accepted trade equals 50% of order volume. - + Min volume: Mindestvolumen: - + Use custom minimum trade amount Benutzerdefinierten Mindesthandelsbetrag verwenden + + + Order Selected + Order ausgewählt + + + + CREATE MAKER SWAP + + + + + START TAKER SWAP + + OrderLine @@ -2622,104 +2682,114 @@ They will be removed from the orderbook until you log in again. OrderModal - + Order Type Orderart - + Maker Order Maker-Order - + Taker Order Taker-Order - + Refund State Rückerstattungsstatus - + Your swap failed but the auto-refund process for your payment started already. Please wait and keep application opened until you receive your payment back Ihr Umtausch ist fehlgeschlagen, aber der automatische Rückerstattungsprozess für Ihre Zahlung hat bereits begonnen. Bitte warten Sie und lassen Sie die Anwendung geöffnet, bis Sie Ihre Zahlung zurückerhalten - + Date Datum - + Error ID Fehler-ID - - + + Error Log Fehlerprotokoll - + Close Schließen - + Cancel Order Order Abbrechen - - + + Min Volume + + + + + Max Volume + + + + + Swap ID Swap ID - + Maker Payment Sent Transaction ID Maker-Zahlung gesendet: Transaktions-ID - + Maker Payment Spent Transaction ID Maker-Zahlung ausgegeben: Transaktions-ID - + Maker Payment TXID Maker-Zahlung: TXID - + Taker Payment Spent Transaction ID Taker-Zahlung ausgegeben: Transaktions-ID - + Taker Payment Sent Transaction ID Taker-Zahlung gesendet: Transaktions-ID - + Taker Payment TXID Taker-Zahlung: TXID - + Recover Funds Rückerstattung der Geldmittel - + Refunding... Rückzahlung… - + View on Explorer Ansicht im Explorer @@ -2733,10 +2803,9 @@ They will be removed from the orderbook until you log in again. - The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available. + The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available. Please select a new order. - Die ausgewählte Order existiert nicht mehr! Sie wurde möglicherweise zugeordnet oder storniert und es ist keine Order mit einem besseren Preis verfügbar. -Bitte wählen Sie eine neue Order aus. + @@ -2768,22 +2837,22 @@ Bitte wählen Sie eine neue Order aus. Filter anwenden - + Cancel All Alles stornieren - + From Von - + To Bis - + Please choose the CSV export name and location Bitte wählen Sie den CSV-Exportnamen und den Speicherort aus @@ -2888,23 +2957,23 @@ Bitte wählen Sie eine neue Order aus. Ausgewählt - + Expensive Teuer - + Expedient Sinnvoll - + %1 compared to CEX PRICE_DIFF% %1 im Vergleich zu CEX - + CEXchange rate CEX-Wechselkurs @@ -2927,17 +2996,17 @@ Bitte wählen Sie eine neue Order aus. CEX-Wechselkurs - + Expensive Teuer - + Expedient Sinnvoll - + %1 compared to CEX PRICE_DIFF% %1 im Vergleich zu CEX @@ -2946,12 +3015,12 @@ Bitte wählen Sie eine neue Order aus. ProView - + Failed to place the order Die Order konnte nicht platziert werden - + Placed the order Order platziert @@ -3136,172 +3205,192 @@ Bitte wählen Sie eine neue Order aus. SendModal - + Failed to send Fehler beim Senden - + Prepare to send Versandvorbereitung von - + Address of the recipient Adresse des Empfängers - + Amount to send Zu sendender Betrag - + Gas price Gas Preis - + Cancel Abbrechen - + Recipient's address Empfängeradresse - + The address has to be mixed case. Die Adresse muss Groß-/Kleinschreibung sein. - + Failed to Broadcast - + Fix Korrigieren - + MAX MAX - + Fiat amount: Unavailable Fiat-Betrag: Nicht verfügbar - + Fiat amount: %1 Fiat-Betrag: %1 - + %1 amount: %2 %1 Betrag: %2 - + Specify in Fiat In Fiat angeben - + Specify in Crypto In Krypto angeben - - Enter memo - - - - + Enable Custom Fees Benutzerdefinierte Gebühren - + Enter the custom fee Geben Sie die benutzerdefinierte Gebühr ein - + Gas Limit Gas Limit - + Custom Fee can't be higher than the amount Die benutzerdefinierten Gebühren dürfen nicht höher sein als der Betrag - + Not enough funds. Nicht genug Geldmittel. - - + + You have %1 AMT TICKER Sie haben %1 - - + + Enter memo (optional) + + + + + Use Custom IBC Channel + + + + + Enter channel ID + + + + + Only use custom IBC channel if you know what you are doing! + + + + + Avoid IBC transfers to centralized exchanges, as assets may be lost. + + + + + Only use custom fees if you know what you are doing! - + Prepare Vorbereiten - - + + Send Senden - + %1 address TICKER - + copied to clipboard. In die Zwischenablage kopiert - + Amount Menge - + Memo - + Fees Gebühren - + Date Datum - + Back Zurück @@ -3352,11 +3441,6 @@ Bitte wählen Sie eine neue Order aus. SendResult - - - Transaction Complete! - Transaktion abgeschlossen! - %1 txid @@ -3405,6 +3489,11 @@ Bitte wählen Sie eine neue Order aus. Transaction Hash Transaktions-Hash + + + Transaction Broadcast! + + Close @@ -3420,7 +3509,7 @@ Bitte wählen Sie eine neue Order aus. SettingModal - + Cancel Abbrechen @@ -3515,63 +3604,83 @@ Bitte wählen Sie eine neue Order aus. Design zu %1 geändert - + + Show orders after placement + + + + Disable 2FA? 2FA deaktivieren? - + Enter your wallet password to confirm Geben Sie zur Bestätigung das Kennwort ihrer Brieftasche ein - + Type password Kennwort eingeben - + 2FA status 2FA Status - + 2FA disabled successfully 2FA erfolgreich deaktiviert - - + + Ok Ok - + Wrong password! Falsches Kennwort! - + Wallet password is incorrect Kennwort der Brieftasche ist falsch - + Reuse static RPC password - + Application Version Anwendungsversion - + copied to clipboard In die Zwischenablage kopiert - + + KDF version + + + + + KDF Version + + + + + KDF Version copied to clipboard. + + + + Search for Update @@ -3593,100 +3702,85 @@ Bitte wählen Sie eine neue Order aus. - + Confirm Bestätigen - + Ask system's password before sending coins ? (2FA) Vor dem Senden von Coins nach dem Kennwort des Systems fragen? (2FA) - + View seed and private keys Seed- und privaten Schlüsseln anzeigen - - + + Show Zeigen - + Setup Camouflage Password Tarnkennwort einrichten - + Open Öffnen - + Disclaimer and ToS Haftungsausschluss und Nutzungsbedingungen - + Application version Anwendungsversion - - MM2 version - MM2 Version - - - - MM2 Version - MM2 Version - - - - MM2 Version copied to clipboard. - MM2 Version in die Zwischenablage kopiert. - - - - + + RPC Port - + RPC Port copied to clipboard. - - + + Peer ID - + Peer ID copied to clipboard. - + Qt version Qt Version - + Qt Version Qt Version - + Qt Version copied to clipboard. Qt Version in die Zwischenablage kopiert. - + Logout Abmelden @@ -3755,7 +3849,7 @@ Bitte wählen Sie eine neue Order aus. Fiat Balance - + No Selectable coin. Kein wählbarer Coin. @@ -4105,7 +4199,7 @@ There is a toggle in settings where you can turn on/off the display of these tra Toast - + Click here to see the details Klicken Sie hier, um die Details anzuzeigen @@ -4151,32 +4245,32 @@ There is a toggle in settings where you can turn on/off the display of these tra Von - + Entered amount must be higher than 0. - + Select an order. - + MAX MAX - + To Nach - + Pick an order Order auswählen - + Price Preis @@ -4196,68 +4290,79 @@ There is a toggle in settings where you can turn on/off the display of these tra %1 - + + Balance: - + + **** + + + + Pick a coin Wählen Sie einen Coin - + SWAP NOW JETZT TAUSCHEN - + Failed to place the order Die Order konnte nicht platziert werden - + Placed the order Order platziert - - + + Disable privacy mode to trade. + + + + + Search coins - + Min Value - + Hide disabled coins - + No buy orders found for %1. Keine Kauforder für %1 gefunden. - + You can check later or try to sell a different coin. Sie können später nachsehen oder versuchen, einen anderen Coin zu verkaufen. - + Calculating fee estimate... Geschätzten Gebühren werden berechnet... - + Total %1 fees: %1 Gesamtgebühren: - + %2 (%3) %2 (%3) @@ -4265,39 +4370,29 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings Pro-Ansicht Einstellungen - + Display Settings Bildschirmeinstellungen - - Ticker Selectors - Ticker Selektoren - - - - Trading Information - Handelsinformationen - - - + Order Book - Orderbuch + Orderbuch - - Best Orders - Beste Order + + Order Form + - - Place Order - Order platzieren + + Trading Information + Handelsinformationen @@ -4335,11 +4430,6 @@ There is a toggle in settings where you can turn on/off the display of these tra Date Datum - - - Unconfirmed - Unbestätigt - Transaction Hash @@ -4396,6 +4486,11 @@ There is a toggle in settings where you can turn on/off the display of these tra To address Nach Adresse + + + Awaiting confirmation + + Notes @@ -4452,12 +4547,12 @@ There is a toggle in settings where you can turn on/off the display of these tra Vertical - Order Book - Orderbuch + %1 Orderbook + - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4574,7 +4669,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. @@ -4597,47 +4692,47 @@ This might take a few minutes... Sie benötigen %1, um das Benzin für %2 Transaktionen zu bezahlen. - + Checksum verification failed for %1. Überprüfung der Prüfsumme für %1 fehlgeschlagen. - + Invalid checksum for %1. Click the button to convert to mixed case address. Ungültige Prüfsumme für %1. Klicken Sie auf die Schaltfläche, um die Adresse in Groß-/Kleinschreibung umzuwandeln. - + Legacy address used for %1. Click the button to convert to a Cashaddress. Legacy-Adresse für %1 verwendet. Klicken Sie auf die Schaltfläche, um sie in eine Cashadresse umzuwandeln. - + %1 address must be prefixed with 0x %1 Adresse muss 0x vorangestellt werden - + %1 address length is invalid, please use a valid address. Länge der %1 Adresse ist ungültig, bitte verwenden Sie eine gültige Adresse. - + %1 address is invalid. %1 Adresse ist ungültig. - + Invalid checksum. Ungültige Prüfsumme. - + %1 address has invalid prefixes. %1 Adresse hat ungültige Vorsilben. - + Backend error: %1 Backend Fehler: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_en.ts b/atomic_defi_design/assets/languages/atomic_defi_en.ts index d81cf703c8..edfe6724dc 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_en.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_en.ts @@ -242,7 +242,7 @@ App - + Recover Funds Result @@ -474,27 +474,32 @@ Center - + Portfolio - + Wallet - + DEX - + + DEX is disabled due to system clock synchronization issues. Please check your device time settings. + + + + Address Book - + Fiat @@ -515,17 +520,17 @@ Chart - - Loading market data + + Loading pair chart data - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -759,83 +764,93 @@ ConfirmTradeModal - + Confirm Exchange Details - + Trade price is more than 50% different to CEX! Confirm? - + This swap request can not be undone and is a final event! - + This transaction can take up to 60 mins - DO NOT close this application! - + Loading fees... - + <b>Total %1 fees:</b> - + Security configuration - + %1 confirmations for incoming %2 transactions - + Read more about dPoW - + + Cancel all existing orders for %1/%2? + + + + + Good until cancelled (order will remain on orderbook until filled or cancelled) + + + + Use custom protection settings for incoming %1 transactions TICKER - + Enable Komodo dPoW security - + dPoW protected - + Required Confirmations - + Warning, this atomic swap is not dPoW protected! - + Cancel Cancel - + Confirm @@ -1411,7 +1426,7 @@ General - + %n day(s) @@ -1419,7 +1434,7 @@ - + %nd day @@ -1428,7 +1443,7 @@ - + %nh hours @@ -1437,7 +1452,7 @@ - + %nm minutes @@ -1446,7 +1461,7 @@ - + %ns seconds @@ -1455,7 +1470,7 @@ - + %nms milliseconds @@ -1464,117 +1479,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - - %1 balance is zero + + Balance is zero! - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1753,17 +1768,17 @@ Try again or select 'Allow custom seed' to continue. List - + Funds are recoverable - Best Orders + Best Orders for %1 - + Enter volume to see best orders. @@ -1771,17 +1786,27 @@ Try again or select 'Allow custom seed' to continue. ListDelegate - + %1 is not enabled - Do you want to enable it to be able to select %2 best orders ?<br><a href='#'>Yes</a> - <a href='#no'>No</a> - + %1 is not enabled - Please enable it through the coin activation menu - + + Orderbook is disabled in privacy mode + + + + + Orderbook is disabled while creating maker orders + + + + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 @@ -1803,7 +1828,7 @@ Try again or select 'Allow custom seed' to continue. - Initializing MM2 + Initializing KDF @@ -1913,7 +1938,7 @@ They will be removed from the orderbook until you log in again. - + Swap @@ -1939,92 +1964,77 @@ They will be removed from the orderbook until you log in again. - - - - Public Key + + Vote Info - - Copied to Clipboard + + + + Public Key - - Explore + + Copied to Clipboard - - Loading market data + + Explore - + There is no chart data for this ticker yet - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - - % activated... + + Loading ticker chart data - - Trading Information + + % activated... - + Chart - - + + Orders - - + + History - - - Place Order - - - - - Order Selected - - - - - START SWAP - - - + Address Book @@ -2049,36 +2059,64 @@ They will be removed from the orderbook until you log in again. - + + No contacts found. + + + + Edit - + Delete - + address copied to clipboard - + This contact does not have any registered address. + + + Taker Order + + + + + Maker Order + + + + + Market + + + Orderbook + + + + + Best Orders + + MarketModeSelector - + Sell %1 TICKER - + Buy %1 TICKER @@ -2512,95 +2550,117 @@ They will be removed from the orderbook until you log in again. OrderForm - + Price - + Reduce 1% relative to CEX market price. - + Use CEX market price. - + Increase 1% relative to CEX market price. - + Send - + Receive - + Max - + Swap 25% of your tradable balance. - + + + + Diasble privacy mode to trade + + + + Swap 50% of your tradable balance. - + Swap 100% of your tradable balance. - + Min Volume - + Min amount to sell - + Min amount to receive - + Minimum accepted trade equals 10% of order volume. - + Minimum accepted trade equals 25% of order volume. - + Minimum accepted trade equals 50% of order volume. - + Min volume: - + Use custom minimum trade amount + + + Order Selected + + + + + CREATE MAKER SWAP + + + + + START TAKER SWAP + + OrderLine @@ -2621,104 +2681,114 @@ They will be removed from the orderbook until you log in again. OrderModal - + Order Type - + Maker Order - + Taker Order - + Refund State - + Your swap failed but the auto-refund process for your payment started already. Please wait and keep application opened until you receive your payment back - + Date - + Error ID - - + + Error Log - + Close - + Cancel Order - - + + Min Volume + + + + + Max Volume + + + + + Swap ID - + Maker Payment Sent Transaction ID - + Maker Payment Spent Transaction ID - + Maker Payment TXID - + Taker Payment Spent Transaction ID - + Taker Payment Sent Transaction ID - + Taker Payment TXID - + Recover Funds - + Refunding... - + View on Explorer @@ -2732,7 +2802,7 @@ They will be removed from the orderbook until you log in again. - The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available. + The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available. Please select a new order. @@ -2766,22 +2836,22 @@ Please select a new order. - + Cancel All - + From - + To - + Please choose the CSV export name and location @@ -2886,23 +2956,23 @@ Please select a new order. - + Expensive - + Expedient - + %1 compared to CEX PRICE_DIFF% - + CEXchange rate @@ -2925,17 +2995,17 @@ Please select a new order. - + Expensive - + Expedient - + %1 compared to CEX PRICE_DIFF% @@ -2944,12 +3014,12 @@ Please select a new order. ProView - + Failed to place the order - + Placed the order @@ -3134,172 +3204,192 @@ Please select a new order. SendModal - + Failed to send - + Prepare to send - + Address of the recipient - + Amount to send - + Gas price - + Cancel Cancel - + Recipient's address - + The address has to be mixed case. - + Failed to Broadcast - + Fix - + MAX - + Fiat amount: Unavailable - + Fiat amount: %1 - + %1 amount: %2 - + Specify in Fiat - + Specify in Crypto - - Enter memo - - - - + Enable Custom Fees - + Enter the custom fee - + Gas Limit - + Custom Fee can't be higher than the amount - + Not enough funds. - - + + You have %1 AMT TICKER - - + + Enter memo (optional) + + + + + Use Custom IBC Channel + + + + + Enter channel ID + + + + + Only use custom IBC channel if you know what you are doing! + + + + + Avoid IBC transfers to centralized exchanges, as assets may be lost. + + + + + Only use custom fees if you know what you are doing! - + Prepare - - + + Send - + %1 address TICKER - + copied to clipboard. - + Amount - + Memo - + Fees - + Date - + Back @@ -3350,11 +3440,6 @@ Please select a new order. SendResult - - - Transaction Complete! - - %1 txid @@ -3403,6 +3488,11 @@ Please select a new order. Transaction Hash + + + Transaction Broadcast! + + Close @@ -3418,7 +3508,7 @@ Please select a new order. SettingModal - + Cancel Cancel @@ -3493,12 +3583,12 @@ Please select a new order. - + Application Version - + copied to clipboard @@ -3540,151 +3630,156 @@ Please select a new order. - + Confirm - + + Show orders after placement + + + + Ask system's password before sending coins ? (2FA) - + Disable 2FA? - + Enter your wallet password to confirm - + Type password - + 2FA status - + 2FA disabled successfully - - + + Ok - + Wrong password! - + Wallet password is incorrect - + View seed and private keys - - + + Show - + Setup Camouflage Password - + Open - + Reuse static RPC password - + Disclaimer and ToS - + Application version - - MM2 version + + KDF version - - MM2 Version + + KDF Version - - MM2 Version copied to clipboard. + + KDF Version copied to clipboard. - - + + RPC Port - + RPC Port copied to clipboard. - - + + Peer ID - + Peer ID copied to clipboard. - + Qt version - + Qt Version - + Qt Version copied to clipboard. - + Search for Update - + Logout @@ -3753,7 +3848,7 @@ Please select a new order. - + No Selectable coin. @@ -4095,7 +4190,7 @@ There is a toggle in settings where you can turn on/off the display of these tra Toast - + Click here to see the details @@ -4141,32 +4236,32 @@ There is a toggle in settings where you can turn on/off the display of these tra - + Entered amount must be higher than 0. - + Select an order. - + MAX - + To - + Pick an order - + Price @@ -4186,68 +4281,79 @@ There is a toggle in settings where you can turn on/off the display of these tra - + + Balance: - + + **** + + + + Pick a coin - + SWAP NOW - + Failed to place the order - + Placed the order - - + + Disable privacy mode to trade. + + + + + Search coins - + Min Value - + Hide disabled coins - + No buy orders found for %1. - + You can check later or try to sell a different coin. - + Calculating fee estimate... - + Total %1 fees: - + %2 (%3) @@ -4255,38 +4361,28 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - - Ticker Selectors - - - - - Trading Information - - - - + Order Book - - Best Orders + + Order Form - - Place Order + + Trading Information @@ -4356,11 +4452,6 @@ There is a toggle in settings where you can turn on/off the display of these tra Date - - - Unconfirmed - - Transaction Hash @@ -4386,6 +4477,11 @@ There is a toggle in settings where you can turn on/off the display of these tra To + + + Awaiting confirmation + + Notes @@ -4442,12 +4538,12 @@ There is a toggle in settings where you can turn on/off the display of these tra Vertical - Order Book + %1 Orderbook - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4564,7 +4660,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. @@ -4587,47 +4683,47 @@ This might take a few minutes... - + Checksum verification failed for %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x - + %1 address length is invalid, please use a valid address. - + %1 address is invalid. - + Invalid checksum. - + %1 address has invalid prefixes. - + Backend error: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_es.ts b/atomic_defi_design/assets/languages/atomic_defi_es.ts index 1e38882cd1..8b05297366 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_es.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_es.ts @@ -242,7 +242,7 @@ App - + Recover Funds Result Resultados de Recuperar Fondos @@ -474,27 +474,32 @@ Center - + Portfolio Cartera - + Wallet Monedero - + DEX DEX - + + DEX is disabled due to system clock synchronization issues. Please check your device time settings. + + + + Address Book Directorio - + Fiat Fiat @@ -515,17 +520,17 @@ Chart - - Loading market data - Cargando datos de mercado + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -759,83 +764,93 @@ ConfirmTradeModal - + Confirm Exchange Details Confirmar Detalles de Intercambio - + Trade price is more than 50% different to CEX! Confirm? ¡El precio comercial es más del 50% diferente al de CEX! ¿Confirmar? - + This swap request can not be undone and is a final event! ¡Esta solicitud de intercambio no se puede deshacer y es un evento final! - + This transaction can take up to 60 mins - DO NOT close this application! Esta transacción puede demorar hasta 60 minutos. ¡NO cierre esta aplicación! - + Loading fees... Cargando tarifas... - + <b>Total %1 fees:</b> <b>Cuota total de %1:</b> - + Security configuration Configuración de seguridad - + %1 confirmations for incoming %2 transactions %1 confirmaciones para %2 transacciones entrantes - + Read more about dPoW Obtenga más información sobre dPoW - + + Cancel all existing orders for %1/%2? + + + + + Good until cancelled (order will remain on orderbook until filled or cancelled) + + + + Use custom protection settings for incoming %1 transactions TICKER Utilice configuraciones de protección personalizadas para %1 transacciones entrantes - + Enable Komodo dPoW security Habilite la seguridad dPoW de Komodo - + dPoW protected Protegido por dPoW - + Required Confirmations Confirmaciones Requeridas - + Warning, this atomic swap is not dPoW protected! Advertencia, este intercambio atómico no está protegido por dPoW! - + Cancel Cancelar - + Confirm Confirmar @@ -1411,7 +1426,7 @@ General - + %n day(s) @@ -1419,7 +1434,7 @@ - + %nd day @@ -1428,7 +1443,7 @@ - + %nh hours @@ -1437,7 +1452,7 @@ - + %nm minutes @@ -1446,7 +1461,7 @@ - + %ns seconds @@ -1455,7 +1470,7 @@ - + %nms milliseconds @@ -1464,117 +1479,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - - %1 balance is zero + + Balance is zero! - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Cantidad Mínima de Intercambio - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1754,17 +1769,17 @@ Vuelva a intentarlo o seleccione 'Permitir semilla personalizada' pers List - + Funds are recoverable Los fondos son recuperables - Best Orders - Mejores Ordenes + Best Orders for %1 + - + Enter volume to see best orders. Introduce el volumen para ver los mejores ordenes @@ -1772,17 +1787,27 @@ Vuelva a intentarlo o seleccione 'Permitir semilla personalizada' pers ListDelegate - + %1 is not enabled - Do you want to enable it to be able to select %2 best orders ?<br><a href='#'>Yes</a> - <a href='#no'>No</a> %1 no está habilitado. ¿Desea habilitarlo para poder seleccionar %2 mejores ordenes?<br><a href='#'>Sí</a> - <a href='#no'>No</a> - + %1 is not enabled - Please enable it through the coin activation menu - + + Orderbook is disabled in privacy mode + + + + + Orderbook is disabled while creating maker orders + + + + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 Este pedido requiere una cantidad mínima de %1 %2 <br>No tiene fondos suficientes.<br> %3 @@ -1804,8 +1829,8 @@ Vuelva a intentarlo o seleccione 'Permitir semilla personalizada' pers - Initializing MM2 - Inicializando MM2 + Initializing KDF + @@ -1916,7 +1941,7 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Recibir - + Swap Intercambiar @@ -1942,92 +1967,77 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Grifo - - - + + Vote Info + + + + + + Public Key Clave Pública - + Copied to Clipboard Copiada en el Portapapeles - + Explore - - Loading market data - Cargando datos de mercado - - - + There is no chart data for this ticker yet No hay datos de gráficos para este ticker aún - + Fetching transactions... Obteniendo transacciones... - + No transactions available. - + Please wait, %1 is %2 Por favor espera %1 es %2 - - % activated... - % activado... + + Loading ticker chart data + - - Trading Information - Información de Intercambios + + % activated... + % activado... - + Chart Gráfico - - + + Orders Pedidos - - + + History Historial - - - Place Order - Realizar pedido - - - - Order Selected - Pedido seleccionado - - - - START SWAP - INICIO INTERCAMBIAR - - + Address Book Libreta de direcciones @@ -2052,36 +2062,64 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión.Etiquetas - + + No contacts found. + + + + Edit Editar - + Delete Eliminar - + address copied to clipboard dirección copiada al portapapeles - + This contact does not have any registered address. Este contacto no tiene ninguna dirección registrada. + + + Taker Order + Orden de Taker + + + + Maker Order + Orden de Maker + + + + Market + + + Orderbook + + + + + Best Orders + Mejores Ordenes + MarketModeSelector - + Sell %1 TICKER Vender %1 - + Buy %1 TICKER Comprar %1 @@ -2515,95 +2553,117 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión. OrderForm - + Price Precio - + Reduce 1% relative to CEX market price. Reducción del 1% en relación con el precio de mercado CEX. - + Use CEX market price. Utilice el precio de mercado CEX. - + Increase 1% relative to CEX market price. Aumento del 1% en relación con el precio de mercado de CEX. - + Send Enviar - + Receive Recibir - + Max Max - + Swap 25% of your tradable balance. Usar el 25% de su saldo comercial. - + + + + Diasble privacy mode to trade + + + + Swap 50% of your tradable balance. Usar el 50% de su saldo comercial. - + Swap 100% of your tradable balance. Usar el 100% de su saldo comercial. - + Min Volume Volumen Mínimo - + Min amount to sell Cantidad mínima para vender - + Min amount to receive Cantidad mínimo para recibir - + Minimum accepted trade equals 10% of order volume. El comercio mínimo aceptado es igual al 10% del volumen del pedido. - + Minimum accepted trade equals 25% of order volume. El comercio mínimo aceptado es igual al 25% del volumen del pedido. - + Minimum accepted trade equals 50% of order volume. El comercio mínimo aceptado es igual al 50% del volumen del pedido. - + Min volume: Volumen mínimo: - + Use custom minimum trade amount Utilizar una cantidad personalizada de intercambio mínima + + + Order Selected + Pedido seleccionado + + + + CREATE MAKER SWAP + + + + + START TAKER SWAP + + OrderLine @@ -2624,104 +2684,114 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión. OrderModal - + Order Type Tipo de Orden - + Maker Order Orden de Maker - + Taker Order Orden de Taker - + Refund State Estado del Reembolso - + Your swap failed but the auto-refund process for your payment started already. Please wait and keep application opened until you receive your payment back Su intercambio falló, pero el proceso de reembolso automático para su pago ya comenzó. Espere y mantenga la aplicación abierta hasta que reciba su pago - + Date Fecha - + Error ID ID de Error - - + + Error Log Registro de Error - + Close Cerrar - + Cancel Order Cancelar Pedido - - + + Min Volume + Volumen Mínimo + + + + Max Volume + + + + + Swap ID ID de Intercambio - + Maker Payment Sent Transaction ID ID de la transacción pago enviada de Maker - + Maker Payment Spent Transaction ID ID de la transacción pago gastado de Maker - + Maker Payment TXID TXID del pago de Maker - + Taker Payment Spent Transaction ID ID de la transacción pago gastado de Taker - + Taker Payment Sent Transaction ID ID de la transacción pago enviada de Taker - + Taker Payment TXID TXID del pago de Taker - + Recover Funds Recuperar fondos - + Refunding... Reembolso... - + View on Explorer Ver en Explorer @@ -2735,10 +2805,9 @@ Se eliminarán del libro de pedidos hasta que vuelva a iniciar sesión. - The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available. + The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available. Please select a new order. - El pedido seleccionado ya no existe, puede haber sido igualado o cancelado, y no hay un pedido con mejor precio disponible. -Seleccione un nuevo pedido. + @@ -2770,22 +2839,22 @@ Seleccione un nuevo pedido. Aplicar Filtro - + Cancel All Cancelar Todo - + From Desde - + To A - + Please choose the CSV export name and location Por favor, elija el nombre y la ubicación de exportación CSV @@ -2890,23 +2959,23 @@ Seleccione un nuevo pedido. Seleccionada - + Expensive Caro - + Expedient Expediente - + %1 compared to CEX PRICE_DIFF% %1 en comparación con CEX - + CEXchange rate Tasa de cambio CEX @@ -2929,17 +2998,17 @@ Seleccione un nuevo pedido. Tasa de cambio CEX - + Expensive Caro - + Expedient Expediente - + %1 compared to CEX PRICE_DIFF% %1 en comparación con CEX @@ -2948,12 +3017,12 @@ Seleccione un nuevo pedido. ProView - + Failed to place the order Error al realizar el pedido - + Placed the order Realizó el pedido El @@ -3138,172 +3207,192 @@ Seleccione un nuevo pedido. SendModal - + Failed to send Error al enviar - + Prepare to send Preparar para enviar - + Address of the recipient Dirección del destinatario - + Amount to send Cantidad a enviar - + Gas price Precio del gas - + Cancel Cancelar - + Recipient's address Dirección del destinatario - + The address has to be mixed case. La dirección debe estar en mayúsculas y minúsculas. - + Failed to Broadcast Error al transmitir - + Fix Arreglar - + MAX MAX - + Fiat amount: Unavailable Cantidad en Fiat: No disponible - + Fiat amount: %1 Cantidad de Fiat: %1 - + %1 amount: %2 Cantidad de %1: %2 - + Specify in Fiat Especificar en Fiat - + Specify in Crypto Especificar en Crypto - - Enter memo - - - - + Enable Custom Fees Habilitar Tarifas Personalizadas - + Enter the custom fee Ingrese la tarifa personalizada - + Gas Limit Límite de gas - + Custom Fee can't be higher than the amount Tarifa personalizada no puede ser mayor que la cantidad - + Not enough funds. No hay suficientes fondos. - - + + You have %1 AMT TICKER Tiene %1 - - + + Enter memo (optional) + + + + + Use Custom IBC Channel + + + + + Enter channel ID + + + + + Only use custom IBC channel if you know what you are doing! + + + + + Avoid IBC transfers to centralized exchanges, as assets may be lost. + + + + + Only use custom fees if you know what you are doing! ¡Solo use tarifas personalizadas si sabe lo que está haciendo! - + Prepare Preparar - - + + Send Enviar - + %1 address TICKER %1 dirección - + copied to clipboard. copiado al portapapeles. - + Amount Cantidad - + Memo - + Fees Tarifas - + Date Fecha - + Back Atrás @@ -3354,11 +3443,6 @@ Seleccione un nuevo pedido. SendResult - - - Transaction Complete! - ¡Transacción completa! - %1 txid @@ -3407,6 +3491,11 @@ Seleccione un nuevo pedido. Transaction Hash Hash de Transaccion + + + Transaction Broadcast! + + Close @@ -3422,7 +3511,7 @@ Seleccione un nuevo pedido. SettingModal - + Cancel Cancelar @@ -3497,12 +3586,12 @@ Seleccione un nuevo pedido. Cambiando el tema a %1 - + Application Version La versión de la aplicación - + copied to clipboard copiado al portapapeles @@ -3544,151 +3633,156 @@ Seleccione un nuevo pedido. - + Confirm Confirmar - + + Show orders after placement + + + + Ask system's password before sending coins ? (2FA) ¿Preguntar la contraseña del sistema antes de enviar monedas? (2FA) - + Disable 2FA? ¿Deshabilitar 2FA? - + Enter your wallet password to confirm Ingrese la contraseña de su billetera para confirmar - + Type password Escriba la contraseña - + 2FA status Estado 2FA - + 2FA disabled successfully 2FA deshabilitado correctamente - - + + Ok Ok - + Wrong password! ¡Contraseña incorrecta! - + Wallet password is incorrect Contraseña de la billetera es incorrecta - + View seed and private keys Ver semilla y claves privadas - - + + Show Mostrar - + Setup Camouflage Password Configuración de Contraseña Camuflaje - + Open Abrir - + Reuse static RPC password - + Disclaimer and ToS Descargo de Responsabilidad y Terminos de Servicio - + Application version Versión de Aplicación - - MM2 version - Versión MM2 + + KDF version + - - MM2 Version - Versión MM2 + + KDF Version + - - MM2 Version copied to clipboard. - Versión MM2 copiada al portapapeles. + + KDF Version copied to clipboard. + - - + + RPC Port - + RPC Port copied to clipboard. - - + + Peer ID - + Peer ID copied to clipboard. - + Qt version Versión Qt - + Qt Version Versión Qt - + Qt Version copied to clipboard. Versión de Qt copiada al portapapeles. - + Search for Update - + Logout Cerrar sesión @@ -3757,7 +3851,7 @@ Seleccione un nuevo pedido. Saldo Fiat - + No Selectable coin. No Moneda seleccionable. @@ -4107,7 +4201,7 @@ There is a toggle in settings where you can turn on/off the display of these tra Toast - + Click here to see the details Haga clic aquí para ver los detalles @@ -4153,32 +4247,32 @@ There is a toggle in settings where you can turn on/off the display of these tra Desde - + Entered amount must be higher than 0. - + Select an order. - + MAX MAX - + To A - + Pick an order Elegir una orden - + Price Precio @@ -4198,68 +4292,79 @@ There is a toggle in settings where you can turn on/off the display of these tra %1 - + + Balance: - + + **** + + + + Pick a coin Elija una moneda - + SWAP NOW CAMBIE AHORA - + Failed to place the order Error al realizar el pedido - + Placed the order Realizó el pedido El - - + + Disable privacy mode to trade. + + + + + Search coins - + Min Value - + Hide disabled coins - + No buy orders found for %1. No se encontraron órdenes de compra para %1. - + You can check later or try to sell a different coin. Puede verificar más tarde o intentar vender una moneda diferente. - + Calculating fee estimate... Calculando tarifa estimada... - + Total %1 fees: Total de %1 tarifas: - + %2 (%3) %2 (%3) @@ -4267,39 +4372,29 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings Vista de Configuración Pro - + Display Settings Configuracion de Vista - - Ticker Selectors - Selectores - - - - Trading Information - Información de Intercambios - - - + Order Book - Libro de Ordenes + Libro de Ordenes - - Best Orders - Mejores Ordenes + + Order Form + - - Place Order - Realizar pedido + + Trading Information + Información de Intercambios @@ -4368,11 +4463,6 @@ There is a toggle in settings where you can turn on/off the display of these tra Date Fecha - - - Unconfirmed - Sin confirmar - Transaction Hash @@ -4398,6 +4488,11 @@ There is a toggle in settings where you can turn on/off the display of these tra To A + + + Awaiting confirmation + + Notes @@ -4454,12 +4549,12 @@ There is a toggle in settings where you can turn on/off the display of these tra Vertical - Order Book - Libro de Ordenes + %1 Orderbook + - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4577,7 +4672,7 @@ Esto puede tardar unos minutos... atomic_dex::settings_page - + An error has occurred. Se ha producido un error. @@ -4600,47 +4695,47 @@ Esto puede tardar unos minutos... Necesita tener %1 para pagar la gasolina de %2 transacciones. - + Checksum verification failed for %1. La verificación de la suma de comprobación falló para %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. Suma de comprobación no válida para %1. Haga clic en el botón para convertir a dirección de mayúsculas y minúsculas. - + Legacy address used for %1. Click the button to convert to a Cashaddress. Dirección heredada utilizada para %1. Haga clic en el botón para convertir a una dirección de efectivo. - + %1 address must be prefixed with 0x La dirección %1 debe tener el prefijo 0x - + %1 address length is invalid, please use a valid address. La longitud de la dirección %1 no es válida, utilice una dirección válida. - + %1 address is invalid. La dirección %1 no es válida. - + Invalid checksum. Suma de comprobación no válida. - + %1 address has invalid prefixes. La dirección %1 tiene prefijos no válidos. - + Backend error: %1 Error de backend: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_fr.ts b/atomic_defi_design/assets/languages/atomic_defi_fr.ts index cbb1fa663d..e02b92de1d 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_fr.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_fr.ts @@ -242,7 +242,7 @@ App - + Recover Funds Result Le résultat de la récupération des fonds @@ -474,27 +474,32 @@ Center - + Portfolio Portfolio - + Wallet Portefeuille - + DEX DEX - + + DEX is disabled due to system clock synchronization issues. Please check your device time settings. + + + + Address Book Carnet d'adresses - + Fiat Monnaie fiduciaire @@ -515,17 +520,17 @@ Chart - - Loading market data - Chargement des données de marché + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -759,83 +764,93 @@ ConfirmTradeModal - + Confirm Exchange Details Détails de la confirmation de l'échange - + This swap request can not be undone and is a final event! La requête de ce swap ne peut pas être annulé, c'est irréversible ! - + Security configuration Configuration de la sécurité - + Read more about dPoW En savoir plus sur dPoW - + Use custom protection settings for incoming %1 transactions TICKER Utiliser les paramètres de protection personnalisés pour les transactions %1 entrantes - + Enable Komodo dPoW security Activer la sécurité de Komodo dPoW - + %1 confirmations for incoming %2 transactions Il y a %1 confirmations pour les transactions entrantes du ticker %2 - + This transaction can take up to 60 mins - DO NOT close this application! Cette transaction peut prendre jusqu'à 60 minutes - NE fermez PAS cette application ! - + Trade price is more than 50% different to CEX! Confirm? Le prix est supérieur à 50% du prix sur les CEX ! Êtes-vous sûr ? - + Loading fees... - + <b>Total %1 fees:</b> Frais totaux %1: - + + Cancel all existing orders for %1/%2? + + + + + Good until cancelled (order will remain on orderbook until filled or cancelled) + + + + dPoW protected Protégé par dPoW - + Required Confirmations Confirmations requises - + Warning, this atomic swap is not dPoW protected! Attention, ce swap atomique n'est pas protégé par dPoW ! - + Cancel Annuler - + Confirm Confirmer @@ -1411,7 +1426,7 @@ General - + %n day(s) @@ -1419,7 +1434,7 @@ - + %nd day @@ -1428,7 +1443,7 @@ - + %nh hours @@ -1437,7 +1452,7 @@ - + %nm minutes @@ -1446,7 +1461,7 @@ - + %ns seconds @@ -1455,7 +1470,7 @@ - + %nms milliseconds @@ -1464,117 +1479,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - - %1 balance is zero + + Balance is zero! - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Montant de trading minimum - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1753,17 +1768,17 @@ Try again or select 'Allow custom seed' to continue. List - + Funds are recoverable Les fonds sont récupérables - Best Orders - Meilleurs offres + Best Orders for %1 + - + Enter volume to see best orders. @@ -1771,17 +1786,27 @@ Try again or select 'Allow custom seed' to continue. ListDelegate - + %1 is not enabled - Do you want to enable it to be able to select %2 best orders ?<br><a href='#'>Yes</a> - <a href='#no'>No</a> %1 n'est pas activé - Souhaitez vous l'activer pour pouvoir selectionnez les meilleurs offres %2 ?<br><a href='#'>Oui</a> - <a href='#no'>Non</a> - + %1 is not enabled - Please enable it through the coin activation menu - + + Orderbook is disabled in privacy mode + + + + + Orderbook is disabled while creating maker orders + + + + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 Cette commande nécessite un montant minimum de %1 %2 <br>Vous n'avez pas assez de fonds.<br> %3 @@ -1803,8 +1828,8 @@ Try again or select 'Allow custom seed' to continue. - Initializing MM2 - Initialisation de MM2 + Initializing KDF + @@ -1913,7 +1938,7 @@ They will be removed from the orderbook until you log in again. Recevoir - + Swap Échange @@ -1939,92 +1964,77 @@ They will be removed from the orderbook until you log in again. Robinet - - - + + Vote Info + + + + + + Public Key - + Copied to Clipboard Copier dans le presse-papier - + Explore - - Loading market data - Chargement des données de marché - - - + There is no chart data for this ticker yet Il n'y a pas encore de données graphiques pour ce ticker - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - - % activated... + + Loading ticker chart data - - Trading Information - Informations de Trading + + % activated... + - + Chart Chart - - + + Orders Ordres - - + + History Historique - - - Place Order - Placer l'ordre - - - - Order Selected - Ordre séléctionné - - - - START SWAP - COMMENCER L'ÉCHANGE - - + Address Book Carnet d'adresses @@ -2049,36 +2059,64 @@ They will be removed from the orderbook until you log in again. Tags - + + No contacts found. + + + + Edit Éditer - + Delete Supprimez - + address copied to clipboard - + This contact does not have any registered address. + + + Taker Order + Ordre d'achat + + + + Maker Order + Ordre de vente + + + + Market + + + Orderbook + + + + + Best Orders + Meilleurs offres + MarketModeSelector - + Sell %1 TICKER - + Buy %1 TICKER @@ -2512,92 +2550,114 @@ They will be removed from the orderbook until you log in again. OrderForm - + Send Envoyez - + Receive Recevoir - + Max Max - + Swap 25% of your tradable balance. - + + + + Diasble privacy mode to trade + + + + Swap 50% of your tradable balance. - + Swap 100% of your tradable balance. - + Min Volume - + Min amount to sell - + Min amount to receive - + Minimum accepted trade equals 10% of order volume. - + Minimum accepted trade equals 25% of order volume. - + Minimum accepted trade equals 50% of order volume. - + Min volume: Min volume : - + Use custom minimum trade amount Utiliser le montant d'échange minimum personnalisé - + + Order Selected + Ordre séléctionné + + + + CREATE MAKER SWAP + + + + + START TAKER SWAP + + + + Price Prix - + Reduce 1% relative to CEX market price. - + Use CEX market price. - + Increase 1% relative to CEX market price. @@ -2621,104 +2681,114 @@ They will be removed from the orderbook until you log in again. OrderModal - + Order Type - + Maker Order Ordre de vente - + Taker Order Ordre d'achat - + + Min Volume + + + + + Max Volume + + + + Refund State État de remboursement - + Your swap failed but the auto-refund process for your payment started already. Please wait and keep application opened until you receive your payment back Votre échange a échoué, mais le processus de remboursement automatique de votre paiement a déjà commencé. Veuillez patienter et garder l'application ouverte jusqu'à ce que vous receviez votre remboursement - + Date Date - + Recover Funds Récupérer des fonds - + Refunding... Remboursement... - + View on Explorer Voir dans l'explorateur - + Cancel Order Annuler l'ordre - + Error ID ID de l'erreur - - + + Swap ID ID du Swap - + Maker Payment Sent Transaction ID - + Maker Payment Spent Transaction ID - + Maker Payment TXID - + Taker Payment Spent Transaction ID - + Taker Payment Sent Transaction ID - + Taker Payment TXID - - + + Error Log Journal des erreurs - + Close Fermer @@ -2732,7 +2802,7 @@ They will be removed from the orderbook until you log in again. - The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available. + The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available. Please select a new order. @@ -2745,12 +2815,12 @@ Please select a new order. OrdersPage - + From De - + To Vers @@ -2776,12 +2846,12 @@ Please select a new order. Exporter CSV - + Cancel All - + Please choose the CSV export name and location Veuillez choisir le nom et l'emplacement de l'exportation CSV @@ -2886,23 +2956,23 @@ Please select a new order. Choisi - + Expensive Coûteuse - + Expedient Abordable - + %1 compared to CEX PRICE_DIFF% %1 par rapport aux CEX - + CEXchange rate Taux du CEX @@ -2925,17 +2995,17 @@ Please select a new order. Taux du CEX - + Expensive Coûteuse - + Expedient Abordable - + %1 compared to CEX PRICE_DIFF% %1 par rapport aux CEX @@ -2944,12 +3014,12 @@ Please select a new order. ProView - + Failed to place the order Échec lors du placement de l'ordre - + Placed the order L'ordre a été placé avec succès @@ -3134,172 +3204,192 @@ Please select a new order. SendModal - + Failed to send Échec de l'envoi - + Prepare to send Préparez à envoyer du - + Address of the recipient Adresse du destinataire - + Amount to send Montant à envoyer - + Gas price Prix ​​du gaz - + Cancel Annuler - + Recipient's address Adresse du destinataire - + The address has to be mixed case. L'adresse doit être mixte (case). - + Failed to Broadcast - + Fix Réparer - + MAX MAX - + Fiat amount: Unavailable - + Fiat amount: %1 - + %1 amount: %2 - + Specify in Fiat - + Specify in Crypto - - Enter memo - - - - + Enable Custom Fees Activer les frais personnalisés - + Enter the custom fee Entrez les frais personnalisées - + Gas Limit Limite de gaz - + Custom Fee can't be higher than the amount Les frais personnalisées ne peuvent pas être supérieurs au montant - + Not enough funds. Pas assez de fonds. - - + + You have %1 AMT TICKER Vous avez %1 - - + + Enter memo (optional) + + + + + Use Custom IBC Channel + + + + + Enter channel ID + + + + + Only use custom IBC channel if you know what you are doing! + + + + + Avoid IBC transfers to centralized exchanges, as assets may be lost. + + + + + Only use custom fees if you know what you are doing! - + Prepare Préparer - - + + Send Envoyez - + %1 address TICKER - + copied to clipboard. - + Amount Montant - + Memo - + Fees Frais - + Date Date - + Back Retour @@ -3350,11 +3440,6 @@ Please select a new order. SendResult - - - Transaction Complete! - Transaction terminée ! - %1 txid @@ -3403,6 +3488,11 @@ Please select a new order. Transaction Hash Hachage de la transaction + + + Transaction Broadcast! + + Close @@ -3418,7 +3508,7 @@ Please select a new order. SettingModal - + Cancel Annuler @@ -3505,7 +3595,7 @@ Please select a new order. - + Confirm Confirmer @@ -3515,63 +3605,83 @@ Please select a new order. Changer le thème en %1 - + + Show orders after placement + + + + Disable 2FA? - + Enter your wallet password to confirm - + Type password Tapez votre mot de passe - + 2FA status - + 2FA disabled successfully - - + + Ok Ok - + Wrong password! - + Wallet password is incorrect - + Reuse static RPC password - + Application Version - + copied to clipboard copié dans le presse-papier - + + KDF version + + + + + KDF Version + + + + + KDF Version copied to clipboard. + + + + Search for Update @@ -3596,95 +3706,80 @@ Please select a new order. Thème - + Ask system's password before sending coins ? (2FA) Demander le mot de passe du système avant d'envoyer des actifs ? (2FA) - + Application version Version de l'application - - MM2 version - Version de MM2 - - - - MM2 Version - MM2 Version - - - - MM2 Version copied to clipboard. - MM2 Version copiée dans le presse-papiers. - - - - + + RPC Port - + RPC Port copied to clipboard. - - + + Peer ID - + Peer ID copied to clipboard. - + Qt version Version de Qt - + Qt Version Qt Version - + Qt Version copied to clipboard. Version Qt copiée dans le presse-papiers. - + Logout Se déconnecter - + View seed and private keys Afficher la phrase de récupération et les clefs privées - - + + Show Montrer - + Setup Camouflage Password Configurer le mot de passe de camouflage - + Open Ouvrir - + Disclaimer and ToS Clause de non-responsabilité et conditions d'utilisation @@ -3753,7 +3848,7 @@ Please select a new order. Balance Fiduciaire - + No Selectable coin. Aucune asset sélectionnable. @@ -4095,7 +4190,7 @@ There is a toggle in settings where you can turn on/off the display of these tra Toast - + Click here to see the details Cliquez ici pour voir les détails @@ -4141,32 +4236,32 @@ There is a toggle in settings where you can turn on/off the display of these tra De - + Entered amount must be higher than 0. - + Select an order. - + MAX MAX - + To Vers - + Pick an order Choisir une commande - + Price Prix @@ -4186,68 +4281,79 @@ There is a toggle in settings where you can turn on/off the display of these tra - + + Balance: - + + **** + + + + Pick a coin Choisissez un actif - + SWAP NOW ÉCHANGER MAINTENANT - + Failed to place the order Échec lors du placement de l'ordre - + Placed the order L'ordre a été placé - - + + Disable privacy mode to trade. + + + + + Search coins - + Min Value - + Hide disabled coins - + No buy orders found for %1. Aucun ordre d'achat trouvé pour %1. - + You can check later or try to sell a different coin. Vous pouvez vérifier plus tard ou essayer de vendre un actif différent. - + Calculating fee estimate... - + Total %1 fees: Frais totaux %1 : - + %2 (%3) @@ -4255,39 +4361,29 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - - Ticker Selectors - - - - - Trading Information - Informations de Trading - - - + Order Book Carnet d'ordres - - Best Orders - Meilleurs offres + + Order Form + - - Place Order - Placer l'ordre + + Trading Information + Informations de Trading @@ -4356,11 +4452,6 @@ There is a toggle in settings where you can turn on/off the display of these tra Date Date - - - Unconfirmed - Non confirmé - Transaction Hash @@ -4386,6 +4477,11 @@ There is a toggle in settings where you can turn on/off the display of these tra To Vers + + + Awaiting confirmation + + Notes @@ -4442,12 +4538,12 @@ There is a toggle in settings where you can turn on/off the display of these tra Vertical - Order Book - Carnet d'ordres + %1 Orderbook + - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4564,7 +4660,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. @@ -4587,47 +4683,47 @@ This might take a few minutes... Vous devez avoir %1 activée pour payer les frais de transactions de %2. - + Checksum verification failed for %1. Échec de la vérification du checksum de contrôle pour %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x L'adresse %1 doit être précédée de 0x - + %1 address length is invalid, please use a valid address. La longueur de l'adresse %1 n'est pas valide, veuillez utiliser une adresse valide. - + %1 address is invalid. L'adresse %1 n'est pas valide. - + Invalid checksum. Somme de contrôle invalide. - + %1 address has invalid prefixes. L'adresse %1 a des préfixes non valides. - + Backend error: %1 Erreur de backend : %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_ru.ts b/atomic_defi_design/assets/languages/atomic_defi_ru.ts index 718b15dcf5..af9b7d5da7 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_ru.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_ru.ts @@ -242,7 +242,7 @@ App - + Recover Funds Result Результат восстановления средств @@ -474,27 +474,32 @@ Center - + Portfolio Портфолио - + Wallet Кошелек - + DEX DEX - + + DEX is disabled due to system clock synchronization issues. Please check your device time settings. + + + + Address Book Адресная книга - + Fiat Фиат @@ -515,17 +520,17 @@ Chart - - Loading market data - Загрузка рыночных данных + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -759,83 +764,93 @@ ConfirmTradeModal - + Confirm Exchange Details Подтвердить данные обмена - + Trade price is more than 50% different to CEX! Confirm? Стоимость обмена в сравнении с CEX дороже более чем на 50%, вы подтверждаете сделку? - + This swap request can not be undone and is a final event! Этот запрос на своп не может быть отменен и является окончательным! - + This transaction can take up to 60 mins - DO NOT close this application! Эта транзакция может занять до 60 минут - НЕ закрывайте приложение! - + Loading fees... - + <b>Total %1 fees:</b> - + Security configuration Настройки безопасности - + %1 confirmations for incoming %2 transactions %1 подтверждений для входящих %2 транзакций - + Read more about dPoW Узнать больше о dPoW - + + Cancel all existing orders for %1/%2? + + + + + Good until cancelled (order will remain on orderbook until filled or cancelled) + + + + Use custom protection settings for incoming %1 transactions TICKER Использовать пользовательские настройки защиты для входящих транзакций %1 - + Enable Komodo dPoW security Включить Komodo dPoW - + dPoW protected dPoW защита - + Required Confirmations Необходимое количество подтверждений - + Warning, this atomic swap is not dPoW protected! Предупреждение, этот атомарный своп не защищен dPoW! - + Cancel Отменить - + Confirm Подтверждение @@ -1411,7 +1426,7 @@ General - + %n day(s) @@ -1420,7 +1435,7 @@ - + %nd day @@ -1430,7 +1445,7 @@ - + %nh hours @@ -1440,7 +1455,7 @@ - + %nm minutes @@ -1450,7 +1465,7 @@ - + %ns seconds @@ -1460,7 +1475,7 @@ - + %nms milliseconds @@ -1470,117 +1485,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - - %1 balance is zero + + Balance is zero! - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Минимальный торговый объем - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1759,17 +1774,17 @@ Try again or select 'Allow custom seed' to continue. List - + Funds are recoverable Средства могут быть восстановлены - Best Orders - Лучшие ордеры + Best Orders for %1 + - + Enter volume to see best orders. @@ -1777,17 +1792,27 @@ Try again or select 'Allow custom seed' to continue. ListDelegate - + %1 is not enabled - Do you want to enable it to be able to select %2 best orders ?<br><a href='#'>Yes</a> - <a href='#no'>No</a> %1 не активирован -Вы хотите активировать этот %2 актив чтобы видеть лучшие ордеры для него ?<br><a href='#'>Да</a> - <a href='#no'>Нет</a> - + %1 is not enabled - Please enable it through the coin activation menu - + + Orderbook is disabled in privacy mode + + + + + Orderbook is disabled while creating maker orders + + + + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 @@ -1809,8 +1834,8 @@ Try again or select 'Allow custom seed' to continue. - Initializing MM2 - Инициализация MM2 + Initializing KDF + @@ -1919,7 +1944,7 @@ They will be removed from the orderbook until you log in again. Получить - + Swap Обменять @@ -1945,92 +1970,77 @@ They will be removed from the orderbook until you log in again. Фаусет - - - + + Vote Info + + + + + + Public Key - + Copied to Clipboard Скопировано в буфер обмена - + Explore - - Loading market data - Загрузка рыночных данных - - - + There is no chart data for this ticker yet Для данного актива пока еще нет графиков данных - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - - % activated... + + Loading ticker chart data - - Trading Information - Торговая информация + + % activated... + - + Chart График - - + + Orders Ордеры - - + + History История - - - Place Order - Разместить ордер - - - - Order Selected - Ордер выбран - - - - START SWAP - НАЧАТЬ ОБМЕН - - + Address Book Адресная книга @@ -2055,36 +2065,64 @@ They will be removed from the orderbook until you log in again. Теги - + + No contacts found. + + + + Edit Редактировать - + Delete Удалить - + address copied to clipboard - + This contact does not have any registered address. + + + Taker Order + Тейкер ордер + + + + Maker Order + Мейкер ордер + + + + Market + + + Orderbook + + + + + Best Orders + Лучшие ордеры + MarketModeSelector - + Sell %1 TICKER - + Buy %1 TICKER @@ -2518,95 +2556,117 @@ They will be removed from the orderbook until you log in again. OrderForm - + Price Цена - + Reduce 1% relative to CEX market price. - + Use CEX market price. - + Increase 1% relative to CEX market price. - + Send Отправить - + Receive Получить - + Max Макс - + Swap 25% of your tradable balance. - + + + + Diasble privacy mode to trade + + + + Swap 50% of your tradable balance. - + Swap 100% of your tradable balance. - + Min Volume - + Min amount to sell - + Min amount to receive - + Minimum accepted trade equals 10% of order volume. - + Minimum accepted trade equals 25% of order volume. - + Minimum accepted trade equals 50% of order volume. - + Min volume: Мин. объем: - + Use custom minimum trade amount Задать минимальный объем сделки + + + Order Selected + Ордер выбран + + + + CREATE MAKER SWAP + + + + + START TAKER SWAP + + OrderLine @@ -2627,104 +2687,114 @@ They will be removed from the orderbook until you log in again. OrderModal - + Order Type - + Maker Order Мейкер ордер - + Taker Order Тейкер ордер - + Refund State Статус рефанда - + Your swap failed but the auto-refund process for your payment started already. Please wait and keep application opened until you receive your payment back Обмен не был завершен, но процесс автоматического рефанда уже начался. Пожалуйста, подождите, оставляя приложение открытым, пока вы не получите свои средства - + Date Дата - + Error ID ID ошибки - - + + Error Log Лог ошибки - + Close Закрыть - + Cancel Order Отменить ордер - - + + Min Volume + + + + + Max Volume + + + + + Swap ID ID обмена - + Maker Payment Sent Transaction ID - + Maker Payment Spent Transaction ID - + Maker Payment TXID - + Taker Payment Spent Transaction ID - + Taker Payment Sent Transaction ID - + Taker Payment TXID - + Recover Funds Восстановить средства - + Refunding... Возмещается... - + View on Explorer Показать в эксплорере @@ -2738,7 +2808,7 @@ They will be removed from the orderbook until you log in again. - The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available. + The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available. Please select a new order. @@ -2751,12 +2821,12 @@ Please select a new order. OrdersPage - + From От - + To Кому @@ -2782,12 +2852,12 @@ Please select a new order. Применить фильтр - + Cancel All - + Please choose the CSV export name and location Выберите название и расположение загружаемого файла @@ -2892,23 +2962,23 @@ Please select a new order. Выбрано - + Expensive Невыгодный курс - + Expedient Выгодный курс - + %1 compared to CEX PRICE_DIFF% %1 по сравнению с CEX - + CEXchange rate CEXchange Цена @@ -2931,17 +3001,17 @@ Please select a new order. CEXchange Цена - + Expensive Невыгодный курс - + Expedient Выгодный курс - + %1 compared to CEX PRICE_DIFF% %1 по сравнению с CEX @@ -2950,12 +3020,12 @@ Please select a new order. ProView - + Failed to place the order Не удалось разместить ордер - + Placed the order Ордер размещен @@ -3140,172 +3210,192 @@ Please select a new order. SendModal - + Failed to send Ошибка отправки - + Prepare to send Подготовить к отправке - + Address of the recipient Адрес получателя - + Amount to send Сумма для отправки - + Gas price Цена газа - + Cancel - + Recipient's address Адрес получателя - + The address has to be mixed case. Адрес должен быть написан в смешанном регистре. - + Failed to Broadcast - + Fix Фикс - + MAX МАКС - + Fiat amount: Unavailable - + Fiat amount: %1 - + %1 amount: %2 - + Specify in Fiat - + Specify in Crypto - - Enter memo - - - - + Enable Custom Fees Включить настройку комиссий - + Enter the custom fee Введите комиссию сети - + Gas Limit Gas лимит - + Custom Fee can't be higher than the amount Комиссия не может больше общей суммы транзакции - + Not enough funds. Недостаточно средств. - - + + You have %1 AMT TICKER У вас %1 - - + + Enter memo (optional) + + + + + Use Custom IBC Channel + + + + + Enter channel ID + + + + + Only use custom IBC channel if you know what you are doing! + + + + + Avoid IBC transfers to centralized exchanges, as assets may be lost. + + + + + Only use custom fees if you know what you are doing! - + Prepare Подготовка - - + + Send Отправить - + %1 address TICKER - + copied to clipboard. - + Amount Сумма - + Memo - + Fees Комиссия - + Date Дата - + Back Назад @@ -3356,11 +3446,6 @@ Please select a new order. SendResult - - - Transaction Complete! - Транзакция завершена! - %1 txid @@ -3409,6 +3494,11 @@ Please select a new order. Transaction Hash Хэш транзакции + + + Transaction Broadcast! + + Close @@ -3424,7 +3514,7 @@ Please select a new order. SettingModal - + Cancel Отмена @@ -3511,7 +3601,7 @@ Please select a new order. - + Confirm Подтвердить @@ -3521,63 +3611,83 @@ Please select a new order. Изменить тему на %1 - + + Show orders after placement + + + + Disable 2FA? - + Enter your wallet password to confirm - + Type password Введите пароль - + 2FA status - + 2FA disabled successfully - - + + Ok Ок - + Wrong password! - + Wallet password is incorrect - + Reuse static RPC password - + Application Version - + copied to clipboard скопировано в буфер - + + KDF version + + + + + KDF Version + + + + + KDF Version copied to clipboard. + + + + Search for Update @@ -3602,95 +3712,80 @@ Please select a new order. Тема - + Ask system's password before sending coins ? (2FA) Спрашивать системный пароль перед отправкой монет? (2FA) - + Application version Версия приложения - - MM2 version - Версия MM2 - - - - MM2 Version - Версия MM2 - - - - MM2 Version copied to clipboard. - Версия MM2 скопирована в буфер обмена. - - - - + + RPC Port - + RPC Port copied to clipboard. - - + + Peer ID - + Peer ID copied to clipboard. - + Qt version Версия Qt - + Qt Version Версия Qt - + Qt Version copied to clipboard. Версия Qt скопирована в буфер обмена. - + Logout Выход - + View seed and private keys Показать seed-фразу и приватные ключи - - + + Show Показать - + Setup Camouflage Password Установить камуфляжный пароль - + Open Установить - + Disclaimer and ToS Дисклеймер и Условия Использования @@ -3759,7 +3854,7 @@ Please select a new order. Баланс в фиате - + No Selectable coin. Нет монет для выбора. @@ -4101,7 +4196,7 @@ There is a toggle in settings where you can turn on/off the display of these tra Toast - + Click here to see the details Нажмите, чтобы узнать подробности @@ -4147,32 +4242,32 @@ There is a toggle in settings where you can turn on/off the display of these tra От - + Entered amount must be higher than 0. - + Select an order. - + MAX МАКС - + To Получатель - + Pick an order Выберите ордер - + Price Цена @@ -4192,68 +4287,79 @@ There is a toggle in settings where you can turn on/off the display of these tra %1 - + + Balance: - + + **** + + + + Pick a coin Выберите монету - + SWAP NOW - + Failed to place the order Не удалось разместить ордер - + Placed the order Ордер размещен - - + + Disable privacy mode to trade. + + + + + Search coins - + Min Value - + Hide disabled coins - + No buy orders found for %1. Не найдено ордеров на покупку дл] %1. - + You can check later or try to sell a different coin. Вы можете попробовать позже или попробовать продать другой актив. - + Calculating fee estimate... - + Total %1 fees: Всего %1 комиссий: - + %2 (%3) %2 (%3) @@ -4261,39 +4367,29 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - - Ticker Selectors - - - - - Trading Information - Торговая информация - - - + Order Book Ордербук - - Best Orders - Лучшие ордеры + + Order Form + - - Place Order - Разместить ордер + + Trading Information + Торговая информация @@ -4362,11 +4458,6 @@ There is a toggle in settings where you can turn on/off the display of these tra Date Дата - - - Unconfirmed - Не подтверждена - Transaction Hash @@ -4392,6 +4483,11 @@ There is a toggle in settings where you can turn on/off the display of these tra To Получатель + + + Awaiting confirmation + + Notes @@ -4448,12 +4544,12 @@ There is a toggle in settings where you can turn on/off the display of these tra Vertical - Order Book - Ордербук + %1 Orderbook + - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4570,7 +4666,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. @@ -4593,47 +4689,47 @@ This might take a few minutes... Вам нужен %1 для оплаты газа за %2 транзакции. - + Checksum verification failed for %1. Checksum верфикация неуспешна для %1. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x %1 адрес должен начинаться с 0x - + %1 address length is invalid, please use a valid address. %1 длина адреса не валидна, пожалуйста используйте валидный адрес. - + %1 address is invalid. некорректный адрес %1. - + Invalid checksum. Неверная чек-сумма. - + %1 address has invalid prefixes. у адреса %1 неверный префикс. - + Backend error: %1 Ошибка бэкенда: %1 diff --git a/atomic_defi_design/assets/languages/atomic_defi_tr.ts b/atomic_defi_design/assets/languages/atomic_defi_tr.ts index 4b7e47216f..05b7aca460 100644 --- a/atomic_defi_design/assets/languages/atomic_defi_tr.ts +++ b/atomic_defi_design/assets/languages/atomic_defi_tr.ts @@ -242,7 +242,7 @@ App - + Recover Funds Result Fon Kurtarma Sonucu @@ -474,27 +474,32 @@ Center - + Portfolio - + Wallet Cüzdan - + DEX DEX - + + DEX is disabled due to system clock synchronization issues. Please check your device time settings. + + + + Address Book Adres Defteri - + Fiat Döviz @@ -515,17 +520,17 @@ Chart - - Loading market data - Piyasa bilgisi yükleniyor + + Loading pair chart data + - + There is no chart data for this pair - + There is no chart data for %1 (testcoin) pairs @@ -759,83 +764,93 @@ ConfirmTradeModal - + Confirm Exchange Details Al-Sat Detaylarını Onayla - + This swap request can not be undone and is a final event! Bu takas isteği geri döndürülemez! - + Security configuration Güvenlik yapılandırması - + Read more about dPoW dPoW hakkında daha fazla bilgi - + Use custom protection settings for incoming %1 transactions TICKER %1 işlemleri için özel güvenlik ayarları kullan - + Enable Komodo dPoW security Komodo dPoW güvenliğini etkinleştir - + %1 confirmations for incoming %2 transactions Gelen %2 işlemleri için %1 onay - + This transaction can take up to 60 mins - DO NOT close this application! Bu işlem 60 dakikayı bulabilir - Programı KAPATMAYINIZ! - + Trade price is more than 50% different to CEX! Confirm? Takas ücreti CEX ile karşılaştırıldığında %50'den daha fazla farka sahip. Onaylıyor musunuz? - + Loading fees... - + <b>Total %1 fees:</b> <b>Toplam %1 işlem giderleri: </b> - + + Cancel all existing orders for %1/%2? + + + + + Good until cancelled (order will remain on orderbook until filled or cancelled) + + + + dPoW protected dPoW korumalı - + Required Confirmations Gereken Onaylar - + Warning, this atomic swap is not dPoW protected! Uyarı, bu atomik takas dPoW korumalı değil! - + Cancel İptal - + Confirm Onayla @@ -1411,14 +1426,14 @@ General - + %n day(s) - + %nd day @@ -1426,7 +1441,7 @@ - + %nh hours @@ -1434,7 +1449,7 @@ - + %nm minutes @@ -1442,7 +1457,7 @@ - + %ns seconds @@ -1450,7 +1465,7 @@ - + %nms milliseconds @@ -1458,117 +1473,117 @@ - + - - + <b>Taker tx fee:</b> - + <b>Dex tx fee:</b> - + <b>Dex fee:</b> - + <b>Maker tx fee:</b> - - %1 balance is zero + + Balance is zero! - + Activating %1 (%2%) - + Loading wallet... - + Min: %1 - + Enter an amount - + Trading Fee - + Minimum Trading Amount Minimum Takas Tutarı - + Wallet %1 already exists WALLETNAME - - + + Please wait for %1 to fully activate - + %1 balance is lower than the fees amount: %2 %3 - + Tradable (after fees) %1 balance is lower than minimum trade amount - + Please fill the price field - + Please fill the volume field - - + + %1 volume is lower than minimum trade amount - - + + %1 needs to be enabled in order to use %2 - - + + %1 balance needs to be funded, a non-zero balance is required to pay the gas of %2 transactions - + Unknown Error @@ -1747,17 +1762,17 @@ Try again or select 'Allow custom seed' to continue. List - + Funds are recoverable Fonlar kurtarılabilir - Best Orders - En İyi Emirler + Best Orders for %1 + - + Enter volume to see best orders. @@ -1765,17 +1780,27 @@ Try again or select 'Allow custom seed' to continue. ListDelegate - + %1 is not enabled - Do you want to enable it to be able to select %2 best orders ?<br><a href='#'>Yes</a> - <a href='#no'>No</a> %1 etkin değil - En iyi %2 siparişini seçebilmesi için etkinleştirmek istiyor musunuz ? <br><a href='#'>Evet</a> - <a href='#no'>Hayır</a> - + %1 is not enabled - Please enable it through the coin activation menu - + + Orderbook is disabled in privacy mode + + + + + Orderbook is disabled while creating maker orders + + + + This order requires a minimum amount of %1 %2 <br>You don't have enough funds.<br> %3 @@ -1797,8 +1822,8 @@ Try again or select 'Allow custom seed' to continue. - Initializing MM2 - MM2 başlatılıyor + Initializing KDF + @@ -1907,7 +1932,7 @@ They will be removed from the orderbook until you log in again. Al - + Swap Takasla @@ -1933,92 +1958,77 @@ They will be removed from the orderbook until you log in again. Musluk - - - + + Vote Info + + + + + + Public Key - + Copied to Clipboard Panoya Kopyalandı - + Explore - - Loading market data - Piyasa bilgisi yükleniyor - - - + There is no chart data for this ticker yet Henüz bu hisse senedi için grafik verisi yok - + Fetching transactions... - + No transactions available. - + Please wait, %1 is %2 - - % activated... + + Loading ticker chart data - - Trading Information - Al Sat Bilgisi + + % activated... + - + Chart Grafik - - + + Orders Emirler - - + + History Tarihçe - - - Place Order - Emir Ver - - - - Order Selected - Emir Seçildi - - - - START SWAP - Takası başlat - - + Address Book Adres Defteri @@ -2043,36 +2053,64 @@ They will be removed from the orderbook until you log in again. Etiketler - + + No contacts found. + + + + Edit Düzenle - + Delete Sil - + address copied to clipboard - + This contact does not have any registered address. + + + Taker Order + Alıcı Emri + + + + Maker Order + Yapıcı Emri + + + + Market + + + Orderbook + + + + + Best Orders + En İyi Emirler + MarketModeSelector - + Sell %1 TICKER - + Buy %1 TICKER @@ -2506,92 +2544,114 @@ They will be removed from the orderbook until you log in again. OrderForm - + Send Gönder - + Receive Al - + Max Maks - + Swap 25% of your tradable balance. - + + + + Diasble privacy mode to trade + + + + Swap 50% of your tradable balance. - + Swap 100% of your tradable balance. - + Min Volume - + Min amount to sell - + Min amount to receive - + Minimum accepted trade equals 10% of order volume. - + Minimum accepted trade equals 25% of order volume. - + Minimum accepted trade equals 50% of order volume. - + Min volume: - + Use custom minimum trade amount - + + Order Selected + Emir Seçildi + + + + CREATE MAKER SWAP + + + + + START TAKER SWAP + + + + Price Fiyat - + Reduce 1% relative to CEX market price. - + Use CEX market price. - + Increase 1% relative to CEX market price. @@ -2615,104 +2675,114 @@ They will be removed from the orderbook until you log in again. OrderModal - + Order Type - + Maker Order Yapıcı Emri - + Taker Order Alıcı Emri - + + Min Volume + + + + + Max Volume + + + + Refund State Geri Ödeme Durumu - + Your swap failed but the auto-refund process for your payment started already. Please wait and keep application opened until you receive your payment back Takas işlemi başarısız oldu, ancak otomatik geri ödeme süreci başladı. Lütfen bekleyin ve ödemenizi geri alana kadar uygulamayı açık tutun - + Date Tarih - + Recover Funds Fon Kurtar - + Refunding... - + View on Explorer Explorer'da Göster - + Cancel Order Emri İptal Et - + Error ID Hata ID - - + + Swap ID - + Maker Payment Sent Transaction ID - + Maker Payment Spent Transaction ID - + Maker Payment TXID - + Taker Payment Spent Transaction ID - + Taker Payment Sent Transaction ID - + Taker Payment TXID - - + + Error Log Hata Kaydı - + Close Kapat @@ -2726,7 +2796,7 @@ They will be removed from the orderbook until you log in again. - The selected order does not exist anymore, it might have been matched or canceled, and no order with a better price is available. + The selected order does not exist anymore, it might have been matched or cancelled, and no order with a better price is available. Please select a new order. @@ -2739,12 +2809,12 @@ Please select a new order. OrdersPage - + From Gönderen - + To Alan @@ -2770,12 +2840,12 @@ Please select a new order. CSV'yi dışa aktar - + Cancel All - + Please choose the CSV export name and location Lütfen CSV dışa aktarma adını ve konumunu seçin @@ -2880,23 +2950,23 @@ Please select a new order. Seçili - + Expensive Pahalı - + Expedient Uygun - + %1 compared to CEX PRICE_DIFF% CEX ile karşılaştırıldığında %1 - + CEXchange rate CEXchange kuru @@ -2919,17 +2989,17 @@ Please select a new order. CEXchange kuru - + Expensive Pahalı - + Expedient Uygun - + %1 compared to CEX PRICE_DIFF% CEX ile karşılaştırıldığında %1 @@ -2938,12 +3008,12 @@ Please select a new order. ProView - + Failed to place the order Emir başarısız oldu - + Placed the order Emir başarılı @@ -3128,172 +3198,192 @@ Please select a new order. SendModal - + Failed to send Gönderilemedi - + Prepare to send Göndermeye hazırlanıyor - + Address of the recipient - + Amount to send - + Gas price - + Cancel İptal - + Recipient's address Alıcı adresi - + The address has to be mixed case. Adres, büyük-küçük harf karışık olmalıdır. - + Failed to Broadcast - + Fix Düzelt - + MAX MAKS - + Fiat amount: Unavailable - + Fiat amount: %1 - + %1 amount: %2 - + Specify in Fiat - + Specify in Crypto - - Enter memo - - - - + Enable Custom Fees Özel İşlem Ücretlerini Etkinleştir - + Enter the custom fee Özel ücreti giriniz - + Gas Limit Gas Limiti - + Custom Fee can't be higher than the amount Özel İşlem Ücreti takas miktarından daha yüksek olamaz - + Not enough funds. Yetersiz bakiye. - - + + You have %1 AMT TICKER %1'niz var - - + + Enter memo (optional) + + + + + Use Custom IBC Channel + + + + + Enter channel ID + + + + + Only use custom IBC channel if you know what you are doing! + + + + + Avoid IBC transfers to centralized exchanges, as assets may be lost. + + + + + Only use custom fees if you know what you are doing! - + Prepare Hazırla - - + + Send Gönder - + %1 address TICKER - + copied to clipboard. - + Amount Miktar - + Memo - + Fees İşlem Ücreti - + Date Tarih - + Back Geri @@ -3344,11 +3434,6 @@ Please select a new order. SendResult - - - Transaction Complete! - İşlem Tamamlandı! - %1 txid @@ -3397,6 +3482,11 @@ Please select a new order. Transaction Hash İşlem Hash'i + + + Transaction Broadcast! + + Close @@ -3412,7 +3502,7 @@ Please select a new order. SettingModal - + Cancel İptal @@ -3499,7 +3589,7 @@ Please select a new order. - + Confirm Onayla @@ -3509,63 +3599,83 @@ Please select a new order. - + + Show orders after placement + + + + Disable 2FA? - + Enter your wallet password to confirm - + Type password - + 2FA status - + 2FA disabled successfully - - + + Ok Tamam - + Wrong password! - + Wallet password is incorrect - + Reuse static RPC password - + Application Version - + copied to clipboard - + + KDF version + + + + + KDF Version + + + + + KDF Version copied to clipboard. + + + + Search for Update @@ -3590,95 +3700,80 @@ Please select a new order. Tema - + Ask system's password before sending coins ? (2FA) Para göndermeden önce sistem parolası sorulsun mu ? (2FA) - + Application version Uygulama sürümü - - MM2 version - MM2 sürümü - - - - MM2 Version - - - - - MM2 Version copied to clipboard. - - - - - + + RPC Port - + RPC Port copied to clipboard. - - + + Peer ID - + Peer ID copied to clipboard. - + Qt version Qt sürümü - + Qt Version - + Qt Version copied to clipboard. - + Logout Çıkış - + View seed and private keys Seed ve özel anahtarları görüntüle - - + + Show Göster - + Setup Camouflage Password Kamuflaj Parolasını Ayarla - + Open - + Disclaimer and ToS Sorumluluk Reddi ve K.Ş. @@ -3747,7 +3842,7 @@ Please select a new order. Fiat Bakiye - + No Selectable coin. Seçilebilir Koin Yok @@ -4089,7 +4184,7 @@ There is a toggle in settings where you can turn on/off the display of these tra Toast - + Click here to see the details Detayları görmek için buraya tıklayın @@ -4135,32 +4230,32 @@ There is a toggle in settings where you can turn on/off the display of these tra Gönderen - + Entered amount must be higher than 0. - + Select an order. - + MAX MAKS - + To Alan - + Pick an order Emri seç - + Price Fiyat @@ -4180,68 +4275,79 @@ There is a toggle in settings where you can turn on/off the display of these tra %1 - + + Balance: - + + **** + + + + Pick a coin - + SWAP NOW - + Failed to place the order Emir başarısız oldu - + Placed the order Emir başarılı - - + + Disable privacy mode to trade. + + + + + Search coins - + Min Value - + Hide disabled coins - + No buy orders found for %1. - + You can check later or try to sell a different coin. - + Calculating fee estimate... - + Total %1 fees: Toplam %1 işlem giderleri: - + %2 (%3) %2 (%3) @@ -4249,39 +4355,29 @@ There is a toggle in settings where you can turn on/off the display of these tra TradeViewHeader - + Pro View Settings - + Display Settings - - Ticker Selectors - - - - - Trading Information - Al Sat Bilgisi - - - + Order Book Emir Defteri - - Best Orders - En İyi Emirler + + Order Form + - - Place Order - Emir Ver + + Trading Information + Al Sat Bilgisi @@ -4350,11 +4446,6 @@ There is a toggle in settings where you can turn on/off the display of these tra Date Tarih - - - Unconfirmed - Onaylanmamış - Transaction Hash @@ -4380,6 +4471,11 @@ There is a toggle in settings where you can turn on/off the display of these tra To Alan + + + Awaiting confirmation + + Notes @@ -4436,12 +4532,12 @@ There is a toggle in settings where you can turn on/off the display of these tra Vertical - Order Book - Emir Defteri + %1 Orderbook + - - traded 24hrs: %1 + + 24hrs | %1 | %2 trades @@ -4558,7 +4654,7 @@ This might take a few minutes... atomic_dex::settings_page - + An error has occurred. @@ -4581,47 +4677,47 @@ This might take a few minutes... %2 işlemi için gaz ödemek üzere %1'e sahip olmanız gerekir. - + Checksum verification failed for %1. %1 için sağlama toplamı doğrulaması başarısız oldu. - + Invalid checksum for %1. Click the button to convert to mixed case address. - + Legacy address used for %1. Click the button to convert to a Cashaddress. - + %1 address must be prefixed with 0x %1 adresinin önüne 0x konulmalı - + %1 address length is invalid, please use a valid address. %1 adres uzunluğu geçersiz, lütfen geçerli bir adres kullanın. - + %1 address is invalid. - + Invalid checksum. - + %1 address has invalid prefixes. - + Backend error: %1 diff --git a/ci_tools_atomic_dex/ci_scripts/choosenim.sh b/ci_tools_atomic_dex/ci_scripts/choosenim.sh new file mode 100755 index 0000000000..b255b48ab1 --- /dev/null +++ b/ci_tools_atomic_dex/ci_scripts/choosenim.sh @@ -0,0 +1,196 @@ +#!/bin/sh +# Copyright 2017 Dominik Picheta and Nim developers. +# +# Licensed under the BSD-3-Clause license. +# +# This script performs some platform detection, downloads the latest version +# of choosenim and initiates its installation. + +set -u +set -e + + +url_prefix="https://github.com/dom96/choosenim/releases/download/" + +temp_prefix="${TMPDIR:-/tmp}" + +CHOOSE_VERSION="${CHOOSENIM_CHOOSE_VERSION:-stable}" + +need_tty=yes +debug="" + +has_curl() { + command -v curl >/dev/null 2>&1 +} + +has_wget() { + command -v wget >/dev/null 2>&1 +} + +install() { + get_platform || return 1 + local platform=$RET_VAL + local stable_version=0.8.4 + local filename="choosenim-$stable_version"_"$platform" + local url="$url_prefix"v"$stable_version/$filename" + local ext="" + + case $platform in + *macosx_amd64* | *linux_amd64* ) + ;; + *windows_amd64* ) + # Download ZIP for Windows + local ext=".exe" + local filename="$filename$ext" + local url="$url$ext" + ;; + * ) + say_err "Sorry, your platform ($platform) is not supported by choosenim." + say_err "You will need to install Nim using an alternative method." + say_err "See the following link for more info: https://nim-lang.org/install.html" + exit 1 + ;; + esac + + say "Downloading $filename" + if has_curl; then + curl -sSfL "$url" -o "$temp_prefix/$filename" + elif has_wget; then + wget -qO "$temp_prefix/$filename" "$url" + fi + chmod +x "$temp_prefix/$filename" + + if [ "$need_tty" = "yes" ]; then + # The installer is going to want to ask for confirmation by + # reading stdin. This script was piped into `sh` though and + # doesn't have stdin to pass to its children. Instead we're going + # to explicitly connect /dev/tty to the installer's stdin. + if [ ! -t 1 ]; then + err "Unable to run interactively. Run with -y to accept defaults." + fi + + # Install Nim from desired channel. + "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall ${debug} < /dev/tty + else + "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall -y ${debug} + fi + + # Copy choosenim binary to Nimble bin. + local nimbleBinDir=`"$temp_prefix/$filename" --getNimbleBin` + cp "$temp_prefix/$filename" "$nimbleBinDir/choosenim$ext" + say "ChooseNim installed in $nimbleBinDir" + say "You must now ensure that the Nimble bin dir is in your PATH." + if [ "$platform" != "windows_amd64" ]; then + say "Place the following line in the ~/.profile or ~/.bashrc file." + say " export PATH=$nimbleBinDir:\$PATH" + case "${SHELL:=sh}" in + *fish*) + say "Running fish shell?" + say "set -ga fish_user_paths $nimbleBinDir" + ;; + esac + fi +} + +get_platform() { + # Get OS/CPU info and store in a `myos` and `mycpu` variable. + local ucpu=`uname -m` + local uos=`uname` + local ucpu=`echo $ucpu | tr "[:upper:]" "[:lower:]"` + local uos=`echo $uos | tr "[:upper:]" "[:lower:]"` + + case $uos in + *linux* ) + local myos="linux" + ;; + *dragonfly* ) + local myos="freebsd" + ;; + *freebsd* ) + local myos="freebsd" + ;; + *openbsd* ) + local myos="openbsd" + ;; + *netbsd* ) + local myos="netbsd" + ;; + *darwin* ) + local myos="macosx" + if [ "$HOSTTYPE" = "x86_64" ] ; then + local ucpu="amd64" + fi + if [ "$HOSTTYPE" = "arm64" ] ; then + # TODO: We don't have arm binaries for choosenim so far, rely on Rosetta. + local ucpu="amd64" + fi + ;; + *aix* ) + local myos="aix" + ;; + *solaris* | *sun* ) + local myos="solaris" + ;; + *haiku* ) + if has_curl; then + stable_version=`curl -sSfL https://nim-lang.org/choosenim/stable` + elif has_wget; then + stable_version=`wget -qO - https://nim-lang.org/choosenim/stable` + fi + err "unknown operating system: $uos" + ;; + esac + + case $ucpu in + *i386* | *i486* | *i586* | *i686* | *bepc* | *i86pc* ) + local mycpu="i386" ;; + *amd*64* | *x86-64* | *x86_64* ) + local mycpu="amd64" ;; + *sparc*|*sun* ) + local mycpu="sparc" + if [ "$(isainfo -b)" = "64" ]; then + local mycpu="sparc64" + fi + ;; + *ppc64* ) + local mycpu="powerpc64" ;; + *power*|*ppc* ) + local mycpu="powerpc" ;; + *mips* ) + local mycpu="mips" ;; + *arm*|*armv6l* ) + local mycpu="arm" ;; + *aarch64* ) + local mycpu="arm64" ;; + *) + err "unknown processor: $ucpu" + ;; + esac + + RET_VAL="$myos"_"$mycpu" +} + +say() { + echo "choosenim-init: $1" +} + +say_err() { + say "Error: $1" >&2 +} + +err() { + say_err "$1" + exit 1 +} + + +# check if we have to use /dev/tty to prompt the user +while getopts "dy" opt; do + case "$opt" in + y) need_tty=no + ;; + d) debug="--debug" + esac +done + +install diff --git a/ci_tools_atomic_dex/ci_scripts/linux_script_docker.sh b/ci_tools_atomic_dex/ci_scripts/linux_script_docker.sh new file mode 100755 index 0000000000..8f5aa4ab92 --- /dev/null +++ b/ci_tools_atomic_dex/ci_scripts/linux_script_docker.sh @@ -0,0 +1,52 @@ +#!/bin/bash + + +# Update `ninja` to the latest compatible version (>= 1.10.2) +wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip +sudo unzip -o ninja-linux.zip -d /usr/bin/ +sudo chmod +x /usr/bin/ninja + +# Install LLVM/Clang +wget https://apt.llvm.org/llvm.sh +chmod +x llvm.sh +sudo ./llvm.sh 12 + +# Set Clang as the default compiler +sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 777 +sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 777 + +# Set GCC/G++ 9 as the fallback compiler +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 777 +sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 777 + +# Install libc++ for C++20 support +sudo apt-get install -y libc++-11-dev libc++abi-11-dev + +# Set environment variables for Clang +export CXX=clang++-12 +export CC=clang-12 + +# Install CMake 3.27.1 +wget https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.tar.gz +tar -xvzf cmake-3.27.1-linux-x86_64.tar.gz +sudo cp -r cmake-3.27.1-linux-x86_64/* /usr/local/ +sudo cp -r cmake-3.27.1-linux-x86_64/* /usr/ +cmake --version + +## tar +wget --timeout=10 --tries=3 https://ftp.gnu.org/gnu/tar/tar-1.32.tar.gz || wget --timeout=10 --tries=3 https://mirrors.sjtug.sjtu.edu.cn/gnu/tar/tar-1.32.tar.gz +tar xvf tar-1.32.tar.gz +cd tar-1.32 +export FORCE_UNSAFE_CONFIGURE=1 +./configure +sudo make -j install +sudo ln -sf /bin/tar /usr/local/bin/tar +sudo update-alternatives --install /usr/bin/tar tar /usr/local/bin/tar 777 + +# get libwally +git clone https://github.com/KomodoPlatform/libwally-core.git --recurse-submodules +cd libwally-core +./tools/autogen.sh +./configure --disable-shared +sudo make -j3 install +cd .. diff --git a/ci_tools_atomic_dex/ci_scripts/osx_script.sh b/ci_tools_atomic_dex/ci_scripts/osx_script.sh index 35c101b085..a6653aa795 100755 --- a/ci_tools_atomic_dex/ci_scripts/osx_script.sh +++ b/ci_tools_atomic_dex/ci_scripts/osx_script.sh @@ -12,13 +12,16 @@ brew install autoconf \ gnu-sed \ coreutils \ libtool \ - llvm \ gnu-getopt +brew unlink python@3.12 +brew install llvm +brew link --overwrite python@3.12 + pip3 install yq export CC=clang export CXX=clang++ -export MACOSX_DEPLOYMENT_TARGET=10.15 +export MACOSX_DEPLOYMENT_TARGET=14.2 # get curl #git clone https://github.com/KomodoPlatform/curl.git diff --git a/ci_tools_atomic_dex/dmg-packager/package.sh b/ci_tools_atomic_dex/dmg-packager/package.sh index 138c354509..1b1723760b 100755 --- a/ci_tools_atomic_dex/dmg-packager/package.sh +++ b/ci_tools_atomic_dex/dmg-packager/package.sh @@ -2,6 +2,8 @@ # Edited for KomodoPlatform/atomicDEX-Pro +set -x + # Original version is by Andy Maloney # http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/ @@ -69,9 +71,11 @@ if [ $? -ne 0 ]; then exit fi +sleep 5 # create the temp DMG file -hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \ - -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}" +for i in {1..5}; do hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \ + -fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}" && break || echo "DMG create attempt $i" && sleep 15; done + echo "Created DMG: ${DMG_TMP}" diff --git a/ci_tools_atomic_dex/linux_misc/linuxdeployqt-continuous-x86_64.AppImage b/ci_tools_atomic_dex/linux_misc/linuxdeployqt-continuous-x86_64.AppImage index 7a4ba91219..be8cf1844e 100755 Binary files a/ci_tools_atomic_dex/linux_misc/linuxdeployqt-continuous-x86_64.AppImage and b/ci_tools_atomic_dex/linux_misc/linuxdeployqt-continuous-x86_64.AppImage differ diff --git a/ci_tools_atomic_dex/src/generate.nim b/ci_tools_atomic_dex/src/generate.nim index d53b6a1ff8..a1407f483b 100644 --- a/ci_tools_atomic_dex/src/generate.nim +++ b/ci_tools_atomic_dex/src/generate.nim @@ -17,6 +17,6 @@ proc generate_solution*(build_type: string, osx_sdk_path: string, compiler_path: os.getCurrentDir().parentDir().parentDir() when defined(osx): if os.dirExists(osx_sdk_path): - cmd_line = cmd_line & " -DCMAKE_OSX_SYSROOT=" & osx_sdk_path & " -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15" + cmd_line = cmd_line & " -DCMAKE_OSX_SYSROOT=" & osx_sdk_path & " -DCMAKE_OSX_DEPLOYMENT_TARGET=14.2" echo "cmd line: " & cmd_line discard execCmd(cmd_line) diff --git a/cmake/install/linux/linux_post_install.cmake b/cmake/install/linux/linux_post_install.cmake index 23eae65e00..4eb4a2225c 100644 --- a/cmake/install/linux/linux_post_install.cmake +++ b/cmake/install/linux/linux_post_install.cmake @@ -34,7 +34,7 @@ else () message(FATAL_ERROR "Didn't find ${PROJECT_APP_PATH}") endif () -set(LINUX_DEPLOY_PATH ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/linux_misc/linuxdeployqt-7-x86_64.AppImage) +set(LINUX_DEPLOY_PATH ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/linux_misc/linuxdeployqt-continuous-x86_64.AppImage) if (EXISTS ${LINUX_DEPLOY_PATH}) message(STATUS "linuxdeployqt path is -> ${LINUX_DEPLOY_PATH}") else () @@ -62,8 +62,8 @@ foreach (current_lib ${LIST_LIBS}) endforeach () message(STATUS "Executing linuxdeployqt to fix dependencies") -message(STATUS "Executing cmd: [${LINUX_DEPLOY_PATH} ${PROJECT_BIN_PATH} -qmldir=${PROJECT_QML_DIR} -bundle-non-qt-libs -exclude-libs='libnss3.so,libnssutil3.so' -unsupported-allow-new-glibc -no-copy-copyright-files -verbose=1 -extra-plugins=iconengines,platformthemes/libqgtk3.so -appimage]") -execute_process(COMMAND ${LINUX_DEPLOY_PATH} ${PROJECT_BIN_PATH} -qmldir=${PROJECT_QML_DIR} -bundle-non-qt-libs -exclude-libs='libnss3.so,libnssutil3.so' -unsupported-allow-new-glibc -no-copy-copyright-files -verbose=1 -extra-plugins=iconengines,platformthemes/libqgtk3.so -appimage +message(STATUS "Executing cmd: [${LINUX_DEPLOY_PATH} ${PROJECT_BIN_PATH} -qmldir=${PROJECT_QML_DIR} -bundle-non-qt-libs -exclude-libs='libnss3.so,libnssutil3.so' -unsupported-allow-new-glibc -no-copy-copyright-files -extra-plugins=iconengines,platformthemes/libqgtk3.so -appimage -verbose=2]") +execute_process(COMMAND ${LINUX_DEPLOY_PATH} ${PROJECT_BIN_PATH} -qmldir=${PROJECT_QML_DIR} -bundle-non-qt-libs -exclude-libs='libnss3.so,libnssutil3.so' -unsupported-allow-new-glibc -no-copy-copyright-files -extra-plugins=iconengines,platformthemes/libqgtk3.so -appimage -verbose=2 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) @@ -71,6 +71,8 @@ execute_process(COMMAND ${LINUX_DEPLOY_PATH} ${PROJECT_BIN_PATH} -qmldir=${PROJE message(STATUS "Renaming ${CMAKE_SOURCE_DIR}/${DEX_PROJECT_NAME}-${VERSION_ID}-x86_64.AppImage to ${CMAKE_SOURCE_DIR}/${DEX_PROJECT_NAME}-linux-${VERSION_ID}-x86_64.AppImage") file(RENAME ${CMAKE_SOURCE_DIR}/${DEX_PROJECT_NAME}-${VERSION_ID}-x86_64.AppImage ${CMAKE_SOURCE_DIR}/${DEX_PROJECT_NAME}-linux-${VERSION_ID}-x86_64.AppImage) +file(COPY ${CMAKE_SOURCE_DIR}/${DEX_PROJECT_NAME}-linux-${VERSION_ID}-x86_64.AppImage DESTINATION ${TARGET_APP_PATH}) + message(STATUS "Copying ${PROJECT_APP_PATH} to ${TARGET_APP_PATH}/${PROJECT_APP_DIR}") file(COPY ${PROJECT_APP_PATH} DESTINATION ${TARGET_APP_PATH}) execute_process(COMMAND zip -r ${DEX_PROJECT_NAME}-linux-${VERSION_ID}.zip AntaraAtomicDexAppDir @@ -82,5 +84,3 @@ execute_process(COMMAND tar --zstd -cf ${DEX_PROJECT_NAME}-linux-${VERSION_ID}.t WORKING_DIRECTORY ${TARGET_APP_PATH} ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) - -file(COPY ${CMAKE_SOURCE_DIR}/${DEX_PROJECT_NAME}-linux-${VERSION_ID}-x86_64.AppImage DESTINATION ${TARGET_APP_PATH}) diff --git a/cmake/install/macos/osx_post_install.cmake b/cmake/install/macos/osx_post_install.cmake index 51f1c6cc4d..5aa979b41f 100644 --- a/cmake/install/macos/osx_post_install.cmake +++ b/cmake/install/macos/osx_post_install.cmake @@ -54,7 +54,7 @@ if (NOT EXISTS ${CMAKE_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.dmg) ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) - execute_process(COMMAND codesign --deep --force -v -s "$ENV{MAC_SIGN_IDENTITY}" -o runtime --timestamp ${PROJECT_APP_PATH}/Contents/Resources/assets/tools/mm2/${DEX_API} + execute_process(COMMAND codesign --deep --force -v -s "$ENV{MAC_SIGN_IDENTITY}" -o runtime --timestamp ${PROJECT_APP_PATH}/Contents/Resources/assets/tools/kdf/${DEX_API} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) diff --git a/cmake/project.metadata.cmake b/cmake/project.metadata.cmake index 52731c3f45..109a9f1543 100644 --- a/cmake/project.metadata.cmake +++ b/cmake/project.metadata.cmake @@ -6,7 +6,7 @@ set(DEX_PROJECT_NAME "firodex") set(DEX_DISPLAY_NAME "Firo Dex") set(DEX_MAINTENANCE_TOOL_NAME "Firo Dex Maintenance Tool") set(DEX_COMPANY "Firo") -set(DEX_VERSION "0.7.0") +set(DEX_VERSION "0.7.2") set(DEX_WEBSITE "https://firo.org/") set(DEX_SUPPORT_PAGE "https://firo.org/guide/") set(DEX_DISCORD "https://discord.com/invite/TGZPRbRT3Y") diff --git a/docker-build-linux.sh b/docker-build-linux.sh new file mode 100755 index 0000000000..01ffb9e9e1 --- /dev/null +++ b/docker-build-linux.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +sudo rm -rf build bundled +# Define the target for the build (Debug or Release) +TARGET="${1:-Debug}" + +docker run -v "$(pwd)":/build/komodo-wallet-desktop --privileged -v /dev/fuse:/dev/fuse \ + kw-build-container \ + bash -c "cd /build/komodo-wallet-desktop/ci_tools_atomic_dex && \ + nimble build -y && \ + ./ci_tools_atomic_dex build $TARGET && \ + ./ci_tools_atomic_dex bundle $TARGET" 2>&1 | tee build.log + +# Check if the build was successful +if [ "${PIPESTATUS[0]}" -eq 0 ]; then + echo "Build completed successfully!" +else + echo "Build failed. Check build.log for details." + echo "Make sure you run 'docker build -t kw-build-container .' first" + exit 1 +fi + +sudo chown $USER:$USER bundled -R diff --git a/docs/BUILD.md b/docs/BUILD.md new file mode 100644 index 0000000000..84dd456b33 --- /dev/null +++ b/docs/BUILD.md @@ -0,0 +1,378 @@ +# Building Komodo Wallet Desktop on Linux + +_Note: These instructions may not be up to date. Please refer to the github actions workflows for more recent build requirements_ + + +## Linux builds with docker + +From project root, run `docker build -t kw-build-container .` to create a build environment container. +Run `./docker-build-linux.sh` to build the app +Run `docker run -it kw-build-container bash` to enter the container for debugging. +Output will be found in the `bundled` subfolder. + +### Prerequisites + +- Clang C++ 17 compiler (clang-12 minimum) +- [CMake](https://cmake.org/install/) 3.18 minimum + + +### Clone Komodo Wallet Desktop repository (with submodules) + +`git clone --recurse-submodules https://github.com/KomodoPlatform/komodo-wallet-desktop.git` + + +### Install Qt + +```bash +python3 -m venv .venv +.venv/bin/pip install aqtinstall==3.1.1 +.venv/bin/python -m aqt install-qt linux desktop 5.15.2 -O $HOME/Qt -b https://qt-mirror.dannhauer.de/ -m qtcharts debug_info qtwebengine +``` + +Add the following environment variables to your `~/.bashrc` or `~/.zshrc` profiles: + * `QT_INSTALL_CMAKE_PATH` equal to the CMake QT path + * `QT_ROOT` equal to the QT root installation folder + +e.g.: +```bash +export QT_INSTALL_CMAKE_PATH=~/Qt/5.15.2/gcc_64/lib/cmake +export QT_ROOT=~/Qt/5.15.2 +``` + +Make sure Qt binaries are on the PATH. E.g. + +```bash +export PATH=$PATH:/home/username/Qt/5.15.2/gcc_64/bin +``` + +### Install Linux dependencies (aptitude) + +```bash +sudo apt-get install build-essential \ + libgl1-mesa-dev \ + ninja-build \ + curl \ + wget \ + zstd \ + software-properties-common \ + lsb-release \ + libpulse-dev \ + libtool \ + autoconf \ + unzip \ + libssl-dev \ + libxkbcommon-x11-0 \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb1-dev \ + libxcb-keysyms1-dev \ + libxcb-render-util0-dev \ + libxcb-xinerama0 \ + libgstreamer-plugins-base1.0-dev \ + git -y + +# get llvm +wget https://apt.llvm.org/llvm.sh +chmod +x llvm.sh +sudo ./llvm.sh 12 + +# set clang version +sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 777 +sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 777 +sudo apt-get update +# if you want to use libclang +#sudo apt-get install libc++abi-12-dev libc++-12-dev -y + +# Add the following environment variables to your `~/.bashrc` or `~/.zshrc` profiles: + +#if you want to use libclang +#export CXXFLAGS=-stdlib=libc++ +#export LDFLAGS=-stdlib=libc++ +export CXX=clang++-12 +export CC=clang-12 +``` + +### Install Linux dependencies (rpm) + +```bash +sudo dnf update +sudo dnf groupinstall "Development Tools" "Development Libraries" +sudo dnf install wget \ + curl \ + cmake \ + perl \ + calng12-devel \ + ninja-build \ + zstd \ + mesa-libGL-devel \ + redhat-lsb-core \ + libtool \ + autoconf \ + zip \ + unzip \ + openssl \ + openssl-devel \ + libxkbcommon-x11 \ + libxcb-* \ + gstreamer1-plugins-base-devel + +# Fresh versions of RedHat (9+) and Fedora (34+) come with clang15 and llvm15, no extra packages or configuration is required +``` + + +### Install Libwally (Windows only) + +```bash +git clone https://github.com/KomodoPlatform/libwally-core.git + +``` + + + +### Bootstrap VCPKG modules + +Install vcpkg from within the `ci_tools_atomic_dex` folder: + +```bash +cd komodo-wallet-desktop/ci_tools_atomic_dex/vcpkg-repo +./bootstrap-vcpkg.sh +``` + + +### Build komodo-wallet-desktop (portable) + +In your shell command prompt (Powershell/Zsh/Bash), from within the `root` folder (e.g. ~/komodo-wallet-desktop), type: + +```bash +cd komodo-wallet-desktop\build # create the 'build' folder if it doesn't exist +cmake -DCMAKE_BUILD_TYPE=Release ../ # add -GNinja if you want to use the ninja build system. +cmake --build . --config Release --target komodo-wallet +``` + + +### Bundle komodo-wallet-desktop (installer) + + +``` +cd komodo-wallet-desktop\build # create the 'build' folder if it doesn't exist +cmake -DCMAKE_BUILD_TYPE=Release -GNinja ../ +cmake --build . --config Release --target komodo-wallet +ninja install +``` + + +# Building Atomicdex Desktop on MacOS + + +### Prerequisites + +- Clang C++ 17 compiler (clang-12 minimum) + - on macOS Catalina/BigSur, Apple Clang 12.0 is picked by default +- [CMake](https://cmake.org/install/) 3.18 minimum +- [brew](https://brew.sh) +- macOS [command line tools](https://developer.apple.com/downloads) + + +### Clone AtomicDEX repository (with submodules) + +`git clone --recurse-submodules https://github.com/KomodoPlatform/komodo-wallet-desktop.git` + + +### Install Qt + +```bash +# Could also be pip3 depending of your python installation +pip install aqtinstall +python3 -m aqt install-qt mac desktop 5.15.2 clang_64 -O $HOME/Qt -b https://qt-mirror.dannhauer.de/ -m qtcharts debug_info qtwebengine +``` + +Add the following environment variables to your `~/.bashrc` or `~/.zshrc` profile: + * `QT_INSTALL_CMAKE_PATH` equal to the CMake QT path + * `QT_ROOT` equal to the QT root installation folder + +e.g.: + +```bash +export QT_INSTALL_CMAKE_PATH=/Users/SatoshiNakamoto/Qt/5.15.2/clang_64/lib/cmake +export QT_ROOT=/Users/SatoshiNakamoto/Qt/5.15.2 +``` + + +### Install brew requirements + +```bash +brew install autoconf \ + automake \ + libtool \ + pkgconfig \ + wget \ + ninja \ + gnu-sed \ + coreutils \ + gnu-getopt +``` + + +### Installing OSX SDK's (optional, for older systems): + +```bash +git clone https://github.com/phracker/MacOSX-SDKs.git ~/MacOSX-SDKs +``` + + +### Install Libwally + +```bash +git clone https://github.com/KomodoPlatform/libwally-core.git +cd libwally-core +./tools/autogen.sh +PYTHON_VERSION=3 ./configure --disable-shared # configure requires you to pass python version to use instead of deprecated python2 +sudo make -j2 install +``` + + +### Bootstrap VCPKG modules + +```bash +cd komodo-wallet-desktop\ci_tools_atomic_dex\vcpkg-repo +./bootstrap-vcpkg.sh +``` + +### Build komodo-wallet-desktop (portable) + +In your shell command prompt (Powershell/Zsh/Bash), from within the `root` folder (e.g. ~/komodo-wallet-desktop), type: + +```bash +cd komodo-wallet-desktop\build # create the 'build' folder if it doesn't exist +cmake -DCMAKE_BUILD_TYPE=Release ../ # add -GNinja if you want to use the ninja build system. +cmake --build . --config Release --target komodo-wallet +``` + +### Bundle komodo-wallet-desktop (installer) + + +On MacOS some extra variables in the environment are required to be able to bundle and sign the app: + +```bash +export PATH=$HOME/Qt/5.15.2/clang_64/bin:$PATH + +## Need to be your Developer ID Application if you want to fork/rebundle the app on OSX +## This also assume your certificates is already in your MacOS Keystore +export MAC_SIGN_IDENTITY="Developer ID Application: Satoshi Nakamoto (923YHAAKNY)" + +## This is app deployment password that can be generate in your apple account profile +export APPLE_ATOMICDEX_PASSWORD="foo-bar-foo-bar" + +## This is your apple id email +export APPLE_ID="satoshinakamoto@bitcoin.com" +``` + +``` +cd komodo-wallet-desktop\build # create the 'build' folder if it doesn't exist +cmake -DCMAKE_BUILD_TYPE=Release -GNinja ../ +cmake --build . --config Release --target komodo-wallet +ninja install +``` + + + +# Building Atomicdex Desktop on Windows + + +### Prerequisites + +- Visual Studio 2019 with [Desktop development with C++](https://docs.microsoft.com/en-gb/cpp/build/vscpp-step-0-installation?view=vs-2019). +- [CMake](https://cmake.org/install/) 3.18 minimum + + +### Clone AtomicDEX repository (with submodules) + +`git clone --recurse-submodules https://github.com/KomodoPlatform/komodo-wallet-desktop.git` + + +### Install Qt + +```powershell +# Could also be pip3 depending of your python installation +python3.exe -m pip install aqtinstall +python3.exe -m aqt install-qt windows desktop "5.15.2" win64_msvc2019_64 -O "C:\Qt" -m qtcharts debug_info qtwebengine -b https://qt-mirror.dannhauer.de/ +``` + +### Install Scoop requirements + +In your powershell execute: + +``` +Set-ExecutionPolicy RemoteSigned -scope CurrentUser +Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') +``` + +After scoop installation execute in powershell as Admin: + +``` +scoop install llvm --global +scoop install ninja --global +scoop install cmake --global +scoop install git --global +scoop install 7zip --global +``` + +- Next, add a `QT_INSTALL_CMAKE_PATH` environment variable pointing to the msvc_2019x64 location + +e.g.: `$Env:QT_INSTALL_CMAKE_PATH = "C:\Qt\5.15.2\msvc2019_64"` + +- Then, also add a `QT_ROOT` environment variable pointing to the Qt root folder location + +e.g.: `$Env:QT_ROOT = "C:\Qt"` + +We advice to set it permanently through the environment variable manager on windows. + + +### Install Libwally + +Libwally build requires tools only available in Development powershell environment. If unsure, start powershell from inside VisualStudio to execute following steps: + +``` +git clone -b v0.8.5 --recurse-submodules https://github.com/KomodoPlatform/libwally-core.git +cd libwally-core +$env:LIBWALLY_DIR=$pwd + +git submodule init +git submodule sync --recursive +git submodule update --init --recursive +Get-ChildItem -Filter build -Recurse -ErrorAction SilentlyContinue + +"$env:LIBWALLY_DIR\tools\msvc\gen_ecmult_static_context.bat" +copy src\ccan\ccan\str\hex\hex.c src\ccan\ccan\str\hex\hex_.c +copy src\ccan\ccan\base64\base64.c src\ccan\ccan\base64\base64_.c +cl /utf-8 /DUSE_ECMULT_STATIC_PRECOMPUTATION /DECMULT_WINDOW_SIZE=15 /DWALLY_CORE_BUILD /DHAVE_CONFIG_H /DSECP256K1_BUILD /I$env:LIBWALLY_DIR\src\wrap_js\windows_config /I$env:LIBWALLY_DIR /I$env:LIBWALLY_DIR\src /I$env:LIBWALLY_DIR\include /I$env:LIBWALLY_DIR\src\ccan /I$env:LIBWALLY_DIR\src\ccan\base64 /I$env:LIBWALLY_DIR\src\secp256k1 /Zi /LD src/aes.c src/anti_exfil.c src/base58.c src/base64.c src/bech32.c src/bip32.c src/bip38.c src/bip39.c src/blech32.c src/ecdh.c src/elements.c src/hex.c src/hmac.c src/internal.c src/mnemonic.c src/pbkdf2.c src/pullpush.c src/psbt.c src/script.c src/scrypt.c src/sign.c src/symmetric.c src/transaction.c src/wif.c src/wordlist.c src/ccan/ccan/crypto/ripemd160/ripemd160.c src/ccan/ccan/crypto/sha256/sha256.c src/ccan/ccan/crypto/sha512/sha512.c src/ccan/ccan/base64/base64_.c src\ccan\ccan\str\hex\hex_.c src/secp256k1/src/secp256k1.c src/secp256k1/src/precomputed_ecmult_gen.c src/secp256k1/src/precomputed_ecmult.c /Fewally.dll + +# After cloning komodo-wallet-desktop, copy the wally.dll file +Copy-Item "$env:LIBWALLY_DIR\wally.dll" -Destination "komodo-wallet-desktop\wally\wally.dll" -force +``` + +### Bootstrap VCPKG modules + +```bash +cd komodo-wallet-desktop\ci_tools_atomic_dex\vcpkg-repo +.\bootstrap-vcpkg.bat +``` + +### Build komodo-wallet-desktop (portable) + +In your shell command prompt (Powershell/Zsh/Bash), from within the `root` folder (e.g. ~/komodo-wallet-desktop), started as Administrator, type: + +```bash +cd komodo-wallet-desktop\build # create the 'build' folder if it doesn't exist +cmake -DCMAKE_BUILD_TYPE=Release ../ -GNinja +cmake --build . --config Release --target komodo-wallet +``` + +### Bundle komodo-wallet-desktop (installer) + +``` +cd komodo-wallet-desktop\build # create the 'build' folder if it doesn't exist +cmake -DCMAKE_BUILD_TYPE=Release -GNinja ../ +cmake --build . --config Release --target komodo-wallet +ninja install +``` \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5d49ac68a..35673f74e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -113,11 +113,11 @@ add_executable(${PROJECT_NAME}_tests MACOSX_BUNDLE ${ICON} ##! API tests/api/coingecko/coingecko.tests.cpp tests/api/komodo_prices/komodo.prices.tests.cpp - tests/api/mm2/mm2.api.address_format.tests.cpp - tests/api/mm2/mm2.api.utxo_merge_params.tests.cpp - tests/api/mm2/mm2.api.balance_infos.tests.cpp - tests/api/mm2/mm2.fraction.tests.cpp - tests/api/mm2/mm2.rpc2.trade_preimage.tests.cpp + tests/api/kdf/kdf.api.address_format.tests.cpp + tests/api/kdf/kdf.api.utxo_merge_params.tests.cpp + tests/api/kdf/kdf.api.balance_infos.tests.cpp + tests/api/kdf/kdf.fraction.tests.cpp + tests/api/kdf/kdf.rpc2.trade_preimage.tests.cpp ##! CFG tests/config/coins.cfg.tests.cpp @@ -125,9 +125,9 @@ add_executable(${PROJECT_NAME}_tests MACOSX_BUNDLE ${ICON} ##! API tests/api/coingecko/coingecko.tests.cpp tests/api/komodo_prices/komodo.prices.tests.cpp - tests/api/mm2/mm2.rpc2.trade_preimage.tests.cpp - tests/api/mm2/mm2.fraction.tests.cpp - tests/api/mm2/enable_bch_with_tokens_rpc_tests.cpp + tests/api/kdf/kdf.rpc2.trade_preimage.tests.cpp + tests/api/kdf/kdf.fraction.tests.cpp + tests/api/kdf/enable_bch_with_tokens_rpc_tests.cpp ##! Utilities tests/utilities/qt.utilities.tests.cpp diff --git a/src/app/app.cpp b/src/app/app.cpp index 54cfc55fb4..f2bf63ef11 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -40,11 +40,11 @@ //! Project Headers #include "app.hpp" #include "atomicdex/services/exporter/exporter.service.hpp" -#include "atomicdex/services/mm2/auto.update.maker.order.service.hpp" +#include "atomicdex/services/kdf/auto.update.maker.order.service.hpp" #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" #include "atomicdex/services/price/coingecko/coingecko.wallet.charts.hpp" -#include "atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp" #include "atomicdex/services/price/orderbook.scanner.service.hpp" +#include "atomicdex/services/sync/timesync.checker.service.hpp" namespace { @@ -74,17 +74,17 @@ namespace atomic_dex std::vector coins_std{}; coins_std.reserve(coins.size()); - atomic_dex::mm2_service& mm2 = get_mm2(); + atomic_dex::kdf_service& kdf = get_kdf(); std::unordered_set extra_coins; for (auto&& coin : coins) { - auto coin_info = mm2.get_coin_info(coin.toStdString()); + auto coin_info = kdf.get_coin_info(coin.toStdString()); if (coin_info.has_parent_fees_ticker && coin_info.ticker != coin_info.fees_ticker && !coins.contains(QString::fromStdString(coin_info.fees_ticker))) { - auto coin_parent_info = mm2.get_coin_info(coin_info.fees_ticker); + auto coin_parent_info = kdf.get_coin_info(coin_info.fees_ticker); // todo: why can it be empty when it has been found ? // refactor coins enabling logic!!! if (coin_parent_info.ticker != "") @@ -101,7 +101,7 @@ namespace atomic_dex { coins_std.push_back(extra_coin); } - mm2.enable_coins(coins_std); + kdf.enable_coins(coins_std); return true; } @@ -115,14 +115,14 @@ namespace atomic_dex QString primary_coin = QString::fromStdString(g_primary_dex_coin); QString secondary_coin = QString::fromStdString(g_second_primary_dex_coin); QStringList coins_copy; - const auto& mm2 = system_manager_.get_system(); + const auto& kdf = system_manager_.get_system(); for (auto&& coin : coins) { - const auto coin_info = mm2.get_coin_info(coin.toStdString()); + const auto coin_info = kdf.get_coin_info(coin.toStdString()); bool has_parent_fees = coin_info.has_parent_fees_ticker; if (not get_orders()->swap_is_in_progress(coin) && coin != primary_coin && coin != secondary_coin) { - if (!get_mm2().is_zhtlc_coin_ready(coin.toStdString())) + if (!get_kdf().is_zhtlc_coin_ready(coin.toStdString())) { this->dispatcher_.trigger(coin.toStdString(), "Can't disable until fully activated."); } @@ -148,13 +148,13 @@ namespace atomic_dex coins_std.reserve(coins_copy.size()); for (auto&& coin : coins_copy) { - if (QString::fromStdString(get_mm2().get_current_ticker()) == coin && m_primary_coin_fully_enabled) + if (QString::fromStdString(get_kdf().get_current_ticker()) == coin && m_primary_coin_fully_enabled) { system_manager_.get_system().set_current_ticker(primary_coin); } coins_std.push_back(coin.toStdString()); } - get_mm2().disable_multiple_coins(coins_std); + get_kdf().disable_multiple_coins(coins_std); this->dispatcher_.trigger(false); } @@ -203,7 +203,7 @@ namespace atomic_dex std::string wallet_custom_cfg_filename = "custom-tokens."s + wallet_name + ".json"s; const fs::path wallet_custom_cfg_path{utils::get_atomic_dex_config_folder() / wallet_custom_cfg_filename}; const fs::path wallet_cfg_path{utils::get_atomic_dex_config_folder() / wallet_cfg_file}; - const fs::path mm2_coins_file_path{atomic_dex::utils::get_current_configs_path() / "coins.json"}; + const fs::path kdf_coins_file_path{atomic_dex::utils::get_current_configs_path() / "coins.json"}; const fs::path ini_file_path = atomic_dex::utils::get_current_configs_path() / "cfg.ini"; const fs::path cfg_json_file_path = atomic_dex::utils::get_current_configs_path() / "cfg.json"; const fs::path logo_path = atomic_dex::utils::get_logo_path(); @@ -309,7 +309,7 @@ namespace atomic_dex file.write(QString::fromStdString(custom_config_json_data.dump()).toUtf8()); file.close(); } - functor_remove(std::move(mm2_coins_file_path)); + functor_remove(std::move(kdf_coins_file_path)); functor_remove(std::move(cfg_json_file_path)); functor_remove(std::move(logo_path)); functor_remove(std::move(theme_path)); @@ -343,17 +343,14 @@ namespace atomic_dex void application::tick() { this->process_one_frame(); - if (m_event_actions[events_action::need_a_full_refresh_of_mm2]) + if (m_event_actions[events_action::need_a_full_refresh_of_kdf]) { - system_manager_.create_system(system_manager_); - - // system_manager_.create_system(system_manager_); - // system_manager_.create_system(system_manager_); + system_manager_.create_system(system_manager_); connect_signals(); - m_event_actions[events_action::need_a_full_refresh_of_mm2] = false; + m_event_actions[events_action::need_a_full_refresh_of_kdf] = false; } - auto& mm2 = get_mm2(); - if (mm2.is_mm2_running()) + auto& kdf = get_kdf(); + if (kdf.is_kdf_running()) { std::vector to_init; while (not m_portfolio_queue.empty()) @@ -414,13 +411,13 @@ namespace atomic_dex switch (last_action) { case action::post_process_orders_and_swaps_finished: - if (mm2.is_mm2_running()) + if (kdf.is_kdf_running()) { qobject_cast(m_manager_models.at("orders"))->refresh_or_insert(); } break; case action::post_process_orders_and_swaps_finished_reset: - if (mm2.is_mm2_running()) + if (kdf.is_kdf_running()) { qobject_cast(m_manager_models.at("orders"))->refresh_or_insert(true); } @@ -429,9 +426,9 @@ namespace atomic_dex } } - mm2_service& application::get_mm2() + kdf_service& application::get_kdf() { - return this->system_manager_.get_system(); + return this->system_manager_.get_system(); } entt::dispatcher& application::get_dispatcher() @@ -490,8 +487,8 @@ namespace atomic_dex } // get_dispatcher().sink().connect<&application::on_refresh_update_status_event>(*this); - //! MM2 system need to be created before the GUI and give the instance to the gui - system_manager_.create_system(system_manager_); + //! KDF system need to be created before the GUI and give the instance to the gui + system_manager_.create_system(system_manager_); auto& settings_page_system = system_manager_.create_system(system_manager_, m_app, this); auto& portfolio_system = system_manager_.create_system(system_manager_, this); portfolio_system.get_portfolio()->set_cfg(settings_page_system.get_cfg()); @@ -500,10 +497,9 @@ namespace atomic_dex system_manager_.create_system(system_manager_, settings_page_system.get_cfg()); system_manager_.create_system(system_manager_); system_manager_.create_system(system_manager_); - //system_manager_.create_system(system_manager_); - //system_manager_.create_system(system_manager_); system_manager_.create_system(); system_manager_.create_system(); + system_manager_.create_system(); system_manager_.create_system(system_manager_); system_manager_.create_system(system_manager_); system_manager_.create_system( @@ -546,17 +542,17 @@ namespace atomic_dex bool application::do_i_have_enough_funds(const QString& ticker, const QString& amount) const { t_float_50 amount_f = safe_float(amount.toStdString()); - return get_mm2().do_i_have_enough_funds(ticker.toStdString(), amount_f); + return get_kdf().do_i_have_enough_funds(ticker.toStdString(), amount_f); } - const mm2_service& application::get_mm2() const + const kdf_service& application::get_kdf() const { - return this->system_manager_.get_system(); + return this->system_manager_.get_system(); } QJsonObject application::get_zhtlc_status(const QString& coin) { - QJsonObject res = nlohmann_json_object_to_qt_json_object(get_mm2().get_zhtlc_status(coin.toStdString())); + QJsonObject res = nlohmann_json_object_to_qt_json_object(get_kdf().get_zhtlc_status(coin.toStdString())); return res; } @@ -564,11 +560,11 @@ namespace atomic_dex { std::error_code ec; SPDLOG_DEBUG("{} l{}", __FUNCTION__, __LINE__); - auto res = get_mm2().get_balance_info(coin.toStdString(), ec); + auto res = get_kdf().get_balance_info(coin.toStdString(), ec); return QString::fromStdString(res); } - void application::on_mm2_initialized_event([[maybe_unused]] const mm2_initialized& evt) + void application::on_kdf_initialized_event([[maybe_unused]] const kdf_initialized& evt) { SPDLOG_DEBUG("{} l{}", __FUNCTION__, __LINE__); system_manager_.get_system().set_status("enabling_coins"); @@ -577,10 +573,10 @@ namespace atomic_dex // Function appears to be unused. void application::refresh_orders_and_swaps() { - auto& mm2 = get_mm2(); - if (mm2.is_mm2_running()) + auto& kdf = get_kdf(); + if (kdf.is_kdf_running()) { - mm2.batch_fetch_orders_and_swap(); + kdf.batch_fetch_orders_and_swap(); } } @@ -617,7 +613,7 @@ namespace atomic_dex //! Mark systems - system_manager_.mark_system(); + system_manager_.mark_system(); //system_manager_.mark_system(); //! Disconnect signals @@ -627,10 +623,10 @@ namespace atomic_dex dispatcher_.sink().disconnect<&application::on_ticker_balance_updated_event>(*this); dispatcher_.sink().disconnect<&application::on_fiat_rate_updated>(*this); dispatcher_.sink().disconnect<&application::on_coin_fully_initialized_event>(*this); - dispatcher_.sink().disconnect<&application::on_mm2_initialized_event>(*this); + dispatcher_.sink().disconnect<&application::on_kdf_initialized_event>(*this); dispatcher_.sink().disconnect<&application::on_process_orders_and_swaps_finished_event>(*this); - m_event_actions[events_action::need_a_full_refresh_of_mm2] = true; + m_event_actions[events_action::need_a_full_refresh_of_kdf] = true; //! Resets wallet name. auto& wallet_manager = this->system_manager_.get_system(); @@ -651,7 +647,7 @@ namespace atomic_dex get_dispatcher().sink().connect<&application::on_ticker_balance_updated_event>(*this); get_dispatcher().sink().connect<&application::on_fiat_rate_updated>(*this); get_dispatcher().sink().connect<&application::on_coin_fully_initialized_event>(*this); - get_dispatcher().sink().connect<&application::on_mm2_initialized_event>(*this); + get_dispatcher().sink().connect<&application::on_kdf_initialized_event>(*this); get_dispatcher().sink().connect<&application::on_process_orders_and_swaps_finished_event>(*this); // get_dispatcher().sink().connect<&application::on_process_swaps_finished_event>(*this); } @@ -670,8 +666,8 @@ namespace atomic_dex { QString result; - mm2::recover_funds_of_swap_request request{.swap_uuid = uuid.toStdString()}; - auto res = get_mm2().get_mm2_client().rpc_recover_funds(std::move(request)); + kdf::recover_funds_of_swap_request request{.swap_uuid = uuid.toStdString()}; + auto res = get_kdf().get_kdf_client().rpc_recover_funds(std::move(request)); result = QString::fromStdString(res.raw_result); return result; @@ -799,7 +795,7 @@ namespace atomic_dex bool application::is_pin_cfg_enabled() const { - return get_mm2().is_pin_cfg_enabled(); + return get_kdf().is_pin_cfg_enabled(); } } // namespace atomic_dex @@ -810,7 +806,7 @@ namespace atomic_dex application::exit_handler() { SPDLOG_DEBUG("will quit app, prevent all threading event"); - this->system_manager_.mark_system(); + this->system_manager_.mark_system(); this->process_one_frame(); m_event_actions[events_action::about_to_exit_app] = true; } @@ -916,7 +912,18 @@ namespace atomic_dex } } // namespace atomic_dex -//! update checker +//! time sync checker +namespace atomic_dex +{ + timesync_checker_service* application::get_timesync_checker_service() const + { + auto ptr = const_cast(std::addressof(system_manager_.get_system())); + assert(ptr != nullptr); + return ptr; + } +} // namespace atomic_dex + +//! zcash_params checker namespace atomic_dex { zcash_params_service* application::get_zcash_params_service() const diff --git a/src/app/app.hpp b/src/app/app.hpp index 6ad76aafc7..6e1e93a9fe 100644 --- a/src/app/app.hpp +++ b/src/app/app.hpp @@ -45,11 +45,12 @@ #include "atomicdex/pages/qt.wallet.page.hpp" #include "atomicdex/services/exporter/exporter.service.hpp" #include "atomicdex/services/internet/internet.checker.service.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/defi.stats.hpp" #include "atomicdex/services/price/global.provider.hpp" #include "atomicdex/services/update/update.checker.service.hpp" #include "atomicdex/services/update/zcash.params.service.hpp" +#include "atomicdex/services/sync/timesync.checker.service.hpp" #include "atomicdex/utilities/qt.utilities.hpp" namespace ag = antara::gaming; @@ -75,6 +76,7 @@ namespace atomic_dex Q_PROPERTY(settings_page* settings_pg READ get_settings_page NOTIFY settingsPageChanged) Q_PROPERTY(qt_wallet_manager* wallet_mgr READ get_wallet_mgr NOTIFY walletMgrChanged) Q_PROPERTY(update_checker_service* updateCheckerService READ get_update_checker_service NOTIFY updateCheckerServiceChanged) + Q_PROPERTY(timesync_checker_service* timesyncCheckerService READ get_timesync_checker_service NOTIFY timesyncCheckerServiceChanged) Q_PROPERTY(zcash_params_service* zcash_params READ get_zcash_params_service NOTIFY zcashParamsServiceChanged) //! Private function @@ -83,7 +85,7 @@ namespace atomic_dex enum events_action { - need_a_full_refresh_of_mm2 = 0, + need_a_full_refresh_of_kdf = 0, about_to_exit_app = 1, size = 2 }; @@ -117,11 +119,11 @@ namespace atomic_dex void on_ticker_balance_updated_event(const ticker_balance_updated&); void on_fiat_rate_updated(const fiat_rate_updated&); void on_coin_fully_initialized_event(const coin_fully_initialized&); - void on_mm2_initialized_event(const mm2_initialized&); + void on_kdf_initialized_event(const kdf_initialized&); void on_process_orders_and_swaps_finished_event(const process_swaps_and_orders_finished&); - mm2_service& get_mm2(); - [[nodiscard]] const mm2_service& get_mm2() const; + kdf_service& get_kdf(); + [[nodiscard]] const kdf_service& get_kdf() const; entt::dispatcher& get_dispatcher(); const entt::registry& get_registry() const; entt::registry& get_registry(); @@ -135,6 +137,7 @@ namespace atomic_dex qt_wallet_manager* get_wallet_mgr() const; internet_service_checker* get_internet_checker() const; update_checker_service* get_update_checker_service() const; + timesync_checker_service* get_timesync_checker_service() const; [[nodiscard]] zcash_params_service* get_zcash_params_service() const; exporter_service* get_exporter_service() const; @@ -180,6 +183,7 @@ namespace atomic_dex void walletPageChanged(); void ordersChanged(); void updateCheckerServiceChanged(); + void timesyncCheckerServiceChanged(); void zcashParamsServiceChanged(); void tradingPageChanged(); void settingsPageChanged(); diff --git a/src/app/main.prerequisites.hpp b/src/app/main.prerequisites.hpp index c6e34acb7f..8f9fc4c201 100644 --- a/src/app/main.prerequisites.hpp +++ b/src/app/main.prerequisites.hpp @@ -104,7 +104,7 @@ qt_message_handler(QtMsgType type, [[maybe_unused]] const QMessageLogContext& co static void signal_handler(int signal) { - SPDLOG_ERROR("sigabort received, cleaning mm2"); + SPDLOG_ERROR("sigabort received, cleaning kdf"); atomic_dex::kill_executable(atomic_dex::g_dex_api); #if defined(linux) || defined(__APPLE__) boost::stacktrace::safe_dump_to("./backtrace.dump"); @@ -158,7 +158,7 @@ init_sodium() static void clean_previous_run() { - SPDLOG_INFO("cleaning previous mm2 instance"); + SPDLOG_INFO("cleaning previous kdf instance"); atomic_dex::kill_executable(atomic_dex::g_dex_api); } diff --git a/src/core/atomicdex/api/coinpaprika/coinpaprika.cpp b/src/core/atomicdex/api/coinpaprika/coinpaprika.cpp deleted file mode 100644 index 0287e13302..0000000000 --- a/src/core/atomicdex/api/coinpaprika/coinpaprika.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -//! Deps -#include -#include - -//! Project Headers -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" -#include "atomicdex/utilities/global.utilities.hpp" - -//! Private -#include "atomicdex/utilities/nlohmann.json.sax.private.cpp" - -namespace -{ - //! Constants - constexpr const char* g_coinpaprika_endpoint = "https://api.coinpaprika.com/v1/"; - web::http::client::http_client_config g_paprika_cfg{[]() { - web::http::client::http_client_config cfg; - cfg.set_validate_certificates(false); - cfg.set_timeout(std::chrono::seconds(5)); - return cfg; - }()}; - t_http_client_ptr g_coinpaprika_client = std::make_unique(FROM_STD_STR(g_coinpaprika_endpoint), g_paprika_cfg); -} // namespace - -namespace atomic_dex -{ - namespace coinpaprika::api - { - void - to_json(nlohmann::json& j, const price_converter_request& evt) - { - j["base_currency_id"] = evt.base_currency_id; - j["quote_currency_id"] = evt.quote_currency_id; - j["amount"] = 1; - } - - void - from_json(const nlohmann::json& j, price_converter_answer& evt) - { - // utils::details::my_json_sax sx; - // nlohmann::json::sax_parse(j.dump(), &sx); - - evt.base_currency_id = j.at("base_currency_id").get(); - evt.base_currency_name = j.at("base_currency_name").get(); - evt.base_price_last_updated = j.at("base_price_last_updated").get(); - evt.quote_currency_id = j.at("quote_currency_id").get(); - evt.quote_currency_name = j.at("quote_currency_name").get(); - evt.quote_price_last_updated = j.at("quote_price_last_updated").get(); - evt.amount = j.at("amount").get(); - evt.price = std::to_string(j.at("price").get()); - - std::replace(evt.price.begin(), evt.price.end(), ',', '.'); - } - - void - from_json(const nlohmann::json& j, ticker_info_answer& evt) - { - evt.answer = j.at("quotes"); - } - - void - from_json(const nlohmann::json& j, ticker_historical_answer& evt) - { - evt.answer = j; - } - - pplx::task - async_price_converter(const price_converter_request& request) - { - using namespace std::string_literals; - web::http::http_request req; - req.set_method(web::http::methods::GET); - auto&& [base_id, quote_id] = request; - const auto url = "/price-converter?base_currency_id="s + base_id + ""e_currency_id="s + quote_id + "&amount=1"s; - req.set_request_uri(FROM_STD_STR(url)); - return g_coinpaprika_client->request(req); - } - - pplx::task - async_ticker_info(const ticker_infos_request& request) - { - using ranges::views::ints; - using ranges::views::zip; - using namespace std::string_literals; - web::http::http_request req; - req.set_method(web::http::methods::GET); - auto&& [ticker_id, quotes] = request; - auto url = "/tickers/"s + ticker_id + "?quotes="s; - for (auto&& [cur_quote, idx]: zip(quotes, ints(0u, ranges::unreachable))) - { - url.append(cur_quote); - - //! Append only if not last element, idx start at 0, if idx + 1 == quotes.size(), we are on the last elemnt, we don't append. - if (idx < quotes.size() - 1) - { - url.append(","); - } - } - SPDLOG_INFO("url: {}", TO_STD_STR(g_coinpaprika_client->base_uri().to_string()) + url); - req.set_request_uri(FROM_STD_STR(url)); - return g_coinpaprika_client->request(req); - } - - pplx::task - async_ticker_historical(const ticker_historical_request& request) - { - using namespace std::string_literals; - web::http::http_request req; - req.set_method(web::http::methods::GET); - auto&& [ticker_id, timestamp, interval] = request; - const auto url = "/tickers/"s + ticker_id + "/historical?start="s + std::to_string(timestamp) + "&interval="s + interval; - SPDLOG_INFO("url: {}", url); - req.set_request_uri(FROM_STD_STR(url)); - return g_coinpaprika_client->request(req); - } - } // namespace coinpaprika::api -} // namespace atomic_dex diff --git a/src/core/atomicdex/api/coinpaprika/coinpaprika.hpp b/src/core/atomicdex/api/coinpaprika/coinpaprika.hpp deleted file mode 100644 index 3650d3f733..0000000000 --- a/src/core/atomicdex/api/coinpaprika/coinpaprika.hpp +++ /dev/null @@ -1,139 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#pragma once - -//! Deps -#include -#include -#include - -//! Project Headers -#include "atomicdex/utilities/cpprestsdk.utilities.hpp" - -namespace -{ - constexpr const std::size_t g_nb_hours_in_a_week{168}; -} - -namespace atomic_dex -{ - namespace coinpaprika::api - { - struct ticker_historical_request - { - std::string ticker_currency_id; - std::size_t timestamp{static_cast( - std::chrono::duration_cast((std::chrono::system_clock::now() - std::chrono::hours(g_nb_hours_in_a_week)).time_since_epoch()).count())}; - std::string interval{"1d"}; - }; - - struct ticker_historical_answer - { - nlohmann::json answer{nlohmann::json::array()}; - int rpc_result_code; - std::string raw_result; - }; - - struct ticker_infos_request - { - std::string ticker_currency_id; - std::vector ticker_quotes; - }; - - struct ticker_info_answer - { - nlohmann::json answer; - int rpc_result_code; - std::string raw_result; - }; - - struct price_converter_request - { - std::string base_currency_id; - std::string quote_currency_id; - }; - - struct price_converter_answer - { - std::string base_currency_id; - std::string base_currency_name; - std::string base_price_last_updated; - std::string quote_currency_id; - std::string quote_currency_name; - std::string quote_price_last_updated; - std::size_t amount; - std::string price{"0.00"}; ///< we need trick here - int rpc_result_code; - std::string raw_result; - }; - - void to_json(nlohmann::json& j, const price_converter_request& evt); - - void from_json(const nlohmann::json& j, price_converter_answer& evt); - - void from_json(const nlohmann::json& j, ticker_info_answer& evt); - - void from_json(const nlohmann::json& j, ticker_historical_answer& evt); - - pplx::task async_price_converter(const price_converter_request& request); - pplx::task async_ticker_info(const ticker_infos_request& request); - pplx::task async_ticker_historical(const ticker_historical_request& request); - - template - TAnswer static inline process_generic_resp(web::http::http_response resp) - { - TAnswer answer; - std::string body = TO_STD_STR(resp.extract_string(true).get()); - if (resp.status_code() == static_cast(antara::app::http_code::bad_request)) - { - SPDLOG_WARN("rpc answer code is 400 (Bad Parameters), body: {}", body); - answer.rpc_result_code = resp.status_code(); - answer.raw_result = body; - return answer; - } - if (resp.status_code() == static_cast(antara::app::http_code::too_many_requests)) - { - SPDLOG_WARN("rpc answer code is 429 (Too Many requests), body: {}", body); - answer.rpc_result_code = resp.status_code(); - answer.raw_result = body; - return answer; - } - try - { - const auto json_answer = nlohmann::json::parse(body); - from_json(json_answer, answer); - answer.rpc_result_code = resp.status_code(); - answer.raw_result = body; - } - catch (const std::exception& error) - { - SPDLOG_ERROR("exception caught: error[{}], body: {}", error.what(), body); - answer.rpc_result_code = -1; - answer.raw_result = error.what(); - } - return answer; - } - } // namespace coinpaprika::api - - - using t_price_converter_answer = coinpaprika::api::price_converter_answer; - using t_price_converter_request = coinpaprika::api::price_converter_request; - using t_ticker_info_answer = coinpaprika::api::ticker_info_answer; - using t_ticker_infos_request = coinpaprika::api::ticker_infos_request; - using t_ticker_historical_answer = coinpaprika::api::ticker_historical_answer; - using t_ticker_historical_request = coinpaprika::api::ticker_historical_request; -} // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/address_format.cpp b/src/core/atomicdex/api/kdf/address_format.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/address_format.cpp rename to src/core/atomicdex/api/kdf/address_format.cpp index d4320ed7d7..07338bb037 100644 --- a/src/core/atomicdex/api/mm2/address_format.cpp +++ b/src/core/atomicdex/api/kdf/address_format.cpp @@ -18,9 +18,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/address_format.hpp" +#include "atomicdex/api/kdf/address_format.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const address_format_t& req) @@ -42,4 +42,4 @@ namespace atomic_dex::mm2 } } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/address_format.hpp b/src/core/atomicdex/api/kdf/address_format.hpp similarity index 97% rename from src/core/atomicdex/api/mm2/address_format.hpp rename to src/core/atomicdex/api/kdf/address_format.hpp index 7b68961d12..a37f57a6f9 100644 --- a/src/core/atomicdex/api/mm2/address_format.hpp +++ b/src/core/atomicdex/api/kdf/address_format.hpp @@ -16,10 +16,11 @@ #pragma once +#include #include #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct address_format_t { diff --git a/src/core/atomicdex/api/mm2/balance_infos.cpp b/src/core/atomicdex/api/kdf/balance_infos.cpp similarity index 96% rename from src/core/atomicdex/api/mm2/balance_infos.cpp rename to src/core/atomicdex/api/kdf/balance_infos.cpp index 9140372b71..57893273b6 100644 --- a/src/core/atomicdex/api/mm2/balance_infos.cpp +++ b/src/core/atomicdex/api/kdf/balance_infos.cpp @@ -20,7 +20,7 @@ // Project Headers #include "balance_infos.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void from_json(const nlohmann::json& j, balance_infos& answer) @@ -28,4 +28,4 @@ namespace atomic_dex::mm2 answer.spendable = j.at("spendable").get(); answer.unspendable = j.at("unspendable").get(); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/balance_infos.hpp b/src/core/atomicdex/api/kdf/balance_infos.hpp similarity index 98% rename from src/core/atomicdex/api/mm2/balance_infos.hpp rename to src/core/atomicdex/api/kdf/balance_infos.hpp index eece30234c..8f4265221f 100644 --- a/src/core/atomicdex/api/mm2/balance_infos.hpp +++ b/src/core/atomicdex/api/kdf/balance_infos.hpp @@ -19,7 +19,7 @@ #include #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct balance_infos { diff --git a/src/core/atomicdex/api/kdf/fraction.cpp b/src/core/atomicdex/api/kdf/fraction.cpp new file mode 100644 index 0000000000..bd66de6882 --- /dev/null +++ b/src/core/atomicdex/api/kdf/fraction.cpp @@ -0,0 +1,12 @@ +#include + +#include "atomicdex/api/kdf/fraction.hpp" + +namespace atomic_dex::kdf +{ + void from_json(const nlohmann::json& j, kdf::fraction& fraction) + { + j.at("denom").get_to(fraction.denom); + j.at("numer").get_to(fraction.numer); + } +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/fraction.fwd.hpp b/src/core/atomicdex/api/kdf/fraction.fwd.hpp similarity index 59% rename from src/core/atomicdex/api/mm2/fraction.fwd.hpp rename to src/core/atomicdex/api/kdf/fraction.fwd.hpp index 8b0b7bb20c..1fed5af188 100644 --- a/src/core/atomicdex/api/mm2/fraction.fwd.hpp +++ b/src/core/atomicdex/api/kdf/fraction.fwd.hpp @@ -1,6 +1,6 @@ #pragma once -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct fraction; } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/fraction.hpp b/src/core/atomicdex/api/kdf/fraction.hpp similarity index 69% rename from src/core/atomicdex/api/mm2/fraction.hpp rename to src/core/atomicdex/api/kdf/fraction.hpp index c197c8a478..af015bb93e 100644 --- a/src/core/atomicdex/api/mm2/fraction.hpp +++ b/src/core/atomicdex/api/kdf/fraction.hpp @@ -5,7 +5,7 @@ #include #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct fraction { @@ -13,5 +13,5 @@ namespace atomic_dex::mm2 std::string numer; }; - ENTT_API void from_json(const nlohmann::json& j, mm2::fraction& fraction); + ENTT_API void from_json(const nlohmann::json& j, kdf::fraction& fraction); } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/generic.error.cpp b/src/core/atomicdex/api/kdf/generic.error.cpp similarity index 76% rename from src/core/atomicdex/api/mm2/generic.error.cpp rename to src/core/atomicdex/api/kdf/generic.error.cpp index 85943adcf6..24388c3bad 100644 --- a/src/core/atomicdex/api/mm2/generic.error.cpp +++ b/src/core/atomicdex/api/kdf/generic.error.cpp @@ -1,6 +1,6 @@ -#include "atomicdex/api/mm2/generic.error.hpp" +#include "atomicdex/api/kdf/generic.error.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void from_json(const nlohmann::json& j, generic_answer_error& res) { @@ -10,4 +10,4 @@ namespace atomic_dex::mm2 j.at("error_type").get_to(res.error_type); j.at("error_data").get_to(res.error_data); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/generic.error.hpp b/src/core/atomicdex/api/kdf/generic.error.hpp similarity index 87% rename from src/core/atomicdex/api/mm2/generic.error.hpp rename to src/core/atomicdex/api/kdf/generic.error.hpp index 7be792aae5..1e03e42d2f 100644 --- a/src/core/atomicdex/api/mm2/generic.error.hpp +++ b/src/core/atomicdex/api/kdf/generic.error.hpp @@ -6,7 +6,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct generic_answer_error { @@ -18,4 +18,4 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, generic_answer_error& res); -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/generics.cpp b/src/core/atomicdex/api/kdf/generics.cpp similarity index 80% rename from src/core/atomicdex/api/mm2/generics.cpp rename to src/core/atomicdex/api/kdf/generics.cpp index a8a0c0ddb4..e9e03bc34a 100644 --- a/src/core/atomicdex/api/mm2/generics.cpp +++ b/src/core/atomicdex/api/kdf/generics.cpp @@ -18,19 +18,19 @@ #include //! Project Headers -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.buy.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.convertaddress.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.disable_coin.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.sell.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.validateaddress.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.buy.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.convertaddress.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.disable_coin.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.sell.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.validateaddress.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { template void @@ -55,4 +55,4 @@ namespace atomic_dex::mm2 template void extract_rpc_json_answer(const nlohmann::json& j, validate_address_answer& answer); template void extract_rpc_json_answer(const nlohmann::json& j, convert_address_answer& answer); template void extract_rpc_json_answer(const nlohmann::json& j, recover_funds_of_swap_answer& answer); -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/generics.hpp b/src/core/atomicdex/api/kdf/generics.hpp similarity index 98% rename from src/core/atomicdex/api/mm2/generics.hpp rename to src/core/atomicdex/api/kdf/generics.hpp index 333180d538..937b8dc1eb 100644 --- a/src/core/atomicdex/api/mm2/generics.hpp +++ b/src/core/atomicdex/api/kdf/generics.hpp @@ -18,7 +18,7 @@ #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { template void diff --git a/src/core/atomicdex/api/mm2/mm2.client.cpp b/src/core/atomicdex/api/kdf/kdf.client.cpp similarity index 70% rename from src/core/atomicdex/api/mm2/mm2.client.cpp rename to src/core/atomicdex/api/kdf/kdf.client.cpp index 151066275d..29c1124874 100644 --- a/src/core/atomicdex/api/mm2/mm2.client.cpp +++ b/src/core/atomicdex/api/kdf/kdf.client.cpp @@ -18,22 +18,22 @@ #include -#include "mm2.hpp" -#include "atomicdex/api/mm2/rpc.hpp" -#include "mm2.client.hpp" +#include "kdf.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "kdf.client.hpp" #include "rpc.tx.history.hpp" #include "atomicdex/constants/dex.constants.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.my_tx_history.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.my_tx_history.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" namespace { @@ -51,11 +51,11 @@ namespace return {FROM_STD_STR(atomic_dex::g_dex_rpc), cfg}; } - template + template web::http::http_request make_request(typename Rpc::expected_request_type data_req = {}) { web::http::http_request request; - nlohmann::json json_req = {{"method", Rpc::endpoint}, {"userpass", atomic_dex::mm2::get_rpc_password()}}; + nlohmann::json json_req = {{"method", Rpc::endpoint}, {"userpass", atomic_dex::kdf::get_rpc_password()}}; nlohmann::json json_data; nlohmann::to_json(json_data, data_req); @@ -71,28 +71,26 @@ namespace json_req.insert(json_req.end(), json_data); } request.set_body(json_req.dump()); + // SPDLOG_DEBUG("request: {}", json_req.dump()); return request; } - template + template Rpc process_rpc_answer(const web::http::http_response& answer) { std::string body = TO_STD_STR(answer.extract_string(true).get()); - if (body.size() > 1000) - { - SPDLOG_DEBUG("redacted rpc answer: {}", body.substr(0, 1000)); - } - SPDLOG_DEBUG("body: {}", body); + // SPDLOG_INFO("body: {}", body); nlohmann::json json_answer; Rpc rpc; try { json_answer = nlohmann::json::parse(body); - // SPDLOG_DEBUG("rpc answer: {}", json_answer.dump(4)); + // SPDLOG_DEBUG("json_answer: {}", json_answer.dump(4)); } catch (const nlohmann::json::parse_error& error) { SPDLOG_ERROR("rpc answer error: {}", error.what()); + // SPDLOG_DEBUG("body: {}", body); } if (Rpc::is_v2) @@ -107,7 +105,6 @@ namespace SPDLOG_DEBUG("rpc2 answer: error"); rpc.error = json_answer.get(); rpc.raw_result = json_answer.dump(); - SPDLOG_DEBUG("rpc.raw_result: {}", rpc.raw_result); } } else @@ -118,10 +115,10 @@ namespace } } // namespace -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { template - RpcReturnType mm2_client::rpc_process_answer(const web::http::http_response& resp, const std::string& rpc_command) + RpcReturnType kdf_client::rpc_process_answer(const web::http::http_response& resp, const std::string& rpc_command) { std::string body = TO_STD_STR(resp.extract_string(true).get()); SPDLOG_INFO("resp code for rpc_command {} is {}", rpc_command, resp.status_code()); @@ -174,7 +171,7 @@ namespace atomic_dex::mm2 } pplx::task - mm2_client::async_rpc_batch_standalone(nlohmann::json batch_array) + kdf_client::async_rpc_batch_standalone(nlohmann::json batch_array) { web::http::http_request request; request.set_method(web::http::methods::POST); @@ -184,62 +181,62 @@ namespace atomic_dex::mm2 } template - void mm2_client::process_rpc_async(const std::function& on_rpc_processed) + void kdf_client::process_rpc_async(const std::function& on_rpc_processed) { using request_type = typename Rpc::expected_request_type; process_rpc_async(request_type{}, on_rpc_processed); } - // template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); - template void mm2_client::process_rpc_async(const std::function&); + // template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); + template void kdf_client::process_rpc_async(const std::function&); - template - void mm2_client::process_rpc_async(typename Rpc::expected_request_type request, const std::function& on_rpc_processed) + template + void kdf_client::process_rpc_async(typename Rpc::expected_request_type request, const std::function& on_rpc_processed) { auto http_request = make_request(request); generate_client() .request(http_request, m_token_source.get_token()) - .template then([on_rpc_processed, request](const web::http::http_response& resp) - { - try - { - auto rpc = process_rpc_answer(resp); - rpc.request = request; - on_rpc_processed(rpc); - } - catch (const std::exception& ex) - { - // SPDLOG_DEBUG("process_rpc_answer rpc.result: {}", rpc.raw_result); - SPDLOG_ERROR(ex.what()); - } - }); + .then([on_rpc_processed, request](const web::http::http_response& resp) + { + try + { + auto rpc = process_rpc_answer(resp); + rpc.request = request; + on_rpc_processed(rpc); + } + catch (const std::exception& ex) + { + // SPDLOG_DEBUG("process_rpc_answer rpc.result: {}", rpc.raw_result); + SPDLOG_ERROR(ex.what()); + } + }); } void - mm2_client::stop() + kdf_client::stop() { m_token_source.cancel(); } template TAnswer - mm2_client::process_rpc(TRequest&& request, std::string rpc_command, bool is_v2) + kdf_client::process_rpc(TRequest&& request, std::string rpc_command, bool is_v2) { SPDLOG_DEBUG("Processing rpc call: {}", rpc_command); - nlohmann::json json_data = mm2::template_request(rpc_command, is_v2); + nlohmann::json json_data = kdf::template_request(rpc_command, is_v2); - mm2::to_json(json_data, request); + kdf::to_json(json_data, request); auto json_copy = json_data; json_copy["userpass"] = "*******"; @@ -253,24 +250,24 @@ namespace atomic_dex::mm2 } t_enable_z_coin_cancel_answer - mm2_client::rpc_enable_z_coin_cancel(t_enable_z_coin_cancel_request&& request) + kdf_client::rpc_enable_z_coin_cancel(t_enable_z_coin_cancel_request&& request) { return process_rpc(std::forward(request), "task::enable_z_coin::cancel", true); } t_disable_coin_answer - mm2_client::rpc_disable_coin(t_disable_coin_request&& request) + kdf_client::rpc_disable_coin(t_disable_coin_request&& request) { return process_rpc(std::forward(request), "disable_coin"); } t_recover_funds_of_swap_answer - mm2_client::rpc_recover_funds(t_recover_funds_of_swap_request&& request) + kdf_client::rpc_recover_funds(t_recover_funds_of_swap_request&& request) { return process_rpc( std::forward(request), "recover_funds_of_swap"); } } // namespace atomic_dex -template atomic_dex::mm2::tx_history_answer atomic_dex::mm2::mm2_client::rpc_process_answer(const web::http::http_response& resp, const std::string& rpc_command); -template atomic_dex::mm2::disable_coin_answer atomic_dex::mm2::mm2_client::rpc_process_answer(const web::http::http_response& resp, const std::string& rpc_command); +template atomic_dex::kdf::tx_history_answer atomic_dex::kdf::kdf_client::rpc_process_answer(const web::http::http_response& resp, const std::string& rpc_command); +template atomic_dex::kdf::disable_coin_answer atomic_dex::kdf::kdf_client::rpc_process_answer(const web::http::http_response& resp, const std::string& rpc_command); diff --git a/src/core/atomicdex/api/mm2/mm2.client.hpp b/src/core/atomicdex/api/kdf/kdf.client.hpp similarity index 79% rename from src/core/atomicdex/api/mm2/mm2.client.hpp rename to src/core/atomicdex/api/kdf/kdf.client.hpp index 13421d986d..1ea8a05074 100644 --- a/src/core/atomicdex/api/mm2/mm2.client.hpp +++ b/src/core/atomicdex/api/kdf/kdf.client.hpp @@ -8,20 +8,20 @@ // Project Headers #include "atomicdex/utilities/cpprestsdk.utilities.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.disable_coin.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp" -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.disable_coin.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { - class ENTT_API mm2_client + class ENTT_API kdf_client { pplx::cancellation_token_source m_token_source; public: - mm2_client() = default; - ~mm2_client() = default; + kdf_client() = default; + ~kdf_client() = default; //! Create the client void stop(); diff --git a/src/core/atomicdex/api/mm2/mm2.constants.hpp b/src/core/atomicdex/api/kdf/kdf.constants.hpp similarity index 100% rename from src/core/atomicdex/api/mm2/mm2.constants.hpp rename to src/core/atomicdex/api/kdf/kdf.constants.hpp diff --git a/src/core/atomicdex/api/mm2/mm2.cpp b/src/core/atomicdex/api/kdf/kdf.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/mm2.cpp rename to src/core/atomicdex/api/kdf/kdf.cpp index 0971464177..25a73d6b87 100644 --- a/src/core/atomicdex/api/mm2/mm2.cpp +++ b/src/core/atomicdex/api/kdf/kdf.cpp @@ -18,16 +18,16 @@ #include //! Project Headers -#include "atomicdex/api/mm2/mm2.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.convertaddress.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.validateaddress.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.withdraw.hpp" +#include "atomicdex/api/kdf/kdf.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.convertaddress.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.validateaddress.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.withdraw.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/services/price/global.provider.hpp" #include "atomicdex/utilities/global.utilities.hpp" @@ -168,7 +168,7 @@ namespace } } // namespace -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const send_raw_transaction_request& cfg) @@ -293,7 +293,8 @@ namespace atomic_dex::mm2 .is_swap = false, .is_cancellable = value.at("cancellable").get(), .is_recoverable = false, - .min_volume = is_maker ? QString::fromStdString(value.at("min_base_vol").get()) : std::optional(std::nullopt), + .min_volume = is_maker ? QString::fromStdString(value.at("min_base_vol").get()) : "", + .max_volume = is_maker ? QString::fromStdString(value.at("max_base_vol").get()) : "", .conf_settings = conf_settings}; if (action.empty() && contents.order_type == "maker") { @@ -738,23 +739,23 @@ namespace atomic_dex::mm2 return answer; } - template mm2::withdraw_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::withdraw_status_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::my_orders_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::trade_fee_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::max_taker_vol_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::min_volume_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::my_recent_swaps_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::active_swaps_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::show_priv_key_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::trade_preimage_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::validate_address_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::convert_address_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); - template mm2::recover_funds_of_swap_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::withdraw_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::withdraw_status_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::my_orders_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::trade_fee_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::max_taker_vol_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::min_volume_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::my_recent_swaps_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::active_swaps_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::show_priv_key_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::trade_preimage_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::validate_address_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::convert_address_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); + template kdf::recover_funds_of_swap_answer rpc_process_answer_batch(nlohmann::json& json_answer, const std::string& rpc_command); void set_system_manager(ag::ecs::system_manager& system_manager) { g_system_mgr = std::addressof(system_manager); } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/mm2.error.code.cpp b/src/core/atomicdex/api/kdf/kdf.error.code.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/mm2.error.code.cpp rename to src/core/atomicdex/api/kdf/kdf.error.code.cpp index f77edf559c..f556758909 100644 --- a/src/core/atomicdex/api/mm2/mm2.error.code.cpp +++ b/src/core/atomicdex/api/kdf/kdf.error.code.cpp @@ -15,11 +15,11 @@ ******************************************************************************/ //! Project Headers -#include "mm2.error.code.hpp" +#include "kdf.error.code.hpp" namespace { - class mm2_error_category_impl final : public std::error_category + class kdf_error_category_impl final : public std::error_category { public: [[nodiscard]] const char* name() const noexcept final; @@ -28,13 +28,13 @@ namespace }; const char* - mm2_error_category_impl::name() const noexcept + kdf_error_category_impl::name() const noexcept { - return "mm2"; + return "kdf"; } std::string - mm2_error_category_impl::message(int code) const + kdf_error_category_impl::message(int code) const { switch (static_cast(code)) { @@ -92,7 +92,7 @@ namespace return ""; } - const mm2_error_category_impl g_err_categ{}; + const kdf_error_category_impl g_err_categ{}; } // namespace std::error_code diff --git a/src/core/atomicdex/api/mm2/mm2.error.code.hpp b/src/core/atomicdex/api/kdf/kdf.error.code.hpp similarity index 98% rename from src/core/atomicdex/api/mm2/mm2.error.code.hpp rename to src/core/atomicdex/api/kdf/kdf.error.code.hpp index a21501285a..bfad61b77f 100644 --- a/src/core/atomicdex/api/mm2/mm2.error.code.hpp +++ b/src/core/atomicdex/api/kdf/kdf.error.code.hpp @@ -55,5 +55,5 @@ std::error_code make_error_code(dextop_error error) ; namespace atomic_dex { - using t_mm2_ec = std::error_code; + using t_kdf_ec = std::error_code; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/mm2.hpp b/src/core/atomicdex/api/kdf/kdf.hpp similarity index 92% rename from src/core/atomicdex/api/mm2/mm2.hpp rename to src/core/atomicdex/api/kdf/kdf.hpp index 2a0efe3c65..42ca488ad0 100644 --- a/src/core/atomicdex/api/mm2/mm2.hpp +++ b/src/core/atomicdex/api/kdf/kdf.hpp @@ -22,17 +22,18 @@ //! Deps #include #include +#include //! Project Headers #include "atomicdex/config/coins.cfg.hpp" -#include "atomicdex/api/mm2/mm2.constants.hpp" +#include "atomicdex/api/kdf/kdf.constants.hpp" #include "atomicdex/constants/qt.coins.enums.hpp" #include "atomicdex/data/dex/qt.orders.data.hpp" #include "atomicdex/utilities/cpprestsdk.utilities.hpp" namespace ag = antara::gaming; -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { inline constexpr const char* g_etherscan_proxy_endpoint = "https://etherscan-proxy.komodo.earth/"; inline std::unique_ptr g_etherscan_proxy_http_client{ @@ -79,7 +80,7 @@ namespace atomic_dex::mm2 void from_json(const nlohmann::json& j, send_raw_transaction_answer& answer); - send_raw_transaction_answer rpc_send_raw_transaction(send_raw_transaction_request&& request, std::shared_ptr mm2_client); + send_raw_transaction_answer rpc_send_raw_transaction(send_raw_transaction_request&& request, std::shared_ptr kdf_client); struct cancel_order_request { @@ -226,7 +227,7 @@ namespace atomic_dex::mm2 int rpc_result_code; }; - // kmd_rewards_info_answer rpc_kmd_rewards_info(std::shared_ptr mm2_client); + // kmd_rewards_info_answer rpc_kmd_rewards_info(std::shared_ptr kdf_client); kmd_rewards_info_answer process_kmd_rewards_answer(nlohmann::json result); template @@ -239,16 +240,16 @@ namespace atomic_dex::mm2 void set_rpc_password(std::string rpc_password) ; const std::string& get_rpc_password() ; void set_system_manager(ag::ecs::system_manager& system_manager); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_my_orders_answer = mm2::my_orders_answer; - using t_broadcast_request = mm2::send_raw_transaction_request; - using t_my_recent_swaps_answer = mm2::my_recent_swaps_answer; - using t_my_recent_swaps_request = mm2::my_recent_swaps_request; - using t_active_swaps_request = mm2::active_swaps_request; - using t_active_swaps_answer = mm2::active_swaps_answer; - using t_get_trade_fee_request = mm2::trade_fee_request; - using t_get_trade_fee_answer = mm2::trade_fee_answer; + using t_my_orders_answer = kdf::my_orders_answer; + using t_broadcast_request = kdf::send_raw_transaction_request; + using t_my_recent_swaps_answer = kdf::my_recent_swaps_answer; + using t_my_recent_swaps_request = kdf::my_recent_swaps_request; + using t_active_swaps_request = kdf::active_swaps_request; + using t_active_swaps_answer = kdf::active_swaps_answer; + using t_get_trade_fee_request = kdf::trade_fee_request; + using t_get_trade_fee_answer = kdf::trade_fee_answer; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/orderbook.order.contents.cpp b/src/core/atomicdex/api/kdf/orderbook.order.contents.cpp similarity index 96% rename from src/core/atomicdex/api/mm2/orderbook.order.contents.cpp rename to src/core/atomicdex/api/kdf/orderbook.order.contents.cpp index 388b67bb24..4ab24fc89b 100644 --- a/src/core/atomicdex/api/mm2/orderbook.order.contents.cpp +++ b/src/core/atomicdex/api/kdf/orderbook.order.contents.cpp @@ -19,13 +19,13 @@ #include //! Project Headers -#include "atomicdex/api/mm2/orderbook.order.contents.hpp" +#include "atomicdex/api/kdf/orderbook.order.contents.hpp" #include "atomicdex/utilities/global.utilities.hpp" #include "atomicdex/pages/qt.trading.page.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/orderbook.scanner.service.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void from_json(const nlohmann::json& j, order_contents& contents) @@ -89,4 +89,4 @@ namespace atomic_dex::mm2 ss << "rel_min_volume: " << rel_min_volume << " "; return ss.str(); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/orderbook.order.contents.hpp b/src/core/atomicdex/api/kdf/orderbook.order.contents.hpp similarity index 96% rename from src/core/atomicdex/api/mm2/orderbook.order.contents.hpp rename to src/core/atomicdex/api/kdf/orderbook.order.contents.hpp index b4cbc7798e..054248b827 100644 --- a/src/core/atomicdex/api/mm2/orderbook.order.contents.hpp +++ b/src/core/atomicdex/api/kdf/orderbook.order.contents.hpp @@ -21,7 +21,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct order_contents { @@ -61,10 +61,10 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, order_contents& contents); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_order_contents = mm2::order_contents; + using t_order_contents = kdf::order_contents; using t_orders_contents = std::vector; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/paging_options.cpp b/src/core/atomicdex/api/kdf/paging_options.cpp similarity index 81% rename from src/core/atomicdex/api/mm2/paging_options.cpp rename to src/core/atomicdex/api/kdf/paging_options.cpp index 2d785b004c..783188e29e 100644 --- a/src/core/atomicdex/api/mm2/paging_options.cpp +++ b/src/core/atomicdex/api/kdf/paging_options.cpp @@ -3,9 +3,9 @@ #include -#include "atomicdex/api/mm2/paging_options.hpp" +#include "atomicdex/api/kdf/paging_options.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const paging_options_t& in) { diff --git a/src/core/atomicdex/api/mm2/paging_options.hpp b/src/core/atomicdex/api/kdf/paging_options.hpp similarity index 92% rename from src/core/atomicdex/api/mm2/paging_options.hpp rename to src/core/atomicdex/api/kdf/paging_options.hpp index 851ce650f7..640cfbd767 100644 --- a/src/core/atomicdex/api/mm2/paging_options.hpp +++ b/src/core/atomicdex/api/kdf/paging_options.hpp @@ -7,7 +7,7 @@ #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct paging_options_t { diff --git a/src/core/atomicdex/api/mm2/rpc.cpp b/src/core/atomicdex/api/kdf/rpc.cpp similarity index 85% rename from src/core/atomicdex/api/mm2/rpc.cpp rename to src/core/atomicdex/api/kdf/rpc.cpp index a5a2786a78..028b0d479c 100644 --- a/src/core/atomicdex/api/mm2/rpc.cpp +++ b/src/core/atomicdex/api/kdf/rpc.cpp @@ -1,8 +1,8 @@ #include -#include "atomicdex/api/mm2/rpc.hpp" +#include "atomicdex/api/kdf/rpc.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void from_json(const nlohmann::json& j, rpc_basic_error_type& in) { diff --git a/src/core/atomicdex/api/mm2/rpc.hpp b/src/core/atomicdex/api/kdf/rpc.hpp similarity index 98% rename from src/core/atomicdex/api/mm2/rpc.hpp rename to src/core/atomicdex/api/kdf/rpc.hpp index ae41949fec..db9bf77687 100644 --- a/src/core/atomicdex/api/mm2/rpc.hpp +++ b/src/core/atomicdex/api/kdf/rpc.hpp @@ -22,7 +22,7 @@ #include "../api.call.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { template concept rpc = requires(Rpc rpc) diff --git a/src/core/atomicdex/api/mm2/rpc.tx.history.cpp b/src/core/atomicdex/api/kdf/rpc.tx.history.cpp similarity index 98% rename from src/core/atomicdex/api/mm2/rpc.tx.history.cpp rename to src/core/atomicdex/api/kdf/rpc.tx.history.cpp index 246eb0750f..2d554b44f7 100644 --- a/src/core/atomicdex/api/mm2/rpc.tx.history.cpp +++ b/src/core/atomicdex/api/kdf/rpc.tx.history.cpp @@ -4,7 +4,7 @@ //! Project Headers #include "rpc.tx.history.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const tx_history_request& cfg) { @@ -105,4 +105,4 @@ namespace atomic_dex::mm2 answer.result = j.at("result").get(); } } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc.tx.history.hpp b/src/core/atomicdex/api/kdf/rpc.tx.history.hpp similarity index 92% rename from src/core/atomicdex/api/mm2/rpc.tx.history.hpp rename to src/core/atomicdex/api/kdf/rpc.tx.history.hpp index a761b2d954..4f8d1cb072 100644 --- a/src/core/atomicdex/api/mm2/rpc.tx.history.hpp +++ b/src/core/atomicdex/api/kdf/rpc.tx.history.hpp @@ -5,10 +5,10 @@ #include -#include "atomicdex/api/mm2/transaction.data.hpp" -#include "atomicdex/api/mm2/paging_options.hpp" +#include "atomicdex/api/kdf/transaction.data.hpp" +#include "atomicdex/api/kdf/paging_options.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct tx_history_request { @@ -80,9 +80,9 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, tx_history_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_tx_history_request = mm2::tx_history_request; + using t_tx_history_request = kdf::tx_history_request; } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.buy.cpp similarity index 92% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.buy.cpp index 06778770c5..00475f3a42 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.buy.cpp @@ -15,14 +15,13 @@ ******************************************************************************/ //! Deps -#include #include //! Project Headers -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.buy.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.buy.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void from_json(const nlohmann::json& j, buy_answer_success& contents) @@ -75,5 +74,9 @@ namespace atomic_dex::mm2 { SPDLOG_INFO("The order is not picked from orderbook we create it from volume = {}, price = {}", j.at("volume").dump(4), request.price); } + if (request.order_type.has_value()) + { + j["order_type"] = request.order_type.value(); + } } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.buy.hpp similarity index 87% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.buy.hpp index 5e31e108e4..e6a5083691 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.buy.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.buy.hpp @@ -21,12 +21,12 @@ #include //! Deps -#include +#include //! Project Header -#include +#include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct buy_request { @@ -43,7 +43,9 @@ namespace atomic_dex::mm2 bool selected_order_use_input_volume{false}; std::optional base_nota{std::nullopt}; std::optional base_confs{std::nullopt}; + // bool is_max; std::optional min_volume{std::nullopt}; + std::optional order_type; }; void to_json(nlohmann::json& j, const buy_request& request); @@ -64,11 +66,11 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, buy_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_buy_request = mm2::buy_request; - using t_buy_answer = mm2::buy_answer; - using t_buy_answer_success = mm2::buy_answer_success; + using t_buy_request = kdf::buy_request; + using t_buy_answer = kdf::buy_answer; + using t_buy_answer_success = kdf::buy_answer_success; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.convertaddress.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.convertaddress.cpp similarity index 80% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.convertaddress.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.convertaddress.cpp index 333a76b46c..a50afb55c1 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.convertaddress.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.convertaddress.cpp @@ -6,10 +6,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v1/rpc.convertaddress.hpp" -#include "atomicdex/api/mm2/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.convertaddress.hpp" +#include "atomicdex/api/kdf/generics.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const convert_address_request& req) @@ -30,4 +30,4 @@ namespace atomic_dex::mm2 { extract_rpc_json_answer(j, answer); } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.convertaddress.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.convertaddress.hpp similarity index 80% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.convertaddress.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.convertaddress.hpp index 02f1553000..da05a2ed63 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.convertaddress.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.convertaddress.hpp @@ -6,7 +6,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct convert_address_request { @@ -33,11 +33,11 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, convert_address_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_convert_address_request = mm2::convert_address_request; - using t_convert_address_answer = mm2::convert_address_answer; - using t_convert_address_answer_success = mm2::convert_address_answer_success; + using t_convert_address_request = kdf::convert_address_request; + using t_convert_address_answer = kdf::convert_address_answer; + using t_convert_address_answer_success = kdf::convert_address_answer_success; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.disable_coin.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.disable_coin.cpp similarity index 77% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.disable_coin.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.disable_coin.cpp index 8de2611550..d3a3b123ed 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.disable_coin.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.disable_coin.cpp @@ -5,10 +5,10 @@ #include //! -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.disable_coin.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.disable_coin.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void @@ -29,4 +29,4 @@ namespace atomic_dex::mm2 { extract_rpc_json_answer(j, resp); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.disable_coin.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.disable_coin.hpp similarity index 81% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.disable_coin.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.disable_coin.hpp index 10159e9b77..8a07b47df2 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.disable_coin.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.disable_coin.hpp @@ -6,7 +6,7 @@ //! JSON FWD #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct disable_coin_request { @@ -31,10 +31,10 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, disable_coin_answer& resp); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_disable_coin_request = mm2::disable_coin_request; - using t_disable_coin_answer = mm2::disable_coin_answer; + using t_disable_coin_request = kdf::disable_coin_request; + using t_disable_coin_answer = kdf::disable_coin_answer; } diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.electrum.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.electrum.cpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.electrum.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.electrum.cpp index f08fb1bb6f..d381fd5c7e 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.electrum.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.electrum.cpp @@ -18,10 +18,10 @@ #include //! Project Deps -#include "atomicdex/api/mm2/rpc_v1/rpc.electrum.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.electrum.hpp" //! Implementation RPC [electrum] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void @@ -29,6 +29,8 @@ namespace atomic_dex::mm2 { j["coin"] = cfg.coin_name; j["tx_history"] = cfg.with_tx_history; + j["min_connected"] = 1; + j["max_connected"] = 3; if (!cfg.servers.empty()) { @@ -70,4 +72,4 @@ namespace atomic_dex::mm2 j.at("balance").get_to(cfg.balance); j.at("result").get_to(cfg.result); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.electrum.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.electrum.hpp similarity index 87% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.electrum.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.electrum.hpp index c3d545c57a..749b9d96f6 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.electrum.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.electrum.hpp @@ -22,9 +22,9 @@ //! Project Headers #include "atomicdex/config/electrum.cfg.hpp" #include "atomicdex/constants/qt.coins.enums.hpp" -#include "atomicdex/api/mm2/address_format.hpp" +#include "atomicdex/api/kdf/address_format.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct electrum_request { @@ -39,6 +39,8 @@ namespace atomic_dex::mm2 std::optional merge_params; std::optional> bchd_urls; std::optional allow_slp_unsafe_conf; + int min_connected{1}; + int max_connected{3}; }; struct electrum_answer @@ -53,10 +55,10 @@ namespace atomic_dex::mm2 void to_json(nlohmann::json& j, const electrum_request& cfg); void from_json(const nlohmann::json& j, electrum_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_electrum_request = mm2::electrum_request; - using t_electrum_answer = mm2::electrum_answer; -} // namespace atomic_dex \ No newline at end of file + using t_electrum_request = kdf::electrum_request; + using t_electrum_answer = kdf::electrum_answer; +} // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.enable.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.enable.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.enable.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.enable.cpp index 83ee67f33e..16ea536dc8 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.enable.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.enable.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v1/rpc.enable.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.enable.hpp" //! Implementation RPC [enable] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void @@ -57,9 +57,9 @@ namespace atomic_dex::mm2 { j["gas_station_decimals"] = cfg.matic_gas_station_decimals.value(); } - if (cfg.mm2.has_value()) + if (cfg.kdf.has_value()) { - j["mm2"] = cfg.mm2.value(); + j["kdf"] = cfg.kdf.value(); } } default: @@ -84,4 +84,4 @@ namespace atomic_dex::mm2 j.at("result").get_to(cfg.result); // SPDLOG_INFO("balance for {} is {}", cfg.address, cfg.balance); } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.enable.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.enable.hpp similarity index 92% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.enable.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.enable.hpp index 4f4bbafeb2..cfdca87eae 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.enable.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.enable.hpp @@ -23,7 +23,7 @@ //! Project Headers #include "atomicdex/constants/qt.coins.enums.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Only for erc 20 struct enable_request @@ -35,7 +35,7 @@ namespace atomic_dex::mm2 const std::string swap_contract_address; std::optional fallback_swap_contract{std::nullopt}; std::optional matic_gas_station_decimals{9}; - std::optional mm2{1}; + std::optional kdf{1}; std::optional gas_station_url{std::nullopt}; std::optional matic_gas_station_url{std::nullopt}; std::optional testnet_matic_gas_station_url{std::nullopt}; @@ -55,10 +55,10 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, const enable_answer& cfg); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_enable_request = mm2::enable_request; - using t_enable_answer = mm2::enable_answer; + using t_enable_request = kdf::enable_request; + using t_enable_answer = kdf::enable_answer; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.cpp index d9de7d5700..19fda288e7 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.cpp @@ -18,12 +18,12 @@ #include //! Project Headers -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.hpp" #include "atomicdex/utilities/global.utilities.hpp" //! Implementation RPC [max_taker_vol] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void @@ -64,4 +64,4 @@ namespace atomic_dex::mm2 answer.result.value().coin = j.at("coin").get(); } } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.hpp similarity index 89% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.hpp index 14bf04af54..ee772d4e0b 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.hpp @@ -23,7 +23,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct max_taker_vol_request { @@ -52,11 +52,11 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, max_taker_vol_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_max_taker_vol_request = mm2::max_taker_vol_request; - using t_max_taker_vol_answer = mm2::max_taker_vol_answer; - using t_max_taker_vol_answer_success = mm2::max_taker_vol_answer_success; + using t_max_taker_vol_request = kdf::max_taker_vol_request; + using t_max_taker_vol_answer = kdf::max_taker_vol_answer; + using t_max_taker_vol_answer_success = kdf::max_taker_vol_answer_success; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.cpp similarity index 79% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.cpp index c26141fc40..0b4d5aff43 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.cpp @@ -2,10 +2,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const min_volume_request& cfg) @@ -27,4 +27,4 @@ namespace atomic_dex::mm2 { extract_rpc_json_answer(j, answer); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp similarity index 74% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp index 1cb5fd8a45..3454726ff2 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp @@ -11,9 +11,9 @@ //! Deps #include -#include "atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct min_volume_request { @@ -39,11 +39,11 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, min_volume_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_min_volume_request = mm2::min_volume_request; - using t_min_volume_answer = mm2::min_volume_answer; - using t_min_volume_answer_success = mm2::min_volume_answer_success; + using t_min_volume_request = kdf::min_volume_request; + using t_min_volume_answer = kdf::min_volume_answer; + using t_min_volume_answer_success = kdf::min_volume_answer_success; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.my_balance.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.my_balance.cpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.my_balance.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.my_balance.cpp index ad79aad144..7c7574975d 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.my_balance.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.my_balance.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v1/rpc.my_balance.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.my_balance.hpp" #include "atomicdex/utilities/global.utilities.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const balance_request& cfg) @@ -37,4 +37,4 @@ namespace atomic_dex::mm2 cfg.balance = atomic_dex::utils::adjust_precision(cfg.balance); j.at("coin").get_to(cfg.coin); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.my_balance.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.my_balance.hpp similarity index 91% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.my_balance.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.my_balance.hpp index a3e4db1dfb..12f17c1707 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.my_balance.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.my_balance.hpp @@ -18,7 +18,7 @@ #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct balance_request { @@ -37,10 +37,10 @@ namespace atomic_dex::mm2 void to_json(nlohmann::json& j, const balance_request& cfg); void from_json(const nlohmann::json& j, balance_answer& cfg); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_balance_request = mm2::balance_request; - using t_balance_answer = mm2::balance_answer; + using t_balance_request = kdf::balance_request; + using t_balance_answer = kdf::balance_answer; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.my_tx_history.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.my_tx_history.hpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.my_tx_history.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.my_tx_history.hpp index e59cd15d8e..a272591909 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.my_tx_history.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.my_tx_history.hpp @@ -3,9 +3,9 @@ #pragma once -#include "atomicdex/api/mm2/rpc.hpp" +#include "atomicdex/api/kdf/rpc.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct my_tx_history_v1_rpc { diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.cpp similarity index 91% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.cpp index 6ca1f0000a..490625251c 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.cpp @@ -6,9 +6,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const recover_funds_of_swap_request& cfg) diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp similarity index 84% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp index d9e2daae9f..3f6f29c25f 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp @@ -6,7 +6,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct recover_funds_of_swap_request { @@ -34,10 +34,10 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, recover_funds_of_swap_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_recover_funds_of_swap_request = mm2::recover_funds_of_swap_request; - using t_recover_funds_of_swap_answer = mm2::recover_funds_of_swap_answer; + using t_recover_funds_of_swap_request = kdf::recover_funds_of_swap_request; + using t_recover_funds_of_swap_answer = kdf::recover_funds_of_swap_answer; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.sell.cpp similarity index 95% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.sell.cpp index 6779feb367..f35302eee0 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.sell.cpp @@ -15,14 +15,13 @@ ******************************************************************************/ //! Deps -#include #include //! Project Headers -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.sell.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.sell.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const sell_request& request) @@ -91,4 +90,4 @@ namespace atomic_dex::mm2 { extract_rpc_json_answer(j, answer); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.sell.hpp similarity index 91% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.sell.hpp index c2a1551731..407447d11e 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.sell.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.sell.hpp @@ -24,9 +24,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/trading.order.contents.hpp" +#include "atomicdex/api/kdf/trading.order.contents.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct sell_request { @@ -66,11 +66,11 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, sell_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_sell_request = mm2::sell_request; - using t_sell_answer = mm2::sell_answer; - using t_sell_answer_success = mm2::sell_answer_success; + using t_sell_request = kdf::sell_request; + using t_sell_answer = kdf::sell_answer; + using t_sell_answer_success = kdf::sell_answer_success; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.setprice.cpp similarity index 90% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.setprice.cpp index a9d0816d74..1e0e1954d5 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.setprice.cpp @@ -17,9 +17,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.setprice.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const setprice_request& request) @@ -28,8 +28,10 @@ namespace atomic_dex::mm2 j["price"] = request.price; j["rel"] = request.rel; j["volume"] = request.volume; - j["cancel_previous"] = request.cancel_previous; - j["max"] = request.max; + if (request.cancel_previous.has_value()) + { + j["cancel_previous"] = request.cancel_previous.value(); + } if (request.base_nota.has_value()) { j["base_nota"] = request.base_nota.value(); diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.setprice.hpp similarity index 90% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.setprice.hpp index 8eb234e274..48e0ea4efd 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.setprice.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.setprice.hpp @@ -23,7 +23,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct setprice_request { @@ -31,8 +31,7 @@ namespace atomic_dex::mm2 std::string rel; std::string price; std::string volume; - bool max{false}; - bool cancel_previous{false}; + std::optional cancel_previous{false}; std::optional base_nota; std::optional base_confs; std::optional rel_nota; @@ -45,5 +44,5 @@ namespace atomic_dex::mm2 namespace atomic_dex { - using t_setprice_request = mm2::setprice_request; + using t_setprice_request = kdf::setprice_request; } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.update_maker_order.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.update_maker_order.cpp similarity index 84% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.update_maker_order.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.update_maker_order.cpp index e7cae487c8..8750f7020a 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.update_maker_order.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.update_maker_order.cpp @@ -6,12 +6,12 @@ #include //! Project Headers -#include +#include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void - to_json(nlohmann::json& j, const mm2::update_maker_order_request& request) + to_json(nlohmann::json& j, const kdf::update_maker_order_request& request) { j["uuid"] = request.uuid; j["new_price"] = request.new_price; @@ -41,4 +41,4 @@ namespace atomic_dex::mm2 j["rel_nota"] = request.rel_nota.value(); } } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.update_maker_order.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.update_maker_order.hpp similarity index 85% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.update_maker_order.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.update_maker_order.hpp index d1249a8b29..4de40143d3 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.update_maker_order.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.update_maker_order.hpp @@ -7,7 +7,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct update_maker_order_request { @@ -23,9 +23,9 @@ namespace atomic_dex::mm2 }; void to_json(nlohmann::json& j, const update_maker_order_request& request); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_update_maker_order_request = mm2::update_maker_order_request; + using t_update_maker_order_request = kdf::update_maker_order_request; } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.validateaddress.cpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.validateaddress.cpp similarity index 71% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.validateaddress.cpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.validateaddress.cpp index e30274b0df..391e213ef9 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.validateaddress.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.validateaddress.cpp @@ -1,12 +1,12 @@ #include -#include "atomicdex/api/mm2/rpc_v1/rpc.validateaddress.hpp" -#include "atomicdex/api/mm2/generics.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.validateaddress.hpp" +#include "atomicdex/api/kdf/generics.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void - to_json(nlohmann::json& j, const mm2::validate_address_request& req) + to_json(nlohmann::json& j, const kdf::validate_address_request& req) { j["coin"] = req.coin; j["address"] = req.address; @@ -26,4 +26,4 @@ namespace atomic_dex::mm2 { extract_rpc_json_answer(j, answer); } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v1/rpc.validateaddress.hpp b/src/core/atomicdex/api/kdf/rpc_v1/rpc.validateaddress.hpp similarity index 80% rename from src/core/atomicdex/api/mm2/rpc_v1/rpc.validateaddress.hpp rename to src/core/atomicdex/api/kdf/rpc_v1/rpc.validateaddress.hpp index 9ca7fbc43f..41dfa5648f 100644 --- a/src/core/atomicdex/api/mm2/rpc_v1/rpc.validateaddress.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v1/rpc.validateaddress.hpp @@ -6,7 +6,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct validate_address_request { @@ -33,11 +33,11 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, validate_address_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_validate_address_request = mm2::validate_address_request; - using t_validate_address_answer = mm2::validate_address_answer; - using t_validate_address_answer_success = mm2::validate_address_answer_success; + using t_validate_address_request = kdf::validate_address_request; + using t_validate_address_answer = kdf::validate_address_answer; + using t_validate_address_answer_success = kdf::validate_address_answer_success; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.bestorders.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.bestorders.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.bestorders.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.bestorders.cpp index ba5dd40660..d1a398b2c4 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.bestorders.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.bestorders.cpp @@ -22,11 +22,11 @@ #include //! Project Headers -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp" //! Implementation RPC [best_orders] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const bestorders_request_rpc& req) @@ -68,4 +68,4 @@ namespace atomic_dex::mm2 } } } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp index 0c9be72572..01472bebd3 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp @@ -24,10 +24,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/orderbook.order.contents.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/orderbook.order.contents.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct bestorders_rpc { @@ -62,4 +62,4 @@ namespace atomic_dex::mm2 void to_json(nlohmann::json& j, const bestorders_request_rpc& req); void from_json(const nlohmann::json& j, bestorders_result_rpc& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.cpp index 0727b2d1af..8dda59518b 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.cpp @@ -1,9 +1,9 @@ #include -#include "atomicdex/api/mm2/address_format.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" +#include "atomicdex/api/kdf/address_format.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const enable_bch_with_tokens_request_rpc& in) { diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp index b9141b4933..658bc96f7b 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp @@ -19,12 +19,12 @@ #include #include "atomicdex/config/electrum.cfg.hpp" -#include "atomicdex/api/mm2/address_format.hpp" -#include "atomicdex/api/mm2/balance_info.hpp" -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/utxo_merge_params.hpp" +#include "atomicdex/api/kdf/address_format.hpp" +#include "atomicdex/api/kdf/balance_infos.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/utxo_merge_params.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_bch_with_tokens_rpc { @@ -65,13 +65,13 @@ namespace atomic_dex::mm2 { derivation_method_t derivation_method; std::string pubkey; - balance_info balances; + balance_infos balances; }; struct slp_address_infos_t { derivation_method_t derivation_method; std::string pubkey; - std::unordered_map balances; + std::unordered_map balances; }; std::size_t current_block; diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.cpp similarity index 86% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.cpp index 4c4bf707c5..0587f03053 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.cpp @@ -1,8 +1,8 @@ #include -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const enable_erc20_rpc_request& request) { @@ -21,6 +21,6 @@ namespace atomic_dex::mm2 { j.at("platform_coin").get_to(in.platform_coin); j.at("required_confirmations").get_to(in.required_confirmations); - j.at("balances").get_to>(in.balances); + j.at("balances").get_to>(in.balances); } } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.hpp similarity index 92% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.hpp index 953bb8f67d..c99b07fe76 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.hpp @@ -17,12 +17,13 @@ #pragma once #include +#include #include //> nlohmann::json -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/balance_info.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/balance_infos.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_erc20_rpc { @@ -39,7 +40,7 @@ namespace atomic_dex::mm2 { std::string platform_coin; int required_confirmations; - std::unordered_map balances; + std::unordered_map balances; }; using expected_error_type = rpc_basic_error_type; diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.cpp similarity index 95% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.cpp index 2a0bb73211..2d4845a99b 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.cpp @@ -1,8 +1,8 @@ #include -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const enable_eth_with_tokens_request_rpc& in) { diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.hpp similarity index 95% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.hpp index 9205777d8d..7e378aac23 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.hpp @@ -18,12 +18,12 @@ #include -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/balance_info.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/balance_infos.hpp" #include "atomicdex/config/enable.cfg.hpp" #include "atomicdex/constants/qt.coins.enums.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_eth_with_tokens_rpc { @@ -60,13 +60,13 @@ namespace atomic_dex::mm2 { derivation_method_t derivation_method; std::string pubkey; - balance_info balances; + balance_infos balances; }; struct erc20_address_infos_t { derivation_method_t derivation_method; std::string pubkey; - std::unordered_map balances; + std::unordered_map balances; }; std::size_t current_block; diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.cpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.cpp index 813fca85f0..0422df4379 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.cpp @@ -2,7 +2,7 @@ #include "rpc2.enable_slp_rpc.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const enable_slp_rpc_request& request) { @@ -22,6 +22,6 @@ namespace atomic_dex::mm2 j.at("platform_coin").get_to(in.platform_coin); j.at("required_confirmations").get_to(in.required_confirmations); j.at("token_id").get_to(in.token_id); - j.at("balances").get_to>(in.balances); + j.at("balances").get_to>(in.balances); } } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.hpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.hpp index 6cabbe2f72..4ed2462a1d 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.hpp @@ -22,10 +22,10 @@ #include //> nlohmann::json -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/balance_info.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/balance_infos.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_slp_rpc { @@ -43,7 +43,7 @@ namespace atomic_dex::mm2 std::string token_id; std::string platform_coin; int required_confirmations; - std::unordered_map balances; + std::unordered_map balances; }; using expected_error_type = rpc_basic_error_type; diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.cpp similarity index 92% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.cpp index d20efa4132..cbdf20206e 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.cpp @@ -2,7 +2,7 @@ #include "rpc2.enable_tendermint_token.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const enable_tendermint_token_rpc_request& request) { @@ -20,6 +20,6 @@ namespace atomic_dex::mm2 void from_json(const nlohmann::json& j, enable_tendermint_token_rpc_result& in) { j.at("platform_coin").get_to(in.platform_coin); - j.at("balances").get_to>(in.balances); + j.at("balances").get_to>(in.balances); } } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.hpp similarity index 91% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.hpp index 86d7525f1d..fcf180a9f2 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.hpp @@ -21,10 +21,10 @@ #include //> nlohmann::json -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/balance_info.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/balance_infos.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_tendermint_token_rpc { @@ -40,7 +40,7 @@ namespace atomic_dex::mm2 struct expected_result_type { std::string platform_coin; - std::unordered_map balances; + std::unordered_map balances; }; using expected_error_type = rpc_basic_error_type; @@ -48,7 +48,7 @@ namespace atomic_dex::mm2 expected_request_type request; std::optional result; std::optional error; - std::string raw_result; + std::string raw_result; }; using enable_tendermint_token_rpc_request = enable_tendermint_token_rpc::expected_request_type; diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.cpp similarity index 92% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.cpp index b924bbe656..280d6b7570 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.cpp @@ -2,12 +2,12 @@ #include "rpc2.enable_tendermint_with_assets.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const enable_tendermint_with_assets_request_rpc& in) { j["ticker"] = in.ticker; - j["rpc_urls"] = in.rpc_urls; + j["nodes"] = in.nodes; j["tx_history"] = in.tx_history; j["tokens_params"] = in.tokens_params; if (in.required_confirmations.has_value()) @@ -25,6 +25,7 @@ namespace atomic_dex::mm2 void from_json(const nlohmann::json& json, enable_tendermint_with_assets_result_rpc& out) { + out.ticker = json["ticker"]; out.address = json["address"]; out.current_block = json["current_block"]; out.tendermint_balances_infos = json["balance"].get(); diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.hpp similarity index 85% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.hpp index 76876d0a89..714f1f810b 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.hpp @@ -2,11 +2,12 @@ #include -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/balance_info.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/config/enable.cfg.hpp" +#include "atomicdex/api/kdf/balance_infos.hpp" #include "atomicdex/config/electrum.cfg.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_tendermint_with_assets_rpc { @@ -20,9 +21,8 @@ namespace atomic_dex::mm2 std::string ticker; std::optional required_confirmations; }; - std::string ticker; - std::vector rpc_urls; + std::vector nodes; bool tx_history{true}; std::vector tokens_params; std::optional required_confirmations; @@ -33,13 +33,14 @@ namespace atomic_dex::mm2 { struct tendermint_balance_infos_t { - balance_info balances; + balance_infos balances; }; + std::string ticker; std::string address; std::size_t current_block; tendermint_balance_infos_t tendermint_balances_infos; - std::unordered_map tendermint_token_balances_infos; + std::unordered_map tendermint_token_balances_infos; }; using expected_error_type = rpc_basic_error_type; diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.cpp index acd53173d5..74f694a2b1 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.cpp @@ -16,9 +16,9 @@ #include -#include "atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const get_public_key_rpc_request& request) { diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.hpp similarity index 97% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.hpp index 98f15bc9f2..6eefb07bad 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.hpp @@ -22,9 +22,9 @@ #include -#include "atomicdex/api/mm2/rpc.hpp" +#include "atomicdex/api/kdf/rpc.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct get_public_key_rpc { diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.cpp similarity index 95% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.cpp index 9b4a104837..8cebd503cf 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.cpp @@ -18,9 +18,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const my_tx_history_request_rpc& in) { diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.hpp similarity index 89% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.hpp index fd7089ae59..a63d85718e 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.my_tx_history.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.my_tx_history.hpp @@ -3,13 +3,13 @@ #include -#include "atomicdex/api/mm2/paging_options.hpp" -#include "atomicdex/api/mm2/transaction.data.hpp" -#include "atomicdex/api/mm2/rpc.hpp" +#include "atomicdex/api/kdf/paging_options.hpp" +#include "atomicdex/api/kdf/transaction.data.hpp" +#include "atomicdex/api/kdf/rpc.hpp" #pragma once -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct my_tx_history_v2_rpc { diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.orderbook.cpp similarity index 96% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.orderbook.cpp index f80fa1ec55..f7f47d0f0b 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.orderbook.cpp @@ -16,13 +16,12 @@ //! Deps #include -#include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp" #include "atomicdex/utilities/global.utilities.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const orderbook_request_rpc& req) @@ -40,7 +39,6 @@ namespace atomic_dex::mm2 if (j.contains("result")) { // Not sure how why where it is being returned in this format - SPDLOG_DEBUG("orderbook_result_rpc: result"); j.at("result").at("rel").get_to(resp.rel); j.at("result").at("num_asks").get_to(resp.numasks); j.at("result").at("num_bids").get_to(resp.numbids); @@ -52,7 +50,6 @@ namespace atomic_dex::mm2 } else { - SPDLOG_DEBUG("orderbook_result_rpc: base"); j.at("base").get_to(resp.base); j.at("rel").get_to(resp.rel); j.at("num_asks").get_to(resp.numasks); @@ -124,4 +121,4 @@ namespace atomic_dex::mm2 } } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp similarity index 96% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp index 6b3a5bd3a2..d6a97f49f2 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp @@ -21,10 +21,10 @@ #include //> nlohmann::json -#include "atomicdex/api/mm2/rpc.hpp" -#include "atomicdex/api/mm2/orderbook.order.contents.hpp" +#include "atomicdex/api/kdf/rpc.hpp" +#include "atomicdex/api/kdf/orderbook.order.contents.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct orderbook_rpc { diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.cpp index 36a58b96b8..5a9ff1919d 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp" //! Implementation 2.0 RPC [enable_z_coin_cancel] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void to_json(nlohmann::json& j, const enable_z_coin_cancel_request& request) @@ -50,4 +50,4 @@ namespace atomic_dex::mm2 } } } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp similarity index 89% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp index 87bfcf4788..67781ebf64 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.cancel.hpp @@ -23,9 +23,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/generic.error.hpp" +#include "atomicdex/api/kdf/generic.error.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_z_coin_cancel_request { @@ -54,7 +54,7 @@ namespace atomic_dex::mm2 namespace atomic_dex { - using t_enable_z_coin_cancel_request = mm2::enable_z_coin_cancel_request; - using t_enable_z_coin_cancel_answer = mm2::enable_z_coin_cancel_answer; - using t_enable_z_coin_cancel_answer_success = mm2::enable_z_coin_cancel_answer_success; + using t_enable_z_coin_cancel_request = kdf::enable_z_coin_cancel_request; + using t_enable_z_coin_cancel_answer = kdf::enable_z_coin_cancel_answer; + using t_enable_z_coin_cancel_answer_success = kdf::enable_z_coin_cancel_answer_success; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.cpp similarity index 95% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.cpp index 6a09fd06a3..b5c7cd7ebc 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.hpp" //! Implementation 2.0 RPC [enable_z_coin] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void to_json(nlohmann::json& j, const enable_z_coin_request& request) @@ -44,4 +44,4 @@ namespace atomic_dex::mm2 { j.at("task_id").get_to(answer.task_id); } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.hpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.hpp index 126e4eda94..2d3208256b 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.hpp @@ -26,7 +26,7 @@ #include "atomicdex/config/electrum.cfg.hpp" #include "atomicdex/constants/qt.coins.enums.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_z_coin_request { @@ -50,6 +50,6 @@ namespace atomic_dex::mm2 namespace atomic_dex { - using t_enable_z_coin_request = mm2::enable_z_coin_request; - using t_enable_z_coin_answer = mm2::enable_z_coin_answer; + using t_enable_z_coin_request = kdf::enable_z_coin_request; + using t_enable_z_coin_answer = kdf::enable_z_coin_answer; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.cpp similarity index 96% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.cpp index 805939e270..a626a6102c 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.hpp" //! Implementation 2.0 RPC [enable_z_coin_status] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void to_json(nlohmann::json& j, const enable_z_coin_status_request& request) @@ -77,5 +77,5 @@ namespace atomic_dex::mm2 } } } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.hpp similarity index 91% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.hpp index 769719303c..bbd62bd386 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.hpp @@ -23,9 +23,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/generic.error.hpp" +#include "atomicdex/api/kdf/generic.error.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct enable_z_coin_status_request { @@ -63,7 +63,7 @@ namespace atomic_dex::mm2 namespace atomic_dex { - using t_enable_z_coin_status_request = mm2::enable_z_coin_status_request; - using t_enable_z_coin_status_answer = mm2::enable_z_coin_status_answer; - using t_enable_z_coin_status_answer_success = mm2::enable_z_coin_status_answer_success; + using t_enable_z_coin_status_request = kdf::enable_z_coin_status_request; + using t_enable_z_coin_status_answer = kdf::enable_z_coin_status_answer; + using t_enable_z_coin_status_answer_success = kdf::enable_z_coin_status_answer_success; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.cpp index 6ca0f2a456..3f1fdd8315 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.hpp" //! Implementation 2.0 RPC [withdraw_init] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const withdraw_init_fees& request) @@ -56,4 +56,4 @@ namespace atomic_dex::mm2 { j.at("task_id").get_to(answer.task_id); } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.hpp similarity index 91% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.hpp index 01db2db54e..7acb5b4224 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.hpp @@ -22,7 +22,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct withdraw_init_fees { @@ -51,7 +51,7 @@ namespace atomic_dex::mm2 namespace atomic_dex { - using t_withdraw_init_request = mm2::withdraw_init_request; - using t_withdraw_init_fees = mm2::withdraw_init_fees; - using t_withdraw_init_answer = mm2::withdraw_init_answer; + using t_withdraw_init_request = kdf::withdraw_init_request; + using t_withdraw_init_fees = kdf::withdraw_init_fees; + using t_withdraw_init_answer = kdf::withdraw_init_answer; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.cpp similarity index 93% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.cpp index e897f25426..4d45d2bd8f 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.hpp" //! Implementation 2.0 RPC [withdraw_status] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void to_json(nlohmann::json& j, const withdraw_status_request& request) @@ -42,4 +42,4 @@ namespace atomic_dex::mm2 answer.result = j.at("result").at("details").get(); } } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.hpp similarity index 88% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.hpp index fce20944e9..dd4ac4909f 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.hpp @@ -23,10 +23,10 @@ #include //! Our Headers -#include "atomicdex/api/mm2/generic.error.hpp" -#include "atomicdex/api/mm2/transaction.data.hpp" +#include "atomicdex/api/kdf/generic.error.hpp" +#include "atomicdex/api/kdf/transaction.data.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct withdraw_status_request { @@ -47,6 +47,6 @@ namespace atomic_dex::mm2 namespace atomic_dex { - using t_withdraw_status_request = mm2::withdraw_status_request; - using t_withdraw_status_answer = mm2::withdraw_status_answer; + using t_withdraw_status_request = kdf::withdraw_status_request; + using t_withdraw_status_answer = kdf::withdraw_status_answer; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.cpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.cpp index baccc6e830..4a11d69d98 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/generics.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp" +#include "atomicdex/api/kdf/generics.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void @@ -74,4 +74,4 @@ namespace atomic_dex::mm2 { extract_rpc_json_answer(j, answer); } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.fwd.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.fwd.hpp similarity index 91% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.fwd.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.fwd.hpp index ee8f2a57f5..c427e9a921 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.fwd.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.fwd.hpp @@ -16,13 +16,13 @@ #pragma once -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct trade_preimage_request; struct trade_preimage_answer; -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_trade_preimage_answer = mm2::trade_preimage_answer; + using t_trade_preimage_answer = kdf::trade_preimage_answer; } \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp similarity index 89% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp index 9b888836b2..b292893092 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp @@ -25,9 +25,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/fraction.hpp" +#include "atomicdex/api/kdf/fraction.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct trade_preimage_request { @@ -45,7 +45,7 @@ namespace atomic_dex::mm2 { std::string coin; std::string amount; - mm2::fraction amount_fraction; + kdf::fraction amount_fraction; }; ENTT_API void from_json(const nlohmann::json& j, coin_fee& fee); @@ -71,11 +71,11 @@ namespace atomic_dex::mm2 }; ENTT_API void from_json(const nlohmann::json& j, trade_preimage_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_trade_preimage_request = mm2::trade_preimage_request; - using t_trade_preimage_answer = mm2::trade_preimage_answer; - using t_trade_preimage_answer_success = mm2::trade_preimage_answer_success; + using t_trade_preimage_request = kdf::trade_preimage_request; + using t_trade_preimage_answer = kdf::trade_preimage_answer; + using t_trade_preimage_answer_success = kdf::trade_preimage_answer_success; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.withdraw.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.withdraw.cpp similarity index 86% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.withdraw.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.withdraw.cpp index 7b2a2aa937..30d65e0649 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.withdraw.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.withdraw.cpp @@ -9,7 +9,7 @@ #include "atomicdex/utilities/global.utilities.hpp" #include "rpc2.withdraw.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const withdraw_fees& cfg) @@ -46,6 +46,13 @@ namespace atomic_dex::mm2 obj["params"]["amount"] = cfg.amount; obj["params"]["to"] = cfg.to; obj["params"]["max"] = cfg.max; + if (cfg.ibc_source_channel.has_value()) + { + if (cfg.ibc_source_channel.value() != "") + { + obj["params"]["ibc_source_channel"] = cfg.ibc_source_channel.value(); + } + } if (cfg.memo.has_value()) { obj["params"]["memo"] = cfg.memo.value(); @@ -69,4 +76,4 @@ namespace atomic_dex::mm2 answer.result = j.at("result").get(); } } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.withdraw.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.withdraw.hpp similarity index 61% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.withdraw.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.withdraw.hpp index e59e4d6674..4ff33b0ebf 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.withdraw.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.withdraw.hpp @@ -7,10 +7,10 @@ #include //! Our Headers -#include "atomicdex/api/mm2/generic.error.hpp" -#include "atomicdex/api/mm2/transaction.data.hpp" +#include "atomicdex/api/kdf/generic.error.hpp" +#include "atomicdex/api/kdf/transaction.data.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct withdraw_fees { @@ -26,10 +26,11 @@ namespace atomic_dex::mm2 struct withdraw_request { std::string coin; - std::string to; ///< coins will be withdraw to this address - std::string amount; ///< ignored if max is true - std::optional fees{std::nullopt}; ///< ignored if std::nullopt - std::optional memo; ///< memo for tendermint + std::string to; ///< coins will be withdraw to this address + std::string amount; ///< ignored if max is true + std::optional fees{std::nullopt}; ///< ignored if std::nullopt + std::optional memo{""}; ///< memo for tendermint + std::optional ibc_source_channel{""}; ///< ibc_source_channel for tendermint bool max{false}; }; @@ -44,11 +45,11 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, withdraw_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_withdraw_request = mm2::withdraw_request; - using t_withdraw_fees = mm2::withdraw_fees; - using t_withdraw_answer = mm2::withdraw_answer; + using t_withdraw_request = kdf::withdraw_request; + using t_withdraw_fees = kdf::withdraw_fees; + using t_withdraw_answer = kdf::withdraw_answer; } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.cpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.cpp similarity index 96% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.cpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.cpp index 9b5053c85f..622598fa3f 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.cpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.cpp @@ -18,10 +18,10 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.hpp" //! Implementation 2.0 RPC [z_coin_tx_history] -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { //! Serialization void to_json(nlohmann::json& j, const z_tx_history_request& request) @@ -103,4 +103,4 @@ namespace atomic_dex::mm2 answer.result = j.at("result").get(); } } -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf diff --git a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.hpp b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.hpp similarity index 94% rename from src/core/atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.hpp rename to src/core/atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.hpp index 2f7c9ce8b9..bc5806a265 100644 --- a/src/core/atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.hpp +++ b/src/core/atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.hpp @@ -24,9 +24,9 @@ #include //! Our Headers -#include "atomicdex/api/mm2/transaction.data.hpp" +#include "atomicdex/api/kdf/transaction.data.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct z_tx_history_request { @@ -94,10 +94,10 @@ namespace atomic_dex::mm2 }; void from_json(const nlohmann::json& j, z_tx_history_answer& answer); -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_z_tx_history_request = mm2::z_tx_history_request; - using t_z_tx_history_answer = mm2::z_tx_history_answer; + using t_z_tx_history_request = kdf::z_tx_history_request; + using t_z_tx_history_answer = kdf::z_tx_history_answer; } // namespace atomic_dex diff --git a/src/core/atomicdex/api/mm2/trading.order.contents.cpp b/src/core/atomicdex/api/kdf/trading.order.contents.cpp similarity index 95% rename from src/core/atomicdex/api/mm2/trading.order.contents.cpp rename to src/core/atomicdex/api/kdf/trading.order.contents.cpp index ea35f974d4..26f69f2cb5 100644 --- a/src/core/atomicdex/api/mm2/trading.order.contents.cpp +++ b/src/core/atomicdex/api/kdf/trading.order.contents.cpp @@ -18,9 +18,9 @@ #include //! Project Headers -#include +#include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void from_json(const nlohmann::json& j, trading_order_contents& contents) diff --git a/src/core/atomicdex/api/mm2/trading.order.contents.hpp b/src/core/atomicdex/api/kdf/trading.order.contents.hpp similarity index 98% rename from src/core/atomicdex/api/mm2/trading.order.contents.hpp rename to src/core/atomicdex/api/kdf/trading.order.contents.hpp index 0bba41b80d..6e4bf05804 100644 --- a/src/core/atomicdex/api/mm2/trading.order.contents.hpp +++ b/src/core/atomicdex/api/kdf/trading.order.contents.hpp @@ -22,7 +22,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct trading_order_contents { diff --git a/src/core/atomicdex/api/mm2/transaction.data.cpp b/src/core/atomicdex/api/kdf/transaction.data.cpp similarity index 81% rename from src/core/atomicdex/api/mm2/transaction.data.cpp rename to src/core/atomicdex/api/kdf/transaction.data.cpp index fd140e4667..cf01a8f743 100644 --- a/src/core/atomicdex/api/mm2/transaction.data.cpp +++ b/src/core/atomicdex/api/kdf/transaction.data.cpp @@ -1,9 +1,9 @@ #include -#include "atomicdex/api/mm2/transaction.data.hpp" +#include "atomicdex/api/kdf/transaction.data.hpp" #include "atomicdex/utilities/global.utilities.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void from_json(const nlohmann::json& j, fee_regular_coin& cfg) { @@ -104,7 +104,7 @@ namespace atomic_dex::mm2 { if (cfg.coin == "FIRO") { - cfg.from.emplace_back("Lelantusjsplit (Hidden)"); + cfg.from.emplace_back("Hidden"); } else { @@ -114,7 +114,24 @@ namespace atomic_dex::mm2 if (j.contains("transaction_type")) { - cfg.transaction_type = j.at("transaction_type").get(); + // Check if the "transaction_type" is an object for tendermint + if (j.at("transaction_type").is_object()) + { + for (auto& [k, v] : j.at("transaction_type").items()) { + cfg.tendermint_transaction_type = k; + cfg.tendermint_transaction_type_hash = v; + } + } + // Check if "transaction_type" is a string + else if (j.at("transaction_type").is_string()) + { + cfg.transaction_type = j.at("transaction_type").get(); + } + else + { + // Handle the case where "transaction_type" is neither a string nor an object + SPDLOG_ERROR("Unexpected type for transaction_type in JSON"); + } } // transaction_fee only in ZHTLC response @@ -142,4 +159,4 @@ namespace atomic_dex::mm2 std::string s = atomic_dex::utils::to_human_date(cfg.timestamp, "%e %b %Y, %H:%M"); cfg.timestamp_as_date = std::move(s); } -} // namespace atomic_dex::mm2 \ No newline at end of file +} // namespace atomic_dex::kdf \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/transaction.data.hpp b/src/core/atomicdex/api/kdf/transaction.data.hpp similarity index 93% rename from src/core/atomicdex/api/mm2/transaction.data.hpp rename to src/core/atomicdex/api/kdf/transaction.data.hpp index a39f64b9fd..296c89efe0 100644 --- a/src/core/atomicdex/api/mm2/transaction.data.hpp +++ b/src/core/atomicdex/api/kdf/transaction.data.hpp @@ -6,7 +6,7 @@ //! Deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct fee_regular_coin { @@ -74,6 +74,8 @@ namespace atomic_dex::mm2 std::optional internal_id; std::optional confirmations; std::optional transaction_type; + std::optional tendermint_transaction_type; + std::optional tendermint_transaction_type_hash; std::optional memo; std::string timestamp_as_date; ///< human readeable timestamp }; diff --git a/src/core/atomicdex/api/mm2/utxo_merge_params.cpp b/src/core/atomicdex/api/kdf/utxo_merge_params.cpp similarity index 98% rename from src/core/atomicdex/api/mm2/utxo_merge_params.cpp rename to src/core/atomicdex/api/kdf/utxo_merge_params.cpp index 2a5d29c474..5469162767 100644 --- a/src/core/atomicdex/api/mm2/utxo_merge_params.cpp +++ b/src/core/atomicdex/api/kdf/utxo_merge_params.cpp @@ -18,7 +18,7 @@ #include "utxo_merge_params.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { void to_json(nlohmann::json& j, const utxo_merge_params_t& req) { diff --git a/src/core/atomicdex/api/mm2/utxo_merge_params.hpp b/src/core/atomicdex/api/kdf/utxo_merge_params.hpp similarity index 98% rename from src/core/atomicdex/api/mm2/utxo_merge_params.hpp rename to src/core/atomicdex/api/kdf/utxo_merge_params.hpp index db30ee5008..a90ce6a1f2 100644 --- a/src/core/atomicdex/api/mm2/utxo_merge_params.hpp +++ b/src/core/atomicdex/api/kdf/utxo_merge_params.hpp @@ -18,7 +18,7 @@ #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct utxo_merge_params_t { diff --git a/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp b/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp index a2282bb4ae..24032437d9 100644 --- a/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp +++ b/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp @@ -10,7 +10,7 @@ namespace { - constexpr const char* g_komodo_prices_endpoint = "https://defi-stats.komodo.earth"; + constexpr const char* g_komodo_prices_endpoint = "https://cache.defi-stats.komodo.earth"; constexpr const char* g_komodo_prices_endpoint_fallback = "https://prices.cipig.net:1717"; web::http::client::http_client_config g_komodo_prices_cfg{[]() @@ -79,7 +79,7 @@ namespace atomic_dex::komodo_prices::api { web::http::http_request req; req.set_method(web::http::methods::GET); - std::string endpoint = fallback ? "api/v2/tickers?expire_at=21600" : "api/v3/prices/tickers_v2?expire_at=21600"; + std::string endpoint = fallback ? "api/v2/tickers?expire_at=21600" : "api/v3/prices/tickers_v2.json?expire_at=21600"; if (fallback) { SPDLOG_INFO("url: {}", TO_STD_STR(g_komodo_prices_client_fallback->base_uri().to_string()) + endpoint); diff --git a/src/core/atomicdex/api/mm2/balance_info.cpp b/src/core/atomicdex/api/mm2/balance_info.cpp deleted file mode 100644 index 00865a30f3..0000000000 --- a/src/core/atomicdex/api/mm2/balance_info.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#include "atomicdex/api/mm2/balance_info.hpp" - -namespace atomic_dex::mm2 -{ - void from_json(const nlohmann::json& j, balance_info& in) - { - j.at("spendable").get_to(in.spendable); - j.at("unspendable").get_to(in.unspendable); - } -} \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/balance_info.hpp b/src/core/atomicdex/api/mm2/balance_info.hpp deleted file mode 100644 index f40047c368..0000000000 --- a/src/core/atomicdex/api/mm2/balance_info.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -#include //> nlohmann::json - -namespace atomic_dex::mm2 -{ - struct balance_info - { - std::string spendable; - std::string unspendable; - }; - - void from_json(const nlohmann::json& j, balance_info& in); -} \ No newline at end of file diff --git a/src/core/atomicdex/api/mm2/fraction.cpp b/src/core/atomicdex/api/mm2/fraction.cpp deleted file mode 100644 index 0bcdc944fc..0000000000 --- a/src/core/atomicdex/api/mm2/fraction.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include - -#include "atomicdex/api/mm2/fraction.hpp" - -namespace atomic_dex::mm2 -{ - void from_json(const nlohmann::json& j, mm2::fraction& fraction) - { - j.at("denom").get_to(fraction.denom); - j.at("numer").get_to(fraction.numer); - } -} // namespace atomic_dex::mm2 \ No newline at end of file diff --git a/src/core/atomicdex/config/app.cfg.cpp b/src/core/atomicdex/config/app.cfg.cpp index 78ec9fda01..50f16d1cc2 100644 --- a/src/core/atomicdex/config/app.cfg.cpp +++ b/src/core/atomicdex/config/app.cfg.cpp @@ -50,6 +50,7 @@ namespace config_json_data["available_signs"] = config.available_currency_signs; config_json_data["notification_enabled"] = config.notification_enabled; config_json_data["spamfilter_enabled"] = config.spamfilter_enabled; + config_json_data["postorder_enabled"] = config.postorder_enabled; config_json_data["static_rpcpass_enabled"] = config.static_rpcpass_enabled; file.close(); @@ -85,6 +86,15 @@ namespace atomic_dex config.spamfilter_enabled = true; } + if (j.contains("postorder_enabled")) + { + j.at("postorder_enabled").get_to(config.postorder_enabled); + } + else + { + config.postorder_enabled = true; + } + if (j.contains("static_rpcpass_enabled")) { j.at("static_rpcpass_enabled").get_to(config.static_rpcpass_enabled); @@ -105,6 +115,16 @@ namespace atomic_dex } } + void + change_postorder_status(cfg& config, bool is_enabled) + { + if (config.postorder_enabled != is_enabled) + { + config.postorder_enabled = is_enabled; + upgrade_cfg(config); + } + } + void change_spamfilter_status(cfg& config, bool is_enabled) { @@ -165,7 +185,7 @@ namespace atomic_dex //! If it's fiat, i set the first element of the possible currencies to the new currency (the new fiat here) and i also set the current fiat if (is_this_currency_a_fiat(config, new_currency)) { - SPDLOG_INFO("{} is fiat, setting it as current fiat and possible currencies", new_currency); + // SPDLOG_INFO("{} is fiat, setting it as current fiat and possible currencies", new_currency); config.current_fiat = new_currency; config.current_fiat_sign = config.current_currency_sign; config.possible_currencies[0] = new_currency; @@ -173,11 +193,11 @@ namespace atomic_dex if (std::count(config.recommended_fiat.begin(), config.recommended_fiat.end(), new_currency)) { - SPDLOG_INFO("{} is already in recommended fiats", new_currency); + // SPDLOG_INFO("{} is already in recommended fiats", new_currency); update_recommended_fiat = false; } if (update_recommended_fiat) { - SPDLOG_INFO("Adding {} to recommended fiats", new_currency); + // SPDLOG_INFO("Adding {} to recommended fiats", new_currency); config.recommended_fiat.pop_back(); config.recommended_fiat.insert(config.recommended_fiat.begin(), new_currency); } diff --git a/src/core/atomicdex/config/app.cfg.hpp b/src/core/atomicdex/config/app.cfg.hpp index 550a182386..d707ee02d5 100644 --- a/src/core/atomicdex/config/app.cfg.hpp +++ b/src/core/atomicdex/config/app.cfg.hpp @@ -32,6 +32,7 @@ namespace atomic_dex std::vector recommended_fiat; std::vector possible_currencies; bool notification_enabled; + bool postorder_enabled{false}; bool spamfilter_enabled{false}; bool static_rpcpass_enabled{false}; }; @@ -40,6 +41,7 @@ namespace atomic_dex void change_currency(cfg& config, const std::string& new_currency); void change_fiat(cfg& config, const std::string& new_fiat); void change_notification_status(cfg& config, bool is_enabled); + void change_postorder_status(cfg& config, bool is_enabled); void change_spamfilter_status(cfg& config, bool is_enabled); void change_static_rpcpass_status(cfg& config, bool is_enabled); [[nodiscard]] bool is_this_currency_a_fiat(const cfg& config, const std::string& currency); diff --git a/src/core/atomicdex/config/coins.cfg.cpp b/src/core/atomicdex/config/coins.cfg.cpp index 1f846b5376..c5c0ba5038 100644 --- a/src/core/atomicdex/config/coins.cfg.cpp +++ b/src/core/atomicdex/config/coins.cfg.cpp @@ -149,6 +149,11 @@ namespace atomic_dex { return std::any_of(g_faucet_coins.begin(), g_faucet_coins.end(), [ticker](std::string x) { return ticker == x; }); } + bool + is_vote_coin(std::string ticker) + { + return std::any_of(g_vote_coins.begin(), g_vote_coins.end(), [ticker](std::string x) { return ticker == x; }); + } void from_json(const nlohmann::json& j, coin_config_t& cfg) @@ -172,6 +177,7 @@ namespace atomic_dex cfg.wallet_only = is_wallet_only(cfg.ticker) ? is_wallet_only(cfg.ticker) : j.contains("wallet_only") ? j.at("wallet_only").get() : false; cfg.default_coin = is_default_coin(cfg.ticker); cfg.is_faucet_coin = is_faucet_coin(cfg.ticker); + cfg.is_vote_coin = is_vote_coin(cfg.ticker); cfg.checkpoint_height = 0; cfg.checkpoint_blocktime = 0; using namespace std::chrono; @@ -211,13 +217,7 @@ namespace atomic_dex } if (j.contains("rpc_urls")) { - auto rpc_urls_obj = j.at("rpc_urls").get>(); - std::vector rpc_urls_list; - cfg.rpc_urls = rpc_urls_list; - for (const auto& url : rpc_urls_obj) - { - cfg.rpc_urls->push_back(url.url); - } + cfg.rpc_urls = j.at("rpc_urls").get>(); } if (j.contains("allow_slp_unsafe_conf")) { @@ -286,21 +286,21 @@ namespace atomic_dex { case CoinType::QRC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "tQTUM" : "QTUM"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "tQTUM" : "QTUM"; break; case CoinType::ERC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "ETHR" : "ETH"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "ETHR" : "ETH"; cfg.is_erc_family = true; break; case CoinType::BEP20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "BNBT" : "BNB"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "BNBT" : "BNB"; cfg.is_erc_family = true; break; case CoinType::PLG20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "MATICTEST" : "MATIC"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "MATICTEST" : "MATIC"; cfg.is_erc_family = true; break; case CoinType::Optimism: @@ -320,62 +320,62 @@ namespace atomic_dex break; case CoinType::AVX20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "AVAXT" : "AVAX"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "AVAXT" : "AVAX"; cfg.is_erc_family = true; break; case CoinType::FTM20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "FTMT" : "FTM"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "FTMT" : "FTM"; cfg.is_erc_family = true; break; case CoinType::HRC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "ONET" : "ONE"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "ONET" : "ONE"; cfg.is_erc_family = true; break; case CoinType::Ubiq: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "UBQT" : "UBQ"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "UBQT" : "UBQ"; cfg.is_erc_family = true; break; case CoinType::KRC20: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "KCST" : "KCS"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "KCST" : "KCS"; cfg.is_erc_family = true; break; case CoinType::Moonriver: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "MOVRT" : "MOVR"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "MOVRT" : "MOVR"; cfg.is_erc_family = true; break; case CoinType::Moonbeam: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "GLMRT" : "GLMR"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "GLMRT" : "GLMR"; cfg.is_erc_family = true; break; case CoinType::HecoChain: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "HTT" : "HT"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "HTT" : "HT"; cfg.is_erc_family = true; break; case CoinType::SmartBCH: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "SBCHT" : "SBCH"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "SBCHT" : "SBCH"; cfg.is_erc_family = true; break; case CoinType::EthereumClassic: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "ETCT" : "ETC"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "ETCT" : "ETC"; cfg.is_erc_family = true; break; case CoinType::RSK: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "RBTCT" : "RBTC"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "RBTCT" : "RBTC"; cfg.is_erc_family = true; break; case CoinType::SLP: cfg.has_parent_fees_ticker = true; - cfg.fees_ticker = cfg.is_testnet.value() ? "tBCH" : "BCH"; + cfg.fees_ticker = cfg.is_testnet.value_or(false) ? "tBCH" : "BCH"; break; case CoinType::TENDERMINT: cfg.has_parent_fees_ticker = true; diff --git a/src/core/atomicdex/config/coins.cfg.hpp b/src/core/atomicdex/config/coins.cfg.hpp index 457b432e8e..f4fa5bcd51 100644 --- a/src/core/atomicdex/config/coins.cfg.hpp +++ b/src/core/atomicdex/config/coins.cfg.hpp @@ -21,8 +21,8 @@ #include -#include "atomicdex/api/mm2/mm2.constants.hpp" -#include "atomicdex/api/mm2/utxo_merge_params.hpp" +#include "atomicdex/api/kdf/kdf.constants.hpp" +#include "atomicdex/api/kdf/utxo_merge_params.hpp" #include "atomicdex/config/electrum.cfg.hpp" #include "atomicdex/config/enable.cfg.hpp" #include "atomicdex/constants/qt.coins.enums.hpp" @@ -67,6 +67,7 @@ namespace atomic_dex bool has_memos{false}; bool is_custom_coin{false}; bool is_faucet_coin{false}; + bool is_vote_coin{false}; bool currently_enabled{false}; bool has_parent_fees_ticker{false}; ///< True if parent fees is different from current ticker eg: ERC20 tokens bool is_erc_family{false}; @@ -90,7 +91,7 @@ namespace atomic_dex std::optional> other_types; std::optional electrum_urls; std::optional urls; - std::optional rpc_urls; + std::optional rpc_urls; std::optional z_urls; std::optional eth_family_urls; std::optional bchd_urls; @@ -102,5 +103,6 @@ namespace atomic_dex bool is_wallet_only(std::string ticker); bool is_default_coin(std::string ticker); bool is_faucet_coin(std::string ticker); + bool is_vote_coin(std::string ticker); } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/config/enable.cfg.cpp b/src/core/atomicdex/config/enable.cfg.cpp index 47580a3f12..c569c9df2c 100644 --- a/src/core/atomicdex/config/enable.cfg.cpp +++ b/src/core/atomicdex/config/enable.cfg.cpp @@ -27,9 +27,9 @@ namespace atomic_dex to_json(nlohmann::json& j, const node& cfg) { j["url"] = cfg.url; - if (cfg.gui_auth.has_value()) + if (cfg.komodo_proxy.has_value()) { - j["gui_auth"] = cfg.gui_auth.value(); + j["komodo_proxy"] = cfg.komodo_proxy.value(); } } @@ -37,9 +37,9 @@ namespace atomic_dex from_json(const nlohmann::json& j, node& cfg) { j.at("url").get_to(cfg.url); - if (j.count("gui_auth") == 1) + if (j.count("komodo_proxy") == 1) { - cfg.gui_auth = j.at("gui_auth").get(); + cfg.komodo_proxy = j.at("komodo_proxy").get(); } } } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/config/enable.cfg.hpp b/src/core/atomicdex/config/enable.cfg.hpp index 94e11e7736..043055e4d9 100644 --- a/src/core/atomicdex/config/enable.cfg.hpp +++ b/src/core/atomicdex/config/enable.cfg.hpp @@ -26,7 +26,7 @@ namespace atomic_dex struct node { std::string url; - std::optional gui_auth{false}; + std::optional komodo_proxy{false}; }; void to_json(nlohmann::json& j, const node& cfg); diff --git a/src/core/atomicdex/config/mm2.cfg.hpp b/src/core/atomicdex/config/kdf.cfg.hpp similarity index 89% rename from src/core/atomicdex/config/mm2.cfg.hpp rename to src/core/atomicdex/config/kdf.cfg.hpp index 21c7aeb62c..380aa2707c 100644 --- a/src/core/atomicdex/config/mm2.cfg.hpp +++ b/src/core/atomicdex/config/kdf.cfg.hpp @@ -29,12 +29,12 @@ namespace atomic_dex using nlohmann::json; using namespace std::string_literals; - struct mm2_config + struct kdf_config { std::string gui{std::string(DEX_NAME) + " "s + atomic_dex::get_version()}; int64_t netid{8762}; int64_t rpcport{atomic_dex::g_dex_rpcport}; - std::vector seednodes{}; + std::vector seednodes{"188.241.240.110", "66.42.60.49"}; //std::vector seednodes{"195.201.91.96", "195.201.91.53", "168.119.174.126", "46.4.78.11", "46.4.87.18"}; //std::vector seednodes{"46.4.78.11", "46.4.87.18"}; #ifdef _WIN32 @@ -43,16 +43,16 @@ namespace atomic_dex std::string userhome{std::getenv("HOME")}; #endif std::string passphrase; - std::string dbdir{utils::u8string((utils::get_atomic_dex_data_folder() / "mm2" / "DB"))}; - std::string rpc_password{"atomic_dex_mm2_passphrase"}; + std::string dbdir{utils::u8string((utils::get_atomic_dex_data_folder() / "kdf" / "DB"))}; + std::string rpc_password{"atomic_dex_kdf_passphrase"}; }; - void from_json(const json& j, mm2_config& cfg); + void from_json(const json& j, kdf_config& cfg); - void to_json(json& j, const mm2_config& cfg); + void to_json(json& j, const kdf_config& cfg); inline void - from_json(const json& j, mm2_config& cfg) + from_json(const json& j, kdf_config& cfg) { cfg.gui = j.at("gui").get(); cfg.netid = j.at("netid").get(); @@ -64,7 +64,7 @@ namespace atomic_dex } inline void - to_json(json& j, const mm2_config& cfg) + to_json(json& j, const kdf_config& cfg) { j = json::object(); j["gui"] = cfg.gui; diff --git a/src/core/atomicdex/config/raw.mm2.coins.cfg.hpp b/src/core/atomicdex/config/raw.kdf.coins.cfg.hpp similarity index 89% rename from src/core/atomicdex/config/raw.mm2.coins.cfg.hpp rename to src/core/atomicdex/config/raw.kdf.coins.cfg.hpp index 503a99828c..43352d06bc 100644 --- a/src/core/atomicdex/config/raw.mm2.coins.cfg.hpp +++ b/src/core/atomicdex/config/raw.kdf.coins.cfg.hpp @@ -7,12 +7,13 @@ //! Deps #include #include +#include //! Project -#include "atomicdex/api/mm2/mm2.constants.hpp" +#include "atomicdex/api/kdf/kdf.constants.hpp" #include "atomicdex/utilities/global.utilities.hpp" #include "atomicdex/utilities/qt.utilities.hpp" -#include "atomicdex/api/mm2/address_format.hpp" +#include "atomicdex/api/kdf/address_format.hpp" #ifndef NLOHMANN_OPT_HELPER # define NLOHMANN_OPT_HELPER @@ -80,7 +81,7 @@ namespace atomic_dex struct coin_element { - using addr_fmt = mm2::address_format_t; + using addr_fmt = kdf::address_format_t; std::string coin; std::optional name{std::nullopt}; std::optional fname{std::nullopt}; @@ -92,7 +93,7 @@ namespace atomic_dex std::optional wiftype{std::nullopt}; std::optional txfee{std::nullopt}; std::optional confpath{std::nullopt}; - std::optional mm2{std::nullopt}; + std::optional kdf{std::nullopt}; std::optional required_confirmations{std::nullopt}; std::optional asset{std::nullopt}; std::optional txversion{std::nullopt}; @@ -120,8 +121,8 @@ namespace atomic_dex namespace atomic_dex { - using t_mm2_raw_coins = std::vector; - using t_mm2_raw_coins_registry = std::unordered_map; + using t_kdf_raw_coins = std::vector; + using t_kdf_raw_coins_registry = std::unordered_map; } // namespace atomic_dex namespace atomic_dex @@ -143,7 +144,7 @@ namespace atomic_dex x.wiftype = atomic_dex::get_optional(j, "wiftype"); x.txfee = atomic_dex::get_optional(j, "txfee"); x.confpath = atomic_dex::get_optional(j, "confpath"); - x.mm2 = atomic_dex::get_optional(j, "mm2"); + x.kdf = atomic_dex::get_optional(j, "kdf"); x.required_confirmations = atomic_dex::get_optional(j, "required_confirmations"); x.asset = atomic_dex::get_optional(j, "asset"); x.txversion = atomic_dex::get_optional(j, "txversion"); @@ -151,7 +152,7 @@ namespace atomic_dex x.requires_notarization = atomic_dex::get_optional(j, "requires_notarization"); x.is_po_s = atomic_dex::get_optional(j, "isPoS"); x.segwit = atomic_dex::get_optional(j, "segwit"); - x.address_format = atomic_dex::get_optional(j, "address_format"); + x.address_format = atomic_dex::get_optional(j, "address_format"); x.estimate_fee_mode = atomic_dex::get_optional(j, "estimate_fee_mode"); x.taddr = atomic_dex::get_optional(j, "taddr"); x.decimals = atomic_dex::get_optional(j, "decimals"); @@ -189,7 +190,7 @@ namespace atomic_dex to_json_functor("wiftype", x.wiftype); to_json_functor("txfee", x.txfee); to_json_functor("confpath", x.confpath); - to_json_functor("mm2", x.mm2); + to_json_functor("kdf", x.kdf); to_json_functor("required_confirmations", x.required_confirmations); to_json_functor("asset", x.asset); to_json_functor("txversion", x.txversion); @@ -213,19 +214,19 @@ namespace atomic_dex j["protocol"] = x.protocol; } - inline t_mm2_raw_coins_registry - parse_raw_mm2_coins_file() + inline t_kdf_raw_coins_registry + parse_raw_kdf_coins_file() { - SPDLOG_INFO("parse_raw_mm2_coins_file"); - t_mm2_raw_coins_registry out; + SPDLOG_INFO("parse_raw_kdf_coins_file"); + t_kdf_raw_coins_registry out; std::filesystem::path file_path{atomic_dex::utils::get_current_configs_path() / "coins.json"}; if (not std::filesystem::exists(file_path)) { - std::filesystem::path original_mm2_coins_path{ag::core::assets_real_path() / "tools" / "mm2" / "coins"}; + std::filesystem::path original_kdf_coins_path{ag::core::assets_real_path() / "tools" / "kdf" / "coins"}; //! Copy our json to current version - LOG_PATH_CMP("Copying mm2 coins cfg: {} to {}", original_mm2_coins_path, file_path); + LOG_PATH_CMP("Copying kdf coins cfg: {} to {}", original_kdf_coins_path, file_path); - std::filesystem::copy_file(original_mm2_coins_path, file_path, std::filesystem::copy_options::overwrite_existing); + std::filesystem::copy_file(original_kdf_coins_path, file_path, std::filesystem::copy_options::overwrite_existing); } QFile file; @@ -238,16 +239,16 @@ namespace atomic_dex { nlohmann::json j = nlohmann::json::parse(val.toStdString()); // ifs >> j; - t_mm2_raw_coins coins = j; + t_kdf_raw_coins coins = j; out.reserve(coins.size()); for (auto&& coin: coins) { out[coin.coin] = coin; } LOG_PATH("successfully parsed: {}", file_path); - SPDLOG_INFO("coins size mm2: {}", coins.size()); + SPDLOG_INFO("coins size kdf: {}", coins.size()); } catch (const std::exception& error) { SPDLOG_ERROR("parse error: {}", error.what()); - LOG_PATH("cannot parse mm2 raw cfg file: {}", file_path); + LOG_PATH("cannot parse kdf raw cfg file: {}", file_path); } return out; } diff --git a/src/core/atomicdex/constants/dex.constants.hpp b/src/core/atomicdex/constants/dex.constants.hpp index 3eee59006c..32a30f11dc 100644 --- a/src/core/atomicdex/constants/dex.constants.hpp +++ b/src/core/atomicdex/constants/dex.constants.hpp @@ -19,11 +19,15 @@ namespace atomic_dex "BUSD-BEP20", "USDC-BEP20", "USDT-BEP20" + "VOTE2024", }; inline const std::vector g_faucet_coins{ "DOC", "MARTY", "ZOMBIE", + "IRISTEST", + }; + inline const std::vector g_vote_coins{ }; inline const std::vector g_wallet_only_coins{ "ARRR-BEP20", @@ -32,7 +36,6 @@ namespace atomic_dex "PAXG-ERC20", "USDT-ERC20", "XPM", - "VOTE2023", "ATOM" }; } diff --git a/src/core/atomicdex/data/dex/orders.and.swaps.data.hpp b/src/core/atomicdex/data/dex/orders.and.swaps.data.hpp index 0cd153feb4..d3837e301a 100644 --- a/src/core/atomicdex/data/dex/orders.and.swaps.data.hpp +++ b/src/core/atomicdex/data/dex/orders.and.swaps.data.hpp @@ -16,7 +16,7 @@ namespace atomic_dex using t_filtering_infos = filtering_infos; - // todo: please change the logic of this and its usage in mm2 service and other places. + // todo: please change the logic of this and its usage in kdf service and other places. // not happy with the current implementation we can do better struct orders_and_swaps { diff --git a/src/core/atomicdex/data/dex/qt.orders.data.hpp b/src/core/atomicdex/data/dex/qt.orders.data.hpp index 27f0859ed2..c6e9ea7ac2 100644 --- a/src/core/atomicdex/data/dex/qt.orders.data.hpp +++ b/src/core/atomicdex/data/dex/qt.orders.data.hpp @@ -9,7 +9,7 @@ //! deps #include -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct order_swaps_data { @@ -85,12 +85,13 @@ namespace atomic_dex::mm2 bool is_swap_active{false}; //! Only available for maker order - std::optional min_volume{std::nullopt}; + QString min_volume; + QString max_volume; std::optional conf_settings{std::nullopt}; }; -} // namespace atomic_dex::mm2 +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_order_swaps_data = mm2::order_swaps_data; + using t_order_swaps_data = kdf::order_swaps_data; } \ No newline at end of file diff --git a/src/core/atomicdex/data/wallet/tx.data.hpp b/src/core/atomicdex/data/wallet/tx.data.hpp index cc99195381..09921943a6 100644 --- a/src/core/atomicdex/data/wallet/tx.data.hpp +++ b/src/core/atomicdex/data/wallet/tx.data.hpp @@ -8,7 +8,7 @@ #include //! Project Headers -#include "atomicdex/api/mm2/mm2.error.code.hpp" +#include "atomicdex/api/kdf/kdf.error.code.hpp" namespace atomic_dex { @@ -25,7 +25,7 @@ namespace atomic_dex std::string my_balance_change; std::string total_amount; std::size_t block_height; - t_mm2_ec ec{dextop_error::success}; + t_kdf_ec ec{dextop_error::success}; bool unconfirmed{false}; std::string transaction_note{""}; }; diff --git a/src/core/atomicdex/events/events.hpp b/src/core/atomicdex/events/events.hpp index 8b468b8031..ad6da41888 100644 --- a/src/core/atomicdex/events/events.hpp +++ b/src/core/atomicdex/events/events.hpp @@ -24,11 +24,11 @@ namespace atomic_dex { - using mm2_started = entt::tag<"mm2_started"_hs>; + using kdf_started = entt::tag<"kdf_started"_hs>; using post_login = entt::tag<"post_login"_hs>; using gui_enter_trading = entt::tag<"gui_enter_trading"_hs>; using gui_leave_trading = entt::tag<"gui_leave_trading"_hs>; - using mm2_initialized = entt::tag<"mm2_running_and_enabling"_hs>; + using kdf_initialized = entt::tag<"kdf_running_and_enabling"_hs>; using default_coins_enabled = entt::tag<"default_coins_enabled"_hs>; using current_currency_changed = entt::tag<"update_orders_and_swap_values"_hs>; using force_update_providers = entt::tag<"force_update_providers"_hs>; diff --git a/src/core/atomicdex/managers/qt.wallet.manager.cpp b/src/core/atomicdex/managers/qt.wallet.manager.cpp index bb73aef9a2..9564f7a375 100644 --- a/src/core/atomicdex/managers/qt.wallet.manager.cpp +++ b/src/core/atomicdex/managers/qt.wallet.manager.cpp @@ -350,9 +350,9 @@ namespace atomic_dex } this->set_wallet_default_name(wallet_name); - this->set_status("initializing_mm2"); - auto& mm2_system = m_system_manager.get_system(); - mm2_system.spawn_mm2_instance(get_default_wallet_name().toStdString(), seed, with_pin_cfg, rpcpass); + this->set_status("initializing_kdf"); + auto& kdf_system = m_system_manager.get_system(); + kdf_system.spawn_kdf_instance(get_default_wallet_name().toStdString(), seed, with_pin_cfg, rpcpass); this->dispatcher_.trigger(); set_log_status(true); diff --git a/src/core/atomicdex/managers/qt.wallet.manager.hpp b/src/core/atomicdex/managers/qt.wallet.manager.hpp index a40b70a59c..bc1b8afe27 100644 --- a/src/core/atomicdex/managers/qt.wallet.manager.hpp +++ b/src/core/atomicdex/managers/qt.wallet.manager.hpp @@ -24,7 +24,7 @@ //! Project Headers #include "atomicdex/config/wallet.cfg.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/utilities/security.utilities.hpp" #include "atomicdex/version/version.hpp" diff --git a/src/core/atomicdex/models/qt.orderbook.model.cpp b/src/core/atomicdex/models/qt.orderbook.model.cpp index 2aa52b3d4f..06b542a34c 100644 --- a/src/core/atomicdex/models/qt.orderbook.model.cpp +++ b/src/core/atomicdex/models/qt.orderbook.model.cpp @@ -247,7 +247,7 @@ namespace atomic_dex { return false; } - mm2::order_contents& order = m_model_data.at(index.row()); + kdf::order_contents& order = m_model_data.at(index.row()); switch (static_cast(role)) { case PriceRole: @@ -397,7 +397,7 @@ namespace atomic_dex void - orderbook_model::initialize_order(const mm2::order_contents& order) + orderbook_model::initialize_order(const kdf::order_contents& order) { if (m_orders_id_registry.contains(order.uuid)) { @@ -435,7 +435,7 @@ namespace atomic_dex } void - orderbook_model::update_order(const mm2::order_contents& order) + orderbook_model::update_order(const kdf::order_contents& order) { if (const auto res = this->match(index(0, 0), UUIDRole, QString::fromStdString(order.uuid)); not res.isEmpty()) { @@ -524,8 +524,8 @@ namespace atomic_dex void orderbook_model::refresh_orderbook_model_data(const t_orders_contents& orderbook, bool is_bestorders) { - // SPDLOG_DEBUG("[orderbook_model::refresh_orderbook_model_data], is_bestorders: {}", is_bestorders); - auto refresh_functor = [this](const std::vector& contents) + SPDLOG_DEBUG("[orderbook_model::refresh_orderbook_model_data], is_bestorders: {}", is_bestorders); + auto refresh_functor = [this](const std::vector& contents) { for (auto&& order: contents) { diff --git a/src/core/atomicdex/models/qt.orderbook.model.hpp b/src/core/atomicdex/models/qt.orderbook.model.hpp index 2ec3b7ef84..9f4b00a7d1 100644 --- a/src/core/atomicdex/models/qt.orderbook.model.hpp +++ b/src/core/atomicdex/models/qt.orderbook.model.hpp @@ -27,7 +27,7 @@ #include //! Project -#include "atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp" #include "atomicdex/models/qt.orderbook.proxy.model.hpp" namespace atomic_dex @@ -53,30 +53,30 @@ namespace atomic_dex PriceRole = Qt::UserRole + 1, // 257 CoinRole, TotalRole, - UUIDRole, + UUIDRole, // 260 IsMineRole, PriceDenomRole, PriceNumerRole, PercentDepthRole, - MinVolumeRole, + MinVolumeRole, // 265 EnoughFundsToPayMinVolume, CEXRatesRole, SendRole, PriceFiatRole, - HaveCEXIDRole, + HaveCEXIDRole, // 270 BaseMinVolumeRole, BaseMinVolumeDenomRole, BaseMinVolumeNumerRole, BaseMaxVolumeRole, - BaseMaxVolumeDenomRole, + BaseMaxVolumeDenomRole, // 275 BaseMaxVolumeNumerRole, RelMinVolumeRole, RelMinVolumeDenomRole, RelMinVolumeNumerRole, - RelMaxVolumeRole, + RelMaxVolumeRole, // 280 RelMaxVolumeDenomRole, RelMaxVolumeNumerRole, - NameAndTicker + NameAndTicker // 283 }; orderbook_model(kind orderbook_kind, ag::ecs::system_manager& system_mgr, QObject* parent = nullptr); @@ -102,8 +102,8 @@ namespace atomic_dex void betterOrderDetected(QVariantMap order_object); private: - void initialize_order(const mm2::order_contents& order); - void update_order(const mm2::order_contents& order); + void initialize_order(const kdf::order_contents& order); + void update_order(const kdf::order_contents& order); QVariantMap get_order_from_uuid(QString uuid); void check_for_better_order(trading_page& trading_pg, const QVariantMap& preferred_order, std::string uuid); diff --git a/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp index 28b47ab518..6117bf3eb9 100644 --- a/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp +++ b/src/core/atomicdex/models/qt.orderbook.proxy.model.cpp @@ -155,23 +155,34 @@ namespace atomic_dex case orderbook_model::kind::bids: break; case orderbook_model::kind::best_orders: - t_float_50 rates = safe_float(this->sourceModel()->data(idx, orderbook_model::CEXRatesRole).toString().toStdString()); - t_float_50 fiat_price = safe_float(this->sourceModel()->data(idx, orderbook_model::PriceFiatRole).toString().toStdString()); - std::string ticker = this->sourceModel()->data(idx, orderbook_model::CoinRole).toString().toStdString(); - const auto& provider = this->m_system_mgr.get_system(); - const auto coin_info = this->m_system_mgr.get_system().get_global_cfg()->get_coin_info(ticker); t_float_50 limit("10000"); + t_float_50 rates = safe_float(this->sourceModel()->data(idx, orderbook_model::CEXRatesRole).toString().toStdString()); + t_float_50 fiat_price = safe_float(this->sourceModel()->data(idx, orderbook_model::PriceFiatRole).toString().toStdString()); bool is_cex_id_available = this->sourceModel()->data(idx, orderbook_model::HaveCEXIDRole).toBool(); - const auto volume = provider.get_total_volume(utils::retrieve_main_ticker(ticker)); + const auto& provider = this->m_system_mgr.get_system(); + std::string ticker = this->sourceModel()->data(idx, orderbook_model::CoinRole).toString().toStdString(); + const auto coin_info = this->m_system_mgr.get_system().get_global_cfg()->get_coin_info(ticker); + const auto volume = provider.get_total_volume(utils::retrieve_main_ticker(ticker)); + std::string left_ticker = this->m_system_mgr.get_system().get_market_pairs_mdl()->get_left_selected_coin().toStdString(); + const auto left_coin_info = this->m_system_mgr.get_system().get_global_cfg()->get_coin_info(left_ticker); + if (coin_info.ticker.empty() || coin_info.wallet_only) //< this means it's not present in our cfg - skipping { return false; } + if (left_coin_info.is_testnet.value_or(false)) + { + if (coin_info.is_testnet.value_or(false)) + { + return true; + } + return false; + } if (is_cex_id_available && (rates > 100 || fiat_price <= 0 || ((safe_float(volume) < limit) && coin_info.coin_type != CoinType::SmartChain))) { return false; } - break; + return true; } } diff --git a/src/core/atomicdex/models/qt.orders.model.cpp b/src/core/atomicdex/models/qt.orders.model.cpp index 72ba1c6444..a350068e9c 100644 --- a/src/core/atomicdex/models/qt.orders.model.cpp +++ b/src/core/atomicdex/models/qt.orders.model.cpp @@ -19,11 +19,11 @@ #include //! Project -#include "atomicdex/api/mm2/rpc_v1/rpc.recover_funds_of_swap.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.recover_funds_of_swap.hpp" #include "atomicdex/events/qt.events.hpp" #include "atomicdex/models/qt.orders.model.hpp" #include "atomicdex/pages/qt.settings.page.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/utilities/qt.utilities.hpp" //! Constructor @@ -82,6 +82,12 @@ namespace atomic_dex case RelCoinAmountCurrentCurrencyRole: item.rel_amount_fiat = value.toString(); break; + case MinVolumeRole: + item.min_volume = value.toString(); + break; + case MaxVolumeRole: + item.max_volume = value.toString(); + break; case OrderTypeRole: item.order_type = value.toString(); break; @@ -166,6 +172,10 @@ namespace atomic_dex return item.rel_amount; case RelCoinAmountCurrentCurrencyRole: return item.rel_amount_fiat; + case MinVolumeRole: + return item.min_volume; + case MaxVolumeRole: + return item.max_volume; case OrderTypeRole: return item.order_type; case HumanDateRole: @@ -233,6 +243,8 @@ namespace atomic_dex {BaseCoinAmountCurrentCurrencyRole, "base_amount_current_currency"}, {RelCoinAmountRole, "rel_amount"}, {RelCoinAmountCurrentCurrencyRole, "rel_amount_current_currency"}, + {MinVolumeRole, "min_volume"}, + {MaxVolumeRole, "max_volume"}, {OrderTypeRole, "type"}, {IsMakerRole, "is_maker"}, {HumanDateRole, "date"}, @@ -295,8 +307,8 @@ namespace atomic_dex SPDLOG_INFO("Current page: {}, new page: {}", m_model_data.current_page, current_page); this->set_fetching_busy(true); this->reset_backend("set_current_page"); ///< We change page, we need to clear, but do not notify the front-end - auto& mm2 = this->m_system_manager.get_system(); - mm2.set_orders_and_swaps_pagination_infos(static_cast(current_page), m_model_data.limit, m_model_data.filtering_infos); + auto& kdf = this->m_system_manager.get_system(); + kdf.set_orders_and_swaps_pagination_infos(static_cast(current_page), m_model_data.limit, m_model_data.filtering_infos); } } @@ -316,8 +328,8 @@ namespace atomic_dex { this->set_fetching_busy(true); this->reset_backend("set_limit_nb_elements"); ///< We change page, we need to clear, but do not notify the front-end - auto& mm2 = this->m_system_manager.get_system(); - mm2.set_orders_and_swaps_pagination_infos(m_model_data.current_page, static_cast(limit), m_model_data.filtering_infos); + auto& kdf = this->m_system_manager.get_system(); + kdf.set_orders_and_swaps_pagination_infos(m_model_data.current_page, static_cast(limit), m_model_data.filtering_infos); } else { @@ -385,9 +397,9 @@ namespace atomic_dex void orders_model::on_current_currency_changed([[maybe_unused]] const current_currency_changed&) { - auto& mm2 = m_system_manager.get_system(); + auto& kdf = m_system_manager.get_system(); - mm2.batch_fetch_orders_and_swap(); + kdf.batch_fetch_orders_and_swap(); } } // namespace atomic_dex @@ -432,8 +444,8 @@ namespace atomic_dex const QString& rel_coin = data(idx, OrdersRoles::RelCoinRole).toString(); m_dispatcher.trigger( contents.order_id, prev_value.toString(), new_value.toString(), base_coin, rel_coin, new_value_d.toString()); - auto& mm2 = m_system_manager.get_system(); - mm2.process_orderbook(true); + auto& kdf = m_system_manager.get_system(); + kdf.process_orderbook(true); } update_value(OrdersRoles::MakerPaymentIdRole, contents.maker_payment_id, idx, *this); update_value(OrdersRoles::TakerPaymentIdRole, contents.taker_payment_id, idx, *this); @@ -483,10 +495,10 @@ namespace atomic_dex } endInsertRows(); emit lengthChanged(); - if (m_system_manager.has_system()) + if (m_system_manager.has_system()) { SPDLOG_DEBUG("Swaps inserted, refreshing orderbook to get new max taker vol"); - this->m_system_manager.get_system().process_orderbook(true); + this->m_system_manager.get_system().process_orderbook(true); } SPDLOG_DEBUG("{} model size: {}", kind, rowCount()); } @@ -594,7 +606,7 @@ namespace atomic_dex if (m_model_data.current_page != contents.current_page) { - SPDLOG_INFO("Page is different from mm2 contents, force change"); + SPDLOG_INFO("Page is different from kdf contents, force change"); this->set_current_page(static_cast(contents.current_page)); } } @@ -650,8 +662,8 @@ namespace atomic_dex SPDLOG_INFO("Fetching busy skipping"); return; } - const auto& mm2 = m_system_manager.get_system(); - const auto contents = mm2.get_orders_and_swaps(); + const auto& kdf = m_system_manager.get_system(); + const auto contents = kdf.get_orders_and_swaps(); //! If model is empty let's init it once if (m_model_data.orders_and_swaps.empty()) @@ -683,14 +695,14 @@ namespace atomic_dex this->set_fetching_busy(true); this->reset(); // this->reset_backend("set_filtering_infos"); ///< We change page, we need to clear, but do not notify the front-end - if (this->m_system_manager.has_system()) + if (this->m_system_manager.has_system()) { - auto& mm2 = this->m_system_manager.get_system(); - mm2.set_orders_and_swaps_pagination_infos(m_model_data.current_page, m_model_data.limit, m_model_data.filtering_infos); + auto& kdf = this->m_system_manager.get_system(); + kdf.set_orders_and_swaps_pagination_infos(m_model_data.current_page, m_model_data.limit, m_model_data.filtering_infos); } else { - SPDLOG_WARN("MM2 is not available, skipping orders and swaps pagination reset"); + SPDLOG_WARN("KDF is not available, skipping orders and swaps pagination reset"); } } else @@ -709,11 +721,11 @@ namespace atomic_dex orders_model::recover_fund(QString uuid) { this->set_recover_fund_busy(true); - auto& mm2_system = m_system_manager.get_system(); + auto& kdf_system = m_system_manager.get_system(); nlohmann::json batch = nlohmann::json::array(); - nlohmann::json json_data = mm2::template_request("recover_funds_of_swap"); - mm2::recover_funds_of_swap_request req{.swap_uuid = uuid.toStdString()}; - mm2::to_json(json_data, req); + nlohmann::json json_data = kdf::template_request("recover_funds_of_swap"); + kdf::recover_funds_of_swap_request req{.swap_uuid = uuid.toStdString()}; + kdf::to_json(json_data, req); batch.push_back(json_data); // json_data["userpass"] = "*****"; @@ -729,7 +741,7 @@ namespace atomic_dex if (resp.status_code() == web::http::status_codes::OK) { auto answers = nlohmann::json::parse(body); - auto recover_answer = mm2::rpc_process_answer_batch(answers[0], "recover_funds_of_swap"); + auto recover_answer = kdf::rpc_process_answer_batch(answers[0], "recover_funds_of_swap"); if (recover_answer.result.has_value()) { auto answer = recover_answer.result.value(); @@ -753,7 +765,7 @@ namespace atomic_dex else if (resp.status_code() == web::http::status_codes::RequestTimeout) { j_out["is_valid"] = false; - j_out["error"] = "Request to mm2 timeout - skipping"; + j_out["error"] = "Request to kdf timeout - skipping"; } else { @@ -781,6 +793,6 @@ namespace atomic_dex } }; - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); } } // namespace atomic_dex diff --git a/src/core/atomicdex/models/qt.orders.model.hpp b/src/core/atomicdex/models/qt.orders.model.hpp index bb00288a28..9623af8157 100644 --- a/src/core/atomicdex/models/qt.orders.model.hpp +++ b/src/core/atomicdex/models/qt.orders.model.hpp @@ -32,7 +32,7 @@ #include //! Project -#include "atomicdex/api/mm2/mm2.hpp" +#include "atomicdex/api/kdf/kdf.hpp" #include "atomicdex/data/dex/orders.and.swaps.data.hpp" #include "atomicdex/events/events.hpp" #include "atomicdex/models/qt.orders.proxy.model.hpp" @@ -63,6 +63,8 @@ namespace atomic_dex RelCoinAmountRole, RelCoinAmountCurrentCurrencyRole, OrderTypeRole, + MinVolumeRole, + MaxVolumeRole, IsMakerRole, HumanDateRole, UnixTimestampRole, diff --git a/src/core/atomicdex/models/qt.orders.proxy.model.cpp b/src/core/atomicdex/models/qt.orders.proxy.model.cpp index f66ce759b8..bd6ec71636 100644 --- a/src/core/atomicdex/models/qt.orders.proxy.model.cpp +++ b/src/core/atomicdex/models/qt.orders.proxy.model.cpp @@ -55,6 +55,10 @@ namespace atomic_dex break; case orders_model::RelCoinAmountCurrentCurrencyRole: break; + case orders_model::MinVolumeRole: + break; + case orders_model::MaxVolumeRole: + break; case orders_model::OrderTypeRole: break; case orders_model::IsMakerRole: diff --git a/src/core/atomicdex/models/qt.portfolio.model.cpp b/src/core/atomicdex/models/qt.portfolio.model.cpp index 55b6557f2f..850241aed0 100644 --- a/src/core/atomicdex/models/qt.portfolio.model.cpp +++ b/src/core/atomicdex/models/qt.portfolio.model.cpp @@ -65,13 +65,13 @@ namespace atomic_dex continue; } SPDLOG_INFO("initialize_portfolio for ticker: {}", ticker); - const auto& mm2_system = this->m_system_manager.get_system(); + const auto& kdf_system = this->m_system_manager.get_system(); const auto& price_service = this->m_system_manager.get_system(); const auto& provider = this->m_system_manager.get_system(); - auto coin = mm2_system.get_coin_info(ticker); + auto coin = kdf_system.get_coin_info(ticker); SPDLOG_INFO("Building portfolio for ticker {}", coin.ticker); std::error_code ec; - std::string balance = mm2_system.get_balance_info(coin.ticker, ec); + std::string balance = kdf_system.get_balance_info(coin.ticker, ec); SPDLOG_INFO("balance for ticker {}: {}", coin.ticker, balance); const QString change_24h = retrieve_change_24h(provider, coin, *m_config, m_system_manager); portfolio_data data{ @@ -89,7 +89,7 @@ namespace atomic_dex .price_provider = QString::fromStdString(provider.get_price_provider(coin.ticker)), .price_last_timestamp = static_cast(provider.get_last_price_timestamp(coin.ticker)), .is_excluded = false, - .public_address = QString::fromStdString(mm2_system.address(coin.ticker, ec))}; + .public_address = QString::fromStdString(kdf_system.address(coin.ticker, ec))}; // data.percent_main_currency = percent_functor(data.main_currency_balance); data.display = QString::fromStdString(coin.gui_ticker) + " (" + data.balance + ")"; data.ticker_and_name = QString::fromStdString(coin.gui_ticker) + data.name; @@ -109,7 +109,9 @@ namespace atomic_dex bool portfolio_model::update_activation_status() { - const auto& mm2_system = this->m_system_manager.get_system(); + // This feels a bit heavy handed. There should be a better way to do this. + // Function may be unused. + const auto& kdf_system = this->m_system_manager.get_system(); const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_enabled_coins(); for (auto&& [_, coin]: coins) @@ -125,18 +127,20 @@ namespace atomic_dex { std::error_code ec; const QModelIndex& idx = res.at(0); - auto coin_info = mm2_system.get_coin_info(ticker); + auto coin_info = kdf_system.get_coin_info(ticker); QJsonObject status = nlohmann_json_object_to_qt_json_object(coin_info.activation_status); update_value(ActivationStatus, status, idx, *this); SPDLOG_DEBUG("updated activation status of: {}", ticker); + return true; } + return false; } } bool portfolio_model::update_currency_values() { - const auto& mm2_system = this->m_system_manager.get_system(); + const auto& kdf_system = this->m_system_manager.get_system(); const auto& price_service = this->m_system_manager.get_system(); const auto& provider = this->m_system_manager.get_system(); const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_enabled_coins(); @@ -169,7 +173,7 @@ namespace atomic_dex update_value(LastPriceTimestamp, last_price_timestamp, idx, *this); QString change24_h = retrieve_change_24h(provider, coin, *m_config, m_system_manager); update_value(Change24H, change24_h, idx, *this); - const QString balance = QString::fromStdString(mm2_system.get_balance_info(coin.ticker, ec)); + const QString balance = QString::fromStdString(kdf_system.get_balance_info(coin.ticker, ec)); auto&& [prev_balance, new_balance, is_change_b] = update_value(BalanceRole, balance, idx, *this); const QString display = QString::fromStdString(coin.ticker) + " (" + balance + ")"; update_value(Display, display, idx, *this); @@ -181,7 +185,7 @@ namespace atomic_dex QJsonArray trend = nlohmann_json_array_to_qt_json_array(provider.get_ticker_historical(ticker)); update_value(Trend7D, trend, idx, *this); - auto coin_info = mm2_system.get_coin_info(ticker); + auto coin_info = kdf_system.get_coin_info(ticker); QJsonObject status = nlohmann_json_object_to_qt_json_object(coin_info.activation_status); update_value(ActivationStatus, status, idx, *this); // SPDLOG_DEBUG("updated currency values of: {}", ticker); @@ -209,7 +213,7 @@ namespace atomic_dex if (const auto res = this->match(this->index(0, 0), TickerRole, QString::fromStdString(ticker), 1, Qt::MatchFlag::MatchExactly); not res.isEmpty()) { // SPDLOG_DEBUG("Updating balance values of: {}", ticker); - const auto& mm2_system = this->m_system_manager.get_system(); + const auto& kdf_system = this->m_system_manager.get_system(); const auto* global_cfg = this->m_system_manager.get_system().get_global_cfg(); const auto coin = global_cfg->get_coin_info(ticker); const auto& price_service = this->m_system_manager.get_system(); @@ -218,7 +222,7 @@ namespace atomic_dex const std::string& currency = m_config->current_currency; const std::string& fiat = m_config->current_fiat; const QModelIndex& idx = res.at(0); - const QString balance = QString::fromStdString(mm2_system.get_balance_info(ticker, ec)); + const QString balance = QString::fromStdString(kdf_system.get_balance_info(ticker, ec)); auto&& [prev_balance, new_balance, is_change_b] = update_value(BalanceRole, balance, idx, *this); const QString main_currency_balance_value = QString::fromStdString(price_service.get_price_in_fiat(currency, ticker, ec)); auto&& [_1, _2, is_change_mc] = update_value(MainCurrencyBalanceRole, main_currency_balance_value, idx, *this); @@ -240,10 +244,10 @@ namespace atomic_dex } QJsonArray trend = nlohmann_json_array_to_qt_json_array(provider.get_ticker_historical(ticker)); update_value(Trend7D, trend, idx, *this); - auto coin_info = mm2_system.get_coin_info(ticker); + auto coin_info = kdf_system.get_coin_info(ticker); QJsonObject status = nlohmann_json_object_to_qt_json_object(coin_info.activation_status); update_value(ActivationStatus, status, idx, *this); - if (ticker == mm2_system.get_current_ticker() && (is_change_b || is_change_mc || is_change_mcpfo)) + if (ticker == kdf_system.get_current_ticker() && (is_change_b || is_change_mc || is_change_mcpfo)) { m_system_manager.get_system().refresh_ticker_infos(); } diff --git a/src/core/atomicdex/models/qt.portfolio.model.hpp b/src/core/atomicdex/models/qt.portfolio.model.hpp index c832c737f7..f92c6bff27 100644 --- a/src/core/atomicdex/models/qt.portfolio.model.hpp +++ b/src/core/atomicdex/models/qt.portfolio.model.hpp @@ -32,7 +32,7 @@ #include "atomicdex/data/wallet/qt.portfolio.data.hpp" #include "atomicdex/events/events.hpp" #include "atomicdex/models/qt.portfolio.proxy.filter.model.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" namespace atomic_dex { diff --git a/src/core/atomicdex/models/transactions_model.cpp b/src/core/atomicdex/models/transactions_model.cpp index 9ee44684e7..7476bd914c 100644 --- a/src/core/atomicdex/models/transactions_model.cpp +++ b/src/core/atomicdex/models/transactions_model.cpp @@ -137,8 +137,8 @@ namespace atomic_dex { const auto& currency = this->m_system_manager.get_system().get_cfg().current_currency; const auto& price_service = this->m_system_manager.get_system(); - const auto& mm2_system = this->m_system_manager.get_system(); - return QString::fromStdString(price_service.get_price_as_currency_from_tx(currency, mm2_system.get_current_ticker(), item)); + const auto& kdf_system = this->m_system_manager.get_system(); + return QString::fromStdString(price_service.get_price_as_currency_from_tx(currency, kdf_system.get_current_ticker(), item)); } case TxHashRole: return QString::fromStdString(item.tx_hash); @@ -148,8 +148,8 @@ namespace atomic_dex { const auto& currency = this->m_system_manager.get_system().get_cfg().current_currency; const auto& price_service = this->m_system_manager.get_system(); - const auto& mm2_system = this->m_system_manager.get_system(); - const auto& fee_ticker = mm2_system.get_coin_info(mm2_system.get_current_ticker()).fees_ticker; + const auto& kdf_system = this->m_system_manager.get_system(); + const auto& fee_ticker = kdf_system.get_coin_info(kdf_system.get_current_ticker()).fees_ticker; return QString::fromStdString(price_service.get_price_as_currency_from_amount(currency, fee_ticker, item.fees)); } case FromRole: diff --git a/src/core/atomicdex/models/transactions_model.hpp b/src/core/atomicdex/models/transactions_model.hpp index 7e40de0728..9c444508ab 100644 --- a/src/core/atomicdex/models/transactions_model.hpp +++ b/src/core/atomicdex/models/transactions_model.hpp @@ -20,7 +20,7 @@ #include #include "transactions_proxy_model.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" namespace atomic_dex { diff --git a/src/core/atomicdex/pages/qt.portfolio.page.cpp b/src/core/atomicdex/pages/qt.portfolio.page.cpp index 6969e28ff1..4e4a227d02 100644 --- a/src/core/atomicdex/pages/qt.portfolio.page.cpp +++ b/src/core/atomicdex/pages/qt.portfolio.page.cpp @@ -163,13 +163,15 @@ namespace atomic_dex void portfolio_page::set_chart_category(WalletChartsCategories category) { + SPDLOG_INFO("new m_current_chart_category: {}", m_current_chart_category); + SPDLOG_INFO("qint32(category): {}", qint32(category)); SPDLOG_INFO("new chart category: {}", QMetaEnum::fromType().valueToKey(category)); if (m_current_chart_category != category) { m_current_chart_category = category; QSettings& settings = entity_registry_.ctx(); - settings.setValue("WalletChartsCategory", qint32(m_current_chart_category)); - if (m_system_manager.get_system().is_mm2_running() && m_system_manager.has_system()) + settings.setValue("WalletChartsCategory", qint32(category)); + if (m_system_manager.get_system().is_kdf_running() && m_system_manager.has_system()) { m_system_manager.get_system().manual_refresh("set_chart_category"); } diff --git a/src/core/atomicdex/pages/qt.portfolio.page.hpp b/src/core/atomicdex/pages/qt.portfolio.page.hpp index 7df303ed2f..5a39a2ba1c 100644 --- a/src/core/atomicdex/pages/qt.portfolio.page.hpp +++ b/src/core/atomicdex/pages/qt.portfolio.page.hpp @@ -51,7 +51,7 @@ namespace atomic_dex global_coins_cfg_model* m_global_cfg_mdl; QString m_current_balance_all{"0"}; QString m_main_current_balance_all{"0"}; - WalletChartsCategories m_current_chart_category; + WalletChartsCategories m_current_chart_category{WalletChartsCategories::OneMonth}; public: //! Constructor diff --git a/src/core/atomicdex/pages/qt.settings.page.cpp b/src/core/atomicdex/pages/qt.settings.page.cpp index 9ff8af5085..251f2046d6 100644 --- a/src/core/atomicdex/pages/qt.settings.page.cpp +++ b/src/core/atomicdex/pages/qt.settings.page.cpp @@ -26,7 +26,7 @@ // Project Headers #include "atomicdex/constants/dex.constants.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.get_public_key.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.get_public_key.hpp" #include "atomicdex/config/enable.cfg.hpp" #include "atomicdex/events/events.hpp" #include "atomicdex/managers/qt.wallet.manager.hpp" @@ -34,7 +34,7 @@ #include "atomicdex/pages/qt.portfolio.page.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/pages/qt.wallet.page.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/coingecko/coingecko.wallet.charts.hpp" #include "atomicdex/services/price/global.provider.hpp" #include "atomicdex/utilities/global.utilities.hpp" @@ -217,15 +217,29 @@ namespace atomic_dex if (m_config.spamfilter_enabled != is_enabled) { - auto& mm2 = m_system_manager.get_system(); + auto& kdf = m_system_manager.get_system(); auto& wallet_pg = m_system_manager.get_system(); - QString ticker = QString::fromStdString(mm2.get_current_ticker()); + QString ticker = QString::fromStdString(kdf.get_current_ticker()); change_spamfilter_status(m_config, is_enabled); emit onSpamFilterEnabledChanged(); wallet_pg.set_current_ticker(ticker, true); } } + bool atomic_dex::settings_page::is_postorder_enabled() const + { + return m_config.postorder_enabled; + } + + void settings_page::set_postorder_enabled(bool is_enabled) + { + if (m_config.postorder_enabled != is_enabled) + { + change_postorder_status(m_config, is_enabled); + emit onPostOrderEnabledChanged(); + } + } + bool atomic_dex::settings_page::is_notification_enabled() const { return m_config.notification_enabled; @@ -301,7 +315,7 @@ namespace atomic_dex { SPDLOG_WARN("Cannot change currency to {} for reason: {}", current_currency.toStdString(), reason); // Try next in line - int8_t selected_idx = utils::get_index_str(m_config.possible_currencies, current_currency.toStdString()); + unsigned long selected_idx = utils::get_index_str(m_config.possible_currencies, current_currency.toStdString()); if (selected_idx < m_config.possible_currencies.size() - 1) { set_current_currency(QString::fromStdString(m_config.possible_currencies[selected_idx + 1])); @@ -439,12 +453,12 @@ namespace atomic_dex bool settings_page::is_this_ticker_present_in_raw_cfg(const QString& ticker) const { - return m_system_manager.get_system().is_this_ticker_present_in_raw_cfg(ticker.toStdString()); + return m_system_manager.get_system().is_this_ticker_present_in_raw_cfg(ticker.toStdString()); } bool settings_page::is_this_ticker_present_in_normal_cfg(const QString& ticker) const { - return m_system_manager.get_system().is_this_ticker_present_in_normal_cfg(ticker.toStdString()); + return m_system_manager.get_system().is_this_ticker_present_in_normal_cfg(ticker.toStdString()); } QString settings_page::get_custom_coins_icons_path() const @@ -463,7 +477,7 @@ namespace atomic_dex { std::string body = TO_STD_STR(resp.extract_string(true).get()); nlohmann::json out = nlohmann::json::object(); - out["mm2_cfg"] = nlohmann::json::object(); + out["kdf_cfg"] = nlohmann::json::object(); out["adex_cfg"] = nlohmann::json::object(); if (resp.status_code() == 200) { @@ -473,32 +487,32 @@ namespace atomic_dex out["ticker"] = ticker; out["name"] = name_lowercase; copy_icon(icon_filepath, get_custom_coins_icons_path(), atomic_dex::utils::retrieve_main_ticker(ticker)); - const auto& mm2 = this->m_system_manager.get_system(); - nlohmann::json qtum_cfg = mm2.get_raw_mm2_ticker_cfg("QTUM"); + const auto& kdf = this->m_system_manager.get_system(); + nlohmann::json qtum_cfg = kdf.get_raw_kdf_ticker_cfg("QTUM"); if (not is_this_ticker_present_in_raw_cfg(QString::fromStdString(ticker))) { - out["mm2_cfg"]["protocol"] = nlohmann::json::object(); - out["mm2_cfg"]["protocol"]["type"] = "QRC20"; - out["mm2_cfg"]["protocol"]["protocol_data"] = nlohmann::json::object(); - out["mm2_cfg"]["protocol"]["protocol_data"]["platform"] = "QTUM"; + out["kdf_cfg"]["protocol"] = nlohmann::json::object(); + out["kdf_cfg"]["protocol"]["type"] = "QRC20"; + out["kdf_cfg"]["protocol"]["protocol_data"] = nlohmann::json::object(); + out["kdf_cfg"]["protocol"]["protocol_data"]["platform"] = "QTUM"; std::string out_address = "0x" + contract_address.toStdString(); - out["mm2_cfg"]["protocol"]["protocol_data"]["contract_address"] = out_address; - out["mm2_cfg"]["coin"] = ticker; - // out["mm2_cfg"]["gui_coin"] = ticker; - out["mm2_cfg"]["mm2"] = 1; + out["kdf_cfg"]["protocol"]["protocol_data"]["contract_address"] = out_address; + out["kdf_cfg"]["coin"] = ticker; + // out["kdf_cfg"]["gui_coin"] = ticker; + out["kdf_cfg"]["kdf"] = 1; if (body_json.at("qrc20").contains("decimals")) { - out["mm2_cfg"]["decimals"] = body_json.at("qrc20").at("decimals").get(); + out["kdf_cfg"]["decimals"] = body_json.at("qrc20").at("decimals").get(); } - out["mm2_cfg"]["txfee"] = qtum_cfg["txfee"]; - out["mm2_cfg"]["pubtype"] = qtum_cfg["pubtype"]; - out["mm2_cfg"]["p2shtype"] = qtum_cfg["p2shtype"]; - out["mm2_cfg"]["wiftype"] = qtum_cfg["wiftype"]; - out["mm2_cfg"]["name"] = qtum_cfg["name"]; - out["mm2_cfg"]["rpcport"] = qtum_cfg["rpcport"]; - out["mm2_cfg"]["segwit"] = qtum_cfg["segwit"]; - out["mm2_cfg"]["required_confirmations"] = 3; - out["mm2_cfg"]["fname"] = name_lowercase; + out["kdf_cfg"]["txfee"] = qtum_cfg["txfee"]; + out["kdf_cfg"]["pubtype"] = qtum_cfg["pubtype"]; + out["kdf_cfg"]["p2shtype"] = qtum_cfg["p2shtype"]; + out["kdf_cfg"]["wiftype"] = qtum_cfg["wiftype"]; + out["kdf_cfg"]["name"] = qtum_cfg["name"]; + out["kdf_cfg"]["rpcport"] = qtum_cfg["rpcport"]; + out["kdf_cfg"]["segwit"] = qtum_cfg["segwit"]; + out["kdf_cfg"]["required_confirmations"] = 3; + out["kdf_cfg"]["fname"] = name_lowercase; } if (not is_this_ticker_present_in_normal_cfg(QString::fromStdString(ticker))) { @@ -513,17 +527,17 @@ namespace atomic_dex out["adex_cfg"][ticker]["active"] = true; out["adex_cfg"][ticker]["currently_enabled"] = false; out["adex_cfg"][ticker]["is_custom_coin"] = true; - if (not out.at("mm2_cfg").empty()) + if (not out.at("kdf_cfg").empty()) { - SPDLOG_INFO("mm2_cfg found, backup from new cfg"); - out["adex_cfg"][ticker]["mm2_backup"] = out["mm2_cfg"]; + SPDLOG_INFO("kdf_cfg found, backup from new cfg"); + out["adex_cfg"][ticker]["kdf_backup"] = out["kdf_cfg"]; } else { - if (mm2.is_this_ticker_present_in_raw_cfg(ticker)) + if (kdf.is_this_ticker_present_in_raw_cfg(ticker)) { - SPDLOG_INFO("mm2_cfg not found backup {} cfg from current cfg", ticker); - out["adex_cfg"][ticker]["mm2_backup"] = mm2.get_raw_mm2_ticker_cfg(ticker); + SPDLOG_INFO("kdf_cfg not found backup {} cfg from current cfg", ticker); + out["adex_cfg"][ticker]["kdf_backup"] = kdf.get_raw_kdf_ticker_cfg(ticker); } } } @@ -537,7 +551,7 @@ namespace atomic_dex this->set_custom_token_data(nlohmann_json_object_to_qt_json_object(out)); this->set_fetching_custom_token_data_busy(false); }; - mm2::async_process_rpc_get(mm2::g_qtum_proxy_http_client, "qrc_infos", url).then(answer_functor).then(&handle_exception_pplx_task); + kdf::async_process_rpc_get(kdf::g_qtum_proxy_http_client, "qrc_infos", url).then(answer_functor).then(&handle_exception_pplx_task); } void settings_page::process_token_add(const QString& contract_address, const QString& coingecko_id, const QString& icon_filepath, CoinType coin_type) @@ -551,17 +565,17 @@ namespace atomic_dex { // case CoinTypeGadget::QRC20: // return std::make_tuple( - // &mm2::g_qtum_proxy_http_client, "/contract/"s + contract_address.toStdString(), "QRC20"s, "QTUM"s, "QRC-20"s, "QTUM"s, "QRC20"s); + // &kdf::g_qtum_proxy_http_client, "/contract/"s + contract_address.toStdString(), "QRC20"s, "QTUM"s, "QRC-20"s, "QTUM"s, "QRC20"s); case CoinTypeGadget::ERC20: return std::make_tuple( - &mm2::g_etherscan_proxy_http_client, "/api/v1/token_infos/erc20/"s + contract_address.toStdString(), "ERC20"s, "ETH"s, "ERC-20"s, + &kdf::g_etherscan_proxy_http_client, "/api/v1/token_infos/erc20/"s + contract_address.toStdString(), "ERC20"s, "ETH"s, "ERC-20"s, "ETH"s, "ERC20"s); case CoinTypeGadget::BEP20: return std::make_tuple( - &mm2::g_etherscan_proxy_http_client, "/api/v1/token_infos/bep20/"s + contract_address.toStdString(), "BEP20"s, "BNB"s, "BEP-20"s, + &kdf::g_etherscan_proxy_http_client, "/api/v1/token_infos/bep20/"s + contract_address.toStdString(), "BEP20"s, "BNB"s, "BEP-20"s, "BNB"s, "ERC20"s); default: - return std::make_tuple(&mm2::g_etherscan_proxy_http_client, ""s, ""s, ""s, ""s, ""s, ""s); + return std::make_tuple(&kdf::g_etherscan_proxy_http_client, ""s, ""s, ""s, ""s, ""s, ""s); } }; auto&& [endpoint, url, type, platform, adex_platform, parent_chain, parent_type] = retrieve_functor_url(); @@ -572,17 +586,17 @@ namespace atomic_dex //! Extract answer std::string body = TO_STD_STR(resp.extract_string(true).get()); nlohmann::json out = nlohmann::json::object(); - out["mm2_cfg"] = nlohmann::json::object(); + out["kdf_cfg"] = nlohmann::json::object(); out["adex_cfg"] = nlohmann::json::object(); - const auto& mm2 = this->m_system_manager.get_system(); + const auto& kdf = this->m_system_manager.get_system(); if (resp.status_code() == 200) { - nlohmann::json raw_parent_cfg = mm2.get_raw_mm2_ticker_cfg(parent_chain); + nlohmann::json raw_parent_cfg = kdf.get_raw_kdf_ticker_cfg(parent_chain); nlohmann::json body_json = nlohmann::json::parse(body).at("result")[0]; const auto ticker = body_json.at("symbol").get() + "-" + type; const auto name_lowercase = body_json.at("tokenName").get(); - const auto& coin_info = mm2.get_coin_info(parent_chain); + const auto& coin_info = kdf.get_coin_info(parent_chain); std::string token_contract_address = contract_address.toStdString(); boost::algorithm::to_lower(token_contract_address); utils::to_eth_checksum(token_contract_address); @@ -592,22 +606,22 @@ namespace atomic_dex copy_icon(icon_filepath, get_custom_coins_icons_path(), atomic_dex::utils::retrieve_main_ticker(ticker)); if (not is_this_ticker_present_in_raw_cfg(QString::fromStdString(ticker))) { - out["mm2_cfg"]["protocol"] = nlohmann::json::object(); - out["mm2_cfg"]["protocol"]["type"] = parent_type; - out["mm2_cfg"]["protocol"]["protocol_data"] = nlohmann::json::object(); - out["mm2_cfg"]["protocol"]["protocol_data"]["platform"] = platform; - out["mm2_cfg"]["protocol"]["protocol_data"]["contract_address"] = token_contract_address; - out["mm2_cfg"]["rpcport"] = raw_parent_cfg.at("rpcport"); - out["mm2_cfg"]["coin"] = ticker; - out["mm2_cfg"]["mm2"] = 1; - out["mm2_cfg"]["decimals"] = std::stoi(body_json.at("divisor").get()); - out["mm2_cfg"]["avg_blocktime"] = raw_parent_cfg.at("avg_blocktime"); - out["mm2_cfg"]["required_confirmations"] = raw_parent_cfg.at("required_confirmations"); + out["kdf_cfg"]["protocol"] = nlohmann::json::object(); + out["kdf_cfg"]["protocol"]["type"] = parent_type; + out["kdf_cfg"]["protocol"]["protocol_data"] = nlohmann::json::object(); + out["kdf_cfg"]["protocol"]["protocol_data"]["platform"] = platform; + out["kdf_cfg"]["protocol"]["protocol_data"]["contract_address"] = token_contract_address; + out["kdf_cfg"]["rpcport"] = raw_parent_cfg.at("rpcport"); + out["kdf_cfg"]["coin"] = ticker; + out["kdf_cfg"]["kdf"] = 1; + out["kdf_cfg"]["decimals"] = std::stoi(body_json.at("divisor").get()); + out["kdf_cfg"]["avg_blocktime"] = raw_parent_cfg.at("avg_blocktime"); + out["kdf_cfg"]["required_confirmations"] = raw_parent_cfg.at("required_confirmations"); if (raw_parent_cfg.contains("chain_id")) { - out["mm2_cfg"]["chain_id"] = raw_parent_cfg.at("chain_id"); + out["kdf_cfg"]["chain_id"] = raw_parent_cfg.at("chain_id"); } - out["mm2_cfg"]["name"] = name_lowercase; + out["kdf_cfg"]["name"] = name_lowercase; } if (not is_this_ticker_present_in_normal_cfg(QString::fromStdString(ticker))) { @@ -647,9 +661,9 @@ namespace atomic_dex out["adex_cfg"][ticker]["explorer_url"] = coin_info.explorer_url; out["adex_cfg"][ticker]["fallback_swap_contract"] = coin_info.swap_contract_address; out["adex_cfg"][ticker]["fname"] = name_lowercase; - out["adex_cfg"][ticker]["is_testnet"] = true; + out["adex_cfg"][ticker]["is_testnet"] = false; out["adex_cfg"][ticker]["currently_enabled"] = false; - out["adex_cfg"][ticker]["mm2"] = 1; + out["adex_cfg"][ticker]["kdf"] = 1; out["adex_cfg"][ticker]["name"] = name_lowercase; out["adex_cfg"][ticker]["nodes"] = coin_info.urls.value_or(std::vector()); out["adex_cfg"][ticker]["parent_coin"] = parent_chain; @@ -674,21 +688,21 @@ namespace atomic_dex this->set_custom_token_data(nlohmann_json_object_to_qt_json_object(out)); this->set_fetching_custom_token_data_busy(false); }; - mm2::async_process_rpc_get(*endpoint, "token_infos", url).then(answer_functor).then(&handle_exception_pplx_task); + kdf::async_process_rpc_get(*endpoint, "token_infos", url).then(answer_functor).then(&handle_exception_pplx_task); } void settings_page::submit() { SPDLOG_DEBUG("submit whole cfg"); nlohmann::json out = m_custom_token_data.get(); - this->m_system_manager.get_system().add_new_coin(out.at("adex_cfg"), out.at("mm2_cfg")); + this->m_system_manager.get_system().add_new_coin(out.at("adex_cfg"), out.at("kdf_cfg")); this->set_custom_token_data(QJsonObject{{}}); } void settings_page::remove_custom_coin(const QString& ticker) { SPDLOG_DEBUG("remove ticker: {}", ticker.toStdString()); - this->m_system_manager.get_system().remove_custom_coin(ticker.toStdString()); + this->m_system_manager.get_system().remove_custom_coin(ticker.toStdString()); } void settings_page::set_qml_engine(QQmlApplicationEngine* engine) @@ -729,12 +743,12 @@ namespace atomic_dex const auto coins = cfg_mdl->get_enabled_coins(); for (auto&& [coin, coin_cfg]: coins) { - mm2::show_priv_key_request req{.coin = coin}; - nlohmann::json req_json = mm2::template_request("show_priv_key"); + kdf::show_priv_key_request req{.coin = coin}; + nlohmann::json req_json = kdf::template_request("show_priv_key"); to_json(req_json, req); batch.push_back(req_json); } - auto& mm2_system = m_system_manager.get_system(); + auto& kdf_system = m_system_manager.get_system(); const auto answer_functor = [this](web::http::http_response resp) { std::string body = TO_STD_STR(resp.extract_string(true).get()); @@ -745,7 +759,7 @@ namespace atomic_dex SPDLOG_WARN("Priv keys fetched, those are sensitive data."); for (auto&& answer: answers) { - auto show_priv_key_answer = mm2::rpc_process_answer_batch(answer, "show_priv_key"); + auto show_priv_key_answer = kdf::rpc_process_answer_batch(answer, "show_priv_key"); auto* portfolio_mdl = this->m_system_manager.get_system().get_portfolio(); const auto idx = portfolio_mdl->match( portfolio_mdl->index(0, 0), portfolio_model::TickerRole, QString::fromStdString(show_priv_key_answer.coin), 1, @@ -754,16 +768,16 @@ namespace atomic_dex { update_value(portfolio_model::PrivKey, QString::fromStdString(show_priv_key_answer.priv_key), idx.at(0), *portfolio_mdl); std::error_code ec; - QString public_address = QString::fromStdString(m_system_manager.get_system().address(show_priv_key_answer.coin, ec)); + QString public_address = QString::fromStdString(m_system_manager.get_system().address(show_priv_key_answer.coin, ec)); update_value(portfolio_model::Address, public_address, idx.at(0), *portfolio_mdl); } } } this->set_fetching_priv_key_busy(false); }; - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor); } - return {QString::fromStdString(seed), QString::fromStdString(mm2::get_rpc_password())}; + return {QString::fromStdString(seed), QString::fromStdString(kdf::get_rpc_password())}; } QString settings_page::get_version() @@ -776,9 +790,9 @@ namespace atomic_dex return QString::fromStdString(utils::get_atomic_dex_logs_folder().string()); } - QString settings_page::get_mm2_version() + QString settings_page::get_kdf_version() { - return QString::fromStdString(mm2::rpc_version()); + return QString::fromStdString(kdf::rpc_version()); } QString settings_page::get_rpcport() @@ -788,7 +802,7 @@ namespace atomic_dex QString settings_page::get_peerid() { - return QString::fromStdString(mm2::peer_id()); + return QString::fromStdString(kdf::peer_id()); } QString settings_page::get_export_folder() @@ -798,7 +812,7 @@ namespace atomic_dex void settings_page::fetchPublicKey() { - auto& mm2_system = m_system_manager.get_system(); + auto& kdf_system = m_system_manager.get_system(); auto get_pub_key_rpc_callback = [this](auto pub_key_rpc) { if (pub_key_rpc.error) @@ -813,6 +827,6 @@ namespace atomic_dex fetching_public_key = true; emit fetchingPublicKeyChanged(); - mm2_system.get_mm2_client().process_rpc_async(get_pub_key_rpc_callback); + kdf_system.get_kdf_client().process_rpc_async(get_pub_key_rpc_callback); } } // namespace atomic_dex diff --git a/src/core/atomicdex/pages/qt.settings.page.hpp b/src/core/atomicdex/pages/qt.settings.page.hpp index 5ce98412a7..9fc117a99e 100644 --- a/src/core/atomicdex/pages/qt.settings.page.hpp +++ b/src/core/atomicdex/pages/qt.settings.page.hpp @@ -46,6 +46,7 @@ namespace atomic_dex Q_PROPERTY(QString current_fiat READ get_current_fiat WRITE set_current_fiat NOTIFY onFiatChanged) Q_PROPERTY(bool notification_enabled READ is_notification_enabled WRITE set_notification_enabled NOTIFY onNotificationEnabledChanged) Q_PROPERTY(bool spamfilter_enabled READ is_spamfilter_enabled WRITE set_spamfilter_enabled NOTIFY onSpamFilterEnabledChanged) + Q_PROPERTY(bool postorder_enabled READ is_postorder_enabled WRITE set_postorder_enabled NOTIFY onPostOrderEnabledChanged) Q_PROPERTY(bool static_rpcpass_enabled READ is_static_rpcpass_enabled WRITE set_static_rpcpass_enabled NOTIFY onStaticRpcPassEnabledChanged) Q_PROPERTY(QVariant custom_token_data READ get_custom_token_data WRITE set_custom_token_data NOTIFY customTokenDataChanged) Q_PROPERTY(bool fetching_custom_token_data_busy READ is_fetching_custom_token_data_busy WRITE set_fetching_custom_token_data_busy NOTIFY customTokenDataStatusChanged) @@ -94,6 +95,8 @@ namespace atomic_dex bool set_zhtlc_status(nlohmann::json data); [[nodiscard]] bool is_spamfilter_enabled() const; void set_spamfilter_enabled(bool is_enabled); + [[nodiscard]] bool is_postorder_enabled() const; + void set_postorder_enabled(bool is_enabled); void set_current_currency(const QString& current_currency); void set_current_fiat(const QString& current_fiat); [[nodiscard]] bool is_fetching_custom_token_data_busy() const; @@ -124,7 +127,7 @@ namespace atomic_dex Q_INVOKABLE void process_qrc_20_token_add(const QString& contract_address, const QString& coingecko_id, const QString& icon_filepath); Q_INVOKABLE void submit(); Q_INVOKABLE QStringList retrieve_seed(const QString& wallet_name, const QString& password); - Q_INVOKABLE static QString get_mm2_version(); + Q_INVOKABLE static QString get_kdf_version(); Q_INVOKABLE static QString get_peerid(); Q_INVOKABLE static QString get_rpcport(); Q_INVOKABLE static QString get_log_folder(); @@ -143,6 +146,7 @@ namespace atomic_dex void onFiatSignChanged(); void onFiatChanged(); void onNotificationEnabledChanged(); + void onPostOrderEnabledChanged(); void onSpamFilterEnabledChanged(); void onStaticRpcPassEnabledChanged(); void customTokenDataChanged(); diff --git a/src/core/atomicdex/pages/qt.trading.page.cpp b/src/core/atomicdex/pages/qt.trading.page.cpp index e073806637..78bfa6cb13 100644 --- a/src/core/atomicdex/pages/qt.trading.page.cpp +++ b/src/core/atomicdex/pages/qt.trading.page.cpp @@ -19,14 +19,15 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v1/rpc.buy.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.sell.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.buy.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.sell.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.setprice.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp" #include "atomicdex/pages/qt.portfolio.page.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/pages/qt.trading.page.hpp" -#include "atomicdex/services/mm2/auto.update.maker.order.service.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/auto.update.maker.order.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/defi.stats.hpp" #include "atomicdex/services/price/global.provider.hpp" #include "atomicdex/utilities/qt.utilities.hpp" @@ -67,10 +68,10 @@ namespace atomic_dex namespace atomic_dex { QVariant - trading_page::get_raw_mm2_coin_cfg(const QString& ticker) const + trading_page::get_raw_kdf_coin_cfg(const QString& ticker) const { QVariant out; - nlohmann::json j = m_system_manager.get_system().get_raw_mm2_ticker_cfg(ticker.toStdString()); + nlohmann::json j = m_system_manager.get_system().get_raw_kdf_ticker_cfg(ticker.toStdString()); out = nlohmann_json_object_to_qt_json_object(j); return out; } @@ -82,7 +83,7 @@ namespace atomic_dex { return; } - if (bool is_wallet_only = m_system_manager.get_system().get_coin_info(base.toStdString()).wallet_only; is_wallet_only) + if (bool is_wallet_only = m_system_manager.get_system().get_coin_info(base.toStdString()).wallet_only; is_wallet_only) { // SPDLOG_WARN("{} is wallet only - skipping", base.toStdString()); return; @@ -103,7 +104,7 @@ namespace atomic_dex this->clear_forms("set_current_orderbook"); } - emit mm2MinTradeVolChanged(); + emit kdfMinTradeVolChanged(); dispatcher_.trigger(base.toStdString(), rel.toStdString()); } @@ -124,7 +125,7 @@ namespace atomic_dex { SPDLOG_DEBUG("Enter DEX"); dispatcher_.trigger(); - if (this->m_system_manager.has_system() && m_system_manager.get_system().is_orderbook_thread_active()) + if (this->m_system_manager.has_system() && m_system_manager.get_system().is_orderbook_thread_active()) { this->m_system_manager.get_system().force_update(); } @@ -138,12 +139,96 @@ namespace atomic_dex } void - trading_page::place_buy_order(const QString& base_nota, const QString& base_confs) + trading_page::place_setprice_order(const QString& base_nota, const QString& base_confs, const QString& cancel_previous) { this->set_buy_sell_rpc_busy(true); this->set_buy_sell_last_rpc_data(QJsonObject{{}}); - auto& mm2_system = m_system_manager.get_system(); + auto& kdf_system = m_system_manager.get_system(); + const auto* market_selector = get_market_pairs_mdl(); + const auto& base = market_selector->get_left_selected_coin(); + const auto& rel = market_selector->get_right_selected_coin(); + t_float_50 rel_min_trade = safe_float(get_orderbook_wrapper()->get_rel_min_taker_vol().toStdString()); + t_float_50 rel_min_volume_f = safe_float(get_min_trade_vol().toStdString()); + + t_setprice_request req{ + .base = base.toStdString(), + .rel = rel.toStdString(), + .price = m_price.toStdString(), + .volume = m_volume.toStdString(), + .cancel_previous = cancel_previous == "true", + .base_nota = base_nota.isEmpty() ? std::optional{std::nullopt} : boost::lexical_cast(base_nota.toStdString()), + .base_confs = base_confs.isEmpty() ? std::optional{std::nullopt} : base_confs.toUInt(), + .min_volume = (rel_min_volume_f <= rel_min_trade) ? std::optional{std::nullopt} : get_min_trade_vol().toStdString() + }; + + nlohmann::json batch; + nlohmann::json setprice_request = kdf::template_request("setprice"); + kdf::to_json(setprice_request, req); + batch.push_back(setprice_request); + setprice_request["userpass"] = "*******"; + + //! Answer + SPDLOG_DEBUG("setprice_request is : {}", setprice_request.dump(4)); + auto answer_functor = [this](const web::http::http_response& resp) + { + std::string body = TO_STD_STR(resp.extract_string(true).get()); + if (resp.status_code() == web::http::status_codes::OK) + { + if (body.find("error") == std::string::npos) + { + auto answers = nlohmann::json::parse(body); + nlohmann::json answer = answers[0]; + this->set_buy_sell_last_rpc_data(nlohmann_json_object_to_qt_json_object(answer)); + auto& cur_kdf_system = m_system_manager.get_system(); + SPDLOG_DEBUG("order successfully placed, refreshing orders and swap"); + cur_kdf_system.batch_fetch_orders_and_swap(); + } + else + { + auto error_json = QJsonObject({{"error_code", -1}, {"error_message", QString::fromStdString(body)}}); + SPDLOG_ERROR("error place_setprice_order: {}", body); + this->set_buy_sell_last_rpc_data(error_json); + } + } + else + { + auto error_json = QJsonObject({{"error_code", resp.status_code()}, {"error_message", QString::fromStdString(body)}}); + this->set_buy_sell_last_rpc_data(error_json); + } + this->set_buy_sell_rpc_busy(false); + this->clear_forms("place_setprice_order"); + }; + + //! Async call + kdf_system.get_kdf_client() + .async_rpc_batch_standalone(batch) + .then(answer_functor) + .then( + [this]([[maybe_unused]] pplx::task previous_task) + { + try + { + previous_task.wait(); + } + catch (const std::exception& e) + { + SPDLOG_ERROR("pplx task error: {}", e.what()); + auto error_json = QJsonObject({{"error_code", web::http::status_codes::InternalError}, {"error_message", e.what()}}); + this->set_buy_sell_last_rpc_data(error_json); + this->set_buy_sell_rpc_busy(false); + this->clear_forms("place_setprice_order"); + } + }); + } + + void + trading_page::place_buy_order(const QString& base_nota, const QString& base_confs, const QString& good_until_canceled) + { + this->set_buy_sell_rpc_busy(true); + this->set_buy_sell_last_rpc_data(QJsonObject{{}}); + + auto& kdf_system = m_system_manager.get_system(); const auto* market_selector = get_market_pairs_mdl(); const auto& base = market_selector->get_left_selected_coin(); const auto& rel = market_selector->get_right_selected_coin(); @@ -178,6 +263,19 @@ namespace atomic_dex .base_confs = base_confs.isEmpty() ? std::optional{std::nullopt} : base_confs.toUInt(), .min_volume = (rel_min_volume_f <= rel_min_trade) ? std::optional{std::nullopt} : get_min_trade_vol().toStdString()}; + if (good_until_canceled == "true") + { + SPDLOG_DEBUG("Good until cancelled order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "GoodTillCancelled"; + } + else + { + SPDLOG_DEBUG("Fill or kill order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "FillOrKill"; + } + if (is_selected_min_max || is_selected_order) { req.min_volume = std::optional{std::nullopt}; @@ -209,8 +307,8 @@ namespace atomic_dex } nlohmann::json batch; - nlohmann::json buy_request = mm2::template_request("buy"); - mm2::to_json(buy_request, req); + nlohmann::json buy_request = kdf::template_request("buy"); + kdf::to_json(buy_request, req); batch.push_back(buy_request); buy_request["userpass"] = "*******"; @@ -226,9 +324,9 @@ namespace atomic_dex auto answers = nlohmann::json::parse(body); nlohmann::json answer = answers[0]; this->set_buy_sell_last_rpc_data(nlohmann_json_object_to_qt_json_object(answer)); - auto& cur_mm2_system = m_system_manager.get_system(); + auto& cur_kdf_system = m_system_manager.get_system(); SPDLOG_DEBUG("order successfully placed, refreshing orders and swap"); - cur_mm2_system.batch_fetch_orders_and_swap(); + cur_kdf_system.batch_fetch_orders_and_swap(); } else { @@ -247,7 +345,7 @@ namespace atomic_dex }; //! Async call - mm2_system.get_mm2_client() + kdf_system.get_kdf_client() .async_rpc_batch_standalone(batch) .then(answer_functor) .then( @@ -269,12 +367,12 @@ namespace atomic_dex } void - trading_page::place_sell_order(const QString& rel_nota, const QString& rel_confs) + trading_page::place_sell_order(const QString& rel_nota, const QString& rel_confs, const QString& good_until_canceled) { this->set_buy_sell_rpc_busy(true); this->set_buy_sell_last_rpc_data(QJsonObject{{}}); - auto& mm2_system = m_system_manager.get_system(); + auto& kdf_system = m_system_manager.get_system(); const auto* market_selector = get_market_pairs_mdl(); const auto& base = market_selector->get_left_selected_coin(); const auto& rel = market_selector->get_right_selected_coin(); @@ -312,6 +410,18 @@ namespace atomic_dex req.order_type.value()["type"] = "FillOrKill"; req.min_volume = std::optional{std::nullopt}; } + else if (good_until_canceled == "true") + { + SPDLOG_DEBUG("Good until cancelled order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "GoodTillCancelled"; + } + else + { + SPDLOG_DEBUG("Fill or kill order"); + req.order_type = nlohmann::json::object(); + req.order_type.value()["type"] = "FillOrKill"; + } if (is_selected_min_max) { @@ -365,8 +475,8 @@ namespace atomic_dex } nlohmann::json batch; - nlohmann::json sell_request = mm2::template_request("sell"); - mm2::to_json(sell_request, req); + nlohmann::json sell_request = kdf::template_request("sell"); + kdf::to_json(sell_request, req); batch.push_back(sell_request); sell_request["userpass"] = "******"; @@ -383,9 +493,9 @@ namespace atomic_dex auto answers = nlohmann::json::parse(body); nlohmann::json answer = answers[0]; this->set_buy_sell_last_rpc_data(nlohmann_json_object_to_qt_json_object(answer)); - auto& cur_mm2_system = m_system_manager.get_system(); + auto& cur_kdf_system = m_system_manager.get_system(); // SPDLOG_DEBUG("order successfully placed, refreshing orders and swap"); - cur_mm2_system.batch_fetch_orders_and_swap(); + cur_kdf_system.batch_fetch_orders_and_swap(); } else { @@ -403,7 +513,7 @@ namespace atomic_dex }; //! Async call - mm2_system.get_mm2_client() + kdf_system.get_kdf_client() .async_rpc_batch_standalone(batch) .then(answer_functor) .then( @@ -479,17 +589,17 @@ namespace atomic_dex { return; } - const auto& mm2_system = m_system_manager.get_system(); + const auto& kdf_system = m_system_manager.get_system(); trading_actions last_action; this->m_actions_queue.pop(last_action); - if (mm2_system.is_mm2_running()) + if (kdf_system.is_kdf_running()) { switch (last_action) { case trading_actions::post_process_orderbook_finished: { std::error_code ec; - mm2::orderbook_result_rpc result = mm2_system.get_orderbook(ec); + kdf::orderbook_result_rpc result = kdf_system.get_orderbook(ec); if (!ec) { @@ -602,6 +712,23 @@ namespace atomic_dex //! Properties related to trading namespace atomic_dex { + bool + trading_page::get_maker_mode() const + { + return m_maker_mode; + } + + void + trading_page::set_maker_mode(bool market_mode) + { + if (this->m_maker_mode != market_mode) + { + this->m_maker_mode = market_mode; + emit makerModeChanged(); + this->set_market_mode(MarketMode::Sell); + } + } + MarketMode trading_page::get_market_mode() const { @@ -678,12 +805,12 @@ namespace atomic_dex void trading_page::clear_forms(QString from) { - if (!this->m_system_manager.has_system()) + if (!this->m_system_manager.has_system()) { - SPDLOG_WARN("MM2 service not available, required to clear forms - skipping"); + SPDLOG_WARN("KDF service not available, required to clear forms - skipping"); return; } - // SPDLOG_DEBUG("clearing forms : {}", from.toStdString()); + SPDLOG_DEBUG("clearing forms : {}", from.toStdString()); if (m_preferred_order.has_value() && m_current_trading_mode == TradingModeGadget::Simple && m_selected_order_status == SelectedOrderGadget::OrderNotExistingAnymore) @@ -708,6 +835,7 @@ namespace atomic_dex this->m_preferred_order = std::nullopt; this->m_fees = QVariantMap(); this->m_cex_price = "0"; + this->m_pair_trades_24hr = "0"; this->m_pair_volume_24hr = "0"; this->m_post_clear_forms = true; this->set_selected_order_status(SelectedOrderStatus::None); @@ -1177,14 +1305,14 @@ namespace atomic_dex void trading_page::determine_fees() { - if (!this->m_system_manager.has_system()) + if (!this->m_system_manager.has_system()) { - SPDLOG_WARN("MM2 Service not available, cannot determine fees - skipping"); + SPDLOG_WARN("KDF Service not available, cannot determine fees - skipping"); return; } const auto* market_pair = get_market_pairs_mdl(); using namespace std::string_literals; - auto& mm2 = this->m_system_manager.get_system(); + auto& kdf = this->m_system_manager.get_system(); // TODO: there is a race condition that sometimes results in base == rel after switching base/rel tickers const auto base = market_pair->get_left_selected_coin().toStdString(); const auto rel = market_pair->get_right_selected_coin().toStdString(); @@ -1214,14 +1342,14 @@ namespace atomic_dex }; nlohmann::json batch; - nlohmann::json preimage_request = mm2::template_request("trade_preimage", true); - mm2::to_json(preimage_request, req); + nlohmann::json preimage_request = kdf::template_request("trade_preimage", true); + kdf::to_json(preimage_request, req); batch.push_back(preimage_request); preimage_request["userpass"] = "******"; // SPDLOG_DEBUG("trade_preimage request: {}", preimage_request.dump(4)); this->set_preimage_busy(true); - auto answer_functor = [this, &mm2](web::http::http_response resp) + auto answer_functor = [this, &kdf](web::http::http_response resp) { std::string body = TO_STD_STR(resp.extract_string(true).get()); // SPDLOG_INFO("[determine_fees] trade_preimage answer received: {}", body); @@ -1229,7 +1357,7 @@ namespace atomic_dex { auto answers = nlohmann::json::parse(body); nlohmann::json answer = answers[0]; - auto trade_preimage_answer = mm2::rpc_process_answer_batch(answer, "trade_preimage"); + auto trade_preimage_answer = kdf::rpc_process_answer_batch(answer, "trade_preimage"); if (trade_preimage_answer.error.has_value()) { auto error_answer = trade_preimage_answer.error.value(); @@ -1261,7 +1389,7 @@ namespace atomic_dex for (auto&& cur: success_answer.total_fees) { - if (!mm2.do_i_have_enough_funds(cur.at("coin").get(), safe_float(cur.at("required_balance").get()))) + if (!kdf.do_i_have_enough_funds(cur.at("coin").get(), safe_float(cur.at("required_balance").get()))) { fees["error_fees"] = atomic_dex::nlohmann_json_object_to_qt_json_object(cur); break; @@ -1274,14 +1402,14 @@ namespace atomic_dex } this->set_preimage_busy(false); }; - mm2.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); + kdf.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); } void trading_page::determine_error_cases() { // SPDLOG_DEBUG("determine_error_cases"); - if (!m_system_manager.has_system()) + if (!m_system_manager.has_system()) return; TradingError current_trading_error = TradingError::None; @@ -1293,42 +1421,42 @@ namespace atomic_dex const auto& rel_min_taker_vol = get_orderbook_wrapper()->get_rel_min_taker_vol().toStdString(); const auto regular_min_taker_vol = m_market_mode == MarketMode::Sell ? get_min_trade_vol().toStdString() : rel_min_taker_vol; const auto& cur_min_taker_vol = get_min_trade_vol().toStdString(); - const auto& mm2 = m_system_manager.get_system(); - const auto left_cfg = mm2.get_coin_info(left); - const auto right_cfg = mm2.get_coin_info(right); + const auto& kdf = m_system_manager.get_system(); + const auto left_cfg = kdf.get_coin_info(left); + const auto right_cfg = kdf.get_coin_info(right); const bool has_preferred_order = m_preferred_order.has_value(); const bool is_selected_min_max = has_preferred_order && m_preferred_order->at("base_min_volume").get() == m_preferred_order->at("base_max_volume").get(); if (left_cfg.has_parent_fees_ticker && left_cfg.ticker != "QTUM") { - const auto left_fee_cfg = mm2.get_coin_info(left_cfg.fees_ticker); + const auto left_fee_cfg = kdf.get_coin_info(left_cfg.fees_ticker); if (!left_fee_cfg.currently_enabled) { current_trading_error = TradingError::LeftParentChainNotEnabled; } - else if (mm2.get_balance_info_f(left_fee_cfg.ticker) <= 0) + else if (kdf.get_balance_info_f(left_fee_cfg.ticker) <= 0) { current_trading_error = TradingError::LeftParentChainNotEnoughBalance; } } else if (right_cfg.has_parent_fees_ticker && right_cfg.ticker != "QTUM") { - const auto right_fee_cfg = mm2.get_coin_info(right_cfg.fees_ticker); + const auto right_fee_cfg = kdf.get_coin_info(right_cfg.fees_ticker); if (!right_fee_cfg.currently_enabled) { current_trading_error = TradingError::RightParentChainNotEnabled; } - else if (mm2.get_balance_info_f(right_fee_cfg.ticker) <= 0) + else if (kdf.get_balance_info_f(right_fee_cfg.ticker) <= 0) { current_trading_error = TradingError::RightParentChainNotEnoughBalance; } } - else if (!mm2.is_zhtlc_coin_ready(left)) + else if (!kdf.is_zhtlc_coin_ready(left)) { current_trading_error = TradingError::LeftZhtlcChainNotEnabled; } - else if (!mm2.is_zhtlc_coin_ready(right)) + else if (!kdf.is_zhtlc_coin_ready(right)) { current_trading_error = TradingError::RightZhtlcChainNotEnabled; } @@ -1394,15 +1522,24 @@ namespace atomic_dex const auto* market_selector = get_market_pairs_mdl(); const auto& base = utils::retrieve_main_ticker(market_selector->get_left_selected_coin().toStdString(), true); const auto& rel = utils::retrieve_main_ticker(market_selector->get_right_selected_coin().toStdString(), true); + QString trades = QString::fromStdString(defi_stats_service.get_trades_24h(base, rel)); QString vol = QString::fromStdString(defi_stats_service.get_volume_24h_usd(base, rel)); if (vol != m_pair_volume_24hr) { + m_pair_trades_24hr = trades; + emit pairTrades24hrChanged(); m_pair_volume_24hr = vol; emit pairVolume24hrChanged(); } } + QString + trading_page::get_pair_trades_24hr() const + { + return m_pair_trades_24hr; + } + QString trading_page::get_pair_volume_24hr() const { @@ -1483,12 +1620,12 @@ namespace atomic_dex trading_page::generate_fees_error(QVariantMap fees) const { TradingError last_trading_error = TradingError::None; - const auto& mm2 = m_system_manager.get_system(); + const auto& kdf = m_system_manager.get_system(); if (fees.contains("error_fees")) { auto&& cur_obj = fees.value("error_fees").toJsonObject(); - if (!mm2.do_i_have_enough_funds(cur_obj["coin"].toString().toStdString(), safe_float(cur_obj["required_balance"].toString().toStdString()))) + if (!kdf.do_i_have_enough_funds(cur_obj["coin"].toString().toStdString(), safe_float(cur_obj["required_balance"].toString().toStdString()))) { last_trading_error = TradingError::TotalFeesNotEnoughFunds; } diff --git a/src/core/atomicdex/pages/qt.trading.page.hpp b/src/core/atomicdex/pages/qt.trading.page.hpp index af97e46860..f750f82004 100644 --- a/src/core/atomicdex/pages/qt.trading.page.hpp +++ b/src/core/atomicdex/pages/qt.trading.page.hpp @@ -46,6 +46,7 @@ namespace atomic_dex // Trading logic Q properties Q_PROPERTY(MarketMode market_mode READ get_market_mode WRITE set_market_mode NOTIFY marketModeChanged) + Q_PROPERTY(bool maker_mode READ get_maker_mode WRITE set_maker_mode NOTIFY makerModeChanged) Q_PROPERTY(TradingError last_trading_error READ get_trading_error WRITE set_trading_error NOTIFY tradingErrorChanged) Q_PROPERTY(TradingMode current_trading_mode READ get_current_trading_mode WRITE set_current_trading_mode NOTIFY tradingModeChanged) Q_PROPERTY(QString price READ get_price WRITE set_price NOTIFY priceChanged) @@ -59,6 +60,7 @@ namespace atomic_dex Q_PROPERTY(SelectedOrderStatus selected_order_status READ get_selected_order_status WRITE set_selected_order_status NOTIFY selectedOrderStatusChanged) Q_PROPERTY(QString price_reversed READ get_price_reversed NOTIFY priceReversedChanged) Q_PROPERTY(QString pair_volume_24hr READ get_pair_volume_24hr NOTIFY pairVolume24hrChanged) + Q_PROPERTY(QString pair_trades_24hr READ get_pair_trades_24hr NOTIFY pairTrades24hrChanged) Q_PROPERTY(QString cex_price READ get_cex_price NOTIFY cexPriceChanged) Q_PROPERTY(QString cex_price_reversed READ get_cex_price_reversed NOTIFY cexPriceReversedChanged) Q_PROPERTY(QString cex_price_diff READ get_cex_price_diff NOTIFY cexPriceDiffChanged) @@ -106,6 +108,7 @@ namespace atomic_dex //! Trading Logic MarketMode m_market_mode{MarketModeGadget::Sell}; + bool m_maker_mode{false}; TradingError m_last_trading_error{TradingErrorGadget::None}; TradingMode m_current_trading_mode{TradingModeGadget::Pro}; SelectedOrderStatus m_selected_order_status{SelectedOrderGadget::None}; @@ -115,6 +118,7 @@ namespace atomic_dex QString m_total_amount{"0.00777"}; QString m_cex_price{"0"}; QString m_pair_volume_24hr{"0"}; + QString m_pair_trades_24hr{"0"}; QString m_minimal_trading_amount{"0.0001"}; std::optional m_preferred_order; boost::synchronized_value m_fees; @@ -151,7 +155,7 @@ namespace atomic_dex //! Public QML API Q_INVOKABLE void on_gui_enter_dex(); Q_INVOKABLE void on_gui_leave_dex(); - Q_INVOKABLE QVariant get_raw_mm2_coin_cfg(const QString& ticker) const; + Q_INVOKABLE QVariant get_raw_kdf_coin_cfg(const QString& ticker) const; Q_INVOKABLE void clear_forms(QString from); //! Trading business @@ -159,8 +163,9 @@ namespace atomic_dex Q_INVOKABLE bool set_pair(bool is_left_side, const QString& changed_ticker); Q_INVOKABLE void set_current_orderbook(const QString& base, const QString& rel); ///< market_selector (called and selecting another coin) - Q_INVOKABLE void place_buy_order(const QString& base_nota = "", const QString& base_confs = ""); - Q_INVOKABLE void place_sell_order(const QString& rel_nota = "", const QString& rel_confs = ""); + Q_INVOKABLE void place_buy_order(const QString& base_nota = "", const QString& base_confs = "", const QString& good_until_canceled = ""); + Q_INVOKABLE void place_sell_order(const QString& rel_nota = "", const QString& rel_confs = "", const QString& good_until_canceled = ""); + Q_INVOKABLE void place_setprice_order(const QString& rel_nota = "", const QString& rel_confs = "", const QString& cancel_previous = ""); Q_INVOKABLE void reset_order(); @@ -176,6 +181,8 @@ namespace atomic_dex void set_buy_sell_rpc_busy(bool status); //! Trading Logic + [[nodiscard]] bool get_maker_mode() const; + void set_maker_mode(bool market_mode); [[nodiscard]] MarketMode get_market_mode() const; void set_market_mode(MarketMode market_mode); [[nodiscard]] TradingError get_trading_error() const; @@ -197,6 +204,7 @@ namespace atomic_dex void set_total_amount(QString total_amount); [[nodiscard]] QString get_base_amount() const; [[nodiscard]] QString get_rel_amount() const; + [[nodiscard]] QString get_pair_trades_24hr() const; [[nodiscard]] QString get_pair_volume_24hr() const; [[nodiscard]] QString get_cex_price() const; [[nodiscard]] QString get_cex_price_reversed() const; @@ -229,6 +237,7 @@ namespace atomic_dex //! Trading logic void priceChanged(); void volumeChanged(); + void makerModeChanged(); void marketModeChanged(); void maxVolumeChanged(); void tradingErrorChanged(); @@ -238,6 +247,7 @@ namespace atomic_dex void baseAmountChanged(); void relAmountChanged(); void feesChanged(); + void pairTrades24hrChanged(); void pairVolume24hrChanged(); void cexPriceChanged(); void cexPriceReversedChanged(); @@ -245,7 +255,7 @@ namespace atomic_dex void invalidCexPriceChanged(); void priceReversedChanged(); void skipTakerChanged(); - void mm2MinTradeVolChanged(); + void kdfMinTradeVolChanged(); void minTradeVolChanged(); void selectedOrderStatusChanged(); void preferredOrderChangeFinished(); diff --git a/src/core/atomicdex/pages/qt.wallet.page.cpp b/src/core/atomicdex/pages/qt.wallet.page.cpp index 7613bc8dc2..43fe14c24d 100644 --- a/src/core/atomicdex/pages/qt.wallet.page.cpp +++ b/src/core/atomicdex/pages/qt.wallet.page.cpp @@ -11,13 +11,13 @@ //! Project Headers #include "atomicdex/api/faucet/faucet.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.convertaddress.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.electrum.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.validateaddress.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.withdraw.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.init.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.withdraw.status.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.convertaddress.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.electrum.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.validateaddress.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.withdraw.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.init.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.withdraw.status.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/global.provider.hpp" #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" #include "atomicdex/utilities/qt.utilities.hpp" @@ -60,14 +60,14 @@ namespace atomic_dex wallet_page::check_send_availability() { // SPDLOG_DEBUG("check_send_availability"); - auto& mm2 = m_system_manager.get_system(); + auto& kdf = m_system_manager.get_system(); auto global_coins_cfg = m_system_manager.get_system().get_global_cfg(); - auto ticker_info = global_coins_cfg->get_coin_info(mm2.get_current_ticker()); + auto ticker_info = global_coins_cfg->get_coin_info(kdf.get_current_ticker()); m_send_available = true; m_send_availability_state = ""; m_current_ticker_fees_coin_enabled = true; - if (not mm2.get_balance_info_f(ticker_info.ticker) > 0) + if (not kdf.get_balance_info_f(ticker_info.ticker) > 0) { m_send_available = false; m_send_availability_state = tr("You do not have enough funds."); @@ -84,7 +84,7 @@ namespace atomic_dex tr("%1 is not activated: click on the button to enable it or enable it manually").arg(QString::fromStdString(parent_ticker_info.ticker)); m_current_ticker_fees_coin_enabled = false; } - else if (not mm2.get_balance_info_f(parent_ticker_info.ticker) > 0) + else if (not kdf.get_balance_info_f(parent_ticker_info.ticker) > 0) { m_send_available = false; m_send_availability_state = tr("You need to have %1 to pay the gas for %2 transactions.") @@ -104,20 +104,20 @@ namespace atomic_dex { QString wallet_page::get_current_ticker() const { - const auto& mm2_system = m_system_manager.get_system(); - return QString::fromStdString(mm2_system.get_current_ticker()); + const auto& kdf_system = m_system_manager.get_system(); + return QString::fromStdString(kdf_system.get_current_ticker()); } void wallet_page::set_current_ticker(const QString& ticker, bool force) { - auto& mm2_system = m_system_manager.get_system(); - auto coin_info = mm2_system.get_coin_info(ticker.toStdString()); - if (mm2_system.set_current_ticker(ticker.toStdString()) || force) + auto& kdf_system = m_system_manager.get_system(); + auto coin_info = kdf_system.get_coin_info(ticker.toStdString()); + if (kdf_system.set_current_ticker(ticker.toStdString()) || force) { SPDLOG_INFO("new ticker: {}", ticker.toStdString()); m_transactions_mdl->reset(); this->set_tx_fetching_busy(true); - mm2_system.fetch_infos_thread(true, true); + kdf_system.fetch_infos_thread(true, true); emit currentTickerChanged(); refresh_ticker_infos(); check_send_availability(); @@ -269,20 +269,21 @@ namespace atomic_dex {"transactions_left", 0}, {"current_block", 1}, {"is_faucet_coin", false}, + {"is_vote_coin", false}, {"qrcode_address", ""}, {"segwit_supported", false}}; std::error_code ec; - auto& mm2_system = m_system_manager.get_system(); - if (mm2_system.is_mm2_running()) + auto& kdf_system = m_system_manager.get_system(); + if (kdf_system.is_kdf_running()) { - // SPDLOG_DEBUG("get_ticker_infos for {} wallet page", mm2_system.get_current_ticker()); + // SPDLOG_DEBUG("get_ticker_infos for {} wallet page", kdf_system.get_current_ticker()); auto& price_service = m_system_manager.get_system(); const auto& settings_system = m_system_manager.get_system(); const auto& provider = m_system_manager.get_system(); - const auto& ticker = mm2_system.get_current_ticker(); - const auto& coin_info = mm2_system.get_coin_info(ticker); + const auto& ticker = kdf_system.get_current_ticker(); + const auto& coin_info = kdf_system.get_coin_info(ticker); const auto& config = settings_system.get_cfg(); - obj["balance"] = QString::fromStdString(mm2_system.get_balance_info(ticker, ec)); + obj["balance"] = QString::fromStdString(kdf_system.get_balance_info(ticker, ec)); obj["name"] = QString::fromStdString(coin_info.name); obj["type"] = QString::fromStdString(coin_info.type); obj["segwit_supported"] = coin_info.segwit; @@ -293,7 +294,7 @@ namespace atomic_dex obj["explorer_url"] = QString::fromStdString(coin_info.explorer_url); obj["current_currency_ticker_price"] = QString::fromStdString(price_service.get_rate_conversion(config.current_currency, ticker, true)); obj["change_24h"] = retrieve_change_24h(provider, coin_info, config, m_system_manager); - const auto& tx_state = mm2_system.get_tx_state(ec); + const auto& tx_state = kdf_system.get_tx_state(ec); obj["tx_state"] = QString::fromStdString(tx_state.state); obj["fiat_amount"] = QString::fromStdString(price_service.get_price_in_fiat(config.current_currency, ticker, ec)); obj["activation_status"] = nlohmann_json_object_to_qt_json_object(coin_info.activation_status); @@ -303,9 +304,10 @@ namespace atomic_dex obj["transactions_left"] = static_cast(tx_state.transactions_left); obj["current_block"] = static_cast(tx_state.current_block); obj["is_faucet_coin"] = coin_info.is_faucet_coin; + obj["is_vote_coin"] = coin_info.is_vote_coin; std::error_code ec; - if (!mm2_system.is_zhtlc_coin_ready(coin_info.ticker)) + if (!kdf_system.is_zhtlc_coin_ready(coin_info.ticker)) { obj["address"] = "activating"; obj["qrcode_address"] = ""; @@ -313,8 +315,8 @@ namespace atomic_dex } else { - obj["address"] = QString::fromStdString(mm2_system.address(ticker, ec)); - qrcodegen::QrCode qr0 = qrcodegen::QrCode::encodeText(mm2_system.address(ticker, ec).c_str(), qrcodegen::QrCode::Ecc::MEDIUM); + obj["address"] = QString::fromStdString(kdf_system.address(ticker, ec)); + qrcodegen::QrCode qr0 = qrcodegen::QrCode::encodeText(kdf_system.address(ticker, ec).c_str(), qrcodegen::QrCode::Ecc::MEDIUM); std::string svg = qr0.toSvgString(2); obj["qrcode_address"] = QString::fromStdString("data:image/svg+xml;base64,") + QString::fromStdString(svg).toLocal8Bit().toBase64(); } @@ -506,14 +508,14 @@ namespace atomic_dex } void - wallet_page::send(const QString& address, const QString& amount, bool max, bool with_fees, QVariantMap fees_data, const QString& memo) + wallet_page::send(const QString& address, const QString& amount, bool max, bool with_fees, QVariantMap fees_data, const QString& memo, const QString& ibc_source_channel) { //! Preparation this->set_send_busy(true); nlohmann::json batch = nlohmann::json::array(); - auto& mm2_system = m_system_manager.get_system(); - const auto& ticker = mm2_system.get_current_ticker(); - auto coin_info = mm2_system.get_coin_info(ticker); + auto& kdf_system = m_system_manager.get_system(); + const auto& ticker = kdf_system.get_current_ticker(); + auto coin_info = kdf_system.get_coin_info(ticker); if (coin_info.is_zhtlc_family) { @@ -524,13 +526,13 @@ namespace atomic_dex qDebug() << fees_data; auto json_fees = nlohmann::json::parse(QString(QJsonDocument(QVariant(fees_data).toJsonObject()).toJson()).toStdString()); withdraw_init_req.fees = t_withdraw_init_fees{ - .type = "UtxoFixed", + .type = "UtxoPerKbyte", .amount = json_fees.at("fees_amount").get() }; } - nlohmann::json json_data = mm2::template_request("task::withdraw::init", true); + nlohmann::json json_data = kdf::template_request("task::withdraw::init", true); - mm2::to_json(json_data, withdraw_init_req); + kdf::to_json(json_data, withdraw_init_req); batch.push_back(json_data); std::string amount_std = amount.toStdString(); @@ -538,7 +540,7 @@ namespace atomic_dex if (max) { std::error_code ec; - amount_std = mm2_system.get_balance_info(ticker, ec); + amount_std = kdf_system.get_balance_info(ticker, ec); } auto answer_functor = [this, coin_info, ticker, amount_std](web::http::http_response resp) @@ -546,7 +548,7 @@ namespace atomic_dex const auto& settings_system = m_system_manager.get_system(); const auto& global_price_system = m_system_manager.get_system(); const auto& current_fiat = settings_system.get_current_fiat().toStdString(); - auto answers = mm2::basic_batch_answer(resp); + auto answers = kdf::basic_batch_answer(resp); if (answers[0].contains("result")) { @@ -556,7 +558,7 @@ namespace atomic_dex { SPDLOG_DEBUG("Task ID: {}", task_id); using namespace std::chrono_literals; - auto& mm2_system = m_system_manager.get_system(); + auto& kdf_system = m_system_manager.get_system(); static std::size_t z_nb_try = 1; static std::size_t loop_limit = 600; nlohmann::json z_error = nlohmann::json::array(); @@ -564,14 +566,14 @@ namespace atomic_dex QString z_status; t_withdraw_status_request z_request{.task_id = task_id}; - nlohmann::json j = mm2::template_request("task::withdraw::status", true); - mm2::to_json(j, z_request); + nlohmann::json j = kdf::template_request("task::withdraw::status", true); + kdf::to_json(j, z_request); z_batch_array.push_back(j); do { - pplx::task z_resp_task = mm2_system.get_mm2_client().async_rpc_batch_standalone(z_batch_array); + pplx::task z_resp_task = kdf_system.get_kdf_client().async_rpc_batch_standalone(z_batch_array); web::http::http_response z_resp = z_resp_task.get(); - auto z_answers = mm2::basic_batch_answer(z_resp); + auto z_answers = kdf::basic_batch_answer(z_resp); z_error = z_answers; z_status = QString::fromStdString(z_answers[0].at("result").at("status").get()); @@ -607,7 +609,7 @@ namespace atomic_dex } else { - auto withdraw_answer = mm2::rpc_process_answer_batch(z_error[0], "task::withdraw::status"); + auto withdraw_answer = kdf::rpc_process_answer_batch(z_error[0], "task::withdraw::status"); nlohmann::json j_out = nlohmann::json::object(); j_out["withdraw_answer"] = z_error[0]["result"]["details"]; j_out.at("withdraw_answer")["date"] = withdraw_answer.result.value().timestamp_as_date; @@ -681,7 +683,7 @@ namespace atomic_dex }; //! Process - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); } else @@ -694,12 +696,17 @@ namespace atomic_dex .max = max }; + if (ibc_source_channel.toStdString() != "") + { + withdraw_req.ibc_source_channel = ibc_source_channel.toStdString(); + } + auto json_fees = nlohmann::json::parse(QString(QJsonDocument(QVariant(fees_data).toJsonObject()).toJson()).toStdString()); if (with_fees) { qDebug() << fees_data; withdraw_req.fees = t_withdraw_fees{ - .type = "UtxoFixed", + .type = "UtxoPerKbyte", .amount = json_fees.at("fees_amount").get(), .gas_limit = json_fees.at("gas_limit").get()}; if (coin_info.coin_type == CoinType::ERC20) @@ -731,16 +738,17 @@ namespace atomic_dex .gas_limit = 150000}; } - nlohmann::json json_data = mm2::template_request("withdraw", true); - mm2::to_json(json_data, withdraw_req); - SPDLOG_DEBUG("final json: {}", json_data.dump(4)); + nlohmann::json json_data = kdf::template_request("withdraw", true); + kdf::to_json(json_data, withdraw_req); + SPDLOG_DEBUG("withdraw request: {}", json_data.dump(4)); + batch.push_back(json_data); std::string amount_std = amount.toStdString(); if (max) { std::error_code ec; - amount_std = mm2_system.get_balance_info(ticker, ec); + amount_std = kdf_system.get_balance_info(ticker, ec); } //! Answer @@ -754,7 +762,7 @@ namespace atomic_dex if (resp.status_code() == 200 && body.find("error") == std::string::npos) { auto answers = nlohmann::json::parse(body); - auto withdraw_answer = mm2::rpc_process_answer_batch(answers[0], "withdraw"); + auto withdraw_answer = kdf::rpc_process_answer_batch(answers[0], "withdraw"); nlohmann::json j_out = nlohmann::json::object(); j_out["withdraw_answer"] = answers[0]["result"]; j_out.at("withdraw_answer")["date"] = withdraw_answer.result.value().timestamp_as_date; @@ -817,7 +825,7 @@ namespace atomic_dex }; //! Process - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); } } @@ -853,12 +861,12 @@ namespace atomic_dex emit auth_succeededChanged(); this->set_rpc_broadcast_data(""); this->set_broadcast_busy(true); - auto& mm2_system = m_system_manager.get_system(); - const auto& ticker = mm2_system.get_current_ticker(); + auto& kdf_system = m_system_manager.get_system(); + const auto& ticker = kdf_system.get_current_ticker(); nlohmann::json batch = nlohmann::json::array(); t_broadcast_request broadcast_request{.tx_hex = tx_hex.toStdString(), .coin = ticker}; - nlohmann::json json_data = mm2::template_request("send_raw_transaction"); - mm2::to_json(json_data, broadcast_request); + nlohmann::json json_data = kdf::template_request("send_raw_transaction"); + kdf::to_json(json_data, broadcast_request); batch.push_back(json_data); //! Answer @@ -867,22 +875,22 @@ namespace atomic_dex std::string body = TO_STD_STR(resp.extract_string(true).get()); if (resp.status_code() == 200) { - auto& mm2_system = m_system_manager.get_system(); - const auto& ticker = mm2_system.get_current_ticker(); + auto& kdf_system = m_system_manager.get_system(); + const auto& ticker = kdf_system.get_current_ticker(); auto answers = nlohmann::json::parse(body); // SPDLOG_INFO("broadcast answer: {}", answers.dump(4)); if (answers[0].contains("tx_hash")) { this->set_rpc_broadcast_data(QString::fromStdString(answers[0].at("tx_hash").get())); - if (mm2_system.is_pin_cfg_enabled() && (not is_claiming && is_max)) + if (kdf_system.is_pin_cfg_enabled() && (not is_claiming && is_max)) { - mm2_system.reset_fake_balance_to_zero(ticker); + kdf_system.reset_fake_balance_to_zero(ticker); } - else if (mm2_system.is_pin_cfg_enabled() && (not is_claiming && not is_max)) + else if (kdf_system.is_pin_cfg_enabled() && (not is_claiming && not is_max)) { - mm2_system.decrease_fake_balance(ticker, amount.toStdString()); + kdf_system.decrease_fake_balance(ticker, amount.toStdString()); } - mm2_system.fetch_infos_thread(); + kdf_system.fetch_infos_thread(); } else { @@ -910,7 +918,7 @@ namespace atomic_dex } }; - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); } void @@ -918,13 +926,13 @@ namespace atomic_dex { this->set_claiming_is_busy(true); nlohmann::json batch = nlohmann::json::array(); - auto& mm2_system = m_system_manager.get_system(); + auto& kdf_system = m_system_manager.get_system(); std::error_code ec; - t_withdraw_request withdraw_req{.coin = "KMD", .to = mm2_system.address("KMD", ec), .amount = "0", .max = true}; - nlohmann::json json_data = mm2::template_request("withdraw", true); - mm2::to_json(json_data, withdraw_req); + t_withdraw_request withdraw_req{.coin = "KMD", .to = kdf_system.address("KMD", ec), .amount = "0", .max = true}; + nlohmann::json json_data = kdf::template_request("withdraw", true); + kdf::to_json(json_data, withdraw_req); batch.push_back(json_data); - json_data = mm2::template_request("kmd_rewards_info"); + json_data = kdf::template_request("kmd_rewards_info"); batch.push_back(json_data); auto answer_functor = [this](web::http::http_response resp) @@ -934,11 +942,11 @@ namespace atomic_dex if (resp.status_code() == static_cast(antara::app::http_code::ok) && body.find("error") == std::string::npos) { auto answers = nlohmann::json::parse(body); - auto withdraw_answer = mm2::rpc_process_answer_batch(answers[0], "withdraw"); + auto withdraw_answer = kdf::rpc_process_answer_batch(answers[0], "withdraw"); nlohmann::json j_out = nlohmann::json::object(); j_out["withdraw_answer"] = answers[0]["result"]; j_out.at("withdraw_answer")["date"] = withdraw_answer.result.value().timestamp_as_date; - auto kmd_rewards_answer = mm2::process_kmd_rewards_answer(answers[1]); + auto kmd_rewards_answer = kdf::process_kmd_rewards_answer(answers[1]); j_out["kmd_rewards_info"] = kmd_rewards_answer.result; this->set_rpc_claiming_data(nlohmann_json_object_to_qt_json_object(j_out)); } @@ -965,17 +973,17 @@ namespace atomic_dex } }; - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor); } void wallet_page ::claim_faucet() { - const auto& mm2_system = m_system_manager.get_system(); - const auto& ticker = mm2_system.get_current_ticker(); - const auto& coin_info = mm2_system.get_coin_info(ticker); + const auto& kdf_system = m_system_manager.get_system(); + const auto& ticker = kdf_system.get_current_ticker(); + const auto& coin_info = kdf_system.get_coin_info(ticker); std::error_code ec; - faucet::api::claim_request claim_request{.coin_name = coin_info.ticker, .wallet_address = mm2_system.address(ticker, ec)}; + faucet::api::claim_request claim_request{.coin_name = coin_info.ticker, .wallet_address = kdf_system.address(ticker, ec)}; this->set_claiming_faucet_is_busy(true); faucet::api::claim(claim_request) @@ -1009,7 +1017,7 @@ namespace atomic_dex { std::error_code ec; const auto& settings = m_system_manager.get_system(); - t_transactions transactions = m_system_manager.get_system().get_tx_history(ec); + t_transactions transactions = m_system_manager.get_system().get_tx_history(ec); t_transactions to_init; if (settings.is_spamfilter_enabled()) { @@ -1054,10 +1062,10 @@ namespace atomic_dex void wallet_page::validate_address(QString address) { - auto& mm2_system = m_system_manager.get_system(); - if (mm2_system.is_mm2_running()) + auto& kdf_system = m_system_manager.get_system(); + if (kdf_system.is_kdf_running()) { - const auto& ticker = mm2_system.get_current_ticker(); + const auto& ticker = kdf_system.get_current_ticker(); validate_address(address, QString::fromStdString(ticker)); } } @@ -1066,15 +1074,15 @@ namespace atomic_dex wallet_page::validate_address(QString address, QString ticker) { // SPDLOG_INFO("validate_address: {} - ticker: {}", address.toStdString(), ticker.toStdString()); - auto& mm2_system = m_system_manager.get_system(); - if (mm2_system.is_mm2_running()) + auto& kdf_system = m_system_manager.get_system(); + if (kdf_system.is_kdf_running()) { std::error_code ec; t_validate_address_request req{.coin = ticker.toStdString(), .address = address.toStdString()}; this->set_validate_address_busy(true); nlohmann::json batch = nlohmann::json::array(); - nlohmann::json json_data = mm2::template_request("validateaddress"); - mm2::to_json(json_data, req); + nlohmann::json json_data = kdf::template_request("validateaddress"); + kdf::to_json(json_data, req); batch.push_back(json_data); auto answer_functor = [this, ticker](web::http::http_response resp) { @@ -1085,7 +1093,7 @@ namespace atomic_dex if (resp.status_code() == static_cast(antara::app::http_code::ok)) { auto answers = nlohmann::json::parse(body); - auto validate_answer = mm2::rpc_process_answer_batch(answers[0], "validateaddress"); + auto validate_answer = kdf::rpc_process_answer_batch(answers[0], "validateaddress"); if (validate_answer.result.has_value()) { auto res = validate_answer.result.value(); @@ -1094,7 +1102,7 @@ namespace atomic_dex } else { - if (!m_system_manager.get_system().is_zhtlc_coin_ready(ticker.toStdString())) + if (!m_system_manager.get_system().is_zhtlc_coin_ready(ticker.toStdString())) { j_out["reason"] = "Validation error: Coin not fully enabled"; } @@ -1114,17 +1122,17 @@ namespace atomic_dex this->set_validate_address_data(nlohmann_json_object_to_qt_json_object(j_out)); this->set_validate_address_busy(false); }; - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); } } void wallet_page::convert_address(QString from, QVariant to_address_format) { - auto& mm2_system = m_system_manager.get_system(); - if (mm2_system.is_mm2_running()) + auto& kdf_system = m_system_manager.get_system(); + if (kdf_system.is_kdf_running()) { - const auto& ticker = mm2_system.get_current_ticker(); + const auto& ticker = kdf_system.get_current_ticker(); convert_address(from, QString::fromStdString(ticker), to_address_format); } } @@ -1132,16 +1140,16 @@ namespace atomic_dex void wallet_page::convert_address(QString from, QString ticker, QVariant to_address_format) { - auto& mm2_system = m_system_manager.get_system(); - if (mm2_system.is_mm2_running()) + auto& kdf_system = m_system_manager.get_system(); + if (kdf_system.is_kdf_running()) { QVariantMap out = to_address_format.value(); auto address_fmt = nlohmann::json::parse(QJsonDocument::fromVariant(out).toJson().toStdString()); t_convert_address_request req{.coin = ticker.toStdString(), .from = from.toStdString(), .to_address_format = address_fmt}; this->set_convert_address_busy(true); nlohmann::json batch = nlohmann::json::array(); - nlohmann::json json_data = mm2::template_request("convertaddress"); - mm2::to_json(json_data, req); + nlohmann::json json_data = kdf::template_request("convertaddress"); + kdf::to_json(json_data, req); batch.push_back(json_data); auto answer_functor = [this](web::http::http_response resp) { @@ -1150,7 +1158,7 @@ namespace atomic_dex if (resp.status_code() == static_cast(antara::app::http_code::ok)) { auto answers = nlohmann::json::parse(body); - auto convert_answer = mm2::rpc_process_answer_batch(answers[0], "convertaddress"); + auto convert_answer = kdf::rpc_process_answer_batch(answers[0], "convertaddress"); if (convert_answer.result.has_value()) { auto res = QString::fromStdString(convert_answer.result.value().address); @@ -1159,7 +1167,7 @@ namespace atomic_dex } this->set_convert_address_busy(false); }; - mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); + kdf_system.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); } } diff --git a/src/core/atomicdex/pages/qt.wallet.page.hpp b/src/core/atomicdex/pages/qt.wallet.page.hpp index 97b90f739f..678d0164df 100644 --- a/src/core/atomicdex/pages/qt.wallet.page.hpp +++ b/src/core/atomicdex/pages/qt.wallet.page.hpp @@ -88,7 +88,7 @@ namespace atomic_dex bool is_auth, const QString& tx_hex, bool is_claiming, bool is_max, const QString& amount); // Broadcast requires OS local user credentials verification. This is called by the Q_INVOKABLE broadcast() method after // entering credentials. - Q_INVOKABLE void send(const QString& address, const QString& amount, bool max, bool with_fees, QVariantMap fees_data, const QString& memo); + Q_INVOKABLE void send(const QString& address, const QString& amount, bool max, bool with_fees, QVariantMap fees_data, const QString& memo, const QString& ibc_source_channel); // QML API Properties Q_PROPERTY(transactions_model* transactions_mdl READ get_transactions_mdl NOTIFY transactionsMdlChanged) diff --git a/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp b/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp index 29a50e8adf..1eaf9ed854 100644 --- a/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp +++ b/src/core/atomicdex/pages/widgets/dex/qt.orderbook.cpp @@ -17,7 +17,7 @@ //! Project headers #include "qt.orderbook.hpp" #include "atomicdex/pages/qt.trading.page.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/orderbook.scanner.service.hpp" namespace @@ -79,9 +79,9 @@ namespace atomic_dex } void - qt_orderbook_wrapper::refresh_orderbook_model_data(mm2::orderbook_result_rpc answer) + qt_orderbook_wrapper::refresh_orderbook_model_data(kdf::orderbook_result_rpc answer) { - SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] bids/asks size: {}/{}", answer.bids.size(), answer.asks.size()); + // SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] bids/asks size: {}/{}", answer.bids.size(), answer.asks.size()); this->m_asks->refresh_orderbook_model_data(answer.asks); this->m_bids->refresh_orderbook_model_data(answer.bids); const auto data = this->m_system_manager.get_system().get_bestorders_data(); @@ -91,19 +91,19 @@ namespace atomic_dex } else if (m_best_orders->rowCount() == 0) { - SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : reset_best_orders"); + // SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : reset_best_orders"); m_best_orders->reset_orderbook(data, true); } else { - SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : refresh_best_orders"); + // SPDLOG_INFO("[qt_orderbook_wrapper::refresh_orderbook_model_data] : refresh_best_orders"); m_best_orders->refresh_orderbook_model_data(data, true); } this->set_both_taker_vol(); } void - qt_orderbook_wrapper::reset_orderbook(mm2::orderbook_result_rpc answer) + qt_orderbook_wrapper::reset_orderbook(kdf::orderbook_result_rpc answer) { this->m_asks->reset_orderbook(answer.asks); this->m_bids->reset_orderbook(answer.bids); @@ -142,7 +142,7 @@ namespace atomic_dex void atomic_dex::qt_orderbook_wrapper::set_both_taker_vol() { - auto&& [base, rel] = m_system_manager.get_system().get_taker_vol(); + auto&& [base, rel] = m_system_manager.get_system().get_taker_vol(); this->m_base_max_taker_vol = QJsonObject{ {"denom", QString::fromStdString(base.denom)}, {"numer", QString::fromStdString(base.numer)}, @@ -156,7 +156,7 @@ namespace atomic_dex {"coin", QString::fromStdString(rel.coin)}}; emit relMaxTakerVolChanged(); - auto&& [min_base, min_rel] = m_system_manager.get_system().get_min_vol(); + auto&& [min_base, min_rel] = m_system_manager.get_system().get_min_vol(); this->m_base_min_taker_vol = QString::fromStdString(min_base.min_trading_vol); emit baseMinTakerVolChanged(); this->m_rel_min_taker_vol = QString::fromStdString(min_rel.min_trading_vol); @@ -264,7 +264,7 @@ namespace atomic_dex // if (trading_pg.) if (price_f <= 0) { - //! Price is not set yet in the UI in this particular case return the min volume calculated by mm2 + //! Price is not set yet in the UI in this particular case return the min volume calculated by kdf return cur_taker_vol; } diff --git a/src/core/atomicdex/pages/widgets/dex/qt.orderbook.hpp b/src/core/atomicdex/pages/widgets/dex/qt.orderbook.hpp index 21cd4ae3bb..44ff5b9c38 100644 --- a/src/core/atomicdex/pages/widgets/dex/qt.orderbook.hpp +++ b/src/core/atomicdex/pages/widgets/dex/qt.orderbook.hpp @@ -47,8 +47,8 @@ namespace atomic_dex public: void adjust_min_vol(); - void refresh_orderbook_model_data(mm2::orderbook_result_rpc answer); - void reset_orderbook(mm2::orderbook_result_rpc answer); + void refresh_orderbook_model_data(kdf::orderbook_result_rpc answer); + void reset_orderbook(kdf::orderbook_result_rpc answer); void clear_orderbook(); [[nodiscard]] orderbook_model* get_asks() const; [[nodiscard]] orderbook_model* get_bids() const; diff --git a/src/core/atomicdex/pages/widgets/dex/qt.orders.widget.cpp b/src/core/atomicdex/pages/widgets/dex/qt.orders.widget.cpp index 3ff8cd10cd..598bb21815 100644 --- a/src/core/atomicdex/pages/widgets/dex/qt.orders.widget.cpp +++ b/src/core/atomicdex/pages/widgets/dex/qt.orders.widget.cpp @@ -20,8 +20,8 @@ //! Project Headers #include "../../qt.settings.page.hpp" #include "../../qt.trading.page.hpp" -#include "atomicdex/api/mm2/mm2.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/api/kdf/kdf.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/global.provider.hpp" #include "qt.orders.widget.hpp" @@ -42,30 +42,30 @@ namespace atomic_dex qt_orders_widget::common_cancel_all_orders(bool by_coin, const QString& ticker) { nlohmann::json batch = nlohmann::json::array(); - nlohmann::json cancel_request = mm2::template_request("cancel_all_orders"); + nlohmann::json cancel_request = kdf::template_request("cancel_all_orders"); if (by_coin && not ticker.isEmpty()) { - mm2::cancel_data cd; + kdf::cancel_data cd; cd.ticker = ticker.toStdString(); - mm2::cancel_all_orders_request req{{"Coin", cd}}; - mm2::to_json(cancel_request, req); + kdf::cancel_all_orders_request req{{"Coin", cd}}; + kdf::to_json(cancel_request, req); } else { - mm2::cancel_data cd; + kdf::cancel_data cd; cd.ticker = ticker.toStdString(); - mm2::cancel_all_orders_request req_all; - mm2::to_json(cancel_request, req_all); + kdf::cancel_all_orders_request req_all; + kdf::to_json(cancel_request, req_all); } batch.push_back(cancel_request); - auto& mm2_system = m_system_mgr.get_system(); - mm2_system.get_mm2_client() + auto& kdf_system = m_system_mgr.get_system(); + kdf_system.get_kdf_client() .async_rpc_batch_standalone(batch) .then([this]([[maybe_unused]] web::http::http_response resp) { - auto& mm2_system = m_system_mgr.get_system(); - mm2_system.batch_fetch_orders_and_swap(); - mm2_system.process_orderbook(false); + auto& kdf_system = m_system_mgr.get_system(); + kdf_system.batch_fetch_orders_and_swap(); + kdf_system.process_orderbook(false); }) .then(&handle_exception_pplx_task); } @@ -81,20 +81,20 @@ namespace atomic_dex nlohmann::json batch = nlohmann::json::array(); for (auto&& order_id: orders_id) { - mm2::cancel_all_orders_request req; - nlohmann::json cancel_request = mm2::template_request("cancel_order"); - mm2::cancel_order_request cancel_req{order_id.toStdString()}; + kdf::cancel_all_orders_request req; + nlohmann::json cancel_request = kdf::template_request("cancel_order"); + kdf::cancel_order_request cancel_req{order_id.toStdString()}; to_json(cancel_request, cancel_req); batch.push_back(cancel_request); } - auto& mm2_system = m_system_mgr.get_system(); - mm2_system.get_mm2_client() + auto& kdf_system = m_system_mgr.get_system(); + kdf_system.get_kdf_client() .async_rpc_batch_standalone(batch) .then([this]([[maybe_unused]] web::http::http_response resp) { - auto& mm2_system = m_system_mgr.get_system(); - mm2_system.batch_fetch_orders_and_swap(); - mm2_system.process_orderbook(false); + auto& kdf_system = m_system_mgr.get_system(); + kdf_system.batch_fetch_orders_and_swap(); + kdf_system.process_orderbook(false); }) .then(&handle_exception_pplx_task); } diff --git a/src/core/atomicdex/services/exporter/exporter.service.cpp b/src/core/atomicdex/services/exporter/exporter.service.cpp index 604d7a8287..d248cf361b 100644 --- a/src/core/atomicdex/services/exporter/exporter.service.cpp +++ b/src/core/atomicdex/services/exporter/exporter.service.cpp @@ -24,9 +24,9 @@ #include //! Project -#include "atomicdex/api/mm2/mm2.hpp" +#include "atomicdex/api/kdf/kdf.hpp" #include "atomicdex/services/exporter/exporter.service.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/utilities/qt.utilities.hpp" //! Constructor @@ -66,9 +66,9 @@ namespace atomic_dex LOG_PATH("new csv path is: {}", csv_path); } nlohmann::json batch = nlohmann::json::array(); - nlohmann::json my_recent_swaps = mm2::template_request("my_recent_swaps"); - auto& mm2 = m_system_manager.get_system(); - const auto swaps_data = mm2.get_orders_and_swaps(); + nlohmann::json my_recent_swaps = kdf::template_request("my_recent_swaps"); + auto& kdf = m_system_manager.get_system(); + const auto swaps_data = kdf.get_orders_and_swaps(); t_my_recent_swaps_request request{ .limit = swaps_data.total_finished_swaps, .page_number = 1, @@ -81,8 +81,8 @@ namespace atomic_dex // SPDLOG_INFO("my_recent_swaps req: {}", my_recent_swaps.dump(4)); auto answer_functor = [csv_path](web::http::http_response resp) { - auto answers = mm2::basic_batch_answer(resp); - const auto swap_answer = mm2::rpc_process_answer_batch(answers[0], "my_recent_swaps"); + auto answers = kdf::basic_batch_answer(resp); + const auto swap_answer = kdf::rpc_process_answer_batch(answers[0], "my_recent_swaps"); if (swap_answer.result.has_value()) { const auto result = swap_answer.result.value(); @@ -123,6 +123,6 @@ namespace atomic_dex } }; - mm2.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); + kdf.get_kdf_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task); } } // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/services/internet/internet.checker.service.cpp b/src/core/atomicdex/services/internet/internet.checker.service.cpp index 9afafd488f..72c51e835e 100644 --- a/src/core/atomicdex/services/internet/internet.checker.service.cpp +++ b/src/core/atomicdex/services/internet/internet.checker.service.cpp @@ -19,7 +19,7 @@ //! Our project #include "atomicdex/services/internet/internet.checker.service.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/utilities/cpprestsdk.utilities.hpp" #include "atomicdex/utilities/qt.utilities.hpp" @@ -32,8 +32,7 @@ namespace return cfg; }()}; - t_http_client_ptr g_paprika_proxy_http_client{std::make_unique(FROM_STD_STR("https://api.coinpaprika.com"), g_cfg)}; - std::atomic_bool g_mm2_default_coins_ready{false}; + std::atomic_bool g_kdf_default_coins_ready{false}; pplx::task async_check_retrieve(t_http_client_ptr& client, const std::string& uri) @@ -164,35 +163,35 @@ namespace atomic_dex void internet_service_checker::fetch_internet_connection() { - //query_internet(g_paprika_proxy_http_client, "/v1/coins/btc-bitcoin", &internet_service_checker::is_paprika_provider_alive); - if (this->m_system_manager.has_system() && g_mm2_default_coins_ready) + // TODO: This is only checking kdf connection, not connection to the internet. + if (this->m_system_manager.has_system() && g_kdf_default_coins_ready) { - auto& mm2 = this->m_system_manager.get_system(); - if (mm2.is_mm2_running()) + auto& kdf = this->m_system_manager.get_system(); + if (kdf.is_kdf_running()) { - SPDLOG_INFO("mm2 is alive, checking if we are able to fetch mm2 version"); + SPDLOG_INFO("kdf is alive, checking if we are able to fetch kdf version"); nlohmann::json batch = nlohmann::json::array(); - nlohmann::json current_request = mm2::template_request("version"); + nlohmann::json current_request = kdf::template_request("version"); // SPDLOG_DEBUG("version request {}", current_request.dump(4)); batch.push_back(current_request); - auto async_answer = mm2.get_mm2_client().async_rpc_batch_standalone(batch); - generic_treat_answer(async_answer, TO_STD_STR(atomic_dex::g_dex_rpc), &internet_service_checker::is_mm2_endpoint_alive); + auto async_answer = kdf.get_kdf_client().async_rpc_batch_standalone(batch); + generic_treat_answer(async_answer, TO_STD_STR(atomic_dex::g_dex_rpc), &internet_service_checker::is_kdf_endpoint_alive); } else { - SPDLOG_WARN("mm2 not running skipping internet connectivity with it"); + SPDLOG_WARN("kdf not running skipping internet connectivity with it"); } } else { - SPDLOG_WARN("mm2 system not available skipping internet connectivity with it"); + SPDLOG_WARN("kdf system not available skipping internet connectivity with it"); } } void internet_service_checker::on_default_coins_enabled([[maybe_unused]] const default_coins_enabled& evt) { - SPDLOG_INFO("Default coins are enabled, we can now check internet with mm2 too"); - g_mm2_default_coins_ready = true; + SPDLOG_INFO("Default coins are enabled, we can now check internet with kdf too"); + g_kdf_default_coins_ready = true; } } // namespace atomic_dex diff --git a/src/core/atomicdex/services/internet/internet.checker.service.hpp b/src/core/atomicdex/services/internet/internet.checker.service.hpp index 553a2fcd95..417ac6897d 100644 --- a/src/core/atomicdex/services/internet/internet.checker.service.hpp +++ b/src/core/atomicdex/services/internet/internet.checker.service.hpp @@ -45,7 +45,7 @@ namespace atomic_dex double m_timer; std::atomic_bool is_internet_reacheable{true}; std::atomic_bool is_paprika_provider_alive{true}; - std::atomic_bool is_mm2_endpoint_alive{true}; + std::atomic_bool is_kdf_endpoint_alive{true}; std::atomic_bool is_our_private_endpoint_reacheable{true}; //! Private functions diff --git a/src/core/atomicdex/services/mm2/auto.update.maker.order.service.cpp b/src/core/atomicdex/services/kdf/auto.update.maker.order.service.cpp similarity index 88% rename from src/core/atomicdex/services/mm2/auto.update.maker.order.service.cpp rename to src/core/atomicdex/services/kdf/auto.update.maker.order.service.cpp index 754b01dfe1..ac1861c9d7 100644 --- a/src/core/atomicdex/services/mm2/auto.update.maker.order.service.cpp +++ b/src/core/atomicdex/services/kdf/auto.update.maker.order.service.cpp @@ -18,9 +18,9 @@ #include // Project Headers -#include "atomicdex/api/mm2/rpc_v1/rpc.update_maker_order.hpp" -#include "atomicdex/services/mm2/auto.update.maker.order.service.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.update_maker_order.hpp" +#include "atomicdex/services/kdf/auto.update.maker.order.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/global.provider.hpp" //! Constructor @@ -61,11 +61,11 @@ namespace atomic_dex void auto_update_maker_order_service::update_order(const t_order_swaps_data& data) { - const auto& mm2 = this->m_system_manager.get_system(); + const auto& kdf = this->m_system_manager.get_system(); const auto base_coin = data.base_coin.toStdString(); const auto rel_coin = data.rel_coin.toStdString(); - const auto base_coin_info = mm2.get_coin_info(base_coin); - const auto rel_coin_info = mm2.get_coin_info(rel_coin); + const auto base_coin_info = kdf.get_coin_info(base_coin); + const auto rel_coin_info = kdf.get_coin_info(rel_coin); QSettings& settings = entity_registry_.ctx(); const auto category_settings = data.base_coin + "_" + data.rel_coin; const QString target_settings = "Disabled"; @@ -81,7 +81,7 @@ namespace atomic_dex nlohmann::json batch = nlohmann::json::array(); std::string new_price = get_new_price_from_order(data, spread); nlohmann::json conf_settings = data.conf_settings.value_or(nlohmann::json()); - nlohmann::json update_maker_order_json = mm2::template_request("update_maker_order"); + nlohmann::json update_maker_order_json = kdf::template_request("update_maker_order"); t_float_50 volume = safe_float(data.base_amount.toStdString()); t_float_50 min_volume = volume * min_volume_percent; t_update_maker_order_request request{ @@ -96,12 +96,12 @@ namespace atomic_dex request.base_confs = conf_settings.at("base_confs").get(); request.rel_confs = conf_settings.at("rel_confs").get(); } - mm2::to_json(update_maker_order_json, request); + kdf::to_json(update_maker_order_json, request); batch.push_back(update_maker_order_json); update_maker_order_json["userpass"] = ""; SPDLOG_INFO("request: {}", update_maker_order_json.dump(1)); - auto& mm2 = this->m_system_manager.get_system(); - mm2.get_mm2_client() + auto& kdf = this->m_system_manager.get_system(); + kdf.get_kdf_client() .async_rpc_batch_standalone(batch) .then( []([[maybe_unused]] web::http::http_response resp) @@ -120,8 +120,8 @@ namespace atomic_dex auto_update_maker_order_service::internal_update() { SPDLOG_DEBUG("update maker orders"); - const auto& mm2 = this->m_system_manager.get_system(); - orders_and_swaps data = mm2.get_orders_and_swaps(); + const auto& kdf = this->m_system_manager.get_system(); + orders_and_swaps data = kdf.get_orders_and_swaps(); auto cur = data.orders_and_swaps.begin(); auto end = data.orders_and_swaps.begin() + data.nb_orders; for (; cur != end && cur != data.orders_and_swaps.end(); ++cur) @@ -139,21 +139,21 @@ namespace atomic_dex { try { - if (this->m_system_manager.has_system()) + if (this->m_system_manager.has_system()) { - const auto& mm2 = this->m_system_manager.get_system(); - if (mm2.is_mm2_running()) + const auto& kdf = this->m_system_manager.get_system(); + if (kdf.is_kdf_running()) { this->internal_update(); } else { - SPDLOG_WARN("MM2 service is not running yet - skipping"); + SPDLOG_WARN("KDF service is not running yet - skipping"); } } else { - SPDLOG_WARN("MM2 service not created yet - skipping"); + SPDLOG_WARN("KDF service not created yet - skipping"); } } catch (const std::exception& error) diff --git a/src/core/atomicdex/services/mm2/auto.update.maker.order.service.hpp b/src/core/atomicdex/services/kdf/auto.update.maker.order.service.hpp similarity index 100% rename from src/core/atomicdex/services/mm2/auto.update.maker.order.service.hpp rename to src/core/atomicdex/services/kdf/auto.update.maker.order.service.hpp diff --git a/src/core/atomicdex/services/mm2/mm2.service.cpp b/src/core/atomicdex/services/kdf/kdf.service.cpp similarity index 87% rename from src/core/atomicdex/services/mm2/mm2.service.cpp rename to src/core/atomicdex/services/kdf/kdf.service.cpp index cccedaed77..33ca01c4c5 100644 --- a/src/core/atomicdex/services/mm2/mm2.service.cpp +++ b/src/core/atomicdex/services/kdf/kdf.service.cpp @@ -18,6 +18,10 @@ #include #include #include +#include +#include +#include + #include #include @@ -27,21 +31,21 @@ #include #include -#include "atomicdex/api/mm2/utxo_merge_params.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.electrum.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.enable.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp" -#include "atomicdex/api/mm2/rpc.tx.history.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.z_coin_tx_history.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.init.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.task.enable_z_coin.status.hpp" -#include "atomicdex/config/mm2.cfg.hpp" +#include "atomicdex/api/kdf/utxo_merge_params.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.electrum.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.enable.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp" +#include "atomicdex/api/kdf/rpc.tx.history.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.z_coin_tx_history.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.init.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.task.enable_z_coin.status.hpp" +#include "atomicdex/config/kdf.cfg.hpp" #include "atomicdex/config/coins.cfg.hpp" #include "atomicdex/constants/dex.constants.hpp" #include "atomicdex/managers/qt.wallet.manager.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/services/internet/internet.checker.service.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/utilities/qt.utilities.hpp" #include "atomicdex/utilities/kill.hpp" @@ -195,7 +199,7 @@ namespace namespace atomic_dex { - std::vector mm2_service::retrieve_coins_informations() + std::vector kdf_service::retrieve_coins_informations() { std::vector cfg; SPDLOG_DEBUG("retrieve_coins_informations"); @@ -264,21 +268,21 @@ namespace atomic_dex return cfg; } - mm2_service::mm2_service(entt::registry& registry, ag::ecs::system_manager& system_manager) : system(registry), m_system_manager(system_manager) + kdf_service::kdf_service(entt::registry& registry, ag::ecs::system_manager& system_manager) : system(registry), m_system_manager(system_manager) { m_orderbook_clock = std::chrono::high_resolution_clock::now(); m_info_clock = std::chrono::high_resolution_clock::now(); - dispatcher_.sink().connect<&mm2_service::on_gui_enter_trading>(*this); - dispatcher_.sink().connect<&mm2_service::on_gui_leave_trading>(*this); - dispatcher_.sink().connect<&mm2_service::on_refresh_orderbook_model_data>(*this); - SPDLOG_INFO("mm2_service created"); + dispatcher_.sink().connect<&kdf_service::on_gui_enter_trading>(*this); + dispatcher_.sink().connect<&kdf_service::on_gui_leave_trading>(*this); + dispatcher_.sink().connect<&kdf_service::on_refresh_orderbook_model_data>(*this); + SPDLOG_INFO("kdf_service created"); } - void mm2_service::update() + void kdf_service::update() { using namespace std::chrono_literals; - if (not m_mm2_running) + if (not m_kdf_running) { return; } @@ -332,45 +336,49 @@ namespace atomic_dex } } - if (s_info >= 29s) + if (s_info >= 23s) { - fetch_infos_thread(); // leads to batch_balance_and_tx - m_info_clock = std::chrono::high_resolution_clock::now(); + std::unique_lock lock(m_activation_mutex); + if (m_activation_queue.empty()) + { + fetch_infos_thread(); // leads to batch_balance_and_tx + m_info_clock = std::chrono::high_resolution_clock::now(); + } } } - mm2_service::~mm2_service() + kdf_service::~kdf_service() { - SPDLOG_INFO("destroying mm2 service..."); - dispatcher_.sink().disconnect<&mm2_service::on_gui_enter_trading>(*this); - dispatcher_.sink().disconnect<&mm2_service::on_gui_leave_trading>(*this); - dispatcher_.sink().disconnect<&mm2_service::on_refresh_orderbook_model_data>(*this); - SPDLOG_INFO("mm2 signals successfully disconnected"); - bool mm2_stopped = false; - if (m_mm2_running) + SPDLOG_INFO("destroying kdf service..."); + dispatcher_.sink().disconnect<&kdf_service::on_gui_enter_trading>(*this); + dispatcher_.sink().disconnect<&kdf_service::on_gui_leave_trading>(*this); + dispatcher_.sink().disconnect<&kdf_service::on_refresh_orderbook_model_data>(*this); + SPDLOG_INFO("kdf signals successfully disconnected"); + bool kdf_stopped = false; + if (m_kdf_running) { - SPDLOG_INFO("preparing mm2 stop batch request"); - nlohmann::json stop_request = mm2::template_request("stop"); + SPDLOG_INFO("preparing kdf stop batch request"); + nlohmann::json stop_request = kdf::template_request("stop"); nlohmann::json batch = nlohmann::json::array(); batch.push_back(stop_request); - SPDLOG_INFO("processing mm2 stop batch request"); - pplx::task resp_task = m_mm2_client.async_rpc_batch_standalone(batch); + SPDLOG_INFO("processing kdf stop batch request"); + pplx::task resp_task = m_kdf_client.async_rpc_batch_standalone(batch); web::http::http_response resp = resp_task.get(); - SPDLOG_INFO("mm2 stop batch answer received"); - auto answers = mm2::basic_batch_answer(resp); + SPDLOG_INFO("kdf stop batch answer received"); + auto answers = kdf::basic_batch_answer(resp); if (answers[0].contains("result")) { - mm2_stopped = answers[0].at("result").get() == "success"; - SPDLOG_INFO("mm2 successfully stopped with rpc stop"); + kdf_stopped = answers[0].at("result").get() == "success"; + SPDLOG_INFO("kdf successfully stopped with rpc stop"); } } - m_mm2_running = false; + m_kdf_running = false; // m_token_source.cancel(); - m_mm2_client.stop(); + m_kdf_client.stop(); - if (!mm2_stopped) + if (!kdf_stopped) { - SPDLOG_INFO("mm2 didn't stop yet with rpc stop, stopping process manually"); + SPDLOG_INFO("kdf didn't stop yet with rpc stop, stopping process manually"); #if defined(_WIN32) || defined(WIN32) atomic_dex::kill_executable(atomic_dex::g_dex_api); #else @@ -379,30 +387,30 @@ namespace atomic_dex {reproc::stop::kill, reproc::milliseconds(5000)}, {reproc::stop::wait, reproc::milliseconds(2000)}};*/ - /*const auto ec = m_mm2_instance.stop(stop_actions).second; + /*const auto ec = m_kdf_instance.stop(stop_actions).second; if (ec) { - SPDLOG_ERROR("error when stopping mm2 by process: {}", ec.message()); + SPDLOG_ERROR("error when stopping kdf by process: {}", ec.message()); // std::cerr << "error: " << ec.message() << std::endl; }*/ #endif } - if (m_mm2_init_thread.joinable()) + if (m_kdf_init_thread.joinable()) { - m_mm2_init_thread.join(); - SPDLOG_INFO("mm2 init thread destroyed"); + m_kdf_init_thread.join(); + SPDLOG_INFO("kdf init thread destroyed"); } - SPDLOG_INFO("mm2 service fully destroyed"); + SPDLOG_INFO("kdf service fully destroyed"); } - const std::atomic_bool& mm2_service::is_mm2_running() const + const std::atomic_bool& kdf_service::is_kdf_running() const { - return m_mm2_running; + return m_kdf_running; } - t_coins mm2_service::get_enabled_coins() const + t_coins kdf_service::get_enabled_coins() const { t_coins destination; @@ -418,7 +426,7 @@ namespace atomic_dex return destination; } - t_coins mm2_service::get_active_coins() const + t_coins kdf_service::get_active_coins() const { t_coins destination; @@ -434,26 +442,26 @@ namespace atomic_dex return destination; } - void mm2_service::enable_z_coin_cancel(const std::int8_t task_id) + void kdf_service::enable_z_coin_cancel(const std::int8_t task_id) { t_enable_z_coin_cancel_request request{.task_id = task_id}; - auto answer = m_mm2_client.rpc_enable_z_coin_cancel(std::move(request)); - // SPDLOG_DEBUG("mm2_service::enable_z_coin_cancel: [task_id {}] result: {}", task_id, answer.raw_result); + auto answer = m_kdf_client.rpc_enable_z_coin_cancel(std::move(request)); + // SPDLOG_DEBUG("kdf_service::enable_z_coin_cancel: [task_id {}] result: {}", task_id, answer.raw_result); } - bool mm2_service::disable_coin(const std::string& ticker, std::error_code& ec) + bool kdf_service::disable_coin(const std::string& ticker, std::error_code& ec) { coin_config_t coin_info = get_coin_info(ticker); if (not coin_info.currently_enabled) { - // SPDLOG_DEBUG("[mm2_service::disable_coin]: {} not currently_enabled", ticker); + // SPDLOG_DEBUG("[kdf_service::disable_coin]: {} not currently_enabled", ticker); return true; } t_disable_coin_request request{.coin = ticker}; - auto answer = m_mm2_client.rpc_disable_coin(std::move(request)); - // SPDLOG_DEBUG("mm2_service::disable_coin: {} result: {}", ticker, answer.raw_result); + auto answer = m_kdf_client.rpc_disable_coin(std::move(request)); + // SPDLOG_DEBUG("kdf_service::disable_coin: {} result: {}", ticker, answer.raw_result); if (answer.error.has_value()) { @@ -484,7 +492,7 @@ namespace atomic_dex return true; } - bool mm2_service::enable_default_coins() + bool kdf_service::enable_default_coins() { std::atomic result{1}; auto coins = get_active_coins(); @@ -494,17 +502,17 @@ namespace atomic_dex return result.load() == 1; } - void mm2_service::enable_coin(const std::string& ticker) + void kdf_service::enable_coin(const std::string& ticker) { enable_coin(get_coin_info(ticker)); } - void mm2_service::enable_coin(const coin_config_t& coin_config) + void kdf_service::enable_coin(const coin_config_t& coin_config) { enable_coins(t_coins{coin_config}); } - void mm2_service::enable_coins(const std::vector& tickers) + void kdf_service::enable_coins(const std::vector& tickers) { t_coins coins{}; @@ -516,7 +524,7 @@ namespace atomic_dex enable_coins(coins); } - void mm2_service::enable_coins(const t_coins& coins) + void kdf_service::enable_coins(const t_coins& coins) { t_coins enabled_coins = get_enabled_coins(); for (const auto& coin : coins) @@ -532,16 +540,14 @@ namespace atomic_dex m_activation_clock = std::chrono::high_resolution_clock::now() - std::chrono::duration_cast(std::chrono::seconds(13)); } - void mm2_service::activate_coins(const t_coins& coins) + void kdf_service::activate_coins(const t_coins& coins) { t_coins other_coins; t_coins erc_family_coins; t_coins slp_coins; t_coins slp_testnet_coins; t_coins zhtlc_coins; - t_coins osmosis_coins; - t_coins iris_coins; - t_coins cosmos_coins; + t_coins tendermint_coins; t_coins bep20_coins; t_coins bep20_testnet_coins; @@ -567,23 +573,7 @@ namespace atomic_dex } else if (coin_cfg.coin_type == CoinType::TENDERMINT || coin_cfg.coin_type == CoinType::TENDERMINTTOKEN) { - if (coin_cfg.parent_coin == "ATOM") - { - cosmos_coins.push_back(coin_cfg); - } - else if (coin_cfg.parent_coin == "IRIS") - { - iris_coins.push_back(coin_cfg); - } - else if (coin_cfg.parent_coin == "OSMO") - { - osmosis_coins.push_back(coin_cfg); - } - else - { - SPDLOG_WARN("Unexpected Tendermint ticker: {}", coin_cfg.ticker); - SPDLOG_WARN("Parent coin: {}", coin_cfg.parent_coin); - } + tendermint_coins.push_back(coin_cfg); } else if (coin_cfg.coin_type == CoinType::ZHTLC) { @@ -639,41 +629,33 @@ namespace atomic_dex SPDLOG_INFO(">>>>>>>>>>>>>>>>>>>>>>>>>>> Enabling {} zhtlc_coins <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<", zhtlc_coins.size()); enable_zhtlc(zhtlc_coins); } - if (iris_coins.size() > 0) - { - SPDLOG_INFO(">>>>>>>>>>>>>>>>>>>>>>>>>>> Enabling {} iris_coins <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<", iris_coins.size()); - enable_tendermint_coins(iris_coins, "IRIS"); - } - if (cosmos_coins.size() > 0) + if (tendermint_coins.size() > 0) { - SPDLOG_INFO(">>>>>>>>>>>>>>>>>>>>>>>>>>> Enabling {} cosmos_coins <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<", cosmos_coins.size()); - enable_tendermint_coins(cosmos_coins, "ATOM"); - } - if (osmosis_coins.size() > 0) - { - SPDLOG_INFO(">>>>>>>>>>>>>>>>>>>>>>>>>>> Enabling {} osmosis_coins <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<", osmosis_coins.size()); - enable_tendermint_coins(osmosis_coins, "OSMO"); + SPDLOG_INFO(">>>>>>>>>>>>>>>>>>>>>>>>>>> Enabling {} tendermint_coins <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<", tendermint_coins.size()); + for (const auto& [parent_coin, coins_vector] : groupByParentCoin(tendermint_coins)) { + enable_tendermint_coins(coins_vector, parent_coin); + } } } - void mm2_service::update_coin_active(const std::vector& tickers, bool status) + void kdf_service::update_coin_active(const std::vector& tickers, bool status) { update_coin_status(this->m_current_wallet_name, tickers, status, m_coins_informations, m_coin_cfg_mutex); } - void mm2_service::enable_erc_family_coin(const coin_config_t& coin_cfg) + void kdf_service::enable_erc_family_coin(const coin_config_t& coin_cfg) { enable_erc_family_coins(t_coins{coin_cfg}); } - void mm2_service::enable_erc_family_coins(const t_coins& coins) + void kdf_service::enable_erc_family_coins(const t_coins& coins) { nlohmann::json batch_array = nlohmann::json::array(); auto callback = [this, coins](const web::http::http_response& resp) { try { - auto answers = mm2::basic_batch_answer(resp); + auto answers = kdf::basic_batch_answer(resp); if (answers.count("error") == 0) { @@ -728,7 +710,7 @@ namespace atomic_dex m_coins_informations[coin.ticker].currently_enabled = false; failed_tickers.push_back(coin.ticker); } - update_coin_active(failed_tickers, false); + //update_coin_active(failed_tickers, false); fetch_infos_thread(false, false); } } @@ -755,35 +737,35 @@ namespace atomic_dex } if (coin_config.is_custom_coin) { - request.mm2 = 1; + request.kdf = 1; } else if (coin_config.wallet_only) { - request.mm2 = 0; + request.kdf = 0; } - nlohmann::json j = mm2::template_request("enable"); - mm2::to_json(j, request); + nlohmann::json j = kdf::template_request("enable"); + kdf::to_json(j, request); batch_array.push_back(j); } - m_mm2_client.async_rpc_batch_standalone(batch_array) + m_kdf_client.async_rpc_batch_standalone(batch_array) .then(callback) .then([this, batch_array](pplx::task previous_task) { this->handle_exception_pplx_task(previous_task, "enable_common_coins", batch_array); }); } - void mm2_service::enable_utxo_qrc20_coin(coin_config_t coin_config) + void kdf_service::enable_utxo_qrc20_coin(coin_config_t coin_config) { enable_utxo_qrc20_coins(t_coins{std::move(coin_config)}); } - void mm2_service::enable_utxo_qrc20_coins(const t_coins& coins) + void kdf_service::enable_utxo_qrc20_coins(const t_coins& coins) { auto batch_array = nlohmann::json::array(); auto callback = [this, coins](const web::http::http_response& resp) { try { - auto answers = mm2::basic_batch_answer(resp); + auto answers = kdf::basic_batch_answer(resp); if (answers.count("error") == 0) { @@ -836,7 +818,7 @@ namespace atomic_dex m_coins_informations[coin.ticker].currently_enabled = false; failed_tickers.push_back(coin.ticker); } - update_coin_active(failed_tickers, false); + //update_coin_active(failed_tickers, false); fetch_infos_thread(false, false); } } @@ -848,21 +830,23 @@ namespace atomic_dex for (const auto& coin_config : coins) { - nlohmann::json j = mm2::template_request("electrum"); + nlohmann::json j = kdf::template_request("electrum"); t_electrum_request request { .coin_name = coin_config.ticker, .servers = coin_config.electrum_urls.value_or(get_electrum_server_from_token(coin_config.ticker)), .coin_type = coin_config.coin_type, .is_testnet = coin_config.is_testnet.value_or(false), - .with_tx_history = true + .with_tx_history = true, + .min_connected = 1, + .max_connected = 3 }; if (coin_config.merge_utxos.value_or(false)) { - mm2::utxo_merge_params_t merge_params{.merge_at = 250, .check_every = 300, .max_merge_at_once = 125}; + kdf::utxo_merge_params_t merge_params{.merge_at = 250, .check_every = 300, .max_merge_at_once = 125}; nlohmann::json json_merge_params; - mm2::to_json(json_merge_params, merge_params); + kdf::to_json(json_merge_params, merge_params); request.merge_params = json_merge_params; } if (coin_config.swap_contract_address.value_or("") != "") @@ -873,21 +857,21 @@ namespace atomic_dex { request.fallback_swap_contract = coin_config.fallback_swap_contract; } - mm2::to_json(j, request); + kdf::to_json(j, request); batch_array.push_back(j); } - m_mm2_client.async_rpc_batch_standalone(batch_array) + m_kdf_client.async_rpc_batch_standalone(batch_array) .then(callback) .then([this, batch_array](pplx::task previous_task) { this->handle_exception_pplx_task(previous_task, "enable_qrc_family_coins", batch_array); }); } - void mm2_service::enable_erc20_coin(coin_config_t coin_config, std::string parent_ticker) + void kdf_service::enable_erc20_coin(coin_config_t coin_config, std::string parent_ticker) { enable_erc20_coins(t_coins{std::move(coin_config)}, parent_ticker); } - void mm2_service::enable_erc20_coins(const t_coins& coins, const std::string parent_ticker) + void kdf_service::enable_erc20_coins(const t_coins& coins, const std::string parent_ticker) { auto callback = [this](RpcRequest rpc) { @@ -901,7 +885,7 @@ namespace atomic_dex std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; dispatcher_.trigger(coin_fully_initialized{.tickers = {rpc.request.ticker}}); - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { SPDLOG_ERROR("{} {}: ", rpc.request.ticker, rpc.error->error_type); @@ -924,7 +908,7 @@ namespace atomic_dex SPDLOG_ERROR("marking {} as inactive: {}", rpc.request.ticker, rpc.error->error_type); std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = false; - update_coin_active({rpc.request.ticker}, false); + //update_coin_active({rpc.request.ticker}, false); this->dispatcher_.trigger(rpc.request.ticker, rpc.error->error); } } @@ -935,7 +919,7 @@ namespace atomic_dex std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; SPDLOG_DEBUG("marking {} as active", rpc.request.ticker); - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { for (const auto& erc20_address_info : rpc.result->erc20_addresses_infos) { @@ -976,18 +960,18 @@ namespace atomic_dex for (const auto& token_config : coins) { // SPDLOG_DEBUG("Processing {} token: {}", parent_ticker, token_config.ticker); - mm2::enable_erc20_rpc rpc{.request={.ticker = token_config.ticker}}; + kdf::enable_erc20_rpc rpc{.request={.ticker = token_config.ticker}}; if (token_config.ticker == parent_ticker_info.ticker) { continue; } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } } else { - mm2::enable_eth_with_tokens_rpc rpc; + kdf::enable_eth_with_tokens_rpc rpc; rpc.request.ticker = parent_ticker_info.ticker; rpc.request.nodes = parent_ticker_info.urls.value_or(std::vector{}); rpc.request.swap_contract_address = parent_ticker_info.swap_contract_address.value_or(""); @@ -1003,17 +987,28 @@ namespace atomic_dex } rpc.request.erc20_tokens_requests.push_back({.ticker = coin_config.ticker}); } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } - SPDLOG_DEBUG("mm2_service::enable_erc20_coins done for {}", parent_ticker); + SPDLOG_DEBUG("kdf_service::enable_erc20_coins done for {}", parent_ticker); } - void mm2_service::enable_tendermint_coin(coin_config_t coin_config, std::string parent_ticker) + + std::map> + kdf_service::groupByParentCoin(const std::vector& coins) { + std::map> groupedCoins; + for (const auto& coin : coins) { + groupedCoins[coin.parent_coin].push_back(coin); + } + return groupedCoins; + } + + + void kdf_service::enable_tendermint_coin(coin_config_t coin_config) { - enable_tendermint_coins(t_coins{std::move(coin_config)}, parent_ticker); + enable_tendermint_coins(t_coins{std::move(coin_config)}, coin_config.parent_coin); } - void mm2_service::enable_tendermint_coins(const t_coins& coins, const std::string parent_ticker) + void kdf_service::enable_tendermint_coins(const t_coins& coins, const std::string parent_ticker) { auto callback = [this](RpcRequest rpc) { @@ -1027,23 +1022,23 @@ namespace atomic_dex std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; dispatcher_.trigger(coin_fully_initialized{.tickers = {rpc.request.ticker}}); - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { for (const auto& tendermint_coin_info : rpc.request.tokens_params) { - SPDLOG_ERROR("{} {}: ", tendermint_coin_info.ticker, rpc.error->error_type); - fetch_single_balance(get_coin_info(tendermint_coin_info.ticker)); std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[tendermint_coin_info.ticker].currently_enabled = true; + fetch_single_balance(get_coin_info(tendermint_coin_info.ticker)); dispatcher_.trigger(coin_fully_initialized{.tickers = {tendermint_coin_info.ticker}}); } } } else { + SPDLOG_DEBUG("{} failed to activate", rpc.request.ticker); std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = false; - update_coin_active({rpc.request.ticker}, false); + //update_coin_active({rpc.request.ticker}, false); this->dispatcher_.trigger(rpc.request.ticker, rpc.error->error); } } @@ -1053,17 +1048,14 @@ namespace atomic_dex fetch_single_balance(get_coin_info(rpc.request.ticker)); std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { for (const auto& tendermint_token_addresses_info : rpc.result->tendermint_token_balances_infos) { dispatcher_.trigger(coin_fully_initialized{.tickers = {tendermint_token_addresses_info.first}}); - process_balance_answer(rpc); - std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[tendermint_token_addresses_info.first].currently_enabled = true; } } - process_balance_answer(rpc); } }; @@ -1081,21 +1073,21 @@ namespace atomic_dex { for (const auto& coin_config : coins) { - mm2::enable_tendermint_token_rpc rpc{.request={.ticker = coin_config.ticker}}; + kdf::enable_tendermint_token_rpc rpc{.request={.ticker = coin_config.ticker}}; if (coin_config.ticker == parent_ticker_info.ticker) { continue; } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } } else { - mm2::enable_tendermint_with_assets_rpc rpc; + kdf::enable_tendermint_with_assets_rpc rpc; rpc.request.ticker = parent_ticker_info.ticker; - rpc.request.rpc_urls = parent_ticker_info.rpc_urls.value_or(std::vector{}); + rpc.request.nodes = parent_ticker_info.rpc_urls.value_or(std::vector{}); for (const auto& coin_config : coins) { if (coin_config.ticker == parent_ticker_info.ticker) @@ -1104,14 +1096,14 @@ namespace atomic_dex } rpc.request.tokens_params.push_back({.ticker = coin_config.ticker}); } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } } - void mm2_service::process_balance_answer(const mm2::enable_erc20_rpc& rpc) + void kdf_service::process_balance_answer(const kdf::enable_erc20_rpc& rpc) { const auto& answer = rpc.result.value(); - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; balance_answer.address = answer.balances.begin()->first; SPDLOG_DEBUG("balance_answer.address: {}", balance_answer.address); @@ -1126,12 +1118,12 @@ namespace atomic_dex SPDLOG_DEBUG("balance_answer for {} complete", rpc.request.ticker); } - void mm2_service::process_balance_answer(const mm2::enable_eth_with_tokens_rpc& rpc) + void kdf_service::process_balance_answer(const kdf::enable_eth_with_tokens_rpc& rpc) { - SPDLOG_DEBUG("mm2_service::process_balance_answer(const mm2::enable_eth_with_tokens_rpc& rpc"); + SPDLOG_DEBUG("kdf_service::process_balance_answer(const kdf::enable_eth_with_tokens_rpc& rpc"); const auto& answer = rpc.result.value(); { - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; balance_answer.coin = rpc.request.ticker; SPDLOG_DEBUG("balance_answer.coin: {}", balance_answer.coin); balance_answer.balance = answer.eth_addresses_infos.begin()->second.balances.spendable; @@ -1153,7 +1145,7 @@ namespace atomic_dex for (auto [address, data] : answer.erc20_addresses_infos) { SPDLOG_DEBUG("for (auto [address, data] : answer.erc20_addresses_infos) address [{}]", address); - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; balance_answer.address = address; if (data.balances.empty()) { @@ -1172,11 +1164,10 @@ namespace atomic_dex SPDLOG_DEBUG("process_balance_answer for enable_eth_with_tokens_rpc complete"); } - void mm2_service::process_balance_answer(const mm2::enable_tendermint_token_rpc& rpc) + void kdf_service::process_balance_answer(const kdf::enable_tendermint_token_rpc& rpc) { const auto& answer = rpc.result.value(); - mm2::balance_answer balance_answer; - + kdf::balance_answer balance_answer; balance_answer.address = answer.balances.begin()->first; balance_answer.balance = answer.balances.begin()->second.spendable; balance_answer.coin = answer.platform_coin; @@ -1187,13 +1178,13 @@ namespace atomic_dex } } - void mm2_service::process_balance_answer(const mm2::enable_tendermint_with_assets_rpc& rpc) + void kdf_service::process_balance_answer(const kdf::enable_tendermint_with_assets_rpc& rpc) { const auto& answer = rpc.result.value(); { - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; - balance_answer.coin = rpc.request.ticker; + balance_answer.coin = answer.ticker; balance_answer.balance = answer.tendermint_balances_infos.balances.spendable; balance_answer.address = answer.address; { @@ -1207,7 +1198,7 @@ namespace atomic_dex } for (auto [ticker, data] : answer.tendermint_token_balances_infos) { - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; balance_answer.coin = ticker; balance_answer.address = answer.address; @@ -1220,12 +1211,12 @@ namespace atomic_dex } } - void mm2_service::enable_slp_coin(coin_config_t coin_config) + void kdf_service::enable_slp_coin(coin_config_t coin_config) { enable_slp_coins(t_coins{std::move(coin_config)}); } - void mm2_service::enable_slp_coins(const t_coins& coins) + void kdf_service::enable_slp_coins(const t_coins& coins) { constexpr auto bch_ticker = "BCH"; auto callback = [this](RpcRequest rpc) @@ -1239,7 +1230,7 @@ namespace atomic_dex std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; dispatcher_.trigger(coin_fully_initialized{.tickers = {rpc.request.ticker}}); - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { for (const auto& slp_coin_info : rpc.request.slp_tokens_requests) { @@ -1255,7 +1246,7 @@ namespace atomic_dex { std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = false; - update_coin_active({rpc.request.ticker}, false); + //update_coin_active({rpc.request.ticker}, false); this->dispatcher_.trigger(rpc.request.ticker, rpc.error->error); } } @@ -1265,7 +1256,7 @@ namespace atomic_dex fetch_single_balance(get_coin_info(rpc.request.ticker)); std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { for (const auto& slp_address_info : rpc.result->slp_addresses_infos) { @@ -1297,18 +1288,18 @@ namespace atomic_dex { for (const auto& coin_config : coins) { - mm2::enable_slp_rpc rpc{.request={.ticker = coin_config.ticker}}; + kdf::enable_slp_rpc rpc{.request={.ticker = coin_config.ticker}}; if (coin_config.ticker == bch_info.ticker) { continue; } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } } else { - mm2::enable_bch_with_tokens_rpc rpc; + kdf::enable_bch_with_tokens_rpc rpc; rpc.request.ticker = bch_info.ticker; rpc.request.allow_slp_unsafe_conf = bch_info.allow_slp_unsafe_conf.has_value() && bch_info.allow_slp_unsafe_conf.value(); @@ -1322,17 +1313,17 @@ namespace atomic_dex } rpc.request.slp_tokens_requests.push_back({.ticker = coin_config.ticker}); } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } } - void mm2_service::enable_slp_testnet_coin(coin_config_t coin_config) + void kdf_service::enable_slp_testnet_coin(coin_config_t coin_config) { enable_slp_testnet_coins(t_coins{std::move(coin_config)}); } - void mm2_service::enable_slp_testnet_coins(const t_coins& coins) + void kdf_service::enable_slp_testnet_coins(const t_coins& coins) { constexpr auto bch_ticker = "tBCH"; auto callback = [this](RpcRequest rpc) @@ -1346,7 +1337,7 @@ namespace atomic_dex std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; dispatcher_.trigger(coin_fully_initialized{.tickers = {rpc.request.ticker}}); - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { for (const auto& slp_coin_info : rpc.request.slp_tokens_requests) { @@ -1362,7 +1353,7 @@ namespace atomic_dex { std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = false; - update_coin_active({rpc.request.ticker}, false); + //update_coin_active({rpc.request.ticker}, false); this->dispatcher_.trigger(rpc.request.ticker, rpc.error->error); } } @@ -1372,7 +1363,7 @@ namespace atomic_dex fetch_single_balance(get_coin_info(rpc.request.ticker)); std::unique_lock lock(m_coin_cfg_mutex); m_coins_informations[rpc.request.ticker].currently_enabled = true; - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { for (const auto& slp_address_info : rpc.result->slp_addresses_infos) { @@ -1404,18 +1395,18 @@ namespace atomic_dex { for (const auto& coin_config : coins) { - mm2::enable_slp_rpc rpc{.request={.ticker = coin_config.ticker}}; + kdf::enable_slp_rpc rpc{.request={.ticker = coin_config.ticker}}; if (coin_config.ticker == bch_info.ticker) { continue; } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } } else { - mm2::enable_bch_with_tokens_rpc rpc; + kdf::enable_bch_with_tokens_rpc rpc; rpc.request.ticker = bch_info.ticker; rpc.request.allow_slp_unsafe_conf = bch_info.allow_slp_unsafe_conf.has_value() && bch_info.allow_slp_unsafe_conf.value(); @@ -1429,14 +1420,14 @@ namespace atomic_dex } rpc.request.slp_tokens_requests.push_back({.ticker = coin_config.ticker}); } - m_mm2_client.process_rpc_async(rpc.request, callback); + m_kdf_client.process_rpc_async(rpc.request, callback); } } - void mm2_service::process_balance_answer(const mm2::enable_slp_rpc& rpc) + void kdf_service::process_balance_answer(const kdf::enable_slp_rpc& rpc) { const auto& answer = rpc.result.value(); - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; balance_answer.address = answer.balances.begin()->first; balance_answer.balance = answer.balances.begin()->second.spendable; @@ -1448,11 +1439,11 @@ namespace atomic_dex } } - void mm2_service::process_balance_answer(const mm2::enable_bch_with_tokens_rpc& rpc) + void kdf_service::process_balance_answer(const kdf::enable_bch_with_tokens_rpc& rpc) { const auto& answer = rpc.result.value(); { - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; balance_answer.coin = rpc.request.ticker; balance_answer.balance = answer.bch_addresses_infos.begin()->second.balances.spendable; @@ -1469,7 +1460,7 @@ namespace atomic_dex continue; } - mm2::balance_answer balance_answer; + kdf::balance_answer balance_answer; balance_answer.coin = data.balances.begin()->first; balance_answer.address = address; @@ -1483,7 +1474,7 @@ namespace atomic_dex } void - mm2_service::disable_multiple_coins(const std::vector& tickers) + kdf_service::disable_multiple_coins(const std::vector& tickers) { for (const auto& ticker: tickers) { @@ -1499,29 +1490,37 @@ namespace atomic_dex } auto - mm2_service::batch_balance_and_tx(bool is_a_reset, std::vector tickers, bool is_during_enabling, bool only_tx) + kdf_service::batch_balance_and_tx(bool is_a_reset, std::vector tickers, bool is_during_enabling, bool only_tx) { (void)tickers; (void)is_during_enabling; auto&& [batch_array, tickers_idx, tokens_to_fetch] = prepare_batch_balance_and_tx(only_tx); - SPDLOG_DEBUG("mm2_service::batch_balance_and_tx"); - return m_mm2_client.async_rpc_batch_standalone(batch_array) + SPDLOG_DEBUG("kdf_service::batch_balance_and_tx"); + return m_kdf_client.async_rpc_batch_standalone(batch_array) .then( [this, tokens_to_fetch = tokens_to_fetch, is_a_reset, tickers, batch_array = batch_array](web::http::http_response resp) { try { - auto answers = mm2::basic_batch_answer(resp); + auto answers = kdf::basic_batch_answer(resp); if (not answers.contains("error")) { for (auto i = 0ul; i < answers.size(); i++) { auto& answer = answers[i]; std::string ticker; + // SPDLOG_DEBUG("batch_balance_and_tx answer: {}", answer.dump(4)); if (batch_array[i].contains("mmrpc") && batch_array[i].at("mmrpc") == "2.0") { - ticker = batch_array[i].at("params").at("coin"); + if (batch_array[i].at("params").contains("coin")) + { + ticker = batch_array[i].at("params").at("coin"); + } + else if (batch_array[i].at("params").contains("ticker")) + { + ticker = batch_array[i].at("params").at("ticker"); + } } else { @@ -1563,9 +1562,9 @@ namespace atomic_dex } std::tuple, std::vector> - mm2_service::prepare_batch_balance_and_tx(bool only_tx) const + kdf_service::prepare_batch_balance_and_tx(bool only_tx) const { - SPDLOG_DEBUG("mm2_service::prepare_batch_balance_and_tx"); + SPDLOG_DEBUG("kdf_service::prepare_batch_balance_and_tx"); const auto& enabled_coins = get_enabled_coins(); nlohmann::json batch_array = nlohmann::json::array(); std::vector tickers_idx; @@ -1600,8 +1599,8 @@ namespace atomic_dex } } t_tx_history_request request{.coin = ticker, .limit = limit}; - nlohmann::json j = mm2::template_request(method, requires_v2); - mm2::to_json(j, request); + nlohmann::json j = kdf::template_request(method, requires_v2); + kdf::to_json(j, request); batch_array.push_back(j); } @@ -1630,8 +1629,8 @@ namespace atomic_dex } SPDLOG_WARN("Getting balance for {} ", coin.ticker); t_balance_request balance_request{.coin = coin.ticker}; - nlohmann::json j = mm2::template_request("my_balance"); - mm2::to_json(j, balance_request); + nlohmann::json j = kdf::template_request("my_balance"); + kdf::to_json(j, balance_request); batch_array.push_back(j); tickers_idx.push_back(coin.ticker); } @@ -1640,7 +1639,7 @@ namespace atomic_dex } std::pair - mm2_service::process_batch_enable_answer(const json& answer) + kdf_service::process_batch_enable_answer(const json& answer) { std::string error = answer.dump(4); std::string data = answer.dump(); @@ -1673,7 +1672,7 @@ namespace atomic_dex return {false, error}; } - void mm2_service::enable_zhtlc(const t_coins& coins) + void kdf_service::enable_zhtlc(const t_coins& coins) { auto request_functor = [this](coin_config_t coin_info) -> std::pair> { @@ -1699,8 +1698,8 @@ namespace atomic_dex request.sync_height = sync_height; } - nlohmann::json j = mm2::template_request("task::enable_z_coin::init", true); - mm2::to_json(j, request); + nlohmann::json j = kdf::template_request("task::enable_z_coin::init", true); + kdf::to_json(j, request); nlohmann::json batch = nlohmann::json::array(); batch.push_back(j); // SPDLOG_INFO("ZHTLC request: {}", batch.dump(4)); @@ -1710,13 +1709,13 @@ namespace atomic_dex auto answer_functor = [this](nlohmann::json batch, std::vector tickers) { - m_mm2_client.async_rpc_batch_standalone(batch) + m_kdf_client.async_rpc_batch_standalone(batch) .then( [this, tickers](web::http::http_response resp) mutable { try { - auto answers = mm2::basic_batch_answer(resp); + auto answers = kdf::basic_batch_answer(resp); auto& settings_system = m_system_manager.get_system(); if (answers.count("error") == 0) @@ -1763,16 +1762,16 @@ namespace atomic_dex // SPDLOG_INFO("{} enable_z_coin Task ID: {}", tickers[idx], task_id); - nlohmann::json j = mm2::template_request("task::enable_z_coin::status", true); - mm2::to_json(j, z_request); + nlohmann::json j = kdf::template_request("task::enable_z_coin::status", true); + kdf::to_json(j, z_request); z_batch_array.push_back(j); std::string last_event = "none"; std::string event = "none"; do { - pplx::task z_resp_task = m_mm2_client.async_rpc_batch_standalone(z_batch_array); + pplx::task z_resp_task = m_kdf_client.async_rpc_batch_standalone(z_batch_array); web::http::http_response z_resp = z_resp_task.get(); - auto z_answers = mm2::basic_batch_answer(z_resp); + auto z_answers = kdf::basic_batch_answer(z_resp); z_error = z_answers; std::string status = z_answers[0].at("result").at("status").get(); @@ -1950,7 +1949,7 @@ namespace atomic_dex } } - nlohmann::json mm2_service::get_zhtlc_status(const std::string coin) const + nlohmann::json kdf_service::get_zhtlc_status(const std::string coin) const { const auto coin_info = get_coin_info(coin); if (coin_info.is_zhtlc_family) @@ -1960,7 +1959,7 @@ namespace atomic_dex return {}; } - bool mm2_service::is_zhtlc_coin_ready(const std::string coin) const + bool kdf_service::is_zhtlc_coin_ready(const std::string coin) const { const auto coin_info = get_coin_info(coin); if (coin_info.is_zhtlc_family) @@ -1987,7 +1986,7 @@ namespace atomic_dex return true; } - coin_config_t mm2_service::get_coin_info(const std::string& ticker) const + coin_config_t kdf_service::get_coin_info(const std::string& ticker) const { std::shared_lock lock(m_coin_cfg_mutex); if (m_coins_informations.find(ticker) == m_coins_informations.cend()) @@ -1997,18 +1996,18 @@ namespace atomic_dex return m_coins_informations.at(ticker); } - bool mm2_service::is_coin_enabled(const std::string& ticker) const + bool kdf_service::is_coin_enabled(const std::string& ticker) const { return m_coins_informations[ticker].currently_enabled; } - bool mm2_service::has_coin(const std::string& ticker) const + bool kdf_service::has_coin(const std::string& ticker) const { return m_coins_informations.contains(ticker); } // [smk] Only called by trading_page::process_action() - mm2::orderbook_result_rpc mm2_service::get_orderbook(t_mm2_ec& ec) const + kdf::orderbook_result_rpc kdf_service::get_orderbook(t_kdf_ec& ec) const { auto&& [base, rel] = this->m_synchronized_ticker_pair.get(); const std::string pair = base + "/" + rel; @@ -2032,19 +2031,19 @@ namespace atomic_dex nlohmann::json generate_req(std::string request_name, auto request, bool is_v2=false) { - nlohmann::json current_request = mm2::template_request(std::move(request_name), is_v2); - mm2::to_json(current_request, request); + nlohmann::json current_request = kdf::template_request(std::move(request_name), is_v2); + kdf::to_json(current_request, request); return current_request; } - void mm2_service::process_orderbook(bool is_a_reset) + void kdf_service::process_orderbook(bool is_a_reset) { prepare_orderbook(is_a_reset); } - void mm2_service::prepare_orderbook(bool is_a_reset) + void kdf_service::prepare_orderbook(bool is_a_reset) { auto callback = [this, is_a_reset](RpcRequest rpc) { @@ -2059,8 +2058,8 @@ namespace atomic_dex { nlohmann::json batch = nlohmann::json::array(); auto&& [base, rel] = m_synchronized_ticker_pair.get(); - batch.push_back(generate_req("max_taker_vol", mm2::max_taker_vol_request{.coin = base})); - batch.push_back(generate_req("max_taker_vol", mm2::max_taker_vol_request{.coin = rel})); + batch.push_back(generate_req("max_taker_vol", kdf::max_taker_vol_request{.coin = base})); + batch.push_back(generate_req("max_taker_vol", kdf::max_taker_vol_request{.coin = rel})); batch.push_back(generate_req("min_trading_vol", t_min_volume_request{.coin = base})); batch.push_back(generate_req("min_trading_vol", t_min_volume_request{.coin = rel})); process_orderbook_extras(batch, is_a_reset); @@ -2078,11 +2077,11 @@ namespace atomic_dex if (rel.empty() || base.empty() || base_ticker == rel_ticker) SPDLOG_ERROR("Invalid ticker pair while requesting orderbook: {} {}", base, rel); - mm2::orderbook_rpc rpc{.request={.base = base, .rel = rel}}; - m_mm2_client.process_rpc_async(rpc.request, callback); + kdf::orderbook_rpc rpc{.request={.base = base, .rel = rel}}; + m_kdf_client.process_rpc_async(rpc.request, callback); } - void mm2_service::process_orderbook_extras(nlohmann::json batch, bool is_a_reset) + void kdf_service::process_orderbook_extras(nlohmann::json batch, bool is_a_reset) { if (batch.empty()) { @@ -2092,7 +2091,7 @@ namespace atomic_dex auto answer_functor = [this, is_a_reset](web::http::http_response resp) { - auto answer = mm2::basic_batch_answer(resp); + auto answer = kdf::basic_batch_answer(resp); if (answer.is_array()) { if (answer.size() < 1) @@ -2110,7 +2109,7 @@ namespace atomic_dex } auto&& [base, rel] = m_synchronized_ticker_pair.get(); - auto base_max_taker_vol_answer = mm2::rpc_process_answer_batch(answer[0], "max_taker_vol"); + auto base_max_taker_vol_answer = kdf::rpc_process_answer_batch(answer[0], "max_taker_vol"); if (base_max_taker_vol_answer.rpc_result_code == 200) { if (base == base_max_taker_vol_answer.result->coin) @@ -2119,7 +2118,7 @@ namespace atomic_dex } } - auto rel_max_taker_vol_answer = mm2::rpc_process_answer_batch(answer[1], "max_taker_vol"); + auto rel_max_taker_vol_answer = kdf::rpc_process_answer_batch(answer[1], "max_taker_vol"); if (rel_max_taker_vol_answer.rpc_result_code == 200) { if (rel == rel_max_taker_vol_answer.result->coin) @@ -2128,14 +2127,14 @@ namespace atomic_dex } } - auto base_min_taker_vol_answer = mm2::rpc_process_answer_batch(answer[2], "min_trading_vol"); + auto base_min_taker_vol_answer = kdf::rpc_process_answer_batch(answer[2], "min_trading_vol"); if (base_min_taker_vol_answer.rpc_result_code == 200) { m_synchronized_min_taker_vol->first = base_min_taker_vol_answer.result.value(); } - auto rel_min_taker_vol_answer = mm2::rpc_process_answer_batch(answer[3], "min_trading_vol"); + auto rel_min_taker_vol_answer = kdf::rpc_process_answer_batch(answer[3], "min_trading_vol"); if (rel_min_taker_vol_answer.rpc_result_code == 200) { m_synchronized_min_taker_vol->second = rel_min_taker_vol_answer.result.value(); @@ -2143,12 +2142,12 @@ namespace atomic_dex } } }; - m_mm2_client.async_rpc_batch_standalone(batch) + m_kdf_client.async_rpc_batch_standalone(batch) .then(answer_functor) .then([this, batch](pplx::task previous_task) { this->handle_exception_pplx_task(previous_task, "process_orderbook_extras", batch); }); } - void mm2_service::fetch_current_orderbook_thread(bool is_a_reset) + void kdf_service::fetch_current_orderbook_thread(bool is_a_reset) { //! If thread is not active ex: we are not on the trading page anymore, we continue sleeping. if (!m_orderbook_thread_active) @@ -2158,7 +2157,7 @@ namespace atomic_dex process_orderbook(is_a_reset); } - void mm2_service::fetch_single_balance(const coin_config_t& cfg_infos) + void kdf_service::fetch_single_balance(const coin_config_t& cfg_infos) { nlohmann::json batch_array = nlohmann::json::array(); if (is_pin_cfg_enabled()) @@ -2172,16 +2171,16 @@ namespace atomic_dex } t_balance_request balance_request{.coin = cfg_infos.ticker}; - // SPDLOG_DEBUG("Getting balance from mm2 for {} ", cfg_infos.ticker); - nlohmann::json j = mm2::template_request("my_balance"); - mm2::to_json(j, balance_request); + // SPDLOG_DEBUG("Getting balance from kdf for {} ", cfg_infos.ticker); + nlohmann::json j = kdf::template_request("my_balance"); + kdf::to_json(j, balance_request); batch_array.push_back(j); auto answer_functor = [this](web::http::http_response resp) { try { - auto answers = mm2::basic_batch_answer(resp); + auto answers = kdf::basic_batch_answer(resp); if (!answers.contains("error") && !answers[0].contains("error")) { this->process_balance_answer(answers[0]); @@ -2195,11 +2194,11 @@ namespace atomic_dex auto error_functor = [this, batch = batch_array](pplx::task previous_task) { this->handle_exception_pplx_task(previous_task, "fetch_single_balance", batch); }; - m_mm2_client.async_rpc_batch_standalone(batch_array).then(answer_functor).then(error_functor); + m_kdf_client.async_rpc_batch_standalone(batch_array).then(answer_functor).then(error_functor); } void - mm2_service::fetch_infos_thread(bool is_a_refresh, bool only_tx) + kdf_service::fetch_infos_thread(bool is_a_refresh, bool only_tx) { if (only_tx) { @@ -2214,7 +2213,7 @@ namespace atomic_dex } } - void mm2_service::spawn_mm2_instance(std::string wallet_name, std::string passphrase, bool with_pin_cfg, std::string rpcpass) + void kdf_service::spawn_kdf_instance(std::string wallet_name, std::string passphrase, bool with_pin_cfg, std::string rpcpass) { this->m_balance_factor = utils::determine_balance_factor(with_pin_cfg); SPDLOG_DEBUG("balance factor is: {}", m_balance_factor); @@ -2223,73 +2222,84 @@ namespace atomic_dex this->dispatcher_.trigger(this->retrieve_coins_informations()); this->dispatcher_.trigger(); this->dispatcher_.trigger(); - mm2_config cfg{ + kdf_config cfg{ .passphrase = std::move(passphrase), .rpc_password = std::move(rpcpass) == "" ? std::move(atomic_dex::gen_random_password()) : std::move(rpcpass) }; - mm2::set_system_manager(m_system_manager); - mm2::set_rpc_password(cfg.rpc_password); + + auto dbdir_parent = std::filesystem::path(utils::get_atomic_dex_data_folder() / "kdf"); + auto old_dbdir_parent = std::filesystem::path(utils::get_atomic_dex_data_folder() / "mm2"); + if (not std::filesystem::exists(dbdir_parent)) + { + if (std::filesystem::exists(old_dbdir_parent)) + { + std::filesystem::rename(old_dbdir_parent, dbdir_parent); + } + } + + kdf::set_system_manager(m_system_manager); + kdf::set_rpc_password(cfg.rpc_password); json json_cfg; - const auto tools_path = ag::core::assets_real_path() / "tools/mm2/"; + const auto tools_path = ag::core::assets_real_path() / "tools/kdf/"; nlohmann::to_json(json_cfg, cfg); - std::filesystem::path mm2_cfg_path = (std::filesystem::temp_directory_path() / "MM2.json"); + std::filesystem::path kdf_cfg_path = (std::filesystem::temp_directory_path() / "KDF.json"); QFile ofs; - ofs.setFileName(std_path_to_qstring(mm2_cfg_path)); + ofs.setFileName(std_path_to_qstring(kdf_cfg_path)); ofs.open(QIODevice::WriteOnly | QIODevice::Text); ofs.write(QString::fromStdString(json_cfg.dump()).toUtf8()); ofs.close(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - env.insert("MM_CONF_PATH", std_path_to_qstring(mm2_cfg_path)); - env.insert("MM_LOG", std_path_to_qstring(utils::get_mm2_atomic_dex_current_log_file())); + env.insert("MM_CONF_PATH", std_path_to_qstring(kdf_cfg_path)); + env.insert("MM_LOG", std_path_to_qstring(utils::get_kdf_atomic_dex_current_log_file())); env.insert("MM_COINS_PATH", std_path_to_qstring((utils::get_current_configs_path() / "coins.json"))); - QProcess mm2_instance; - mm2_instance.setProgram(std_path_to_qstring((tools_path / atomic_dex::g_dex_api))); - mm2_instance.setWorkingDirectory(std_path_to_qstring(tools_path)); - mm2_instance.setProcessEnvironment(env); - bool started = mm2_instance.startDetached(); + QProcess kdf_instance; + kdf_instance.setProgram(std_path_to_qstring((tools_path / atomic_dex::g_dex_api))); + kdf_instance.setWorkingDirectory(std_path_to_qstring(tools_path)); + kdf_instance.setProcessEnvironment(env); + bool started = kdf_instance.startDetached(); if (!started) { - SPDLOG_ERROR("Couldn't start mm2"); + SPDLOG_ERROR("Couldn't start kdf"); std::exit(EXIT_FAILURE); } - m_mm2_init_thread = std::thread( - [this, mm2_cfg_path]() + m_kdf_init_thread = std::thread( + [this, kdf_cfg_path]() { // std::this_thread:: using namespace std::chrono_literals; - auto check_mm2_alive = []() { return mm2::rpc_version() != "error occured during rpc_version"; }; + auto check_kdf_alive = []() { return kdf::rpc_version() != "error occured during rpc_version"; }; static std::size_t nb_try = 0; - while (not check_mm2_alive()) + while (not check_kdf_alive()) { nb_try += 1; if (nb_try == 30) { - SPDLOG_ERROR("MM2 not started correctly"); - //! TODO: emit mm2_failed_initialization - std::filesystem::remove(mm2_cfg_path); + SPDLOG_ERROR("KDF not started correctly"); + //! TODO: emit kdf_failed_initialization + std::filesystem::remove(kdf_cfg_path); return; } std::this_thread::sleep_for(1s); } - // m_mm2_client.connect_client(); - std::filesystem::remove(mm2_cfg_path); - SPDLOG_INFO("mm2 is initialized"); - dispatcher_.trigger(); + // m_kdf_client.connect_client(); + std::filesystem::remove(kdf_cfg_path); + SPDLOG_INFO("kdf is initialized"); + dispatcher_.trigger(); enable_default_coins(); - m_mm2_running = true; - dispatcher_.trigger(); + m_kdf_running = true; + dispatcher_.trigger(); }); } std::pair - mm2_service::get_tx(t_mm2_ec& ec) const + kdf_service::get_tx(t_kdf_ec& ec) const { const auto& ticker = get_current_ticker(); // SPDLOG_DEBUG("asking history of ticker: {}", ticker); @@ -2305,19 +2315,19 @@ namespace atomic_dex } t_tx_state - mm2_service::get_tx_state(t_mm2_ec& ec) const + kdf_service::get_tx_state(t_kdf_ec& ec) const { return get_tx(ec).second; } t_transactions - mm2_service::get_tx_history(t_mm2_ec& ec) const + kdf_service::get_tx_history(t_kdf_ec& ec) const { return get_tx(ec).first; } t_float_50 - mm2_service::get_balance_info_f(const std::string& ticker) const + kdf_service::get_balance_info_f(const std::string& ticker) const { std::error_code ec; std::string balance_str = get_balance_info(ticker, ec); @@ -2327,7 +2337,7 @@ namespace atomic_dex } std::string - mm2_service::get_balance_info(const std::string& ticker, t_mm2_ec& ec) const + kdf_service::get_balance_info(const std::string& ticker, t_kdf_ec& ec) const { // This happens quite often std::shared_lock lock(m_balance_mutex); ///! read @@ -2360,10 +2370,10 @@ namespace atomic_dex } void - mm2_service::batch_fetch_orders_and_swap(bool after_manual_reset) + kdf_service::batch_fetch_orders_and_swap(bool after_manual_reset) { nlohmann::json batch = nlohmann::json::array(); - nlohmann::json my_orders_request = mm2::template_request("my_orders"); + nlohmann::json my_orders_request = kdf::template_request("my_orders"); batch.push_back(my_orders_request); // SPDLOG_DEBUG("my_orders_request {}", my_orders_request.dump(4)); @@ -2384,7 +2394,7 @@ namespace atomic_dex } //! First time fetch or current page - nlohmann::json my_swaps = mm2::template_request("my_recent_swaps"); + nlohmann::json my_swaps = kdf::template_request("my_recent_swaps"); t_my_recent_swaps_request request{ .limit = limit, .page_number = current_page, @@ -2398,7 +2408,7 @@ namespace atomic_dex // SPDLOG_INFO("my_swaps req: {}", my_swaps.dump(4)); //! Active swaps - nlohmann::json active_swaps = mm2::template_request("active_swaps"); + nlohmann::json active_swaps = kdf::template_request("active_swaps"); t_active_swaps_request active_swaps_request{.statuses = true}; to_json(active_swaps, active_swaps_request); batch.push_back(active_swaps); @@ -2410,12 +2420,12 @@ namespace atomic_dex //! Parsing Resp orders_and_swaps result; - auto answers = mm2::basic_batch_answer(resp); + auto answers = kdf::basic_batch_answer(resp); //! Extract - const auto orders_answers = mm2::rpc_process_answer_batch(answers[0], "my_orders"); - const auto swap_answer = mm2::rpc_process_answer_batch(answers[1], "my_recent_swaps"); - const auto active_swaps_answer = mm2::rpc_process_answer_batch(answers[2], "active_swaps"); + const auto orders_answers = kdf::rpc_process_answer_batch(answers[0], "my_orders"); + const auto swap_answer = kdf::rpc_process_answer_batch(answers[1], "my_recent_swaps"); + const auto active_swaps_answer = kdf::rpc_process_answer_batch(answers[2], "active_swaps"); result.orders_and_swaps.reserve(orders_answers.orders.size() + limit); result.nb_orders = orders_answers.orders.size(); @@ -2471,12 +2481,12 @@ namespace atomic_dex }; // SPDLOG_INFO("batch request:{}", batch.dump(4)); - m_mm2_client.async_rpc_batch_standalone(batch) + m_kdf_client.async_rpc_batch_standalone(batch) .then(answer_functor) .then([this, batch](pplx::task previous_task) { this->handle_exception_pplx_task(previous_task, "batch_fetch_orders_and_swap", batch); }); } - void mm2_service::process_tx_tokenscan(const std::string& ticker, [[maybe_unused]] bool is_a_refresh) + void kdf_service::process_tx_tokenscan(const std::string& ticker, [[maybe_unused]] bool is_a_refresh) { SPDLOG_DEBUG("Process transactions of ticker: {}", ticker); std::error_code ec; @@ -2492,7 +2502,7 @@ namespace atomic_dex } else { - const std::string contract_address = get_raw_mm2_ticker_cfg(ticker).at("protocol").at("protocol_data").at("contract_address"); + const std::string contract_address = get_raw_kdf_ticker_cfg(ticker).at("protocol").at("protocol_data").at("contract_address"); out = "/api/v2/" + token_url + "/" + contract_address + "/" + address; } return out; @@ -2550,11 +2560,11 @@ namespace atomic_dex }; std::string url = retrieve_api_functor(ticker, address(ticker, ec)); SPDLOG_INFO("url scan: {}", url); - mm2::async_process_rpc_get(mm2::g_etherscan_proxy_http_client, "tx_history", url) + kdf::async_process_rpc_get(kdf::g_etherscan_proxy_http_client, "tx_history", url) .then( [this, ticker](const web::http::http_response& resp) { - auto answer = m_mm2_client.rpc_process_answer(resp, "tx_history"); + auto answer = m_kdf_client.rpc_process_answer(resp, "tx_history"); if (answer.rpc_result_code != 200) { @@ -2628,19 +2638,19 @@ namespace atomic_dex } void - mm2_service::update_sync_ticker_pair(std::string base, std::string rel) + kdf_service::update_sync_ticker_pair(std::string base, std::string rel) { // SPDLOG_DEBUG("update_sync_ticker_pair: [{} / {}]", base, rel); this->m_synchronized_ticker_pair = std::make_pair(base, rel); } void - mm2_service::on_refresh_orderbook_model_data(const refresh_orderbook_model_data& evt) + kdf_service::on_refresh_orderbook_model_data(const refresh_orderbook_model_data& evt) { // SPDLOG_DEBUG("refreshing orderbook pair: [{} / {}]", evt.base, evt.rel); this->m_synchronized_ticker_pair = std::make_pair(evt.base, evt.rel); - if (this->m_mm2_running) + if (this->m_kdf_running) { // SPDLOG_DEBUG("process_orderbook(true)"); process_orderbook(true); @@ -2648,7 +2658,7 @@ namespace atomic_dex } void - mm2_service::on_gui_enter_trading([[maybe_unused]] const gui_enter_trading& evt) + kdf_service::on_gui_enter_trading([[maybe_unused]] const gui_enter_trading& evt) { SPDLOG_DEBUG("{} l{} f[{}]", __FUNCTION__, __LINE__, std::filesystem::path(__FILE__).filename().string()); @@ -2656,14 +2666,14 @@ namespace atomic_dex } void - mm2_service::on_gui_leave_trading([[maybe_unused]] const gui_leave_trading& evt) + kdf_service::on_gui_leave_trading([[maybe_unused]] const gui_leave_trading& evt) { SPDLOG_DEBUG("{} l{} f[{}]", __FUNCTION__, __LINE__, std::filesystem::path(__FILE__).filename().string()); m_orderbook_thread_active = false; } bool - mm2_service::do_i_have_enough_funds(const std::string& ticker, const t_float_50& amount) const + kdf_service::do_i_have_enough_funds(const std::string& ticker, const t_float_50& amount) const { SPDLOG_DEBUG("do_i_have_enough_funds for {}: [{}]", ticker, amount.str(8, std::ios_base::fixed)); t_float_50 funds = get_balance_info_f(ticker); @@ -2671,7 +2681,7 @@ namespace atomic_dex } std::string - mm2_service::address(const std::string& ticker, t_mm2_ec& ec) const + kdf_service::address(const std::string& ticker, t_kdf_ec& ec) const { std::shared_lock lock(m_balance_mutex); auto it = m_balance_informations.find(ticker); @@ -2687,19 +2697,19 @@ namespace atomic_dex } bool - mm2_service::is_orderbook_thread_active() const + kdf_service::is_orderbook_thread_active() const { return this->m_orderbook_thread_active.load(); } nlohmann::json - mm2_service::get_raw_mm2_ticker_cfg(const std::string& ticker) const + kdf_service::get_raw_kdf_ticker_cfg(const std::string& ticker) const { nlohmann::json out; std::shared_lock lock(m_raw_coin_cfg_mutex); - const auto it = m_mm2_raw_coins_cfg.find(ticker); - if (it != m_mm2_raw_coins_cfg.end()) + const auto it = m_kdf_raw_coins_cfg.find(ticker); + if (it != m_kdf_raw_coins_cfg.end()) { atomic_dex::coin_element element = it->second; to_json(out, element); @@ -2708,26 +2718,26 @@ namespace atomic_dex return nlohmann::json::object(); } - mm2_service::t_pair_max_vol - mm2_service::get_taker_vol() const + kdf_service::t_pair_max_vol + kdf_service::get_taker_vol() const { return m_synchronized_max_taker_vol.get(); } - mm2_service::t_pair_min_vol - mm2_service::get_min_vol() const + kdf_service::t_pair_min_vol + kdf_service::get_min_vol() const { return m_synchronized_min_taker_vol.get(); } bool - mm2_service::is_pin_cfg_enabled() const + kdf_service::is_pin_cfg_enabled() const { return m_balance_factor != 1.0; } void - mm2_service::reset_fake_balance_to_zero(const std::string& ticker) + kdf_service::reset_fake_balance_to_zero(const std::string& ticker) { { std::unique_lock lock(m_balance_mutex); @@ -2737,7 +2747,7 @@ namespace atomic_dex } void - mm2_service::decrease_fake_balance(const std::string& ticker, const std::string& amount) + kdf_service::decrease_fake_balance(const std::string& ticker, const std::string& amount) { SPDLOG_DEBUG("decrease_fake_balance for {}: [{}]", ticker, amount); t_float_50 balance = get_balance_info_f(ticker); @@ -2760,10 +2770,10 @@ namespace atomic_dex } void - mm2_service::process_tx_answer(const nlohmann::json& answer_json, std::string ticker) + kdf_service::process_tx_answer(const nlohmann::json& answer_json, std::string ticker) { - mm2::tx_history_answer answer; - mm2::from_json(answer_json, answer); + kdf::tx_history_answer answer; + kdf::from_json(answer_json, answer); t_tx_state state; state.state = answer.result.value().sync_status.state; state.current_block = answer.result.value().current_block; @@ -2837,13 +2847,13 @@ namespace atomic_dex void - mm2_service::process_balance_answer(const nlohmann::json& answer) + kdf_service::process_balance_answer(const nlohmann::json& answer) { try { t_balance_answer answer_r; - mm2::from_json(answer, answer_r); + kdf::from_json(answer, answer_r); if (is_pin_cfg_enabled()) { std::shared_lock lock(m_balance_mutex); @@ -2868,19 +2878,19 @@ namespace atomic_dex } } - mm2::mm2_client& mm2_service::get_mm2_client() + kdf::kdf_client& kdf_service::get_kdf_client() { - return m_mm2_client; + return m_kdf_client; } std::string - mm2_service::get_current_ticker() const + kdf_service::get_current_ticker() const { return m_current_ticker.get(); } bool - mm2_service::set_current_ticker(const std::string& ticker) + kdf_service::set_current_ticker(const std::string& ticker) { if (ticker != get_current_ticker()) { @@ -2891,7 +2901,7 @@ namespace atomic_dex } void - mm2_service::add_new_coin(const nlohmann::json& coin_cfg_json, const nlohmann::json& raw_coin_cfg_json) + kdf_service::add_new_coin(const nlohmann::json& coin_cfg_json, const nlohmann::json& raw_coin_cfg_json) { //! Normal cfg part SPDLOG_DEBUG("[{}], [{}]", coin_cfg_json.dump(4), raw_coin_cfg_json.dump(4)); @@ -2918,7 +2928,7 @@ namespace atomic_dex if (not raw_coin_cfg_json.empty() && not is_this_ticker_present_in_raw_cfg(raw_coin_cfg_json.at("coin").get())) { const fs::path coins_json_path{atomic_dex::utils::get_current_configs_path() / "coins.json"}; - SPDLOG_DEBUG("Adding entry : {} to mm2 coins file {}", raw_coin_cfg_json.dump(4), coins_json_path.string()); + SPDLOG_DEBUG("Adding entry : {} to kdf coins file {}", raw_coin_cfg_json.dump(4), coins_json_path.string()); QFile ifs; ifs.setFileName(std_path_to_qstring(coins_json_path)); ifs.open(QIODevice::ReadOnly | QIODevice::Text); @@ -2941,21 +2951,21 @@ namespace atomic_dex } bool - mm2_service::is_this_ticker_present_in_raw_cfg(const std::string& ticker) const + kdf_service::is_this_ticker_present_in_raw_cfg(const std::string& ticker) const { std::shared_lock lock(m_raw_coin_cfg_mutex); - return m_mm2_raw_coins_cfg.find(ticker) != m_mm2_raw_coins_cfg.end(); + return m_kdf_raw_coins_cfg.find(ticker) != m_kdf_raw_coins_cfg.end(); } bool - mm2_service::is_this_ticker_present_in_normal_cfg(const std::string& ticker) const + kdf_service::is_this_ticker_present_in_normal_cfg(const std::string& ticker) const { std::shared_lock lock(m_coin_cfg_mutex); return m_coins_informations.find(ticker) != m_coins_informations.end(); } void - mm2_service::remove_custom_coin(const std::string& ticker) + kdf_service::remove_custom_coin(const std::string& ticker) { //! Coin need to be disabled to be removed assert(not get_coin_info(ticker).currently_enabled); @@ -2986,7 +2996,7 @@ namespace atomic_dex if (is_this_ticker_present_in_raw_cfg(ticker)) { - SPDLOG_DEBUG("remove it from mm2 cfg: {}", ticker); + SPDLOG_DEBUG("remove it from kdf cfg: {}", ticker); fs::path coins_json_path{atomic_dex::utils::get_current_configs_path() / "coins.json"}; QFile ifs; ifs.setFileName(std_path_to_qstring(coins_json_path)); @@ -3013,13 +3023,13 @@ namespace atomic_dex } std::vector - mm2_service::get_electrum_server_from_token(const std::string& ticker) + kdf_service::get_electrum_server_from_token(const std::string& ticker) { std::vector servers; const coin_config_t cfg = this->get_coin_info(ticker); if (cfg.coin_type == CoinType::QRC20) { - if (cfg.is_testnet.value()) + if (cfg.is_testnet.value_or(false)) { SPDLOG_INFO("{} is from testnet picking tQTUM electrum", ticker); servers = std::move(get_coin_info("tQTUM").electrum_urls.value()); @@ -3034,13 +3044,13 @@ namespace atomic_dex } orders_and_swaps - mm2_service::get_orders_and_swaps() const + kdf_service::get_orders_and_swaps() const { return m_orders_and_swaps.get(); } void - mm2_service::set_orders_and_swaps_pagination_infos(std::size_t current_page, std::size_t limit, t_filtering_infos filter_infos) + kdf_service::set_orders_and_swaps_pagination_infos(std::size_t current_page, std::size_t limit, t_filtering_infos filter_infos) { { m_orders_and_swaps = orders_and_swaps{.current_page = current_page, .limit = limit, .filtering_infos = std::move(filter_infos)}; @@ -3049,7 +3059,7 @@ namespace atomic_dex } void - mm2_service::handle_exception_pplx_task(pplx::task previous_task, const std::string& from, nlohmann::json request) + kdf_service::handle_exception_pplx_task(pplx::task previous_task, const std::string& from, nlohmann::json request) { try { diff --git a/src/core/atomicdex/services/mm2/mm2.service.hpp b/src/core/atomicdex/services/kdf/kdf.service.hpp similarity index 79% rename from src/core/atomicdex/services/mm2/mm2.service.hpp rename to src/core/atomicdex/services/kdf/kdf.service.hpp index acec7b3cd3..6bcca6cd56 100644 --- a/src/core/atomicdex/services/mm2/mm2.service.hpp +++ b/src/core/atomicdex/services/kdf/kdf.service.hpp @@ -27,21 +27,21 @@ #include #include -#include "atomicdex/api/mm2/mm2.client.hpp" -#include "atomicdex/api/mm2/mm2.constants.hpp" -#include "atomicdex/api/mm2/mm2.error.code.hpp" -#include "atomicdex/api/mm2/mm2.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.min_trading_vol.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.max_taker_vol.hpp" -#include "atomicdex/api/mm2/rpc_v1/rpc.my_balance.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.orderbook.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_slp_rpc.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_with_assets.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_tendermint_token.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_erc20.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_eth_with_tokens.hpp" -#include "atomicdex/config/raw.mm2.coins.cfg.hpp" +#include "atomicdex/api/kdf/kdf.client.hpp" +#include "atomicdex/api/kdf/kdf.constants.hpp" +#include "atomicdex/api/kdf/kdf.error.code.hpp" +#include "atomicdex/api/kdf/kdf.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.min_trading_vol.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.max_taker_vol.hpp" +#include "atomicdex/api/kdf/rpc_v1/rpc.my_balance.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.orderbook.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_with_assets.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_tendermint_token.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_eth_with_tokens.hpp" +#include "atomicdex/config/raw.kdf.coins.cfg.hpp" #include "atomicdex/constants/dex.constants.hpp" #include "atomicdex/data/dex/orders.and.swaps.data.hpp" #include "atomicdex/data/wallet/tx.data.hpp" @@ -60,17 +60,17 @@ namespace atomic_dex using t_coins_registry = std::unordered_map; using t_coins = std::vector; - class ENTT_API mm2_service final : public ag::ecs::pre_update_system + class ENTT_API kdf_service final : public ag::ecs::pre_update_system { public: using t_pair_max_vol = std::pair; using t_pair_min_vol = std::pair; private: - using t_mm2_time_point = std::chrono::high_resolution_clock::time_point; + using t_kdf_time_point = std::chrono::high_resolution_clock::time_point; using t_balance_registry = std::unordered_map; using t_tx_registry = t_shared_synchronized_value>>; - using t_orderbook = boost::synchronized_value; + using t_orderbook = boost::synchronized_value; using t_orders_and_swaps = boost::synchronized_value; using t_synchronized_ticker_pair = boost::synchronized_value>; using t_synchronized_max_taker_vol = boost::synchronized_value; @@ -79,7 +79,7 @@ namespace atomic_dex ag::ecs::system_manager& m_system_manager; - mm2::mm2_client m_mm2_client; + kdf::kdf_client m_kdf_client; //! Current ticker t_synchronized_ticker m_current_ticker{g_primary_dex_coin}; @@ -90,14 +90,14 @@ namespace atomic_dex t_synchronized_min_taker_vol m_synchronized_min_taker_vol; //! Timers - t_mm2_time_point m_orderbook_clock; - t_mm2_time_point m_info_clock; - t_mm2_time_point m_activation_clock; + t_kdf_time_point m_orderbook_clock; + t_kdf_time_point m_info_clock; + t_kdf_time_point m_activation_clock; //! Atomicity / Threads - std::atomic_bool m_mm2_running{false}; + std::atomic_bool m_kdf_running{false}; std::atomic_bool m_orderbook_thread_active{false}; // Only active when in trading view (pro and simple) - std::thread m_mm2_init_thread; + std::thread m_kdf_init_thread; //! Current wallet name std::string m_current_wallet_name; @@ -112,9 +112,9 @@ namespace atomic_dex t_coins_registry& m_coins_informations{entity_registry_.set()}; t_balance_registry m_balance_informations; t_tx_registry m_tx_informations; - t_orderbook m_orderbook{mm2::orderbook_result_rpc{}}; + t_orderbook m_orderbook{kdf::orderbook_result_rpc{}}; t_orders_and_swaps m_orders_and_swaps{orders_and_swaps{}}; - t_mm2_raw_coins_registry m_mm2_raw_coins_cfg{parse_raw_mm2_coins_file()}; + t_kdf_raw_coins_registry m_kdf_raw_coins_cfg{parse_raw_kdf_coins_file()}; t_coins m_activation_queue; //! Balance factor @@ -134,7 +134,7 @@ namespace atomic_dex //! std::pair process_batch_enable_answer(const nlohmann::json& answer); - [[nodiscard]] std::pair get_tx(t_mm2_ec& ec) const; + [[nodiscard]] std::pair get_tx(t_kdf_ec& ec) const; std::vector get_electrum_server_from_token(const std::string& ticker); std::vector retrieve_coins_informations(); @@ -142,16 +142,16 @@ namespace atomic_dex public: //! Constructor - explicit mm2_service(entt::registry& registry, ag::ecs::system_manager& system_manager); + explicit kdf_service(entt::registry& registry, ag::ecs::system_manager& system_manager); //! Delete useless operator - mm2_service(const mm2_service& other) = delete; - mm2_service(const mm2_service&& other) = delete; - mm2_service& operator=(const mm2_service& other) = delete; - mm2_service& operator=(const mm2_service&& other) = delete; + kdf_service(const kdf_service& other) = delete; + kdf_service(const kdf_service&& other) = delete; + kdf_service& operator=(const kdf_service& other) = delete; + kdf_service& operator=(const kdf_service&& other) = delete; //! Destructor - ~mm2_service() final; + ~kdf_service() final; //! Events void on_refresh_orderbook_model_data(const refresh_orderbook_model_data& evt); @@ -160,8 +160,8 @@ namespace atomic_dex void on_gui_leave_trading(const gui_leave_trading& evt); - //! Spawn mm2 instance with given seed - void spawn_mm2_instance(std::string wallet_name, std::string passphrase, bool with_pin_cfg = false, std::string rpcpassword = ""); + //! Spawn kdf instance with given seed + void spawn_kdf_instance(std::string wallet_name, std::string passphrase, bool with_pin_cfg = false, std::string rpcpassword = ""); //! Refresh the current info (internally call process_balance and process_tx) void fetch_infos_thread(bool is_a_fresh = true, bool only_tx = false); @@ -185,20 +185,20 @@ namespace atomic_dex void enable_slp_testnet_coins(const t_coins& coins); void enable_erc20_coin(coin_config_t coin_config, std::string parent_ticker); void enable_erc20_coins(const t_coins& coins, const std::string parent_ticker); - void enable_tendermint_coin(coin_config_t coin_config, std::string parent_ticker); + void enable_tendermint_coin(coin_config_t coin_config); void enable_tendermint_coins(const t_coins& coins, const std::string parent_ticker); void enable_zhtlc(const t_coins& coins); // Balances processing functions - void process_balance_answer(const mm2::enable_bch_with_tokens_rpc& rpc); // Called after enabling SLP coins along tBCH/BCH. - void process_balance_answer(const mm2::enable_slp_rpc& rpc); // Called after enabling an SLP coin. - void process_balance_answer(const mm2::enable_tendermint_with_assets_rpc& rpc); - void process_balance_answer(const mm2::enable_tendermint_token_rpc& rpc); - void process_balance_answer(const mm2::enable_eth_with_tokens_rpc& rpc); - void process_balance_answer(const mm2::enable_erc20_rpc& rpc); + void process_balance_answer(const kdf::enable_bch_with_tokens_rpc& rpc); // Called after enabling SLP coins along tBCH/BCH. + void process_balance_answer(const kdf::enable_slp_rpc& rpc); // Called after enabling an SLP coin. + void process_balance_answer(const kdf::enable_tendermint_with_assets_rpc& rpc); + void process_balance_answer(const kdf::enable_tendermint_token_rpc& rpc); + void process_balance_answer(const kdf::enable_eth_with_tokens_rpc& rpc); + void process_balance_answer(const kdf::enable_erc20_rpc& rpc); public: - //! Add a new coin in the coin_info cfg add_new_coin(normal_cfg, mm2_cfg) + //! Add a new coin in the coin_info cfg add_new_coin(normal_cfg, kdf_cfg) void add_new_coin(const nlohmann::json& coin_cfg_json, const nlohmann::json& raw_coin_cfg_json); void remove_custom_coin(const std::string& ticker); void update_sync_ticker_pair(std::string base, std::string rel); @@ -207,6 +207,7 @@ namespace atomic_dex [[nodiscard]] bool is_zhtlc_coin_ready(const std::string coin) const; [[nodiscard]] nlohmann::json get_zhtlc_status(const std::string coin) const; + std::map groupByParentCoin(const t_coins& coins); //! Cancel zhtlc activation void enable_z_coin_cancel(const std::int8_t task_id); @@ -221,13 +222,13 @@ namespace atomic_dex void update() final; //! Retrieve public address of the given ticker - std::string address(const std::string& ticker, t_mm2_ec& ec) const; + std::string address(const std::string& ticker, t_kdf_ec& ec) const; - //! Is MM2 Process correctly running ? - [[nodiscard]] const std::atomic_bool& is_mm2_running() const; + //! Is KDF Process correctly running ? + [[nodiscard]] const std::atomic_bool& is_kdf_running() const; //! Retrieve my balance for a given ticker as a string. - [[nodiscard]] std::string get_balance_info(const std::string& ticker, t_mm2_ec& ec) const; + [[nodiscard]] std::string get_balance_info(const std::string& ticker, t_kdf_ec& ec) const; //! Refresh the current orderbook (internally call process_orderbook) void fetch_current_orderbook_thread(bool is_a_reset = false); @@ -235,10 +236,10 @@ namespace atomic_dex void process_orderbook(bool is_a_reset = false); //! Last 50 transactions maximum - [[nodiscard]] t_transactions get_tx_history(t_mm2_ec& ec) const; + [[nodiscard]] t_transactions get_tx_history(t_kdf_ec& ec) const; //! Last 50 transactions maximum - [[nodiscard]] t_tx_state get_tx_state(t_mm2_ec& ec) const; + [[nodiscard]] t_tx_state get_tx_state(t_kdf_ec& ec) const; //! Get coins that are currently enabled [[nodiscard]] t_coins get_enabled_coins() const; @@ -256,7 +257,7 @@ namespace atomic_dex [[nodiscard]] bool has_coin(const std::string& ticker) const; //! Get Current orderbook - [[nodiscard]] mm2::orderbook_result_rpc get_orderbook(t_mm2_ec& ec) const; + [[nodiscard]] kdf::orderbook_result_rpc get_orderbook(t_kdf_ec& ec) const; //! Get Swaps [[nodiscard]] orders_and_swaps get_orders_and_swaps() const; @@ -269,7 +270,7 @@ namespace atomic_dex [[nodiscard]] bool is_orderbook_thread_active() const; - [[nodiscard]] nlohmann::json get_raw_mm2_ticker_cfg(const std::string& ticker) const; + [[nodiscard]] nlohmann::json get_raw_kdf_ticker_cfg(const std::string& ticker) const; [[nodiscard]] t_pair_max_vol get_taker_vol() const; [[nodiscard]] t_pair_min_vol get_min_vol() const; @@ -281,7 +282,7 @@ namespace atomic_dex void batch_fetch_orders_and_swap(bool after_manual_reset = false); //! Async API - mm2::mm2_client& get_mm2_client(); + kdf::kdf_client& get_kdf_client(); //! Wallet api [[nodiscard]] std::string get_current_ticker() const; @@ -295,4 +296,4 @@ namespace atomic_dex }; } // namespace atomic_dex -REFL_AUTO(type(atomic_dex::mm2_service)) +REFL_AUTO(type(atomic_dex::kdf_service)) diff --git a/src/core/atomicdex/services/mm2/mm2_events.hpp b/src/core/atomicdex/services/kdf/kdf_events.hpp similarity index 81% rename from src/core/atomicdex/services/mm2/mm2_events.hpp rename to src/core/atomicdex/services/kdf/kdf_events.hpp index b5b24fa784..92174b4860 100644 --- a/src/core/atomicdex/services/mm2/mm2_events.hpp +++ b/src/core/atomicdex/services/kdf/kdf_events.hpp @@ -5,9 +5,9 @@ #include -#include "atomicdex/api/mm2/transaction.data.hpp" +#include "atomicdex/api/kdf/transaction.data.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { struct transactions_fetched_event { diff --git a/src/core/atomicdex/services/price/coingecko/coingecko.provider.cpp b/src/core/atomicdex/services/price/coingecko/coingecko.provider.cpp index f5414da671..cd6977dbd7 100644 --- a/src/core/atomicdex/services/price/coingecko/coingecko.provider.cpp +++ b/src/core/atomicdex/services/price/coingecko/coingecko.provider.cpp @@ -14,7 +14,7 @@ namespace atomic_dex { SPDLOG_INFO("coingecko_provider created"); this->disable(); - dispatcher_.sink().connect<&coingecko_provider::on_mm2_started>(*this); + dispatcher_.sink().connect<&coingecko_provider::on_kdf_started>(*this); dispatcher_.sink().connect<&coingecko_provider::on_coin_enabled>(*this); dispatcher_.sink().connect<&coingecko_provider::on_coin_disabled>(*this); } @@ -22,7 +22,7 @@ namespace atomic_dex coingecko_provider::~coingecko_provider() { SPDLOG_INFO("coingecko_provider destroyed"); - dispatcher_.sink().disconnect<&coingecko_provider::on_mm2_started>(*this); + dispatcher_.sink().disconnect<&coingecko_provider::on_kdf_started>(*this); dispatcher_.sink().disconnect<&coingecko_provider::on_coin_enabled>(*this); dispatcher_.sink().disconnect<&coingecko_provider::on_coin_disabled>(*this); } @@ -41,9 +41,9 @@ namespace atomic_dex namespace atomic_dex { void - coingecko_provider::on_mm2_started([[maybe_unused]] const mm2_started& evt) + coingecko_provider::on_kdf_started([[maybe_unused]] const kdf_started& evt) { - SPDLOG_INFO("on_mm2_started"); + SPDLOG_INFO("on_kdf_started"); update_ticker_and_provider(); } @@ -75,7 +75,7 @@ namespace atomic_dex coingecko_provider::update_ticker_and_provider() { SPDLOG_INFO("update_ticker_and_provider"); - if (m_system_manager.has_system() && m_system_manager.get_system().is_mm2_running()) + if (m_system_manager.has_system() && m_system_manager.get_system().is_kdf_running()) { const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_model_data(); auto&& [ids, registry] = coingecko::api::from_enabled_coins(coins); @@ -83,7 +83,7 @@ namespace atomic_dex } else { - SPDLOG_WARN("mm2 not running - skipping update_ticker_and_provider"); + SPDLOG_WARN("kdf not running - skipping update_ticker_and_provider"); } } diff --git a/src/core/atomicdex/services/price/coingecko/coingecko.provider.hpp b/src/core/atomicdex/services/price/coingecko/coingecko.provider.hpp index 28473a8d21..5958e9b2fe 100644 --- a/src/core/atomicdex/services/price/coingecko/coingecko.provider.hpp +++ b/src/core/atomicdex/services/price/coingecko/coingecko.provider.hpp @@ -37,8 +37,8 @@ namespace atomic_dex void update_ticker_and_provider(); - //! Event that occur when the mm2 process is launched correctly. - void on_mm2_started(const mm2_started& evt) ; + //! Event that occur when the kdf process is launched correctly. + void on_kdf_started(const kdf_started& evt) ; //! Event that occur when a coin is correctly enabled. void on_coin_enabled(const coin_enabled& evt) ; diff --git a/src/core/atomicdex/services/price/coingecko/coingecko.wallet.charts.cpp b/src/core/atomicdex/services/price/coingecko/coingecko.wallet.charts.cpp index 65ffbcbfe8..c0475ff9ff 100644 --- a/src/core/atomicdex/services/price/coingecko/coingecko.wallet.charts.cpp +++ b/src/core/atomicdex/services/price/coingecko/coingecko.wallet.charts.cpp @@ -60,7 +60,7 @@ namespace atomic_dex auto chart_registry = this->m_chart_data_registry.get(); nlohmann::json out = nlohmann::json::array(); const auto& data = chart_registry.begin()->second; - const auto& mm2 = m_system_manager.get_system(); + const auto& kdf = m_system_manager.get_system(); t_float_50 first_total = 0; for (std::size_t idx = 0; idx < data.size(); idx++) { @@ -77,7 +77,7 @@ namespace atomic_dex to_skip = true; continue; } - t_float_50 cur_total = (t_float_50(value[idx][1].get()) * mm2.get_balance_info_f(key)) * rate; + t_float_50 cur_total = (t_float_50(value[idx][1].get()) * kdf.get_balance_info_f(key)) * rate; total += cur_total; } if (to_skip) @@ -210,7 +210,7 @@ namespace atomic_dex const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_enabled_coins(); auto* portfolio_model = this->m_system_manager.get_system().get_portfolio(); auto final_task = m_taskflow.emplace([this]() { this->generate_fiat_chart(); }).name("Post task"); - auto active_coins = m_system_manager.get_system().get_active_coins().size(); + auto active_coins = m_system_manager.get_system().get_active_coins().size(); SPDLOG_INFO("active_coins: {} coins_size: {}", active_coins, coins.size()); if (active_coins == coins.size()) diff --git a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp b/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp deleted file mode 100644 index 9719887871..0000000000 --- a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -// Deps Headers -#include - -// Project Headers -#include "atomicdex/pages/qt.portfolio.page.hpp" -#include "atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp" - -namespace -{ - //! Using namespace - using namespace std::chrono_literals; - using namespace atomic_dex::coinpaprika::api; - - //! Constants - constexpr std::uint16_t g_pending_init_tasks_limit = 3; -} // namespace - -//! Constructor/Destructor -namespace atomic_dex -{ - coinpaprika_provider::coinpaprika_provider(entt::registry& registry, ag::ecs::system_manager& system_manager) : - system(registry), m_system_manager(system_manager) - { - SPDLOG_INFO("coinpaprika_provider created"); - disable(); - dispatcher_.sink().connect<&coinpaprika_provider::on_mm2_started>(*this); - dispatcher_.sink().connect<&coinpaprika_provider::on_coin_enabled>(*this); - dispatcher_.sink().connect<&coinpaprika_provider::on_coin_disabled>(*this); - } - - coinpaprika_provider::~coinpaprika_provider() - { - SPDLOG_INFO("coinpaprika_provider destroyed"); - dispatcher_.sink().disconnect<&coinpaprika_provider::on_mm2_started>(*this); - dispatcher_.sink().disconnect<&coinpaprika_provider::on_coin_enabled>(*this); - dispatcher_.sink().disconnect<&coinpaprika_provider::on_coin_disabled>(*this); - } -} // namespace atomic_dex - -//! Private Generics -namespace atomic_dex -{ - template - TAnswer - coinpaprika_provider::get_infos(const std::string& ticker, const TRegistry& registry, TLockable& mutex) const - { - std::shared_lock lock(mutex); - const auto it = registry.find(ticker); - return it != registry.cend() ? it->second : TAnswer{}; - } -} // namespace atomic_dex - -//! RPC Generics -namespace atomic_dex -{ - void - coinpaprika_provider::verify_idx(t_ref_count_idx idx, uint16_t target_size, const std::vector& tickers) - { - if (idx != nullptr) - { - const auto cur = idx->fetch_add(1) + 1; - // SPDLOG_DEBUG("cur: {}, target size: {}, remaining before adding in the model: {}", cur, target_size, target_size - cur); - if (cur == target_size) - { - if (not tickers.empty()) - { - dispatcher_.trigger(tickers); - } - else - { - this->dispatcher_.trigger(""); - } - } - } - } - - template - void - coinpaprika_provider::generic_post_verification(std::shared_mutex& mtx, TContainer& container, std::string&& ticker, TAnswer&& answer, Args... args) - { - { - std::unique_lock lock(mtx); - container.insert_or_assign(std::move(ticker), std::forward(answer)); - } - verify_idx(std::move(args)...); - } - - template - void - coinpaprika_provider::generic_rpc_paprika_process( - const TRequest& request, std::string ticker, std::shared_mutex& mtx, std::unordered_map& container, TExecutorFunctor&& functor, - Args... args) - { - const auto answer_functor = [this, &mtx, &container, functor = std::forward(functor), request, ticker = std::move(ticker), - ... args = std::move(args)](web::http::http_response resp) mutable { - const auto answer = process_generic_resp(resp); - if (answer.rpc_result_code == static_cast(antara::app::http_code::too_many_requests)) - { - std::this_thread::sleep_for(1s); - generic_rpc_paprika_process(request, std::move(ticker), mtx, container, std::forward(functor), std::move(args)...); - } - else - { - generic_post_verification(mtx, container, std::move(ticker), std::move(answer), std::move(args)...); - } - }; - - functor(request).then(answer_functor).then(&handle_exception_pplx_task); - } -} // namespace atomic_dex - -//! RPC call -namespace atomic_dex -{ - template - void - coinpaprika_provider::process_provider(const coin_config_t& current_coin, Args... args) - { - const price_converter_request request{.base_currency_id = current_coin.coinpaprika_id, .quote_currency_id = "usd-us-dollars"}; - generic_rpc_paprika_process( - request, current_coin.ticker, m_provider_mutex, m_usd_rate_providers, - [](auto&& request) { return async_price_converter(std::forward(request)); }, std::move(args)...); - } - - template - void - coinpaprika_provider::process_ticker_infos(const coin_config_t& current_coin, Args... args) - { - const ticker_infos_request request{.ticker_currency_id = current_coin.coinpaprika_id, .ticker_quotes = {"USD", "EUR", "BTC"}}; - generic_rpc_paprika_process( - request, current_coin.ticker, m_ticker_infos_mutex, m_ticker_infos_registry, - [](auto&& request) { return async_ticker_info(std::forward(request)); }, std::move(args)...); - } - - template - void - coinpaprika_provider::process_ticker_historical(const coin_config_t& current_coin, Args... args) - { - const ticker_historical_request request{.ticker_currency_id = current_coin.coinpaprika_id, .interval = "2h"}; - generic_rpc_paprika_process( - request, current_coin.ticker, m_ticker_historical_mutex, m_ticker_historical_registry, - [](auto&& request) { return async_ticker_historical(std::forward(request)); }, std::move(args)...); - } -} // namespace atomic_dex - -//! System Override -namespace atomic_dex -{ - void - coinpaprika_provider::update() - { - } -} // namespace atomic_dex - -//! Events -namespace atomic_dex -{ - void - coinpaprika_provider::on_mm2_started([[maybe_unused]] const mm2_started& evt) - { - update_ticker_and_provider(); - } - - void - coinpaprika_provider::on_coin_enabled(const coin_enabled& evt) - { - SPDLOG_INFO("{} enabled, retrieve coinpaprika infos", fmt::format("{}", fmt::join(evt.tickers, ", "))); - auto idx{std::make_shared(0)}; - const auto target_size = evt.tickers.size() * g_pending_init_tasks_limit; - const auto* global_cfg_system = m_system_manager.get_system().get_global_cfg(); - for (auto&& ticker: evt.tickers) - { - const auto config = global_cfg_system->get_coin_info(ticker); - if (config.coinpaprika_id != "test-coin") - { - process_provider(config, idx, target_size, evt.tickers); - process_ticker_infos(config, idx, target_size, evt.tickers); - process_ticker_historical(config, idx, target_size, evt.tickers); - } - else - { - const std::uint16_t cur = idx->fetch_add(g_pending_init_tasks_limit) + g_pending_init_tasks_limit; ///< Manually skip the above 3 operations - if (cur == target_size) - { - this->dispatcher_.trigger(evt.tickers); - } - } - } - } - - void - coinpaprika_provider::on_coin_disabled(const coin_disabled& evt) - { - SPDLOG_INFO("{} disabled, removing from paprika provider", evt.ticker); - std::unique_lock lock(m_provider_mutex); - m_usd_rate_providers.erase(evt.ticker); - } -} // namespace atomic_dex - -//! Public member functions -namespace atomic_dex -{ - void - coinpaprika_provider::update_ticker_and_provider() - { - const auto coins = this->m_system_manager.get_system().get_global_cfg()->get_enabled_coins(); - auto idx{std::make_shared(0)}; - const auto target_size = coins.size(); - for (auto&& [_, current_coin]: coins) - { - if (current_coin.coinpaprika_id == "test-coin") - { - const std::uint16_t cur = idx->fetch_add(1) + 1; - if (cur == target_size) - { - dispatcher_.trigger(""); - } - continue; - } - process_ticker_infos(current_coin); - process_ticker_historical(current_coin); - process_provider(current_coin, idx, target_size, std::vector{}); - } - } - - std::string - coinpaprika_provider::get_rate_conversion(const std::string& ticker) const - { - return get_infos(ticker, m_usd_rate_providers, m_provider_mutex).price; - } - - t_ticker_info_answer - coinpaprika_provider::get_ticker_infos(const std::string& ticker) const - { - return get_infos(ticker, m_ticker_infos_registry, m_ticker_infos_mutex); - } - - t_ticker_historical_answer - coinpaprika_provider::get_ticker_historical(const std::string& ticker) const - { - return get_infos(ticker, m_ticker_historical_registry, m_ticker_historical_mutex); - } -} // namespace atomic_dex \ No newline at end of file diff --git a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp b/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp deleted file mode 100644 index 01352719e5..0000000000 --- a/src/core/atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/****************************************************************************** - * Copyright © 2013-2024 The Komodo Platform Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * Komodo Platform software, including this file may be copied, modified, * - * propagated or distributed except according to the terms contained in the * - * LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#pragma once - -//! STD -#include - -//! Deps -#include - -//! Project Headers -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" -#include "atomicdex/events/events.hpp" - -namespace atomic_dex -{ - namespace ag = antara::gaming; - - class coinpaprika_provider final : public ag::ecs::pre_update_system - { - //! Typedefs - using t_ref_count_idx = std::shared_ptr; - using t_providers_registry = std::unordered_map; - using t_ticker_infos_registry = std::unordered_map; - using t_ticker_historical_registry = std::unordered_map; - - //! Private fields - - //! ag::system_manager - ag::ecs::system_manager& m_system_manager; - - //! Containers - t_providers_registry m_usd_rate_providers{}; ///< USD Rate Providers - t_ticker_infos_registry m_ticker_infos_registry{}; ///< Ticker info registry, key is the ticker - t_ticker_historical_registry m_ticker_historical_registry{}; ///< Ticker historical registry, key is the ticker - - //! Mutexes - mutable std::shared_mutex m_ticker_historical_mutex; - mutable std::shared_mutex m_ticker_infos_mutex; - mutable std::shared_mutex m_provider_mutex; - - //! Private member functions - void verify_idx(t_ref_count_idx idx = nullptr, uint16_t target_size = 0, const std::vector& tickers = {}); - - //! Private templated member functions - template - TAnswer get_infos(const std::string& ticker, const TRegistry& registry, TLockable& mutex) const ; - - template - void generic_post_verification(std::shared_mutex& mtx, TContainer& container, std::string&& ticker, TAnswer&& answer, Args... args); - - template - void generic_rpc_paprika_process( - const TRequest& request, std::string ticker, std::shared_mutex& mtx, std::unordered_map& container, - TExecutorFunctor&& functor, Args... args); - - //! Private RPC Call - template - void process_provider(const coin_config_t& current_coin, Args... args); - template - void process_ticker_infos(const coin_config_t& current_coin, Args... args); - template - void process_ticker_historical(const coin_config_t& current_coin, Args... args); - - public: - //! Deleted operation - coinpaprika_provider(coinpaprika_provider& other) = delete; - coinpaprika_provider(coinpaprika_provider&& other) = delete; - coinpaprika_provider& operator=(coinpaprika_provider& other) = delete; - coinpaprika_provider& operator=(coinpaprika_provider&& other) = delete; - - //! Constructor - coinpaprika_provider(entt::registry& registry, ag::ecs::system_manager& system_manager) ; - - //! Destructor - ~coinpaprika_provider() final; - - ///< Public API - - //! Update all the data of the provider in an async way - void update_ticker_and_provider(); - - //! Get the rate conversion for the given fiat. - [[nodiscard]] std::string get_rate_conversion(const std::string& ticker) const ; - - //! Get the ticker informations. - [[nodiscard]] t_ticker_info_answer get_ticker_infos(const std::string& ticker) const ; - - //! Get the ticker informations. - [[nodiscard]] t_ticker_historical_answer get_ticker_historical(const std::string& ticker) const ; - - ///< Events - - //! Event that occur when the mm2 process is launched correctly. - void on_mm2_started(const mm2_started& evt) ; - - //! Event that occur when a coin is correctly enabled. - void on_coin_enabled(const coin_enabled& evt) ; - - //! Event that occur when a coin is correctly disabled. - void on_coin_disabled(const coin_disabled& evt) ; - - //! Override ag::system functions - void update() final; - }; -} // namespace atomic_dex - -REFL_AUTO(type(atomic_dex::coinpaprika_provider)) \ No newline at end of file diff --git a/src/core/atomicdex/services/price/defi.stats.cpp b/src/core/atomicdex/services/price/defi.stats.cpp index 22bbd98d4c..e14d40283c 100644 --- a/src/core/atomicdex/services/price/defi.stats.cpp +++ b/src/core/atomicdex/services/price/defi.stats.cpp @@ -17,7 +17,6 @@ //! Project Headers #include "atomicdex/services/price/defi.stats.hpp" #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/services/price/global.provider.hpp" @@ -49,17 +48,17 @@ namespace pplx::cancellation_token_source d_token_source; pplx::task - async_fetch_defi_ticker_stats() + async_fetch_defi_stats_volumes() { web::http::http_request req; req.set_method(web::http::methods::GET); - req.set_request_uri(FROM_STD_STR("api/v3/tickers/summary")); + req.set_request_uri(FROM_STD_STR("api/v3/pairs/volumes_24hr")); SPDLOG_INFO("defi_stats req: {}", TO_STD_STR(req.to_string())); return g_defi_stats_client->request(req, d_token_source.get_token()); } nlohmann::json - process_fetch_defi_ticker_stats_answer(web::http::http_response resp) + process_fetch_defi_stats_volumes_answer(web::http::http_response resp) { std::string body = TO_STD_STR(resp.extract_string(true).get()); if (resp.status_code() == 200) @@ -119,11 +118,11 @@ namespace atomic_dex this->process_update(); }; }; - async_fetch_defi_ticker_stats() + async_fetch_defi_stats_volumes() .then( [this](web::http::http_response resp) { - this->m_defi_ticker_stats = process_fetch_defi_ticker_stats_answer(resp); + this->m_defi_stats_volumes = process_fetch_defi_stats_volumes_answer(resp); nb_try = 0; }) .then(error_functor); @@ -136,33 +135,140 @@ namespace atomic_dex auto ticker = base + "_" + quote; auto ticker_reversed = quote + "_" + base; SPDLOG_INFO("Getting 24hr volume data for {}", ticker); + + // Check if base/quote are the same if (base == quote) { SPDLOG_INFO("Base/quote must be different, no volume data for {}", ticker); return volume_24h_usd; } - auto defi_ticker_stats = m_defi_ticker_stats.get(); - // SPDLOG_INFO("Volume data: {}", defi_ticker_stats.dump(4)); + // Check if defi_stats_volumes is valid + auto defi_stats_volumes = m_defi_stats_volumes.get(); + if (!defi_stats_volumes.is_object()) + { + SPDLOG_WARN("Invalid defi stats volumes data."); + return volume_24h_usd; + } - if (defi_ticker_stats.contains("data")) + // Check if volumes key exists + if (!defi_stats_volumes.contains("volumes")) + { + SPDLOG_WARN("No volumes data available."); + return volume_24h_usd; + } + + // Extract ticker trade_volume_usd safely + if (defi_stats_volumes.at("volumes").contains(ticker)) { - SPDLOG_INFO("Combined volume usd: {}", defi_ticker_stats["combined_volume_usd"]); - if (defi_ticker_stats.at("data").contains(ticker)) + auto volume_node = defi_stats_volumes["volumes"][ticker]["ALL"]["trade_volume_usd"]; + if (volume_node.is_number()) { - volume_24h_usd = defi_ticker_stats.at("data").at(ticker).at("volume_usd_24hr").get(); + volume_24h_usd = std::to_string(volume_node.get()); SPDLOG_INFO("{} volume usd: {}", ticker, volume_24h_usd); } - else if (defi_ticker_stats.at("data").contains(ticker_reversed)) + else if (volume_node.is_null()) + { + SPDLOG_WARN("Volume value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Volume value is not a number for {}: {}", ticker, volume_node.type_name()); + } + } + else if (defi_stats_volumes["volumes"].contains(ticker_reversed)) + { + auto volume_node = defi_stats_volumes["volumes"][ticker_reversed]["ALL"]["trade_volume_usd"]; + if (volume_node.is_number()) { - volume_24h_usd = defi_ticker_stats.at("data").at(ticker_reversed).at("volume_usd_24hr").get(); + volume_24h_usd = std::to_string(volume_node.get()); SPDLOG_INFO("{} volume usd: {}", ticker_reversed, volume_24h_usd); } + else if (volume_node.is_null()) + { + SPDLOG_WARN("Volume value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Volume value is not a number for {}: {}", ticker, volume_node.type_name()); + } } else { - SPDLOG_WARN("Empty 24hr volume data for {}", defi_ticker_stats.dump(4)); + SPDLOG_WARN("No volume data available for {}", ticker); } return volume_24h_usd; } + + std::string + global_defi_stats_service::get_trades_24h(const std::string& base, const std::string& quote) const + { + std::string trades_24h = "0"; + auto ticker = base + "_" + quote; + auto ticker_reversed = quote + "_" + base; + SPDLOG_INFO("Getting 24hr trade data for {}", ticker); + + // Check if base/quote are the same + if (base == quote) + { + SPDLOG_INFO("Base/quote must be different, no volume data for {}", ticker); + return trades_24h; + } + + // Check if defi_stats_volumes is valid + auto defi_stats_volumes = m_defi_stats_volumes.get(); + if (!defi_stats_volumes.is_object()) + { + SPDLOG_WARN("Invalid defi stats volumes data."); + return trades_24h; + } + + // Check if volumes key exists + if (!defi_stats_volumes.contains("volumes")) + { + SPDLOG_WARN("No volumes data available."); + return trades_24h; + } + + // Extract ticker trade_volume_usd safely + if (defi_stats_volumes.at("volumes").contains(ticker)) + { + auto trades_node = defi_stats_volumes["volumes"][ticker]["ALL"]["trades_24hr"]; + if (trades_node.is_number()) + { + trades_24h = std::to_string(trades_node.get()); + SPDLOG_INFO("{} trades_24h: {}", ticker, trades_24h); + } + else if (trades_node.is_null()) + { + SPDLOG_WARN("Trades value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Trades value is not a number for {}: {}", ticker, trades_node.type_name()); + } + } + else if (defi_stats_volumes["volumes"].contains(ticker_reversed)) + { + auto trades_node = defi_stats_volumes["volumes"][ticker_reversed]["ALL"]["trades_24hr"]; + if (trades_node.is_number()) + { + trades_24h = std::to_string(trades_node.get()); + SPDLOG_INFO("{} trades_24h: {}", ticker_reversed, trades_24h); + } + else if (trades_node.is_null()) + { + SPDLOG_WARN("Trades value is null for {}", ticker); + } + else + { + SPDLOG_WARN("Trades value is not a number for {}: {}", ticker, trades_node.type_name()); + } + } + else + { + SPDLOG_WARN("No trades data available for {}", ticker); + } + return trades_24h; + } } // namespace atomic_dex diff --git a/src/core/atomicdex/services/price/defi.stats.hpp b/src/core/atomicdex/services/price/defi.stats.hpp index 61941aec41..885af0357e 100644 --- a/src/core/atomicdex/services/price/defi.stats.hpp +++ b/src/core/atomicdex/services/price/defi.stats.hpp @@ -20,22 +20,22 @@ #include #include #include "atomicdex/config/app.cfg.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" -namespace atomic_dex::mm2 +namespace atomic_dex::kdf { - struct defi_ticker_stats_answer + struct defi_stats_volumes_answer { nlohmann::json result; int status_code; }; - void from_json(const nlohmann::json& j, defi_ticker_stats_answer& answer); -} // namespace atomic_dex::mm2 + void from_json(const nlohmann::json& j, defi_stats_volumes_answer& answer); +} // namespace atomic_dex::kdf namespace atomic_dex { - using t_defi_ticker_stats_answer = mm2::defi_ticker_stats_answer; + using t_defi_stats_volumes_answer = kdf::defi_stats_volumes_answer; } // namespace atomic_dex namespace atomic_dex @@ -49,7 +49,7 @@ namespace atomic_dex //! Private member fields ag::ecs::system_manager& m_system_manager; - t_json_synchronized m_defi_ticker_stats; + t_json_synchronized m_defi_stats_volumes; t_defi_stats_time_point m_update_clock; //! private functions @@ -67,6 +67,7 @@ namespace atomic_dex //! Public API void process_defi_stats(); + std::string get_trades_24h(const std::string& base, const std::string& quote) const; std::string get_volume_24h_usd(const std::string& base, const std::string& quote) const; diff --git a/src/core/atomicdex/services/price/global.provider.cpp b/src/core/atomicdex/services/price/global.provider.cpp index 1da473e6a7..772577cc09 100644 --- a/src/core/atomicdex/services/price/global.provider.cpp +++ b/src/core/atomicdex/services/price/global.provider.cpp @@ -16,7 +16,6 @@ //! Project Headers #include "atomicdex/services/price/global.provider.hpp" -#include "atomicdex/api/coinpaprika/coinpaprika.hpp" #include "atomicdex/pages/qt.settings.page.hpp" #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" @@ -100,63 +99,26 @@ namespace atomic_dex global_price_service::refresh_other_coins_rates( const std::string& quote_id, const std::string& ticker, bool with_update_providers, std::atomic_uint16_t nb_try) { - nb_try += 1; - SPDLOG_INFO("refresh_other_coins_rates - try {}", nb_try.load()); - if (nb_try == 10) + SPDLOG_DEBUG("refresh_other_coins_rates: {} - {} - {} - {}", quote_id, ticker, with_update_providers, nb_try); + if (nb_try > 3) { - SPDLOG_WARN("refresh other coins rates max try reached, skipping"); + SPDLOG_ERROR("Failed to fetch rates for ticker after 3 tries: {}", ticker); + this->m_coin_rate_providers[ticker] = "0.00"; return; } - using namespace std::chrono_literals; - coinpaprika::api::price_converter_request request{.base_currency_id = "usd-us-dollars", .quote_currency_id = quote_id}; - auto error_functor = [this, quote_id, ticker, with_update_providers, nb_try_load = nb_try.load()](pplx::task previous_task) + + t_float_50 price = safe_float(get_rate_conversion("USD", ticker, true)); + if (price <= 0) { - try - { - previous_task.wait(); - } - catch (const std::exception& e) - { - SPDLOG_ERROR("pplx task error from refresh_other_coins_rates: {} - nb_try {}", e.what(), nb_try_load); - using namespace std::chrono_literals; - std::this_thread::sleep_for(1s); - this->refresh_other_coins_rates(quote_id, ticker, with_update_providers, nb_try_load); - }; - }; - coinpaprika::api::async_price_converter(request) - .then( - [this, quote_id, ticker, with_update_providers, nb_try_cap = nb_try.load()](web::http::http_response resp) - { - auto answer = coinpaprika::api::process_generic_resp(resp); - if (answer.rpc_result_code == static_cast(antara::app::http_code::too_many_requests)) - { - std::this_thread::sleep_for(1s); - SPDLOG_WARN("too many request - retrying"); - this->refresh_other_coins_rates(quote_id, ticker, with_update_providers, nb_try_cap); - } - else - { - SPDLOG_INFO("Successfully get the coinpaprika::api::async_price_converter answer after {} try", nb_try_cap); - if (answer.raw_result.find("error") == std::string::npos) - { - if (not answer.price.empty()) - { - std::unique_lock lock(m_coin_rate_mutex); - this->m_coin_rate_providers[ticker] = answer.price; - } - } - else - { - std::unique_lock lock(m_coin_rate_mutex); - this->m_coin_rate_providers[ticker] = "0.00"; - } - } - if (with_update_providers) - { - //this->m_system_manager.get_system().update_ticker_and_provider(); - } - }) - .then(error_functor); + SPDLOG_ERROR("Price is 0 for ticker: {}", ticker); + this->m_coin_rate_providers[ticker] = "0.00"; + } + else + { + t_float_50 rate = 1 / price; + this->m_coin_rate_providers[ticker] = rate.str(); + } + } global_price_service::global_price_service(entt::registry& registry, ag::ecs::system_manager& system_manager, atomic_dex::cfg& cfg) : @@ -189,14 +151,14 @@ namespace atomic_dex { if (fiat == utils::retrieve_main_ticker(ticker_in)) { - return "1"; + return "1.00"; } std::string ticker = utils::retrieve_main_ticker(ticker_in); try { //! FIXME: fix zatJum crash report, frontend QML try to retrieve price before program is even launched if (ticker.empty()) - return "0"; + return "0.00"; auto& provider = m_system_manager.get_system(); std::string current_price = provider.get_rate_conversion(ticker); @@ -231,7 +193,7 @@ namespace atomic_dex { if (current_price_f < 1.0) { - default_precision = 5; + default_precision = 8; } } //! Trick: If there conversion in a fixed representation is 0.00 then use a default precision to 2 without fixed ios flags @@ -266,8 +228,8 @@ namespace atomic_dex std::string global_price_service::get_price_in_fiat_all(const std::string& fiat, std::error_code& ec) const { - auto& mm2_instance = m_system_manager.get_system(); - t_coins coins = mm2_instance.get_enabled_coins(); + auto& kdf_instance = m_system_manager.get_system(); + t_coins coins = kdf_instance.get_enabled_coins(); try { t_float_50 final_price_f = 0; @@ -312,9 +274,14 @@ namespace atomic_dex { try { - auto& mm2_instance = m_system_manager.get_system(); + if (amount == "" || ticker == "" || currency == "") + { + return "0.00"; + } + + auto& kdf_instance = m_system_manager.get_system(); - const auto ticker_infos = mm2_instance.get_coin_info(ticker); + const auto ticker_infos = kdf_instance.get_coin_info(ticker); const auto current_price = get_rate_conversion(currency, ticker); if (current_price == "0.00") @@ -339,7 +306,7 @@ namespace atomic_dex // SPDLOG_INFO("get_price_in_fiat [{}] [{}]", fiat, ticker); try { - auto& mm2_instance = m_system_manager.get_system(); + auto& kdf_instance = m_system_manager.get_system(); if (m_supported_fiat_registry.count(fiat) == 0u) { @@ -355,7 +322,7 @@ namespace atomic_dex } std::error_code t_ec; - const auto amount = mm2_instance.get_balance_info(ticker, t_ec); // from registry + const auto amount = kdf_instance.get_balance_info(ticker, t_ec); // from registry if (t_ec) { @@ -438,11 +405,11 @@ namespace atomic_dex [this](web::http::http_response resp) { this->m_other_fiats_rates = process_fetch_fiat_answer(resp); - const auto& mm2 = this->m_system_manager.get_system(); - const bool with_update = mm2.is_mm2_running(); + const auto& kdf = this->m_system_manager.get_system(); + const bool with_update = kdf.is_kdf_running(); bool already_send = false; - const auto first_id = mm2.get_coin_info(g_primary_dex_coin).coinpaprika_id; - const auto second_id = mm2.get_coin_info(g_second_primary_dex_coin).coinpaprika_id; + const auto first_id = kdf.get_coin_info(g_primary_dex_coin).coinpaprika_id; + const auto second_id = kdf.get_coin_info(g_second_primary_dex_coin).coinpaprika_id; if (!first_id.empty()) { @@ -458,7 +425,7 @@ namespace atomic_dex if (g_primary_dex_coin != coin && g_second_primary_dex_coin != coin) { refresh_other_coins_rates( - mm2.get_coin_info(coin).coinpaprika_id, + kdf.get_coin_info(coin).coinpaprika_id, coin, !already_send, 0 diff --git a/src/core/atomicdex/services/price/global.provider.hpp b/src/core/atomicdex/services/price/global.provider.hpp index e4234e7fbe..515c08ef22 100644 --- a/src/core/atomicdex/services/price/global.provider.hpp +++ b/src/core/atomicdex/services/price/global.provider.hpp @@ -20,7 +20,7 @@ #include #include "atomicdex/config/app.cfg.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" namespace atomic_dex { diff --git a/src/core/atomicdex/services/price/komodo_prices/komodo.prices.provider.cpp b/src/core/atomicdex/services/price/komodo_prices/komodo.prices.provider.cpp index bc3e5d9203..689e12b54c 100644 --- a/src/core/atomicdex/services/price/komodo_prices/komodo.prices.provider.cpp +++ b/src/core/atomicdex/services/price/komodo_prices/komodo.prices.provider.cpp @@ -90,7 +90,7 @@ namespace atomic_dex const auto now = std::chrono::high_resolution_clock::now(); const auto s = std::chrono::duration_cast(now - m_clock); - if (s >= 30s) + if (s >= 45s) { process_update(); m_clock = std::chrono::high_resolution_clock::now(); diff --git a/src/core/atomicdex/services/price/orderbook.scanner.service.cpp b/src/core/atomicdex/services/price/orderbook.scanner.service.cpp index 76c08a5209..6479066abf 100644 --- a/src/core/atomicdex/services/price/orderbook.scanner.service.cpp +++ b/src/core/atomicdex/services/price/orderbook.scanner.service.cpp @@ -16,9 +16,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp" #include "atomicdex/pages/qt.trading.page.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" #include "atomicdex/services/price/orderbook.scanner.service.hpp" //! Constructor @@ -46,10 +46,10 @@ namespace atomic_dex } // SPDLOG_INFO("process_best_orders processing"); - if (m_system_manager.has_system()) + if (m_system_manager.has_system()) { - auto& mm2_system = m_system_manager.get_system(); - if (mm2_system.is_mm2_running() && mm2_system.is_orderbook_thread_active()) + auto& kdf_system = m_system_manager.get_system(); + if (kdf_system.is_kdf_running() && kdf_system.is_orderbook_thread_active()) { // SPDLOG_INFO("process_best_orders"); using namespace std::string_literals; @@ -63,9 +63,9 @@ namespace atomic_dex nlohmann::json batch = nlohmann::json::array(); if (rpc.error) { - SPDLOG_ERROR("error: bad answer json for process_best_orders: {}", rpc.error->error); + // SPDLOG_DEBUG("error: bad answer json for process_best_orders: {}", rpc.error->error); this->m_bestorders_busy = false; - SPDLOG_ERROR("Triggering [process_orderbook_finished]: true"); + // SPDLOG_DEBUG("Triggering [process_orderbook_finished]: true"); this->dispatcher_.trigger(true); } else @@ -75,7 +75,7 @@ namespace atomic_dex this->m_best_orders_infos = rpc.result.value(); } this->m_bestorders_busy = false; - SPDLOG_ERROR("Triggering [process_orderbook_finished]: false"); + // SPDLOG_DEBUG("Triggering [process_orderbook_finished]: false"); this->dispatcher_.trigger(false); emit trading_pg.get_orderbook_wrapper()->bestOrdersBusyChanged(); } @@ -84,17 +84,17 @@ namespace atomic_dex this->m_bestorders_busy = true; emit trading_pg.get_orderbook_wrapper()->bestOrdersBusyChanged(); - mm2::bestorders_rpc rpc{.request={.coin = std::move(coin), .volume = std::move(volume), .action = std::move(action)}}; - mm2_system.get_mm2_client().process_rpc_async(rpc.request, callback); + kdf::bestorders_rpc rpc{.request={.coin = std::move(coin), .volume = std::move(volume), .action = std::move(action)}}; + kdf_system.get_kdf_client().process_rpc_async(rpc.request, callback); } else { - SPDLOG_WARN("MM2 Service not launched yet - skipping process_best_orders"); + SPDLOG_WARN("KDF Service not launched yet - skipping process_best_orders"); } } else { - SPDLOG_WARN("MM2 Service not created yet - skipping process_best_orders"); + SPDLOG_WARN("KDF Service not created yet - skipping process_best_orders"); } } } // namespace atomic_dex @@ -110,7 +110,7 @@ namespace atomic_dex const auto now = std::chrono::high_resolution_clock::now(); const auto s = std::chrono::duration_cast(now - m_update_clock); - if (s >= 30s) + if (s >= 45s) { SPDLOG_DEBUG("<<<<<<<<<<< orderbook_scanner_service update loop after 30 seconds >>>>>>>>>>>>>"); process_best_orders(); diff --git a/src/core/atomicdex/services/price/orderbook.scanner.service.hpp b/src/core/atomicdex/services/price/orderbook.scanner.service.hpp index 9a7896c68f..63c9b89dea 100644 --- a/src/core/atomicdex/services/price/orderbook.scanner.service.hpp +++ b/src/core/atomicdex/services/price/orderbook.scanner.service.hpp @@ -22,8 +22,8 @@ #include //! Project Headers -#include "atomicdex/api/mm2/mm2.client.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.bestorders.hpp" +#include "atomicdex/api/kdf/kdf.client.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.bestorders.hpp" //! Namespace declaration namespace atomic_dex @@ -33,7 +33,7 @@ namespace atomic_dex { //! Private typedefs using t_update_time_point = std::chrono::high_resolution_clock::time_point; - using t_best_orders_synchronized = boost::synchronized_value; + using t_best_orders_synchronized = boost::synchronized_value; //! Private member fields ag::ecs::system_manager& m_system_manager; diff --git a/src/core/atomicdex/services/sync/timesync.checker.service.cpp b/src/core/atomicdex/services/sync/timesync.checker.service.cpp new file mode 100644 index 0000000000..d1c1327e0d --- /dev/null +++ b/src/core/atomicdex/services/sync/timesync.checker.service.cpp @@ -0,0 +1,130 @@ +/****************************************************************************** + * Copyright © 2013-2024 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include +#include "atomicdex/services/sync/timesync.checker.service.hpp" +#include "atomicdex/utilities/cpprestsdk.utilities.hpp" + +namespace +{ + constexpr const char* g_timesync_endpoint = "https://worldtimeapi.org"; + web::http::client::http_client_config g_timesync_cfg{[]() + { + web::http::client::http_client_config cfg; + cfg.set_validate_certificates(false); + cfg.set_timeout(std::chrono::seconds(5)); + return cfg; + }()}; + t_http_client_ptr g_timesync_client = std::make_unique(FROM_STD_STR(g_timesync_endpoint), g_timesync_cfg); + pplx::cancellation_token_source g_synctoken_source; + + pplx::task + async_fetch_timesync() + { + web::http::http_request req; + req.set_method(web::http::methods::GET); + req.set_request_uri(FROM_STD_STR("api/timezone/UTC")); + return g_timesync_client->request(req, g_synctoken_source.get_token()); + } + + bool get_timesync_info_rpc(web::http::http_response resp_http) + { + using namespace std::string_literals; + nlohmann::json resp; + bool sync_ok = true; + std::string resp_str = TO_STD_STR(resp_http.extract_string(true).get()); + if (resp_http.status_code() != 200) + { + SPDLOG_ERROR("Cannot reach the endpoint [{}]: {}", g_timesync_endpoint, resp_str); + } + else + { + resp = nlohmann::json::parse(resp_str); + int64_t epoch_ts = resp["unixtime"]; + int64_t current_ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + int64_t ts_diff = epoch_ts - current_ts; + if (abs(ts_diff) > 60) + { + SPDLOG_WARN("Time sync failed! Actual: {}, System: {}, Diff: {}", epoch_ts, current_ts, ts_diff); + sync_ok = false; + } + } + return sync_ok; + } +} // namespace + + +namespace atomic_dex +{ + timesync_checker_service::timesync_checker_service(entt::registry& registry, QObject* parent) : QObject(parent), system(registry) + { + m_timesync_clock = std::chrono::high_resolution_clock::now(); + m_timesync_status = true; + fetch_timesync_status(); + } + + void timesync_checker_service::update() + { + using namespace std::chrono_literals; + + int64_t m_timesync_clock_ts = std::chrono::duration_cast(m_timesync_clock.time_since_epoch()).count(); + int64_t now_ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + int64_t ts_diff = now_ts - m_timesync_clock_ts; + if (abs(ts_diff) > 300) + { + if (!m_timesync_status) + { + fetch_timesync_status(); + m_timesync_clock = std::chrono::high_resolution_clock::now(); + } + } + } + + void timesync_checker_service::fetch_timesync_status() + { + SPDLOG_INFO("Checking system time is in sync..."); + if (is_timesync_fetching) + { + SPDLOG_WARN("Already checking timesync, returning"); + return; + } + is_timesync_fetching = true; + emit isTimesyncFetchingChanged(); + async_fetch_timesync() + .then([this](web::http::http_response resp) { + bool is_timesync_ok = get_timesync_info_rpc(resp); + SPDLOG_INFO("System time is in sync: {}", is_timesync_ok); + + if (is_timesync_ok != *m_timesync_status) + { + this->m_timesync_status = is_timesync_ok; + emit timesyncInfoChanged(); + } + }) + .then(&handle_exception_pplx_task); + is_timesync_fetching = false; + emit isTimesyncFetchingChanged(); + } + + bool timesync_checker_service::get_timesync_info() const + { + return *m_timesync_status; + } + +} // namespace atomic_dex + + + diff --git a/src/core/atomicdex/services/sync/timesync.checker.service.hpp b/src/core/atomicdex/services/sync/timesync.checker.service.hpp new file mode 100644 index 0000000000..54b3f73bf5 --- /dev/null +++ b/src/core/atomicdex/services/sync/timesync.checker.service.hpp @@ -0,0 +1,60 @@ +/****************************************************************************** + * Copyright © 2013-2024 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#pragma once + +#include +#include + +#include +#include + +#include + +namespace atomic_dex +{ + class timesync_checker_service final : public QObject, public ag::ecs::pre_update_system + { + Q_OBJECT + + Q_PROPERTY(QVariant timesyncInfo READ get_timesync_info NOTIFY timesyncInfoChanged) + Q_PROPERTY(bool isTimesyncFetching READ get_is_timesync_fetching NOTIFY isTimesyncFetchingChanged) + + using t_timesync_time_point = std::chrono::high_resolution_clock::time_point; + using t_bool_synchronized = boost::synchronized_value; + + t_bool_synchronized m_timesync_status; + t_timesync_time_point m_timesync_clock; + t_bool_synchronized is_timesync_fetching; + + void fetch_timesync_status(); + + public: + explicit timesync_checker_service(entt::registry& registry, QObject* parent = nullptr); + ~timesync_checker_service() final = default; + + void update() final; + + [[nodiscard]] bool get_timesync_info() const; + [[nodiscard]] bool get_is_timesync_fetching() const noexcept { return *is_timesync_fetching; } + + signals: + void timesyncInfoChanged(); + void isTimesyncFetchingChanged(); + }; +} // namespace atomic_dex + +REFL_AUTO(type(atomic_dex::timesync_checker_service)) diff --git a/src/core/atomicdex/services/update/update.checker.service.cpp b/src/core/atomicdex/services/update/update.checker.service.cpp index a1da62b8d8..f8123dd7d0 100644 --- a/src/core/atomicdex/services/update/update.checker.service.cpp +++ b/src/core/atomicdex/services/update/update.checker.service.cpp @@ -34,11 +34,13 @@ namespace pplx::task async_check_retrieve() { - nlohmann::json json_data{{"currentVersion", atomic_dex::get_raw_version()}}; + // Uncomment this when testing the next release. + // nlohmann::json json_data{{"testing", true}}; + nlohmann::json json_data{{"testing", false}}; return g_komodolive_client->request(create_json_post_request(std::move(json_data))); } - nlohmann::json get_update_info_rpc(web::http::http_response resp_http) + nlohmann::json process_update_info_resp(web::http::http_response resp_http) { using namespace std::string_literals; nlohmann::json resp; @@ -59,20 +61,16 @@ namespace result["currentVersion"] = atomic_dex::get_raw_version(); if (resp_http.status_code() == 200) { - bool update_needed = false; - std::string current_version_str = atomic_dex::get_raw_version(); - std::string endpoint_version = resp.at("new_version").get(); - boost::algorithm::replace_all(current_version_str, ".", ""); - boost::algorithm::replace_all(endpoint_version, ".", ""); - boost::algorithm::trim_left_if(current_version_str, boost::is_any_of("0")); - boost::algorithm::trim_left_if(endpoint_version, boost::is_any_of("0")); - update_needed = std::stoi(current_version_str) < std::stoi(endpoint_version); - result["updateNeeded"] = update_needed; - result["newVersion"] = resp["new_version"]; - result["downloadUrl"] = resp["download_url"]; - result["changelog"] = resp["changelog"]; - result["status"] = resp["status"]; + int current_version = atomic_dex::get_num_version(); + int endpoint_version = stoi(resp.at("version_num").get()); + result["updateNeeded"] = current_version < endpoint_version; + result["newVersion"] = resp["new_version"]; + result["downloadUrl"] = resp["download_url"]; + result["changelog"] = resp["changelog"]; + result["status"] = resp["status"]; + result["version_num"] = resp["version_num"]; } + SPDLOG_INFO(result.dump()); return result; } } @@ -107,7 +105,8 @@ namespace atomic_dex emit isFetchingChanged(); async_check_retrieve() .then([this](web::http::http_response resp) { - this->m_update_info = get_update_info_rpc(resp); + this->m_update_info = process_update_info_resp(resp); + SPDLOG_INFO("UpdateInfo has updated..."); is_fetching = false; emit isFetchingChanged(); emit updateInfoChanged(); diff --git a/src/core/atomicdex/services/update/zcash.params.service.cpp b/src/core/atomicdex/services/update/zcash.params.service.cpp index af8b1f5d29..ee04bd523d 100644 --- a/src/core/atomicdex/services/update/zcash.params.service.cpp +++ b/src/core/atomicdex/services/update/zcash.params.service.cpp @@ -45,7 +45,7 @@ namespace atomic_dex const auto now = std::chrono::high_resolution_clock::now(); const auto s = std::chrono::duration_cast(now - m_update_clock); - if (s >= 1s) + if (s >= 15s) { // TODO: We could use this for an ETA } diff --git a/src/core/atomicdex/utilities/global.utilities.cpp b/src/core/atomicdex/utilities/global.utilities.cpp index e045d9e469..d311c84537 100644 --- a/src/core/atomicdex/utilities/global.utilities.cpp +++ b/src/core/atomicdex/utilities/global.utilities.cpp @@ -154,14 +154,14 @@ namespace atomic_dex::utils } std::filesystem::path - get_mm2_atomic_dex_current_log_file() + get_kdf_atomic_dex_current_log_file() { using namespace std::chrono; using namespace date; static auto timestamp = duration_cast(system_clock::now().time_since_epoch()).count(); static date::sys_seconds tp{seconds{timestamp}}; static std::string s = date::format("%Y-%m-%d-%H-%M-%S", tp); - static const std::filesystem::path log_path = get_atomic_dex_logs_folder() / (s + ".mm2.log"); + static const std::filesystem::path log_path = get_atomic_dex_logs_folder() / (s + ".kdf.log"); return log_path; } @@ -220,9 +220,9 @@ namespace atomic_dex::utils std::filesystem::path get_current_configs_path() { - const auto fs_raw_mm2_shared_folder = get_atomic_dex_data_folder() / get_raw_version() / "configs"; - create_if_doesnt_exist(fs_raw_mm2_shared_folder); - return fs_raw_mm2_shared_folder; + const auto fs_raw_kdf_shared_folder = get_atomic_dex_data_folder() / get_raw_version() / "configs"; + create_if_doesnt_exist(fs_raw_kdf_shared_folder); + return fs_raw_kdf_shared_folder; } std::string diff --git a/src/core/atomicdex/utilities/global.utilities.hpp b/src/core/atomicdex/utilities/global.utilities.hpp index 64137e613c..9bd4eb3393 100644 --- a/src/core/atomicdex/utilities/global.utilities.hpp +++ b/src/core/atomicdex/utilities/global.utilities.hpp @@ -77,7 +77,7 @@ namespace atomic_dex::utils ENTT_API std::filesystem::path get_current_configs_path(); - std::filesystem::path get_mm2_atomic_dex_current_log_file(); + std::filesystem::path get_kdf_atomic_dex_current_log_file(); std::filesystem::path get_atomic_dex_config_folder(); diff --git a/src/core/atomicdex/utilities/safe.float.cpp b/src/core/atomicdex/utilities/safe.float.cpp index 62dea4f09a..05d924d736 100644 --- a/src/core/atomicdex/utilities/safe.float.cpp +++ b/src/core/atomicdex/utilities/safe.float.cpp @@ -19,12 +19,16 @@ safe_float(const std::string& from) { try { + if (from.empty()) + { + return t_float_50(0); + } t_float_50 out(boost::algorithm::replace_all_copy(from, ",", ".")); return out; } catch (const std::exception& error) { - SPDLOG_ERROR("exception caught when creating a floating point number: {}", error.what()); + SPDLOG_ERROR("exception caught when creating a floating point number from {}: {}", from, error.what()); //#if defined(linux) || defined(__APPLE__) // SPDLOG_ERROR("stacktrace: {}", boost::stacktrace::to_string(boost::stacktrace::stacktrace())); //#endif diff --git a/src/core/atomicdex/utilities/security.utilities.cpp b/src/core/atomicdex/utilities/security.utilities.cpp index 0fdcb101bd..2685d2717b 100644 --- a/src/core/atomicdex/utilities/security.utilities.cpp +++ b/src/core/atomicdex/utilities/security.utilities.cpp @@ -31,7 +31,7 @@ #include //! Project Headers -#include "atomicdex/api/mm2/mm2.error.code.hpp" +#include "atomicdex/api/kdf/kdf.error.code.hpp" #include "atomicdex/utilities/qt.utilities.hpp" #include "atomicdex/utilities/security.utilities.hpp" diff --git a/src/core/atomicdex/version/version.hpp b/src/core/atomicdex/version/version.hpp index a3126acaa9..747cf9a5fc 100644 --- a/src/core/atomicdex/version/version.hpp +++ b/src/core/atomicdex/version/version.hpp @@ -21,24 +21,24 @@ namespace atomic_dex constexpr const char* get_version() { - return "0.7.0-beta"; + return "0.8.2-beta"; } constexpr int get_num_version() noexcept { - return 70; + return 82; } constexpr const char* get_raw_version() { - return "0.7.0"; + return "0.8.2"; } constexpr const char* get_precedent_raw_version() { - return "0.6.1"; + return "0.8.1"; } } // namespace atomic_dex diff --git a/src/tests/api/mm2/enable_bch_with_tokens_rpc_tests.cpp b/src/tests/api/kdf/enable_bch_with_tokens_rpc_tests.cpp similarity index 97% rename from src/tests/api/mm2/enable_bch_with_tokens_rpc_tests.cpp rename to src/tests/api/kdf/enable_bch_with_tokens_rpc_tests.cpp index c8d6c738b0..d020a0de50 100644 --- a/src/tests/api/mm2/enable_bch_with_tokens_rpc_tests.cpp +++ b/src/tests/api/kdf/enable_bch_with_tokens_rpc_tests.cpp @@ -1,10 +1,10 @@ #include -#include "atomicdex/api/mm2/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.enable_bch_with_tokens_rpc.hpp" TEST_CASE("enable_bch_with_tokens_request_rpc serialization") { - using namespace atomic_dex::mm2; + using namespace atomic_dex::kdf; nlohmann::json result; enable_bch_with_tokens_request_rpc data @@ -49,7 +49,7 @@ TEST_CASE("enable_bch_with_tokens_request_rpc serialization") TEST_CASE("enable_bch_with_tokens_result_rpc deserialization") { - using namespace atomic_dex::mm2; + using namespace atomic_dex::kdf; enable_bch_with_tokens_result_rpc result; nlohmann::json json = nlohmann::json::parse(R"( diff --git a/src/tests/api/mm2/mm2.api.address_format.tests.cpp b/src/tests/api/kdf/kdf.api.address_format.tests.cpp similarity index 90% rename from src/tests/api/mm2/mm2.api.address_format.tests.cpp rename to src/tests/api/kdf/kdf.api.address_format.tests.cpp index 7b43419bb9..65ec78bb03 100644 --- a/src/tests/api/mm2/mm2.api.address_format.tests.cpp +++ b/src/tests/api/kdf/kdf.api.address_format.tests.cpp @@ -18,9 +18,9 @@ #include "doctest/doctest.h" #include -#include "atomicdex/api/mm2/address_format.hpp" +#include "atomicdex/api/kdf/address_format.hpp" -TEST_CASE("mm2::address_format serialisation") +TEST_CASE("kdf::address_format serialisation") { const nlohmann::json expected_json = R"( { @@ -28,7 +28,7 @@ TEST_CASE("mm2::address_format serialisation") "network":"bchtest" } )"_json; - atomic_dex::mm2::address_format_t req{.format = "cashaddress", .network = "bchtest"}; + atomic_dex::kdf::address_format_t req{.format = "cashaddress", .network = "bchtest"}; nlohmann::json j; to_json(j, req); diff --git a/src/tests/api/mm2/mm2.api.balance_infos.tests.cpp b/src/tests/api/kdf/kdf.api.balance_infos.tests.cpp similarity index 88% rename from src/tests/api/mm2/mm2.api.balance_infos.tests.cpp rename to src/tests/api/kdf/kdf.api.balance_infos.tests.cpp index 9b80fab15a..56762a9684 100644 --- a/src/tests/api/mm2/mm2.api.balance_infos.tests.cpp +++ b/src/tests/api/kdf/kdf.api.balance_infos.tests.cpp @@ -18,9 +18,9 @@ #include "doctest/doctest.h" #include -#include "atomicdex/api/mm2/balance_infos.hpp" +#include "atomicdex/api/kdf/balance_infos.hpp" -TEST_CASE("mm2::balance_infos deserialization") +TEST_CASE("kdf::balance_infos deserialization") { const nlohmann::json json = R"( { @@ -29,8 +29,8 @@ TEST_CASE("mm2::balance_infos deserialization") "unspendable":"0.00001" } })"_json; - atomic_dex::mm2::balance_infos infos; - atomic_dex::mm2::from_json(json.at("balances"), infos); + atomic_dex::kdf::balance_infos infos; + atomic_dex::kdf::from_json(json.at("balances"), infos); CHECK_EQ(infos.spendable, "0.11398301"); CHECK_EQ(infos.unspendable, "0.00001"); } \ No newline at end of file diff --git a/src/tests/api/mm2/mm2.api.utxo_merge_params.tests.cpp b/src/tests/api/kdf/kdf.api.utxo_merge_params.tests.cpp similarity index 88% rename from src/tests/api/mm2/mm2.api.utxo_merge_params.tests.cpp rename to src/tests/api/kdf/kdf.api.utxo_merge_params.tests.cpp index de8d38ccda..77538e2ca5 100644 --- a/src/tests/api/mm2/mm2.api.utxo_merge_params.tests.cpp +++ b/src/tests/api/kdf/kdf.api.utxo_merge_params.tests.cpp @@ -18,9 +18,9 @@ #include "doctest/doctest.h" #include -#include "atomicdex/api/mm2/utxo_merge_params.hpp" +#include "atomicdex/api/kdf/utxo_merge_params.hpp" -TEST_CASE("mm2::utxo_merge_params serialisation") +TEST_CASE("kdf::utxo_merge_params serialisation") { const nlohmann::json expected_json = R"( { @@ -29,8 +29,8 @@ TEST_CASE("mm2::utxo_merge_params serialisation") "max_merge_at_once":25 } )"_json; - atomic_dex::mm2::utxo_merge_params_t request{.merge_at = 50, .check_every = 10, .max_merge_at_once = 25}; + atomic_dex::kdf::utxo_merge_params_t request{.merge_at = 50, .check_every = 10, .max_merge_at_once = 25}; nlohmann::json j; - atomic_dex::mm2::to_json(j, request); + atomic_dex::kdf::to_json(j, request); CHECK_EQ(j, expected_json); } \ No newline at end of file diff --git a/src/tests/api/mm2/mm2.fraction.tests.cpp b/src/tests/api/kdf/kdf.fraction.tests.cpp similarity index 73% rename from src/tests/api/mm2/mm2.fraction.tests.cpp rename to src/tests/api/kdf/kdf.fraction.tests.cpp index 148edf607e..3d90c4eebd 100644 --- a/src/tests/api/mm2/mm2.fraction.tests.cpp +++ b/src/tests/api/kdf/kdf.fraction.tests.cpp @@ -12,9 +12,9 @@ #include //! Project Headers -#include "atomicdex/api/mm2/fraction.hpp" +#include "atomicdex/api/kdf/fraction.hpp" -TEST_CASE("atomic_dex::mm2::fraction deserialisation") +TEST_CASE("atomic_dex::kdf::fraction deserialisation") { nlohmann::json fraction_json = R"( { @@ -22,8 +22,8 @@ TEST_CASE("atomic_dex::mm2::fraction deserialisation") "numer": "333" } )"_json; - atomic_dex::mm2::fraction fraction; - atomic_dex::mm2::from_json(fraction_json, fraction); + atomic_dex::kdf::fraction fraction; + atomic_dex::kdf::from_json(fraction_json, fraction); CHECK_EQ(fraction.numer, "333"); CHECK_EQ(fraction.denom, "777"); diff --git a/src/tests/api/mm2/mm2.rpc2.trade_preimage.tests.cpp b/src/tests/api/kdf/kdf.rpc2.trade_preimage.tests.cpp similarity index 92% rename from src/tests/api/mm2/mm2.rpc2.trade_preimage.tests.cpp rename to src/tests/api/kdf/kdf.rpc2.trade_preimage.tests.cpp index ee920f3e43..345eb0ebdf 100644 --- a/src/tests/api/mm2/mm2.rpc2.trade_preimage.tests.cpp +++ b/src/tests/api/kdf/kdf.rpc2.trade_preimage.tests.cpp @@ -15,8 +15,8 @@ #include "../../atomic.dex.tests.hpp" //! Project Headers -#include "atomicdex/api/mm2/mm2.hpp" -#include "atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp" +#include "atomicdex/api/kdf/kdf.hpp" +#include "atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp" //! Constants namespace @@ -234,37 +234,37 @@ namespace })"_json; } // namespace -TEST_CASE("atomic_dex::mm2::preimage_request serialisation") +TEST_CASE("atomic_dex::kdf::preimage_request serialisation") { atomic_dex::t_trade_preimage_request request{.base_coin = "KMD", .rel_coin = "BTC", .swap_method = "buy", .volume = "10"}; nlohmann::json j; - atomic_dex::mm2::to_json(j, request); + atomic_dex::kdf::to_json(j, request); CHECK_EQ(j, g_preimage_request_buy_kmd_btc); } -TEST_CASE("atomic_dex::mm2::coin_fee deserialization") +TEST_CASE("atomic_dex::kdf::coin_fee deserialization") { - atomic_dex::mm2::coin_fee answer; - atomic_dex::mm2::from_json(g_coin_fee_answer, answer); + atomic_dex::kdf::coin_fee answer; + atomic_dex::kdf::from_json(g_coin_fee_answer, answer); CHECK_EQ("0.00042049", answer.amount); CHECK_EQ("BTC", answer.coin); CHECK_EQ("100000000", answer.amount_fraction.denom); } -TEST_CASE("atomic_dex::mm2::preimage_answer_success deserialization from buy") +TEST_CASE("atomic_dex::kdf::preimage_answer_success deserialization from buy") { - atomic_dex::mm2::trade_preimage_answer_success answer; - atomic_dex::mm2::from_json(g_preimage_answer_success_buy, answer); + atomic_dex::kdf::trade_preimage_answer_success answer; + atomic_dex::kdf::from_json(g_preimage_answer_success_buy, answer); CHECK(answer.taker_fee.has_value()); CHECK(answer.fee_to_send_taker_fee.has_value()); } -TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites") +TEST_SUITE("atomic_dex::kdf::preimage_answer deserialization test suites") { TEST_CASE("setprice BTC/DOC") { atomic_dex::t_trade_preimage_answer answer; - atomic_dex::mm2::from_json(g_preimage_answer_setprice, answer); + atomic_dex::kdf::from_json(g_preimage_answer_setprice, answer); CHECK(answer.result.has_value()); CHECK_FALSE(answer.error.has_value()); CHECK_FALSE(answer.result.value().fee_to_send_taker_fee.has_value()); @@ -273,7 +273,7 @@ TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites") TEST_CASE("buy BTC/DOC") { atomic_dex::t_trade_preimage_answer answer; - atomic_dex::mm2::from_json(g_preimage_answer_buy, answer); + atomic_dex::kdf::from_json(g_preimage_answer_buy, answer); CHECK(answer.result.has_value()); CHECK_FALSE(answer.error.has_value()); CHECK(answer.result.value().fee_to_send_taker_fee.has_value()); @@ -282,7 +282,7 @@ TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites") TEST_CASE("sell max BTC/DOC") { atomic_dex::t_trade_preimage_answer answer; - atomic_dex::mm2::from_json(g_preimage_answer_sell_max, answer); + atomic_dex::kdf::from_json(g_preimage_answer_sell_max, answer); CHECK(answer.result.has_value()); CHECK_FALSE(answer.error.has_value()); CHECK(answer.result.value().fee_to_send_taker_fee.has_value()); @@ -291,7 +291,7 @@ TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites") TEST_CASE("setprice ERC20 BAT/DOC") { atomic_dex::t_trade_preimage_answer answer; - atomic_dex::mm2::from_json(g_preimage_answer_setprice_erc, answer); + atomic_dex::kdf::from_json(g_preimage_answer_setprice_erc, answer); CHECK(answer.result.has_value()); CHECK_FALSE(answer.error.has_value()); CHECK_FALSE(answer.result.value().fee_to_send_taker_fee.has_value()); @@ -320,10 +320,10 @@ TEST_SUITE("atomic_dex::mm2::preimage_answer deserialization test suites") #include "atomicdex/tests/atomic.dex.tests.hpp" //! Project Headers - #include "atomicdex/api/mm2/mm2.hpp" - #include "atomicdex/api/mm2/rpc_v2/rpc2.trade_preimage.hpp" ///< replace this one by your current rpc file + #include "atomicdex/api/kdf/kdf.hpp" + #include "atomicdex/api/kdf/rpc_v2/rpc2.trade_preimage.hpp" ///< replace this one by your current rpc file */ -SCENARIO("atomic_dex::mm2::preimage scenario") +SCENARIO("atomic_dex::kdf::preimage scenario") { /** * Checking that the test context is valid @@ -335,15 +335,15 @@ SCENARIO("atomic_dex::mm2::preimage scenario") CHECK(batch.is_array()); //! Prepare request template - nlohmann::json request_json = atomic_dex::mm2::template_request("trade_preimage", true); + nlohmann::json request_json = atomic_dex::kdf::template_request("trade_preimage", true); - //! Retrieve mm2 service - auto& mm2 = g_context->system_manager().get_system(); + //! Retrieve kdf service + auto& kdf = g_context->system_manager().get_system(); //! Generic resp functor that will be used in every tests - auto generic_resp_process = [&mm2, &batch]() { + auto generic_resp_process = [&kdf, &batch]() { //! Process the actual request - const auto resp = mm2.get_mm2_client().async_rpc_batch_standalone(batch).get(); + const auto resp = kdf.get_kdf_client().async_rpc_batch_standalone(batch).get(); //! Retrieve the body std::string body = TO_STD_STR(resp.extract_string(true).get()); @@ -368,7 +368,7 @@ SCENARIO("atomic_dex::mm2::preimage scenario") CHECK(batch.empty()); //! Give the concrete C++ type - here it's atomic_dex::t_trade_preimage_answer - return atomic_dex::mm2::rpc_process_answer_batch(answers[0], "trade_preimage"); + return atomic_dex::kdf::rpc_process_answer_batch(answers[0], "trade_preimage"); }; //! A test with DOC/MARTY @@ -378,7 +378,7 @@ SCENARIO("atomic_dex::mm2::preimage scenario") atomic_dex::t_trade_preimage_request request{.base_coin = "DOC", .rel_coin = "MARTY", .swap_method = "buy", .volume = "1", .price = "1"}; //! Transform request into json - atomic_dex::mm2::to_json(request_json, request); + atomic_dex::kdf::to_json(request_json, request); //! Add it to the batch request batch.push_back(request_json); @@ -406,7 +406,7 @@ SCENARIO("atomic_dex::mm2::preimage scenario") GIVEN("Preparing a wrong request DOC/NONEXISTENT coin") { atomic_dex::t_trade_preimage_request request{.base_coin = "DOC", .rel_coin = "NONEXISTENT", .swap_method = "buy", .volume = "1"}; - atomic_dex::mm2::to_json(request_json, request); + atomic_dex::kdf::to_json(request_json, request); batch.push_back(request_json); auto copy_request = request_json; copy_request["userpass"] = ""; diff --git a/src/tests/atomic.dex.provider.cex.prices.tests.cpp b/src/tests/atomic.dex.provider.cex.prices.tests.cpp index 3f2772cd94..f8a519c7a8 100644 --- a/src/tests/atomic.dex.provider.cex.prices.tests.cpp +++ b/src/tests/atomic.dex.provider.cex.prices.tests.cpp @@ -28,8 +28,8 @@ TEST_CASE("atomic dex cex prices provider constructor") //entt::registry registry; //ag::ecs::system_manager mgr{registry}; //registry.set(); - //atomic_dex::mm2 mm2(registry, mgr); - //atomic_dex::ohlc_provider provider(registry, mm2); + //atomic_dex::kdf kdf(registry, mgr); + //atomic_dex::ohlc_provider provider(registry, kdf); } /*SCENARIO("atomic dex cex price service functionnality") @@ -41,12 +41,12 @@ TEST_CASE("atomic dex cex prices provider constructor") entt::registry registry; registry.set(); antara::gaming::ecs::system_manager system_manager_{registry}; - auto& mm2_s = system_manager_.create_system(); - auto& cex_system = system_manager_.create_system(mm2_s); + auto& kdf_s = system_manager_.create_system(); + auto& cex_system = system_manager_.create_system(kdf_s); - THEN("I start mm2") + THEN("I start kdf") { - registry.ctx().trigger(); + registry.ctx().trigger(); AND_WHEN("i set the current orderbook pair to a valid supported pair (kmd-btc)") { diff --git a/src/tests/atomic.dex.tests.hpp b/src/tests/atomic.dex.tests.hpp index 09fe13824f..c7e8600eac 100644 --- a/src/tests/atomic.dex.tests.hpp +++ b/src/tests/atomic.dex.tests.hpp @@ -23,7 +23,7 @@ #include "atomicdex/events/events.hpp" #include "atomicdex/managers/qt.wallet.manager.hpp" #include "atomicdex/pages/qt.portfolio.page.hpp" -#include "atomicdex/services/mm2/mm2.service.hpp" +#include "atomicdex/services/kdf/kdf.service.hpp" struct tests_context : public antara::gaming::world::app { @@ -53,8 +53,8 @@ struct tests_context : public antara::gaming::world::app { #if !defined(WIN32) && !defined(_WIN32) this->dispatcher_.sink().connect<&tests_context::on_coin_initialized>(*this); - //! Creates mm2 service. - auto& mm2 = system_manager_.create_system(system_manager_); + //! Creates kdf service. + auto& kdf = system_manager_.create_system(system_manager_); //! Creates special wallet for the unit tests then logs to it. auto& wallet_manager = system_manager_.create_system(system_manager_); @@ -92,15 +92,15 @@ struct tests_context : public antara::gaming::world::app } wallet_manager.login(test_password != nullptr ? test_password : "fakepasswordtemporary", "komodo-wallet_tests"); - //! Waits for mm2 to be initialized before running tests - while (!mm2.is_mm2_running() && !m_test_context_ready) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } - const auto& enabled_coins = mm2.get_enabled_coins(); + //! Waits for kdf to be initialized before running tests + while (!kdf.is_kdf_running() && !m_test_context_ready) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } + const auto& enabled_coins = kdf.get_enabled_coins(); bool found = std::any_of(enabled_coins.begin(), enabled_coins.end(), [](const auto& item) -> bool { return item.ticker == "tBTC-TEST" || item.ticker == "tQTUM"; }); if (!found) { SPDLOG_INFO("Extra coins not enabled yet, enabling now"); - mm2.enable_coins(m_extra_coins); + kdf.enable_coins(m_extra_coins); } while (!m_extra_coins_ready) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } //! At this point BTC/KMD are enabled but we need ERC20 and QRC20 too / change login behaviour ? diff --git a/src/tests/config/coins.cfg.tests.cpp b/src/tests/config/coins.cfg.tests.cpp index 14f47460d0..82493f1437 100644 --- a/src/tests/config/coins.cfg.tests.cpp +++ b/src/tests/config/coins.cfg.tests.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include constexpr const char* g_komodolive_endpoint = "http://95.216.160.96:8080/api/v1"; @@ -21,7 +21,7 @@ t_http_client_ptr g_komodolive_client{std::make_unique(FROM_S TEST_CASE("generate all coinpaprika possibilities") { #if defined(__APPLE__) - const auto resp = atomic_dex::mm2::async_process_rpc_get(g_komodolive_client, "tickers", "/ticker").get(); + const auto resp = atomic_dex::kdf::async_process_rpc_get(g_komodolive_client, "tickers", "/ticker").get(); std::string body = TO_STD_STR(resp.extract_string(true).get()); nlohmann::json j_metrics = nlohmann::json::parse(body); nlohmann::json metrics = nlohmann::json::object(); diff --git a/vcpkg.json b/vcpkg.json index a8b3291ae0..78278f8556 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "firodex-wallet", - "version-string": "0.7.0", + "version-string": "0.7.2", "dependencies": [ "entt", "boost-multiprecision", diff --git a/version.json b/version.json new file mode 100644 index 0000000000..7b5d0749d5 --- /dev/null +++ b/version.json @@ -0,0 +1,4 @@ +{ + "version": "0.8.2", + "update": "required" +} \ No newline at end of file