@ckbfs/api 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/transaction.ts +10 -2
package/package.json
CHANGED
package/src/utils/transaction.ts
CHANGED
@@ -113,6 +113,7 @@ export async function createPublishTransaction(
|
|
113
113
|
contentType,
|
114
114
|
filename,
|
115
115
|
lock,
|
116
|
+
capacity,
|
116
117
|
feeRate,
|
117
118
|
network = DEFAULT_NETWORK,
|
118
119
|
version = DEFAULT_VERSION,
|
@@ -164,6 +165,12 @@ export async function createPublishTransaction(
|
|
164
165
|
// Get CKBFS script config
|
165
166
|
const config = getCKBFSScriptConfig(network, version, useTypeID);
|
166
167
|
|
168
|
+
const preCkbfsTypeScript = new Script(
|
169
|
+
ensureHexPrefix(config.codeHash),
|
170
|
+
config.hashType as any,
|
171
|
+
"0x0000000000000000000000000000000000000000000000000000000000000000"
|
172
|
+
);
|
173
|
+
const ckbfsCellSize = BigInt(outputData.length + preCkbfsTypeScript.occupiedSize + lock.occupiedSize + 8) * 100000000n
|
167
174
|
// Create pre transaction without cell deps initially
|
168
175
|
const preTx = Transaction.from({
|
169
176
|
outputs: [
|
@@ -173,7 +180,8 @@ export async function createPublishTransaction(
|
|
173
180
|
lock,
|
174
181
|
network,
|
175
182
|
version,
|
176
|
-
useTypeID
|
183
|
+
useTypeID,
|
184
|
+
capacity: ckbfsCellSize || capacity
|
177
185
|
})
|
178
186
|
],
|
179
187
|
witnesses: [
|
@@ -339,7 +347,7 @@ export async function createAppendTransaction(
|
|
339
347
|
// Add the additional capacity to the original cell capacity
|
340
348
|
console.log(`Original capacity: ${capacity}, Additional needed: ${additionalCapacity}, Data size diff: ${dataSizeDiff}, Version: ${version}`);
|
341
349
|
const outputCapacity = capacity + additionalCapacity;
|
342
|
-
|
350
|
+
|
343
351
|
// Create initial transaction with the CKBFS cell input
|
344
352
|
const tx = Transaction.from({
|
345
353
|
inputs: [
|