Skip to content

Commit

Permalink
Merge pull request #132 from Chia-Network/develop
Browse files Browse the repository at this point in the history
Release 1.0.22
  • Loading branch information
TheLastCicada authored Oct 3, 2023
2 parents d598693 + 1ad11eb commit e63eab2
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 54 deletions.
48 changes: 9 additions & 39 deletions .github/workflows/build-installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ jobs:
intel: [ubuntu-latest]
electron-builder-options: --linux
electron-builder-unpacked: linux-unpacked
# token-driver-artifact:
# arm: climate-tokenization-chia-linux-arm64
# intel: climate-tokenization-chia-linux-amd64
executable-extension: ''
build-result-pattern: '"climate-wallet"*".deb"'
artifact-name: linux
Expand All @@ -51,9 +48,6 @@ jobs:
intel: [macos-latest]
electron-builder-options: --macos
electron-builder-unpacked: mac
# token-driver-artifact:
# arm: climate-tokenization-chia-macos-arm64
# intel: climate-tokenization-chia-macos-amd64
executable-extension: ''
build-result-pattern: '"Climate Wallet-"*".dmg"'
artifact-name: macos
Expand All @@ -64,8 +58,6 @@ jobs:
intel: [windows-latest]
electron-builder-options: --windows
electron-builder-unpacked: win-unpacked
# token-driver-artifact:
# intel: climate-tokenization-chia-windows-amd64
executable-extension: '.exe'
build-result-pattern: '"Climate Wallet Setup "*".exe"'
artifact-name: windows
Expand Down Expand Up @@ -103,19 +95,6 @@ jobs:
run: |
npm install dmg-license
# - name: download token driver
# env:
# GH_TOKEN: ${{ secrets.GH_READ_REPOS }}
# DESTINATION: extraResources/main${{ matrix.os.executable-extension }}
# run: |
# RUN_ID=$(gh run list --repo chia-network/climate-token-driver --branch ${{ matrix.configuration.token-driver-artifact-ref }} --limit 1 --workflow "Build & Release" --json databaseId --jq '.[0].databaseId')
# gh run download $RUN_ID --repo chia-network/climate-token-driver --name climate-token-driver_${{ matrix.os.matrix }}_${{ matrix.configuration.token-driver-artifact-ref }}_${{ matrix.arch.artifact-name }} --dir downloaded-artifacts/
# mkdir -p extraResources/
# # expected to fail if there are multiple files
# mv downloaded-artifacts/* "${DESTINATION}"
# chmod a+x "${DESTINATION}"
# ls -la extraResources/ || true

- name: Download Token Driver Client
env:
GH_TOKEN: ${{ secrets.GH_READ_REPOS }}
Expand Down Expand Up @@ -205,6 +184,15 @@ jobs:
sm_code_signing_cert_sha1_hash: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }}
file: '${{ github.workspace }}/${{ env.INSTALLER_FILE }}'

- name: Release
uses: softprops/action-gh-release@v0.1.15
with:
files: artifacts/*
fail_on_unmatched_files: true
target_commitish: ${{ github.sha }}
if: startsWith(github.ref, 'refs/tags/')

# Create aritifacts so we have builds to test from pull requests
- name: Upload Installer to artifacts
uses: actions/upload-artifact@v3
with:
Expand All @@ -222,24 +210,6 @@ jobs:
needs:
- build
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: installers

- name: Report installers
run: |
ls -lda installers/* || true
echo ====
ls -lda installers/*/* || true
- name: Release
uses: softprops/action-gh-release@v0.1.15
with:
files: installers/*/*
fail_on_unmatched_files: true
target_commitish: ${{ github.sha }}

- name: Get repo name
id: repo-name
run: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "Chia Network <hello@chia.net> (https://chia.net/)",
"description": "Climate Wallet for Chia Blockchain",
"productName": "Climate Wallet",
"version": "1.1.21",
"version": "1.1.22",
"private": true,
"homepage": "./",
"main": "build/electron/main.js",
Expand Down
6 changes: 3 additions & 3 deletions src/components/token/TokenType.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum TokenType {
Default = 0,
Send = 1,
Receive = 2,
Detokenize = 2051,
Retire = 2052,
Receive = 0,
Detokenize = 3,
Retire = 2,
}
16 changes: 14 additions & 2 deletions src/components/transaction/TransactionCATInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ const TransactionCATInput = () => {

const max = (walletBalance?.confirmedWalletBalance ?? 1000) / 1000

if (isLoadingWalletBalance) {
return null
}

return (
<TextField
label={<Trans>Quantity</Trans>}
fullWidth
{...register('amount', {
required: true,
pattern: TOKEN_AMOUNT_REGEX,
max: max,
max,
})}
error={Boolean(errors['amount'])}
InputProps={{
Expand All @@ -53,7 +57,15 @@ const TransactionCATInput = () => {
wallet.
</Trans>
) : (
<Trans>Amount input format is error.</Trans>
<>
{!isNaN(parseFloat(getValues('amount'))) &&
isFinite(Number(getValues('amount'))) &&
!Number.isInteger(Number(getValues('amount'))) ? (
<Trans>Only integers are allowed.</Trans>
) : (
<Trans>Amount input format is error.</Trans>
)}
</>
))
}
required
Expand Down
43 changes: 40 additions & 3 deletions src/components/transaction/TransactionFeeInput.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
import { useMemo } from 'react'
import { XCH_FEE_REGEX } from '@/constants/regex'
import { useWallet } from '@/hooks/wallet'
import { useWallet, useWalletsBalance, useWalletsList } from '@/hooks/wallet'
import { InputType } from '@/types/SendType'
import { Trans } from '@lingui/macro'
import { InputAdornment, TextField, Typography } from '@mui/material'
import { useEffect } from 'react'
import { useFormContext } from 'react-hook-form'
import { WalletType } from '@chia/api'
import { MOJO_PER_CHIA } from '@/constants/chia'

const TransactionFeeInput = () => {
const { unit } = useWallet(1)

const { list: wallets, isLoading: isLoadingWallets } = useWalletsList(
[WalletType.STANDARD_WALLET],
''
)

const { isLoading: isLoadingWalletsBalance, data: walletsBalance } =
useWalletsBalance(wallets || [])

const {
register,
getValues,
formState: { errors },
} = useFormContext<Pick<InputType, 'fee'>>()

const max = useMemo(() => {
const mojoBalance = walletsBalance?.[0] || 0

if (!mojoBalance || isNaN(mojoBalance)) {
return 0
}

return mojoBalance / MOJO_PER_CHIA
}, [walletsBalance])

if (isLoadingWallets || isLoadingWalletsBalance) {
return null
}

return (
<TextField
label={<Trans>Fee</Trans>}
fullWidth
{...register('fee', { required: true, pattern: XCH_FEE_REGEX })}
{...register('fee', { required: true, pattern: XCH_FEE_REGEX, max })}
error={Boolean(errors['fee'])}
InputProps={{
endAdornment: (
Expand All @@ -31,6 +56,18 @@ const TransactionFeeInput = () => {
</InputAdornment>
),
}}
helperText={
Boolean(errors['fee']) &&
(Number(getValues('fee')) > max ? (
<Trans>
Amount entered is higher than the amount you currently hold. Please
lower the amount so that it is below the number displayed in your
wallet.
</Trans>
) : (
<Trans>Amount input format is error.</Trans>
))
}
required
/>
)
Expand Down
1 change: 1 addition & 0 deletions src/constants/chia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const MOJO_PER_CHIA = 1000000000000
2 changes: 1 addition & 1 deletion src/constants/regex.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const TOKEN_AMOUNT_REGEX = /^[0-9]+(.[0-9]{1,3})?$/
export const TOKEN_AMOUNT_REGEX = /^-?\d+$/
export const XCH_FEE_REGEX = /^[0-9]+(.[0-9]{1,12})?$/
38 changes: 34 additions & 4 deletions src/pages/NoTokensFound/NoTokensFound.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import { useMemo } from 'react'
import { useMemo, useEffect } from 'react'
import { Box, Grid } from '@mui/material'
import { useNavigate } from 'react-router-dom'
import { useWalletsBalance, useWalletsList } from '@/hooks/wallet'
import {
useCWAddStrayCats,
useWalletsBalance,
useWalletsList,
useWalletState,
} from '@/hooks/wallet'
import { useGetAllCWAssets } from '@/hooks/useGetAllCWAssets'
import SyncingStatus from '@/constants/SyncingStatus'
import { WalletType } from '@chia/api'
import { checkMarketplaceIdentifier } from '@/util/token'
import { WalletListItem } from '../../types/WalletType'

const NoTokensFound = () => {
const navigate = useNavigate()
const { state: walletState } = useWalletState()

const { list: wallets, isLoading: isLoadingWallets } = useWalletsList(
[WalletType.STANDARD_WALLET, WalletType.CAT],
''
)

const { isLoadingAddStrayCats } = useCWAddStrayCats()

const { data: allCWAssets, isLoading: isLoadingAllCWAssets } =
useGetAllCWAssets()

Expand All @@ -36,9 +45,30 @@ const NoTokensFound = () => {
useWalletsBalance(filteredWallets)

const isLoading =
isLoadingWallets || isLoadingAllCWAssets || isLoadingWalletsBalance
isLoadingWallets ||
isLoadingAllCWAssets ||
isLoadingAddStrayCats ||
isLoadingWalletsBalance

useEffect(() => {
// Since most of the hooks in this repo are "hooks" of "hooks",
// Its difficult to use the traditional "pollingInterval" method
// So instead on an interval we are going to redirect to the dashboard
// where it will do a fresh check for climate tokens and redirect back here
// if there are none, where the cycle will continue until tokens are detected.
const interval = setInterval(() => {
console.log('Checking for Climate Tokens')
navigate('/dashboard')
}, 60000)
return () => clearInterval(interval)
}, [isLoading, filteredWallets])

if (isLoading) {
if (
isLoading &&
walletState === SyncingStatus.SYNCED &&
filteredWallets.length !== 0
) {
console.log('Climate Tokens Detected')
navigate('/dashboard')
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/TokenWallet/TokenSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default function TokenSidebar() {

if (
!isLoading &&
sortedWallets.length === 0 &&
filteredWallets.length === 0 &&
walletState === SyncingStatus.SYNCED
) {
navigate('/dashboard/wallets/no-token')
Expand Down

0 comments on commit e63eab2

Please sign in to comment.