本文整理匯總了TypeScript中nem-library.SimpleWallet.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript SimpleWallet.default方法的具體用法?TypeScript SimpleWallet.default怎麽用?TypeScript SimpleWallet.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nem-library.SimpleWallet
的用法示例。
在下文中一共展示了SimpleWallet.default方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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);
}
}
};