Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
branches:
- master
- 'rc/**'
- 'hotfix/**'
- "rc/**"
- "hotfix/**"

jobs:
default:
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
cache: "yarn"

- name: Restore
uses: actions/cache@v3
Expand All @@ -49,7 +49,7 @@ jobs:
if: matrix.os == 'windows-2019'
uses: microsoft/setup-msbuild@v1.1.3
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"

- name: Install libudev
if: matrix.os == 'ubuntu-20.04'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package_for_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: 'yarn'
cache: "yarn"

- name: Restore
uses: actions/cache@v3
Expand All @@ -44,7 +44,7 @@ jobs:
if: matrix.os == 'windows-2019'
uses: microsoft/setup-msbuild@v1.1.3
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"

- name: Install libudev
if: matrix.os == 'ubuntu-20.04'
Expand Down
1,617 changes: 725 additions & 892 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packages": [
"packages/*"
],
"packages": ["packages/*"],
"version": "0.106.0",
"npmClient": "yarn",
"useWorkspaces": true
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-ui/src/components/NFTSend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { isMainnet as isMainnetUtil, isSuccessResponse, validateAddress } from '
import TextField from 'widgets/TextField'
import { generateNFTSendTransaction } from 'services/remote'
import Button from 'widgets/Button'
import { MEDIUM_FEE_RATE } from 'utils/const'
import { ReactComponent as Attention } from 'widgets/Icons/Attention.svg'
import { isErrorWithI18n } from 'exceptions'
import styles from './NFTSend.module.scss'
Expand Down Expand Up @@ -42,6 +41,7 @@ const NFTSend = () => {
wallet: { id: walletId },
app: {
loadings: { sending: isSending = false },
feeRateStatics: { suggestFeeRate = 0 },
},
settings: { networks },
chain: { networkID },
Expand Down Expand Up @@ -122,7 +122,7 @@ const NFTSend = () => {
receiveAddress: sendState.address,
outPoint,
description: sendState.description,
feeRate: `${MEDIUM_FEE_RATE}`,
feeRate: `${suggestFeeRate}`,
}

generateNFTSendTransaction(params)
Expand All @@ -141,7 +141,7 @@ const NFTSend = () => {
})
}, TIMER_DELAY)
return clearTimer
}, [isSubmittable, globalDispatch, sendState, walletId, outPoint])
}, [isSubmittable, globalDispatch, sendState, walletId, outPoint, suggestFeeRate])

return (
<div>
Expand Down
25 changes: 20 additions & 5 deletions packages/neuron-ui/src/components/NervosDAO/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ export const useUpdateMaxDeposit = ({
setMaxDepositTx,
setMaxDepositErrorMessage,
isBalanceReserved,
suggestFeeRate,
}: {
wallet: State.Wallet
setMaxDepositAmount: React.Dispatch<React.SetStateAction<bigint>>
setMaxDepositTx: React.Dispatch<React.SetStateAction<any>>
setMaxDepositErrorMessage: React.Dispatch<React.SetStateAction<string>>
isBalanceReserved: boolean
suggestFeeRate: number | string
}) => {
useEffect(() => {
generateDaoDepositAllTx({
walletID: wallet.id,
feeRate: `${MEDIUM_FEE_RATE}`,
feeRate: `${suggestFeeRate}`,
isBalanceReserved,
})
.then((res: any) => {
Expand All @@ -72,7 +74,15 @@ export const useUpdateMaxDeposit = ({
setMaxDepositTx(undefined)
setMaxDepositErrorMessage(err.message)
})
}, [wallet.id, wallet.balance, setMaxDepositAmount, setMaxDepositErrorMessage, setMaxDepositTx, isBalanceReserved])
}, [
wallet.id,
wallet.balance,
setMaxDepositAmount,
setMaxDepositErrorMessage,
setMaxDepositTx,
isBalanceReserved,
suggestFeeRate,
])
}

export const useInitData = ({
Expand Down Expand Up @@ -129,6 +139,7 @@ export const useUpdateDepositValue = ({
maxDepositErrorMessage,
isBalanceReserved,
t,
suggestFeeRate,
}: {
setDepositValue: React.Dispatch<React.SetStateAction<string>>
setErrorMessage: React.Dispatch<React.SetStateAction<string>>
Expand All @@ -140,6 +151,7 @@ export const useUpdateDepositValue = ({
maxDepositErrorMessage: string
isBalanceReserved: boolean
t: TFunction
suggestFeeRate: number | string
}) =>
useCallback(
(value: string) => {
Expand Down Expand Up @@ -171,7 +183,7 @@ export const useUpdateDepositValue = ({
const capacity = CKBToShannonFormatter(amount, CapacityUnit.CKB)
if (BigInt(capacity) < maxDepositAmount) {
generateDaoDepositTx({
feeRate: `${MEDIUM_FEE_RATE}`,
feeRate: `${suggestFeeRate}`,
capacity,
walletID,
}).then(res => {
Expand Down Expand Up @@ -213,6 +225,7 @@ export const useUpdateDepositValue = ({
setDepositValue,
setErrorMessage,
isBalanceReserved,
suggestFeeRate,
]
)

Expand Down Expand Up @@ -298,19 +311,21 @@ export const useOnWithdrawDialogSubmit = ({
clearGeneratedTx,
walletID,
dispatch,
suggestFeeRate,
}: {
activeRecord: State.NervosDAORecord | null
setActiveRecord: React.Dispatch<null>
clearGeneratedTx: () => void
walletID: string
dispatch: React.Dispatch<StateAction>
suggestFeeRate: number | string
}) =>
useCallback(() => {
if (activeRecord) {
generateDaoWithdrawTx({
walletID,
outPoint: activeRecord.outPoint,
feeRate: `${MEDIUM_FEE_RATE}`,
feeRate: `${suggestFeeRate}`,
})
.then(res => {
if (isSuccessResponse(res)) {
Expand Down Expand Up @@ -342,7 +357,7 @@ export const useOnWithdrawDialogSubmit = ({
})
}
setActiveRecord(null)
}, [activeRecord, setActiveRecord, clearGeneratedTx, walletID, dispatch])
}, [activeRecord, setActiveRecord, clearGeneratedTx, walletID, dispatch, suggestFeeRate])

export const useOnActionClick = ({
records,
Expand Down
33 changes: 31 additions & 2 deletions packages/neuron-ui/src/components/NervosDAO/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useState, useMemo, useCallback } from 'react'
import { useState as useGlobalState, useDispatch, AppActions } from 'states'
import { useTranslation } from 'react-i18next'
import { ReactComponent as TooltipIcon } from 'widgets/Icons/Tooltip.svg'

import appState from 'states/init/app'
import { useState as useGlobalState, useDispatch } from 'states'

import {
CONSTANTS,
Expand All @@ -15,9 +15,12 @@ import {
getCurrentUrl,
getSyncStatus,
CKBToShannonFormatter,
ErrorCode,
CapacityUnit,
isSuccessResponse,
} from 'utils'

import { openExternal } from 'services/remote'
import { generateDaoDepositTx, openExternal } from 'services/remote'

import DepositDialog from 'components/DepositDialog'
import WithdrawDialog from 'components/WithdrawDialog'
Expand All @@ -43,6 +46,7 @@ const NervosDAO = () => {
tipBlockHash,
tipBlockTimestamp,
epoch,
feeRateStatics: { suggestFeeRate = 0 },
},
wallet,
nervosDAO: { records },
Expand Down Expand Up @@ -79,6 +83,7 @@ const NervosDAO = () => {
maxDepositErrorMessage,
isBalanceReserved,
t,
suggestFeeRate,
})

const onDepositValueChange = hooks.useOnDepositValueChange({ updateDepositValue })
Expand All @@ -102,6 +107,7 @@ const NervosDAO = () => {
setMaxDepositTx,
setMaxDepositErrorMessage,
isBalanceReserved,
suggestFeeRate,
})
hooks.useInitData({ clearGeneratedTx, dispatch, updateDepositValue, wallet, setGenesisBlockTimestamp })
hooks.useUpdateGlobalAPC({ bestKnownBlockTimestamp, genesisBlockTimestamp, setGlobalAPC })
Expand All @@ -111,6 +117,7 @@ const NervosDAO = () => {
clearGeneratedTx,
walletID: wallet.id,
dispatch,
suggestFeeRate,
})

const onActionClick = hooks.useOnActionClick({
Expand Down Expand Up @@ -244,6 +251,28 @@ const NervosDAO = () => {
}
}, [maxDepositAmount, depositValue, setDepositValue])

// use to update fee with suggestFeeRate
useEffect(() => {
generateDaoDepositTx({
feeRate: `${suggestFeeRate}`,
capacity: CKBToShannonFormatter(depositValue, CapacityUnit.CKB),
walletID: wallet.id,
}).then(res => {
if (isSuccessResponse(res)) {
dispatch({
type: AppActions.UpdateGeneratedTx,
payload: res.result,
})
} else if (res.status === 0) {
setErrorMessage(`${typeof res.message === 'string' ? res.message : res.message.content}`)
} else if (res.status === ErrorCode.CapacityNotEnoughForChange) {
setErrorMessage(t(`messages.codes.106`))
} else {
setErrorMessage(t(`messages.codes.${res.status}`))
}
})
}, [suggestFeeRate, generateDaoDepositTx])

const MemoizedDepositDialog = useMemo(() => {
return (
<DepositDialog
Expand Down
Loading