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


TypeScript nem-library.TransferTransaction类代码示例

本文整理汇总了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;未经允许,请勿转载。