Skip to content

Commit d32fa5d

Browse files
committed
Fixing account switching and adding accounts
Issue was due to id/name mixup
1 parent 5f6221a commit d32fa5d

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

src/components/account-select.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@
5656
selectedAccount.value = accounts.value[newVal];
5757
store.dispatch(
5858
"AccountStore/selectAccount",
59-
{chain: accounts.value[newVal].chain, accountID: accounts.value[newVal].accountID}
59+
{
60+
chain: accounts.value[newVal].chain,
61+
accountID: accounts.value[newVal].accountID
62+
? accounts.value[newVal].accountID
63+
: accounts.value[newVal].accountName
64+
}
6065
);
6166
}
6267
}, {immediate: true});

src/components/dapps.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
function fetchDapps() {
1818
let storedDapps = [];
1919
for (let i = 0; i < store.state.AccountStore.accountlist.length; i++) {
20-
let apps = store.getters['OriginStore/walletAccessibleDapps'](store.state.AccountStore.accountlist[i].accountID, store.state.AccountStore.accountlist[i].chain);
20+
let apps = store.getters['OriginStore/walletAccessibleDapps'](
21+
store.state.AccountStore.accountlist[i].accountID
22+
? store.state.AccountStore.accountlist[i].accountID
23+
: store.state.AccountStore.accountlist[i].accountName,
24+
store.state.AccountStore.accountlist[i].chain
25+
);
2126
if (typeof apps != 'undefined') {
2227
storedDapps = storedDapps.concat(apps);
2328
}
@@ -28,7 +33,12 @@
2833
let dapps = computed(() => {
2934
let storedDapps = [];
3035
for (let i = 0; i < store.state.AccountStore.accountlist.length; i++) {
31-
let apps = store.getters['OriginStore/walletAccessibleDapps'](store.state.AccountStore.accountlist[i].accountID, store.state.AccountStore.accountlist[i].chain);
36+
let apps = store.getters['OriginStore/walletAccessibleDapps'](
37+
store.state.AccountStore.accountlist[i].accountID
38+
? store.state.AccountStore.accountlist[i].accountID
39+
: store.state.AccountStore.accountlist[i].accountName,
40+
store.state.AccountStore.accountlist[i].chain
41+
);
3242
if (typeof apps != 'undefined') {
3343
storedDapps = storedDapps.concat(apps);
3444
}

src/components/popups/identityrequestpopup.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
if (!props.accounts || !props.accounts.length) {
2929
return '';
3030
}
31-
return props.accounts[0].accountID;
31+
return props.accounts[0].accountID
32+
? props.accounts[0].accountID
33+
: props.accounts[0].accountName;
3234
});
3335
3436
let accountName = computed(() => {

src/components/popups/relinkrequestpopup.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
origin: props.request.origin,
3737
chain: props.request.chain,
3838
accountId: props.accounts[0].accountID
39+
? props.accounts[0].accountID
40+
: props.accounts[0].accountName
3941
}
4042
);
4143
});
@@ -52,7 +54,9 @@
5254
identityhash: props.request.payload.identityhash,
5355
name: props.accounts[0].accountName,
5456
chain: props.accounts[0].chain,
55-
id: props.accounts[0].accountID,
57+
id: props.accounts[0].accountID
58+
? props.accounts[0].accountID
59+
: props.accounts[0].accountName,
5660
success: true
5761
},
5862
request: {

src/store/modules/AccountStore.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ const actions = {
3333
state
3434
}, payload) {
3535
return new Promise((resolve, reject) => {
36-
let existingAccount = state.accountlist.find(x => x.chain == payload.account.chain && x.accountID == payload.account.accountID)
36+
let existingAccount = state.accountlist.find(
37+
x => x.chain == payload.account.chain &&
38+
(x.accountID == payload.account.accountName || x.accountName === payload.account.accountName)
39+
);
3740

3841
if (!existingAccount) {
3942
for (let keytype in payload.account.keys) {
@@ -83,7 +86,14 @@ const actions = {
8386
return new Promise((resolve, reject) => {
8487
let index = -1;
8588
for (let i = 0; i < state.accountlist.length; i++) {
86-
if ((payload.chain == state.accountlist[i].chain) && (payload.accountID == state.accountlist[i].accountID)) {
89+
if (
90+
(payload.chain == state.accountlist[i].chain) &&
91+
(
92+
payload.accountID == state.accountlist[i].accountID ||
93+
payload.accountID == state.accountlist[i].accountName ||
94+
payload.accountName == state.accountlist[i].accountName
95+
)
96+
) {
8797
index = i;
8898
break;
8999
}

0 commit comments

Comments
 (0)