@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.
@@ -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 "node:path";
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 "node:path";
323
- import { fileURLToPath } from "node:url";
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}> & IAccountSignerMeta<${typeParam}>`).addImports("solanaInstructions", ["type WritableSignerAccount"]).addImports("solanaSigners", ["type IAccountSignerMeta"]);
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}> & IAccountSignerMeta<${typeParam}>`).addImports("solanaInstructions", ["type ReadonlySignerAccount"]).addImports("solanaSigners", ["type IAccountSignerMeta"]);
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 ? " | IAccountMeta<string>" : "";
672
+ const accountMeta = allowAccountMeta ? " | AccountMeta<string>" : "";
673
673
  const imports = new ImportMap();
674
674
  if (allowAccountMeta) {
675
- imports.add("solanaInstructions", "type IAccountMeta");
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: IAccountMeta[] = ${r.length === 1 ? r[0] : `[...${r.join(", ...")}]`}`
1241
- ).addImports("solanaInstructions", ["type IAccountMeta"]);
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} & IInstructionWithByteDelta`;
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 IAccountMeta"]).addImports("shared", ["getAccountMetaFactory", "type ResolvedAccount"]);
1398
+ functionFragment.addImports("solanaInstructions", ["type AccountMeta"]).addImports("shared", ["getAccountMetaFactory", "type ResolvedAccount"]);
1399
1399
  }
1400
1400
  if (hasByteDeltas) {
1401
- functionFragment.addImports("shared", ["type IInstructionWithByteDelta"]);
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}> & IAccountSignerMeta<${typeParam}> : ${typeParam}`
1422
- ).addImports("solanaInstructions", [`type ${signerRole}`]).addImports("solanaSigners", ["type IAccountSignerMeta"]);
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 IInstruction"]).addImports("solanaInstructions", hasAccounts ? ["type IInstructionWithAccounts", "type IAccountMeta"] : []).addImports("solanaInstructions", hasData ? ["type IInstructionWithData"] : []);
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 IAccountMeta",
1521
- "type IInstruction",
1522
- "type IInstructionWithAccounts",
1523
- ...hasData ? ["type IInstructionWithData"] : []
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 "node:path";
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 IAccountMeta",
2823
+ "type AccountMeta",
2824
2824
  "upgradeRoleToSigner"
2825
2825
  ]).add("solanaSigners", [
2826
- "type IAccountSignerMeta",
2826
+ "type AccountSignerMeta",
2827
2827
  "isTransactionSigner",
2828
2828
  "type TransactionSigner"
2829
2829
  ]).addAlias("solanaSigners", "isTransactionSigner", "kitIsTransactionSigner").toString(dependencyMap, useGranularImports)