-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from suiet/feat/stashed-wallet
Feat/stashed wallet
- Loading branch information
Showing
27 changed files
with
8,543 additions
and
10,141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@suiet/wallet-kit", | ||
"version": "0.2.25", | ||
"version": "0.3.0", | ||
"type": "module", | ||
"files": [ | ||
"dist" | ||
|
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,9 @@ | ||
import { createContext } from "react"; | ||
import { UnknownChain } from "@suiet/wallet-sdk"; | ||
import { SuiClient } from "@mysten/sui/client"; | ||
|
||
export const SuiClientContext = createContext<SuiClient>( | ||
new SuiClient({ | ||
url: UnknownChain.rpcUrl, | ||
}) | ||
); |
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,5 +1,6 @@ | ||
export * from './useWallet'; | ||
export * from './useAccountBalance'; | ||
export * from './useCoinBalance'; | ||
export * from './useChain'; | ||
export * from './useSuiProvider'; | ||
export * from "./useWallet"; | ||
export * from "./useAccountBalance"; | ||
export * from "./useCoinBalance"; | ||
export * from "./useChain"; | ||
export * from "./useSuiProvider"; | ||
export * from "./useSuiClient"; |
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,28 @@ | ||
import { useLayoutEffect } from "react"; | ||
import { IDefaultWallet, WalletType } from "@suiet/wallet-sdk"; | ||
import { isNonEmptyArray } from "../utils"; | ||
|
||
export function useInstallWebWalletAdapters(defaultWallets: IDefaultWallet[]) { | ||
useLayoutEffect(() => { | ||
const unregisterFunctions: (() => void)[] = []; | ||
|
||
if (isNonEmptyArray(defaultWallets)) { | ||
defaultWallets.forEach((item) => { | ||
if ( | ||
item.type === WalletType.WEB && | ||
item.downloadUrl?.registerWebWallet | ||
) { | ||
const unregister = item.downloadUrl.registerWebWallet(); | ||
unregisterFunctions.push(unregister); | ||
} | ||
}); | ||
} | ||
|
||
return () => { | ||
if (!isNonEmptyArray(unregisterFunctions)) return; | ||
unregisterFunctions.forEach((unregister) => { | ||
unregister(); | ||
}); | ||
}; | ||
}, [defaultWallets]); | ||
} |
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,9 @@ | ||
import { useContext } from "react"; | ||
import { SuiClientContext } from "../contexts/SuiClientContext"; | ||
|
||
/** | ||
* Return a SuiClient instance with the current chain's rpcUrl | ||
*/ | ||
export const useSuiClient = () => { | ||
return useContext(SuiClientContext); | ||
}; |
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.