Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: show help to correct missing storage adapter #457

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"));
};