-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
82 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,5 +51,6 @@ enum WalletType { | |
XDEFI = "xdefi", | ||
CAPSULE = "capsule", | ||
COSMIFRAME = "cosmiframe", | ||
COMPASS = "compass", | ||
} | ||
``` |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "graz", | ||
"description": "React hooks for Cosmos", | ||
"version": "0.1.18", | ||
"version": "0.1.19", | ||
"author": "Griko Nibras <[email protected]>", | ||
"repository": "https://github.com/graz-sh/graz.git", | ||
"homepage": "https://github.com/graz-sh/graz", | ||
|
@@ -48,7 +48,7 @@ | |
"@cosmjs/proto-signing": "*", | ||
"@cosmjs/stargate": "*", | ||
"@cosmjs/tendermint-rpc": "*", | ||
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.37", | ||
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.39", | ||
"react": ">=17" | ||
}, | ||
"dependencies": { | ||
|
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,46 @@ | ||
import type { KeplrIntereactionOptions } from "@keplr-wallet/types"; | ||
|
||
import { useGrazInternalStore } from "../../store"; | ||
import type { Wallet } from "../../types/wallet"; | ||
import { clearSession } from "."; | ||
|
||
/** | ||
* Function to return Compass object (which is {@link Wallet}) and throws and error if it does not exist on `window`. | ||
* | ||
* @example | ||
* ```ts | ||
* try { | ||
* const compass = getCompass(); | ||
* } catch (error: Error) { | ||
* console.error(error.message); | ||
* } | ||
* ``` | ||
* | ||
* @see https://docs.leapwallet.io/cosmos/for-dapps-connect-to-leap/add-leap-to-existing-keplr-integration | ||
*/ | ||
export const getCompass = (): Wallet => { | ||
if (typeof window.compass !== "undefined") { | ||
const compass = window.compass; | ||
const subscription: (reconnect: () => void) => () => void = (reconnect) => { | ||
const listener = () => { | ||
clearSession(); | ||
reconnect(); | ||
}; | ||
window.addEventListener("leap_keystorechange", listener); | ||
return () => { | ||
window.removeEventListener("leap_keystorechange", listener); | ||
}; | ||
}; | ||
const setDefaultOptions = (options: KeplrIntereactionOptions) => { | ||
compass.defaultOptions = options; | ||
}; | ||
const res = Object.assign(compass, { | ||
subscription, | ||
setDefaultOptions, | ||
}); | ||
return res; | ||
} | ||
|
||
useGrazInternalStore.getState()._notFoundFn(); | ||
throw new Error("window.leap is not defined"); | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.