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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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