Skip to content

Commit

Permalink
purchase soulname with identity: added some type improvements to masa…
Browse files Browse the repository at this point in the history
… shape
  • Loading branch information
hide-on-bush-x committed Aug 8, 2023
1 parent 46252ef commit cac7ee4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/provider/masa-shape.ts
Expand Up @@ -69,9 +69,13 @@ export interface MasaShape {
handlePurchaseIdentityWithSoulname?: (
paymentMethod: PaymentMethod,
soulname: string,
registrationPrice: number,
registrationPeriod: number,
style?: string
) => Promise<boolean | Error>;
) => Promise<
| ({ identityId?: string | BigNumber | undefined } & CreateSoulNameResult)
| Error
| undefined
>;
reloadIdentity?: () => void;

// session
Expand Down Expand Up @@ -148,7 +152,9 @@ export interface MasaShape {
registrationPeriod: number,
paymentMethod: PaymentMethod,
style?: string | undefined
) => Promise<CreateSoulNameResult | (Error & { code?: string | undefined; }) | undefined>;
) => Promise<
CreateSoulNameResult | (Error & { code?: string | undefined }) | undefined
>;
isConnected?: boolean;
isDisconnected?: boolean;
// new-modal
Expand Down
Expand Up @@ -35,6 +35,7 @@ const SoulnameModal = ({
const { isLoadingSigner, address } = useWalletClient();
const { sdk: masa } = useMasaClient();
const { extension, soulname } = useCreateSoulnameModal();
const {connector} = useWalletClient();

const { fireMintEvent } = useCookieMonster({
clientApp: 'Masa React', // TODO: Forward from MasaClient a client name
Expand All @@ -46,23 +47,20 @@ const SoulnameModal = ({
setShouldRestart(true);
onError?.();
}, [onError]);

// const [error, setError] = useState<null | {
// title: string;
// subtitle: string;
// }>(null);

// const handleErrorConfirmed = useCallback(() => setError(null), []);

const handleMintSuccess = async (
result: CreateSoulNameResult
) => {

const handleMintSuccess = async (result: CreateSoulNameResult) => {
// TODO: Remove lint disable
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const price = result?.metadata?.value;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
const priceValue = price?.toNumber() as number ?? '';
const priceValue = (price?.toNumber() as number) ?? '';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const paymentMethod = result?.metadata?.paymentMethod as string;

Expand All @@ -84,6 +82,7 @@ const SoulnameModal = ({
priceValue.toString(),
{
soulname,
wallet_type: connector?.name ?? "Unknown"
}
);
onMintSuccess?.();
Expand Down

0 comments on commit cac7ee4

Please sign in to comment.