Skip to content

Commit

Permalink
update twitter url share for pot donation
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Rb3 committed Apr 30, 2024
1 parent 22b6053 commit 3920ab2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/potlock/widget/ModalDonation/ConfirmPot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const pollForDonationSuccess = ({
for (const donation of alldonations) {
const { project_id, donated_at_ms, donated_at } = donation;
if (projectIds.includes(project_id) && (donated_at_ms || donated_at) > afterTs) {
donations[project_id] = donation;
donations[project_id] = { ...donation, potId };
}
}
if (Object.keys(donations).length === projectIds.length) {
Expand Down
11 changes: 6 additions & 5 deletions apps/potlock/widget/Project/ModalSuccess.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,16 @@ const totalAmount = getTotalAmount();

if (props.isModalOpen && !successfulDonation) {
const transactionHashes = props.transactionHashes.split(",");

for (let i = 0; i < transactionHashes.length; i++) {
const txHash = transactionHashes[i];

const body = JSON.stringify({
jsonrpc: "2.0",
id: "dontcare",
method: "tx",
params: [txHash, context.accountId],
});
const res = asyncFetch("https://rpc.mainnet.near.org", {
asyncFetch("https://rpc.mainnet.near.org", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -287,7 +287,6 @@ if (props.isModalOpen && !successfulDonation) {
const successVal = res.body.result.status?.SuccessValue;
const receiver_id = res.body.result.transaction.receiver_id;
const result = JSON.parse(Buffer.from(successVal, "base64").toString("utf-8")); // atob not working

const args = JSON.parse(
Buffer.from(res.body.result.transaction.actions[0].FunctionCall.args, "base64").toString(
"utf-8"
Expand All @@ -307,7 +306,7 @@ if (props.isModalOpen && !successfulDonation) {
if (methodName === "donate") {
setSuccessfulDonation((prev) => ({
...prev,
[recipientId]: result,
[recipientId]: { ...result, potId: receiver_id },
}));
} else if (methodName === "apply") {
// application
Expand Down Expand Up @@ -374,7 +373,9 @@ const twitterIntent = useMemo(() => {

let url =
DEFAULT_GATEWAY +
`${ownerId}/widget/Index?tab=project&projectId=${recipient_id}&referrerId=${context.accountId}`;
(successfulDonationVals[0].potId
? `${ownerId}/widget/Index?tab=pot&potId=${successfulDonationVals[0].potId}&referrerId=${context.accountId}`
: `${ownerId}/widget/Index?tab=project&projectId=${recipient_id}&referrerId=${context.accountId}`);
let text = `I just donated to ${tag} on @${POTLOCK_TWITTER_ACCOUNT_ID}! Support public goods at `;
text = encodeURIComponent(text);
url = encodeURIComponent(url);
Expand Down

0 comments on commit 3920ab2

Please sign in to comment.