Skip to content

Instantly share code, notes, and snippets.

@KasraAb
Last active November 2, 2020 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KasraAb/428bcb4427786d29bfaacf64ee3721cb to your computer and use it in GitHub Desktop.
Save KasraAb/428bcb4427786d29bfaacf64ee3721cb to your computer and use it in GitHub Desktop.
NashTransfer
//update recipient's account
const new_recipient_nash = (!recipient.asset.nash)? this.asset.amount
: new BigNum(recipient.asset.nash).add(this.asset.amount).toString();
const updated_recipient = { ...recipient, asset: { ...recipient.asset, nash: new_recipient_nash} };
store.account.set(updated_recipient.address, updated_recipient);
//update sender's account
const new_sender_nash = new BigNum(sender.asset.nash).sub(this.asset.amount).toString();
const updated_sender = { ...sender, asset: { ...sender.asset, nash: new_sender_nash} };
store.account.set(updated_sender.address, updated_sender);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment