@codama/renderers-js 1.2.14 → 1.3.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.node.cjs +19 -19
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +23 -23
- package/dist/index.node.mjs.map +1 -1
- package/dist/templates/fragments/instructionParseFunction.njk +5 -5
- package/dist/templates/fragments/instructionType.njk +5 -5
- package/dist/templates/pages/sharedPage.njk +2 -2
- package/dist/types/fragments/instructionParseFunction.d.ts.map +1 -1
- package/dist/types/fragments/instructionType.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.node.mjs
CHANGED
|
@@ -135,7 +135,7 @@ var ImportMap = class {
|
|
|
135
135
|
import { getLastNodeFromPath } from "@codama/visitors-core";
|
|
136
136
|
|
|
137
137
|
// src/fragments/common.ts
|
|
138
|
-
import { join as join2 } from "
|
|
138
|
+
import { join as join2 } from "path";
|
|
139
139
|
|
|
140
140
|
// src/utils/async.ts
|
|
141
141
|
import {
|
|
@@ -319,8 +319,8 @@ function getImportFromFactory(overrides, customAccountData, customInstructionDat
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
// src/utils/render.ts
|
|
322
|
-
import { dirname as pathDirname, join } from "
|
|
323
|
-
import { fileURLToPath } from "
|
|
322
|
+
import { dirname as pathDirname, join } from "path";
|
|
323
|
+
import { fileURLToPath } from "url";
|
|
324
324
|
import { camelCase as camelCase2, kebabCase, pascalCase, snakeCase, titleCase } from "@codama/nodes";
|
|
325
325
|
import nunjucks from "nunjucks";
|
|
326
326
|
function jsDocblock(docs) {
|
|
@@ -645,10 +645,10 @@ import { pascalCase as pascalCase2 } from "@codama/nodes";
|
|
|
645
645
|
function getInstructionAccountMetaFragment(instructionAccountNode) {
|
|
646
646
|
const typeParam = `TAccount${pascalCase2(instructionAccountNode.name)}`;
|
|
647
647
|
if (instructionAccountNode.isSigner === true && instructionAccountNode.isWritable) {
|
|
648
|
-
return fragment(`WritableSignerAccount<${typeParam}> &
|
|
648
|
+
return fragment(`WritableSignerAccount<${typeParam}> & AccountSignerMeta<${typeParam}>`).addImports("solanaInstructions", ["type WritableSignerAccount"]).addImports("solanaSigners", ["type AccountSignerMeta"]);
|
|
649
649
|
}
|
|
650
650
|
if (instructionAccountNode.isSigner === true) {
|
|
651
|
-
return fragment(`ReadonlySignerAccount<${typeParam}> &
|
|
651
|
+
return fragment(`ReadonlySignerAccount<${typeParam}> & AccountSignerMeta<${typeParam}>`).addImports("solanaInstructions", ["type ReadonlySignerAccount"]).addImports("solanaSigners", ["type AccountSignerMeta"]);
|
|
652
652
|
}
|
|
653
653
|
if (instructionAccountNode.isWritable) {
|
|
654
654
|
return fragment(`WritableAccount<${typeParam}>`).addImports("solanaInstructions", "type WritableAccount");
|
|
@@ -669,10 +669,10 @@ function getInstructionAccountTypeParamFragment(scope) {
|
|
|
669
669
|
const instructionNode = findInstructionNodeFromPath(instructionAccountPath);
|
|
670
670
|
const programNode = findProgramNodeFromPath2(instructionAccountPath);
|
|
671
671
|
const typeParam = `TAccount${pascalCase3(instructionAccountNode.name)}`;
|
|
672
|
-
const accountMeta = allowAccountMeta ? " |
|
|
672
|
+
const accountMeta = allowAccountMeta ? " | AccountMeta<string>" : "";
|
|
673
673
|
const imports = new ImportMap();
|
|
674
674
|
if (allowAccountMeta) {
|
|
675
|
-
imports.add("solanaInstructions", "type
|
|
675
|
+
imports.add("solanaInstructions", "type AccountMeta");
|
|
676
676
|
}
|
|
677
677
|
if (instructionNode.optionalAccountStrategy === "omitted" && instructionAccountNode.isOptional) {
|
|
678
678
|
return fragment(`${typeParam} extends string${accountMeta} | undefined = undefined`, imports);
|
|
@@ -1237,8 +1237,8 @@ function getInstructionRemainingAccountsFragment(scope) {
|
|
|
1237
1237
|
return mergeFragments(
|
|
1238
1238
|
fragments,
|
|
1239
1239
|
(r) => `// Remaining accounts.
|
|
1240
|
-
const remainingAccounts:
|
|
1241
|
-
).addImports("solanaInstructions", ["type
|
|
1240
|
+
const remainingAccounts: AccountMeta[] = ${r.length === 1 ? r[0] : `[...${r.join(", ...")}]`}`
|
|
1241
|
+
).addImports("solanaInstructions", ["type AccountMeta"]);
|
|
1242
1242
|
}
|
|
1243
1243
|
function getRemainingAccountsFragment2(remainingAccounts, scope) {
|
|
1244
1244
|
const remainingAccountsFragment = (() => {
|
|
@@ -1358,7 +1358,7 @@ function getInstructionFunctionFragment(scope) {
|
|
|
1358
1358
|
const getReturnType = (instructionType) => {
|
|
1359
1359
|
let returnType = instructionType;
|
|
1360
1360
|
if (hasByteDeltas) {
|
|
1361
|
-
returnType = `${returnType} &
|
|
1361
|
+
returnType = `${returnType} & InstructionWithByteDelta`;
|
|
1362
1362
|
}
|
|
1363
1363
|
return useAsync ? `Promise<${returnType}>` : returnType;
|
|
1364
1364
|
};
|
|
@@ -1395,10 +1395,10 @@ function getInstructionFunctionFragment(scope) {
|
|
|
1395
1395
|
argsTypeFragment
|
|
1396
1396
|
).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaAddresses", ["type Address"]);
|
|
1397
1397
|
if (hasAccounts) {
|
|
1398
|
-
functionFragment.addImports("solanaInstructions", ["type
|
|
1398
|
+
functionFragment.addImports("solanaInstructions", ["type AccountMeta"]).addImports("shared", ["getAccountMetaFactory", "type ResolvedAccount"]);
|
|
1399
1399
|
}
|
|
1400
1400
|
if (hasByteDeltas) {
|
|
1401
|
-
functionFragment.addImports("shared", ["type
|
|
1401
|
+
functionFragment.addImports("shared", ["type InstructionWithByteDelta"]);
|
|
1402
1402
|
}
|
|
1403
1403
|
return functionFragment;
|
|
1404
1404
|
}
|
|
@@ -1418,8 +1418,8 @@ function getInstructionType(scope) {
|
|
|
1418
1418
|
if (account.isSigner === "either") {
|
|
1419
1419
|
const signerRole = account.isWritable ? "WritableSignerAccount" : "ReadonlySignerAccount";
|
|
1420
1420
|
return fragment(
|
|
1421
|
-
`typeof input["${camelName}"] extends TransactionSigner<${typeParam}> ? ${signerRole}<${typeParam}> &
|
|
1422
|
-
).addImports("solanaInstructions", [`type ${signerRole}`]).addImports("solanaSigners", ["type
|
|
1421
|
+
`typeof input["${camelName}"] extends TransactionSigner<${typeParam}> ? ${signerRole}<${typeParam}> & AccountSignerMeta<${typeParam}> : ${typeParam}`
|
|
1422
|
+
).addImports("solanaInstructions", [`type ${signerRole}`]).addImports("solanaSigners", ["type AccountSignerMeta"]);
|
|
1423
1423
|
}
|
|
1424
1424
|
return fragment(typeParam);
|
|
1425
1425
|
});
|
|
@@ -1468,7 +1468,7 @@ function getInstructionParseFunctionFragment(scope) {
|
|
|
1468
1468
|
instructionParsedType: nameApi.instructionParsedType(instructionNode.name),
|
|
1469
1469
|
minimumNumberOfAccounts,
|
|
1470
1470
|
programAddressConstant
|
|
1471
|
-
}).mergeImportsWith(dataTypeFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaInstructions", ["type
|
|
1471
|
+
}).mergeImportsWith(dataTypeFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaInstructions", ["type Instruction"]).addImports("solanaInstructions", hasAccounts ? ["type InstructionWithAccounts", "type AccountMeta"] : []).addImports("solanaInstructions", hasData ? ["type InstructionWithData"] : []).addImports("solanaCodecsCore", hasData ? ["type ReadonlyUint8Array"] : []);
|
|
1472
1472
|
}
|
|
1473
1473
|
|
|
1474
1474
|
// src/fragments/instructionType.ts
|
|
@@ -1516,11 +1516,11 @@ function getInstructionTypeFragment(scope) {
|
|
|
1516
1516
|
instruction: instructionNode,
|
|
1517
1517
|
instructionType: nameApi.instructionType(instructionNode.name),
|
|
1518
1518
|
programAddressConstant
|
|
1519
|
-
}).mergeImportsWith(accountTypeParamsFragment, accountMetasFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaInstructions", [
|
|
1520
|
-
"type
|
|
1521
|
-
"type
|
|
1522
|
-
"type
|
|
1523
|
-
...hasData ? ["type
|
|
1519
|
+
}).mergeImportsWith(accountTypeParamsFragment, accountMetasFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaCodecsCore", hasData ? ["type ReadonlyUint8Array"] : []).addImports("solanaInstructions", [
|
|
1520
|
+
"type AccountMeta",
|
|
1521
|
+
"type Instruction",
|
|
1522
|
+
"type InstructionWithAccounts",
|
|
1523
|
+
...hasData ? ["type InstructionWithData"] : []
|
|
1524
1524
|
]);
|
|
1525
1525
|
return fragment2;
|
|
1526
1526
|
}
|
|
@@ -1763,7 +1763,7 @@ function mergeManifests(manifests, options = {}) {
|
|
|
1763
1763
|
}
|
|
1764
1764
|
|
|
1765
1765
|
// src/getRenderMapVisitor.ts
|
|
1766
|
-
import { join as join3 } from "
|
|
1766
|
+
import { join as join3 } from "path";
|
|
1767
1767
|
import { logWarn } from "@codama/errors";
|
|
1768
1768
|
import {
|
|
1769
1769
|
camelCase as camelCase12,
|
|
@@ -2820,10 +2820,10 @@ function getRenderMapVisitor(options = {}) {
|
|
|
2820
2820
|
"type ProgramDerivedAddress"
|
|
2821
2821
|
]).add("solanaInstructions", [
|
|
2822
2822
|
"AccountRole",
|
|
2823
|
-
"type
|
|
2823
|
+
"type AccountMeta",
|
|
2824
2824
|
"upgradeRoleToSigner"
|
|
2825
2825
|
]).add("solanaSigners", [
|
|
2826
|
-
"type
|
|
2826
|
+
"type AccountSignerMeta",
|
|
2827
2827
|
"isTransactionSigner",
|
|
2828
2828
|
"type TransactionSigner"
|
|
2829
2829
|
]).addAlias("solanaSigners", "isTransactionSigner", "kitIsTransactionSigner").toString(dependencyMap, useGranularImports)
|