Skip to content

Commit

Permalink
docs: show help to correct missing storage adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal authored Jul 3, 2022
1 parent 790818b commit 9596266
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/wallet-lib/src/types/Storage/_getDefaultAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@ module.exports = async function getDefaultAdapter() {
const isReactNative = (typeof navigator !== 'undefined' && navigator.product === 'ReactNative');
const isNode = !isBrowser && !isReactNative;

function getWarn(env) {
return [
`Running on ${env} without 'dapiOpts.wallet.adapter' for address storage. Data will not persist.`,
`See <https://github.com/dashevo/platform/blob/master/packages/wallet-lib/src/adapters/InMem.js>`,
`and <https://github.com/coolaj86/platform-readme-tutorials/blob/better-storage-example/create-wallet.js>`,
].join('\n');
}

if (isNode) {
logger.warn('Running on a NodeJS env without any specified adapter. Data will not persist.');
logger.warn(getWarn("a NodeJS env"));
return InMem;
}
if (isReactNative) {
logger.warn('Running on a React Native env without any specified adapter. Data will not persist.');
logger.warn(getWarn("a React Native env"));
return InMem;
} if (isBrowser) {
return InMem;
}
throw new Error('Undetected platform - No default adapter to persist data to.');
throw new Error(getWarn("an unknown platform"));
};

0 comments on commit 9596266

Please sign in to comment.