From 190122a669e16f9d41e82eb97c9555af7d37c71c Mon Sep 17 00:00:00 2001 From: philippe-ftx <62417741+philippe-ftx@users.noreply.github.com> Date: Mon, 5 Oct 2020 13:26:34 +0200 Subject: [PATCH] Auto settle (#24) * Auto settle funds function * Auto settle * Add settings panel * Cleanup * Use OpenOrders.findForOwner and support custom markets * Some touch ups Co-authored-by: Nathaniel Parke --- src/App.js | 9 ++-- src/components/Settings.jsx | 26 +++++++++++ src/components/TopBar.js | 22 +++++++++- src/utils/markets.js | 11 +++-- src/utils/preferences.js | 55 +++++++++++++++++++++++ src/utils/send.js | 87 +++++++++++++++++++++++++++++++++++++ src/utils/wallet.js | 4 ++ 7 files changed, 206 insertions(+), 8 deletions(-) create mode 100644 src/components/Settings.jsx create mode 100644 src/utils/preferences.js diff --git a/src/App.js b/src/App.js index a6b15b9..cdf6679 100644 --- a/src/App.js +++ b/src/App.js @@ -7,6 +7,7 @@ import { GlobalStyle } from './global_style'; import { Spin } from 'antd'; import ErrorBoundary from './components/ErrorBoundary'; import { Routes } from './routes'; +import { PreferencesProvider } from './utils/preferences'; export default function App() { return ( @@ -16,9 +17,11 @@ export default function App() { - }> - - + + }> + + + diff --git a/src/components/Settings.jsx b/src/components/Settings.jsx new file mode 100644 index 0000000..e262d57 --- /dev/null +++ b/src/components/Settings.jsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { Switch, Typography } from 'antd'; +import { usePreferences } from '../utils/preferences'; + +const { Paragraph } = Typography; + +export default function Settings({ autoApprove }) { + const { autoSettleEnabled, setAutoSettleEnabled } = usePreferences(); + + return ( +
+ {' '} + Auto settle + {!autoApprove && ( + + To use auto settle, first enable auto approval in your wallet + + )} +
+ ); +} diff --git a/src/components/TopBar.js b/src/components/TopBar.js index 839eb07..5544533 100644 --- a/src/components/TopBar.js +++ b/src/components/TopBar.js @@ -1,4 +1,8 @@ -import { InfoCircleOutlined, UserOutlined } from '@ant-design/icons'; +import { + InfoCircleOutlined, + SettingOutlined, + UserOutlined, +} from '@ant-design/icons'; import { Button, Menu, Popover, Select } from 'antd'; import React, { useCallback } from 'react'; import { useHistory, useLocation } from 'react-router-dom'; @@ -7,6 +11,7 @@ import styled from 'styled-components'; import { useWallet, WALLET_PROVIDERS } from '../utils/wallet'; import { ENDPOINTS, useConnectionConfig } from '../utils/connection'; import LinkAddress from './LinkAddress'; +import Settings from './Settings'; const Wrapper = styled.div` background-color: #0d1017; @@ -63,6 +68,21 @@ export default function TopBar() { > TRADE + {connected && ( +
+ } + placement="bottomRight" + title="Settings" + trigger="click" + > + + +
+ )}