-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from multiversx/development
Development
- Loading branch information
Showing
45 changed files
with
787 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,30 @@ | ||
import { NftTypeEnum, TokenTypeEnum } from 'types'; | ||
import { Overlay, NftTypeBadge, NftSubTypeBadge } from 'components'; | ||
import { | ||
NftSubtypeEnum, | ||
NftTypeEnum, | ||
TokenTypeEnum, | ||
WithClassnameType | ||
} from 'types'; | ||
|
||
export interface NftBadgeUIType extends WithClassnameType { | ||
type: NftTypeEnum | TokenTypeEnum; | ||
subType?: NftSubtypeEnum; | ||
showTooltip?: boolean; | ||
} | ||
|
||
export const NftBadge = ({ | ||
type, | ||
subType, | ||
showTooltip = true, | ||
className | ||
}: { | ||
type: NftTypeEnum | TokenTypeEnum; | ||
className?: string; | ||
}) => { | ||
switch (type) { | ||
case NftTypeEnum.SemiFungibleESDT: | ||
return ( | ||
<div | ||
className={`badge badge-outline badge-outline-orange ${ | ||
className ? className : '' | ||
}`} | ||
> | ||
SFT | ||
</div> | ||
); | ||
case NftTypeEnum.NonFungibleESDT: | ||
return ( | ||
<div | ||
className={`badge badge-outline badge-outline-yellow ${ | ||
className ? className : '' | ||
}`} | ||
> | ||
NFT | ||
</div> | ||
); | ||
case NftTypeEnum.MetaESDT: | ||
return ( | ||
<div | ||
className={`badge badge-outline badge-outline-green ${ | ||
className ? className : '' | ||
}`} | ||
> | ||
Meta-ESDT | ||
</div> | ||
); | ||
default: | ||
return null; | ||
}: NftBadgeUIType) => { | ||
if (showTooltip && subType) { | ||
return ( | ||
<Overlay title={<NftSubTypeBadge subType={subType} />}> | ||
<NftTypeBadge type={type} className={className}></NftTypeBadge> | ||
</Overlay> | ||
); | ||
} | ||
|
||
return <NftTypeBadge type={type} className={className}></NftTypeBadge>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import classNames from 'classnames'; | ||
|
||
import { NftSubtypeEnum } from 'types'; | ||
|
||
export const NftSubTypeBadge = ({ | ||
subType, | ||
className | ||
}: { | ||
subType: NftSubtypeEnum; | ||
className?: string; | ||
}) => { | ||
switch (subType) { | ||
// NFT Subtypes | ||
case NftSubtypeEnum.DynamicSemiFungibleESDT: | ||
case NftSubtypeEnum.DynamicNonFungibleESDT: | ||
case NftSubtypeEnum.NonFungibleESDTv2: | ||
case NftSubtypeEnum.DynamicMetaESDT: | ||
return ( | ||
<div | ||
className={classNames( | ||
'badge', | ||
{ | ||
'badge-orange text-orange-100': | ||
subType === NftSubtypeEnum.DynamicSemiFungibleESDT, | ||
'badge-yellow text-orange-100': | ||
subType === NftSubtypeEnum.DynamicNonFungibleESDT || | ||
subType === NftSubtypeEnum.NonFungibleESDTv2, | ||
'badge-green text-green-100': | ||
subType === NftSubtypeEnum.DynamicMetaESDT | ||
}, | ||
className | ||
)} | ||
> | ||
{subType} | ||
</div> | ||
); | ||
|
||
default: | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import classNames from 'classnames'; | ||
|
||
import { getNftText } from 'helpers'; | ||
import { NftTypeEnum, TokenTypeEnum } from 'types'; | ||
|
||
export const NftTypeBadge = ({ | ||
type, | ||
className | ||
}: { | ||
type: NftTypeEnum | TokenTypeEnum; | ||
className?: string; | ||
}) => { | ||
switch (type) { | ||
// default NFT types | ||
case NftTypeEnum.SemiFungibleESDT: | ||
case NftTypeEnum.NonFungibleESDT: | ||
case NftTypeEnum.MetaESDT: | ||
return ( | ||
<div | ||
className={classNames( | ||
'badge badge-outline', | ||
{ 'badge-outline-orange': type === NftTypeEnum.SemiFungibleESDT }, | ||
{ 'badge-outline-yellow': type === NftTypeEnum.NonFungibleESDT }, | ||
{ 'badge-outline-green': type === NftTypeEnum.MetaESDT }, | ||
className | ||
)} | ||
> | ||
{getNftText(type)} | ||
</div> | ||
); | ||
|
||
default: | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './NftBadge'; | ||
export * from './NftTypeBadge'; | ||
export * from './NftSubTypeBadge'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import BigNumber from 'bignumber.js'; | ||
|
||
import { ZERO } from 'appConstants'; | ||
import { AccountDelegationType } from 'types'; | ||
|
||
export const getAccountDelegationDetails = ( | ||
delegation: AccountDelegationType[] | ||
) => { | ||
if (delegation && delegation.length > 0) { | ||
const bNactive = delegation | ||
.map(({ userActiveStake }) => userActiveStake) | ||
.reduce((a, b) => new BigNumber(a).plus(b), new BigNumber(ZERO)); | ||
const bNclaimableRewards = delegation | ||
.map(({ claimableRewards }) => claimableRewards ?? ZERO) | ||
.reduce((a, b) => new BigNumber(a).plus(b), new BigNumber(ZERO)); | ||
const undelegatedAmounts = delegation | ||
.map( | ||
({ userUndelegatedList }) => | ||
userUndelegatedList?.map(({ amount }) => amount) ?? [] | ||
) | ||
.reduce((a, b) => a.concat(b), []); | ||
const bNunstaked = undelegatedAmounts.reduce( | ||
(a, b) => new BigNumber(a).plus(b), | ||
new BigNumber(ZERO) | ||
); | ||
const bNunbondable = delegation | ||
.map(({ userUnBondable }) => userUnBondable) | ||
.reduce((a, b) => new BigNumber(a).plus(b), new BigNumber(ZERO)); | ||
|
||
const activePlusUnStaked = bNactive.plus(bNunstaked); | ||
const bNlocked = activePlusUnStaked | ||
.plus(bNclaimableRewards) | ||
.plus(bNunbondable); | ||
|
||
const show = bNlocked.isGreaterThan(0); | ||
|
||
return { | ||
active: bNactive, | ||
unstaked: bNunstaked.plus(bNunbondable), | ||
claimable: bNclaimableRewards, | ||
locked: bNlocked, | ||
show | ||
}; | ||
} | ||
|
||
return { | ||
active: new BigNumber(ZERO), | ||
unstaked: new BigNumber(ZERO), | ||
claimable: new BigNumber(ZERO), | ||
locked: new BigNumber(ZERO), | ||
show: false | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import BigNumber from 'bignumber.js'; | ||
|
||
import { ZERO } from 'appConstants'; | ||
import { AccountDelegationLegacyType } from 'types'; | ||
|
||
export const getAccountLegacyDelegationDetails = ( | ||
delegationLegacy: AccountDelegationLegacyType | ||
) => { | ||
if (delegationLegacy) { | ||
const bNactive = new BigNumber(delegationLegacy.userActiveStake ?? ZERO); | ||
const bNuserWaitingStake = new BigNumber( | ||
delegationLegacy.userWaitingStake ?? ZERO | ||
); | ||
const bNclaimableRewards = new BigNumber( | ||
delegationLegacy.claimableRewards ?? ZERO | ||
); | ||
const bNunstakedStakeLegacy = new BigNumber( | ||
delegationLegacy.userUnstakedStake ?? ZERO | ||
); | ||
const bNdeferredPaymentLegacy = new BigNumber( | ||
delegationLegacy.userDeferredPaymentStake ?? ZERO | ||
); | ||
const bNwithdrawOnlyStakeLegacy = new BigNumber( | ||
delegationLegacy.userWithdrawOnlyStake ?? ZERO | ||
); | ||
|
||
const bNunstaked = bNunstakedStakeLegacy.plus(bNdeferredPaymentLegacy); | ||
const bNlocked = bNactive | ||
.plus(bNuserWaitingStake) | ||
.plus(bNclaimableRewards) | ||
.plus(bNunstakedStakeLegacy) | ||
.plus(bNdeferredPaymentLegacy) | ||
.plus(bNwithdrawOnlyStakeLegacy); | ||
|
||
const show = bNlocked.isGreaterThan(0); | ||
|
||
return { | ||
active: bNactive, | ||
unstaked: bNunstaked, | ||
claimable: bNclaimableRewards, | ||
locked: bNlocked, | ||
show | ||
}; | ||
} | ||
|
||
return { | ||
active: new BigNumber(ZERO), | ||
unstaked: new BigNumber(ZERO), | ||
claimable: new BigNumber(ZERO), | ||
locked: new BigNumber(ZERO), | ||
show: false | ||
}; | ||
}; |
Oops, something went wrong.