From 5bcbf1c52570635656bf712a09a7767652dcebe9 Mon Sep 17 00:00:00 2001 From: Alex Stelea Date: Fri, 7 Jun 2024 16:56:09 +0100 Subject: [PATCH] code: include logger --- .../radix-connect-relay.module.ts | 2 +- .../radix-connect-relay/rcfm-page.module.ts | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/radix-connect-relay.module.ts b/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/radix-connect-relay.module.ts index d942e7f1..e2c7c722 100644 --- a/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/radix-connect-relay.module.ts +++ b/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/radix-connect-relay.module.ts @@ -55,7 +55,7 @@ export const RadixConnectRelayModule = (input: { callBackPath: '/connect', }) - const rcfmPageModule = providers?.rcfmPageModule ?? RcfmPageModule() + const rcfmPageModule = providers?.rcfmPageModule ?? RcfmPageModule({ logger }) const identityModule = providers?.identityModule ?? diff --git a/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/rcfm-page.module.ts b/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/rcfm-page.module.ts index 7fd17267..dc410f7f 100644 --- a/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/rcfm-page.module.ts +++ b/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/rcfm-page.module.ts @@ -1,4 +1,5 @@ import { isBrowser } from '../../../../helpers/is-browser' +import { Logger } from '../../../../helpers' export const RcfmPageState = { loading: 'loading', @@ -9,8 +10,10 @@ export const RcfmPageState = { export type RcfmPageState = (typeof RcfmPageState)[keyof typeof RcfmPageState] export type RcfmPageModule = ReturnType -export const RcfmPageModule = () => { +export const RcfmPageModule = (input: { logger?: Logger }) => { + const logger = input.logger?.getSubLogger({ name: 'RcfmPageModule' }) if (!isBrowser()) { + logger?.debug({ method: 'isBrowser', isBrowser: false }) return { show: () => {}, hide: () => {}, @@ -21,28 +24,30 @@ export const RcfmPageModule = () => { const rcfmPageHtmlElement = document.createElement('radix-rcfm-page') document.body.appendChild(rcfmPageHtmlElement) - const showWithData = ({ - header, - subheader, - isError, - isLoading, - }: { + const showWithData = (values: { header?: string subheader?: string isError?: boolean isLoading?: boolean }) => { + const { header, subheader, isError, isLoading } = values rcfmPageHtmlElement.header = header || '' rcfmPageHtmlElement.subheader = subheader || '' rcfmPageHtmlElement.isError = isError || false rcfmPageHtmlElement.isLoading = isLoading || false rcfmPageHtmlElement.isHidden = false + logger?.debug({ + method: 'showWithData', + values, + }) } const hide = () => { + logger?.debug({ method: 'hide', isHidden: true }) rcfmPageHtmlElement.isHidden = true } const show = (state: RcfmPageState) => { + logger?.debug({ method: 'show', state }) switch (state) { case RcfmPageState.dAppVerified: showWithData({