Displaying the "agreement" field of a DAML contract - daml

How can I display the contents of the "agreement" field of a DAML contract in Navigator?
For instance this parameterized text from the test_project contract:
agreement
toText landlord <> " promises to let "
toText tenant <> " live at " <> address
" until " <> toText expirationDate

Unfortunately, this feature is not implemented in Navigator.
Some technical background:
The Ledger API does include everything needed to compute the agreement text:
The agreement text expression is included in the DAML-LF package returned by the package service.
The contract argument (the value of variables used in the agreement expression) is given by the transaction service
However, Navigator currently does not support DAML-LF expressions.

Related

AWS SDK in java - How to get activities from worker when multple execution on going for a state machine

AWS Step Function
My problem is to how to sendTaskSuccess or sendTaskFailuer to Activity which are running under the state machine in AWS .
My Actual intent is to Notify the specific activities which belongs to particular State machine execution.
I successfully send notification to all waiting activities by activityARN. But my actual need is to send notification to specific activity which belong to particular state machine execution .
Example . StateMachine - SM1
There two execution on going for SM1-- SM1E1, SM1E2 . In that case I want to sendTaskSuccess to activity which belongs to SM1E1 .
follwoing code i used . But it send notification to all activities
GetActivityTaskResult getActivityTaskResult = client.getActivityTask(new GetActivityTaskRequest()
.withActivityArn("arn detail"));
if (getActivityTaskResult.getTaskToken() != null) {
try {
JsonNode json = Jackson.jsonNodeOf(getActivityTaskResult.getInput());
String outputResult = patientRegistrationActivity.setStatus(json.get("patientId").textValue());
System.out.println("outputResult " + outputResult);
SendTaskSuccessRequest sendTaskRequest = new SendTaskSuccessRequest().withOutput(outputResult)
.withTaskToken(getActivityTaskResult.getTaskToken());
client.sendTaskSuccess(sendTaskRequest);
} catch (Exception e) {
client.sendTaskFailure(
new SendTaskFailureRequest().withTaskToken(getActivityTaskResult.getTaskToken()));
}
As far as I know you have no control over which task token is returned. You may get one for SM1E1 or SM1E2 and you cannot tell by looking at the task token. GetActivityTask returns "input" so based on that you may be able to tell which execution you are dealing with but if you get a token you are not interested in, I don't think there's a way to put it back so you won't be able to get it again with GetActivityTask later. I guess you could store it in a database somewhere for use later.
One idea you can try is to use the new callback integration pattern. You can specify the Payload parameter in the state definition to include the task token like this token.$: "$$.Task.Token" and then use GetExecutionHistory to find the TaskScheduled state of the execution you are interested in and retrieve the parameters.Payload.token value and then use that with sendTaskSuccess.
Here's a snippet of my serverless.yml file that describes the state
WaitForUserInput: #Wait for the user to do something
Type: Task
Resource: arn:aws:states:::lambda:invoke.waitForTaskToken
Parameters:
FunctionName:
Fn::GetAtt: [WaitForUserInputLambdaFunction, Arn]
Payload:
token.$: "$$.Task.Token"
executionArn.$: "$$.Execution.Id"
Next: DoSomethingElse
I did a POC to check and below is the solution .
if token is consumed by getActivityTaskResult.getTaskToken() and if your conditions not satisfied by request input then you can use below line to avoid token consumption .awsStepFunctionClient.sendTaskHeartbeat(new SendTaskHeartbeatRequest().withTaskToken(taskToken))

Is it possible to have a module function that modifies parameter values of the caller script?

Motivation
Reduce the maintenance of an Azure DevOps task that invokes a Powershell script with a lot of parameters ("a lot" could be 5).
The idea relies on the fact that Azure DevOps generates environment variables to reflect the build variables. So, I devised the following scheme:
Prefix all non secret Azure DevOps variables with MyBuild.
The task powershell script would call a function to check the script parameters against the MyBuild_ environment variables and would automatically assign the value of the MyBuild_xyz environment variable to the script parameter xyz if the latter has no value.
This way the task command line would only contain secret parameters (which are not reflected in the environment). Often, there are no secret parameters and so the command line remains empty. We find this scheme to reduce the maintenance of the tasks driven by a powershell script.
Example
param(
$DBUser,
[ValidateNotNullOrEmpty()]$DBPassword,
$DBServer,
$Configuration,
$Solutions,
$ClientDB = $env:Build_DefinitionName,
$RawBuildVersion = $env:Build_BuildNumber,
$BuildDefinition = $env:Build_DefinitionName,
$Changeset = $env:Build_SourceVersion,
$OutDir = $env:Build_BinariesDirectory,
$TempDir,
[Switch]$EnforceNoMetadataStoreChanges
)
$ErrorActionPreference = "Stop"
. $PSScriptRoot\AutomationBootstrap.ps1
$AutomationScripts = GetToolPackage DevOpsAutomation
. "$AutomationScripts\vNext\DefaultParameterValueBinding.ps1" $PSCommandPath -Required 'ClientDB' -Props #{
OutDir = #{ DefaultValue = [io.path]::GetFullPath("$PSScriptRoot\..\..\bin") }
TempDir = #{ DefaultValue = 'D:\_gctemp' }
DBUser = #{ DefaultValue = 'SomeUser' }
}
The described parameter binding logic is implemented in the script DefaultParameterValueBinding.ps1 which is published in a NuGet package. The code installs the package and thus gets access to the script.
In the example above, some parameters default to predefined Azure Devops variables, like $RawBuildVersion = $env:Build_BuildNumber. Some are left uninitialized, like $DBServer, which means it would default to $env:MyBuild_DBServer.
We can get away without the special function to do the binding, but then the script author would have to write something like this:
$DBServer = $env:MyBuild_DBServer,
$Configuration = $env:MyBuild_Configuration,
$Solutions = $env:MyBuild_Solutions,
I wanted to avoid this, because of the possibility of an accidental name mismatch.
The Problem
The approach does not work when I package the logic of DefaultParameterValueBinding.ps1 into a module function. This is because of the module scope isolation - I just cannot modify the parameters of the caller script.
Is it still possible to do? Is it possible to achieve my goal in a more elegant way? Remember, I want to reduce the cost associated with maintaining the task command line in Azure DevOps.
Right now I am inclined to retreat back to this scheme:
$xyz = $(Resolve-ParameterValue 'xyz' x y z ...)
Where Resolve-ParameterValue would first check $env:MyBuild_xyz and if not found select the first not null value out of x,y,z,...
But if the Resolve-ParameterValue method comes from a module, then the script must assume the module has already been installed, because it has no way to install it before the parameters are evaluated. Or has it?
EDIT 1
Notice the command line used to invoke the DefaultParameterValueBinding.ps1 script does not contain the caller script parameters! It does include $PSCommandPath, which is used to obtain the PSBoundParameters collection.
Yea, but it will require modifications to the calling script and the function. Pass the parameters by reference. Adam B. has a nice piece on passing parameters by reference in the following:
https://mcpmag.com/articles/2015/06/04/reference-variables-in-powershell.aspx
Net-net, the following is an example:
$age = 12;
function birthday {
param([ref]$age)
$age.value += 1
}
birthday -age ([ref]$age)
Write-Output $age
I've got an age of 12. I pass it into a function as a parameter. The function increments the value of $age by 1. You can do the same thing with a function in a module. You get my drift.

How to send messages on a transaction in the Ethereum

I want to send a message on a transaction. Here is my codes:
_data = web3.toHex('xxxx');
instance.function_name(param1, param2, param3, param4, {value: web3.toWei(_price, 'ether'), from: web3.eth.accounts[0], data:_data}).then(...);
The transaction is processed successfully, But the input data message is not the _data value in the etherscan.io
can anybody help me? Thank you.
The data field in the transaction object is used when deploying a contract or when using the general sendTransaction or sendRawTransaction methods. If you are using a contract instance, the data field is ignored.
From the Solidity docs:
Object - (optional) The (previous) last parameter can be a transaction object, see web3.eth.sendTransaction parameter 1 for more. Note: data and to properties will not be taken into account.
If you want to send the data manually, use sendTransaction.
The information shown in Etherscan is the decoded data from the signed transaction describing the function call made. It is not free form user data (if that's what you're trying to insert). The first 32 bits of the data are the function signature and each 256 bit block afterwards are the parameters.
See this source for more in-depth information.

Rendering attributes on aglio?

I'm new to aglio I was trying to render attributes for my documentation, but it does not work.
## Modify User [/users/{id}.json?{token}=API_TOKEN]
Modify any accessible fields if authorized
### Modify User [PUT]
+ Parameters
+ id: 1 (required, String) - User ID
+ token: (String) - API Token provided by the application
+ Attributes (object)
+ email : Format: john#appleseed.com (string) - Email UNIQUE
+ password : (string) - Password
+ firstname : (string) - Firstname
+ lastname : 1 (string) - Lastname
When trying to render this function with `aglio -i input.apib --theme-template triple -o output.html, I don't see the attributes. Why?
I want it to look like this where you can see the parameters and the attributes
I found this image in a GitHub issue thread
Thanks for helping.
Jonathan, attributes rendering is currently not supported in Aglio. Rendering them is not trivial and Apiary has spent a lot of time and effort to get it working, which I haven't had the time to do in Aglio yet.
Additionally I would like to support attributes rendering for Swagger and other inputs. I have a partial implementation of a general-purpose JSON schema renderer that takes both API Blueprint and Swagger (Open API) as input, but I have no idea when I'll have the time to finish it, polish it up and make a release.

UILabel not showing text inside ScrollView for big Content

My ScrollView's ContentView consists of just a UILabel which has leading space 8, trailing space 8, top space to container 8dp, and number lines set to 0. ScrollView ContentView height is to 9000.
I'm adding a big html content dynamically to the label..
public override void ViewDidLoad()
{
base.ViewDidLoad();
var attr = new NSAttributedStringDocumentAttributes();
var nsError = new NSError();
attr.DocumentType = NSDocumentType.HTML;
contentLabel.AttributedText = new NSAttributedString(GetContent(), attr, ref nsError);
contentLabel.Font = UIFont.FromName("Helvetica", 11f);
contentLabel.Layer.BorderWidth = 1f;
contentLabel.Layer.BorderColor = AZConstants.SeparatorColor.CGColor;
contentLabel.Layer.CornerRadius = 4f;
contentLabel.ClipsToBounds = true;
}
string GetContent()
{
var myHtmlText = "<h4 style=\"text-align: center;\">TERMS OF SERVICE AGREEMENT</h4>\n <p>\n " +
"PLEASE READ THE FOLLOWING TERMS OF USE AGREEMENT CAREFULLY. BY ACCESSING OR USING OUR SITES AND OUR SERVICES, YOU HEREBY AGREE\n " +
"TO BE BOUND BY THE TERMS AND ALL TERMS INCORPORATED HEREIN BY REFERENCE. IF YOU DO NOT EXPRESSLY AGREE TO ALL OF THE TERMS AND CONDITIONS, THEN PLEASE DO\n" +
"NOT ACCESS OR USE OUR SITES OR OUR SERVICES. THIS TERMS OF SERVICE AGREEMENT IS LAST REVISED AS OF July 1, 2014. \n </p>";
myHtmlText += "<h4>ACCEPTANCE OF TERMS</h4>";
myHtmlText += "<p>\n The following Terms of Service Agreement (the \"TOS\") is a legally binding agreement that shall " +
"govern the relationship with our users and others which may\n interact or interface with Simple Healthcare LLC " +
"(SHL), also known as Green Circle Health(GCH), located at 5 Portofino Drive, Suite 2101, Pensacola Beach, " +
"Florida 32561, and our\n subsidiaries and affiliates, in association with the use of the SHL websites, which includes " +
"GOGCH.COM (the \"Site\") and its services (\"Services\"), which shall be defined below.\n </p>";
myHtmlText += "<h4>DESCRIPTION OF SERVICES OFFERED</h4>\n <p>\n Green Circle Health (GCH) is a platform for patients to store " +
"and share personal medical data including vitals and documents. GCH provides medical forms needed to check-in at a medical " +
"facility. GCH enables remote monitoring of patient vitals and fitness activities for population health management and " +
"clinical research trials.\n </p>";
myHtmlText += "<p>\n <strong>GCH enables you to store your personal data</strong>\n </p>";
myHtmlText += "<p>\n Any and all visitors to our site, despite whether they are registered or not, shall be deemed " +
"as \"users\" of the herein contained Services provided for the\n purpose of this TOS. Once an individual registers " +
"for our Services, through the process of creating an account, the user shall then be considered a\n \"member.\"\n </p>";
myHtmlText += "<p>\n The user and/or member acknowledges and agrees that the Services provided and made available through " +
"our website and applications, which may include some\n mobile applications and that those applications may be made " +
"available on various social media networking sites and numerous other platforms and\n downloadable programs, are " +
"the sole property of SHL. At its sole discretion, SHL may offer additional websites or services and/or products, " +
"or update, modify or\n revise any current content and Services, and this Agreement shall apply to any and all " +
"additional services and/or products and any and all updated,\n modified or revised Services unless otherwise " +
"stipulated. SHL does hereby reserve the right to cancel and cease offering any of the aforementioned Services\n " +
"and/or products. You, as the end user and/or member, acknowledge, accept and agree that SHL shall not be held " +
"liable for any such updates, modifications,\n revisions, suspensions or discontinuance of any of our Services " +
"and/or products. Your continued use of the Services provided, after such posting of any\n updates, changes, and/or " +
"modifications shall constitute your acceptance of such updates, changes and/or modifications, and as such, " +
"frequent review of this\n Agreement and any and all applicable terms and policies should be made by you to " +
"ensure you are aware of all terms and policies currently in effect. Should\n " +
"you not agree to the updated, modified, revised or modified terms, you must stop using the provided Services.\n </p>";
myHtmlText += "<p>\n Furthermore, the user and/or member understands, acknowledges and agrees that the Services offered " +
"shall be provided \"AS IS\" and as such SHL shall not assume any responsibility or obligation for the timeliness, " +
"missed delivery, deletion and/or any failure to store user content, communication or personalization settings.\n</p>";
myHtmlText += "<h4>REGISTRATION</h4>\n <p>\n To register and become a \"member\" of the Site, you must be 18 years of age " +
"to enter into and form a legally binding contract. In addition, you must be in\n good standing and not an individual " +
"that has been previously barred from receiving SHL's Services under the laws and statutes of the United States or " +
"other\n applicable jurisdiction.\n </p>";
myHtmlText += "<p>\nFurthermore, the registering party hereby acknowledges, understands and agrees to:\n</p>";
myHtmlText += "<ol type=\"a\">\n <li>\n furnish factual, correct, current and complete information with regards to yourself " +
"as may be requested by the data registration process, and\n </li>\n <li>\n maintain and promptly update your " +
"registration and profile information in an effort to maintain accuracy and completeness at all times.\n </li>\n </ol>";
myHtmlText += "<p>\n If anyone knowingly provides any information of a false, untrue, inaccurate or incomplete nature, " +
"SHL will have sufficient grounds and rights to suspend or\n terminate the member in violation of this aspect of the Agreement, " +
"and as such refuse any and all current or future use of SHL Services, or any portion\n " +
"thereof.\n </p>";
myHtmlText += "<p>\nIt is SHL's priority to ensure the safety and privacy of all its visitors, users and members, " +
"especially that of children. Therefore, it is for this reason\n that the parents of any child under the age of 18 " +
"that permit their child or children access to the SHL website platform Services must create a \"family\"\n " +
"account, which will certify that the individual creating the \"family\" account is of 18 years of age and as such, " +
"the parent or legal guardian of any child\n or children registered under the \"family\" account. As the creator of the " +
"\"family\" account, s/he is thereby granting permission for his/her child or\n children to access the various Services provided, " +
"including, but not limited to, message boards, email, and/or instant messaging. It is the parent's and/or\n legal " +
"guardian's responsibility to determine whether any of the Services and/or content provided are age-appropriate for his/her child.\n</p>";
myHtmlText += ..... there are more characters in between, I can't add them all because of the character limit in stackoverflow
myHtmlText += "<p> " +
"Should you intend to create or to join any service, receive or request any such news, messages, " +
"alerts or other information from our Services concerning healthcare, treatment, devices, companies, stock " +
"quotes, investments or securities, please review the above Sections Warranty Disclaimers and Limitations of Liability again. In addition, for this " +
"</p>";
return myHtmlText;
}
Upto this everything works fine.
Now if I add just one word to myHtmlText, (In addition, for this particalur "</p>") the label text becomes invisible. Though the label border is visible. Is there some maximum content size? I couldn't find anything about it when I searched.
What am I doing wrong here? Any help is appreciated...
You need to use UITextView with scrolling enabled and editable/selected disabled (instead of UIScrollView & Content view & UILabel).