Skip to content

Commit

Permalink
Fix slow prod site (mirgate to Alchemy and remove some unused deps) (#…
Browse files Browse the repository at this point in the history
…2369)

* Update orderBy to use a non deprecated value

* Switch out endpoint for WS

* Switch to alchemy

* Add env files

* Fix typos

* Add declarations

* Remove unused libraries

* Fix a bunch of type errors

* update api keys

* update more alchemy api keys

---------

Co-authored-by: Guillermo Perez <[email protected]>
  • Loading branch information
sophialittlejohn and gpmayorga authored Aug 13, 2024
1 parent acac0a2 commit d25e5e5
Show file tree
Hide file tree
Showing 27 changed files with 85 additions and 196 deletions.
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.altair
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-altair
REACT_APP_SUBSCAN_URL=https://altair.subscan.io
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=8ed99a9a115349bbbc01dcf3a24edc96
REACT_APP_ONFINALITY_KEY=18704429-288d-4f55-bda8-8b60f4c53b96
REACT_APP_ALCHEMY_KEY=KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ
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
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.catalyst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-catalyst
REACT_APP_SUBSCAN_URL=
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=8ed99a9a115349bbbc01dcf3a24edc96
REACT_APP_ONFINALITY_KEY=18704429-288d-4f55-bda8-8b60f4c53b96
REACT_APP_ALCHEMY_KEY=KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ
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
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-demo-mul
REACT_APP_SUBSCAN_URL=
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=8cd8e043ee8d4001b97a1c37e08fd9dd
REACT_APP_ONFINALITY_KEY=0e1c049f-d876-4e77-a45f-b5afdf5739b2
REACT_APP_ALCHEMY_KEY=KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ
REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_NETWORK=centrifuge
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-demo-mul
REACT_APP_SUBSCAN_URL=
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=8cd8e043ee8d4001b97a1c37e08fd9dd
REACT_APP_ONFINALITY_KEY=0e1c049f-d876-4e77-a45f-b5afdf5739b2
REACT_APP_ALCHEMY_KEY=KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ
REACT_APP_WHITELISTED_ACCOUNTS=
REACT_APP_NETWORK=centrifuge
REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-developm
REACT_APP_SUBSCAN_URL=
REACT_APP_TINLAKE_NETWORK=goerli
REACT_APP_INFURA_KEY=bf808e7d3d924fbeb74672d9341d0550
REACT_APP_ONFINALITY_KEY=
REACT_APP_ALCHEMY_KEY=KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ
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
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.ff-prod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-multicha
REACT_APP_SUBSCAN_URL=https://centrifuge.subscan.io
REACT_APP_TINLAKE_NETWORK=mainnet
REACT_APP_INFURA_KEY=8ed99a9a115349bbbc01dcf3a24edc96
REACT_APP_ONFINALITY_KEY=18704429-288d-4f55-bda8-8b60f4c53b96
REACT_APP_ALCHEMY_KEY=KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ
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
Expand Down
4 changes: 2 additions & 2 deletions centrifuge-app/.env-config/.env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_COLLATOR_WSS_URL=wss://centrifuge-parachain.api.onfinality.io/public-ws
REACT_APP_COLLATOR_WSS_URL=wss://apps.fullnode.centrifuge.io
REACT_APP_DEFAULT_UNLIST_POOLS=false
REACT_APP_FAUCET_URL=
REACT_APP_IPFS_GATEWAY=https://centrifuge.mypinata.cloud/
Expand All @@ -12,7 +12,7 @@ REACT_APP_SUBQUERY_URL=https://api.subquery.network/sq/centrifuge/pools-multicha
REACT_APP_SUBSCAN_URL=https://centrifuge.subscan.io
REACT_APP_TINLAKE_NETWORK=mainnet
REACT_APP_INFURA_KEY=8ed99a9a115349bbbc01dcf3a24edc96
REACT_APP_ONFINALITY_KEY=84bb59f4-05cc-440b-8fd4-7917623a90c6
REACT_APP_ALCHEMY_KEY=KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ
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
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ImportMetaEnv {
REACT_APP_ONBOARDING_API_URL: string
REACT_APP_TINLAKE_NETWORK: 'goerli' | 'mainnet'
REACT_APP_INFURA_KEY: string
REACT_APP_ONFINALITY_KEY: string
REACT_APP_ALCHEMY_KEY: string
REACT_APP_WALLETCONNECT_ID: string
REACT_APP_PRIME_IPFS_HASH: string
}
3 changes: 0 additions & 3 deletions centrifuge-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
"@makerdao/multicall": "^0.12.0",
"@polkadot/react-identicon": "~3.1.4",
"@styled-system/css": "^5.1.5",
"@styled-system/should-forward-prop": "^5.1.5",
"@subwallet/wallet-connect": "^0.2.6",
"@web3modal/standalone": "^2.4.2",
"bn.js": "^5.2.1",
"formik": "^2.4.5",
"merkletreejs": "^0.3.11",
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/PoolFees/EditFeesDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const EditFeesDrawer = ({ onClose, isOpen }: ChargeFeesProps) => {
})
.map((fee) => {
const destination = isEvmAddress(fee.receivingAddress)
? evmToSubstrateAddress(fee.receivingAddress, chainId)
? evmToSubstrateAddress(fee.receivingAddress, chainId!)
: fee.receivingAddress
return {
poolId,
Expand Down
22 changes: 12 additions & 10 deletions centrifuge-app/src/components/PoolOverview/Cashflows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,18 @@ export const Cashflows = () => {
<Text fontSize="18px" fontWeight="500">
Cashflows
</Text>
<AnchorButton
href={csvUrl}
download={`pool-cashflow-data-${poolId}.csv`}
variant="secondary"
icon={IconDownload}
small
target="_blank"
>
Download
</AnchorButton>
{csvUrl && (
<AnchorButton
href={csvUrl}
download={`pool-cashflow-data-${poolId}.csv`}
variant="secondary"
icon={IconDownload}
small
target="_blank"
>
Download
</AnchorButton>
)}
</Shelf>
<CashflowsChart poolStates={truncatedPoolStates} pool={pool} />
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Report/AssetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export function AssetList({ pool }: { pool: Pool }) {
align: col.align,
header: col.sortable ? <SortableTableHeader label={col.header} /> : col.header,
sortKey: col.sortable ? `value[${index}]` : undefined,
cell: (row: TableDataRow) => {
cell: (row: TableDataRow & { id: string }) => {
const assetId = row?.id?.split('-')[1]
return col.header === 'Name' ? (
<Text as="span" variant="body3">
Expand Down
3 changes: 3 additions & 0 deletions centrifuge-app/src/components/Report/AssetTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export function AssetTransactions({ pool }: { pool: Pool }) {
Object.fromEntries(columnConfig.map((col, index) => [col.header, `"${values[index]}"`]))
)
const dataUrl = getCSVDownloadUrl(formatted)
if (!dataUrl) {
throw new Error('Failed to generate CSV')
}

setCsvData({
dataUrl,
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Report/BalanceSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ export function BalanceSheet({ pool }: { pool: Pool }) {

const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to generate CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-balance-sheet-${formatDate(startDate, {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Report/CashflowStatement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ export function CashflowStatement({ pool }: { pool: Pool }) {

const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to generate CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-cash-flow-statement-${formatDate(startDate, {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Report/FeeTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export function FeeTransactions({ pool }: { pool: Pool }) {
)
const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to generate CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-fee-transactions-${formatDate(startDate, {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Report/InvestorTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ export function InvestorTransactions({ pool }: { pool: Pool }) {

const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to create CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-investor-transactions-${formatDate(startDate, {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Report/OracleTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export function OracleTransactions({ pool }: { pool: Pool }) {
)
const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to create CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-oracle-transactions-${formatDate(startDate, {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Report/PoolBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ export function PoolBalance({ pool }: { pool: Pool }) {

const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to create CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-pool-balance-${formatDate(startDate, {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Report/ProfitAndLoss.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ export function ProfitAndLoss({ pool }: { pool: Pool }) {

const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to create CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-profit-and-loss-${formatDate(startDate, {
Expand Down
6 changes: 5 additions & 1 deletion centrifuge-app/src/components/Report/TokenPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ export function TokenPrice({ pool }: { pool: Pool }) {

const dataUrl = getCSVDownloadUrl(formatted)

if (!dataUrl) {
throw new Error('Failed to create CSV')
}

setCsvData({
dataUrl,
fileName: `${pool.id}-token-price-${formatDate(startDate, {
Expand All @@ -259,7 +263,7 @@ export function TokenPrice({ pool }: { pool: Pool }) {

return () => {
setCsvData(undefined)
URL.revokeObjectURL(dataUrl)
URL.revokeObjectURL(dataUrl || '')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [priceRecords])
Expand Down
1 change: 0 additions & 1 deletion centrifuge-app/src/components/Report/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export type TableDataRow = {
name: string
value: (string | number | JSX.Element | Decimal | undefined)[]
heading?: boolean
id: string | undefined
}

export function ReportComponent({ pool }: { pool: Pool }) {
Expand Down
12 changes: 6 additions & 6 deletions centrifuge-app/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,18 @@ const CENTRIFUGE: EnvironmentConfig = {
}

const ethNetwork = import.meta.env.REACT_APP_TINLAKE_NETWORK || 'mainnet'
const onfinalityKey = import.meta.env.REACT_APP_ONFINALITY_KEY
const alchemyKey = import.meta.env.REACT_APP_ALCHEMY_KEY

const goerliConfig = {
rpcUrl: `https://eth-goerli.api.onfinality.io/rpc?apikey=${onfinalityKey}`,
rpcUrl: `https://eth-sepolia.g.alchemy.com/v2/${alchemyKey}`,
chainId: 5,
poolRegistryAddress: '0x5ba1e12693dc8f9c48aad8770482f4739beed696',
tinlakeUrl: 'https://goerli.staging.tinlake.cntrfg.com/',
poolsHash: 'QmQe9NTiVJnVcb4srw6sBpHefhYieubR7v3J8ZriULQ8vB', // TODO: add registry to config and fetch poolHash
blockExplorerUrl: 'https://goerli.etherscan.io',
}
const mainnetConfig = {
rpcUrl: `https://eth.api.onfinality.io/rpc?apikey=${onfinalityKey}`,
rpcUrl: `https://eth-mainnet.g.alchemy.com/v2/${alchemyKey}`,
chainId: 1,
poolRegistryAddress: '0x5ba1e12693dc8f9c48aad8770482f4739beed696',
tinlakeUrl: 'https://tinlake.centrifuge.io',
Expand Down Expand Up @@ -171,7 +171,7 @@ export const evmChains: EvmChains = {
decimals: 18,
},
blockExplorerUrl: 'https://etherscan.io/',
urls: [`https://eth.api.onfinality.io/rpc?apikey=${onfinalityKey}`],
urls: [`https://eth-mainnet.g.alchemy.com/v2/${alchemyKey}`],
iconUrl: ethereumLogo,
isTestnet: false,
},
Expand All @@ -183,15 +183,15 @@ export const evmChains: EvmChains = {
decimals: 18,
},
blockExplorerUrl: 'https://goerli.etherscan.io/',
urls: [`https://eth-goerli.api.onfinality.io/rpc?apikey=${onfinalityKey}`],
urls: [`https://eth-sepolia.g.alchemy.com/v2/${alchemyKey}`],
iconUrl: goerliLogo,
isTestnet: true,
},
11155111: {
name: 'Ethereum Sepolia',
nativeCurrency: { name: 'Sepolia Ether', symbol: 'sepETH', decimals: 18 },
blockExplorerUrl: 'https://sepolia.etherscan.io/',
urls: [`https://eth-sepolia.api.onfinality.io/rpc?apikey=${onfinalityKey}`],
urls: [`https://eth-sepolia.g.alchemy.com/v2/${alchemyKey}`],
iconUrl: sepoliaLogo,
isTestnet: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,7 @@ export function EpochAndTranches() {
<Stack gap={2}>
<Text variant="heading3">Tranches</Text>

{isEditing ? (
<TrancheInput currency={pool?.currency.symbol} isUpdating />
) : (
<DataTable data={trancheData} columns={columns} />
)}
{isEditing ? <TrancheInput isUpdating /> : <DataTable data={trancheData} columns={columns} />}
</Stack>
</Stack>
</PageSection>
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/utils/tinlake/useTinlakePools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function useTinlakeLoans(poolId: string) {
const loans = await getTinlakeLoans(poolId)
const writeOffPercentages = await getWriteOffPercentages(pool!, loans)

return loans.map((loan, i) => ({
return (loans as any[]).map((loan, i) => ({
asset: {
nftId: loan.nftId,
collectionId: poolId,
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,7 @@ export function getPoolsModule(inst: Centrifuge) {
}
}>(
`query {
poolSnapshots(first: 1000, orderBy: PERIOD_START_ASC) {
poolSnapshots(first: 1000, orderBy: PERIOD_ID_ASC) {
nodes {
netAssetValue
periodId
Expand Down
Loading

0 comments on commit d25e5e5

Please sign in to comment.