MCPcopy Index your code
hub / github.com/SmartTokenLabs/TokenScript / renderProps

Method renderProps

bootstrap-js/tokenscript-bootstrap.js:275–432  ·  view source on GitHub ↗
(props = false, wrap, cardName, cardType)

Source from the content-addressed store, hash-verified

273
274
275 async renderProps(props = false, wrap, cardName, cardType){
276
277 // console.log('try to get props');
278 // props = props ? props : await this.getProps();
279 this.debug && console.log('props received');
280 this.debug && console.log(props);
281
282 // get card-view html
283 let selector = 'ts:cards/ts:card[@name="' + cardName + '"][@type="' + cardType + '"][1]';
284 let cardNode = getXMLItem(this.xmlDoc, selector, this.tokenXMLNode );
285
286 if (!cardNode) {
287 this.debug && console.log('cant see card for >>>'+selector+'<<<');
288 // if (cardName =='main' && cardType =="token" ) this.cardHtml = '<h2 style="text-transform: uppercase;">' + this.tokenName + '</h2>';
289 return [props];
290 }
291
292 selector = 'ts:origins/ethereum:event';
293 let originsNodes = this.xmlDoc.evaluate(selector, cardNode, this.nsResolver, XPathResult.ANY_TYPE, null );
294
295 let ethereumEventNode;
296 while (originsNodes && (ethereumEventNode = originsNodes.iterateNext() ) ) {
297
298 this.debug && console.log('ethereumEventNode');
299 this.debug && console.log(ethereumEventNode);
300 // ------------------------
301 // ethereum:event
302 var eventFilter = ethereumEventNode.getAttribute('filter');
303 var eventType = ethereumEventNode.getAttribute('type');
304 var ethContract = ethereumEventNode.getAttribute('contract');
305 ethContract = ethContract? ethContract: this.defaultContract;
306
307 var { contractInterface, contractAddress } = getContractAddress(this.xmlDoc, ethContract, this.tokenXMLNode, this.ethersData.chainID);
308
309 if (!contractAddress) {
310 this.debug && console.log('Contract address required. chainID = '+this.ethersData.chainID);
311 throw new Error('Contract address required. chainID = '+this.ethersData.chainID);
312 }
313
314 if (!ethContract && !contractAddress) throw new Error(' ethContract and contractAddress required for {Address='+this.ethersData.userAddress+', chainID = '+this.ethersData.chainID+' , tokenName = '+this.tokenName+'}. Check logs for details');
315
316 let params = getErc20EventParams(eventType, this.xmlDoc, this.tokenXMLNode);
317 // console.log('params');
318 // console.log(params);
319
320 if (!params) throw new Error(eventType+' parameters missing.');
321
322 const match = eventFilter.match(/(\S+)=(\S+)/);
323
324 if (match) {
325 let paramName = match[1];
326 let paramValue = match[2];
327 if (paramName in params) {
328 params[paramName] = paramValue == '${ownerAddress}' ? this.ethersData.userAddress : paramValue;
329 }
330 }
331
332 let paramsArray = [];

Callers 1

renderMethod · 0.95

Calls 8

renderActivityItemMethod · 0.95
runMainDataChangedMethod · 0.95
getXMLItemFunction · 0.90
getContractAddressFunction · 0.90
getErc20EventParamsFunction · 0.90
toFunction · 0.90
getJSONAbiFunction · 0.90
filterResultConverterFunction · 0.90

Tested by

no test coverage detected