Skip to content

Commit

Permalink
Merge pull request #1222 from multiversx/development
Browse files Browse the repository at this point in the history
2.36.3
  • Loading branch information
razvantomegea authored Aug 6, 2024
2 parents 252b460 + eddf0e8 commit d760287
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[v2.36.3]](https://github.com/multiversx/mx-sdk-dapp/pull/1222)] - 2024-08-06
- [Prevent network update if there are no changes](https://github.com/multiversx/mx-sdk-dapp/pull/1220)

## [[v2.36.2]](https://github.com/multiversx/mx-sdk-dapp/pull/1219)] - 2024-08-06
- [Allow signing transactions wihen user balance is zero](https://github.com/multiversx/mx-sdk-dapp/pull/1218)
- [Prevent setting polling interval when websocket is present](https://github.com/multiversx/mx-sdk-dapp/pull/1217)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp",
"version": "2.36.2",
"version": "2.36.3",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down
8 changes: 6 additions & 2 deletions src/components/ProviderInitializer/ProviderInitializer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ export function ProviderInitializer() {
const loginService = useLoginService(
nativeAuthConfig ? nativeAuthConfig : false
);

const initializedAccountRef = useRef(false);
const dispatch = useDispatch();
const { setLedgerProvider, ledgerData } = useSetLedgerProvider();

useWebViewLogin();

const { callbackRoute, logoutRoute: wcLogoutRoute } = walletConnectLogin
Expand Down Expand Up @@ -116,8 +116,12 @@ export function ProviderInitializer() {
async function refreshNetworkConfig() {
try {
const networkConfig = await getNetworkConfigFromApi();
const hasDifferentNetworkConfig =
networkConfig &&
(network.chainId !== networkConfig.erd_chain_id ||
network.roundDuration !== networkConfig.erd_round_duration);

if (networkConfig) {
if (hasDifferentNetworkConfig) {
dispatch(
updateNetworkConfig({
chainId: networkConfig.erd_chain_id,
Expand Down
34 changes: 22 additions & 12 deletions src/utils/account/refreshAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import { getLatestNonce } from './getLatestNonce';
const setNewAccount = async () => {
try {
const address = await getAddress();

try {
const account = await getAccount(address);

if (account != null) {
const accountData = {
...account,
nonce: getLatestNonce(account)
};

store.dispatch(setAccount(accountData));

return accountData;
}
} catch (e) {
Expand All @@ -24,30 +28,36 @@ const setNewAccount = async () => {
} catch (e) {
console.error('Failed getting address ', e);
}

return null;
};

export async function refreshAccount() {
const provider = getAccountProvider();

if (provider == null) {
throw 'Provider not initialized';
}

if (!provider.isInitialized || provider.isInitialized()) {
return setNewAccount();
} else {
try {
if (!provider.init) {
throw 'Current provider does not have init() function';
}
}

const initialized = await provider.init();
if (!initialized) {
return;
}
return setNewAccount();
} catch (e) {
console.error('Failed initializing provider ', e);
try {
if (!provider.init) {
throw 'Current provider does not have init() function';
}

const initialized = await provider.init();

if (!initialized) {
return;
}

return setNewAccount();
} catch (e) {
console.error('Failed initializing provider ', e);
}

return undefined;
}

0 comments on commit d760287

Please sign in to comment.