Fixes to the Registry dapp (#4838)

* Fix wrong ABI methods

* Fix
This commit is contained in:
Nicolas Gotchac 2017-03-09 16:55:57 +01:00 committed by Jaco Greeff
parent ea020948fc
commit 5342a482b5
3 changed files with 16 additions and 8 deletions

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { sha3 } from '../parity.js'; import { api, sha3 } from '../parity.js';
import { getOwner } from '../util/registry'; import { getOwner } from '../util/registry';
export const clear = () => ({ type: 'lookup clear' }); export const clear = () => ({ type: 'lookup clear' });
@ -34,14 +34,21 @@ export const lookup = (name, key) => (dispatch, getState) => {
return; return;
} }
const getAddress = contract.functions const method = key === 'A'
.find((f) => f.name === 'getAddress'); ? contract.instance.getAddress
: contract.instance.getData;
name = name.toLowerCase(); name = name.toLowerCase();
dispatch(lookupStart(name, key)); dispatch(lookupStart(name, key));
getAddress.call({}, [ sha3.text(name), key ]) method.call({}, [ sha3.text(name), key ])
.then((address) => dispatch(success('lookup', address))) .then((result) => {
if (key !== 'A') {
result = api.util.bytesToHex(result);
}
dispatch(success('lookup', result));
})
.catch((err) => { .catch((err) => {
console.error(`could not lookup ${key} for ${name}`); console.error(`could not lookup ${key} for ${name}`);
if (err) { if (err) {

View File

@ -46,8 +46,9 @@ export const update = (name, key, value) => (dispatch, getState) => {
throw new Error(`you are not the owner of "${name}"`); throw new Error(`you are not the owner of "${name}"`);
} }
const fnName = key === 'A' ? 'setAddress' : 'set'; const method = key === 'A'
const method = contract.instance[fnName]; ? contract.instance.setAddress
: contract.instance.setData || contract.instance.set;
const options = { const options = {
from: account.address from: account.address

View File

@ -34,7 +34,7 @@ export default (address) => {
return ( return (
<img <img
src={ `${parityNode}/${address}/` } src={ `${parityNode}/api/content/${address.replace(/^0x/, '')}` }
alt={ address } alt={ address }
style={ styles } style={ styles }
/> />