@codama/renderers-js 1.2.4 → 1.2.6
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 +16 -16
- package/dist/index.node.cjs +19 -20
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +21 -22
- package/dist/index.node.mjs.map +1 -1
- package/dist/templates/pages/sharedPage.njk +1 -1
- package/package.json +8 -9
package/dist/index.node.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NodeStack, pipe, staticVisitor, extendVisitor, visit, findLastNodeFromPath, recordNodeStackVisitor, LinkableDictionary, getResolvedInstructionInputsVisitor, findProgramNodeFromPath, recordLinkablesOnFirstVisitVisitor, rootNodeVisitor, getLastNodeFromPath,
|
|
1
|
+
import { NodeStack, pipe, staticVisitor, extendVisitor, visit, findLastNodeFromPath, recordNodeStackVisitor, LinkableDictionary, getResolvedInstructionInputsVisitor, findProgramNodeFromPath, recordLinkablesOnFirstVisitVisitor, rootNodeVisitor, getLastNodeFromPath, findInstructionNodeFromPath, deduplicateInstructionDependencies } from '@codama/visitors-core';
|
|
2
2
|
import { join, dirname } from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { camelCase, pascalCase, snakeCase, REGISTERED_TYPE_NODE_KINDS, REGISTERED_VALUE_NODE_KINDS, isNodeFilter, resolveNestedTypeNode, structTypeNodeFromInstructionArgumentNodes, isNode, isScalarEnum, structTypeNode, structFieldTypeNode, titleCase, kebabCase, capitalize, getAllPrograms, getAllPdas, getAllAccounts, getAllInstructionsWithSubs, getAllDefinedTypes, definedTypeNode, definedTypeLinkNode, isDataEnum, accountValueNode, argumentValueNode, VALUE_NODES, getAllInstructionArguments, constantDiscriminatorNode, constantValueNodeFromBytes, constantValueNode, assertIsNode } from '@codama/nodes';
|
|
4
4
|
import { getBase64Encoder, getBase58Encoder, getBase16Encoder, getUtf8Encoder, getBase64Decoder } from '@solana/codecs-strings';
|
|
5
5
|
import { logWarn, CodamaError, CODAMA_ERROR__UNEXPECTED_NODE_KIND } from '@codama/errors';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
@@ -12,18 +12,18 @@ import { format } from 'prettier/standalone';
|
|
|
12
12
|
|
|
13
13
|
// src/ImportMap.ts
|
|
14
14
|
var DEFAULT_EXTERNAL_MODULE_MAP = {
|
|
15
|
-
solanaAccounts: "@solana/
|
|
16
|
-
solanaAddresses: "@solana/
|
|
17
|
-
solanaCodecsCore: "@solana/
|
|
18
|
-
solanaCodecsDataStructures: "@solana/
|
|
19
|
-
solanaCodecsNumbers: "@solana/
|
|
20
|
-
solanaCodecsStrings: "@solana/
|
|
21
|
-
solanaErrors: "@solana/
|
|
22
|
-
solanaInstructions: "@solana/
|
|
23
|
-
solanaOptions: "@solana/
|
|
24
|
-
solanaPrograms: "@solana/
|
|
25
|
-
solanaRpcTypes: "@solana/
|
|
26
|
-
solanaSigners: "@solana/
|
|
15
|
+
solanaAccounts: "@solana/kit",
|
|
16
|
+
solanaAddresses: "@solana/kit",
|
|
17
|
+
solanaCodecsCore: "@solana/kit",
|
|
18
|
+
solanaCodecsDataStructures: "@solana/kit",
|
|
19
|
+
solanaCodecsNumbers: "@solana/kit",
|
|
20
|
+
solanaCodecsStrings: "@solana/kit",
|
|
21
|
+
solanaErrors: "@solana/kit",
|
|
22
|
+
solanaInstructions: "@solana/kit",
|
|
23
|
+
solanaOptions: "@solana/kit",
|
|
24
|
+
solanaPrograms: "@solana/kit",
|
|
25
|
+
solanaRpcTypes: "@solana/kit",
|
|
26
|
+
solanaSigners: "@solana/kit"
|
|
27
27
|
};
|
|
28
28
|
var DEFAULT_GRANULAR_EXTERNAL_MODULE_MAP = {
|
|
29
29
|
solanaAccounts: "@solana/accounts",
|
|
@@ -429,7 +429,7 @@ function getAccountPdaHelpersFragment(scope) {
|
|
|
429
429
|
const { accountPath, nameApi, linkables, customAccountData, typeManifest: typeManifest2 } = scope;
|
|
430
430
|
const accountNode = getLastNodeFromPath(accountPath);
|
|
431
431
|
const programNode = findProgramNodeFromPath(accountPath);
|
|
432
|
-
const pdaNode = accountNode.pda ? linkables.get([...accountPath, accountNode.pda]) :
|
|
432
|
+
const pdaNode = accountNode.pda ? linkables.get([...accountPath, accountNode.pda]) : void 0;
|
|
433
433
|
if (!pdaNode) {
|
|
434
434
|
return fragment("");
|
|
435
435
|
}
|
|
@@ -609,14 +609,14 @@ function getInstructionAccountMetaFragment(instructionAccountNode) {
|
|
|
609
609
|
return fragment(`ReadonlyAccount<${typeParam}>`).addImports("solanaInstructions", "type ReadonlyAccount");
|
|
610
610
|
}
|
|
611
611
|
function getInstructionAccountTypeParamFragment(scope) {
|
|
612
|
-
const { instructionAccountPath,
|
|
612
|
+
const { instructionAccountPath, linkables } = scope;
|
|
613
613
|
const instructionAccountNode = getLastNodeFromPath(instructionAccountPath);
|
|
614
614
|
const instructionNode = findInstructionNodeFromPath(instructionAccountPath);
|
|
615
615
|
const programNode = findProgramNodeFromPath(instructionAccountPath);
|
|
616
616
|
const typeParam = `TAccount${pascalCase(instructionAccountNode.name)}`;
|
|
617
|
-
const accountMeta =
|
|
617
|
+
const accountMeta = " | IAccountMeta<string>" ;
|
|
618
618
|
const imports = new ImportMap();
|
|
619
|
-
|
|
619
|
+
{
|
|
620
620
|
imports.add("solanaInstructions", "type IAccountMeta");
|
|
621
621
|
}
|
|
622
622
|
if (instructionNode.optionalAccountStrategy === "omitted" && instructionAccountNode.isOptional) {
|
|
@@ -781,7 +781,7 @@ function getInstructionInputDefaultFragment(scope) {
|
|
|
781
781
|
if (input.kind === "instructionAccountNode" && isNode(defaultValue, "resolverValueNode")) {
|
|
782
782
|
return fragment(`accounts.${inputName} = { ...accounts.${inputName}, ...${renderedValue} };`);
|
|
783
783
|
}
|
|
784
|
-
if (input.kind === "instructionAccountNode" && isWritable ===
|
|
784
|
+
if (input.kind === "instructionAccountNode" && isWritable === void 0) {
|
|
785
785
|
return fragment(`accounts.${inputName}.value = ${renderedValue};`);
|
|
786
786
|
}
|
|
787
787
|
if (input.kind === "instructionAccountNode") {
|
|
@@ -967,7 +967,7 @@ ${ifTrueRenderer ? ifTrueRenderer.render : ifFalseRenderer?.render}
|
|
|
967
967
|
}
|
|
968
968
|
function renderNestedInstructionDefault(scope) {
|
|
969
969
|
const { input, defaultValue } = scope;
|
|
970
|
-
if (!defaultValue) return
|
|
970
|
+
if (!defaultValue) return void 0;
|
|
971
971
|
return getInstructionInputDefaultFragment({
|
|
972
972
|
...scope,
|
|
973
973
|
input: { ...input, defaultValue }
|
|
@@ -1370,7 +1370,6 @@ function getInstructionTypeFragment(scope) {
|
|
|
1370
1370
|
instructionNode.accounts.map(
|
|
1371
1371
|
(account) => getInstructionAccountTypeParamFragment({
|
|
1372
1372
|
...scope,
|
|
1373
|
-
allowAccountMeta: true,
|
|
1374
1373
|
instructionAccountPath: [...instructionPath, account]
|
|
1375
1374
|
})
|
|
1376
1375
|
),
|
|
@@ -2635,7 +2634,7 @@ function getRenderMapVisitor(options = {}) {
|
|
|
2635
2634
|
"type IAccountSignerMeta",
|
|
2636
2635
|
"isTransactionSigner",
|
|
2637
2636
|
"type TransactionSigner"
|
|
2638
|
-
]).addAlias("solanaSigners", "isTransactionSigner", "
|
|
2637
|
+
]).addAlias("solanaSigners", "isTransactionSigner", "kitIsTransactionSigner").toString(dependencyMap, useGranularImports)
|
|
2639
2638
|
})
|
|
2640
2639
|
);
|
|
2641
2640
|
}
|