Balances calculation

The fourth section contains functions that calculate and update the balances object in global state:

...
updateInitialBalance(amount, fieldName) {
this.state.balances[fieldName] = amount;
},

// Update the "balances" object in global state based on the current
// initial balances:
recalculateBalances() {
const { initialRaw, initialCooked } = this.state.balances;
const { currentRaw, currentCooked } = this.wasm.getCurrentBalances(
initialRaw,
initialCooked
);
this.state.balances = {
initialRaw,
currentRaw,
initialCooked,
currentCooked
};
}
};

The updateInitialBalance() function sets the property value in the balances object in global state based on the amount and fieldName arguments. The recalculateBalances() function updates all of the fields on the balances object to reflect any changes made to the initial balances or transactions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset