Skip to content

Commit

Permalink
Merge pull request #2641 from SelfKeyFoundation/release
Browse files Browse the repository at this point in the history
Release 1.9.14
  • Loading branch information
andregoncalves authored Sep 24, 2021
2 parents 00d22f2 + 8704212 commit 8330313
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "selfkey-identity-wallet",
"productName": "SelfKey Identity Wallet",
"version": "1.9.13",
"version": "1.9.14",
"description": "The Official SelfKey Identity Wallet for Desktop",
"browser": [
"chrome"
Expand Down
9 changes: 6 additions & 3 deletions src/common/transaction/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,13 @@ export const setTransactionFee = (newAddress, newAmount, newGasPrice, newGasLimi
let maxPriorityFee = 0;
if (featureIsEnabled('eip_1559')) {
if (!transaction.maxPriorityFee) {
maxPriorityFee =
state.ethGasStationInfo.ethGasStationInfo.fees.medium.suggestedMaxFeePerGas;
maxPriorityFee = Number(
parseFloat(
state.ethGasStationInfo.ethGasStationInfo.fees.medium.suggestedMaxFeePerGas
).toFixed(2)
);
} else {
maxPriorityFee = transaction.maxPriorityFee;
maxPriorityFee = parseFloat(transaction.maxPriorityFee);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/did/create-did-popup-container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CreateDIDPopupContainerComponent extends PureComponent {
const gasPrice = ethGasStationInfo ? ethGasStationInfo.average : 50;
const maxPriorityFee =
ethGasStationInfo && ethGasStationInfo.fees && ethGasStationInfo.fees.medium
? ethGasStationInfo.fees.medium.suggestedMaxFeePerGas
? parseFloat(ethGasStationInfo.fees.medium.suggestedMaxFeePerGas)
: 1;
const ethFee = EthUnits.toEther((gasPrice + maxPriorityFee) * gasLimit, 'gwei');
const usdFee = ethFee * ethRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BankAccountsCheckoutContainer extends MarketplaceBankAccountsComponent {
const gasPrice = ethGasStationInfo ? ethGasStationInfo.average : 50;
const maxPriorityFee =
ethGasStationInfo && ethGasStationInfo.fees && ethGasStationInfo.fees.medium
? ethGasStationInfo.fees.medium.suggestedMaxFeePerGas
? parseFloat(ethGasStationInfo.fees.medium.suggestedMaxFeePerGas)
: 1;
const price = jurisdiction.price;
const keyAmount = price / keyRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class IncorporationsCheckoutContainer extends MarketplaceIncorporationsComponent
const gasPrice = ethGasStationInfo ? ethGasStationInfo.average : 50;
const maxPriorityFee =
ethGasStationInfo && ethGasStationInfo.fees && ethGasStationInfo.fees.medium
? ethGasStationInfo.fees.medium.suggestedMaxFeePerGas
? parseFloat(ethGasStationInfo.fees.medium.suggestedMaxFeePerGas)
: 1;
const price = program.price;
const keyAmount = price / keyRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MarketplaceKeyFiCheckoutContainerComponent extends MarketplaceKeyFiCompone
const gasPrice = ethGasStationInfo ? ethGasStationInfo.average : 50;
const maxPriorityFee =
ethGasStationInfo && ethGasStationInfo.fees && ethGasStationInfo.fees.medium
? ethGasStationInfo.fees.medium.suggestedMaxFeePerGas
? parseFloat(ethGasStationInfo.fees.medium.suggestedMaxFeePerGas)
: 1;
const price = product.price;
const ethPrice = price;
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/marketplace/keyfi/widget/keyfi-widget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ const styles = theme => ({
},
actions: {
textAlign: 'center',
marginTop: '24px'
marginTop: '24px',
'& span': {
marginLeft: '10px'
}
},
ctabutton: {
backgroundColor: '#1E262E',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class RequestNotarizationContainer extends MarketplaceNotariesComponent {
const gasPrice = ethGasStationInfo ? ethGasStationInfo.average : 50;
const maxPriorityFee =
ethGasStationInfo && ethGasStationInfo.fees && ethGasStationInfo.fees.medium
? ethGasStationInfo.fees.medium.suggestedMaxFeePerGas
? parseFloat(ethGasStationInfo.fees.medium.suggestedMaxFeePerGas)
: 1;
const gasLimit = FIXED_GAS_LIMIT_PRICE;
const gasEthFee = EthUnits.toEther((gasPrice + maxPriorityFee) * gasLimit, 'gwei');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PassportsCheckoutContainerComponent extends MarketplacePassportsComponent
const gasPrice = ethGasStationInfo ? ethGasStationInfo.average : 50;
const maxPriorityFee =
ethGasStationInfo && ethGasStationInfo.fees && ethGasStationInfo.fees.medium
? ethGasStationInfo.fees.medium.suggestedMaxFeePerGas
? parseFloat(ethGasStationInfo.fees.medium.suggestedMaxFeePerGas)
: 1;

const price = program.price;
Expand Down
81 changes: 58 additions & 23 deletions src/renderer/transaction/send/components/transaction-fee-box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ const styles = theme => ({
}
});

const SECOND_CUTOFF = 90;

// Shows "seconds" as unit of time if under SECOND_CUTOFF, otherwise "minutes"
const toHumanReadableTime = (milliseconds = 1) => {
const seconds = Math.ceil(milliseconds / 1000);
if (seconds <= SECOND_CUTOFF) {
return 'Likely in < ' + seconds + ' sec';
}
return 'Likely in < ' + Math.ceil(seconds / 60) + ' min';
};

export class TransactionFeeBoxComponent extends PureComponent {
state = {
showAdvanced: this.props.showAdvanced || false
Expand All @@ -156,19 +167,31 @@ export class TransactionFeeBoxComponent extends PureComponent {
if (!this.props.ethGasStationInfo || !this.props.ethGasStationInfo[type]) {
return;
}
if (this.props.eip1559) {
return this.props.ethGasStationInfo[type];
} else {
return this.props.ethGasStationInfo[type];
return this.props.ethGasStationInfo[type];
}

getMaxPriorityFee(type) {
if (
!this.props.ethGasStationInfo ||
!this.props.ethGasStationInfo[type] ||
!this.props.ethGasStationInfo.fees
) {
return;
}
const maxPriorityFee = parseFloat(
this.props.ethGasStationInfo.fees[this.typeTranslation(type)].suggestedMaxFeePerGas
).toFixed(2);
return maxPriorityFee;
}

getFeeInEth(type, digits = false) {
const gasPrice = this.getFee(type);
const gasLimit = this.props.gasLimit ? this.props.gasLimit : DEFAULT_ETH_GAS_LIMIT;

const maxFee = this.props.ethGasStationInfo.fees[this.typeTranslation(type)]
.suggestedMaxFeePerGas;
const maxFee = parseFloat(
this.props.ethGasStationInfo.fees[this.typeTranslation(type)].suggestedMaxFeePerGas
);

const ethFee = EthUnits.toEther((gasPrice + maxFee) * gasLimit, 'gwei');
return digits ? Number.parseFloat(ethFee).toFixed(digits) : ethFee;
}
Expand All @@ -179,20 +202,14 @@ export class TransactionFeeBoxComponent extends PureComponent {
return ethFee * ethRate;
}

getTransactionTiming(data) {
getTransactionTiming(data, what) {
if (data && data.maxWaitTimeEstimate) {
return `Likely in < ${Math.ceil(data.maxWaitTimeEstimate / 1000 / 60)} min`;
return toHumanReadableTime(data.maxWaitTimeEstimate);
} else {
return '';
}
}

getMaxPriorityFee(data) {
if (data && data.maxPriorityFee) {
return data.maxPriorityFee;
}
}

toggleShowAdvanced() {
const { showAdvanced } = this.state;
this.setState({ ...this.state, showAdvanced: !showAdvanced });
Expand Down Expand Up @@ -221,6 +238,7 @@ export class TransactionFeeBoxComponent extends PureComponent {

setMaxPriorityFee = event => {
const value = event.target.value;

if (this.props.changeMaxPriorityFeeAction) {
this.props.changeMaxPriorityFeeAction(value);
}
Expand All @@ -234,8 +252,10 @@ export class TransactionFeeBoxComponent extends PureComponent {
}

const gasPrice = this.props.ethGasStationInfo[type];
const maxPriorityFee = this.props.ethGasStationInfo.fees[this.typeTranslation(type)]
.suggestedMaxPriorityFeePerGas;
const maxPriorityFee = parseFloat(
this.props.ethGasStationInfo.fees[this.typeTranslation(type)]
.suggestedMaxPriorityFeePerGas
);

if (changeMaxPriorityFeeAction) {
changeMaxPriorityFeeAction(maxPriorityFee);
Expand Down Expand Up @@ -267,7 +287,11 @@ export class TransactionFeeBoxComponent extends PureComponent {
<div className={classes.transactionFee}>
<div
className={`${
this.props.gasPrice === this.getFee('safeLow') ? 'selected' : ''
gasPrice === this.getFee('safeLow') &&
parseFloat(maxPriorityFee).toFixed(2) ===
this.getMaxPriorityFee('safeLow')
? 'selected'
: ''
}`}
onClick={() => this.selectPreDefinedGas('safeLow')}
>
Expand Down Expand Up @@ -301,13 +325,17 @@ export class TransactionFeeBoxComponent extends PureComponent {
</div>
<div className={classes.transactionExpectedTiming}>
<Typography variant="subtitle2" color="success">
{this.getTransactionTiming(ethGasStationInfo.fees.low)}
{this.getTransactionTiming(ethGasStationInfo.fees.high, 'low')}
</Typography>
</div>
</div>
<div
className={`${
this.props.gasPrice === this.getFee('average') ? 'selected' : ''
this.props.gasPrice === this.getFee('average') &&
parseFloat(maxPriorityFee).toFixed(2) ===
this.getMaxPriorityFee('average')
? 'selected'
: ''
}`}
onClick={() => this.selectPreDefinedGas('average')}
>
Expand Down Expand Up @@ -341,13 +369,20 @@ export class TransactionFeeBoxComponent extends PureComponent {
</div>
<div className={classes.transactionExpectedTiming}>
<Typography variant="subtitle2" color="success">
{this.getTransactionTiming(ethGasStationInfo.fees.medium)}
{this.getTransactionTiming(
ethGasStationInfo.fees.medium,
'medium'
)}
</Typography>
</div>
</div>
<div
className={`${
this.props.gasPrice === this.getFee('fast') ? 'selected' : ''
this.props.gasPrice === this.getFee('fast') &&
parseFloat(maxPriorityFee).toFixed(2) ===
this.getMaxPriorityFee('fast')
? 'selected'
: ''
}`}
onClick={() => this.selectPreDefinedGas('fast')}
>
Expand Down Expand Up @@ -381,7 +416,7 @@ export class TransactionFeeBoxComponent extends PureComponent {
</div>
<div className={classes.transactionExpectedTiming}>
<Typography variant="subtitle2" color="success">
{this.getTransactionTiming(ethGasStationInfo.fees.high)}
{this.getTransactionTiming(ethGasStationInfo.fees.low, 'high')}
</Typography>
</div>
</div>
Expand Down Expand Up @@ -418,7 +453,7 @@ export class TransactionFeeBoxComponent extends PureComponent {
<input
type="text"
className={classes.formControl}
value={Number.parseFloat(maxPriorityFee).toFixed(2)}
value={maxPriorityFee}
onChange={e => this.setMaxPriorityFee(e)}
/>
</div>
Expand Down

0 comments on commit 8330313

Please sign in to comment.