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

Function getJSONAbi

bootstrap-js/modules/ts_helpers.js:262–287  ·  view source on GitHub ↗
(ethContract, jsons, path = '', debug = false)

Source from the content-addressed store, hash-verified

260 */
261
262export async function getJSONAbi(ethContract, jsons, path = '', debug = false){
263 let contractJson = jsons ? jsons[ethContract] : false;
264
265 if (contractJson) return contractJson;
266
267 try {
268 let response = await fetch(path + ethContract + '.json');
269 if (response.status !== 200) {
270 const message = 'Looks like there was a problem. Status Code: ' +
271 response.status;
272 debug && console.log(message);
273 throw new Error(message);
274 }
275 contractJson = await response.json();
276 jsons[ethContract] = contractJson;
277
278 } catch (e) {
279 let message = 'token JSON fetch error. ' + e;
280 debug && console.log(e);
281 debug && console.log(message);
282 // throw new Error(message);
283 return false;
284 }
285
286 return contractJson;
287}
288
289/**
290 * Convert Contact filter results to readable values and extends it with common token props

Callers 2

renderPropsMethod · 0.90
getPropsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected