Skip to content

Commit

Permalink
Restore changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arhtudormorar committed Sep 6, 2024
1 parent d95fe19 commit 0a8e43d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 42 deletions.
53 changes: 12 additions & 41 deletions src/core/methods/initApp/initApp.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,13 @@
import { initStore } from 'store/store';
import { defaultStorageCallback, StorageCallback } from 'store/storage';
import { defaultStorageCallback } from 'store/storage';
import { setNativeAuthConfig } from 'store/actions/config/configActions';
import { initializeNetwork } from 'store/actions';
import { CustomNetworkType } from 'types/network.types';
import { EnvironmentsEnum } from 'types/enums.types';
import { NativeAuthConfigType } from 'services/nativeAuth/nativeAuth.types';
import { getDefaultNativeAuthConfig } from 'services/nativeAuth/methods/getDefaultNativeAuthConfig';
import { InitAppType } from './initApp.types';
import { getIsLoggedIn } from '../account/getIsLoggedIn';
import { restoreProvider } from 'core/providers/helpers/restoreProvider';

export type InitAppType = {
/**
* The storage configuration for the dApp.
*/
storage?: {
/**
* The callback to get the storage (custom storage).
*/
getStorageCallback: StorageCallback;
};
dAppConfig?: {
/**
* The native auth configuration for the dApp.
* If set to `true`, will fallback on default configuration.
* If set to `false`, will disable native auth.
* If set to `NativeAuthConfigType`, will set the native auth configuration.
*/
nativeAuth?: boolean | NativeAuthConfigType;
/**
* Can override the network configuration, e.g. for sovereign shards.
*/
network?: CustomNetworkType;
/**
* If passed in, will automatically initialize the network with the given environment.
*/
environment?: EnvironmentsEnum;
};
};

const defaultInitAppProps = {
storage: {
getStorageCallback: defaultStorageCallback
Expand All @@ -51,12 +21,15 @@ const defaultInitAppProps = {
* @example
* ```ts
initApp({
nativeAuth: true
nativeAuth: true,
environment: EnvironmentsEnum.devnet
});
* ```
* */
export const initApp = async (props?: InitAppType) => {
const { storage, dAppConfig } = { ...defaultInitAppProps, ...props };
export const initApp = async ({
storage = defaultInitAppProps.storage,
dAppConfig
}: InitAppType) => {
initStore(storage.getStorageCallback);

if (dAppConfig?.nativeAuth) {
Expand All @@ -68,12 +41,10 @@ export const initApp = async (props?: InitAppType) => {
setNativeAuthConfig(nativeAuthConfig);
}

if (dAppConfig?.network) {
await initializeNetwork({
customNetworkConfig: dAppConfig.network,
environment: dAppConfig.environment
});
}
await initializeNetwork({
customNetworkConfig: dAppConfig.network,
environment: dAppConfig.environment
});

const isLoggedIn = getIsLoggedIn();

Expand Down
1 change: 1 addition & 0 deletions src/core/methods/signMessage/signMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface SignMessageType {
};
}

// TODO: upgrade to Message
export const signMessage = async ({
message,
callbackRoute,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@
"@walletconnect/utils" "2.12.2"
bech32 "1.1.4"

"@multiversx/sdk-wallet@^4.5.1":
"@multiversx/[email protected]":
version "4.5.1"
resolved "https://registry.yarnpkg.com/@multiversx/sdk-wallet/-/sdk-wallet-4.5.1.tgz#e4ffd218645c870c466bc0a7ef9bf68a4737ceb5"
integrity sha512-rvaMUV6OxNj9gchOn7wSCPZcWc6hjs1nQuY6QwnaEcBfPsHtFemNNt+t3uxPZOrDhAwXqUgyy9WdltvOs8somg==
Expand Down

0 comments on commit 0a8e43d

Please sign in to comment.