Skip to content

Commit

Permalink
Some fixes for scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Feb 28, 2023
1 parent 0c852f6 commit 220ebb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/provider/masa-context-provider.tsx
Expand Up @@ -102,7 +102,10 @@ export const MasaContextProvider = ({
} = useGreen(masaInstance, walletAddress);

// scope
const { scope, setScope, areScopesFullfiled } = useScopes(soulnames ?? []);
const { scope, setScope, areScopesFullfiled } = useScopes(
soulnames ?? [],
isLoggedIn
);

// modal
const {
Expand Down
7 changes: 6 additions & 1 deletion src/provider/modules/scopes/scopes.ts
@@ -1,12 +1,17 @@
import { SoulNameDetails } from '@masa-finance/masa-sdk';
import { useMemo, useState } from 'react';

export const useScopes = (soulnames: SoulNameDetails[]) => {
export const useScopes = (
soulnames: SoulNameDetails[],
isLoggedIn?: boolean
) => {
const [scope, setScope] = useState<string[]>([]);
const areScopesFullfiled = useMemo(() => {
if (scope?.includes('soulname') && (soulnames?.length ?? 0) === 0)
return false;

if (scope?.includes('auth') && !isLoggedIn) return false;

return true;
}, [soulnames, scope]);

Expand Down

0 comments on commit 220ebb2

Please sign in to comment.