@codama/renderers-js 2.0.2 → 2.1.0
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/dist/index.browser.cjs +51 -12
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +51 -13
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.cjs +51 -12
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +51 -13
- package/dist/index.node.mjs.map +1 -1
- package/dist/index.react-native.mjs +51 -13
- package/dist/index.react-native.mjs.map +1 -1
- package/dist/types/fragments/programPlugin.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/nameTransformers.d.ts +1 -1
- package/dist/types/utils/nameTransformers.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -333,6 +333,8 @@ var DEFAULT_NAME_TRANSFORMERS = {
|
|
|
333
333
|
programPluginInstructionKey: (name) => `${nodes.camelCase(name)}`,
|
|
334
334
|
programPluginInstructionsType: (name) => `${nodes.pascalCase(name)}PluginInstructions`,
|
|
335
335
|
programPluginKey: (name) => `${nodes.camelCase(name)}`,
|
|
336
|
+
programPluginPdaKey: (name) => `${nodes.camelCase(name)}`,
|
|
337
|
+
programPluginPdasType: (name) => `${nodes.pascalCase(name)}PluginPdas`,
|
|
336
338
|
programPluginRequirementsType: (name) => `${nodes.pascalCase(name)}PluginRequirements`,
|
|
337
339
|
programPluginType: (name) => `${nodes.pascalCase(name)}Plugin`,
|
|
338
340
|
resolverFunction: (name) => `${nodes.camelCase(name)}`
|
|
@@ -2267,7 +2269,8 @@ function getProgramInstructionsParseFunctionFragment(scope) {
|
|
|
2267
2269
|
}`;
|
|
2268
2270
|
}
|
|
2269
2271
|
function getProgramPluginFragment(scope) {
|
|
2270
|
-
if (scope.programNode.accounts.length === 0 && scope.programNode.instructions.length === 0)
|
|
2272
|
+
if (scope.programNode.accounts.length === 0 && scope.programNode.instructions.length === 0 && scope.programNode.pdas.length === 0)
|
|
2273
|
+
return;
|
|
2271
2274
|
const resolvedInstructionInputVisitor = visitorsCore.getResolvedInstructionInputsVisitor();
|
|
2272
2275
|
const asyncInstructions = scope.programNode.instructions.filter(
|
|
2273
2276
|
(instruction) => hasAsyncFunction(instruction, visitorsCore.visit(instruction, resolvedInstructionInputVisitor), scope.asyncResolvers)
|
|
@@ -2277,6 +2280,7 @@ function getProgramPluginFragment(scope) {
|
|
|
2277
2280
|
getProgramPluginTypeFragment(scope),
|
|
2278
2281
|
getProgramPluginAccountsTypeFragment(scope),
|
|
2279
2282
|
getProgramPluginInstructionsTypeFragment({ ...scope, asyncInstructions }),
|
|
2283
|
+
getProgramPluginPdasTypeFragment(scope),
|
|
2280
2284
|
getProgramPluginRequirementsTypeFragment(scope),
|
|
2281
2285
|
getProgramPluginFunctionFragment({ ...scope, asyncInstructions }),
|
|
2282
2286
|
getMakeOptionalHelperTypeFragment(scope)
|
|
@@ -2289,10 +2293,12 @@ function getProgramPluginTypeFragment(scope) {
|
|
|
2289
2293
|
const programPluginType = nameApi.programPluginType(programNode.name);
|
|
2290
2294
|
const programPluginAccountsType = nameApi.programPluginAccountsType(programNode.name);
|
|
2291
2295
|
const programPluginInstructionsType = nameApi.programPluginInstructionsType(programNode.name);
|
|
2296
|
+
const programPluginPdasType = nameApi.programPluginPdasType(programNode.name);
|
|
2292
2297
|
const fields = mergeFragments(
|
|
2293
2298
|
[
|
|
2294
2299
|
programNode.accounts.length > 0 ? fragment`accounts: ${programPluginAccountsType};` : void 0,
|
|
2295
|
-
programNode.instructions.length > 0 ? fragment`instructions: ${programPluginInstructionsType};` : void 0
|
|
2300
|
+
programNode.instructions.length > 0 ? fragment`instructions: ${programPluginInstructionsType};` : void 0,
|
|
2301
|
+
programNode.pdas.length > 0 ? fragment`pdas: ${programPluginPdasType};` : void 0
|
|
2296
2302
|
],
|
|
2297
2303
|
(c) => c.join(" ")
|
|
2298
2304
|
);
|
|
@@ -2337,6 +2343,33 @@ function getProgramPluginInstructionsTypeFragment(scope) {
|
|
|
2337
2343
|
);
|
|
2338
2344
|
return fragment`export type ${programPluginInstructionsType} = { ${fields} }`;
|
|
2339
2345
|
}
|
|
2346
|
+
function getProgramPluginPdasTypeFragment(scope) {
|
|
2347
|
+
const { programNode, nameApi } = scope;
|
|
2348
|
+
if (programNode.pdas.length === 0) return;
|
|
2349
|
+
const programPluginPdasType = nameApi.programPluginPdasType(programNode.name);
|
|
2350
|
+
const fields = mergeFragments(
|
|
2351
|
+
programNode.pdas.map((pda) => {
|
|
2352
|
+
const name = nameApi.programPluginPdaKey(pda.name);
|
|
2353
|
+
const pdaFindFunction = use("type " + nameApi.pdaFindFunction(pda.name), "generatedPdas");
|
|
2354
|
+
return fragment`${name}: typeof ${pdaFindFunction};`;
|
|
2355
|
+
}),
|
|
2356
|
+
(c) => c.join(" ")
|
|
2357
|
+
);
|
|
2358
|
+
return fragment`export type ${programPluginPdasType} = { ${fields} }`;
|
|
2359
|
+
}
|
|
2360
|
+
function getProgramPluginPdasObjectFragment(scope) {
|
|
2361
|
+
const { programNode, nameApi } = scope;
|
|
2362
|
+
if (programNode.pdas.length === 0) return;
|
|
2363
|
+
const fields = mergeFragments(
|
|
2364
|
+
programNode.pdas.map((pda) => {
|
|
2365
|
+
const name = nameApi.programPluginPdaKey(pda.name);
|
|
2366
|
+
const pdaFindFunction = use(nameApi.pdaFindFunction(pda.name), "generatedPdas");
|
|
2367
|
+
return fragment`${name}: ${pdaFindFunction}`;
|
|
2368
|
+
}),
|
|
2369
|
+
(c) => c.join(", ")
|
|
2370
|
+
);
|
|
2371
|
+
return fragment`pdas: { ${fields} }`;
|
|
2372
|
+
}
|
|
2340
2373
|
function getProgramPluginRequirementsTypeFragment(scope) {
|
|
2341
2374
|
const { programNode, nameApi } = scope;
|
|
2342
2375
|
const programRequirementsType = nameApi.programPluginRequirementsType(programNode.name);
|
|
@@ -2346,15 +2379,16 @@ function getProgramPluginRequirementsTypeFragment(scope) {
|
|
|
2346
2379
|
const clientWithTransactionSending = use("type ClientWithTransactionSending", "solanaPluginInterfaces");
|
|
2347
2380
|
const hasAccounts = programNode.accounts.length > 0;
|
|
2348
2381
|
const hasInstructions = programNode.instructions.length > 0;
|
|
2349
|
-
const
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2382
|
+
const requirementList = [
|
|
2383
|
+
hasAccounts ? clientWithRpc : void 0,
|
|
2384
|
+
hasPayerDefaultValues(programNode) ? clientWithPayer : void 0,
|
|
2385
|
+
hasInstructions ? clientWithTransactionPlanning : void 0,
|
|
2386
|
+
hasInstructions ? clientWithTransactionSending : void 0
|
|
2387
|
+
].filter((r) => r !== void 0);
|
|
2388
|
+
if (requirementList.length === 0) {
|
|
2389
|
+
return fragment`export type ${programRequirementsType} = object`;
|
|
2390
|
+
}
|
|
2391
|
+
const requirements = mergeFragments(requirementList, (c) => c.join(" & "));
|
|
2358
2392
|
return fragment`export type ${programRequirementsType} = ${requirements}`;
|
|
2359
2393
|
}
|
|
2360
2394
|
function getProgramPluginFunctionFragment(scope) {
|
|
@@ -2364,7 +2398,11 @@ function getProgramPluginFunctionFragment(scope) {
|
|
|
2364
2398
|
const programPluginRequirementsType = nameApi.programPluginRequirementsType(programNode.name);
|
|
2365
2399
|
const programPluginKey = nameApi.programPluginKey(programNode.name);
|
|
2366
2400
|
const fields = mergeFragments(
|
|
2367
|
-
[
|
|
2401
|
+
[
|
|
2402
|
+
getProgramPluginAccountsObjectFragment(scope),
|
|
2403
|
+
getProgramPluginInstructionsObjectFragment(scope),
|
|
2404
|
+
getProgramPluginPdasObjectFragment(scope)
|
|
2405
|
+
],
|
|
2368
2406
|
(c) => c.join(", ")
|
|
2369
2407
|
);
|
|
2370
2408
|
return fragment`export function ${programPluginFunction}() {
|
|
@@ -3374,6 +3412,7 @@ function renderVisitor(packageFolder, options = {}) {
|
|
|
3374
3412
|
});
|
|
3375
3413
|
}
|
|
3376
3414
|
|
|
3415
|
+
exports.DEFAULT_KIT_IMPORT_STRATEGY = DEFAULT_KIT_IMPORT_STRATEGY;
|
|
3377
3416
|
exports.DEFAULT_NAME_TRANSFORMERS = DEFAULT_NAME_TRANSFORMERS;
|
|
3378
3417
|
exports.addToImportMap = addToImportMap;
|
|
3379
3418
|
exports.createImportMap = createImportMap;
|