-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
executable file
·130 lines (128 loc) · 5.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env node
"use strict";
const {deployPermission, checkPermissions, deploySet, deployService} = require("./tools");
const clargs = require("yargs")
.usage('Usage: $0 <command> [options]')
.command("deploypermission", "Deploy simple Secret Store permissioning contracts", (yargs) => {
return yargs
.option('contract', {
type: 'string',
desc: "Which contract to deploy. Please refer to it by name. E.g.: \"PermissioningDynamic\", or just simply \"Dynamic\". Case sensitive. It is used for JSON ABI file lookup.",
choices: ['PermissioningDynamic', 'Dynamic', 'PermissioningNoDoc', 'NoDoc', 'PermissioningStatic', 'Static', 'PermissioningFireAndForget', 'FireAndForget'],
demandOption: true,
alias: "c"
})
.option('docid', {
type: 'string',
desc: "The document's ID to passed to the permissioning contract constructor, if it has any. It should be a exadec address starting with 0x",
demandOption: false,
alias: "d",
default: undefined
})
.option('accounts', {
type: 'array',
desc: "Permissioned accounts to pass to the permissioning contract constructor.",
demandOption: false,
alias: "acc",
default: []
})
.option('from', {
type: 'string',
desc: "Deployer account. Defaults to the first account of the local accounts list.",
demandOption: false,
alias: "f",
default: undefined
})
.option('rpc', {
type: 'string',
desc: "HTTP RPC API endpoint.",
demandOption: false,
alias: "r",
default: "http://localhost:8545"
})
}, (vargs) => {
deployPermission(vargs);
})
.command("deployservice", "Deploy Secret Store service contracts", (yargs) => {
return yargs
.option('contract', {
type: 'string',
desc: "Which contract to deploy. Please refer to it by name. E.g.: \"SecretStoreDocumentKeyStoreService\", or just simply \"DocumentKeyStoreService\". Case sensitive. It is used for JSON ABI file lookup.",
choices: ['SecretStoreDocumentKeyStoreService', 'DocumentKeyStoreService', 'SecretStoreDocumentKeyShadowRetrievalService', 'DocumentKeyShadowRetrievalService', 'SecretStoreServerKeyRetrievalService', 'ServerKeyRetrievalService', 'SecretStoreServerKeyGenerationService', 'ServerKeyGenerationService'],
demandOption: false,
default: undefined,
alias: "c"
})
.option('serverSet', {
type: 'string',
desc: "Address of the key server set (nodes) contract.",
demandOption: true,
alias: ["s", "k","address", "a", "serverset", "keyServerSet"],
default: undefined
})
.option('from', {
type: 'string',
desc: "Deployer account. Defaults to the first account of the local accounts list.",
demandOption: false,
alias: "f",
default: undefined
})
.option('rpc', {
type: 'string',
desc: "HTTP RPC API endpoint.",
demandOption: false,
alias: "r",
default: "http://localhost:8545"
})
}, (vargs) => {
deployService(vargs);
})
.command("deployset", "Deploy Secret Store node-set contract", (yargs) => {
return yargs.option('from', {
type: 'string',
desc: "Deployer account. Defaults to the first account of the local accounts list.",
demandOption: false,
alias: "f",
default: undefined
})
.option('rpc', {
type: 'string',
desc: "HTTP RPC API endpoint.",
demandOption: false,
alias: "r",
default: "http://localhost:8545"
})
}, (vargs) => {
deploySet(vargs);
})
.command("checkpermissions", "Check permission of accounts for deployed contracts.", (yargs) => {
return yargs.option('address', {
type: 'string',
desc: "The address of the permissioning contract.",
demandOption: true,
alias: "a"
})
.option('docid', {
type: 'string',
desc: "The document's ID to check permissions for.",
demandOption: true,
alias: "d"
})
.option('accounts', {
type: 'array',
desc: "Accounts to check for the given document ID. Multiple can be given which are checked individually.",
demandOption: true,
alias: "acc"
})
.option('rpc', {
type: 'string',
desc: "HTTP RPC API endpoint. Defaults to http://localhost:8545",
demandOption: false,
alias: "r",
default: "http://localhost:8545"
})
}, (vargs) => {
checkPermissions(vargs);
})
.demandCommand(1, 'You need to give at least a command.')
.argv;