-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding some basic structure for the contract templates library. (#2748)
- Loading branch information
Showing
10 changed files
with
145 additions
and
54 deletions.
There are no files selected for viewing
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
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,50 @@ | ||
module Template.Library (templates) where | ||
|
||
import Template.Types (Template) | ||
|
||
-- we could potentially just hard code these here for now, but it would be | ||
-- better to fetch them from the library; in any case, I'm hard coding some | ||
-- approximations of what these might look like to help get the ball rolling | ||
templates :: Array Template | ||
templates = | ||
[ { name: "Sample escrow contract 1" | ||
, type_: "Escrow" | ||
, description: "Escrow is a financial arrangement where a third party holds and regulates payment of the funds required for two parties involved in a given transaction." | ||
, contract: 0 | ||
} | ||
, { name: "Sample escrow contract 2" | ||
, type_: "Escrow" | ||
, description: "Escrow is a financial arrangement where a third party holds and regulates payment of the funds required for two parties involved in a given transaction." | ||
, contract: 0 | ||
} | ||
, { name: "Sample zero coupon bond contract 1" | ||
, type_: "Zero Coupon Bond" | ||
, description: "A zero-coupon bond is a debt security that does not pay interest but instead trades at a deep discount, rendering a profit at maturity, when the bond is redeemed for its full face value." | ||
, contract: 0 | ||
} | ||
, { name: "Sample zero coupon bond contract 2" | ||
, type_: "Zero Coupon Bond" | ||
, description: "A zero-coupon bond is a debt security that does not pay interest but instead trades at a deep discount, rendering a profit at maturity, when the bond is redeemed for its full face value." | ||
, contract: 0 | ||
} | ||
, { name: "Sample coupon bond guaranteed contract 1" | ||
, type_: "Coupon Bond Guaranteed" | ||
, description: "A guaranteed bond is a debt security that offers a secondary guarantee that interest and principal payments will be made by a third party, should the issuer default. It can be backed by a bond insurance company, a fund or group entity, a government authority, or the corporate parents of subsidiaries or joint ventures that are issuing bonds." | ||
, contract: 0 | ||
} | ||
, { name: "Sample coupon bond guaranteed contract 2" | ||
, type_: "Coupon Bond Guaranteed" | ||
, description: "A guaranteed bond is a debt security that offers a secondary guarantee that interest and principal payments will be made by a third party, should the issuer default. It can be backed by a bond insurance company, a fund or group entity, a government authority, or the corporate parents of subsidiaries or joint ventures that are issuing bonds." | ||
, contract: 0 | ||
} | ||
, { name: "Sample swap contract 1" | ||
, type_: "Swap" | ||
, description: "A swap is a derivative contract through which two parties exchange the cash flows or liabilities from two different financial instruments. Most swaps involve cash flows based on a notional principal amount such as a loan or bond, although the instrument can be almost anything. Usually, the principal does not change hands. Each cash flow comprises one leg of the swap. One cash flow is generally fixed, while the other is variable and based on a benchmark interest rate, floating currency exchange rate or index price." | ||
, contract: 0 | ||
} | ||
, { name: "Sample swap contract 2" | ||
, type_: "Swap" | ||
, description: "A swap is a derivative contract through which two parties exchange the cash flows or liabilities from two different financial instruments. Most swaps involve cash flows based on a notional principal amount such as a loan or bond, although the instrument can be almost anything. Usually, the principal does not change hands. Each cash flow comprises one leg of the swap. One cash flow is generally fixed, while the other is variable and based on a benchmark interest rate, floating currency exchange rate or index price." | ||
, contract: 0 | ||
} | ||
] |
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,15 @@ | ||
module Template.Types | ||
( Template | ||
, Contract | ||
) where | ||
|
||
type Template | ||
= { name :: String | ||
, type_ :: String | ||
, description :: String | ||
, contract :: Contract | ||
} | ||
|
||
-- TODO: move Marlowe.Extended to web-common-marlowe and import Marlowe.Extended.Contract | ||
type Contract | ||
= Int |
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,28 +1,44 @@ | ||
module Template.View | ||
( templateLibraryCard | ||
, templateDetailsCard | ||
, templateSetupScreen | ||
, contractSetupScreen | ||
) where | ||
|
||
import Prelude hiding (div) | ||
import Css (classNames) | ||
import Halogen.HTML (HTML, div, text) | ||
import MainFrame.Types (Action, ContractTemplate) | ||
import Data.Maybe (Maybe(..)) | ||
import Halogen.HTML (HTML, button, div, div_, h2_, h3_, h4_, p_, text) | ||
import Halogen.HTML.Events (onClick) | ||
import MainFrame.Types (Action(..), Screen(..)) | ||
import Template.Types (Template) | ||
|
||
templateLibraryCard :: forall p. HTML p Action | ||
templateLibraryCard = | ||
div | ||
[ classNames [ "h-full", "overflow-auto" ] ] | ||
[ text "Start new from template" ] | ||
templateLibraryCard :: forall p. Array Template -> HTML p Action | ||
templateLibraryCard templates = | ||
div_ | ||
[ h2_ [ text "Start new from template" ] | ||
, div | ||
[ classNames [ "grid", "gap-1", "md:grid-cols-2", "lg:grid-cols-3" ] ] | ||
(templateBox <$> templates) | ||
] | ||
|
||
templateDetailsCard :: forall p. ContractTemplate -> HTML p Action | ||
templateDetailsCard contractTemplate = | ||
templateBox :: forall p. Template -> HTML p Action | ||
templateBox template = | ||
div | ||
[ classNames [ "h-full", "overflow-auto" ] ] | ||
[ text "Contract Template" ] | ||
[ classNames [ "bg-white", "p-1" ] ] | ||
[ h4_ | ||
[ text template.type_ ] | ||
, h3_ | ||
[ text template.name ] | ||
, p_ | ||
[ text template.description ] | ||
, button | ||
[ classNames [ "bg-green", "text-white" ] | ||
, onClick $ const $ Just $ SetScreen $ ContractSetupScreen template | ||
] | ||
[ text "Setup" ] | ||
] | ||
|
||
templateSetupScreen :: forall p. ContractTemplate -> HTML p Action | ||
templateSetupScreen contractTemplate = | ||
contractSetupScreen :: forall p. Template -> HTML p Action | ||
contractSetupScreen template = | ||
div | ||
[ classNames [ "h-full", "overflow-auto" ] ] | ||
[ classNames [ "p-1" ] ] | ||
[ text "Setup Contract" ] |
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
Oops, something went wrong.