Skip to content

Instantly share code, notes, and snippets.

@KasraAb
Created November 2, 2020 16:36
Show Gist options
  • Save KasraAb/90752b4eabf8430a72dca34a9c214514 to your computer and use it in GitHub Desktop.
Save KasraAb/90752b4eabf8430a72dca34a9c214514 to your computer and use it in GitHub Desktop.
Bon2Nash
//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