working example of marketplace client install and start on win

This commit is contained in:
thatben 2025-04-21 15:36:35 +02:00
parent d017b5a733
commit 77a5da5be8
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
6 changed files with 37 additions and 22 deletions

View File

@ -77,8 +77,8 @@ export class ProcessControl {
// Open issue: https://github.com/codex-storage/nim-codex/issues/1206
// So we're setting them here.
"persistence",
`--eth-provider=https://rpc.testnet.codex.storage`,
`--eth-private-key=eth.key`
`--eth-provider=${this.codexGlobals.getEthProvider()}`,
`--eth-private-key=eth.key`, // duplicated in configService.
];
await this.shell.spawnDetachedProcess(executable, workingDir, args);
};

View File

@ -109,7 +109,12 @@ export async function main() {
const configService = new ConfigService(fsService, osService);
const codexApp = new CodexApp(configService);
const pathSelector = new PathSelector(uiService, new MenuLoop(), fsService);
const ethersService = new EthersService(fsService, configService);
const ethersService = new EthersService(
fsService,
configService,
osService,
shellService,
);
const marketplaceSetup = new MarketplaceSetup(
uiService,
configService,

View File

@ -13,5 +13,5 @@ export class CodexGlobals {
getEthProvider = () => {
return "https://rpc.testnet.codex.storage";
}
};
}

View File

@ -94,22 +94,18 @@ export class ConfigService {
this.fs.writeFile(
this.getCodexConfigFilePath(),
`data-dir="${datadir}"${nl}` +
`log-level="TRACE"${nl}` +
`log-file="${codexLogFile}"${nl}` +
`storage-quota=${this.config.storageQuota}${nl}` +
`disc-port=${this.config.ports.discPort}${nl}` +
`listen-addrs=["/ip4/0.0.0.0/tcp/${this.config.ports.listenPort}"]${nl}` +
`api-port=${this.config.ports.apiPort}${nl}` +
`nat="extip:${publicIp}"${nl}` +
`api-cors-origin="*"${nl}` +
`bootstrap-node=[${bootNodes}]${nl}` +
// Marketplace client parameters:
// `[persistence]${nl}` +
//`eth-provider="${ethProvider}"${nl}` +
// `eth-provider="https://rpc.testnet.codex.storage"${nl}` +
// //`eth-private-key="${ethKeyFile}"${nl}` +
// `eth-private-key="notafile.no"${nl}` +
`${nl}`
`log-level="TRACE"${nl}` +
`log-file="${codexLogFile}"${nl}` +
`storage-quota=${this.config.storageQuota}${nl}` +
`disc-port=${this.config.ports.discPort}${nl}` +
`listen-addrs=["/ip4/0.0.0.0/tcp/${this.config.ports.listenPort}"]${nl}` +
`api-port=${this.config.ports.apiPort}${nl}` +
`nat="extip:${publicIp}"${nl}` +
`api-cors-origin="*"${nl}` +
`bootstrap-node=[${bootNodes}]${nl}` +
// Marketplace client parameters cannot be set via config file.
// Open issue: https://github.com/codex-storage/nim-codex/issues/1206
`${nl}`,
);
};
}

View File

@ -1,10 +1,12 @@
import { ethers } from 'ethers';
import { ethers } from "ethers";
import crypto from "crypto";
export class EthersService {
constructor(fsService, configService) {
constructor(fsService, configService, osService, shellService) {
this.fs = fsService;
this.configService = configService;
this.os = osService;
this.shell = shellService;
}
getOrCreateEthKey = () => {
@ -27,6 +29,14 @@ export class EthersService {
const keys = this.generateKey();
this.fs.writeFile(paths.key, keys.key);
this.fs.writeFile(paths.address, keys.address);
if (this.os.isWindows()) {
const username = this.os.getUsername();
this.shell.run(`icacls ${paths.key} /inheritance:r >nul 2>&1`);
this.shell.run(`icacls ${paths.key} /grant:r ${username}:F >nul 2>&1`);
} else {
this.shell.run(`chmod 600 "${paths.key}"`);
}
};
generateKey = () => {

View File

@ -33,4 +33,8 @@ export class OsService {
terminateProcess = (pid) => {
process.kill(pid, "SIGTERM");
};
getUsername = () => {
return os.userInfo().username;
};
}