-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from input-output-hk/hrajchert/PLT-7500-compat…
…ibility-layer Refactor language-core-v1
- Loading branch information
Showing
66 changed files
with
460 additions
and
461 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
changelog.d/20230928_115519_hrajchert_PLT_7500_compatibility_layer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### @marlowe.io/language-core-v1 | ||
|
||
- Moved the examples to the `@marlowe.io/language-examples` package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[scriv] | ||
format = md | ||
categories = General, @marlowe.io/wallet, @marlowe.io/adapter, @marlowe.io/language-core-v1, @marlowe.io/runtime-rest-client, @marlowe.io/runtime-core, @marlowe.io/runtime-lifecycle | ||
categories = General, @marlowe.io/wallet, @marlowe.io/adapter, @marlowe.io/language-core-v1, @marlowe.io/language-examples, @marlowe.io/runtime-rest-client, @marlowe.io/runtime-core, @marlowe.io/runtime-lifecycle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as t from "io-ts/lib/index.js"; | ||
|
||
import { Observation } from "./value-and-observation.js"; | ||
import { ChoiceId } from "./value-and-observation.js"; | ||
import { Party } from "./participants.js"; | ||
import { AccountId } from "./payee.js"; | ||
import { Token } from "./token.js"; | ||
import { Value } from "./value-and-observation.js"; | ||
|
||
export type Bound = { from: bigint; to: bigint }; | ||
|
||
export const Bound: t.Type<Bound> = t.recursion("Bound", () => | ||
t.type({ from: t.bigint, to: t.bigint }) | ||
); | ||
|
||
export type Choice = { choose_between: Bound[]; for_choice: ChoiceId }; | ||
|
||
export const Choice: t.Type<Choice> = t.recursion("Choice", () => | ||
t.type({ choose_between: t.array(Bound), for_choice: ChoiceId }) | ||
); | ||
|
||
export type Deposit = { | ||
party: Party; | ||
deposits: Value; | ||
of_token: Token; | ||
into_account: AccountId; | ||
}; | ||
|
||
export const Deposit: t.Type<Deposit> = t.type({ | ||
party: Party, | ||
deposits: Value, | ||
of_token: Token, | ||
into_account: AccountId, | ||
}); | ||
|
||
export type Notify = { notify_if: Observation }; | ||
|
||
export const Notify: t.Type<Notify> = t.recursion("Notify", () => | ||
t.type({ notify_if: Observation }) | ||
); | ||
|
||
export type Action = Deposit | Choice | Notify; | ||
|
||
export const Action: t.Type<Action> = t.recursion("Action", () => | ||
t.union([Deposit, Choice, Notify]) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as t from "io-ts/lib/index.js"; | ||
|
||
// TODO: This should be DELETED as there is a newtype for this in runtime-core, | ||
// but a preliminary change broke the build with weird type errors | ||
export type AddressBech32 = string; | ||
export const AddressBech32 = t.string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import * as t from "io-ts/lib/index.js"; | ||
import { Observation } from "./value-and-observation.js"; | ||
import { AccountId } from "./payee.js"; | ||
import { Payee } from "./payee.js"; | ||
import { Token } from "./token.js"; | ||
import { Value, ValueId } from "./value-and-observation.js"; | ||
import { Action } from "./actions.js"; | ||
import { pipe } from "fp-ts/lib/function.js"; | ||
import getUnixTime from "date-fns/getUnixTime/index.js"; | ||
|
||
export const close = "close"; | ||
export type Close = t.TypeOf<typeof Close>; | ||
export const Close = t.literal("close"); | ||
|
||
export const pay = ( | ||
pay: Value, | ||
token: Token, | ||
from_account: AccountId, | ||
to: Payee, | ||
then: Contract | ||
) => ({ | ||
pay: pay, | ||
token: token, | ||
from_account: from_account, | ||
to: to, | ||
then: then, | ||
}); | ||
|
||
export type Pay = { | ||
pay: Value; | ||
token: Token; | ||
from_account: AccountId; | ||
to: Payee; | ||
then: Contract; | ||
}; | ||
|
||
export const Pay = t.recursion<Pay>("Pay", () => | ||
t.type({ | ||
pay: Value, | ||
token: Token, | ||
from_account: AccountId, | ||
to: Payee, | ||
then: Contract, | ||
}) | ||
); | ||
|
||
export type If = { if: Observation; then: Contract; else: Contract }; | ||
|
||
export const If: t.Type<If> = t.recursion("If", () => | ||
t.type({ if: Observation, then: Contract, else: Contract }) | ||
); | ||
|
||
export type Let = { let: ValueId; be: Value; then: Contract }; | ||
|
||
export const Let: t.Type<Let> = t.recursion("Let", () => | ||
t.type({ let: ValueId, be: Value, then: Contract }) | ||
); | ||
|
||
export type Assert = { assert: Observation; then: Contract }; | ||
|
||
export const Assert: t.Type<Assert> = t.recursion("Assert", () => | ||
t.type({ assert: Observation, then: Contract }) | ||
); | ||
|
||
export type When = { | ||
when: Case[]; | ||
timeout: Timeout; | ||
timeout_continuation: Contract; | ||
}; | ||
|
||
export const When: t.Type<When> = t.recursion("When", () => | ||
t.type({ | ||
when: t.array(Case), | ||
timeout: Timeout, | ||
timeout_continuation: Contract, | ||
}) | ||
); | ||
|
||
export type Case = { case: Action; then: Contract }; | ||
|
||
export const Case: t.Type<Case> = t.recursion("Case", () => | ||
t.type({ case: Action, then: Contract }) | ||
); | ||
|
||
export type Timeout = t.TypeOf<typeof Timeout>; | ||
export const Timeout = t.bigint; | ||
|
||
export const datetoTimeout = (date: Date): Timeout => | ||
pipe( | ||
date, | ||
getUnixTime, | ||
(a) => a * 1_000, | ||
BigInt, | ||
(a) => a.valueOf() | ||
); | ||
|
||
export type Contract = Close | Pay | If | When | Let | Assert; | ||
|
||
export const Contract: t.Type<Contract> = t.recursion("Contract", () => | ||
t.union([Close, Pay, If, When, Let, Assert]) | ||
); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// TODO: REVISIT | ||
|
||
export { | ||
Contract, | ||
Assert, | ||
Close, | ||
close, | ||
If, | ||
Let, | ||
Pay, | ||
When, | ||
datetoTimeout, | ||
Timeout, | ||
} from "./contract.js"; | ||
export { role, Party } from "./participants.js"; | ||
export { Action } from "./actions.js"; | ||
export { inputNotify } from "./inputs.js"; | ||
export { Input, BuiltinByteString } from "./inputs.js"; | ||
export { Value } from "./value-and-observation.js"; | ||
export { Accounts } from "./state.js"; | ||
export { Token, TokenName, tokenToString, token } from "./token.js"; | ||
export { TokenValue, tokenValue, adaValue } from "./tokenValue.js"; | ||
export { PolicyId } from "./policyId.js"; | ||
export { MarloweState } from "./state.js"; | ||
export { Environment, mkEnvironment } from "./environment.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as t from "io-ts/lib/index.js"; | ||
import { Contract } from "./contract.js"; | ||
import { ChoiceId } from "./value-and-observation.js"; | ||
import { Party } from "./participants.js"; | ||
import { AccountId } from "./payee.js"; | ||
import { Token } from "./token.js"; | ||
|
||
export type ChosenNum = t.TypeOf<typeof ChosenNum>; | ||
export const ChosenNum = t.bigint; | ||
|
||
export type InputChoice = t.TypeOf<typeof InputChoice>; | ||
export const InputChoice = t.type({ | ||
for_choice_id: ChoiceId, | ||
input_that_chooses_num: ChosenNum, | ||
}); | ||
|
||
export type InputDeposit = t.TypeOf<typeof InputDeposit>; | ||
export const InputDeposit = t.type({ | ||
input_from_party: Party, | ||
that_deposits: t.bigint, | ||
of_token: Token, | ||
into_account: AccountId, | ||
}); | ||
|
||
export const inputNotify = "input_notify"; | ||
export type InputNotify = t.TypeOf<typeof InputNotify>; | ||
export const InputNotify = t.literal("input_notify"); | ||
|
||
// Maybe this should be a newtype | ||
export type BuiltinByteString = t.TypeOf<typeof BuiltinByteString>; | ||
export const BuiltinByteString = t.string; | ||
|
||
export type InputContent = t.TypeOf<typeof InputContent>; | ||
export const InputContent = t.union([InputDeposit, InputChoice, InputNotify]); | ||
|
||
export type NormalInput = t.TypeOf<typeof NormalInput>; | ||
export const NormalInput = InputContent; | ||
|
||
export type MerkleizedInput = t.TypeOf<typeof MerkleizedInput>; | ||
export const MerkleizedInput = t.intersection([ | ||
InputContent, | ||
t.partial({ | ||
continuation_hash: BuiltinByteString, | ||
merkleized_continuation: Contract, | ||
}), | ||
]); | ||
|
||
export type Input = t.TypeOf<typeof Input>; | ||
export const Input = t.union([NormalInput, MerkleizedInput]); |
6 changes: 3 additions & 3 deletions
6
...c/semantics/next/applicables/canChoose.ts → ...core/v1/src/next/applicables/canChoose.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
.../semantics/next/applicables/canDeposit.ts → ...ore/v1/src/next/applicables/canDeposit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...c/semantics/next/applicables/canNotify.ts → ...core/v1/src/next/applicables/canNotify.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.