Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: smart legal contract (.slc) format with contract signing #698

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7bf6dae
chore(dep) Upgrade to latest dev version with CiceroMark 0.4
jeromesimeon Oct 27, 2021
5412758
refactor(core) Clearer separation between contract template and contr…
jeromesimeon Jun 15, 2021
f7c3dcf
refactor(core) Rename instance classes
jeromesimeon Jun 16, 2021
81fa7f5
feature(instance) Adjust API, passing metadata to the instance
jeromesimeon Jun 19, 2021
4e250d0
feature(slc) Initial support for creating a smart legal contract archive
jeromesimeon Jun 19, 2021
14378e9
fix(slc) Add contract data to .slc archive
jeromesimeon Jun 19, 2021
330252e
feature(core) Distinguish between template and instance metadata
jeromesimeon Jun 20, 2021
f426bb3
chore(slc) Some basic testing for slc archives creation
jeromesimeon Jun 22, 2021
60e6748
feature(slc) Allow triggers on smart legal contracts
jeromesimeon Jun 22, 2021
cc5984b
feature(slc) Add invoke and initialization support for smart legal co…
jeromesimeon Jun 22, 2021
dab36c9
feature(slc) Export capability for smart legal contracts
jeromesimeon Jun 30, 2021
24fd02e
chore(build) Remove lib from gitignore for new package
jeromesimeon Jun 30, 2021
bafc232
feat(*): contract instance signing and verification
sanketshevkar Aug 16, 2021
622ffba
test(cli): test for signing contract
sanketshevkar Aug 17, 2021
b4805f6
test(cli): contract signatures verification
sanketshevkar Aug 18, 2021
e88b61d
refactor(*): signed slc name and contract instance error
sanketshevkar Aug 18, 2021
554ee04
test(core): failing test cases for contract signature verification
sanketshevkar Aug 19, 2021
e31e2fa
refactor(*): removal of commented code and logger message correction …
sanketshevkar Aug 23, 2021
c1d9dc1
fix(test) Fixes failing negative tests for verify signature
jeromesimeon Aug 24, 2021
4919999
test(cicero-cli): failing tests corrected
Sep 20, 2021
59b9865
refactor(cli): removal of duplicate verify command
Sep 22, 2021
72ee296
fix(build) Add longer timeout for tests
jeromesimeon Oct 27, 2021
de62bc8
chore(dep) Upgrade Concerto/MdTransform/Ergo to latest dev versions
jeromesimeon Oct 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26,053 changes: 19,285 additions & 6,768 deletions package-lock.json

Large diffs are not rendered by default.

183 changes: 174 additions & 9 deletions packages/cicero-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ require('yargs')
});
yargs.option('format', {
describe: 'target format',
type: 'string'
type: 'string',
default: 'markdown'
});
yargs.option('unquoteVariables', {
describe: 'remove variables quoting',
Expand Down Expand Up @@ -148,11 +149,15 @@ require('yargs')
}
})

.command('verify', 'verify the template signatures of the template author/developer', (yargs) => {
.command('verify', 'verify the signatures on template or contract instances', (yargs) => {
yargs.option('template', {
describe: 'path to the template',
type: 'string'
});
yargs.option('contract', {
describe: 'path to a smart legal contract slc file',
type: 'string'
});
yargs.option('warnings', {
describe: 'print warnings',
type: 'boolean',
Expand All @@ -168,9 +173,9 @@ require('yargs')
const options = {
warnings: argv.warnings,
};
return Commands.verify(argv.template, options)
return Commands.verify(argv.template, argv.contract, options)
.then((result) => {
if(result) {Logger.info(`Author/developer's signature for ${argv.template} template is verified`);}
if(result) {Logger.info('all signatures verified');}
})
.catch((err) => {
Logger.error(err.message);
Expand Down Expand Up @@ -221,7 +226,8 @@ require('yargs')
});
yargs.option('format', {
describe: 'target format',
type: 'string'
type: 'string',
default: 'markdown'
});
yargs.option('unquoteVariables', {
describe: 'remove variables quoting',
Expand Down Expand Up @@ -255,7 +261,11 @@ require('yargs')
})
.command('trigger', 'send a request to the contract', (yargs) => {
yargs.option('template', {
describe: 'path to the template',
describe: 'path to a template',
type: 'string'
});
yargs.option('contract', {
describe: 'path to a smart legal contract',
type: 'string'
});
yargs.option('sample', {
Expand Down Expand Up @@ -304,7 +314,7 @@ require('yargs')
offline: argv.offline,
warnings: argv.warnings,
};
return Commands.trigger(argv.template, argv.sample, argv.data, argv.request, argv.state, argv.currentTime, argv.utcOffset, options)
return Commands.trigger(argv.template, argv.contract, argv.sample, argv.data, argv.request, argv.state, argv.currentTime, argv.utcOffset, options)
.then((result) => {
if(result) {Logger.info(JSON.stringify(result));}
})
Expand All @@ -320,6 +330,10 @@ require('yargs')
describe: 'path to the template',
type: 'string'
});
yargs.option('contract', {
describe: 'path to a smart legal contract',
type: 'string'
});
yargs.option('sample', {
describe: 'path to the contract text',
type: 'string',
Expand Down Expand Up @@ -369,7 +383,7 @@ require('yargs')
offline: argv.offline,
warnings: argv.warnings,
};
return Commands.invoke(argv.template, argv.sample, argv.data, argv.clauseName, argv.params, argv.state, argv.currentTime, argv.utcOffset, options)
return Commands.invoke(argv.template, argv.contract, argv.sample, argv.data, argv.clauseName, argv.params, argv.state, argv.currentTime, argv.utcOffset, options)
.then((result) => {
if(result) {Logger.info(JSON.stringify(result));}
})
Expand All @@ -385,6 +399,10 @@ require('yargs')
describe: 'path to the template',
type: 'string'
});
yargs.option('contract', {
describe: 'path to a smart legal contract',
type: 'string'
});
yargs.option('sample', {
describe: 'path to the contract text',
type: 'string',
Expand Down Expand Up @@ -427,7 +445,7 @@ require('yargs')
offline: argv.offline,
warnings: argv.warnings,
};
return Commands.initialize(argv.template, argv.sample, argv.data, argv.params, argv.currentTime, argv.utcOffset, options)
return Commands.initialize(argv.template, argv.contract, argv.sample, argv.data, argv.params, argv.currentTime, argv.utcOffset, options)
.then((result) => {
if(result) {Logger.info(JSON.stringify(result));}
})
Expand Down Expand Up @@ -499,6 +517,49 @@ require('yargs')
return;
}
})
.command('instantiate', 'create a smart legal contract instance', (yargs) => {
yargs.option('template', {
describe: 'path to the template',
type: 'string'
});
yargs.option('data', {
describe: 'path to the contract data',
type: 'string'
});
yargs.option('target', {
describe: 'the target language of the archive',
type: 'string',
default: 'ergo'
});
yargs.option('output', {
describe: 'file name for new archive',
type: 'string',
default: null
});
yargs.option('warnings', {
describe: 'print warnings',
type: 'boolean',
default: false
});
}, (argv) => {
if (argv.verbose) {
Logger.info(`create an archive for ${argv.template}`);
}

try {
argv = Commands.validateInstantiateArgs(argv);
const options = {
warnings: argv.warnings,
};
return Commands.instantiate(argv.template, argv.data, argv.target, argv.output, options)
.catch((err) => {
Logger.error(err.message);
});
} catch (err){
Logger.error(err.message);
return;
}
})
.command('compile', 'generate code for a target platform', (yargs) => {
yargs.option('template', {
describe: 'path to the template',
Expand Down Expand Up @@ -541,6 +602,57 @@ require('yargs')
return;
}
})
.command('sign', 'sign a contract', (yargs) => {
yargs.option('contract', {
describe: 'path to a smart legal contract slc file',
type: 'string'
});
yargs.option('keystore', {
describe: 'p12 keystore path',
type: 'string',
default: null
});
yargs.option('passphrase', {
describe: 'p12 keystore passphrase',
type: 'string',
default: null
});
yargs.option('signatory', {
describe: 'name of the signatory',
type: 'string',
default: null
});
yargs.option('output', {
describe: 'file name for new archive',
type: 'string',
default: null
});
yargs.option('warnings', {
describe: 'print warnings',
type: 'boolean',
default: false
});
}, (argv) => {
if (argv.verbose) {
Logger.info(`sign contract ${argv.contract} for signatory ${argv.signatory}`);
}

try {
argv = Commands.validateSignArgs(argv);
const options = {
warnings: argv.warnings,
};
return Commands.sign(argv.contract, argv.keystore, argv.passphrase, argv.signatory, argv.output, options)
.then((result) => {
if(result) {Logger.info('contract has been successfully signed');}
})
.catch((err) => {
Logger.error(err.message);
});
} catch (err){
Logger.error(err.message);
}
})
.command('get', 'save local copies of external dependencies', (yargs) => {
yargs.option('template', {
describe: 'path to the template',
Expand Down Expand Up @@ -569,6 +681,59 @@ require('yargs')
return;
}
})
.command('export', 'export smart legal contract to a different format', (yargs) => {
yargs.option('contract', {
describe: 'path to a smart legal contract',
type: 'string'
});
yargs.option('output', {
describe: 'path to the output file',
type: 'string'
});
yargs.option('currentTime', {
describe: 'set current time',
type: 'string',
default: null
});
yargs.option('utcOffset', {
describe: 'set UTC offset',
type: 'number',
default: null
});
yargs.option('format', {
describe: 'target format',
type: 'string',
default: 'markdown'
});
yargs.option('warnings', {
describe: 'print warnings',
type: 'boolean',
default: false
});
}, (argv) => {
if (argv.verbose) {
Logger.info(`export contract to format ${argv.format}`);
}

try {
argv = Commands.validateExportArgs(argv);
const options = {
offline: true,
unquoteVariables: true,
warnings: argv.warnings,
format: argv.format,
};
return Commands.export(argv.contract, argv.output, argv.currentTime, argv.utcOffset, options)
.then((result) => {
})
.catch((err) => {
Logger.error(err.message);
});
} catch (err){
Logger.error(err.message);
return;
}
})
.option('verbose', {
alias: 'v',
default: false
Expand Down
Loading