This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e4a9e8
commit 5502397
Showing
12 changed files
with
161 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {NetworkType} from 'nem2-sdk'; | ||
import {Profile} from '../model/profile'; | ||
import {OptionsChoiceResolver} from '../options-resolver'; | ||
import {ProfileOptions} from '../profile.command'; | ||
import {NetworkValidator} from '../validators/network.validator'; | ||
import {Resolver} from './resolver'; | ||
|
||
/** | ||
* Restriction account address flags resolver | ||
*/ | ||
export class NetworkTypeResolver implements Resolver { | ||
|
||
/** | ||
* Resolves a network type provided by the user. | ||
* @param {ProfileOptions} options - Command options. | ||
* @param {Profile} secondSource - Secondary data source. | ||
* @param {string} altText - Alternative text. | ||
* @returns {number} | ||
*/ | ||
resolve(options: ProfileOptions, secondSource?: Profile, altText?: string): any { | ||
const choices = ['MAIN_NET', 'TEST_NET', 'MIJIN', 'MIJIN_TEST']; | ||
const index = +OptionsChoiceResolver(options, | ||
'network', | ||
altText ? altText : 'Select the network type: ', | ||
choices, | ||
); | ||
const networkFriendlyName = choices[index] as any; | ||
new NetworkValidator().validate(networkFriendlyName); | ||
return NetworkType[networkFriendlyName]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Password} from 'nem2-sdk'; | ||
import {Profile} from '../model/profile'; | ||
import {OptionsPasswordResolver} from '../options-resolver'; | ||
import {ProfileOptions} from '../profile.command'; | ||
import {PasswordValidator} from '../validators/password.validator'; | ||
import {Resolver} from './resolver'; | ||
|
||
/** | ||
* Password resolver | ||
*/ | ||
export class PasswordResolver implements Resolver { | ||
|
||
/** | ||
* Resolves a password provided by the user. | ||
* @param {ProfileOptions} options - Command options. | ||
* @param {Profile} secondSource - Secondary data source. | ||
* @param {string} altText - Alternative text. | ||
* @returns {Password} | ||
*/ | ||
resolve(options: ProfileOptions, secondSource?: Profile, altText?: string): any { | ||
const resolution = OptionsPasswordResolver(options, | ||
'password', | ||
() => undefined, | ||
'Enter your wallet password: '); | ||
new PasswordValidator().validate(resolution); | ||
return new Password(resolution); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {Password} from 'nem2-sdk'; | ||
import {Profile} from '../model/profile'; | ||
import {OptionsPasswordResolver} from '../options-resolver'; | ||
import {ProfileOptions} from '../profile.command'; | ||
import {PasswordValidator} from '../validators/password.validator'; | ||
import {Resolver} from './resolver'; | ||
import {PrivateKeyValidator} from '../validators/privateKey.validator'; | ||
|
||
/** | ||
* Private key resolver | ||
*/ | ||
export class PrivateKeyResolver implements Resolver { | ||
|
||
/** | ||
* Resolves a private key provided by the user. | ||
* @param {ProfileOptions} options - Command options. | ||
* @param {Profile} secondSource - Secondary data source. | ||
* @param {string} altText - Alternative text. | ||
* @returns {Password} | ||
*/ | ||
resolve(options: ProfileOptions, secondSource?: Profile, altText?: string): any { | ||
const resolution = OptionsPasswordResolver(options, | ||
'privateKey', | ||
() => undefined, | ||
'Enter your private key: ').trim(); | ||
new PrivateKeyValidator().validate(resolution); | ||
return resolution; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {Password} from 'nem2-sdk'; | ||
import {Profile} from '../model/profile'; | ||
import {OptionsPasswordResolver, OptionsResolver} from '../options-resolver'; | ||
import {ProfileOptions} from '../profile.command'; | ||
import {PasswordValidator} from '../validators/password.validator'; | ||
import {Resolver} from './resolver'; | ||
|
||
/** | ||
* Profile name resolver | ||
*/ | ||
export class ProfileNameResolver implements Resolver { | ||
|
||
/** | ||
* Resolves a profile name provided by the user. | ||
* @param {ProfileOptions} options - Command options. | ||
* @param {Profile} secondSource - Secondary data source. | ||
* @param {string} altText - Alternative text. | ||
* @returns {string} | ||
*/ | ||
resolve(options: ProfileOptions, secondSource?: Profile, altText?: string): any { | ||
const resolution = OptionsResolver(options, | ||
'profile', | ||
() => undefined, | ||
'Enter profile name: ').trim(); | ||
return resolution; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters