From e3fe24f925a3ea34d661face110eca2bb2a8184b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Tue, 17 Jan 2023 10:57:47 +0100 Subject: [PATCH] Simulate: Don't attempt to sign transaction (#2331) --- CHANGELOG.md | 3 ++- ts/packages/anchor/src/provider.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a41229552d..80460fff17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,8 @@ The minor version will be incremented upon a breaking change and the patch versi ### Fixes -- cli: Don't regenerate idl in read_all_programs(). ([#2332](https://github.com/coral-xyz/anchor/pull/2332)) +- cli: Don't regenerate idl in read_all_programs(). ([#2332](https://github.com/coral-xyz/anchor/pull/2332)). +- ts: `provider.simulate` will send the transaction with `sigVerify: false` if no `signers` are present ([#2331](https://github.com/coral-xyz/anchor/pull/2331)). ### Breaking diff --git a/ts/packages/anchor/src/provider.ts b/ts/packages/anchor/src/provider.ts index 26b7218571..e0fd503d7b 100644 --- a/ts/packages/anchor/src/provider.ts +++ b/ts/packages/anchor/src/provider.ts @@ -246,7 +246,10 @@ export class AnchorProvider implements Provider { * Simulates the given transaction, returning emitted logs from execution. * * @param tx The transaction to send. - * @param signers The signers of the transaction. + * @param signers The signers of the transaction. If unset, the transaction + * will be simulated with the "sigVerify: false" option. This + * allows for simulation of transactions without asking the + * wallet for a signature. * @param opts Transaction confirmation options. */ async simulate( @@ -263,7 +266,9 @@ export class AnchorProvider implements Provider { ) ).blockhash; - tx = await this.wallet.signTransaction(tx); + if (signers) { + tx = await this.wallet.signTransaction(tx); + } const result = await simulateTransaction( this.connection, tx,