From 996f9ba7f8386fc214d79c666c2063cb260fb95c Mon Sep 17 00:00:00 2001 From: Bassem Date: Fri, 17 Sep 2021 21:47:49 +0200 Subject: [PATCH] fixes #202 #88 --- src/locales/translations/en.json | 2 +- src/screens/CreateAccount.js | 1 + src/services/QRService.js | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/locales/translations/en.json b/src/locales/translations/en.json index df27842..0b1369b 100644 --- a/src/locales/translations/en.json +++ b/src/locales/translations/en.json @@ -548,7 +548,7 @@ "title": "Add Account", "name": "Account name", "type": "Account type", - "seed": "Seed index (blank for automatic increase)", + "seed": "Seed account index (blank for automatic increase)", "fromSeed": "Add seed account from mnemonics", "createSeed": "Add account", "fromPk": "Import account by private key", diff --git a/src/screens/CreateAccount.js b/src/screens/CreateAccount.js index 1a9b4f9..cc799f7 100644 --- a/src/screens/CreateAccount.js +++ b/src/screens/CreateAccount.js @@ -141,6 +141,7 @@ class CreateAccount extends Component { placeholder={translate('createAccount.seed')} theme="light" fullWidth + keyboardType='numeric' onChangeText={val => this.handleIndexChange(val)} /> diff --git a/src/services/QRService.js b/src/services/QRService.js index 7fcf760..ac10d15 100644 --- a/src/services/QRService.js +++ b/src/services/QRService.js @@ -11,7 +11,10 @@ import { TransactionType, Address, CosignatureSignedTransaction, - SignedTransaction + SignedTransaction, + RepositoryFactoryHttp, + Mosaic, + UInt64 } from 'symbol-sdk'; import MosaicService from './MosaicService'; import NetworkService from './NetworkService'; @@ -81,11 +84,19 @@ export default class { }; static parseRequestTransaction = async (data, network) => { + let networkCurrency = undefined; const transaction = TransactionMapping.createFromPayload(data.data.payload); if(transaction.type !== TransactionType.TRANSFER) throw Error('Transaction type is not a transfer'); + if(!transaction.mosaics[0]){ + networkCurrency = await new RepositoryFactoryHttp(network.node, { + networkType: network.networkType, + generationHash: network.generationHashSeed + }).getCurrencies().toPromise() + } - const formattedMosaic = await this.formatMosaic(transaction.mosaics[0], network); + const mosaic = transaction.mosaics[0] || (new Mosaic(networkCurrency.currency.mosaicId, UInt64.fromUint(0))); + const formattedMosaic = await this.formatMosaic(mosaic, network); const formatedTransaction = { recipientAddress: transaction.recipientAddress.pretty(), message: transaction.message.payload, @@ -135,4 +146,4 @@ export default class { return formattedMosaic; } -} +} \ No newline at end of file