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

fix(app): making distinction between technically possible points and points to tell the user about #3148

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions app/__test-fixtures__/contextTestHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export const scorerContext = {
connectMessage: "Verify amount",
isEVM: true,
possiblePoints: 7.4399999999999995,
displayPossiblePoints: 7.4399999999999995,
earnedPoints: 0,
},
{
Expand All @@ -161,6 +162,7 @@ export const scorerContext = {
connectMessage: "Connect Account",
isEVM: true,
possiblePoints: 12.93,
displayPossiblePoints: 12.93,
earnedPoints: 0,
},
{
Expand All @@ -170,6 +172,7 @@ export const scorerContext = {
description: "Connect your existing Twitter account to verify.",
connectMessage: "Connect Account",
possiblePoints: 3.63,
displayPossiblePoints: 3.63,
earnedPoints: 3.63,
},
{
Expand All @@ -179,6 +182,7 @@ export const scorerContext = {
description: "Connect your existing Discord account to verify.",
connectMessage: "Connect Account",
possiblePoints: 0.689,
displayPossiblePoints: 0.689,
earnedPoints: 0,
},
{
Expand All @@ -188,6 +192,7 @@ export const scorerContext = {
description: "Connect your existing Google Account to verify",
connectMessage: "Connect Account",
possiblePoints: 2.25,
displayPossiblePoints: 2.25,
earnedPoints: 1,
},
],
Expand Down
14 changes: 14 additions & 0 deletions app/__tests__/components/CardList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ let categoryProps: CategoryProps = {
name: "Github",
platform: "Github",
possiblePoints: 7.0600000000000005,
displayPossiblePoints: 7.0600000000000005,
website: "https://github.com",
},
{
Expand All @@ -65,6 +66,7 @@ let categoryProps: CategoryProps = {
name: "Google",
platform: "Google",
possiblePoints: 0.525,
displayPossiblePoints: 0.525,
website: "https://www.google.com/",
},
{
Expand All @@ -75,6 +77,7 @@ let categoryProps: CategoryProps = {
name: "Discord",
platform: "Discord",
possiblePoints: 0.516,
displayPossiblePoints: 0.516,
website: "https://discord.com/",
},
],
Expand Down Expand Up @@ -147,6 +150,7 @@ describe("<CardList />", () => {
description: "ETH",
connectMessage: "ETH",
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 7,
}}
onOpen={mockOnOpen}
Expand Down Expand Up @@ -187,6 +191,7 @@ describe("<CardList />", () => {
connectMessage: "Verify",
isEVM: true,
possiblePoints: 100,
displayPossiblePoints: 100,
earnedPoints: 100,
},
] as PlatformScoreSpec[],
Expand Down Expand Up @@ -241,6 +246,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 0,
platform: "TestPlatform" as PLATFORM_ID,
name: "Test Platform",
Expand Down Expand Up @@ -285,6 +291,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 5,
platform: "TestPlatform" as PLATFORM_ID,
name: "Test Platform",
Expand Down Expand Up @@ -340,6 +347,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 0,
platform: "NFT" as PLATFORM_ID,
name: "NFT",
Expand Down Expand Up @@ -379,6 +387,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 10,
platform: "AllowList",
name: "Allow List Platform",
Expand Down Expand Up @@ -421,6 +430,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 0,
platform: "AllowList",
name: "Allow List Platform",
Expand Down Expand Up @@ -456,6 +466,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 2,
...platforms["GtcStaking"].PlatformDetails,
},
Expand Down Expand Up @@ -484,6 +495,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 2,
...platforms["GtcStaking"].PlatformDetails,
},
Expand All @@ -506,6 +518,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 10,
displayPossiblePoints: 10,
earnedPoints: 2,
...platforms["GtcStaking"].PlatformDetails,
},
Expand All @@ -528,6 +541,7 @@ describe("show/hide tests", () => {
scoredPlatforms: [
{
possiblePoints: 0,
displayPossiblePoints: 10,
earnedPoints: 0,
...platforms["GtcStaking"].PlatformDetails,
},
Expand Down
4 changes: 2 additions & 2 deletions app/components/CardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export const CardList = ({ className, isLoading = false, initialOpen = true }: C
);

const sortedPlatforms = [
...unverified.sort((a, b) => b.possiblePoints - a.possiblePoints),
...verified.sort((a, b) => b.possiblePoints - b.earnedPoints - (a.possiblePoints - a.earnedPoints)),
...unverified.sort((a, b) => b.displayPossiblePoints - a.displayPossiblePoints),
...verified.sort((a, b) => b.displayPossiblePoints - b.earnedPoints - (a.displayPossiblePoints - a.earnedPoints)),
];

const groupedPlatforms: {
Expand Down
6 changes: 3 additions & 3 deletions app/components/PlatformCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const DefaultStamp = ({ idx, platform, className, onClick, variant }: StampProps
)}
<div className={`text-right`}>
<h1 data-testid="available-points" className="text-2xl text-color-2">
{+Math.max(platform.possiblePoints - platform.earnedPoints, 0).toFixed(1)}
{+Math.max(platform.displayPossiblePoints - platform.earnedPoints, 0).toFixed(1)}
</h1>
<p className="text-xs">Available Points</p>
</div>
Expand Down Expand Up @@ -169,7 +169,7 @@ const VerifiedStamp = ({ idx, platform, daysUntilExpiration, className, onClick
<div className="text-2xl font-bold">{+platform.earnedPoints.toFixed(1)}</div>
<ProgressBar
pointsGained={platform.earnedPoints}
pointsAvailable={Math.max(platform.possiblePoints - platform.earnedPoints, 0)}
pointsAvailable={Math.max(platform.displayPossiblePoints - platform.earnedPoints, 0)}
isSlim={true}
/>
</div>
Expand Down Expand Up @@ -253,7 +253,7 @@ const ExpiredStamp = ({ idx, platform, daysUntilExpiration, className, onClick }
<div className="text-2xl font-bold">{+platform.earnedPoints.toFixed(1)}</div>
<ProgressBar
pointsGained={platform.earnedPoints}
pointsAvailable={Math.max(platform.possiblePoints - platform.earnedPoints, 0)}
pointsAvailable={Math.max(platform.displayPossiblePoints - platform.earnedPoints, 0)}
isSlim={true}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/PlatformDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export const PlatformDetails = ({
const hasStamps = platformPassportData && !!platformPassportData.length;

const earnedPoints = currentPlatformScoreSpec?.earnedPoints || 0;
const possiblePoints = currentPlatformScoreSpec?.possiblePoints || 0;
const possiblePoints = currentPlatformScoreSpec?.displayPossiblePoints || 0;

const pointsGained = +earnedPoints.toFixed(1);
const pointsAvailable = +Math.max(possiblePoints - earnedPoints, 0).toFixed(1);
Expand Down
12 changes: 11 additions & 1 deletion app/context/scorerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export type StampScores = {

export type PlatformScoreSpec = PlatformSpec & {
possiblePoints: number;
// Possible points that we want to tell the user
// about (i.e. excluding deprecated providers)
displayPossiblePoints: number;
earnedPoints: number;
};

Expand Down Expand Up @@ -214,6 +217,10 @@ export const ScorerContextProvider = ({ children }: { children: any }) => {
const scoredPlatforms = [...platforms.keys()].map((platformId) => {
const providers = platformProviders[platformId];
const possiblePoints = providers.reduce(
(acc, { name }) => acc + (parseFloat(stampWeights[name] || "0") || 0),
0
);
const displayPossiblePoints = providers.reduce(
(acc, { name, isDeprecated }) => acc + (isDeprecated ? 0 : parseFloat(stampWeights[name] || "0") || 0),
0
);
Expand All @@ -222,6 +229,7 @@ export const ScorerContextProvider = ({ children }: { children: any }) => {
return {
...platformSpec,
possiblePoints,
displayPossiblePoints,
earnedPoints,
};
});
Expand All @@ -231,7 +239,9 @@ export const ScorerContextProvider = ({ children }: { children: any }) => {

useEffect(() => {
if (!stampScores || !stampWeights) {
setScoredPlatforms(platformSpecs.map((platform) => ({ ...platform, possiblePoints: 0, earnedPoints: 0 })));
setScoredPlatforms(
platformSpecs.map((platform) => ({ ...platform, possiblePoints: 0, earnedPoints: 0, displayPossiblePoints: 0 }))
);
return;
}
calculatePlatformScore();
Expand Down
2 changes: 1 addition & 1 deletion platforms/src/Holonym/App-Bindings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class HolonymPlatform implements Platform {
</li>
<li>
Go to <Hyperlink href="https://holonym.id">Holonym's page</Hyperlink>, verify your ID by connecting your
wallet, and follow prompts to obtain the Government ID, ePassport or Phone Proofs
wallet, and follow prompts to obtain the Government ID, ePassport or Phone Proofs.
</li>
<li>After verification, mint the SBT to your wallet, then link it to your Passport by verifying it.</li>
</ul>
Expand Down
5 changes: 4 additions & 1 deletion platforms/src/Holonym/Providers-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ export const ProviderConfig: PlatformGroupSpec[] = [
platformGroup: "Holonym KYC",
providers: [
{ title: "Proven uniqueness using Holonym KYC with government ID or ePassport", name: "HolonymGovIdProvider" },
{ title: "Proven uniqueness using Holonym Phone Verification", name: "HolonymPhone" },
],
},
{
platformGroup: "Phone Number",
providers: [{ title: "Proven uniqueness using Holonym Phone Verification", name: "HolonymPhone" }],
},
];

export const providers: Provider[] = [new HolonymGovIdProvider(), new HolonymPhone()];
Loading