Skip to content

Commit 5a19e84

Browse files
authored
Merge pull request #32 from mars-protocol/v1.5.0
v1.5.0
2 parents b40979d + 7c20496 commit 5a19e84

File tree

109 files changed

+5126
-3434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+5126
-3434
lines changed

.env

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
NEXT_PUBLIC_NETWORK=mainnet
2-
NEXT_PUBLIC_STAGE=production

.env.example

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
NEXT_PUBLIC_NETWORK=mainnet
2-
NEXT_PUBLIC_RPC=https://rpc-osmosis.blockapsis.com
3-
NEXT_PUBLIC_GQL=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql
4-
NEXT_PUBLIC_REST=https://lcd-osmosis.blockapsis.com
1+
# OSMOSIS-1 #
2+
NEXT_PUBLIC_OSMOSIS_RPC=https://rpc-osmosis.blockapsis.com
3+
NEXT_PUBLIC_OSMOSIS_REST=https://lcd-osmosis.blockapsis.com
4+
NEXT_PUBLIC_OSMOSIS_GQL=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql
5+
6+
# OSMO-TEST-5 #
7+
NEXT_PUBLIC_OSMOSIS_TEST_RPC=https://rpc.osmotest5.osmosis.zone
8+
NEXT_PUBLIC_OSMOSIS_TEST_REST=https://lcd.osmotest5.osmosis.zone
9+
NEXT_PUBLIC_OSMOSIS_TEST_GQL=https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql
10+
11+
# PION-1 #
12+
NEXT_PUBLIC_NEUTRON_TEST_RPC=https://rpc-palvus.pion-1.ntrn.tech/
13+
NEXT_PUBLIC_NEUTRON_TEST_REST=https://rest-palvus.pion-1.ntrn.tech/
14+
NEXT_PUBLIC_NEUTRON_TEST_GQL=https://testnet-neutron-gql.marsprotocol.io/graphql

.env.production

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# DO NOT EDIT THIS FILE WHEN USING DOCKER
22
# These values are used to replace the values in the built app,
33
# you should pass environment variables as defined in README.md
4-
NEXT_PUBLIC_NETWORK=APP_NEXT_NETWORK
5-
NEXT_PUBLIC_RPC=APP_NEXT_RPC
6-
NEXT_PUBLIC_GQL=APP_NEXT_GQL
7-
NEXT_PUBLIC_REST=APP_NEXT_REST
4+
# OSMOSIS-1 #
5+
NEXT_PUBLIC_OSMOSIS_RPC=APP_NEXT_OSMOSIS_RPC
6+
NEXT_PUBLIC_OSMOSIS_REST=APP_NEXT_OSMOSIS_REST
7+
NEXT_PUBLIC_OSMOSIS_GQL=APP_NEXT_OSMOSIS_GQL
8+
9+
# OSMO-TEST-5 #
10+
NEXT_PUBLIC_OSMOSIS_TEST_RPC=APP_NEXT_OSMOSIS_TEST_RPC
11+
NEXT_PUBLIC_OSMOSIS_TEST_REST=APP_NEXT_OSMOSIS_TEST_REST
12+
NEXT_PUBLIC_OSMOSIS_TEST_GQL=APP_NEXT_OSMOSIS_TEST_GQL
13+
14+
# PION-1 #
15+
NEXT_PUBLIC_NEUTRON_TEST_RPC=APP_NEXT_NEUTRON_TEST_RPC
16+
NEXT_PUBLIC_NEUTRON_TEST_REST=APP_NEXT_NEUTRON_TEST_REST
17+
NEXT_PUBLIC_NEUTRON_TEST_GQL=APP_NEXT_NEUTRON_TEST_GQL

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ We allow the use of environment variables to be passed to the Docker container t
3131

3232
|Variable|Description|Default|
3333
|--------|-----------|-------|
34-
|NETWORK|Flag for mainnet or testnet|mainnet|
35-
|URL_GQL|The Hive GraphQL endpoint to use|https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql|
36-
|URL_REST|The node REST endpoint to use|https://lcd-osmosis.blockapsis.com|
37-
|URL_RPC|The node RPC endpoint to use|https://rpc-osmosis.blockapsis.com|
34+
|URL_OSMOSIS_GQL|The Osmosis Hive GraphQL endpoint to use|https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql|
35+
|URL_OSMOSIS_REST|The Osmosis node REST endpoint to use|https://lcd-osmosis.blockapsis.com|
36+
|URL_OSMOSIS_RPC|The Osmosis node RPC endpoint to use|https://rpc-osmosis.blockapsis.com|
37+
|URL_OSMOSIS_TEST_GQL|The Osmosis Testnet Hive GraphQL endpoint to use|https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql|
38+
|URL_OSMOSIS_TEST_REST|The Osmosis Testnet node REST endpoint to use|https://lcd.osmotest5.osmosis.zone|
39+
|URL_OSMOSIS_TEST_RPC|The Osmosis Testnet node RPC endpoint to use|https://rpc.osmotest5.osmosis.zone|
40+
|URL_NEUTRON_TEST_GQL|The Neutron Testnet Hive GraphQL endpoint to use|https://testnet-neutron-gql.marsprotocol.io/graphql|
41+
|URL_NEUTRON_TEST_REST|The Neutron Testnet node REST endpoint to use|https://rest-palvus.pion-1.ntrn.tech|
42+
|URL_NEUTRON_TEST_RPC|The Neutron Testnet node RPC endpoint to use|https://rpc-palvus.pion-1.ntrn.tech|
3843

3944
**Sample Docker run command**
4045

@@ -43,9 +48,15 @@ This command will start the container in interactive mode with port 3000 bound t
4348
```sh
4449
docker run -it -p 3000:3000 \
4550
-e NETWORK=mainnet \
46-
-e URL_GQL=https://your-hive-endpoint.com \
47-
-e URL_REST=https://your-rest-endpoint.com \
48-
-e URL_RPC=https://your-rpc-endpoint.com marsprotocol/interface:latest
51+
-e URL_OSMOSIS_GQL=https://your-osmosis-hive-endpoint.com \
52+
-e URL_OSMOSIS_REST=https://your-osmosis-rest-endpoint.com \
53+
-e URL_OSMOSIS_RPC=https://your-osmosis-rpc-endpoint.com \
54+
-e URL_OSMOSIS_TEST_GQL=https://your-osmosis-testnet-hive-endpoint.com \
55+
-e URL_OSMOSIS_TEST_REST=https://your-osmosis-testnet-rest-endpoint.com \
56+
-e URL_OSMOSIS_TEST_RPC=https://your-osmosis-testnet-rpc-endpoint.com \
57+
-e URL_NEUTRON_TEST_GQL=https://your-neutron-testnet-hive-endpoint.com \
58+
-e URL_NEUTRON_TEST_REST=https://your-neutron-testnet-rest-endpoint.com \
59+
-e URL_NEUTRON_TEST_RPC=https://your-neutron-testnet-rpc-endpoint.com marsprotocol/interface:latest
4960
```
5061

5162
## 3. Text and translations

entrypoint.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ set +x
44
nextFolder='/app/.next'
55
# create the config file from environment variables
66
envFilename='override.conf'
7-
echo "APP_NEXT_NETWORK=$NETWORK" >> $envFilename
8-
echo "APP_NEXT_GQL=$URL_GQL" >> $envFilename
9-
echo "APP_NEXT_REST=$URL_REST" >> $envFilename
10-
echo "APP_NEXT_RPC=$URL_RPC" >> $envFilename
7+
echo "APP_NEXT_OSMOSIS_RPC=$URL_OSMOSIS_RPC" >> $envFilename
8+
echo "APP_NEXT_OSMOSIS_REST=$URL_OSMOSIS_REST" >> $envFilename
9+
echo "APP_NEXT_OSMOSIS_GQL=$URL_OSMOSIS_GQL" >> $envFilename
10+
echo "APP_NEXT_OSMOSIS_TEST_RPC=$URL_OSMOSIS_TEST_RPC" >> $envFilename
11+
echo "APP_NEXT_OSMOSIS_TEST_REST=$URL_OSMOSIS_TEST_REST" >> $envFilename
12+
echo "APP_NEXT_OSMOSIS_TEST_GQL=$URL_OSMOSIS_TEST_GQL" >> $envFilename
13+
echo "APP_NEXT_NEUTRON_TEST_RPC=$URL_NEUTRON_TEST_RPC" >> $envFilename
14+
echo "APP_NEXT_NEUTRON_TEST_REST=$URL_NEUTRON_TEST_REST" >> $envFilename
15+
echo "APP_NEXT_NEUTRON_TEST_GQL=$URL_NEUTRON_TEST_GQL" >> $envFilename
1116
function apply_path {
1217
# read all config file
1318
while read line; do

next.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const path = require('path')
44

55
const moduleExports = {
66
reactStrictMode: true,
7-
experimental: { images: { unoptimized: true } },
87
sassOptions: {
98
includePaths: [path.join(__dirname, 'src/styles')],
109
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mars",
33
"homepage": "./",
4-
"version": "1.4.9",
4+
"version": "1.5.0",
55
"license": "SEE LICENSE IN LICENSE FILE",
66
"private": false,
77
"scripts": {
@@ -22,7 +22,7 @@
2222
"@cosmjs/launchpad": "^0.27.1",
2323
"@cosmjs/proto-signing": "^0.30.1",
2424
"@cosmjs/stargate": "^0.30.1",
25-
"@marsprotocol/wallet-connector": "^1.5.8",
25+
"@marsprotocol/wallet-connector": "^1.8.6",
2626
"@material-ui/core": "^4.12.4",
2727
"@material-ui/icons": "^4.11.3",
2828
"@ramonak/react-progress-bar": "^5.0.3",

src/components/common/CircularProgress/CircularProgress.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@ interface Props {
77
color?: string
88
size?: number
99
className?: string
10+
forceAnimation?: boolean
1011
}
1112

12-
export const CircularProgress = ({ color = '#FFFFFF', size = 20, className }: Props) => {
13+
export const CircularProgress = ({
14+
color = '#FFFFFF',
15+
size = 20,
16+
className,
17+
forceAnimation = false,
18+
}: Props) => {
1319
const enableAnimations = useStore((s) => s.enableAnimations)
1420
const borderWidth = `${size / 10}px`
1521
const borderColor = `${color} transparent transparent transparent`
1622
const loaderClasses = classNames(styles.loader, className)
1723

18-
if (!enableAnimations) return <div className={styles.staticLoader}>...</div>
24+
if (!enableAnimations && !forceAnimation) return <div className={styles.staticLoader}>...</div>
1925

2026
return (
2127
<div className={loaderClasses} style={{ width: `${size}px`, height: `${size}px` }}>
Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate'
22
import {
3-
ChainInfoID,
43
getChainInfo,
54
getClient,
65
useWallet,
@@ -9,7 +8,6 @@ import {
98
} from '@marsprotocol/wallet-connector'
109
import { useQueryClient } from '@tanstack/react-query'
1110
import { MARS_SYMBOL } from 'constants/appConstants'
12-
import { NETWORK } from 'constants/env'
1311
import {
1412
useBlockHeight,
1513
useDepositAndDebt,
@@ -20,12 +18,14 @@ import {
2018
useUserDebt,
2119
useUserIcns,
2220
} from 'hooks/queries'
21+
import { usePythVaa } from 'hooks/queries/usePythVaa'
2322
import { useSpotPrice } from 'hooks/queries/useSpotPrice'
2423
import { useUserCollaterals } from 'hooks/queries/useUserCollaterals'
2524
import { ReactNode, useEffect, useState } from 'react'
2625
import useStore from 'store'
2726
import { State } from 'types/enums'
28-
import { Network } from 'types/enums/network'
27+
28+
import { MigrationInProgress } from '../MigrationInProgress/MigrationInProgress'
2929

3030
interface CommonContainerProps {
3131
children: ReactNode
@@ -35,101 +35,110 @@ export const CommonContainer = ({ children }: CommonContainerProps) => {
3535
// ------------------
3636
// EXTERNAL HOOKS
3737
// ---------------
38-
const { recentWallet, simulate, sign, broadcast } = useWallet()
39-
const { status } = useWalletManager()
38+
const { simulate, sign, broadcast } = useWallet()
39+
const { status, connectedWallet } = useWalletManager()
4040
const queryClient = useQueryClient()
4141

42-
const chainInfo = recentWallet?.network
43-
? getChainInfo(recentWallet?.network.chainId as ChainInfoID)
44-
: undefined
45-
const address = status !== WalletConnectionStatus.Connected ? '' : recentWallet?.account.address
46-
4742
const [cosmWasmClient, setCosmWasmClient] = useState<CosmWasmClient | undefined>()
4843

4944
// ------------------
5045
// STORE STATE
5146
// ------------------
52-
const chainID = useStore((s) => s.chainInfo?.chainId)
47+
const assetPricesUSDState = useStore((s) => s.assetPricesUSDState)
48+
const assetPricesUSD = useStore((s) => s.assetPricesUSD)
49+
const chainId = useStore((s) => s.currentNetwork)
5350
const exchangeRates = useStore((s) => s.exchangeRates)
5451
const exchangeRatesState = useStore((s) => s.exchangeRatesState)
55-
const isNetworkLoaded = useStore((s) => s.isNetworkLoaded)
56-
const rpc = useStore((s) => s.chainInfo?.rpc)
52+
const networkConfig = useStore((s) => s.networkConfig)
5753
const marketDeposits = useStore((s) => s.marketDeposits)
5854
const marketInfo = useStore((s) => s.marketInfo)
5955
const marketIncentiveInfo = useStore((s) => s.marketIncentiveInfo)
56+
const migrationInProgress = useStore((s) => s.migrationInProgress)
6057
const redBankState = useStore((s) => s.redBankState)
58+
const rpc = useStore((s) => s.networkConfig.rpcUrl)
6159
const userBalances = useStore((s) => s.userBalances)
6260
const userBalancesState = useStore((s) => s.userBalancesState)
6361
const userDebts = useStore((s) => s.userDebts)
6462
const userDeposits = useStore((s) => s.userDeposits)
6563
const userWalletAddress = useStore((s) => s.userWalletAddress)
6664
const whitelistedAssets = useStore((s) => s.whitelistedAssets)
67-
const loadNetworkConfig = useStore((s) => s.loadNetworkConfig)
6865
const setRedBankAssets = useStore((s) => s.setRedBankAssets)
69-
const setChainInfo = useStore((s) => s.setChainInfo)
70-
const setCurrentNetwork = useStore((s) => s.setCurrentNetwork)
7166
const setLcdClient = useStore((s) => s.setLcdClient)
72-
const setClient = useStore((s) => s.setClient)
67+
const setChainInfo = useStore((s) => s.setChainInfo)
7368
const setUserBalancesState = useStore((s) => s.setUserBalancesState)
7469
const setUserWalletAddress = useStore((s) => s.setUserWalletAddress)
70+
const pythVaa = useStore((s) => s.pythVaa)
7571

7672
// ------------------
7773
// SETTERS
7874
// ------------------
75+
7976
useEffect(() => {
80-
if (NETWORK === 'mainnet') {
81-
setCurrentNetwork(Network.MAINNET)
77+
if (status !== WalletConnectionStatus.Connected && cosmWasmClient) {
78+
setCosmWasmClient(undefined)
79+
useStore.setState({
80+
client: undefined,
81+
creditManagerClient: undefined,
82+
accountNftClient: undefined,
83+
userWalletAddress: '',
84+
})
8285
}
83-
loadNetworkConfig()
84-
}, [loadNetworkConfig, setCurrentNetwork])
86+
}, [status, cosmWasmClient])
8587

8688
useEffect(() => {
87-
if (!chainInfo) return
89+
const chainInfo = getChainInfo(chainId, {
90+
rpc: networkConfig.rpcUrl,
91+
rest: networkConfig.restUrl,
92+
})
8893
setChainInfo(chainInfo)
89-
}, [chainInfo, setChainInfo])
94+
}, [chainId, networkConfig, setChainInfo])
9095

9196
useEffect(() => {
92-
setUserWalletAddress(address || '')
93-
}, [setUserWalletAddress, address])
97+
if (!connectedWallet || connectedWallet.network.chainId !== chainId) return
98+
setUserWalletAddress(connectedWallet.account.address)
99+
}, [setUserWalletAddress, connectedWallet, chainId])
94100

95101
useEffect(() => {
96-
if (!rpc || !chainID) return
97-
setLcdClient(rpc, chainID)
98-
}, [rpc, chainID, setLcdClient])
102+
if (!rpc || !chainId) return
103+
setLcdClient(rpc, chainId)
104+
}, [rpc, chainId, setLcdClient])
99105

100106
useEffect(() => {
101-
if (userDebts && userDeposits && userBalances) {
107+
if (userBalances) {
102108
setUserBalancesState(State.READY)
103109
} else {
104110
setUserBalancesState(State.ERROR)
105111
}
106112
}, [userDebts, userDeposits, userBalances, setUserBalancesState])
107113

108114
useEffect(() => {
109-
if (!recentWallet) return
115+
if (!connectedWallet || connectedWallet.network.chainId !== chainId) return
110116
if (!cosmWasmClient) {
111117
const getCosmWasmClient = async () => {
112-
const cosmClient = await getClient(recentWallet.network.rpc)
118+
const cosmClient = await getClient(networkConfig.rpcUrl)
113119
setCosmWasmClient(cosmClient)
114120
}
115121

116122
getCosmWasmClient()
117123
return
118124
}
119125

120-
const client = {
121-
broadcast,
122-
cosmWasmClient,
123-
recentWallet,
124-
sign,
125-
simulate,
126-
}
127-
setClient(client)
128-
}, [simulate, sign, recentWallet, cosmWasmClient, broadcast, setClient])
126+
useStore.setState({
127+
client: {
128+
broadcast,
129+
cosmWasmClient,
130+
connectedWallet,
131+
sign,
132+
simulate,
133+
},
134+
})
135+
}, [simulate, sign, connectedWallet, cosmWasmClient, broadcast, networkConfig, chainId])
129136

130137
useEffect(() => {
131138
setRedBankAssets()
132139
}, [
140+
assetPricesUSD,
141+
assetPricesUSDState,
133142
exchangeRatesState,
134143
redBankState,
135144
userBalancesState,
@@ -151,17 +160,19 @@ export const CommonContainer = ({ children }: CommonContainerProps) => {
151160
// ------------------
152161
// QUERY RELATED
153162
// ------------------
163+
useUsdPrice()
154164
useBlockHeight()
155-
useRedBank()
156165
useUserBalance()
157166
useUserIcns()
158167
useUserDebt()
159168
useUserCollaterals()
160169
useMarsOracle()
161170
useSpotPrice(MARS_SYMBOL)
162-
useUsdPrice()
163171
useDepositAndDebt()
164172
useRedBank()
173+
usePythVaa()
174+
175+
if (migrationInProgress) return <MigrationInProgress />
165176

166-
return <>{isNetworkLoaded && children}</>
177+
return <>{children}</>
167178
}

0 commit comments

Comments
 (0)