Remove personal_* calls from dapps (#2860)

* remove accountsInfo & listAccounts

* registry accounts selector works
This commit is contained in:
Jaco Greeff 2016-10-25 15:15:22 +02:00 committed by Gav Wood
parent b6f2628018
commit 4fc1c5f42e
9 changed files with 30 additions and 29 deletions

View File

@ -16,7 +16,7 @@
import React, { Component, PropTypes } from 'react';
import { api } from '../parity';
// import { api } from '../parity';
import { attachInstances } from '../services';
import Header from './Header';
@ -83,9 +83,10 @@ export default class Application extends Component {
Promise
.all([
attachInstances(),
api.personal.accountsInfo()
null // api.personal.accountsInfo()
])
.then(([{ managerInstance, registryInstance, tokenregInstance }, accountsInfo]) => {
accountsInfo = accountsInfo || {};
this.setState({
loading: false,
managerInstance,

View File

@ -205,11 +205,12 @@ export default class Application extends Component {
return Promise
.all([
registry.getAddress.call({}, [api.util.sha3('gavcoin'), 'A']),
api.personal.listAccounts(),
api.personal.accountsInfo()
api.eth.accounts(),
null // api.personal.accountsInfo()
]);
})
.then(([address, addresses, infos]) => {
infos = infos || {};
console.log(`gavcoin was found at ${address}`);
const contract = api.newContract(abis.gavcoin, address);
@ -220,11 +221,11 @@ export default class Application extends Component {
contract,
instance: contract.instance,
accounts: addresses.map((address) => {
const info = infos[address];
const info = infos[address] || {};
return {
address,
name: info.name || 'Unnamed',
name: info.name,
uuid: info.uuid
};
})

View File

@ -80,7 +80,7 @@ export default class Event extends Component {
const { accounts } = this.context;
const account = accounts.find((_account) => _account.address === address);
if (account) {
if (account && account.name) {
return (
<div className={ styles.name }>
{ account.name }

View File

@ -28,21 +28,22 @@ export function attachInterface () {
return Promise
.all([
registry.getAddress.call({}, [api.util.sha3('githubhint'), 'A']),
api.personal.listAccounts(),
api.personal.accountsInfo()
api.eth.accounts(),
null // api.personal.accountsInfo()
]);
})
.then(([address, addresses, accountsInfo]) => {
accountsInfo = 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 info = accountsInfo[address] || {};
return Object.assign(obj, {
[address]: {
address,
name: info.name || 'Unnamed',
name: info.name,
uuid: info.uuid
}
});

View File

@ -21,16 +21,13 @@ export const set = (addresses) => ({ type: 'addresses set', addresses });
export const fetch = () => (dispatch) => {
return Promise
.all([
api.personal.listAccounts(),
api.personal.accountsInfo()
api.eth.accounts(),
null // api.personal.accountsInfo()
])
.then(([ accounts, data ]) => {
const addresses = Object.keys(data)
.filter((address) => data[address] && !data[address].meta.deleted)
.map((address) => ({
...data[address], address,
isAccount: accounts.includes(address)
}));
const addresses = accounts.map((address) => {
return { address, isAccount: true };
});
dispatch(set(addresses));
})
.catch((error) => {

View File

@ -32,9 +32,9 @@ const align = {
export default (address, accounts, contacts, shortenHash = true) => {
let caption;
if (accounts[address]) {
caption = (<abbr title={ address } style={ align }>{ accounts[address].name }</abbr>);
caption = (<abbr title={ address } style={ align }>{ accounts[address].name || address }</abbr>);
} else if (contacts[address]) {
caption = (<abbr title={ address } style={ align }>{ contacts[address].name }</abbr>);
caption = (<abbr title={ address } style={ align }>{ contacts[address].name || address }</abbr>);
} else {
caption = (<code style={ align }>{ shortenHash ? renderHash(address) : address }</code>);
}

View File

@ -46,16 +46,17 @@ export function attachInterface (callback) {
return Promise
.all([
registry.getAddress.call({}, [api.util.sha3('signaturereg'), 'A']),
api.personal.listAccounts(),
api.personal.accountsInfo()
api.eth.accounts(),
null // api.personal.accountsInfo()
]);
})
.then(([address, addresses, accountsInfo]) => {
accountsInfo = accountsInfo || {};
console.log(`signaturereg was found at ${address}`);
const contract = api.newContract(abis.signaturereg, address);
const accounts = addresses.reduce((obj, address) => {
const info = accountsInfo[address];
const info = accountsInfo[address] || {};
return Object.assign(obj, {
[address]: {

View File

@ -37,11 +37,11 @@ export const setSelectedAccount = (address) => ({
export const loadAccounts = () => (dispatch) => {
Promise
.all([
api.personal.listAccounts(),
api.personal.accountsInfo()
api.eth.accounts(),
null // api.personal.accountsInfo()
])
.then(results => {
const [ accounts, accountsInfo ] = results;
.then(([ accounts, accountsInfo ]) => {
accountsInfo = accountsInfo || {};
const accountsList = accounts
.map(address => ({

View File

@ -82,7 +82,7 @@ export const loadContractDetails = () => (dispatch, getState) => {
Promise
.all([
api.personal.listAccounts(),
api.eth.accounts(),
instance.owner.call(),
instance.fee.call()
])