-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathBatchCommand.BatchFileCommands.cs
316 lines (259 loc) · 13.6 KB
/
BatchCommand.BatchFileCommands.cs
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
// Copyright (C) 2015-2023 The Neo Project.
//
// BatchCommand.BatchFileCommands.cs file belongs to neo-express project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.
using McMaster.Extensions.CommandLineUtils;
using Neo.Network.P2P.Payloads;
using NeoExpress.Models;
using System.ComponentModel.DataAnnotations;
namespace NeoExpress.Commands
{
partial class BatchCommand
{
[Command]
[Subcommand(typeof(Checkpoint), typeof(Contract), typeof(FastForward), typeof(Oracle), typeof(Policy), typeof(Transfer), typeof(Wallet))]
internal class BatchFileCommands
{
[Command("checkpoint")]
[Subcommand(typeof(Create))]
internal class Checkpoint
{
[Command("create")]
internal class Create
{
[Argument(0, "Checkpoint file name")]
[Required]
internal string Name { get; init; } = string.Empty;
[Option(Description = "Overwrite existing data")]
internal bool Force { get; }
}
}
[Command("contract")]
[Subcommand(typeof(Deploy), typeof(Download), typeof(Invoke), typeof(Run))]
internal class Contract
{
[Command("deploy")]
internal class Deploy
{
[Argument(0, Description = "Path to contract .nef file")]
[Required]
internal string Contract { get; init; } = string.Empty;
[Argument(1, Description = "Account to pay contract deployment GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 account")]
internal string Password { get; init; } = string.Empty;
[Option(Description = "Witness Scope to use for transaction signer (Default: CalledByEntry)")]
[AllowedValues(StringComparison.OrdinalIgnoreCase, "None", "CalledByEntry", "Global")]
internal WitnessScope WitnessScope { get; init; } = WitnessScope.CalledByEntry;
[Option(Description = "Optional data parameter to pass to _deploy operation")]
internal string Data { get; init; } = string.Empty;
[Option(Description = "Deploy contract regardless of name conflict")]
internal bool Force { get; }
}
[Command("download")]
internal class Download
{
[Argument(0, Description = "Contract invocation hash")]
[Required]
internal string Contract { get; init; } = string.Empty;
[Argument(1, Description = "URL of Neo JSON-RPC Node\nSpecify MainNet (default), TestNet or JSON-RPC URL")]
[Required]
internal string RpcUri { get; } = string.Empty;
[Option(Description = "Block height to get contract state for")]
[Required]
internal uint Height { get; } = 0;
[Option(CommandOptionType.SingleOrNoValue,
Description = "Replace contract and storage if it already exists\nDefaults to None if option unspecified, All if option value unspecified")]
internal (bool hasValue, ContractCommand.OverwriteForce value) Force { get; init; }
}
[Command("invoke")]
internal class Invoke
{
[Argument(0, Description = "Path to contract invocation JSON file")]
[Required]
internal string InvocationFile { get; init; } = string.Empty;
[Argument(1, Description = "Account to pay contract invocation GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 account")]
internal string Password { get; init; } = string.Empty;
[Option(Description = "Witness Scope to use for transaction signer (Default: CalledByEntry)")]
[AllowedValues(StringComparison.OrdinalIgnoreCase, "None", "CalledByEntry", "Global")]
internal WitnessScope WitnessScope { get; init; } = WitnessScope.CalledByEntry;
}
[Command("run")]
internal class Run
{
[Argument(0, Description = "Contract name or invocation hash")]
[Required]
internal string Contract { get; init; } = string.Empty;
[Argument(1, Description = "Contract method to invoke")]
[Required]
internal string Method { get; init; } = string.Empty;
[Argument(2, Description = "Arguments to pass to contract")]
internal string[] Arguments { get; init; } = Array.Empty<string>();
[Option(Description = "Account to pay contract invocation GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 account")]
internal string Password { get; init; } = string.Empty;
[Option(Description = "Witness Scope to use for transaction signer (Default: CalledByEntry)")]
[AllowedValues(StringComparison.OrdinalIgnoreCase, "None", "CalledByEntry", "Global")]
internal WitnessScope WitnessScope { get; init; } = WitnessScope.CalledByEntry;
}
[Command("update")]
internal class Update
{
[Argument(0, Description = "Contract name or invocation hash")]
[Required]
internal string Contract { get; init; } = string.Empty;
[Argument(1, Description = "Path to contract .nef file")]
[Required]
internal string NefFile { get; init; } = string.Empty;
[Argument(2, Description = "Account to pay contract deployment GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "Witness Scope to use for transaction signer (Default: CalledByEntry)")]
[AllowedValues(StringComparison.OrdinalIgnoreCase, "None", "CalledByEntry", "Global")]
internal WitnessScope WitnessScope { get; init; } = WitnessScope.CalledByEntry;
[Option(Description = "Password to use for NEP-2/NEP-6 account")]
internal string Password { get; init; } = string.Empty;
}
}
[Command("fastfwd")]
internal class FastForward
{
[Argument(0, Description = "Number of blocks to mint")]
[Required]
internal uint Count { get; init; }
[Option(Description = "Timestamp delta for last generated block")]
internal string TimestampDelta { get; init; } = string.Empty;
}
[Command("oracle")]
[Subcommand(typeof(Enable), typeof(Response))]
internal class Oracle
{
[Command("enable")]
internal class Enable
{
[Argument(0, Description = "Account to pay contract invocation GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 account")]
internal string Password { get; init; } = string.Empty;
}
[Command("response")]
internal class Response
{
[Argument(0, Description = "URL of oracle request")]
[Required]
internal string Url { get; init; } = string.Empty;
[Argument(1, Description = "Path to JSON file with oracle response content")]
[Required]
internal string ResponsePath { get; init; } = string.Empty;
[Option(Description = "Oracle request ID")]
internal ulong? RequestId { get; }
}
}
[Command("policy")]
[Subcommand(typeof(Block), typeof(Set), typeof(Sync), typeof(Unblock))]
internal class Policy
{
[Command("block")]
internal class Block
{
[Argument(0, Description = "Account to block")]
[Required]
internal string ScriptHash { get; init; } = string.Empty;
[Argument(1, Description = "Account to pay contract invocation GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 sender")]
internal string Password { get; init; } = string.Empty;
}
[Command("set")]
internal class Set
{
[Argument(0, Description = "Policy to set")]
[Required]
internal PolicySettings Policy { get; init; }
[Argument(1, Description = "New Policy Value")]
[Required]
internal decimal Value { get; set; }
[Argument(2, Description = "Account to pay contract invocation GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 sender")]
internal string Password { get; init; } = string.Empty;
}
[Command("sync")]
internal class Sync
{
[Argument(0, Description = "Source of policy values. Must be path to policy settings JSON file")]
[Required]
internal string Source { get; init; } = string.Empty;
[Option(Description = "Account to pay contract invocation GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 sender")]
internal string Password { get; init; } = string.Empty;
}
[Command("unblock")]
internal class Unblock
{
[Argument(0, Description = "Account to unblock")]
[Required]
internal string ScriptHash { get; init; } = string.Empty;
[Argument(1, Description = "Account to pay contract invocation GAS fee")]
[Required]
internal string Account { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 sender")]
internal string Password { get; init; } = string.Empty;
}
}
[Command("transfer")]
internal class Transfer
{
[Argument(0, Description = "Amount to transfer")]
[Required]
internal string Quantity { get; init; } = string.Empty;
[Argument(1, Description = "Asset to transfer (symbol or script hash)")]
[Required]
internal string Asset { get; init; } = string.Empty;
[Argument(2, Description = "Account to send asset from")]
[Required]
internal string Sender { get; init; } = string.Empty;
[Argument(3, Description = "Account to send asset to")]
[Required]
internal string Receiver { get; init; } = string.Empty;
[Option(Description = "Optional data parameter to pass to transfer operation")]
internal string Data { get; init; } = string.Empty;
[Option(Description = "password to use for NEP-2/NEP-6 sender")]
internal string Password { get; init; } = string.Empty;
}
[Command("wallet")]
[Subcommand(typeof(Create))]
internal class Wallet
{
[Command("create")]
internal class Create
{
[Argument(0, Description = "Wallet name")]
[Required]
internal string Name { get; init; } = string.Empty;
[Option(Description = "Overwrite existing data")]
internal bool Force { get; }
[Option(Description = "Private key for account (Format: HEX or WIF)\nDefault: Random")]
internal string PrivateKey { get; set; } = string.Empty;
}
}
}
}
}