Skip to content

Commit

Permalink
Merge branch 'main' into canary
Browse files Browse the repository at this point in the history
  • Loading branch information
kalvkusk committed Feb 29, 2024
2 parents 761ac70 + 4160b04 commit 10f846f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 40 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ on:
tags:
- '*'
branches:
- '*'
- '*'
pull_request:
types:
- opened
branches:
- 'release**'
- 'main'

jobs:
build:
build:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
os: [ windows-latest, macos-11, macos-14 ]
name: build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -34,10 +34,10 @@ jobs:
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set rust_version from rust_toolchain file
run: echo "RUST_VERSION=$(cat src-tauri/rust-toolchain)" >> $GITHUB_ENV

- name: Set rust_version from rust_toolchain file
if: matrix.os == 'windows-latest'
run: |
Expand All @@ -47,9 +47,9 @@ jobs:
- uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: '${{ env.RUST_VERSION }}'
toolchain: "${{ env.RUST_VERSION }}"
override: true

# Setup Node.js
- name: setup node
uses: actions/[email protected]
Expand All @@ -60,7 +60,7 @@ jobs:
if: matrix.os == 'windows-latest'
uses: KyleMayes/install-llvm-action@v1
with:
version: '11.0'
version: "11.0"
directory: ${{ runner.temp }}/llvm

- name: Set LIBCLANG_PATH
Expand All @@ -74,16 +74,17 @@ jobs:
$var = (get-item $(rustup which rustc)).Directory.Parent.FullName+ '\lib\rustlib\' + (rustc -vV | findstr "host:*").split(':')[1].Trim() + '\lib'
Copy-Item ('${{ github.workspace }}' + '\redist' + '\x86_64\*') -Destination $var -Recurse
######## CACHE ########
######## CACHE ########

- uses: Swatinem/rust-cache@v2
with:
workspaces: ./src-tauri
shared-key: '${{ matrix.os }}'
cache-all-crates: true
cache-on-failure: true
workspaces: ./src-tauri
shared-key: "${{ matrix.os }}"
cache-on-failure: true


######## BUILD ########
######## BUILD ########

- name: yarn installation
run: yarn install
Expand All @@ -95,6 +96,6 @@ jobs:
- name: build tauri
run: yarn run build:github-pr
env:
# Mocked keys.
TAURI_PRIVATE_KEY: 'dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5ZUYrUFF0RS9ZbU5EN0VFWk52TmpDRDQvTFFWOHhqSXNkZFVvUjZSRWNJc0FBQkFBQUFBQUFBQUFBQUlBQUFBQTZhNUxkYVFJWDNWTENKR2tSNzFVcDhsRzcvd0lKeWRGcytBZDNyZ3o3OWRXOWVmbmZCQktJYk8xOHVHWG5CZ25XN1pBOXM3SjMyWW1DRFNZWFJ5WGxsd3B6d3RvOEtTNHFFbFM5VE5obmNEZ1dHeEljVFRhZ2FXa0RzNHZOVkNESE5DdDArUmkvUUE9Cg=='
TAURI_KEY_PASSWORD: 'mock'
# Mocked keys.
TAURI_PRIVATE_KEY: "dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5ZUYrUFF0RS9ZbU5EN0VFWk52TmpDRDQvTFFWOHhqSXNkZFVvUjZSRWNJc0FBQkFBQUFBQUFBQUFBQUlBQUFBQTZhNUxkYVFJWDNWTENKR2tSNzFVcDhsRzcvd0lKeWRGcytBZDNyZ3o3OWRXOWVmbmZCQktJYk8xOHVHWG5CZ25XN1pBOXM3SjMyWW1DRFNZWFJ5WGxsd3B6d3RvOEtTNHFFbFM5VE5obmNEZ1dHeEljVFRhZ2FXa0RzNHZOVkNESE5DdDArUmkvUUE9Cg=="
TAURI_KEY_PASSWORD: "mock"
9 changes: 5 additions & 4 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- opened
branches:
- 'release**'
- 'canary**'
- 'main'
jobs:
ts-lint:
Expand Down Expand Up @@ -43,10 +44,10 @@ jobs:
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Set rust_version from rust_toolchain file
run: echo "RUST_VERSION=$(cat src-tauri/rust-toolchain)" >> $GITHUB_ENV

- uses: actions-rs/[email protected]
with:
profile: minimal
Expand All @@ -62,10 +63,10 @@ jobs:
with:
shared-key: 'libra' # to share across CI builds, so it is not job-id specific
cache-on-failure: true

- name: check format
working-directory: ./src-tauri
run: cargo fmt --all -- --check
run: cargo fmt --all -- --check

- name: lint
working-directory: ./src-tauri
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@ name: release

on:
workflow_dispatch:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-canary.[0-9]+'

branches:
- 'canary*'
- 'release-[0-9]+.[0-9]+.[0-9]+'
- 'ci'
jobs:
build-and-publish:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
os: [ windows-latest, macos-11, macos-14]
name: build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -63,10 +54,9 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
workspaces: ./src-tauri
shared-key: '${{ matrix.os }}'
cache-all-crates: true
cache-on-failure: true
workspaces: ./src-tauri
shared-key: "${{ matrix.os }}"
cache-on-failure: true

######## BUILD ########

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.canary.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"updater": {
"active": true,
"endpoints": [
"https://raw.githubusercontent.com/0LNetworkCommunity/carpe/canary/autoupdater/autoupdater_payload_canary.json"
"https://raw.githubusercontent.com/0LNetworkCommunity/carpe/main/autoupdater/autoupdater_payload_canary.json"
],
"dialog": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDk2NDM3QUIwRDdENjkyNjgKUldSb2t0YlhzSHBEbHZOTkNCT3ljZTJESE1yc2t5c1dqbFd0VkZ2THM3N0RucTV0TC9FeDBQb1oK"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.pr.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"https://raw.githubusercontent.com/0LNetworkCommunity/carpe/main/autoupdater/non_existent.json"
],
"dialog": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEI1NEM2REJBMjU1MUQxMjQKUldRazBWRWx1bTFNdFY4bmxyVEg4NVFvZXFlMnNacGF0VlNLYSs1RmNENzFWaUx0amhOSjI0UU0K"
"pubkey":"dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEI1NEM2REJBMjU1MUQxMjQKUldRazBWRWx1bTFNdFY4bmxyVEg4NVFvZXFlMnNacGF0VlNLYSs1RmNENzFWaUx0amhOSjI0UU0K"
},
"bundle": {
"active": true,
Expand Down
32 changes: 30 additions & 2 deletions src/modules/miner_toggle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { get } from 'svelte/store'
import { minerLoopEnabled, tower, minerEventReceived } from './miner'
import { signingAccount } from './accounts'
import { raise_error, ErrMap } from './carpeError'
import { notify_success } from './carpeNotify'
import { minerLoopEnabled } from './miner'
import {
killBacklogListener,
startBacklogListener,
Expand Down Expand Up @@ -42,10 +45,35 @@ export async function disableMining(): Promise<boolean> {
return true
}

export function toggleMining() {
export async function toggleMining() {
const account = get(signingAccount)

// Check if the account exists and has an unlocked balance sufficient for mining
if (!account || account.balance.unlocked < 10) {
// Customizing the variable for the error message based on the specific condition
let errorMessage = 'Your balance is too low to start mining.'
if (!account) {
errorMessage += ' Account does not exist or is not currently active on-chain.'
} else if (account.balance.unlocked < 10) {
errorMessage += ' You need at least 10 tokens in your wallet to start mining.'
}

// Construct a CarpeError object according to the CarpeError interface
const error = {
category: ErrMap.InsufficientBalance, // Assuming this is the correct category for this error
uid: ErrMap.InsufficientBalance, // This should be a unique identifier, using the same value for simplicity
msg: errorMessage,
}

raise_error(error, false, 'toggleMining')
return // Exit the function to prevent further execution
}

// enableMining and disableMining functions
if (get(minerLoopEnabled)) {
disableMining()
} else {
enableMining()
notify_success('Mining status toggled.') // Notify the user of successful operation
}
}

0 comments on commit 10f846f

Please sign in to comment.