Skip to content

Commit

Permalink
Merge branch 'develop' into chore-update-typeorm
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Feb 4, 2024
2 parents faf6c69 + ace289b commit cd78f32
Show file tree
Hide file tree
Showing 77 changed files with 1,793 additions and 533 deletions.
2 changes: 1 addition & 1 deletion .ckb-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.113.0
v0.113.1
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: 'chore-update-valid-target/${{github.ref_name}}'
branch: 'chore-update-wallet-env/${{github.ref_name}}'
sha: '${{ github.event.create.head.sha }}'

- name: Checkout
uses: actions/checkout@v4
with:
ref: 'chore-update-valid-target/${{github.ref_name}}'
ref: 'chore-update-wallet-env/${{github.ref_name}}'

- name: Setup Node
uses: actions/setup-node@v4
Expand All @@ -29,7 +29,7 @@ jobs:

- name: Write env file
run: |
npm run update:valid-target
npm run update:wallet-env
- name: Commit env file
uses: actions/github-script@v7
Expand All @@ -41,7 +41,7 @@ jobs:
const fs = require('node:fs')
const { BASE, HEAD } = process.env
const envFilePath = 'packages/neuron-wallet/.env'
const destinationBranch = `chore-update-valid-target/${BASE}`
const destinationBranch = `chore-update-wallet-env/${BASE}`
const { data } = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -63,7 +63,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE: ${{github.ref}}
HEAD: chore-update-valid-target/${{github.ref_name}}
HEAD: chore-update-wallet-env/${{github.ref_name}}
REPO: ${{github.repository}}
with:
script: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"lint": "lerna run --stream lint",
"postinstall": "husky install",
"db:chain": "node ./node_modules/.bin/typeorm",
"update:valid-target": "node ./scripts/update-valid-target.js",
"update:wallet-env": "node ./scripts/update-wallet-env.js",
"update:neuron-compatible": "node ./scripts/add-neuron-version-in-compatibility-table.js",
"update:client-versions": "node ./scripts/update-ckb-client-versions.js"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.main {
tr {
td {
font-size: 14px;
line-height: 26px;
color: var(--main-text-color);
svg {
width: 14px;
height: 14px;
margin-right: 4px;
position: relative;
top: 2px;
}
}
.first {
padding-right: 24px;
color: var(--input-second-color);
}
}
}

.warningDialog {
width: 680px;
.content {
display: flex;
justify-content: center;
margin-top: 24px;
color: var(--main-text-color);
}
}

.textarea {
color: var(--main-text-color);
margin-top: 17px;
width: 648px;
height: 206px;
resize: none;
background: var(--secondary-background-color);
border: 1px solid var(--divide-line-color);
border-radius: 8px;
padding: 16px;
}
136 changes: 136 additions & 0 deletions packages/neuron-ui/src/components/BroadcastTransaction/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import React, { useCallback, useMemo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import { isSuccessResponse, RoutePath, isMainnet as isMainnetUtil, useGoBack, getExplorerUrl } from 'utils'
import Dialog from 'widgets/Dialog'
import AlertDialog from 'widgets/AlertDialog'
import { useDispatch, useState as useGlobalState } from 'states'
import { broadcastSignedTransaction, OfflineSignStatus, openExternal, getTransactionList } from 'services/remote'

import styles from './broadcastTransaction.module.scss'

const BroadcastTransaction = () => {
const {
app: { loadedTransaction = {} },
chain: { networkID },
settings: { networks },
wallet,
} = useGlobalState()

const [isBroadcasting, setIsBroadcasting] = useState(false)
const [broadcastedTxHash, setBroadcastedTxHash] = useState<string | null>('')
const [t] = useTranslation()
const dispatch = useDispatch()
const [errMsg, setErrMsg] = useState('')
const isMainnet = isMainnetUtil(networks, networkID)

const { filePath, json } = loadedTransaction

const jsonContent = useMemo(() => {
return JSON.stringify(json, null, 2)
}, [json])

const signStatus: OfflineSignStatus = json.status

const isSigned = useMemo(() => signStatus === OfflineSignStatus.Signed, [signStatus])

const onBack = useGoBack()

const navigate = useNavigate()
const onBroadcast = useCallback(async () => {
if (broadcastedTxHash) {
openExternal(`${getExplorerUrl(isMainnet)}/transaction/${broadcastedTxHash}`)
return
}

setIsBroadcasting(true)

const res = await broadcastSignedTransaction({
...json,
})

setIsBroadcasting(false)

if (isSuccessResponse(res)) {
if (!wallet?.id) {
setBroadcastedTxHash(res.result)
return
}

if (res.result) {
getTransactionList({
walletID: wallet.id,
pageNo: 1,
pageSize: 10,
keywords: res.result,
}).then(txRes => {
if (isSuccessResponse(txRes) && txRes.result.items.length) {
navigate(RoutePath.History)
} else {
setBroadcastedTxHash(res.result)
}
})
}
} else {
setErrMsg(typeof res.message === 'string' ? res.message : res.message.content || '')
}
}, [wallet, json, navigate, dispatch, broadcastedTxHash, setBroadcastedTxHash])

return (
<>
<Dialog
show={isSigned}
title={t('offline-sign.broadcast-transaction')}
cancelText={t('offline-sign.actions.cancel')}
onCancel={onBack}
confirmText={
broadcastedTxHash ? t('offline-sign.actions.view-in-explorer') : t('offline-sign.actions.broadcast')
}
isLoading={isBroadcasting}
onConfirm={onBroadcast}
>
<div className={styles.main}>
<table>
<tbody>
<tr>
<td className={styles.first}>{t('offline-sign.json-file')}</td>
<td>{filePath}</td>
</tr>
<tr>
<td className={styles.first}>{t('offline-sign.status.label')}</td>
<td>{t('offline-sign.status.signed')}</td>
</tr>
<tr>
<td className={styles.first}>{t('offline-sign.content')}</td>
</tr>
</tbody>
</table>
<textarea disabled value={jsonContent} className={styles.textarea} />
</div>
</Dialog>

<Dialog
show={!isSigned}
className={styles.warningDialog}
title={t('offline-sign.import-transaction-to-sign')}
cancelText={t('offline-sign.actions.cancel')}
onCancel={onBack}
onConfirm={onBack}
>
<div className={styles.content}>{t('offline-sign.import-unsigned-transaction-detail')}</div>
</Dialog>

<AlertDialog
show={!!errMsg}
title={t('message-types.alert')}
message={errMsg}
type="failed"
onCancel={() => setErrMsg('')}
/>
</>
)
}

BroadcastTransaction.displayName = 'BroadcastTransaction'

export default BroadcastTransaction
Original file line number Diff line number Diff line change
Expand Up @@ -160,71 +160,3 @@
word-break: normal;
white-space: normal;
}

.dialogContainer {
max-width: 700px;
color: var(--main-text-color);
font-size: 14px;
line-height: 24px;

.attention {
display: flex;
justify-content: center;
align-items: center;
padding: 8px;
width: 80%;
margin: 32px auto 0;
background: var(--warn-background-color);
border: 1px solid rgba(252, 136, 0, 0.2);
border-radius: 4px;
font-weight: 500;
font-size: 12px;
line-height: 24px;
color: var(--warn-text-color);

@media (prefers-color-scheme: dark) {
border: none;
}

svg {
margin-right: 4px;
width: 14px;
}
}
}

.footer {
padding: 24px 0;
@include dialog-footer;
--footer-background-color: #ecf9f0;
@media (prefers-color-scheme: dark) {
--footer-background-color: #2d3534;
}

.footerBtn {
padding: 0 20px;
background: var(--footer-background-color);
color: var(--primary-color);
&:not([disabled]) {
&:hover,
&:focus {
background-color: var(--footer-background-color);
color: color-mix(in srgb, #000000 20%, var(--primary-color));
}

&:active {
background-color: var(--footer-background-color);
color: color-mix(in srgb, #000000 20%, var(--primary-color));
}
}
&:last-of-type {
margin-left: 24px;
}
svg {
g,
path {
fill: var(--primary-color);
}
}
}
}
47 changes: 8 additions & 39 deletions packages/neuron-ui/src/components/DataSetting/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import React, { useCallback, useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
getCkbNodeDataPath,
invokeShowOpenDialog,
startProcessMonitor,
stopProcessMonitor,
setCkbNodeDataPath,
} from 'services/remote'
import { getCkbNodeDataPath, invokeShowOpenDialog, startProcessMonitor, stopProcessMonitor } from 'services/remote'
import { isSuccessResponse } from 'utils'

const type = 'ckb'

export const useDataPath = (network?: State.Network) => {
const [t] = useTranslation()
const [isSaving, setIsSaving] = useState(false)
const [savingType, setSavingType] = useState<string | null>()
const [prevPath, setPrevPath] = useState<string>()
const [currentPath, setCurrentPath] = useState<string | undefined>()
const [prevPath, setPrevPath] = useState('')
const [currentPath, setCurrentPath] = useState('')
const [isDialogOpen, setIsDialogOpen] = useState(false)
const [faidMessage, setFaidMessage] = useState('')

useEffect(() => {
getCkbNodeDataPath().then(res => {
Expand Down Expand Up @@ -50,41 +41,19 @@ export const useDataPath = (network?: State.Network) => {
})
}, [setIsDialogOpen, type])
const onConfirm = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
setFaidMessage('')
const { dataset } = e.currentTarget
setIsSaving(true)
setSavingType(dataset.syncType)
setCkbNodeDataPath({
dataPath: currentPath!,
clearCache: type === 'ckb' && dataset?.resync === 'true',
})
.then(res => {
if (isSuccessResponse(res)) {
setPrevPath(currentPath)
setIsDialogOpen(false)
} else {
setFaidMessage(typeof res.message === 'string' ? res.message : res.message.content!)
}
})
.finally(() => {
setIsSaving(false)
setSavingType(null)
})
(dataPath: string) => {
setPrevPath(dataPath)
setIsDialogOpen(false)
},
[currentPath, setIsDialogOpen, setPrevPath]
[setIsDialogOpen, setPrevPath]
)
return {
prevPath,
currentPath,
onSetting,
onCancel,
onConfirm,
isSaving,
savingType,
isDialogOpen,
faidMessage,
setFaidMessage,
}
}

Expand Down
Loading

1 comment on commit cd78f32

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 7772632360

Please sign in to comment.