mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-11 10:34:06 +00:00
Safe apps url config (#1001)
* safe-react-apps url from config and add request app * Adding types * safe-react-components bump * extracting types * add return type Co-authored-by: lukasschor <lukas.schor@gnosis.pm> Co-authored-by: Mati Dastugue <matias.dastugue@altoros.com> Co-authored-by: Fernando <fernando.greco@gmail.com> Co-authored-by: Mikhail Mikheev <mmvsha73@gmail.com>
This commit is contained in:
parent
8f9cd58d4e
commit
ea1662bc6f
@ -149,7 +149,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@gnosis.pm/safe-contracts": "1.1.1-dev.2",
|
||||
"@gnosis.pm/safe-react-components": "^0.1.2",
|
||||
"@gnosis.pm/safe-react-components": "^0.1.3",
|
||||
"@gnosis.pm/util-contracts": "2.0.6",
|
||||
"@ledgerhq/hw-transport-node-hid": "5.16.0",
|
||||
"@material-ui/core": "4.10.1",
|
||||
|
@ -1,10 +1,11 @@
|
||||
//
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL } from 'src/config/names'
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL, SAFE_APPS_URL } from 'src/config/names'
|
||||
|
||||
const devConfig = {
|
||||
[TX_SERVICE_HOST]: 'https://safe-transaction.staging.gnosisdev.com/api/v1/',
|
||||
[SIGNATURES_VIA_METAMASK]: false,
|
||||
[RELAY_API_URL]: 'https://safe-relay.staging.gnosisdev.com/api/v1/',
|
||||
//[SAFE_APPS_URL]: 'https://safe-apps.dev.gnosisdev.com/'
|
||||
[SAFE_APPS_URL]: 'http://localhost:3002/'
|
||||
}
|
||||
|
||||
export default devConfig
|
||||
|
@ -3,7 +3,8 @@ import { ETHEREUM_NETWORK, getWeb3 } from 'src/logic/wallets/getWeb3'
|
||||
import {
|
||||
RELAY_API_URL,
|
||||
SIGNATURES_VIA_METAMASK,
|
||||
TX_SERVICE_HOST
|
||||
TX_SERVICE_HOST,
|
||||
SAFE_APPS_URL
|
||||
} from 'src/config/names'
|
||||
import devConfig from './development'
|
||||
import testConfig from './testing'
|
||||
@ -67,6 +68,12 @@ export const signaturesViaMetamask = () => {
|
||||
return config[SIGNATURES_VIA_METAMASK]
|
||||
}
|
||||
|
||||
export const getGnosisSafeAppsUrl = () => {
|
||||
const config = getConfig()
|
||||
|
||||
return config[SAFE_APPS_URL]
|
||||
}
|
||||
|
||||
export const getGoogleAnalyticsTrackingID = () =>
|
||||
getNetwork() === ETHEREUM_NETWORK.MAINNET
|
||||
? process.env.REACT_APP_GOOGLE_ANALYTICS_ID_MAINNET
|
||||
|
@ -1,5 +1,4 @@
|
||||
//
|
||||
|
||||
export const TX_SERVICE_HOST = 'tsh'
|
||||
export const SIGNATURES_VIA_METAMASK = 'svm'
|
||||
export const RELAY_API_URL = 'rau'
|
||||
export const SAFE_APPS_URL = 'sau'
|
||||
|
@ -1,10 +1,10 @@
|
||||
//
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL } from 'src/config/names'
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL, SAFE_APPS_URL } from 'src/config/names'
|
||||
|
||||
const prodConfig = {
|
||||
[TX_SERVICE_HOST]: 'https://safe-transaction.rinkeby.gnosis.io/api/v1/',
|
||||
[SIGNATURES_VIA_METAMASK]: false,
|
||||
[RELAY_API_URL]: 'https://safe-relay.rinkeby.gnosis.io/api/v1/',
|
||||
[SAFE_APPS_URL]: 'https://apps.gnosis-safe.io/'
|
||||
}
|
||||
|
||||
export default prodConfig
|
||||
|
@ -1,10 +1,10 @@
|
||||
//
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL } from 'src/config/names'
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL, SAFE_APPS_URL } from 'src/config/names'
|
||||
|
||||
const stagingConfig = {
|
||||
[TX_SERVICE_HOST]: 'https://safe-transaction.staging.gnosisdev.com/api/v1/',
|
||||
[SIGNATURES_VIA_METAMASK]: false,
|
||||
[RELAY_API_URL]: 'https://safe-relay.staging.gnosisdev.com/api/v1/',
|
||||
[SAFE_APPS_URL]: 'https://safe-apps.staging.gnosisdev.com'
|
||||
}
|
||||
|
||||
export default stagingConfig
|
||||
|
@ -1,10 +1,10 @@
|
||||
//
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL } from 'src/config/names'
|
||||
import { TX_SERVICE_HOST, SIGNATURES_VIA_METAMASK, RELAY_API_URL, SAFE_APPS_URL } from 'src/config/names'
|
||||
|
||||
const testConfig = {
|
||||
[TX_SERVICE_HOST]: 'http://localhost:8000/api/v1/',
|
||||
[SIGNATURES_VIA_METAMASK]: false,
|
||||
[RELAY_API_URL]: 'https://safe-relay.staging.gnosisdev.com/api/v1',
|
||||
[SAFE_APPS_URL]: 'http://localhost:3002/'
|
||||
}
|
||||
|
||||
export default testConfig
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Icon, ModalFooterConfirmation, Text, Title } from '@gnosis.pm/safe-react-components'
|
||||
import { BigNumber } from 'bignumber.js'
|
||||
import React from 'react'
|
||||
import React, { ReactElement } from 'react'
|
||||
import styled from 'styled-components'
|
||||
|
||||
import { getWeb3 } from 'src/logic/wallets/getWeb3'
|
||||
import AddressInfo from 'src/components/AddressInfo'
|
||||
import DividerLine from 'src/components/DividerLine'
|
||||
import Collapse from 'src/components/Collapse'
|
||||
@ -14,6 +15,20 @@ import Heading from 'src/components/layout/Heading'
|
||||
import Img from 'src/components/layout/Img'
|
||||
import { getEthAsToken } from 'src/logic/tokens/utils/tokenHelpers'
|
||||
|
||||
export type SafeAppTx = {
|
||||
to: string
|
||||
value: string | number
|
||||
data: string
|
||||
}
|
||||
|
||||
// TODO: This should be exported by safe-rect-components
|
||||
type GenericModalProps = {
|
||||
title: ReactElement
|
||||
body: ReactElement
|
||||
footer: ReactElement
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
const humanReadableBalance = (balance, decimals) => new BigNumber(balance).times(`1e-${decimals}`).toFixed()
|
||||
|
||||
const Wrapper = styled.div`
|
||||
@ -40,22 +55,35 @@ const IconText = styled.div`
|
||||
margin-right: 4px;
|
||||
}
|
||||
`
|
||||
const isTxValid = (t) => {
|
||||
const isTxValid = (t): boolean => {
|
||||
try {
|
||||
if (!['string', 'number'].includes(typeof t.value)) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof t.value === 'string') {
|
||||
const web3 = getWeb3()
|
||||
web3.eth.abi.decodeParameter('uint256', t.value)
|
||||
}
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
|
||||
const isAddressValid = mustBeEthereumAddress(t.to) === undefined
|
||||
return isAddressValid && t.value !== undefined && typeof t.value === 'number' && t.data && typeof t.data === 'string'
|
||||
return isAddressValid && t.data && typeof t.data === 'string'
|
||||
}
|
||||
|
||||
const confirmTransactions = (
|
||||
safeAddress,
|
||||
safeName,
|
||||
ethBalance,
|
||||
nameApp,
|
||||
iconApp,
|
||||
txs,
|
||||
openModal,
|
||||
closeModal,
|
||||
onConfirm,
|
||||
) => {
|
||||
safeAddress: string,
|
||||
safeName: string,
|
||||
ethBalance: string,
|
||||
nameApp: string,
|
||||
iconApp: string,
|
||||
txs: Array<SafeAppTx>,
|
||||
openModal: (modalInfo: GenericModalProps) => void,
|
||||
closeModal: () => void,
|
||||
onConfirm: () => void,
|
||||
): any => {
|
||||
const areTxsMalformed = txs.some((t) => !isTxValid(t))
|
||||
|
||||
const title = <ModalTitle iconUrl={iconApp} title={nameApp} />
|
||||
|
@ -1,7 +1,7 @@
|
||||
import axios from 'axios'
|
||||
|
||||
import appsIconSvg from 'src/routes/safe/components/Transactions/TxsTable/TxType/assets/appsIcon.svg'
|
||||
|
||||
import { getGnosisSafeAppsUrl } from 'src/config/index'
|
||||
import { SafeApp } from './types'
|
||||
|
||||
const removeLastTrailingSlash = (url) => {
|
||||
@ -11,13 +11,14 @@ const removeLastTrailingSlash = (url) => {
|
||||
return url
|
||||
}
|
||||
|
||||
const gnosisAppsUrl = removeLastTrailingSlash(process.env.REACT_APP_GNOSIS_APPS_URL)
|
||||
const gnosisAppsUrl = removeLastTrailingSlash(getGnosisSafeAppsUrl())
|
||||
export const staticAppsList: Array<{ url: string; disabled: boolean }> = [
|
||||
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmQapdJP6zERqpDKKPECNeMDDgwmGUqbKk1PjHpYj8gfDJ`, disabled: false },
|
||||
{ url: `${gnosisAppsUrl}/compound`, disabled: false },
|
||||
{ url: `${gnosisAppsUrl}/tx-builder`, disabled: false },
|
||||
{ url: `${gnosisAppsUrl}/aave`, disabled: false },
|
||||
{ url: `${gnosisAppsUrl}/pool-together`, disabled: false },
|
||||
{ url: `${gnosisAppsUrl}/open-zeppelin`, disabled: false },
|
||||
{ url: `${gnosisAppsUrl}/request`, disabled: false },
|
||||
{ url: `${gnosisAppsUrl}/synthetix`, disabled: false },
|
||||
]
|
||||
|
||||
|
35
yarn.lock
35
yarn.lock
@ -1091,7 +1091,7 @@
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.4"
|
||||
|
||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.1.5", "@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.3.1", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.4", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
|
||||
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.1.5", "@babel/runtime@^7.10.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.2.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.4", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
|
||||
version "7.10.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.2.tgz#d103f21f2602497d38348a32e008637d506db839"
|
||||
integrity sha512-6sF3uQw2ivImfVIl62RZ7MXhO2tap69WeWK57vAaimT6AZbE4FbqjdEJIN1UqoD6wI6B+1n9UiagafH1sxjOtg==
|
||||
@ -1343,14 +1343,15 @@
|
||||
solc "0.5.14"
|
||||
truffle "^5.1.21"
|
||||
|
||||
"@gnosis.pm/safe-react-components@^0.1.2":
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-react-components/-/safe-react-components-0.1.2.tgz#67abee86bdfcf8c3a7c82b3faba691f87f251b7a"
|
||||
integrity sha512-hEXUjVOj2ToVxwWf1hGotjof5BffMdMacImWNjEji/IBHqwmlAJdMhQ2+cQNlue+iPkKfpSAsxmp8XAVurgtpw==
|
||||
"@gnosis.pm/safe-react-components@^0.1.3":
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-react-components/-/safe-react-components-0.1.3.tgz#ac80029862fd2a042a4400361db46e92e29a81c0"
|
||||
integrity sha512-N3EMk1bvsPUaKeuUXirlF8aXEdJucIxt+QjA1IjShrEy40zKT9S3Gj2H0nqMqLVcIo6IpZ0iRwv+MulYfpbqbQ==
|
||||
dependencies:
|
||||
classnames "^2.2.6"
|
||||
polished "3.6.3"
|
||||
react-docgen-typescript-loader "^3.7.2"
|
||||
react-media "^1.10.0"
|
||||
url-loader "^4.1.0"
|
||||
|
||||
"@gnosis.pm/util-contracts@2.0.6":
|
||||
@ -10424,6 +10425,13 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
|
||||
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
|
||||
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=
|
||||
|
||||
json2mq@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/json2mq/-/json2mq-0.2.0.tgz#b637bd3ba9eabe122c83e9720483aeb10d2c904a"
|
||||
integrity sha1-tje9O6nqvhIsg+lyBIOusQ0skEo=
|
||||
dependencies:
|
||||
string-convert "^0.2.0"
|
||||
|
||||
json3@^3.3.2:
|
||||
version "3.3.3"
|
||||
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81"
|
||||
@ -13723,7 +13731,7 @@ prompts@^2.0.1:
|
||||
kleur "^3.0.3"
|
||||
sisteransi "^1.0.4"
|
||||
|
||||
prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
|
||||
prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2, prop-types@^15.7.2:
|
||||
version "15.7.2"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
|
||||
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
|
||||
@ -14084,6 +14092,16 @@ react-lifecycles-compat@^3.0.2, react-lifecycles-compat@^3.0.4:
|
||||
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
|
||||
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
|
||||
|
||||
react-media@^1.10.0:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.yarnpkg.com/react-media/-/react-media-1.10.0.tgz#7b0c5fe8ac55a53ce31b5249db3aaf8a22ff7703"
|
||||
integrity sha512-FjgYmFoaPTImST06jqotuu0Mk8LOXiGYS/fIyiXuLnf20l3DPniBwtrxi604/HxxjqvmHS3oz5rAwnqdvosV4A==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.2.0"
|
||||
invariant "^2.2.2"
|
||||
json2mq "^0.2.0"
|
||||
prop-types "^15.5.10"
|
||||
|
||||
react-qr-reader@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/react-qr-reader/-/react-qr-reader-2.2.1.tgz#dc89046d1c1a1da837a683dd970de5926817d55b"
|
||||
@ -15864,6 +15882,11 @@ string-argv@0.3.1:
|
||||
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"
|
||||
integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==
|
||||
|
||||
string-convert@^0.2.0:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
|
||||
integrity sha1-aYLMMEn7tM2F+LJFaLnZvznu/5c=
|
||||
|
||||
string-length@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed"
|
||||
|
Loading…
x
Reference in New Issue
Block a user