@btc-vision/cli 1.0.5 → 1.0.6

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.
Files changed (46) hide show
  1. package/package.json +4 -1
  2. package/.gitattributes +0 -2
  3. package/.github/dependabot.yml +0 -9
  4. package/.github/workflows/ci.yml +0 -48
  5. package/.prettierrc.json +0 -12
  6. package/CONTRIBUTING.md +0 -56
  7. package/NOTICE +0 -17
  8. package/SECURITY.md +0 -35
  9. package/eslint.config.js +0 -41
  10. package/gulpfile.js +0 -41
  11. package/src/commands/AcceptCommand.ts +0 -224
  12. package/src/commands/BaseCommand.ts +0 -59
  13. package/src/commands/CompileCommand.ts +0 -195
  14. package/src/commands/ConfigCommand.ts +0 -117
  15. package/src/commands/DeprecateCommand.ts +0 -193
  16. package/src/commands/InfoCommand.ts +0 -293
  17. package/src/commands/InitCommand.ts +0 -541
  18. package/src/commands/InstallCommand.ts +0 -179
  19. package/src/commands/KeygenCommand.ts +0 -157
  20. package/src/commands/ListCommand.ts +0 -169
  21. package/src/commands/LoginCommand.ts +0 -197
  22. package/src/commands/LogoutCommand.ts +0 -76
  23. package/src/commands/PublishCommand.ts +0 -340
  24. package/src/commands/ScopeRegisterCommand.ts +0 -164
  25. package/src/commands/SearchCommand.ts +0 -140
  26. package/src/commands/SignCommand.ts +0 -110
  27. package/src/commands/TransferCommand.ts +0 -363
  28. package/src/commands/UndeprecateCommand.ts +0 -167
  29. package/src/commands/UpdateCommand.ts +0 -200
  30. package/src/commands/VerifyCommand.ts +0 -228
  31. package/src/commands/WhoamiCommand.ts +0 -113
  32. package/src/index.ts +0 -88
  33. package/src/lib/PackageRegistry.abi.json +0 -765
  34. package/src/lib/PackageRegistry.abi.ts +0 -365
  35. package/src/lib/binary.ts +0 -338
  36. package/src/lib/config.ts +0 -265
  37. package/src/lib/credentials.ts +0 -176
  38. package/src/lib/ipfs.ts +0 -382
  39. package/src/lib/manifest.ts +0 -195
  40. package/src/lib/provider.ts +0 -121
  41. package/src/lib/registry.ts +0 -467
  42. package/src/lib/transaction.ts +0 -205
  43. package/src/lib/wallet.ts +0 -262
  44. package/src/types/PackageRegistry.ts +0 -344
  45. package/src/types/index.ts +0 -147
  46. package/tsconfig.json +0 -25
@@ -1,363 +0,0 @@
1
- /**
2
- * Transfer command - Initiate ownership transfer
3
- *
4
- * @module commands/TransferCommand
5
- */
6
-
7
- import { confirm, input } from '@inquirer/prompts';
8
- import { Address } from '@btc-vision/transaction';
9
- import { BaseCommand } from './BaseCommand.js';
10
- import {
11
- getPackage,
12
- getPendingScopeTransfer,
13
- getPendingTransfer,
14
- getRegistryContract,
15
- getScope,
16
- } from '../lib/registry.js';
17
- import { canSign, loadCredentials } from '../lib/credentials.js';
18
- import { CLIWallet } from '../lib/wallet.js';
19
- import {
20
- buildTransactionParams,
21
- checkBalance,
22
- formatSats,
23
- getWalletAddress,
24
- } from '../lib/transaction.js';
25
- import { NetworkName } from '../types/index.js';
26
-
27
- interface TransferOptions {
28
- network: string;
29
- yes?: boolean;
30
- cancel?: boolean;
31
- }
32
-
33
- export class TransferCommand extends BaseCommand {
34
- constructor() {
35
- super('transfer', 'Initiate ownership transfer of a package or scope');
36
- }
37
-
38
- protected configure(): void {
39
- this.command
40
- .argument('<name>', 'Package name or @scope')
41
- .argument('[newOwner]', 'New owner address')
42
- .option('-n, --network <network>', 'Network', 'mainnet')
43
- .option('-y, --yes', 'Skip confirmation')
44
- .option('--cancel', 'Cancel pending transfer')
45
- .action((name: string, newOwner?: string, options?: TransferOptions) =>
46
- this.execute(name, newOwner, options || { network: 'mainnet' }),
47
- );
48
- }
49
-
50
- private async execute(
51
- name: string,
52
- newOwner?: string,
53
- options?: TransferOptions,
54
- ): Promise<void> {
55
- try {
56
- // Load credentials
57
- this.logger.info('Loading wallet...');
58
- const credentials = loadCredentials();
59
- if (!credentials || !canSign(credentials)) {
60
- this.logger.fail('No credentials configured');
61
- this.logger.warn('Run `opnet login` to configure your wallet.');
62
- process.exit(1);
63
- }
64
- const wallet = CLIWallet.fromCredentials(credentials);
65
- this.logger.success('Wallet loaded');
66
-
67
- const network = (options?.network || 'mainnet') as NetworkName;
68
- const isScope = name.startsWith('@') && !name.includes('/');
69
- const displayName = isScope ? name : `package ${name}`;
70
-
71
- if (options?.cancel) {
72
- await this.handleCancel(name, isScope, network, options);
73
- return;
74
- }
75
-
76
- // Initiate transfer
77
- let targetOwner = newOwner;
78
- if (!targetOwner) {
79
- targetOwner = await input({
80
- message: 'New owner address:',
81
- validate: (value) => {
82
- if (!value || value.length < 20) {
83
- return 'Please enter a valid address';
84
- }
85
- return true;
86
- },
87
- });
88
- }
89
-
90
- // Verify target exists
91
- this.logger.info(`Checking ${displayName}...`);
92
-
93
- if (isScope) {
94
- const scopeName = name.substring(1);
95
- const scopeInfo = await getScope(scopeName, network);
96
- if (!scopeInfo) {
97
- this.logger.fail('Scope not found');
98
- this.logger.error(`Scope "${name}" does not exist.`);
99
- process.exit(1);
100
- }
101
- this.logger.success(`Found scope ${name}`);
102
- } else {
103
- const packageInfo = await getPackage(name, network);
104
- if (!packageInfo) {
105
- this.logger.fail('Package not found');
106
- this.logger.error(`Package "${name}" does not exist.`);
107
- process.exit(1);
108
- }
109
- this.logger.success(`Found package ${name}`);
110
- }
111
-
112
- // Display summary
113
- this.logger.log('');
114
- this.logger.info('Transfer Summary');
115
- this.logger.log('─'.repeat(50));
116
- this.logger.log(`Type: ${isScope ? 'Scope' : 'Package'}`);
117
- this.logger.log(`Name: ${name}`);
118
- this.logger.log(`New Owner: ${targetOwner}`);
119
- this.logger.log(`Network: ${options?.network}`);
120
- this.logger.log('');
121
-
122
- this.logger.warn(
123
- 'Note: The new owner must call `opnet accept` to complete the transfer.',
124
- );
125
- this.logger.log('');
126
-
127
- // Confirmation
128
- if (!options?.yes) {
129
- const confirmed = await confirm({
130
- message: `Initiate transfer of ${displayName}?`,
131
- default: false,
132
- });
133
-
134
- if (!confirmed) {
135
- this.logger.warn('Transfer cancelled.');
136
- return;
137
- }
138
- }
139
-
140
- // Check wallet balance
141
- this.logger.info('Checking wallet balance...');
142
- const { sufficient, balance } = await checkBalance(wallet, network);
143
- if (!sufficient) {
144
- this.logger.fail('Insufficient balance');
145
- this.logger.error(`Wallet balance: ${formatSats(balance)}`);
146
- this.logger.error('Please fund your wallet before initiating transfer.');
147
- process.exit(1);
148
- }
149
- this.logger.success(`Wallet balance: ${formatSats(balance)}`);
150
-
151
- // Execute transfer
152
- this.logger.info('Initiating transfer...');
153
-
154
- const sender = getWalletAddress(wallet);
155
- const contract = getRegistryContract(network, sender);
156
- const txParams = buildTransactionParams(wallet, network);
157
- const newOwnerAddress = Address.fromString(targetOwner);
158
-
159
- if (isScope) {
160
- const scopeName = name.substring(1);
161
- const transferResult = await contract.initiateScopeTransfer(
162
- scopeName,
163
- newOwnerAddress,
164
- );
165
-
166
- if (transferResult.revert) {
167
- this.logger.fail('Transfer initiation would fail');
168
- this.logger.error(`Reason: ${transferResult.revert}`);
169
- process.exit(1);
170
- }
171
-
172
- if (transferResult.estimatedGas) {
173
- this.logger.info(`Estimated gas: ${transferResult.estimatedGas} sats`);
174
- }
175
-
176
- const receipt = await transferResult.sendTransaction(txParams);
177
-
178
- this.logger.log('');
179
- this.logger.success('Scope transfer initiated successfully!');
180
- this.logger.log('');
181
- this.logger.log(`Scope: ${name}`);
182
- this.logger.log(`New Owner: ${targetOwner}`);
183
- this.logger.log(`Transaction ID: ${receipt.transactionId}`);
184
- this.logger.log(`Fees paid: ${formatSats(receipt.estimatedFees)}`);
185
- this.logger.log('');
186
- this.logger.warn(
187
- 'Note: The new owner must call `opnet accept` to complete the transfer.',
188
- );
189
- } else {
190
- const transferResult = await contract.initiateTransfer(name, newOwnerAddress);
191
-
192
- if (transferResult.revert) {
193
- this.logger.fail('Transfer initiation would fail');
194
- this.logger.error(`Reason: ${transferResult.revert}`);
195
- process.exit(1);
196
- }
197
-
198
- if (transferResult.estimatedGas) {
199
- this.logger.info(`Estimated gas: ${transferResult.estimatedGas} sats`);
200
- }
201
-
202
- const receipt = await transferResult.sendTransaction(txParams);
203
-
204
- this.logger.log('');
205
- this.logger.success('Package transfer initiated successfully!');
206
- this.logger.log('');
207
- this.logger.log(`Package: ${name}`);
208
- this.logger.log(`New Owner: ${targetOwner}`);
209
- this.logger.log(`Transaction ID: ${receipt.transactionId}`);
210
- this.logger.log(`Fees paid: ${formatSats(receipt.estimatedFees)}`);
211
- this.logger.log('');
212
- this.logger.warn(
213
- 'Note: The new owner must call `opnet accept` to complete the transfer.',
214
- );
215
- }
216
- this.logger.log('');
217
- } catch (error) {
218
- this.logger.fail('Transfer failed');
219
- if (this.isUserCancelled(error)) {
220
- this.logger.warn('Transfer cancelled.');
221
- process.exit(0);
222
- }
223
- this.exitWithError(this.formatError(error));
224
- }
225
- }
226
-
227
- private async handleCancel(
228
- name: string,
229
- isScope: boolean,
230
- network: NetworkName,
231
- options: TransferOptions,
232
- ): Promise<void> {
233
- this.logger.info('Checking pending transfer...');
234
-
235
- // Load wallet for cancellation
236
- const credentials = loadCredentials();
237
- if (!credentials || !canSign(credentials)) {
238
- this.logger.fail('No credentials configured');
239
- this.logger.warn('Run `opnet login` to configure your wallet.');
240
- process.exit(1);
241
- }
242
- const wallet = CLIWallet.fromCredentials(credentials);
243
-
244
- if (isScope) {
245
- const scopeName = name.substring(1);
246
- const pending = await getPendingScopeTransfer(scopeName, network);
247
- if (!pending) {
248
- this.logger.warn('No pending transfer');
249
- this.logger.log(`No pending transfer for ${name}.`);
250
- return;
251
- }
252
- this.logger.success(`Found pending transfer to ${pending.pendingOwner}`);
253
-
254
- if (!options?.yes) {
255
- const confirmed = await confirm({
256
- message: `Cancel ownership transfer of ${name}?`,
257
- default: true,
258
- });
259
- if (!confirmed) {
260
- this.logger.warn('Cancelled.');
261
- return;
262
- }
263
- }
264
-
265
- // Check wallet balance
266
- this.logger.info('Checking wallet balance...');
267
- const { sufficient, balance } = await checkBalance(wallet, network);
268
- if (!sufficient) {
269
- this.logger.fail('Insufficient balance');
270
- this.logger.error(`Wallet balance: ${formatSats(balance)}`);
271
- process.exit(1);
272
- }
273
- this.logger.success(`Wallet balance: ${formatSats(balance)}`);
274
-
275
- this.logger.info('Cancelling transfer...');
276
-
277
- const sender = getWalletAddress(wallet);
278
- const contract = getRegistryContract(network, sender);
279
- const txParams = buildTransactionParams(wallet, network);
280
-
281
- const cancelResult = await contract.cancelScopeTransfer(scopeName);
282
-
283
- if (cancelResult.revert) {
284
- this.logger.fail('Cancellation would fail');
285
- this.logger.error(`Reason: ${cancelResult.revert}`);
286
- process.exit(1);
287
- }
288
-
289
- if (cancelResult.estimatedGas) {
290
- this.logger.info(`Estimated gas: ${cancelResult.estimatedGas} sats`);
291
- }
292
-
293
- const receipt = await cancelResult.sendTransaction(txParams);
294
-
295
- this.logger.log('');
296
- this.logger.success('Scope transfer cancelled successfully!');
297
- this.logger.log('');
298
- this.logger.log(`Scope: ${name}`);
299
- this.logger.log(`Transaction ID: ${receipt.transactionId}`);
300
- this.logger.log(`Fees paid: ${formatSats(receipt.estimatedFees)}`);
301
- this.logger.log('');
302
- } else {
303
- const pending = await getPendingTransfer(name, network);
304
- if (!pending) {
305
- this.logger.warn('No pending transfer');
306
- this.logger.log(`No pending transfer for ${name}.`);
307
- return;
308
- }
309
- this.logger.success(`Found pending transfer to ${pending.pendingOwner}`);
310
-
311
- if (!options?.yes) {
312
- const confirmed = await confirm({
313
- message: `Cancel ownership transfer of ${name}?`,
314
- default: true,
315
- });
316
- if (!confirmed) {
317
- this.logger.warn('Cancelled.');
318
- return;
319
- }
320
- }
321
-
322
- // Check wallet balance
323
- this.logger.info('Checking wallet balance...');
324
- const { sufficient, balance } = await checkBalance(wallet, network);
325
- if (!sufficient) {
326
- this.logger.fail('Insufficient balance');
327
- this.logger.error(`Wallet balance: ${formatSats(balance)}`);
328
- process.exit(1);
329
- }
330
- this.logger.success(`Wallet balance: ${formatSats(balance)}`);
331
-
332
- this.logger.info('Cancelling transfer...');
333
-
334
- const sender = getWalletAddress(wallet);
335
- const contract = getRegistryContract(network, sender);
336
- const txParams = buildTransactionParams(wallet, network);
337
-
338
- const cancelResult = await contract.cancelTransfer(name);
339
-
340
- if (cancelResult.revert) {
341
- this.logger.fail('Cancellation would fail');
342
- this.logger.error(`Reason: ${cancelResult.revert}`);
343
- process.exit(1);
344
- }
345
-
346
- if (cancelResult.estimatedGas) {
347
- this.logger.info(`Estimated gas: ${cancelResult.estimatedGas} sats`);
348
- }
349
-
350
- const receipt = await cancelResult.sendTransaction(txParams);
351
-
352
- this.logger.log('');
353
- this.logger.success('Package transfer cancelled successfully!');
354
- this.logger.log('');
355
- this.logger.log(`Package: ${name}`);
356
- this.logger.log(`Transaction ID: ${receipt.transactionId}`);
357
- this.logger.log(`Fees paid: ${formatSats(receipt.estimatedFees)}`);
358
- this.logger.log('');
359
- }
360
- }
361
- }
362
-
363
- export const transferCommand = new TransferCommand().getCommand();
@@ -1,167 +0,0 @@
1
- /**
2
- * Undeprecate command - Remove deprecation from a package version
3
- *
4
- * @module commands/UndeprecateCommand
5
- */
6
-
7
- import { confirm } from '@inquirer/prompts';
8
- import { BaseCommand } from './BaseCommand.js';
9
- import { getPackage, getRegistryContract, getVersion, isVersionImmutable } from '../lib/registry.js';
10
- import { canSign, loadCredentials } from '../lib/credentials.js';
11
- import { CLIWallet } from '../lib/wallet.js';
12
- import {
13
- buildTransactionParams,
14
- checkBalance,
15
- formatSats,
16
- getWalletAddress,
17
- } from '../lib/transaction.js';
18
- import { NetworkName } from '../types/index.js';
19
-
20
- interface UndeprecateOptions {
21
- network: string;
22
- yes?: boolean;
23
- }
24
-
25
- export class UndeprecateCommand extends BaseCommand {
26
- constructor() {
27
- super('undeprecate', 'Remove deprecation from a package version');
28
- }
29
-
30
- protected configure(): void {
31
- this.command
32
- .argument('<package>', 'Package name (e.g., @scope/name or name)')
33
- .argument('<version>', 'Version to undeprecate')
34
- .option('-n, --network <network>', 'Network', 'mainnet')
35
- .option('-y, --yes', 'Skip confirmation')
36
- .action((packageName: string, version: string, options?: UndeprecateOptions) =>
37
- this.execute(packageName, version, options || { network: 'mainnet' }),
38
- );
39
- }
40
-
41
- private async execute(
42
- packageName: string,
43
- version: string,
44
- options?: UndeprecateOptions,
45
- ): Promise<void> {
46
- try {
47
- // Load credentials
48
- this.logger.info('Loading wallet...');
49
- const credentials = loadCredentials();
50
- if (!credentials || !canSign(credentials)) {
51
- this.logger.fail('No credentials configured');
52
- this.logger.warn('Run `opnet login` to configure your wallet.');
53
- process.exit(1);
54
- }
55
- const wallet = CLIWallet.fromCredentials(credentials);
56
- this.logger.success('Wallet loaded');
57
-
58
- // Get package info
59
- this.logger.info('Fetching package info...');
60
- const network = (options?.network || 'mainnet') as NetworkName;
61
- const packageInfo = await getPackage(packageName, network);
62
-
63
- if (!packageInfo) {
64
- this.logger.fail('Package not found');
65
- this.logger.error(`Package "${packageName}" does not exist.`);
66
- process.exit(1);
67
- }
68
-
69
- // Get version info
70
- const versionInfo = await getVersion(packageName, version, network);
71
- if (!versionInfo) {
72
- this.logger.fail('Version not found');
73
- this.logger.error(`Version "${version}" does not exist.`);
74
- process.exit(1);
75
- }
76
-
77
- if (!versionInfo.deprecated) {
78
- this.logger.warn('Not deprecated');
79
- this.logger.log(`Version ${version} is not deprecated.`);
80
- return;
81
- }
82
-
83
- // Check if immutable
84
- const immutable = await isVersionImmutable(packageName, version, network);
85
- if (immutable) {
86
- this.logger.fail('Version is immutable');
87
- this.logger.error('This version is past the 72-hour mutability window.');
88
- this.logger.error('Immutable versions cannot be undeprecated.');
89
- process.exit(1);
90
- }
91
-
92
- this.logger.success(`Found: ${packageName}@${version} (deprecated)`);
93
-
94
- // Display summary
95
- this.logger.log('');
96
- this.logger.info('Undeprecation Summary');
97
- this.logger.log('─'.repeat(50));
98
- this.logger.log(`Package: ${packageName}`);
99
- this.logger.log(`Version: ${version}`);
100
- this.logger.log(`Network: ${options?.network}`);
101
- this.logger.log('');
102
-
103
- // Confirmation
104
- if (!options?.yes) {
105
- const confirmed = await confirm({
106
- message: `Remove deprecation from ${packageName}@${version}?`,
107
- default: true,
108
- });
109
-
110
- if (!confirmed) {
111
- this.logger.warn('Undeprecation cancelled.');
112
- return;
113
- }
114
- }
115
-
116
- // Check wallet balance
117
- this.logger.info('Checking wallet balance...');
118
- const { sufficient, balance } = await checkBalance(wallet, network);
119
- if (!sufficient) {
120
- this.logger.fail('Insufficient balance');
121
- this.logger.error(`Wallet balance: ${formatSats(balance)}`);
122
- this.logger.error('Please fund your wallet before undeprecating.');
123
- process.exit(1);
124
- }
125
- this.logger.success(`Wallet balance: ${formatSats(balance)}`);
126
-
127
- // Execute undeprecation
128
- this.logger.info('Removing deprecation...');
129
-
130
- const sender = getWalletAddress(wallet);
131
- const contract = getRegistryContract(network, sender);
132
- const txParams = buildTransactionParams(wallet, network);
133
-
134
- const undeprecateResult = await contract.undeprecateVersion(packageName, version);
135
-
136
- if (undeprecateResult.revert) {
137
- this.logger.fail('Undeprecation would fail');
138
- this.logger.error(`Reason: ${undeprecateResult.revert}`);
139
- process.exit(1);
140
- }
141
-
142
- if (undeprecateResult.estimatedGas) {
143
- this.logger.info(`Estimated gas: ${undeprecateResult.estimatedGas} sats`);
144
- }
145
-
146
- const receipt = await undeprecateResult.sendTransaction(txParams);
147
-
148
- this.logger.log('');
149
- this.logger.success('Deprecation removed successfully!');
150
- this.logger.log('');
151
- this.logger.log(`Package: ${packageName}`);
152
- this.logger.log(`Version: ${version}`);
153
- this.logger.log(`Transaction ID: ${receipt.transactionId}`);
154
- this.logger.log(`Fees paid: ${formatSats(receipt.estimatedFees)}`);
155
- this.logger.log('');
156
- } catch (error) {
157
- this.logger.fail('Undeprecation failed');
158
- if (this.isUserCancelled(error)) {
159
- this.logger.warn('Undeprecation cancelled.');
160
- process.exit(0);
161
- }
162
- this.exitWithError(this.formatError(error));
163
- }
164
- }
165
- }
166
-
167
- export const undeprecateCommand = new UndeprecateCommand().getCommand();