Skip to content

Commit

Permalink
Merge pull request #411 from Adamant-im/stage
Browse files Browse the repository at this point in the history
v2.11.0 New security features
  • Loading branch information
dev-adamant-im authored May 1, 2021
2 parents e52815b + b3caf2b commit 923470e
Show file tree
Hide file tree
Showing 62 changed files with 1,089 additions and 340 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant-im",
"version": "2.10.0",
"version": "2.11.0",
"author": "ADAMANT Foundation <[email protected]>",
"license": "GPLv3",
"description": "Decentralized Messenger",
Expand Down
9 changes: 8 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<v-app :dark="isDarkTheme" class="application--linear-gradient">
<warning-on-addresses-dialog v-model="showWarningOnAddressesDialog" />
<component :is="layout">
<router-view />
</component>
Expand All @@ -8,7 +9,7 @@

<script>
import dayjs from 'dayjs'
import WarningOnAddressesDialog from '@/components/WarningOnAddressesDialog'
import Notifications from '@/lib/notifications'
export default {
Expand All @@ -23,6 +24,12 @@ export default {
this.notifications.stop()
this.$store.dispatch('stopInterval')
},
data: () => ({
showWarningOnAddressesDialog: false
}),
components: {
WarningOnAddressesDialog
},
computed: {
layout () {
return this.$route.meta.layout || 'default'
Expand Down
36 changes: 18 additions & 18 deletions src/components/AChat/AChatTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
<div :title="timeTitle" class="a-chat__timestamp">{{ time }}</div>
<div class="a-chat__status">
<v-icon
@click="updateStatus"
size="13"
:title="i18n.statuses[status]"
:color="statusColor"
:style="statusUpdatable ? 'cursor: pointer;': 'cursor: default;'"
>{{ statusIcon }}</v-icon>
</div>
</div>
Expand Down Expand Up @@ -47,46 +49,44 @@
</template>

<script>
import { tsIcon, tsUpdatable, tsColor } from '@/lib/constants'
export default {
mounted () {
this.$emit('mount')
},
computed: {
statusIcon () {
if (this.status === 'confirmed') {
return 'mdi-check'
} else if (this.status === 'pending' || this.status === 'delivered') {
return 'mdi-clock-outline'
} else if (this.status === 'rejected') {
return 'mdi-close-circle-outline'
} else if (this.status === 'invalid') {
return 'mdi-alert-outline'
} else if (this.status === 'unknown') {
return 'mdi-help-circle-outline'
}
return tsIcon(this.status)
},
statusUpdatable () {
return tsUpdatable(this.status, this.currency)
},
statusColor () {
if (this.status === 'rejected') {
return 'red'
} else if (this.status === 'invalid' || this.status === 'unknown') {
return 'yellow'
}
return ''
return tsColor(this.status)
}
},
methods: {
onClickAmount () {
if (this.isClickable) {
this.$emit('click:transaction', this.id)
}
},
updateStatus () {
if (this.statusUpdatable) {
this.$emit('click:transactionStatus', this.id)
}
}
},
props: {
id: {
type: null,
required: true
},
currency: {
type: String,
default: ''
},
message: {
type: String,
default: ''
Expand Down
4 changes: 2 additions & 2 deletions src/components/BuyTokensDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import Icon from '@/components/icons/BaseIcon'
import CryptoIcon from '@/components/icons/CryptoIcon'
import CdlIcon from '@/components/icons/common/Cdl'
import AtomarsIcon from '@/components/icons/common/Atomars'
import { uriToOnion } from '@/lib/uri'
import { websiteUriToOnion } from '@/lib/uri'
export default {
computed: {
Expand All @@ -81,7 +81,7 @@ export default {
{
icon: 'ADM',
title: this.$t('home.buy_tokens_anonymously'),
link: uriToOnion(this.adamantAddress
link: websiteUriToOnion(this.adamantAddress
? `${this.$t('home.buy_tokens_btn_link')}?wallet=${this.adamantAddress}`
: `${this.$t('home.buy_tokens_btn_link')}`)
},
Expand Down
18 changes: 9 additions & 9 deletions src/components/Chat/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
:status="getTransactionStatus(message, partnerId)"
:is-clickable="isCryptoSupported(message.type)"
@click:transaction="openTransaction(message)"
@click:transactionStatus="updateTransactionStatus(message)"
@mount="fetchTransactionStatus(message, partnerId)"
>
<crypto-icon
Expand Down Expand Up @@ -124,7 +125,7 @@ import partnerName from '@/mixins/partnerName'
import dateFilter from '@/filters/date'
import CryptoIcon from '@/components/icons/CryptoIcon'
import FreeTokensDialog from '@/components/FreeTokensDialog'
import { uriToOnion } from '@/lib/uri'
import { websiteUriToOnion } from '@/lib/uri'
/**
* Returns user meta by userId.
Expand Down Expand Up @@ -158,12 +159,10 @@ function validateMessage (message) {
}
if (this.$store.state.balance < 0.001) {
if (Object.keys(this.$store.state.adm.transactions).length) {
this.$store.dispatch('snackbar/show', {
message: this.$t('chats.no_money')
})
} else {
if (this.$store.getters.isAccountNew()) {
this.showFreeTokensDialog = true
} else {
this.$store.dispatch('snackbar/show', { message: this.$t('chats.no_money') })
}
return false
}
Expand Down Expand Up @@ -283,6 +282,9 @@ export default {
console.error(err.message)
})
},
updateTransactionStatus (message) {
this.$store.dispatch(message.type.toLowerCase() + '/updateTransaction', { hash: message.hash, force: true, updateOnly: false, dropStatus: true })
},
markAsRead () {
this.$store.commit('chat/markAsRead', this.partnerId)
},
Expand Down Expand Up @@ -321,10 +323,8 @@ export default {
}
},
isTransaction (type) {
// @todo remove LSK when will be supported
return (
type in Cryptos ||
type === 'LSK' ||
type === 'UNKNOWN_CRYPTO'
)
},
Expand All @@ -333,7 +333,7 @@ export default {
},
formatMessage (transaction) {
if (this.isChatReadOnly || transaction.i18n) {
return renderMarkdown(uriToOnion(this.$t(transaction.message)))
return renderMarkdown(websiteUriToOnion(this.$t(transaction.message)))
}
if (this.$store.state.options.formatMessages) {
Expand Down
16 changes: 5 additions & 11 deletions src/components/ChatPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import ChatAvatar from '@/components/Chat/ChatAvatar'
import Icon from '@/components/icons/BaseIcon'
import AdmFillIcon from '@/components/icons/AdmFill'
import partnerName from '@/mixins/partnerName'
import { tsIcon } from '@/lib/constants'
export default {
mounted () {
Expand Down Expand Up @@ -129,17 +130,10 @@ export default {
return this.getTransactionStatus(this.transaction)
},
statusIcon () {
if (this.status === 'confirmed' || this.status === 'delivered') {
return 'mdi-check'
} else if (this.status === 'pending') {
return 'mdi-clock-outline'
} else if (this.status === 'rejected') {
return 'mdi-close-circle-outline'
} else if (this.status === 'invalid') {
return 'mdi-alert-outline'
} else if (this.status === 'unknown') {
return 'mdi-help-circle-outline'
}
// There were a bit change
// if (this.status === 'confirmed' || this.status === 'delivered') {
// return 'mdi-check'
return tsIcon(this.status)
}
},
data: () => ({
Expand Down
4 changes: 2 additions & 2 deletions src/components/FreeTokensDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</template>

<script>
import { uriToOnion } from '@/lib/uri'
import { websiteUriToOnion } from '@/lib/uri'
export default {
computed: {
Expand All @@ -54,7 +54,7 @@ export default {
},
methods: {
getFreeTokens () {
const link = uriToOnion(this.$t('home.free_tokens_link') + '?wallet=' + this.$store.state.address)
const link = websiteUriToOnion(this.$t('home.free_tokens_link') + '?wallet=' + this.$store.state.address)
window.open(link, '_blank', 'resizable,scrollbars,status,noopener')
this.show = false
},
Expand Down
36 changes: 28 additions & 8 deletions src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div :class="className">
<warning-on-partner-address-dialog :info="warningOnPartnerInfo"
v-model="showWarningOnPartnerAddressDialog" />

<v-form
v-model="validForm"
@submit.prevent="confirm"
Expand Down Expand Up @@ -183,6 +186,8 @@ import validateAddress from '@/lib/validateAddress'
import { formatNumber, isNumeric } from '@/lib/numericHelpers'
import partnerName from '@/mixins/partnerName'
import WarningOnPartnerAddressDialog from '@/components/WarningOnPartnerAddressDialog'
/**
* @returns {string | boolean}
*/
Expand All @@ -206,7 +211,8 @@ export default {
mixins: [partnerName],
components: {
QrcodeCapture,
QrcodeScannerDialog
QrcodeScannerDialog,
WarningOnPartnerAddressDialog
},
created () {
this.currency = this.cryptoCurrency
Expand Down Expand Up @@ -421,7 +427,9 @@ export default {
showSpinner: false,
dialog: false,
fetchAddress: null, // fn throttle
increaseFee: false
increaseFee: false,
showWarningOnPartnerAddressDialog: false,
warningOnPartnerInfo: { }
}),
methods: {
confirm () {
Expand All @@ -432,7 +440,7 @@ export default {
} else {
this.$store.dispatch('snackbar/show', {
message: abstract,
timeout: 7000
timeout: 5000
})
}
},
Expand Down Expand Up @@ -534,9 +542,9 @@ export default {
})
.catch(err => {
let message = err.message
if (this.currency === Cryptos.DASH && get(err, 'response.data.error.code') === -26) {
if (/dust/i.test(message) || get(err, 'response.data.error.code') === -26) {
message = this.$t('transfer.error_dust_amount')
} else if (this.currency === Cryptos.ETH && /Invalid JSON RPC Response/i.test(message)) {
} else if (/Invalid JSON RPC Response/i.test(message)) {
message = this.$t('transfer.error_unknown')
}
this.$emit('error', message)
Expand Down Expand Up @@ -612,9 +620,21 @@ export default {
if (validateAddress('ADM', this.address)) {
this.$store.dispatch('partners/fetchAddress', {
crypto: this.currency,
partner: this.address
}).then(address => {
this.cryptoAddress = address
partner: this.address,
records: 20
}).then(addresses => {
this.cryptoAddress = addresses[0]
if (addresses.length > 1) {
let addressesList = addresses.join(', ')
this.warningOnPartnerInfo.coin = this.currency
this.warningOnPartnerInfo.ADMaddress = this.address
this.warningOnPartnerInfo.ADMname = ''
if (this.recipientName) {
this.warningOnPartnerInfo.ADMname = ' (' + this.recipientName + ')'
}
this.warningOnPartnerInfo.coinAddresses = addressesList
this.showWarningOnPartnerAddressDialog = true
}
})
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/WalletCardListActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<script>
import { Cryptos } from '@/lib/constants'
import BuyTokensDialog from '@/components/BuyTokensDialog'
import { uriToOnion } from '@/lib/uri'
import { websiteUriToOnion } from '@/lib/uri'
export default {
computed: {
Expand All @@ -65,7 +65,7 @@ export default {
this.showBuyTokensDialog = true
},
getFreeTokens () {
const link = uriToOnion(this.$t('home.free_tokens_link') + '?wallet=' + this.$store.state.address)
const link = websiteUriToOnion(this.$t('home.free_tokens_link') + '?wallet=' + this.$store.state.address)
window.open(link, '_blank', 'resizable,scrollbars,status,noopener')
}
},
Expand Down
Loading

0 comments on commit 923470e

Please sign in to comment.