Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1099: Transaction history Quipuswap #1001

Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@taquito/tzip16": "17.0.0",
"@taquito/utils": "17.0.0",
"@temple-wallet/dapp": "5.0.2",
"@temple-wallet/transactions-parser": "^4.0.0",
"@temple-wallet/transactions-parser": "^5.0.0",
lendihop marked this conversation as resolved.
Show resolved Hide resolved
"@temple-wallet/wallet-address-validator": "^0.4.3",
"@tezos-domains/core": "1.26.0",
"@tezos-domains/taquito-client": "1.26.0",
Expand Down
54 changes: 54 additions & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3131,5 +3131,59 @@
},
"today": {
"message": "Today"
},
"coinflip": {
"message": "Coin flip"
},
"investInV1": {
"message": "Invest in V1"
},
"divestFromV1": {
"message": "Divest from V1"
},
"investInV2": {
"message": "Invest in V2"
},
"divestFromV2": {
"message": "Divest from V2"
},
"investInV3": {
"message": "Invest in V3"
},
"divestFromV3": {
"message": "Divest from V3"
},
"investInStableswap": {
"message": "Invest in Stableswap"
},
"divestFromStableswap": {
"message": "Divest from Stableswap"
},
"investInDividends": {
"message": "Invest In Dividends"
},
"divestFromDividends": {
"message": "Divest From Dividends"
},
"stakeToFarm": {
"message": "Stake to farm"
},
"unstakeFromFarm": {
"message": "Unstake from farm"
},
"claimRewards": {
"message": "Claim Rewards"
},
"harvestFromDividends": {
"message": "Harvest From Dividends"
},
"swapAndSend": {
"message": "Swap and Send"
},
"receiveFromSwap": {
"message": "Receive from swap"
},
"quipuswap": {
"message": "Quipuswap"
}
}
54 changes: 54 additions & 0 deletions public/_locales/en_GB/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1793,5 +1793,59 @@
},
"viewAdsDescription": {
"message": "I agree to share data(wallet address, IP) and get cashback at Temple Keys for viewing ads"
},
"coinflip": {
"message": "Coin flip"
},
"investInV1": {
"message": "Invest in V1"
},
"divestFromV1": {
"message": "Divest from V1"
},
"investInV2": {
"message": "Invest in V2"
},
"divestFromV2": {
"message": "Divest from V2"
},
"investInV3": {
"message": "Invest in V3"
},
"divestFromV3": {
"message": "Divest from V3"
},
"investInStableswap": {
"message": "Invest in Stableswap"
},
"divestFromStableswap": {
"message": "Divest from Stableswap"
},
"investInDividends": {
"message": "Invest In Dividends"
},
"divestFromDividends": {
"message": "Divest From Dividends"
},
"stakeToFarm": {
"message": "Stake to farm"
},
"unstakeFromFarm": {
"message": "Unstake from farm"
},
"claimRewards": {
"message": "Claim Rewards"
},
"harvestFromDividends": {
"message": "Harvest From Dividends"
},
"swapAndSend": {
"message": "Swap and Send"
},
"receiveFromSwap": {
"message": "Receive from swap"
},
"quipuswap": {
"message": "Quipuswap"
}
}
55 changes: 54 additions & 1 deletion src/app/templates/activity/activity-item/activity-subtitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,27 @@ interface Props {

export const ActivitySubtitle: FC<Props> = memo(({ activity }) => {
const { prepositionI18nKey, actor } = getActor(activity);
const { isSend, isReceive, is3Route, isAllowanceChange, isDelegation, isBakingRewards } =
const { isSend, isReceive, is3Route, isAllowanceChange, isDelegation, isBakingRewards, quipuswap } =
getActivityTypeFlags(activity);
const {
isQuipuswapCoinflip,
isQuipuswapAddLiqiudityV1,
isQuipuswapRemoveLiquidityV1,
isQuipuswapAddLiqiudityV2,
isQuipuswapRemoveLiquidityV2,
isQuipuswapAddLiqiudityV3,
isQuipuswapRemoveLiquidityV3,
isQuipuswapAddLiqiudityStableswap,
isQuipuswapRemoveLiquidityStableswap,
isQuipuswapInvestInDividends,
isQuipuswapDivestFromDividends,
isQuipuswapInvestInFarm,
isQuipuswapDivestFromFarm,
isQuipuswapHarvestFromFarm,
isQuipuswapHarvestFromDividends,
isQuipuswapSend,
isQuipuswapReceive
} = quipuswap;
const shouldShowActorAddressInSubtitle = (isSend || isReceive || isAllowanceChange) && isDefined(actor);
const shouldShowBaker = (isDelegation || isBakingRewards) && isDefined(actor);
const shouldShowActor = isDelegation || isBakingRewards || isSend || isReceive || isAllowanceChange;
Expand All @@ -28,6 +47,40 @@ export const ActivitySubtitle: FC<Props> = memo(({ activity }) => {
secondPart = <BakerName bakerAddress={actor.address} />;
} else if (is3Route) {
secondPart = <T id="swapTokens" />;
} else if (isQuipuswapCoinflip) {
lendihop marked this conversation as resolved.
Show resolved Hide resolved
secondPart = <T id="coinflip" />;
} else if (isQuipuswapAddLiqiudityV1) {
secondPart = <T id="investInV1" />;
} else if (isQuipuswapRemoveLiquidityV1) {
secondPart = <T id="divestFromV1" />;
} else if (isQuipuswapAddLiqiudityV2) {
secondPart = <T id="investInV2" />;
} else if (isQuipuswapRemoveLiquidityV2) {
secondPart = <T id="divestFromV2" />;
} else if (isQuipuswapAddLiqiudityV3) {
secondPart = <T id="investInV3" />;
} else if (isQuipuswapRemoveLiquidityV3) {
secondPart = <T id="divestFromV3" />;
} else if (isQuipuswapAddLiqiudityStableswap) {
secondPart = <T id="investInStableswap" />;
} else if (isQuipuswapRemoveLiquidityStableswap) {
secondPart = <T id="divestFromStableswap" />;
} else if (isQuipuswapInvestInDividends) {
secondPart = <T id="investInDividends" />;
} else if (isQuipuswapDivestFromDividends) {
secondPart = <T id="divestFromDividends" />;
} else if (isQuipuswapInvestInFarm) {
secondPart = <T id="stakeToFarm" />;
} else if (isQuipuswapDivestFromFarm) {
secondPart = <T id="unstakeFromFarm" />;
} else if (isQuipuswapHarvestFromFarm) {
secondPart = <T id="claimRewards" />;
} else if (isQuipuswapHarvestFromDividends) {
secondPart = <T id="harvestFromDividends" />;
} else if (isQuipuswapSend) {
secondPart = <T id="swapAndSend" />;
} else if (isQuipuswapReceive) {
secondPart = <T id="receiveFromSwap" />;
} else {
secondPart = '‒';
}
Expand Down
24 changes: 22 additions & 2 deletions src/app/templates/activity/activity-item/activity-type-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,34 @@ interface Props {

const activityTypesI18nKeys = {
[ActivityType.Send]: 'send' as const,
[ActivityType.Recieve]: 'receive' as const,
[ActivityType.Receive]: 'receive' as const,
[ActivityType.Delegation]: 'delegation' as const,
[ActivityType.BakingRewards]: 'bakerRewards' as const,
[ActivityType.Interaction]: 'interaction' as const
};

const quipuswapActivitySubtype = 'quipuswap' as const;

const activitySubtypesI18nKeys = {
[ActivitySubtype.Route3]: 'route3' as const
[ActivitySubtype.Route3]: 'route3' as const,
[ActivitySubtype.QuipuswapCoinflipBet]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapCoinflipWin]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapAddLiqiudityV1]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapRemoveLiquidityV1]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapAddLiqiudityV2]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapRemoveLiquidityV2]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapAddLiqiudityV3]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapRemoveLiquidityV3]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapAddLiquidityStableswap]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapRemoveLiquidityStableswap]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapInvestInDividends]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapDivestFromDividends]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapInvestInFarm]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapDivestFromFarm]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapHarvestFromFarm]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapHarvestFromDividends]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapSend]: quipuswapActivitySubtype,
[ActivitySubtype.QuipuswapReceive]: quipuswapActivitySubtype
};

export const ActivityTypeView: FC<Props> = ({ activity }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ import {
getActivityTypeFlags,
getActor,
isAllowanceInteractionActivityTypeGuard,
isInteractionActivityTypeGuard
isInteractionActivityTypeGuard,
isQuipuswapSubtype
} from 'lib/temple/activity-new/utils';
import { formatTcInfraImgUri } from 'lib/temple/front/image-uri';
import { Image } from 'lib/ui/Image';

import Route3LogoSrc from '../../assets/3route.png';
import QuipuswapLogoSrc from '../../assets/quipuswap.png';
import { BakerLogo } from '../../baker-logo';
import { RobotIcon } from '../../robot-icon';
import { FilteringMode } from '../../tokens-delta-view';
Expand All @@ -37,7 +39,25 @@ const statusesColors = {
};

const interactionActivitiesLogos = {
[ActivitySubtype.Route3]: Route3LogoSrc
[ActivitySubtype.Route3]: Route3LogoSrc,
[ActivitySubtype.QuipuswapCoinflipBet]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapCoinflipWin]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapAddLiqiudityV1]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapRemoveLiquidityV1]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapAddLiqiudityV2]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapRemoveLiquidityV2]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapAddLiqiudityV3]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapRemoveLiquidityV3]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapAddLiquidityStableswap]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapRemoveLiquidityStableswap]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapInvestInDividends]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapDivestFromDividends]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapInvestInFarm]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapDivestFromFarm]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapHarvestFromFarm]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapHarvestFromDividends]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapSend]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapReceive]: QuipuswapLogoSrc
};

const actorAvatarStyles = 'border border-gray-300 mr-2 rounded-md min-w-9';
Expand All @@ -48,11 +68,28 @@ export const useActivityItemViewModel = (activity: DisplayableActivity) => {
const [isOpen, setIsOpen] = useState(false);
const [wasToggled, setWasToggled] = useState(false);

const { isDelegation, isBakingRewards, isSend, isReceive, isInteraction, is3Route, isAllowanceChange, isRevoke } =
getActivityTypeFlags(activity);
const {
isDelegation,
isBakingRewards,
isSend,
isReceive,
isInteraction,
is3Route,
isAllowanceChange,
isRevoke,
quipuswap
} = getActivityTypeFlags(activity);
const { isQuipuswapSend, isQuipuswapReceive } = quipuswap;
const { prepositionI18nKey: actorPrepositionI18nKey, actor } = getActor(activity);
const shouldShowBaker = (isDelegation || isBakingRewards) && isDefined(actor);
const shouldShowActor = isDelegation || isBakingRewards || isSend || isReceive || isAllowanceChange;
const shouldShowActor =
isDelegation ||
isBakingRewards ||
isSend ||
isReceive ||
isQuipuswapSend ||
isQuipuswapReceive ||
isAllowanceChange;
const headerTokensDeltasFilteringMode = isInteraction ? FilteringMode.ONLY_POSITIVE_IF_PRESENT : FilteringMode.NONE;
const allowanceChanges = isAllowanceChange ? (activity as AllowanceInteractionActivity).allowanceChanges : [];
const cashback = is3Route ? (activity as Route3Activity).cashback : undefined;
Expand Down Expand Up @@ -84,9 +121,11 @@ export const useActivityItemViewModel = (activity: DisplayableActivity) => {
}

if (isInteractionActivityTypeGuard(activity)) {
const width = isDefined(activity.subtype) && isQuipuswapSubtype(activity.subtype) ? 36 : 24;

return isDefined(activity.subtype) && !isAllowanceInteractionActivityTypeGuard(activity) ? (
<div className={classNames('flex items-center justify-center', actorAvatarStyles)}>
<img src={interactionActivitiesLogos[activity.subtype]} alt={activity.subtype} height={12} width={24} />
<div className={classNames('flex items-center justify-center overflow-hidden', actorAvatarStyles)}>
<img src={interactionActivitiesLogos[activity.subtype]} alt={activity.subtype} height={12} width={width} />
lendihop marked this conversation as resolved.
Show resolved Hide resolved
</div>
) : null;
}
Expand Down
Binary file added src/app/templates/activity/assets/quipuswap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/lib/apis/tzkt/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface TzktDelegationOperation extends TzktOperationBase {
amount?: number;
prevDelegate?: TzktAlias | null;
newDelegate?: TzktAlias | null;
parameter: undefined;
}

interface TzktTransactionOperation extends TzktOperationBase {
Expand All @@ -55,7 +56,7 @@ interface TzktTransactionOperation extends TzktOperationBase {
allocationFee: number;
target: TzktAlias;
amount: number;
parameter?: unknown;
parameter: unknown;
entrypoint?: string;
hasInternals: boolean;
tokenTransfersCount?: number;
Expand All @@ -65,10 +66,12 @@ interface TzktOriginationOperation extends TzktOperationBase {
type: TzktOperationType.Origination;
originatedContract?: TzktAlias;
contractBalance?: string;
parameter: unknown;
}

interface TzktRevealOperation extends TzktOperationBase {
type: TzktOperationType.Reveal;
parameter: unknown;
}

export type TzktOperation =
Expand Down
Loading