Skip to content

Commit

Permalink
remove sybil check from donation
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Rb3 committed Apr 26, 2024
1 parent 413a3e0 commit 2acf320
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 37 deletions.
68 changes: 68 additions & 0 deletions apps/potlock/widget/ModalDonation/Banners.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,48 @@ const NadabotBanner = styled.div`
}
}
`;

const VerifyInfoWrapper = styled.div`
display: flex;
align-items: center;
gap: 14px;
padding: 1rem;
border-radius: 6px;
border: 1px solid #ecc113;
background: #fbf9c6;
box-shadow: 0px 2px 1px 1px rgba(255, 255, 255, 0.8) inset,
0px -2px 4px 0px rgba(15, 15, 15, 0.15) inset;
font-size: 14px;
color: #3f2209;
margin-top: 1.5rem;
.icon {
width: 17px;
display: flex;
height: fit-content;
svg {
width: 100%;
}
}
.text {
flex: 1;
line-height: 150%;
}
a {
font-weight: 500;
color: #dd3345;
:hover {
text-decoration: none;
}
}
@media only screen and (max-width: 480px) {
flex-wrap: wrap;
a {
width: 100%;
text-align: center;
}
}
`;

const NADA_BOT_ICON = "bafkreicojpp23dmf7hakbt67eah4ba52dx3reekdccaupoggzzlhdkroyi";

const Alert = ({ error }) => (
Expand Down Expand Up @@ -83,7 +125,33 @@ const Nadabot = () => (
</NadabotBanner>
);

const VerifyInfo = () => (
<VerifyInfoWrapper>
<div className="icon">
<svg
width="18"
height="16"
viewBox="0 0 18 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M0.75 15.125H17.25L9 0.875L0.75 15.125ZM9.75 12.875H8.25V11.375H9.75V12.875ZM9.75 9.875H8.25V6.875H9.75V9.875Z"
fill="#ECC113"
/>
</svg>
</div>
<div className="text">
Your contribution won't be matched unless verified as human before the matching round ends.
</div>
<a href="https://app.nada.bot/" target="_blank">
Verify you’re human
</a>
</VerifyInfoWrapper>
);

return {
Alert,
Nadabot,
VerifyInfo,
};
27 changes: 13 additions & 14 deletions apps/potlock/widget/ModalDonation/Form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const { AmountInput } = VM.require(`potlock.near/widget/ModalDonation.AmountInpu
const { Checks } = VM.require(`potlock.near/widget/ModalDonation.Checks`) || {
Checks: () => {},
};
const { Nadabot, Alert } = VM.require(`potlock.near/widget/ModalDonation.Banners`) || {
Nadabot: () => {},
const { VerifyInfo, Alert } = VM.require(`potlock.near/widget/ModalDonation.Banners`) || {
VerifyInfo: () => {},
Alert: () => {},
};

Expand Down Expand Up @@ -204,16 +204,14 @@ const FormDirect = (props) => {
>
Amount
</Label>
{!needsToVerify && (
<AmountInput
value={amount}
donationType={donationType}
HandleAmoutChange={HandleAmoutChange}
updateState={updateState}
denominationOptions={denominationOptions}
selectedDenomination={selectedDenomination}
/>
)}
<AmountInput
value={amount}
donationType={donationType}
HandleAmoutChange={HandleAmoutChange}
updateState={updateState}
denominationOptions={denominationOptions}
selectedDenomination={selectedDenomination}
/>

{ftBalance && (
<CurrentBalance>
Expand All @@ -226,13 +224,14 @@ const FormDirect = (props) => {
</CurrentBalance>
)}
{amountError && <Alert error={amountError} />}
{needsToVerify && <Nadabot />}
{needsToVerify && <VerifyInfo />}

<Button>
<Widget
src={`${ownerId}/widget/Components.Button`}
props={{
type: "primary",
disabled: amountError || needsToVerify || !amount,
disabled: amountError || !amount,
text: isLoading ? "Loading..." : "Proceed to donate",
onClick: () => updateState({ currentPage: "confirm" }),
}}
Expand Down
15 changes: 14 additions & 1 deletion apps/potlock/widget/ModalDonation/FormPot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const { ownerId, NADABOT_HUMAN_METHOD } = VM.require("potlock.near/widget/consta
NADABOT_HUMAN_METHOD: "",
};

const { VerifyInfo } = VM.require(`potlock.near/widget/ModalDonation.Banners`) || {
VerifyInfo: () => {},
Alert: () => {},
};

const { nearToUsd } = VM.require("potlock.near/widget/utils");

const { Checks } = VM.require(`potlock.near/widget/ModalDonation.Checks`) || {
Expand Down Expand Up @@ -232,6 +237,7 @@ const FormPot = (props) => {
ftBalance,
hrefWithParams,
selectedProjects,
NADABOT_CONTRACT_ID,
} = props;

const projects = props.projects ?? [];
Expand Down Expand Up @@ -292,6 +298,12 @@ const FormPot = (props) => {
});
};

const isUserHumanVerified = Near.view(NADABOT_CONTRACT_ID, NADABOT_HUMAN_METHOD, {
account_id: accountId,
});

const needsToVerify = isUserHumanVerified === false;

return (
<Form>
<Content>
Expand Down Expand Up @@ -355,6 +367,7 @@ const FormPot = (props) => {
)}
</CurrentBalance>
{amountError && <Alert error={amountError} />}
{needsToVerify && <VerifyInfo />}
</Content>
<Projects style={{ height: projectsContaienrHegiht + "px" }}>
{projects.map(({ project_id }) => {
Expand Down Expand Up @@ -433,7 +446,7 @@ const FormPot = (props) => {
: totalAmountAllocated > ftBalance ||
amountError ||
parseFloat(totalAmountAllocated) === 0),
text: isUserHumanVerified ? "Verify to nadabot" : "Proceed to donate",
text: "Proceed to donate",
onClick: () => {
if (donationType === "auto") updateState({ currentPage: "confirmPot" });
else {
Expand Down
28 changes: 14 additions & 14 deletions apps/potlock/widget/Pots/Detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,20 @@ State.init({
registryStatus: null,
});

if (state.sybilRequirementMet === null) {
if (potDetail.sybil_wrapper_provider) {
const [contractId, methodName] = potDetail.sybil_wrapper_provider.split(":");
Near.asyncView(contractId, methodName, { account_id: context.accountId })
.then((result) => {
State.update({ sybilRequirementMet: result });
})
.catch((e) => {
State.update({ sybilRequirementMet: false });
});
} else {
State.update({ sybilRequirementMet: true });
}
}
// if (state.sybilRequirementMet === null) {
// if (potDetail.sybil_wrapper_provider) {
// const [contractId, methodName] = potDetail.sybil_wrapper_provider.split(":");
// Near.asyncView(contractId, methodName, { account_id: context.accountId })
// .then((result) => {
// State.update({ sybilRequirementMet: result });
// })
// .catch((e) => {
// State.update({ sybilRequirementMet: false });
// });
// } else {
// State.update({ sybilRequirementMet: true });
// }
// }

const noPot = potDetail === undefined;
const loading = potDetail === null;
Expand Down
1 change: 1 addition & 0 deletions apps/potlock/widget/Pots/FlaggedAccounts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Title = styled.div`
const Table = styled.div`
display: flex;
flex-direction: column;
overflow-y: scroll;
width: 100%;
border-radius: 6px;
border: 1px solid #7b7b7b;
Expand Down
4 changes: 2 additions & 2 deletions apps/potlock/widget/Pots/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ const existingChallengeForUser = (payoutsChallenges || []).find(
(challenge) => challenge.challenger_id === context.accountId
);

const canDonate = sybilRequirementMet && projects.length > 0;
const canDonate = context.accountId && projects.length > 0;

return (
<Container>
<Header>
<Title>{pot_name}</Title>
<Title onClick={() => setSuccessfulDonation({})}>{pot_name}</Title>
<Description>
<Markdown text={pot_description} />
</Description>
Expand Down
8 changes: 2 additions & 6 deletions apps/potlock/widget/Pots/Projects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const [projects, setProjects] = useState(null);
const [flaggedAddresses, setFlaggedAddresses] = useState(null);

// get projects
const { ownerId, potId, potDetail, sybilRequirementMet, allDonations } = props;
const { ownerId, potId, potDetail, allDonations } = props;
const { calculatePayouts, getTagsFromSocialProfileData, getTeamMembersFromSocialProfileData } =
VM.require("potlock.near/widget/utils") || {
calculatePayouts: () => {},
Expand Down Expand Up @@ -294,11 +294,7 @@ return (
potDetail,
projects,
projectId: project.project_id,
allowDonate:
sybilRequirementMet &&
publicRoundOpen &&
project.project_id !== context.accountId,
requireVerification: !sybilRequirementMet,
allowDonate: publicRoundOpen && project.project_id !== context.accountId,
potRferralFeeBasisPoints: referral_fee_public_round_basis_points,
payoutDetails: payouts[project.project_id] || {
donorCount: 0,
Expand Down
17 changes: 17 additions & 0 deletions apps/potlock/widget/Project/ModalSuccess.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ const {
ownerId,
SUPPORTED_FTS: { NEAR },
IPFS_BASE_URL,
NADABOT_HUMAN_METHOD,
NADABOT_CONTRACT_ID,
} = VM.require("potlock.near/widget/constants") || {
ownerId: "",
SUPPORTED_FTS: {},
IPFS_BASE_URL: "",
NADABOT_HUMAN_METHOD: "",
NADABOT_CONTRACT_ID: "",
};

const { VerifyInfo } = VM.require(`potlock.near/widget/ModalDonation.Banners`) || {
VerifyInfo: () => {},
};

const { yoctosToUsd } = VM.require("potlock.near/widget/utils") || { yoctosToUsd: () => null };

let DonateSDK =
Expand Down Expand Up @@ -372,6 +381,12 @@ const twitterIntent = useMemo(() => {
return twitterIntentBase + text + `&url=${url}` + `&hashtags=${DEFAULT_SHARE_HASHTAGS.join(",")}`;
}, [successfulDonation, recipientProfile]);

const isUserHumanVerified = Near.view(NADABOT_CONTRACT_ID, NADABOT_HUMAN_METHOD, {
account_id: context.accountId,
});

const needsToVerify = isUserHumanVerified === false;

return (
<Widget
src={`${ownerId}/widget/Components.Modal`}
Expand Down Expand Up @@ -496,6 +511,8 @@ return (
ftIcon: ftMetadata?.icon,
}}
/>

{needsToVerify && <VerifyInfo />}
</ModalMain>
) : (
""
Expand Down
1 change: 1 addition & 0 deletions apps/potlock/widget/constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ return {
PROJECT_STATUSES: ["Pending", "Approved", "Rejected", "Graylisted", "Blacklisted"],
DONATION_CONTRACT_ID: "donate.potlock.near",
NADABOT_HUMAN_METHOD: "is_human",
NADABOT_CONTRACT_ID: "v1.nadabot.near",
IPFS_BASE_URL: "https://ipfs.near.social/ipfs/",
ONE_TGAS: Big(1_000_000_000_000),
MAX_DONATION_MESSAGE_LENGTH: 100,
Expand Down

0 comments on commit 2acf320

Please sign in to comment.