Skip to content

Commit

Permalink
Merge branch 'main' of github.com:centrifuge/apps into feat/portfolio…
Browse files Browse the repository at this point in the history
…-page
  • Loading branch information
sophialittlejohn committed Sep 22, 2023
2 parents 73330f7 + 0a38bea commit 8814cf2
Show file tree
Hide file tree
Showing 169 changed files with 4,574 additions and 1,964 deletions.
20 changes: 5 additions & 15 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
# Monorepo for the Centrifuge applications.

## Setup

Make sure you have installed Yarn and NVM.

1. Use Node v14.15.1: `nvm use`
2. Install dependencies: `yarn install`
3. Install `husky`: `yarn postinstall`
4. Add `.env` files with the right environment variables to each project.

It's also recommended to run Prettier automatically in your editor, e.g. using [this VS Code plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).
# Monorepo for the Centrifuge applications

## Preparing Envs (e.g when the dev chain data is reset)

Expand All @@ -24,9 +13,10 @@ It's also recommended to run Prettier automatically in your editor, e.g. using [
Setup pure proxy to sign transactions (whitelisting & transfer tokens).

1. Run `/initProxies` to create the pure proxy, fund it, and give it sufficient permissions
2. Copy the resulting pure proxy address and add it to the env varibles: `MEMBERLIST_ADMIN_PURE_PROXY` (onboarding-api) and `REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY` (centrifuge-app)
3. Enable onboarding for each new pool under /issuer/<poolId>/investors
1. Use sudo in polkadot UI to give Alice enough currency to distribute (tokens.setBalance()). For currencyId select ForeignAsset and submit the transacton once with ForeignAsset 1 and once with ForeignAsset 2
2. Run `/initProxies` to create the pure proxy, fund it, and give it sufficient permissions
3. Copy the resulting pure proxy address and add it to the env varibles: `MEMBERLIST_ADMIN_PURE_PROXY` (onboarding-api) and `REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY` (centrifuge-app)
4. Enable onboarding for each new pool under /issuer/<poolId>/investors

### Asset Originator POD Access

Expand Down
5 changes: 5 additions & 0 deletions .github/actions/prepare-deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ runs:
echo "function_name=${{ inputs.app_base_name }}-demo" >> $GITHUB_OUTPUT
echo "front_url=${{ inputs.app_base_name }}-demo.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=demo" >> $GITHUB_OUTPUT
elif ${{ contains(inputs.deploy_to, 'moonbeam-alpha') }}; then
# moonbeam-alpha
echo "function_name=${{ inputs.app_base_name }}-moonbeam-alpha" >> $GITHUB_OUTPUT
echo "front_url=${{ inputs.app_base_name }}-moonbeam-alpha.k-f.dev" >> $GITHUB_OUTPUT
echo "env_name=moonbeam-alpha" >> $GITHUB_OUTPUT
elif ${{ github.ref == 'refs/heads/main' }}; then
# DEV
echo "function_name=${{ inputs.app_base_name }}-dev" >> $GITHUB_OUTPUT
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/moonbeam-alpha-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Moonbeam dev (alpha) deployments (manual)"
on:
push:
branches: main
pull_request:
paths:
- '.github/workflows/moonbeam-alpha-deploy.yml'

jobs:
app-moonbeam-alpha:
uses: ./.github/workflows/centrifuge-app.yml
secrets: inherit
with:
deploy_env: moonbeam-alpha


pinning-moonbeam-alpha:
uses: ./.github/workflows/pinning-api.yml
secrets: inherit
with:
deploy_env: moonbeam-alpha


onboarding-moonbeam-alpha:
uses: ./.github/workflows/onboarding-api.yml
secrets: inherit
with:
deploy_env: moonbeam-alpha

# faucet-moonbeam-alpha:
# uses: ./.github/workflows/faucet-api.yml
# secrets: inherit
# with:
# deploy_env: moonbeam-alpha
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ yarn-error.log
!.env.demo
!.env.catalyst
!.env.production
!.env.moonbeam-alpha
5 changes: 3 additions & 2 deletions centrifuge-app/.env-config/.env.altair
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ REACT_APP_COLLATOR_WSS_URL=wss://fullnode.altair.centrifuge.io
REACT_APP_DEFAULT_NODE_URL=
REACT_APP_DEFAULT_UNLIST_POOLS=false
REACT_APP_FAUCET_URL=''
REACT_APP_IPFS_GATEWAY=https://altair.mypinata.cloud/
REACT_APP_IPFS_GATEWAY=https://centrifuge.mypinata.cloud/
REACT_APP_IS_DEMO=false
REACT_APP_NETWORK=altair
REACT_APP_ONBOARDING_API_URL=https://europe-central2-centrifuge-production-x.cloudfunctions.net/onboarding-api-altair
Expand All @@ -15,5 +15,6 @@ REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=bf808e7d3d924fbeb74672d9341d0550
REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake
3 changes: 2 additions & 1 deletion centrifuge-app/.env-config/.env.catalyst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ REACT_APP_COLLATOR_WSS_URL=wss://fullnode.catalyst.cntrfg.com
REACT_APP_DEFAULT_NODE_URL=
REACT_APP_DEFAULT_UNLIST_POOLS=true
REACT_APP_FAUCET_URL=
REACT_APP_IPFS_GATEWAY=https://altair.mypinata.cloud/
REACT_APP_IPFS_GATEWAY=https://centrifuge.mypinata.cloud/
REACT_APP_IS_DEMO=false
REACT_APP_NETWORK=centrifuge
REACT_APP_ONBOARDING_API_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/onboarding-api-catalyst
Expand All @@ -17,3 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=4bo2vNkwZtr2PuqppWwqya6dPC8MzxqZ4kgnAoTZyKo9Kxq8
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake
3 changes: 2 additions & 1 deletion centrifuge-app/.env-config/.env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ REACT_APP_COLLATOR_WSS_URL=wss://fullnode.algol.cntrfg.com/public-ws
REACT_APP_DEFAULT_NODE_URL=https://pod.algol.k-f.dev
REACT_APP_DEFAULT_UNLIST_POOLS=true
REACT_APP_FAUCET_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/faucet-api-demo
REACT_APP_IPFS_GATEWAY=https://altair.mypinata.cloud/
REACT_APP_IPFS_GATEWAY=https://centrifuge.mypinata.cloud/
REACT_APP_IS_DEMO=true
REACT_APP_ONBOARDING_API_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/onboarding-api-demo
REACT_APP_PINNING_API_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/pinning-api-demo
Expand All @@ -17,3 +17,4 @@ REACT_APP_NETWORK=centrifuge
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALwmJutBq95s41U9fWnoApCUgvPqPGTh1GSmFnQh5f9fWo93
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake
5 changes: 3 additions & 2 deletions centrifuge-app/.env-config/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ REACT_APP_COLLATOR_WSS_URL=wss://fullnode.development.cntrfg.com
REACT_APP_DEFAULT_NODE_URL=https://pod-development.k-f.dev
REACT_APP_DEFAULT_UNLIST_POOLS=false
REACT_APP_FAUCET_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/faucet-api-dev
REACT_APP_IPFS_GATEWAY=https://altair.mypinata.cloud/
REACT_APP_IPFS_GATEWAY=https://centrifuge.mypinata.cloud/
REACT_APP_IS_DEMO=false
REACT_APP_NETWORK=centrifuge
REACT_APP_ONBOARDING_API_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/onboarding-api-dev
Expand All @@ -14,6 +14,7 @@ REACT_APP_SUBSCAN_URL=
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=bf808e7d3d924fbeb74672d9341d0550
REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kAKfp33p1SHRq6d1BMtGndP7Cek6pH6oZKKUoA7wJXRUqf6FY
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kAJ27w29x7gHM75xajP2yXVLjVBaKmmUTxHwgRuCoAcWaoEiz
3 changes: 2 additions & 1 deletion centrifuge-app/.env-config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ REACT_APP_COLLATOR_WSS_URL=wss://fullnode.development.cntrfg.com
REACT_APP_DEFAULT_NODE_URL=https://pod.development.cntrfg.com
REACT_APP_DEFAULT_UNLIST_POOLS=
REACT_APP_FAUCET_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/faucetDev
REACT_APP_IPFS_GATEWAY=https://altair.mypinata.cloud/
REACT_APP_IPFS_GATEWAY=https://centrifuge.mypinata.cloud/
REACT_APP_IS_DEMO=false
REACT_APP_NETWORK=altair
REACT_APP_ONBOARDING_API_URL=https://europe-central2-centrifuge-fargate-apps-dev.cloudfunctions.net/onboarding
Expand All @@ -17,3 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS=''
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake
20 changes: 20 additions & 0 deletions centrifuge-app/.env-config/.env.moonbeam-alpha
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
REACT_APP_COLLATOR_WSS_URL=wss://fullnode.moonbase-dev.cntrfg.com/public-ws
REACT_APP_DEFAULT_NODE_URL=https://pod.moonbeam-alpha.k-f.dev
REACT_APP_DEFAULT_UNLIST_POOLS=true
REACT_APP_FAUCET_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/faucet-api-moonbean-alpha
REACT_APP_IPFS_GATEWAY=https://centrifuge.mypinata.cloud/
REACT_APP_IS_DEMO=true
REACT_APP_ONBOARDING_API_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/onboarding-api-moonbean-alpha
REACT_APP_PINNING_API_URL=https://europe-central2-peak-vista-185616.cloudfunctions.net/pinning-api-moonbean-alpha
REACT_APP_POOL_CREATION_TYPE=immediate
REACT_APP_RELAY_WSS_URL=wss://frag-moonbase-relay-rpc-ws.g.moonbase.moonbeam.network
REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-demo
REACT_APP_SUBSCAN_URL=
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=bf808e7d3d924fbeb74672d9341d0550
REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_NETWORK=centrifuge
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALwmJutBq95s41U9fWnoApCUgvPqPGTh1GSmFnQh5f9fWo93
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake
1 change: 1 addition & 0 deletions centrifuge-app/.env-config/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS=''
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-mainnet-production/latest.json
REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19
REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a
REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake
49 changes: 32 additions & 17 deletions centrifuge-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,50 @@

## Data and UI Architecture

- `centrifuge-js`: fetch data from the chain or subquery.
- `fabric`: all design system elements (run storybook in fabric to see everything available).
UI

## Commands
- `centrifuge-js`: library to interact with the Centrifuge chain and subquery
- `fabric`: design system elements and components
- `centrifuge-react`: reusable React component and hooks (wallets, queries, transactions)

#### `yarn start`
Cloud functions

Running `yarn start` will start the following processes:
Start a development server that watches the different workspace modules and the react app (using Vite)
- `onboarding-api`: KYC/KYB and investor whitelisting
- `faucet-api`: dev chain faucet
- `pinning-api`: pin documents to Pinata (IPFS)

#### `yarn start:deps`
It will start a development mode on the dependencies (`fabric` & `centrifuge-js`), to allow HMR to work when making changes
Indexing

#### `yarn build` or `yarn build --mode $ENV` or `yarn build immutable`
- [pools-subql](https://github.com/centrifuge/pools-subql): subquery to index pools and assets

Build all dependencies, functions, and app with libraries.
## Development

## Other useful information
### Prerequisites

- node v16
- yarn

This app uses [`vite`](https://vitejs.dev/guide/) but serve, build and bundle.
### Setup

To reference env variables in code please use the vite standard `import.meta.env.ENV_VARIABLE`.
1. copy [.env.development](./.env-config/env.development) to `.env.development.local`
2. Install modules:
```bash
$ yarn
```
3. Start the development server:
```bash
$ yarn start
```
4. Open [http://localhost:3000](http://localhost:3000) in your browser

## Other useful information

Check the Vite configuration file to find where we keep env file. Vite automatically grabs the right file when building with the `--mode` flag. [More info here](https://vitejs.dev/guide/env-and-mode.html)
This app uses [`vite`](https://vitejs.dev/guide/) to serve, build and bundle.

> in Netlify functions you still need to reference env variables with `process.env`
To reference env variables in code please use the viste standard `import.meta.env.ENV_VARIABLE`.

## Deployments

Up-to-date info in k-f's Knowledge Base:
Up-to-date info in k-f's Knowledge Base:

https://centrifuge.hackmd.io/MFsnRldyQSa4cadx11OtVg?view#Environments-amp-Deployments
https://centrifuge.hackmd.io/MFsnRldyQSa4cadx11OtVg?view#Environments-amp-Deployments
92 changes: 92 additions & 0 deletions centrifuge-app/src/components/CardTotalValueLocked.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { Box, Stack, Text, TextWithPlaceholder, Tooltip } from '@centrifuge/fabric'
import * as React from 'react'
import { useTheme } from 'styled-components'
import { config } from '../config'
import { formatDate } from '../utils/date'
import { Dec } from '../utils/Decimal'
import { formatBalance } from '../utils/formatting'
import { useListedPools } from '../utils/useListedPools'
import { DataPoint, TotalValueLocked } from './Charts/TotalValueLocked'
import { tooltipText } from './Tooltips'

export function CardTotalValueLocked() {
const { colors } = useTheme()
const [hovered, setHovered] = React.useState<DataPoint | undefined>(undefined)
const [, listedTokens] = useListedPools()

const chartHeight = 100
const balanceProps = {
as: 'strong',
fontSize: [28, 32],
}
const headingProps = {
as: 'h2',
variant: 'heading3',
}

const totalValueLocked = React.useMemo(() => {
return (
listedTokens
?.map((tranche) => ({
valueLocked: tranche.totalIssuance
.toDecimal()
.mul(tranche.tokenPrice?.toDecimal() ?? Dec(0))
.toNumber(),
}))
.reduce((prev, curr) => prev.add(curr.valueLocked), Dec(0)) ?? Dec(0)
)
}, [listedTokens])

return (
<Box
role="article"
borderRadius="card"
borderStyle="solid"
borderWidth={1}
borderColor="borderSecondary"
p={3}
pb={chartHeight * 0.6}
position="relative"
style={{
boxShadow: `0px 3px 2px -2px ${colors.borderPrimary}`,
}}
>
<Stack style={{ pointerEvents: 'none' }}>
{hovered ? (
<>
<Text {...headingProps}>
TVL on{' '}
<time dateTime={new Date(hovered.dateInMilliseconds).toISOString()}>
{formatDate(hovered.dateInMilliseconds)}
</time>
</Text>
<Text {...balanceProps}>{formatBalance(Dec(hovered?.tvl || 0), config.baseCurrency)}</Text>
</>
) : (
<>
<Tooltip body={tooltipText.tvl.body} style={{ pointerEvents: 'auto' }}>
<Text {...headingProps}>{tooltipText.tvl.label}</Text>
</Tooltip>
<TextWithPlaceholder {...balanceProps} isLoading={!totalValueLocked}>
{formatBalance(Dec(totalValueLocked || 0), config.baseCurrency)}
</TextWithPlaceholder>
</>
)}
</Stack>

<Box
as="figure"
position="absolute"
right={0}
bottom={0}
width="100%"
height={chartHeight}
overflow="hidden"
borderBottomRightRadius="card"
borderBottomLeftRadius="card"
>
<TotalValueLocked setHovered={setHovered} chainTVL={totalValueLocked} />
</Box>
</Box>
)
}
Loading

0 comments on commit 8814cf2

Please sign in to comment.