From cbafe3dfac9fae68b32791da3d8767977219d0a8 Mon Sep 17 00:00:00 2001 From: Kendal Cormany Date: Fri, 29 Oct 2021 15:56:51 -0700 Subject: [PATCH] 1.0.5 hotfix --- CHANGELOG.md | 11 +++++++- nxs_package.json | 2 +- package-lock.json | 4 +-- package.json | 2 +- src/App/Invoice/InvoiceForm.js | 5 +++- src/App/Invoice/selectors.js | 42 ++++++++++++++---------------- src/shared/component/AccountAsk.js | 18 ++++++------- 7 files changed, 46 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9406a7..41b8892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,13 @@ -# 1.0.3 (2021.4.16) +# 1.0.5 (2021.10.29) + +[Release Link](https://github.com/Nexusoft/Nexus-Interface-Invoice-Module/releases/tag/v1.0.5) + +#### Fixes + +- Fixed crashed when using the pay modal +- Fixed edge case with complex names by exclusively using addresses to send + +# 1.0.4 (2021.4.16) [Release Link](https://github.com/Nexusoft/Nexus-Interface-Invoice-Module/releases/tag/v1.0.4) diff --git a/nxs_package.json b/nxs_package.json index 06a5e24..c1d4bfc 100644 --- a/nxs_package.json +++ b/nxs_package.json @@ -1,7 +1,7 @@ { "name": "nexus_interface_invoice_module", "displayName": "Nexus Invoice System", - "version": "1.0.4", + "version": "1.0.5", "targetWalletVersion": "3.0.3", "description": "Use Case for the Invoice System", "type": "app", diff --git a/package-lock.json b/package-lock.json index c92e698..8fa8d8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nexus_interface_invoice_module", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "nexus_interface_invoice_module", - "version": "1.0.3", + "version": "1.0.4", "dependencies": { "ajv": "^6.12.2", "core-js": "^2.0.0", diff --git a/package.json b/package.json index 3de6dd4..7e0bfc9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nexus_interface_invoice_module", - "version": "1.0.4", + "version": "1.0.5", "description": "Use Case for the Invoice System", "devDependencies": { "@babel/core": "^7.9.0", diff --git a/src/App/Invoice/InvoiceForm.js b/src/App/Invoice/InvoiceForm.js index ec326f9..dcfd1b3 100644 --- a/src/App/Invoice/InvoiceForm.js +++ b/src/App/Invoice/InvoiceForm.js @@ -212,7 +212,10 @@ class RecipientField extends Component { }; isSendAddress.is_valid ? (params.account = sendFrom) - : (params.account_name = `${props.username}:${sendFrom}`); + : (params.account = props.accountOptions.filter( + (e) => e.value === sendFrom + )[0].account.address); + if (recipientAddress.startsWith('a') && recipientAddress.length === 64) { params.recipient = recipientAddress; } else { diff --git a/src/App/Invoice/selectors.js b/src/App/Invoice/selectors.js index 1fa679d..62b43ea 100644 --- a/src/App/Invoice/selectors.js +++ b/src/App/Invoice/selectors.js @@ -20,15 +20,10 @@ const { FormField, Button, }, - utilities: { - confirm, - - showErrorDialog, - showSuccessDialog, - }, + utilities: { confirm, showErrorDialog, showSuccessDialog }, } = NEXUS; -const __ = input => input; +const __ = (input) => input; const TokenRecipientName = styled.span({ color: 'gray', @@ -51,12 +46,13 @@ export const getAccountOptions = memoize((myAccounts, myTokens) => { }); options.push( ...myAccounts - .filter(acc => acc.token_name === 'NXS') - .map(acc => ({ + .filter((acc) => acc.token_name === 'NXS') + .map((acc) => ({ value: acc.name || acc.address, - display: `${acc.name || acc.address} (${ - acc.balance - } ${acc.token_name || 'Tokens'})`, + account: acc, + display: `${acc.name || acc.address} (${acc.balance} ${ + acc.token_name || 'Tokens' + })`, indent: true, })) ); @@ -68,8 +64,8 @@ export const getAccountOptions = memoize((myAccounts, myTokens) => { export const getAccountBalance = memoize( (accountName, myAccounts, myTokens) => { const account = - myAccounts && myAccounts.find(acc => acc.name === accountName); - const token = myTokens && myTokens(tkn => tkn.name === accountName); + myAccounts && myAccounts.find((acc) => acc.name === accountName); + const token = myTokens && myTokens((tkn) => tkn.name === accountName); return account && account.balance; } ); @@ -78,19 +74,19 @@ export const getAccountInfo = memoize((accountName, myAccounts, myTokens) => { const account = myAccounts && myAccounts.find( - acc => acc.name === accountName || acc.address === accountName + (acc) => acc.name === accountName || acc.address === accountName ); const token = myTokens && myTokens.find( - tkn => tkn.name === accountName || tkn.address === accountName + (tkn) => tkn.name === accountName || tkn.address === accountName ); return account || token || { balance: 0 }; }); export const getNxsFiatPrice = memoize((rawNXSvalues, fiatCurrency) => { if (rawNXSvalues) { - const marketInfo = rawNXSvalues.find(e => e.name === fiatCurrency); + const marketInfo = rawNXSvalues.find((e) => e.name === fiatCurrency); if (marketInfo) { return marketInfo.price; } @@ -101,7 +97,7 @@ export const getNxsFiatPrice = memoize((rawNXSvalues, fiatCurrency) => { export const getAddressNameMap = memoize((addressBook, myTritiumAccounts) => { const map = {}; if (addressBook) { - Object.values(addressBook).forEach(contact => { + Object.values(addressBook).forEach((contact) => { if (contact.addresses) { contact.addresses.forEach(({ address, label }) => { map[address] = contact.name + (label ? ' - ' + label : ''); @@ -110,7 +106,7 @@ export const getAddressNameMap = memoize((addressBook, myTritiumAccounts) => { }); } if (myTritiumAccounts) { - myTritiumAccounts.forEach(element => { + myTritiumAccounts.forEach((element) => { map[element.address] = element.name; }); } @@ -127,10 +123,10 @@ export const getRecipientSuggestions = memoize( console.log(addressBook); const suggestions = []; if (addressBook) { - Object.values(addressBook).forEach(contact => { + Object.values(addressBook).forEach((contact) => { if (contact.addresses) { contact.addresses - .filter(e => e.address.startsWith('a')) + .filter((e) => e.address.startsWith('a')) .forEach(({ address, label, isMine }) => { if (!isMine) { suggestions.push({ @@ -179,12 +175,12 @@ export const isMyAddress = (myAccounts, myGenesis, testAddress) => { if (!myGenesis || !myAccounts) return false; if (myGenesis === testAddress) return true; - const foundAddress = myAccounts.find(e => e.address === testAddress); + const foundAddress = myAccounts.find((e) => e.address === testAddress); if (foundAddress) return true; return false; }; -export const getRegisteredFieldNames = memoize(registeredFields => +export const getRegisteredFieldNames = memoize((registeredFields) => Object.keys(registeredFields || {}) ); diff --git a/src/shared/component/AccountAsk.js b/src/shared/component/AccountAsk.js index 70dfd50..f91df0a 100644 --- a/src/shared/component/AccountAsk.js +++ b/src/shared/component/AccountAsk.js @@ -43,7 +43,7 @@ class AccountAsk extends Component { .map((element) => { return { value: element.address, - display: `${(element.address)} (${element.balance} NXS)`, + display: `${element.address} (${element.balance} NXS)`, }; }); } @@ -55,19 +55,20 @@ class AccountAsk extends Component { async openConfirm() { const total = this.calculateTotal(this.props.invoice.items); const account = - this.props.accounts.filter((e) => e.address === this.state.account)[0] - .name || this.state.account; + this.props.accounts.filter((e) => e.address === this.state.account)[0] || + this.state.account; const result = await confirm({ question: 'Do you want to fulfill this invoice?', - note: `You are paying ${total} NXS with your ${account} Account`, + note: `You are paying ${total} NXS with your ${ + account.name || 'Default' + } Account`, }); if (result) { try { - console.log('Send NXS'); const params = { address: this.props.invoice.address, amount: this.calculateTotal(this.props.invoice.items), - name_from: `${this.props.username}:default`, + address_from: account.address, }; const apiResult = await secureApiCall('invoices/pay/invoice', params); if (apiResult) { @@ -78,9 +79,8 @@ class AccountAsk extends Component { } catch (error) { showErrorDialog({ message: 'Did Not Send', - note: error, + note: `${error.code} , ${error.message}`, }); - console.error(error); } } } @@ -118,7 +118,7 @@ class AccountAsk extends Component { } const mapStateToProps = (state) => { - return { accounts: state.user.accounts, username: state.user.username }; + return { accounts: state.user.accounts || [], username: state.user.username }; }; export default connect(mapStateToProps, { loadInvoices, ClosePopUp })(