Skip to content

Commit

Permalink
Merge pull request #58 from hashgreen/fix/verify-bls-input
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwei authored Nov 3, 2022
2 parents 4595503 + ba003b6 commit 43b93fa
Show file tree
Hide file tree
Showing 50 changed files with 1,450 additions and 1,381 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CLIMATE_SERVICE=http://localhost:31313
CLIMATE_SERVICE=http://localhost:31312
CLIMATE_WAREHOUSE=https://api.climatewarehouse.chia.net
2 changes: 1 addition & 1 deletion .env.submodule
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SERVER_HOST="0.0.0.0"
SERVER_PORT="31313"
SERVER_PORT="31312"
BLOCK_START="1500000"
BLOCK_RANGE="10000"
CLIMATE_API_URL="https://api.climatewarehouse.chia.net"
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@
"byte-size": "8.1.0",
"core-js": "3.20.3",
"crypto-browserify": "3.12.0",
"detect-port": "^1.5.1",
"dotenv": "14.2.0",
"es6-promise": "4.2.8",
"history": "5.2.0",
"is-electron": "2.2.1",
"isomorphic-fetch": "3.0.0",
"js-yaml": "^4.1.0",
"json-bigint": "^1.0.0",
"kill-port": "^2.0.1",
"lodash": "4.17.21",
"make-plural": "7.0.0",
"match-sorter": "6.3.1",
Expand Down Expand Up @@ -229,5 +231,5 @@
]
}
},
"version": "1.0.3"
}
"version": "1.0.4"
}
66 changes: 39 additions & 27 deletions src/electron/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import '@/config/env'
import { i18n } from '@/config/locales'
import loadConfig from '@/util/loadConfig'
import { initialize } from '@electron/remote/main'
import detect from 'detect-port'
import {
app,
BrowserWindow,
Expand All @@ -14,11 +15,12 @@ import {
net,
shell,
} from 'electron'
import http from 'http'
import kill from 'kill-port'
import path from 'path'
import { PythonShell } from 'python-shell'
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import request from 'request-promise'
import { ServerStyleSheet, StyleSheetManager } from 'styled-components'
import url from 'url'
import packageJson from '../../package.json'
Expand Down Expand Up @@ -309,41 +311,51 @@ const createWindow = async () => {
require('@electron/remote/main').enable(mainWindow.webContents)
}

app.on('will-quit', (e) => {
if (!isDev && pyProc) {
pyProc.kill('SIGINT')
if (process.platform === 'win32') {
process.kill(pyProc?.pid)
}
pyProc = null
}
})

//app start here
app.on('ready', () => {
const startUp = function () {
if (isDev) {
//need to load python venv
pyProc = onRunService()
} else {
pyProc = onRunService()
}
const startUp = function () {
pyProc = onRunService()

const pythonUri = process.env.CLIMATE_SERVICE
if (pyProc) {
console.log('climate service:', pythonUri)
}
createWindow()
}

createWindow()
}
const killTokenPort = (port) => {
detect(port)
.then((_port) => {
if (port === _port) {
console.log(`port: ${port} was not occupied`)
startUp()
} else {
console.log(`port: ${port} was occupied, restart it`)
kill(port, 'tcp')
.then(() => {
startUp()
})
.catch(console.log)
}
})
.catch((err) => {
console.log(err)
})
}

startUp()
//app start here
app.on('ready', () => {
killTokenPort(31312)

app.applicationMenu = createMenu()
})

const exitPyProc = () => {
pyProc.kill()
console.log('child process exit')
pyProc = null
}

app.on('will-quit', (e) => {
pyProc.kill()
})
//app quit+
app.on('window-all-closed', () => {
pyProc.kill()
app.quit()
})

Expand Down
29 changes: 23 additions & 6 deletions src/hooks/wallet/useAddCWStrayCats.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import { useGetAllCWAssets } from '@/hooks/useGetAllCWAssets'
import { checkMarketplaceIdentifier } from '@/util/token'
import { WalletType } from '@chia/api'
import { useGetStrayCatsQuery } from '@chia/api-react'
import { useAddCATTokenMutation, useGetStrayCatsQuery } from '@chia/api-react'
import { useEffect, useState } from 'react'
import useWalletsList from './useWalletsList'

export default function useCWAddStrayCats(): {
isLoadingAddStrayCats: boolean
} {
const [isLoadingAddStrayCats, setIsLoadingAddStrayCats] =
useState<boolean>(true)

const { show: addStrayCat } = useWalletsList([WalletType.CAT], '')
const [addCATToken] = useAddCATTokenMutation()
const { data: allCWAssets } = useGetAllCWAssets()
const { data: strayCats } = useGetStrayCatsQuery(undefined, {
pollingInterval: 10000,
})

const handleAddCat = async (strayCat) => {
const { assetId, name } = strayCat
try {
const res = await addCATToken({
name: name,
assetId: assetId,
fee: '0',
}).unwrap()
return res
} catch (error) {
return error
}
}

useEffect(() => {
if (allCWAssets && strayCats) {
if (
allCWAssets &&
strayCats &&
allCWAssets.length > 0 &&
strayCats.length > 0
) {
Promise.all(
strayCats.map((strayCat) => {
const { assetId } = strayCat
Expand All @@ -28,7 +45,7 @@ export default function useCWAddStrayCats(): {
checkMarketplaceIdentifier(cw.marketplaceIdentifier) === assetId
)
) {
return addStrayCat(assetId)
return handleAddCat(strayCat)
} else {
return Promise.resolve()
}
Expand Down
Loading

0 comments on commit 43b93fa

Please sign in to comment.