* Create a new Interface for the %%fragments%%.
(fragments)
| 236 | * Create a new Interface for the %%fragments%%. |
| 237 | */ |
| 238 | constructor(fragments) { |
| 239 | let abi = []; |
| 240 | if (typeof (fragments) === "string") { |
| 241 | abi = JSON.parse(fragments); |
| 242 | } |
| 243 | else { |
| 244 | abi = fragments; |
| 245 | } |
| 246 | this.#functions = new Map(); |
| 247 | this.#errors = new Map(); |
| 248 | this.#events = new Map(); |
| 249 | // this.#structs = new Map(); |
| 250 | const frags = []; |
| 251 | for (const a of abi) { |
| 252 | try { |
| 253 | frags.push(fragments_js_1.Fragment.from(a)); |
| 254 | } |
| 255 | catch (error) { |
| 256 | console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`, error.message); |
| 257 | } |
| 258 | } |
| 259 | (0, index_js_3.defineProperties)(this, { |
| 260 | fragments: Object.freeze(frags) |
| 261 | }); |
| 262 | let fallback = null; |
| 263 | let receive = false; |
| 264 | this.#abiCoder = this.getAbiCoder(); |
| 265 | // Add all fragments by their signature |
| 266 | this.fragments.forEach((fragment, index) => { |
| 267 | let bucket; |
| 268 | switch (fragment.type) { |
| 269 | case "constructor": |
| 270 | if (this.deploy) { |
| 271 | console.log("duplicate definition - constructor"); |
| 272 | return; |
| 273 | } |
| 274 | //checkNames(fragment, "input", fragment.inputs); |
| 275 | (0, index_js_3.defineProperties)(this, { deploy: fragment }); |
| 276 | return; |
| 277 | case "fallback": |
| 278 | if (fragment.inputs.length === 0) { |
| 279 | receive = true; |
| 280 | } |
| 281 | else { |
| 282 | (0, index_js_3.assertArgument)(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment); |
| 283 | fallback = fragment; |
| 284 | receive = fallback.payable; |
| 285 | } |
| 286 | return; |
| 287 | case "function": |
| 288 | //checkNames(fragment, "input", fragment.inputs); |
| 289 | //checkNames(fragment, "output", (<FunctionFragment>fragment).outputs); |
| 290 | bucket = this.#functions; |
| 291 | break; |
| 292 | case "event": |
| 293 | //checkNames(fragment, "input", fragment.inputs); |
| 294 | bucket = this.#events; |
| 295 | break; |
nothing calls this directly
no test coverage detected