Skip to content

Commit

Permalink
Merge pull request #23 from Nexusoft/1.0.5-hotfix
Browse files Browse the repository at this point in the history
1.0.5 hotfix
  • Loading branch information
KenCorma authored Oct 29, 2021
2 parents b9046c7 + cbafe3d commit f9dfa90
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 38 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion nxs_package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/App/Invoice/InvoiceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
42 changes: 19 additions & 23 deletions src/App/Invoice/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
}))
);
Expand All @@ -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;
}
);
Expand All @@ -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;
}
Expand All @@ -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 : '');
Expand All @@ -110,7 +106,7 @@ export const getAddressNameMap = memoize((addressBook, myTritiumAccounts) => {
});
}
if (myTritiumAccounts) {
myTritiumAccounts.forEach(element => {
myTritiumAccounts.forEach((element) => {
map[element.address] = element.name;
});
}
Expand All @@ -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({
Expand Down Expand Up @@ -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 || {})
);
18 changes: 9 additions & 9 deletions src/shared/component/AccountAsk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)`,
};
});
}
Expand All @@ -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) {
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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 })(
Expand Down

0 comments on commit f9dfa90

Please sign in to comment.