Skip to content

Commit

Permalink
refactor: rearrange functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tuliomir committed Jan 24, 2024
1 parent b28c6cd commit bc6232b
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions src/screens/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,27 @@ function Wallet() {
setTransactionsCount(totalTransactions);
}

/*
* We show the administrative tools tab only for the users that one day had an authority output, even if it was already spent
*
* This will set the shouldShowAdministrativeTab state param based on the response of getMintAuthority and getMeltAuthority
*/
const calculateShouldShowAdministrativeTab = async (tokenId) => {
const mintAuthorities = await wallet.getMintAuthority(tokenId, { skipSpent: false });

if (mintAuthorities.length > 0) {
return setShouldShowAdministrativeTab(true);
}

const meltAuthorities = await wallet.getMeltAuthority(tokenId, { skipSpent: false });

if (meltAuthorities.length > 0) {
return setShouldShowAdministrativeTab(true);
}

return setShouldShowAdministrativeTab(false);
}

/**
* Triggered when user clicks to do the backup of words, then opens backup modal
*
Expand Down Expand Up @@ -256,28 +277,6 @@ function Wallet() {
})
}

// TODO: Understand when this calculation should be done. Maybe when token data was updated?
/*
* We show the administrative tools tab only for the users that one day had an authority output, even if it was already spent
*
* This will set the shouldShowAdministrativeTab state param based on the response of getMintAuthority and getMeltAuthority
*/
const calculateShouldShowAdministrativeTab = async (tokenId) => {
const mintAuthorities = await wallet.getMintAuthority(tokenId, { skipSpent: false });

if (mintAuthorities.length > 0) {
return setShouldShowAdministrativeTab(true);
}

const meltAuthorities = await wallet.getMeltAuthority(tokenId, { skipSpent: false });

if (meltAuthorities.length > 0) {
return setShouldShowAdministrativeTab(true);
}

return setShouldShowAdministrativeTab(false);
}

/**
* @deprecated This should be replaced by usage of `useHistory` inside the child component
*/
Expand Down

0 comments on commit bc6232b

Please sign in to comment.