This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* scaffold-eth/eth-ui#125 updates to types * scaffold-eth/eth-ui#125 updates to types * scaffold-eth/eth-ui#125 updates to type simplicity * update packages * #125 update eth-sdk scaffold-eth/eth-ui#125
- Loading branch information
1 parent
e571cba
commit 48075a1
Showing
9 changed files
with
157 additions
and
226 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
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
44 changes: 0 additions & 44 deletions
44
packages/vite-app-ts/src/components/common/hooks/contractContext.ts
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,44 +1,25 @@ | ||
import { contractConnectorConfig, TAppConnectorList } from '~~/config/contractConnectorConfig'; | ||
import { TTypedContract } from 'eth-hooks/models'; | ||
import { TAppContractsContext, TTypedContract } from 'eth-hooks/models'; | ||
import { contractsContextFactory, useEthersContext } from 'eth-hooks/context'; | ||
|
||
/** | ||
* This file initalises the contractContextFactory and exports the types | ||
* You don't need to change this file. | ||
* 🙅🏽♂️ You don't need to change this file. | ||
*/ | ||
|
||
/** | ||
* A type which is composed of contracts (contractNames) in your app | ||
* #### Summary | ||
* Call contractContextFactory with the contractConnectorConfig. | ||
* This will create your Context and hooks. | ||
*/ | ||
export type TAppContractNames = keyof TAppConnectorList; | ||
/** | ||
* A generic with 'contractName' that provides the appropriate type for your contract | ||
*/ | ||
export type TAppContractTypes<GContractName extends TAppContractNames> = TTypedContract< | ||
GContractName, | ||
TAppConnectorList | ||
>; | ||
|
||
export const { | ||
ContractsAppContext, | ||
useAppContractsActions, | ||
useAppContractsContext, | ||
useAppContracts, | ||
useLoadAppContracts, | ||
useConnectAppContracts, | ||
} = contractsContextFactory<TAppContractNames, TAppConnectorList, TAppContractTypes<TAppContractNames>>( | ||
contractConnectorConfig | ||
); | ||
|
||
/** | ||
* Wraps useAppContractsContext to provide narrowly typed contracts for app contracts | ||
* @param contractName | ||
* @param chainId | ||
* @returns | ||
*/ | ||
export const useAppContracts = <GContractName extends TAppContractNames>( | ||
contractName: GContractName, | ||
chainId: number | undefined | ||
): TAppContractTypes<GContractName> | undefined => { | ||
const result = useAppContractsContext(contractName, chainId); | ||
return result as TAppContractTypes<GContractName>; | ||
}; | ||
} = contractsContextFactory< | ||
keyof TAppConnectorList, | ||
TAppConnectorList, | ||
TTypedContract<keyof TAppConnectorList, TAppConnectorList> | ||
>(contractConnectorConfig); |
Oops, something went wrong.