diff --git a/src/core/types.ts b/src/core/types.ts index 64deb207..06ea4896 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -165,8 +165,3 @@ export type Cardano = { isEnabled(): Promise; }; }; - -declare global { - // deno-lint-ignore no-var - var cardano: Cardano; -} diff --git a/src/plutus/data.ts b/src/plutus/data.ts index 75944a37..86bfa501 100644 --- a/src/plutus/data.ts +++ b/src/plutus/data.ts @@ -8,6 +8,10 @@ import { toHex, } from "../mod.ts"; +type DeepRemoveReadonly = T extends object + ? { -readonly [K in keyof T]: DeepRemoveReadonly } + : T; + export class Constr { index: number; fields: T[]; @@ -30,7 +34,7 @@ export const Data = { options?: | { minLength?: number; maxLength?: number; enum?: string[] } | number, - ) => { + ): string => { const bytes: Record = { dataType: "bytes" }; if (typeof options === "number") { bytes.minLength = options; @@ -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", @@ -65,7 +69,7 @@ export const Data = { options?: | { minItems?: number; maxItems?: number; uniqueItems?: boolean } | number, - ) => { + ): Array => { const array: Record = { dataType: "list", items }; if (typeof options === "number") { array.minItems = options; @@ -81,7 +85,7 @@ export const Data = { keys: K, values: V, options?: { minItems?: number; maxItems?: number } | number, - ) => { + ): Map => { const map: Record = { dataType: "map", keys, @@ -100,7 +104,7 @@ export const Data = { Object: ( properties: T, options?: { hasConstr?: boolean }, - ) => { + ): T => { const object = { anyOf: [{ dataType: "constructor", @@ -121,7 +125,9 @@ export const Data = { options.hasConstr; return object as unknown as T; }, - Enum: (...items: T) => { + Enum: ( + ...items: T + ): DeepRemoveReadonly => { const union = { anyOf: items.flatMap((item, index) => { if (typeof item === "string") { @@ -166,16 +172,12 @@ export const Data = { }), }; - type DeepRemoveReadonly = T extends object - ? { -readonly [K in keyof T]: DeepRemoveReadonly } - : T; - return union as unknown as DeepRemoveReadonly; }, Tuple: ( items: [...T], options?: { hasConstr?: boolean }, - ) => { + ): T => { const tuple: Record = { dataType: "list", items, @@ -187,7 +189,7 @@ export const Data = { } return tuple as unknown as T; }, - Nullable: (item: T) => { + Nullable: (item: T): T | null => { return { anyOf: [ { diff --git a/src/utils/merkle_tree.ts b/src/utils/merkle_tree.ts index 6dac9b2a..5ce69305 100644 --- a/src/utils/merkle_tree.ts +++ b/src/utils/merkle_tree.ts @@ -25,7 +25,7 @@ export class MerkleTree { } /** Construct Merkle tree from sha256 hashes */ - static fromHashes(hashes: Array) { + static fromHashes(hashes: Array): MerkleTree { return new this(hashes); } diff --git a/src/utils/script_utility.ts b/src/utils/script_utility.ts index 7058f270..12d6f3be 100644 --- a/src/utils/script_utility.ts +++ b/src/utils/script_utility.ts @@ -53,7 +53,7 @@ export class ScriptUtility { return this.lucid.utils.scriptToRewardAddress(this.script); } - toString() { + toString(): string { return this.script.script; } }