Skip to content

Commit

Permalink
Merge pull request #274 from sunrise-stake/develop
Browse files Browse the repository at this point in the history
0.7.4 ReGenerOsa and Client ESM module update
  • Loading branch information
dankelleher authored Jul 12, 2023
2 parents 7d18c8f + 6a64cf4 commit 0c3e7b6
Show file tree
Hide file tree
Showing 78 changed files with 8,632 additions and 152 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extends:
- plugin:prettier/recommended
plugins:
- prettier
- file-extension-in-import-ts
ignorePatterns:
- "**/types/sunrise_stake.ts"
parser: "@typescript-eslint/parser"
Expand All @@ -20,3 +21,13 @@ rules:
"@typescript-eslint/return-await":
- error
- in-try-catch
# "import/extensions":
# - error
# - ignorePackages
# "n/file-extension-in-import":
# - error
# - tryExtensions:
# - ".js"
# - ".json"
"file-extension-in-import-ts/file-extension-in-import-ts":
- error
Binary file removed doc/accruing_yield_white.png
Binary file not shown.
Binary file removed doc/rebalancing_white.png
Binary file not shown.
Binary file removed doc/stake.gif
Binary file not shown.
Binary file removed doc/staking_white_without_comments.png
Binary file not shown.
Binary file removed doc/unstaking_white_without_comments.png
Binary file not shown.
Binary file removed doc/yield_controller_white_without_comments.png
Binary file not shown.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
"build": "yarn workspaces run build",
"app:build": "yarn workspace @sunrisestake/app build",
"app:start": "yarn workspace @sunrisestake/app start",
"report:mainnet": "cross-env REACT_APP_SOLANA_NETWORK=mainnet-beta yarn ts-node packages/scripts/get.ts",
"report:devnet": "cross-env REACT_APP_SOLANA_NETWORK=devnet yarn ts-node packages/scripts/get.ts",
"rebalance:mainnet": "cross-env REACT_APP_SOLANA_NETWORK=mainnet-beta yarn ts-node packages/scripts/rebalance.ts"
"report:mainnet": "cross-env REACT_APP_SOLANA_NETWORK=mainnet-beta yarn ts-node-esm -P packages/client/tsconfig.json packages/scripts/get.ts",
"report:devnet": "cross-env REACT_APP_SOLANA_NETWORK=devnet yarn ts-node-esm packages/scripts/get.ts",
"updateEpochReport:mainnet": "cross-env REACT_APP_SOLANA_NETWORK=mainnet-beta yarn ts-node-esm packages/scripts/updateEpochReport.ts",
"rebalance:mainnet": "cross-env REACT_APP_SOLANA_NETWORK=mainnet-beta yarn ts-node-esm packages/scripts/rebalance.ts"
},
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
Expand All @@ -36,6 +37,7 @@
"eslint": "^8.33.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-standard-with-typescript": "^34.0.0",
"eslint-plugin-file-extension-in-import-ts": "^1.0.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/app/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ settings:
plugins:
- react
rules:
react/react-in-jsx-scope: "off"

react/react-in-jsx-scope: "off"
file-extension-in-import-ts/file-extension-in-import-ts: "off"
Binary file added packages/app/public/partners/regenerosa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/app/src/grow/charities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ export const charityApps: Charity[] = [
address: new PublicKey("HDRbSHqQRqZLTUrNiGxxLCviPS7Xjf7MgpFeTb6xc6SC"),
website: "https://bloomnetwork.earth/",
},
{
name: "ReGenerOsa",
imageUrl: "partners/regenerosa.png",
address: new PublicKey("9WHWU8n42suhdpoxwYJ3DrJ31FfwZt2Wuy1LMQQ1pZgn"),
website: "https://regenerosa.wixsite.com/regenerosacollective",
},
];
89 changes: 89 additions & 0 deletions packages/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Sunrise Stake Client

A client library for the [Sunrise Stake](https://sunrisestake.com) Solana programs.

## What is Sunrise Stake?

Sunrise Stake is a climate-positive staking platform on Solana, that allows you to stake your SOL
and redirects staking yield to offset your carbon footprint.

For more details, visit [sunrisestake.com](https://sunrisestake.com).

To stake, visit the [app](https://app.sunrisestake.com).

## Quick Start

```shell
yarn add @sunrisestake/client
```

Usage in a browser (React app):

```typescript
import { SunriseStakeClient } from '@sunrisestake/client';
import { AnchorProvider } from "@coral-xyz/anchor";
import { useAnchorWallet, useConnection } from "@solana/wallet-adapter-react";

// inside your app
const connection = useConnection()
const anchorWallet = useAnchorWallet()
const anchorProvider = new AnchorProvider(connection, anchorWallet, {});
const client = SunriseStakeClient.get(provider, 'mainnet-beta');
```

Usage in Node:

```typescript
import { SunriseStakeClient } from '@sunrisestake/client';
import { Connection } from "@solana/web3.js";

const connection = new Connection(/* mainnet RPC endpoint */);
const provider = AnchorProvider.env();
const client = SunriseStakeClient.get(provider, 'mainnet-beta');
```

## Usage

### Details

Almost all information is available via the details() function

```
const details = await client.details()
// user's current staked balance
details.balances.gsolBalance
// total staked balance
details.balances.gsolSupply
// amount of gsol a user has locked
details.lockDetails.amountLocked
// if a user has an impact NFT, this is the mint address
details.impactNFTDetails.mint
```

### Staking

Stake SOL to receive gSOL

```typescript
await client.sendAndConfirmTransaction(
client.deposit(amountInLamports)
);
```

### Unstaking

Unstake gSOL to receive SOL back

```typescript
await client.sendAndConfirmTransaction(
await client.unstake(amountInLamports)
);
```

### Advanced Usage

For more advanced usage view the test files in the [source code](https://github.com/sunrise-stake/app).
1 change: 1 addition & 0 deletions packages/client/doc/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
78 changes: 78 additions & 0 deletions packages/client/doc/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
:root {
--light-hl-0: #795E26;
--dark-hl-0: #DCDCAA;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #A31515;
--dark-hl-2: #CE9178;
--light-hl-3: #AF00DB;
--dark-hl-3: #C586C0;
--light-hl-4: #001080;
--dark-hl-4: #9CDCFE;
--light-hl-5: #008000;
--dark-hl-5: #6A9955;
--light-hl-6: #0000FF;
--dark-hl-6: #569CD6;
--light-hl-7: #0070C1;
--dark-hl-7: #4FC1FF;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
pre, code { background: var(--code-background); }
58 changes: 58 additions & 0 deletions packages/client/doc/assets/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/client/doc/assets/search.js

Large diffs are not rendered by default.

Loading

1 comment on commit 0c3e7b6

@vercel
Copy link

@vercel vercel bot commented on 0c3e7b6 Jul 12, 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-git-main-sunrise-stake.vercel.app
app-sunrise-stake.vercel.app
app.sunrisestake.com

Please sign in to comment.