Skip to content

Commit

Permalink
Merge pull request #180 from rsksmart/unsopported-solidity-versions
Browse files Browse the repository at this point in the history
feat: add unsupport solidity version verification logic
  • Loading branch information
ezequiel-rodriguez authored Nov 7, 2023
2 parents 39bb5dc + eaa46ce commit d012214
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
22 changes: 19 additions & 3 deletions src/components/VerifyContract.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
form-row(v-if='versionsData' v-bind='formFields.VERSION')
select(name='version' :value='version' @change='changeVersion($event.target.value)' :class='cssClass("version")')
option(v-for="path,version in versions" :value='path') {{path}}
ctrl-switch( :value='showAllVersions' @change='(value)=>showAllVersions=value' label='Show all versions')
ctrl-switch( :value='showAllVersions' @change='(value) => changeAllVersions(value)' label='Show all versions')

form-row(v-bind='formFields.OPTIMIZATION')
ctrl-radio-grp.frow(name='optimization' @change='(value)=>settings.optimizer.enabled=value' :selected='settings.optimizer.enabled')
Expand Down Expand Up @@ -116,6 +116,7 @@ import { camelCaseTo } from '../filters/TextFilters'
import { ObjectIdSecondsElapsed, isAddress } from '../lib/js/utils'
import { messages, formFields } from '../config/texts/verifyContract'
import { ROUTES } from '../config/types'
import { UNSUPPORTED_SOLC_VERSIONS } from '@/config/entities/lib/solidityVersions'
const KEYS = {
contract: '__contractVerifierContract',
Expand Down Expand Up @@ -277,7 +278,6 @@ export default {
if (releases) releases = this.releasesList(releases)
return (showAllVersions) ? builds : releases
},
evmVersions () {
const { data } = this.getPage()(EVM_VERSIONS_KEY) || {}
return data
Expand All @@ -295,7 +295,7 @@ export default {
}, {})
const params = Object.assign({}, { address, settings, version, name })
let ready = !Object.values(params).filter(v => undefined === v).length
ready = (files.length) ? ready : false
ready = (files.length) && this.isSupportedSolidityVersion() ? ready : false
if (!ready) return false
const imports = [...files]
const source = imports[0].contents
Expand Down Expand Up @@ -416,6 +416,15 @@ export default {
changeVersion (version) {
this.version = version
this.inputErrors.delete('version')
this.errors.pop()
if (!this.isSupportedSolidityVersion()) {
this.errors.push(messages.NOT_SUPPORTED_SOLIDITY_VERSION_ERROR(version))
}
},
changeAllVersions (version) {
this.showAllVersions = version
this.inputErrors.delete('version')
this.errors.pop()
},
getContract (event) {
const { address } = this
Expand Down Expand Up @@ -465,6 +474,10 @@ export default {
if (!this.version) this.inputErrors.add('version')
if (!this.files.length) this.inputErrors.add('file')
if (!this.name) this.inputErrors.add('name')
if (!this.isSupportedSolidityVersion()) {
this.inputErrors.add('version')
this.errors.push(messages.NOT_SUPPORTED_SOLIDITY_VERSION_ERROR(this.version))
}
},
async requestVerification (request) {
Expand All @@ -487,6 +500,9 @@ export default {
}
if (constructorArguments) constructorArguments = constructorArguments.split(',')
return { constructorArguments, encodedConstructorArguments }
},
isSupportedSolidityVersion () {
return !(UNSUPPORTED_SOLC_VERSIONS.find((v) => this.version.includes(v)))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/config/entities/lib/solidityVersions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const UNSUPPORTED_SOLC_VERSIONS = []
5 changes: 3 additions & 2 deletions src/config/texts/verifyContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export const messages = {
VERIFICATION_FAILED: 'Verification failed',
REQUEST_VERIFICATION: 'Requesting verification',
SHOW_RESULT: 'Go to contract page',
VERIFIER_DATA_ERROR: 'Missing contract verifier data'
VERIFIER_DATA_ERROR: 'Missing contract verifier data',
NOT_SUPPORTED_SOLIDITY_VERSION_ERROR: (value) => `You have selected version ${value} which is not supported. Please, try another one.`
}

export const formFields = {
ADDRESS: add('Contract Address'),
NAME: add('Contract name', `Contract name declared in code,
NAME: add('Contract name', `Contract name declared in code,
\n e.g. contract MyContract {}
\n 'MyContract' is the contract name.`),
SOURCE: add('Source file', '.sol source file of contract'),
Expand Down

0 comments on commit d012214

Please sign in to comment.