Skip to content

Commit

Permalink
fix lint etc
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Mar 9, 2023
1 parent 2942cb2 commit 090c2c8
Show file tree
Hide file tree
Showing 30 changed files with 110 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .env.basealpha
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ VUE_APP_LINKED_VERIFIER_SUBIDENTIFIER=torus
VUE_APP_LOGIN_DOMAIN=https://torus-test.auth0.com
VUE_APP_PASSWORDLESS_DOMAIN=https://lrc.auth.openlogin.com
VUE_APP_DEVELOPER_DASHBOARD_URL=https://api-dev-dashboard.web3auth.io
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
2 changes: 1 addition & 1 deletion .env.binance
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ VUE_APP_HIDE_TOPUP=true
VUE_APP_TKEY_SECURITY_QUESTIONS_MANDATORY=true
VUE_APP_ETH_TRANSFER_ONLY=true
VUE_APP_SENTRY_DSN=https://92430bf0bfdc4b82b7239c359b98ac56@o503538.ingest.sentry.io/5607693
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
2 changes: 1 addition & 1 deletion .env.bnb
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ VUE_APP_SENTRY_DSN=https://f41105d21e8d44048a36e7fdee4bafcd@o503538.ingest.sentr
VUE_APP_DEVELOPER_DASHBOARD_URL=https://api.developer.tor.us
# this is for bnb.tor.us
VUE_APP_OPENLOGIN_ORIGIN_SIGNATURE=MEQCIB9wN5FYV91zbJWssKw-T707Iz-k2qigQ8OB6tt0N_IGAiAJ6aoQZ2oM3RBJ6G1bFeU8zPv54cv_LBYzOVtXZj6G3w
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ VUE_APP_LOGIN_DOMAIN=https://torus-test.auth0.com
VUE_APP_PASSWORDLESS_DOMAIN=https://lrc.auth.openlogin.com
VUE_APP_DEVELOPER_DASHBOARD_URL=https://api-dev-dashboard.web3auth.io
# VUE_APP_DEVELOPER_DASHBOARD_URL=http://localhost:5051
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
2 changes: 1 addition & 1 deletion .env.lrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ VUE_APP_PASSWORDLESS_DOMAIN=https://lrc.auth.openlogin.com
VUE_APP_DEVELOPER_DASHBOARD_URL=https://api-dev-dashboard.web3auth.io
# this is for lrc.tor.us
VUE_APP_OPENLOGIN_ORIGIN_SIGNATURE=MEQCIGv3oTOdAMltfeDrcT-0ilhYlGuZ8yuhezQHU883XjJEAiByG6Duhn5kqNgEy2oJosza1t0VOfPxzeI25g_ZHysXNA
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
2 changes: 1 addition & 1 deletion .env.polygon
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ VUE_APP_SENTRY_DSN=https://f41105d21e8d44048a36e7fdee4bafcd@o503538.ingest.sentr
VUE_APP_DEVELOPER_DASHBOARD_URL=https://api.developer.tor.us
# this is for polygon.tor.us
VUE_APP_OPENLOGIN_ORIGIN_SIGNATURE=MEQCIHmKCljC6Ncxe-TyhKHWxTUI7eFj3kjUEqgu40aLZkS0AiAki72DNFmj2WD_itl-5LZ_wYzK1ZS_B7o5qzHzSnzI5w
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ VUE_APP_SENTRY_DSN=https://f41105d21e8d44048a36e7fdee4bafcd@o503538.ingest.sentr
VUE_APP_DEVELOPER_DASHBOARD_URL=https://api.developer.tor.us
# this is for app.tor.us
VUE_APP_OPENLOGIN_ORIGIN_SIGNATURE=MEUCIQDFdkBIGWMCQzmclVVWSrUiropSXKmh9OudXiOhp-jZfwIgdCCO2LM3xE5XQPVQA4M4d_GNwYU-h87ieA3cfhZ6-Yo
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
2 changes: 1 addition & 1 deletion .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ VUE_APP_PASSWORDLESS_DOMAIN=https://auth.openlogin.com
VUE_APP_DEVELOPER_DASHBOARD_URL=https://api.developer.tor.us
# this is for testing.tor.us
VUE_APP_OPENLOGIN_ORIGIN_SIGNATURE=MEUCIQDtJOb6jb4iY6-ENsf8IB19W0SZ21VJFNHd1GfSTOj7RwIgfIiCR7QU8MA-kIkv_qaF28fqTljaCLvF38-oWtvg-ZI
VUE_APP_WALLET_CONNECT_PROJECT_ID=04309ed1007e77d1f119b85205bb779d
VUE_APP_WALLET_CONNECT_PROJECT_ID=000b7e9596f9a108b279f1a72ee7cd31
28 changes: 14 additions & 14 deletions src/components/Confirm/ConfirmForm/ConfirmForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ export default {
return `~ ${totalCost} ${this.selectedCurrency}`
},
currencyMultiplier() {
const currencyMultiplierNumber = this.selectedCurrency !== 'ETH' ? this.currencyData[this.selectedCurrency.toLowerCase()] || 1 : 1
const currencyMultiplierNumber = this.selectedCurrency === 'ETH' ? 1 : this.currencyData[this.selectedCurrency.toLowerCase()] || 1
return new BigNumber(currencyMultiplierNumber)
},
getCurrencyRate() {
Expand Down Expand Up @@ -712,18 +712,7 @@ export default {
this.id = id
this.message = data
this.sender = from
} else if (type !== TRANSACTION_TYPES.STANDARD_TRANSACTION) {
const { msgParams: { message, typedMessages } = {}, id = '' } = msgParams || {}
let finalTypedMessages = typedMessages
try {
finalTypedMessages = typedMessages && JSON.parse(typedMessages)
} catch (error) {
log.error(error)
}
this.id = id
this.message = message
this.typedMessages = finalTypedMessages
} else {
} else if (type === TRANSACTION_TYPES.STANDARD_TRANSACTION) {
let finalValue = new BigNumber('0')
const { simulationFails, id, transactionCategory, methodParams, contractParams, txParams: txObject, userInfo } = txParams || {}
const { value, to, data, from: sender, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas } = txObject || {}
Expand Down Expand Up @@ -834,7 +823,7 @@ export default {
this.gasEstimate = new BigNumber(gas, 16) // gas number
this.gasEstimateDefault = new BigNumber(gas, 16) // gas number
this.txData = data // data hex
this.txDataParams = txDataParameters !== '' ? JSON.stringify(txDataParameters, null, 2) : ''
this.txDataParams = txDataParameters === '' ? '' : JSON.stringify(txDataParameters, null, 2)
this.sender = sender // address of sender
this.gasCost = this.gasEstimate.times(gweiGasPrice).div(new BigNumber('10').pow(new BigNumber('9')))
this.txFees = this.gasCost.times(this.currencyMultiplier)
Expand All @@ -856,6 +845,17 @@ export default {
this.errorMsg = ''
this.topUpErrorShow = false
}
} else {
const { msgParams: { message, typedMessages } = {}, id = '' } = msgParams || {}
let finalTypedMessages = typedMessages
try {
finalTypedMessages = typedMessages && JSON.parse(typedMessages)
} catch (error) {
log.error(error)
}
this.id = id
this.message = message
this.typedMessages = finalTypedMessages
}
this.type = type // type of tx
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
return this.supportedNetworks[this.network].networkName
}
finalNetwork = !state.networkType.networkName ? state.networkType.host : state.networkType.networkName
finalNetwork = state.networkType.networkName ? state.networkType.networkName : state.networkType.host
return finalNetwork
},
}),
Expand Down
32 changes: 16 additions & 16 deletions src/components/WalletAccount/AccountImport/AccountImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,7 @@ export default {
this.setErrorState(new Error('Unable to parse keystore file'))
return
}
if (!window.Worker) {
this.$store
.dispatch('importAccount', { keyData: [keyData, this.jsonPassword], strategy: 'JSON File' })
.then((privKey) => {
this.onClose()
this.keyStoreFileContents = ''
this.jsonPassword = ''
this.showJsonPassword = false
this.isLoadingKeystore = false
this.informClients(privKey)
this.$refs.jsonFileForm.resetValidation()
})
.catch((error) => {
this.setErrorState(error)
})
} else {
if (window.Worker) {
const worker = new WalletWorker()
worker.addEventListener('message', (event) => {
const { privateKey: bufferPrivateKey } = event.data
Expand All @@ -286,6 +271,21 @@ export default {
this.isLoadingKeystore = false
})
worker.postMessage({ type: 'unlockWallet', data: [keyData, this.jsonPassword] })
} else {
this.$store
.dispatch('importAccount', { keyData: [keyData, this.jsonPassword], strategy: 'JSON File' })
.then((privKey) => {
this.onClose()
this.keyStoreFileContents = ''
this.jsonPassword = ''
this.showJsonPassword = false
this.isLoadingKeystore = false
this.informClients(privKey)
this.$refs.jsonFileForm.resetValidation()
})
.catch((error) => {
this.setErrorState(error)
})
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/WalletSettings/Network/Network.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default {
...mapGetters(['supportedNetworks']),
...mapState(['networkType']),
networks() {
return [...Object.values(this.supportedNetworks)]
return Object.values(this.supportedNetworks)
},
isRPCSelected() {
return this.selectedNetwork.host === RPC
Expand Down
10 changes: 5 additions & 5 deletions src/components/WalletSettings/PrivateKeys/PrivateKeys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,7 @@ export default {
if (this.$refs.downloadForm.validate()) {
this.isLoadingDownloadWallet = true
if (!window.Worker) {
const finishedWallet = await this.createWallet(this.keyStorePassword)
this.exportKeyStoreFile(finishedWallet)
this.isLoadingDownloadWallet = false
} else {
if (window.Worker) {
const worker = new WalletWorker()
worker.addEventListener('message', (ev) => {
const finishedWallet = ev.data
Expand All @@ -233,6 +229,10 @@ export default {
})
// log.info(this.keyStorePassword, this.selectedKey)
worker.postMessage({ type: 'createWallet', data: [this.keyStorePassword, this.selectedKey] })
} else {
const finishedWallet = await this.createWallet(this.keyStorePassword)
this.exportKeyStoreFile(finishedWallet)
this.isLoadingDownloadWallet = false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export default {
},
gasFees(newValue, oldValue) {
if (!isEqual(newValue, oldValue)) {
this.updateDetails(this.newSelectedSpeed !== '' ? this.newSelectedSpeed : this.oldSelectedSpeed)
this.updateDetails(this.newSelectedSpeed === '' ? this.oldSelectedSpeed : this.newSelectedSpeed)
}
},
showAdvance(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export default {
this.newNonce = this.nonce >= 0 ? this.nonce : this.nonceItems[0]
},
convertedDisplay(amount, multiplier) {
return !BigNumber.isBigNumber(amount) ? new BigNumber(amount).times(multiplier) : amount.times(multiplier)
return BigNumber.isBigNumber(amount) ? amount.times(multiplier) : new BigNumber(amount).times(multiplier)
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Popup/PopupWidget/PopupWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export default {
getActionText(transaction) {
if (transaction.type_name === 'n/a' || transaction.type === 'n/a') {
return `${transaction.action === ACTIVITY_ACTION_SEND ? this.t('walletActivity.sent') : this.t('walletActivity.received')} ${
transaction.type_name !== 'n/a' ? transaction.type_name : transaction.type?.toUpperCase() || ''
transaction.type_name === 'n/a' ? transaction.type?.toUpperCase() || '' : transaction.type_name
}`
}
if (transaction.type_name || transaction.type) {
Expand Down
6 changes: 3 additions & 3 deletions src/containers/WalletHistory/WalletHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default {
return finalTx.sort((a, b) => b.date - a.date) || []
},
currencyMultiplier() {
const currencyMultiplierNumber = this.selectedCurrency !== 'ETH' ? this.currencyData[this.selectedCurrency.toLowerCase()] || 1 : 1
const currencyMultiplierNumber = this.selectedCurrency === 'ETH' ? 1 : this.currencyData[this.selectedCurrency.toLowerCase()] || 1
return new BigNumber(currencyMultiplierNumber)
},
},
Expand Down Expand Up @@ -270,11 +270,11 @@ export default {
return this.t('walletActivity.contractDeployment')
}
if (activity.transaction_category === TRANSACTION_TYPES.TOKEN_METHOD_APPROVE) {
return `${this.t('walletActivity.approved')} ${activity.type_name !== 'n/a' ? activity.type_name.toUpperCase() : activity.type.toUpperCase()}`
return `${this.t('walletActivity.approved')} ${activity.type_name === 'n/a' ? activity.type.toUpperCase() : activity.type_name.toUpperCase()}`
}
if (activity.type_name === 'n/a' || activity.type === 'n/a') {
return `${activity.action === ACTIVITY_ACTION_SEND ? this.t('walletActivity.sent') : this.t('walletActivity.received')} ${
activity.type_name !== 'n/a' ? activity.type_name : activity.type.toUpperCase()
activity.type_name === 'n/a' ? activity.type.toUpperCase() : activity.type_name
}`
}
if (activity.type_name || activity.type) {
Expand Down
4 changes: 2 additions & 2 deletions src/containers/WalletTransfer/WalletTransfer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ export default {
const selectedAsset =
this.contractType === CONTRACT_TYPE_ERC721 || this.contractType === CONTRACT_TYPE_ERC1155 ? this.assetSelected.name : this.selectedItem.symbol
const amount = `${this.contractType === CONTRACT_TYPE_ERC721 || this.contractType === CONTRACT_TYPE_ERC1155 ? '' : this.displayAmount} ${
!this.toggle_exclusive ? selectedAsset : this.selectedCurrency
this.toggle_exclusive ? this.selectedCurrency : selectedAsset
}`
const message = this.t('walletTransfer.transferTweet')
.replace(/{address}/gi, this.toAddress)
Expand Down Expand Up @@ -1312,7 +1312,7 @@ export default {
this.toggle_exclusive = value
const currencyRate = this.getCurrencyTokenRate
if (value === 0) {
this.onChangeDisplayAmount(!currencyRate.eq(new BigNumber('0')) ? this.displayAmount.div(currencyRate) : this.displayAmount)
this.onChangeDisplayAmount(currencyRate.eq(new BigNumber('0')) ? this.displayAmount : this.displayAmount.div(currencyRate))
} else if (value === 1) {
this.onChangeDisplayAmount(this.displayAmount.times(currencyRate))
}
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/AssetsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ export default class AssetController {
return {}
}
}
if (!normalizedContractInfo.logo) {
// fallback to asset image
normalizedContractInfo.logo = assetImage
} else {
if (normalizedContractInfo.logo) {
try {
await validateImageUrl(sanitizeNftMetdataUrl(normalizedContractInfo.logo))
} catch {
normalizedContractInfo.logo = assetImage
}
} else {
// fallback to asset image
normalizedContractInfo.logo = assetImage
}
return normalizedContractInfo
}
Expand Down
15 changes: 8 additions & 7 deletions src/controllers/PreferencesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class PreferencesController extends SafeEventEmitter {
this.errorStore.putState(error)
} else if (error && typeof error === 'object') {
const prettyError = prettyPrintData(error)
const payloadError = prettyError !== '' ? `Error: ${prettyError}` : 'Something went wrong. Pls try again'
const payloadError = prettyError === '' ? 'Something went wrong. Pls try again' : `Error: ${prettyError}`
this.errorStore.putState(payloadError)
} else {
this.errorStore.putState(error || '')
Expand All @@ -189,7 +189,7 @@ class PreferencesController extends SafeEventEmitter {
this.successStore.putState(message)
} else if (message && typeof message === 'object') {
const prettyMessage = prettyPrintData(message)
const payloadMessage = prettyMessage !== '' ? `Success: ${prettyMessage}` : 'Success'
const payloadMessage = prettyMessage === '' ? 'Success' : `Success: ${prettyMessage}`
this.successStore.putState(payloadMessage)
} else {
this.successStore.putState(message || '')
Expand Down Expand Up @@ -327,11 +327,11 @@ class PreferencesController extends SafeEventEmitter {
x.from &&
(lowerCaseSelectedAddress === x.from.toLowerCase() || lowerCaseSelectedAddress === x.to.toLowerCase())
) {
if (x.status !== 'confirmed') {
pendingTx.push(x)
} else {
if (x.status === 'confirmed') {
const finalObject = formatPastTx(x, lowerCaseSelectedAddress)
pastTx.push(finalObject)
} else {
pendingTx.push(x)
}
}
}
Expand All @@ -354,9 +354,10 @@ class PreferencesController extends SafeEventEmitter {
const nonceMap = {}
for (const x of pastTx) {
const txKey = [x.nonce, x.from].join(':')
if (!nonceMap[txKey]) nonceMap[txKey] = [x]
else {
if (nonceMap[txKey]) {
nonceMap[txKey].push(x)
} else {
nonceMap[txKey] = [x]
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/network/NetworkController.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ export default class NetworkController extends EventEmitter {
getCurrentChainId() {
const { type, chainId: configChainId } = this.getProviderConfig()
const chainId = SUPPORTED_NETWORK_TYPES[type]?.chainId || configChainId
return !isHexStrict(chainId) ? `0x${Number(chainId).toString(16)}` : chainId
return isHexStrict(chainId) ? chainId : `0x${Number(chainId).toString(16)}`
}

setRpcTarget(networkId, rpcUrl, chainId, ticker = 'ETH', nickname = '', rpcPrefs = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/transactions/TransactionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ class TransactionController extends SafeEventEmitter {

// It seems that sometimes the numerical values being returned from
// this.query.getTransactionReceipt are BN instances and not strings.
const gasUsed = typeof txReceipt.gasUsed !== 'string' ? txReceipt.gasUsed.toString(16) : txReceipt.gasUsed
const gasUsed = typeof txReceipt.gasUsed === 'string' ? txReceipt.gasUsed : txReceipt.gasUsed.toString(16)

txMeta.txReceipt = {
...txReceipt,
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/transactions/TransactionStateManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ class TransactionStateManager extends SafeEventEmitter {
// the originally submitted gasParams.
// TODO: Maybe check origin here?
if (opts.txParams && typeof opts.origin === 'string' && opts.origin !== 'torus') {
if (typeof opts.txParams.gasPrice !== 'undefined') {
if (opts.txParams.gasPrice !== undefined) {
dappSuggestedGasFees = {
gasPrice: opts.txParams.gasPrice,
}
} else if (typeof opts.txParams.maxFeePerGas !== 'undefined' || typeof opts.txParams.maxPriorityFeePerGas !== 'undefined') {
} else if (opts.txParams.maxFeePerGas !== undefined || opts.txParams.maxPriorityFeePerGas !== undefined) {
dappSuggestedGasFees = {
maxPriorityFeePerGas: opts.txParams.maxPriorityFeePerGas,
maxFeePerGas: opts.txParams.maxFeePerGas,
}
}

if (typeof opts.txParams.gas !== 'undefined') {
if (opts.txParams.gas !== undefined) {
dappSuggestedGasFees = {
...dappSuggestedGasFees,
gas: opts.txParams.gas,
Expand Down Expand Up @@ -411,7 +411,7 @@ class TransactionStateManager extends SafeEventEmitter {
@param error_ {errorObject} - error object
*/
setTxStatusFailed(txId, error_) {
const error = !error_ ? new Error('Internal torus failure') : error_
const error = error_ || new Error('Internal torus failure')

const txMeta = this.getTransaction(txId)
txMeta.err = {
Expand Down
Loading

0 comments on commit 090c2c8

Please sign in to comment.