@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.cjs
CHANGED
|
@@ -673,10 +673,10 @@ var import_nodes6 = require("@codama/nodes");
|
|
|
673
673
|
function getInstructionAccountMetaFragment(instructionAccountNode) {
|
|
674
674
|
const typeParam = `TAccount${(0, import_nodes6.pascalCase)(instructionAccountNode.name)}`;
|
|
675
675
|
if (instructionAccountNode.isSigner === true && instructionAccountNode.isWritable) {
|
|
676
|
-
return fragment(`WritableSignerAccount<${typeParam}> &
|
|
676
|
+
return fragment(`WritableSignerAccount<${typeParam}> & AccountSignerMeta<${typeParam}>`).addImports("solanaInstructions", ["type WritableSignerAccount"]).addImports("solanaSigners", ["type AccountSignerMeta"]);
|
|
677
677
|
}
|
|
678
678
|
if (instructionAccountNode.isSigner === true) {
|
|
679
|
-
return fragment(`ReadonlySignerAccount<${typeParam}> &
|
|
679
|
+
return fragment(`ReadonlySignerAccount<${typeParam}> & AccountSignerMeta<${typeParam}>`).addImports("solanaInstructions", ["type ReadonlySignerAccount"]).addImports("solanaSigners", ["type AccountSignerMeta"]);
|
|
680
680
|
}
|
|
681
681
|
if (instructionAccountNode.isWritable) {
|
|
682
682
|
return fragment(`WritableAccount<${typeParam}>`).addImports("solanaInstructions", "type WritableAccount");
|
|
@@ -693,10 +693,10 @@ function getInstructionAccountTypeParamFragment(scope) {
|
|
|
693
693
|
const instructionNode = (0, import_visitors_core7.findInstructionNodeFromPath)(instructionAccountPath);
|
|
694
694
|
const programNode = (0, import_visitors_core7.findProgramNodeFromPath)(instructionAccountPath);
|
|
695
695
|
const typeParam = `TAccount${(0, import_nodes7.pascalCase)(instructionAccountNode.name)}`;
|
|
696
|
-
const accountMeta = allowAccountMeta ? " |
|
|
696
|
+
const accountMeta = allowAccountMeta ? " | AccountMeta<string>" : "";
|
|
697
697
|
const imports = new ImportMap();
|
|
698
698
|
if (allowAccountMeta) {
|
|
699
|
-
imports.add("solanaInstructions", "type
|
|
699
|
+
imports.add("solanaInstructions", "type AccountMeta");
|
|
700
700
|
}
|
|
701
701
|
if (instructionNode.optionalAccountStrategy === "omitted" && instructionAccountNode.isOptional) {
|
|
702
702
|
return fragment(`${typeParam} extends string${accountMeta} | undefined = undefined`, imports);
|
|
@@ -1240,8 +1240,8 @@ function getInstructionRemainingAccountsFragment(scope) {
|
|
|
1240
1240
|
return mergeFragments(
|
|
1241
1241
|
fragments,
|
|
1242
1242
|
(r) => `// Remaining accounts.
|
|
1243
|
-
const remainingAccounts:
|
|
1244
|
-
).addImports("solanaInstructions", ["type
|
|
1243
|
+
const remainingAccounts: AccountMeta[] = ${r.length === 1 ? r[0] : `[...${r.join(", ...")}]`}`
|
|
1244
|
+
).addImports("solanaInstructions", ["type AccountMeta"]);
|
|
1245
1245
|
}
|
|
1246
1246
|
function getRemainingAccountsFragment2(remainingAccounts, scope) {
|
|
1247
1247
|
const remainingAccountsFragment = (() => {
|
|
@@ -1361,7 +1361,7 @@ function getInstructionFunctionFragment(scope) {
|
|
|
1361
1361
|
const getReturnType = (instructionType) => {
|
|
1362
1362
|
let returnType = instructionType;
|
|
1363
1363
|
if (hasByteDeltas) {
|
|
1364
|
-
returnType = `${returnType} &
|
|
1364
|
+
returnType = `${returnType} & InstructionWithByteDelta`;
|
|
1365
1365
|
}
|
|
1366
1366
|
return useAsync ? `Promise<${returnType}>` : returnType;
|
|
1367
1367
|
};
|
|
@@ -1398,10 +1398,10 @@ function getInstructionFunctionFragment(scope) {
|
|
|
1398
1398
|
argsTypeFragment
|
|
1399
1399
|
).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaAddresses", ["type Address"]);
|
|
1400
1400
|
if (hasAccounts) {
|
|
1401
|
-
functionFragment.addImports("solanaInstructions", ["type
|
|
1401
|
+
functionFragment.addImports("solanaInstructions", ["type AccountMeta"]).addImports("shared", ["getAccountMetaFactory", "type ResolvedAccount"]);
|
|
1402
1402
|
}
|
|
1403
1403
|
if (hasByteDeltas) {
|
|
1404
|
-
functionFragment.addImports("shared", ["type
|
|
1404
|
+
functionFragment.addImports("shared", ["type InstructionWithByteDelta"]);
|
|
1405
1405
|
}
|
|
1406
1406
|
return functionFragment;
|
|
1407
1407
|
}
|
|
@@ -1421,8 +1421,8 @@ function getInstructionType(scope) {
|
|
|
1421
1421
|
if (account.isSigner === "either") {
|
|
1422
1422
|
const signerRole = account.isWritable ? "WritableSignerAccount" : "ReadonlySignerAccount";
|
|
1423
1423
|
return fragment(
|
|
1424
|
-
`typeof input["${camelName}"] extends TransactionSigner<${typeParam}> ? ${signerRole}<${typeParam}> &
|
|
1425
|
-
).addImports("solanaInstructions", [`type ${signerRole}`]).addImports("solanaSigners", ["type
|
|
1424
|
+
`typeof input["${camelName}"] extends TransactionSigner<${typeParam}> ? ${signerRole}<${typeParam}> & AccountSignerMeta<${typeParam}> : ${typeParam}`
|
|
1425
|
+
).addImports("solanaInstructions", [`type ${signerRole}`]).addImports("solanaSigners", ["type AccountSignerMeta"]);
|
|
1426
1426
|
}
|
|
1427
1427
|
return fragment(typeParam);
|
|
1428
1428
|
});
|
|
@@ -1471,7 +1471,7 @@ function getInstructionParseFunctionFragment(scope) {
|
|
|
1471
1471
|
instructionParsedType: nameApi.instructionParsedType(instructionNode.name),
|
|
1472
1472
|
minimumNumberOfAccounts,
|
|
1473
1473
|
programAddressConstant
|
|
1474
|
-
}).mergeImportsWith(dataTypeFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaInstructions", ["type
|
|
1474
|
+
}).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"] : []);
|
|
1475
1475
|
}
|
|
1476
1476
|
|
|
1477
1477
|
// src/fragments/instructionType.ts
|
|
@@ -1519,11 +1519,11 @@ function getInstructionTypeFragment(scope) {
|
|
|
1519
1519
|
instruction: instructionNode,
|
|
1520
1520
|
instructionType: nameApi.instructionType(instructionNode.name),
|
|
1521
1521
|
programAddressConstant
|
|
1522
|
-
}).mergeImportsWith(accountTypeParamsFragment, accountMetasFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaInstructions", [
|
|
1523
|
-
"type
|
|
1524
|
-
"type
|
|
1525
|
-
"type
|
|
1526
|
-
...hasData ? ["type
|
|
1522
|
+
}).mergeImportsWith(accountTypeParamsFragment, accountMetasFragment).addImports("generatedPrograms", [programAddressConstant]).addImports("solanaCodecsCore", hasData ? ["type ReadonlyUint8Array"] : []).addImports("solanaInstructions", [
|
|
1523
|
+
"type AccountMeta",
|
|
1524
|
+
"type Instruction",
|
|
1525
|
+
"type InstructionWithAccounts",
|
|
1526
|
+
...hasData ? ["type InstructionWithData"] : []
|
|
1527
1527
|
]);
|
|
1528
1528
|
return fragment2;
|
|
1529
1529
|
}
|
|
@@ -2779,10 +2779,10 @@ function getRenderMapVisitor(options = {}) {
|
|
|
2779
2779
|
"type ProgramDerivedAddress"
|
|
2780
2780
|
]).add("solanaInstructions", [
|
|
2781
2781
|
"AccountRole",
|
|
2782
|
-
"type
|
|
2782
|
+
"type AccountMeta",
|
|
2783
2783
|
"upgradeRoleToSigner"
|
|
2784
2784
|
]).add("solanaSigners", [
|
|
2785
|
-
"type
|
|
2785
|
+
"type AccountSignerMeta",
|
|
2786
2786
|
"isTransactionSigner",
|
|
2787
2787
|
"type TransactionSigner"
|
|
2788
2788
|
]).addAlias("solanaSigners", "isTransactionSigner", "kitIsTransactionSigner").toString(dependencyMap, useGranularImports)
|