Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

feat: shown placeholder message if wallet is a known wallet #881

Merged
merged 8 commits into from
Dec 31, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe('TransactionShow', () => {
session_network: {
constants: {
activeDelegates: 51
}
},
knownWallets: []
},
wallet_formatAddress: address => address
},
Expand Down
66 changes: 57 additions & 9 deletions __tests__/unit/components/Wallet/WalletAddress.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ describe('WalletAddress', () => {
i18n,
localVue,
mocks: {
session_network: {
knownWallets: []
},
wallet_formatAddress: address => address
}
})
Expand All @@ -22,7 +25,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 1 },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.SECOND_SIGNATURE'))
})
Expand All @@ -31,7 +39,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 2 },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.DELEGATE_REGISTRATION'))
})
Expand All @@ -40,7 +53,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 3, asset: { votes: ['+dummyAddress'] } },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.VOTE'))
})
Expand All @@ -49,7 +67,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 3, asset: { votes: ['-dummyAddress'] } },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.UNVOTE'))
})
Expand All @@ -58,7 +81,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 4 },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.MULTI_SIGNATURE'))
})
Expand All @@ -67,7 +95,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 5 },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.IPFS'))
})
Expand All @@ -76,7 +109,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 6 },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.TIMELOCK_TRANSFER'))
})
Expand All @@ -85,7 +123,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 7 },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.MULTI_PAYMENT'))
})
Expand All @@ -94,7 +137,12 @@ describe('WalletAddress', () => {
const wrapper = shallowMount(WalletAddress, {
propsData: { address: 'dummyAddress', type: 8 },
i18n,
localVue
localVue,
mocks: {
session_network: {
knownWallets: []
}
}
})
expect(wrapper.text()).toEqual(expect.stringContaining('TRANSACTION.TYPE.DELEGATE_RESIGNATION'))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const network = {
fractionDigits: 8,
market: {
enabled: false
}
},
knownWallets: []
}

const sampleWalletData = {
Expand Down
22 changes: 22 additions & 0 deletions src/renderer/assets/svg/verified-address.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 28 additions & 1 deletion src/renderer/components/Wallet/WalletAddress.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<template>
<span>
<span class="flex items-center">
<span v-if="!type">
<a
v-tooltip="{
Expand Down Expand Up @@ -53,15 +53,28 @@
<span v-else-if="type === 8">
{{ $t("TRANSACTION.TYPE.DELEGATE_RESIGNATION") }}
</span>

<SvgIcon
v-if="isKnownWallet()"
v-tooltip="{ content: verifiedAddressText, trigger: 'hover' }"
name="verified-address"
view-box="0 0 14 14"
class="ml-2 text-blue"
/>
</span>
</template>

<script>
import store from '@/store'
import SvgIcon from '@/components/SvgIcon'

export default {
name: 'WalletAddress',

components: {
SvgIcon
},

props: {
address: {
type: String,
Expand Down Expand Up @@ -117,6 +130,16 @@ export default {

votedDelegateAddress () {
return this.votedDelegate ? this.votedDelegate.address : ''
},

verifiedAddressText () {
let verifiedText = ''
let knownWallet = this.isKnownWallet()
if (knownWallet && knownWallet !== this.wallet_formatAddress(this.address, this.addressLength)) {
verifiedText = `${knownWallet} - `
}

return verifiedText + this.$t('COMMON.VERIFIED_ADDRESS')
}
},

Expand All @@ -131,6 +154,10 @@ export default {
this.votedDelegate = store.getters['delegate/byPublicKey'](this.votePublicKey)
},

isKnownWallet () {
return this.session_network.knownWallets[this.address]
},

openAddress () {
if (this.votePublicKey) {
this.$router.push({ name: 'wallet-show', params: { address: this.votedDelegateAddress } })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
<span class="hidden xl:block">
{{ name | truncate(30) }}
</span>
<SvgIcon
v-if="isKnownWallet()"
v-tooltip="{ content: verifiedAddressText, trigger: 'hover' }"
name="verified-address"
view-box="0 0 18 18"
class="ml-2"
/>
</div>

<p class="WalletHeading__address tracking-wide mb-3 flex items-center text-sm font-semibold">
Expand Down Expand Up @@ -77,7 +84,7 @@
>
<SvgIcon
:name="showPublicKey ? 'world' : 'key'"
view-box="0 0 18 18"
view-box="0 0 16 16"
/>
</button>
</p>
Expand Down Expand Up @@ -161,6 +168,15 @@ export default {
},
labelTooltip () {
return this.showPublicKey ? this.$t('WALLET_HEADING.ACTIONS.SHOW_ADDRESS') : this.$t('WALLET_HEADING.ACTIONS.SHOW_PUBLIC_KEY')
},
verifiedAddressText () {
let verifiedText = ''
let knownWallet = this.isKnownWallet()
if (knownWallet && knownWallet !== this.name) {
verifiedText = `${knownWallet} - `
}

return verifiedText + this.$t('COMMON.VERIFIED_ADDRESS')
}
},

Expand All @@ -175,6 +191,10 @@ export default {
this.showPublicKey = !this.showPublicKey
},

isKnownWallet () {
return this.session_network.knownWallets[this.address]
},

// Called by the parent when the address changed
// Fetch watch-only address, since the wallet is not stored on vuex
async refreshWallet () {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/i18n/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export default {
WARNING: 'Warning',
FETCH: 'Fetch',
REMOVE: 'Remove',
OTHER: 'Other'
OTHER: 'Other',
VERIFIED_ADDRESS: 'This is a verified address'
},

ANNOUNCEMENTS: {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/pages/Wallet/WalletNew.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
v-model="ensureEntirePassphrase"
:label="$t('PAGES.WALLET_NEW.STEP3.CHECK_ENTIRE_PASSPHRASE')"
:text="$t('PAGES.WALLET_NEW.STEP3.VERIFY_ALL_WORDS')"
@change="onSwitch"
class="my-3"
@change="onSwitch"
/>

<PassphraseVerification
Expand Down