Skip to content

Commit

Permalink
feat: check spore transaction witnesses length
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonn committed Jul 18, 2024
1 parent b35236f commit 11de67b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/services/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ interface ITransactionProcessor {
export const TRANSACTION_QUEUE_NAME = 'rgbpp-ckb-transaction-queue';

class InvalidTransactionError extends Error {
public data: ITransactionRequest;
public data?: ITransactionRequest;

constructor(message: string, data: ITransactionRequest) {
constructor(message: string, data?: ITransactionRequest) {
super(message);
this.name = this.constructor.name;
this.data = data;
Expand Down Expand Up @@ -340,11 +340,11 @@ export default class TransactionProcessor
// make sure the spore cobuild witness is the last witness
if (needPaymasterCell) {
const witnesses = signedTx.witnesses;
signedTx.witnesses = [
...witnesses.slice(0, witnesses.length - 2),
witnesses[witnesses.length - 1],
witnesses[witnesses.length - 2],
];
const len = witnesses.length;
if (len < 2) {
throw new InvalidTransactionError('Not enough spore transaction witnesses');
}
signedTx.witnesses = [...witnesses.slice(0, len - 2), witnesses[len - 1], witnesses[len - 2]];
}

const tx = await this.appendSporeCobuildWitness(signedTx);
Expand Down

0 comments on commit 11de67b

Please sign in to comment.