| 11 | }; |
| 12 | |
| 13 | function buildDecodedMap(types: ParameterType[], nameValuePairs: [string, string][]): DecodedMap { |
| 14 | return nameValuePairs.reduce((acc, pair, index) => { |
| 15 | const [encodedName, encodedValue] = pair; |
| 16 | const name = ethers.utils.parseBytes32String(encodedName); |
| 17 | const type = types[index]; |
| 18 | const transform = VALUE_TRANSFORMATIONS[type]; |
| 19 | // If the type does not need to be transformed, return it as is |
| 20 | if (!transform) { |
| 21 | return { ...acc, [name]: encodedValue }; |
| 22 | } |
| 23 | const parsedValue = transform(encodedValue); |
| 24 | return { ...acc, [name]: parsedValue }; |
| 25 | }, {}); |
| 26 | } |
| 27 | |
| 28 | export function decode(encodedData: string): DecodedMap { |
| 29 | // Special cases for empty parameters |