MCPcopy Create free account
hub / github.com/SmartTokenLabs/TokenScript / getProps

Method getProps

bootstrap-js/tokenscript-bootstrap.js:470–569  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

468 }
469
470 async getProps(){
471 let basicProps = {};
472 try {
473 ethersData = await getEthersData();
474
475 const attributeXmlNodes = this.xmlDoc.evaluate('ts:attribute', this.tokenXMLNode, this.nsResolver, XPathResult.ANY_TYPE, null );
476
477
478 let attributeNode;
479
480 while (attributeXmlNodes && (attributeNode = attributeXmlNodes.iterateNext() ) ) {
481 let name = attributeNode.getAttribute('name');
482 let originsInnerNode = getXMLItem(this.xmlDoc ,'ts:origins/*[1]',attributeNode);
483 if (!originsInnerNode) continue;
484
485 let dataNodeName = originsInnerNode.nodeName;
486 let res;
487
488 // this.debug && console.log(dataNodeName);
489
490 switch (dataNodeName) {
491 case 'ts:token-id':
492 // res = "542b33000000000000000000000001075b2282";
493 res = this.tokenID;
494
495 this.debug && console.log('its ts:token-id, just use tokenID ');
496 break;
497 case "ethereum:call":
498 // this.debug && console.log('its ethereum call start');
499 let {
500 params,
501 ethCallAttributtes,
502 contract,
503 missedAttribute
504 } = getEthereumCallParams({
505 userAddress: this.ethersData.userAddress,
506 chainID: this.ethersData.chainID,
507 ethereumNode: originsInnerNode,
508 xmlDoc: this.xmlDoc,
509 tokenXmlNode: this.tokenXMLNode,
510 tokenName: this.tokenName,
511 tokenId: this.tokenID,
512 debug: this.debug,
513 });
514
515 if ( (!ethCallAttributtes || !ethCallAttributtes.contract) && (!contract || !contract.contractAddress) ) throw new Error(' ethContract and contractAddress required for {Address='+this.ethersData.userAddress+', chainID = '+this.ethersData.chainID+' , tokenName = '+this.tokenName+'}. Check logs for details');
516
517 if (missedAttribute) {
518 this.debug && console.log('missed attribute: "' + missedAttribute + '", ethereum call skipped');
519 break;
520 }
521
522 const [abi_error, abi] = await to( getJSONAbi(ethCallAttributtes.contract,jsons,config.contractJsonPath, tsDebug ) );
523
524 if (!abi) {
525 console.error('Cant get Contract ABI for "'+ ethCallAttributtes.contract +'" , attribute "' + name + '" skipped');
526 throw new Error('Empty ABI for '+ethCallAttributtes.contract);
527 }

Callers 3

getDistinctItemsMethod · 0.95
negotiateFunction · 0.95
runMainDataChangedMethod · 0.80

Calls 6

getEthersDataFunction · 0.90
getXMLItemFunction · 0.90
getEthereumCallParamsFunction · 0.90
toFunction · 0.90
getJSONAbiFunction · 0.90
bnStringPrecisionFunction · 0.90

Tested by

no test coverage detected