@taqueria/protocol 0.3.1 → 0.4.0-rc3
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/Alias.ts +38 -0
- package/Base.ts +105 -0
- package/Command.ts +24 -0
- package/Config.ts +155 -0
- package/Crypto.ts +3 -0
- package/EconomicalProtocolHash.ts +26 -0
- package/Environment.ts +36 -0
- package/EphemeralState.ts +208 -0
- package/Faucet.ts +46 -0
- package/HumanReadableIdentifier.ts +24 -0
- package/InstalledPlugin.ts +28 -0
- package/LoadedConfig.ts +45 -0
- package/NetworkConfig.ts +39 -0
- package/Operation.ts +70 -0
- package/Option.ts +56 -0
- package/ParsedOperation.ts +33 -0
- package/ParsedPluginInfo.ts +47 -0
- package/PersistentState.ts +67 -0
- package/PluginInfo.ts +67 -0
- package/PositionalArg.ts +49 -0
- package/Provisioner.ts +61 -0
- package/ProvisionerID.ts +25 -0
- package/Provisions.ts +70 -0
- package/PublicKeyHash.ts +28 -0
- package/README.md +87 -3
- package/RequestArgs.ts +76 -0
- package/SHA256.ts +40 -0
- package/SandboxAccountConfig.ts +35 -0
- package/SandboxConfig.ts +63 -0
- package/SanitizedAbsPath.ts +23 -0
- package/SanitizedArgs.ts +154 -0
- package/SanitizedPath.ts +26 -0
- package/SingleChar.ts +23 -0
- package/TaqError.ts +73 -0
- package/Task.ts +71 -0
- package/Timestamp.ts +25 -0
- package/Tz.ts +22 -0
- package/Url.ts +28 -0
- package/Verb.ts +23 -0
- package/VersionNumber.ts +23 -0
- package/i18n.ts +63 -0
- package/package.json +39 -32
- package/taqueria-protocol-types.ts +90 -608
- package/url-join.ts +0 -73
- package/url-parse.ts +0 -150
|
@@ -1,626 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
[stringMax30Type]: void
|
|
31
|
-
static create(value: string, truncate=false) : StringMax30 | undefined {
|
|
32
|
-
return (value.length <= 30)
|
|
33
|
-
? new StringMax30(value)
|
|
34
|
-
: (truncate
|
|
35
|
-
? new StringMax30(value.substr(0, 30))
|
|
36
|
-
: undefined
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const stringNoSpaces: unique symbol = Symbol()
|
|
42
|
-
export class StringNoSpaces extends StringLike {
|
|
43
|
-
[stringNoSpaces]: void
|
|
44
|
-
static create(value: string) : StringNoSpaces {
|
|
45
|
-
return new StringNoSpaces(value.replace(/\s+/g, '_'))
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const identiferType: unique symbol = Symbol()
|
|
50
|
-
export class Identifier extends StringLike {
|
|
51
|
-
[identiferType]: void
|
|
52
|
-
static create(value: string): Identifier | undefined {
|
|
53
|
-
const result = StringNoSpaces.create(value).value.match(/^[A-Za-z0-9]+[A-Za-z0-9-_]*$/)
|
|
54
|
-
return result ? new Identifier(result[0]) : undefined
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const humanReadableIdentifierType: unique symbol = Symbol()
|
|
59
|
-
export class HumanReadableIdentifier extends StringLike {
|
|
60
|
-
[humanReadableIdentifierType]: void
|
|
61
|
-
static create(value: string): HumanReadableIdentifier | undefined {
|
|
62
|
-
const input = StringMax30.create(StringNoSpaces.create(value).value)
|
|
63
|
-
if (input) {
|
|
64
|
-
const result = input.value.match(/^[A-Za-z]+[A-Za-z0-9-_]*$/)
|
|
65
|
-
return result ? new HumanReadableIdentifier(result[0]) : undefined
|
|
66
|
-
}
|
|
67
|
-
return undefined
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const verbType: unique symbol = Symbol()
|
|
72
|
-
export class Verb extends StringLike {
|
|
73
|
-
[verbType]: void
|
|
74
|
-
static create(value: string): Verb | undefined {
|
|
75
|
-
const result = value.match(/^[A-Za-z\-\ ]+/)
|
|
76
|
-
// TODO - should we do more validation whether its a verb?
|
|
77
|
-
return result ? new Verb(result[0]) : undefined
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const commandType: unique symbol = Symbol()
|
|
82
|
-
export class Command extends StringLike {
|
|
83
|
-
[commandType]: void
|
|
84
|
-
static create(value: string) : Command | undefined {
|
|
85
|
-
if (value.match(/^([A-Za-z-_ ]+ ?)((\[.+\] ?)|(\<.+\>) ?)*$/)) {
|
|
86
|
-
return new Command(value)
|
|
87
|
-
}
|
|
88
|
-
return undefined
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const singleChar: unique symbol = Symbol()
|
|
93
|
-
export class SingleChar extends StringLike {
|
|
94
|
-
[singleChar]: void
|
|
95
|
-
static create(value: string): SingleChar | undefined {
|
|
96
|
-
return value && value.toString().match(/^[A-Za-z]/)
|
|
97
|
-
? new SingleChar(value[0])
|
|
98
|
-
: undefined
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const urlType: unique symbol = Symbol()
|
|
103
|
-
export class Url {
|
|
104
|
-
[urlType]: void
|
|
105
|
-
readonly url: URL
|
|
106
|
-
private constructor(value: URL) {
|
|
107
|
-
this.url = value
|
|
108
|
-
}
|
|
109
|
-
static create(value: string): Url | undefined {
|
|
110
|
-
try {
|
|
111
|
-
const url = urlParse(value)
|
|
112
|
-
return new Url(url)
|
|
113
|
-
}
|
|
114
|
-
catch (_) {
|
|
115
|
-
return undefined
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export type Alias = Verb | SingleChar
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Types used in the Taqueria Config
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
export interface InstalledPlugin {
|
|
127
|
-
readonly name: string
|
|
128
|
-
readonly type: 'npm' | 'binary' | "deno"
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export interface Config {
|
|
132
|
-
readonly language?: 'en' | 'fr'
|
|
133
|
-
readonly plugins: InstalledPlugin[]
|
|
134
|
-
readonly contractsDir: string
|
|
135
|
-
readonly testsDir: string
|
|
136
|
-
readonly artifactsDir: string
|
|
137
|
-
|
|
138
|
-
readonly environment: Record<'default'|string, string|EnvironmentConfig>
|
|
139
|
-
|
|
140
|
-
readonly sandbox: Record<string, SandboxConfig>
|
|
141
|
-
|
|
142
|
-
readonly network: Record<string, NetworkConfig>
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface ConfigArgs extends Config {
|
|
146
|
-
projectDir: SanitizedAbsPath,
|
|
147
|
-
configFile: SanitizedAbsPath,
|
|
148
|
-
|
|
149
|
-
hash: SHA256
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Protocol Models
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
export interface UnvalidatedPositionalArg {
|
|
157
|
-
readonly placeholder: string
|
|
158
|
-
readonly type?: OptionType
|
|
159
|
-
readonly defaultValue?: string | number | boolean
|
|
160
|
-
readonly description: string
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
export interface UnvalidatedOption {
|
|
165
|
-
readonly shortFlag?: string
|
|
166
|
-
readonly flag: string
|
|
167
|
-
readonly description: string
|
|
168
|
-
readonly defaultValue?: string | number | boolean
|
|
169
|
-
readonly choices?: string[]
|
|
170
|
-
readonly required?: boolean
|
|
171
|
-
readonly boolean?: boolean
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export interface UnvalidatedHook {
|
|
175
|
-
// TODO
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface UnvalidatedScaffold {
|
|
179
|
-
// TODO
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export interface UnvalidatedNetwork {
|
|
183
|
-
readonly name: string
|
|
184
|
-
readonly label: string
|
|
185
|
-
readonly rpcUrl: string
|
|
186
|
-
readonly protocol: string
|
|
187
|
-
readonly attributes?: Attributes
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// NOTE: This is a workaround as TypeScript doesn't support
|
|
191
|
-
// recursive / cyclical types yet. :(
|
|
192
|
-
type Accounts_Base = Record<string, AccountDetails>
|
|
193
|
-
export type Accounts = Record<string, (keyof Accounts_Base)|AccountDetails>
|
|
194
|
-
|
|
195
|
-
export interface UnvalidatedSandbox extends UnvalidatedNetwork {
|
|
196
|
-
readonly plugin?: string
|
|
197
|
-
readonly accounts?: Accounts
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const hookType: unique symbol = Symbol()
|
|
201
|
-
export class Hook {
|
|
202
|
-
[hookType] : void
|
|
203
|
-
static create(unvalidatedHook: UnvalidatedHook): Hook | undefined {
|
|
204
|
-
return undefined
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const scaffoldType: unique symbol = Symbol()
|
|
209
|
-
export class Scaffold {
|
|
210
|
-
[scaffoldType] : void
|
|
211
|
-
static create(unvalidatedScaffold: UnvalidatedScaffold): Scaffold | undefined {
|
|
212
|
-
return undefined
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export type TaskHandler = "proxy" | string | string[]
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
export interface UnvalidatedTask {
|
|
220
|
-
readonly task: string
|
|
221
|
-
readonly command: string
|
|
222
|
-
readonly description: string
|
|
223
|
-
readonly aliases?: string[]
|
|
224
|
-
readonly options?: (UnvalidatedOption|Option|undefined)[],
|
|
225
|
-
readonly positionals?: (UnvalidatedPositionalArg|undefined|PositionalArg)[]
|
|
226
|
-
readonly handler: TaskHandler
|
|
227
|
-
readonly hidden?: boolean
|
|
228
|
-
readonly example?: string
|
|
229
|
-
readonly encoding?: "json" | "application/json" | "none"
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export interface UnvalidatedPluginInfo {
|
|
233
|
-
readonly schema: string
|
|
234
|
-
readonly name: string
|
|
235
|
-
readonly alias?: string
|
|
236
|
-
readonly version: string
|
|
237
|
-
readonly tasks?: (UnvalidatedTask|undefined)[]
|
|
238
|
-
readonly scaffolds?: (UnvalidatedScaffold|undefined)[]
|
|
239
|
-
readonly hooks?: (UnvalidatedHook|undefined)[]
|
|
240
|
-
readonly networks?: (UnvalidatedNetwork|undefined)[]
|
|
241
|
-
readonly sandboxes?: (UnvalidatedSandbox|undefined)[]
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export class PluginInfo {
|
|
245
|
-
readonly schema: string
|
|
246
|
-
readonly name: string
|
|
247
|
-
readonly alias?: string
|
|
248
|
-
readonly version: string
|
|
249
|
-
readonly tasks: Task[]
|
|
250
|
-
readonly scaffolds: Scaffold[]
|
|
251
|
-
readonly hooks: Hook[]
|
|
252
|
-
readonly networks: Network[]
|
|
253
|
-
readonly sandboxes: Sandbox[]
|
|
254
|
-
constructor(schema: string, name: string, version: string, tasks: Task[], scaffolds: Scaffold[], hooks: Hook[], networks: Network[], sandboxes: Sandbox[], alias?: string) {
|
|
255
|
-
this.schema = schema
|
|
256
|
-
this.alias = alias
|
|
257
|
-
this.name = name
|
|
258
|
-
this.version = version
|
|
259
|
-
this.tasks = tasks
|
|
260
|
-
this.scaffolds = scaffolds
|
|
261
|
-
this.hooks = hooks
|
|
262
|
-
this.networks = networks
|
|
263
|
-
this.sandboxes = sandboxes
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
static convert<A, B>(factory: (item: A) => B|undefined) {
|
|
267
|
-
return (obj: UnvalidatedPluginInfo, prop: keyof UnvalidatedPluginInfo) : B[] => obj[prop] ? (obj[prop] as (A|undefined)[]).reduce(
|
|
268
|
-
(retval: B[], unvalidatedItem: A|undefined) => {
|
|
269
|
-
if (unvalidatedItem) {
|
|
270
|
-
try {
|
|
271
|
-
const item = factory(unvalidatedItem)
|
|
272
|
-
return item ? [...retval, item]: retval
|
|
273
|
-
}
|
|
274
|
-
catch (_) {
|
|
275
|
-
return retval
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return retval
|
|
279
|
-
},
|
|
280
|
-
[]
|
|
281
|
-
) : []
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
static create(obj: UnvalidatedPluginInfo) : PluginInfo | undefined {
|
|
285
|
-
if (obj.version && obj.schema) {
|
|
286
|
-
try {
|
|
287
|
-
const createTask = Task.create.bind(Task)
|
|
288
|
-
//TODO: Finish doing the above for each factory/constructor
|
|
289
|
-
|
|
290
|
-
const temp: Record<string, string> = obj.alias
|
|
291
|
-
? {alias: obj.alias}
|
|
292
|
-
: {}
|
|
293
|
-
|
|
294
|
-
const pluginInfo : PluginInfo = {
|
|
295
|
-
...temp,
|
|
296
|
-
name: obj.name,
|
|
297
|
-
schema: obj.schema,
|
|
298
|
-
version: obj.version,
|
|
299
|
-
tasks: this.convert<UnvalidatedTask, Task>(createTask) (obj, "tasks"),
|
|
300
|
-
hooks: this.convert(Hook.create) (obj, "hooks"),
|
|
301
|
-
scaffolds: this.convert(Scaffold.create) (obj, "scaffolds"),
|
|
302
|
-
networks: this.convert(Network.create) (obj, "networks"),
|
|
303
|
-
sandboxes: this.convert(Sandbox.create) (obj, "sandboxes")
|
|
304
|
-
}
|
|
305
|
-
return pluginInfo
|
|
306
|
-
}
|
|
307
|
-
catch (_) {
|
|
308
|
-
return undefined
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return undefined
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
export type OptionType = 'string' | 'number' | 'boolean'
|
|
316
|
-
|
|
317
|
-
const positionalArgType: unique symbol = Symbol()
|
|
318
|
-
export class PositionalArg {
|
|
319
|
-
[positionalArgType]: void
|
|
320
|
-
readonly placeholder: HumanReadableIdentifier
|
|
321
|
-
readonly description: string
|
|
322
|
-
readonly defaultValue?: string | number | boolean
|
|
323
|
-
readonly type?: OptionType
|
|
324
|
-
|
|
325
|
-
protected constructor(placeholder: HumanReadableIdentifier, description: string, type?: OptionType, defaultValue?: string | number | boolean) {
|
|
326
|
-
this.placeholder = placeholder
|
|
327
|
-
this.defaultValue = defaultValue
|
|
328
|
-
this.description = description
|
|
329
|
-
this.type = type
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
static create(arg: UnvalidatedPositionalArg) {
|
|
333
|
-
const placeholder = HumanReadableIdentifier.create(arg.placeholder)
|
|
334
|
-
return placeholder
|
|
335
|
-
? new PositionalArg(placeholder, arg.description, arg.type, arg.defaultValue)
|
|
336
|
-
: undefined
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const optionType: unique symbol = Symbol()
|
|
341
|
-
export class Option {
|
|
342
|
-
[optionType]: void
|
|
343
|
-
readonly shortFlag?: SingleChar
|
|
344
|
-
readonly flag: Verb
|
|
345
|
-
readonly description: string
|
|
346
|
-
readonly defaultValue?: string | number | boolean
|
|
347
|
-
readonly choices?: string[]
|
|
348
|
-
readonly required?: boolean
|
|
349
|
-
readonly boolean?: boolean
|
|
350
|
-
private constructor(shortFlag: SingleChar | undefined, flag: Verb, description: string, choices: string[], required: boolean, boolean: boolean, defaultValue?: string | number | boolean) {
|
|
351
|
-
this.shortFlag = shortFlag
|
|
352
|
-
this.flag = flag
|
|
353
|
-
this.description = description
|
|
354
|
-
this.defaultValue = defaultValue
|
|
355
|
-
this.required = required
|
|
356
|
-
this.choices = choices
|
|
357
|
-
this.boolean = boolean
|
|
358
|
-
}
|
|
359
|
-
static create(option: UnvalidatedOption): Option | undefined {
|
|
360
|
-
const flag = Verb.create(option.flag)
|
|
361
|
-
|
|
362
|
-
if (!option.shortFlag && flag)
|
|
363
|
-
return new Option(undefined, flag, option.description, option.choices || [], option.required || false, option.boolean ? true : false, option.defaultValue)
|
|
364
|
-
|
|
365
|
-
if (option.shortFlag && flag) {
|
|
366
|
-
const shortFlag = SingleChar.create(option.shortFlag)
|
|
367
|
-
return shortFlag
|
|
368
|
-
? new Option(shortFlag, flag, option.description, option.choices || [], option.required || false, option.boolean ? true : false, option.defaultValue)
|
|
369
|
-
: undefined
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return undefined
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export type TaskEncoding = "none" | "json" | "application/json"
|
|
377
|
-
|
|
378
|
-
const taskType: unique symbol = Symbol()
|
|
379
|
-
export class Task {
|
|
380
|
-
[taskType]: void
|
|
381
|
-
readonly task: Verb
|
|
382
|
-
readonly command: Command
|
|
383
|
-
readonly aliases: Alias[]
|
|
384
|
-
readonly description: string
|
|
385
|
-
readonly example?: string
|
|
386
|
-
readonly options?: Option[]
|
|
387
|
-
readonly handler: TaskHandler
|
|
388
|
-
readonly hidden: boolean
|
|
389
|
-
readonly positionals: PositionalArg[]
|
|
390
|
-
readonly encoding: TaskEncoding
|
|
391
|
-
protected constructor(name: Verb, command: Command, description: string, handler: TaskHandler, options: Option[]=[], positionals: PositionalArg[]=[], aliases: Alias[]=[], hidden=false, encoding="none", example?: string) {
|
|
392
|
-
this.task = name
|
|
393
|
-
this.command = command
|
|
394
|
-
this.description = description
|
|
395
|
-
this.options = options
|
|
396
|
-
this.aliases = aliases
|
|
397
|
-
this.handler = handler
|
|
398
|
-
this.hidden = hidden
|
|
399
|
-
this.example = example
|
|
400
|
-
this.positionals = positionals
|
|
401
|
-
this.encoding = ["none", "json", "application/json"].includes(encoding)
|
|
402
|
-
? encoding as TaskEncoding
|
|
403
|
-
: "none"
|
|
404
|
-
}
|
|
405
|
-
static createAlias(value: string): Alias | undefined {
|
|
406
|
-
return Verb.create(value) || SingleChar.create(value)
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
static create (task: UnvalidatedTask): Task | undefined {
|
|
410
|
-
const name = Verb.create(task.task)
|
|
411
|
-
const command = Command.create(task.command)
|
|
412
|
-
const aliases = task.aliases
|
|
413
|
-
? task.aliases.reduce(
|
|
414
|
-
(retval: Alias[], unvalidatedAlias) => {
|
|
415
|
-
const alias = this.createAlias(unvalidatedAlias)
|
|
416
|
-
return alias ? [...retval, alias] : retval
|
|
417
|
-
},
|
|
418
|
-
[]
|
|
419
|
-
)
|
|
420
|
-
: []
|
|
421
|
-
|
|
422
|
-
const options = !task.options ? [] : task.options.reduce(
|
|
423
|
-
(retval: Option[], option) => {
|
|
424
|
-
if (option instanceof Option) {
|
|
425
|
-
return [...retval, option]
|
|
426
|
-
}
|
|
427
|
-
else if (option === undefined) {
|
|
428
|
-
return retval
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
const validOption = Option.create(option as UnvalidatedOption)
|
|
432
|
-
return validOption ? [...retval, validOption] : retval
|
|
433
|
-
}
|
|
434
|
-
},
|
|
435
|
-
[]
|
|
436
|
-
)
|
|
437
|
-
|
|
438
|
-
const positionals = !task.positionals ? [] : task.positionals.reduce(
|
|
439
|
-
(retval: PositionalArg[], item) => {
|
|
440
|
-
if (item instanceof PositionalArg) {
|
|
441
|
-
return [...retval, item]
|
|
442
|
-
}
|
|
443
|
-
else if (item === undefined) {
|
|
444
|
-
return retval
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
const positional = PositionalArg.create(item as UnvalidatedPositionalArg)
|
|
448
|
-
return positional
|
|
449
|
-
? [...retval, positional]:
|
|
450
|
-
retval
|
|
451
|
-
},
|
|
452
|
-
[]
|
|
453
|
-
)
|
|
454
|
-
|
|
455
|
-
return name && command
|
|
456
|
-
? new Task(name, command, task.description, task.handler, options, positionals, aliases, task.hidden ? true : false, task.encoding, task.example)
|
|
457
|
-
: undefined
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
export interface AccountKeys {
|
|
462
|
-
alias: string
|
|
463
|
-
encryptedKey: string
|
|
464
|
-
publicKeyHash: string
|
|
465
|
-
secretKey: string
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
export interface AccountDetails {
|
|
469
|
-
readonly initialBalance?: string,
|
|
470
|
-
keys?: AccountKeys
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
export interface SandboxConfig {
|
|
474
|
-
readonly label?: string,
|
|
475
|
-
readonly plugin?: string,
|
|
476
|
-
readonly rpcUrl?: string
|
|
477
|
-
readonly protocol?: string
|
|
478
|
-
readonly attributes?: Attributes
|
|
479
|
-
readonly accounts: Accounts
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
export interface NetworkConfig {
|
|
483
|
-
readonly label?: string,
|
|
484
|
-
readonly rpcUrl?: string
|
|
485
|
-
readonly protocol?: string
|
|
486
|
-
readonly faucet: {
|
|
487
|
-
readonly pkh: string
|
|
488
|
-
readonly mnemonic: string[]
|
|
489
|
-
readonly email: string
|
|
490
|
-
readonly password: string
|
|
491
|
-
readonly amount: string
|
|
492
|
-
readonly activation_code: string
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
export interface EnvironmentConfig {
|
|
497
|
-
readonly networks?: string[]
|
|
498
|
-
readonly sandboxes: string[]
|
|
499
|
-
readonly storage: Record<string, unknown>
|
|
500
|
-
}
|
|
501
|
-
|
|
1
|
+
import * as Alias from '@taqueria/protocol/Alias';
|
|
2
|
+
import * as Config from '@taqueria/protocol/Config';
|
|
3
|
+
import * as EconomicalProtocolHash from '@taqueria/protocol/EconomicalProtocolHash';
|
|
4
|
+
import * as Environment from '@taqueria/protocol/Environment';
|
|
5
|
+
import * as EphemeralState from '@taqueria/protocol/EphemeralState';
|
|
6
|
+
import * as HumanReadableIdentifier from '@taqueria/protocol/HumanReadableIdentifier';
|
|
7
|
+
import * as i18n from '@taqueria/protocol/i18n';
|
|
8
|
+
import * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin';
|
|
9
|
+
import * as LoadedConfig from '@taqueria/protocol/LoadedConfig';
|
|
10
|
+
import * as NetworkConfig from '@taqueria/protocol/NetworkConfig';
|
|
11
|
+
import * as Operation from '@taqueria/protocol/Operation';
|
|
12
|
+
import * as Option from '@taqueria/protocol/Option';
|
|
13
|
+
import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
|
|
14
|
+
import * as ParsedPluginInfo from '@taqueria/protocol/ParsedPluginInfo';
|
|
15
|
+
import * as PersistentState from '@taqueria/protocol/PersistentState';
|
|
16
|
+
import * as PluginInfo from '@taqueria/protocol/PluginInfo';
|
|
17
|
+
import * as PositionalArg from '@taqueria/protocol/PositionalArg';
|
|
18
|
+
import * as RequestArgs from '@taqueria/protocol/RequestArgs';
|
|
19
|
+
import * as SandboxAccountConfig from '@taqueria/protocol/SandboxAccountConfig';
|
|
20
|
+
import * as SandboxConfig from '@taqueria/protocol/SandboxConfig';
|
|
21
|
+
import * as SanitizedAbsPath from '@taqueria/protocol/SanitizedAbsPath';
|
|
22
|
+
import * as SanitizedArgs from '@taqueria/protocol/SanitizedArgs';
|
|
23
|
+
import * as SanitizedPath from '@taqueria/protocol/SanitizedPath';
|
|
24
|
+
import * as SHA256 from '@taqueria/protocol/SHA256';
|
|
25
|
+
import * as TaqError from '@taqueria/protocol/TaqError';
|
|
26
|
+
import * as Task from '@taqueria/protocol/Task';
|
|
27
|
+
import * as Url from '@taqueria/protocol/Url';
|
|
28
|
+
import * as Verb from '@taqueria/protocol/Verb';
|
|
29
|
+
import * as VersionNumber from '@taqueria/protocol/VersionNumber';
|
|
502
30
|
export interface RuntimeDependency {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly path: string;
|
|
33
|
+
readonly version: string;
|
|
34
|
+
readonly kind: 'required' | 'optional';
|
|
507
35
|
}
|
|
508
36
|
|
|
509
|
-
export
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
[economicalPrototypeHashType]: void
|
|
516
|
-
static create(value: string): EconomicalProtocolHash | undefined {
|
|
517
|
-
return value.length === 51 && value[0] === 'P' && /[A-Za-z0-9]+/.test(value)
|
|
518
|
-
? new EconomicalProtocolHash(value)
|
|
519
|
-
: undefined
|
|
520
|
-
}
|
|
521
|
-
}
|
|
37
|
+
export type PluginActionName =
|
|
38
|
+
| 'checkRuntimeDependencies'
|
|
39
|
+
| 'installRuntimeDependencies'
|
|
40
|
+
| 'proxy'
|
|
41
|
+
| 'pluginInfo'
|
|
42
|
+
| string;
|
|
522
43
|
|
|
523
|
-
|
|
524
|
-
export class EconomicalProtocol {
|
|
525
|
-
[economicProtocalType]: void
|
|
526
|
-
readonly hash: EconomicalProtocolHash
|
|
527
|
-
readonly label: HumanReadableIdentifier | undefined
|
|
528
|
-
constructor(hash: EconomicalProtocolHash, label: (HumanReadableIdentifier|undefined)=undefined) {
|
|
529
|
-
this.hash = hash
|
|
530
|
-
this.label = label
|
|
531
|
-
}
|
|
532
|
-
static create(hash: string, label: (string|undefined)=undefined) {
|
|
533
|
-
const validHash = EconomicalProtocolHash.create(hash)
|
|
534
|
-
const validLabel = label ? HumanReadableIdentifier.create(label) : undefined
|
|
535
|
-
return validHash
|
|
536
|
-
? new EconomicalProtocol(validHash, validLabel)
|
|
537
|
-
: undefined
|
|
538
|
-
}
|
|
539
|
-
}
|
|
44
|
+
export type PluginProxyAction = Task.t;
|
|
540
45
|
|
|
541
|
-
|
|
542
|
-
export class Network {
|
|
543
|
-
[networkType]: void
|
|
544
|
-
readonly name: HumanReadableIdentifier
|
|
545
|
-
readonly label: StringMax30
|
|
546
|
-
readonly rpcUrl: Url
|
|
547
|
-
readonly protocol: EconomicalProtocol
|
|
548
|
-
readonly attributes: Attributes
|
|
549
|
-
public constructor (name: HumanReadableIdentifier, label: StringMax30, rpcUrl: Url, protocol: EconomicalProtocol, attributes: Attributes) {
|
|
550
|
-
this.name = name
|
|
551
|
-
this.label = label
|
|
552
|
-
this.rpcUrl = rpcUrl
|
|
553
|
-
this.protocol = protocol
|
|
554
|
-
this.attributes = attributes
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
static create(network : UnvalidatedNetwork) {
|
|
558
|
-
const validName = HumanReadableIdentifier.create(network.name)
|
|
559
|
-
const validLabel = StringMax30.create(network.label)
|
|
560
|
-
const validUrl = Url.create(network.rpcUrl)
|
|
561
|
-
const validProto = EconomicalProtocol.create(network.protocol)
|
|
562
|
-
|
|
563
|
-
return validName && validLabel && validUrl && validProto
|
|
564
|
-
? new Network(validName, validLabel, validUrl, validProto, network.attributes ? network.attributes : {})
|
|
565
|
-
: undefined
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
const sandboxType: unique symbol = Symbol()
|
|
570
|
-
export class Sandbox extends Network {
|
|
571
|
-
readonly accounts: Accounts
|
|
572
|
-
[sandboxType]: void
|
|
573
|
-
readonly plugin?: string
|
|
574
|
-
|
|
575
|
-
protected constructor(name: HumanReadableIdentifier, label: StringMax30, rpcUrl: Url, protocol: EconomicalProtocol, attributes: Attributes, plugin?: string, accounts?: Accounts) {
|
|
576
|
-
super(name, label, rpcUrl, protocol, attributes)
|
|
577
|
-
this.plugin = plugin
|
|
578
|
-
this.accounts = accounts ? accounts: {}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
static create(sandbox: UnvalidatedSandbox) {
|
|
582
|
-
const network = super.create(sandbox)
|
|
583
|
-
return network
|
|
584
|
-
? new Sandbox(network.name, network.label, network.rpcUrl, network.protocol, network.attributes, sandbox.plugin, sandbox.accounts)
|
|
585
|
-
: undefined
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
export interface Environment {
|
|
590
|
-
readonly name: string
|
|
591
|
-
readonly networks?: Network[]
|
|
592
|
-
readonly sandboxes?: Sandbox[]
|
|
593
|
-
readonly storage: Record<string, unknown>
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
export type PluginActionName = "checkRuntimeDependencies" | "installRuntimeDependencies" | "proxy" | "pluginInfo" | string
|
|
597
|
-
|
|
598
|
-
export type PluginProxyAction = Task
|
|
599
|
-
|
|
600
|
-
export type PluginAction = "checkRuntimeDependencies" | "installRuntimeDependencies" | "pluginInfo" | PluginProxyAction
|
|
46
|
+
export type PluginAction = 'checkRuntimeDependencies' | 'installRuntimeDependencies' | 'pluginInfo' | PluginProxyAction;
|
|
601
47
|
|
|
602
48
|
export interface RuntimeDependencyReport extends RuntimeDependency {
|
|
603
|
-
|
|
49
|
+
readonly met: boolean;
|
|
604
50
|
}
|
|
605
51
|
|
|
606
52
|
export interface CheckRuntimeDependenciesResponse {
|
|
607
|
-
|
|
53
|
+
readonly report: RuntimeDependencyReport[];
|
|
608
54
|
}
|
|
609
55
|
|
|
610
56
|
export interface InstallRuntimeDependenciesResponse {
|
|
611
|
-
|
|
57
|
+
readonly report: RuntimeDependencyReport[];
|
|
612
58
|
}
|
|
613
59
|
|
|
614
60
|
export type PluginActionNotSupportedResponse = {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
61
|
+
readonly status: 'notSupported';
|
|
62
|
+
readonly msg: string;
|
|
63
|
+
};
|
|
618
64
|
|
|
619
65
|
export interface PluginJsonResponse {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
export type
|
|
625
|
-
|
|
626
|
-
|
|
66
|
+
readonly data?: unknown;
|
|
67
|
+
readonly render?: 'none' | 'string' | 'table';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type PluginResponse =
|
|
71
|
+
| PluginJsonResponse
|
|
72
|
+
| CheckRuntimeDependenciesResponse
|
|
73
|
+
| InstallRuntimeDependenciesResponse
|
|
74
|
+
| PluginInfo.t
|
|
75
|
+
| PluginActionNotSupportedResponse
|
|
76
|
+
| void;
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
Alias,
|
|
80
|
+
Config,
|
|
81
|
+
EconomicalProtocolHash,
|
|
82
|
+
Environment,
|
|
83
|
+
EphemeralState,
|
|
84
|
+
HumanReadableIdentifier,
|
|
85
|
+
i18n,
|
|
86
|
+
InstalledPlugin,
|
|
87
|
+
LoadedConfig,
|
|
88
|
+
NetworkConfig,
|
|
89
|
+
Operation,
|
|
90
|
+
Option,
|
|
91
|
+
ParsedOperation,
|
|
92
|
+
ParsedPluginInfo,
|
|
93
|
+
PersistentState,
|
|
94
|
+
PluginInfo,
|
|
95
|
+
PositionalArg,
|
|
96
|
+
RequestArgs,
|
|
97
|
+
SandboxAccountConfig,
|
|
98
|
+
SandboxConfig,
|
|
99
|
+
SanitizedAbsPath,
|
|
100
|
+
SanitizedArgs,
|
|
101
|
+
SanitizedPath,
|
|
102
|
+
SHA256,
|
|
103
|
+
TaqError,
|
|
104
|
+
Task,
|
|
105
|
+
Url,
|
|
106
|
+
Verb,
|
|
107
|
+
VersionNumber,
|
|
108
|
+
};
|