Skip to content

Commit

Permalink
refactor(demo): use getTransactionWithHeader for NervosDAO
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanssen0 committed Feb 14, 2025
1 parent d584059 commit 19e8be5
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions packages/demo/src/app/connected/(tools)/NervosDao/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,13 @@ function DaoButton({ dao }: { dao: ccc.Cell }) {
const tipHeader = await signer.client.getTipHeader();
setTip(tipHeader);

const previousTx = await signer.client.getTransaction(
const previousTxRes = await signer.client.getTransactionWithHeader(
dao.outPoint.txHash,
);
if (!previousTx?.blockHash) {
return;
}
const previousHeader = await signer.client.getHeaderByHash(
previousTx.blockHash,
);
if (!previousHeader) {
if (!previousTxRes || !previousTxRes.header) {
return;
}
const { transaction: previousTx, header: previousHeader } = previousTxRes;

const claimInfo = await (async (): Promise<typeof infos> => {
if (isNew) {
Expand All @@ -110,17 +105,13 @@ function DaoButton({ dao }: { dao: ccc.Cell }) {
const depositTxHash =
previousTx.transaction.inputs[Number(dao.outPoint.index)]
.previousOutput.txHash;
const depositTx = await signer.client.getTransaction(depositTxHash);
if (!depositTx?.blockHash) {
const depositTxRes =
await signer.client.getTransactionWithHeader(depositTxHash);
if (!depositTxRes || !depositTxRes.header) {
return;
}
const depositHeader = await signer.client.getHeaderByHash(
depositTx.blockHash,
);
const { transaction: depositTx, header: depositHeader } = depositTxRes;

if (!depositHeader) {
return;
}
return [
getProfit(dao, depositHeader, previousHeader),
depositTx,
Expand Down

0 comments on commit 19e8be5

Please sign in to comment.