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 4 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": "^4.1.1",
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
48 changes: 48 additions & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3131,5 +3131,53 @@
},
"today": {
"message": "Today"
},
"coinflip": {
"message": "Coinflip"
},
"addLiqiudityV1": {
"message": "Add Liquidity V1"
},
"removeLiqiudityV1": {
"message": "Remove Liqiudity V1"
},
"addLiqiudityV2": {
"message": "Add Liqiudity V2"
},
"removeLiqiudityV2": {
"message": "Remove Liqiudity V2"
},
"addLiqiudityV3": {
"message": "Add Liqiudity V3"
},
"removeLiqiudityV3": {
"message": "Remove Liqiudity V3"
},
"addLiqiudityStableswap": {
"message": "Add Liqiudity Stableswap"
},
"removeLiqiudityStableswap": {
"message": "Remove Liqiudity Stableswap"
},
"investInDividents": {
"message": "Invest In Dividents"
},
"divestFromDividents": {
"message": "Divest From Dividents"
},
"investInFarm": {
"message": "Invest In Farm"
},
"divestFromFarm": {
"message": "Divest From Farm"
},
"harvestFromFarm": {
"message": "Harvest From Farm"
},
"harvestFromDividents": {
"message": "Harvest From Dividents"
},
"quipuswap": {
"message": "Quipuswap"
}
}
48 changes: 48 additions & 0 deletions public/_locales/en_GB/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1793,5 +1793,53 @@
},
"viewAdsDescription": {
"message": "I agree to share data(wallet address, IP) and get cashback at Temple Keys for viewing ads"
},
"coinflip": {
"message": "Coinflip"
},
"addLiqiudityV1": {
"message": "Add Liquidity V1"
},
"removeLiqiudityV1": {
"message": "Remove Liqiudity V1"
},
"addLiqiudityV2": {
"message": "Add Liqiudity V2"
},
"removeLiqiudityV2": {
"message": "Remove Liqiudity V2"
},
"addLiqiudityV3": {
"message": "Add Liqiudity V3"
},
"removeLiqiudityV3": {
"message": "Remove Liqiudity V3"
},
"addLiqiudityStableswap": {
"message": "Add Liqiudity Stableswap"
},
"removeLiqiudityStableswap": {
"message": "Remove Liqiudity Stableswap"
},
"investInDividents": {
"message": "Invest In Dividents"
},
"divestFromDividents": {
"message": "Divest From Dividents"
},
"investInFarm": {
"message": "Invest In Farm"
},
"divestFromFarm": {
"message": "Divest From Farm"
},
"harvestFromFarm": {
"message": "Harvest From Farm"
},
"harvestFromDividents": {
"message": "Harvest From Dividents"
},
"quipuswap": {
"message": "Quipuswap"
}
}
55 changes: 53 additions & 2 deletions src/app/templates/activity/activity-item/activity-subtitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,29 @@ interface Props {

export const ActivitySubtitle: FC<Props> = memo(({ activity }) => {
const { prepositionI18nKey, actor } = getActor(activity);
const { isSend, isReceive, is3Route, isAllowanceChange, isDelegation, isBakingRewards } =
getActivityTypeFlags(activity);
const {
isSend,
isReceive,
is3Route,
isAllowanceChange,
isDelegation,
isBakingRewards,
isQuipuswapCoinflip,
isQuipuswapAddLiqiudityV1,
isQuipuswapRemoveLiquidityV1,
isQuipuswapAddLiqiudityV2,
isQuipuswapRemoveLiquidityV2,
isQuipuswapAddLiqiudityV3,
isQuipuswapRemoveLiquidityV3,
isQuipuswapAddLiqiudityStableswap,
isQuipuswapRemoveLiquidityStableswap,
isQuipuswapInvestInDividents,
isQuipuswapDivestFromDividents,
isQuipuswapInvestInFarm,
isQuipuswapDivestFromFarm,
isQuipuswapHarvestFromFarm,
isQuipuswapHarvestFromDividents
} = getActivityTypeFlags(activity);
const shouldShowActorAddressInSubtitle = (isSend || isReceive || isAllowanceChange) && isDefined(actor);
const shouldShowBaker = (isDelegation || isBakingRewards) && isDefined(actor);
const shouldShowActor = isDelegation || isBakingRewards || isSend || isReceive || isAllowanceChange;
Expand All @@ -28,6 +49,36 @@ 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="addLiqiudityV1" />;
} else if (isQuipuswapRemoveLiquidityV1) {
secondPart = <T id="removeLiqiudityV1" />;
} else if (isQuipuswapAddLiqiudityV2) {
secondPart = <T id="addLiqiudityV2" />;
} else if (isQuipuswapRemoveLiquidityV2) {
secondPart = <T id="removeLiqiudityV2" />;
} else if (isQuipuswapAddLiqiudityV3) {
secondPart = <T id="addLiqiudityV3" />;
} else if (isQuipuswapRemoveLiquidityV3) {
secondPart = <T id="removeLiqiudityV3" />;
} else if (isQuipuswapAddLiqiudityStableswap) {
secondPart = <T id="addLiqiudityStableswap" />;
} else if (isQuipuswapRemoveLiquidityStableswap) {
secondPart = <T id="removeLiqiudityStableswap" />;
} else if (isQuipuswapInvestInDividents) {
secondPart = <T id="investInDividents" />;
} else if (isQuipuswapDivestFromDividents) {
secondPart = <T id="divestFromDividents" />;
} else if (isQuipuswapInvestInFarm) {
secondPart = <T id="investInFarm" />;
} else if (isQuipuswapDivestFromFarm) {
secondPart = <T id="divestFromFarm" />;
} else if (isQuipuswapHarvestFromFarm) {
secondPart = <T id="harvestFromFarm" />;
} else if (isQuipuswapHarvestFromDividents) {
secondPart = <T id="harvestFromDividents" />;
} else {
secondPart = '‒';
}
Expand Down
18 changes: 17 additions & 1 deletion src/app/templates/activity/activity-item/activity-type-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,23 @@ const activityTypesI18nKeys = {
};

const activitySubtypesI18nKeys = {
[ActivitySubtype.Route3]: 'route3' as const
[ActivitySubtype.Route3]: 'route3' as const,
[ActivitySubtype.QuipuswapCoinflipBet]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapCoinflipWin]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapAddLiqiudityV1]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapRemoveLiquidityV1]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapAddLiqiudityV2]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapRemoveLiquidityV2]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapAddLiqiudityV3]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapRemoveLiquidityV3]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapAddLiquidityStableswap]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapRemoveLiquidityStableswap]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapInvestInDividents]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapDivestFromDividents]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapInvestInFarm]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapDivestFromFarm]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapHarvestFromFarm]: 'quipuswap' as const,
[ActivitySubtype.QuipuswapHarvestFromDividents]: 'quipuswap' as const
};

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,23 @@ 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.QuipuswapInvestInDividents]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapDivestFromDividents]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapInvestInFarm]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapDivestFromFarm]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapHarvestFromFarm]: QuipuswapLogoSrc,
[ActivitySubtype.QuipuswapHarvestFromDividents]: QuipuswapLogoSrc
};

const actorAvatarStyles = 'border border-gray-300 mr-2 rounded-md min-w-9';
Expand Down Expand Up @@ -84,9 +102,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
68 changes: 67 additions & 1 deletion src/lib/temple/activity-new/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,58 @@ export const getActivityTypeFlags = (activity: DisplayableActivity) => {
const isReceive = type === ActivityType.Recieve;
const isInteraction = type === ActivityType.Interaction;
const is3Route = isInteraction && activity.subtype === ActivitySubtype.Route3;
const isQuipuswapCoinflip =
isInteraction &&
(activity.subtype === ActivitySubtype.QuipuswapCoinflipBet ||
activity.subtype === ActivitySubtype.QuipuswapCoinflipWin);

const isQuipuswapAddLiqiudityV1 = isInteraction && activity.subtype === ActivitySubtype.QuipuswapAddLiqiudityV1;
const isQuipuswapRemoveLiquidityV1 = isInteraction && activity.subtype === ActivitySubtype.QuipuswapRemoveLiquidityV1;
const isQuipuswapAddLiqiudityV2 = isInteraction && activity.subtype === ActivitySubtype.QuipuswapAddLiqiudityV2;
const isQuipuswapRemoveLiquidityV2 = isInteraction && activity.subtype === ActivitySubtype.QuipuswapRemoveLiquidityV2;
const isQuipuswapAddLiqiudityV3 = isInteraction && activity.subtype === ActivitySubtype.QuipuswapAddLiqiudityV3;
const isQuipuswapRemoveLiquidityV3 = isInteraction && activity.subtype === ActivitySubtype.QuipuswapRemoveLiquidityV3;
const isQuipuswapAddLiqiudityStableswap =
isInteraction && activity.subtype === ActivitySubtype.QuipuswapAddLiquidityStableswap;
const isQuipuswapRemoveLiquidityStableswap =
isInteraction && activity.subtype === ActivitySubtype.QuipuswapRemoveLiquidityStableswap;
const isQuipuswapInvestInDividents = isInteraction && activity.subtype === ActivitySubtype.QuipuswapInvestInDividents;
const isQuipuswapDivestFromDividents =
isInteraction && activity.subtype === ActivitySubtype.QuipuswapDivestFromDividents;
const isQuipuswapInvestInFarm = isInteraction && activity.subtype === ActivitySubtype.QuipuswapInvestInFarm;
const isQuipuswapDivestFromFarm = isInteraction && activity.subtype === ActivitySubtype.QuipuswapDivestFromFarm;
const isQuipuswapHarvestFromFarm = isInteraction && activity.subtype === ActivitySubtype.QuipuswapHarvestFromFarm;
const isQuipuswapHarvestFromDividents =
isInteraction && activity.subtype === ActivitySubtype.QuipuswapHarvestFromDividents;

const isAllowanceChange = isInteraction && activity.subtype === ActivitySubtype.ChangeAllowance;
const isRevoke = isAllowanceChange && Boolean(activity.allowanceChanges[0]?.atomicAmount.isZero());

return { isDelegation, isBakingRewards, isSend, isReceive, isInteraction, is3Route, isAllowanceChange, isRevoke };
return {
isDelegation,
isBakingRewards,
isSend,
isReceive,
isInteraction,
is3Route,
isAllowanceChange,
isRevoke,
isQuipuswapCoinflip,
isQuipuswapAddLiqiudityV1,
isQuipuswapRemoveLiquidityV1,
isQuipuswapAddLiqiudityV2,
isQuipuswapRemoveLiquidityV2,
isQuipuswapAddLiqiudityV3,
isQuipuswapRemoveLiquidityV3,
isQuipuswapAddLiqiudityStableswap,
isQuipuswapRemoveLiquidityStableswap,
isQuipuswapInvestInDividents,
isQuipuswapDivestFromDividents,
isQuipuswapInvestInFarm,
isQuipuswapDivestFromFarm,
isQuipuswapHarvestFromFarm,
isQuipuswapHarvestFromDividents
};
};

export const isInteractionActivityTypeGuard = (activity: DisplayableActivity): activity is InteractionActivity =>
Expand Down Expand Up @@ -63,3 +111,21 @@ export const getActor = (activity: DisplayableActivity) => {
actor: isSend || isDelegation ? activity.to : activity.from
};
};

export const isQuipuswapSubtype = (subtype: ActivitySubtype): boolean =>
subtype === ActivitySubtype.QuipuswapCoinflipBet ||
lendihop marked this conversation as resolved.
Show resolved Hide resolved
subtype === ActivitySubtype.QuipuswapCoinflipWin ||
subtype === ActivitySubtype.QuipuswapAddLiqiudityV1 ||
subtype === ActivitySubtype.QuipuswapRemoveLiquidityV1 ||
subtype === ActivitySubtype.QuipuswapAddLiqiudityV2 ||
subtype === ActivitySubtype.QuipuswapRemoveLiquidityV2 ||
subtype === ActivitySubtype.QuipuswapAddLiqiudityV3 ||
subtype === ActivitySubtype.QuipuswapRemoveLiquidityV3 ||
subtype === ActivitySubtype.QuipuswapAddLiquidityStableswap ||
subtype === ActivitySubtype.QuipuswapRemoveLiquidityStableswap ||
subtype === ActivitySubtype.QuipuswapInvestInDividents ||
subtype === ActivitySubtype.QuipuswapDivestFromDividents ||
subtype === ActivitySubtype.QuipuswapInvestInFarm ||
subtype === ActivitySubtype.QuipuswapDivestFromFarm ||
subtype === ActivitySubtype.QuipuswapHarvestFromFarm ||
subtype === ActivitySubtype.QuipuswapHarvestFromDividents;
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2796,10 +2796,10 @@
dependencies:
nanoid "^3.1.25"

"@temple-wallet/transactions-parser@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@temple-wallet/transactions-parser/-/transactions-parser-4.0.0.tgz#edf24ba111ea367bd6a2d98d144c82fc01cd7fa0"
integrity sha512-Fkl2AcTO5iu9pRF7HQB/vUJsri+0R96XDaPBsBemMqYed/H8Zm5RQ8YGveMFYbAxwfsgeR33gLzXSzObPzIM9Q==
"@temple-wallet/transactions-parser@^4.1.1":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@temple-wallet/transactions-parser/-/transactions-parser-4.1.1.tgz#837bc6f28a221856d91c87dd572696f0ba85b7be"
integrity sha512-AvrKVABAWzh5oLFKrIlrvWFzYVgJO4lCefKICUY6cRsDLZzbzQ2Vl5eovzPRA3KmjlNHCayw9RBhLYUBUWCKLg==
dependencies:
bignumber.js "^9.1.0"

Expand Down