当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript colors.white函数代码示例

本文整理汇总了TypeScript中colors.white函数的典型用法代码示例。如果您正苦于以下问题:TypeScript white函数的具体用法?TypeScript white怎么用?TypeScript white使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了white函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: printBalance

			await printBalance(async (balance) => {
				const amt = parseFloat(args[1]);
				const address = args[2];
				if (isNaN(amt)) {
					console.log(red('Must provide a valid number with maximum of 6 digits ie 10.356784'));
					process.exit(1);
				}
				if (!address) {
					console.log(red('Must provide a valid recipient address'));
					process.exit(1);
				}
				if  (amt > balance) {
					console.log(red(`You don't have enough ${MOSAIC_NAME} to send`));
					process.exit(1);
				}
				try {
					const preTransaction = await prepareTransfer(address, amt);
					const xemFee = (preTransaction.fee / 1e6).toString();
					console.log(white('Transaction Details: \n'));
					console.log(`Recipient:          ${yellow(address)}\n`);
					console.log(`${MOSAIC_NAME} to send:      ${yellow(amt.toString())}\n`);
					console.log(`XEM Fee:            ${yellow(xemFee)}\n\n`);
					console.log(`${white('Would you like to proceed?\n')}`);

					prompt.message = white(`${MOSAIC_NAME} Transfer`);
					prompt.start();
					prompt.get({
						properties: {
							confirmation: {
								description: yellow('Proceed? ( y/n )')
							}
						}
					}, async (_, result) => {
						if (result.confirmation.toLowerCase() === 'y' || result.confirmation.toLowerCase() === 'yes') {
							try {
								const result = await sendMosaic(address, amt, selectedAccount);
								console.log(result);
								console.log('\n\n');
								console.log(white('Transaction successfully announced to the NEM blockchain. Transaction could take some time. Come back here in 5 minutes to check your balance to ensure that the transaction was successfully sent\n'));

							} catch (err) {
								console.log(red(err));
							}
						} else {
							console.log('Transaction canceled');
							process.exit(1);
						}
					});
				} catch (err) {
					console.log(`\n${err}\n`);
				}
			});
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:52,代码来源:wallet-cli.ts

示例2: white

const createPwd = () => {
	console.log(white(
		`\nPlease enter a unique password ${yellow('(8 character minimum)')}.\n 
This password will be used to encrypt your private key and make working with your wallet easier.\n\n`
	));
	console.log(red(
		`Store this password somewhere safe. If you lose or forget it you will never be able to transfer funds\n`
	));
	prompt.message = white(`${MOSAIC_NAME} wallet`);
	prompt.start();
	prompt.get({
		properties: {
			password: {
				description: white('Password'),
				hidden: true
			},
			confirmPass: {
				description: white('Re-enter password'),
				hidden: true
			}
		}
	}, async (_, result) => {
		if (result.password !== result.confirmPass) {
			console.log(magenta('\nPasswords do not match.\n\n'));
			createPwd();
		} else {
			/**
			 * Create new SimpleWallet
			 * Open it to access the new Account
			 * Print account info
			 */
			const wallet = createSimpleWallet(result.password);
			const pass = new Password(result.password);
			const account = wallet.open(pass);
			const address = account.address.pretty();
			console.log(green(`${MOSAIC_NAME} wallet successfully created.`));
			console.log(white(`You can now start sending and receiving ${MOSAIC_NAME}!`));
			console.log(white(`\n${MOSAIC_NAME} Public Address:`));
			console.log(yellow(`${address}`));
			console.log(white(`\nPrivate Key:`));
			console.log(yellow(`${account.privateKey}`));
			await downloadWallet(wallet);
		}
	})
};
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:45,代码来源:wallet-cli.ts

示例3: Password

		}, (_, result) => {
			const pass = new Password(result.password);
			try {
				resolve(wallet.open(pass));
			} catch (err) {
				console.log(red(`${err}`));
				console.log(white('Please try again'));
				reject();
			}
		});
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:10,代码来源:wallet-cli.ts

示例4: async

const printBalance = async (onBalance: (balance: number) => void) => {
	const wallet = loadWallet();
	try {
		const account = await attemptWalletOpen(wallet);
		selectedAccount = account;
		console.log('\n');
		console.log(`\n${white('Public Address:')} ${white(account.address.pretty())}\n`);
		const spinner = new Spinner(yellow('Fetching balance... %s'));
		spinner.setSpinnerString(0);
		spinner.start();
		const balances = await getAccountBalances(account);
		const mosaic = await mosaicBalance(balances);
		const xem = await xemBalance(balances);
		spinner.stop();
		/**
		 * Convert raw number into user-readable string
		 * 1e6 is Scientific Notation - adds the decimal six
		 * places from the right: ie 156349876 => 156.349876
		 */
		const bal = (mosaic / 1e6).toString();
		const xemBal = (xem / 1e6).toString();
		console.log('\n');
		console.log(`\n${white('XEM Balance:')} ${white(xemBal)}`);
		console.log(`\n${white(`${MOSAIC_NAME} Balance:`)} ${white(bal)}\n`);
		onBalance(mosaic / 1e6);
	} catch (err) {
		if (err) {
			console.log(err);
		}
	}
};
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:31,代码来源:wallet-cli.ts

示例5: applyColor

function applyColor(message: string, color: Color): string {
    if (!message) return;
    if (!color) return message;

    switch (color) {
        case Color.black:   return colors.black(message);
        case Color.red:     return colors.red(message);
        case Color.green:   return colors.green(message);
        case Color.yellow:  return colors.yellow(message);
        case Color.blue:    return colors.blue(message);
        case Color.magenta: return colors.magenta(message);
        case Color.cyan:    return colors.cyan(message);
        case Color.white:   return colors.white(message);
        case Color.grey:    return colors.grey(message);
        default:            throw new Error('Invalid Color');
    }
}
开发者ID:herculesinc,项目名称:credo.logger,代码行数:17,代码来源:ConsoleLogger.ts

示例6: Date

const downloadWallet = (wallet: SimpleWallet) => {
	console.log(white(`\n\nDownloading wallet for your convenience.\n\nPlease store someplace safe. The private key is encrypted by your password.\n\nTo load this wallet on a new computer you would simply import the .wlt file into this app and enter your password and you'll be able to sign transactions.
	`));

	if (!fs.existsSync(PATH_HOME)) {
		fs.mkdirSync(PATH_HOME);
	}

	let fullPath = PATH_WALLET;
	if (fs.existsSync(fullPath)) {
		const stamp = new Date().toISOString();
		fullPath = `${PATH_HOME}/${stamp}-${MOSAIC_NAME}-wallet.wlt`
	}
	fs.writeFileSync(fullPath, wallet.writeWLTFile());

	console.log(green(`Downloaded wallet to ${fullPath}`))
};
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:17,代码来源:wallet-cli.ts

示例7: Provider

    .action((filename) => {
        // Console message
        console.log(colors.white('\n\t👁\t:: Running remix-tests - Unit testing for solidity ::\t👁\n'))
        // set logger verbosity
        if (commander.verbose) {
            logger.setVerbosity(commander.verbose)
            log.info('verbosity level set to ' + commander.verbose.blue)
        }
        let web3 = new Web3()
        // web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'))
        web3.setProvider(new Provider())
        // web3.setProvider(new web3.providers.WebsocketProvider('ws://localhost:8546'))

        if (!fs.existsSync(filename)) {
            console.error(filename + ' not found')
            process.exit(1)
        }

        let isDirectory = fs.lstatSync(filename).isDirectory()
        runTestFiles(filename, isDirectory, web3)
    })
开发者ID:0mkara,项目名称:remix,代码行数:21,代码来源:run.ts


注:本文中的colors.white函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。