Skip to content

Instantly share code, notes, and snippets.

@KasraAb
Created November 2, 2020 16:39
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/55bfa32d23c8395a38f06416c4731fa6 to your computer and use it in GitHub Desktop.
Save KasraAb/55bfa32d23c8395a38f06416c4731fa6 to your computer and use it in GitHub Desktop.
Initialization
if( this.asset.type === 'manager'){
const Manager = store.account.get(manager.address);
const updated_Manager = {...Manager,
asset: {...Manager.asset, type:'manager', nash: '10000', nashSupply: '10000'}} ;
store.account.set(updated_Manager.address,updated_Manager);
}
else if ( this.asset.type === 'bond'){
if(!this.asset.price){
errors.push(new TransactionError(
'invalid transaction asset',
this.id,
'.asset',
this.asset,
'price must be provided'));
}
else{
const bond = store.account.get(this.senderId);
const updated_bond = {...bond, asset: { price: this.asset.price,
status: 'not sold', type: 'bond', ownerId: manager.address}} ;
store.account.set(updated_bond.address,updated_bond);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment