Skip to content

Commit

Permalink
fix duplicated headers when batching dao unlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tea2x committed Aug 18, 2024
1 parent 32d03d9 commit 3800e7f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "joy-dao",
"version": "0.0.3",
"version": "0.0.4",
"description": "Nervos DAO transaction builder",
"main": "dist/index.js",
"files": [
Expand Down
21 changes: 14 additions & 7 deletions src/lumos-patcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,22 @@ export const unlock = async (
}

// add dao unlock header deps
txSkeleton = txSkeleton.update("headerDeps", (headerDeps) => {
return headerDeps.push(
daoDepositCell.blockHash!,
daoWithdrawalCell.blockHash!
);
});
let headerDeps = txSkeleton.get("headerDeps");
if (!headerDeps.contains(daoDepositCell.blockHash!)) {
txSkeleton = txSkeleton.update("headerDeps", (headerDeps) => {
return headerDeps.push(daoDepositCell.blockHash!);
});
}

if (!headerDeps.contains(daoWithdrawalCell.blockHash!)) {
txSkeleton = txSkeleton.update("headerDeps", (headerDeps) => {
return headerDeps.push(daoWithdrawalCell.blockHash!);
});
}

// add dao unlock witness
const depositHeaderDepIndex = txSkeleton.get("headerDeps").size - 2;
headerDeps = txSkeleton.get("headerDeps");
const depositHeaderDepIndex = headerDeps.indexOf(daoDepositCell.blockHash!);
const defaultWitnessArgs: WitnessArgs = {
inputType: bytes.hexify(number.Uint64LE.pack(depositHeaderDepIndex)),
};
Expand Down

0 comments on commit 3800e7f

Please sign in to comment.