Skip to content

Commit 636fd16

Browse files
committed
Enhance CLI with fake wallet configuration and add prepublish script to package.json
1 parent 9ecd312 commit 636fd16

File tree

8 files changed

+56
-16
lines changed

8 files changed

+56
-16
lines changed

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser',
3-
extends: ['eslint:recommended', '@typescript-eslint/recommended'],
3+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
44
plugins: ['@typescript-eslint'],
55
env: {
66
node: true,
@@ -9,6 +9,7 @@ module.exports = {
99
parserOptions: {
1010
ecmaVersion: 2022,
1111
sourceType: 'module',
12+
project: './tsconfig.json',
1213
},
1314
rules: {
1415
// Simple rules - not overly strict
@@ -20,6 +21,12 @@ module.exports = {
2021
'prefer-const': 'error',
2122
'no-var': 'error',
2223
'no-console': 'off', // Allow console for CLI
24+
25+
// Promise/async rules to catch unawaited promises
26+
'@typescript-eslint/no-floating-promises': 'error',
27+
'@typescript-eslint/no-misused-promises': 'error',
28+
'@typescript-eslint/await-thenable': 'error',
29+
'@typescript-eslint/require-await': 'warn',
2330
},
24-
ignorePatterns: ['dist/', 'node_modules/'],
31+
ignorePatterns: ['dist/', 'node_modules/', '.eslintrc.cjs'],
2532
};

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ixo-oracles-cli",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "CLI tool for creating and managing IXO Oracle projects",
55
"main": "dist/cli.js",
66
"type": "module",
@@ -14,7 +14,8 @@
1414
"test": "jest",
1515
"lint": "eslint src/**/*.ts",
1616
"lint:fix": "eslint src/**/*.ts --fix",
17-
"type-check": "tsc --noEmit"
17+
"type-check": "tsc --noEmit",
18+
"prepublishOnly": "pnpm build"
1819
},
1920
"keywords": [
2021
"cli",
@@ -67,8 +68,8 @@
6768
"@types/md5": "^2.3.5",
6869
"@types/node": "^22.0.0",
6970
"@types/qrcode-terminal": "^0.12.2",
70-
"@typescript-eslint/eslint-plugin": "^7.0.0",
71-
"@typescript-eslint/parser": "^7.0.0",
71+
"@typescript-eslint/eslint-plugin": "^8.39.0",
72+
"@typescript-eslint/parser": "^8.39.0",
7273
"eslint": "^8.57.0",
7374
"jest": "^29.7.0",
7475
"ts-jest": "^29.1.0",

src/cli.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ class CLIManager {
2929
}
3030

3131
private async showHelp(): Promise<void> {
32+
// add fake wallet to the config
33+
this.wallet.setWallet({
34+
address: '0x0000000000000000000000000000000000000000',
35+
algo: 'secp',
36+
did: 'did:ixo:entity:1a76366f16570483cea72b111b27fd78',
37+
network: 'devnet',
38+
name: 'My oracle',
39+
pubKey:
40+
'0x0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
41+
ledgered: false,
42+
matrix: {
43+
accessToken: '',
44+
userId: '0x0000000000000000000000000000000000000000',
45+
address: '',
46+
roomId: '',
47+
},
48+
});
3249
this.registerCommands();
3350
const helpCommand = new HelpCommand(this.registry);
3451
const result = await helpCommand.execute();

src/commands/init.command.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ export class InitCommand implements Command {
177177
p.log.error('Failed to create Oracle Entity and Matrix Account');
178178
}
179179

180-
createProjectEnvFile(this.config);
181-
p.log.warning(`Environment file created at ${path.join(projectPath, '.env')}`);
180+
await createProjectEnvFile(this.config);
182181
// Show success message with next steps
183182
p.log.success(
184183
`\n✅ IXO project created successfully!\n\n` +

src/commands/logout.commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class LogoutCommand implements Command {
1515
initialValue: false,
1616
});
1717
if (shouldClear) {
18-
this.wallet.clearWallet();
18+
await this.wallet.clearWallet();
1919
return {
2020
success: true,
2121
data: 'Logged out successfully',

src/utils/create-project-env-file.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ export const createProjectEnvFile = async (config: RuntimeConfig) => {
1111
deviceName: config.getOrThrow('registerUserResult').matrixDeviceName,
1212
});
1313
const network = config.getOrThrow('network');
14-
const envFile = path.join(config.getOrThrow('projectPath'), 'apps', 'app', '.env');
14+
const projectPath = config.getOrThrow('projectPath');
15+
const envFile = path.join(projectPath, 'apps', 'app', '.env');
16+
17+
console.log('Creating .env file at:', envFile);
18+
console.log('Project path:', projectPath);
19+
20+
// Ensure the directory exists
21+
const envDir = path.dirname(envFile);
22+
if (!fs.existsSync(envDir)) {
23+
console.log('Creating directory:', envDir);
24+
fs.mkdirSync(envDir, { recursive: true });
25+
}
1526
const envContent = `
1627
PORT=4000
1728
ORACLE_NAME=${config.getValue('projectName')}
@@ -21,6 +32,7 @@ MATRIX_BASE_URL=${MatrixHomeServerUrl[network]}
2132
MATRIX_ORACLE_ADMIN_ACCESS_TOKEN=${freshMx.accessToken}
2233
MATRIX_ORACLE_ADMIN_PASSWORD=${config.getOrThrow('registerUserResult').matrixPassword}
2334
MATRIX_ORACLE_ADMIN_USER_ID=${config.getOrThrow('registerUserResult').matrixUserId}
35+
MATRIX_RECOVERY_PHRASE=${config.getOrThrow('registerUserResult').matrixRecoveryPhrase}
2436
2537
# OPENAI
2638
OPENAI_API_KEY=
@@ -41,5 +53,11 @@ ORACLE_MNEMONIC=${config.getOrThrow('registerUserResult').mnemonic}
4153
MATRIX_VAULT_PIN=${config.getOrThrow('registerUserResult').pin}
4254
ENTITY_DID=${config.getOrThrow('entityDid')}
4355
`;
44-
fs.writeFileSync(envFile, envContent);
56+
try {
57+
fs.writeFileSync(envFile, envContent);
58+
console.log('✅ .env file created successfully at:', envFile);
59+
} catch (error) {
60+
console.error('❌ Failed to create .env file:', error);
61+
throw error;
62+
}
4563
};

src/utils/entity.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { LinkedResource, Service } from '@ixo/impactxclient-sdk/types/codegen/ix
44
import { NETWORK } from '@ixo/signx-sdk/types/types/transact';
55
import { registerUserSimplified } from './account/simplifiedRegistration';
66
import { checkRequiredString, RELAYER_NODE_DID } from './common';
7-
import { Room } from './matrix';
87
import { publicUpload } from './matrix/upload-to-matrix';
98
import { RuntimeConfig } from './runtime-config';
109
import { Wallet } from './wallet';
@@ -431,8 +430,6 @@ export class CreateEntity {
431430
log.success('Entity created -- config files attached');
432431
const s = spinner();
433432
s.start('Creating Entity Matrix Room...');
434-
const room = new Room(this.config, this.wallet);
435-
const roomId = await room.sourceRoomAndJoin(did);
436433
s.stop('Room created -- room joined');
437434
log.warn('Please save the following information in a secure location as it is not stored:');
438435
log.info(`ORACLE ACCOUNT DETAILS`);

src/utils/wallet.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { cosmos } from '@ixo/impactxclient-sdk';
22
import { existsSync, readFileSync, writeFileSync } from 'fs';
33
import { unlink } from 'fs/promises';
4+
import os from 'os';
45
import path from 'path';
56
import { SignXClient } from './signx/signx';
67
import { WalletProps } from './signx/types';
78

89
// Use hidden .wallet.json file in user's home directory
9-
// const WALLET_PATH = path.join(os.homedir(), '.wallet.json');
10+
const WALLET_PATH = path.join(os.homedir(), '.wallet.json');
1011

1112
// for dev make it here
12-
const WALLET_PATH = path.join(__dirname, '.wallet.json');
13+
// const WALLET_PATH = path.join(__dirname, '.wallet.json');
1314

1415
export class Wallet {
1516
public wallet: WalletProps | undefined;

0 commit comments

Comments
 (0)