@codama/renderers-js 1.4.1 → 1.4.3
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.
- package/README.md +13 -14
- package/dist/index.browser.cjs +133 -132
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +51 -50
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.cjs +133 -132
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +51 -50
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.react-native.mjs +51 -50
- package/dist/index.react-native.mjs.map +1 -1
- package/dist/types/fragments/indexPage.d.ts +1 -2
- package/dist/types/fragments/indexPage.d.ts.map +1 -1
- package/package.json +28 -10
package/dist/index.browser.cjs
CHANGED
|
@@ -314,7 +314,7 @@ function mergeTypeManifests(manifests, options = {}) {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
// src/visitors/getRenderMapVisitor.ts
|
|
317
|
-
var
|
|
317
|
+
var import_nodes29 = require("@codama/nodes");
|
|
318
318
|
var import_renderers_core13 = require("@codama/renderers-core");
|
|
319
319
|
var import_visitors_core29 = require("@codama/visitors-core");
|
|
320
320
|
|
|
@@ -928,16 +928,17 @@ function getIsErrorFunctionFragment(scope) {
|
|
|
928
928
|
}
|
|
929
929
|
|
|
930
930
|
// src/fragments/indexPage.ts
|
|
931
|
+
var import_nodes11 = require("@codama/nodes");
|
|
931
932
|
function getIndexPageFragment(items) {
|
|
932
933
|
if (items.length === 0) return;
|
|
933
|
-
const names = items.map((item) => item.name).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
|
|
934
|
+
const names = items.map((item) => (0, import_nodes11.camelCase)(item.name)).sort((a, b) => a.localeCompare(b)).map((name) => getExportAllFragment(`./${name}`));
|
|
934
935
|
return mergeFragments(names, (cs) => cs.join("\n"));
|
|
935
936
|
}
|
|
936
937
|
|
|
937
938
|
// src/fragments/instructionAccountMeta.ts
|
|
938
|
-
var
|
|
939
|
+
var import_nodes12 = require("@codama/nodes");
|
|
939
940
|
function getInstructionAccountMetaFragment(instructionAccountNode) {
|
|
940
|
-
const typeParam = `TAccount${(0,
|
|
941
|
+
const typeParam = `TAccount${(0, import_nodes12.pascalCase)(instructionAccountNode.name)}`;
|
|
941
942
|
if (instructionAccountNode.isSigner === true && instructionAccountNode.isWritable) {
|
|
942
943
|
return fragment`${use("type WritableSignerAccount", "solanaInstructions")}<${typeParam}> & ${use("type AccountSignerMeta", "solanaSigners")}<${typeParam}>`;
|
|
943
944
|
}
|
|
@@ -951,14 +952,14 @@ function getInstructionAccountMetaFragment(instructionAccountNode) {
|
|
|
951
952
|
}
|
|
952
953
|
|
|
953
954
|
// src/fragments/instructionAccountTypeParam.ts
|
|
954
|
-
var
|
|
955
|
+
var import_nodes13 = require("@codama/nodes");
|
|
955
956
|
var import_visitors_core9 = require("@codama/visitors-core");
|
|
956
957
|
function getInstructionAccountTypeParamFragment(scope) {
|
|
957
958
|
const { instructionAccountPath, allowAccountMeta, linkables } = scope;
|
|
958
959
|
const instructionAccountNode = (0, import_visitors_core9.getLastNodeFromPath)(instructionAccountPath);
|
|
959
960
|
const instructionNode = (0, import_visitors_core9.findInstructionNodeFromPath)(instructionAccountPath);
|
|
960
961
|
const programNode = (0, import_visitors_core9.findProgramNodeFromPath)(instructionAccountPath);
|
|
961
|
-
const typeParam = `TAccount${(0,
|
|
962
|
+
const typeParam = `TAccount${(0, import_nodes13.pascalCase)(instructionAccountNode.name)}`;
|
|
962
963
|
const accountMeta = allowAccountMeta ? fragment` | ${use("type AccountMeta", "solanaInstructions")}<string>` : void 0;
|
|
963
964
|
if (instructionNode.optionalAccountStrategy === "omitted" && instructionAccountNode.isOptional) {
|
|
964
965
|
return fragment`${typeParam} extends string${accountMeta} | undefined = undefined`;
|
|
@@ -981,7 +982,7 @@ function getDefaultAddress(defaultValue, programId, linkables) {
|
|
|
981
982
|
}
|
|
982
983
|
|
|
983
984
|
// src/fragments/instructionByteDelta.ts
|
|
984
|
-
var
|
|
985
|
+
var import_nodes14 = require("@codama/nodes");
|
|
985
986
|
var import_renderers_core3 = require("@codama/renderers-core");
|
|
986
987
|
var import_visitors_core10 = require("@codama/visitors-core");
|
|
987
988
|
function getInstructionByteDeltaFragment(scope) {
|
|
@@ -996,16 +997,16 @@ const byteDelta: number = [${c.join(",")}].reduce((a, b) => a + b, 0);`
|
|
|
996
997
|
}
|
|
997
998
|
function getByteDeltaFragment(byteDelta, scope) {
|
|
998
999
|
let bytesFragment = (() => {
|
|
999
|
-
if ((0,
|
|
1000
|
+
if ((0, import_nodes14.isNode)(byteDelta.value, "numberValueNode")) {
|
|
1000
1001
|
return getNumberValueNodeFragment(byteDelta);
|
|
1001
1002
|
}
|
|
1002
|
-
if ((0,
|
|
1003
|
+
if ((0, import_nodes14.isNode)(byteDelta.value, "argumentValueNode")) {
|
|
1003
1004
|
return getArgumentValueNodeFragment(byteDelta);
|
|
1004
1005
|
}
|
|
1005
|
-
if ((0,
|
|
1006
|
+
if ((0, import_nodes14.isNode)(byteDelta.value, "accountLinkNode")) {
|
|
1006
1007
|
return getAccountLinkNodeFragment(byteDelta, scope);
|
|
1007
1008
|
}
|
|
1008
|
-
if ((0,
|
|
1009
|
+
if ((0, import_nodes14.isNode)(byteDelta.value, "resolverValueNode")) {
|
|
1009
1010
|
return getResolverValueNodeFragment(byteDelta, scope);
|
|
1010
1011
|
}
|
|
1011
1012
|
return null;
|
|
@@ -1020,16 +1021,16 @@ function getByteDeltaFragment(byteDelta, scope) {
|
|
|
1020
1021
|
return [bytesFragment];
|
|
1021
1022
|
}
|
|
1022
1023
|
function getNumberValueNodeFragment(byteDelta) {
|
|
1023
|
-
(0,
|
|
1024
|
+
(0, import_nodes14.assertIsNode)(byteDelta.value, "numberValueNode");
|
|
1024
1025
|
return fragment`${byteDelta.value.number}`;
|
|
1025
1026
|
}
|
|
1026
1027
|
function getArgumentValueNodeFragment(byteDelta) {
|
|
1027
|
-
(0,
|
|
1028
|
-
const argumentName = (0,
|
|
1028
|
+
(0, import_nodes14.assertIsNode)(byteDelta.value, "argumentValueNode");
|
|
1029
|
+
const argumentName = (0, import_nodes14.camelCase)(byteDelta.value.name);
|
|
1029
1030
|
return fragment`Number(args.${argumentName})`;
|
|
1030
1031
|
}
|
|
1031
1032
|
function getAccountLinkNodeFragment(byteDelta, scope) {
|
|
1032
|
-
(0,
|
|
1033
|
+
(0, import_nodes14.assertIsNode)(byteDelta.value, "accountLinkNode");
|
|
1033
1034
|
const functionName = use(
|
|
1034
1035
|
scope.nameApi.accountGetSizeFunction(byteDelta.value.name),
|
|
1035
1036
|
scope.getImportFrom(byteDelta.value)
|
|
@@ -1037,7 +1038,7 @@ function getAccountLinkNodeFragment(byteDelta, scope) {
|
|
|
1037
1038
|
return fragment`${functionName}()`;
|
|
1038
1039
|
}
|
|
1039
1040
|
function getResolverValueNodeFragment(byteDelta, scope) {
|
|
1040
|
-
(0,
|
|
1041
|
+
(0, import_nodes14.assertIsNode)(byteDelta.value, "resolverValueNode");
|
|
1041
1042
|
const isAsync = scope.asyncResolvers.includes(byteDelta.value.name);
|
|
1042
1043
|
if (!scope.useAsync && isAsync) return null;
|
|
1043
1044
|
const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
|
|
@@ -1052,7 +1053,7 @@ function getResolverValueNodeFragment(byteDelta, scope) {
|
|
|
1052
1053
|
}
|
|
1053
1054
|
|
|
1054
1055
|
// src/fragments/instructionData.ts
|
|
1055
|
-
var
|
|
1056
|
+
var import_nodes15 = require("@codama/nodes");
|
|
1056
1057
|
var import_visitors_core11 = require("@codama/visitors-core");
|
|
1057
1058
|
function getInstructionDataFragment(scope) {
|
|
1058
1059
|
const { instructionPath, dataArgsManifest, nameApi, customInstructionData } = scope;
|
|
@@ -1063,7 +1064,7 @@ function getInstructionDataFragment(scope) {
|
|
|
1063
1064
|
manifest: dataArgsManifest,
|
|
1064
1065
|
name: instructionDataName,
|
|
1065
1066
|
nameApi,
|
|
1066
|
-
node: (0,
|
|
1067
|
+
node: (0, import_nodes15.structTypeNodeFromInstructionArgumentNodes)(instructionNode.arguments),
|
|
1067
1068
|
size: scope.size
|
|
1068
1069
|
});
|
|
1069
1070
|
}
|
|
@@ -1081,17 +1082,17 @@ function getInstructionExtraArgsFragment(scope) {
|
|
|
1081
1082
|
}
|
|
1082
1083
|
|
|
1083
1084
|
// src/fragments/instructionFunction.ts
|
|
1084
|
-
var
|
|
1085
|
+
var import_nodes20 = require("@codama/nodes");
|
|
1085
1086
|
var import_renderers_core8 = require("@codama/renderers-core");
|
|
1086
1087
|
var import_visitors_core17 = require("@codama/visitors-core");
|
|
1087
1088
|
|
|
1088
1089
|
// src/fragments/instructionInputResolved.ts
|
|
1089
|
-
var
|
|
1090
|
+
var import_nodes17 = require("@codama/nodes");
|
|
1090
1091
|
var import_renderers_core6 = require("@codama/renderers-core");
|
|
1091
1092
|
var import_visitors_core14 = require("@codama/visitors-core");
|
|
1092
1093
|
|
|
1093
1094
|
// src/fragments/instructionInputDefault.ts
|
|
1094
|
-
var
|
|
1095
|
+
var import_nodes16 = require("@codama/nodes");
|
|
1095
1096
|
var import_renderers_core5 = require("@codama/renderers-core");
|
|
1096
1097
|
var import_visitors_core13 = require("@codama/visitors-core");
|
|
1097
1098
|
function getInstructionInputDefaultFragment(scope) {
|
|
@@ -1104,8 +1105,8 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1104
1105
|
}
|
|
1105
1106
|
const { defaultValue } = input;
|
|
1106
1107
|
const defaultFragment = (renderedValue, isWritable) => {
|
|
1107
|
-
const inputName = (0,
|
|
1108
|
-
if (input.kind === "instructionAccountNode" && (0,
|
|
1108
|
+
const inputName = (0, import_nodes16.camelCase)(input.name);
|
|
1109
|
+
if (input.kind === "instructionAccountNode" && (0, import_nodes16.isNode)(defaultValue, "resolverValueNode")) {
|
|
1109
1110
|
return fragment`accounts.${inputName} = { ...accounts.${inputName}, ...${renderedValue} };`;
|
|
1110
1111
|
}
|
|
1111
1112
|
if (input.kind === "instructionAccountNode" && isWritable === void 0) {
|
|
@@ -1118,7 +1119,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1118
1119
|
};
|
|
1119
1120
|
switch (defaultValue.kind) {
|
|
1120
1121
|
case "accountValueNode":
|
|
1121
|
-
const name = (0,
|
|
1122
|
+
const name = (0, import_nodes16.camelCase)(defaultValue.name);
|
|
1122
1123
|
if (input.kind === "instructionAccountNode" && input.resolvedIsSigner && !input.isSigner) {
|
|
1123
1124
|
return (0, import_visitors_core13.pipe)(
|
|
1124
1125
|
defaultFragment(`expectTransactionSigner(accounts.${name}.value).address`),
|
|
@@ -1136,13 +1137,13 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1136
1137
|
(f) => addFragmentImports(f, "shared", ["expectAddress"])
|
|
1137
1138
|
);
|
|
1138
1139
|
case "pdaValueNode":
|
|
1139
|
-
if ((0,
|
|
1140
|
+
if ((0, import_nodes16.isNode)(defaultValue.pda, "pdaNode")) {
|
|
1140
1141
|
const pdaProgram = defaultValue.pda.programId ? (0, import_visitors_core13.pipe)(
|
|
1141
1142
|
fragment`'${defaultValue.pda.programId}' as Address<'${defaultValue.pda.programId}'>`,
|
|
1142
1143
|
(f) => addFragmentImports(f, "solanaAddresses", ["type Address"])
|
|
1143
1144
|
) : fragment`programAddress`;
|
|
1144
1145
|
const pdaSeeds2 = defaultValue.pda.seeds.flatMap((seed) => {
|
|
1145
|
-
if ((0,
|
|
1146
|
+
if ((0, import_nodes16.isNode)(seed, "constantPdaSeedNode") && (0, import_nodes16.isNode)(seed.value, "programIdValueNode")) {
|
|
1146
1147
|
return [
|
|
1147
1148
|
(0, import_visitors_core13.pipe)(
|
|
1148
1149
|
fragment`getAddressEncoder().encode(${pdaProgram})`,
|
|
@@ -1150,27 +1151,27 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1150
1151
|
)
|
|
1151
1152
|
];
|
|
1152
1153
|
}
|
|
1153
|
-
if ((0,
|
|
1154
|
+
if ((0, import_nodes16.isNode)(seed, "constantPdaSeedNode") && !(0, import_nodes16.isNode)(seed.value, "programIdValueNode")) {
|
|
1154
1155
|
const typeManifest2 = (0, import_visitors_core13.visit)(seed.type, typeManifestVisitor);
|
|
1155
1156
|
const valueManifest2 = (0, import_visitors_core13.visit)(seed.value, typeManifestVisitor);
|
|
1156
1157
|
return [fragment`${typeManifest2.encoder}.encode(${valueManifest2.value})`];
|
|
1157
1158
|
}
|
|
1158
|
-
if ((0,
|
|
1159
|
+
if ((0, import_nodes16.isNode)(seed, "variablePdaSeedNode")) {
|
|
1159
1160
|
const typeManifest2 = (0, import_visitors_core13.visit)(seed.type, typeManifestVisitor);
|
|
1160
1161
|
const valueSeed = defaultValue.seeds.find((s) => s.name === seed.name)?.value;
|
|
1161
1162
|
if (!valueSeed) return [];
|
|
1162
|
-
if ((0,
|
|
1163
|
+
if ((0, import_nodes16.isNode)(valueSeed, "accountValueNode")) {
|
|
1163
1164
|
return [
|
|
1164
1165
|
(0, import_visitors_core13.pipe)(
|
|
1165
|
-
fragment`${typeManifest2.encoder}.encode(expectAddress(accounts.${(0,
|
|
1166
|
+
fragment`${typeManifest2.encoder}.encode(expectAddress(accounts.${(0, import_nodes16.camelCase)(valueSeed.name)}.value))`,
|
|
1166
1167
|
(f) => addFragmentImports(f, "shared", ["expectAddress"])
|
|
1167
1168
|
)
|
|
1168
1169
|
];
|
|
1169
1170
|
}
|
|
1170
|
-
if ((0,
|
|
1171
|
+
if ((0, import_nodes16.isNode)(valueSeed, "argumentValueNode")) {
|
|
1171
1172
|
return [
|
|
1172
1173
|
(0, import_visitors_core13.pipe)(
|
|
1173
|
-
fragment`${typeManifest2.encoder}.encode(expectSome(args.${(0,
|
|
1174
|
+
fragment`${typeManifest2.encoder}.encode(expectSome(args.${(0, import_nodes16.camelCase)(valueSeed.name)}))`,
|
|
1174
1175
|
(f) => addFragmentImports(f, "shared", ["expectSome"])
|
|
1175
1176
|
)
|
|
1176
1177
|
];
|
|
@@ -1192,15 +1193,15 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1192
1193
|
const pdaFunction = nameApi.pdaFindFunction(defaultValue.pda.name);
|
|
1193
1194
|
const pdaArgs = [];
|
|
1194
1195
|
const pdaSeeds = defaultValue.seeds.map((seed) => {
|
|
1195
|
-
if ((0,
|
|
1196
|
+
if ((0, import_nodes16.isNode)(seed.value, "accountValueNode")) {
|
|
1196
1197
|
return (0, import_visitors_core13.pipe)(
|
|
1197
|
-
fragment`${seed.name}: expectAddress(accounts.${(0,
|
|
1198
|
+
fragment`${seed.name}: expectAddress(accounts.${(0, import_nodes16.camelCase)(seed.value.name)}.value)`,
|
|
1198
1199
|
(f) => addFragmentImports(f, "shared", ["expectAddress"])
|
|
1199
1200
|
);
|
|
1200
1201
|
}
|
|
1201
|
-
if ((0,
|
|
1202
|
+
if ((0, import_nodes16.isNode)(seed.value, "argumentValueNode")) {
|
|
1202
1203
|
return (0, import_visitors_core13.pipe)(
|
|
1203
|
-
fragment`${seed.name}: expectSome(args.${(0,
|
|
1204
|
+
fragment`${seed.name}: expectSome(args.${(0, import_nodes16.camelCase)(seed.value.name)})`,
|
|
1204
1205
|
(f) => addFragmentImports(f, "shared", ["expectSome"])
|
|
1205
1206
|
);
|
|
1206
1207
|
}
|
|
@@ -1243,12 +1244,12 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1243
1244
|
return fragment``;
|
|
1244
1245
|
case "accountBumpValueNode":
|
|
1245
1246
|
return (0, import_visitors_core13.pipe)(
|
|
1246
|
-
defaultFragment(`expectProgramDerivedAddress(accounts.${(0,
|
|
1247
|
+
defaultFragment(`expectProgramDerivedAddress(accounts.${(0, import_nodes16.camelCase)(defaultValue.name)}.value)[1]`),
|
|
1247
1248
|
(f) => addFragmentImports(f, "shared", ["expectProgramDerivedAddress"])
|
|
1248
1249
|
);
|
|
1249
1250
|
case "argumentValueNode":
|
|
1250
1251
|
return (0, import_visitors_core13.pipe)(
|
|
1251
|
-
defaultFragment(`expectSome(args.${(0,
|
|
1252
|
+
defaultFragment(`expectSome(args.${(0, import_nodes16.camelCase)(defaultValue.name)})`),
|
|
1252
1253
|
(f) => addFragmentImports(f, "shared", ["expectSome"])
|
|
1253
1254
|
);
|
|
1254
1255
|
case "resolverValueNode":
|
|
@@ -1280,7 +1281,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1280
1281
|
}
|
|
1281
1282
|
const negatedCondition = !ifTrueRenderer;
|
|
1282
1283
|
let condition = "true";
|
|
1283
|
-
if ((0,
|
|
1284
|
+
if ((0, import_nodes16.isNode)(defaultValue.condition, "resolverValueNode")) {
|
|
1284
1285
|
const conditionalResolverFunction = nameApi.resolverFunction(defaultValue.condition.name);
|
|
1285
1286
|
const module3 = getImportFrom(defaultValue.condition);
|
|
1286
1287
|
conditionalFragment = (0, import_visitors_core13.pipe)(
|
|
@@ -1292,7 +1293,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
1292
1293
|
condition = `${conditionalResolverAwait}${conditionalResolverFunction}(resolverScope)`;
|
|
1293
1294
|
condition = negatedCondition ? `!${condition}` : condition;
|
|
1294
1295
|
} else {
|
|
1295
|
-
const comparedInputName = (0,
|
|
1296
|
+
const comparedInputName = (0, import_nodes16.isNode)(defaultValue.condition, "accountValueNode") ? `accounts.${(0, import_nodes16.camelCase)(defaultValue.condition.name)}.value` : `args.${(0, import_nodes16.camelCase)(defaultValue.condition.name)}`;
|
|
1296
1297
|
if (defaultValue.value) {
|
|
1297
1298
|
const comparedValue = (0, import_visitors_core13.visit)(defaultValue.value, typeManifestVisitor).value;
|
|
1298
1299
|
conditionalFragment = mergeFragments([conditionalFragment, comparedValue], (c) => c[0]);
|
|
@@ -1339,14 +1340,14 @@ function getInstructionInputResolvedFragment(scope) {
|
|
|
1339
1340
|
const inputFragment = getInstructionInputDefaultFragment({
|
|
1340
1341
|
...scope,
|
|
1341
1342
|
input,
|
|
1342
|
-
optionalAccountStrategy: (0,
|
|
1343
|
+
optionalAccountStrategy: (0, import_nodes17.parseOptionalAccountStrategy)(instructionNode.optionalAccountStrategy)
|
|
1343
1344
|
});
|
|
1344
1345
|
if (!inputFragment.content) return [];
|
|
1345
|
-
const camelName = (0,
|
|
1346
|
+
const camelName = (0, import_nodes17.camelCase)(input.name);
|
|
1346
1347
|
return [
|
|
1347
1348
|
(0, import_renderers_core6.mapFragmentContent)(
|
|
1348
1349
|
inputFragment,
|
|
1349
|
-
(c) => (0,
|
|
1350
|
+
(c) => (0, import_nodes17.isNode)(input, "instructionArgumentNode") ? `if (!args.${camelName}) {
|
|
1350
1351
|
${c}
|
|
1351
1352
|
}` : `if (!accounts.${camelName}.value) {
|
|
1352
1353
|
${c}
|
|
@@ -1361,7 +1362,7 @@ ${c}
|
|
|
1361
1362
|
}
|
|
1362
1363
|
|
|
1363
1364
|
// src/fragments/instructionInputType.ts
|
|
1364
|
-
var
|
|
1365
|
+
var import_nodes18 = require("@codama/nodes");
|
|
1365
1366
|
var import_renderers_core7 = require("@codama/renderers-core");
|
|
1366
1367
|
var import_visitors_core15 = require("@codama/visitors-core");
|
|
1367
1368
|
function getInstructionInputTypeFragment(scope) {
|
|
@@ -1371,7 +1372,7 @@ function getInstructionInputTypeFragment(scope) {
|
|
|
1371
1372
|
const [dataArgumentsFragment, customDataArgumentsFragment] = getDataArgumentsFragments(scope);
|
|
1372
1373
|
let accountTypeParams = "";
|
|
1373
1374
|
if (instructionNode.accounts.length > 0) {
|
|
1374
|
-
accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0,
|
|
1375
|
+
accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes18.pascalCase)(account.name)} extends string = string`).join(", ");
|
|
1375
1376
|
accountTypeParams = `<${accountTypeParams}>`;
|
|
1376
1377
|
}
|
|
1377
1378
|
const typeBodyFragment = mergeFragments(
|
|
@@ -1394,15 +1395,15 @@ function getAccountsFragment(scope) {
|
|
|
1394
1395
|
const resolvedAccount = resolvedInputs.find(
|
|
1395
1396
|
(input) => input.kind === "instructionAccountNode" && input.name === account.name
|
|
1396
1397
|
);
|
|
1397
|
-
const hasDefaultValue = !!resolvedAccount.defaultValue && !(0,
|
|
1398
|
+
const hasDefaultValue = !!resolvedAccount.defaultValue && !(0, import_nodes18.isNode)(resolvedAccount.defaultValue, ["identityValueNode", "payerValueNode"]) && (useAsync || !isAsyncDefaultValue(resolvedAccount.defaultValue, asyncResolvers));
|
|
1398
1399
|
const docs = getDocblockFragment(account.docs ?? [], true);
|
|
1399
1400
|
const optionalSign = hasDefaultValue || resolvedAccount.isOptional ? "?" : "";
|
|
1400
|
-
return fragment`${docs}${(0,
|
|
1401
|
+
return fragment`${docs}${(0, import_nodes18.camelCase)(account.name)}${optionalSign}: ${getAccountTypeFragment2(resolvedAccount)};`;
|
|
1401
1402
|
});
|
|
1402
1403
|
return mergeFragments(fragments, (c) => c.join("\n"));
|
|
1403
1404
|
}
|
|
1404
1405
|
function getAccountTypeFragment2(account) {
|
|
1405
|
-
const typeParam = `TAccount${(0,
|
|
1406
|
+
const typeParam = `TAccount${(0, import_nodes18.pascalCase)(account.name)}`;
|
|
1406
1407
|
const address = use("type Address", "solanaAddresses");
|
|
1407
1408
|
const signer = use("type TransactionSigner", "solanaSigners");
|
|
1408
1409
|
const pda = use("type ProgramDerivedAddress", "solanaAddresses");
|
|
@@ -1448,18 +1449,18 @@ function getExtraArgumentsFragment(scope) {
|
|
|
1448
1449
|
}
|
|
1449
1450
|
function getArgumentFragment(arg, argsType, resolvedInputs, renamedArgs) {
|
|
1450
1451
|
const resolvedArg = resolvedInputs.find(
|
|
1451
|
-
(input) => (0,
|
|
1452
|
+
(input) => (0, import_nodes18.isNode)(input, "instructionArgumentNode") && input.name === arg.name
|
|
1452
1453
|
);
|
|
1453
1454
|
if (arg.defaultValue && arg.defaultValueStrategy === "omitted") return null;
|
|
1454
1455
|
const renamedName = renamedArgs.get(arg.name) ?? arg.name;
|
|
1455
1456
|
const optionalSign = arg.defaultValue || resolvedArg?.defaultValue ? "?" : "";
|
|
1456
|
-
return fragment`${(0,
|
|
1457
|
+
return fragment`${(0, import_nodes18.camelCase)(renamedName)}${optionalSign}: ${argsType}["${(0, import_nodes18.camelCase)(arg.name)}"];`;
|
|
1457
1458
|
}
|
|
1458
1459
|
function getRemainingAccountsFragment(instructionNode) {
|
|
1459
1460
|
const fragments = (instructionNode.remainingAccounts ?? []).flatMap((remainingAccountsNode) => {
|
|
1460
|
-
if ((0,
|
|
1461
|
+
if ((0, import_nodes18.isNode)(remainingAccountsNode.value, "resolverValueNode")) return [];
|
|
1461
1462
|
const { name } = remainingAccountsNode.value;
|
|
1462
|
-
const allArguments = (0,
|
|
1463
|
+
const allArguments = (0, import_nodes18.getAllInstructionArguments)(instructionNode);
|
|
1463
1464
|
const argumentExists = allArguments.some((arg) => arg.name === name);
|
|
1464
1465
|
if (argumentExists) return [];
|
|
1465
1466
|
const isSigner = remainingAccountsNode.isSigner ?? false;
|
|
@@ -1470,14 +1471,14 @@ function getRemainingAccountsFragment(instructionNode) {
|
|
|
1470
1471
|
if (isSigner === "either") return fragment`${signerFragment} | ${addressFragment}`;
|
|
1471
1472
|
return isSigner ? signerFragment : addressFragment;
|
|
1472
1473
|
})();
|
|
1473
|
-
return fragment`${(0,
|
|
1474
|
+
return fragment`${(0, import_nodes18.camelCase)(name)}${optionalSign}: Array<${typeFragment}>;`;
|
|
1474
1475
|
});
|
|
1475
1476
|
if (fragments.length === 0) return;
|
|
1476
1477
|
return mergeFragments(fragments, (c) => c.join("\n"));
|
|
1477
1478
|
}
|
|
1478
1479
|
|
|
1479
1480
|
// src/fragments/instructionRemainingAccounts.ts
|
|
1480
|
-
var
|
|
1481
|
+
var import_nodes19 = require("@codama/nodes");
|
|
1481
1482
|
var import_visitors_core16 = require("@codama/visitors-core");
|
|
1482
1483
|
function getInstructionRemainingAccountsFragment(scope) {
|
|
1483
1484
|
const { remainingAccounts } = (0, import_visitors_core16.getLastNodeFromPath)(scope.instructionPath);
|
|
@@ -1494,10 +1495,10 @@ const remainingAccounts: AccountMeta[] = ${c.length === 1 ? c[0] : `[...${c.join
|
|
|
1494
1495
|
}
|
|
1495
1496
|
function getRemainingAccountsFragment2(remainingAccounts, scope) {
|
|
1496
1497
|
const remainingAccountsFragment = (() => {
|
|
1497
|
-
if ((0,
|
|
1498
|
+
if ((0, import_nodes19.isNode)(remainingAccounts.value, "argumentValueNode")) {
|
|
1498
1499
|
return getArgumentValueNodeFragment2(remainingAccounts, scope);
|
|
1499
1500
|
}
|
|
1500
|
-
if ((0,
|
|
1501
|
+
if ((0, import_nodes19.isNode)(remainingAccounts.value, "resolverValueNode")) {
|
|
1501
1502
|
return getResolverValueNodeFragment2(remainingAccounts, scope);
|
|
1502
1503
|
}
|
|
1503
1504
|
return null;
|
|
@@ -1507,8 +1508,8 @@ function getRemainingAccountsFragment2(remainingAccounts, scope) {
|
|
|
1507
1508
|
}
|
|
1508
1509
|
function getArgumentValueNodeFragment2(remainingAccounts, scope) {
|
|
1509
1510
|
const instructionNode = (0, import_visitors_core16.getLastNodeFromPath)(scope.instructionPath);
|
|
1510
|
-
(0,
|
|
1511
|
-
const argumentName = (0,
|
|
1511
|
+
(0, import_nodes19.assertIsNode)(remainingAccounts.value, "argumentValueNode");
|
|
1512
|
+
const argumentName = (0, import_nodes19.camelCase)(remainingAccounts.value.name);
|
|
1512
1513
|
const isOptional = remainingAccounts.isOptional ?? false;
|
|
1513
1514
|
const isSigner = remainingAccounts.isSigner ?? false;
|
|
1514
1515
|
const isWritable = remainingAccounts.isWritable ?? false;
|
|
@@ -1517,7 +1518,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
|
|
|
1517
1518
|
const signerRole = isWritable ? fragment`${accountRole}.WRITABLE_SIGNER` : fragment`${accountRole}.READONLY_SIGNER`;
|
|
1518
1519
|
const role = isSigner === true ? signerRole : nonSignerRole;
|
|
1519
1520
|
const argumentArray = isOptional ? `(args.${argumentName} ?? [])` : `args.${argumentName}`;
|
|
1520
|
-
const allArguments = (0,
|
|
1521
|
+
const allArguments = (0, import_nodes19.getAllInstructionArguments)(instructionNode);
|
|
1521
1522
|
const argumentExists = allArguments.some((arg) => arg.name === remainingAccounts.value.name);
|
|
1522
1523
|
if (argumentExists || isSigner === false) {
|
|
1523
1524
|
return fragment`${argumentArray}.map((address) => ({ address, role: ${role} }))`;
|
|
@@ -1528,7 +1529,7 @@ function getArgumentValueNodeFragment2(remainingAccounts, scope) {
|
|
|
1528
1529
|
return fragment`${argumentArray}.map((signer) => ({ address: signer.address, role: ${signerRole}, signer }))`;
|
|
1529
1530
|
}
|
|
1530
1531
|
function getResolverValueNodeFragment2(remainingAccounts, scope) {
|
|
1531
|
-
(0,
|
|
1532
|
+
(0, import_nodes19.assertIsNode)(remainingAccounts.value, "resolverValueNode");
|
|
1532
1533
|
const isAsync = scope.asyncResolvers.includes(remainingAccounts.value.name);
|
|
1533
1534
|
if (!scope.useAsync && isAsync) return null;
|
|
1534
1535
|
const awaitKeyword = scope.useAsync && isAsync ? "await " : "";
|
|
@@ -1551,7 +1552,7 @@ function getInstructionFunctionFragment(scope) {
|
|
|
1551
1552
|
const customData = customInstructionData.get(instructionNode.name);
|
|
1552
1553
|
const hasAccounts = instructionNode.accounts.length > 0;
|
|
1553
1554
|
const instructionDependencies = getInstructionDependencies(instructionNode, asyncResolvers, useAsync);
|
|
1554
|
-
const argDependencies = instructionDependencies.filter((0,
|
|
1555
|
+
const argDependencies = instructionDependencies.filter((0, import_nodes20.isNodeFilter)("argumentValueNode")).map((node) => node.name);
|
|
1555
1556
|
const hasData = !!customData || instructionNode.arguments.length > 0;
|
|
1556
1557
|
const argIsNotOmitted = (arg) => !(arg.defaultValue && arg.defaultValueStrategy === "omitted");
|
|
1557
1558
|
const argIsDependent = (arg) => argDependencies.includes(arg.name);
|
|
@@ -1564,7 +1565,7 @@ function getInstructionFunctionFragment(scope) {
|
|
|
1564
1565
|
const hasExtraArgs = (instructionNode.extraArguments ?? []).filter(
|
|
1565
1566
|
(field) => argIsNotOmitted(field) && (argIsDependent(field) || argHasDefaultValue(field))
|
|
1566
1567
|
).length > 0;
|
|
1567
|
-
const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => (0,
|
|
1568
|
+
const hasRemainingAccountArgs = (instructionNode.remainingAccounts ?? []).filter(({ value }) => (0, import_nodes20.isNode)(value, "argumentValueNode")).length > 0;
|
|
1568
1569
|
const hasAnyArgs = hasDataArgs || hasExtraArgs || hasRemainingAccountArgs;
|
|
1569
1570
|
const hasInput = hasAccounts || hasAnyArgs;
|
|
1570
1571
|
const programAddressConstant = use(nameApi.programAddressConstant(programNode.name), "generatedPrograms");
|
|
@@ -1615,7 +1616,7 @@ function getAccountsInitializationFragment(instructionNode) {
|
|
|
1615
1616
|
if (instructionNode.accounts.length === 0) return;
|
|
1616
1617
|
const accounts = mergeFragments(
|
|
1617
1618
|
instructionNode.accounts.map((account) => {
|
|
1618
|
-
const name = (0,
|
|
1619
|
+
const name = (0, import_nodes20.camelCase)(account.name);
|
|
1619
1620
|
const isWritable = account.isWritable ? "true" : "false";
|
|
1620
1621
|
return fragment`${name}: { value: input.${name} ?? null, isWritable: ${isWritable} }`;
|
|
1621
1622
|
}),
|
|
@@ -1650,7 +1651,7 @@ function getReturnStatementFragment(scope) {
|
|
|
1650
1651
|
const hasLegacyOptionalAccounts = instructionNode.optionalAccountStrategy === "omitted" && instructionNode.accounts.some((account) => account.isOptional);
|
|
1651
1652
|
const getAccountMeta = hasAccounts ? fragment`const getAccountMeta = ${use("getAccountMetaFactory", "shared")}(programAddress, '${optionalAccountStrategy}');` : "";
|
|
1652
1653
|
const accountItems = [
|
|
1653
|
-
...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${(0,
|
|
1654
|
+
...instructionNode.accounts.map((account) => `getAccountMeta(accounts.${(0, import_nodes20.camelCase)(account.name)})`),
|
|
1654
1655
|
...hasRemainingAccounts ? ["...remainingAccounts"] : []
|
|
1655
1656
|
].join(", ");
|
|
1656
1657
|
let accounts;
|
|
@@ -1687,7 +1688,7 @@ function getReturnTypeFragment(instructionTypeFragment, hasByteDeltas, useAsync)
|
|
|
1687
1688
|
function getTypeParamsFragment(instructionNode, programAddressConstant) {
|
|
1688
1689
|
return mergeFragments(
|
|
1689
1690
|
[
|
|
1690
|
-
...instructionNode.accounts.map((account) => fragment`TAccount${(0,
|
|
1691
|
+
...instructionNode.accounts.map((account) => fragment`TAccount${(0, import_nodes20.pascalCase)(account.name)} extends string`),
|
|
1691
1692
|
fragment`TProgramAddress extends ${use("type Address", "solanaAddresses")} = typeof ${programAddressConstant}`
|
|
1692
1693
|
],
|
|
1693
1694
|
(cs) => `<${cs.join(", ")}>`
|
|
@@ -1698,8 +1699,8 @@ function getInstructionTypeFragment(scope) {
|
|
|
1698
1699
|
const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
|
|
1699
1700
|
const instructionTypeName = nameApi.instructionType(instructionNode.name);
|
|
1700
1701
|
const accountTypeParamsFragments = instructionNode.accounts.map((account) => {
|
|
1701
|
-
const typeParam = fragment`TAccount${(0,
|
|
1702
|
-
const camelName = (0,
|
|
1702
|
+
const typeParam = fragment`TAccount${(0, import_nodes20.pascalCase)(account.name)}`;
|
|
1703
|
+
const camelName = (0, import_nodes20.camelCase)(account.name);
|
|
1703
1704
|
if (account.isSigner === "either") {
|
|
1704
1705
|
const signerRole = use(
|
|
1705
1706
|
account.isWritable ? "type WritableSignerAccount" : "type ReadonlySignerAccount",
|
|
@@ -1722,17 +1723,17 @@ function getInputTypeCallFragment(scope) {
|
|
|
1722
1723
|
const instructionNode = (0, import_visitors_core17.getLastNodeFromPath)(instructionPath);
|
|
1723
1724
|
const inputTypeName = useAsync ? nameApi.instructionAsyncInputType(instructionNode.name) : nameApi.instructionSyncInputType(instructionNode.name);
|
|
1724
1725
|
if (instructionNode.accounts.length === 0) return fragment`${inputTypeName}`;
|
|
1725
|
-
const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0,
|
|
1726
|
+
const accountTypeParams = instructionNode.accounts.map((account) => `TAccount${(0, import_nodes20.pascalCase)(account.name)}`).join(", ");
|
|
1726
1727
|
return fragment`${inputTypeName}<${accountTypeParams}>`;
|
|
1727
1728
|
}
|
|
1728
1729
|
|
|
1729
1730
|
// src/fragments/instructionPage.ts
|
|
1730
1731
|
var import_errors2 = require("@codama/errors");
|
|
1731
|
-
var
|
|
1732
|
+
var import_nodes23 = require("@codama/nodes");
|
|
1732
1733
|
var import_visitors_core20 = require("@codama/visitors-core");
|
|
1733
1734
|
|
|
1734
1735
|
// src/fragments/instructionParseFunction.ts
|
|
1735
|
-
var
|
|
1736
|
+
var import_nodes21 = require("@codama/nodes");
|
|
1736
1737
|
var import_visitors_core18 = require("@codama/visitors-core");
|
|
1737
1738
|
function getInstructionParseFunctionFragment(scope) {
|
|
1738
1739
|
const instructionNode = (0, import_visitors_core18.getLastNodeFromPath)(scope.instructionPath);
|
|
@@ -1757,7 +1758,7 @@ function getTypeFragment2(scope) {
|
|
|
1757
1758
|
const accounts = mergeFragments(
|
|
1758
1759
|
scope.instructionNode.accounts.map((account, i) => {
|
|
1759
1760
|
const docs = getDocblockFragment(account.docs ?? [], true);
|
|
1760
|
-
const name = (0,
|
|
1761
|
+
const name = (0, import_nodes21.camelCase)(account.name);
|
|
1761
1762
|
return fragment`${docs}${name}${account.isOptional ? "?" : ""}: TAccountMetas[${i}]${account.isOptional ? " | undefined" : ""};`;
|
|
1762
1763
|
}),
|
|
1763
1764
|
(cs) => hasAccounts ? `
|
|
@@ -1829,7 +1830,7 @@ const getNextOptionalAccount = () => {
|
|
|
1829
1830
|
}
|
|
1830
1831
|
const accounts = mergeFragments(
|
|
1831
1832
|
scope.instructionNode.accounts.map(
|
|
1832
|
-
(account) => account.isOptional ? fragment`${(0,
|
|
1833
|
+
(account) => account.isOptional ? fragment`${(0, import_nodes21.camelCase)(account.name)}: getNextOptionalAccount()` : fragment`${(0, import_nodes21.camelCase)(account.name)}: getNextAccount()`
|
|
1833
1834
|
),
|
|
1834
1835
|
(cs) => hasAccounts ? `, accounts: { ${cs.join(", ")} }` : ""
|
|
1835
1836
|
);
|
|
@@ -1841,7 +1842,7 @@ const getNextOptionalAccount = () => {
|
|
|
1841
1842
|
}
|
|
1842
1843
|
|
|
1843
1844
|
// src/fragments/instructionType.ts
|
|
1844
|
-
var
|
|
1845
|
+
var import_nodes22 = require("@codama/nodes");
|
|
1845
1846
|
var import_renderers_core9 = require("@codama/renderers-core");
|
|
1846
1847
|
var import_visitors_core19 = require("@codama/visitors-core");
|
|
1847
1848
|
function getInstructionTypeFragment2(scope) {
|
|
@@ -1868,7 +1869,7 @@ function getInstructionTypeFragment2(scope) {
|
|
|
1868
1869
|
const accountMetasFragment = mergeFragments(
|
|
1869
1870
|
instructionNode.accounts.map(
|
|
1870
1871
|
(account) => (0, import_renderers_core9.mapFragmentContent)(getInstructionAccountMetaFragment(account), (c) => {
|
|
1871
|
-
const typeParam = `TAccount${(0,
|
|
1872
|
+
const typeParam = `TAccount${(0, import_nodes22.pascalCase)(account.name)}`;
|
|
1872
1873
|
const isLegacyOptional = account.isOptional && usesLegacyOptionalAccounts;
|
|
1873
1874
|
const type = `${typeParam} extends string ? ${c} : ${typeParam}`;
|
|
1874
1875
|
if (!isLegacyOptional) return type;
|
|
@@ -1893,9 +1894,9 @@ function getInstructionPageFragment(scope) {
|
|
|
1893
1894
|
...scope,
|
|
1894
1895
|
dataArgsManifest: (0, import_visitors_core20.visit)(node, scope.typeManifestVisitor),
|
|
1895
1896
|
extraArgsManifest: (0, import_visitors_core20.visit)(
|
|
1896
|
-
(0,
|
|
1897
|
+
(0, import_nodes23.definedTypeNode)({
|
|
1897
1898
|
name: scope.nameApi.instructionExtraType(node.name),
|
|
1898
|
-
type: (0,
|
|
1899
|
+
type: (0, import_nodes23.structTypeNodeFromInstructionArgumentNodes)(node.extraArguments ?? [])
|
|
1899
1900
|
}),
|
|
1900
1901
|
scope.typeManifestVisitor
|
|
1901
1902
|
),
|
|
@@ -1934,11 +1935,11 @@ function getRenamedArgsMap(instruction) {
|
|
|
1934
1935
|
(0, import_errors2.logWarn)(
|
|
1935
1936
|
`[JavaScript] Accounts and args of instruction [${instruction.name}] have the following conflicting attributes [${duplicates.join(", ")}]. Thus, the arguments have been renamed to avoid conflicts in the input type.`
|
|
1936
1937
|
);
|
|
1937
|
-
return new Map(duplicates.map((name) => [(0,
|
|
1938
|
+
return new Map(duplicates.map((name) => [(0, import_nodes23.camelCase)(name), (0, import_nodes23.camelCase)(`${name}Arg`)]));
|
|
1938
1939
|
}
|
|
1939
1940
|
|
|
1940
1941
|
// src/fragments/pdaFunction.ts
|
|
1941
|
-
var
|
|
1942
|
+
var import_nodes24 = require("@codama/nodes");
|
|
1942
1943
|
var import_visitors_core21 = require("@codama/visitors-core");
|
|
1943
1944
|
function getPdaFunctionFragment(scope) {
|
|
1944
1945
|
const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
|
|
@@ -1949,7 +1950,7 @@ function getPdaFunctionFragment(scope) {
|
|
|
1949
1950
|
);
|
|
1950
1951
|
}
|
|
1951
1952
|
function getSeedInputTypeFragment(seeds, scope) {
|
|
1952
|
-
const variableSeeds = seeds.filter((0,
|
|
1953
|
+
const variableSeeds = seeds.filter((0, import_nodes24.isNodeFilter)("variablePdaSeedNode"));
|
|
1953
1954
|
if (variableSeeds.length === 0) return;
|
|
1954
1955
|
const pdaNode = (0, import_visitors_core21.getLastNodeFromPath)(scope.pdaPath);
|
|
1955
1956
|
const seedTypeName = scope.nameApi.pdaSeedsType(pdaNode.name);
|
|
@@ -1968,7 +1969,7 @@ function getFunctionFragment2(seeds, scope) {
|
|
|
1968
1969
|
const seedTypeName = scope.nameApi.pdaSeedsType(pdaNode.name);
|
|
1969
1970
|
const findPdaFunction = scope.nameApi.pdaFindFunction(pdaNode.name);
|
|
1970
1971
|
const docs = getDocblockFragment(pdaNode.docs ?? [], true);
|
|
1971
|
-
const hasVariableSeeds = seeds.filter((0,
|
|
1972
|
+
const hasVariableSeeds = seeds.filter((0, import_nodes24.isNodeFilter)("variablePdaSeedNode")).length > 0;
|
|
1972
1973
|
const seedArgument = hasVariableSeeds ? `seeds: ${seedTypeName}, ` : "";
|
|
1973
1974
|
const programAddress = pdaNode.programId ?? programNode.publicKey;
|
|
1974
1975
|
const encodedSeeds = mergeFragments(
|
|
@@ -1982,8 +1983,8 @@ function getFunctionFragment2(seeds, scope) {
|
|
|
1982
1983
|
}
|
|
1983
1984
|
function parsePdaSeedNodes(seeds, scope) {
|
|
1984
1985
|
return seeds.map((seed) => {
|
|
1985
|
-
if ((0,
|
|
1986
|
-
const name = (0,
|
|
1986
|
+
if ((0, import_nodes24.isNode)(seed, "variablePdaSeedNode")) {
|
|
1987
|
+
const name = (0, import_nodes24.camelCase)(seed.name);
|
|
1987
1988
|
const docs = getDocblockFragment(seed.docs ?? [], true);
|
|
1988
1989
|
const { encoder: encoder2, looseType } = (0, import_visitors_core21.visit)(seed.type, scope.typeManifestVisitor);
|
|
1989
1990
|
return {
|
|
@@ -1992,7 +1993,7 @@ function parsePdaSeedNodes(seeds, scope) {
|
|
|
1992
1993
|
inputAttribute: fragment`${docs}${name}: ${looseType};`
|
|
1993
1994
|
};
|
|
1994
1995
|
}
|
|
1995
|
-
if ((0,
|
|
1996
|
+
if ((0, import_nodes24.isNode)(seed.value, "programIdValueNode")) {
|
|
1996
1997
|
const addressEncoder = use("getAddressEncoder", "solanaAddresses");
|
|
1997
1998
|
return { ...seed, encodedValue: fragment`${addressEncoder}().encode(programAddress)` };
|
|
1998
1999
|
}
|
|
@@ -2012,7 +2013,7 @@ function getPdaPageFragment(scope) {
|
|
|
2012
2013
|
}
|
|
2013
2014
|
|
|
2014
2015
|
// src/fragments/programAccounts.ts
|
|
2015
|
-
var
|
|
2016
|
+
var import_nodes25 = require("@codama/nodes");
|
|
2016
2017
|
var import_renderers_core10 = require("@codama/renderers-core");
|
|
2017
2018
|
var import_visitors_core23 = require("@codama/visitors-core");
|
|
2018
2019
|
function getProgramAccountsFragment(scope) {
|
|
@@ -2048,7 +2049,7 @@ function getProgramAccountsIdentifierFunctionFragment(scope) {
|
|
|
2048
2049
|
dataName: "data",
|
|
2049
2050
|
discriminators: account.discriminators ?? [],
|
|
2050
2051
|
ifTrue: `return ${programAccountsEnum}.${variant};`,
|
|
2051
|
-
struct: (0,
|
|
2052
|
+
struct: (0, import_nodes25.resolveNestedTypeNode)(account.data)
|
|
2052
2053
|
});
|
|
2053
2054
|
}),
|
|
2054
2055
|
(c) => c.join("\n")
|
|
@@ -2077,12 +2078,12 @@ function getProgramConstantFragment(scope) {
|
|
|
2077
2078
|
}
|
|
2078
2079
|
|
|
2079
2080
|
// src/fragments/programInstructions.ts
|
|
2080
|
-
var
|
|
2081
|
+
var import_nodes26 = require("@codama/nodes");
|
|
2081
2082
|
var import_renderers_core11 = require("@codama/renderers-core");
|
|
2082
2083
|
var import_visitors_core25 = require("@codama/visitors-core");
|
|
2083
2084
|
function getProgramInstructionsFragment(scope) {
|
|
2084
2085
|
if (scope.programNode.instructions.length === 0) return;
|
|
2085
|
-
const allInstructions = (0,
|
|
2086
|
+
const allInstructions = (0, import_nodes26.getAllInstructionsWithSubs)(scope.programNode, {
|
|
2086
2087
|
leavesOnly: !scope.renderParentInstructions,
|
|
2087
2088
|
subInstructionsFirst: true
|
|
2088
2089
|
});
|
|
@@ -2121,7 +2122,7 @@ function getProgramInstructionsIdentifierFunctionFragment(scope) {
|
|
|
2121
2122
|
dataName: "data",
|
|
2122
2123
|
discriminators: instruction.discriminators ?? [],
|
|
2123
2124
|
ifTrue: `return ${programInstructionsEnum}.${variant};`,
|
|
2124
|
-
struct: (0,
|
|
2125
|
+
struct: (0, import_nodes26.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments)
|
|
2125
2126
|
});
|
|
2126
2127
|
}),
|
|
2127
2128
|
(c) => c.join("\n")
|
|
@@ -2308,10 +2309,10 @@ export function isTransactionSigner<TAddress extends string = string>(value: Add
|
|
|
2308
2309
|
}
|
|
2309
2310
|
|
|
2310
2311
|
// src/fragments/typeDiscriminatedUnionHelpers.ts
|
|
2311
|
-
var
|
|
2312
|
+
var import_nodes27 = require("@codama/nodes");
|
|
2312
2313
|
function getTypeDiscriminatedUnionHelpersFragment(scope) {
|
|
2313
2314
|
const { name, typeNode, nameApi } = scope;
|
|
2314
|
-
const isDiscriminatedUnion = (0,
|
|
2315
|
+
const isDiscriminatedUnion = (0, import_nodes27.isNode)(typeNode, "enumTypeNode") && (0, import_nodes27.isDataEnum)(typeNode);
|
|
2315
2316
|
if (!isDiscriminatedUnion) return;
|
|
2316
2317
|
const functionName = nameApi.discriminatedUnionFunction(name);
|
|
2317
2318
|
const isDiscriminatedUnionFunctionName = nameApi.isDiscriminatedUnionFunction(name);
|
|
@@ -2323,10 +2324,10 @@ function getTypeDiscriminatedUnionHelpersFragment(scope) {
|
|
|
2323
2324
|
const variantSignatures = mergeFragments(
|
|
2324
2325
|
typeNode.variants.map((variant) => {
|
|
2325
2326
|
const variantName = nameApi.discriminatedUnionVariant(variant.name);
|
|
2326
|
-
if ((0,
|
|
2327
|
+
if ((0, import_nodes27.isNode)(variant, "enumStructVariantTypeNode")) {
|
|
2327
2328
|
return fragment`export function ${functionName}(kind: '${variantName}', data: ${getVariantContentType}<${looseName}, '${discriminatorName}', '${variantName}'>): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
|
|
2328
2329
|
}
|
|
2329
|
-
if ((0,
|
|
2330
|
+
if ((0, import_nodes27.isNode)(variant, "enumTupleVariantTypeNode")) {
|
|
2330
2331
|
return fragment`export function ${functionName}(kind: '${variantName}', data: ${getVariantContentType}<${looseName}, '${discriminatorName}', '${variantName}'>['fields']): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
|
|
2331
2332
|
}
|
|
2332
2333
|
return fragment`export function ${functionName}(kind: '${variantName}'): ${getVariantType}<${looseName}, '${discriminatorName}', '${variantName}'>;`;
|
|
@@ -2369,7 +2370,7 @@ function getTypePageFragment(scope) {
|
|
|
2369
2370
|
}
|
|
2370
2371
|
|
|
2371
2372
|
// src/visitors/getTypeManifestVisitor.ts
|
|
2372
|
-
var
|
|
2373
|
+
var import_nodes28 = require("@codama/nodes");
|
|
2373
2374
|
var import_renderers_core12 = require("@codama/renderers-core");
|
|
2374
2375
|
var import_visitors_core28 = require("@codama/visitors-core");
|
|
2375
2376
|
function getTypeManifestVisitor(input) {
|
|
@@ -2379,8 +2380,8 @@ function getTypeManifestVisitor(input) {
|
|
|
2379
2380
|
return (0, import_visitors_core28.pipe)(
|
|
2380
2381
|
(0, import_visitors_core28.staticVisitor)(() => typeManifest(), {
|
|
2381
2382
|
keys: [
|
|
2382
|
-
...
|
|
2383
|
-
...
|
|
2383
|
+
...import_nodes28.REGISTERED_TYPE_NODE_KINDS,
|
|
2384
|
+
...import_nodes28.REGISTERED_VALUE_NODE_KINDS,
|
|
2384
2385
|
"definedTypeLinkNode",
|
|
2385
2386
|
"definedTypeNode",
|
|
2386
2387
|
"accountNode",
|
|
@@ -2423,7 +2424,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2423
2424
|
visitBooleanType(booleanType, { self }) {
|
|
2424
2425
|
let sizeEncoder = fragment``;
|
|
2425
2426
|
let sizeDecoder = fragment``;
|
|
2426
|
-
const resolvedSize = (0,
|
|
2427
|
+
const resolvedSize = (0, import_nodes28.resolveNestedTypeNode)(booleanType.size);
|
|
2427
2428
|
if (resolvedSize.format !== "u8" || resolvedSize.endian !== "le") {
|
|
2428
2429
|
const size = (0, import_visitors_core28.visit)(booleanType.size, self);
|
|
2429
2430
|
sizeEncoder = fragment`{ size: ${size.encoder} }`;
|
|
@@ -2453,7 +2454,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2453
2454
|
return typeManifest({ value: fragment`new Uint8Array([${Array.from(bytes).join(", ")}])` });
|
|
2454
2455
|
},
|
|
2455
2456
|
visitConstantValue(node, { self }) {
|
|
2456
|
-
if ((0,
|
|
2457
|
+
if ((0, import_nodes28.isNode)(node.type, "bytesTypeNode") && (0, import_nodes28.isNode)(node.value, "bytesValueNode")) {
|
|
2457
2458
|
return (0, import_visitors_core28.visit)(node.value, self);
|
|
2458
2459
|
}
|
|
2459
2460
|
return typeManifest({
|
|
@@ -2486,7 +2487,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2486
2487
|
});
|
|
2487
2488
|
},
|
|
2488
2489
|
visitEnumEmptyVariantType(enumEmptyVariantType) {
|
|
2489
|
-
const discriminator = nameApi.discriminatedUnionDiscriminator((0,
|
|
2490
|
+
const discriminator = nameApi.discriminatedUnionDiscriminator((0, import_nodes28.camelCase)(parentName?.strict ?? ""));
|
|
2490
2491
|
const name = nameApi.discriminatedUnionVariant(enumEmptyVariantType.name);
|
|
2491
2492
|
const kindAttribute = `${discriminator}: "${name}"`;
|
|
2492
2493
|
return typeManifest({
|
|
@@ -2499,7 +2500,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2499
2500
|
visitEnumStructVariantType(enumStructVariantType, { self }) {
|
|
2500
2501
|
const currentParentName = parentName;
|
|
2501
2502
|
const discriminator = nameApi.discriminatedUnionDiscriminator(
|
|
2502
|
-
(0,
|
|
2503
|
+
(0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
|
|
2503
2504
|
);
|
|
2504
2505
|
const name = nameApi.discriminatedUnionVariant(enumStructVariantType.name);
|
|
2505
2506
|
const kindAttribute = `${discriminator}: "${name}"`;
|
|
@@ -2523,12 +2524,12 @@ function getTypeManifestVisitor(input) {
|
|
|
2523
2524
|
visitEnumTupleVariantType(enumTupleVariantType, { self }) {
|
|
2524
2525
|
const currentParentName = parentName;
|
|
2525
2526
|
const discriminator = nameApi.discriminatedUnionDiscriminator(
|
|
2526
|
-
(0,
|
|
2527
|
+
(0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
|
|
2527
2528
|
);
|
|
2528
2529
|
const name = nameApi.discriminatedUnionVariant(enumTupleVariantType.name);
|
|
2529
2530
|
const kindAttribute = `${discriminator}: "${name}"`;
|
|
2530
|
-
const struct = (0,
|
|
2531
|
-
(0,
|
|
2531
|
+
const struct = (0, import_nodes28.structTypeNode)([
|
|
2532
|
+
(0, import_nodes28.structFieldTypeNode)({
|
|
2532
2533
|
name: "fields",
|
|
2533
2534
|
type: enumTupleVariantType.tuple
|
|
2534
2535
|
})
|
|
@@ -2554,16 +2555,16 @@ function getTypeManifestVisitor(input) {
|
|
|
2554
2555
|
const currentParentName = parentName;
|
|
2555
2556
|
const encoderOptions = [];
|
|
2556
2557
|
const decoderOptions = [];
|
|
2557
|
-
const enumSize = (0,
|
|
2558
|
+
const enumSize = (0, import_nodes28.resolveNestedTypeNode)(enumType.size);
|
|
2558
2559
|
if (enumSize.format !== "u8" || enumSize.endian !== "le") {
|
|
2559
2560
|
const sizeManifest = (0, import_visitors_core28.visit)(enumType.size, self);
|
|
2560
2561
|
encoderOptions.push(fragment`size: ${sizeManifest.encoder}`);
|
|
2561
2562
|
decoderOptions.push(fragment`size: ${sizeManifest.decoder}`);
|
|
2562
2563
|
}
|
|
2563
2564
|
const discriminator = nameApi.discriminatedUnionDiscriminator(
|
|
2564
|
-
(0,
|
|
2565
|
+
(0, import_nodes28.camelCase)(currentParentName?.strict ?? "")
|
|
2565
2566
|
);
|
|
2566
|
-
if (!(0,
|
|
2567
|
+
if (!(0, import_nodes28.isScalarEnum)(enumType) && discriminator !== "__kind") {
|
|
2567
2568
|
encoderOptions.push(fragment`discriminator: '${discriminator}'`);
|
|
2568
2569
|
decoderOptions.push(fragment`discriminator: '${discriminator}'`);
|
|
2569
2570
|
}
|
|
@@ -2575,7 +2576,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2575
2576
|
decoderOptions,
|
|
2576
2577
|
(cs) => cs.length > 0 ? `, { ${cs.join(", ")} }` : ""
|
|
2577
2578
|
);
|
|
2578
|
-
if ((0,
|
|
2579
|
+
if ((0, import_nodes28.isScalarEnum)(enumType)) {
|
|
2579
2580
|
if (currentParentName === null) {
|
|
2580
2581
|
throw new Error(
|
|
2581
2582
|
"Scalar enums cannot be inlined and must be introduced via a defined type. Ensure you are not inlining a defined type that is a scalar enum through a visitor."
|
|
@@ -2609,7 +2610,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2609
2610
|
const enumFunction = nameApi.discriminatedUnionFunction(node.enum.name);
|
|
2610
2611
|
const importFrom = getImportFrom(node.enum);
|
|
2611
2612
|
const enumNode = linkables.get([...stack.getPath(), node.enum])?.type;
|
|
2612
|
-
const isScalar = enumNode && (0,
|
|
2613
|
+
const isScalar = enumNode && (0, import_nodes28.isNode)(enumNode, "enumTypeNode") ? (0, import_nodes28.isScalarEnum)(enumNode) : !nonScalarEnums.includes(node.enum.name);
|
|
2613
2614
|
if (!node.value && isScalar) {
|
|
2614
2615
|
const variantName2 = nameApi.enumVariant(node.variant);
|
|
2615
2616
|
return typeManifest({
|
|
@@ -2690,7 +2691,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2690
2691
|
strict: nameApi.dataType(instructionDataName)
|
|
2691
2692
|
};
|
|
2692
2693
|
const link = customInstructionData.get(instruction.name)?.linkNode;
|
|
2693
|
-
const struct = (0,
|
|
2694
|
+
const struct = (0, import_nodes28.structTypeNodeFromInstructionArgumentNodes)(instruction.arguments);
|
|
2694
2695
|
const manifest = link ? (0, import_visitors_core28.visit)(link, self) : (0, import_visitors_core28.visit)(struct, self);
|
|
2695
2696
|
parentName = null;
|
|
2696
2697
|
return manifest;
|
|
@@ -2746,7 +2747,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2746
2747
|
const childManifest = (0, import_visitors_core28.visit)(optionType.item, self);
|
|
2747
2748
|
const encoderOptions = [];
|
|
2748
2749
|
const decoderOptions = [];
|
|
2749
|
-
const optionPrefix = (0,
|
|
2750
|
+
const optionPrefix = (0, import_nodes28.resolveNestedTypeNode)(optionType.prefix);
|
|
2750
2751
|
if (optionPrefix.format !== "u8" || optionPrefix.endian !== "le") {
|
|
2751
2752
|
const prefixManifest = (0, import_visitors_core28.visit)(optionType.prefix, self);
|
|
2752
2753
|
encoderOptions.push(fragment`prefix: ${prefixManifest.encoder}`);
|
|
@@ -2930,7 +2931,7 @@ function getTypeManifestVisitor(input) {
|
|
|
2930
2931
|
});
|
|
2931
2932
|
},
|
|
2932
2933
|
visitStructFieldType(structFieldType, { self }) {
|
|
2933
|
-
const name = (0,
|
|
2934
|
+
const name = (0, import_nodes28.camelCase)(structFieldType.name);
|
|
2934
2935
|
const originalChildManifest = (0, import_visitors_core28.visit)(structFieldType.type, self);
|
|
2935
2936
|
let docs = getDocblockFragment(structFieldType.docs ?? [], true);
|
|
2936
2937
|
docs = docs ? fragment`\n${docs}` : docs;
|
|
@@ -2982,12 +2983,12 @@ function getTypeManifestVisitor(input) {
|
|
|
2982
2983
|
const accountNode = (0, import_visitors_core28.findLastNodeFromPath)(parentPath, "accountNode");
|
|
2983
2984
|
const discriminatorPrefix = instructionNode ? instructionNode.name : accountNode?.name;
|
|
2984
2985
|
const discriminators = (instructionNode ? instructionNode.discriminators : accountNode?.discriminators) ?? [];
|
|
2985
|
-
const fieldDiscriminators = discriminators.filter((0,
|
|
2986
|
+
const fieldDiscriminators = discriminators.filter((0, import_nodes28.isNodeFilter)("fieldDiscriminatorNode"));
|
|
2986
2987
|
const defaultValues = mergeFragments(
|
|
2987
2988
|
optionalFields.map((f) => {
|
|
2988
|
-
const key = (0,
|
|
2989
|
+
const key = (0, import_nodes28.camelCase)(f.name);
|
|
2989
2990
|
if (fieldDiscriminators.some((d) => d.name === f.name)) {
|
|
2990
|
-
const constantName = nameApi.constant((0,
|
|
2991
|
+
const constantName = nameApi.constant((0, import_nodes28.camelCase)(`${discriminatorPrefix}_${f.name}`));
|
|
2991
2992
|
return f.defaultValueStrategy === "omitted" ? fragment`${key}: ${constantName}` : fragment`${key}: value.${key} ?? ${constantName}`;
|
|
2992
2993
|
}
|
|
2993
2994
|
const defaultValue = f.defaultValue;
|
|
@@ -3058,19 +3059,19 @@ function getTypeManifestVisitor(input) {
|
|
|
3058
3059
|
);
|
|
3059
3060
|
}
|
|
3060
3061
|
function getArrayLikeSizeOption(count, visitor) {
|
|
3061
|
-
if ((0,
|
|
3062
|
+
if ((0, import_nodes28.isNode)(count, "fixedCountNode")) {
|
|
3062
3063
|
return {
|
|
3063
3064
|
decoder: fragment`size: ${count.value}`,
|
|
3064
3065
|
encoder: fragment`size: ${count.value}`
|
|
3065
3066
|
};
|
|
3066
3067
|
}
|
|
3067
|
-
if ((0,
|
|
3068
|
+
if ((0, import_nodes28.isNode)(count, "remainderCountNode")) {
|
|
3068
3069
|
return {
|
|
3069
3070
|
decoder: fragment`size: 'remainder'`,
|
|
3070
3071
|
encoder: fragment`size: 'remainder'`
|
|
3071
3072
|
};
|
|
3072
3073
|
}
|
|
3073
|
-
const prefix = (0,
|
|
3074
|
+
const prefix = (0, import_nodes28.resolveNestedTypeNode)(count.prefix);
|
|
3074
3075
|
if (prefix.format === "u32" && prefix.endian === "le") {
|
|
3075
3076
|
return { decoder: void 0, encoder: void 0 };
|
|
3076
3077
|
}
|
|
@@ -3088,20 +3089,20 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3088
3089
|
const customAccountData = parseCustomDataOptions(options.customAccountData ?? [], "AccountData");
|
|
3089
3090
|
const customInstructionData = parseCustomDataOptions(options.customInstructionData ?? [], "InstructionData");
|
|
3090
3091
|
const renderScopeWithTypeManifestVisitor = {
|
|
3091
|
-
asyncResolvers: (options.asyncResolvers ?? []).map(
|
|
3092
|
+
asyncResolvers: (options.asyncResolvers ?? []).map(import_nodes29.camelCase),
|
|
3092
3093
|
customAccountData,
|
|
3093
3094
|
customInstructionData,
|
|
3094
3095
|
dependencyMap: options.dependencyMap ?? {},
|
|
3095
3096
|
getImportFrom: getImportFromFactory(options.linkOverrides ?? {}, customAccountData, customInstructionData),
|
|
3096
3097
|
linkables,
|
|
3097
3098
|
nameApi: getNameApi({ ...DEFAULT_NAME_TRANSFORMERS, ...options.nameTransformers }),
|
|
3098
|
-
nonScalarEnums: (options.nonScalarEnums ?? []).map(
|
|
3099
|
+
nonScalarEnums: (options.nonScalarEnums ?? []).map(import_nodes29.camelCase),
|
|
3099
3100
|
renderParentInstructions: options.renderParentInstructions ?? false,
|
|
3100
3101
|
useGranularImports: options.useGranularImports ?? false
|
|
3101
3102
|
};
|
|
3102
3103
|
const typeManifestVisitor = getTypeManifestVisitor({ ...renderScopeWithTypeManifestVisitor, stack });
|
|
3103
3104
|
const renderScope = { ...renderScopeWithTypeManifestVisitor, typeManifestVisitor };
|
|
3104
|
-
const internalNodes = (options.internalNodes ?? []).map(
|
|
3105
|
+
const internalNodes = (options.internalNodes ?? []).map(import_nodes29.camelCase);
|
|
3105
3106
|
const resolvedInstructionInputVisitor = (0, import_visitors_core29.getResolvedInstructionInputsVisitor)();
|
|
3106
3107
|
const byteSizeVisitor = (0, import_visitors_core29.getByteSizeVisitor)(linkables, { stack });
|
|
3107
3108
|
const asPage = (fragment2, dependencyMap = {}) => {
|
|
@@ -3118,7 +3119,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3118
3119
|
(v) => (0, import_visitors_core29.extendVisitor)(v, {
|
|
3119
3120
|
visitAccount(node) {
|
|
3120
3121
|
return (0, import_renderers_core13.createRenderMap)(
|
|
3121
|
-
`accounts/${(0,
|
|
3122
|
+
`accounts/${(0, import_nodes29.camelCase)(node.name)}.ts`,
|
|
3122
3123
|
asPage(
|
|
3123
3124
|
getAccountPageFragment({
|
|
3124
3125
|
...renderScope,
|
|
@@ -3130,7 +3131,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3130
3131
|
},
|
|
3131
3132
|
visitDefinedType(node) {
|
|
3132
3133
|
return (0, import_renderers_core13.createRenderMap)(
|
|
3133
|
-
`types/${(0,
|
|
3134
|
+
`types/${(0, import_nodes29.camelCase)(node.name)}.ts`,
|
|
3134
3135
|
asPage(getTypePageFragment({ ...renderScope, node, size: (0, import_visitors_core29.visit)(node, byteSizeVisitor) }), {
|
|
3135
3136
|
generatedTypes: "."
|
|
3136
3137
|
})
|
|
@@ -3138,7 +3139,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3138
3139
|
},
|
|
3139
3140
|
visitInstruction(node) {
|
|
3140
3141
|
return (0, import_renderers_core13.createRenderMap)(
|
|
3141
|
-
`instructions/${(0,
|
|
3142
|
+
`instructions/${(0, import_nodes29.camelCase)(node.name)}.ts`,
|
|
3142
3143
|
asPage(
|
|
3143
3144
|
getInstructionPageFragment({
|
|
3144
3145
|
...renderScope,
|
|
@@ -3151,7 +3152,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3151
3152
|
},
|
|
3152
3153
|
visitPda(node) {
|
|
3153
3154
|
return (0, import_renderers_core13.createRenderMap)(
|
|
3154
|
-
`pdas/${(0,
|
|
3155
|
+
`pdas/${(0, import_nodes29.camelCase)(node.name)}.ts`,
|
|
3155
3156
|
asPage(getPdaPageFragment({ ...renderScope, pdaPath: stack.getPath("pdaNode") }))
|
|
3156
3157
|
);
|
|
3157
3158
|
},
|
|
@@ -3163,28 +3164,28 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3163
3164
|
const scope = { ...renderScope, programNode: node };
|
|
3164
3165
|
return (0, import_renderers_core13.mergeRenderMaps)([
|
|
3165
3166
|
(0, import_renderers_core13.createRenderMap)({
|
|
3166
|
-
[`programs/${(0,
|
|
3167
|
-
[`errors/${(0,
|
|
3167
|
+
[`programs/${(0, import_nodes29.camelCase)(node.name)}.ts`]: asPage(getProgramPageFragment(scope)),
|
|
3168
|
+
[`errors/${(0, import_nodes29.camelCase)(node.name)}.ts`]: node.errors.length > 0 ? asPage(getErrorPageFragment(scope)) : void 0
|
|
3168
3169
|
}),
|
|
3169
3170
|
...node.pdas.map((p) => (0, import_visitors_core29.visit)(p, self)),
|
|
3170
3171
|
...node.accounts.map((a) => (0, import_visitors_core29.visit)(a, self)),
|
|
3171
3172
|
...node.definedTypes.map((t) => (0, import_visitors_core29.visit)(t, self)),
|
|
3172
3173
|
...customDataDefinedType.map((t) => (0, import_visitors_core29.visit)(t, self)),
|
|
3173
|
-
...(0,
|
|
3174
|
+
...(0, import_nodes29.getAllInstructionsWithSubs)(node, { leavesOnly: !renderScope.renderParentInstructions }).map(
|
|
3174
3175
|
(i) => (0, import_visitors_core29.visit)(i, self)
|
|
3175
3176
|
)
|
|
3176
3177
|
]);
|
|
3177
3178
|
},
|
|
3178
3179
|
visitRoot(node, { self }) {
|
|
3179
3180
|
const isNotInternal = (n) => !internalNodes.includes(n.name);
|
|
3180
|
-
const programsToExport = (0,
|
|
3181
|
+
const programsToExport = (0, import_nodes29.getAllPrograms)(node).filter(isNotInternal);
|
|
3181
3182
|
const programsWithErrorsToExport = programsToExport.filter((p) => p.errors.length > 0);
|
|
3182
|
-
const pdasToExport = (0,
|
|
3183
|
-
const accountsToExport = (0,
|
|
3184
|
-
const instructionsToExport = (0,
|
|
3183
|
+
const pdasToExport = (0, import_nodes29.getAllPdas)(node);
|
|
3184
|
+
const accountsToExport = (0, import_nodes29.getAllAccounts)(node).filter(isNotInternal);
|
|
3185
|
+
const instructionsToExport = (0, import_nodes29.getAllInstructionsWithSubs)(node, {
|
|
3185
3186
|
leavesOnly: !renderScope.renderParentInstructions
|
|
3186
3187
|
}).filter(isNotInternal);
|
|
3187
|
-
const definedTypesToExport = (0,
|
|
3188
|
+
const definedTypesToExport = (0, import_nodes29.getAllDefinedTypes)(node).filter(isNotInternal);
|
|
3188
3189
|
const hasAnythingToExport = programsToExport.length > 0 || accountsToExport.length > 0 || instructionsToExport.length > 0 || definedTypesToExport.length > 0;
|
|
3189
3190
|
const scope = {
|
|
3190
3191
|
...renderScope,
|
|
@@ -3205,7 +3206,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
3205
3206
|
["shared/index.ts"]: hasAnythingToExport ? asPage(getSharedPageFragment()) : void 0,
|
|
3206
3207
|
["types/index.ts"]: asPage(getIndexPageFragment(definedTypesToExport))
|
|
3207
3208
|
}),
|
|
3208
|
-
...(0,
|
|
3209
|
+
...(0, import_nodes29.getAllPrograms)(node).map((p) => (0, import_visitors_core29.visit)(p, self))
|
|
3209
3210
|
]);
|
|
3210
3211
|
}
|
|
3211
3212
|
}),
|