Skip to content

Commit

Permalink
Restrict ContractInterfaceFunction type alias usage
Browse files Browse the repository at this point in the history
This commit restricts EnrichedContractInterfaceFunction type alias usage to
relevant methods and adds a JSDoc comment to the definition.
  • Loading branch information
BowTiedRadone committed Jan 23, 2025
1 parent 89f0bcc commit a1fe34c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 5 additions & 9 deletions property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "./shared";
import { dim, green, red, underline, yellow } from "ansicolor";
import { ContractInterfaceFunction } from "@hirosystems/clarinet-sdk-wasm";
import { EnrichedContractInterfaceFunction } from "./shared.types";
import {
buildTraitReferenceMap,
enrichInterfaceWithTraitData,
Expand Down Expand Up @@ -386,11 +385,8 @@ const validateDiscardFunction = (
contractId: string,
discardFunctionName: string,
testFunctionName: string,
testContractsDiscardFunctions: Map<
string,
EnrichedContractInterfaceFunction[]
>,
testContractsTestFunctions: Map<string, EnrichedContractInterfaceFunction[]>,
testContractsDiscardFunctions: Map<string, ContractInterfaceFunction[]>,
testContractsTestFunctions: Map<string, ContractInterfaceFunction[]>,
radio: EventEmitter
) => {
const testFunction = testContractsTestFunctions
Expand Down Expand Up @@ -437,8 +433,8 @@ const validateDiscardFunction = (
* @returns A boolean indicating if the parameters match.
*/
export const isParamsMatch = (
testFunction: EnrichedContractInterfaceFunction,
discardFunction: EnrichedContractInterfaceFunction
testFunction: ContractInterfaceFunction,
discardFunction: ContractInterfaceFunction
) => {
const sortedTestFunctionArgs = [...testFunction.args].sort((a, b) =>
a.name.localeCompare(b.name)
Expand All @@ -458,5 +454,5 @@ export const isParamsMatch = (
* @returns A boolean indicating if the return type is boolean.
*/
export const isReturnTypeBoolean = (
discardFunction: EnrichedContractInterfaceFunction
discardFunction: ContractInterfaceFunction
) => discardFunction.outputs.type === "bool";
2 changes: 1 addition & 1 deletion shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const getFunctionsFromContractInterfaces = (
);

export const getFunctionsListForContract = (
functionsMap: Map<string, any[]>,
functionsMap: Map<string, EnrichedContractInterfaceFunction[]>,
contractId: string
) => functionsMap.get(contractId) || [];

Expand Down
4 changes: 4 additions & 0 deletions shared.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import { ImplementedTraitType, ImportedTraitType } from "./traits.types";

// Types used for Clarity Value conversion.

/**
* The type of the function interface, after the contract interface is
* "enriched" with additional information about trait references.
*/
export type EnrichedContractInterfaceFunction = {
args: (
| ContractInterfaceFunctionArg
Expand Down

0 comments on commit a1fe34c

Please sign in to comment.