Skip to content

Commit

Permalink
Merge pull request #2412 from Emurgo/ruslan/unblock-rewards
Browse files Browse the repository at this point in the history
Release / 4.7.400
  • Loading branch information
vsubhuman committed Sep 26, 2021
2 parents 5b059b0 + 64ae983 commit 9a5c8b7
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 54 deletions.
Expand Up @@ -473,33 +473,33 @@ export function newAdaUnsignedTxFromUtxo(
return [u, false, hasRequiredAsset, Math.floor(spendable / 1_000_000) * 1_000_000];
});

const utxosFiltered: Array<[RemoteUnspentOutput, boolean, boolean, number]> = utxosMapped
.filter(([, isPure, hasRequiredAsset, spendableValue]) =>
isPure || hasRequiredAsset || (spendableValue > 0));

// prioritize inputs
const sortedUtxos: Array<RemoteUnspentOutput> = utxosFiltered.sort((v1, v2) => {
const [, isPure1, hasRequiredAsset1, spendableValue1] = v1;
const [, isPure2, hasRequiredAsset2, spendableValue2] = v2;
const sortedUtxos: Array<RemoteUnspentOutput> = utxosMapped.sort((v1, v2) => {
const [u1, isPure1, hasRequiredAsset1, spendableValue1] = v1;
const [u2, isPure2, hasRequiredAsset2, spendableValue2] = v2;
// $FlowFixMe[unsafe-addition]
if (hasRequiredAsset1 ^ hasRequiredAsset2) {
// one but not both of the utxos has required assets
// utxos with required assets are always prioritized
// ahead of any other, pure or dirty
return hasRequiredAsset1 ? -1 : 1;
}
if (isPure1 && isPure2) {
// both utxos are clean - randomize them
return Math.random() - 0.5;
}
if (isPure1 || isPure2) {
// at least one of the utxos is clean
if (isPure1 && isPure2) {
// both utxos are clean - randomize them
return Math.random() - 0.5;
}
// At least one of the utxos is clean
// The clean utxo is prioritized
return isPure1 ? -1 : 1;
}
// both utxos are dirty
// dirty utxos with highest spendable ADA are prioritised
return spendableValue2 - spendableValue1;
if (spendableValue1 !== spendableValue2) {
// dirty utxos with highest spendable ADA are prioritised
return spendableValue2 - spendableValue1;
}
// utxo with fewer assets is prioritised
return u1.assets.length - u2.assets.length;
}).map(([u]) => u);

/*
Expand Down
Expand Up @@ -18,8 +18,8 @@ import globalMessages from '../../i18n/global-messages';

const messages = defineMessages({
dialogTitle: {
id: 'buysell.dialog.title',
defaultMessage: '!!!Buy / Sell ADA',
id: 'buy.dialog.title',
defaultMessage: '!!!Buy ADA',
},
dialogSelectAddress: {
id: 'buysell.dialog.selectAddress',
Expand Down
Expand Up @@ -27,7 +27,7 @@ export default class BuySellAdaButton extends Component<Props> {

return (
<Button
label={intl.formatMessage(globalMessages.buySellAda)}
label={intl.formatMessage(globalMessages.buyAda)}
className={classnames([styles.button, 'secondary'])}
onClick={() => this.props.onBuySellClick()}
skin={ButtonSkin}
Expand Down
2 changes: 1 addition & 1 deletion packages/yoroi-extension/app/components/topbar/NavPlate.js
Expand Up @@ -76,7 +76,7 @@ export default class NavPlate extends Component<Props> {
if (wallet instanceof Bip44Wallet) {
return globalMessages.byronLabel;
}
return globalMessages.shelleyLabel;
return undefined;
}

getType: ConceptualWallet => $Exact<$npm$ReactIntl$MessageDescriptor> = (wallet) => {
Expand Down
18 changes: 7 additions & 11 deletions packages/yoroi-extension/app/components/topbar/NavWalletDetails.js
Expand Up @@ -63,8 +63,6 @@ export default class NavWalletDetails extends Component<Props> {
shouldHideBalance,
onUpdateHideBalance,
highlightTitle,
// <TODO:RWRD2109>
// eslint-disable-next-line no-unused-vars
rewards,
walletAmount,
assetDeposit,
Expand Down Expand Up @@ -115,6 +113,12 @@ export default class NavWalletDetails extends Component<Props> {
</p>
{this.renderAmountDisplay({ shouldHideBalance, amount: walletAmount })}
</div>
<div>
<p className={styles.label}>
{intl.formatMessage(globalMessages.rewardsLabel)}&nbsp;
</p>
{this.renderAmountDisplay({ shouldHideBalance, amount: rewards })}
</div>
{isNonZeroDeposit ? (
<div>
<p className={styles.label}>
Expand All @@ -123,13 +127,6 @@ export default class NavWalletDetails extends Component<Props> {
{this.renderAmountDisplay({ shouldHideBalance, amount: assetDeposit })}
</div>
) : null}
{/* <TODO:RWRD2109> */}
{/* <div> */}
{/* <p className={styles.label}> */}
{/* {intl.formatMessage(globalMessages.rewardsLabel)}&nbsp; */}
{/* </p> */}
{/* {this.renderAmountDisplay({ shouldHideBalance, amount: rewards })} */}
{/* </div> */}
</div>
}
{this.props.rewards === undefined && (
Expand Down Expand Up @@ -164,8 +161,7 @@ export default class NavWalletDetails extends Component<Props> {
if (this.props.rewards === null || this.props.walletAmount === null) {
return null;
}
// <TODO:RWRD2109>
return this.props.walletAmount; // .joinAddCopy(this.props.rewards);
return this.props.walletAmount.joinAddCopy(this.props.rewards);
}

renderAmountDisplay: {|
Expand Down
Expand Up @@ -53,7 +53,7 @@
}
font-family: var(--font-medium);
font-size: 16px;
line-height: 24px;
line-height: 20px;

.afterDecimal {
font-family: var(--font-regular);
Expand Down Expand Up @@ -84,8 +84,8 @@
@include loading-spinner("../../assets/images/spinner-dark.svg", 8);
}
font-size: 10px;
line-height: 16px;
margin-top: 2px;
line-height: 14px;
margin-top: -2px;

.afterDecimal {
font-size: 10px;
Expand Down
Expand Up @@ -22,8 +22,8 @@ const messages = defineMessages({
defaultMessage: '!!!Byron-era (read-only) wallet',
},
restoreShelleyEraWalletTitle: {
id: 'wallet.add.optionDialog.walletEra.shelleyEra.title',
defaultMessage: '!!!Shelley-era wallet',
id: 'wallet.add.optionDialog.walletEra.standard.title',
defaultMessage: '!!!Standard wallet',
},
});

Expand Down
Expand Up @@ -96,8 +96,8 @@ export default class StakingDashboard extends Component<Props> {
: (null);

// don't show anything when user has never delegated
const hideGraph = this.props.delegationHistory != null &&
this.props.delegationHistory.length === 0;
const hideGraph = (this.props.delegationHistory != null &&
this.props.delegationHistory.length === 0) || true; // <TODO:RWRD2109>

const graphs = hideGraph
? null
Expand Down
Expand Up @@ -145,9 +145,7 @@ export default class UserSummary extends Component<Props, State> {
<h3 className={styles.label}>
{intl.formatMessage(globalMessages.totalRewardsLabel)}:
</h3>
{/* <TODO:RWRD2109> */}
Due to protocol update, the rewards are being recalculated.
{/* {this.renderAmount(this.props.totalRewards)} */}
{this.renderAmount(this.props.totalRewards)}
</div>
<div className={styles.footer}>
{this.props.withdrawRewards != null && (
Expand All @@ -156,7 +154,6 @@ export default class UserSummary extends Component<Props, State> {
label={intl.formatMessage(globalMessages.withdrawLabel)}
onClick={this.props.withdrawRewards}
skin={ButtonSkin}
disabled // <TODO:RWRD2109>
/>
)}
<div
Expand Down
Expand Up @@ -715,8 +715,6 @@ export default class StakingDashboardPage extends Component<Props> {
const txRequests = this.generated.stores.transactions.getTxRequests(request.publicDeriver);
const balance = txRequests.requests.getBalanceRequest.result;

// <TODO:RWRD2109>
// eslint-disable-next-line no-unused-vars
const rewardBalance =
request.delegationRequests.getDelegatedBalance.result == null
? new MultiToken([], defaultToken)
Expand Down Expand Up @@ -745,7 +743,7 @@ export default class StakingDashboardPage extends Component<Props> {
totalSum={
balance == null
? undefined
: balance // .joinAddCopy(rewardBalance) // <TODO:RWRD2109>
: balance.joinAddCopy(rewardBalance)
}
totalRewards={
!showRewardAmount || request.delegationRequests.getDelegatedBalance.result == null
Expand Down
10 changes: 5 additions & 5 deletions packages/yoroi-extension/app/i18n/global-messages.js
Expand Up @@ -506,8 +506,8 @@ const globalMessages: * = defineMessages({
defaultMessage: '!!!Wallets created before July 29th, 2020 are Byron-era wallets and cannot delegate.',
},
restoreShelleyEraWalletDescription: {
id: 'wallet.add.optionDialog.walletEra.shelleyEra.description',
defaultMessage: '!!!Shelley-era wallets support delegation to stake pools.',
id: 'wallet.add.optionDialog.walletEra.standard.description',
defaultMessage: '!!!Standard modern wallets support delegation to stake pools.',
},
hardwareTransferInstructions: {
id: 'transfer.instructions.hardware.disclaimer.instructions1',
Expand Down Expand Up @@ -773,9 +773,9 @@ const globalMessages: * = defineMessages({
id: 'global.errors.invalidPin',
defaultMessage: '!!!Invalid Pin',
},
buySellAda: {
id: 'button.buySellAda',
defaultMessage: '!!!Buy/Sell ADA',
buyAda: {
id: 'button.buyAda',
defaultMessage: '!!!Buy ADA',
},
txConfirmationLedgerNanoLine2: {
id: 'wallet.send.ledger.confirmationDialog.info.line.2',
Expand Down
8 changes: 4 additions & 4 deletions packages/yoroi-extension/app/i18n/locales/en-US.json
Expand Up @@ -50,11 +50,11 @@
"app.errors.unableToLoad": "Unable to load!",
"app.errors.unexpectedError": "Something unexpected happened. Please retry.",
"app.errors.unknowError": "Unknown error.",
"button.buySellAda": "Buy / Sell ADA",
"button.buyAda": "Buy ADA",
"buysell.dialog.instructions": "Please select your preferences. On the next screen, confirm your selection by pressing the green arrow on the top right",
"buysell.dialog.manual": "I will add my address manually",
"buysell.dialog.selectAddress": "Please select the receiving address. This will be shared with the third party provider called Changelly for the buy / sell of ADA. ",
"buysell.dialog.title": "Buy / Sell ADA",
"buy.dialog.title": "Buy ADA",
"connector.connect.connectedWallets": "Connected Wallets",
"connector.connect.noWebsitesConnected": "You don't have any websites connected yet",
"connector.settings.about": "About",
Expand Down Expand Up @@ -387,8 +387,8 @@
"wallet.add.optionDialog.walletEra.byronEra.description": "Wallets created before July 29th, 2020 are Byron-era wallets and cannot delegate.",
"wallet.add.optionDialog.walletEra.byronEra.title": "Byron-era (read-only) wallet",
"wallet.add.optionDialog.walletEra.dialogTitle": "Choose era",
"wallet.add.optionDialog.walletEra.shelleyEra.description": "Shelley-era wallets support delegation to stake pools.",
"wallet.add.optionDialog.walletEra.shelleyEra.title": "Shelley-era wallet",
"wallet.add.optionDialog.walletEra.standard.description": "Standard modern wallets support delegation to stake pools.",
"wallet.add.optionDialog.walletEra.standard.title": "Standard wallet",
"wallet.add.page.create.title": "Create wallet",
"wallet.add.page.create.tooltip": "Generate a new 15-word recovery phrase<br/>and create a Yoroi wallet.",
"wallet.add.page.daedalusTransfer.title": "Transfer funds from a Daedalus wallet to Yoroi",
Expand Down
2 changes: 1 addition & 1 deletion packages/yoroi-extension/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 packages/yoroi-extension/package.json
@@ -1,6 +1,6 @@
{
"name": "yoroi",
"version": "4.7.310",
"version": "4.7.400",
"description": "Cardano ADA wallet",
"scripts": {
"dev:build": "rimraf dev/ && babel-node scripts/build --type=debug",
Expand Down

0 comments on commit 9a5c8b7

Please sign in to comment.