@ckbfs/api 1.2.3 → 1.2.4

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.
@@ -168,10 +168,12 @@ async function createAppendTransaction(signer, options) {
168
168
  // cumulative nature as required by Rule 11 in the RFC
169
169
  const contentChecksum = await (0, checksum_1.updateChecksum)(data.checksum, combinedContent);
170
170
  console.log(`Updated checksum from ${data.checksum} to ${contentChecksum} for appended content`);
171
+ // Get the recommended address to ensure lock script cell deps are included
172
+ const address = await signer.getRecommendedAddressObj();
171
173
  // Calculate the actual witness indices where our content is placed
172
- // Index 0 is reserved for the secp256k1 witness for signing
173
- // So our CKBFS data starts at index 1
174
- const contentStartIndex = 1;
174
+ // CKBFS data starts at index 1 if signer's lock script is the same as ckbfs's lock script
175
+ // else CKBFS data starts at index 0
176
+ const contentStartIndex = address.script.hash() === lock.hash() ? 1 : 0;
175
177
  const witnessIndices = Array.from({ length: contentChunks.length }, (_, i) => contentStartIndex + i);
176
178
  // Create backlink for the current state based on version
177
179
  let newBackLink;
@@ -266,8 +268,6 @@ async function createAppendTransaction(signer, options) {
266
268
  },
267
269
  depType: "depGroup"
268
270
  });
269
- // Get the recommended address to ensure lock script cell deps are included
270
- const address = await signer.getRecommendedAddressObj();
271
271
  const inputsBefore = tx.inputs.length;
272
272
  // If we need more capacity than the original cell had, add additional inputs
273
273
  if (outputCapacity > capacity) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckbfs/api",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "SDK for CKBFS protocol on CKB",
5
5
  "license": "MIT",
6
6
  "author": "Code Monad<code@lab-11.org>",
@@ -280,10 +280,13 @@ export async function createAppendTransaction(
280
280
  const contentChecksum = await updateChecksum(data.checksum, combinedContent);
281
281
  console.log(`Updated checksum from ${data.checksum} to ${contentChecksum} for appended content`);
282
282
 
283
+ // Get the recommended address to ensure lock script cell deps are included
284
+ const address = await signer.getRecommendedAddressObj();
285
+
283
286
  // Calculate the actual witness indices where our content is placed
284
- // Index 0 is reserved for the secp256k1 witness for signing
285
- // So our CKBFS data starts at index 1
286
- const contentStartIndex = 1;
287
+ // CKBFS data starts at index 1 if signer's lock script is the same as ckbfs's lock script
288
+ // else CKBFS data starts at index 0
289
+ const contentStartIndex = address.script.hash() === lock.hash() ? 1 : 0;
287
290
  const witnessIndices = Array.from(
288
291
  { length: contentChunks.length },
289
292
  (_, i) => contentStartIndex + i
@@ -393,9 +396,6 @@ export async function createAppendTransaction(
393
396
  depType: "depGroup"
394
397
  });
395
398
 
396
- // Get the recommended address to ensure lock script cell deps are included
397
- const address = await signer.getRecommendedAddressObj();
398
-
399
399
  const inputsBefore = tx.inputs.length;
400
400
  // If we need more capacity than the original cell had, add additional inputs
401
401
  if (outputCapacity > capacity) {