set send value

yann300-patch-36
David Disu 3 years ago committed by yann300
parent 8331b93837
commit dd5de59a2d
  1. 6
      apps/remix-ide-e2e/src/commands/addAtAddressInstance.ts
  2. 1
      apps/remix-ide-e2e/src/commands/validateValueInput.ts
  3. 4
      apps/remix-ide-e2e/src/tests/ballot.test.ts
  4. 4
      apps/remix-ide-e2e/src/tests/ballot_0_4_11.test.ts
  5. 13
      apps/remix-ide-e2e/src/tests/runAndDeploy.test.ts
  6. 4
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  7. 2
      libs/remix-ui/run-tab/src/lib/components/account.tsx
  8. 2
      libs/remix-ui/run-tab/src/lib/components/settingsUI.tsx
  9. 27
      libs/remix-ui/run-tab/src/lib/components/value.tsx
  10. 5
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  11. 4
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -18,10 +18,8 @@ function addInstance (browser: NightwatchBrowser, address: string, isValidFormat
if (!isValidFormat || !isValidChecksum) browser.assert.elementPresent('button[id^="runAndDeployAtAdressButton"]:disabled')
else {
browser.click('button[id^="runAndDeployAtAdressButton"]')
.execute(function () {
const modal = document.querySelector('[data-id="fileSystem-modal-footer-ok-react"]') as HTMLElement
modal.click()
})
.waitForElementPresent('[data-id="udappNotify-modal-footer-ok-react"]')
.click('[data-id="udappNotify-modal-footer-ok-react"]')
}
callback()
})

@ -6,6 +6,7 @@ class ValidateValueInput extends EventEmitter {
const browser = this.api
browser.perform((done) => {
browser.clearValue(selector)
.pause(2000)
.setValue(selector, valueTosSet)
.execute(function (selector) {
const elem = document.querySelector(selector) as HTMLInputElement

@ -84,8 +84,8 @@ module.exports = {
.openFile('Untitled.sol')
.clickLaunchIcon('udapp')
.click('*[data-id="settingsWeb3Mode"]')
.waitForElementPresent('[data-id="fileSystem-modal-footer-ok-react"]')
.click('[data-id="fileSystem-modal-footer-ok-react"]')
.waitForElementPresent('[data-id="udappNotify-modal-footer-ok-react"]')
.click('[data-id="udappNotify-modal-footer-ok-react"]')
.pause(5000)
.execute(function () {
const env: any = document.getElementById('selectExEnvOptions')

@ -79,8 +79,8 @@ module.exports = {
.openFile('Untitled.sol')
.clickLaunchIcon('udapp')
.click('*[data-id="settingsWeb3Mode"]')
.waitForElementPresent('[data-id="fileSystem-modal-footer-ok-react"]')
.click('[data-id="fileSystem-modal-footer-ok-react"]')
.waitForElementPresent('[data-id="udappNotify-modal-footer-ok-react"]')
.click('[data-id="udappNotify-modal-footer-ok-react"]')
.clickLaunchIcon('solidity')
.clickLaunchIcon('udapp')
.pause(2000)

@ -36,16 +36,19 @@ module.exports = {
.pause(2000)
.click('*[data-id="settingsRemixRunSignMsg"]')
.pause(2000)
.waitForElementVisible('*[data-id="modalDialogCustomPromptText"]', 120000)
.setValue('*[data-id="modalDialogCustomPromptText"]', 'Remix is cool!')
.waitForElementVisible('*[data-id="signMessageTextarea"]', 120000)
.click('*[data-id="signMessageTextarea"]')
.setValue('*[data-id="signMessageTextarea"]', 'Remix is cool!')
.assert.elementNotPresent('*[data-id="settingsRemixRunSignMsgHash"]')
.assert.elementNotPresent('*[data-id="settingsRemixRunSignMsgSignature"]')
.pause(2000)
.modalFooterOKClick()
.waitForElementVisible('*[data-id="modalDialogContainer"]', 12000)
.waitForElementPresent('[data-id="udappNotify-modal-footer-ok-react"]')
.click('[data-id="udappNotify-modal-footer-ok-react"]')
.waitForElementVisible('*[data-id="udappNotifyModalDialogModalBody-react"]', 12000)
.assert.elementPresent('*[data-id="settingsRemixRunSignMsgHash"]')
.assert.elementPresent('*[data-id="settingsRemixRunSignMsgSignature"]')
.modalFooterOKClick()
.waitForElementPresent('[data-id="udappNotify-modal-footer-ok-react"]')
.click('[data-id="udappNotify-modal-footer-ok-react"]')
},
'Should deploy contract on JavascriptVM #group3': function (browser: NightwatchBrowser) {

@ -717,3 +717,7 @@ export const updateScenarioPath = (path: string) => {
export const getFuncABIInputs = (funcABI: FuncABI) => {
return plugin.blockchain.getInputs(funcABI)
}
export const setSendTransactionValue = (value: string) => {
dispatch(setSendValue(value))
}

@ -123,7 +123,7 @@ export function AccountUI (props: AccountProps) {
<div>
<textarea
id="prompt_text"
data-id="modalDialogCustomPromptText"
data-id="signMessageTextarea"
style={{ width: '100%' }}
rows={4}
cols={50}

@ -16,7 +16,7 @@ export function SettingsUI (props: SettingsProps) {
<NetworkUI networkName={props.networkName} />
<AccountUI personalMode={props.personalMode} selectExEnv={props.selectExEnv} accounts={props.accounts} setAccount={props.setAccount} createNewBlockchainAccount={props.createNewBlockchainAccount} setPassphrase={props.setPassphrase} setMatchPassphrase={props.setMatchPassphrase} tooltip={props.tooltip} modal={props.modal} signMessageWithAddress={props.signMessageWithAddress} passphrase={props.passphrase} />
<GasPriceUI gasLimit={props.gasLimit} setGasFee={props.setGasFee} />
<ValueUI setUnit={props.setUnit} sendValue={props.sendValue} sendUnit={props.sendUnit} />
<ValueUI setUnit={props.setUnit} sendValue={props.sendValue} sendUnit={props.sendUnit} setSendValue={props.setSendValue} />
</div>
)
}

@ -1,11 +1,16 @@
// eslint-disable-next-line no-use-before-define
import React, { useRef } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import { BN } from 'ethereumjs-util'
import { isNumeric } from '@remix-ui/helper'
import { ValueProps } from '../types'
export function ValueUI (props: ValueProps) {
const inputValue = useRef(null)
const [sendValue, setSendValue] = useState<string>('')
useEffect(() => {
sendValue && props.setSendValue(sendValue)
}, [sendValue])
const validateInputKey = (e) => {
// preventing not numeric keys
@ -13,31 +18,32 @@ export function ValueUI (props: ValueProps) {
if (!isNumeric(e.key) ||
(e.key === '0' && !parseInt(inputValue.current.value) && inputValue.current.value.length > 0)) {
e.preventDefault()
e.stopImmediatePropagation()
}
}
const validateValue = () => {
if (!inputValue.current.value) {
const validateValue = (e) => {
const value = e.target.value
if (!value) {
// assign 0 if given value is
// - empty
inputValue.current.value = 0
setSendValue('0')
return
}
let v
try {
v = new BN(inputValue.current.value, 10)
inputValue.current.value = v.toString(10)
v = new BN(value, 10)
setSendValue(v.toString(10))
} catch (e) {
// assign 0 if given value is
// - not valid (for ex 4345-54)
// - contains only '0's (for ex 0000) copy past or edit
inputValue.current.value = 0
setSendValue('0')
}
// if giveen value is negative(possible with copy-pasting) set to 0
if (v.lt(0)) inputValue.current.value = 0
if (v.lt(0)) setSendValue('0')
}
return (
@ -45,6 +51,7 @@ export function ValueUI (props: ValueProps) {
<label className="udapp_settingsLabel" data-id="remixDRValueLabel">Value</label>
<div className="udapp_gasValueContainer">
<input
ref={inputValue}
type="number"
min="0"
pattern="^[0-9]"
@ -52,7 +59,7 @@ export function ValueUI (props: ValueProps) {
className="form-control udapp_gasNval udapp_col2"
id="value"
data-id="dandrValue"
value={props.sendValue}
value={sendValue || '0'}
title="Enter the value and choose the unit"
onKeyPress={validateInputKey}
onChange={validateValue}

@ -16,7 +16,7 @@ import {
clearPopUp, createNewBlockchainAccount,
setPassphrasePrompt, setMatchPassphrasePrompt,
signMessageWithAddress, getSelectedContract,
createInstance,
createInstance, setSendTransactionValue,
updateBaseFeePerGas, updateConfirmSettings,
updateGasPrice, updateGasPriceStatus,
updateMaxFee, updateMaxPriorityFee,
@ -228,6 +228,7 @@ export function RunTabUI (props: RunTabProps) {
setAccount={setAccount}
setUnit={setUnit}
sendValue={runTab.sendValue}
setSendValue={setSendTransactionValue}
sendUnit={runTab.sendUnit}
gasLimit={runTab.gasLimit}
setGasFee={setGasFee}
@ -287,7 +288,7 @@ export function RunTabUI (props: RunTabProps) {
/>
</div>
</div>
<ModalDialog id='fileSystem' { ...focusModal } handleHide={ handleHideModal } />
<ModalDialog id='udappNotify' { ...focusModal } handleHide={ handleHideModal } />
<Toaster message={focusToaster} handleHide={handleToaster} />
<PublishToStorage id='udapp' api={props.plugin} resetStorage={resetStorage} storage={publishData.storage} contract={publishData.contract} />
</Fragment>

@ -42,7 +42,8 @@ export interface SettingsProps {
tooltip: (toasterMsg: string) => void,
signMessageWithAddress: (account: string, message: string, modalContent: (hash: string, data: string) => JSX.Element, passphrase?: string) => void,
passphrase: string,
web3ProviderDialog: () => JSX.Element
web3ProviderDialog: () => JSX.Element,
setSendValue: (value: string) => void
}
export interface EnvironmentProps {
@ -95,6 +96,7 @@ export interface GasPriceProps {
export interface ValueProps {
setUnit: (unit: 'ether' | 'finney' | 'gwei' | 'wei') => void,
setSendValue: (value: string) => void,
sendValue: string,
sendUnit: string
}

Loading…
Cancel
Save