@btc-vision/cli 1.0.0
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/.gitattributes +2 -0
- package/.github/dependabot.yml +9 -0
- package/.github/workflows/ci.yml +48 -0
- package/.prettierrc.json +12 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +190 -0
- package/NOTICE +17 -0
- package/README.md +509 -0
- package/SECURITY.md +35 -0
- package/build/commands/AcceptCommand.d.ts +7 -0
- package/build/commands/AcceptCommand.js +110 -0
- package/build/commands/BaseCommand.d.ts +12 -0
- package/build/commands/BaseCommand.js +27 -0
- package/build/commands/CompileCommand.d.ts +7 -0
- package/build/commands/CompileCommand.js +138 -0
- package/build/commands/ConfigCommand.d.ts +17 -0
- package/build/commands/ConfigCommand.js +124 -0
- package/build/commands/DeprecateCommand.d.ts +7 -0
- package/build/commands/DeprecateCommand.js +112 -0
- package/build/commands/InfoCommand.d.ts +10 -0
- package/build/commands/InfoCommand.js +223 -0
- package/build/commands/InitCommand.d.ts +16 -0
- package/build/commands/InitCommand.js +336 -0
- package/build/commands/InstallCommand.d.ts +7 -0
- package/build/commands/InstallCommand.js +130 -0
- package/build/commands/KeygenCommand.d.ts +13 -0
- package/build/commands/KeygenCommand.js +133 -0
- package/build/commands/ListCommand.d.ts +7 -0
- package/build/commands/ListCommand.js +117 -0
- package/build/commands/LoginCommand.d.ts +9 -0
- package/build/commands/LoginCommand.js +139 -0
- package/build/commands/LogoutCommand.d.ts +7 -0
- package/build/commands/LogoutCommand.js +57 -0
- package/build/commands/PublishCommand.d.ts +7 -0
- package/build/commands/PublishCommand.js +163 -0
- package/build/commands/SearchCommand.d.ts +7 -0
- package/build/commands/SearchCommand.js +97 -0
- package/build/commands/SignCommand.d.ts +7 -0
- package/build/commands/SignCommand.js +80 -0
- package/build/commands/TransferCommand.d.ts +8 -0
- package/build/commands/TransferCommand.js +179 -0
- package/build/commands/UndeprecateCommand.d.ts +7 -0
- package/build/commands/UndeprecateCommand.js +95 -0
- package/build/commands/UpdateCommand.d.ts +7 -0
- package/build/commands/UpdateCommand.js +130 -0
- package/build/commands/VerifyCommand.d.ts +7 -0
- package/build/commands/VerifyCommand.js +167 -0
- package/build/commands/WhoamiCommand.d.ts +7 -0
- package/build/commands/WhoamiCommand.js +84 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +64 -0
- package/build/lib/PackageRegistry.abi.d.ts +2 -0
- package/build/lib/PackageRegistry.abi.js +356 -0
- package/build/lib/binary.d.ts +16 -0
- package/build/lib/binary.js +165 -0
- package/build/lib/config.d.ts +11 -0
- package/build/lib/config.js +160 -0
- package/build/lib/credentials.d.ts +10 -0
- package/build/lib/credentials.js +89 -0
- package/build/lib/ipfs.d.ts +16 -0
- package/build/lib/ipfs.js +209 -0
- package/build/lib/manifest.d.ts +14 -0
- package/build/lib/manifest.js +88 -0
- package/build/lib/provider.d.ts +9 -0
- package/build/lib/provider.js +48 -0
- package/build/lib/registry.d.ts +58 -0
- package/build/lib/registry.js +197 -0
- package/build/lib/wallet.d.ts +32 -0
- package/build/lib/wallet.js +114 -0
- package/build/types/PackageRegistry.d.ts +177 -0
- package/build/types/PackageRegistry.js +1 -0
- package/build/types/index.d.ts +30 -0
- package/build/types/index.js +52 -0
- package/eslint.config.js +41 -0
- package/gulpfile.js +41 -0
- package/package.json +83 -0
- package/src/commands/AcceptCommand.ts +151 -0
- package/src/commands/BaseCommand.ts +59 -0
- package/src/commands/CompileCommand.ts +196 -0
- package/src/commands/ConfigCommand.ts +144 -0
- package/src/commands/DeprecateCommand.ts +156 -0
- package/src/commands/InfoCommand.ts +293 -0
- package/src/commands/InitCommand.ts +465 -0
- package/src/commands/InstallCommand.ts +179 -0
- package/src/commands/KeygenCommand.ts +157 -0
- package/src/commands/ListCommand.ts +169 -0
- package/src/commands/LoginCommand.ts +197 -0
- package/src/commands/LogoutCommand.ts +76 -0
- package/src/commands/PublishCommand.ts +230 -0
- package/src/commands/SearchCommand.ts +141 -0
- package/src/commands/SignCommand.ts +122 -0
- package/src/commands/TransferCommand.ts +235 -0
- package/src/commands/UndeprecateCommand.ts +134 -0
- package/src/commands/UpdateCommand.ts +200 -0
- package/src/commands/VerifyCommand.ts +228 -0
- package/src/commands/WhoamiCommand.ts +113 -0
- package/src/index.ts +86 -0
- package/src/lib/PackageRegistry.abi.json +765 -0
- package/src/lib/PackageRegistry.abi.ts +365 -0
- package/src/lib/binary.ts +336 -0
- package/src/lib/config.ts +265 -0
- package/src/lib/credentials.ts +176 -0
- package/src/lib/ipfs.ts +369 -0
- package/src/lib/manifest.ts +172 -0
- package/src/lib/provider.ts +121 -0
- package/src/lib/registry.ts +464 -0
- package/src/lib/wallet.ts +271 -0
- package/src/types/PackageRegistry.ts +344 -0
- package/src/types/index.ts +145 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
|
+
import { BaseCommand } from './BaseCommand.js';
|
|
4
|
+
import { parseOpnetBinary, verifyChecksum, formatFileSize } from '../lib/binary.js';
|
|
5
|
+
import { CLIWallet } from '../lib/wallet.js';
|
|
6
|
+
export class VerifyCommand extends BaseCommand {
|
|
7
|
+
constructor() {
|
|
8
|
+
super('verify', 'Verify a .opnet binary signature and integrity');
|
|
9
|
+
}
|
|
10
|
+
configure() {
|
|
11
|
+
this.command
|
|
12
|
+
.argument('<file>', 'Path to .opnet file')
|
|
13
|
+
.option('-v, --verbose', 'Show detailed information')
|
|
14
|
+
.option('--json', 'Output as JSON')
|
|
15
|
+
.action((file, options) => this.execute(file, options));
|
|
16
|
+
}
|
|
17
|
+
execute(file, options) {
|
|
18
|
+
try {
|
|
19
|
+
if (!fs.existsSync(file)) {
|
|
20
|
+
if (options.json) {
|
|
21
|
+
this.logger.log(JSON.stringify({ valid: false, error: `File not found: ${file}` }));
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
this.exitWithError(`File not found: ${file}`);
|
|
25
|
+
}
|
|
26
|
+
const data = fs.readFileSync(file);
|
|
27
|
+
const fileSize = data.length;
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = parseOpnetBinary(data);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (options.json) {
|
|
34
|
+
this.logger.log(JSON.stringify({
|
|
35
|
+
valid: false,
|
|
36
|
+
error: `Parse error: ${error instanceof Error ? error.message : String(error)}`,
|
|
37
|
+
}));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
this.exitWithError(`Parse error: ${error instanceof Error ? error.message : String(error)}`);
|
|
41
|
+
}
|
|
42
|
+
const mldsaLevel = [44, 65, 87][parsed.mldsaLevel];
|
|
43
|
+
const checksumValid = verifyChecksum(parsed);
|
|
44
|
+
let signatureValid = false;
|
|
45
|
+
let signatureError;
|
|
46
|
+
const isUnsigned = parsed.publicKey.every((b) => b === 0);
|
|
47
|
+
if (isUnsigned) {
|
|
48
|
+
signatureError = 'Binary is unsigned (public key is empty)';
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
try {
|
|
52
|
+
signatureValid = CLIWallet.verifyMLDSA(parsed.checksum, parsed.signature, parsed.publicKey, mldsaLevel);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
signatureError = error instanceof Error ? error.message : String(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const isValid = checksumValid && signatureValid;
|
|
59
|
+
if (options.json) {
|
|
60
|
+
const output = {
|
|
61
|
+
valid: isValid,
|
|
62
|
+
file,
|
|
63
|
+
fileSize,
|
|
64
|
+
formatVersion: parsed.formatVersion,
|
|
65
|
+
mldsaLevel,
|
|
66
|
+
checksumValid,
|
|
67
|
+
signatureValid,
|
|
68
|
+
signatureError,
|
|
69
|
+
isUnsigned,
|
|
70
|
+
metadata: parsed.metadata,
|
|
71
|
+
publicKeyHash: crypto.createHash('sha256').update(parsed.publicKey).digest('hex'),
|
|
72
|
+
bytecodeSize: parsed.bytecode.length,
|
|
73
|
+
protoSize: parsed.proto?.length ?? 0,
|
|
74
|
+
};
|
|
75
|
+
this.logger.log(JSON.stringify(output, null, 2));
|
|
76
|
+
process.exit(isValid ? 0 : 1);
|
|
77
|
+
}
|
|
78
|
+
this.logger.info('\nOPNet Binary Verification\n');
|
|
79
|
+
this.logger.log('─'.repeat(60));
|
|
80
|
+
this.logger.log(`File: ${file}`);
|
|
81
|
+
this.logger.log(`Size: ${formatFileSize(fileSize)}`);
|
|
82
|
+
this.logger.log(`Format Version: ${parsed.formatVersion}`);
|
|
83
|
+
this.logger.log('');
|
|
84
|
+
this.logger.log('Plugin:');
|
|
85
|
+
this.logger.log(` Name: ${parsed.metadata.name}`);
|
|
86
|
+
this.logger.log(` Version: ${parsed.metadata.version}`);
|
|
87
|
+
this.logger.log(` Type: ${parsed.metadata.pluginType}`);
|
|
88
|
+
this.logger.log(` OPNet Version: ${parsed.metadata.opnetVersion}`);
|
|
89
|
+
this.logger.log('');
|
|
90
|
+
this.logger.log('Cryptography:');
|
|
91
|
+
this.logger.log(` MLDSA Level: MLDSA-${mldsaLevel}`);
|
|
92
|
+
this.logger.log(` Public Key: ${formatFileSize(parsed.publicKey.length)}`);
|
|
93
|
+
this.logger.log(` Signature: ${formatFileSize(parsed.signature.length)}`);
|
|
94
|
+
if (!isUnsigned) {
|
|
95
|
+
const pkHash = crypto.createHash('sha256').update(parsed.publicKey).digest('hex');
|
|
96
|
+
this.logger.log(` PubKey Hash: ${pkHash.substring(0, 16)}...`);
|
|
97
|
+
}
|
|
98
|
+
this.logger.log('');
|
|
99
|
+
this.logger.log('Verification:');
|
|
100
|
+
this.logger.log(` Checksum: ${checksumValid ? 'VALID' : 'INVALID'}`);
|
|
101
|
+
if (isUnsigned) {
|
|
102
|
+
this.logger.log(` Signature: UNSIGNED`);
|
|
103
|
+
}
|
|
104
|
+
else if (signatureError) {
|
|
105
|
+
this.logger.log(` Signature: ERROR - ${signatureError}`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.logger.log(` Signature: ${signatureValid ? 'VALID' : 'INVALID'}`);
|
|
109
|
+
}
|
|
110
|
+
this.logger.log('');
|
|
111
|
+
this.logger.log('─'.repeat(60));
|
|
112
|
+
if (isUnsigned) {
|
|
113
|
+
this.logger.warn('WARNING: This binary is unsigned and cannot be published.');
|
|
114
|
+
this.logger.warn('Use `opnet sign` to sign it.');
|
|
115
|
+
}
|
|
116
|
+
else if (isValid) {
|
|
117
|
+
this.logger.success('VERIFIED: Binary is valid and properly signed.');
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
this.logger.fail('FAILED: Binary verification failed.');
|
|
121
|
+
if (!checksumValid) {
|
|
122
|
+
this.logger.error(' - Checksum mismatch (binary may be corrupted)');
|
|
123
|
+
}
|
|
124
|
+
if (!signatureValid && !signatureError) {
|
|
125
|
+
this.logger.error(' - Signature invalid (binary may be tampered)');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
this.logger.log('');
|
|
129
|
+
if (options.verbose) {
|
|
130
|
+
this.logger.log('Sizes:');
|
|
131
|
+
this.logger.log(` Metadata: ${formatFileSize(parsed.rawMetadata.length)}`);
|
|
132
|
+
this.logger.log(` Bytecode: ${formatFileSize(parsed.bytecode.length)}`);
|
|
133
|
+
this.logger.log(` Proto: ${formatFileSize(parsed.proto?.length ?? 0)}`);
|
|
134
|
+
this.logger.log('');
|
|
135
|
+
this.logger.log('Checksums:');
|
|
136
|
+
this.logger.log(` Stored: ${parsed.checksum.toString('hex')}`);
|
|
137
|
+
this.logger.log('');
|
|
138
|
+
this.logger.log('Author:');
|
|
139
|
+
this.logger.log(` Name: ${parsed.metadata.author.name}`);
|
|
140
|
+
if (parsed.metadata.author.email) {
|
|
141
|
+
this.logger.log(` Email: ${parsed.metadata.author.email}`);
|
|
142
|
+
}
|
|
143
|
+
this.logger.log('');
|
|
144
|
+
this.logger.log('Permissions:');
|
|
145
|
+
const perms = parsed.metadata.permissions;
|
|
146
|
+
if (perms) {
|
|
147
|
+
this.logger.log(` Database: ${perms.database?.enabled ? 'Yes' : 'No'}`);
|
|
148
|
+
this.logger.log(` Block Hooks: ${perms.blocks?.preProcess || perms.blocks?.postProcess || perms.blocks?.onChange ? 'Yes' : 'No'}`);
|
|
149
|
+
this.logger.log(` Epoch Hooks: ${perms.epochs?.onChange || perms.epochs?.onFinalized ? 'Yes' : 'No'}`);
|
|
150
|
+
this.logger.log(` Mempool Feed: ${perms.mempool?.txFeed ? 'Yes' : 'No'}`);
|
|
151
|
+
this.logger.log(` API Endpoints: ${perms.api?.addEndpoints ? 'Yes' : 'No'}`);
|
|
152
|
+
this.logger.log(` Websocket: ${perms.api?.addWebsocket ? 'Yes' : 'No'}`);
|
|
153
|
+
this.logger.log(` Filesystem: ${perms.filesystem?.configDir || perms.filesystem?.tempDir ? 'Yes' : 'No'}`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this.logger.log(' (none configured)');
|
|
157
|
+
}
|
|
158
|
+
this.logger.log('');
|
|
159
|
+
}
|
|
160
|
+
process.exit(isValid ? 0 : 1);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
this.exitWithError(this.formatError(error));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export const verifyCommand = new VerifyCommand().getCommand();
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BaseCommand } from './BaseCommand.js';
|
|
2
|
+
import { loadCredentials, hasCredentials, getCredentialSource, maskSensitive, } from '../lib/credentials.js';
|
|
3
|
+
import { CLIWallet } from '../lib/wallet.js';
|
|
4
|
+
export class WhoamiCommand extends BaseCommand {
|
|
5
|
+
constructor() {
|
|
6
|
+
super('whoami', 'Display current wallet identity and configuration');
|
|
7
|
+
}
|
|
8
|
+
configure() {
|
|
9
|
+
this.command
|
|
10
|
+
.option('-v, --verbose', 'Show detailed information')
|
|
11
|
+
.option('--public-key', 'Show full MLDSA public key')
|
|
12
|
+
.action((options) => this.execute(options));
|
|
13
|
+
}
|
|
14
|
+
execute(options) {
|
|
15
|
+
try {
|
|
16
|
+
if (!hasCredentials()) {
|
|
17
|
+
this.logger.warn('Not logged in.');
|
|
18
|
+
this.logger.info('Run `opnet login` to configure your wallet.');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const credentials = loadCredentials();
|
|
22
|
+
if (!credentials) {
|
|
23
|
+
this.logger.warn('No credentials found.');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const source = getCredentialSource();
|
|
27
|
+
this.logger.info('\nOPNet Identity\n');
|
|
28
|
+
this.logger.log('─'.repeat(50));
|
|
29
|
+
this.logger.log(`Network: ${credentials.network}`);
|
|
30
|
+
this.logger.log(`MLDSA Level: ${credentials.mldsaLevel}`);
|
|
31
|
+
this.logger.log(`Auth Source: ${source}`);
|
|
32
|
+
try {
|
|
33
|
+
const wallet = CLIWallet.fromCredentials(credentials);
|
|
34
|
+
this.logger.log('');
|
|
35
|
+
this.logger.log(`P2TR Address: ${wallet.p2trAddress}`);
|
|
36
|
+
this.logger.log(`MLDSA PubKey Hash: ${wallet.mldsaPublicKeyHash}`);
|
|
37
|
+
if (options.publicKey) {
|
|
38
|
+
this.logger.log('');
|
|
39
|
+
this.logger.log('MLDSA Public Key:');
|
|
40
|
+
this.logger.log(wallet.mldsaPublicKey.toString('hex'));
|
|
41
|
+
}
|
|
42
|
+
if (options.verbose) {
|
|
43
|
+
this.logger.log('');
|
|
44
|
+
this.logger.log('─'.repeat(50));
|
|
45
|
+
this.logger.log('Details:');
|
|
46
|
+
this.logger.log(` Security Level: MLDSA-${credentials.mldsaLevel}`);
|
|
47
|
+
this.logger.log(` Public Key Size: ${wallet.mldsaPublicKey.length} bytes`);
|
|
48
|
+
if (credentials.mnemonic) {
|
|
49
|
+
this.logger.log(' Auth Method: BIP-39 Mnemonic');
|
|
50
|
+
this.logger.log(` Mnemonic: ${maskSensitive(credentials.mnemonic, 8)}`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.logger.log(' Auth Method: WIF + MLDSA Keys');
|
|
54
|
+
if (credentials.wif) {
|
|
55
|
+
this.logger.log(` WIF: ${maskSensitive(credentials.wif, 4)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
this.logger.log('');
|
|
62
|
+
this.logger.warn('Could not load wallet details.');
|
|
63
|
+
if (options.verbose) {
|
|
64
|
+
this.logger.debug(` Error: ${this.formatError(error)}`);
|
|
65
|
+
}
|
|
66
|
+
this.logger.log('');
|
|
67
|
+
if (credentials.mnemonic) {
|
|
68
|
+
this.logger.log(`Auth Method: BIP-39 Mnemonic`);
|
|
69
|
+
if (options.verbose) {
|
|
70
|
+
this.logger.log(`Mnemonic: ${maskSensitive(credentials.mnemonic, 8)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.logger.log(`Auth Method: WIF + MLDSA Keys`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.logger.log('');
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
this.exitWithError(this.formatError(error));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export const whoamiCommand = new WhoamiCommand().getCommand();
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { Logger } from '@btc-vision/logger';
|
|
4
|
+
import { configCommand } from './commands/ConfigCommand.js';
|
|
5
|
+
import { loginCommand } from './commands/LoginCommand.js';
|
|
6
|
+
import { logoutCommand } from './commands/LogoutCommand.js';
|
|
7
|
+
import { whoamiCommand } from './commands/WhoamiCommand.js';
|
|
8
|
+
import { keygenCommand } from './commands/KeygenCommand.js';
|
|
9
|
+
import { initCommand } from './commands/InitCommand.js';
|
|
10
|
+
import { compileCommand } from './commands/CompileCommand.js';
|
|
11
|
+
import { verifyCommand } from './commands/VerifyCommand.js';
|
|
12
|
+
import { infoCommand } from './commands/InfoCommand.js';
|
|
13
|
+
import { signCommand } from './commands/SignCommand.js';
|
|
14
|
+
import { publishCommand } from './commands/PublishCommand.js';
|
|
15
|
+
import { deprecateCommand } from './commands/DeprecateCommand.js';
|
|
16
|
+
import { undeprecateCommand } from './commands/UndeprecateCommand.js';
|
|
17
|
+
import { transferCommand } from './commands/TransferCommand.js';
|
|
18
|
+
import { acceptCommand } from './commands/AcceptCommand.js';
|
|
19
|
+
import { installCommand } from './commands/InstallCommand.js';
|
|
20
|
+
import { updateCommand } from './commands/UpdateCommand.js';
|
|
21
|
+
import { listCommand } from './commands/ListCommand.js';
|
|
22
|
+
import { searchCommand } from './commands/SearchCommand.js';
|
|
23
|
+
const logger = new Logger();
|
|
24
|
+
const program = new Command();
|
|
25
|
+
program
|
|
26
|
+
.name('opnet')
|
|
27
|
+
.description('OPNet CLI - Build, sign, and publish plugins for the OPNet ecosystem')
|
|
28
|
+
.version('1.0.0');
|
|
29
|
+
program.addCommand(configCommand);
|
|
30
|
+
program.addCommand(loginCommand);
|
|
31
|
+
program.addCommand(logoutCommand);
|
|
32
|
+
program.addCommand(whoamiCommand);
|
|
33
|
+
program.addCommand(keygenCommand);
|
|
34
|
+
program.addCommand(initCommand);
|
|
35
|
+
program.addCommand(compileCommand);
|
|
36
|
+
program.addCommand(verifyCommand);
|
|
37
|
+
program.addCommand(infoCommand);
|
|
38
|
+
program.addCommand(signCommand);
|
|
39
|
+
program.addCommand(publishCommand);
|
|
40
|
+
program.addCommand(deprecateCommand);
|
|
41
|
+
program.addCommand(undeprecateCommand);
|
|
42
|
+
program.addCommand(transferCommand);
|
|
43
|
+
program.addCommand(acceptCommand);
|
|
44
|
+
program.addCommand(installCommand);
|
|
45
|
+
program.addCommand(updateCommand);
|
|
46
|
+
program.addCommand(listCommand);
|
|
47
|
+
program.addCommand(searchCommand);
|
|
48
|
+
program.showHelpAfterError();
|
|
49
|
+
program.showSuggestionAfterError();
|
|
50
|
+
program.exitOverride((err) => {
|
|
51
|
+
if (err.code === 'commander.help') {
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
if (err.code === 'commander.version') {
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}
|
|
57
|
+
logger.error(`Error: ${err.message}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
});
|
|
60
|
+
program.parseAsync(process.argv).catch((error) => {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
logger.error(`Error: ${message}`);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
});
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { ABIDataTypes } from '@btc-vision/transaction';
|
|
2
|
+
import { BitcoinAbiTypes } from 'opnet';
|
|
3
|
+
export const PACKAGE_REGISTRY_ABI = [
|
|
4
|
+
{
|
|
5
|
+
name: 'setTreasuryAddress',
|
|
6
|
+
type: BitcoinAbiTypes.Function,
|
|
7
|
+
inputs: [{ name: 'treasuryAddress', type: ABIDataTypes.STRING }],
|
|
8
|
+
outputs: [],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: 'setScopePrice',
|
|
12
|
+
type: BitcoinAbiTypes.Function,
|
|
13
|
+
inputs: [{ name: 'priceSats', type: ABIDataTypes.UINT64 }],
|
|
14
|
+
outputs: [],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'setPackagePrice',
|
|
18
|
+
type: BitcoinAbiTypes.Function,
|
|
19
|
+
inputs: [{ name: 'priceSats', type: ABIDataTypes.UINT64 }],
|
|
20
|
+
outputs: [],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'registerScope',
|
|
24
|
+
type: BitcoinAbiTypes.Function,
|
|
25
|
+
inputs: [{ name: 'scopeName', type: ABIDataTypes.STRING }],
|
|
26
|
+
outputs: [],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'initiateScopeTransfer',
|
|
30
|
+
type: BitcoinAbiTypes.Function,
|
|
31
|
+
inputs: [
|
|
32
|
+
{ name: 'scopeName', type: ABIDataTypes.STRING },
|
|
33
|
+
{ name: 'newOwner', type: ABIDataTypes.ADDRESS },
|
|
34
|
+
],
|
|
35
|
+
outputs: [],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'acceptScopeTransfer',
|
|
39
|
+
type: BitcoinAbiTypes.Function,
|
|
40
|
+
inputs: [{ name: 'scopeName', type: ABIDataTypes.STRING }],
|
|
41
|
+
outputs: [],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'cancelScopeTransfer',
|
|
45
|
+
type: BitcoinAbiTypes.Function,
|
|
46
|
+
inputs: [{ name: 'scopeName', type: ABIDataTypes.STRING }],
|
|
47
|
+
outputs: [],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'registerPackage',
|
|
51
|
+
type: BitcoinAbiTypes.Function,
|
|
52
|
+
inputs: [{ name: 'packageName', type: ABIDataTypes.STRING }],
|
|
53
|
+
outputs: [],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'publishVersion',
|
|
57
|
+
type: BitcoinAbiTypes.Function,
|
|
58
|
+
inputs: [
|
|
59
|
+
{ name: 'packageName', type: ABIDataTypes.STRING },
|
|
60
|
+
{ name: 'version', type: ABIDataTypes.STRING },
|
|
61
|
+
{ name: 'ipfsCid', type: ABIDataTypes.STRING },
|
|
62
|
+
{ name: 'checksum', type: ABIDataTypes.BYTES32 },
|
|
63
|
+
{ name: 'signature', type: ABIDataTypes.BYTES },
|
|
64
|
+
{ name: 'mldsaLevel', type: ABIDataTypes.UINT8 },
|
|
65
|
+
{ name: 'opnetVersionRange', type: ABIDataTypes.STRING },
|
|
66
|
+
{ name: 'pluginType', type: ABIDataTypes.UINT8 },
|
|
67
|
+
{ name: 'permissionsHash', type: ABIDataTypes.BYTES32 },
|
|
68
|
+
{ name: 'dependencies', type: ABIDataTypes.BYTES },
|
|
69
|
+
],
|
|
70
|
+
outputs: [],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'deprecateVersion',
|
|
74
|
+
type: BitcoinAbiTypes.Function,
|
|
75
|
+
inputs: [
|
|
76
|
+
{ name: 'packageName', type: ABIDataTypes.STRING },
|
|
77
|
+
{ name: 'version', type: ABIDataTypes.STRING },
|
|
78
|
+
{ name: 'reason', type: ABIDataTypes.STRING },
|
|
79
|
+
],
|
|
80
|
+
outputs: [],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'undeprecateVersion',
|
|
84
|
+
type: BitcoinAbiTypes.Function,
|
|
85
|
+
inputs: [
|
|
86
|
+
{ name: 'packageName', type: ABIDataTypes.STRING },
|
|
87
|
+
{ name: 'version', type: ABIDataTypes.STRING },
|
|
88
|
+
],
|
|
89
|
+
outputs: [],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'initiateTransfer',
|
|
93
|
+
type: BitcoinAbiTypes.Function,
|
|
94
|
+
inputs: [
|
|
95
|
+
{ name: 'packageName', type: ABIDataTypes.STRING },
|
|
96
|
+
{ name: 'newOwner', type: ABIDataTypes.ADDRESS },
|
|
97
|
+
],
|
|
98
|
+
outputs: [],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'acceptTransfer',
|
|
102
|
+
type: BitcoinAbiTypes.Function,
|
|
103
|
+
inputs: [{ name: 'packageName', type: ABIDataTypes.STRING }],
|
|
104
|
+
outputs: [],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'cancelTransfer',
|
|
108
|
+
type: BitcoinAbiTypes.Function,
|
|
109
|
+
inputs: [{ name: 'packageName', type: ABIDataTypes.STRING }],
|
|
110
|
+
outputs: [],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'getScope',
|
|
114
|
+
type: BitcoinAbiTypes.Function,
|
|
115
|
+
inputs: [{ name: 'scopeName', type: ABIDataTypes.STRING }],
|
|
116
|
+
outputs: [
|
|
117
|
+
{ name: 'exists', type: ABIDataTypes.BOOL },
|
|
118
|
+
{ name: 'owner', type: ABIDataTypes.ADDRESS },
|
|
119
|
+
{ name: 'createdAt', type: ABIDataTypes.UINT64 },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'getScopeOwner',
|
|
124
|
+
type: BitcoinAbiTypes.Function,
|
|
125
|
+
inputs: [{ name: 'scopeName', type: ABIDataTypes.STRING }],
|
|
126
|
+
outputs: [{ name: 'owner', type: ABIDataTypes.ADDRESS }],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'getPackage',
|
|
130
|
+
type: BitcoinAbiTypes.Function,
|
|
131
|
+
inputs: [{ name: 'packageName', type: ABIDataTypes.STRING }],
|
|
132
|
+
outputs: [
|
|
133
|
+
{ name: 'exists', type: ABIDataTypes.BOOL },
|
|
134
|
+
{ name: 'owner', type: ABIDataTypes.ADDRESS },
|
|
135
|
+
{ name: 'createdAt', type: ABIDataTypes.UINT64 },
|
|
136
|
+
{ name: 'versionCount', type: ABIDataTypes.UINT256 },
|
|
137
|
+
{ name: 'latestVersion', type: ABIDataTypes.STRING },
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'getOwner',
|
|
142
|
+
type: BitcoinAbiTypes.Function,
|
|
143
|
+
inputs: [{ name: 'packageName', type: ABIDataTypes.STRING }],
|
|
144
|
+
outputs: [{ name: 'owner', type: ABIDataTypes.ADDRESS }],
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'getVersion',
|
|
148
|
+
type: BitcoinAbiTypes.Function,
|
|
149
|
+
inputs: [
|
|
150
|
+
{ name: 'packageName', type: ABIDataTypes.STRING },
|
|
151
|
+
{ name: 'version', type: ABIDataTypes.STRING },
|
|
152
|
+
],
|
|
153
|
+
outputs: [
|
|
154
|
+
{ name: 'exists', type: ABIDataTypes.BOOL },
|
|
155
|
+
{ name: 'ipfsCid', type: ABIDataTypes.STRING },
|
|
156
|
+
{ name: 'checksum', type: ABIDataTypes.BYTES32 },
|
|
157
|
+
{ name: 'sigHash', type: ABIDataTypes.BYTES32 },
|
|
158
|
+
{ name: 'mldsaLevel', type: ABIDataTypes.UINT8 },
|
|
159
|
+
{ name: 'opnetVersionRange', type: ABIDataTypes.STRING },
|
|
160
|
+
{ name: 'pluginType', type: ABIDataTypes.UINT8 },
|
|
161
|
+
{ name: 'permissionsHash', type: ABIDataTypes.BYTES32 },
|
|
162
|
+
{ name: 'depsHash', type: ABIDataTypes.BYTES32 },
|
|
163
|
+
{ name: 'publisher', type: ABIDataTypes.ADDRESS },
|
|
164
|
+
{ name: 'publishedAt', type: ABIDataTypes.UINT64 },
|
|
165
|
+
{ name: 'deprecated', type: ABIDataTypes.BOOL },
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: 'isDeprecated',
|
|
170
|
+
type: BitcoinAbiTypes.Function,
|
|
171
|
+
inputs: [
|
|
172
|
+
{ name: 'packageName', type: ABIDataTypes.STRING },
|
|
173
|
+
{ name: 'version', type: ABIDataTypes.STRING },
|
|
174
|
+
],
|
|
175
|
+
outputs: [{ name: 'deprecated', type: ABIDataTypes.BOOL }],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'isImmutable',
|
|
179
|
+
type: BitcoinAbiTypes.Function,
|
|
180
|
+
inputs: [
|
|
181
|
+
{ name: 'packageName', type: ABIDataTypes.STRING },
|
|
182
|
+
{ name: 'version', type: ABIDataTypes.STRING },
|
|
183
|
+
],
|
|
184
|
+
outputs: [{ name: 'immutable', type: ABIDataTypes.BOOL }],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'getPendingTransfer',
|
|
188
|
+
type: BitcoinAbiTypes.Function,
|
|
189
|
+
inputs: [{ name: 'packageName', type: ABIDataTypes.STRING }],
|
|
190
|
+
outputs: [
|
|
191
|
+
{ name: 'pendingOwner', type: ABIDataTypes.ADDRESS },
|
|
192
|
+
{ name: 'initiatedAt', type: ABIDataTypes.UINT64 },
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: 'getPendingScopeTransfer',
|
|
197
|
+
type: BitcoinAbiTypes.Function,
|
|
198
|
+
inputs: [{ name: 'scopeName', type: ABIDataTypes.STRING }],
|
|
199
|
+
outputs: [
|
|
200
|
+
{ name: 'pendingOwner', type: ABIDataTypes.ADDRESS },
|
|
201
|
+
{ name: 'initiatedAt', type: ABIDataTypes.UINT64 },
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'getTreasuryAddress',
|
|
206
|
+
type: BitcoinAbiTypes.Function,
|
|
207
|
+
inputs: [],
|
|
208
|
+
outputs: [{ name: 'treasuryAddress', type: ABIDataTypes.STRING }],
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: 'getScopePrice',
|
|
212
|
+
type: BitcoinAbiTypes.Function,
|
|
213
|
+
inputs: [],
|
|
214
|
+
outputs: [{ name: 'priceSats', type: ABIDataTypes.UINT64 }],
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'getPackagePrice',
|
|
218
|
+
type: BitcoinAbiTypes.Function,
|
|
219
|
+
inputs: [],
|
|
220
|
+
outputs: [{ name: 'priceSats', type: ABIDataTypes.UINT64 }],
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: 'TreasuryAddressChanged',
|
|
224
|
+
type: BitcoinAbiTypes.Event,
|
|
225
|
+
values: [
|
|
226
|
+
{ name: 'previousAddressHash', type: ABIDataTypes.UINT256 },
|
|
227
|
+
{ name: 'newAddressHash', type: ABIDataTypes.UINT256 },
|
|
228
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'ScopePriceChanged',
|
|
233
|
+
type: BitcoinAbiTypes.Event,
|
|
234
|
+
values: [
|
|
235
|
+
{ name: 'oldPrice', type: ABIDataTypes.UINT64 },
|
|
236
|
+
{ name: 'newPrice', type: ABIDataTypes.UINT64 },
|
|
237
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'PackagePriceChanged',
|
|
242
|
+
type: BitcoinAbiTypes.Event,
|
|
243
|
+
values: [
|
|
244
|
+
{ name: 'oldPrice', type: ABIDataTypes.UINT64 },
|
|
245
|
+
{ name: 'newPrice', type: ABIDataTypes.UINT64 },
|
|
246
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'ScopeRegistered',
|
|
251
|
+
type: BitcoinAbiTypes.Event,
|
|
252
|
+
values: [
|
|
253
|
+
{ name: 'scopeHash', type: ABIDataTypes.UINT256 },
|
|
254
|
+
{ name: 'owner', type: ABIDataTypes.ADDRESS },
|
|
255
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: 'ScopeTransferInitiated',
|
|
260
|
+
type: BitcoinAbiTypes.Event,
|
|
261
|
+
values: [
|
|
262
|
+
{ name: 'scopeHash', type: ABIDataTypes.UINT256 },
|
|
263
|
+
{ name: 'currentOwner', type: ABIDataTypes.ADDRESS },
|
|
264
|
+
{ name: 'newOwner', type: ABIDataTypes.ADDRESS },
|
|
265
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: 'ScopeTransferCompleted',
|
|
270
|
+
type: BitcoinAbiTypes.Event,
|
|
271
|
+
values: [
|
|
272
|
+
{ name: 'scopeHash', type: ABIDataTypes.UINT256 },
|
|
273
|
+
{ name: 'previousOwner', type: ABIDataTypes.ADDRESS },
|
|
274
|
+
{ name: 'newOwner', type: ABIDataTypes.ADDRESS },
|
|
275
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: 'ScopeTransferCancelled',
|
|
280
|
+
type: BitcoinAbiTypes.Event,
|
|
281
|
+
values: [
|
|
282
|
+
{ name: 'scopeHash', type: ABIDataTypes.UINT256 },
|
|
283
|
+
{ name: 'owner', type: ABIDataTypes.ADDRESS },
|
|
284
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
285
|
+
],
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: 'PackageRegistered',
|
|
289
|
+
type: BitcoinAbiTypes.Event,
|
|
290
|
+
values: [
|
|
291
|
+
{ name: 'packageHash', type: ABIDataTypes.UINT256 },
|
|
292
|
+
{ name: 'owner', type: ABIDataTypes.ADDRESS },
|
|
293
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: 'VersionPublished',
|
|
298
|
+
type: BitcoinAbiTypes.Event,
|
|
299
|
+
values: [
|
|
300
|
+
{ name: 'packageHash', type: ABIDataTypes.UINT256 },
|
|
301
|
+
{ name: 'versionHash', type: ABIDataTypes.UINT256 },
|
|
302
|
+
{ name: 'publisher', type: ABIDataTypes.ADDRESS },
|
|
303
|
+
{ name: 'checksum', type: ABIDataTypes.UINT256 },
|
|
304
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
305
|
+
{ name: 'mldsaLevel', type: ABIDataTypes.UINT8 },
|
|
306
|
+
{ name: 'pluginType', type: ABIDataTypes.UINT8 },
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: 'VersionDeprecated',
|
|
311
|
+
type: BitcoinAbiTypes.Event,
|
|
312
|
+
values: [
|
|
313
|
+
{ name: 'packageHash', type: ABIDataTypes.UINT256 },
|
|
314
|
+
{ name: 'versionHash', type: ABIDataTypes.UINT256 },
|
|
315
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
316
|
+
],
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: 'VersionUndeprecated',
|
|
320
|
+
type: BitcoinAbiTypes.Event,
|
|
321
|
+
values: [
|
|
322
|
+
{ name: 'packageHash', type: ABIDataTypes.UINT256 },
|
|
323
|
+
{ name: 'versionHash', type: ABIDataTypes.UINT256 },
|
|
324
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
325
|
+
],
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'PackageTransferInitiated',
|
|
329
|
+
type: BitcoinAbiTypes.Event,
|
|
330
|
+
values: [
|
|
331
|
+
{ name: 'packageHash', type: ABIDataTypes.UINT256 },
|
|
332
|
+
{ name: 'currentOwner', type: ABIDataTypes.ADDRESS },
|
|
333
|
+
{ name: 'newOwner', type: ABIDataTypes.ADDRESS },
|
|
334
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
335
|
+
],
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: 'PackageTransferCompleted',
|
|
339
|
+
type: BitcoinAbiTypes.Event,
|
|
340
|
+
values: [
|
|
341
|
+
{ name: 'packageHash', type: ABIDataTypes.UINT256 },
|
|
342
|
+
{ name: 'previousOwner', type: ABIDataTypes.ADDRESS },
|
|
343
|
+
{ name: 'newOwner', type: ABIDataTypes.ADDRESS },
|
|
344
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
345
|
+
],
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: 'PackageTransferCancelled',
|
|
349
|
+
type: BitcoinAbiTypes.Event,
|
|
350
|
+
values: [
|
|
351
|
+
{ name: 'packageHash', type: ABIDataTypes.UINT256 },
|
|
352
|
+
{ name: 'owner', type: ABIDataTypes.ADDRESS },
|
|
353
|
+
{ name: 'timestamp', type: ABIDataTypes.UINT64 },
|
|
354
|
+
],
|
|
355
|
+
},
|
|
356
|
+
];
|