Skip to content

Commit

Permalink
fixed linter
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 29, 2025
1 parent 06bc967 commit 443dd99
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 20 deletions.
5 changes: 0 additions & 5 deletions src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,3 @@ export type Cardano = {
isEnabled(): Promise<boolean>;
};
};

declare global {
// deno-lint-ignore no-var
var cardano: Cardano;
}
28 changes: 15 additions & 13 deletions src/plutus/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {
toHex,
} from "../mod.ts";

type DeepRemoveReadonly<T> = T extends object
? { -readonly [K in keyof T]: DeepRemoveReadonly<T[K]> }
: T;

export class Constr<T> {
index: number;
fields: T[];
Expand All @@ -30,7 +34,7 @@ export const Data = {
options?:
| { minLength?: number; maxLength?: number; enum?: string[] }
| number,
) => {
): string => {
const bytes: Record<string, unknown> = { dataType: "bytes" };
if (typeof options === "number") {
bytes.minLength = options;
Expand All @@ -42,8 +46,8 @@ export const Data = {
}
return bytes as unknown as string;
},
Integer: () => ({ dataType: "integer" } as unknown as bigint),
Boolean: () => ({
Integer: (): bigint => ({ dataType: "integer" } as unknown as bigint),
Boolean: (): boolean => ({
anyOf: [
{
title: "False",
Expand All @@ -65,7 +69,7 @@ export const Data = {
options?:
| { minItems?: number; maxItems?: number; uniqueItems?: boolean }
| number,
) => {
): Array<T> => {
const array: Record<string, unknown> = { dataType: "list", items };
if (typeof options === "number") {
array.minItems = options;
Expand All @@ -81,7 +85,7 @@ export const Data = {
keys: K,
values: V,
options?: { minItems?: number; maxItems?: number } | number,
) => {
): Map<K, V> => {
const map: Record<string, unknown> = {
dataType: "map",
keys,
Expand All @@ -100,7 +104,7 @@ export const Data = {
Object: <T extends object>(
properties: T,
options?: { hasConstr?: boolean },
) => {
): T => {
const object = {
anyOf: [{
dataType: "constructor",
Expand All @@ -121,7 +125,9 @@ export const Data = {
options.hasConstr;
return object as unknown as T;
},
Enum: <const T extends unknown[]>(...items: T) => {
Enum: <const T extends unknown[]>(
...items: T
): DeepRemoveReadonly<T[number]> => {
const union = {
anyOf: items.flatMap((item, index) => {
if (typeof item === "string") {
Expand Down Expand Up @@ -166,16 +172,12 @@ export const Data = {
}),
};

type DeepRemoveReadonly<T> = T extends object
? { -readonly [K in keyof T]: DeepRemoveReadonly<T[K]> }
: T;

return union as unknown as DeepRemoveReadonly<T[number]>;
},
Tuple: <T extends unknown[]>(
items: [...T],
options?: { hasConstr?: boolean },
) => {
): T => {
const tuple: Record<string, unknown> = {
dataType: "list",
items,
Expand All @@ -187,7 +189,7 @@ export const Data = {
}
return tuple as unknown as T;
},
Nullable: <T>(item: T) => {
Nullable: <T>(item: T): T | null => {
return {
anyOf: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/merkle_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class MerkleTree {
}

/** Construct Merkle tree from sha256 hashes */
static fromHashes(hashes: Array<Hash>) {
static fromHashes(hashes: Array<Hash>): MerkleTree {
return new this(hashes);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/script_utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ScriptUtility<T extends unknown[] = Data[]> {
return this.lucid.utils.scriptToRewardAddress(this.script);
}

toString() {
toString(): string {
return this.script.script;
}
}

0 comments on commit 443dd99

Please sign in to comment.