@macalinao/codama-rename-visitor 0.3.3 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,75 +1,28 @@
1
- import { bottomUpTransformerVisitor, rootNodeVisitor, visit } from "codama";
2
1
  import { renameAccountTransform } from "./rename-accounts-visitor.js";
3
2
  import { renameDefinedTypeTransform } from "./rename-defined-types-visitor.js";
4
3
  import { renameInstructionTransform } from "./rename-instructions-visitor.js";
4
+ import { bottomUpTransformerVisitor, rootNodeVisitor, visit } from "codama";
5
+ //#region src/rename-visitor.ts
5
6
  /**
6
- * Creates a visitor that renames accounts, instructions, and defined types in specific programs.
7
- * This follows the same pattern as addPdasVisitor from Codama.
8
- *
9
- * @param renamesByProgram - Object mapping program names to their rename configurations
10
- * @returns A root node visitor that performs all specified renames
11
- *
12
- * @example
13
- * ```typescript
14
- * const visitor = renameVisitor({
15
- * quarryMine: {
16
- * instructions: {
17
- * claimRewards: "claimRewardsMine"
18
- * },
19
- * accounts: {
20
- * miner: "minerAccount"
21
- * }
22
- * },
23
- * token: {
24
- * instructions: {
25
- * transfer: "transferTokens",
26
- * mint: "mintNft"
27
- * },
28
- * definedTypes: {
29
- * tokenData: "tokenMetadata"
30
- * }
31
- * }
32
- * });
33
- * codama.update(visitor);
34
- * ```
35
- */
36
- export function renameVisitor(renamesByProgram) {
37
- return rootNodeVisitor((root) => {
38
- const transforms = [];
39
- // Process each program's rename configuration
40
- Object.entries(renamesByProgram).forEach(([programName, renameOptions]) => {
41
- // Add instruction renames for this program
42
- if (renameOptions.instructions) {
43
- Object.entries(renameOptions.instructions).forEach(([oldName, newName]) => {
44
- transforms.push({
45
- select: `[programNode]${programName}.[instructionNode]${oldName}`,
46
- transform: (node) => renameInstructionTransform(node, { [oldName]: newName }),
47
- });
48
- });
49
- }
50
- if (renameOptions.accounts) {
51
- Object.entries(renameOptions.accounts).forEach(([oldName, newName]) => {
52
- transforms.push({
53
- select: `[programNode]${programName}.[accountNode]${oldName}`,
54
- transform: (node) => renameAccountTransform(node, { [oldName]: newName }),
55
- });
56
- });
57
- }
58
- // Add defined type renames for this program
59
- if (renameOptions.definedTypes) {
60
- Object.entries(renameOptions.definedTypes ?? {}).forEach(([oldName, newName]) => {
61
- transforms.push({
62
- select: `[programNode]${programName}.[definedTypeNode]${oldName}`,
63
- transform: (node) => renameDefinedTypeTransform(node, { [oldName]: newName }),
64
- });
65
- });
66
- }
67
- });
68
- if (transforms.length === 0) {
69
- return root;
70
- }
71
- const visitor = bottomUpTransformerVisitor(transforms);
72
- return visit(root, visitor);
73
- });
7
+ * Builds a transform for each entry of a rename record, targeting nodes of the
8
+ * given kind within the given program.
9
+ */
10
+ function buildRenameTransforms(programName, nodeKind, renames, rename) {
11
+ if (!renames) return [];
12
+ return Object.entries(renames).map(([oldName, newName]) => ({
13
+ select: `[programNode]${programName}.[${nodeKind}]${oldName}`,
14
+ transform: (node) => rename(node, { [oldName]: newName })
15
+ }));
16
+ }
17
+ function renameVisitor(renamesByProgram) {
18
+ return rootNodeVisitor((root) => {
19
+ const transforms = [];
20
+ for (const [programName, renameOptions] of Object.entries(renamesByProgram)) transforms.push(...buildRenameTransforms(programName, "instructionNode", renameOptions.instructions, renameInstructionTransform), ...buildRenameTransforms(programName, "accountNode", renameOptions.accounts, renameAccountTransform), ...buildRenameTransforms(programName, "definedTypeNode", renameOptions.definedTypes, renameDefinedTypeTransform));
21
+ if (transforms.length === 0) return root;
22
+ return visit(root, bottomUpTransformerVisitor(transforms));
23
+ });
74
24
  }
25
+ //#endregion
26
+ export { renameVisitor };
27
+
75
28
  //# sourceMappingURL=rename-visitor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rename-visitor.js","sourceRoot":"","sources":["../src/rename-visitor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,aAAa,CAC3B,gBAAsD;IAEtD,OAAO,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9B,MAAM,UAAU,GAGV,EAAE,CAAC;QAET,8CAA8C;QAC9C,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,aAAa,CAAC,EAAE,EAAE;YACxE,2CAA2C;YAC3C,IAAI,aAAa,CAAC,YAAY,EAAE,CAAC;gBAC/B,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,OAAO,CAChD,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;oBACrB,UAAU,CAAC,IAAI,CAAC;wBACd,MAAM,EAAE,gBAAgB,WAAW,qBAAqB,OAAO,EAAE;wBACjE,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;qBAC3D,CAAC,CAAC;gBACL,CAAC,CACF,CAAC;YACJ,CAAC;YAED,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;gBAC3B,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;oBACpE,UAAU,CAAC,IAAI,CAAC;wBACd,MAAM,EAAE,gBAAgB,WAAW,iBAAiB,OAAO,EAAE;wBAC7D,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,sBAAsB,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;qBACvD,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC;YAED,4CAA4C;YAC5C,IAAI,aAAa,CAAC,YAAY,EAAE,CAAC;gBAC/B,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,OAAO,CACtD,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE;oBACrB,UAAU,CAAC,IAAI,CAAC;wBACd,MAAM,EAAE,gBAAgB,WAAW,qBAAqB,OAAO,EAAE;wBACjE,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,0BAA0B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;qBAC3D,CAAC,CAAC;gBACL,CAAC,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACvD,OAAO,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Node } from \"codama\";\nimport type { ProgramRenameOptions } from \"./types.js\";\nimport { bottomUpTransformerVisitor, rootNodeVisitor, visit } from \"codama\";\nimport { renameAccountTransform } from \"./rename-accounts-visitor.js\";\nimport { renameDefinedTypeTransform } from \"./rename-defined-types-visitor.js\";\nimport { renameInstructionTransform } from \"./rename-instructions-visitor.js\";\n\n/**\n * Creates a visitor that renames accounts, instructions, and defined types in specific programs.\n * This follows the same pattern as addPdasVisitor from Codama.\n *\n * @param renamesByProgram - Object mapping program names to their rename configurations\n * @returns A root node visitor that performs all specified renames\n *\n * @example\n * ```typescript\n * const visitor = renameVisitor({\n * quarryMine: {\n * instructions: {\n * claimRewards: \"claimRewardsMine\"\n * },\n * accounts: {\n * miner: \"minerAccount\"\n * }\n * },\n * token: {\n * instructions: {\n * transfer: \"transferTokens\",\n * mint: \"mintNft\"\n * },\n * definedTypes: {\n * tokenData: \"tokenMetadata\"\n * }\n * }\n * });\n * codama.update(visitor);\n * ```\n */\nexport function renameVisitor(\n renamesByProgram: Record<string, ProgramRenameOptions>,\n): ReturnType<typeof rootNodeVisitor> {\n return rootNodeVisitor((root) => {\n const transforms: {\n select: string;\n transform: (node: Node) => Node | null;\n }[] = [];\n\n // Process each program's rename configuration\n Object.entries(renamesByProgram).forEach(([programName, renameOptions]) => {\n // Add instruction renames for this program\n if (renameOptions.instructions) {\n Object.entries(renameOptions.instructions).forEach(\n ([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[instructionNode]${oldName}`,\n transform: (node) =>\n renameInstructionTransform(node, { [oldName]: newName }),\n });\n },\n );\n }\n\n if (renameOptions.accounts) {\n Object.entries(renameOptions.accounts).forEach(([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[accountNode]${oldName}`,\n transform: (node) =>\n renameAccountTransform(node, { [oldName]: newName }),\n });\n });\n }\n\n // Add defined type renames for this program\n if (renameOptions.definedTypes) {\n Object.entries(renameOptions.definedTypes ?? {}).forEach(\n ([oldName, newName]) => {\n transforms.push({\n select: `[programNode]${programName}.[definedTypeNode]${oldName}`,\n transform: (node) =>\n renameDefinedTypeTransform(node, { [oldName]: newName }),\n });\n },\n );\n }\n });\n\n if (transforms.length === 0) {\n return root;\n }\n\n const visitor = bottomUpTransformerVisitor(transforms);\n return visit(root, visitor);\n });\n}\n"]}
1
+ {"version":3,"file":"rename-visitor.js","names":[],"sources":["../src/rename-visitor.ts"],"sourcesContent":["import type { Node, Visitor } from \"codama\";\nimport type { ProgramRenameOptions } from \"./types.js\";\nimport { bottomUpTransformerVisitor, rootNodeVisitor, visit } from \"codama\";\nimport { renameAccountTransform } from \"./rename-accounts-visitor.js\";\nimport { renameDefinedTypeTransform } from \"./rename-defined-types-visitor.js\";\nimport { renameInstructionTransform } from \"./rename-instructions-visitor.js\";\n\n/**\n * Creates a visitor that renames accounts, instructions, and defined types in specific programs.\n * This follows the same pattern as addPdasVisitor from Codama.\n *\n * @param renamesByProgram - Object mapping program names to their rename configurations\n * @returns A root node visitor that performs all specified renames\n *\n * @example\n * ```typescript\n * const visitor = renameVisitor({\n * quarryMine: {\n * instructions: {\n * claimRewards: \"claimRewardsMine\"\n * },\n * accounts: {\n * miner: \"minerAccount\"\n * }\n * },\n * token: {\n * instructions: {\n * transfer: \"transferTokens\",\n * mint: \"mintNft\"\n * },\n * definedTypes: {\n * tokenData: \"tokenMetadata\"\n * }\n * }\n * });\n * codama.update(visitor);\n * ```\n */\ninterface RenameTransform {\n select: string;\n transform: (node: Node) => Node | null;\n}\n\n/**\n * Builds a transform for each entry of a rename record, targeting nodes of the\n * given kind within the given program.\n */\nfunction buildRenameTransforms(\n programName: string,\n nodeKind: string,\n renames: Record<string, string> | undefined,\n rename: (node: Node, mapping: Record<string, string>) => Node | null,\n): RenameTransform[] {\n if (!renames) {\n return [];\n }\n return Object.entries(renames).map(([oldName, newName]) => ({\n select: `[programNode]${programName}.[${nodeKind}]${oldName}`,\n transform: (node: Node) => rename(node, { [oldName]: newName }),\n }));\n}\n\nexport function renameVisitor(\n renamesByProgram: Record<string, ProgramRenameOptions>,\n): Visitor<Node | null, \"rootNode\"> {\n return rootNodeVisitor<Node | null>((root) => {\n const transforms: RenameTransform[] = [];\n\n // Process each program's rename configuration\n for (const [programName, renameOptions] of Object.entries(\n renamesByProgram,\n )) {\n transforms.push(\n ...buildRenameTransforms(\n programName,\n \"instructionNode\",\n renameOptions.instructions,\n renameInstructionTransform,\n ),\n ...buildRenameTransforms(\n programName,\n \"accountNode\",\n renameOptions.accounts,\n renameAccountTransform,\n ),\n ...buildRenameTransforms(\n programName,\n \"definedTypeNode\",\n renameOptions.definedTypes,\n renameDefinedTypeTransform,\n ),\n );\n }\n\n if (transforms.length === 0) {\n return root;\n }\n\n const visitor = bottomUpTransformerVisitor(transforms);\n return visit(root, visitor);\n });\n}\n"],"mappings":";;;;;;;;;AA+CA,SAAS,sBACP,aACA,UACA,SACA,QACmB;CACnB,IAAI,CAAC,SACH,OAAO,CAAC;CAEV,OAAO,OAAO,QAAQ,OAAO,CAAC,CAAC,KAAK,CAAC,SAAS,cAAc;EAC1D,QAAQ,gBAAgB,YAAY,IAAI,SAAS,GAAG;EACpD,YAAY,SAAe,OAAO,MAAM,GAAG,UAAU,QAAQ,CAAC;CAChE,EAAE;AACJ;AAEA,SAAgB,cACd,kBACkC;CAClC,OAAO,iBAA8B,SAAS;EAC5C,MAAM,aAAgC,CAAC;EAGvC,KAAK,MAAM,CAAC,aAAa,kBAAkB,OAAO,QAChD,gBACF,GACE,WAAW,KACT,GAAG,sBACD,aACA,mBACA,cAAc,cACd,0BACF,GACA,GAAG,sBACD,aACA,eACA,cAAc,UACd,sBACF,GACA,GAAG,sBACD,aACA,mBACA,cAAc,cACd,0BACF,CACF;EAGF,IAAI,WAAW,WAAW,GACxB,OAAO;EAIT,OAAO,MAAM,MADG,2BAA2B,UAClB,CAAC;CAC5B,CAAC;AACH"}
package/dist/types.d.ts CHANGED
@@ -1,12 +1,15 @@
1
+ //#region src/types.d.ts
1
2
  /**
2
- * Rename mapping for a single program
3
- */
4
- export interface ProgramRenameOptions {
5
- /** Mapping of old account names to new account names */
6
- accounts?: Record<string, string>;
7
- /** Mapping of old instruction names to new instruction names */
8
- instructions?: Record<string, string>;
9
- /** Mapping of old defined type names to new defined type names */
10
- definedTypes?: Record<string, string>;
3
+ * Rename mapping for a single program
4
+ */
5
+ interface ProgramRenameOptions {
6
+ /** Mapping of old account names to new account names */
7
+ accounts?: Record<string, string>;
8
+ /** Mapping of old instruction names to new instruction names */
9
+ instructions?: Record<string, string>;
10
+ /** Mapping of old defined type names to new defined type names */
11
+ definedTypes?: Record<string, string>;
11
12
  }
13
+ //#endregion
14
+ export { ProgramRenameOptions };
12
15
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;AAGA;;UAAiB,oBAAA;;EAEf,QAAA,GAAW,MAAA;;EAEX,YAAA,GAAe,MAAA;EAEA;EAAf,YAAA,GAAe,MAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macalinao/codama-rename-visitor",
3
- "version": "0.3.3",
3
+ "version": "0.4.1",
4
4
  "description": "Codama visitor for renaming instructions and events within a program",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -39,19 +39,20 @@
39
39
  "directory": "packages/codama-rename-visitor"
40
40
  },
41
41
  "scripts": {
42
- "build": "tsc",
43
- "clean": "tsc --build --clean && rm -fr .eslintcache dist/ node_modules/ tsconfig.tsbuildinfo",
42
+ "build": "tsdown",
43
+ "clean": "rm -fr .eslintcache dist/ node_modules/ tsconfig.tsbuildinfo",
44
44
  "lint": "eslint . --cache",
45
45
  "test": "bun test src/"
46
46
  },
47
47
  "dependencies": {
48
- "codama": "^1.5.0"
48
+ "codama": "^1.7.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@types/bun": "^1.3.5",
52
- "@macalinao/eslint-config": "^7.0.3",
51
+ "@types/bun": "^1.3.14",
52
+ "@macalinao/eslint-config": "^8.1.0",
53
53
  "@macalinao/tsconfig": "^3.2.5",
54
- "eslint": "^9.39.2",
55
- "typescript": "^5.9.3"
54
+ "eslint": "^10.4.1",
55
+ "typescript": "^6.0.3",
56
+ "tsdown": "^0.22.2"
56
57
  }
57
58
  }
@@ -1,4 +1,4 @@
1
- import type { AccountNode, Node, rootNodeVisitor } from "codama";
1
+ import type { AccountNode, Node, Visitor } from "codama";
2
2
  import { assertIsNode, bottomUpTransformerVisitor, camelCase } from "codama";
3
3
 
4
4
  /**
@@ -40,7 +40,7 @@ export function renameAccountTransform(
40
40
  */
41
41
  export function renameAccountsVisitor(
42
42
  mapping: Record<string, string>,
43
- ): ReturnType<typeof rootNodeVisitor> {
43
+ ): Visitor<Node | null, "rootNode"> {
44
44
  return bottomUpTransformerVisitor([
45
45
  {
46
46
  select: "[accountNode]",
@@ -1,4 +1,4 @@
1
- import type { DefinedTypeNode, Node } from "codama";
1
+ import type { DefinedTypeNode, Node, Visitor } from "codama";
2
2
  import {
3
3
  assertIsNode,
4
4
  bottomUpTransformerVisitor,
@@ -46,8 +46,8 @@ export function renameDefinedTypeTransform(
46
46
  */
47
47
  export function renameDefinedTypesVisitor(
48
48
  mapping: Record<string, string>,
49
- ): ReturnType<typeof rootNodeVisitor> {
50
- return rootNodeVisitor((root) => {
49
+ ): Visitor<Node | null, "rootNode"> {
50
+ return rootNodeVisitor<Node | null>((root) => {
51
51
  const typeVisitor = bottomUpTransformerVisitor([
52
52
  {
53
53
  select: "[definedTypeNode]",
@@ -1,4 +1,4 @@
1
- import type { Node } from "codama";
1
+ import type { Node, Visitor } from "codama";
2
2
  import type { ProgramRenameOptions } from "./types.js";
3
3
  import { bottomUpTransformerVisitor, rootNodeVisitor, visit } from "codama";
4
4
  import { renameAccountTransform } from "./rename-accounts-visitor.js";
@@ -36,53 +36,61 @@ import { renameInstructionTransform } from "./rename-instructions-visitor.js";
36
36
  * codama.update(visitor);
37
37
  * ```
38
38
  */
39
+ interface RenameTransform {
40
+ select: string;
41
+ transform: (node: Node) => Node | null;
42
+ }
43
+
44
+ /**
45
+ * Builds a transform for each entry of a rename record, targeting nodes of the
46
+ * given kind within the given program.
47
+ */
48
+ function buildRenameTransforms(
49
+ programName: string,
50
+ nodeKind: string,
51
+ renames: Record<string, string> | undefined,
52
+ rename: (node: Node, mapping: Record<string, string>) => Node | null,
53
+ ): RenameTransform[] {
54
+ if (!renames) {
55
+ return [];
56
+ }
57
+ return Object.entries(renames).map(([oldName, newName]) => ({
58
+ select: `[programNode]${programName}.[${nodeKind}]${oldName}`,
59
+ transform: (node: Node) => rename(node, { [oldName]: newName }),
60
+ }));
61
+ }
62
+
39
63
  export function renameVisitor(
40
64
  renamesByProgram: Record<string, ProgramRenameOptions>,
41
- ): ReturnType<typeof rootNodeVisitor> {
42
- return rootNodeVisitor((root) => {
43
- const transforms: {
44
- select: string;
45
- transform: (node: Node) => Node | null;
46
- }[] = [];
65
+ ): Visitor<Node | null, "rootNode"> {
66
+ return rootNodeVisitor<Node | null>((root) => {
67
+ const transforms: RenameTransform[] = [];
47
68
 
48
69
  // Process each program's rename configuration
49
- Object.entries(renamesByProgram).forEach(([programName, renameOptions]) => {
50
- // Add instruction renames for this program
51
- if (renameOptions.instructions) {
52
- Object.entries(renameOptions.instructions).forEach(
53
- ([oldName, newName]) => {
54
- transforms.push({
55
- select: `[programNode]${programName}.[instructionNode]${oldName}`,
56
- transform: (node) =>
57
- renameInstructionTransform(node, { [oldName]: newName }),
58
- });
59
- },
60
- );
61
- }
62
-
63
- if (renameOptions.accounts) {
64
- Object.entries(renameOptions.accounts).forEach(([oldName, newName]) => {
65
- transforms.push({
66
- select: `[programNode]${programName}.[accountNode]${oldName}`,
67
- transform: (node) =>
68
- renameAccountTransform(node, { [oldName]: newName }),
69
- });
70
- });
71
- }
72
-
73
- // Add defined type renames for this program
74
- if (renameOptions.definedTypes) {
75
- Object.entries(renameOptions.definedTypes ?? {}).forEach(
76
- ([oldName, newName]) => {
77
- transforms.push({
78
- select: `[programNode]${programName}.[definedTypeNode]${oldName}`,
79
- transform: (node) =>
80
- renameDefinedTypeTransform(node, { [oldName]: newName }),
81
- });
82
- },
83
- );
84
- }
85
- });
70
+ for (const [programName, renameOptions] of Object.entries(
71
+ renamesByProgram,
72
+ )) {
73
+ transforms.push(
74
+ ...buildRenameTransforms(
75
+ programName,
76
+ "instructionNode",
77
+ renameOptions.instructions,
78
+ renameInstructionTransform,
79
+ ),
80
+ ...buildRenameTransforms(
81
+ programName,
82
+ "accountNode",
83
+ renameOptions.accounts,
84
+ renameAccountTransform,
85
+ ),
86
+ ...buildRenameTransforms(
87
+ programName,
88
+ "definedTypeNode",
89
+ renameOptions.definedTypes,
90
+ renameDefinedTypeTransform,
91
+ ),
92
+ );
93
+ }
86
94
 
87
95
  if (transforms.length === 0) {
88
96
  return root;