diff --git a/.github/workflows/atomicdex-desktop-ci.yml b/.github/workflows/atomicdex-desktop-ci.yml index b2ee3f70cc..9979d90b82 100644 --- a/.github/workflows/atomicdex-desktop-ci.yml +++ b/.github/workflows/atomicdex-desktop-ci.yml @@ -28,31 +28,50 @@ jobs: fail-fast: false matrix: name: [ - ubuntu-qt-5-15-2, - osx-qt-5-15-2, - windows-10-qt-5-15-2 + ubuntu-release, + ubuntu-debug, + osx-release, + osx-debug, + windows-release, + windows-debug ] include: - - name: ubuntu-qt-5-15-2 - os: ubuntu-18.04 + - name: ubuntu-release + os: ubuntu-latest qt: '5.15.2' - type: 'release' + type: 'Release' + host: 'linux' - - name: osx-qt-5-15-2 - os: macos-latest + - name: ubuntu-debug + os: ubuntu-latest qt: '5.15.2' - type: 'release' + type: 'Debug' + host: 'linux' - - name: windows-10-qt-5-15-2 + - name: osx-release + os: macos-11 + qt: '5.15.2' + type: 'Release' + host: 'mac' + + - name: osx-debug + os: macos-11 + qt: '5.15.2' + type: 'Debug' + host: 'mac' + + - name: windows-release os: windows-latest qt: '5.15.2' - type: 'release' + type: 'Release' + host: 'windows' - #- name: osx-qt-5-15-2-dbg - # os: macos-latest - # qt: '5.15.2' - # type: 'debug' + - name: windows-debug + os: windows-latest + qt: '5.15.2' + type: 'Debug' + host: 'windows' steps: - uses: actions/checkout@v2 @@ -78,7 +97,6 @@ jobs: git submodule init git submodule sync --recursive git submodule update --init --recursive - Get-ChildItem -Filter build -Recurse -ErrorAction SilentlyContinue $env:LIBWALLY_DIR='${{ github.workspace }}\libwally-core' "$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 @@ -87,55 +105,53 @@ jobs: Copy-Item "${{ github.workspace }}\libwally-core\wally.dll" -Destination "${{ github.workspace }}\wally\wally.dll" -force - - name: Install QT (Linux) - if: runner.os == 'Linux' + - name: Install QT (macOS) + if: runner.os == 'macOS' uses: KomodoPlatform/install-qt-action@v2.14.0 with: version: ${{ matrix.qt }} setup-python: 'false' - host: 'linux' + host: ${{ matrix.host }} target: 'desktop' dir: '${{ github.workspace }}' modules: 'qtcharts qtwidgets debug_info qtwebengine qtwebview' - aqtversion: '==0.8' - py7zrversion: '==0.6' - - name: Install QT (MacOS) - if: runner.os == 'macOS' + - name: Install QT (Linux) + if: runner.os == 'Linux' uses: KomodoPlatform/install-qt-action@v2.14.0 with: version: ${{ matrix.qt }} setup-python: 'false' - host: 'mac' + host: ${{ matrix.host }} target: 'desktop' dir: '${{ github.workspace }}' - modules: 'qtcharts qtwidgets debug_info qtwebview qtwebengine' - - - name: Install QT IFW (MacOS) - if: runner.os == 'macOS' - run: | - python3 -m aqt tool mac tools_ifw 4.4.2 qt.tools.ifw.44 --outputdir ${{ github.workspace }}/Qt - echo "${{ github.workspace }}/Qt/Tools/QtInstallerFramework/4.4/bin" >> $GITHUB_PATH + modules: 'qtcharts qtwidgets debug_info qtwebengine qtwebview' + aqtversion: '==0.8' + py7zrversion: '==0.6' - name: Install QT (Windows) if: runner.os == 'Windows' uses: KomodoPlatform/install-qt-action@v2.14.0 with: version: ${{ matrix.qt }} - host: 'windows' + host: ${{ matrix.host }} target: 'desktop' arch: 'win64_msvc2019_64' dir: 'C:\' modules: 'qtcharts qtwidgets debug_info qtwebview qtwebengine' + - name: Install QT IFW (MacOS) + if: runner.os == 'macOS' + run: | + python3 -m aqt tool ${{ matrix.host }} tools_ifw 4.4.2 qt.tools.ifw.44 --outputdir ${{ github.workspace }}/Qt + echo "${{ github.workspace }}/Qt/Tools/QtInstallerFramework/4.4/bin" >> $GITHUB_PATH + - name: Install QT IFW (Windows) if: runner.os == 'Windows' run: | python -m pip install --upgrade pip - python -m aqt tool windows tools_ifw 4.4.2 qt.tools.ifw.44 --outputdir C:/Qt + python -m aqt tool ${{ matrix.host }} tools_ifw 4.4.2 qt.tools.ifw.44 --outputdir C:/Qt echo "C:/Qt/Tools/QtInstallerFramework/4.4/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo $env:GITHUB_PATH - echo $env:PATH - name: Install nim (Linux) if: runner.os == 'Linux' @@ -148,7 +164,6 @@ jobs: chmod +x choosenim.sh ./choosenim.sh -y export PATH=/home/runner/.nimble/bin:$PATH - ls /home/runner/.choosenim/toolchains chmod +x /home/runner/.choosenim/toolchains/nim-1.4.8/bin/* - name: Install deps (Linux) @@ -158,21 +173,6 @@ jobs: echo ${{ github.sha }} sudo ./ci_tools_atomic_dex/ci_scripts/linux_script.sh - - name: Upload env variable for vpkg (Linux) - if: runner.os == 'Linux' - run: | - #echo "CXXFLAGS=-stdlib=libc++" >> $GITHUB_ENV - #echo "LDFLAGS=-stdlib=libc++" >> $GITHUB_ENV - echo "CXX=clang++-12" >> $GITHUB_ENV - echo "CC=clang-12" >> $GITHUB_ENV - - - name: vcpkg deps (All) - uses: KomodoPlatform/run-vcpkg@v7 - with: - vcpkgDirectory: '${{ github.workspace }}/ci_tools_atomic_dex/vcpkg-repo' - setupOnly: true - appendedCacheKey: ${{ hashFiles('vcpkg.json') }} - - name: Install deps (MacOS) if: runner.os == 'macOS' run: | @@ -184,25 +184,22 @@ jobs: echo "CXX=/usr/local/opt/llvm/bin/clang++" >> $GITHUB_ENV echo "CC=/usr/local/opt/llvm/bin/clang" >> $GITHUB_ENV - - name: Build AtomicDEX (Linux) + - name: Upload env variable for vpkg (Linux) if: runner.os == 'Linux' run: | - export QT_INSTALL_CMAKE_PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/gcc_64/lib/cmake - export QT_ROOT=${{ github.workspace }}/Qt/${{ matrix.qt }} - export PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/gcc_64/bin:$PATH - export PATH=$HOME/.nimble/bin:$PATH - #export CXXFLAGS=-stdlib=libc++ - #export LDFLAGS=-stdlib=libc++ - export CXX=clang++-12 - export CC=clang-12 - cd ci_tools_atomic_dex - nimble build -y + echo "CXX=clang++-12" >> $GITHUB_ENV + echo "CC=clang-12" >> $GITHUB_ENV + + - name: vcpkg deps (All) + uses: KomodoPlatform/run-vcpkg@v7 + with: + vcpkgDirectory: '${{ github.workspace }}/ci_tools_atomic_dex/vcpkg-repo' + setupOnly: true + appendedCacheKey: ${{ hashFiles('vcpkg.json') }} - ./ci_tools_atomic_dex build release - ./ci_tools_atomic_dex bundle release - name: import code signing certificates (macos) - if: runner.os == 'macOS' + if: runner.os == 'macOS' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository uses: Apple-Actions/import-codesign-certs@v1 with: keychain: ${{ github.run_id }} @@ -211,7 +208,7 @@ jobs: p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} - name: import installer code signing certificates (macos) - if: runner.os == 'macOS' + if: runner.os == 'macOS' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository uses: apple-actions/import-codesign-certs@v1 with: keychain: ${{ github.run_id }} @@ -220,6 +217,8 @@ jobs: p12-file-base64: ${{ secrets.CERTIFICATES_INSTALLER_P12 }} p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }} + + - name: Build AtomicDEX (MacOS) if: runner.os == 'macOS' run: | @@ -237,20 +236,10 @@ jobs: nimble build -y ./ci_tools_atomic_dex bundle ${{ matrix.type }} --osx_sdk=$HOME/sdk/MacOSX10.14.sdk --compiler=clang++ - - name: Build AtomicDEX (Windows) - if: runner.os == 'Windows' - shell: powershell - run: | - $Env:QT_VERSION = "${{ matrix.qt }}" - .\ci_tools_atomic_dex\ci_scripts\windows_script.ps1 - - name: Running Tests (Linux) - working-directory: ci_tools_atomic_dex - if: runner.os == 'Linux' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository + - name: Build AtomicDEX (Linux) + if: runner.os == 'Linux' run: | - export REPORT_CI_TOKEN=${{ secrets.REPORT_CI_TOKEN_SECRET }} - export ATOMICDEX_TEST_SEED=${{ secrets.ATOMICDEX_TEST_SEED }} - export ATOMICDEX_PASSWORD=${{ secrets.ATOMICDEX_PASSWORD }} export QT_INSTALL_CMAKE_PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/gcc_64/lib/cmake export QT_ROOT=${{ github.workspace }}/Qt/${{ matrix.qt }} export PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/gcc_64/bin:$PATH @@ -259,57 +248,31 @@ jobs: #export LDFLAGS=-stdlib=libc++ export CXX=clang++-12 export CC=clang-12 - echo "Running tests" - ./ci_tools_atomic_dex tests release - cd build-Release/bin/AntaraAtomicDexTestsAppDir/usr/bin - cat ${{ env.DEX_PROJECT_NAME }}-tests-result.xml - #curl https://report.ci/upload.py --output upload.py - ls - #python upload.py --sha `git rev-parse HEAD` -n "[Doctest Linux]" --include='${{ env.DEX_PROJECT_NAME }}-tests-result.xml' --framework=doctest --merge ".*" - #echo "Uploading tests on Linux finished" + cd ci_tools_atomic_dex + nimble build -y - - name: Running Tests (MacOS) - working-directory: ci_tools_atomic_dex - if: runner.os == 'macOS' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository - run: | - export REPORT_CI_TOKEN=${{ secrets.REPORT_CI_TOKEN_SECRET }} - export ATOMICDEX_TEST_SEED=${{ secrets.ATOMICDEX_TEST_SEED }} - export ATOMICDEX_PASSWORD=${{ secrets.ATOMICDEX_PASSWORD }} - export QT_INSTALL_CMAKE_PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/clang_64/lib/cmake - export QT_ROOT=${{ github.workspace }}/Qt/${{ matrix.qt }} - export CC=clang - export CXX=clang++ - echo "Running tests" - #./ci_tools_atomic_dex tests ${{ matrix.type }} - #cd build-${{ matrix.type }}/bin/${{ env.DEX_PROJECT_NAME }}_tests.app/Contents/MacOS - #cat ${{ env.DEX_PROJECT_NAME }}-tests-result.xml - #curl https://report.ci/upload.py --output upload.py - ls - #python upload.py --sha `git rev-parse HEAD` -n "[Doctest MacOS ${{ matrix.type }}]" --include='${{ env.DEX_PROJECT_NAME }}-tests-result.xml' --framework=doctest --merge ".*" - #echo "Uploading tests on OSX finished" + ./ci_tools_atomic_dex build ${{ matrix.type }} + ./ci_tools_atomic_dex bundle ${{ matrix.type }} - - name: Running Tests (Windows) + + - name: Build AtomicDEX (Windows) + if: runner.os == 'Windows' shell: powershell - if: runner.os == 'Windows' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository run: | - echo "Running tests" - $Env:REPORT_CI_TOKEN = "${{ secrets.REPORT_CI_TOKEN_SECRET }}" - $Env:QT_INSTALL_CMAKE_PATH = "C:\Qt\${{ matrix.qt }}\msvc2019_64" - cd b\bin - ./${{ env.DEX_PROJECT_NAME }}_tests.exe --reporters=xml --out=${{ env.DEX_PROJECT_NAME }}-tests-result.xml -s - #Invoke-WebRequest -Uri https://report.ci/upload.py -OutFile upload.py - #python upload.py --sha $(git rev-parse HEAD) -n "[Doctest Windows]" --include='${{ env.DEX_PROJECT_NAME }}-tests-result.xml' --framework=doctest --merge ".*" + $Env:QT_VERSION = "${{ matrix.qt }}" + .\ci_tools_atomic_dex\ci_scripts\windows_script.ps1 - name: Upload env variable for artifacts (Linux) if: runner.os == 'Linux' run: | - ls ./bundled/linux/ echo "artifact_name_zstd=${{ env.DEX_PROJECT_NAME }}-${{ matrix.name }}-$(git rev-parse --short HEAD).tar.zst" >> $GITHUB_ENV echo "artifact_name_zip=${{ env.DEX_PROJECT_NAME }}-${{ matrix.name }}-$(git rev-parse --short HEAD).zip" >> $GITHUB_ENV echo "artifact_name_appimage=${{ env.DEX_PROJECT_NAME }}-${{ matrix.name }}-$(git rev-parse --short HEAD)-x86_64.AppImage" >> $GITHUB_ENV echo "target_name_zstd=${{ env.DEX_PROJECT_NAME }}-linux-$(git rev-parse --short HEAD).tar.zst" >> $GITHUB_ENV 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 }}-$(git rev-parse --short HEAD)-x86_64.AppImage" >> $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' @@ -338,7 +301,6 @@ jobs: - name: Upload env variable for artifacts (macOS) if: runner.os == 'macOS' run: | - ls ./bundled/osx/ echo "artifact_name_dmg=${{ env.DEX_PROJECT_NAME }}-${{ matrix.name }}-$(git rev-parse --short HEAD).dmg" >> $GITHUB_ENV echo "artifact_name_installer=${{ env.DEX_PROJECT_NAME }}-installer-${{ matrix.name }}-$(git rev-parse --short HEAD).7z" >> $GITHUB_ENV @@ -363,7 +325,7 @@ jobs: run: | echo "on_windows" echo "artifact_name_zip=${{ env.DEX_PROJECT_NAME }}-${{ matrix.name }}-$(git rev-parse --short HEAD).zip" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "artifact_name_installer=${{ env.DEX_PROJECT_NAME }}-installer-${{ matrix.name }}-$(git rev-parse --short HEAD).exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "artifact_name_installer=${{ env.DEX_PROJECT_NAME }}-${{ matrix.name }}-installer-$(git rev-parse --short HEAD).exe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Upload artifacts (Windows zip) if: runner.os == 'Windows' @@ -380,3 +342,61 @@ jobs: 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 + if: runner.os == 'Linux' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository + run: | + export REPORT_CI_TOKEN=${{ secrets.REPORT_CI_TOKEN_SECRET }} + export ATOMICDEX_TEST_SEED=${{ secrets.ATOMICDEX_TEST_SEED }} + export ATOMICDEX_PASSWORD=${{ secrets.ATOMICDEX_PASSWORD }} + export QT_INSTALL_CMAKE_PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/gcc_64/lib/cmake + export QT_ROOT=${{ github.workspace }}/Qt/${{ matrix.qt }} + export PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/gcc_64/bin:$PATH + export PATH=$HOME/.nimble/bin:$PATH + export CXX=clang++-12 + export CC=clang-12 + #echo "Running tests" + #./ci_tools_atomic_dex tests ${{ matrix.type }} + #cd build-${{ matrix.type }}/bin/AntaraAtomicDexTestsAppDir/usr/bin + #cat ${{ env.DEX_PROJECT_NAME }}-tests-result.xml + + - name: Running Tests (MacOS) + working-directory: ci_tools_atomic_dex + continue-on-error: true + if: runner.os == 'macOS' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository + run: | + export MAC_SIGN_IDENTITY="${{ secrets.MAC_SIGN_IDENTITY }}" + export INSTALLER_MAC_SIGN_IDENTITY="${{ secrets.INSTALLER_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 REPORT_CI_TOKEN=${{ secrets.REPORT_CI_TOKEN_SECRET }} + export ATOMICDEX_TEST_SEED=${{ secrets.ATOMICDEX_TEST_SEED }} + export ATOMICDEX_PASSWORD=${{ secrets.ATOMICDEX_PASSWORD }} + export QT_INSTALL_CMAKE_PATH=${{ github.workspace }}/Qt/${{ matrix.qt }}/clang_64/lib/cmake + export QT_ROOT=${{ github.workspace }}/Qt/${{ matrix.qt }} + export CC=clang + export CXX=clang++ + #echo "Running tests" + #nimble build -y + #./ci_tools_atomic_dex tests ${{ matrix.type }} + #cd build-${{ matrix.type }}/bin/${{ env.DEX_PROJECT_NAME }}_tests.app/Contents/MacOS + #cat ${{ env.DEX_PROJECT_NAME }}-tests-result.xml + + - name: Running Tests (Windows) + shell: powershell + continue-on-error: true + if: runner.os == 'Windows' && 'KomodoPlatform/atomicDEX-Desktop' == github.repository + run: | + #echo "Running tests" + $Env:REPORT_CI_TOKEN = "${{ secrets.REPORT_CI_TOKEN_SECRET }}" + $Env:QT_INSTALL_CMAKE_PATH = "C:\Qt\${{ matrix.qt }}\msvc2019_64" + #cd b\bin + #./${{ env.DEX_PROJECT_NAME }}_tests.exe --reporters=xml --out=${{ env.DEX_PROJECT_NAME }}-tests-result.xml -s + #Invoke-WebRequest -Uri https://report.ci/upload.py -OutFile upload.py + #python upload.py --sha $(git rev-parse HEAD) -n "[Doctest Windows]" --include='${{ env.DEX_PROJECT_NAME }}-tests-result.xml' --framework=doctest --merge ".*" \ No newline at end of file diff --git a/ci_tools_atomic_dex/src/ci_tools_atomic_dex.nim b/ci_tools_atomic_dex/src/ci_tools_atomic_dex.nim index feb24df7e3..ab8425ffa5 100644 --- a/ci_tools_atomic_dex/src/ci_tools_atomic_dex.nim +++ b/ci_tools_atomic_dex/src/ci_tools_atomic_dex.nim @@ -16,11 +16,11 @@ Atomic Dex CI Tools. Usage: ci_tools_atomic_dex --install_vcpkg ci_tools_atomic_dex --install_dependencies - ci_tools_atomic_dex build (release|debug) [--osx_sdk=] [--compiler=] + ci_tools_atomic_dex build (Release|Debug) [--osx_sdk=] [--compiler=] ci_tools_atomic_dex clean (full|dependencies|build_dir) - ci_tools_atomic_dex generate (release|debug) [--osx_sdk=] [--compiler=] - ci_tools_atomic_dex bundle (release|debug) [--osx_sdk=] [--compiler=] - ci_tools_atomic_dex tests (release|debug) [--osx_sdk=] [--compiler=] + ci_tools_atomic_dex generate (Release|Debug) [--osx_sdk=] [--compiler=] + ci_tools_atomic_dex bundle (Release|Debug) [--osx_sdk=] [--compiler=] + ci_tools_atomic_dex tests (Release|Debug) [--osx_sdk=] [--compiler=] ci_tools_atomic_dex --version ci_tools_atomic_dex (-h | --help) @@ -32,30 +32,37 @@ Options: proc main() = let args = docopt(doc, version = "Atomic Dex CI Tools 0.0.1") vcpkg_prepare() + if args["--install_vcpkg"]: install_vcpkg() + elif args["--install_dependencies"]: download_packages() + elif args["generate"]: - if args["release"]: + if args["Release"]: generate_solution("Release", $args["--osx_sdk"], $args["--compiler"]) - elif args["debug"]: + elif args["Debug"]: generate_solution("Debug", $args["--osx_sdk"], $args["--compiler"]) + elif args["build"]: - if args["release"]: + if args["Release"]: build_atomic_qt("Release", $args["--osx_sdk"], $args["--compiler"]) - elif args["debug"]: + elif args["Debug"]: build_atomic_qt("Debug", $args["--osx_sdk"], $args["--compiler"]) + elif args["bundle"]: - if args["release"]: + if args["Release"]: bundle("Release", $args["--osx_sdk"], $args["--compiler"]) - elif args["debug"]: + elif args["Debug"]: bundle("Debug", $args["--osx_sdk"], $args["--compiler"]) + elif args["tests"]: - if args["release"]: + if args["Release"]: run_tests("Release", $args["--osx_sdk"], $args["--compiler"]) - elif args["debug"]: + elif args["Debug"]: run_tests("Debug", $args["--osx_sdk"], $args["--compiler"]) + elif args["clean"]: if args["full"]: clean("full") diff --git a/ci_tools_atomic_dex/src/tests.nim b/ci_tools_atomic_dex/src/tests.nim index 0b8240610a..78ee2980ff 100644 --- a/ci_tools_atomic_dex/src/tests.nim +++ b/ci_tools_atomic_dex/src/tests.nim @@ -12,8 +12,26 @@ proc run_tests*(build_type: string, osx_sdk_path: string, compiler_path: string) generate_solution(build_type, osx_sdk_path, compiler_path) when defined(osx): + echo "CURRENT OSX FOLDER" echo os.getCurrentDir() - os.setCurrentDir(os.getCurrentDir().joinPath("bin").joinPath(os.getEnv("DEX_PROJECT_NAME") & "_tests.app").joinPath("Contents").joinPath("MacOS")) + discard osproc.execCmd("ls") + os.setCurrentDir(os.getCurrentDir().joinPath("bin")) + echo "CURRENT OSX FOLDER" + echo os.getCurrentDir() + discard osproc.execCmd("ls") + os.setCurrentDir(os.getCurrentDir().joinPath(os.getEnv("DEX_PROJECT_NAME") & "_tests.app")) + echo "CURRENT OSX FOLDER" + echo os.getCurrentDir() + discard osproc.execCmd("ls") + os.setCurrentDir(os.getCurrentDir().joinPath("Contents")) + echo "CURRENT OSX FOLDER" + echo os.getCurrentDir() + discard osproc.execCmd("ls") + os.setCurrentDir(os.getCurrentDir().joinPath("MacOS")) + echo "CURRENT OSX FOLDER" + echo os.getCurrentDir() + discard osproc.execCmd("ls") + # os.setCurrentDir(os.getCurrentDir().joinPath("bin").joinPath(os.getEnv("DEX_PROJECT_NAME") & "_tests.app").joinPath("Contents").joinPath("MacOS")) echo "Running AtomicDex Pro Unit tests" discard osproc.execCmd("./" & os.getEnv("DEX_PROJECT_NAME") & "_tests --reporters=xml --out=" & os.getEnv("DEX_PROJECT_NAME") & "-tests-result.xml -s") echo "Successfully Generated", os.getEnv("DEX_PROJECT_NAME"), "-tests-result.xml" diff --git a/cmake/install/linux/linux_post_install.cmake b/cmake/install/linux/linux_post_install.cmake index 246a03f62e..23eae65e00 100644 --- a/cmake/install/linux/linux_post_install.cmake +++ b/cmake/install/linux/linux_post_install.cmake @@ -5,20 +5,26 @@ execute_process(COMMAND bash -c "echo -n `git rev-parse --short HEAD`" OUTPUT_VARIABLE VERSION_ID ) +message(STATUS "PROJECT_ROOT_DIR (before readjusting) -> ${PROJECT_ROOT_DIR}") + get_filename_component(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR} DIRECTORY) -if (EXISTS ${PROJECT_ROOT_DIR}/build-Release) +if (EXISTS ${PROJECT_ROOT_DIR}/build-Release OR EXISTS ${PROJECT_ROOT_DIR}/build-Debug) message(STATUS "from ci tools, readjusting") get_filename_component(PROJECT_ROOT_DIR ${PROJECT_ROOT_DIR} DIRECTORY) endif () -message(STATUS "PROJECT_ROOT_DIR -> ${PROJECT_ROOT_DIR}") set(PROJECT_QML_DIR ${PROJECT_ROOT_DIR}/atomic_defi_design/Dex) -message(STATUS "PROJECT_QML_DIR -> ${PROJECT_QML_DIR}") set(PROJECT_APP_DIR AntaraAtomicDexAppDir) set(PROJECT_APP_PATH ${CMAKE_SOURCE_DIR}/bin/${PROJECT_APP_DIR}) set(PROJECT_BIN_PATH ${PROJECT_APP_PATH}/usr/bin/${DEX_PROJECT_NAME}) set(PROJECT_LIB_PATH ${PROJECT_APP_PATH}/usr/lib) set(TARGET_APP_PATH ${PROJECT_ROOT_DIR}/bundled/linux) + +message(STATUS "VCPKG package manager enabled") +message(STATUS "PROJECT_ROOT_DIR (after readjusting) -> ${PROJECT_ROOT_DIR}") +message(STATUS "PROJECT_QML_DIR -> ${PROJECT_QML_DIR}") +message(STATUS "VERSION_ID -> ${VERSION_ID}") + if (EXISTS ${PROJECT_APP_PATH}) message(STATUS "PROJECT_APP_PATH path is -> ${PROJECT_APP_PATH}") message(STATUS "PROJECT_BIN_PATH path is -> ${PROJECT_BIN_PATH}") @@ -28,16 +34,13 @@ else () message(FATAL_ERROR "Didn't find ${PROJECT_APP_PATH}") endif () -message(STATUS "VCPKG package manager enabled") set(LINUX_DEPLOY_PATH ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/linux_misc/linuxdeployqt-7-x86_64.AppImage) - if (EXISTS ${LINUX_DEPLOY_PATH}) message(STATUS "linuxdeployqt path is -> ${LINUX_DEPLOY_PATH}") else () message(FATAL_ERROR "Didn't find ${LINUX_DEPLOY_PATH}") endif () - message(STATUS "Copying required libraries for QtWebEngine") list(APPEND LIST_LIBS "/usr/lib/x86_64-linux-gnu/libsmime3.so" @@ -49,26 +52,35 @@ list(APPEND LIST_LIBS "/usr/lib/x86_64-linux-gnu/nss/libnssdbm3.so" "/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.chk" "/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so") + file(COPY ${PROJECT_APP_PATH}/usr/share/icons/default/64x64/apps/dex-logo-64.png DESTINATION ${PROJECT_APP_PATH}) file(COPY ${PROJECT_APP_PATH}/usr/share/applications/dex.desktop DESTINATION ${PROJECT_APP_PATH}) + foreach (current_lib ${LIST_LIBS}) message(STATUS "copying ${current_lib} to ${PROJECT_LIB_PATH}") file(COPY ${current_lib} DESTINATION ${PROJECT_LIB_PATH}) 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 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) + +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) + 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 WORKING_DIRECTORY ${TARGET_APP_PATH} ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) + execute_process(COMMAND tar --zstd -cf ${DEX_PROJECT_NAME}-linux-${VERSION_ID}.tar.zst AntaraAtomicDexAppDir WORKING_DIRECTORY ${TARGET_APP_PATH} ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) -file(COPY ${CMAKE_SOURCE_DIR}/${DEX_PROJECT_NAME}-${VERSION_ID}-x86_64.AppImage DESTINATION ${TARGET_APP_PATH}) \ No newline at end of file + +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 c2b835a81c..b407e987e5 100644 --- a/cmake/install/macos/osx_post_install.cmake +++ b/cmake/install/macos/osx_post_install.cmake @@ -1,38 +1,43 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../project.metadata.cmake) +message(STATUS "OSX POST INSTALL CMAKE") +message(STATUS "PROJECT_ROOT_DIR (before readjusting) -> ${PROJECT_ROOT_DIR}") + get_filename_component(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR} DIRECTORY) if (EXISTS ${PROJECT_ROOT_DIR}/build-Release OR EXISTS ${PROJECT_ROOT_DIR}/build-Debug) message(STATUS "from ci tools, readjusting") get_filename_component(PROJECT_ROOT_DIR ${PROJECT_ROOT_DIR} DIRECTORY) endif () -message(STATUS "PROJECT_ROOT_DIR -> ${PROJECT_ROOT_DIR}") -set(PROJECT_QML_DIR ${PROJECT_ROOT_DIR}/atomic_defi_design/Dex) -message(STATUS "PROJECT_QML_DIR -> ${PROJECT_QML_DIR}") -message(STATUS "bin dir -> ${CMAKE_CURRENT_SOURCE_DIR}/bin") +set(BIN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bin) set(TARGET_APP_PATH ${PROJECT_ROOT_DIR}/bundled/osx/) set(PROJECT_APP_DIR ${DEX_PROJECT_NAME}.app) -set(PROJECT_APP_PATH ${CMAKE_SOURCE_DIR}/bin/${PROJECT_APP_DIR}) -if (EXISTS ${PROJECT_APP_PATH}) - message(STATUS "PROJECT_APP_PATH path is -> ${PROJECT_APP_PATH}") -else () - message(FATAL_ERROR "Didn't find PROJECT_APP_PATH -> ${PROJECT_APP_PATH}") -endif () - +set(PROJECT_APP_PATH ${BIN_DIR}/${PROJECT_APP_DIR}) +set(PROJECT_QML_DIR ${PROJECT_ROOT_DIR}/atomic_defi_design/Dex) +set(MAC_DEPLOY_PATH $ENV{QT_ROOT}/clang_64/bin/macdeployqt) message(STATUS "VCPKG package manager enabled") +message(STATUS "QT_ROOT -> ${QT_ROOT}") +message(STATUS "BIN_DIR -> ${BIN_DIR}") +message(STATUS "TARGET_APP_PATH -> ${TARGET_APP_PATH}") +message(STATUS "PROJECT_APP_DIR -> ${PROJECT_APP_DIR}") +message(STATUS "PROJECT_QML_DIR -> ${PROJECT_QML_DIR}") +message(STATUS "PROJECT_ROOT_DIR (after readjusting) -> ${PROJECT_ROOT_DIR}") -message(STATUS "Using QT tools from $HOME/QT") -set(MAC_DEPLOY_PATH $ENV{QT_ROOT}/clang_64/bin/macdeployqt) +if (EXISTS ${PROJECT_APP_PATH}) + message(STATUS "PROJECT_APP_PATH -> ${PROJECT_APP_PATH}") +else () + message(FATAL_ERROR "Didn't find PROJECT_APP_PATH") +endif () if (EXISTS ${MAC_DEPLOY_PATH}) - message(STATUS "macdeployqt path is -> ${MAC_DEPLOY_PATH}") + message(STATUS "MAC_DEPLOY_PATH -> ${MAC_DEPLOY_PATH}") else () - message(FATAL_ERROR "Didn't find macdeployqt") + message(FATAL_ERROR "Didn't find MAC_DEPLOY_PATH") endif () +message(STATUS "CREATING DMG") if (NOT EXISTS ${CMAKE_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.dmg) - ##------------------------------------------- message(STATUS "${MAC_DEPLOY_PATH} ${PROJECT_APP_PATH} -qmldir=${PROJECT_QML_DIR} -always-overwrite -sign-for-notarization=$ENV{MAC_SIGN_IDENTITY} -verbose=3") execute_process( COMMAND @@ -41,9 +46,6 @@ if (NOT EXISTS ${CMAKE_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.dmg) ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE ) - ##------------------------------------------- - - ##------------------------------------------- message(STATUS "Fixing QTWebengineProcess") set(QTWEBENGINE_BUNDLED_PATH ${PROJECT_APP_PATH}/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess) message(STATUS "Executing: [install_name_tool -add_rpath @executable_path/../../../../../../Frameworks ${QTWEBENGINE_BUNDLED_PATH}]") @@ -68,7 +70,6 @@ if (NOT EXISTS ${CMAKE_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.dmg) ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) - ##------------------------------------------- message(STATUS "Packaging the DMG") set(PACKAGER_PATH ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/dmg-packager/package.sh) if (EXISTS ${PACKAGER_PATH}) @@ -97,13 +98,14 @@ endif () file(COPY ${CMAKE_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.dmg DESTINATION ${TARGET_APP_PATH}) -get_filename_component(QT_ROOT_DIR $ENV{QT_ROOT} DIRECTORY) +get_filename_component(QT_ROOT_DIR $ENV{QT_ROOT} DIRECTORY) set(IFW_BINDIR ${QT_ROOT_DIR}/Tools/QtInstallerFramework/4.4/bin) message(STATUS "IFW_BIN PATH IS ${IFW_BINDIR}") if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.7z) + execute_process(COMMAND ls WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) message(STATUS "Generating ${DEX_PROJECT_NAME}.7z with [${IFW_BINDIR}/archivegen ${DEX_PROJECT_NAME}.7z ${DEX_PROJECT_NAME}.app] from directory: ${CMAKE_CURRENT_SOURCE_DIR}/bin") execute_process(COMMAND - ${IFW_BINDIR}/archivegen ${DEX_PROJECT_NAME}.7z ${DEX_PROJECT_NAME}.app + ${IFW_BINDIR}/archivegen ${DEX_PROJECT_NAME}.7z ${PROJECT_APP_PATH} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) @@ -111,9 +113,11 @@ else() message(STATUS "${DEX_PROJECT_NAME}.7z already created - skipping") endif() +message(STATUS "Copying ${CMAKE_CURRENT_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.7z TO ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/installer/osx/packages/com.komodoplatform.atomicdex/data") + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${DEX_PROJECT_NAME}.7z DESTINATION ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/installer/osx/packages/com.komodoplatform.atomicdex/data) -execute_process(COMMAND ${IFW_BINDIR}/binarycreator -c ./config/config.xml -p ./packages/ ${DEX_PROJECT_NAME}_installer -s $ENV{MAC_SIGN_IDENTITY} +execute_process(COMMAND ${IFW_BINDIR}/binarycreator -c ./config/config.xml -p ./packages/ ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/installer/osx/${DEX_PROJECT_NAME}_installer -s $ENV{MAC_SIGN_IDENTITY} WORKING_DIRECTORY ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/installer/osx ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) @@ -130,7 +134,10 @@ execute_process(COMMAND ${PROJECT_ROOT_DIR}/cmake/install/macos/macos_notarize.s file(COPY ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/installer/osx/${DEX_PROJECT_NAME}_installer.app DESTINATION ${TARGET_APP_PATH}) -execute_process(COMMAND ${IFW_BINDIR}/archivegen ${DEX_PROJECT_NAME}_installer.7z ${DEX_PROJECT_NAME}_installer.app + +execute_process(COMMAND ${IFW_BINDIR}/archivegen ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/installer/osx/${DEX_PROJECT_NAME}_installer.7z ${DEX_PROJECT_NAME}_installer.app WORKING_DIRECTORY ${TARGET_APP_PATH} ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE) + +file(COPY ${PROJECT_ROOT_DIR}/ci_tools_atomic_dex/installer/osx/${DEX_PROJECT_NAME}_installer.7z DESTINATION ${TARGET_APP_PATH}) diff --git a/cmake/install/windows/windows_post_install.cmake b/cmake/install/windows/windows_post_install.cmake index 6867250ad1..9dce9dd05a 100644 --- a/cmake/install/windows/windows_post_install.cmake +++ b/cmake/install/windows/windows_post_install.cmake @@ -1,17 +1,21 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../project.metadata.cmake) +message(STATUS "PROJECT_ROOT_DIR (before readjusting) -> ${PROJECT_ROOT_DIR}") + get_filename_component(PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR} DIRECTORY) -if (EXISTS ${PROJECT_ROOT_DIR}/build-Release) +if (EXISTS ${PROJECT_ROOT_DIR}/build-Release OR EXISTS ${PROJECT_ROOT_DIR}/build-Debug) message(STATUS "from ci tools, readjusting") get_filename_component(PROJECT_ROOT_DIR ${PROJECT_ROOT_DIR} DIRECTORY) endif () -message(STATUS "PROJECT_ROOT_DIR -> ${PROJECT_ROOT_DIR}") - set(PROJECT_APP_DIR bin) set(PROJECT_APP_PATH ${CMAKE_SOURCE_DIR}/${PROJECT_APP_DIR}) set(TARGET_APP_PATH ${PROJECT_ROOT_DIR}/bundled/windows) +message(STATUS "VCPKG package manager enabled") +message(STATUS "PROJECT_ROOT_DIR (after readjusting) -> ${PROJECT_ROOT_DIR}") +message(STATUS "PROJECT_QML_DIR -> ${PROJECT_QML_DIR}") + if (EXISTS ${PROJECT_APP_PATH}) message(STATUS "PROJECT_APP_PATH path is -> ${PROJECT_APP_PATH}") message(STATUS "TARGET_APP_PATH path is -> ${TARGET_APP_PATH}") diff --git a/cmake/project.metadata.cmake b/cmake/project.metadata.cmake index 07ea76264b..27ce679f99 100644 --- a/cmake/project.metadata.cmake +++ b/cmake/project.metadata.cmake @@ -21,8 +21,6 @@ if (APPLE) else () set(DEX_APPDATA_FOLDER "atomic_qt") endif () -message(STATUS "APPDATA folder is ${DEX_APPDATA_FOLDER}") - if (UNIX AND NOT APPLE) set(DEX_LINUX_APP_ID "dex.desktop") endif () @@ -49,9 +47,25 @@ endif () if (DEFINED ENV{DEX_WEBSITE}) set(DEX_WEBSITE $ENV{DEX_WEBSITE}) endif () +if (DEFINED ENV{PROJECT_ROOT}) + set(PROJECT_ROOT $ENV{PROJECT_ROOT}) +else () + set(PROJECT_ROOT ${CMAKE_SOURCE_DIR}) +endif () + # Shows project metadata -message(STATUS "Project Metadata: ${DEX_PROJECT_NAME}.${DEX_DISPLAY_NAME}.${DEX_COMPANY}.${DEX_WEBSITE}") +message(STATUS "Project Metadata:") +message(STATUS "DEX_APPDATA_FOLDER --> ${DEX_APPDATA_FOLDER}") +message(STATUS "CMAKE_BUILD_TYPE --> ${CMAKE_BUILD_TYPE}") +message(STATUS "DEX_PROJECT_NAME --> ${DEX_PROJECT_NAME}") +message(STATUS "DEX_DISPLAY_NAME --> ${DEX_DISPLAY_NAME}") +message(STATUS "DEX_COMPANY --> ${DEX_COMPANY}") +message(STATUS "DEX_WEBSITE --> ${DEX_WEBSITE}") +message(STATUS "CMAKE_SOURCE_DIR --> ${CMAKE_SOURCE_DIR}") +message(STATUS "PROJECT_ROOT --> ${PROJECT_ROOT}") + + # Generates files which need to be configured with custom variables from env/CMake. macro(generate_dex_project_metafiles) 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 c0d6ed535a..0cd153feb4 100644 --- a/src/core/atomicdex/data/dex/orders.and.swaps.data.hpp +++ b/src/core/atomicdex/data/dex/orders.and.swaps.data.hpp @@ -16,6 +16,8 @@ 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. + // not happy with the current implementation we can do better struct orders_and_swaps { //! Registries diff --git a/src/core/atomicdex/models/qt.orderbook.model.cpp b/src/core/atomicdex/models/qt.orderbook.model.cpp index 22857e82af..9f6b9344c5 100644 --- a/src/core/atomicdex/models/qt.orderbook.model.cpp +++ b/src/core/atomicdex/models/qt.orderbook.model.cpp @@ -543,17 +543,14 @@ namespace atomic_dex { auto refresh_functor = [this](const std::vector& contents) { - // SPDLOG_INFO("refresh orderbook of size: {}", contents.size()); for (auto&& current_order: contents) { if (this->m_orders_id_registry.find(current_order.uuid) != this->m_orders_id_registry.end()) { - //! Update this->update_order(current_order); } else { - //! Insertion this->initialize_order(current_order); } } @@ -569,10 +566,6 @@ namespace atomic_dex auto res_list = this->match(index(0, 0), UUIDRole, QString::fromStdString(id)); if (not res_list.empty()) { - if (this->m_current_orderbook_kind == kind::best_orders) - { - // SPDLOG_INFO("Removing order with UUID: {}", id); - } this->removeRow(res_list.at(0).row()); to_remove.emplace(id); } diff --git a/src/core/atomicdex/models/qt.portfolio.model.cpp b/src/core/atomicdex/models/qt.portfolio.model.cpp index 5b2354ccf4..6fce77b3ca 100644 --- a/src/core/atomicdex/models/qt.portfolio.model.cpp +++ b/src/core/atomicdex/models/qt.portfolio.model.cpp @@ -103,15 +103,13 @@ namespace atomic_dex bool portfolio_model::update_currency_values() { - SPDLOG_INFO("update_currency_values"); const auto& mm2_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(); const std::string& currency = m_config->current_currency; const std::string& fiat = m_config->current_fiat; - tf::Executor executor; - tf::Taskflow taskflow; + for (auto&& [_, coin]: coins) { if (m_ticker_registry.find(coin.ticker) == m_ticker_registry.end()) @@ -119,47 +117,42 @@ namespace atomic_dex SPDLOG_WARN("ticker: {} not inserted yet in the model, skipping", coin.ticker); return false; } - auto update_functor = [coin = std::move(coin), &provider, &mm2_system, &price_service, currency, fiat, this]() + const std::string& ticker = coin.ticker; + if (const auto res = this->match(this->index(0, 0), TickerRole, QString::fromStdString(ticker), 1, Qt::MatchFlag::MatchExactly); + not res.isEmpty()) { - const std::string& ticker = coin.ticker; - if (const auto res = this->match(this->index(0, 0), TickerRole, QString::fromStdString(ticker), 1, Qt::MatchFlag::MatchExactly); - not res.isEmpty()) + std::error_code ec; + const QModelIndex& idx = res.at(0); + const QString main_currency_balance_value = QString::fromStdString(price_service.get_price_in_fiat(currency, ticker, ec)); + update_value(MainCurrencyBalanceRole, main_currency_balance_value, idx, *this); + const QString currency_price_for_one_unit = QString::fromStdString(price_service.get_rate_conversion(currency, ticker, true)); + update_value(MainCurrencyPriceForOneUnit, currency_price_for_one_unit, idx, *this); + const QString currency_fiat_for_one_unit = QString::fromStdString(price_service.get_rate_conversion(fiat, ticker, false)); + update_value(MainFiatPriceForOneUnit, currency_fiat_for_one_unit, idx, *this); + const QString price_provider = QString::fromStdString(provider.get_price_provider(ticker)); + update_value(PriceProvider, price_provider, idx, *this); + int last_price_timestamp = static_cast(provider.get_last_price_timestamp(ticker)); + 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.my_balance(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); + // Not a good way to trigger notification, use websocket instead in the future. New was of enabling coins is not compatible. + if (is_change_b) { - std::error_code ec; - const QModelIndex& idx = res.at(0); - const QString main_currency_balance_value = QString::fromStdString(price_service.get_price_in_fiat(currency, ticker, ec)); - update_value(MainCurrencyBalanceRole, main_currency_balance_value, idx, *this); - const QString currency_price_for_one_unit = QString::fromStdString(price_service.get_rate_conversion(currency, ticker, true)); - update_value(MainCurrencyPriceForOneUnit, currency_price_for_one_unit, idx, *this); - const QString currency_fiat_for_one_unit = QString::fromStdString(price_service.get_rate_conversion(fiat, ticker, false)); - update_value(MainFiatPriceForOneUnit, currency_fiat_for_one_unit, idx, *this); - const QString price_provider = QString::fromStdString(provider.get_price_provider(ticker)); - update_value(PriceProvider, price_provider, idx, *this); - int last_price_timestamp = static_cast(provider.get_last_price_timestamp(ticker)); - 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.my_balance(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); - // Not a good way to trigger notification, use websocket instead in the future. New was of enabling coins is not compatible. - if (is_change_b) - { - balance_update_handler(prev_balance.toString(), new_balance.toString(), QString::fromStdString(ticker)); - } - 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); - 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); + balance_update_handler(prev_balance.toString(), new_balance.toString(), QString::fromStdString(ticker)); } - }; - taskflow.emplace(update_functor); + 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); + 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); + } } - executor.run(taskflow).wait(); return true; } diff --git a/src/core/atomicdex/services/mm2/auto.update.maker.order.service.cpp b/src/core/atomicdex/services/mm2/auto.update.maker.order.service.cpp index a662b3f632..eea078ba52 100644 --- a/src/core/atomicdex/services/mm2/auto.update.maker.order.service.cpp +++ b/src/core/atomicdex/services/mm2/auto.update.maker.order.service.cpp @@ -106,15 +106,10 @@ namespace atomic_dex .then( []([[maybe_unused]] web::http::http_response resp) { - std::string body = TO_STD_STR(resp.extract_string(true).get()); - SPDLOG_INFO("status_code: {}", resp.status_code()); - if (resp.status_code() == 200) + if (resp.status_code() != 200) { - SPDLOG_INFO("order resp: {}", body); - } - else - { - SPDLOG_WARN("An error occured during update_maker_order: {}", body); + std::string body = TO_STD_STR(resp.extract_string(true).get()); + SPDLOG_ERROR("An error occured during update_maker_order (code: {}): {}", resp.status_code(), body); } }) .then(&handle_exception_pplx_task); @@ -124,16 +119,16 @@ namespace atomic_dex void auto_update_maker_order_service::internal_update() { - SPDLOG_INFO("update maker orders"); + SPDLOG_DEBUG("update maker orders"); const auto& mm2 = this->m_system_manager.get_system(); orders_and_swaps data = mm2.get_orders_and_swaps(); - auto cur = data.orders_and_swaps.cbegin(); - auto end = data.orders_and_swaps.cbegin() + data.nb_orders; - for (; cur != end; ++cur) + 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) { if (cur->is_maker) { - SPDLOG_INFO("Updating order: {}", cur->order_id.toStdString()); + SPDLOG_DEBUG("Updating order: {}", cur->order_id.toStdString()); this->update_order(*cur); } } diff --git a/src/core/atomicdex/services/mm2/mm2.service.cpp b/src/core/atomicdex/services/mm2/mm2.service.cpp index 9cf4167e03..480ded23b0 100644 --- a/src/core/atomicdex/services/mm2/mm2.service.cpp +++ b/src/core/atomicdex/services/mm2/mm2.service.cpp @@ -1240,7 +1240,6 @@ namespace atomic_dex this->m_nb_update_required += 1; this->dispatcher_.trigger(coin_fully_initialized{.tickers = {tickers[idx]}}); this->dispatcher_.trigger(tickers[idx], "Complete!"); - break; } else { @@ -1275,7 +1274,7 @@ namespace atomic_dex web::http::http_response z_resp = z_resp_task.get(); auto z_answers = mm2::basic_batch_answer(z_resp); z_error = z_answers; - // SPDLOG_DEBUG("z_answer: {}", z_answers[0].dump(4)); + std::string status = z_answers[0].at("result").at("status").get(); if (status == "Ready") @@ -1304,6 +1303,8 @@ namespace atomic_dex } else { + // todo(syl): many unused variables. + // fix that if (z_answers[0].at("result").at("details").contains("UpdatingBlocksCache")) { event = "UpdatingBlocksCache"; @@ -1342,6 +1343,8 @@ namespace atomic_dex this->dispatcher_.trigger(tickers[idx], event); last_event = event; } + + // todo(syl): refactor to a background task std::this_thread::sleep_for(2s); } m_coins_informations[tickers[idx]].activation_status = z_answers[0]; @@ -1540,10 +1543,22 @@ namespace atomic_dex auto answer = mm2::basic_batch_answer(resp); if (answer.is_array()) { + if (answer.size() < 1) + { + SPDLOG_ERROR("Answer array did not contain enough elements"); + return; + } + auto orderbook_answer = mm2::rpc_process_answer_batch(answer[0], "orderbook"); if (is_a_reset) { + if (answer.size() < 5) + { + SPDLOG_ERROR("Answer array did not contain enough elements"); + return; + } + auto base_max_taker_vol_answer = mm2::rpc_process_answer_batch(answer[1], "max_taker_vol"); if (base_max_taker_vol_answer.rpc_result_code == 200) { @@ -1643,7 +1658,6 @@ namespace atomic_dex void mm2_service::fetch_infos_thread(bool is_a_refresh, bool only_tx) { - SPDLOG_INFO("fetch_infos_thread"); if (only_tx) { batch_balance_and_tx(is_a_refresh, {}, false, only_tx);