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 archive #679

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
766 changes: 734 additions & 32 deletions package-lock.json

Large diffs are not rendered by default.

146 changes: 137 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 @@ -187,7 +188,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 @@ -221,12 +223,22 @@ 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', {
describe: 'path to the contract text',
type: 'string'
type: 'string',
default: null,
});
yargs.option('data', {
describe: 'path to JSON data',
type: 'string',
default: null,
});
yargs.option('request', {
describe: 'path to the JSON request',
Expand Down Expand Up @@ -264,7 +276,7 @@ require('yargs')
offline: argv.offline,
warnings: argv.warnings,
};
return Commands.trigger(argv.template, argv.sample, 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 @@ -280,9 +292,19 @@ 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'
type: 'string',
default: null,
});
yargs.option('data', {
describe: 'path to JSON data',
type: 'string',
default: null,
});
yargs.option('clauseName', {
describe: 'the name of the clause to invoke',
Expand Down Expand Up @@ -323,7 +345,7 @@ require('yargs')
offline: argv.offline,
warnings: argv.warnings,
};
return Commands.invoke(argv.template, argv.sample, 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 @@ -339,9 +361,19 @@ 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'
type: 'string',
default: null,
});
yargs.option('data', {
describe: 'path to JSON data',
type: 'string',
default: null,
});
yargs.option('params', {
describe: 'path to the parameters',
Expand Down Expand Up @@ -375,7 +407,7 @@ require('yargs')
offline: argv.offline,
warnings: argv.warnings,
};
return Commands.initialize(argv.template, argv.sample, 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 @@ -425,6 +457,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 @@ -495,6 +570,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