Merge branch 'development' of github.com:gnosis/safe-react into feature/address-book-suggestions

This commit is contained in:
Mati Dastugue 2020-06-24 16:39:30 -03:00
commit cf2fd4522c
6 changed files with 48 additions and 25 deletions

View File

@ -1,6 +1,6 @@
{
"name": "safe-react",
"version": "2.1.1",
"version": "2.3.0",
"description": "Allowing crypto users manage funds in a safer way",
"website": "https://github.com/gnosis/safe-react#readme",
"bugs": {

View File

@ -58,14 +58,18 @@ export const minValue = (min: number | string) => (value: string) => {
return `Should be at least ${min}`
}
export const maxValue = (max: number | string) => (value: string) => {
if (Number.isNaN(Number(value)) || parseFloat(value) <= parseFloat(max.toString())) {
export const maxValueCheck = (max: number | string, value: string): string | undefined => {
if (!max || Number.isNaN(Number(value)) || parseFloat(value) <= parseFloat(max.toString())) {
return undefined
}
return `Maximum value is ${max}`
}
export const maxValue = (max: number | string) => (value: string) => {
return maxValueCheck(max, value)
}
export const ok = () => undefined
export const mustBeEthereumAddress = simpleMemoize((address: string) => {

View File

@ -13,10 +13,14 @@ const removeLastTrailingSlash = (url) => {
const gnosisAppsUrl = removeLastTrailingSlash(getGnosisSafeAppsUrl())
export const staticAppsList: Array<{ url: string; disabled: boolean }> = [
// Sablier
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmabPEk7g4zaytFefp6fE4nz8f85QMJoWmRQQZypvJViNG`, disabled: false },
// request
{ url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmQapdJP6zERqpDKKPECNeMDDgwmGUqbKk1PjHpYj8gfDJ`, disabled: false },
// Aave
// { url: `${process.env.REACT_APP_IPFS_GATEWAY}/QmUfgEqdJ5kVjWTQofnDmvxdhDLBAaejiHkhQhfw6aYvBg`, 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}/synthetix`, disabled: false },

View File

@ -101,6 +101,9 @@ const AddressBookInput = ({
)
})
setADBKList(filteredADBK)
if (!isValidText) {
setSelectedEntry({ address: addressValue })
}
}
setIsValidForm(isValidText === undefined)
setValidationText(isValidText)

View File

@ -17,7 +17,14 @@ import { ScanQRWrapper } from 'src/components/ScanQRModal/ScanQRWrapper'
import Field from 'src/components/forms/Field'
import GnoForm from 'src/components/forms/GnoForm'
import TextField from 'src/components/forms/TextField'
import { composeValidators, greaterThan, maxValue, mustBeFloat, required } from 'src/components/forms/validator'
import {
composeValidators,
greaterThan,
maxValue,
maxValueCheck,
mustBeFloat,
required,
} from 'src/components/forms/validator'
import Block from 'src/components/layout/Block'
import Button from 'src/components/layout/Button'
import ButtonLink from 'src/components/layout/ButtonLink'
@ -39,7 +46,7 @@ const formMutators = {
utils.changeValue(state, 'amount', () => args[0])
},
onTokenChange: (args, state, utils) => {
utils.changeValue(state, 'amount', () => '')
utils.changeValue(state, 'amount', () => state.formState.values.amount)
},
setRecipient: (args, state, utils) => {
utils.changeValue(state, 'recipientAddress', () => args[0])
@ -56,6 +63,7 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT
address: recipientAddress || initialValues.recipientAddress,
name: '',
})
const [pristine, setPristine] = useState(true)
const [isValidAddress, setIsValidAddress] = useState(true)
@ -86,7 +94,18 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT
</IconButton>
</Row>
<Hairline />
<GnoForm formMutators={formMutators} initialValues={initialValues} onSubmit={handleSubmit}>
<GnoForm
formMutators={formMutators}
initialValues={initialValues}
onSubmit={handleSubmit}
validation={(values) => {
const selectedTokenRecord = tokens.find((token) => token.address === values?.token)
return {
amount: maxValueCheck(selectedTokenRecord?.balance, values.amount),
}
}}
>
{(...args) => {
const formState = args[2]
const mutators = args[3]
@ -224,11 +243,15 @@ const SendFunds = ({ initialValues, onClose, onNext, recipientAddress, selectedT
required,
mustBeFloat,
greaterThan(0),
maxValue(selectedTokenRecord && selectedTokenRecord.balance),
maxValue(selectedTokenRecord?.balance),
)}
/>
<OnChange name="token">
{() => {
setSelectedEntry({
name: selectedEntry?.name,
address: selectedEntry?.address,
})
mutators.onTokenChange()
}}
</OnChange>

View File

@ -6854,19 +6854,6 @@ etag@~1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
eth-block-tracker@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/eth-block-tracker/-/eth-block-tracker-3.0.1.tgz#95cd5e763c7293e0b1b2790a2a39ac2ac188a5e1"
integrity sha512-WUVxWLuhMmsfenfZvFO5sbl1qFY2IqUlw/FPVmjjdElpqLsZtSG+wPe9Dz7W/sB6e80HgFKknOmKk2eNlznHug==
dependencies:
eth-query "^2.1.0"
ethereumjs-tx "^1.3.3"
ethereumjs-util "^5.1.3"
ethjs-util "^0.1.3"
json-rpc-engine "^3.6.0"
pify "^2.3.0"
tape "^4.6.3"
eth-block-tracker@^4.2.0, eth-block-tracker@^4.4.1, eth-block-tracker@^4.4.2:
version "4.4.3"
resolved "https://registry.yarnpkg.com/eth-block-tracker/-/eth-block-tracker-4.4.3.tgz#766a0a0eb4a52c867a28328e9ae21353812cf626"
@ -7204,7 +7191,7 @@ ethereumjs-util@4.5.0, ethereumjs-util@^4.3.0:
rlp "^2.0.0"
secp256k1 "^3.0.1"
ethereumjs-util@5.2.0, ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2, ethereumjs-util@^5.1.3, ethereumjs-util@^5.1.5:
ethereumjs-util@5.2.0, ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2, ethereumjs-util@^5.1.5:
version "5.2.0"
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz#3e0c0d1741471acf1036052d048623dee54ad642"
integrity sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==
@ -17257,16 +17244,18 @@ web3-provider-engine@^15.0.4:
xhr "^2.2.0"
xtend "^4.0.1"
"web3-provider-engine@git+https://github.com/trufflesuite/provider-engine.git#web3-one":
"web3-provider-engine@https://github.com/trufflesuite/provider-engine#web3-one":
version "14.0.6"
resolved "git+https://github.com/trufflesuite/provider-engine.git#3538c60bc4836b73ccae1ac3f64c8fed8ef19c1a"
resolved "https://github.com/trufflesuite/provider-engine#9694f5b4e5500651bd2ff689df8529bb5cf6b96f"
dependencies:
async "^2.5.0"
backoff "^2.5.0"
clone "^2.0.0"
cross-fetch "^2.1.0"
eth-block-tracker "^3.0.0"
eth-block-tracker "^4.2.0"
eth-json-rpc-filters "^4.0.2"
eth-json-rpc-infura "^3.1.0"
eth-json-rpc-middleware "^4.1.1"
eth-sig-util "^1.4.2"
ethereumjs-block "^1.2.2"
ethereumjs-tx "^1.2.0"