Skip to content

Commit

Permalink
feat: create soulname modal, lint fixes, walletconnect fix
Browse files Browse the repository at this point in the history
  • Loading branch information
simodrws committed Jul 28, 2023
1 parent 78de8c2 commit fc7cd80
Show file tree
Hide file tree
Showing 15 changed files with 465 additions and 222 deletions.
1 change: 0 additions & 1 deletion src/provider/masa-provider.tsx
Expand Up @@ -61,7 +61,6 @@ export const MasaProvider = ({
// networkName: 'ethereum',
environment: environmentName ?? 'dev',
// arweave: arweaveConfig,
// environment: environmentName,
},
rainbowkitConfig: {
modalSize: rainbowKitModalSize ?? 'wide',
Expand Down
14 changes: 8 additions & 6 deletions src/refactor/masa-client/use-masa-sdk.ts
Expand Up @@ -93,17 +93,19 @@ export const useMasaSDK = (
.catch((error: unknown) => console.error({ error }));
}

const arweaveConfigToPass = {
host: arweaveConfig?.host || 'arweave.net',
port: Number.parseInt(arweaveConfig?.port || '443', 10),
protocol: arweaveConfig?.protocol || 'https',
logging: !!arweaveConfig?.logging || true,
};
// console.log({ arweaveConfigToPass });
return new Masa({
signer,
apiUrl: apiUrl ?? environment.apiUrl,
networkName,
environment: environment.environment,
arweave: {
host: arweaveConfig?.host || 'arweave.net',
port: Number.parseInt(arweaveConfig?.port || '443', 10),
protocol: arweaveConfig?.protocol || 'https',
logging: !!arweaveConfig?.logging || false,
},
arweave: arweaveConfigToPass,
contractOverrides,
verbose,
});
Expand Down
3 changes: 2 additions & 1 deletion src/refactor/masanew.stories.tsx
Expand Up @@ -486,6 +486,7 @@ const ModalFlow = () => {
openCreateSoulnameModal({
onMintSuccess: () => console.log('MINT SUCCESS FROM OUTSIDE'),
onMintError: () => console.log('MINT ERROR FROM OUTSIDE'),
onRegisterFinish: () => console.log('REGISTER SOULNAME FINISHED OUTSIDE'),
});
}, []);
return (
Expand Down Expand Up @@ -577,7 +578,7 @@ const TemplateNewMasaState = (props: Args) => (
'unknown',
],
masaConfig: {
networkName: 'celo',
networkName: 'goerli',
},
}}
>
Expand Down
26 changes: 26 additions & 0 deletions src/refactor/ui/components/modals/ModalError.tsx
@@ -0,0 +1,26 @@
import React from 'react';
import { MasaLoading } from '../masa-loading';

export const ModalError = ({
subtitle,
handleComplete,
buttonText,
isLoading,
}: {
subtitle: string;
handleComplete: () => void;
buttonText: string;
isLoading?: boolean;
}): JSX.Element => {
if (isLoading) return <MasaLoading />;

return (
<div className="interface-error-modal">
<h3 className="title">Whoops! 💸</h3>
<p className="subtitle">{subtitle}</p>
<button type="button" className="masa-button" onClick={handleComplete}>
{buttonText}
</button>
</div>
);
};
152 changes: 152 additions & 0 deletions src/refactor/ui/components/modals/ModalSuccess.tsx
@@ -0,0 +1,152 @@
import { useAsync } from 'react-use';
import React, { useCallback, useMemo, useState } from 'react';

import { twitterLogo } from '../../../../assets/twitterLogo';
import { MasaLoading } from '../masa-loading';
import { useMasaClient } from '../../../masa-client/use-masa-client';
import { useSoulNames } from '../../../masa/use-soulnames';
import { useConfig } from '../../../base-provider';
import { Modal } from './modal';

export const ModalSuccess = ({
onFinish,
}: {
onFinish?: () => void;
}): JSX.Element => {
const [extension, setExtension] = useState<string>();
const { sdk: masa } = useMasaClient();
const { company } = useConfig();
const { soulnames, isLoadingSoulnames } = useSoulNames();
// const { masa, isLoading, setForcedPage, soulnames, company } = useMasa();

useAsync(async () => {
setExtension(await masa?.contracts.instances.SoulNameContract.extension());
}, [masa]);

const handleComplete = useCallback(() => {
onFinish?.();
}, [onFinish]);

const title = useMemo(() => {
switch (company) {
case 'Masa': {
return 'You have claimed your .soul domain and your Soulbound Identity has been minted.';
}
case 'Celo': {
return 'You have claimed your .celo domain and your Prosperity Passport has been minted.';
}
case 'Base': {
return 'You have claimed your .base domain name. Welcome to Base Camp ⛺️';
}
case 'Base Universe': {
return 'You have claimed your Base Universe .bu domain name. Welcome to Base Universe.';
}
case 'Brozo': {
return 'You have claimed your Brozo .bro domain name. Welcome to the Brozo community!';
}
default: {
return 'You have claimed your .soul domain and your Soulbound Identity has been minted.';
}
}
}, [company]);

const tweetContentLink = useMemo(() => {
const companyUrlFormatted = company?.toLowerCase().replaceAll(' ', '-');

switch (company) {
case 'Masa': {
return 'https://app.masa.finance';
}
case 'Celo': {
if (soulnames && soulnames.length > 0) {
return `https://raregems.io/celo/celo-domain-names/${
soulnames?.at(-1)?.tokenDetails.tokenId.toString() ?? ''
}`;
}

return 'https://app.masa.finance';
}
case 'Base': {
return 'https://app.basecamp.global';
}
case 'Base Universe':
case 'Brozo': {
return `https://masa.finance/sbts/${
companyUrlFormatted ?? ''
}-soulname-token`;
}
default: {
return 'https://app.masa.finance';
}
}
}, [soulnames, company]);

const baseTwitterUrl = 'https://twitter.com/intent/tweet?text=';

const twitterLink = useMemo(() => {
switch (company) {
case 'Masa': {
return `https://twitter.com/intent/tweet?text=Just%20claimed%20my%20.soul%20domain!%20The%20process%20is%20super%20simple%2C%20and%205%2B%20character%20domains%20are%20free%20%F0%9F%A4%A9.%20Grab%20yours%20here%3A%20&url=${tweetContentLink}&hashtags=SoulboundIdentity,Masa`;
}
case 'Celo': {
return `https://twitter.com/intent/tweet?text=Just%20claimed%20my%20.celo%20domain!%20The%20process%20is%20super%20simple%2C%20and%205%2B%20character%20domains%20are%20free%20%F0%9F%A4%A9.%20Grab%20yours%20here%3A%20&url=${tweetContentLink}&hashtags=ProsperityPassport,Celo,Masa`;
}
case 'Base': {
return `https://twitter.com/intent/tweet?text=Just%20claimed%20my%20.base%20domain!%20The%20process%20is%20super%20simple%2C%20and%205%2B%20character%20domains%20are%20free%20%F0%9F%A4%A9.%20Grab%20yours%20here%3A%20&url=${tweetContentLink}&hashtags=Basecamp,Base,Masa`;
}
case 'Base Universe': {
return `https://twitter.com/intent/tweet?text=Just%20claimed%20my%20Base%20Universe%20.bu%20domain%2C%20powered%20by%20%40getmasafi!%20The%20process%20is%20super%20simple%2C%20and%20domains%20are%20free%20on%20testnet%20%F0%9F%A4%A9%C2%A0Grab%20yours%20here%3A%20${tweetContentLink}%20%40UniverseOnBase%20%40BuildOnBase`;
}
case 'Brozo': {
return (
baseTwitterUrl +
encodeURIComponent(
`Just claimed my @BrozoNFT .bro domain, powered by @getmasafi! The process is super simple. Mint your rare .bro domain before it’s taken: ${tweetContentLink} #Brozo #NFT`
)
);
}
default: {
return `https://twitter.com/intent/tweet?text=Just%20claimed%20my%20.soul%20domain!%20The%20process%20is%20super%20simple%2C%20and%205%2B%20character%20domains%20are%20free%20%F0%9F%A4%A9.%20Grab%20yours%20here%3A%20&url=${tweetContentLink}&hashtags=SoulboundIdentity,Masa`;
}
}
}, [company, tweetContentLink]);

const buttonText = useMemo(() => {
switch (company) {
default: {
return 'Go to dashboard';
}
}
}, [company]);

if (isLoadingSoulnames)
return (
<Modal>
<MasaLoading />;
</Modal>
);

return (
<Modal onClose={onFinish}>
<div
id="gtm_hurray_identity_minted"
className="interface-create-identity"
>
<h3 className="title">Hurray! 🎉</h3>
<p className="subtitle">{title}</p>
<a
className="tweet-domain"
href={twitterLink}
target="_blank"
rel="noreferrer"
>
<img src={twitterLogo} style={{ width: 40 }} alt="twitter" />{' '}
{`Tweet your ${extension ?? ''} domain`}
</a>
<button className="masa-button" onClick={handleComplete} type="button">
{buttonText}
</button>
</div>
</Modal>
);
};
@@ -1,10 +1,10 @@
import React, { useCallback, useState } from 'react';
/* import { MasaLoading } from '../../masa-loading'; */
/* import { useCreditScores } from '../../../../masa/use-credit-scores'; */
import NiceModal from '@ebay/nice-modal-react';
import { useCreditScoreCreate } from '../../../../masa/use-credit-scores-create';
/* import { useIdentity } from '../../../../masa/use-identity'; */

import NiceModal from '@ebay/nice-modal-react';
import { Modal } from '../modal';

export const CreateCreditScoreModal = NiceModal.create((): JSX.Element => {
Expand Down Expand Up @@ -38,11 +38,15 @@ export const CreateCreditScoreModal = NiceModal.create((): JSX.Element => {
)}
</div>
<div>
<button className="masa-button" onClick={createCreditScore}>
<button
type="button"
className="masa-button"
onClick={createCreditScore}
>
Create now!
</button>
<div className="dont-have-a-wallet">
<p>I don't want to use this wallet</p>
<p>I don&apos;t want to use this wallet</p>
</div>
</div>
</section>
Expand Down
26 changes: 12 additions & 14 deletions src/refactor/ui/components/modals/create-identity/hurray-view.tsx
Expand Up @@ -4,19 +4,17 @@ interface HurrayViewProps {
createIdentity: () => void;
}

const HurrayView = ({ createIdentity }: HurrayViewProps): JSX.Element => {
return (
<section className="interface-create-identity">
<h3 className="title">Hurray! 🎉</h3>
<p className="subtitle">
Congratulations you already have a Celo Domain Name in your wallet. You
must now mint a Celo Prosperity Passport.
</p>
<button className="masa-button" onClick={createIdentity}>
Get Prosperity Passport
</button>
</section>
);
};
const HurrayView = ({ createIdentity }: HurrayViewProps): JSX.Element => (
<section className="interface-create-identity">
<h3 className="title">Hurray! 🎉</h3>
<p className="subtitle">
Congratulations you already have a Celo Domain Name in your wallet. You
must now mint a Celo Prosperity Passport.
</p>
<button type="button" className="masa-button" onClick={createIdentity}>
Get Prosperity Passport
</button>
</section>
);

export default HurrayView;
38 changes: 19 additions & 19 deletions src/refactor/ui/components/modals/create-identity/success-view.tsx
@@ -1,33 +1,33 @@
import React from 'react';
import { NiceModalHandler } from '@ebay/nice-modal-react';
import { twitterLogo } from '../../../../../assets/twitterLogo';

interface SuccessViewProps {
titleText: string;
twitterText: string | undefined;
modal: any;
modal: NiceModalHandler<Record<string, unknown>>;
}

const SuccessView = ({
titleText,
twitterText,
modal,
}: SuccessViewProps): JSX.Element => {
return (
<section
id="gtm_hurray_identity_minted"
className="interface-create-identity"
>
<h3 className="title">Hurray! 🎉</h3>
<p className="subtitle">{titleText}</p>
<a className="tweet-domain" target="_blank" rel="noreferrer">
<img src={twitterLogo} style={{ width: 40 }} alt="twitter" />{' '}
{twitterText}
</a>
<button className="masa-button" onClick={() => modal.hide()}>
Go to dashboard
</button>
</section>
);
};
}: SuccessViewProps): JSX.Element => (
<section
id="gtm_hurray_identity_minted"
className="interface-create-identity"
>
<h3 className="title">Hurray! 🎉</h3>
<p className="subtitle">{titleText}</p>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a className="tweet-domain" target="_blank" rel="noreferrer">
<img src={twitterLogo} style={{ width: 40 }} alt="twitter" />{' '}
{twitterText}
</a>
<button type="button" className="masa-button" onClick={() => modal.hide()}>
Go to dashboard
</button>
</section>
);

export default SuccessView;
@@ -1,12 +1,13 @@
import React, { useMemo } from 'react';
import { useSoulnameInterface, useSoulnameModal } from './use-soulname-modal';
import { Input } from '../../Input';
import { Spinner } from '../../spinner';
import { Select } from '../../Select';
import { useCreateSoulnameModal } from './CreateSoulnameProvider';

const CreateSoulnameForm = () => {
const { extension, paymentMethods } = useSoulnameModal();
const {
extension,
paymentMethods,
soulname,
paymentMethod,
handleChangeSoulname,
Expand All @@ -16,7 +17,7 @@ const CreateSoulnameForm = () => {
updatePaymentMethod,
registrationPrice,
updatePeriod,
} = useSoulnameInterface();
} = useCreateSoulnameModal();

const LoadingSoulnameAvailible = useMemo(() => {
if (soulname !== '' && soulname.length > 0) {
Expand Down

0 comments on commit fc7cd80

Please sign in to comment.