Skip to content

Commit e6054db

Browse files
authored
feat: add debug option to SimulatorProfile and conditionally log messages (#496)
1 parent 2b2e8b4 commit e6054db

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

.changeset/brave-dodos-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ledgerhq/wallet-api-simulator": minor
3+
---
4+
5+
feat: add debug option to SimulatorProfile and conditionally log messages

packages/simulator/src/transport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function getSimulatorTransport(
1616
const serverTransport: Transport = {
1717
onMessage: undefined,
1818
send: (payload) => {
19-
console.info("wallet -> app", payload);
19+
if (profile.debug) console.info("wallet -> app", payload);
2020
// Using setTimeout to simulate async call (Do we want to keep this sync ?)
2121
// It also avoids an act warning when using RTL to test components
2222
setTimeout(() => {
@@ -30,7 +30,7 @@ export function getSimulatorTransport(
3030
const clientTransport: Transport = {
3131
onMessage: undefined,
3232
send: (payload) => {
33-
console.info("app -> wallet", payload);
33+
if (profile.debug) console.info("app -> wallet", payload);
3434
// Using setTimeout to simulate async call (Do we want to keep this sync ?)
3535
// It also avoids an act warning when using RTL to test components
3636
setTimeout(() => {

packages/simulator/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Account, Currency, Permission } from "@ledgerhq/wallet-api-core";
22
import type { ServerConfig, WalletHandlers } from "@ledgerhq/wallet-api-server";
33

44
export type SimulatorProfile = {
5+
debug?: boolean;
56
config: ServerConfig;
67
// TODO: remove omit<Permission, "currencyIds"> in next major release of core
78
permissions: Omit<Permission, "currencyIds">;

0 commit comments

Comments
 (0)