Skip to content

Commit

Permalink
Merge pull request #396 from ergolabs/dev
Browse files Browse the repository at this point in the history
v1.2.7
  • Loading branch information
yasha-black authored Feb 14, 2022
2 parents 9aa575d + 2e872f4 commit 058f06a
Show file tree
Hide file tree
Showing 107 changed files with 2,029 additions and 1,571 deletions.
12 changes: 12 additions & 0 deletions src/@types/dapp-wallet-web-bridge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,16 @@ namespace ErgoBridge {
}
}

declare let ergoConnector: {
nautilus: any;
};
declare let NautilusErgoApi: any;

declare let cardano: Record<string, any>;

declare let ergo: ErgoBridge.ErgoAPI;

interface Window {
yoroi: ErgoBridge.ErgoAPI;
nautilus: ErgoBridge.ErgoAPI;
}
107 changes: 52 additions & 55 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
AppLoadingProvider,
SettingsProvider,
WalletAddressesProvider,
WalletContextProvider,
} from './context';
import { globalHistory } from './createBrowserHistory';
import { ContextModalProvider } from './ergodex-cdk';
Expand All @@ -32,60 +31,58 @@ const Application = withTranslation()(() => {
return (
<Router history={globalHistory}>
<AppLoadingProvider>
<WalletContextProvider>
<SettingsProvider>
<WalletAddressesProvider>
<ContextModalProvider>
<Layout>
<BrowserView>
<Switch>
<Route path="/" exact>
<Redirect to="/swap" />
</Route>
<Route path="/swap" exact component={Swap} />
<Route path="/pool" exact component={Pool} />
<Route path="/pool/add" exact component={AddLiquidity} />
<Route
path="/pool/:poolId/remove"
exact
component={RemoveLiquidity}
/>
<Route
path="/pool/:poolId/lock"
exact
component={LockLiquidity}
/>
<Route
path="/pool/:poolId/relock"
exact
component={RelockLiquidity}
/>
<Route
path="/pool/:poolId/withdrawal"
exact
component={WithdrawalLiquidity}
/>
<Route
path="/pool/:poolId/add"
exact
component={AddLiquidity}
/>
<Route
path="/pool/:poolId"
exact
component={PoolOverview}
/>
<Route component={NotFound} />
</Switch>
</BrowserView>
<MobileView>
<MobilePlug />
</MobileView>
</Layout>
</ContextModalProvider>
</WalletAddressesProvider>
</SettingsProvider>
</WalletContextProvider>
<SettingsProvider>
<WalletAddressesProvider>
<ContextModalProvider>
<Layout>
<BrowserView>
<Switch>
<Route path="/" exact>
<Redirect to="/swap" />
</Route>
<Route path="/swap" exact component={Swap} />
<Route path="/pool" exact component={Pool} />
<Route path="/pool/add" exact component={AddLiquidity} />
<Route
path="/pool/:poolId/remove"
exact
component={RemoveLiquidity}
/>
<Route
path="/pool/:poolId/lock"
exact
component={LockLiquidity}
/>
<Route
path="/pool/:poolId/relock"
exact
component={RelockLiquidity}
/>
<Route
path="/pool/:poolId/withdrawal"
exact
component={WithdrawalLiquidity}
/>
<Route
path="/pool/:poolId/add"
exact
component={AddLiquidity}
/>
<Route
path="/pool/:poolId"
exact
component={PoolOverview}
/>
<Route component={NotFound} />
</Switch>
</BrowserView>
<MobileView>
<MobilePlug />
</MobileView>
</Layout>
</ContextModalProvider>
</WalletAddressesProvider>
</SettingsProvider>
</AppLoadingProvider>
</Router>
);
Expand Down
13 changes: 7 additions & 6 deletions src/api/assets.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { AssetInfo } from '@ergolabs/ergo-sdk/build/main/entities/assetInfo';
import { uniqBy } from 'lodash';
import { map, Observable, publishReplay, refCount, switchMap } from 'rxjs';
import { map, Observable, publishReplay, refCount } from 'rxjs';

import { selectedNetwork$ } from '../network/network';
import { ammPools$ } from './ammPools';

export const assets$ = selectedNetwork$.pipe(
switchMap((network) => network.assets$),
export const tokenAssets$ = ammPools$.pipe(
map((pools) => pools.flatMap((p) => [p.x.asset, p.y.asset])),
map((assets) => uniqBy(assets, 'id')),
publishReplay(1),
refCount(),
);

export const lpAssets$ = selectedNetwork$.pipe(
switchMap((network) => network.lpAssets$),
export const lpAssets$ = ammPools$.pipe(
map((pools) => pools.map((p) => p.lp.asset)),
map((assets) => uniqBy(assets, 'id')),
publishReplay(1),
refCount(),
);
Expand Down
50 changes: 50 additions & 0 deletions src/api/wallets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {
filter,
first,
mapTo,
Observable,
publishReplay,
refCount,
switchMap,
} from 'rxjs';

import { Wallet, WalletState } from '../network/common';
import { selectedNetwork$ } from '../network/network';

export const wallets$ = selectedNetwork$.pipe(
switchMap((n) => n.wallets$),
publishReplay(1),
refCount(),
);

export const selectedWallet$ = selectedNetwork$.pipe(
switchMap((n) => n.selectedWallet$),
publishReplay(1),
refCount(),
);

export const selectedWalletState$ = selectedNetwork$.pipe(
switchMap((n) => n.selectedWalletState$),
publishReplay(1),
refCount(),
);

export const isWalletSetuped$ = selectedWalletState$.pipe(
filter(
(state) =>
state === WalletState.CONNECTED || state === WalletState.CONNECTING,
),
mapTo(true),
publishReplay(1),
refCount(),
);

export const connectWallet = (wallet: Wallet): Observable<any> =>
selectedNetwork$.pipe(
switchMap((n) => n.connectWallet(wallet)),
first(),
);

export const disconnectWallet = (): void => {
selectedNetwork$.pipe(first()).subscribe((n) => n.disconnectWallet());
};
2 changes: 2 additions & 0 deletions src/applicationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ interface ApplicationConfig {
readonly hiddenAssets: string[];
readonly blacklistedPools: string[];
readonly operationsRestrictions: OperationRestriction[];
readonly requestRetryCount: number;
}

export const applicationConfig: ApplicationConfig = {
api: 'https://api.ergodex.io/v1/',
requestRetryCount: 3,
social: {
twitter: 'https://twitter.com/ErgoDex',
telegram: 'https://t.me/ergodex_community',
Expand Down
3 changes: 3 additions & 0 deletions src/assets/icons/icon-logout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 058f06a

Please sign in to comment.