Created
November 2, 2020 16:36
-
-
Save KasraAb/90752b4eabf8430a72dca34a9c214514 to your computer and use it in GitHub Desktop.
Bon2Nash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//update bond's account | |
const updated_bond = { ...bond, asset: { ...bond.asset, ownerId: '', status: 'expired'} }; | |
store.account.set(updated_bond.address, updated_bond); | |
//update owner's account | |
const new_owner_nash = (!owner.asset.nash)? '100' : new BigNum(owner.asset.nash).add('100').toString(); | |
const updated_owner = { ...owner, asset: { ...owner.asset, nash : new_owner_nash } }; | |
store.account.set(updated_owner.address, updated_owner); | |
//update Manager's account | |
const new_supply = (!Manager.asset.nashSupply) ? '100' : new BigNum(Manager.asset.nashSupply).add('100').toString(); | |
const new_bondsList = Manager.asset.bondsList.filter( item => item !== bond.address ); | |
const updated_Manager = {...Manager,asset : {...Manager.asset, bondsList : new_bondsList, nashSupply: new_supply}}; | |
store.account.set(updated_Manager.address, updated_Manager); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment