MCPcopy Create free account
hub / github.com/api3dao/airnode / buildDecodedMap

Function buildDecodedMap

packages/airnode-abi/src/decoding.ts:13–26  ·  view source on GitHub ↗
(types: ParameterType[], nameValuePairs: [string, string][])

Source from the content-addressed store, hash-verified

11};
12
13function 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
28export function decode(encodedData: string): DecodedMap {
29 // Special cases for empty parameters

Callers 1

decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected