Skip to content

Commit

Permalink
Merge branch 'development' into cross-window-hub
Browse files Browse the repository at this point in the history
  • Loading branch information
arhtudormorar committed Dec 21, 2023
2 parents 057ade9 + 6a7af41 commit afcbccd
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 39 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [[v2.26.1]](https://github.com/multiversx/mx-sdk-dapp/pull/1001)] - 2023-12-21

- [Remove sdk-network-providers from the dependencies](https://github.com/multiversx/mx-sdk-dapp/pull/1000)

## [[v2.26.0]](https://github.com/multiversx/mx-sdk-dapp/pull/998)] - 2023-12-20

- [Prevent logout action when not logged in or provider not initialized](https://github.com/multiversx/mx-sdk-dapp/pull/997)
- [Fix cancel sign message toast](https://github.com/multiversx/mx-sdk-dapp/pull/995)
- [⚠️ Breaking change: message signing URL to use `addOriginToLocationPath`](https://github.com/multiversx/mx-sdk-dapp/pull/994)

Expand All @@ -22,7 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Added latest `axios` version](https://github.com/multiversx/mx-sdk-dapp/pull/989)
- [Prevent redirect on logout if `callbackURL` is the current URL](https://github.com/multiversx/mx-sdk-dapp/pull/987)
- [Fix sign message with web wallet provider](https://github.com/multiversx/mx-sdk-dapp/pull/985)
- [Fix typo in AxiosInterceptor](https://github.com/multiversx/mx-sdk-dapp/pull/984)
- [⚠️ Breaking change: Fix typo in AxiosInterceptor](https://github.com/multiversx/mx-sdk-dapp/pull/984)

## [[v2.24.4]](https://github.com/multiversx/mx-sdk-dapp/pull/983)] - 2023-12-11

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
"@multiversx/sdk-extension-provider": "3.0.0",
"@multiversx/sdk-hw-provider": "6.4.0",
"@multiversx/sdk-native-auth-client": "1.0.6",
"@multiversx/sdk-network-providers": "2.2.0",
"@multiversx/sdk-opera-provider": "1.0.0-alpha.1",
"@multiversx/sdk-wallet": "4.2.0",
"@multiversx/sdk-wallet-connect-provider": "4.0.4",
Expand Down
83 changes: 83 additions & 0 deletions src/models/TransactionStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* An abstraction for handling and interpreting the "status" field of a transaction.
*/
export class TransactionStatus {
/**
* The raw status, as fetched from the Network.
*/
readonly status: string;

/**
* Creates a new TransactionStatus object.
*/
constructor(status: string) {
this.status = (status || '').toLowerCase();
}

/**
* Creates an unknown status.
*/
static createUnknown(): TransactionStatus {
return new TransactionStatus('unknown');
}

/**
* Returns whether the transaction is pending (e.g. in mempool).
*/
isPending(): boolean {
return this.status == 'received' || this.status == 'pending';
}

/**
* Returns whether the transaction has been executed (not necessarily with success).
*/
isExecuted(): boolean {
return this.isSuccessful() || this.isFailed() || this.isInvalid();
}

/**
* Returns whether the transaction has been executed successfully.
*/
isSuccessful(): boolean {
return (
this.status == 'executed' ||
this.status == 'success' ||
this.status == 'successful'
);
}

/**
* Returns whether the transaction has been executed, but with a failure.
*/
isFailed(): boolean {
return (
this.status == 'fail' ||
this.status == 'failed' ||
this.status == 'unsuccessful' ||
this.isInvalid()
);
}

/**
* Returns whether the transaction has been executed, but marked as invalid (e.g. due to "insufficient funds").
*/
isInvalid(): boolean {
return this.status == 'invalid';
}

toString(): string {
return this.status;
}

valueOf(): string {
return this.status;
}

equals(other: TransactionStatus) {
if (!other) {
return false;
}

return this.status == other.status;
}
}
2 changes: 1 addition & 1 deletion src/services/transactions/getTransactionsDetails.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TransactionStatus } from '@multiversx/sdk-network-providers';
import { getTransactionByHashPromise } from 'apiCalls';
import { TransactionStatus } from 'models/TransactionStatus';
import { ServerTransactionType } from 'types';
import { delayWithPromise } from 'utils/delayWithPromise';

Expand Down
2 changes: 1 addition & 1 deletion src/utils/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export async function logout(
console.error('error fetching logout address', err);
}

store.dispatch(logoutAction());
const url = addOriginToLocationPath(callbackUrl);
const location = getWindowLocation();
const callbackPathname = new URL(url).pathname;
Expand All @@ -83,6 +82,7 @@ export async function logout(
}

try {
store.dispatch(logoutAction());
await provider.logout({ callbackUrl: url });
} catch (err) {
console.error('error logging out', err);
Expand Down
13 changes: 6 additions & 7 deletions src/utils/operations/calculateFeeLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Address,
TokenPayment
} from '@multiversx/sdk-core';
import { NetworkConfig } from '@multiversx/sdk-network-providers';
import BigNumber from 'bignumber.js';
import {
EXTRA_GAS_LIMIT_GUARDED_TX,
Expand Down Expand Up @@ -62,13 +61,13 @@ export function calculateFeeLimit({
version: new TransactionVersion(1)
});

const networkConfig = new NetworkConfig();
networkConfig.MinGasLimit = parseInt(minGasLimit);
networkConfig.GasPerDataByte = parseInt(gasPerDataByte);
networkConfig.GasPriceModifier = parseFloat(gasPriceModifier);

try {
const bNfee = transaction.computeFee(networkConfig);
const bNfee = transaction.computeFee({
GasPerDataByte: parseInt(gasPerDataByte),
MinGasLimit: parseInt(minGasLimit),
GasPriceModifier: parseFloat(gasPriceModifier),
ChainID: chainId
});
return bNfee.toString(10);
} catch (err) {
console.error(err);
Expand Down
29 changes: 1 addition & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1978,17 +1978,6 @@
dependencies:
axios "^1.6.2"

"@multiversx/sdk-network-providers@2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@multiversx/sdk-network-providers/-/sdk-network-providers-2.2.0.tgz#2b8d5fbbc848dbeba38950db2f02340908dfcfd3"
integrity sha512-2n/+7Ap6S9rJGTiX38GCZ2TmY9zQ1U7o1DwnWpHNRJRxArSN/xzLrbcSKy8InMyc+4A+VHf5pV0Pk8NdPV6++w==
dependencies:
axios "1.6.1"
bech32 "1.1.4"
bignumber.js "9.0.1"
buffer "6.0.3"
json-bigint "1.0.0"

"@multiversx/sdk-opera-provider@1.0.0-alpha.1":
version "1.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/@multiversx/sdk-opera-provider/-/sdk-opera-provider-1.0.0-alpha.1.tgz#2beebd5423fdc2e667b33660f17cbff325449097"
Expand Down Expand Up @@ -5411,15 +5400,6 @@ axios-mock-adapter@1.21.2:
fast-deep-equal "^3.1.3"
is-buffer "^2.0.5"

axios@1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.1.tgz#76550d644bf0a2d469a01f9244db6753208397d7"
integrity sha512-vfBmhDpKafglh0EldBEbVuoe7DyAavGSLWhuSm5ZSEKQnHhBf0xAAwybbNH1IkrJNGnS/VG4I5yxig1pCEXE4g==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@1.6.2, axios@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2"
Expand Down Expand Up @@ -5651,7 +5631,7 @@ bignumber.js@9.0.1:
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.1.tgz#8d7ba124c882bfd8e43260c67475518d0689e4e5"
integrity sha512-IdZR9mh6ahOBv/hYGiXyVuyCetmGJhtYkqLBpTStdhEGjegpPlUawydyaF3pbIOFynJTpllEs+NP+CS9jKFLjA==

bignumber.js@9.x, bignumber.js@^9.0.0:
bignumber.js@9.x:
version "9.1.2"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c"
integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==
Expand Down Expand Up @@ -10906,13 +10886,6 @@ jsesc@~0.5.0:
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
integrity sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==

json-bigint@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1"
integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==
dependencies:
bignumber.js "^9.0.0"

json-buffer@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13"
Expand Down

0 comments on commit afcbccd

Please sign in to comment.