-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add an adapter for Hub for wallets-react and enabling Hub by de…
…fault.
- Loading branch information
1 parent
1ce3367
commit 9355468
Showing
81 changed files
with
2,910 additions
and
918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { | ||
NamespaceInputForConnect, | ||
NamespaceInputWithDiscoverMode, | ||
} from './types.js'; | ||
|
||
import { Namespace } from './types.js'; | ||
|
||
export async function eagerConnectHandler<R = unknown>(params: { | ||
canEagerConnect: () => Promise<boolean>; | ||
connectHandler: () => Promise<R>; | ||
providerName: string; | ||
}) { | ||
// Check if we can eagerly connect to the wallet | ||
if (await params.canEagerConnect()) { | ||
// Connect to wallet as usual | ||
return await params.connectHandler(); | ||
} | ||
throw new Error(`can't restore connection for ${params.providerName}.`); | ||
} | ||
|
||
export function isNamespaceDiscoverMode( | ||
namespace: NamespaceInputForConnect | ||
): namespace is NamespaceInputWithDiscoverMode { | ||
return namespace.namespace === 'DISCOVER_MODE'; | ||
} | ||
|
||
export function isEvmNamespace( | ||
namespace: NamespaceInputForConnect | ||
): namespace is NamespaceInputForConnect<Namespace.Evm> { | ||
return namespace.namespace === Namespace.Evm; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.