@ckbfs/api 2.0.4 → 2.0.5

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.
@@ -161,9 +161,9 @@ function extractCKBFSV3WitnessContent(witness, isHeadWitness = true) {
161
161
  // Extract previous position
162
162
  const prevTxHashBytes = witness.slice(6, 38);
163
163
  const previousTxHash = '0x' + Array.from(prevTxHashBytes).map(b => b.toString(16).padStart(2, '0')).join('');
164
- const previousWitnessIndex = new DataView(witness.slice(38, 42).buffer).getUint32(0, true);
165
- const previousChecksum = new DataView(witness.slice(42, 46).buffer).getUint32(0, true);
166
- const nextIndex = new DataView(witness.slice(46, 50).buffer).getUint32(0, true);
164
+ const previousWitnessIndex = new DataView(witness.slice(38, 42).buffer.slice(witness.slice(38, 42).byteOffset, witness.slice(38, 42).byteOffset + 4)).getUint32(0, true);
165
+ const previousChecksum = new DataView(witness.slice(42, 46).buffer.slice(witness.slice(42, 46).byteOffset, witness.slice(42, 46).byteOffset + 4)).getUint32(0, true);
166
+ const nextIndex = new DataView(witness.slice(46, 50).buffer.slice(witness.slice(46, 50).byteOffset, witness.slice(46, 50).byteOffset + 4)).getUint32(0, true);
167
167
  const content = witness.slice(50);
168
168
  return {
169
169
  version,
@@ -113,13 +113,7 @@ export async function claim(to: string, sporeId: string, ckbfsId: string) {
113
113
 
114
114
  const content = `TRANSFER,FROM:${fromHash},TO:${toHash}\n`
115
115
 
116
- const previousData = {
117
- previousTxHash: ckbfsCell.outPoint.txHash,
118
- previousWitnessIndex: ckbfsCell.data?.index || 0,
119
- previousChecksum: ckbfsCell.data?.checksum || 0
120
- };
121
-
122
- let tx = await ckbfs.createAppendContentTransaction(content, ckbfsCell, previousData as any);
116
+ let tx = await ckbfs.createAppendContentTransaction(content, ckbfsCell);
123
117
  tx.addCellDeps(TraceLockDep)
124
118
 
125
119
  const sizeBefore = tx.outputs[0].lock.occupiedSize
@@ -405,8 +399,8 @@ async function testReresolve(ckbfsId: string) {
405
399
  // })
406
400
 
407
401
 
408
- // getCellInfoFromV3Transaction("0x8dc79a7630145e2a220e2363beca2781c6a4f0f79ef7a01ab73f17dc90571fb7").then(console.log)
402
+ getCellInfoFromV3Transaction("0x54c86dbdc6bdafb4616221d54cfc0ff186a4a772eba509838684f8e1ea271b40").then(console.log)
409
403
 
410
- // getCkbfsCellInfo("0x0084106b9bea08f512e35b725c4a710ebf09cb65c05601ebde8d911bc6c662bf").then(console.log)
404
+ getCkbfsCellInfo("0x2c734e7f72e2e9d1a472f5ba26b229ac319c2ab26fdcd05fd7ce301390875f81").then(console.log)
411
405
 
412
406
  // testReresolve("0x0084106b9bea08f512e35b725c4a710ebf09cb65c05601ebde8d911bc6c662bf").then(console.log)
@@ -110,7 +110,7 @@ async function retrieveAndSaveFileV3Example() {
110
110
  async function retrieveFileByURIV3Example() {
111
111
  try {
112
112
  // Example CKBFS URI (replace with actual URI)
113
- const ckbfsUri = "ckbfs://d52d8536d3498bd68fa1e235f7e090c2d047154e22fcea5cfa54ccb58c236eb3";
113
+ const ckbfsUri = "ckbfs://d49b78d821a12da1fc484ef36f855109fc52b195af29cafda1c134656e940a35";
114
114
 
115
115
  console.log(`Retrieving CKBFS v3 file by URI: ${ckbfsUri}`);
116
116
 
@@ -242,10 +242,10 @@ async function main() {
242
242
  // Uncomment to test different retrieval methods:
243
243
  //await retrieveFileByTypeIdV3Example();
244
244
  // await retrieveAndSaveFileV3Example();
245
- // await retrieveFileByURIV3Example();
245
+ await retrieveFileByURIV3Example();
246
246
  // //await retrieveFileByOutPointV3Example();
247
247
 
248
- await testReresolve("0x0084106b9bea08f512e35b725c4a710ebf09cb65c05601ebde8d911bc6c662bf").then(console.log)
248
+ // await testReresolve("0x0084106b9bea08f512e35b725c4a710ebf09cb65c05601ebde8d911bc6c662bf").then(console.log)
249
249
 
250
250
  // console.log('Retrieval example structure completed successfully!');
251
251
  // console.log('Update the identifiers and uncomment methods to test.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckbfs/api",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "SDK for CKBFS protocol on CKB",
5
5
  "license": "MIT",
6
6
  "author": "Code Monad<code@lab-11.org>",
@@ -208,10 +208,9 @@ export function extractCKBFSV3WitnessContent(witness: Uint8Array, isHeadWitness:
208
208
  // Extract previous position
209
209
  const prevTxHashBytes = witness.slice(6, 38);
210
210
  const previousTxHash = '0x' + Array.from(prevTxHashBytes).map(b => b.toString(16).padStart(2, '0')).join('');
211
-
212
- const previousWitnessIndex = new DataView(witness.slice(38, 42).buffer).getUint32(0, true);
213
- const previousChecksum = new DataView(witness.slice(42, 46).buffer).getUint32(0, true);
214
- const nextIndex = new DataView(witness.slice(46, 50).buffer).getUint32(0, true);
211
+ const previousWitnessIndex = new DataView(witness.slice(38, 42).buffer.slice(witness.slice(38, 42).byteOffset, witness.slice(38, 42).byteOffset + 4)).getUint32(0, true);
212
+ const previousChecksum = new DataView(witness.slice(42, 46).buffer.slice(witness.slice(42, 46).byteOffset, witness.slice(42, 46).byteOffset + 4)).getUint32(0, true);
213
+ const nextIndex = new DataView(witness.slice(46, 50).buffer.slice(witness.slice(46, 50).byteOffset, witness.slice(46, 50).byteOffset + 4)).getUint32(0, true);
215
214
  const content = witness.slice(50);
216
215
 
217
216
  return {