-
-
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
11 changed files
with
84 additions
and
7 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 |
---|---|---|
|
@@ -49,5 +49,6 @@ enum WalletType { | |
STATION = "station", | ||
XDEFI = "xdefi", | ||
CAPSULE = "capsule", | ||
COSMIFRAME = "cosmiframe", | ||
} | ||
``` |
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,38 @@ | ||
import { Cosmiframe } from "@dao-dao/cosmiframe"; | ||
|
||
import { useGrazInternalStore } from "../../store"; | ||
import type { Wallet } from "../../types/wallet"; | ||
|
||
/** | ||
* Function to return {@link Wallet} object and throws and error if not in an iframe. | ||
* | ||
* @example | ||
* ```ts | ||
* try { | ||
* const cosmiframe = getCosmiframe(); | ||
* } catch (error: Error) { | ||
* console.error(error.message); | ||
* } | ||
* ``` | ||
* | ||
* | ||
*/ | ||
export const getCosmiframe = (): Wallet => { | ||
if (window.parent === window.self) { | ||
useGrazInternalStore.getState()._notFoundFn(); | ||
throw new Error("not in iframe"); | ||
} | ||
|
||
const keplr = new Cosmiframe().getKeplrClient(); | ||
|
||
return { | ||
enable: keplr.enable.bind(keplr), | ||
getKey: keplr.getKey.bind(keplr), | ||
getOfflineSigner: keplr.getOfflineSigner.bind(keplr), | ||
getOfflineSignerAuto: keplr.getOfflineSignerAuto.bind(keplr), | ||
getOfflineSignerOnlyAmino: keplr.getOfflineSignerOnlyAmino.bind(keplr), | ||
experimentalSuggestChain: keplr.experimentalSuggestChain.bind(keplr), | ||
signDirect: keplr.signDirect.bind(keplr), | ||
signAmino: keplr.signAmino.bind(keplr), | ||
}; | ||
}; |
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.