Skip to content

Commit 6d25c00

Browse files
committed
chore: remove margin capacity in addOutput
1 parent eaf3dc6 commit 6d25c00

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

packages/core/src/ckb/transaction.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,6 @@ export class Transaction extends mol.Entity.Base<
17871787
addOutput(
17881788
cellOrOutputLike: CellAnyLike | CellOutputLike,
17891789
outputDataLike?: HexLike | null,
1790-
marginCapacity?: NumLike | null,
17911790
): number {
17921791
const cell =
17931792
"cellOutput" in cellOrOutputLike
@@ -1800,14 +1799,6 @@ export class Transaction extends mol.Entity.Base<
18001799
const len = this.outputs.push(cell.cellOutput);
18011800
this.setOutputDataAt(len - 1, cell.outputData);
18021801

1803-
if (
1804-
marginCapacity !== undefined &&
1805-
marginCapacity !== null &&
1806-
marginCapacity !== Zero
1807-
) {
1808-
cell.cellOutput.capacity += numFrom(marginCapacity);
1809-
}
1810-
18111802
return len;
18121803
}
18131804

packages/spore/src/spore/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export async function createSpore(params: {
115115
ids.push(id);
116116

117117
const packedData = packRawSporeData(data);
118-
tx.addOutput(
118+
const outputIndex = tx.addOutput(
119119
{
120120
lock: to ?? lock,
121121
type: {
@@ -124,9 +124,16 @@ export async function createSpore(params: {
124124
},
125125
},
126126
packedData,
127-
marginCapacity ? ccc.numFrom(marginCapacity) : ONE_CKB,
128127
);
129128

129+
// Add margin capacity if specified
130+
if (marginCapacity) {
131+
const margin = ccc.numFrom(marginCapacity);
132+
if (margin > ONE_CKB) {
133+
tx.outputs[outputIndex - 1].capacity += margin;
134+
}
135+
}
136+
130137
// create spore action
131138
if (scriptInfo.cobuild) {
132139
const output = tx.outputs[tx.outputs.length - 1];

0 commit comments

Comments
 (0)