@ckbfs/api 1.2.1 → 1.2.3
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/ABC.LOGS +1 -0
- package/dist/utils/transaction.js +15 -5
- package/package.json +1 -1
- package/src/utils/transaction.ts +21 -8
package/ABC.LOGS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
MINT,TO:ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqdpallzwnhe64rqnqmev7hf98yrmh4yzucgdw7qwGIVE_NAME,NEW_NAME:NERVAPE_COOKIE
|
@@ -254,10 +254,6 @@ async function createAppendTransaction(signer, options) {
|
|
254
254
|
capacity: outputCapacity,
|
255
255
|
}
|
256
256
|
],
|
257
|
-
witnesses: [
|
258
|
-
[], // Empty secp witness for signing
|
259
|
-
...ckbfsWitnesses.map(w => `0x${Buffer.from(w).toString('hex')}`),
|
260
|
-
],
|
261
257
|
outputsData: [
|
262
258
|
outputData,
|
263
259
|
]
|
@@ -272,14 +268,28 @@ async function createAppendTransaction(signer, options) {
|
|
272
268
|
});
|
273
269
|
// Get the recommended address to ensure lock script cell deps are included
|
274
270
|
const address = await signer.getRecommendedAddressObj();
|
271
|
+
const inputsBefore = tx.inputs.length;
|
275
272
|
// If we need more capacity than the original cell had, add additional inputs
|
276
273
|
if (outputCapacity > capacity) {
|
277
274
|
console.log(`Need additional capacity: ${outputCapacity - capacity} shannons`);
|
278
275
|
// Add more inputs to cover the increased capacity
|
279
276
|
await tx.completeInputsByCapacity(signer);
|
280
277
|
}
|
278
|
+
const witnesses = [];
|
279
|
+
// add empty witness for signer if ckbfs's lock is the same as signer's lock
|
280
|
+
if (address.script.hash() === lock.hash()) {
|
281
|
+
witnesses.push('0x');
|
282
|
+
}
|
283
|
+
// add ckbfs witnesses
|
284
|
+
witnesses.push(...ckbfsWitnesses.map(w => `0x${Buffer.from(w).toString('hex')}`));
|
285
|
+
// Add empty witnesses for signer's input
|
286
|
+
// This is to ensure that the transaction is valid and can be signed
|
287
|
+
for (let i = inputsBefore; i < tx.inputs.length; i++) {
|
288
|
+
witnesses.push('0x');
|
289
|
+
}
|
290
|
+
tx.witnesses = witnesses;
|
281
291
|
// Complete fee
|
282
|
-
await tx.completeFeeChangeToLock(signer,
|
292
|
+
await tx.completeFeeChangeToLock(signer, address.script, feeRate || 2000);
|
283
293
|
return tx;
|
284
294
|
}
|
285
295
|
/**
|
package/package.json
CHANGED
package/src/utils/transaction.ts
CHANGED
@@ -378,15 +378,12 @@ export async function createAppendTransaction(
|
|
378
378
|
capacity: outputCapacity,
|
379
379
|
}
|
380
380
|
],
|
381
|
-
witnesses: [
|
382
|
-
[], // Empty secp witness for signing
|
383
|
-
...ckbfsWitnesses.map(w => `0x${Buffer.from(w).toString('hex')}`),
|
384
|
-
],
|
385
381
|
outputsData: [
|
386
382
|
outputData,
|
387
383
|
]
|
388
384
|
});
|
389
|
-
|
385
|
+
|
386
|
+
|
390
387
|
// Add the CKBFS dep group cell dependency
|
391
388
|
tx.addCellDeps({
|
392
389
|
outPoint: {
|
@@ -398,16 +395,32 @@ export async function createAppendTransaction(
|
|
398
395
|
|
399
396
|
// Get the recommended address to ensure lock script cell deps are included
|
400
397
|
const address = await signer.getRecommendedAddressObj();
|
401
|
-
|
398
|
+
|
399
|
+
const inputsBefore = tx.inputs.length;
|
402
400
|
// If we need more capacity than the original cell had, add additional inputs
|
403
401
|
if (outputCapacity > capacity) {
|
404
402
|
console.log(`Need additional capacity: ${outputCapacity - capacity} shannons`);
|
405
403
|
// Add more inputs to cover the increased capacity
|
406
404
|
await tx.completeInputsByCapacity(signer);
|
407
405
|
}
|
408
|
-
|
406
|
+
|
407
|
+
const witnesses: any = []
|
408
|
+
// add empty witness for signer if ckbfs's lock is the same as signer's lock
|
409
|
+
if(address.script.hash() === lock.hash()) {
|
410
|
+
witnesses.push('0x')
|
411
|
+
}
|
412
|
+
// add ckbfs witnesses
|
413
|
+
witnesses.push(...ckbfsWitnesses.map(w => `0x${Buffer.from(w).toString('hex')}`))
|
414
|
+
|
415
|
+
// Add empty witnesses for signer's input
|
416
|
+
// This is to ensure that the transaction is valid and can be signed
|
417
|
+
for(let i = inputsBefore; i < tx.inputs.length; i++) {
|
418
|
+
witnesses.push('0x')
|
419
|
+
}
|
420
|
+
tx.witnesses = witnesses
|
421
|
+
|
409
422
|
// Complete fee
|
410
|
-
await tx.completeFeeChangeToLock(signer,
|
423
|
+
await tx.completeFeeChangeToLock(signer, address.script, feeRate || 2000);
|
411
424
|
|
412
425
|
return tx;
|
413
426
|
}
|