ts: Remove deprecated Transaction.setSigners api (#332)

This commit is contained in:
Armani Ferrante 2021-05-27 13:03:08 -07:00 committed by GitHub
parent 631cb97b83
commit 062b9257c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 27 deletions

View File

@ -92,18 +92,15 @@ export default class Provider {
opts = this.opts;
}
const signerKps = signers.filter((s) => s !== undefined) as Array<Signer>;
const signerPubkeys = [this.wallet.publicKey].concat(
signerKps.map((s) => s.publicKey)
);
tx.setSigners(...signerPubkeys);
tx.feePayer = this.wallet.publicKey;
tx.recentBlockhash = (
await this.connection.getRecentBlockhash(opts.preflightCommitment)
).blockhash;
await this.wallet.signTransaction(tx);
signerKps.forEach((kp) => {
signers
.filter((s) => s !== undefined)
.forEach((kp) => {
tx.partialSign(kp);
});
@ -140,14 +137,12 @@ export default class Provider {
signers = [];
}
const signerKps = signers.filter((s) => s !== undefined) as Array<Signer>;
const signerPubkeys = [this.wallet.publicKey].concat(
signerKps.map((s) => s.publicKey)
);
tx.setSigners(...signerPubkeys);
tx.feePayer = this.wallet.publicKey;
tx.recentBlockhash = blockhash.blockhash;
signerKps.forEach((kp) => {
signers
.filter((s) => s !== undefined)
.forEach((kp) => {
tx.partialSign(kp);
});
@ -189,12 +184,7 @@ export default class Provider {
opts = this.opts;
}
const signerKps = signers.filter((s) => s !== undefined) as Array<Signer>;
const signerPubkeys = [this.wallet.publicKey].concat(
signerKps.map((s) => s.publicKey)
);
tx.setSigners(...signerPubkeys);
tx.feePayer = this.wallet.publicKey;
tx.recentBlockhash = (
await this.connection.getRecentBlockhash(
opts.preflightCommitment ?? this.opts.preflightCommitment
@ -202,9 +192,12 @@ export default class Provider {
).blockhash;
await this.wallet.signTransaction(tx);
signerKps.forEach((kp) => {
signers
.filter((s) => s !== undefined)
.forEach((kp) => {
tx.partialSign(kp);
});
return await simulateTransaction(
this.connection,
tx,