@sentio/sdk 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/cli.js +123 -178
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/commands/run-create.d.ts +1 -0
- package/lib/cli/commands/run-create.js +43 -0
- package/lib/cli/commands/run-create.js.map +1 -0
- package/lib/cli/commands/run-login.d.ts +1 -0
- package/lib/cli/commands/run-login.js +77 -0
- package/lib/cli/commands/run-login.js.map +1 -0
- package/lib/cli/config.d.ts +2 -1
- package/lib/cli/config.js +13 -11
- package/lib/cli/config.js.map +1 -1
- package/lib/target-ethers-sentio/codegen.js +27 -11
- package/lib/target-ethers-sentio/codegen.js.map +1 -1
- package/lib/test/codegen.test.js +9 -7
- package/lib/test/codegen.test.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/cli.ts +122 -179
- package/src/cli/commands/run-create.ts +36 -0
- package/src/cli/commands/run-login.ts +70 -0
- package/src/cli/config.ts +11 -9
- package/src/target-ethers-sentio/codegen.ts +26 -12
- package/src/test/abis/evm/CommitmentPool.json +1034 -0
- package/src/test/codegen.test.ts +10 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/target-ethers-sentio/codegen.ts"],"names":[],"mappings":";;;AAAA,yCAMkB;AAElB,2FAAsF;AACtF,mEAA4E;AAC5E,gEAA0E;AAC1E,2CAAqE;AAErE,SAAgB,YAAY,CAAC,QAAkB;IAC7C,OAAO;+BACsB,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE;+BAC3B,QAAQ,CAAC,IAAI;GACzC,CAAA;AACH,CAAC;AALD,oCAKC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,MAAM,MAAM,GAAG;IACb,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,iCAAqB,CAAC,CAAC,IAAI,CAAC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|
|
33
33
|
describe('Test EVM codegen', () => {
|
|
34
34
|
const codeGenFolder = fs.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'codegen_test'));
|
|
35
35
|
jest.setTimeout(20000);
|
|
36
|
-
|
|
36
|
+
// TODO make sure code could be compile
|
|
37
|
+
test('code gen for evm', async () => {
|
|
38
|
+
console.log('source code generated to ' + codeGenFolder);
|
|
37
39
|
await (0, build_1.codeGenEthersProcessor)(path_1.default.join(__dirname, 'abis/evm'), 'lib/target-ethers-sentio', `${codeGenFolder}/internal`);
|
|
38
40
|
expect(fs.existsSync(codeGenFolder)).toEqual(true);
|
|
39
|
-
expect(fs.readdirSync(codeGenFolder).length).toEqual(
|
|
40
|
-
});
|
|
41
|
-
afterAll(() => {
|
|
42
|
-
if (fs.existsSync(codeGenFolder)) {
|
|
43
|
-
fs.rmSync(codeGenFolder, { recursive: true, force: true });
|
|
44
|
-
}
|
|
41
|
+
expect(fs.readdirSync(codeGenFolder).length).toEqual(3);
|
|
45
42
|
});
|
|
43
|
+
// afterAll(() => {
|
|
44
|
+
// if (fs.existsSync(codeGenFolder)) {
|
|
45
|
+
// fs.rmSync(codeGenFolder, { recursive: true, force: true })
|
|
46
|
+
// }
|
|
47
|
+
// })
|
|
46
48
|
});
|
|
47
49
|
//# sourceMappingURL=codegen.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.test.js","sourceRoot":"","sources":["../../src/test/codegen.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAqD;AACrD,gDAAuB;AACvB,uCAAwB;AACxB,4CAAmB;AAEnB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,aAAa,GAAG,EAAE,CAAC,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC,CAAA;IAE5E,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAEtB,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"codegen.test.js","sourceRoot":"","sources":["../../src/test/codegen.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAqD;AACrD,gDAAuB;AACvB,uCAAwB;AACxB,4CAAmB;AAEnB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,aAAa,GAAG,EAAE,CAAC,WAAW,CAAC,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC,CAAA;IAE5E,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAEtB,uCAAuC;IACvC,IAAI,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,2BAA2B,GAAG,aAAa,CAAC,CAAA;QAExD,MAAM,IAAA,8BAAsB,EAC1B,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EAChC,0BAA0B,EAC1B,GAAG,aAAa,WAAW,CAC5B,CAAA;QACD,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAClD,MAAM,CAAC,EAAE,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;IAEF,mBAAmB;IACnB,wCAAwC;IACxC,iEAAiE;IACjE,MAAM;IACN,KAAK;AACP,CAAC,CAAC,CAAA","sourcesContent":["import { codeGenEthersProcessor } from '../cli/build'\nimport path from 'path'\nimport * as fs from 'fs'\nimport os from 'os'\n\ndescribe('Test EVM codegen', () => {\n const codeGenFolder = fs.mkdtempSync(path.join(os.tmpdir(), 'codegen_test'))\n\n jest.setTimeout(20000)\n\n // TODO make sure code could be compile\n test('code gen for evm', async () => {\n console.log('source code generated to ' + codeGenFolder)\n\n await codeGenEthersProcessor(\n path.join(__dirname, 'abis/evm'),\n 'lib/target-ethers-sentio',\n `${codeGenFolder}/internal`\n )\n expect(fs.existsSync(codeGenFolder)).toEqual(true)\n expect(fs.readdirSync(codeGenFolder).length).toEqual(3)\n })\n\n // afterAll(() => {\n // if (fs.existsSync(codeGenFolder)) {\n // fs.rmSync(codeGenFolder, { recursive: true, force: true })\n // }\n // })\n})\n"]}
|
package/package.json
CHANGED
package/src/cli/cli.ts
CHANGED
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
import commandLineArgs from 'command-line-args'
|
|
4
4
|
import commandLineUsage from 'command-line-usage'
|
|
5
5
|
import fs from 'fs'
|
|
6
|
-
import https from 'https'
|
|
7
|
-
import http from 'http'
|
|
8
6
|
import path from 'path'
|
|
9
7
|
|
|
10
8
|
import yaml from 'js-yaml'
|
|
11
|
-
import { EVM,
|
|
12
|
-
import { WriteKey } from './key'
|
|
9
|
+
import { EVM, finalizeHost, FinalizeProjectName, SentioProjectConfig } from './config'
|
|
13
10
|
import { uploadFile } from './upload'
|
|
14
11
|
import chalk from 'chalk'
|
|
15
12
|
import { buildProcessor } from './build'
|
|
13
|
+
import { runLogin } from './commands/run-login'
|
|
14
|
+
import { runCreate } from './commands/run-create'
|
|
16
15
|
|
|
17
16
|
const mainDefinitions = [{ name: 'command', defaultOption: true }]
|
|
18
17
|
const mainOptions = commandLineArgs(mainDefinitions, {
|
|
@@ -20,198 +19,142 @@ const mainOptions = commandLineArgs(mainDefinitions, {
|
|
|
20
19
|
})
|
|
21
20
|
const argv = mainOptions._unknown || []
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
const packageJson = path.join(pwd, 'package.json')
|
|
31
|
-
if (!fs.existsSync(packageJson)) {
|
|
32
|
-
console.error('package.json not found, please run this command in the root of your project')
|
|
33
|
-
process.exit(1)
|
|
34
|
-
}
|
|
22
|
+
if (mainOptions.command === 'login') {
|
|
23
|
+
runLogin(argv)
|
|
24
|
+
} else if (mainOptions.command === 'create') {
|
|
25
|
+
runCreate(argv)
|
|
26
|
+
} else {
|
|
27
|
+
// For all the commands that need read project configs
|
|
28
|
+
// TODO move them to their own modules
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
// Process configs
|
|
31
|
+
let processorConfig: SentioProjectConfig = { host: '', project: '', source: '', build: true, targets: [] }
|
|
32
|
+
// Fist step, read from project yaml file
|
|
33
|
+
try {
|
|
34
|
+
console.log(chalk.blue('Loading Process config'))
|
|
35
|
+
// TODO correctly located sentio.yaml
|
|
36
|
+
const pwd = process.cwd()
|
|
37
|
+
const packageJson = path.join(pwd, 'package.json')
|
|
38
|
+
if (!fs.existsSync(packageJson)) {
|
|
39
|
+
console.error('package.json not found, please run this command in the root of your project')
|
|
40
|
+
process.exit(1)
|
|
41
|
+
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (processorConfig.build === undefined) {
|
|
48
|
-
processorConfig.build = true
|
|
49
|
-
}
|
|
50
|
-
if (!processorConfig.host) {
|
|
51
|
-
processorConfig.host = 'prod'
|
|
52
|
-
}
|
|
43
|
+
const yamlPath = path.join(pwd, 'sentio.yaml')
|
|
44
|
+
if (!fs.existsSync(yamlPath)) {
|
|
45
|
+
console.error('sentio.yaml not found, please create one according to: TODO docs')
|
|
46
|
+
process.exit(1)
|
|
47
|
+
}
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
processorConfig.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
processorConfig.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
processorConfig = yaml.load(fs.readFileSync('sentio.yaml', 'utf8')) as SentioProjectConfig
|
|
50
|
+
if (!processorConfig.project === undefined) {
|
|
51
|
+
console.error('Config yaml must have contain a valid project identifier')
|
|
52
|
+
process.exit(1)
|
|
53
|
+
}
|
|
54
|
+
if (processorConfig.build === undefined) {
|
|
55
|
+
processorConfig.build = true
|
|
56
|
+
}
|
|
57
|
+
if (!processorConfig.host) {
|
|
58
|
+
processorConfig.host = 'prod'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!processorConfig.source) {
|
|
62
|
+
processorConfig.source = 'src/processor.ts'
|
|
63
|
+
}
|
|
64
|
+
if (!processorConfig.targets) {
|
|
65
|
+
console.warn('targets is not defined, use EVM as the default target')
|
|
66
|
+
processorConfig.targets = []
|
|
67
|
+
}
|
|
68
|
+
if (processorConfig.targets.length === 0) {
|
|
69
|
+
// By default evm
|
|
70
|
+
processorConfig.targets.push({ chain: EVM })
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error(e)
|
|
74
|
+
process.exit(1)
|
|
64
75
|
}
|
|
65
|
-
} catch (e) {
|
|
66
|
-
console.error(e)
|
|
67
|
-
process.exit(1)
|
|
68
|
-
}
|
|
69
76
|
|
|
70
|
-
if (mainOptions.command === 'upload') {
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
name: 'help',
|
|
74
|
-
alias: 'h',
|
|
75
|
-
type: Boolean,
|
|
76
|
-
description: 'Display this usage guide.',
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: 'api-key',
|
|
80
|
-
type: String,
|
|
81
|
-
description: '(Optional) Manually provide API key rather than use saved credential',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: 'host',
|
|
85
|
-
description: '(Optional) Override Sentio Host name',
|
|
86
|
-
type: String,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'owner',
|
|
90
|
-
description: '(Optional) Override Project owner',
|
|
91
|
-
type: String,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
name: 'nobuild',
|
|
95
|
-
description: '(Optional) Skip build & pack file before uploading, default false',
|
|
96
|
-
type: Boolean,
|
|
97
|
-
},
|
|
98
|
-
]
|
|
99
|
-
const options = commandLineArgs(optionDefinitions, { argv })
|
|
100
|
-
if (options.help) {
|
|
101
|
-
const usage = commandLineUsage([
|
|
77
|
+
if (mainOptions.command === 'upload') {
|
|
78
|
+
const optionDefinitions = [
|
|
102
79
|
{
|
|
103
|
-
|
|
104
|
-
|
|
80
|
+
name: 'help',
|
|
81
|
+
alias: 'h',
|
|
82
|
+
type: Boolean,
|
|
83
|
+
description: 'Display this usage guide.',
|
|
105
84
|
},
|
|
106
85
|
{
|
|
107
|
-
|
|
108
|
-
|
|
86
|
+
name: 'api-key',
|
|
87
|
+
type: String,
|
|
88
|
+
description: '(Optional) Manually provide API key rather than use saved credential',
|
|
109
89
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
90
|
+
{
|
|
91
|
+
name: 'host',
|
|
92
|
+
description: '(Optional) Override Sentio Host name',
|
|
93
|
+
type: String,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'owner',
|
|
97
|
+
description: '(Optional) Override Project owner',
|
|
98
|
+
type: String,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'nobuild',
|
|
102
|
+
description: '(Optional) Skip build & pack file before uploading, default false',
|
|
103
|
+
type: Boolean,
|
|
104
|
+
},
|
|
105
|
+
]
|
|
106
|
+
const options = commandLineArgs(optionDefinitions, { argv })
|
|
107
|
+
if (options.help) {
|
|
108
|
+
const usage = commandLineUsage([
|
|
109
|
+
{
|
|
110
|
+
header: 'Sentio upload',
|
|
111
|
+
content: 'Upload your project files to Sentio.',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
header: 'Options',
|
|
115
|
+
optionList: optionDefinitions,
|
|
116
|
+
},
|
|
117
|
+
])
|
|
118
|
+
console.log(usage)
|
|
119
|
+
} else {
|
|
120
|
+
if (options.host) {
|
|
121
|
+
processorConfig.host = options.host
|
|
122
|
+
}
|
|
123
|
+
if (options.nobuild) {
|
|
124
|
+
processorConfig.build = false
|
|
125
|
+
}
|
|
126
|
+
finalizeHost(processorConfig)
|
|
127
|
+
FinalizeProjectName(processorConfig, options.owner)
|
|
128
|
+
console.log(processorConfig)
|
|
122
129
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
let apiOverride = undefined
|
|
131
|
+
if (options['api-key']) {
|
|
132
|
+
apiOverride = options['api-key']
|
|
133
|
+
}
|
|
134
|
+
uploadFile(processorConfig, apiOverride)
|
|
126
135
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} else if (mainOptions.command === '
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
name: 'help',
|
|
133
|
-
alias: 'h',
|
|
134
|
-
type: Boolean,
|
|
135
|
-
description: 'Display this usage guide.',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
name: 'api-key',
|
|
139
|
-
type: String,
|
|
140
|
-
description: '(Required) Your API key',
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: 'host',
|
|
144
|
-
description: '(Optional) Override Sentio Host name',
|
|
145
|
-
type: String,
|
|
146
|
-
},
|
|
147
|
-
]
|
|
148
|
-
const options = commandLineArgs(optionDefinitions, { argv })
|
|
149
|
-
|
|
150
|
-
if (options.help || !options['api-key']) {
|
|
136
|
+
} else if (mainOptions.command === 'build') {
|
|
137
|
+
buildProcessor(false, processorConfig.targets)
|
|
138
|
+
} else if (mainOptions.command === 'gen') {
|
|
139
|
+
buildProcessor(true, processorConfig.targets)
|
|
140
|
+
} else {
|
|
151
141
|
const usage = commandLineUsage([
|
|
152
142
|
{
|
|
153
|
-
header: 'Sentio
|
|
154
|
-
content: '
|
|
143
|
+
header: 'Sentio',
|
|
144
|
+
content: 'Login & Manage your project files to Sentio.',
|
|
155
145
|
},
|
|
156
146
|
{
|
|
157
|
-
header: '
|
|
158
|
-
|
|
147
|
+
header: 'Usage',
|
|
148
|
+
content: [
|
|
149
|
+
'sentio $command --help\t\tshow detail usage of specific command',
|
|
150
|
+
'sentio login --api-key=xx\t\tsave credential to local',
|
|
151
|
+
'sentio create\t\t\t\tcreate a template project',
|
|
152
|
+
'sentio upload\t\t\t\tbuild and upload processor to sentio',
|
|
153
|
+
'sentio gen\t\t\t\tgenerate abi',
|
|
154
|
+
'sentio build\t\t\t\tgenerate abi and build',
|
|
155
|
+
],
|
|
159
156
|
},
|
|
160
157
|
])
|
|
161
158
|
console.log(usage)
|
|
162
|
-
} else {
|
|
163
|
-
if (options.host) {
|
|
164
|
-
processorConfig.host = options.host
|
|
165
|
-
}
|
|
166
|
-
FinalizeHost(processorConfig)
|
|
167
|
-
console.log(processorConfig)
|
|
168
|
-
|
|
169
|
-
const url = new URL(processorConfig.host)
|
|
170
|
-
const reqOptions = {
|
|
171
|
-
hostname: url.hostname,
|
|
172
|
-
port: url.port,
|
|
173
|
-
path: '/api/v1/processors/check_key',
|
|
174
|
-
method: 'HEAD',
|
|
175
|
-
headers: {
|
|
176
|
-
'api-key': options['api-key'],
|
|
177
|
-
},
|
|
178
|
-
}
|
|
179
|
-
const h = url.protocol == 'https:' ? https : http
|
|
180
|
-
const req = h.request(reqOptions, (res) => {
|
|
181
|
-
if (res.statusCode == 200) {
|
|
182
|
-
WriteKey(processorConfig.host, options['api-key'])
|
|
183
|
-
console.log(chalk.green('login success'))
|
|
184
|
-
} else {
|
|
185
|
-
console.error(chalk.red('login failed, code:', res.statusCode, res.statusMessage))
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
req.on('error', (error) => {
|
|
190
|
-
console.error(error)
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
req.end()
|
|
194
159
|
}
|
|
195
|
-
} else if (mainOptions.command === 'build') {
|
|
196
|
-
buildProcessor(false, processorConfig.targets)
|
|
197
|
-
} else if (mainOptions.command === 'gen') {
|
|
198
|
-
buildProcessor(true, processorConfig.targets)
|
|
199
|
-
} else {
|
|
200
|
-
const usage = commandLineUsage([
|
|
201
|
-
{
|
|
202
|
-
header: 'Sentio',
|
|
203
|
-
content: 'Login & Upload your project files to Sentio.',
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
header: 'Usage',
|
|
207
|
-
content: [
|
|
208
|
-
'sentio $command --help\t\tshow detail usage of specific command',
|
|
209
|
-
'sentio login --api-key=xx\t\tsave credential to local',
|
|
210
|
-
'sentio upload\t\t\t\tbuild and upload processor to sentio',
|
|
211
|
-
'sentio gen\t\t\t\tgenerate abi',
|
|
212
|
-
'sentio build\t\t\t\tgenerate abi and build',
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
])
|
|
216
|
-
console.log(usage)
|
|
217
160
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import commandLineArgs from 'command-line-args'
|
|
2
|
+
import commandLineUsage from 'command-line-usage'
|
|
3
|
+
|
|
4
|
+
export function runCreate(argv: string[]) {
|
|
5
|
+
const optionDefinitions = [
|
|
6
|
+
{
|
|
7
|
+
name: 'help',
|
|
8
|
+
alias: 'h',
|
|
9
|
+
type: Boolean,
|
|
10
|
+
description: 'Display this usage guide.',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: 'name',
|
|
14
|
+
alias: 'n',
|
|
15
|
+
type: String,
|
|
16
|
+
description: '(Required) Project name',
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
const options = commandLineArgs(optionDefinitions, { argv })
|
|
21
|
+
if (options.help || !options.name) {
|
|
22
|
+
const usage = commandLineUsage([
|
|
23
|
+
{
|
|
24
|
+
header: 'Sentio Create',
|
|
25
|
+
content: 'Create a template project',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
header: 'Options',
|
|
29
|
+
optionList: optionDefinitions,
|
|
30
|
+
},
|
|
31
|
+
])
|
|
32
|
+
console.log(usage)
|
|
33
|
+
} else {
|
|
34
|
+
//
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import commandLineArgs from 'command-line-args'
|
|
2
|
+
import commandLineUsage from 'command-line-usage'
|
|
3
|
+
import { getFinalizedHost } from '../config'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
import https from 'https'
|
|
6
|
+
import http from 'http'
|
|
7
|
+
import { WriteKey } from '../key'
|
|
8
|
+
|
|
9
|
+
export function runLogin(argv: string[]) {
|
|
10
|
+
const optionDefinitions = [
|
|
11
|
+
{
|
|
12
|
+
name: 'help',
|
|
13
|
+
alias: 'h',
|
|
14
|
+
type: Boolean,
|
|
15
|
+
description: 'Display this usage guide.',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'api-key',
|
|
19
|
+
type: String,
|
|
20
|
+
description: '(Required) Your API key',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'host',
|
|
24
|
+
description: '(Optional) Override Sentio Host name',
|
|
25
|
+
type: String,
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
const options = commandLineArgs(optionDefinitions, { argv })
|
|
29
|
+
|
|
30
|
+
if (options.help || !options['api-key']) {
|
|
31
|
+
const usage = commandLineUsage([
|
|
32
|
+
{
|
|
33
|
+
header: 'Sentio Login',
|
|
34
|
+
content: 'Try login to Sentio with your apikey.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
header: 'Options',
|
|
38
|
+
optionList: optionDefinitions,
|
|
39
|
+
},
|
|
40
|
+
])
|
|
41
|
+
console.log(usage)
|
|
42
|
+
} else {
|
|
43
|
+
const host = getFinalizedHost(options.host)
|
|
44
|
+
console.log(chalk.blue('login to ' + host))
|
|
45
|
+
const url = new URL(host)
|
|
46
|
+
const reqOptions = {
|
|
47
|
+
hostname: url.hostname,
|
|
48
|
+
port: url.port,
|
|
49
|
+
path: '/api/v1/processors/check_key',
|
|
50
|
+
method: 'HEAD',
|
|
51
|
+
headers: {
|
|
52
|
+
'api-key': options['api-key'],
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
const h = url.protocol == 'https:' ? https : http
|
|
56
|
+
const req = h.request(reqOptions, (res) => {
|
|
57
|
+
if (res.statusCode == 200) {
|
|
58
|
+
WriteKey(host, options['api-key'])
|
|
59
|
+
console.log(chalk.green('login success'))
|
|
60
|
+
} else {
|
|
61
|
+
console.error(chalk.red('login failed, code:', res.statusCode, res.statusMessage))
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
req.on('error', (error) => {
|
|
66
|
+
console.error(error)
|
|
67
|
+
})
|
|
68
|
+
req.end()
|
|
69
|
+
}
|
|
70
|
+
}
|
package/src/cli/config.ts
CHANGED
|
@@ -6,21 +6,23 @@ export interface SentioProjectConfig {
|
|
|
6
6
|
targets: Target[]
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function
|
|
10
|
-
switch (
|
|
9
|
+
export function getFinalizedHost(host: string): string {
|
|
10
|
+
switch (host) {
|
|
11
11
|
case '':
|
|
12
12
|
case 'prod':
|
|
13
|
-
|
|
14
|
-
break
|
|
13
|
+
return 'https://app.sentio.xyz'
|
|
15
14
|
case 'test':
|
|
16
|
-
|
|
17
|
-
break
|
|
15
|
+
return 'https://test.sentio.xyz'
|
|
18
16
|
case 'staging':
|
|
19
|
-
|
|
20
|
-
break
|
|
17
|
+
return 'https://staging.sentio.xyz'
|
|
21
18
|
case 'local':
|
|
22
|
-
|
|
19
|
+
return 'http://localhost:10000'
|
|
23
20
|
}
|
|
21
|
+
return host
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function finalizeHost(config: SentioProjectConfig) {
|
|
25
|
+
config.host = getFinalizedHost(config.host)
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export function FinalizeProjectName(config: SentioProjectConfig, owner: string | undefined) {
|
|
@@ -125,6 +125,31 @@ export function codeGenSentioFile(contract: Contract): string {
|
|
|
125
125
|
return contract
|
|
126
126
|
}
|
|
127
127
|
`
|
|
128
|
+
const eventsImports = Object.values(contract.events).flatMap((events) => {
|
|
129
|
+
if (events.length === 1) {
|
|
130
|
+
return [`${events[0].name}Event`, `${events[0].name}EventFilter`]
|
|
131
|
+
} else {
|
|
132
|
+
return events.flatMap((e) => [
|
|
133
|
+
`${getFullSignatureAsSymbolForEvent(e)}_Event`,
|
|
134
|
+
`${getFullSignatureAsSymbolForEvent(e)}_EventFilter`,
|
|
135
|
+
])
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const structImports = Object.values(contract.structs).flatMap((structs) => {
|
|
140
|
+
return structs.flatMap((s) => {
|
|
141
|
+
if (!s.structName) {
|
|
142
|
+
return []
|
|
143
|
+
}
|
|
144
|
+
if (s.structName.namespace) {
|
|
145
|
+
return [s.structName.namespace]
|
|
146
|
+
} else {
|
|
147
|
+
return [s.structName.identifier]
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
// dedup namespace
|
|
152
|
+
const uniqueStructImports = [...new Set(structImports)]
|
|
128
153
|
|
|
129
154
|
const imports = createImportsForUsedIdentifiers(
|
|
130
155
|
{
|
|
@@ -149,18 +174,7 @@ export function codeGenSentioFile(contract: Contract): string {
|
|
|
149
174
|
],
|
|
150
175
|
'./common': ['PromiseOrValue'],
|
|
151
176
|
'./index': [`${contract.name}`, `${contract.name}__factory`],
|
|
152
|
-
[`./${contract.name}`]:
|
|
153
|
-
...Object.values(contract.events).map((events) => {
|
|
154
|
-
if (events.length === 1) {
|
|
155
|
-
return [`${events[0].name}Event`, `${events[0].name}EventFilter`]
|
|
156
|
-
} else {
|
|
157
|
-
return events.flatMap((e) => [
|
|
158
|
-
`${getFullSignatureAsSymbolForEvent(e)}_Event`,
|
|
159
|
-
`${getFullSignatureAsSymbolForEvent(e)}_EventFilter`,
|
|
160
|
-
])
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
),
|
|
177
|
+
[`./${contract.name}`]: eventsImports.concat(uniqueStructImports),
|
|
164
178
|
},
|
|
165
179
|
source
|
|
166
180
|
)
|