Snippets

chromawallet nfa lib

Created by Riccardo Sibani last modified
nfaObjList = array();

createNfaObj(nfa_id) // this creates the nfa object given the nfa_id and adds it to nfaObjList. It recursively calls itself until all the components of type nfa are added to objList. The object definition might be exported. E.g. Saved in localstorage, need to analyze how safe it is.

/* 

	So now one object has *properties* that are set 
	
	Next step is to add the modifiers. So: 
	 	* if I want to create a new entitee I need register function
		* if I want to modify entitee I need update modifier (this can be an array??)
	
	Ideas to accomplish that.
		* setRegisterFunction(()=> {}: Function}
		* addFunction(nameOfTheFunction, () => {});
	
*/

const Planet = nfaObjList[indexOfPlanet);
Planet.setRegisterFuntion((account)=> op('create_new_planet', account.id, account.auth_descriptor));
Planet.addFunction('changeColor', (account, colorHex) => { 
		this.color = colorHexl;
		runTx(op('change_color', this.id, account.auth_descriptor, colorHex))
}


/*
	Then is possible to use Planet
*/

const earth = new Planet();
earth.register();
earth.changeColor(account, #333);

const getEarth = Planet.getById(earth.id); // This should work anyway

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.