Skip to content

Commit 10b7a3a

Browse files
authored
Signers: put console.log behind debug flag (#533)
* put console.log behind debug flag * more chains
1 parent 0a3c9e7 commit 10b7a3a

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

platforms/algorand/src/signer.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ export class AlgorandSigner<N extends Network, C extends AlgorandChains>
6363
}
6464

6565
if (signer) {
66-
console.log(
67-
`Signing: ${description} with signer ${signer.address} for address ${this.address()}`,
68-
);
66+
if (this._debug)
67+
console.log(
68+
`Signing: ${description} with signer ${signer.address} for address ${this.address()}`,
69+
);
6970
signed.push(await signer.signTxn(tx));
7071
} else {
71-
console.log(`Signing: ${description} without signer for address ${this.address()}`);
72+
if (this._debug)
73+
console.log(`Signing: ${description} without signer for address ${this.address()}`);
7274
signed.push(tx.signTxn(this._account.sk));
7375
}
7476
}

platforms/aptos/src/signer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class AptosSigner<N extends Network, C extends AptosChains>
2828
private _chain: C,
2929
private _account: AptosAccount,
3030
private _rpc: AptosClient,
31+
private _debug?: boolean,
3132
) {}
3233

3334
chain() {
@@ -45,7 +46,7 @@ export class AptosSigner<N extends Network, C extends AptosChains>
4546
description: string;
4647
transaction: Types.EntryFunctionPayload;
4748
};
48-
console.log(`Signing: ${description} for ${this.address()}`);
49+
if (this._debug) console.log(`Signing: ${description} for ${this.address()}`);
4950

5051
// overwriting `max_gas_amount` and `gas_unit_price` defaults
5152
// rest of defaults are defined here: https://aptos-labs.github.io/ts-sdk-doc/classes/AptosClient.html#generateTransaction

platforms/cosmwasm/src/signer.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class CosmwasmSigner<N extends Network, C extends CosmwasmChains>
6161
private _chain: C,
6262
private _signer: SigningCosmWasmClient,
6363
private _account: string,
64+
private _debug?: string,
6465
) {}
6566

6667
chain(): C {
@@ -75,9 +76,10 @@ export class CosmwasmSigner<N extends Network, C extends CosmwasmChains>
7576
const signed = [];
7677
for (const txn of tx) {
7778
const { description, transaction } = txn as CosmwasmUnsignedTransaction<N, C>;
78-
console.log(`Signing: ${description} for ${this.address()}`);
79-
80-
console.log(transaction.msgs, transaction.fee, transaction.memo);
79+
if (this._debug) {
80+
console.log(`Signing: ${description} for ${this.address()}`);
81+
console.log(transaction.msgs, transaction.fee, transaction.memo);
82+
}
8183

8284
const txRaw = await this._signer.sign(
8385
this.address(),

platforms/evm/src/signer.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export async function getEvmSigner(
2626
opts?: {
2727
maxGasLimit?: bigint;
2828
chain?: EvmChains;
29+
debug?: boolean;
2930
},
3031
): Promise<Signer> {
3132
const signer: EthersSigner =
@@ -74,7 +75,7 @@ export class EvmNativeSigner<N extends Network, C extends EvmChains = EvmChains>
7475
_chain: C,
7576
_address: string,
7677
_signer: EthersSigner,
77-
readonly opts?: { maxGasLimit?: bigint },
78+
readonly opts?: { maxGasLimit?: bigint; debug?: boolean },
7879
) {
7980
super(_chain, _address, _signer);
8081
}
@@ -105,7 +106,8 @@ export class EvmNativeSigner<N extends Network, C extends EvmChains = EvmChains>
105106

106107
for (const txn of tx) {
107108
const { transaction, description } = txn;
108-
console.log(`Signing: ${description} for ${this.address()}`);
109+
if (this.opts?.debug)
110+
console.log(`Signing: ${description} for ${this.address()}`);
109111

110112
const t: TransactionRequest = {
111113
...transaction,

platforms/solana/src/signer.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ export class SolanaSigner<N extends Network, C extends SolanaChains = 'Solana'>
102102
transaction: { transaction, signers: extraSigners },
103103
} = txn;
104104

105-
console.log(`Signing: ${description} for ${this.address()}`);
105+
if (this._debug)
106+
console.log(`Signing: ${description} for ${this.address()}`);
106107

107108
if (this._debug) logTxDetails(transaction);
108109

@@ -190,7 +191,9 @@ export class SolanaSendSigner<
190191
description,
191192
transaction: { transaction, signers: extraSigners },
192193
} = txn as SolanaUnsignedTransaction<N, C>;
193-
console.log(`Signing: ${description} for ${this.address()}`);
194+
195+
if (this._debug)
196+
console.log(`Signing: ${description} for ${this.address()}`);
194197

195198
let priorityFeeIx: TransactionInstruction[] | undefined;
196199
if (this._priorityFeePercentile && this._priorityFeePercentile > 0)

platforms/sui/src/signer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class SuiSigner<N extends Network, C extends SuiChains> implements SignAn
2222
private _chain: C,
2323
private _client: SuiClient,
2424
private _signer: Ed25519Keypair,
25+
private _debug?: boolean,
2526
) {}
2627

2728
chain(): C {
@@ -36,7 +37,7 @@ export class SuiSigner<N extends Network, C extends SuiChains> implements SignAn
3637
const txids: TxHash[] = [];
3738
for (const tx of txns) {
3839
const { description, transaction } = tx as SuiUnsignedTransaction<N, C>;
39-
console.log(`Signing ${description} for ${this.address()}`);
40+
if (this._debug) console.log(`Signing ${description} for ${this.address()}`);
4041

4142
const result = await this._client.signAndExecuteTransactionBlock({
4243
transactionBlock: transaction,

0 commit comments

Comments
 (0)