Skip to content

Commit

Permalink
Migrate to the new API + Fix NEM setup on testrpc (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlenko authored and dkchv committed Dec 22, 2017
1 parent a6033c1 commit 4b8c8d7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/login/network/NemMiddlewareNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ export default class NemMiddlewareNode extends AbstractNode {
mosaics,
} = res.data
return {
balance: new BigNumber(balance),
balance: new BigNumber(balance.value),
mosaics: Object.entries(mosaics).reduce((t, [k, v]) => ({
...t,
[k]: new BigNumber(v),
[k]: new BigNumber(v.value),
}), {}),
}
} catch (e) {
Expand Down
11 changes: 7 additions & 4 deletions src/dao/ERC20ManagerDAO.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ export default class ERC20ManagerDAO extends AbstractContractDAO {
}

async _setupNemTokens () {
return await Promise.all([
this._setupNemMosaic('XEM', 'XEM', new NemDAO('XEM', 'XEM', nemProvider, null, 6)),
...(nemProvider.getMosaics() || []).map((m) => this._setupNemMosaic(m.name, m.title, new NemDAO(m.name, m.symbol, nemProvider, m.namespace, 2))),
])
if (nemProvider.isInitialized()) {
return await Promise.all([
this._setupNemMosaic('XEM', 'XEM', new NemDAO('XEM', 'XEM', nemProvider, null, 6)),
...(nemProvider.getMosaics() || []).map((m) => this._setupNemMosaic(m.name, m.title, new NemDAO(m.name, m.symbol, nemProvider, m.namespace, 2))),
])
}
return []
}

async _setupNemMosaic (name, title, dao) {
Expand Down
4 changes: 2 additions & 2 deletions src/dao/NemDAO.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ export default class NemDAO {
async watchBalance (callback) {
this._nemProvider.addListener(EVENT_BALANCE, async ({ account, time, balance }) => {
const b = this._mosaic
? balance.balance
: balance.mosaics[this._mosaic]
? balance.balance.value
: balance.mosaics[this._mosaic].value
callback({
account,
time,
Expand Down

0 comments on commit 4b8c8d7

Please sign in to comment.