Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cawfree/use-delegatecash
βοΈ πΈ React.js hooks for delegate.cash
https://github.com/cawfree/use-delegatecash
asset cash delegate eip-5639 ethereum ethers protection react wagmi
Last synced: 12 days ago
JSON representation
βοΈ πΈ React.js hooks for delegate.cash
- Host: GitHub
- URL: https://github.com/cawfree/use-delegatecash
- Owner: cawfree
- License: mit
- Created: 2023-01-25T06:28:09.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-09T00:05:36.000Z (almost 2 years ago)
- Last Synced: 2024-10-23T03:31:39.688Z (25 days ago)
- Topics: asset, cash, delegate, eip-5639, ethereum, ethers, protection, react, wagmi
- Language: TypeScript
- Homepage: https://delegate.cash
- Size: 89.8 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# use-delegatecash
βοΈ πΈ React.js hooks for [__delegate.cash__](https://delegate.cash) which enable you to build safer user experiences powered by asset delegation. Supports both [__React__](https://reactjs.org/) and [__React Native__](https://reactnative.dev).### π Getting Started
To get started, make sure you've got the following dependencies installed:
```
yarn add ethers wagmi [email protected] use-delegatecash
```> π `use-delegatecash` assumes you've already declared a [`WagmiConfig`](https://github.com/wagmi-dev/wagmi) at the root of your application.
### βοΈ Usage
`use-delegatecash` wraps all of the getter functions exported by [`delegatecash`](https://github.com/delegatecash/delegatecash-javascript-sdk) inside stateful typesafe React hooks.
You can also `useDelegateCash()` to return a [`DelegateCash`](https://github.com/delegatecash/delegatecash-javascript-sdk/blob/ef2f7b2d0e50b7b2ac8a9faef0edd1ed07e6807a/src/index.ts#L7) object, which can be used to initiate transactions.
```typescript
import * as React from 'react';
import {
ActivityIndicator,
StyleSheet,
Text,
View,
} from 'react-native';import {
useCheckDelegateForAll,
useGetDelegatesForContract,
useCheckDelegateForContract,
useCheckDelegateForToken,
useDelegateCash,
useGetContractLevelDelegations,
useGetDelegatesForAll,
useGetDelegatesForContract,
useGetDelegationsByDelegate,
useGetTokenLevelDelegations,
isDelegateCashResult,
isDelegateCashError,
} from 'use-delegatecash';export const AppExample = React.memo(
function AppExample(): JSX.Element {
const state = useGetDelegatesForAll({
vault: '0x312e71162Df834A87a2684d30562b94816b0f072',
});
return (
{isDelegateCashError(state)
?
: isDelegateCashResult(state)
?
: }
);
},
);const styles = StyleSheet.create({
center: {alignItems: 'center', justifyContent: 'center'},
});
```### βοΈLicense
[__MIT__](./LICENSE)