Skip to content

Commit

Permalink
Merge pull request #49 from input-output-hk/hrajchert/plt-3331-change…
Browse files Browse the repository at this point in the history
…-ada-block

PLT-3331 change ada block
  • Loading branch information
paluh authored Oct 24, 2023
2 parents f3b367d + 8ef2083 commit e0c3954
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Changed

- Change ada block to lovelace
- Change timeout gap on TimeParams from 5 to 10 minutes
54 changes: 27 additions & 27 deletions marlowe-playground-client/src/Examples/JS/Contracts.purs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ escrow =
function deposit(timeout: Timeout, timeoutContinuation: Contract, continuation: Contract): Contract {
return When([Case(Deposit(seller, buyer, ada, price), continuation)],
return When([Case(Deposit(seller, buyer, lovelace, price), continuation)],
timeout,
timeoutContinuation);
}
Expand All @@ -47,16 +47,16 @@ escrow =
}
function sellerToBuyer(continuation: Contract): Contract {
return Pay(seller, Account(buyer), ada, price, continuation);
return Pay(seller, Account(buyer), lovelace, price, continuation);
}
function paySeller(continuation: Contract): Contract {
return Pay(buyer, Party(seller), ada, price, continuation);
return Pay(buyer, Party(seller), lovelace, price, continuation);
}
const refundBuyer: Contract = explicitRefunds ? Pay(buyer, Party(buyer), ada, price, Close) : Close;
const refundBuyer: Contract = explicitRefunds ? Pay(buyer, Party(buyer), lovelace, price, Close) : Close;
const refundSeller: Contract = explicitRefunds ? Pay(seller, Party(seller), ada, price, Close) : Close;
const refundSeller: Contract = explicitRefunds ? Pay(seller, Party(seller), lovelace, price, Close) : Close;
const contract: Contract =
deposit(depositTimeout, Close,
Expand Down Expand Up @@ -102,19 +102,19 @@ escrowWithCollateral =
const answerTimeout: Timeout = TimeParam("Complaint deadline");
function depositCollateral(party: Party, timeout: Timeout, timeoutContinuation: Contract, continuation: Contract): Contract {
return When([Case(Deposit(party, party, ada, collateral), continuation)],
return When([Case(Deposit(party, party, lovelace, collateral), continuation)],
timeout,
timeoutContinuation);
}
function burnCollaterals(continuation: Contract): Contract {
return Pay(seller, Party(burnAddress), ada, collateral,
Pay(buyer, Party(burnAddress), ada, collateral,
return Pay(seller, Party(burnAddress), lovelace, collateral,
Pay(buyer, Party(burnAddress), lovelace, collateral,
continuation));
}
function deposit(timeout: Timeout, timeoutContinuation: Contract, continuation: Contract): Contract {
return When([Case(Deposit(seller, buyer, ada, price), continuation)],
return When([Case(Deposit(seller, buyer, lovelace, price), continuation)],
timeout,
timeoutContinuation);
}
Expand All @@ -134,20 +134,20 @@ escrowWithCollateral =
}
function sellerToBuyer(continuation: Contract): Contract {
return Pay(seller, Account(buyer), ada, price, continuation);
return Pay(seller, Account(buyer), lovelace, price, continuation);
}
function refundSellerCollateral(continuation: Contract): Contract {
if (explicitRefunds) {
return Pay(seller, Party(seller), ada, collateral, continuation);
return Pay(seller, Party(seller), lovelace, collateral, continuation);
} else {
return continuation;
}
}
function refundBuyerCollateral(continuation: Contract): Contract {
if (explicitRefunds) {
return Pay(buyer, Party(buyer), ada, collateral, continuation);
return Pay(buyer, Party(buyer), lovelace, collateral, continuation);
} else {
return continuation;
}
Expand All @@ -157,9 +157,9 @@ escrowWithCollateral =
return refundSellerCollateral(refundBuyerCollateral(continuation));
}
const refundBuyer: Contract = explicitRefunds ? Pay(buyer, Party(buyer), ada, price, Close) : Close;
const refundBuyer: Contract = explicitRefunds ? Pay(buyer, Party(buyer), lovelace, price, Close) : Close;
const refundSeller: Contract = explicitRefunds ? Pay(seller, Party(seller), ada, price, Close) : Close;
const refundSeller: Contract = explicitRefunds ? Pay(seller, Party(seller), lovelace, price, Close) : Close;
const contract: Contract =
depositCollateral(seller, sellerCollateralTimeout, Close,
Expand Down Expand Up @@ -193,8 +193,8 @@ zeroCouponBond =
const maturityExchangeTimeout: Timeout = TimeParam("Payback deadline");
function transfer(timeout: Timeout, from: Party, to: Party, amount: Value, continuation: Contract): Contract {
return When([Case(Deposit(from, from, ada, amount),
Pay(from, Party(to), ada, amount, continuation))],
return When([Case(Deposit(from, from, lovelace, amount),
Pay(from, Party(to), lovelace, amount, continuation))],
timeout,
Close);
}
Expand Down Expand Up @@ -231,26 +231,26 @@ couponBondGuaranteed =
function deposit(amount: Value, by: Party, toAccount: Party,
timeout: ETimeout, timeoutContinuation: Contract,
continuation: Contract): Contract {
return When([Case(Deposit(toAccount, by, ada, amount), continuation)],
return When([Case(Deposit(toAccount, by, lovelace, amount), continuation)],
timeout,
timeoutContinuation);
}
function refundGuarantor(amount: Value, continuation: Contract): Contract {
return Pay(investor, Party(guarantor), ada, amount, continuation)
return Pay(investor, Party(guarantor), lovelace, amount, continuation)
}
function transfer(amount: Value, from: Party, to: Party,
timeout: ETimeout, timeoutContinuation: Contract,
continuation: Contract): Contract {
return deposit(amount, from, to, timeout, timeoutContinuation,
Pay(to, Party(to), ada, amount,
Pay(to, Party(to), lovelace, amount,
continuation))
}
function giveCollateralToLender(amount: Value): Contract {
if (explicitRefunds) {
return Pay(investor, Party(investor), ada, amount,
return Pay(investor, Party(investor), lovelace, amount,
Close);
} else {
return Close;
Expand Down Expand Up @@ -302,7 +302,7 @@ swap =
const adaProvider: SwapParty = {
party: Role("Ada provider"),
currency: ada,
currency: lovelace,
amount: amountOfLovelace
}
Expand Down Expand Up @@ -367,7 +367,7 @@ contractForDifferences =
function initialDeposit(by: Party, deposit: Value, timeout: ETimeout, timeoutContinuation: Contract,
continuation: Contract): Contract {
return When([Case(Deposit(by, by, ada, deposit), continuation)],
return When([Case(Deposit(by, by, lovelace, deposit), continuation)],
timeout,
timeoutContinuation);
}
Expand Down Expand Up @@ -395,12 +395,12 @@ contractForDifferences =
}
function transferUpToDeposit(from: Party, payerDeposit: Value, to: Party, amount: Value, continuation: Contract): Contract {
return Pay(from, Account(to), ada, Cond(ValueLT(amount, payerDeposit), amount, payerDeposit), continuation);
return Pay(from, Account(to), lovelace, Cond(ValueLT(amount, payerDeposit), amount, payerDeposit), continuation);
}
function refund(who: Party, amount: Value, continuation: Contract): Contract {
if (explicitRefunds) {
return Pay(who, Party(who), ada, amount,
return Pay(who, Party(who), lovelace, amount,
continuation);
} else {
return continuation;
Expand Down Expand Up @@ -480,7 +480,7 @@ contractForDifferencesWithOracle =
function initialDeposit(by: Party, deposit: Value, timeout: ETimeout, timeoutContinuation: Contract,
continuation: Contract): Contract {
return When([Case(Deposit(by, by, ada, deposit), continuation)],
return When([Case(Deposit(by, by, lovelace, deposit), continuation)],
timeout,
timeoutContinuation);
}
Expand Down Expand Up @@ -514,12 +514,12 @@ contractForDifferencesWithOracle =
}
function transferUpToDeposit(from: Party, payerDeposit: Value, to: Party, amount: Value, continuation: Contract): Contract {
return Pay(from, Account(to), ada, Cond(ValueLT(amount, payerDeposit), amount, payerDeposit), continuation);
return Pay(from, Account(to), lovelace, Cond(ValueLT(amount, payerDeposit), amount, payerDeposit), continuation);
}
function refund(who: Party, amount: Value, continuation: Contract): Contract {
if (explicitRefunds) {
return Pay(who, Party(who), ada, amount,
return Pay(who, Party(who), lovelace, amount,
continuation);
} else {
return continuation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export const Token = function (
}
};

/**
* @deprecated in favour of lovelace
*/
export const ada: Token = { currency_symbol: "", token_name: "" };
export const lovelace: Token = { currency_symbol: "", token_name: "" };

type ValueId = string;

Expand Down
2 changes: 1 addition & 1 deletion marlowe-playground-client/src/Marlowe/Blockly.purs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ toDefinition blockType@(TokenType AdaTokenType) =
BlockDefinition
$ merge
{ type: show AdaTokenType
, message0: "ada"
, message0: "lovelace"
, args0: []
, colour: blockColour blockType
, output: Just "token"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ processBlocklyCode metadata = do
maybeUpdateTemplateContent = case Holes.fromTerm holesContract of
Just (contract :: Extended.Contract) -> Template.updateTemplateContent
currentTime
(Minutes 5.0)
(Minutes 30.0)
(OMap.keys metadata.timeParameterDescriptions)
(Template.getPlaceholderIds contract)
Nothing -> identity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ handleAction metadata Compile = do
over (_analysisState <<< _templateContent)
( Template.updateTemplateContent
currentTime
(Minutes 5.0)
(Minutes 30.0)
(OMap.keys metadata.timeParameterDescriptions)
(getPlaceholderIds contract)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ handleAction metadata Compile = do
over (_analysisState <<< _templateContent)
( updateTemplateContent
currentTime
(Minutes 5.0)
(Minutes 30.0)
(OMap.keys metadata.timeParameterDescriptions)
(getPlaceholderIds contract)
)
Expand Down Expand Up @@ -268,7 +268,7 @@ analyze doAnalyze = do
decorationHeader :: String
decorationHeader =
"""import {
Address, Role, Account, Party, ada, AvailableMoney, Constant, ConstantParam,
Address, Role, Account, Party, ada, lovelace, AvailableMoney, Constant, ConstantParam,
NegValue, AddValue, SubValue, MulValue, DivValue, ChoiceValue, TimeIntervalStart,
TimeIntervalEnd, UseValue, Cond, AndObs, OrObs, NotObs, ChoseSomething,
ValueGE, ValueGT, ValueLT, ValueLE, ValueEQ, TrueObs, FalseObs, Deposit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ processMarloweCode metadata text = do
Just contract ->
Template.updateTemplateContent
currentTime
(Minutes 5.0)
(Minutes 30.0)
(OMap.keys metadata.timeParameterDescriptions)
(Template.getPlaceholderIds contract)
void $ H.request _marloweEditorPageSlot unit $ Monaco.SetModelMarkers
Expand Down
2 changes: 1 addition & 1 deletion marlowe-playground-client/src/Simulator/State.purs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ simulationNotStarted initialTime termContract metadata prevTemplateContent =
tc@(TemplateContent { timeContent, valueContent }) =
initializeTemplateContentWithIncreasingTime
initialTime
(Minutes 5.0)
(Minutes 30.0)
(OMap.keys metadata.timeParameterDescriptions)
(getPlaceholderIds termContract)
templateContent = case prevTemplateContent of
Expand Down
6 changes: 3 additions & 3 deletions marlowe-playground-client/test/BridgeTests.purs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ serializationTest =
it "Contract Serialization" do
-- A simple test that runs the Escrow contract to completion
let
ada = Token "" ""
lovelace = Token "" ""

aliceAddr = Address
"addr_test1vz3vyrrh3pavu8xescvnunn4h27cny70645etn2ulnnqnssrz8utc"
Expand All @@ -80,9 +80,9 @@ serializationTest =
contract =
Assert TrueObs
( When
[ Case (Deposit aliceAddr aliceAddr ada valueExpr)
[ Case (Deposit aliceAddr aliceAddr lovelace valueExpr)
( Let (ValueId "x") valueExpr
( Pay aliceAddr (Party bobRole) ada
( Pay aliceAddr (Party bobRole) lovelace
( Cond TrueObs (UseValue (ValueId "x"))
(UseValue (ValueId "y"))
)
Expand Down
6 changes: 3 additions & 3 deletions marlowe-playground-client/test/Marlowe/ContractTests.purs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ buyer = Role "Buyer"
arbiter :: Party
arbiter = Role "Mediator"

ada :: Token
ada = Token "" ""
lovelace :: Token
lovelace = Token "" ""

filledEscrow :: Term T.Contract
filledEscrow =
Expand Down Expand Up @@ -288,7 +288,7 @@ escrowSimpleFlow =
it "Escrow simple flow" do
-- A simple test that runs the Escrow contract to completion
let
deposit = IDeposit seller buyer ada (BigInt.fromInt 450)
deposit = IDeposit seller buyer lovelace (BigInt.fromInt 450)

choice1 = IChoice ((ChoiceId "Report problem") buyer) (BigInt.fromInt 1)

Expand Down
Loading

0 comments on commit e0c3954

Please sign in to comment.