Skip to content

Commit

Permalink
Merge pull request #283 from sunrise-stake/develop
Browse files Browse the repository at this point in the history
0.7.5 Remove mangrove promotion
  • Loading branch information
dankelleher authored Sep 26, 2023
2 parents a5140c1 + 8b17f52 commit c2da628
Show file tree
Hide file tree
Showing 56 changed files with 214 additions and 657 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ yarn test
| TreasuryController Program | [sbnbpcN3HVfcj9jTwzncwLeNvCzSwbfMwNmdAgX36VW](https://explorer.solana.com/address/sbnbpcN3HVfcj9jTwzncwLeNvCzSwbfMwNmdAgX36VW) | [stcGmoLCBsr2KSu2vvcSuqMiEZx36F32ySUtCXjab5B](https://explorer.solana.com/address/stcGmoLCBsr2KSu2vvcSuqMiEZx36F32ySUtCXjab5B?cluster=devnet) | Program address for the [treasury controller](https://github.com/sunrise-stake/treasury-controller) | |
| TreasuryController State | [DzyP73X4TWnh5jarfjapaNBxtjeEVsfknWVfToRYARDL](https://explorer.solana.com/address/DzyP73X4TWnh5jarfjapaNBxtjeEVsfknWVfToRYARDL) | [8Z8BwUqZTD8XyJ6sdEEeWLaZ9Bg1J7TRDoYPfhkGS9Hr](https://explorer.solana.com/address/8Z8BwUqZTD8XyJ6sdEEeWLaZ9Bg1J7TRDoYPfhkGS9Hr?cluster=devnet) | State PDA describing the configuration of the treasury controller - includes references to the token mint to purchase, proportion to pass to the treasury (currently 0) etc. | |
| TreasuryController Update Authority | [48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv](https://explorer.solana.com/address/48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv) | [48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv](https://explorer.solana.com/address/48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv?cluster=devnet) | Update authority for the treasury controller state. In future this will be controlled by the [DAO](https://app.realms.today/dao/sunrisestake) | |
| Yield Account | [E7BjB9UQp814RsMPq7U6S4fy6wRzn6tFTYt31kJoskoq](https://explorer.solana.com/address/E7BjB9UQp814RsMPq7U6S4fy6wRzn6tFTYt31kJoskoq) | [GRrWR48gthj53CpmdvThjh3Nh5XtjNJLsxqdKtNpJyDp](https://explorer.solana.com/address/GRrWR48gthj53CpmdvThjh3Nh5XtjNJLsxqdKtNpJyDp?cluster=devnet) | PDA, owned by the treasury controller, that yield from Sunrise is deposited into, pending spending. | |
| Yield Account | [6HQrvpMJFqMj35JqMReyhnUrRXNucAAB6FywdDu7xPKA](https://explorer.solana.com/address/6HQrvpMJFqMj35JqMReyhnUrRXNucAAB6FywdDu7xPKA) | [GRrWR48gthj53CpmdvThjh3Nh5XtjNJLsxqdKtNpJyDp](https://explorer.solana.com/address/GRrWR48gthj53CpmdvThjh3Nh5XtjNJLsxqdKtNpJyDp?cluster=devnet) | PDA, owned by the treasury controller, that yield from Sunrise is deposited into, pending spending via [offset.sunrisestake.com](https://offset.sunrisestake.com) | |
| Treasury Account | [Bup7DZk56XwQUDzuvBz9nzbr8e2iLPVrBpha1KTfEbbJ](https://explorer.solana.com/address/Bup7DZk56XwQUDzuvBz9nzbr8e2iLPVrBpha1KTfEbbJ) | [stdeYBs3MUtQN7zqgAQaxvsYemxncJKNDMJhciHct9M](https://explorer.solana.com/address/stdeYBs3MUtQN7zqgAQaxvsYemxncJKNDMJhciHct9M?cluster=devnet) | [Sunrise DAO](https://app.realms.today/dao/sunrisestake) treasury account | |
| NCT Mint | [7sbtAMfAuSfsUvZKPWiXUXaizYCnpLL2BBnKNTU3wjfT](https://explorer.solana.com/address/7sbtAMfAuSfsUvZKPWiXUXaizYCnpLL2BBnKNTU3wjfT) | [tnct1RC5jg94CJLpiTZc2A2d98MP1Civjh7o6ShmTP6](https://explorer.solana.com/address/tnct1RC5jg94CJLpiTZc2A2d98MP1Civjh7o6ShmTP6?cluster=devnet) | Carbon token bought and burned by the treasury controller: [Toucan NCT](https://blog.toucan.earth/announcing-nct-nature-carbon-tonne/) - bridged via Wormhole from Polygon. | |
| Holding Account SOL | [shcFT8Ur2mzpX61uWQRL9KyERZp4w2ehDEvA7iaAthn](https://explorer.solana.com/address/shcFT8Ur2mzpX61uWQRL9KyERZp4w2ehDEvA7iaAthn) | [dhcB568T3skiP2D9ujf4eAJEnW2gACaaA9BUCVbwbXD](https://explorer.solana.com/address/dhcB568T3skiP2D9ujf4eAJEnW2gACaaA9BUCVbwbXD?cluster=devnet) | Recipient account for SOL used to purchase NCT. (Temporary, until a liquid market for NCT exists on Solana) | |
Expand Down
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@marinade.finance/marinade-ts-sdk": "^4.0.4",
"cross-env": "^7.0.3"
},
Expand Down
77 changes: 6 additions & 71 deletions packages/app/src/api/db.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
import {
type GetNeighboursResponse,
type Mint,
type MintResponse,
type MongoResponse,
type NeighbourEntry,
type RawGetNeighboursResponse,
type RawNeighbourEntry,
type Transfer,
type TransferResponse,
} from "./types";
import { PublicKey } from "@solana/web3.js";
import mintStub from "./stubs/mints.json";
import sendingStub from "./stubs/sendings.json";
import receiptStub from "./stubs/receipts.json";

const STUB_DB = false;
const STUBS = {
mints: mintStub,
sender: sendingStub,
recipient: receiptStub,
};
const GET_NEIGHBOURS_URL = process.env.REACT_APP_GET_NEIGHBOURS_URL ?? "";
const MONGODB_API_URL = process.env.REACT_APP_MONGODB_API_URL ?? "";
const MONGODB_READ_TOKEN = process.env.REACT_APP_MONGODB_READ_TOKEN ?? "";
const buildTransferRecord = (transfer: TransferResponse): Transfer => ({
timestamp: new Date(transfer.timestamp),
sender: new PublicKey(transfer.sender),
recipient: new PublicKey(transfer.recipient),
amount: transfer.amount,
});
const buildMintRecord = (mint: MintResponse): Mint => ({
timestamp: new Date(mint.timestamp),
recipient: new PublicKey(mint.recipient),
sender: mint.sender !== undefined ? new PublicKey(mint.sender) : undefined,
amount: mint.amount,
});

const fromRawNeighbourEntry = (
rawEntry: RawNeighbourEntry
Expand All @@ -54,8 +26,12 @@ export const getNeighbours = async (
fetch(`${GET_NEIGHBOURS_URL}/${address.toBase58()}?depth=${depth}`)
.then(async (resp) => resp.json() as Promise<RawGetNeighboursResponse>)
.then((rawResponse) => ({
firstTransfer: new Date(rawResponse.firstTransfer),
lastTransfer: new Date(rawResponse.lastTransfer),
firstTransfer: rawResponse.firstTransfer
? new Date(rawResponse.firstTransfer)
: null,
lastTransfer: rawResponse.lastTransfer
? new Date(rawResponse.lastTransfer)
: null,
neighbours: {
senderResult: rawResponse.neighbours.senderResult.map(
fromRawNeighbourEntry
Expand All @@ -65,44 +41,3 @@ export const getNeighbours = async (
),
},
}));

const getDBData = async <T>(
collection: "mints" | "transfers",
types: Array<"recipient" | "sender">,
address: PublicKey
): Promise<MongoResponse<T>> => {
if (STUB_DB) {
return (
collection === "mints"
? STUBS.mints
: types.flatMap((type) => STUBS[type])
) as MongoResponse<T>;
}
return fetch(`${MONGODB_API_URL}/action/find`, {
method: "POST",
headers: {
"api-key": MONGODB_READ_TOKEN,
"Content-Type": "application/json",
},
body: JSON.stringify({
dataSource: "Cluster0",
database: "gsol-tracker",
collection,
filter: {
$or: types.map((type) => ({
[type]: address.toString(),
})),
},
}),
}).then(async (resp) => resp.json());
};
export const getAccountMints = async (address: PublicKey): Promise<Mint[]> =>
getDBData<MintResponse>("mints", ["sender", "recipient"], address)
.then((resp) => resp.documents)
.then((mints) => mints.map(buildMintRecord));
export const getAccountTransfers = async (
address: PublicKey
): Promise<Transfer[]> =>
getDBData<TransferResponse>("transfers", ["sender", "recipient"], address)
.then((resp) => resp.documents)
.then((transfers) => transfers.map(buildTransferRecord));
4 changes: 2 additions & 2 deletions packages/app/src/api/forest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export class ForestService {
const parentTreeNode = {
address,
balance: currentBalance + lockedBalance,
startDate: firstTransfer,
mostRecentTransfer: lastTransfer,
startDate: firstTransfer ?? new Date(), // Default to the current date if for some reason the API returned no date
mostRecentTransfer: lastTransfer ?? new Date(),
parents: [],
children: [],
};
Expand Down
22 changes: 0 additions & 22 deletions packages/app/src/api/stubs/mints.json

This file was deleted.

3 changes: 0 additions & 3 deletions packages/app/src/api/stubs/receipts.json

This file was deleted.

46 changes: 0 additions & 46 deletions packages/app/src/api/stubs/sendings.json

This file was deleted.

36 changes: 2 additions & 34 deletions packages/app/src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import { type PublicKey } from "@solana/web3.js";

export interface MintResponse {
timestamp: string;
sender?: string; // the wallet that pays for the mint (assume = the recipient if missing)
recipient: string;
amount: number;
}

export interface TransferResponse {
timestamp: string;
sender: string;
recipient: string;
amount: number;
}

export interface BalanceDetails {
address: PublicKey;
balance: number;
Expand Down Expand Up @@ -56,26 +42,8 @@ export interface RawGetNeighboursResponse {

export interface GetNeighboursResponse {
neighbours: NeighbourResult;
firstTransfer: Date;
lastTransfer: Date;
}

export interface MongoResponse<T> {
documents: T[];
}

export interface Mint {
timestamp: Date;
sender?: PublicKey; // the wallet that pays for the mint (assume = the recipient if missing)
recipient: PublicKey; // the wallet that receives the minted gSOL
amount: number;
}

export interface Transfer {
timestamp: Date;
sender: PublicKey;
recipient: PublicKey;
amount: number;
firstTransfer: Date | null;
lastTransfer: Date | null;
}

export type ParentRelationship = "PARENT_IS_SENDER" | "PARENT_IS_RECIPIENT";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Dialog } from "@headlessui/react";
import { ExclamationTriangleIcon } from "@heroicons/react/24/solid";
import React, { type FC } from "react";
import { type FC } from "react";

import { BaseModal, type ModalProps } from "./";
import { MangroveButton } from "../../../rewards/components/MangroveButton";

const LockWarningModal: FC<ModalProps> = (props) => {
return (
Expand All @@ -28,10 +27,6 @@ const LockWarningModal: FC<ModalProps> = (props) => {
Locked gSOL will be available to unlock after one full epoch (2-3
days).
</p>
<MangroveButton />
<p className="text-md">
To earn a bonus Mangrove NFT, you must lock at least 0.5 gSOL.
</p>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/grow/components/PartnerButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type PartnerProps = PropsWithChildren & { partner: Partner };

const ExternalPartner: FC<PartnerProps> = ({ children, partner }) => (
<a
href={partner.website}
target="_blank"
href={partner.website ?? "#"}
target={partner.website == null ? "_blank" : "_self"}
rel="noreferrer"
className="transition-all cursor-pointer bg-cover bg-blend-multiply bg-center bg-no-repeat hover:scale-105 hover:brightness-105"
style={
Expand All @@ -28,7 +28,7 @@ const ExternalPartner: FC<PartnerProps> = ({ children, partner }) => (

const InternalPartner: FC<PartnerProps> = ({ children, partner }) => (
<Link
to={partner.website}
to={partner.website ?? "#"}
className="transition-all cursor-pointer bg-cover bg-blend-multiply bg-center bg-no-repeat hover:scale-105 hover:brightness-105"
style={
partner.imageUrl !== undefined
Expand Down
1 change: 0 additions & 1 deletion packages/app/src/grow/partners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const partners = [
},
{
name: "Coinable",
website: "https://coinablepay.com/",
imageUrl: "partners/coinable.svg",
},
];
2 changes: 1 addition & 1 deletion packages/app/src/grow/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export type Charity = PlaceholderOrg & {
};

export type Partner = PlaceholderOrg & {
website: string;
website?: string;
internal?: boolean;
};
22 changes: 0 additions & 22 deletions packages/app/src/hub/HubApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import { useCarbon } from "../common/hooks";
import { useForest } from "../common/context/forestContext";
import { useHelp } from "../common/context/HelpContext";
import { AppRoute } from "../Routes";
import { AlertBadge } from "../common/content/Badge";
import { useLockHubDetails } from "./hooks/useLockHubDetails";
import { MangroveIcon } from "../rewards/components/MangroveIcon";

const LINK_CHEVRON_SIZE = 32;

Expand All @@ -37,12 +34,10 @@ const _HubApp: ForwardRefRenderFunction<
const [zenMode, updateZenMode] = useZenMode();
const { myTree } = useForest();
const { totalCarbon } = useCarbon();
const { needsUpgrade: showLockAlert } = useLockHubDetails();

const [showIntro, updateShowIntro] = useState(false);
const [introLeft, updateIntroLeft] = useState(false);
const [showHubNav, updateShowHubNav] = useState(false);
const [showAlerts, updateShowAlerts] = useState(false);

const wasHubNavShown = useRef(false);
const showWalletButton = useMemo(() => {
Expand Down Expand Up @@ -123,21 +118,6 @@ const _HubApp: ForwardRefRenderFunction<
});
}, [active, currentHelpRoute, showHubNav, showWalletButton]);

// show alerts 3s after hub nav is shown
useEffect(() => {
if (!showHubNav) {
updateShowAlerts(false);
return;
}

const timer = setTimeout(() => {
updateShowAlerts(showHubNav);
}, 3000);
return () => {
clearTimeout(timer);
};
}, [showHubNav]);

return (
<div
className={clx(
Expand Down Expand Up @@ -266,8 +246,6 @@ const _HubApp: ForwardRefRenderFunction<
<Link to="/lock" className="block w-full mt-4 leading-none">
<div className="relative inline-block">
<span className="text-2xl">Lock</span>
{showLockAlert && <AlertBadge />}
{showAlerts && <MangroveIcon />}
</div>
<br />
<IoChevronDownOutline
Expand Down
4 changes: 0 additions & 4 deletions packages/app/src/hub/components/HubIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { WalletMultiButton } from "@solana/wallet-adapter-react-ui";
import { type FC } from "react";

import { CarbonRecovered, LogoIcon, LogoText } from "../../common/components";
import { MangroveButton } from "../../rewards/components/MangroveButton";

const HubIntro: FC<{
show: boolean;
Expand Down Expand Up @@ -86,9 +85,6 @@ const HubIntro: FC<{
<WalletMultiButton className="!bg-green hover:!bg-green-light !text-white">
Start reducing CO<sub>2</sub>&nbsp;emissions
</WalletMultiButton>
<div className="mt-6">
<MangroveButton />
</div>
<CarbonRecovered />
</Transition.Child>
</Transition>
Expand Down
Loading

1 comment on commit c2da628

@vercel
Copy link

@vercel vercel bot commented on c2da628 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

app – ./

app-sunrise-stake.vercel.app
app-git-main-sunrise-stake.vercel.app
app.sunrisestake.com

Please sign in to comment.