(typeName: string)
| 219 | } |
| 220 | |
| 221 | export const elementaryToTypeDef = (typeName: string): AbiElementaryType => { |
| 222 | const isBool = /bool/g.exec(typeName); |
| 223 | if (isBool) |
| 224 | return { |
| 225 | meta: "elementary", |
| 226 | dynamic: false, |
| 227 | size: 1, |
| 228 | type: "bool", |
| 229 | }; |
| 230 | const isUint = /uint(\d{0,3})/g.exec(typeName); |
| 231 | if (isUint) { |
| 232 | const size = isUint[1]; |
| 233 | return { |
| 234 | meta: "elementary", |
| 235 | dynamic: !size, |
| 236 | size: size ? +size : null, |
| 237 | type: "uint", |
| 238 | }; |
| 239 | } |
| 240 | const isInt = /int(\d{0,3})/g.exec(typeName); |
| 241 | if (isInt) { |
| 242 | const size = isInt[1] |
| 243 | if (!size || +size % 8) throw Error(`Signed ints must have size that is a multiple of 8`) |
| 244 | return { |
| 245 | meta: 'elementary', |
| 246 | dynamic: false, |
| 247 | size: size ? +size : null, |
| 248 | type: "int", |
| 249 | } |
| 250 | } |
| 251 | const isBytes = /bytes(\d{0,2})/g.exec(typeName); |
| 252 | if (isBytes) { |
| 253 | const size = isBytes[1]; |
| 254 | return { |
| 255 | meta: "elementary", |
| 256 | dynamic: !size, |
| 257 | size: size ? 8 * +size : null, |
| 258 | type: "bytes", |
| 259 | }; |
| 260 | } |
| 261 | const isAddress = /address/g.exec(typeName); |
| 262 | if (isAddress) { |
| 263 | return { |
| 264 | meta: "elementary", |
| 265 | dynamic: false, |
| 266 | size: 160, |
| 267 | type: "address", |
| 268 | }; |
| 269 | } |
| 270 | }; |
no outgoing calls
no test coverage detected