Finish up deploy

pull/5370/head
David Disu 3 years ago committed by yann300
parent 686a43b53c
commit 273590db04
  1. 5
      .eslintrc.json
  2. 2
      libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx
  3. 74
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  4. 1
      libs/remix-ui/run-tab/src/lib/actions/payload.ts
  5. 32
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  6. 39
      libs/remix-ui/run-tab/src/lib/components/mainnet.tsx
  7. 8
      libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
  8. 2
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  9. 50
      libs/remix-ui/run-tab/src/lib/types/index.ts
  10. 2
      libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx
  11. 6
      libs/remix-ui/solidity-compiler/src/lib/types/index.ts
  12. 1
      libs/remix-ui/workspace/src/lib/contexts/index.ts
  13. 1
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx
  14. 1
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -31,5 +31,8 @@
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
}
]
],
"globals": {
"JSX": true
}
}

@ -79,7 +79,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => {
resetStorage()
}
const modal = async (title: string, message: string | JSX.Element) => { // eslint-disable-line no-undef
const modal = async (title: string, message: string | JSX.Element) => {
await setState(prevState => {
return {
...prevState,

@ -7,7 +7,7 @@ import { addProvider, displayNotification, displayPopUp, fetchAccountsListFailed
import { RunTab } from '../types/run-tab'
import { CompilerAbstract } from '@remix-project/remix-solidity'
import * as remixLib from '@remix-project/remix-lib'
import { ContractData } from '../types'
import { ContractData, Network, Tx } from '../types'
declare global {
interface Window {
_paq: any
@ -228,7 +228,6 @@ const removeExternalProvider = (name) => {
dispatch(removeProvider(name))
}
// eslint-disable-next-line no-undef
export const setExecutionContext = (executionContext: { context: string, fork: string }, displayContent: JSX.Element) => {
plugin.blockchain.changeExecutionContext(executionContext, () => {
dispatch(displayNotification('External node request', displayContent, 'OK', 'Cancel', () => {
@ -250,7 +249,6 @@ export const clearPopUp = async () => {
dispatch(hidePopUp())
}
// eslint-disable-next-line no-undef
export const createNewBlockchainAccount = async (cbMessage: JSX.Element) => {
plugin.blockchain.newAccount(
'',
@ -283,7 +281,6 @@ export const setMatchPassphrasePrompt = (passphrase: string) => {
dispatch(setMatchPassphrase(passphrase))
}
// eslint-disable-next-line no-undef
export const signMessageWithAddress = (account: string, message: string, modalContent: (hash: string, data: string) => JSX.Element, passphrase?: string) => {
plugin.blockchain.signMessage(message, account, passphrase, (err, msgHash, signedData) => {
if (err) {
@ -382,27 +379,32 @@ const getCompilerContracts = () => {
return plugin.compilersArtefacts.__last.getData().contracts
}
// eslint-disable-next-line no-undef
const terminalLogger = (view: JSX.Element) => {
plugin.call('terminal', 'logHtml', view)
}
const getConfirmationCb = () => {
const getConfirmationCb = (confirmDialogContent: (
tx: Tx, network:
Network, amount: string,
gasEstimation: string,
gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void,
determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void
) => JSX.Element) => {
// this code is the same as in recorder.js. TODO need to be refactored out
const confirmationCb = (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
if (network.name !== 'Main') {
return continueTxExecution(null)
}
const amount = plugin.blockchain.fromWei(tx.value, true, 'ether')
const content = confirmDialog(tx, network, amount, gasEstimation, plugin.blockchain.determineGasFees(tx), plugin.blockchain.determineGasPrice.bind(plugin.blockchain))
const content = confirmDialogContent(tx, network, amount, gasEstimation, plugin.blockchain.determineGasFees(tx), plugin.blockchain.determineGasPrice.bind(plugin.blockchain))
dispatch(displayNotification('Confirm transaction', content, 'Confirm', 'Cancel', () => {
plugin.blockchain.config.setUnpersistedProperty('doNotShowTransactionConfirmationAgain', content.querySelector('input#confirmsetting').checked)
plugin.blockchain.config.setUnpersistedProperty('doNotShowTransactionConfirmationAgain', plugin.REACT_API.confirmSettings)
// TODO: check if this is check is still valid given the refactor
if (!content.gasPriceStatus) {
if (!plugin.REACT_API.gasPriceStatus) {
cancelCb('Given transaction fee is not correct')
} else {
continueTxExecution(content.txFee)
continueTxExecution({ maxFee: plugin.REACT_API.maxFee, maxPriorityFee: plugin.REACT_API.maxPriorityFee, baseFeePerGas: plugin.REACT_API.baseFeePerGas, gasPrice: plugin.REACT_API.gasPrice })
}
}, () => {
return cancelCb('Transaction canceled by user.')
@ -412,8 +414,22 @@ const getConfirmationCb = () => {
return confirmationCb
}
// eslint-disable-next-line no-undef
export const createInstance = async (selectedContract: ContractData, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, logBuilder: (msg: string) => JSX.Element, publishToStorage: (storage: 'ipfs' | 'swarm', contract: ContractData) => void) => {
export const createInstance = async (
selectedContract: ContractData,
gasEstimationPrompt: (msg: string) => JSX.Element,
passphrasePrompt: (msg: string) => JSX.Element,
logBuilder: (msg: string) => JSX.Element,
publishToStorage: (storage: 'ipfs' | 'swarm',
contract: ContractData) => void,
mainnetPrompt: (
tx: Tx, network:
Network, amount: string,
gasEstimation: string,
gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void,
determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void
) => JSX.Element,
isOverSizePrompt: () => JSX.Element,
args) => {
const continueCb = (error, continueTxExecution, cancelCb) => {
if (error) {
const msg = typeof error !== 'string' ? error.message : error
@ -468,33 +484,27 @@ export const createInstance = async (selectedContract: ContractData, gasEstimati
const compilerContracts = getCompilerContracts()
const confirmationCb = getConfirmationCb(mainnetPrompt)
// if (selectedContract.isOverSizeLimit()) {
// return modalDialog('Contract code size over limit', yo`<div>Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails. <br>
// More info: <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md" target="_blank">eip-170</a>
// </div>`,
// {
// label: 'Force Send',
// fn: () => {
// this.deployContract(selectedContract, args, contractMetadata, compilerContracts, { continueCb, promptCb, statusCb, finalCb }, confirmationCb)
// }
// }, {
// label: 'Cancel',
// fn: () => {
// this.logCallback(`creation of ${selectedContract.name} canceled by user.`)
// }
// })
// }
// this.deployContract(selectedContract, args, contractMetadata, compilerContracts, { continueCb, promptCb, statusCb, finalCb }, confirmationCb)
if (selectedContract.isOverSizeLimit()) {
return dispatch(displayNotification('Contract code size over limit', isOverSizePrompt(), 'Force Send', 'Cancel', () => {
deployContract(selectedContract, args, contractMetadata, compilerContracts, { continueCb, promptCb, statusCb, finalCb }, confirmationCb)
}, () => {
const log = logBuilder(`creation of ${selectedContract.name} canceled by user.`)
return terminalLogger(log)
}))
}
deployContract(selectedContract, args, contractMetadata, compilerContracts, { continueCb, promptCb, statusCb, finalCb }, confirmationCb)
}
const deployContract = (selectedContract, args, contractMetadata, compilerContracts, callbacks, confirmationCb) => {
_paq.push(['trackEvent', 'udapp', 'DeployContractTo', this.networkName + '_' + this.networkId])
_paq.push(['trackEvent', 'udapp', 'DeployContractTo', plugin.REACT_API.networkName])
const { statusCb } = callbacks
if (!contractMetadata || (contractMetadata && contractMetadata.autoDeployLib)) {
return this.blockchain.deployContractAndLibraries(selectedContract, args, contractMetadata, compilerContracts, callbacks, confirmationCb)
return plugin.blockchain.deployContractAndLibraries(selectedContract, args, contractMetadata, compilerContracts, callbacks, confirmationCb)
}
if (Object.keys(selectedContract.bytecodeLinkReferences).length) statusCb(`linking ${JSON.stringify(selectedContract.bytecodeLinkReferences, null, '\t')} using ${JSON.stringify(contractMetadata.linkReferences, null, '\t')}`)
this.blockchain.deployContractWithLibrary(selectedContract, args, contractMetadata, compilerContracts, callbacks, confirmationCb)
plugin.blockchain.deployContractWithLibrary(selectedContract, args, contractMetadata, compilerContracts, callbacks, confirmationCb)
}
export const setCheckIpfs = (value: boolean) => {

@ -1,4 +1,3 @@
/* eslint-disable no-undef */
export const fetchAccountsListRequest = () => {
return {
type: 'FETCH_ACCOUNTS_LIST_REQUEST',

@ -1,9 +1,10 @@
// eslint-disable-next-line no-use-before-define
import React, { useEffect, useState } from 'react'
import { ContractData, ContractDropdownProps } from '../types'
import { ContractData, ContractDropdownProps, Network, Tx } from '../types'
import * as ethJSUtil from 'ethereumjs-util'
import { ContractGUI } from './contractGUI'
import { PassphrasePrompt } from './passphrase'
import { MainnetPrompt } from './mainnet'
export function ContractDropdownUI (props: ContractDropdownProps) {
const [networkName, setNetworkName] = useState<string>('')
@ -121,7 +122,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
if (selectedContract.bytecodeObject.length === 0) {
return props.modal('Alert', 'This contract may be abstract, not implement an abstract parent\'s methods completely or not invoke an inherited contract\'s constructor correctly.', 'OK', () => {})
}
props.createInstance(loadedContractData, gasEstimationPrompt, passphrasePrompt, logBuilder, props.publishToStorage)
props.createInstance(loadedContractData, gasEstimationPrompt, passphrasePrompt, logBuilder, props.publishToStorage, mainnetPrompt, isOverSizePrompt, args)
}
// listenToContextChange () {
@ -346,8 +347,31 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
return <PassphrasePrompt message={message} setPassphrase={props.setPassphrase} defaultValue={props.passphrase} />
}
const mainnetPrompt = () => {
const mainnetPrompt = (tx: Tx, network: Network, amount: string, gasEstimation: string, gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void, determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void) => {
return <MainnetPrompt
init={determineGasPrice}
network={network}
tx={tx}
amount={amount}
gasEstimation={gasEstimation}
setNewGasPrice={gasFees}
updateBaseFeePerGas={props.updateBaseFeePerGas}
updateConfirmSettings={props.updateConfirmSettings}
updateGasPrice={props.updateGasPrice}
updateGasPriceStatus={props.updateGasPriceStatus}
updateMaxFee={props.updateMaxFee}
updateMaxPriorityFee={props.updateMaxPriorityFee}
setTxFeeContent={props.updateTxFeeContent}
txFeeContent={props.txFeeContent}
/>
}
const isOverSizePrompt = () => {
return (
<div>Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails. <br />
More info: <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-170.md" target="_blank">eip-170</a>
</div>
)
}
return (

@ -2,34 +2,9 @@
import React, { useEffect } from 'react'
import { CopyToClipboard } from '@remix-ui/clipboard'
import Web3 from 'web3'
import { MainnetProps } from '../types'
interface MainnetProps {
network: {
name: string,
lastBlock: {
baseFeePerGas: string
}
},
tx: {
from: string,
to: string,
data: string,
gas: string
},
amount: string,
gasEstimation: string,
setNewGasPrice: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void,
updateGasPriceStatus: (status: boolean) => void,
updateConfirmSettings: (confirmation: boolean) => void,
updateMaxFee: (fee: string) => void,
updateBaseFeePerGas: (fee: string) => void,
init: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void,
setTxFeeContent: (content: string) => void,
updateGasPrice: (price: string) => void,
txFeeContent: string
}
export function PassphrasePrompt (props: MainnetProps) {
export function MainnetPrompt (props: MainnetProps) {
useEffect(() => {
props.init((txFeeText, gasPriceValue, gasPriceStatus) => {
if (txFeeText) props.setTxFeeContent(txFeeText)
@ -75,6 +50,10 @@ export function PassphrasePrompt (props: MainnetProps) {
})
}
const onMaxPriorityFeeChange = (value: string) => {
props.updateMaxPriorityFee(value)
}
return (
<div>
<div className="text-dark">You are about to create a transaction on {props.network.name} Network. Confirm the details to send the info to your provider.
@ -113,14 +92,14 @@ export function PassphrasePrompt (props: MainnetProps) {
<div className="align-items-center my-1" title="Represents the part of the tx fee that goes to the miner.">
<div className='d-flex'>
<span className="text-dark mr-2 text-nowrap">Max Priority fee:</span>
<input className="form-control mr-1 text-right" style={{ height: '1.2rem', width: '6rem' }} value="1" id='maxpriorityfee' />
<input className="form-control mr-1 text-right" style={{ height: '1.2rem', width: '6rem' }} value="1" id='maxpriorityfee' onInput={(e: any) => onMaxPriorityFeeChange(e.target.value)} />
<span title="visit https://ethgasstation.info for current gas price info.">Gwei</span>
</div>
</div>
<div className="align-items-center my-1" title="Represents the maximum amount of fee that you will pay for this transaction. The minimun needs to be set to base fee.">
<div className='d-flex'>
<span className="text-dark mr-2 text-nowrap">Max fee (Not less than base fee {Web3.utils.fromWei(Web3.utils.toBN(parseInt(props.network.lastBlock.baseFeePerGas, 16)), 'Gwei')} Gwei):</span>
<input className="form-control mr-1 text-right" style={{ height: '1.2rem', width: '6rem' }} id='maxfee' onInput={(e) => onMaxFeeChange(e.target.value)} />
<input className="form-control mr-1 text-right" style={{ height: '1.2rem', width: '6rem' }} id='maxfee' onInput={(e: any) => onMaxFeeChange(e.target.value)} />
<span>Gwei</span>
<span className="text-dark ml-2"></span>
</div>
@ -128,7 +107,7 @@ export function PassphrasePrompt (props: MainnetProps) {
</div>
: <div className="d-flex align-items-center my-1">
<span className="text-dark mr-2 text-nowrap">Gas price:</span>
<input className="form-control mr-1 text-right" style={{ width: '40px', height: '28px' }} id='gasprice' onInput={(e) => onGasPriceChange(e.target.value)} />
<input className="form-control mr-1 text-right" style={{ width: '40px', height: '28px' }} id='gasprice' onInput={(e: any) => onGasPriceChange(e.target.value)} />
<span>Gwei (visit <a target='_blank' href='https://ethgasstation.info'>ethgasstation.info</a> for current gas price info.)</span>
</div>
}

@ -60,7 +60,8 @@ export interface RunTabState {
maxFee: string,
maxPriorityFee: string,
baseFeePerGas: string,
txFeeContent: string
txFeeContent: string,
gasPrice: string
}
export const runTabInitialState: RunTabState = {
@ -134,9 +135,10 @@ export const runTabInitialState: RunTabState = {
gasPriceStatus: false,
confirmSettings: false,
maxFee: '',
maxPriorityFee: '',
maxPriorityFee: '1',
baseFeePerGas: '',
txFeeContent: ''
txFeeContent: '',
gasPrice: ''
}
export const runTabReducer = (state: RunTabState = runTabInitialState, action: Action) => {

@ -102,7 +102,6 @@ export function RunTabUI (props: RunTabProps) {
}
}, [runTab.popup])
// eslint-disable-next-line no-undef
const modal = (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => {
setModals(modals => {
modals.push({ message, title, okLabel, okFn, cancelLabel, cancelFn })
@ -187,6 +186,7 @@ export function RunTabUI (props: RunTabProps) {
updateMaxFee={updateMaxFee}
updateMaxPriorityFee={updateMaxPriorityFee}
updateTxFeeContent={updateTxFeeContent}
txFeeContent={runTab.txFeeContent}
/>
<RecorderUI />
<InstanceContainerUI />

@ -1,4 +1,3 @@
/* eslint-disable no-undef */
import { RunTab } from './run-tab'
export interface RunTabProps {
plugin: RunTab
@ -116,6 +115,20 @@ export interface ContractData {
metadata: any
}
export interface Tx {
from: string,
to: string,
data: string,
gas: string
}
export interface Network {
name: string,
lastBlock: {
baseFeePerGas: string
}
}
export interface ContractDropdownProps {
exEnvironment: string,
contracts: {
@ -134,7 +147,21 @@ export interface ContractDropdownProps {
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
passphrase: string,
setPassphrase: (passphrase: string) => void,
createInstance: (selectedContract: ContractData, gasEstimationPrompt: (msg: string) => JSX.Element, passphrasePrompt: (msg: string) => JSX.Element, logBuilder: (msg: string) => JSX.Element, publishToStorage: (storage: 'ipfs' | 'swarm', contract: ContractData) => void) => void,
createInstance: (selectedContract: ContractData,
gasEstimationPrompt: (msg: string) => JSX.Element,
passphrasePrompt: (msg: string) => JSX.Element,
logBuilder: (msg: string) => JSX.Element,
publishToStorage: (storage: 'ipfs' | 'swarm',
contract: ContractData) => void,
mainnetPrompt: (
tx: Tx, network:
Network, amount: string,
gasEstimation: string,
gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void,
determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void
) => JSX.Element,
isOverSizePrompt: () => JSX.Element,
args) => void,
ipfsCheckedState: boolean,
setIpfsCheckedState: (value: boolean) => void,
publishToStorage: (storage: 'ipfs' | 'swarm', contract: ContractData) => void,
@ -144,7 +171,8 @@ export interface ContractDropdownProps {
updateMaxFee: (fee: string) => void,
updateMaxPriorityFee: (fee: string) => void,
updateGasPrice: (price: string) => void,
updateTxFeeContent: (content: string) => void
updateTxFeeContent: (content: string) => void,
txFeeContent: string
}
export interface RecorderProps {
@ -181,3 +209,19 @@ export interface ContractGUIProps {
evmBC: any,
lookupOnly: boolean
}
export interface MainnetProps {
network: Network,
tx: Tx,
amount: string,
gasEstimation: string,
setNewGasPrice: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void,
updateGasPriceStatus: (status: boolean) => void,
updateConfirmSettings: (confirmation: boolean) => void,
updateMaxFee: (fee: string) => void,
updateBaseFeePerGas: (fee: string) => void,
init: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void,
setTxFeeContent: (content: string) => void,
updateGasPrice: (price: string) => void,
updateMaxPriorityFee: (fee: string) => void
txFeeContent: string
}

@ -81,7 +81,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
setCurrentVersion(value)
api.setCompilerParameters({ version: value })
}
// eslint-disable-next-line no-undef
const modal = async (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => {
await setState(prevState => {
return {

@ -10,8 +10,8 @@ export interface CompilerContainerProps {
api: ICompilerApi,
compileTabLogic: CompileTabLogic,
isHardhatProject: boolean,
tooltip: (message: string | JSX.Element) => void, // eslint-disable-line no-undef
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, // eslint-disable-line no-undef
tooltip: (message: string | JSX.Element) => void,
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
compiledFileName: string,
updateCurrentVersion: any,
configurationSettings: ConfigurationSettings
@ -21,6 +21,6 @@ export interface ContractSelectionProps {
contractMap: {
file: string
} | Record<string, any>,
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void, // eslint-disable-line no-undef
modal: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
contractsDetails: Record<string, any>
}

@ -4,7 +4,6 @@ import { BrowserState } from '../reducers/workspace'
export const FileSystemContext = createContext<{
fs: BrowserState,
// eslint-disable-next-line no-undef
modal:(title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => void,
dispatchInitWorkspace:() => Promise<void>,
dispatchFetchDirectory:(path: string) => Promise<void>,

@ -170,7 +170,6 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
})
}
// eslint-disable-next-line no-undef
const modal = (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void) => {
setModals(modals => {
modals.push({ message, title, okLabel, okFn, cancelLabel, cancelFn })

@ -41,7 +41,6 @@ export interface WorkspaceState {
export interface Modal {
hide?: boolean
title: string
// eslint-disable-next-line no-undef
message: string | JSX.Element
okLabel: string
okFn: () => void

Loading…
Cancel
Save