Delegation
diff --git a/src/views/UserAccountImportAddress.vue b/src/views/UserAccountImportAddress.vue
index bb1c935c..27962cb0 100644
--- a/src/views/UserAccountImportAddress.vue
+++ b/src/views/UserAccountImportAddress.vue
@@ -79,6 +79,29 @@
+
+
+
+
+ {{ errors[0] }}
+
+
+
@@ -113,6 +136,29 @@
+
+
+
+
+ {{ errors[0] }}
+
+
+
{
- const { logo, addr_prefix } = this.chains[x]
- const addr = addressEnCode(addr_prefix, data)
- return { chain: x, addr, logo }
- })
+ if (this.accounts && this.accounts.address) {
+ const { data } = addressDecode(this.accounts.address)
+ return this.selected.map(x => {
+ const { logo, addr_prefix } = this.chains[x]
+ const addr = addressEnCode(addr_prefix, data)
+ return {
+ chain: x, addr, logo, hdpath: this.hdpath,
+ }
+ })
+ }
+ return []
},
},
created() {
@@ -271,11 +323,18 @@ export default {
}
},
methods: {
+ formatPubkey(v) {
+ if (typeof (v) === 'string') {
+ return v
+ }
+ if (v) {
+ return toHex(v)
+ }
+ return ''
+ },
async connect() {
const transport = this.device === 'ledger' ? 'usb' : 'bluetooth'
- return getLedgerAddress(transport).catch(e => {
- this.debug = e
- })
+ return getLedgerAddress(transport, this.hdpath)
},
async cennectKeplr() {
if (!window.getOfflineSigner || !window.keplr) {
@@ -338,12 +397,12 @@ export default {
case 'ledger2':
await this.connect().then(accounts => {
if (accounts) {
- this.accounts = {
- address: accounts.bech32_address,
- pubkey: accounts.compressed_pk,
- }
+ // eslint-disable-next-line prefer-destructuring
+ this.accounts = accounts[0]
ok = true
}
+ }).catch(e => {
+ this.debug = e
})
break
default:
diff --git a/src/views/UserAccounts.vue b/src/views/UserAccounts.vue
index 15f94d36..0cf3996b 100644
--- a/src/views/UserAccounts.vue
+++ b/src/views/UserAccounts.vue
@@ -254,9 +254,14 @@ export default {
return 0
},
removeAddress(v) {
- Object.values(this.accounts).forEach(item => {
+ Object.keys(this.accounts).forEach(key => {
+ const item = this.accounts[key]
const newAddrs = item.address.filter(a => a.addr !== v)
- this.$set(item, 'address', newAddrs)
+ if (newAddrs.length > 0) {
+ this.$set(item, 'address', newAddrs)
+ } else {
+ delete this.accounts[key]
+ }
})
localStorage.setItem('accounts', JSON.stringify(this.accounts))
},