accordproject / template-archive

Smart Legal Contracts & Templating System
https://accordproject.org/projects/cicero/
Apache License 2.0
281 stars 119 forks source link

feat(cicero-cli): add --data option to trigger cmd #682

Closed martinhalford closed 3 years ago

martinhalford commented 3 years ago

Closes #681

Changes

Flags

Example Usage

cicero trigger --template ./hello-world --data ./hello-world/data.json 
cicero initialize  --template ./hello-world --data ./hello-world/data.json 
cicero invoke  --template ./hello-world --clauseName default --params ./hello-world/params.json --state ./hello-world/state.json --data ./hello-world/data.json
martinhalford commented 3 years ago

OK. Fair call. I'll add to those too.

martinhalford commented 3 years ago

@jeromesimeon @mttrbrts - I've refactored so that cicero invoke and cicero initialize both accept a --data option now too.

I've had to make some significant changes to the validateInvokeArgs, validateTriggerArgs & validateInitializeArgs to handle the scenario where either the--sample option is provided --OR-- the --data option is provided.

I've tried to ensure that, where needed, the logic looks for defaultSample, defaultData, defaultParams or defaultState.

Please let me know if you can see any issues.

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.2%) to 97.039% when pulling 9dffcde8de6360890d29fac846e303a5418ebc33 on beNEXT-io:add-data-option-to-trigger-cmd into 01f5393dd3075512d688844773f7a3b871062135 on accordproject:master.

martinhalford commented 3 years ago

@jeromesimeon - Fixed a small logic bug in validateInvokeArgs which was causing the code to pickup defaultState and defaultParams when these options had been passed in. Apologies for the many commits.

martinhalford commented 3 years ago

@jeromesimeon Superseded by https://github.com/accordproject/cicero/pull/685 which is a cleaned up new PR based on this PR.