* Create a new Interface for the %%fragments%%.
(fragments)
| 139 | * Create a new Interface for the %%fragments%%. |
| 140 | */ |
| 141 | constructor(fragments) { |
| 142 | let abi = []; |
| 143 | if (typeof (fragments) === "string") { |
| 144 | abi = JSON.parse(fragments); |
| 145 | } |
| 146 | else { |
| 147 | abi = fragments; |
| 148 | } |
| 149 | this.#functions = new Map(); |
| 150 | this.#errors = new Map(); |
| 151 | this.#events = new Map(); |
| 152 | // this.#structs = new Map(); |
| 153 | const frags = []; |
| 154 | for (const a of abi) { |
| 155 | try { |
| 156 | frags.push(Fragment.from(a)); |
| 157 | } |
| 158 | catch (error) { |
| 159 | console.log("EE", error); |
| 160 | } |
| 161 | } |
| 162 | defineProperties(this, { |
| 163 | fragments: Object.freeze(frags) |
| 164 | }); |
| 165 | let fallback = null; |
| 166 | let receive = false; |
| 167 | this.#abiCoder = this.getAbiCoder(); |
| 168 | // Add all fragments by their signature |
| 169 | this.fragments.forEach((fragment, index) => { |
| 170 | let bucket; |
| 171 | switch (fragment.type) { |
| 172 | case "constructor": |
| 173 | if (this.deploy) { |
| 174 | console.log("duplicate definition - constructor"); |
| 175 | return; |
| 176 | } |
| 177 | //checkNames(fragment, "input", fragment.inputs); |
| 178 | defineProperties(this, { deploy: fragment }); |
| 179 | return; |
| 180 | case "fallback": |
| 181 | if (fragment.inputs.length === 0) { |
| 182 | receive = true; |
| 183 | } |
| 184 | else { |
| 185 | assertArgument(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment); |
| 186 | fallback = fragment; |
| 187 | receive = fallback.payable; |
| 188 | } |
| 189 | return; |
| 190 | case "function": |
| 191 | //checkNames(fragment, "input", fragment.inputs); |
| 192 | //checkNames(fragment, "output", (<FunctionFragment>fragment).outputs); |
| 193 | bucket = this.#functions; |
| 194 | break; |
| 195 | case "event": |
| 196 | //checkNames(fragment, "input", fragment.inputs); |
| 197 | bucket = this.#events; |
| 198 | break; |
nothing calls this directly
no test coverage detected