pontus-x_cli 1.2.6 → 1.2.7
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/README.md +107 -24
- package/dist/commands/compute.d.ts +3 -2
- package/dist/commands/compute.js +53 -42
- package/dist/commands/compute.js.map +1 -1
- package/dist/commands/edit-asset-allowed.d.ts +14 -0
- package/dist/commands/edit-asset-allowed.js +143 -0
- package/dist/commands/edit-asset-allowed.js.map +1 -0
- package/dist/commands/edit-trusted-algos.d.ts +1 -1
- package/dist/commands/edit-trusted-algos.js +36 -36
- package/dist/commands/edit-trusted-algos.js.map +1 -1
- package/dist/commands/generate-manifest.d.ts +11 -0
- package/dist/commands/generate-manifest.js +71 -0
- package/dist/commands/generate-manifest.js.map +1 -0
- package/dist/commands/generate-private-keys.d.ts +12 -0
- package/dist/commands/generate-private-keys.js +80 -0
- package/dist/commands/generate-private-keys.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +48 -48
- package/dist/config.js.map +1 -1
- package/dist/lib/aquarius.d.ts +2 -1
- package/dist/lib/aquarius.js +23 -26
- package/dist/lib/aquarius.js.map +1 -1
- package/dist/utils/asset.d.ts +4 -3
- package/dist/utils/asset.js +27 -21
- package/dist/utils/asset.js.map +1 -1
- package/dist/utils/login.d.ts +2 -2
- package/dist/utils/login.js +15 -13
- package/dist/utils/login.js.map +1 -1
- package/oclif.manifest.json +200 -1
- package/package.json +2 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const config_1 = require("../config");
|
|
7
|
+
const aquarius_1 = require("../lib/aquarius");
|
|
8
|
+
const asset_1 = require("../utils/asset");
|
|
9
|
+
const connection_1 = require("../utils/connection");
|
|
10
|
+
const login_1 = require("../utils/login");
|
|
11
|
+
const nautilus_1 = require("@deltadao/nautilus");
|
|
12
|
+
const core_1 = require("@oclif/core");
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const readline_sync_1 = __importDefault(require("readline-sync"));
|
|
15
|
+
class EditAssetAllowed extends core_1.Command {
|
|
16
|
+
async run() {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
const { flags } = await this.parse(EditAssetAllowed);
|
|
19
|
+
// Validation
|
|
20
|
+
if (flags.public && ((_a = flags.users) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
21
|
+
this.error('You cannot specify user addresses and set the asset as public at the same time.');
|
|
22
|
+
}
|
|
23
|
+
if (!flags.public && !((_b = flags.users) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
24
|
+
this.error('You must either specify user addresses with -u or use --public to remove all restrictions.');
|
|
25
|
+
}
|
|
26
|
+
// Network selection
|
|
27
|
+
const network = flags.network || (0, login_1.getEnvNetwork)() || (await (0, login_1.askForNetwork)());
|
|
28
|
+
console.log(`${chalk_1.default.green('Using network:')} ${network}\n`);
|
|
29
|
+
const chainId = config_1.NETWORK_CONFIGS[network].chainId;
|
|
30
|
+
// Authentication selection
|
|
31
|
+
const loginInfos = await (0, login_1.getLoginInfos)(flags.manifest);
|
|
32
|
+
(0, login_1.printLoginInfos)(loginInfos);
|
|
33
|
+
// Asset selection
|
|
34
|
+
const assets = flags.datasets
|
|
35
|
+
? await (0, aquarius_1.getAssetsFromDids)(flags.datasets)
|
|
36
|
+
: await askForAssets(loginInfos, chainId);
|
|
37
|
+
console.log('\nThe following assets will be edited:');
|
|
38
|
+
for (const asset of assets) {
|
|
39
|
+
const ownerName = await (0, aquarius_1.getOwnerName)(asset.owner);
|
|
40
|
+
console.log(`${chalk_1.default.blue(asset.did)} | ${chalk_1.default.green(asset.created.split('T')[0])} | ${chalk_1.default.yellow(ownerName)} | ${chalk_1.default.magenta(asset.name)}`);
|
|
41
|
+
}
|
|
42
|
+
// Summary of what will change
|
|
43
|
+
if (flags.public) {
|
|
44
|
+
console.log('\nAssets will be set as public (all address restrictions removed).');
|
|
45
|
+
}
|
|
46
|
+
else if ((_c = flags.users) === null || _c === void 0 ? void 0 : _c.length) {
|
|
47
|
+
console.log('\nThe following addresses will be set as allowed users:');
|
|
48
|
+
for (const address of flags.users) {
|
|
49
|
+
console.log(` ${chalk_1.default.cyan(address)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log('\nNo users specified — assets will be set to deny all (empty allow list).');
|
|
54
|
+
}
|
|
55
|
+
// Confirmation prompt
|
|
56
|
+
if (!flags.yes &&
|
|
57
|
+
!readline_sync_1.default.keyInYNStrict('\nDo you want to proceed with editing the allowed users for the selected assets?')) {
|
|
58
|
+
console.log('Operation cancelled by the user.');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Edit each asset
|
|
62
|
+
for (const asset of assets) {
|
|
63
|
+
console.log(`Editing allowed users for asset ${chalk_1.default.gray(asset.did)} (${chalk_1.default.magenta(asset.name)})...`);
|
|
64
|
+
try {
|
|
65
|
+
const envOverrides = {
|
|
66
|
+
NETWORK: network,
|
|
67
|
+
PRIVATE_KEY: (0, login_1.getPrivateKeyForOwner)(loginInfos, asset.owner),
|
|
68
|
+
};
|
|
69
|
+
const connection = await connection_1.Connection.connect(envOverrides);
|
|
70
|
+
const aquariusAsset = await connection.nautilus.getAquariusAsset(asset.did);
|
|
71
|
+
const assetBuilder = new nautilus_1.AssetBuilder(aquariusAsset);
|
|
72
|
+
if (flags.public) {
|
|
73
|
+
;
|
|
74
|
+
[nautilus_1.CredentialListTypes.ALLOW, nautilus_1.CredentialListTypes.DENY].forEach(type => {
|
|
75
|
+
var _a, _b, _c, _d;
|
|
76
|
+
// Delete current allowed addresses
|
|
77
|
+
const existing = (_d = (_c = (_b = (_a = aquariusAsset.credentials) === null || _a === void 0 ? void 0 : _a[type]) === null || _b === void 0 ? void 0 : _b.find((c) => c.type === 'address')) === null || _c === void 0 ? void 0 : _c.values) !== null && _d !== void 0 ? _d : [];
|
|
78
|
+
assetBuilder.removeCredentialAddresses(type, existing);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
;
|
|
83
|
+
[nautilus_1.CredentialListTypes.ALLOW].forEach(type => { var _a; return assetBuilder.addCredentialAddresses(type, [asset.owner, ...((_a = flags.users) !== null && _a !== void 0 ? _a : [])]); });
|
|
84
|
+
}
|
|
85
|
+
const nautilusAsset = assetBuilder.build();
|
|
86
|
+
const result = await connection.nautilus.edit(nautilusAsset);
|
|
87
|
+
this.log(`Allowed users updated for asset, transaction: ${connection.networkConfig.explorerUri}/tx/${result.setMetadataTxReceipt.transactionHash}\n`);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
this.warn(`Error editing allowed users for asset ${asset.did}: ${error}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
EditAssetAllowed.description = 'Overwrite the list of allowed users for assets';
|
|
96
|
+
EditAssetAllowed.examples = [
|
|
97
|
+
'<%= config.bin %> <%= command.id %> -u 0xAbc123... 0xDef456... -d <assetDid1> <assetDid2>',
|
|
98
|
+
'<%= config.bin %> <%= command.id %> -u 0xAbc123... --public',
|
|
99
|
+
];
|
|
100
|
+
EditAssetAllowed.flags = {
|
|
101
|
+
users: core_1.Flags.string({
|
|
102
|
+
char: 'u',
|
|
103
|
+
description: 'Ethereum addresses of users to allow (0x...)',
|
|
104
|
+
multiple: true,
|
|
105
|
+
required: false,
|
|
106
|
+
}),
|
|
107
|
+
datasets: core_1.Flags.string({
|
|
108
|
+
char: 'd',
|
|
109
|
+
description: 'Asset DIDs to edit (did:op:...)',
|
|
110
|
+
multiple: true,
|
|
111
|
+
}),
|
|
112
|
+
yes: core_1.Flags.boolean({
|
|
113
|
+
char: 'y',
|
|
114
|
+
description: 'Skip confirmation prompt',
|
|
115
|
+
}),
|
|
116
|
+
manifest: core_1.Flags.string({
|
|
117
|
+
char: 'm',
|
|
118
|
+
description: 'Path to manifest file with the accounts to use for authentication',
|
|
119
|
+
}),
|
|
120
|
+
public: core_1.Flags.boolean({
|
|
121
|
+
char: 'p',
|
|
122
|
+
description: 'Make assets public (remove all address restrictions)',
|
|
123
|
+
}),
|
|
124
|
+
network: core_1.Flags.string({
|
|
125
|
+
char: 'n',
|
|
126
|
+
description: 'Network to use (env: NETWORK)',
|
|
127
|
+
options: Object.keys(config_1.NETWORK_CONFIGS),
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
exports.default = EditAssetAllowed;
|
|
131
|
+
async function askForAssets(loginInfos, chainId) {
|
|
132
|
+
console.log('\nPlease select the filters to find the assets you want to edit:');
|
|
133
|
+
return (0, asset_1.PromptForAssets)({
|
|
134
|
+
assetTypes: ['dataset', 'algorithm'],
|
|
135
|
+
accessTypes: ['access', 'compute'],
|
|
136
|
+
chainIds: [chainId],
|
|
137
|
+
ownerChoices: loginInfos.map(info => ({
|
|
138
|
+
name: info.ownerName,
|
|
139
|
+
value: info.ownerAddress,
|
|
140
|
+
})),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=edit-asset-allowed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-asset-allowed.js","sourceRoot":"","sources":["../../src/commands/edit-asset-allowed.ts"],"names":[],"mappings":";;;;;AAAA,qCAAwD;AACxD,6CAAgF;AAChF,yCAA+C;AAC/C,mDAA+C;AAC/C,yCAOsB;AACtB,iDAAsE;AACtE,sCAA4C;AAC5C,kDAAyB;AACzB,kEAAwC;AAExC,MAAqB,gBAAiB,SAAQ,cAAO;IAqCnD,KAAK,CAAC,GAAG;;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAEpD,aAAa;QACb,IAAI,KAAK,CAAC,M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E,OAAO,IAAA,uBAAe,EAAC;QACrB,UAAU,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;QACpC,WAAW,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;QAClC,QAAQ,EAAE,CAAC,OAAO,CAAC;QACnB,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,SAAS;YACpB,KAAK,EAAE,IAAI,CAAC,YAAY;SACzB,CAAC,CAAC;KACJ,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -3,26 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const nautilus_1 = require("@deltadao/nautilus");
|
|
7
|
-
const core_1 = require("@oclif/core");
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const readline_sync_1 = __importDefault(require("readline-sync"));
|
|
10
6
|
const config_1 = require("../config");
|
|
11
7
|
const aquarius_1 = require("../lib/aquarius");
|
|
12
8
|
const asset_1 = require("../utils/asset");
|
|
13
9
|
const connection_1 = require("../utils/connection");
|
|
14
10
|
const login_1 = require("../utils/login");
|
|
11
|
+
const nautilus_1 = require("@deltadao/nautilus");
|
|
12
|
+
const core_1 = require("@oclif/core");
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const readline_sync_1 = __importDefault(require("readline-sync"));
|
|
15
15
|
class EditTrustedAlgos extends core_1.Command {
|
|
16
16
|
async run() {
|
|
17
17
|
var _a;
|
|
18
18
|
const { flags } = await this.parse(EditTrustedAlgos);
|
|
19
19
|
// Validation
|
|
20
20
|
if (flags.public && ((_a = flags.algos) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
21
|
-
this.error(
|
|
21
|
+
this.error('You cannot specify algorithm DIDs and set the dataset as public at the same time.');
|
|
22
22
|
}
|
|
23
23
|
// Network selection
|
|
24
24
|
const network = flags.network || (0, login_1.getEnvNetwork)() || (await (0, login_1.askForNetwork)());
|
|
25
|
-
console.log(`${chalk_1.default.green(
|
|
25
|
+
console.log(`${chalk_1.default.green('Using network:')} ${network}\n`);
|
|
26
26
|
const chainId = config_1.NETWORK_CONFIGS[network].chainId;
|
|
27
27
|
// Authentication selection
|
|
28
28
|
const loginInfos = await (0, login_1.getLoginInfos)(flags.manifest);
|
|
@@ -32,10 +32,10 @@ class EditTrustedAlgos extends core_1.Command {
|
|
|
32
32
|
? await (0, aquarius_1.getAssetsFromDids)(flags.dids)
|
|
33
33
|
: await askForDatasets(loginInfos, chainId);
|
|
34
34
|
if (flags.dids) {
|
|
35
|
-
console.log(
|
|
35
|
+
console.log(`\nThe following assets will be edited ${assets.length}:`);
|
|
36
36
|
for (const asset of assets) {
|
|
37
37
|
const ownerName = await (0, aquarius_1.getOwnerName)(asset.owner);
|
|
38
|
-
console.log(`${chalk_1.default.blue(asset.did)} | ${chalk_1.default.green(asset.created.split(
|
|
38
|
+
console.log(`${chalk_1.default.blue(asset.did)} | ${chalk_1.default.green(asset.created.split('T')[0])} | ${chalk_1.default.yellow(ownerName)} | ${chalk_1.default.magenta(asset.name)}`);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
// Trusted Algorithms selection
|
|
@@ -45,26 +45,26 @@ class EditTrustedAlgos extends core_1.Command {
|
|
|
45
45
|
? await askForAlgorithms(loginInfos, chainId)
|
|
46
46
|
: [];
|
|
47
47
|
if (flags.public) {
|
|
48
|
-
console.log(
|
|
48
|
+
console.log('\nThe dataset will be set as public, all algorithms will be trusted.');
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
if (algorithms.length === 0) {
|
|
52
|
-
console.log(
|
|
52
|
+
console.log('\nNo algorithms selected, the dataset will be set as private (no trusted algorithms).');
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
if (flags.algos) {
|
|
56
|
-
console.log(
|
|
56
|
+
console.log('\nThe following algorithms will be set as trusted:');
|
|
57
57
|
for (const algo of algorithms) {
|
|
58
58
|
const ownerName = await (0, aquarius_1.getOwnerName)(algo.owner);
|
|
59
|
-
console.log(`${chalk_1.default.blue(algo.did)} | ${chalk_1.default.green(algo.created.split(
|
|
59
|
+
console.log(`${chalk_1.default.blue(algo.did)} | ${chalk_1.default.green(algo.created.split('T')[0])} | ${chalk_1.default.yellow(ownerName)} | ${chalk_1.default.magenta(algo.name)}`);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
// Confirmation prompt
|
|
65
65
|
if (!flags.yes &&
|
|
66
|
-
!readline_sync_1.default.keyInYNStrict(
|
|
67
|
-
console.log(
|
|
66
|
+
!readline_sync_1.default.keyInYNStrict(`\nDo you want to proceed with editing the trusted algorithms for the selected (${assets.length}) datasets?`)) {
|
|
67
|
+
console.log('Operation cancelled by the user.');
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
// Edit trusted algorithms for each selected dataset
|
|
@@ -108,59 +108,59 @@ class EditTrustedAlgos extends core_1.Command {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
EditTrustedAlgos.description =
|
|
111
|
+
EditTrustedAlgos.description = 'Overwrite datasets trusted algorithms';
|
|
112
112
|
EditTrustedAlgos.examples = [
|
|
113
|
-
|
|
113
|
+
'<%= config.bin %> <%= command.id %> -d <datasetDid1> <datasetDid2> ... -a <algorithmDid1> <algorithmDid2> ...',
|
|
114
114
|
];
|
|
115
115
|
EditTrustedAlgos.flags = {
|
|
116
116
|
datasets: core_1.Flags.string({
|
|
117
|
-
char:
|
|
118
|
-
description:
|
|
117
|
+
char: 'd',
|
|
118
|
+
description: 'Dataset DIDs (did:op:...)',
|
|
119
119
|
multiple: true,
|
|
120
120
|
}),
|
|
121
121
|
algorithms: core_1.Flags.string({
|
|
122
|
-
char:
|
|
123
|
-
description:
|
|
122
|
+
char: 'a',
|
|
123
|
+
description: 'Trusted algorithm DIDs (did:op:...)',
|
|
124
124
|
multiple: true,
|
|
125
125
|
}),
|
|
126
126
|
yes: core_1.Flags.boolean({
|
|
127
|
-
char:
|
|
128
|
-
description:
|
|
127
|
+
char: 'y',
|
|
128
|
+
description: 'Skip confirmation prompt',
|
|
129
129
|
}),
|
|
130
130
|
manifest: core_1.Flags.string({
|
|
131
|
-
char:
|
|
132
|
-
description:
|
|
131
|
+
char: 'm',
|
|
132
|
+
description: 'Path to manifest file with the accounts to use for authentication',
|
|
133
133
|
}),
|
|
134
134
|
public: core_1.Flags.boolean({
|
|
135
|
-
char:
|
|
136
|
-
description:
|
|
135
|
+
char: 'p',
|
|
136
|
+
description: 'Make dataset public (set all algorithms as trusted)',
|
|
137
137
|
}),
|
|
138
138
|
network: core_1.Flags.string({
|
|
139
|
-
char:
|
|
140
|
-
description:
|
|
139
|
+
char: 'n',
|
|
140
|
+
description: 'Network to use (env: NETWORK)',
|
|
141
141
|
options: Object.keys(config_1.NETWORK_CONFIGS),
|
|
142
142
|
}),
|
|
143
143
|
};
|
|
144
144
|
exports.default = EditTrustedAlgos;
|
|
145
145
|
async function askForDatasets(loginInfos, chainId) {
|
|
146
|
-
console.log(
|
|
146
|
+
console.log('\nPlease select the filters to find the datasets you want to edit:');
|
|
147
147
|
return (0, asset_1.PromptForAssets)({
|
|
148
|
-
assetTypes: [
|
|
149
|
-
accessTypes: [
|
|
148
|
+
assetTypes: ['dataset'],
|
|
149
|
+
accessTypes: ['compute'],
|
|
150
150
|
chainIds: [chainId],
|
|
151
|
-
ownerChoices: loginInfos.map(
|
|
151
|
+
ownerChoices: loginInfos.map(info => ({
|
|
152
152
|
name: info.ownerName,
|
|
153
153
|
value: info.ownerAddress,
|
|
154
154
|
})),
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
async function askForAlgorithms(loginInfos, chainId) {
|
|
158
|
-
console.log(
|
|
158
|
+
console.log('\nPlease select the filters to find the algorithms you want to set as trusted:');
|
|
159
159
|
return (0, asset_1.PromptForAssets)({
|
|
160
|
-
assetTypes: [
|
|
161
|
-
accessTypes: [
|
|
160
|
+
assetTypes: ['algorithm'],
|
|
161
|
+
accessTypes: ['compute'],
|
|
162
162
|
chainIds: [chainId],
|
|
163
|
-
ownerChoices: loginInfos.map(
|
|
163
|
+
ownerChoices: loginInfos.map(info => ({
|
|
164
164
|
name: info.ownerName,
|
|
165
165
|
value: info.ownerAddress,
|
|
166
166
|
})),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-trusted-algos.js","sourceRoot":"","sources":["../../src/commands/edit-trusted-algos.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"edit-trusted-algos.js","sourceRoot":"","sources":["../../src/commands/edit-trusted-algos.ts"],"names":[],"mappings":";;;;;AAAA,qCAAwD;AACxD,6CAAgF;AAChF,yCAA+C;AAC/C,mDAA+C;AAC/C,yCAOsB;AACtB,iDAAiE;AACjE,sCAA4C;AAC5C,kDAAyB;AACzB,kEAAwC;AAExC,MAAqB,gBAAiB,SAAQ,cAAO;IAmCnD,KAAK,CAAC,GAAG;;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAEpD,aAAa;QACb,IAAI,KAAK,CAAC,MAAM,KAAI,MAAA,KAAK,CAAC,KAAK,0CAAE,MAAM,CAAA,EAAE,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,mFAAmF,CAAC,CAAA;QACjG,CAAC;QAED,oBAAoB;QACpB,MAAM,OAAO,GAAI,KAAK,CAAC,OAAmB,IAAI,IAAA,qBAAa,GAAE,IAAI,CAAC,MAAM,IAAA,qBAAa,GAAE,CAAC,CAAA;QACxF,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,OAAO,IAAI,CA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UAAuB,EAAE,OAAe;IACpE,OAAO,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAA;IACjF,OAAO,IAAA,uBAAe,EAAC;QACrB,UAAU,EAAE,CAAC,SAAS,CAAC;QACvB,WAAW,EAAE,CAAC,SAAS,CAAC;QACxB,QAAQ,EAAE,CAAC,OAAO,CAAC;QACnB,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,SAAS;YACpB,KAAK,EAAE,IAAI,CAAC,YAAY;SACzB,CAAC,CAAC;KACJ,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,UAAuB,EAAE,OAAe;IACtE,OAAO,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAA;IAC7F,OAAO,IAAA,uBAAe,EAAC;QACrB,UAAU,EAAE,CAAC,WAAW,CAAC;QACzB,WAAW,EAAE,CAAC,SAAS,CAAC;QACxB,QAAQ,EAAE,CAAC,OAAO,CAAC;QACnB,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,SAAS;YACpB,KAAK,EAAE,IAAI,CAAC,YAAY;SACzB,CAAC,CAAC;KACJ,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class GenerateManifest extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: Command.Example[];
|
|
5
|
+
static flags: {
|
|
6
|
+
'keys-dir': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
'password-env': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
output: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = require("@oclif/core");
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
class GenerateManifest extends core_1.Command {
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(GenerateManifest);
|
|
12
|
+
const keysDir = flags['keys-dir'];
|
|
13
|
+
const passwordEnvKey = flags['password-env'];
|
|
14
|
+
const outputFile = flags.output;
|
|
15
|
+
if (!node_fs_1.default.existsSync(keysDir)) {
|
|
16
|
+
this.error(`Keys directory not found: ${keysDir}`);
|
|
17
|
+
}
|
|
18
|
+
const keyFiles = node_fs_1.default
|
|
19
|
+
.readdirSync(keysDir)
|
|
20
|
+
.filter(f => f.endsWith('.json'))
|
|
21
|
+
.sort();
|
|
22
|
+
if (keyFiles.length === 0) {
|
|
23
|
+
this.error(`No JSON key files found in ${keysDir}`);
|
|
24
|
+
}
|
|
25
|
+
console.log(`Found ${keyFiles.length} key file(s) in ${keysDir}\n`);
|
|
26
|
+
const lines = ['accounts:', ''];
|
|
27
|
+
keyFiles.forEach((file, i) => {
|
|
28
|
+
const filePath = node_path_1.default.join(keysDir, file);
|
|
29
|
+
let address;
|
|
30
|
+
try {
|
|
31
|
+
const json = JSON.parse(node_fs_1.default.readFileSync(filePath, 'utf-8'));
|
|
32
|
+
address = `0x${json.address}`;
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
this.warn(`Skipping ${file}: could not parse JSON or missing address field`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
lines.push(`- name: "Address #${i + 1}"`);
|
|
39
|
+
lines.push(` address: '${address}'`);
|
|
40
|
+
lines.push(` privateKeyPath: ${node_path_1.default.join(keysDir, file)}`);
|
|
41
|
+
lines.push(` passwordEnvKey: ${passwordEnvKey}`);
|
|
42
|
+
lines.push('');
|
|
43
|
+
});
|
|
44
|
+
node_fs_1.default.writeFileSync(outputFile, lines.join('\n'));
|
|
45
|
+
console.log(`Manifest written to ${outputFile}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
GenerateManifest.description = 'Generate a YAML manifest file from a folder of encrypted key JSON files';
|
|
49
|
+
GenerateManifest.examples = [
|
|
50
|
+
'<%= config.bin %> <%= command.id %> --keys-dir ./keys --password-env KEY_PASSWORD',
|
|
51
|
+
'<%= config.bin %> <%= command.id %> --keys-dir ./keys --password-env KEY_PASSWORD --output manifest.yaml',
|
|
52
|
+
];
|
|
53
|
+
GenerateManifest.flags = {
|
|
54
|
+
'keys-dir': core_1.Flags.string({
|
|
55
|
+
char: 'k',
|
|
56
|
+
description: 'Directory containing the encrypted key JSON files',
|
|
57
|
+
required: true,
|
|
58
|
+
}),
|
|
59
|
+
'password-env': core_1.Flags.string({
|
|
60
|
+
char: 'e',
|
|
61
|
+
description: 'Environment variable name to use as passwordEnvKey for all accounts',
|
|
62
|
+
required: true,
|
|
63
|
+
}),
|
|
64
|
+
output: core_1.Flags.string({
|
|
65
|
+
char: 'o',
|
|
66
|
+
description: 'Output YAML file path (default: manifest.yaml)',
|
|
67
|
+
default: 'manifest.yaml',
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
exports.default = GenerateManifest;
|
|
71
|
+
//# sourceMappingURL=generate-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-manifest.js","sourceRoot":"","sources":["../../src/commands/generate-manifest.ts"],"names":[],"mappings":";;;;;AAAA,sCAA4C;AAC5C,sDAAwB;AACxB,0DAA4B;AAE5B,MAAqB,gBAAiB,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
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class GeneratePrivateKeys extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: Command.Example[];
|
|
5
|
+
static flags: {
|
|
6
|
+
count: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
+
'output-dir': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
|
+
password: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
|
+
mnemonic: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = require("@oclif/core");
|
|
7
|
+
const bip39_1 = require("bip39");
|
|
8
|
+
const ethereumjs_wallet_1 = require("ethereumjs-wallet");
|
|
9
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const readline_sync_1 = __importDefault(require("readline-sync"));
|
|
13
|
+
class GeneratePrivateKeys extends core_1.Command {
|
|
14
|
+
async run() {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const { flags } = await this.parse(GeneratePrivateKeys);
|
|
17
|
+
const mnemonic = (_a = flags.mnemonic) !== null && _a !== void 0 ? _a : readline_sync_1.default.question('\nExporting accounts from a mnemonic phrase as encrypted JSON files...\n' +
|
|
18
|
+
'Please paste your BIP39 mnemonic phrase (12 or 24 words): ', { hideEchoBack: true });
|
|
19
|
+
const password = (_b = flags.password) !== null && _b !== void 0 ? _b : readline_sync_1.default.question('Enter a password to encrypt all generated key files: ', { hideEchoBack: true });
|
|
20
|
+
const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic);
|
|
21
|
+
const root = ethereumjs_wallet_1.hdkey.fromMasterSeed(seed);
|
|
22
|
+
if (!node_fs_1.default.existsSync(flags['output-dir'])) {
|
|
23
|
+
node_fs_1.default.mkdirSync(flags['output-dir'], { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
console.log(`\nGenerating ${flags.count} account(s)...\n`);
|
|
26
|
+
for (let i = 0; i < flags.count; i++) {
|
|
27
|
+
const derivationPath = `m/44'/60'/0'/0/${i}`;
|
|
28
|
+
const child = root.derivePath(derivationPath);
|
|
29
|
+
const account = child.getWallet();
|
|
30
|
+
const address = account.getAddress().toString('hex');
|
|
31
|
+
console.log(`[${i}] Address: 0x${address} (${derivationPath})`);
|
|
32
|
+
await account
|
|
33
|
+
.toV3(password, {
|
|
34
|
+
dklen: 32,
|
|
35
|
+
kdf: 'scrypt',
|
|
36
|
+
n: 2 ** 14,
|
|
37
|
+
p: 1,
|
|
38
|
+
r: 8,
|
|
39
|
+
salt: node_crypto_1.default.randomBytes(32),
|
|
40
|
+
})
|
|
41
|
+
.then(value => {
|
|
42
|
+
const file = node_path_1.default.join(flags['output-dir'], `${address}.json`);
|
|
43
|
+
node_fs_1.default.writeFileSync(file, JSON.stringify(value));
|
|
44
|
+
console.log(` Saved to ${file}`);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
console.log('\nDone.\n');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
GeneratePrivateKeys.description = 'Export accounts derived from a mnemonic phrase as encrypted JSON files, to use later with the login command or for Pontus-X portals automation';
|
|
51
|
+
GeneratePrivateKeys.examples = [
|
|
52
|
+
'<%= config.bin %> <%= command.id %>',
|
|
53
|
+
'<%= config.bin %> <%= command.id %> --count 5 --output-dir ./keys',
|
|
54
|
+
];
|
|
55
|
+
GeneratePrivateKeys.flags = {
|
|
56
|
+
count: core_1.Flags.integer({
|
|
57
|
+
char: 'c',
|
|
58
|
+
description: 'Number of accounts to generate (default is 1)',
|
|
59
|
+
default: 1,
|
|
60
|
+
required: false,
|
|
61
|
+
}),
|
|
62
|
+
'output-dir': core_1.Flags.string({
|
|
63
|
+
char: 'o',
|
|
64
|
+
description: 'Directory to save the encrypted JSON files (default is current directory)',
|
|
65
|
+
required: false,
|
|
66
|
+
default: '.',
|
|
67
|
+
}),
|
|
68
|
+
password: core_1.Flags.string({
|
|
69
|
+
char: 'p',
|
|
70
|
+
description: 'Password to encrypt the key files',
|
|
71
|
+
required: false,
|
|
72
|
+
}),
|
|
73
|
+
mnemonic: core_1.Flags.string({
|
|
74
|
+
char: 'm',
|
|
75
|
+
description: 'Your BIP39 mnemonic phrase',
|
|
76
|
+
required: false,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
exports.default = GeneratePrivateKeys;
|
|
80
|
+
//# sourceMappingURL=generate-private-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-private-keys.js","sourceRoot":"","sources":["../../src/commands/generate-private-keys.ts"],"names":[],"mappings":";;;;;AAAA,sCAA4C;AAC5C,iCAA0C;AAC1C,yDAAyC;AACzC,8DAAgC;AAChC,sDAAwB;AACxB,0DAA4B;AAC5B,kEAAwC;AAExC,MAAqB,mBAAoB,SAAQ,cAAO;IAgCtD,KAAK,CAAC,GAAG;;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;QAEvD,MAAM,QAAQ,GACZ,MAAA,KAAK,CAAC,QAAQ,mCACd,uBAAY,CAAC,QAAQ,CACnB,0EAA0E;YACxE,4DAA4D,EAC9D,EAAE,YAAY,EAAE,IAAI,EAAE,CACvB,CAAA;QAEH,MAAM,QAAQ,GAC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