MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / resolveGroupMembers

Function resolveGroupMembers

src/code-gen/fields.ts:53–76  ·  view source on GitHub ↗
(
  struct: AbiStruct,
  group: GroupType,
  fields: ProcessedField[],
)

Source from the content-addressed store, hash-verified

51};
52
53export const resolveGroupMembers = (
54 struct: AbiStruct,
55 group: GroupType,
56 fields: ProcessedField[],
57): ProcessedField[] => {
58 const fieldCopies: ProcessedField[] = []
59 for (const member of group.members) {
60 const field = fields.find((field) => field.name === member.name);
61 if (!field) throw Error(`Member ${member.name} of group ${group.name} not found in ${struct.name}`);
62
63 // Shallow copy because we won't need to modify nested values
64 const fieldCopy = { ...field };
65
66 // If group member defines coder type, it will override the group's coder type
67 // and the coder type of the original field in the struct.
68 // If group defines coder type, it will override the coder type of the original
69 // field in the struct.
70 if (member.coderType) applyCoderType(fieldCopy, member.coderType);
71 else if (group.coderType) applyCoderType(fieldCopy, group.coderType);
72
73 fieldCopies.push(fieldCopy);
74 }
75 return fieldCopies;
76}
77
78export const applyGroupAccessCoder = (
79 group: GroupType,

Callers 1

processStructFunction · 0.85

Calls 1

applyCoderTypeFunction · 0.85

Tested by

no test coverage detected