Skip to content

Commit

Permalink
feat: correct error handling and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
simodrws committed Aug 4, 2023
1 parent 10490e5 commit 1e77259
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/components/masa-interface/masa-interface.tsx
Expand Up @@ -60,7 +60,7 @@ export const MasaInterface = ({
}): JSX.Element => {
useMetamask({ disabled: disableMetamask });
const { isConnected } = useAccount();
console.log({ hideLegacyModal });

const {
isModalOpen,
setModalOpen,
Expand All @@ -87,6 +87,8 @@ export const MasaInterface = ({
} = useMasa();

const page = useMemo(() => {
if (hideLegacyModal) return '';

if (verbose) {
console.log('INTERFACE', {
hasWalletAddress,
Expand Down Expand Up @@ -275,6 +277,7 @@ export const MasaInterface = ({
);

if (hideLegacyModal) return <div />;

return (
<ModalComponent
open={isModalOpen as boolean}
Expand Down
7 changes: 6 additions & 1 deletion src/provider/masa-provider.tsx
Expand Up @@ -69,7 +69,12 @@ export const MasaProvider = ({
>
<MasaContextProvider {...args}>
<div id="modal-mount" />
<MasaInterface hideLegacyModal={args.hideLegacyModal} disableMetamask={args.useRainbowKitWalletConnect} />
{!args.hideLegacyModal && (
<MasaInterface
hideLegacyModal={args.hideLegacyModal}
disableMetamask={args.useRainbowKitWalletConnect}
/>
)}
{children}
</MasaContextProvider>
</MasaRefactorProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/refactor/masa-client/use-masa-client.ts
Expand Up @@ -13,7 +13,7 @@ export const useMasaClient = () => {
const { activeChainId, currentNetwork } = useNetwork();

const networkName = getMasaNetworkName(currentNetwork?.networkName);

// console.log({ contractAddressOverrides });
const masa = useMasaSDK(
{
address,
Expand Down
2 changes: 2 additions & 0 deletions src/refactor/masa-client/use-masa-sdk.ts
Expand Up @@ -76,6 +76,8 @@ export const useMasaSDK = (
signer
);
contractOverrides.SoulNameContract.hasAddress = true;

console.log('END OF OVERRIDES', { contractOverrides });
}
if (verbose) {
signer
Expand Down
2 changes: 2 additions & 0 deletions src/refactor/masanew.stories.tsx
Expand Up @@ -495,6 +495,7 @@ const ModalFlow = () => {
onRegisterFinish: () => console.log('FINISH FROM OUTSIDE ?????'),
onMintSuccess: () => console.log('MINT SUCCESS FROM OUTSIDE'),
onMintError: () => console.log('MINT ERROR FROM OUTSIDE'),
onError: () => console.log('CREATE SOULNAME ERROR'),
});

const onClickSoulname = useCallback(() => {
Expand All @@ -503,6 +504,7 @@ const ModalFlow = () => {
onMintError: () => console.log('MINT ERROR FROM OUTSIDE'),
onRegisterFinish: () => console.log('REGISTER SOULNAME FINISHED OUTSIDE'),
onSuccess: () => console.log('EVERYTHING WAS SUCCESSFUL'),
onError: () => console.log('CREATE SOULNAME ERROR'),
closeOnSuccess: true,
});
}, []);
Expand Down
Expand Up @@ -58,12 +58,10 @@ export const useRegisterSoulname = ({
soulNameStyle
);

console.log({ type: typeof result, isError: result instanceof Error });

if (result instanceof Error) {
// onMintError?.();
throw result;
}

if (result) {
onMintSuccess?.();
}
Expand All @@ -87,12 +85,14 @@ export const useRegisterSoulname = ({
soulNameStyle
);

if (result instanceof Error) {
throw result;
}

if (result) {
onMintSuccess?.();
}

if (!result) onMintError?.();

onRegisterFinish?.();

return result;
Expand All @@ -111,7 +111,7 @@ export const useRegisterSoulname = ({
console.log('ERROR registerSoulname catch2', error);
onMintError?.();

return error as Error;
throw error as Error;
// return {
// title: '',
// subtitle,
Expand Down
1 change: 0 additions & 1 deletion stories/masa.stories.tsx
Expand Up @@ -245,7 +245,6 @@ const TemplateWithRainbowKit: Story = (props: Args) => {
company="Masa"
walletsToUse={['metamask', 'walletconnect', 'valora']}
useRainbowKitWalletConnect
hideLegacyModal
rainbowKitModalSize={'wide'}
contractAddressOverrides={{
SoulNameAddress: '0x9C78Bf97A6abf185C8878C13F1Fd5976C41dDCfa',
Expand Down

0 comments on commit 1e77259

Please sign in to comment.