Allow operation when no registry is available (#2980)
* Allow retrieval of native network balances without registry * Remove debugging address * Disable dapps when no registry is available
This commit is contained in:
parent
1255105490
commit
ea784d7419
@ -32,6 +32,7 @@ export default class Balances {
|
|||||||
this._api = api;
|
this._api = api;
|
||||||
this._store = store;
|
this._store = store;
|
||||||
this._accountsInfo = null;
|
this._accountsInfo = null;
|
||||||
|
this._tokens = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
start () {
|
start () {
|
||||||
@ -50,7 +51,10 @@ export default class Balances {
|
|||||||
this._retrieveBalances();
|
this._retrieveBalances();
|
||||||
})
|
})
|
||||||
.then((subscriptionId) => {
|
.then((subscriptionId) => {
|
||||||
console.log('balances._subscribeAccountsInfo', 'subscriptionId', subscriptionId);
|
console.log('_subscribeAccountsInfo', 'subscriptionId', subscriptionId);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('_subscribeAccountsInfo', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +68,10 @@ export default class Balances {
|
|||||||
this._retrieveTokens();
|
this._retrieveTokens();
|
||||||
})
|
})
|
||||||
.then((subscriptionId) => {
|
.then((subscriptionId) => {
|
||||||
console.log('balances._subscribeBlockNumber', 'subscriptionId', subscriptionId);
|
console.log('_subscribeBlockNumber', 'subscriptionId', subscriptionId);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('_subscribeBlockNumber', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,12 +137,13 @@ export default class Balances {
|
|||||||
this._retrieveBalances();
|
this._retrieveBalances();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('balances._retrieveTokens', error);
|
console.warn('_retrieveTokens', error);
|
||||||
|
this._retrieveBalances();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_retrieveBalances () {
|
_retrieveBalances () {
|
||||||
if (!this._accountsInfo || !this._tokens) {
|
if (!this._accountsInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +194,7 @@ export default class Balances {
|
|||||||
this._store.dispatch(getBalances(this._balances));
|
this._store.dispatch(getBalances(this._balances));
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('balances._retrieveBalances', error);
|
console.warn('_retrieveBalances', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,11 @@
|
|||||||
// 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 BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
import { parityNode } from '../../environment';
|
import { parityNode } from '../../environment';
|
||||||
|
|
||||||
const builtinApps = [
|
const apps = [
|
||||||
{
|
{
|
||||||
id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f',
|
id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f',
|
||||||
url: 'basiccoin',
|
url: 'basiccoin',
|
||||||
@ -73,7 +75,7 @@ const builtinApps = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function () {
|
export default function (api) {
|
||||||
return fetch(`${parityNode}/api/apps`)
|
return fetch(`${parityNode}/api/apps`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return response.ok
|
return response.ok
|
||||||
@ -85,8 +87,19 @@ export default function () {
|
|||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
.then((localApps) => {
|
.then((localApps) => {
|
||||||
return builtinApps
|
return api.ethcore
|
||||||
.concat(localApps.filter((app) => !['ui'].includes(app.id)))
|
.registryAddress()
|
||||||
.sort((a, b) => a.name.localeCompare(b.name));
|
.then((registryAddress) => {
|
||||||
|
if (new BigNumber(registryAddress).eq(0)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return apps;
|
||||||
|
})
|
||||||
|
.then((builtinApps) => {
|
||||||
|
return builtinApps
|
||||||
|
.concat(localApps.filter((app) => !['ui'].includes(app.id)))
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -42,16 +42,14 @@ export default class Dapps extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
fetchAvailable()
|
const { api } = this.context;
|
||||||
.then((available) => {
|
|
||||||
|
fetchAvailable(api).then((available) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
available,
|
available,
|
||||||
hidden: readHiddenApps()
|
hidden: readHiddenApps()
|
||||||
});
|
});
|
||||||
this.loadImages();
|
this.loadImages();
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error('error fetching available apps', err);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user