UNPKG

@privy-io/js-sdk-core

Version:

Vanilla JS client for the Privy Auth API

2 lines (1 loc) 1.1 kB
import{getUserEmbeddedEthereumWallet as e}from"../../utils/getUserEmbeddedEthereumWallet.mjs";import{getUserEmbeddedSolanaWallet as t}from"../../utils/getUserEmbeddedSolanaWallet.mjs";import{shouldCreateEmbeddedEthWallet as r}from"../../utils/shouldCreateEmbeddedEthWallet.mjs";import{shouldCreateEmbeddedSolWallet as s}from"../../utils/shouldCreateEmbeddedSolWallet.mjs";import"../../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../../utils/getAllUserEmbeddedSolanaWallets.mjs";const o=async(o,a,l)=>{let u=r(a.user,l?.ethereum?.createOnLogin??"off"),i=s(a.user,l?.solana?.createOnLogin??"off");if(u&&i){let t=await o.create({recoveryMethod:"privy",skipCallbacks:!0});return{...await o.createSolana({ethereumAccount:e(t.user)??void 0}),is_new_user:a.is_new_user,oauth_tokens:a.oauth_tokens}}return u?{...await o.create({recoveryMethod:"privy",solanaAccount:t(a.user)??void 0}),is_new_user:a.is_new_user,oauth_tokens:a.oauth_tokens}:i?{...await o.createSolana({ethereumAccount:e(a.user)??void 0}),is_new_user:a.is_new_user,oauth_tokens:a.oauth_tokens}:a};export{o as maybeCreateWalletOnLogin};