@rango-dev/wallets-react 0.23.1-next.0 → 0.23.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var L=Object.defineProperty;var l=(e,n)=>L(e,"name",{value:n,configurable:!0});import{Persistor as w}from"@rango-dev/wallets-core/legacy";var u="last-connected-wallets";function Q(e,n){return e.find(
|
|
1
|
+
var L=Object.defineProperty;var l=(e,n)=>L(e,"name",{value:n,configurable:!0});import{Persistor as w}from"@rango-dev/wallets-core/legacy";var u="last-connected-wallets";function Q(e,n){return e.find(c=>c.type===n)||null}l(Q,"choose");var m={connected:!1,connecting:!1,reachable:!1,installed:!1,accounts:null,network:null};function v(e,n){if(n.type==="new_state"){let c=e[n.wallet];return c?{...e,[n.wallet]:{...c,[n.name]:n.value}}:{...e,[n.wallet]:{...m,[n.name]:n.value}}}return e}l(v,"stateReducer");function P(e){return Object.entries(e).filter(([,n])=>n?.connected).map(([n])=>n)}l(P,"connectedWallets");function I(e){return Object.entries(e).map(([n])=>n)}l(I,"availableWallets");function k(e){let n=new Map;return e.forEach(c=>{let{config:a,...i}=c;n.set(a.type,{actions:i,config:a})}),n}l(k,"checkWalletProviders");function V(e){return e?.constructor?.name==="AsyncFunction"}l(V,"isAsync");function X(e){let{checkInstallation:n=!0}=e.config;return n}l(X,"needsCheckInstallation");async function x({type:e,walletActions:n,getState:c}){if(n.canEagerConnect){let a=new w,i=a.getItem(u);i?.find(t=>!c(t).connected)&&W();let p=!!i?.find(t=>t===e);i&&!p?a.setItem(u,i.concat(e)):a.setItem(u,[e])}}l(x,"tryPersistWallet");function S({type:e,walletActions:n}){if(n.canEagerConnect){let c=new w,a=c.getItem(u);a&&c.setItem(u,a.filter(i=>i!==e))}}l(S,"tryRemoveWalletFromPersistance");function W(){let e=new w;e.getItem(u)&&e.removeItem(u)}l(W,"clearPersistance");async function E(e,n){let c=new w,a=c.getItem(u);if(a&&a.length){let i=[];a.forEach(t=>{let o=e.get(t);if(o){let r=n(o);i.push({walletType:t,eagerConnect:r.eagerConnect.bind(r)})}});let d=await Promise.allSettled(i.map(async({eagerConnect:t})=>t()));if(!!d.find(({status:t})=>t==="fulfilled")){let t=[];d.forEach((o,r)=>{let{status:s}=o;s==="rejected"&&t.push(i[r].walletType)}),t.length&&c.setItem(u,a.filter(o=>!t.includes(o)))}}}l(E,"autoConnect");function h(e,n){return l((a,i,d,p,t)=>{e({type:"new_state",wallet:a,name:i,value:d}),n&&n(a,i,d,p,t)},"handler")}l(h,"makeEventHandler");import _ from"react";import{createContext as B}from"react";var f="Context hasn't been initialized yet.",R={async connect(){throw new Error(f)},async disconnect(){throw new Error(f)},async disconnectAll(){throw new Error(f)},async suggestAndConnect(){throw new Error(f)},state(){throw new Error(f)},canSwitchNetworkTo(){throw new Error(f)},providers(){throw new Error(f)},getWalletInfo(){throw new Error(f)},getSigners(){throw new Error(f)}},g=B(R);import{useEffect as C,useReducer as D}from"react";import{LegacyWallet as O}from"@rango-dev/wallets-core/legacy";import{useContext as H,useRef as M}from"react";function T(e){let n=M({});function c(a){let i=a.config.type;return typeof n.current[i]>"u"&&(n.current[i]=new O({config:a.config,handler:e},a.actions)),n.current[i]}return l(c,"updater"),c}l(T,"useInitializers");function F(){let e=H(g);if(!e)throw Error("useWallet can only be used within the Provider component");return e}l(F,"useWallets");import{useEffect as G,useRef as j}from"react";function A(e){let n=j(!1);G(()=>{e.allBlockChains&&e.allBlockChains.length&&e.autoConnect&&!n.current&&(n.current=!0,(async()=>await E(e.wallets,e.getWalletInstanceFromLegacy))())},[e.autoConnect,e.allBlockChains])}l(A,"useAutoConnect");function N(e){let[n,c]=D(v,{}),a=T(h(c,e.onUpdateState)),i=e.providers,d=k(i);A({wallets:d,allBlockChains:e.allBlockChains,autoConnect:e.autoConnect,getWalletInstanceFromLegacy:a});let p={async connect(t,o,r){let s=d.get(t);if(!s)throw new Error(`You should add ${t} to provider first.`);let b=await a(s).connect(o,r);return e.autoConnect&&x({type:t,walletActions:s.actions,getState:p.state}),b},async disconnect(t){let o=d.get(t);if(!o)throw new Error(`You should add ${t} to provider first.`);await a(o).disconnect(),e.autoConnect&&S({type:t,walletActions:o.actions})},async disconnectAll(){let t=[];return P(n).forEach(o=>{let r=d.get(o);if(r){let s=a(r);t.push(s.disconnect())}}),e.autoConnect&&W(),await Promise.allSettled(t)},async suggestAndConnect(t,o){let r=d.get(t);if(!r)throw new Error(`You should add ${t} to provider first.`);return await a(r).suggestAndConnect(o)},state(t){return n[t]||m},canSwitchNetworkTo(t,o){let r=d.get(t);if(!r)return!1;let s=a(r);return s.canSwitchNetworkTo?s.canSwitchNetworkTo(o,s.provider):!1},providers(){let t={};return I(n).forEach(o=>{let r=d.get(o);if(r){let s=a(r);t[o]=s.provider}}),t},getWalletInfo(t){let o=d.get(t);if(!o)throw new Error(`You should add ${t} to provider first.`);return o.actions.getWalletInfo(e.allBlockChains||[])},async getSigners(t){let o=d.get(t);if(!o)throw new Error(`You should add ${t} to provider first.`);let r=a(o),s=r.provider;return r.getSigners(s)}};return C(()=>{d.forEach(t=>{let o=a(t),r=l(()=>{o.onInit&&o.onInit()},"runOnInit"),s=l(y=>{y.target&&y.target.readyState==="complete"&&(r(),document.removeEventListener("readystatechange",s))},"initWhenPageIsReady");r(),document.addEventListener("readystatechange",s)})},[]),C(()=>{e.allBlockChains&&d.forEach(o=>{let r=a(o),s=r.getWalletInfo(e.allBlockChains||[]);r.setInfo({supportedBlockchains:s.supportedChains,isContractWallet:!!s.isContractWallet})})},[e.allBlockChains]),C(()=>{d.forEach(t=>{a(t).setHandler(h(c,e.onUpdateState))})},[e.onUpdateState]),p}l(N,"useLegacyProviders");function Y(e){let n=N(e);return _.createElement(g.Provider,{value:n},e.children)}l(Y,"Provider");var $=Y;var U=(p=>(p.CONNECTED="connected",p.CONNECTING="connecting",p.REACHABLE="reachable",p.INSTALLED="installed",p.ACCOUNTS="accounts",p.NETWORK="network",p))(U||{});export{U as Events,$ as Provider,E as autoConnect,I as availableWallets,k as checkWalletProviders,Q as choose,W as clearPersistance,P as connectedWallets,m as defaultWalletState,V as isAsync,h as makeEventHandler,X as needsCheckInstallation,v as stateReducer,x as tryPersistWallet,S as tryRemoveWalletFromPersistance,F as useWallets};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/legacy/helpers.ts", "../src/legacy/constants.ts", "../src/provider.tsx", "../src/legacy/context.ts", "../src/legacy/useLegacyProviders.ts", "../src/legacy/hooks.ts", "../src/legacy/useAutoConnect.ts", "../src/legacy/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n ProviderInterface,\n State,\n WalletActions,\n WalletProviders,\n} from './types.js';\nimport type {\n LegacyOptions as Options,\n LegacyWallet as Wallet,\n LegacyEventHandler as WalletEventHandler,\n LegacyState as WalletState,\n} from '@rango-dev/wallets-core/legacy';\nimport type { WalletConfig, WalletType } from '@rango-dev/wallets-shared';\n\nimport { Persistor } from '@rango-dev/wallets-core/legacy';\n\nimport { LAST_CONNECTED_WALLETS } from './constants.js';\n\nexport function choose(wallets: any[], type: WalletType): any | null {\n return wallets.find((wallet) => wallet.type === type) || null;\n}\n\nexport const defaultWalletState: WalletState = {\n connected: false,\n connecting: false,\n reachable: false,\n installed: false,\n accounts: null,\n network: null,\n};\n\nexport function stateReducer(state: State, action: any) {\n if (action.type === 'new_state') {\n // TODO fix problem and remove ts-ignore\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const target_wallet = state[action.wallet];\n if (!target_wallet) {\n return {\n ...state,\n [action.wallet]: {\n ...defaultWalletState,\n [action.name]: action.value,\n },\n };\n }\n\n return {\n ...state,\n [action.wallet]: {\n ...target_wallet,\n [action.name]: action.value,\n },\n };\n }\n\n return state;\n}\n\nexport function connectedWallets(providersState: State): WalletType[] {\n return Object.entries(providersState)\n .filter(([, wallet_state]) => {\n return wallet_state?.connected;\n })\n .map(([type]) => {\n return type;\n });\n}\n\nexport function availableWallets(providersState: State): WalletType[] {\n return Object.entries(providersState).map(([type]) => {\n return type;\n });\n}\n\nexport function checkWalletProviders(\n list: ProviderInterface[]\n): WalletProviders {\n const wallets: WalletProviders = new Map();\n\n list.forEach((provider) => {\n const { config, ...actions } = provider;\n wallets.set(config.type, {\n actions,\n config,\n });\n });\n\n return wallets;\n}\n\n/* eslint-disable @typescript-eslint/ban-types */\nexport function isAsync(fn: Function) {\n return fn?.constructor?.name === 'AsyncFunction';\n}\n\nexport function needsCheckInstallation(options: Options) {\n const { checkInstallation = true } = options.config;\n return checkInstallation;\n}\n\nexport async function tryPersistWallet({\n type,\n walletActions,\n getState,\n}: {\n type: WalletType;\n walletActions: WalletActions;\n getState: (walletType: WalletType) => WalletState;\n}) {\n if (walletActions.canEagerConnect) {\n const persistor = new Persistor<string[]>();\n const wallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n\n /*\n *If on the last attempt we are unable to eagerly connect to any wallet and the user connects any wallet manualy,\n *persistance will be outdated and will need to be removed.\n */\n const shouldClearPersistance = wallets?.find(\n (walletType) => !getState(walletType).connected\n );\n\n if (shouldClearPersistance) {\n clearPersistance();\n }\n\n const walletAlreadyPersisted = !!wallets?.find((wallet) => wallet === type);\n if (wallets && !walletAlreadyPersisted) {\n persistor.setItem(LAST_CONNECTED_WALLETS, wallets.concat(type));\n } else {\n persistor.setItem(LAST_CONNECTED_WALLETS, [type]);\n }\n }\n}\n\nexport function tryRemoveWalletFromPersistance({\n type,\n walletActions,\n}: {\n type: WalletType;\n walletActions: WalletActions;\n}) {\n if (walletActions.canEagerConnect) {\n const persistor = new Persistor<string[]>();\n const wallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n if (wallets) {\n persistor.setItem(\n LAST_CONNECTED_WALLETS,\n wallets.filter((wallet) => wallet !== type)\n );\n }\n }\n}\n\nexport function clearPersistance() {\n const persistor = new Persistor<string[]>();\n const wallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n if (wallets) {\n persistor.removeItem(LAST_CONNECTED_WALLETS);\n }\n}\n\n/*\n *If a wallet has multiple providers and one of them can be eagerly connected,\n *then the whole wallet will support it at that point and we try to connect to that wallet as usual in eagerConnect method.\n */\nexport async function autoConnect(\n wallets: WalletProviders,\n getWalletInstance: (wallet: {\n actions: WalletActions;\n config: WalletConfig;\n }) => Wallet<any>\n) {\n const persistor = new Persistor<string[]>();\n const lastConnectedWallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n if (lastConnectedWallets && lastConnectedWallets.length) {\n const connect_promises: {\n walletType: WalletType;\n eagerConnect: () => Promise<any>;\n }[] = [];\n lastConnectedWallets.forEach((walletType) => {\n const wallet = wallets.get(walletType);\n\n if (!!wallet) {\n const walletInstance = getWalletInstance(wallet);\n connect_promises.push({\n walletType,\n eagerConnect: walletInstance.eagerConnect.bind(walletInstance),\n });\n }\n });\n\n const result = await Promise.allSettled(\n connect_promises.map(async ({ eagerConnect }) => eagerConnect())\n );\n\n const canRestoreAnyConnection = !!result.find(\n ({ status }) => status === 'fulfilled'\n );\n\n /*\n *After successfully connecting to at least one wallet,\n *we will removing the other wallets from persistence.\n *If we are unable to connect to any wallet,\n *the persistence will not be removed and the eager connection will be retried with another page load.\n */\n if (canRestoreAnyConnection) {\n const walletsToRemoveFromPersistance: WalletType[] = [];\n result.forEach((settleResult, index) => {\n const { status } = settleResult;\n\n if (status === 'rejected') {\n walletsToRemoveFromPersistance.push(\n connect_promises[index].walletType\n );\n }\n });\n\n if (walletsToRemoveFromPersistance.length) {\n persistor.setItem(\n LAST_CONNECTED_WALLETS,\n lastConnectedWallets.filter(\n (walletType) => !walletsToRemoveFromPersistance.includes(walletType)\n )\n );\n }\n }\n }\n}\n/*\n *Our event handler includes an internal state updater, and a notifier\n *for the outside listener.\n *On creating first wallet refrence, and on chaning `props.onUpdateState`\n *we are using this function.\n */\nexport function makeEventHandler(\n dispatcher: any,\n onUpdateState?: WalletEventHandler\n) {\n const handler: WalletEventHandler = (\n type,\n name,\n value,\n coreState,\n supportedChains\n ) => {\n const action = { type: 'new_state', wallet: type, name, value };\n // Update state\n dispatcher(action);\n\n // Giving the event to the outside listener\n if (onUpdateState) {\n onUpdateState(type, name, value, coreState, supportedChains);\n }\n };\n\n return handler;\n}\n", "export const LAST_CONNECTED_WALLETS = 'last-connected-wallets';\n", "import type { ProviderProps } from './legacy/types.js';\n\nimport React from 'react';\n\nimport { WalletContext } from './legacy/context.js';\nimport { useLegacyProviders } from './legacy/useLegacyProviders.js';\n\nfunction Provider(props: ProviderProps) {\n const legacyApi = useLegacyProviders(props);\n\n return (\n <WalletContext.Provider value={legacyApi}>\n {props.children}\n </WalletContext.Provider>\n );\n}\n\nexport default Provider;\n", "import type { ProviderContext } from './types.js';\n\nimport { createContext } from 'react';\n\nconst defaultErrorMesssage = \"Context hasn't been initialized yet.\";\nconst defaultContext: ProviderContext = {\n async connect() {\n throw new Error(defaultErrorMesssage);\n },\n async disconnect() {\n throw new Error(defaultErrorMesssage);\n },\n async disconnectAll() {\n throw new Error(defaultErrorMesssage);\n },\n async suggestAndConnect() {\n throw new Error(defaultErrorMesssage);\n },\n state() {\n throw new Error(defaultErrorMesssage);\n },\n canSwitchNetworkTo() {\n throw new Error(defaultErrorMesssage);\n },\n providers() {\n throw new Error(defaultErrorMesssage);\n },\n getWalletInfo() {\n throw new Error(defaultErrorMesssage);\n },\n getSigners() {\n throw new Error(defaultErrorMesssage);\n },\n};\n\nexport const WalletContext = createContext<ProviderContext>(defaultContext);\n", "import type { ProviderContext, ProviderProps } from './types.js';\nimport type { WalletType } from '@rango-dev/wallets-shared';\n\nimport { useEffect, useReducer } from 'react';\n\nimport {\n availableWallets,\n checkWalletProviders,\n clearPersistance,\n connectedWallets,\n defaultWalletState,\n makeEventHandler,\n stateReducer,\n tryPersistWallet,\n tryRemoveWalletFromPersistance,\n} from './helpers.js';\nimport { useInitializers } from './hooks.js';\nimport { useAutoConnect } from './useAutoConnect.js';\n\nexport function useLegacyProviders(props: ProviderProps): ProviderContext {\n const [providersState, dispatch] = useReducer(stateReducer, {});\n\n // Get (or add) wallet instance (`provider`s will be wrapped in a `Wallet`)\n const getWalletInstance = useInitializers(\n makeEventHandler(dispatch, props.onUpdateState)\n );\n\n // Getting providers from props and put all of them in a `Map` with an appropriate interface.\n const listOfProviders = props.providers;\n const wallets = checkWalletProviders(listOfProviders);\n\n useAutoConnect({\n wallets,\n allBlockChains: props.allBlockChains,\n autoConnect: props.autoConnect,\n getWalletInstanceFromLegacy: getWalletInstance,\n });\n\n // Final API we put in context and it will be available to use for users.\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n const api: ProviderContext = {\n async connect(type, network, namespaces) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n const walletInstance = getWalletInstance(wallet);\n const result = await walletInstance.connect(network, namespaces);\n if (props.autoConnect) {\n void tryPersistWallet({\n type,\n walletActions: wallet.actions,\n getState: api.state,\n });\n }\n\n return result;\n },\n async disconnect(type) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n const walletInstance = getWalletInstance(wallet);\n await walletInstance.disconnect();\n if (props.autoConnect) {\n tryRemoveWalletFromPersistance({ type, walletActions: wallet.actions });\n }\n },\n async disconnectAll() {\n const disconnect_promises: Promise<any>[] = [];\n\n /*\n * When a wallet is initializing, a record will be added to `providersState`\n * So we use them to know what wallet has been initialized then we need to\n * filter connected wallets only.\n */\n connectedWallets(providersState).forEach((type) => {\n const wallet = wallets.get(type);\n\n if (wallet) {\n const walletInstance = getWalletInstance(wallet);\n disconnect_promises.push(walletInstance.disconnect());\n }\n });\n\n if (props.autoConnect) {\n clearPersistance();\n }\n return await Promise.allSettled(disconnect_promises);\n },\n\n async suggestAndConnect(type, network) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n const walletInstance = getWalletInstance(wallet);\n const result = await walletInstance.suggestAndConnect(network);\n\n return result;\n },\n\n state(type) {\n return providersState[type] || defaultWalletState;\n },\n canSwitchNetworkTo(type, network) {\n const wallet = wallets.get(type);\n if (!wallet) {\n return false;\n }\n\n const walletInstance = getWalletInstance(wallet);\n return walletInstance.canSwitchNetworkTo\n ? walletInstance.canSwitchNetworkTo(network, walletInstance.provider)\n : false;\n },\n providers() {\n const providers: { [type in WalletType]?: any } = {};\n availableWallets(providersState).forEach((type) => {\n const wallet = wallets.get(type);\n if (wallet) {\n const walletInstance = getWalletInstance(wallet);\n providers[type] = walletInstance.provider;\n }\n });\n\n return providers;\n },\n getWalletInfo(type) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n /*\n * Get wallet info could be used in render methods to show wallets data\n * So, addWalletRef method shouldn't be called in this method\n */\n\n return wallet.actions.getWalletInfo(props.allBlockChains || []);\n },\n getSigners(type) {\n const wallet = wallets.get(type);\n\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n const walletInstance = getWalletInstance(wallet);\n const provider = walletInstance.provider;\n const result = walletInstance.getSigners(provider);\n\n return result;\n },\n };\n\n // Initialize instances\n useEffect(() => {\n wallets.forEach((wallet) => {\n const walletInstance = getWalletInstance(wallet);\n const runOnInit = () => {\n if (walletInstance.onInit) {\n walletInstance.onInit();\n }\n };\n\n const initWhenPageIsReady = (event: Event) => {\n if (\n event.target &&\n (event.target as Document).readyState === 'complete'\n ) {\n runOnInit();\n\n document.removeEventListener('readystatechange', initWhenPageIsReady);\n }\n };\n\n // Try to run, maybe it's ready.\n runOnInit();\n\n /*\n * Try again when the page has been completely loaded.\n * Some of wallets, take some time to be fully injected and loaded.\n */\n document.addEventListener('readystatechange', initWhenPageIsReady);\n });\n }, []);\n\n // Setting supported blockchains on instances\n useEffect(() => {\n const allBlockChains = props.allBlockChains;\n if (allBlockChains) {\n wallets.forEach((wallet) => {\n const walletInstance = getWalletInstance(wallet);\n const walletInfo = walletInstance.getWalletInfo(\n props.allBlockChains || []\n );\n walletInstance.setInfo({\n supportedBlockchains: walletInfo.supportedChains,\n isContractWallet: !!walletInfo.isContractWallet,\n });\n });\n }\n }, [props.allBlockChains]);\n\n // Setting event handler on instances\n useEffect(() => {\n wallets.forEach((wallet) => {\n const walletInstance = getWalletInstance(wallet);\n walletInstance.setHandler(\n makeEventHandler(dispatch, props.onUpdateState)\n );\n });\n }, [props.onUpdateState]);\n\n return api;\n}\n", "import type { ProviderContext, WalletActions, WalletConfig } from './types.js';\nimport type { LegacyEventHandler as WalletEventHandler } from '@rango-dev/wallets-core/legacy';\n\nimport { LegacyWallet as Wallet } from '@rango-dev/wallets-core/legacy';\nimport { useContext, useRef } from 'react';\n\nimport { WalletContext } from './context.js';\n\nexport type GetWalletInstance = (wallet: {\n actions: WalletActions;\n config: WalletConfig;\n}) => Wallet;\n\nexport function useInitializers(\n onChangeState: WalletEventHandler\n): GetWalletInstance {\n const availableWallets = useRef<{\n [key: string]: Wallet | undefined;\n }>({});\n\n /*\n * If `wallet` hasn't been added to `availableWallets`,\n * Get a instance of `Wallet` and save the refrence in `availableWallets`.\n * Otherwise, return the already created instance.\n */\n function updater(wallet: {\n actions: WalletActions;\n config: WalletConfig;\n }): Wallet {\n const type = wallet.config.type;\n // We only update, if there is no instance available.\n if (typeof availableWallets.current[type] === 'undefined') {\n availableWallets.current[type] = new Wallet(\n {\n config: wallet.config,\n handler: onChangeState,\n },\n wallet.actions\n );\n }\n\n return availableWallets.current[type]!;\n }\n\n return updater;\n}\n\nexport function useWallets(): ProviderContext {\n const context = useContext(WalletContext);\n if (!context) {\n throw Error('useWallet can only be used within the Provider component');\n }\n return context;\n}\n", "import type { GetWalletInstance } from './hooks.js';\nimport type { ProviderProps, WalletProviders } from './types.js';\n\nimport { useEffect, useRef } from 'react';\n\nimport { autoConnect } from './helpers.js';\n\nexport function useAutoConnect(\n props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'> & {\n wallets: WalletProviders;\n getWalletInstanceFromLegacy: GetWalletInstance;\n }\n) {\n const autoConnectInitiated = useRef(false);\n\n // Running auto connect on instances\n useEffect(() => {\n const shouldTryAutoConnect =\n props.allBlockChains &&\n props.allBlockChains.length &&\n props.autoConnect &&\n !autoConnectInitiated.current;\n\n if (shouldTryAutoConnect) {\n autoConnectInitiated.current = true;\n void (async () => {\n await autoConnect(props.wallets, props.getWalletInstanceFromLegacy);\n })();\n }\n }, [props.autoConnect, props.allBlockChains]);\n}\n", "import type {\n LegacyNamespaceData as NamespaceData,\n LegacyNetwork as Network,\n LegacyEventHandler as WalletEventHandler,\n LegacyWalletInfo as WalletInfo,\n LegacyState as WalletState,\n LegacyWalletType as WalletType,\n} from '@rango-dev/wallets-core/legacy';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\nimport type { PropsWithChildren } from 'react';\n\nexport type State = {\n [key: string]: WalletState | undefined;\n};\n\nexport type ConnectResult = {\n accounts: string[] | null;\n network: Network | null;\n provider: any;\n};\n\nexport type Providers = { [type in WalletType]?: any };\n\nexport type ProviderContext = {\n connect(\n type: WalletType,\n network?: Network,\n namespaces?: NamespaceData[]\n ): Promise<ConnectResult>;\n disconnect(type: WalletType): Promise<void>;\n disconnectAll(): Promise<PromiseSettledResult<any>[]>;\n state(type: WalletType): WalletState;\n canSwitchNetworkTo(type: WalletType, network: Network): boolean;\n /**\n * `Provider` in legacy terms means injected instances by wallets into window (e.g. window.ethereum)\n * that can be retrieved by `getInstance`.\n *\n * Note 1: Providers are lazy evaluated, which means you need to call `connect` (or `state`) first, then the value will be shown in object.\n * before doing that, it's a key (wallet name or we call it `type` to be more specific) with null value. (e.g. {metamask: null})\n */\n providers(): Providers;\n getSigners(type: WalletType): SignerFactory;\n getWalletInfo(type: WalletType): WalletInfo;\n suggestAndConnect(type: WalletType, network: Network): Promise<ConnectResult>;\n};\n\nexport type ProviderProps = PropsWithChildren<{\n onUpdateState?: WalletEventHandler;\n allBlockChains?: BlockchainMeta[];\n autoConnect?: boolean;\n providers: ProviderInterface[];\n}>;\n\nexport enum Events {\n CONNECTED = 'connected',\n CONNECTING = 'connecting',\n REACHABLE = 'reachable',\n INSTALLED = 'installed',\n ACCOUNTS = 'accounts',\n NETWORK = 'network',\n}\n\nexport type ProviderConnectResult = {\n accounts: string[];\n chainId: string;\n};\n\nexport type GetInstanceOptions = {\n network?: Network;\n currentProvider: any;\n meta: BlockchainMeta[];\n getState: () => WalletState;\n /**\n * We always get the instance once and reuse it whenever we needs. By using this option\n * We can force the library to get a new instance and replace it with the old one.\n *\n * Originally, we used this option for wallet connect 1 and its switching network challenge.\n */\n force?: boolean;\n updateChainId: (chainId: number | string) => void;\n};\n\nexport type GetInstance =\n | (() => any)\n | ((options: GetInstanceOptions) => Promise<any>);\nexport type TryGetInstance =\n | (() => any)\n | ((options: Pick<GetInstanceOptions, 'force' | 'network'>) => Promise<any>);\nexport type Connect = (options: {\n instance: any;\n network?: Network;\n meta: BlockchainMeta[];\n}) => Promise<ProviderConnectResult | ProviderConnectResult[]>;\n\nexport type Disconnect = (options: {\n instance: any;\n destroyInstance: () => void;\n}) => Promise<void>;\n\ntype CleanupSubscribe = () => void;\n\nexport type Subscribe = (options: {\n instance: any;\n state: WalletState;\n meta: BlockchainMeta[];\n updateChainId: (chainId: string) => void;\n updateAccounts: (accounts: string[], chainId?: string) => void;\n connect: (network?: Network) => void;\n disconnect: () => void;\n}) => CleanupSubscribe | void;\n\nexport type SwitchNetwork = (options: {\n instance: any;\n network: Network;\n meta: BlockchainMeta[];\n newInstance?: TryGetInstance;\n getState?: () => WalletState;\n updateChainId: (chainId: string) => void;\n}) => Promise<void>;\n\nexport type Suggest = (options: {\n instance: any;\n network: Network;\n meta: BlockchainMeta[];\n}) => Promise<void>;\n\nexport type CanSwitchNetwork = (options: {\n network: Network;\n meta: BlockchainMeta[];\n provider: any;\n}) => boolean;\n\nexport type CanEagerConnect = (options: {\n instance: any;\n meta: BlockchainMeta[];\n}) => Promise<boolean>;\n\nexport interface WalletActions {\n connect: Connect;\n getInstance: any;\n disconnect?: Disconnect;\n subscribe?: Subscribe;\n // unsubscribe, // coupled to subscribe.\n\n // Optional, but should be provided at the same time.\n suggest?: Suggest;\n switchNetwork?: SwitchNetwork;\n getSigners: (provider: any) => SignerFactory;\n canSwitchNetworkTo?: CanSwitchNetwork;\n canEagerConnect?: CanEagerConnect;\n getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;\n}\n\nexport interface WalletConfig {\n type: WalletType;\n defaultNetwork?: Network;\n checkInstallation?: boolean;\n isAsyncInstance?: boolean;\n isAsyncSwitchNetwork?: boolean;\n}\n\nexport type WalletProviders = Map<\n WalletType,\n {\n actions: WalletActions;\n config: WalletConfig;\n }\n>;\n\nexport type ProviderInterface = { config: WalletConfig } & WalletActions;\n"],
|
|
5
|
-
"mappings": "+EAcA,OAAS,aAAAA,MAAiB,iCCdnB,IAAMC,EAAyB,yBDkB/B,SAASC,EAAOC,EAAgBC,EAA8B,CACnE,OAAOD,EAAQ,KAAME,GAAWA,EAAO,OAASD,CAAI,GAAK,IAC3D,CAFgBE,EAAAJ,EAAA,UAIT,IAAMK,EAAkC,CAC7C,UAAW,GACX,WAAY,GACZ,UAAW,GACX,UAAW,GACX,SAAU,KACV,QAAS,IACX,EAEO,SAASC,EAAaC,EAAcC,EAAa,CACtD,GAAIA,EAAO,OAAS,YAAa,CAI/B,IAAMC,EAAgBF,EAAMC,EAAO,MAAM,EACzC,OAAKC,EAUE,CACL,GAAGF,EACH,CAACC,EAAO,MAAM,EAAG,CACf,GAAGC,EACH,CAACD,EAAO,IAAI,EAAGA,EAAO,KACxB,CACF,EAfS,CACL,GAAGD,EACH,CAACC,EAAO,MAAM,EAAG,CACf,GAAGH,EACH,CAACG,EAAO,IAAI,EAAGA,EAAO,KACxB,CACF,CAUJ,CAEA,OAAOD,CACT,CA1BgBH,EAAAE,EAAA,gB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ASP,EAAQ,IAAII,CAAI,EAC/B,GAAIG,EAAQ,CACV,IAAMM,EAAiBjB,EAAkBW,CAAM,EAC/CS,EAAUZ,CAAI,EAAIS,EAAe,QACnC,CACF,CAAC,EAEMG,CACT,EACA,cAAcZ,EAAM,CAClB,IAAMG,EAASP,EAAQ,IAAII,CAAI,EAC/B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,kBAAkBH,CAAI,qBAAqB,EAQ7D,OAAOG,EAAO,QAAQ,cAAchB,EAAM,gBAAkB,CAAC,CAAC,CAChE,EACA,WAAWa,EAAM,
|
|
4
|
+
"sourcesContent": ["import type {\n ProviderInterface,\n State,\n WalletActions,\n WalletProviders,\n} from './types.js';\nimport type {\n LegacyOptions as Options,\n LegacyWallet as Wallet,\n LegacyEventHandler as WalletEventHandler,\n LegacyState as WalletState,\n} from '@rango-dev/wallets-core/legacy';\nimport type { WalletConfig, WalletType } from '@rango-dev/wallets-shared';\n\nimport { Persistor } from '@rango-dev/wallets-core/legacy';\n\nimport { LAST_CONNECTED_WALLETS } from './constants.js';\n\nexport function choose(wallets: any[], type: WalletType): any | null {\n return wallets.find((wallet) => wallet.type === type) || null;\n}\n\nexport const defaultWalletState: WalletState = {\n connected: false,\n connecting: false,\n reachable: false,\n installed: false,\n accounts: null,\n network: null,\n};\n\nexport function stateReducer(state: State, action: any) {\n if (action.type === 'new_state') {\n // TODO fix problem and remove ts-ignore\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const target_wallet = state[action.wallet];\n if (!target_wallet) {\n return {\n ...state,\n [action.wallet]: {\n ...defaultWalletState,\n [action.name]: action.value,\n },\n };\n }\n\n return {\n ...state,\n [action.wallet]: {\n ...target_wallet,\n [action.name]: action.value,\n },\n };\n }\n\n return state;\n}\n\nexport function connectedWallets(providersState: State): WalletType[] {\n return Object.entries(providersState)\n .filter(([, wallet_state]) => {\n return wallet_state?.connected;\n })\n .map(([type]) => {\n return type;\n });\n}\n\nexport function availableWallets(providersState: State): WalletType[] {\n return Object.entries(providersState).map(([type]) => {\n return type;\n });\n}\n\nexport function checkWalletProviders(\n list: ProviderInterface[]\n): WalletProviders {\n const wallets: WalletProviders = new Map();\n\n list.forEach((provider) => {\n const { config, ...actions } = provider;\n wallets.set(config.type, {\n actions,\n config,\n });\n });\n\n return wallets;\n}\n\n/* eslint-disable @typescript-eslint/ban-types */\nexport function isAsync(fn: Function) {\n return fn?.constructor?.name === 'AsyncFunction';\n}\n\nexport function needsCheckInstallation(options: Options) {\n const { checkInstallation = true } = options.config;\n return checkInstallation;\n}\n\nexport async function tryPersistWallet({\n type,\n walletActions,\n getState,\n}: {\n type: WalletType;\n walletActions: WalletActions;\n getState: (walletType: WalletType) => WalletState;\n}) {\n if (walletActions.canEagerConnect) {\n const persistor = new Persistor<string[]>();\n const wallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n\n /*\n *If on the last attempt we are unable to eagerly connect to any wallet and the user connects any wallet manualy,\n *persistance will be outdated and will need to be removed.\n */\n const shouldClearPersistance = wallets?.find(\n (walletType) => !getState(walletType).connected\n );\n\n if (shouldClearPersistance) {\n clearPersistance();\n }\n\n const walletAlreadyPersisted = !!wallets?.find((wallet) => wallet === type);\n if (wallets && !walletAlreadyPersisted) {\n persistor.setItem(LAST_CONNECTED_WALLETS, wallets.concat(type));\n } else {\n persistor.setItem(LAST_CONNECTED_WALLETS, [type]);\n }\n }\n}\n\nexport function tryRemoveWalletFromPersistance({\n type,\n walletActions,\n}: {\n type: WalletType;\n walletActions: WalletActions;\n}) {\n if (walletActions.canEagerConnect) {\n const persistor = new Persistor<string[]>();\n const wallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n if (wallets) {\n persistor.setItem(\n LAST_CONNECTED_WALLETS,\n wallets.filter((wallet) => wallet !== type)\n );\n }\n }\n}\n\nexport function clearPersistance() {\n const persistor = new Persistor<string[]>();\n const wallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n if (wallets) {\n persistor.removeItem(LAST_CONNECTED_WALLETS);\n }\n}\n\n/*\n *If a wallet has multiple providers and one of them can be eagerly connected,\n *then the whole wallet will support it at that point and we try to connect to that wallet as usual in eagerConnect method.\n */\nexport async function autoConnect(\n wallets: WalletProviders,\n getWalletInstance: (wallet: {\n actions: WalletActions;\n config: WalletConfig;\n }) => Wallet<any>\n) {\n const persistor = new Persistor<string[]>();\n const lastConnectedWallets = persistor.getItem(LAST_CONNECTED_WALLETS);\n if (lastConnectedWallets && lastConnectedWallets.length) {\n const connect_promises: {\n walletType: WalletType;\n eagerConnect: () => Promise<any>;\n }[] = [];\n lastConnectedWallets.forEach((walletType) => {\n const wallet = wallets.get(walletType);\n\n if (!!wallet) {\n const walletInstance = getWalletInstance(wallet);\n connect_promises.push({\n walletType,\n eagerConnect: walletInstance.eagerConnect.bind(walletInstance),\n });\n }\n });\n\n const result = await Promise.allSettled(\n connect_promises.map(async ({ eagerConnect }) => eagerConnect())\n );\n\n const canRestoreAnyConnection = !!result.find(\n ({ status }) => status === 'fulfilled'\n );\n\n /*\n *After successfully connecting to at least one wallet,\n *we will removing the other wallets from persistence.\n *If we are unable to connect to any wallet,\n *the persistence will not be removed and the eager connection will be retried with another page load.\n */\n if (canRestoreAnyConnection) {\n const walletsToRemoveFromPersistance: WalletType[] = [];\n result.forEach((settleResult, index) => {\n const { status } = settleResult;\n\n if (status === 'rejected') {\n walletsToRemoveFromPersistance.push(\n connect_promises[index].walletType\n );\n }\n });\n\n if (walletsToRemoveFromPersistance.length) {\n persistor.setItem(\n LAST_CONNECTED_WALLETS,\n lastConnectedWallets.filter(\n (walletType) => !walletsToRemoveFromPersistance.includes(walletType)\n )\n );\n }\n }\n }\n}\n/*\n *Our event handler includes an internal state updater, and a notifier\n *for the outside listener.\n *On creating first wallet refrence, and on chaning `props.onUpdateState`\n *we are using this function.\n */\nexport function makeEventHandler(\n dispatcher: any,\n onUpdateState?: WalletEventHandler\n) {\n const handler: WalletEventHandler = (\n type,\n name,\n value,\n coreState,\n supportedChains\n ) => {\n const action = { type: 'new_state', wallet: type, name, value };\n // Update state\n dispatcher(action);\n\n // Giving the event to the outside listener\n if (onUpdateState) {\n onUpdateState(type, name, value, coreState, supportedChains);\n }\n };\n\n return handler;\n}\n", "export const LAST_CONNECTED_WALLETS = 'last-connected-wallets';\n", "import type { ProviderProps } from './legacy/types.js';\n\nimport React from 'react';\n\nimport { WalletContext } from './legacy/context.js';\nimport { useLegacyProviders } from './legacy/useLegacyProviders.js';\n\nfunction Provider(props: ProviderProps) {\n const legacyApi = useLegacyProviders(props);\n\n return (\n <WalletContext.Provider value={legacyApi}>\n {props.children}\n </WalletContext.Provider>\n );\n}\n\nexport default Provider;\n", "import type { ProviderContext } from './types.js';\n\nimport { createContext } from 'react';\n\nconst defaultErrorMesssage = \"Context hasn't been initialized yet.\";\nconst defaultContext: ProviderContext = {\n async connect() {\n throw new Error(defaultErrorMesssage);\n },\n async disconnect() {\n throw new Error(defaultErrorMesssage);\n },\n async disconnectAll() {\n throw new Error(defaultErrorMesssage);\n },\n async suggestAndConnect() {\n throw new Error(defaultErrorMesssage);\n },\n state() {\n throw new Error(defaultErrorMesssage);\n },\n canSwitchNetworkTo() {\n throw new Error(defaultErrorMesssage);\n },\n providers() {\n throw new Error(defaultErrorMesssage);\n },\n getWalletInfo() {\n throw new Error(defaultErrorMesssage);\n },\n getSigners() {\n throw new Error(defaultErrorMesssage);\n },\n};\n\nexport const WalletContext = createContext<ProviderContext>(defaultContext);\n", "import type { ProviderContext, ProviderProps } from './types.js';\nimport type { WalletType } from '@rango-dev/wallets-shared';\n\nimport { useEffect, useReducer } from 'react';\n\nimport {\n availableWallets,\n checkWalletProviders,\n clearPersistance,\n connectedWallets,\n defaultWalletState,\n makeEventHandler,\n stateReducer,\n tryPersistWallet,\n tryRemoveWalletFromPersistance,\n} from './helpers.js';\nimport { useInitializers } from './hooks.js';\nimport { useAutoConnect } from './useAutoConnect.js';\n\nexport function useLegacyProviders(props: ProviderProps): ProviderContext {\n const [providersState, dispatch] = useReducer(stateReducer, {});\n\n // Get (or add) wallet instance (`provider`s will be wrapped in a `Wallet`)\n const getWalletInstance = useInitializers(\n makeEventHandler(dispatch, props.onUpdateState)\n );\n\n // Getting providers from props and put all of them in a `Map` with an appropriate interface.\n const listOfProviders = props.providers;\n const wallets = checkWalletProviders(listOfProviders);\n\n useAutoConnect({\n wallets,\n allBlockChains: props.allBlockChains,\n autoConnect: props.autoConnect,\n getWalletInstanceFromLegacy: getWalletInstance,\n });\n\n // Final API we put in context and it will be available to use for users.\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n const api: ProviderContext = {\n async connect(type, network, namespaces) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n const walletInstance = getWalletInstance(wallet);\n const result = await walletInstance.connect(network, namespaces);\n if (props.autoConnect) {\n void tryPersistWallet({\n type,\n walletActions: wallet.actions,\n getState: api.state,\n });\n }\n\n return result;\n },\n async disconnect(type) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n const walletInstance = getWalletInstance(wallet);\n await walletInstance.disconnect();\n if (props.autoConnect) {\n tryRemoveWalletFromPersistance({ type, walletActions: wallet.actions });\n }\n },\n async disconnectAll() {\n const disconnect_promises: Promise<any>[] = [];\n\n /*\n * When a wallet is initializing, a record will be added to `providersState`\n * So we use them to know what wallet has been initialized then we need to\n * filter connected wallets only.\n */\n connectedWallets(providersState).forEach((type) => {\n const wallet = wallets.get(type);\n\n if (wallet) {\n const walletInstance = getWalletInstance(wallet);\n disconnect_promises.push(walletInstance.disconnect());\n }\n });\n\n if (props.autoConnect) {\n clearPersistance();\n }\n return await Promise.allSettled(disconnect_promises);\n },\n\n async suggestAndConnect(type, network) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n const walletInstance = getWalletInstance(wallet);\n const result = await walletInstance.suggestAndConnect(network);\n\n return result;\n },\n\n state(type) {\n return providersState[type] || defaultWalletState;\n },\n canSwitchNetworkTo(type, network) {\n const wallet = wallets.get(type);\n if (!wallet) {\n return false;\n }\n\n const walletInstance = getWalletInstance(wallet);\n return walletInstance.canSwitchNetworkTo\n ? walletInstance.canSwitchNetworkTo(network, walletInstance.provider)\n : false;\n },\n providers() {\n const providers: { [type in WalletType]?: any } = {};\n availableWallets(providersState).forEach((type) => {\n const wallet = wallets.get(type);\n if (wallet) {\n const walletInstance = getWalletInstance(wallet);\n providers[type] = walletInstance.provider;\n }\n });\n\n return providers;\n },\n getWalletInfo(type) {\n const wallet = wallets.get(type);\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n\n /*\n * Get wallet info could be used in render methods to show wallets data\n * So, addWalletRef method shouldn't be called in this method\n */\n\n return wallet.actions.getWalletInfo(props.allBlockChains || []);\n },\n async getSigners(type) {\n const wallet = wallets.get(type);\n\n if (!wallet) {\n throw new Error(`You should add ${type} to provider first.`);\n }\n const walletInstance = getWalletInstance(wallet);\n const provider = walletInstance.provider;\n const result = walletInstance.getSigners(provider);\n\n return result;\n },\n };\n\n // Initialize instances\n useEffect(() => {\n wallets.forEach((wallet) => {\n const walletInstance = getWalletInstance(wallet);\n const runOnInit = () => {\n if (walletInstance.onInit) {\n walletInstance.onInit();\n }\n };\n\n const initWhenPageIsReady = (event: Event) => {\n if (\n event.target &&\n (event.target as Document).readyState === 'complete'\n ) {\n runOnInit();\n\n document.removeEventListener('readystatechange', initWhenPageIsReady);\n }\n };\n\n // Try to run, maybe it's ready.\n runOnInit();\n\n /*\n * Try again when the page has been completely loaded.\n * Some of wallets, take some time to be fully injected and loaded.\n */\n document.addEventListener('readystatechange', initWhenPageIsReady);\n });\n }, []);\n\n // Setting supported blockchains on instances\n useEffect(() => {\n const allBlockChains = props.allBlockChains;\n if (allBlockChains) {\n wallets.forEach((wallet) => {\n const walletInstance = getWalletInstance(wallet);\n const walletInfo = walletInstance.getWalletInfo(\n props.allBlockChains || []\n );\n walletInstance.setInfo({\n supportedBlockchains: walletInfo.supportedChains,\n isContractWallet: !!walletInfo.isContractWallet,\n });\n });\n }\n }, [props.allBlockChains]);\n\n // Setting event handler on instances\n useEffect(() => {\n wallets.forEach((wallet) => {\n const walletInstance = getWalletInstance(wallet);\n walletInstance.setHandler(\n makeEventHandler(dispatch, props.onUpdateState)\n );\n });\n }, [props.onUpdateState]);\n\n return api;\n}\n", "import type { ProviderContext, WalletActions, WalletConfig } from './types.js';\nimport type { LegacyEventHandler as WalletEventHandler } from '@rango-dev/wallets-core/legacy';\n\nimport { LegacyWallet as Wallet } from '@rango-dev/wallets-core/legacy';\nimport { useContext, useRef } from 'react';\n\nimport { WalletContext } from './context.js';\n\nexport type GetWalletInstance = (wallet: {\n actions: WalletActions;\n config: WalletConfig;\n}) => Wallet;\n\nexport function useInitializers(\n onChangeState: WalletEventHandler\n): GetWalletInstance {\n const availableWallets = useRef<{\n [key: string]: Wallet | undefined;\n }>({});\n\n /*\n * If `wallet` hasn't been added to `availableWallets`,\n * Get a instance of `Wallet` and save the refrence in `availableWallets`.\n * Otherwise, return the already created instance.\n */\n function updater(wallet: {\n actions: WalletActions;\n config: WalletConfig;\n }): Wallet {\n const type = wallet.config.type;\n // We only update, if there is no instance available.\n if (typeof availableWallets.current[type] === 'undefined') {\n availableWallets.current[type] = new Wallet(\n {\n config: wallet.config,\n handler: onChangeState,\n },\n wallet.actions\n );\n }\n\n return availableWallets.current[type]!;\n }\n\n return updater;\n}\n\nexport function useWallets(): ProviderContext {\n const context = useContext(WalletContext);\n if (!context) {\n throw Error('useWallet can only be used within the Provider component');\n }\n return context;\n}\n", "import type { GetWalletInstance } from './hooks.js';\nimport type { ProviderProps, WalletProviders } from './types.js';\n\nimport { useEffect, useRef } from 'react';\n\nimport { autoConnect } from './helpers.js';\n\nexport function useAutoConnect(\n props: Pick<ProviderProps, 'allBlockChains' | 'autoConnect'> & {\n wallets: WalletProviders;\n getWalletInstanceFromLegacy: GetWalletInstance;\n }\n) {\n const autoConnectInitiated = useRef(false);\n\n // Running auto connect on instances\n useEffect(() => {\n const shouldTryAutoConnect =\n props.allBlockChains &&\n props.allBlockChains.length &&\n props.autoConnect &&\n !autoConnectInitiated.current;\n\n if (shouldTryAutoConnect) {\n autoConnectInitiated.current = true;\n void (async () => {\n await autoConnect(props.wallets, props.getWalletInstanceFromLegacy);\n })();\n }\n }, [props.autoConnect, props.allBlockChains]);\n}\n", "import type {\n LegacyNamespaceData as NamespaceData,\n LegacyNetwork as Network,\n LegacyEventHandler as WalletEventHandler,\n LegacyWalletInfo as WalletInfo,\n LegacyState as WalletState,\n LegacyWalletType as WalletType,\n} from '@rango-dev/wallets-core/legacy';\nimport type { BlockchainMeta, SignerFactory } from 'rango-types';\nimport type { PropsWithChildren } from 'react';\n\nexport type State = {\n [key: string]: WalletState | undefined;\n};\n\nexport type ConnectResult = {\n accounts: string[] | null;\n network: Network | null;\n provider: any;\n};\n\nexport type Providers = { [type in WalletType]?: any };\n\nexport type ProviderContext = {\n connect(\n type: WalletType,\n network?: Network,\n namespaces?: NamespaceData[]\n ): Promise<ConnectResult>;\n disconnect(type: WalletType): Promise<void>;\n disconnectAll(): Promise<PromiseSettledResult<any>[]>;\n state(type: WalletType): WalletState;\n canSwitchNetworkTo(type: WalletType, network: Network): boolean;\n /**\n * `Provider` in legacy terms means injected instances by wallets into window (e.g. window.ethereum)\n * that can be retrieved by `getInstance`.\n *\n * Note 1: Providers are lazy evaluated, which means you need to call `connect` (or `state`) first, then the value will be shown in object.\n * before doing that, it's a key (wallet name or we call it `type` to be more specific) with null value. (e.g. {metamask: null})\n */\n providers(): Providers;\n getSigners(type: WalletType): Promise<SignerFactory>;\n getWalletInfo(type: WalletType): WalletInfo;\n suggestAndConnect(type: WalletType, network: Network): Promise<ConnectResult>;\n};\n\nexport type ProviderProps = PropsWithChildren<{\n onUpdateState?: WalletEventHandler;\n allBlockChains?: BlockchainMeta[];\n autoConnect?: boolean;\n providers: ProviderInterface[];\n}>;\n\nexport enum Events {\n CONNECTED = 'connected',\n CONNECTING = 'connecting',\n REACHABLE = 'reachable',\n INSTALLED = 'installed',\n ACCOUNTS = 'accounts',\n NETWORK = 'network',\n}\n\nexport type ProviderConnectResult = {\n accounts: string[];\n chainId: string;\n};\n\nexport type GetInstanceOptions = {\n network?: Network;\n currentProvider: any;\n meta: BlockchainMeta[];\n getState: () => WalletState;\n /**\n * We always get the instance once and reuse it whenever we needs. By using this option\n * We can force the library to get a new instance and replace it with the old one.\n *\n * Originally, we used this option for wallet connect 1 and its switching network challenge.\n */\n force?: boolean;\n updateChainId: (chainId: number | string) => void;\n};\n\nexport type GetInstance =\n | (() => any)\n | ((options: GetInstanceOptions) => Promise<any>);\nexport type TryGetInstance =\n | (() => any)\n | ((options: Pick<GetInstanceOptions, 'force' | 'network'>) => Promise<any>);\nexport type Connect = (options: {\n instance: any;\n network?: Network;\n meta: BlockchainMeta[];\n}) => Promise<ProviderConnectResult | ProviderConnectResult[]>;\n\nexport type Disconnect = (options: {\n instance: any;\n destroyInstance: () => void;\n}) => Promise<void>;\n\ntype CleanupSubscribe = () => void;\n\nexport type Subscribe = (options: {\n instance: any;\n state: WalletState;\n meta: BlockchainMeta[];\n updateChainId: (chainId: string) => void;\n updateAccounts: (accounts: string[], chainId?: string) => void;\n connect: (network?: Network) => void;\n disconnect: () => void;\n}) => CleanupSubscribe | void;\n\nexport type SwitchNetwork = (options: {\n instance: any;\n network: Network;\n meta: BlockchainMeta[];\n newInstance?: TryGetInstance;\n getState?: () => WalletState;\n updateChainId: (chainId: string) => void;\n}) => Promise<void>;\n\nexport type Suggest = (options: {\n instance: any;\n network: Network;\n meta: BlockchainMeta[];\n}) => Promise<void>;\n\nexport type CanSwitchNetwork = (options: {\n network: Network;\n meta: BlockchainMeta[];\n provider: any;\n}) => boolean;\n\nexport type CanEagerConnect = (options: {\n instance: any;\n meta: BlockchainMeta[];\n}) => Promise<boolean>;\n\nexport interface WalletActions {\n connect: Connect;\n getInstance: any;\n disconnect?: Disconnect;\n subscribe?: Subscribe;\n // unsubscribe, // coupled to subscribe.\n\n // Optional, but should be provided at the same time.\n suggest?: Suggest;\n switchNetwork?: SwitchNetwork;\n getSigners: (provider: any) => Promise<SignerFactory>;\n canSwitchNetworkTo?: CanSwitchNetwork;\n canEagerConnect?: CanEagerConnect;\n getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;\n}\n\nexport interface WalletConfig {\n type: WalletType;\n defaultNetwork?: Network;\n checkInstallation?: boolean;\n isAsyncInstance?: boolean;\n isAsyncSwitchNetwork?: boolean;\n}\n\nexport type WalletProviders = Map<\n WalletType,\n {\n actions: WalletActions;\n config: WalletConfig;\n }\n>;\n\nexport type ProviderInterface = { config: WalletConfig } & WalletActions;\n"],
|
|
5
|
+
"mappings": "+EAcA,OAAS,aAAAA,MAAiB,iCCdnB,IAAMC,EAAyB,yBDkB/B,SAASC,EAAOC,EAAgBC,EAA8B,CACnE,OAAOD,EAAQ,KAAME,GAAWA,EAAO,OAASD,CAAI,GAAK,IAC3D,CAFgBE,EAAAJ,EAAA,UAIT,IAAMK,EAAkC,CAC7C,UAAW,GACX,WAAY,GACZ,UAAW,GACX,UAAW,GACX,SAAU,KACV,QAAS,IACX,EAEO,SAASC,EAAaC,EAAcC,EAAa,CACtD,GAAIA,EAAO,OAAS,YAAa,CAI/B,IAAMC,EAAgBF,EAAMC,EAAO,MAAM,EACzC,OAAKC,EAUE,CACL,GAAGF,EACH,CAACC,EAAO,MAAM,EAAG,CACf,GAAGC,EACH,CAACD,EAAO,IAAI,EAAGA,EAAO,KACxB,CACF,EAfS,CACL,GAAGD,EACH,CAACC,EAAO,MAAM,EAAG,CACf,GAAGH,EACH,CAACG,EAAO,IAAI,EAAGA,EAAO,KACxB,CACF,CAUJ,CAEA,OAAOD,CACT,CA1BgBH,EAAAE,EAAA,gBA4BT,SAASI,EAAiBC,EAAqC,CACpE,OAAO,OAAO,QAAQA,CAAc,EACjC,OAAO,CAAC,CAAC,CAAEC,CAAY,IACfA,GAAc,S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EAAUF,EAAM,aAAa,CAChD,CACF,CAAC,CACH,EAAG,CAACA,EAAM,aAAa,CAAC,EAEjBY,CACT,CAtMgBkB,EAAA/B,EAAA,sBFZhB,SAASmC,EAASC,EAAsB,CACtC,IAAMC,EAAYC,EAAmBF,CAAK,EAE1C,OACEG,EAAA,cAACC,EAAc,SAAd,CAAuB,MAAOH,GAC5BD,EAAM,QACT,CAEJ,CARSK,EAAAN,EAAA,YAUT,IAAOO,EAAQP,EKoCR,IAAKQ,OACVA,EAAA,UAAY,YACZA,EAAA,WAAa,aACbA,EAAA,UAAY,YACZA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,QAAU,UANAA,OAAA",
|
|
6
6
|
"names": ["Persistor", "LAST_CONNECTED_WALLETS", "choose", "wallets", "type", "wallet", "__name", "defaultWalletState", "stateReducer", "state", "action", "target_wallet", "connectedWallets", "providersState", "wallet_state", "availableWallets", "checkWalletProviders", "list", "provider", "config", "actions", "isAsync", "fn", "needsCheckInstallation", "options", "checkInstallation", "tryPersistWallet", "walletActions", "getState", "persistor", "Persistor", "LAST_CONNECTED_WALLETS", "walletType", "clearPersistance", "walletAlreadyPersisted", "tryRemoveWalletFromPersistance", "autoConnect", "getWalletInstance", "lastConnectedWallets", "connect_promises", "walletInstance", "result", "eagerConnect", "status", "walletsToRemoveFromPersistance", "settleResult", "index", "makeEventHandler", "dispatcher", "onUpdateState", "name", "value", "coreState", "supportedChains", "React", "createContext", "defaultErrorMesssage", "defaultContext", "WalletContext", "useEffect", "useReducer", "Wallet", "useContext", "useRef", "useInitializers", "onChangeState", "availableWallets", "useRef", "updater", "wallet", "type", "Wallet", "__name", "useWallets", "context", "useContext", "WalletContext", "useEffect", "useRef", "useAutoConnect", "props", "autoConnectInitiated", "useRef", "useEffect", "autoConnect", "__name", "useLegacyProviders", "props", "providersState", "dispatch", "useReducer", "stateReducer", "getWalletInstance", "useInitializers", "makeEventHandler", "listOfProviders", "wallets", "checkWalletProviders", "useAutoConnect", "api", "type", "network", "namespaces", "wallet", "result", "tryPersistWallet", "tryRemoveWalletFromPersistance", "disconnect_promises", "connectedWallets", "walletInstance", "clearPersistance", "defaultWalletState", "providers", "availableWallets", "provider", "useEffect", "runOnInit", "__name", "initWhenPageIsReady", "event", "walletInfo", "Provider", "props", "legacyApi", "useLegacyProviders", "React", "WalletContext", "__name", "provider_default", "Events"]
|
|
7
7
|
}
|
package/dist/legacy/types.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type ProviderContext = {
|
|
|
26
26
|
* before doing that, it's a key (wallet name or we call it `type` to be more specific) with null value. (e.g. {metamask: null})
|
|
27
27
|
*/
|
|
28
28
|
providers(): Providers;
|
|
29
|
-
getSigners(type: WalletType): SignerFactory
|
|
29
|
+
getSigners(type: WalletType): Promise<SignerFactory>;
|
|
30
30
|
getWalletInfo(type: WalletType): WalletInfo;
|
|
31
31
|
suggestAndConnect(type: WalletType, network: Network): Promise<ConnectResult>;
|
|
32
32
|
};
|
|
@@ -112,7 +112,7 @@ export interface WalletActions {
|
|
|
112
112
|
subscribe?: Subscribe;
|
|
113
113
|
suggest?: Suggest;
|
|
114
114
|
switchNetwork?: SwitchNetwork;
|
|
115
|
-
getSigners: (provider: any) => SignerFactory
|
|
115
|
+
getSigners: (provider: any) => Promise<SignerFactory>;
|
|
116
116
|
canSwitchNetworkTo?: CanSwitchNetwork;
|
|
117
117
|
canEagerConnect?: CanEagerConnect;
|
|
118
118
|
getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/legacy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,IAAI,aAAa,EACpC,aAAa,IAAI,OAAO,EACxB,kBAAkB,IAAI,kBAAkB,EACxC,gBAAgB,IAAI,UAAU,EAC9B,WAAW,IAAI,WAAW,EAC1B,gBAAgB,IAAI,UAAU,EAC/B,MAAM,gCAAgC,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AAM,iBAAiB,GAAG;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/legacy/constants.ts":{"bytes":64,"imports":[],"format":"esm"},"src/legacy/helpers.ts":{"bytes":6923,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/legacy/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/context.ts":{"bytes":905,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/hooks.ts":{"bytes":1545,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useAutoConnect.ts":{"bytes":916,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useLegacyProviders.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/legacy/constants.ts":{"bytes":64,"imports":[],"format":"esm"},"src/legacy/helpers.ts":{"bytes":6923,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"src/legacy/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/context.ts":{"bytes":905,"imports":[{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/hooks.ts":{"bytes":1545,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./context.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useAutoConnect.ts":{"bytes":916,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/useLegacyProviders.ts":{"bytes":6608,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./helpers.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./hooks.js"},{"path":"src/legacy/useAutoConnect.ts","kind":"import-statement","original":"./useAutoConnect.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/provider.tsx":{"bytes":442,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"src/legacy/context.ts","kind":"import-statement","original":"./legacy/context.js"},{"path":"src/legacy/useLegacyProviders.ts","kind":"import-statement","original":"./legacy/useLegacyProviders.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/legacy/types.ts":{"bytes":4851,"imports":[],"format":"esm"},"src/index.ts":{"bytes":173,"imports":[{"path":"src/legacy/helpers.ts","kind":"import-statement","original":"./legacy/helpers.js"},{"path":"src/provider.tsx","kind":"import-statement","original":"./provider.js"},{"path":"src/legacy/hooks.ts","kind":"import-statement","original":"./legacy/hooks.js"},{"path":"src/legacy/types.ts","kind":"import-statement","original":"./legacy/types.js"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":32801},"dist/index.js":{"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"exports":["Events","Provider","autoConnect","availableWallets","checkWalletProviders","choose","clearPersistance","connectedWallets","defaultWalletState","isAsync","makeEventHandler","needsCheckInstallation","stateReducer","tryPersistWallet","tryRemoveWalletFromPersistance","useWallets"],"entryPoint":"src/index.ts","inputs":{"src/legacy/helpers.ts":{"bytesInOutput":1940},"src/legacy/constants.ts":{"bytesInOutput":31},"src/index.ts":{"bytesInOutput":0},"src/provider.tsx":{"bytesInOutput":126},"src/legacy/context.ts":{"bytesInOutput":427},"src/legacy/useLegacyProviders.ts":{"bytesInOutput":2071},"src/legacy/hooks.ts":{"bytesInOutput":450},"src/legacy/useAutoConnect.ts":{"bytesInOutput":283},"src/legacy/types.ts":{"bytesInOutput":162}},"bytes":5938}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/wallets-react",
|
|
3
|
-
"version": "0.23.1-next.
|
|
3
|
+
"version": "0.23.1-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@rango-dev/wallets-core": "^0.38.1-next.
|
|
30
|
-
"@rango-dev/wallets-shared": "^0.37.1-next.
|
|
29
|
+
"@rango-dev/wallets-core": "^0.38.1-next.1",
|
|
30
|
+
"@rango-dev/wallets-shared": "^0.37.1-next.1",
|
|
31
31
|
"rango-types": "^0.1.69"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
package/src/legacy/types.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type ProviderContext = {
|
|
|
39
39
|
* before doing that, it's a key (wallet name or we call it `type` to be more specific) with null value. (e.g. {metamask: null})
|
|
40
40
|
*/
|
|
41
41
|
providers(): Providers;
|
|
42
|
-
getSigners(type: WalletType): SignerFactory
|
|
42
|
+
getSigners(type: WalletType): Promise<SignerFactory>;
|
|
43
43
|
getWalletInfo(type: WalletType): WalletInfo;
|
|
44
44
|
suggestAndConnect(type: WalletType, network: Network): Promise<ConnectResult>;
|
|
45
45
|
};
|
|
@@ -145,7 +145,7 @@ export interface WalletActions {
|
|
|
145
145
|
// Optional, but should be provided at the same time.
|
|
146
146
|
suggest?: Suggest;
|
|
147
147
|
switchNetwork?: SwitchNetwork;
|
|
148
|
-
getSigners: (provider: any) => SignerFactory
|
|
148
|
+
getSigners: (provider: any) => Promise<SignerFactory>;
|
|
149
149
|
canSwitchNetworkTo?: CanSwitchNetwork;
|
|
150
150
|
canEagerConnect?: CanEagerConnect;
|
|
151
151
|
getWalletInfo(allBlockChains: BlockchainMeta[]): WalletInfo;
|
|
@@ -141,7 +141,7 @@ export function useLegacyProviders(props: ProviderProps): ProviderContext {
|
|
|
141
141
|
|
|
142
142
|
return wallet.actions.getWalletInfo(props.allBlockChains || []);
|
|
143
143
|
},
|
|
144
|
-
getSigners(type) {
|
|
144
|
+
async getSigners(type) {
|
|
145
145
|
const wallet = wallets.get(type);
|
|
146
146
|
|
|
147
147
|
if (!wallet) {
|