• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript nem-library.TransferTransaction类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: async

		.map( async (transferTransaction: TransferTransaction) => {
			try {
				const rawMsg = (transferTransaction.message as PlainMessage).plain().replace(/ /g, '');
				const hashId = rawMsg.substr(rawMsg.indexOf(':'), rawMsg.length);

				/**
				 * Try finding a transaction in the database that may be a partial payment. Sometimes people will send
				 * multiple amounts of XEM to purchase a product
				 */
				let transaction: XemTransaction = await findOneThatContains<XemTransaction>(DB_PARTIAL_XEM_CHARGES, 'message', hashId, TRANSACTION_MESSAGE_LENGTH);
				/**
				 * If it is not partial, we look up pending charges
				 */
				if (!transaction) {
					transaction = await findOneThatContains<XemTransaction>(DB_PENDING_XEM_CHARGES, 'message', hashId, TRANSACTION_MESSAGE_LENGTH);
				}
				const transfer = await formatIncomingTransaction(transferTransaction);

				/**
				 * Ignore transactions that are confirmed for the holding account - we only want to
				 * listen for customer transactions
				 */
				if (transfer.tokenRecipientAddress === tokenHoldingAccountAddress()
					|| transfer.tokenRecipientAddress === nemConfig.multisigAddress) {
					return;
				}

				/**
				 * If the transaction is not in the database someone sent us XEM without using
				 * our purchase process on the website
				 */
				if (!transaction) {
					saveAnonymousTransaction(transfer);
				} else {
					/**
					 * We found the pending transaction in the database
					 */
					onTransactionConfirmed(transaction, transfer);
				}
			} catch (err) {
				/**
				 * Save errors to the database so we can handle customer inquiries
				 */
				const amountPaid = transferTransaction.xem().amount;
				const errorTrans: XemTransaction = {
					_id: new ObjectID(),
					tokenRecipientAddress: transferTransaction.signer.address.plain(),
					tokenType: TokenType.NA,
					totalPaid: amountPaid,
					message: 'Contains mosaics: ' + transferTransaction.containsMosaics(),
					createdAt: new Date(),
					errMsg: err
				};
				await saveWithId<XemTransaction>(DB_PROBLEM_XEM_CHARGES, errorTrans);
			}
		})
开发者ID:joseabril25,项目名称:nem-coinbase-token-sale-api,代码行数:56,代码来源:nem-service.ts


示例2: resolve

				.subscribe(transferable => {
					resolve(TransferTransaction.createWithMosaics(
						TimeWindow.createWithDeadline(),
						new Address(toAddress),
						[transferable],
						EmptyMessage))
				}, error => {
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:7,代码来源:wallet.ts


示例3: Address

			.map(mosaics => TransferTransaction.createWithMosaics(
				TimeWindow.createWithDeadline(),
				new Address(toAddress),
				mosaics,
				EmptyMessage))
开发者ID:devslopes,项目名称:mosaic-cli-wallet,代码行数:5,代码来源:wallet.ts


示例4:

			.map(mosaics => TransferTransaction.createWithMosaics(
				TimeWindow.createWithDeadline(),
				tokenTransfer.toAddress,
				mosaics,
				EmptyMessage))
开发者ID:joseabril25,项目名称:nem-coinbase-token-sale-api,代码行数:5,代码来源:token-transfer.ts


示例5: xemToUsd

	return new Promise<XemTransaction>(async (resolve, reject) => {
		try {
			let tokenType = TokenType.NA;
			let paid = 0;
			let usdPaid = 0;
			/**
			 * This first part is a safeguard - it means someone sent a Mosaic token
			 * instead of XEM. Handle these scenario accordingly
			 */
			if (transaction.containsMosaics()) {
				transaction.mosaics().map(mosaic => {
					if (mosaic.mosaicId.namespaceId === nemConfig.mosaicNamespace
						&& mosaic.mosaicId.name === nemConfig.mosaicForTransfer) {
						tokenType = TokenType.CHE;
						paid += mosaic.quantity;
					}
				});
			} else {
				/**
				 * Someone sent XEM
				 */
				tokenType = TokenType.XEM;
				paid = transaction.xem().amount * 1e6;
				usdPaid = await xemToUsd(paid);
			}
			const formmatedTransaction: XemTransaction = {
				_id: new ObjectID(),
				tokenRecipientAddress: transaction.signer.address.plain(),
				tokenType: tokenType,
				totalPaid: paid,
				usdPaid: usdPaid,
				createdAt: new Date()
			};
			if (transaction.message) {
				formmatedTransaction.message = (transaction.message as PlainMessage).plain().replace(/ /g, '');
			}
			resolve(formmatedTransaction);
		} catch (err) {
			reject(err);
		}
	});
开发者ID:joseabril25,项目名称:nem-coinbase-token-sale-api,代码行数:41,代码来源:nem-service.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript MultisigTransaction.MultisigTransaction类代码示例发布时间:2022-05-25
下一篇:
TypeScript nem-library.TransactionHttp类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap