Skip to content

Commit

Permalink
fix: improved Password type
Browse files Browse the repository at this point in the history
  • Loading branch information
fboucquez committed Feb 4, 2022
1 parent 7dcd80b commit be3a0ef
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.

The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.1.4] - NEXT
## [1.1.4] - Feb-4-2022

**Milestone**: Mainnet(1.0.3.1)

Expand Down
2 changes: 1 addition & 1 deletion presets/mainnet/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ minVotingKeyLifetime: 112
maxVotingKeyLifetime: 360
votingKeyDesiredLifetime: 360
votingKeyDesiredFutureLifetime: 60
lastKnownNetworkEpoch: 645
lastKnownNetworkEpoch: 650
stepDuration: 5m
maxBlockFutureTime: 300ms
maxAccountRestrictionValues: 100
Expand Down
2 changes: 1 addition & 1 deletion presets/testnet/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ importanceGrouping: 180
votingSetGrouping: 720
votingKeyDesiredLifetime: 720
votingKeyDesiredFutureLifetime: 120
lastKnownNetworkEpoch: 190
lastKnownNetworkEpoch: 199
minVotingKeyLifetime: 28
maxVotingKeyLifetime: 720
stepDuration: 4m
Expand Down
3 changes: 2 additions & 1 deletion src/commands/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
ConfigService,
Constants,
KeyName,
Password,
Preset,
RuntimeService,
YamlUtils,
Expand Down Expand Up @@ -113,7 +114,7 @@ export class Wizard {
noPassword: boolean;
skipPull?: boolean;
target: string;
password: string | undefined;
password: Password;
network: Network | undefined;
customPreset: string;
ready?: boolean;
Expand Down
3 changes: 2 additions & 1 deletion src/service/CommandUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { prompt } from 'inquirer';
import { Convert, PublicAccount } from 'symbol-sdk';
import { Logger, LoggerFactory, LogType } from '../logger';
import { Constants } from './Constants';
import { Password } from './YamlUtils';

export class CommandUtils {
public static passwordPromptDefaultMessage = `Enter the password used to encrypt and decrypt custom presets, addresses.yml, and preset.yml files. When providing a password, private keys will be encrypted. Keep this password in a secure place!`;
Expand Down Expand Up @@ -74,7 +75,7 @@ export class CommandUtils {

public static async resolvePassword(
logger: Logger,
providedPassword: string | undefined,
providedPassword: Password | undefined,
noPassword: boolean,
message: string,
log: boolean,
Expand Down
4 changes: 2 additions & 2 deletions src/service/ComposeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import { HandlebarsUtils } from './HandlebarsUtils';
import { RemoteNodeService } from './RemoteNodeService';
import { RuntimeService } from './RuntimeService';
import { Utils } from './Utils';
import { YamlUtils } from './YamlUtils';
import { Password, YamlUtils } from './YamlUtils';

export type ComposeParams = { target: string; user?: string; upgrade?: boolean; password?: string; workingDir: string; offline: boolean };
export type ComposeParams = { target: string; user?: string; upgrade?: boolean; password?: Password; workingDir: string; offline: boolean };

const targetNodesFolder = Constants.targetNodesFolder;
const targetDatabasesFolder = Constants.targetDatabasesFolder;
Expand Down
2 changes: 1 addition & 1 deletion src/service/ConfigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface ConfigParams extends VotingParams, ReportParams {
offline: boolean;
preset?: string;
target: string;
password?: string;
password?: Password;
user: string;
assembly?: string;
customPreset?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/service/LinkService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from 'symbol-sdk';
import { Logger } from '../logger';
import { Addresses, ConfigPreset, NodeAccount } from '../model';
import { AccountResolver, BootstrapAccountResolver } from '../service';
import { AccountResolver, BootstrapAccountResolver, Password } from '../service';
import { AnnounceService, TransactionFactory } from './AnnounceService';
import { ConfigLoader } from './ConfigLoader';
import { Constants } from './Constants';
Expand All @@ -38,7 +38,7 @@ import { VotingKeyAccount } from './VotingUtils';
*/
export type LinkParams = {
target: string;
password?: string;
password?: Password;
url: string;
maxFee?: number | undefined;
unlink: boolean;
Expand Down
5 changes: 4 additions & 1 deletion src/service/ModifyMultisigService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ import { BootstrapAccountResolver } from './BootstrapAccountResolver';
import { ConfigLoader } from './ConfigLoader';
import { Constants } from './Constants';
import { TransactionUtils } from './TransactionUtils';
import { Password } from './YamlUtils';

/**
* params necessary to announce multisig account modification transaction to network.
*/
export type ModifyMultisigParams = {
target: string;
password?: string;
password?: Password;
url: string;
maxFee?: number;
useKnownRestGateways: boolean;
Expand Down Expand Up @@ -84,6 +85,7 @@ export class ModifyMultisigService implements TransactionFactory {
this.params.serviceProviderPublicKey,
);
}

public async createTransactions({ presetData, deadline, maxFee, mainAccount }: TransactionFactoryParams): Promise<Transaction[]> {
const networkType = presetData.networkType;

Expand Down Expand Up @@ -193,6 +195,7 @@ export class ModifyMultisigService implements TransactionFactory {
}) || []
);
}

private toAddress(addressString: string, networkType: NetworkType): Address {
if (!Address.isValidRawAddress(addressString)) {
throw new Error(`Address ${addressString} is not valid!`);
Expand Down
2 changes: 1 addition & 1 deletion src/service/YamlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class YamlUtils {
return string.toLowerCase().endsWith('.yml') || string.toLowerCase().endsWith('.yaml');
}

public static async writeYaml(path: string, object: unknown, password: string | undefined): Promise<void> {
public static async writeYaml(path: string, object: unknown, password: Password): Promise<void> {
const yamlString = this.toYaml(password ? CryptoUtils.encrypt(object, Utils.validatePassword(password)) : object);
await this.writeTextFile(path, yamlString);
}
Expand Down

0 comments on commit be3a0ef

Please sign in to comment.