Skip to content

Commit

Permalink
fix: updated libraries to latests. (#370)
Browse files Browse the repository at this point in the history
fix: updated sdk to latest alpha
fix: migrated noble to @noble/ed25519 lib
  • Loading branch information
fboucquez authored Feb 2, 2022
1 parent 75cd67e commit 7dcd80b
Show file tree
Hide file tree
Showing 30 changed files with 1,935 additions and 1,763 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e
- `BootstrapUtils` code clean up split.
- Allowing user provided compose services via custom preset.
- Added `services` assembly.
- Lib upgrades.

## [1.1.3] - Jan-21-2022

Expand Down
2 changes: 1 addition & 1 deletion docs/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ EXAMPLES
$ symbol-bootstrap autocomplete --refresh-cache
```

_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v0.3.0/src/commands/autocomplete/index.ts)_
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.2.0/src/commands/autocomplete/index.ts)_
2 changes: 1 addition & 1 deletion docs/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ OPTIONS
--all see all commands in CLI
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.17/src/commands/help.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.18/src/commands/help.ts)_
3,432 changes: 1,794 additions & 1,638 deletions package-lock.json

Large diffs are not rendered by default.

88 changes: 43 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,67 @@
},
"bugs": "https://github.com/fboucquez/symbol-bootstrap/issues",
"dependencies": {
"@oclif/command": "^1.8.12",
"@oclif/config": "^1.18.2",
"@oclif/plugin-autocomplete": "^0.3.0",
"@oclif/plugin-help": "^3.2.17",
"archiver": "^5.2.0",
"cross-fetch": "^3.1.4",
"figlet": "^1.2.4",
"@noble/ed25519": "^1.5.3",
"@oclif/command": "^1.8.16",
"@oclif/config": "^1.18.3",
"@oclif/plugin-autocomplete": "^1.2.0",
"@oclif/plugin-help": "^5.1.11",
"archiver": "^5.3.0",
"cross-fetch": "^3.1.5",
"figlet": "^1.5.2",
"handlebars": "^4.7.7",
"inquirer": "^7.3.3",
"inquirer": "^8.2.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"memorystream": "^0.3.1",
"noble-ed25519": "^1.0.3",
"node-stream-zip": "^1.12.0",
"rxjs": "^6.6.3",
"node-stream-zip": "^1.15.0",
"rxjs": "^7.5.2",
"semver": "^7.3.5",
"shx": "^0.3.2",
"symbol-sdk": "^1.0.3",
"symbol-statistics-service-typescript-fetch-client": "^1.1.3",
"tslib": "^1.13.0",
"utf8": "^2.1.2",
"winston": "^3.3.3"
"shx": "^0.3.4",
"symbol-sdk": "^1.0.4-alpha-202112211435",
"symbol-statistics-service-typescript-fetch-client": "^1.1.5",
"tslib": "^2.3.1",
"utf8": "^3.0.0",
"winston": "^3.5.1"
},
"devDependencies": {
"@oclif/dev-cli": "^1.26.9",
"@oclif/dev-cli": "^1.26.10",
"@oclif/test": "^1.2.8",
"@types/archiver": "^5.1.0",
"@types/chai": "^4.2.12",
"@types/figlet": "^1.2.0",
"@types/archiver": "^5.3.1",
"@types/chai": "^4.3.0",
"@types/figlet": "^1.5.4",
"@types/handlebars": "^4.1.0",
"@types/inquirer": "^7.3.1",
"@types/inquirer": "^8.2.0",
"@types/js-yaml": "^4.0.5",
"@types/lodash": "^4.14.165",
"@types/lodash": "^4.14.178",
"@types/memorystream": "^0.3.0",
"@types/mocha": "^8.2.2",
"@types/node": "^10.17.28",
"@types/semver": "^7.3.6",
"@types/sinon": "^10.0.4",
"@types/mocha": "^9.1.0",
"@types/node": "^17.0.14",
"@types/semver": "^7.3.9",
"@types/sinon": "^10.0.9",
"@types/winston": "^2.4.4",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"chai": "^4.2.0",
"coveralls": "^3.1.0",
"create-ts-index": "^1.13.7",
"dir-compare": "^3.3.0",
"eslint": "^8.0.1",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"chai": "^4.3.6",
"coveralls": "^3.1.1",
"create-ts-index": "^1.14.0",
"dir-compare": "^4.0.0",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"globby": "^10.0.2",
"marked": ">=2.0.0",
"mocha": "^9.1.3",
"marked": ">=4.0.12",
"mocha": "^9.2.0",
"mocha-lcov-reporter": "^1.3.0",
"mock-stdin": "^1.0.0",
"nock": "^13.1.1",
"nock": "^13.2.2",
"nyc": "^15.1.0",
"prettier": "^2.3.2",
"prettier-plugin-organize-imports": "^1.1.1",
"rxjs": "^6.6.3",
"rxjs-compat": "^6.6.3",
"sinon": "^11.1.2",
"ts-node": "^8.10.2",
"typedoc": "^0.20.34",
"typescript": "^3.9.7"
"prettier": "^2.5.1",
"prettier-plugin-organize-imports": "^2.3.4",
"sinon": "^13.0.1",
"ts-node": "^10.4.0",
"typedoc": "^0.22.11",
"typescript": "^4.5.5"
},
"engines": {
"node": ">=12.0.0"
Expand Down
8 changes: 4 additions & 4 deletions src/commands/updateVotingKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { Command, flags } from '@oclif/command';
import { LoggerFactory, System } from '../logger';
import { ConfigPreset } from '../model';
import { CommandUtils, ConfigLoader, Constants, CryptoUtils, RemoteNodeService, VotingService, YamlUtils } from '../service';
import { CommandUtils, ConfigLoader, Constants, CryptoUtils, RemoteNodeService, Utils, VotingService, YamlUtils } from '../service';

export default class UpdateVotingKeys extends Command {
static description = `It updates the voting files containing the voting keys when required.
Expand Down Expand Up @@ -64,9 +64,9 @@ When a new voting file is created, Bootstrap will advise running the \`link\` co
});
} catch (e) {
throw new Error(
`Node's preset cannot be loaded. Have you provided the right --target? If you have, please rerun the 'config' command with --upgrade. Error: ${
e.message || 'unknown'
}`,
`Node's preset cannot be loaded. Have you provided the right --target? If you have, please rerun the 'config' command with --upgrade. Error: ${Utils.getMessage(
e,
)}`,
);
}
const addresses = configLoader.loadExistingAddresses(target, password);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export class Wizard {
);
}

public async resolveFileContent(encoding: string, message: string, notFoundMessage: string): Promise<string> {
public async resolveFileContent(encoding: 'base64', message: string, notFoundMessage: string): Promise<string> {
const { value } = await prompt([
{
name: 'value',
Expand Down
34 changes: 18 additions & 16 deletions src/service/AnnounceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
import { flags } from '@oclif/command';
import { prompt } from 'inquirer';
import { firstValueFrom } from 'rxjs';
import {
Account,
AccountInfo,
Expand Down Expand Up @@ -46,6 +47,7 @@ import { AccountResolver } from './AccountResolver';
import { CommandUtils } from './CommandUtils';
import { KeyName } from './ConfigService';
import { TransactionUtils } from './TransactionUtils';
import { Utils } from './Utils';

export interface TransactionFactoryParams {
presetData: ConfigPreset;
Expand Down Expand Up @@ -123,19 +125,19 @@ export class AnnounceService {
presetData,
useKnownRestGateways ? undefined : url,
);
const networkType = await repositoryFactory.getNetworkType().toPromise();
const networkType = await firstValueFrom(repositoryFactory.getNetworkType());
const transactionRepository = repositoryFactory.createTransactionRepository();
const transactionService = new TransactionService(transactionRepository, repositoryFactory.createReceiptRepository());
const epochAdjustment = await repositoryFactory.getEpochAdjustment().toPromise();
const epochAdjustment = await firstValueFrom(repositoryFactory.getEpochAdjustment());
const listener = repositoryFactory.createListener();
await listener.open();
const faucetUrl = presetData.faucetUrl;
const currency = (await repositoryFactory.getCurrencies().toPromise()).currency;
const currency = (await firstValueFrom(repositoryFactory.getCurrencies())).currency;
const currencyMosaicId = currency.mosaicId;
const deadline = Deadline.create(epochAdjustment);
const minFeeMultiplier = (await repositoryFactory.createNetworkRepository().getTransactionFees().toPromise()).minFeeMultiplier;
const latestFinalizedBlockEpoch = (await repositoryFactory.createChainRepository().getChainInfo().toPromise()).latestFinalizedBlock
.finalizationEpoch;
const minFeeMultiplier = (await firstValueFrom(repositoryFactory.createNetworkRepository().getTransactionFees())).minFeeMultiplier;
const latestFinalizedBlockEpoch = (await firstValueFrom(repositoryFactory.createChainRepository().getChainInfo()))
.latestFinalizedBlock.finalizationEpoch;
if (!currencyMosaicId) {
throw new Error('Mosaic Id must not be null!');
}
Expand All @@ -145,7 +147,7 @@ export class AnnounceService {
this.logger.info(`Node's minFeeMultiplier is ${minFeeMultiplier}`);
}

const generationHash = await repositoryFactory.getGenerationHash().toPromise();
const generationHash = await firstValueFrom(repositoryFactory.getGenerationHash());
if (generationHash?.toUpperCase() !== presetData.nemesisGenerationHashSeed?.toUpperCase()) {
throw new Error(
`You are connecting to the wrong network. Expected generation hash is ${presetData.nemesisGenerationHashSeed} but got ${generationHash}`,
Expand Down Expand Up @@ -480,7 +482,7 @@ export class AnnounceService {

private async getAccountInfo(repositoryFactory: RepositoryFactory, mainAccountAddress: Address): Promise<AccountInfo | undefined> {
try {
return await repositoryFactory.createAccountRepository().getAccountInfo(mainAccountAddress).toPromise();
return await firstValueFrom(repositoryFactory.createAccountRepository().getAccountInfo(mainAccountAddress));
} catch (e) {
return undefined;
}
Expand All @@ -494,7 +496,7 @@ export class AnnounceService {
const accountRepository = repositoryFactory.createAccountRepository();
for (const cosigner of cosigners) {
try {
const accountInfo = await accountRepository.getAccountInfo(cosigner.address).toPromise();
const accountInfo = await firstValueFrom(accountRepository.getAccountInfo(cosigner.address));
if (!this.isAccountEmpty(accountInfo, currencyMosaicId)) {
return cosigner;
}
Expand Down Expand Up @@ -558,15 +560,15 @@ export class AnnounceService {

try {
this.logger.info(`Announcing ${this.getTransactionDescription(lockFundsTransaction, signedLockFundsTransaction, currency)}`);
await transactionService.announce(signedLockFundsTransaction, listener).toPromise();
await firstValueFrom(transactionService.announce(signedLockFundsTransaction, listener));
this.logger.info(
`${this.getTransactionDescription(lockFundsTransaction, signedLockFundsTransaction, currency)} has been confirmed`,
);

this.logger.info(
`Announcing Bonded ${this.getTransactionDescription(aggregateTransaction, signedAggregateTransaction, currency)}`,
);
await transactionService.announceAggregateBonded(signedAggregateTransaction, listener).toPromise();
await firstValueFrom(transactionService.announceAggregateBonded(signedAggregateTransaction, listener));
this.logger.info(
`${this.getTransactionDescription(aggregateTransaction, signedAggregateTransaction, currency)} has been announced`,
);
Expand All @@ -576,7 +578,7 @@ export class AnnounceService {
const message =
`Aggregate Bonded Transaction ${signedAggregateTransaction.type} ${
signedAggregateTransaction.hash
} - signer ${signedAggregateTransaction.getSignerAddress().plain()} failed!! ` + e.message;
} - signer ${signedAggregateTransaction.getSignerAddress().plain()} failed!! ` + Utils.getMessage(e);
this.logger.error(message);
return false;
}
Expand Down Expand Up @@ -616,7 +618,7 @@ export class AnnounceService {
}
try {
this.logger.info(`Announcing ${this.getTransactionDescription(aggregateTransaction, signedAggregateTransaction, currency)}`);
await transactionService.announce(signedAggregateTransaction, listener).toPromise();
await firstValueFrom(transactionService.announce(signedAggregateTransaction, listener));
this.logger.info(
`${this.getTransactionDescription(aggregateTransaction, signedAggregateTransaction, currency)} has been confirmed`,
);
Expand All @@ -625,7 +627,7 @@ export class AnnounceService {
const message =
`Aggregate Complete Transaction ${signedAggregateTransaction.type} ${
signedAggregateTransaction.hash
} - signer ${signedAggregateTransaction.getSignerAddress().plain()} failed!! ` + e.message;
} - signer ${signedAggregateTransaction.getSignerAddress().plain()} failed!! ` + Utils.getMessage(e);
this.logger.error(message);
return false;
}
Expand All @@ -652,14 +654,14 @@ export class AnnounceService {
}
try {
this.logger.info(`Announcing ${this.getTransactionDescription(transaction, signedTransaction, currency)}`);
await transactionService.announce(signedTransaction, listener).toPromise();
await firstValueFrom(transactionService.announce(signedTransaction, listener));
this.logger.info(`${this.getTransactionDescription(transaction, signedTransaction, currency)} has been confirmed`);
return true;
} catch (e) {
const message =
`Simple Transaction ${signedTransaction.type} ${signedTransaction.hash} - signer ${signedTransaction
.getSignerAddress()
.plain()} failed!! ` + e.message;
.plain()} failed!! ` + Utils.getMessage(e);
this.logger.error(message);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/CertificateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class CertificateService {
metadata.version !== CertificateService.METADATA_VERSION
);
} catch (e) {
this.logger.warn(`Cannot load node certificate metadata from file ${metadataFile}. Error: ${e.message}`, e);
this.logger.warn(`Cannot load node certificate metadata from file ${metadataFile}. Error: ${Utils.getMessage(e)}`, e);
return true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/service/ConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ export class ConfigService {
this.logger.info(`Configuration generated.`);
return { presetData, addresses };
} catch (e) {
if (e.known) {
this.logger.error(e.message);
if ((e as any).known) {
this.logger.error(Utils.getMessage(e));
} else {
this.logger.error(`Unknown error generating the configuration. ${e.message}`, e);
this.logger.error(`Unknown error generating the configuration. ${Utils.getMessage(e)}`, e);
this.logger.error(`The target folder '${target}' should be deleted!!!`);
}
throw e;
Expand Down
4 changes: 2 additions & 2 deletions src/service/FileSystemService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class FileSystemService {
}
}

public mkdir(path: string): Promise<void> {
return fsPromises.mkdir(path, { recursive: true });
public async mkdir(path: string): Promise<void> {
await fsPromises.mkdir(path, { recursive: true });
}

public async mkdirParentFolder(fileName: string): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/service/HandlebarsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class HandlebarsUtils {
} catch (e) {
const securedTemplate = Utils.secureString(template);
const securedContext = Utils.secureString(YamlUtils.toYaml(templateContext));
const securedMessage = Utils.secureString(e.message || 'Unknown');
const securedMessage = Utils.secureString(Utils.getMessage(e));

const message = `Unknown error rendering template. Error: ${securedMessage}\nTemplate:\n${securedTemplate}.`;
throw new Error(`${message}\nContext: \n${securedContext}`);
Expand Down Expand Up @@ -157,7 +157,7 @@ export class HandlebarsUtils {
try {
return JSON.stringify(JSON.parse(string), null, 2);
} catch (e) {
throw new Error(`${e.message}:JSON\n ${string}`);
throw new Error(`${Utils.getMessage(e)}:JSON\n ${string}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/service/NemgenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class NemgenService {
failed = stdout.indexOf('<error>') > -1;
} catch (e) {
failed = true;
({ stdout, stderr, message } = e);
({ stdout, stderr, message } = e as any);
}
if (failed) {
if (message) this.logger.error(message);
Expand Down
Loading

0 comments on commit 7dcd80b

Please sign in to comment.