-
Notifications
You must be signed in to change notification settings - Fork 93
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
32 changed files
with
491 additions
and
284 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useSessionStore } from './useSessionsStore.js' | ||
|
||
/** | ||
* Retrieves the all session account | ||
*/ | ||
export function useSession(scope: string) { | ||
return useSessionStore((state) => | ||
state.sessions.find((item) => | ||
scope.includes('::') | ||
? item.getScopes().find((_scope) => _scope === scope) | ||
: item.getScopes().find((_scope) => _scope.startsWith(scope)) !== undefined, | ||
), | ||
) | ||
} |
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
8 changes: 8 additions & 0 deletions
8
sdk/typescript/rooch-sdk-kit/src/hooks/wallet/useConnectionStatus.ts
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,8 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useWalletStore } from './useWalletStore' | ||
|
||
export function useConnectionStatus() { | ||
return useWalletStore((state) => state.connectionStatus) | ||
} |
2 changes: 1 addition & 1 deletion
2
...kit/src/hooks/wallet/useCurrentAccount.ts → ...kit/src/hooks/wallet/useCurrentAddress.ts
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
50 changes: 50 additions & 0 deletions
50
sdk/typescript/rooch-sdk-kit/src/provider/errorProvider.tsx
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,50 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { createContext, ReactNode, useContext, useMemo, useState } from 'react' | ||
|
||
export type ErrorType = { | ||
code: number | ||
msg: string | ||
} | ||
|
||
export interface ErrorProviderContext { | ||
error: ErrorType | null | ||
setError: (error: ErrorType) => void | ||
resolve: () => void | ||
} | ||
|
||
const ErrorContext = createContext<ErrorProviderContext | null>(null) | ||
|
||
export const useError = () => { | ||
const ctx = useContext(ErrorContext)! | ||
return { | ||
error: ctx.error, | ||
resolve: ctx.resolve, | ||
} | ||
} | ||
|
||
export const useSetError = () => { | ||
const ctx = useContext(ErrorContext)! | ||
return ctx.setError | ||
} | ||
|
||
export type ErrorProviderProps = { | ||
children: ReactNode | ||
} | ||
|
||
export const ErrorProvider = (props: ErrorProviderProps) => { | ||
const { children } = props | ||
const [error, setError] = useState<ErrorType | null>(null) | ||
|
||
const ctx = useMemo((): ErrorProviderContext => { | ||
return { | ||
error: error, | ||
setError: setError, | ||
resolve: () => { | ||
setError(null) | ||
}, | ||
} | ||
}, [error]) | ||
return <ErrorContext.Provider value={ctx}>{children}</ErrorContext.Provider> | ||
} |
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.