10 | { props.hideTop ||
}
11 | {props.children}
12 | { props.hideBottom ||
}
13 |
14 | );
15 | }
16 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/components/OversizedPanel/oversized-panel.scss:
--------------------------------------------------------------------------------
1 | @import '../../variables.scss';
2 |
3 | .oversized-panel {
4 | position: relative;
5 | background-color: $concrete-gray;
6 | width: calc(100% - 1rem);
7 | margin: 0 auto;
8 | border-radius: .625rem;
9 |
10 | &__top {
11 | content: "";
12 | position: absolute;
13 | top: -.5rem;
14 | left: 0;
15 | height: 1rem;
16 | width: 100%;
17 | background-color: $concrete-gray;
18 | z-index: 100;
19 | }
20 |
21 | &__bottom {
22 | position: absolute;
23 | top: 80%;
24 | left: 0;
25 | height: 1rem;
26 | width: 100%;
27 | background-color: $concrete-gray;
28 | z-index: 100;
29 | }
30 | }
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/components/QrCode/qr-code.scss:
--------------------------------------------------------------------------------
1 |
2 | .qr-code {
3 | &__video {
4 | height: 100%;
5 | width: 100%;
6 | }
7 |
8 | &__modal {
9 | z-index: 2000;
10 | position: absolute;
11 | top: 100px;
12 | bottom: 100px;
13 | right: 100px;
14 | left: 100px;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/constants/currencyInputErrorTypes.js:
--------------------------------------------------------------------------------
1 | export const INSUFFICIENT_BALANCE = 'Insufficient balance';
2 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/ducks/app.js:
--------------------------------------------------------------------------------
1 | const DISMISS_BETA_MESSAGE = 'app/app/dismissBetaMessage';
2 |
3 | const initialState = {
4 | showBetaMessage: true,
5 | };
6 |
7 | export const dismissBetaMessage = () => ({ type: DISMISS_BETA_MESSAGE });
8 |
9 | export default function appReducer(state = initialState, { type, payload }) {
10 | switch (type) {
11 | case DISMISS_BETA_MESSAGE:
12 | return { ...state, showBetaMessage: false };
13 | default:
14 | return state;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/ducks/index.js:
--------------------------------------------------------------------------------
1 | import { combineReducers } from 'redux';
2 | import addresses from './addresses';
3 | import app from './app';
4 | import pending from './pending';
5 | import web3connect from './web3connect';
6 |
7 | export default combineReducers({
8 | app,
9 | addresses,
10 | pending,
11 | web3connect,
12 | });
13 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/ducks/pending.js:
--------------------------------------------------------------------------------
1 | const ADD_APPROVAL_TX = 'app/send/addApprovalTx';
2 |
3 | const getInitialState = () => {
4 | return {
5 | approvals: {},
6 | };
7 | };
8 |
9 | export const addApprovalTx = ({ tokenAddress, txId }) => ({
10 | type: ADD_APPROVAL_TX,
11 | payload: { tokenAddress, txId },
12 | });
13 |
14 | export default function sendReducer(state = getInitialState(), { type, payload }) {
15 | switch (type) {
16 | case ADD_APPROVAL_TX:
17 | return {
18 | approvals: {
19 | ...state.approvals,
20 | [payload.tokenAddress]: payload.txId,
21 | }
22 | };
23 | default:
24 | return state;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/fuse/bitap/bitap_matched_indices.js:
--------------------------------------------------------------------------------
1 | export default function (matchmask = [], minMatchCharLength = 1) {
2 | let matchedIndices = []
3 | let start = -1
4 | let end = -1
5 | let i = 0
6 |
7 | for (let len = matchmask.length; i < len; i += 1) {
8 | let match = matchmask[i]
9 | if (match && start === -1) {
10 | start = i
11 | } else if (!match && start !== -1) {
12 | end = i - 1
13 | if ((end - start) + 1 >= minMatchCharLength) {
14 | matchedIndices.push([start, end])
15 | }
16 | start = -1
17 | }
18 | }
19 |
20 | // (i-1 - start) + 1 => i - start
21 | if (matchmask[i - 1] && (i - start) >= minMatchCharLength) {
22 | matchedIndices.push([start, i - 1])
23 | }
24 |
25 | return matchedIndices
26 | }
27 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/fuse/bitap/bitap_pattern_alphabet.js:
--------------------------------------------------------------------------------
1 | export default function (pattern) {
2 | let mask = {}
3 | let len = pattern.length
4 |
5 | for (let i = 0; i < len; i += 1) {
6 | mask[pattern.charAt(i)] = 0
7 | }
8 |
9 | for (let i = 0; i < len; i += 1) {
10 | mask[pattern.charAt(i)] |= 1 << (len - i - 1)
11 | }
12 |
13 | return mask
14 | }
15 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/fuse/bitap/bitap_regex_search.js:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line no-unused-escape
2 | const SPECIAL_CHARS_REGEX = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g
3 |
4 | export default function (text, pattern, tokenSeparator = / +/g) {
5 | let regex = new RegExp(pattern.replace(SPECIAL_CHARS_REGEX, '\\$&').replace(tokenSeparator, '|'))
6 | let matches = text.match(regex)
7 | let isMatch = !!matches
8 | let matchedIndices = []
9 |
10 | if (isMatch) {
11 | for (let i = 0, matchesLen = matches.length; i < matchesLen; i += 1) {
12 | let match = matches[i]
13 | matchedIndices.push([text.indexOf(match), match.length - 1])
14 | }
15 | }
16 |
17 | return {
18 | // TODO: revisit this score
19 | score: isMatch ? 0.5 : 1,
20 | isMatch,
21 | matchedIndices
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/fuse/bitap/bitap_score.js:
--------------------------------------------------------------------------------
1 | export default function (pattern, { errors = 0, currentLocation = 0, expectedLocation = 0, distance = 100 }) {
2 | const accuracy = errors / pattern.length
3 | const proximity = Math.abs(expectedLocation - currentLocation)
4 |
5 | if (!distance) {
6 | // Dodge divide by zero error.
7 | return proximity ? 1.0 : accuracy
8 | }
9 |
10 | return accuracy + (proximity / distance)
11 | }
12 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/fuse/helpers/is_array.js:
--------------------------------------------------------------------------------
1 | module.exports = obj => !Array.isArray ? Object.prototype.toString.call(obj) === '[object Array]' : Array.isArray(obj)
2 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/promise-utils.js:
--------------------------------------------------------------------------------
1 | export function retry(func, retryCount=5) {
2 | return new Promise((resolve, reject) => {
3 | func().then((...args) => {
4 | resolve(...args);
5 | }, () => {
6 | if (retryCount === 0) {
7 | return reject();
8 | }
9 | setTimeout(() => retry(func, retryCount - 1).then(resolve, reject), 50);
10 | });
11 | });
12 | }
13 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/web3-promisfy.js:
--------------------------------------------------------------------------------
1 | export default function promisify(web3, methodName, ...args) {
2 | return new Promise((resolve, reject) => {
3 | if (!web3) {
4 | reject(new Error('No Web3 object'));
5 | return;
6 | }
7 |
8 | const method = web3.eth[methodName];
9 |
10 | if (!method) {
11 | reject(new Error(`Cannot find web3.eth.${methodName}`));
12 | return;
13 | }
14 |
15 | method(...args, (error, data) => {
16 | if (error) {
17 | reject(error);
18 | return;
19 | }
20 |
21 | resolve(data);
22 | })
23 | });
24 | }
25 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/helpers/web3-utils.js:
--------------------------------------------------------------------------------
1 | import promisify from "./web3-promisfy";
2 |
3 | export function getBlockDeadline(web3, deadline) {
4 | return new Promise(async (resolve, reject) => {
5 | const blockNumber = await promisify(web3, 'getBlockNumber');
6 | if (!blockNumber && blockNumber !== 0) {
7 | return reject();
8 | }
9 |
10 | const block = await promisify(web3, 'getBlock', blockNumber);
11 | if (!block) {
12 | return reject();
13 | }
14 |
15 | resolve(block.timestamp + deadline);
16 | });
17 | }
18 |
--------------------------------------------------------------------------------
/src/Apps/Uniswap/src/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import { Provider } from 'react-redux';
4 | import ReactGA from 'react-ga';
5 | import './i18n';
6 | import App from './pages/App';
7 | import store from './store';
8 |
9 | import './index.scss';
10 |
11 | if (process.env.NODE_ENV === 'development') {
12 | // ReactGA.initialize('UA-128182339-02');
13 | } else {
14 | ReactGA.initialize('UA-128182339-1');
15 | }
16 | ReactGA.pageview(window.location.pathname + window.location.search);
17 |
18 | window.addEventListener('load', function() {
19 | ReactDOM.render(
20 |