Skip to content

Commit

Permalink
PLT-7260 Added guard for safety errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwbush committed Sep 10, 2023
1 parent 5e19245 commit 3993642
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lessons/08-cip45/marleon.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script src="controller.js" type="application/javascript"> </script>
<title>Donate via Marleon</title>
</head>
<body id="uiBody" style="color:darkblue;font-size:smaller" onload="Controller.initialize()">
<body id="uiBody" style="color:darkblue;background-color:aliceblue;font-size:smaller" onload="Controller.initialize()">
<h1>Donate via Marleon</h1>
<p>Marleon is a Marlowe contract for sending tokens to the holder of a Marlowe role token.</p>
<ol>
Expand Down
26 changes: 15 additions & 11 deletions lessons/08-cip45/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,22 @@ export async function createContract() {
, uiRuntime.innerText + "/contracts"
, "application/vendor.iog.marlowe-runtime.contract-tx-json"
, function(res) {
uiFundingPolicy.disabled = true
uiFundingName.disabled = true
uiFundingAmount.disabled = true
uiDepositTime.disabled = true
setContract(res.resource.contractId)
contractUrl = uiRuntime.innerText + "/" + res.links.contract
const followup = function() {
uiCreate.disabled = true
uiDeposit.disabled = false
setTx(uiCreateTx, contractId.replace(/#.*$/, ""))
if (res.resource.safetyErrors.length > 0) {
report("Refusing to create contract with safety errors: " + res.resource.safetyErrors.map(x => x.detail).join(" "))
} else {
uiFundingPolicy.disabled = true
uiFundingName.disabled = true
uiFundingAmount.disabled = true
uiDepositTime.disabled = true
setContract(res.resource.contractId)
contractUrl = uiRuntime.innerText + "/" + res.links.contract
const followup = function() {
uiCreate.disabled = true
uiDeposit.disabled = false
setTx(uiCreateTx, contractId.replace(/#.*$/, ""))
}
submitTransaction(res.resource.tx.cborHex, contractUrl, waitForConfirmation(contractUrl, followup))
}
submitTransaction(res.resource.tx.cborHex, contractUrl, waitForConfirmation(contractUrl, followup))
}
)
}
Expand Down
1 change: 0 additions & 1 deletion lessons/08-cip45/view.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ body {
max-width: 100%;
overflow-x: hidden;
font-family: sans-serif;
background-color: aliceblue;
}
30 changes: 30 additions & 0 deletions lessons/08-cip45/webpack-production.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const path = require('path')

module.exports = {
entry : './src/controller.js'
, mode : 'production'
, output : {
filename : 'controller.js'
, path : path.resolve(__dirname, '.')
, libraryTarget : "var"
, library : "Controller"
},
devServer: {
static: ".",
allowedHosts: "all",
host: "0.0.0.0",
port: 8080,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
},
https: {
key: 'key.pem',
cert: 'cert.pem'
},
client: {
overlay: false,
}
}
}
12 changes: 2 additions & 10 deletions lessons/08-cip45/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path')

module.exports = {
entry : './src/controller.js'
, mode : 'production'
, mode : 'development'
, output : {
filename : 'controller.js'
, path : path.resolve(__dirname, '.')
Expand All @@ -11,20 +11,12 @@ module.exports = {
},
devServer: {
static: ".",
allowedHosts: "all",
host: "0.0.0.0",
host: "127.0.0.1",
port: 8080,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
},
https: {
key: 'key.pem',
cert: 'cert.pem'
},
client: {
overlay: false,
}
}
}

0 comments on commit 3993642

Please sign in to comment.