diff --git a/.ckb-version b/.ckb-version index 64a30f7e97..cff1fcdc66 100644 --- a/.ckb-version +++ b/.ckb-version @@ -1 +1 @@ -v0.113.0 +v0.113.1 diff --git a/.github/workflows/update_valid_target.yml b/.github/workflows/update_wallet_env.yml similarity index 89% rename from .github/workflows/update_valid_target.yml rename to .github/workflows/update_wallet_env.yml index c5c40702b8..bda340a1ba 100644 --- a/.github/workflows/update_valid_target.yml +++ b/.github/workflows/update_wallet_env.yml @@ -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 @@ -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 @@ -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, @@ -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: | diff --git a/package.json b/package.json index d52255be37..1318cbb1a7 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/packages/neuron-ui/src/components/BroadcastTransaction/broadcastTransaction.module.scss b/packages/neuron-ui/src/components/BroadcastTransaction/broadcastTransaction.module.scss new file mode 100644 index 0000000000..56ed207431 --- /dev/null +++ b/packages/neuron-ui/src/components/BroadcastTransaction/broadcastTransaction.module.scss @@ -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; +} diff --git a/packages/neuron-ui/src/components/BroadcastTransaction/index.tsx b/packages/neuron-ui/src/components/BroadcastTransaction/index.tsx new file mode 100644 index 0000000000..ccc1da482c --- /dev/null +++ b/packages/neuron-ui/src/components/BroadcastTransaction/index.tsx @@ -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('') + 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 ( + <> + +
+ + + + + + + + + + + + + + +
{t('offline-sign.json-file')}{filePath}
{t('offline-sign.status.label')}{t('offline-sign.status.signed')}
{t('offline-sign.content')}
+