(ethContract, jsons, path = '', debug = false)
| 260 | */ |
| 261 | |
| 262 | export 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 |
no outgoing calls
no test coverage detected