Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
670 changes: 340 additions & 330 deletions src/ui/package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.2.0",
"private": true,
"dependencies": {
"@airgap/beacon-sdk": "^4.6.4",
"@airgap/beacon-sdk": "^4.7.0",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
Expand Down Expand Up @@ -58,8 +58,9 @@
"vm-browserify": "^1.1.2"
},
"scripts": {
"start": "DISABLE_ESLINT_PLUGIN=true REACT_APP_ENV=dev npm run patch && react-app-rewired start",
"mainnet": "DISABLE_ESLINT_PLUGIN=true npm run patch && react-app-rewired start",
"start": "DISABLE_ESLINT_PLUGIN=true REACT_APP_ENV=shadownet npm run patch && react-app-rewired start",
"mainnet": "DISABLE_ESLINT_PLUGIN=true REACT_APP_ENV=mainnet npm run patch && react-app-rewired start",
"tezlink:shadownet": "DISABLE_ESLINT_PLUGIN=true REACT_APP_ENV=tezlink-shadownet npm run patch && react-app-rewired start",
"patch": "patch-package",
"build": "npm run patch && tsc && react-app-rewired build",
"test": "react-app-rewired test",
Expand Down
51 changes: 33 additions & 18 deletions src/ui/src/components/Constants/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { AssetType, testnetAddresses, mainnetAddresses } from 'tezoslendingplatformjs';
import {
AssetType, testnetAddresses, mainnetAddresses, tezlinkShadownetAddresses
} from 'tezoslendingplatformjs';
import fUSDtz from '../../assets/fusdtz.svg';
import fXTZ from '../../assets/fXTZ.svg';
import fUSDT from '../../assets/fusdt.svg';
Expand All @@ -24,7 +26,20 @@ import fstXTZ from '../../assets/fstXTZ.svg';
// import fOXTZ from '../../assets/foxtz.svg';
// import fWTZ from '../../assets/fwtz.svg';

const addresses = process.env.REACT_APP_ENV=="dev"? testnetAddresses : mainnetAddresses;
export const getAddresses = () => {
switch (process.env.REACT_APP_ENV) {
case 'shadownet':
return testnetAddresses;
case 'tezlink-shadownet':
return tezlinkShadownetAddresses;
case 'mainnet':
return mainnetAddresses;
default:
return mainnetAddresses;
}
};

const addresses = getAddresses();

export const tokens = [
{
Expand All @@ -34,7 +49,7 @@ export const tokens = [
fLogo: fXTZ,
banner: 'Tez',
assetType: AssetType.XTZ,
address: ''
address: ''
},
{
title: 'USDtz',
Expand All @@ -43,7 +58,7 @@ export const tokens = [
fLogo: fUSDtz,
banner: 'USDtz',
assetType: AssetType.USD,
address: addresses.underlying.USD?.address ?? ''
address: addresses.underlying.USD?.address ?? ''
},
{
title: 'USDt',
Expand All @@ -52,17 +67,17 @@ export const tokens = [
fLogo: fUSDT,
banner: 'USDt',
assetType: AssetType.USDT,
address: addresses.underlying.USDT?.address ?? ''
address: addresses.underlying.USDT?.address ?? ''
},
{
process.env.REACT_APP_ENV !== 'tezlink-shadownet' && {
title: 'tzBTC',
name: 'tzBTC',
logo: tzBTC,
fLogo: ftzBTC,
banner: 'tzBTC',
assetType: AssetType.TZBTC,
visibilityThreshold: 0.0000001,
address: addresses.underlying.TZBTC?.address ?? ''
address: addresses.underlying.TZBTC?.address ?? ''
},
{
title: 'stXTZ',
Expand All @@ -86,16 +101,16 @@ export const tokens = [
// {
// title: 'WTZ', logo: wtz, fLogo: fWTZ, banner: 'WTZ', assetType: AssetType.WTZ // TODO: update fToken for WTZ
// }
];
].filter(Boolean);
export const tokenColor = {
XTZ: 'rgb(51,145,246)',
USDtz: 'rgb(24,157,163)',
USDt: 'rgb(65 145 146)',
tzBTC: 'rgb(20,89,255)',
stXTZ: '#2B62F8'
// ETHtz: '#662F9D',
// BTCtz: '#F2991A',
// oXTZ: '#B52B31',
// WTZ: '#0C2C93'
// CTEZ: '#2B62F8'
XTZ: 'rgb(51,145,246)',
USDtz: 'rgb(24,157,163)',
USDt: 'rgb(65 145 146)',
tzBTC: 'rgb(20,89,255)',
stXTZ: '#2B62F8'
// ETHtz: '#662F9D',
// BTCtz: '#F2991A',
// oXTZ: '#B52B31',
// WTZ: '#0C2C93'
// CTEZ: '#2B62F8'
};
13 changes: 5 additions & 8 deletions src/ui/src/components/Dashboard/BorrowMarketTokenTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import React, { useState } from 'react';
import { useSelector } from 'react-redux';

import { AssetType, decimals, mainnetAddresses, testnetAddresses } from 'tezoslendingplatformjs';
import { AssetType, decimals } from 'tezoslendingplatformjs';
import BigNumber from 'bignumber.js';

import Table from '@mui/material/Table';
Expand All @@ -16,12 +16,13 @@ import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import { Button, Typography } from '@mui/material';

import { decimalify, nFormatter, roundValue } from '../../util';
import { decimalify, getExplorerLink, nFormatter, roundValue } from '../../util';

import AllMarketModal from '../AllMarketModal';
import TableSkeleton from '../Skeleton';

import { useStyles } from './style';
import { getAddresses } from '../Constants';

const BorrowMarketTokenTable = (props) => {
const classes = useStyles();
Expand All @@ -36,12 +37,8 @@ const BorrowMarketTokenTable = (props) => {
};

const handleClickDetails = (asset: AssetType) => {
const fTokenAddress =
process.env.REACT_APP_ENV == 'dev' ? testnetAddresses.fTokens[asset] : mainnetAddresses.fTokens[asset];
const tzktUrl =
process.env.REACT_APP_ENV == "dev"
? `https://shadownet.tzkt.io/${fTokenAddress}/operations`
: `https://tzkt.io/${fTokenAddress}/operations`;
const fTokenAddress = getAddresses().fTokens[asset];
const tzktUrl = `${getExplorerLink()}/${fTokenAddress}/operations`;
window.open(tzktUrl, '_blank');
};

Expand Down
2 changes: 1 addition & 1 deletion src/ui/src/components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { borrowCompositionAction } from "../../reduxContent/borrowComposition/ac
import { LightTooltip } from "../StackedBars/style.tsx";

// eslint-disable-next-line import/no-dynamic-require
const config = require(`../../library/${process.env.REACT_APP_ENV || "prod"}-network-config.json`);
const config = require(`../../library/${process.env.REACT_APP_ENV || 'mainnet'}-network-config.json`);

const Header = () => {
const classes = useStyles();
Expand Down
10 changes: 3 additions & 7 deletions src/ui/src/components/StatusModal/PendingModal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// eslint-disable-next-line no-use-before-define
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';

import IconButton from '@mui/material/IconButton';

Expand All @@ -10,14 +9,12 @@ import confirmGif from '../../assets/confirm.gif';
import CopyIcon from '../../assets/copyIcon.svg';

import useStyles from './style';
import { shorten } from '../../util';
import { shorten, getExplorerLink } from '../../util';

const PendingModal = (props) => {
const classes = useStyles();
const { token, tokenText, response } = props;

const { network } = useSelector((state) => state.nodes.tezosNode.conseilServerInfo);

const [transactionHash, setTransactionHash] = useState('one');

useEffect(() => {
Expand All @@ -35,9 +32,8 @@ const PendingModal = (props) => {
? <>
Operation hash: {' '}
<a
href={(network === 'mainnet')
? `https://tzkt.io/${transactionHash}`
: `https://${network}.tzkt.io/${transactionHash}`
href={
`${getExplorerLink()}/${transactionHash}`
}
target="_blank"
rel="noopener"
Expand Down
12 changes: 12 additions & 0 deletions src/ui/src/library/tezlink-shadownet-network-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

{
"infra": {
"tezosNode": "https://rpc.shadownet.tezlink.nomadic-labs.com",
"conseilServer": {
"url": "https://conseil-ithaca.cryptonomic-infra.tech:443",
"apiKey": "",
"network": "tezlink-shadownet"
}
},
"dappName": "TezFin"
}
9 changes: 4 additions & 5 deletions src/ui/src/reduxContent/nodes/actions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {
Comptroller,
testnetAddresses,
mainnetAddresses,
Comptroller
} from "tezoslendingplatformjs";
import { GET_COMPTROLLER, GET_PROTOCOL_ADDRESSES, GET_TEZOS_NODE } from './types';
import { getAddresses } from '../../components/Constants';

const config = require(`../../library/${
process.env.REACT_APP_ENV || "prod"
process.env.REACT_APP_ENV || "mainnet"
}-network-config.json`);

const addresses = process.env.REACT_APP_ENV=="dev"? testnetAddresses : mainnetAddresses
const addresses = getAddresses();

export const granadanetAction = () => async (dispatch) => {
dispatch({ type: GET_PROTOCOL_ADDRESSES, payload: addresses });
Expand Down
18 changes: 16 additions & 2 deletions src/ui/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import bigInt from 'big-integer';
import { TezosLendingPlatform } from 'tezoslendingplatformjs';

// eslint-disable-next-line import/no-dynamic-require
const config = require(`../library/${process.env.REACT_APP_ENV || 'prod'}-network-config.json`);
const config = require(`../library/${process.env.REACT_APP_ENV || 'mainnet'}-network-config.json`);

const client = new DAppClient({ name: config.dappName, network: { type: config.infra.conseilServer.network } });

Expand Down Expand Up @@ -79,12 +79,13 @@ export const evaluateTransaction = async (operations) => {
const counter = await TezosNodeReader.getCounterForAccount(config.infra.tezosNode, address);

console.log("operation", operations);
const optimizeGas = config.infra.conseilServer.network !== 'tezlink-shadownet';
const opGroup = await TezosNodeWriter.prepareOperationGroup(
config.infra.tezosNode,
keyStore,
counter,
operations,
true,
optimizeGas
);

return { opGroup };
Expand Down Expand Up @@ -228,3 +229,16 @@ export const nFormatter = (num, formatDecimals = 4) => {
.match(/^-?\d+(?:\.\d{0,2})?/) + suffix[i].symbol
);
};

export const getExplorerLink = () => {
switch (config.infra.conseilServer.network) {
case 'mainnet':
return 'https://tzkt.io';
case 'shadownet':
return 'https://shadownet.tzkt.io';
case 'tezlink-shadownet':
return 'https://shadownet.tezlink.tzkt.io';
default:
return 'https://tzkt.io';
}
};
Loading
Loading