fix: allow signing a populated transaction (#24475)
This commit is contained in:
parent
342b201339
commit
7ba419e5d5
|
@ -167,7 +167,7 @@ export interface TransactionJSON {
|
|||
nonceInstruction: TransactionInstructionJSON;
|
||||
} | null;
|
||||
instructions: TransactionInstructionJSON[];
|
||||
signatures: {publicKey: string; signature: number[] | null}[];
|
||||
signers: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,10 +242,9 @@ export class Transaction {
|
|||
}
|
||||
: null,
|
||||
instructions: this.instructions.map(instruction => instruction.toJSON()),
|
||||
signatures: this.signatures.map(({publicKey, signature}) => ({
|
||||
publicKey: publicKey.toJSON(),
|
||||
signature: signature ? [...signature] : null,
|
||||
})),
|
||||
signers: this.signatures.map(({publicKey}) => {
|
||||
return publicKey.toJSON();
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -280,7 +279,7 @@ export class Transaction {
|
|||
if (this._message) {
|
||||
if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
|
||||
throw new Error(
|
||||
'Transaction mutated after being populated from Message',
|
||||
'Transaction message mutated after being populated from Message',
|
||||
);
|
||||
}
|
||||
return this._message;
|
||||
|
|
|
@ -134,7 +134,7 @@ describe('Transaction', () => {
|
|||
|
||||
const fee = await transaction.getEstimatedFee(connection);
|
||||
expect(fee).to.eq(5000);
|
||||
});
|
||||
}).timeout(10 * 1000);
|
||||
|
||||
it('partialSign', () => {
|
||||
const account1 = Keypair.generate();
|
||||
|
@ -412,7 +412,7 @@ describe('Transaction', () => {
|
|||
|
||||
transaction.feePayer = new PublicKey(6);
|
||||
expect(() => transaction.compileMessage()).to.throw(
|
||||
'Transaction mutated after being populated from Message',
|
||||
'Transaction message mutated after being populated from Message',
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -612,8 +612,8 @@ describe('Transaction', () => {
|
|||
programId: Keypair.generate().publicKey,
|
||||
}),
|
||||
);
|
||||
t0.partialSign(signer);
|
||||
const t1 = Transaction.from(t0.serialize());
|
||||
const t1 = Transaction.from(t0.serialize({requireAllSignatures: false}));
|
||||
t1.partialSign(signer);
|
||||
t1.serialize();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue