Fix dapp account selection (#3399)

* Fix GHH accounts (filter non accounts)

* SignatureReg handle undefined ABI names gracefully

* SignatureReg fix accounts (filter non accounts)

* TokenReg fix accounts (filter non accounts)

* Registry fix accounts (filter non accounts)
This commit is contained in:
Jaco Greeff 2016-11-12 22:24:55 +01:00 committed by Gav Wood
parent e5486f5d58
commit 6b33899239
5 changed files with 43 additions and 48 deletions

View File

@ -28,23 +28,23 @@ export function attachInterface () {
return Promise
.all([
registry.getAddress.call({}, [api.util.sha3('githubhint'), 'A']),
api.eth.accounts(),
api.parity.accounts()
]);
})
.then(([address, addresses, accountsInfo]) => {
accountsInfo = accountsInfo || {};
.then(([address, accountsInfo]) => {
console.log(`githubhint was found at ${address}`);
const contract = api.newContract(abis.githubhint, address);
const accounts = addresses.reduce((obj, address) => {
const info = accountsInfo[address] || {};
const accounts = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address].uuid)
.reduce((obj, address) => {
const account = accountsInfo[address];
return Object.assign(obj, {
[address]: {
address,
name: info.name,
uuid: info.uuid
name: account.name
}
});
}, {});

View File

@ -19,18 +19,16 @@ import { api } from '../parity';
export const set = (addresses) => ({ type: 'addresses set', addresses });
export const fetch = () => (dispatch) => {
return Promise
.all([
api.eth.accounts(),
api.parity.accounts()
])
.then(([ accounts, data ]) => {
data = data || {};
const addresses = Object.keys(data)
.filter((address) => data[address] && !data[address].meta.deleted)
return api.parity
.accounts()
.then((accountsInfo) => {
const addresses = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address] && !accountsInfo[address].meta.deleted)
.map((address) => ({
...data[address], address,
isAccount: accounts.includes(address)
...accountsInfo[address],
address,
isAccount: !!accountsInfo[address].uuid
}));
dispatch(set(addresses));
})

View File

@ -146,7 +146,7 @@ export default class Import extends Component {
}
sortFunctions = (a, b) => {
return a.name.localeCompare(b.name);
return (a.name || '').localeCompare(b.name || '');
}
countFunctions () {

View File

@ -49,23 +49,23 @@ export function attachInterface (callback) {
return Promise
.all([
registry.getAddress.call({}, [api.util.sha3('signaturereg'), 'A']),
api.eth.accounts(),
api.parity.accounts()
]);
})
.then(([address, addresses, accountsInfo]) => {
accountsInfo = accountsInfo || {};
.then(([address, accountsInfo]) => {
console.log(`signaturereg was found at ${address}`);
const contract = api.newContract(abis.signaturereg, address);
const accounts = addresses.reduce((obj, address) => {
const accounts = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address].uuid)
.reduce((obj, address) => {
const info = accountsInfo[address] || {};
return Object.assign(obj, {
[address]: {
address,
name: info.name || 'Unnamed',
uuid: info.uuid
name: info.name || 'Unnamed'
}
});
}, {});

View File

@ -35,16 +35,13 @@ export const setSelectedAccount = (address) => ({
});
export const loadAccounts = () => (dispatch) => {
Promise
.all([
api.eth.accounts(),
api.parity.accounts()
])
.then(([ accounts, accountsInfo ]) => {
accountsInfo = accountsInfo || {};
const accountsList = accounts
.map(address => ({
api.parity
.accounts()
.then((accountsInfo) => {
const accountsList = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address].uuid)
.map((address) => ({
...accountsInfo[address],
address
}));