-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Remove getActiveAccount usage (#183)
Similar to PR gnoverse/dsocial#130, we update gnoboard to use the new Gno Native Kit API which removes `selectAccount` and requires passing the account address to `setPassword`, etc. This PR has five commits: 1. The app needs to keep track of the active account, so add `GnoboardProvider`. 2. Instead of calling Gno Native Kit `selectAccount`, call `GnoboardProvider` `setAccount` to remember the active account. 3. `setPassword` needs the account address, so in `ReenterPassword` add param `accountAddress`. 4. In wallet/home: Pass in the account instead of calling `getActiveAccount`. Use the account address to call `queryAccount`. 5. As in a [similar dsocial PR](gnoverse/dsocial#134), fix the Makefile to call ts_check after node_modules. With this PR, all known apps have been updated to remove `selectAcount` and to pass the account address to the methods of Gno Native Kit, which can be updated to remove deprecated functions and to make the address not optional. --------- Signed-off-by: Jeff Thompson <jeff@thefirst.org>
- Loading branch information
Showing
9 changed files
with
78 additions
and
24 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
35 changes: 35 additions & 0 deletions
35
examples/js/expo/gnoboard/src/provider/gnoboard-provider.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,35 @@ | ||
import { createContext, useContext, useState, useCallback } from 'react'; | ||
|
||
import { KeyInfo } from '@gnolang/gnonative'; | ||
|
||
interface GnoboardProviderProps { | ||
children: React.ReactNode; | ||
} | ||
interface GnoboardContextType { | ||
account: KeyInfo | undefined; | ||
setAccount: (keyInfo : KeyInfo | undefined) => void; | ||
} | ||
|
||
const GnoboardContext = createContext<GnoboardContextType | null>(null); | ||
|
||
const GnoboardProvider: React.FC<GnoboardProviderProps> = ({ children }) => { | ||
const [account, setAccount] = useState<KeyInfo | undefined>(undefined) | ||
|
||
const value = { | ||
account, | ||
setAccount | ||
}; | ||
|
||
return <GnoboardContext.Provider value={value}>{children}</GnoboardContext.Provider>; | ||
}; | ||
|
||
function useGnoboardContext() { | ||
const context = useContext(GnoboardContext) as GnoboardContextType; | ||
|
||
if (context === undefined) { | ||
throw new Error('useGnoboardContext must be used within a GnoboardProvider'); | ||
} | ||
return context; | ||
} | ||
|
||
export { GnoboardProvider, useGnoboardContext }; |
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