Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

chore: adding preamble type #2

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/common/plutus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
CurrencySymbol,
TokenName,
List,
PlutusData,
} from '../type/plutus';

export const conStr = <N, T>(constructor: N, fields: T): ConStr<N, T> => ({
Expand All @@ -31,7 +32,7 @@ export const conStr2 = <T>(fields: T): ConStr2<T> => conStr<2, T>(2, fields);
export const bool = (b: boolean): Bool => (b ? conStr1<[]>([]) : conStr0<[]>([]));
export const builtinByteString = (bytes: string): BuiltinByteString => ({ bytes });
export const integer = (int: number): Integer => ({ int });
export const list = <T>(pList: T[]): List<T> => ({ list: pList });
export const list = (pList: PlutusData[]): List => ({ list: pList });
export const currencySymbol = (bytes: string): CurrencySymbol => builtinByteString(bytes);
export const tokenName = (bytes: string): TokenName => builtinByteString(bytes);
export const maybeStakingHash = (stakeCredential: string): MaybeStakingHash => {
Expand Down
18 changes: 18 additions & 0 deletions src/core/type/blueprint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
import * as Plutus from './plutus';

export type PreambleType = {
title: string;
description: string;
version: string;
plutusVersion: string;
compiler: {
name: string;
version: 'v1' | 'v2' | 'v3';
};
license: string;
};

export type BPValidator<D, R, P> = {
title: string;
datum: {
Expand All @@ -21,3 +35,7 @@ export type BPValidator<D, R, P> = {
compiledCode: string;
hash: string;
};

export type ByteArray = Plutus.BuiltinByteString;
export type Int = Plutus.Integer;
export type Constructor<N, T> = Plutus.ConStr<N, T>;
1 change: 1 addition & 0 deletions src/core/type/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './plutus';
export * from './blueprint';
5 changes: 4 additions & 1 deletion src/core/type/plutus.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-explicit-any */

export type ConStr<N, T> = { constructor: N; fields: T };
export type ConStr0<T> = ConStr<0, T>;
export type ConStr1<T> = ConStr<1, T>;
export type ConStr2<T> = ConStr<2, T>;
export type Bool = ConStr0<[]> | ConStr1<[]>;
export type BuiltinByteString = { bytes: string };
export type Integer = { int: number };
export type List<T> = { list: T[] };
export type List = { list: PlutusData[] };
export type ValidatorHash = BuiltinByteString;
export type PaymentPubKeyHash = BuiltinByteString;
export type PubKeyHash = PaymentPubKeyHash;
Expand Down
Loading