Skip to content

Commit

Permalink
Merge branch 'develop' into feat/bob-gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
rick23p committed Dec 9, 2024
2 parents 2b71a6a + 28b7aa1 commit c9e1d4e
Show file tree
Hide file tree
Showing 61 changed files with 4,429 additions and 253 deletions.
5 changes: 0 additions & 5 deletions .changeset/long-buckets-smash.md

This file was deleted.

2 changes: 2 additions & 0 deletions apps/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/public/charting_library
/public/datafeeds
/node_modules
/.pnp
.pnp.js
Expand Down
64 changes: 64 additions & 0 deletions apps/frontend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,69 @@
# frontend

## 1.1.29

### Patch Changes

- 08fa89a4: Update spiceInfo.json
- e3c19dae: SOV-4609: fix display ambient liq balance

## 1.1.28

### Patch Changes

- c760d5c0: Fix Spice multipliers

## 1.1.27

### Patch Changes

- 58350fd0: Adjust homepage banners

## 1.1.26

### Patch Changes

- 5dcc907d: chore: fix asset icon styles
- 29852f48: [SOV-4525] - Display LP Fee Rate Without Wallet Connection
- 5dcc907d: SOV-4524: Show USD values on Convert page
- 9579578f: SOV-4537: Add incentives column to market making

## 1.1.25

### Patch Changes

- d953df39: fix: custom messages on convert page dropdown
- ae74555b: chore: fix asset icon styles
- c426bb82: SOV-4493: Show ecosystem statistics only in BTC and USD
- d3d711eb: SOV-4532: add PUPS pools
- d5079dae: SOV-4462: D2 charts on Convert page
- a5b4f389: Make charts bigger on larger screens
- Updated dependencies [d3d711eb]
- @sovryn/contracts@1.2.4
- @sovryn/sdk@2.0.4

## 1.1.24

### Patch Changes

- 0bc23cc0: chore: update rune symbols
- 52b7c4fe: chore: add new pools
- Updated dependencies [0bc23cc0]
- Updated dependencies [52b7c4fe]
- @sovryn/contracts@1.2.3
- @sovryn/sdk@2.0.3

## 1.1.23

### Patch Changes

- eedbb292: SOV-4445: Add Runes page
- 2028847d: SOV-4468: Show protocol data in BTC and USD only
- 750f7473: SOV-4496: add new pools
- Updated dependencies [750f7473]
- @sovryn/contracts@1.2.2
- @sovryn/sdk@2.0.2

## 1.1.22

### Patch Changes
Expand Down
11 changes: 7 additions & 4 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.1.22",
"version": "1.1.29",
"homepage": ".",
"private": true,
"dependencies": {
Expand All @@ -11,6 +11,7 @@
"@loadable/component": "5.15.2",
"@sovryn-zero/lib-base": "0.2.1",
"@sovryn-zero/lib-ethers": "0.2.5",
"@sovryn/charting-library": "2.0.0",
"@sovryn/contracts": "*",
"@sovryn/ethers-provider": "*",
"@sovryn/onboard-bitget": "1.0.1",
Expand Down Expand Up @@ -61,6 +62,7 @@
"rxjs": "7.5.6",
"sanitize-html": "2.11.0",
"socket.io-client": "4.5.4",
"storage-factory": "^0.2.1",
"utf8": "^3.0.0",
"zustand": "^4.5.1"
},
Expand Down Expand Up @@ -95,16 +97,17 @@
},
"scripts": {
"predev": "yarn generate:graphql",
"dev": "craco start",
"dev": "yarn copy-libs && craco start",
"prebuild": "yarn generate:graphql",
"build": "craco build",
"build": "yarn copy-libs && craco build",
"test": "craco test --watchAll=false --passWithNoTests",
"test:staged": "craco test --watchAll=false --passWithNoTests --bail --onlyChanged",
"lint": "eslint -c .eslintrc.js ./",
"generate:graphql": "graphql-codegen",
"generate:graphql:fetch:testnet": "env-cmd -f .env.development.local graphql-codegen -c codegen.fetch.yml",
"generate:graphql:fetch:mainnet": "env-cmd -f .env.staging graphql-codegen -c codegen.fetch.yml",
"find-deadcode": "ts-prune -s .generated.tsx | grep -v '(used in module)'"
"find-deadcode": "ts-prune -s .generated.tsx | grep -v '(used in module)'",
"copy-libs": "node scripts/copyLibs.js"
},
"browserslist": [
"last 5 chrome version",
Expand Down
61 changes: 61 additions & 0 deletions apps/frontend/scripts/copyLibs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const fs = require('fs');
const path = require('path');
const fsp = fs.promises;

async function deleteDir(dir) {
if (fs.existsSync(dir)) {
await fsp.rmdir(dir, { recursive: true });
console.log(`Deleted directory: ${dir}`);
}
}

async function copyDir(src, dest) {
await fsp.mkdir(dest, { recursive: true });
const entries = await fsp.readdir(src, { withFileTypes: true });

for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);

if (entry.isDirectory()) {
await copyDir(srcPath, destPath);
} else {
await fsp.copyFile(srcPath, destPath);
}
}
}

async function copyLibs() {
const chartingLibrarySrc = path.resolve(
__dirname,
'../../../node_modules/@sovryn/charting-library/public/charting_library',
);
const chartingLibraryDest = path.resolve(
__dirname,
'../public/charting_library',
);

const datafeedsSrc = path.resolve(
__dirname,
'../../../node_modules/@sovryn/charting-library/public/datafeeds',
);
const datafeedsDest = path.resolve(__dirname, '../public/datafeeds');

if (fs.existsSync(chartingLibrarySrc)) {
await deleteDir(chartingLibraryDest);
await copyDir(chartingLibrarySrc, chartingLibraryDest);
console.log('Charting Library copied.');
} else {
console.error('Charting Library source not found.');
}

if (fs.existsSync(datafeedsSrc)) {
await deleteDir(datafeedsDest);
await copyDir(datafeedsSrc, datafeedsDest);
console.log('Datafeeds copied.');
} else {
console.error('Datafeeds source not found.');
}
}

copyLibs();
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}

.assetLogo svg {
@apply mr-2 w-5 h-5;
@apply mr-2 w-5 h-5 bg-gray-80 rounded-full overflow-hidden;
}

.asset {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { storageFactory } from 'storage-factory';

import { ResolutionString } from '@sovryn/charting-library/src/charting_library';

import { INDEXER_SERVICE } from '../../../constants/infrastructure';
import { Environments } from '../../../types/global';
import { CandleDuration } from './dictionary';

export const REFRESH_RATE = 15 * 1e3;
export const MAXIMUM_CHUNK_SIZE = 1e3;
export const endTimeCache = new Map<string, number>();
export const supportedResolutions = [
'1',
'5',
'10',
'15',
'30',
'60',
'240',
'720',
'1D',
'3D',
'1W',
'1M',
] as ResolutionString[];

export const resolutionMap: { [key: string]: CandleDuration } = {
'1': CandleDuration.M_1,
'5': CandleDuration.M_1,
'10': CandleDuration.M_10,
'15': CandleDuration.M_15,
'30': CandleDuration.M_30,
'60': CandleDuration.H_1,
H: CandleDuration.H_1,
'240': CandleDuration.H_4,
'720': CandleDuration.H_12,
'1440': CandleDuration.D_1,
D: CandleDuration.D_1,
'1D': CandleDuration.D_1,
'3D': CandleDuration.D_3,
W: CandleDuration.W_1,
'1W': CandleDuration.W_1,
M: CandleDuration.D_30,
'1M': CandleDuration.D_30,
};

export const local = storageFactory(() => localStorage);

export const chartStorageKey = 'sovryn.charts';

export const config = {
exchanges: [],
symbols_types: [],
supported_resolutions: supportedResolutions,
supports_time: false,
};

export const SOVRYN_INDEXER_MAINNET = `${
INDEXER_SERVICE[Environments.Mainnet]
}chart`;

export const SOVRYN_INDEXER_TESTNET = `${
INDEXER_SERVICE[Environments.Testnet]
}chart`;
82 changes: 82 additions & 0 deletions apps/frontend/src/app/2_molecules/TradingChart/TradingChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { useApolloClient } from '@apollo/client';

import React, { FC, useEffect, useLayoutEffect, useRef, useState } from 'react';

import {
ChartingLibraryWidgetOptions,
IChartingLibraryWidget,
ResolutionString,
widget,
} from '@sovryn/charting-library/src/charting_library';
import { noop } from '@sovryn/ui';

import { SeriesStyle, TradingChartProps } from './TradingChart.types';
import Datafeed from './datafeed';

export const TradingChart: FC<TradingChartProps> = ({ pair }) => {
const chartContainerRef =
useRef<HTMLDivElement>() as React.MutableRefObject<HTMLInputElement>;

const [hasCharts, setHasCharts] = useState(false);
const [chart, setChart] = useState<IChartingLibraryWidget | null>(null);
const client = useApolloClient();

useEffect(() => {
try {
const widgetOptions: ChartingLibraryWidgetOptions = {
symbol: pair,
datafeed: Datafeed(client),
interval: '1D' as ResolutionString,
container: chartContainerRef.current,
library_path: '/charting_library/',
load_last_chart: true, //last chart layout (if present)
theme: 'dark',
locale: 'en',
disabled_features: ['header_symbol_search', 'header_compare'],
enabled_features: [
'study_templates',
'side_toolbar_in_fullscreen_mode',
],
charts_storage_url: 'https://saveload.tradingview.com',
charts_storage_api_version: '1.1',
client_id: 'tradingview.com',
user_id: 'public_user_id',
fullscreen: false,
autosize: true,
studies_overrides: {},
};

const myChart = new widget(widgetOptions);
setChart(myChart);
myChart.onChartReady(() => {
setHasCharts(true);
});

return () => {
myChart.remove();
setHasCharts(false);
setChart(null);
};
} catch (e) {
console.error(e);
setHasCharts(false);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [client]);

useLayoutEffect(() => {
if (chart && hasCharts) {
chart.chart().resetData();

chart.chart().setChartType(SeriesStyle.Candles as number);

chart.chart().setSymbol(pair, noop);
}
}, [chart, hasCharts, pair]);

return (
<div className="w-full p-0 sm:border sm:border-gray-50 sm:rounded sm:p-6 sm:bg-gray-90">
<div ref={chartContainerRef} className="h-full min-h-96" />
</div>
);
};
Loading

0 comments on commit c9e1d4e

Please sign in to comment.