fix
This commit is contained in:
parent
fc94b6e27e
commit
2c6adbd244
|
@ -1,4 +1,5 @@
|
|||
import Big from 'bignumber.js'
|
||||
import { validateWork } from 'nanocurrency'
|
||||
import { useCallback, useState } from 'react'
|
||||
|
||||
import computeWorkAsync from '../computeWorkAsync'
|
||||
|
@ -16,7 +17,13 @@ const useReceiveNano = () => {
|
|||
async (hash: string, amount: string) => {
|
||||
if (account === undefined) return
|
||||
let precomputedWork = await getPrecomputedWork(account.address)
|
||||
if (precomputedWork === null) {
|
||||
const isWorkValid =
|
||||
precomputedWork !== null &&
|
||||
validateWork({
|
||||
work: precomputedWork,
|
||||
blockHash: account.frontier ?? account.publicKey,
|
||||
})
|
||||
if (!isWorkValid) {
|
||||
setGeneratingWork(true)
|
||||
precomputedWork = await computeWorkAsync(
|
||||
account.frontier ?? account.publicKey,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Big from 'bignumber.js'
|
||||
import { validateWork } from 'nanocurrency'
|
||||
import { useCallback, useState } from 'react'
|
||||
|
||||
import computeWorkAsync from '../computeWorkAsync'
|
||||
|
@ -21,7 +22,13 @@ const useSendNano = () => {
|
|||
)
|
||||
throw new Error('wrong_block_data') // todo improve this error
|
||||
let precomputedWork = await getPrecomputedWork(account.address)
|
||||
if (precomputedWork === null) {
|
||||
const isWorkValid =
|
||||
precomputedWork !== null &&
|
||||
validateWork({
|
||||
work: precomputedWork,
|
||||
blockHash: account.frontier,
|
||||
})
|
||||
if (!isWorkValid) {
|
||||
setGeneratingWork(true)
|
||||
precomputedWork = await computeWorkAsync(
|
||||
account.frontier ?? account.publicKey,
|
||||
|
|
|
@ -4,7 +4,7 @@ import useSetup from './useSetup'
|
|||
|
||||
const useSetupServiceWorker = (skip?: boolean) =>
|
||||
useSetup(
|
||||
useCallback(() => {
|
||||
useCallback(async () => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
try {
|
||||
navigator.serviceWorker.register('/sw.js')
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"noEmit": true,
|
||||
"incremental": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
|
|
Reference in a new issue