contractpendev / contractpen-work-client

NodeJS Client for ContractPen
https://contractpen.com/
Apache License 2.0
2 stars 1 forks source link

Generate text from an Accord Clause template when given data as input #1

Open contractpendev opened 5 years ago

contractpendev commented 5 years ago

Hi ! Please read and understand what this file does before starting any task https://github.com/contractpendev/contractpen_node_client/blob/master/src/services/SetupClient.coffee and also better to read and understand the existing code base. Refer to Accord Project https://www.accordproject.org/ Ergo API https://docs.accordproject.org/docs/ergo-api.html Cicero API https://docs.accordproject.org/docs/cicero-api.html


If you are interested in the following technologies then there will be a series of tasks like this one. If your interested in Coffeescript, Legal Contracts on Accord Project https://www.accordproject.org/, eventually deployment to Blockchain. The first task starts small.

This project contractpen_node_client needs to be adjusted to add the function of generating text from a Accord Cicero template when given the data as input. This is done by using the Accord Cicero javascript API.

The task here is to create a new command so that when the following is typed at the dos prompt (or Linux or MacOSX prompt), it should then output the text of the Cicero template as filled with the input json files data. We assume a cicero project directory already exists with all the files downloaded.

What is a cicero project directory? It is for example the hello world template https://github.com/accordproject/cicero-template-library/tree/master/src/helloworld

run template <input json file> <directory of cicero project>

Let me given you an example.

run template datafile.json clauseprojectdirectoryforhelloworld

If in the above, datafile.json contains the data and clauseprojectdirectoryforhelloworld is a folder containing the NodeJS cicero project, then it should output the text of the template correctly with the data inserted into the template by using the Accord Project API's.

An example in coffeescript is given here. To explain, testLatePenaltyInput is the JSON input which you should read from , the directory is the and clause.generateText() generates the text which should then be outputted to the console.

Comedy = require 'comedy'
Awilix = require 'awilix'
Setup = require './Setup'

Template = require('@accordproject/cicero-core').Template
Clause = require('@accordproject/cicero-core').Clause
Engine = require('@accordproject/cicero-engine').Engine

# This function is NOT in use, just here for demonstration purpose
testClauseTemplate = ->
  testLatePenaltyInput = {
    "$class": "org.accordproject.latedeliveryandpenalty.LateDeliveryAndPenaltyClause",
    "forceMajeure": true,
    "penaltyDuration": {
        "$class": "org.accordproject.time.Duration",
        "amount": 537704789,
        "unit": "hours"
    },
    "penaltyPercentage": 160.789,
    "capPercentage": 63.475,
    "termination": {
        "$class": "org.accordproject.time.Duration",
        "amount": 4149649232,
        "unit": "minutes"
    },
    "fractionalPart": "seconds",
    "clauseId": "427c99b0-6df4-11e8-bb3b-67a2e79acc24"
  }

  template = await Template.fromDirectory('C:\\home\\projects\\ContractPen\\cicero-template-library\\src\\latedeliveryandpenalty')
  clause = new Clause(template)
  clause.setData testLatePenaltyInput
  n1 = clause.generateText()
  console.log n1

For example if this above example was adjusted for the Accord Cicero hello world template, it would be as follows. Note the clauseId is required.

testClauseTemplate = ->
  testLatePenaltyInput = {
    "$class": "org.accordproject.helloworld.HelloWorldClause",
    "name": "Philip",
    "clauseId": "427c99b0-6df4-11e8-bb3b-67a2e79acc24"
  }

  template = await Template.fromDirectory('C:\\home\\projects\\contractpen_node_client\\testcicerofolder')
  clause = new Clause(template)
  clause.setData testLatePenaltyInput
  n1 = clause.generateText()
  console.log n1

For me, this outputs the following which is what I expected, the template was filled with the data from the JSON.

C:\home\projects\contractpen_node_client>call npm run compile

> contractpen_node_client@1.0.0 compile C:\home\projects\contractpen_node_client
> coffee --compile src/

6:05:04 PM - info: Compiling Ergo logic
Name of the person to greet: "Philip". Thank you!

C:\home\projects\contractpen_node_client>

The task is to add a new command so that this text can be outputted to the console when the program is run from command line with parameters. You can see existing commands for example in

https://github.com/contractpendev/contractpen_node_client/blob/master/src/services/SetupClient.coffee

    program.usage('deploy <guid> <dir>').command('deploy <guid> <dir>').action (guid, directoryToCreate, cmd) =>

Check that the following are true.

run template <input json file> <directory of cicero project>
gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.09 ETH (17.62 USD @ $195.75/ETH) attached to it.

contractpendev commented 5 years ago

.... contact me if you would like to work on issue

PumpkingWok commented 5 years ago

Hi @contractpendev, is this issue still open ? I would be interested to work in it. Thanks in advance.

PumpkingWok commented 5 years ago

Hi @contractpendev, I have just marked the issue as started. If someone is already working in it I can stop the work without problem, let me know. Thanks.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 6 months, 1 week from now. Please review their action plans below:

1) michaelnetbiz has started work.

My work on this issue will consist in the following tasks:

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 5 years ago

@michaelnetbiz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

michaelnetbiz commented 5 years ago

I'm still working on this issue. WIP pull request submitted here. Thanks!

gitcoinbot commented 5 years ago

@michaelnetbiz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

contractpendev commented 5 years ago

Hello, Sorry I was away in Japan for a holiday and came back recently, let me take a look now.

contractpendev commented 5 years ago

Ok hi then who is working on the issue ? there seems to be two accounts, michaelnetbiz and PumpkingWok, from what I see there is michaelnetbiz with a fork and a work in progress?

PumpkingWok commented 5 years ago

Hi @contractpendev, I have left the issue some days ago, cause not reply. I think that @michaelnetbiz is working in it !! Thanks

michaelnetbiz commented 5 years ago

Hi to you both. Yes, I've been working to update the template CLI command run asynchronously, addressing at this checklist item:

  1. Make sure that async await is used correctly so that all is done asynchronously without blocking.

Tonight (I'm UTC-4), I'll submit a PR with jasmine specs covering the previous PR.

gitcoinbot commented 5 years ago

@michaelnetbiz Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

michaelnetbiz commented 5 years ago

Hi @contractpendev, I've submitted my work for your review -- the transaction is taking quite a while to process.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 0.09 ETH (18.07 USD @ $200.83/ETH) has been submitted by:

  1. @michaelnetbiz

@contractpendev please take a look at the submitted work:


rmshea commented 5 years ago

Hey @contractpendev, Ryan from Gitcoin here, quickly checking in. Looks like @michaelnetbiz has submitted some work to review!

contractpendev commented 5 years ago

Hello Michael, Sorry I'm a little slow to get back to you, as just released a new version of this website https://contractpen.com/ today and then was quite busy getting it for release. Will get back to you soon. Philip

frankchen07 commented 5 years ago

hey @contractpendev - Frank from Gitcoin here, looping back to see how your schedule looks to checkout the PR by @michaelnetbiz! :)

contractpendev commented 5 years ago

How can I accept this work? Do I need to merge it or can I accept it without a merge?

contractpendev commented 5 years ago

@frankchen07 How can I accept this work? Do I need to merge it or can I accept it without a merge?

frankchen07 commented 5 years ago

hey @contractpendev - you can go here: https://gitcoin.co/issue/contractpendev/contractpen_node_client/1/1229 to see @michaelnetbiz's PR. It looks like this:

screen shot 2018-11-21 at 15 06 01

The link should lead you here: https://github.com/contractpendev/contractpen_node_client/pull/7

You can review the PR make sure it's to your liking, and merge it. Then you can return to https://gitcoin.co/issue/contractpendev/contractpen_node_client/1/1229 and hit the "Payout Bounty button" when you're ready to payout for the PR.

CPSTL commented 5 years ago

Hey @frankchen07 and @contractpendev ! Just checking in to see if the PR has been reviewed and/or merged? If not, what needs to get done in order for it to get merged and paid out?

contractpendev commented 5 years ago

I don't want to accept the pull request BUT I want to payout, how do I do that.

contractpendev commented 5 years ago

As far as I can get to trying to payout is here:

Generate Text From An Accord Clause Template When Given Data As Input 0.09 ETH 12.44 USD Funder Address: 0x(hidden) Ready to Pay? Set Your Metamask to this address!

Why do I need to set it to that address?