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

Sanket slc history #712

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 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
dca4657
WIP(slc) Sanket's latest version for slc with state history
Jan 24, 2022
759fe68
fix(slc) history can be omitted in contract archives
Jan 24, 2022
b21ce11
fix(slc) Add missing directory for tests in cicero-server
Jan 24, 2022
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
52,751 changes: 45,840 additions & 6,911 deletions package-lock.json

Large diffs are not rendered by default.

202 changes: 193 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 All @@ -276,6 +286,10 @@ require('yargs')
describe: 'path to the JSON state',
type: 'string'
});
yargs.option('party', {
describe: 'party which triggers the contract',
type: 'string'
});
yargs.option('currentTime', {
describe: 'set current time',
type: 'string',
Expand Down Expand Up @@ -304,7 +318,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.party, argv.currentTime, argv.utcOffset, options)
.then((result) => {
if(result) {Logger.info(JSON.stringify(result));}
})
Expand All @@ -320,6 +334,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 All @@ -342,6 +360,10 @@ require('yargs')
describe: 'path to the JSON state',
type: 'string'
});
yargs.option('party', {
describe: 'party which invokes the contract',
type: 'string'
});
yargs.option('currentTime', {
describe: 'set current time',
type: 'string',
Expand Down Expand Up @@ -369,7 +391,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.party, argv.currentTime, argv.utcOffset, options)
.then((result) => {
if(result) {Logger.info(JSON.stringify(result));}
})
Expand All @@ -385,6 +407,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 All @@ -399,6 +425,10 @@ require('yargs')
describe: 'path to the parameters',
type: 'string'
});
yargs.option('party', {
describe: 'party which initializes the contract',
type: 'string'
});
yargs.option('currentTime', {
describe: 'initialize with this current time',
type: 'string',
Expand Down Expand Up @@ -427,7 +457,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.party, argv.currentTime, argv.utcOffset, options)
.then((result) => {
if(result) {Logger.info(JSON.stringify(result));}
})
Expand Down Expand Up @@ -499,6 +529,53 @@ 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('instantiator', {
describe: 'name of the instantiator',
type: 'string'
});
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, argv.instantiator, 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 +618,56 @@ 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 party/signatory signing the contract',
type: 'string'
});
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 +696,63 @@ 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('party', {
describe: 'party which exports the 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.party, 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