0.1.9 • Published 1 year ago

use-delegatecash v0.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

use-delegatecash

⚛️ 💸 React.js hooks for delegate.cash which enable you to build safer user experiences powered by asset delegation. Supports both React and React Native.

🚀 Getting Started

To get started, make sure you've got the following dependencies installed:

yarn add ethers wagmi delegatecash use-delegatecash

💭 use-delegatecash assumes you've already declared a WagmiConfig at the root of your application.

✍️ Usage

use-delegatecash wraps all of the getter functions exported by delegatecash inside stateful typesafe React hooks.

You can also useDelegateCash() to return a DelegateCash object, which can be used to initiate transactions.

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 (
      <View style={[StyleSheet.absoluteFill, styles.center]}>
        {isDelegateCashError(state)
          ? <Text children={state.error.message} />
          : isDelegateCashResult(state)
          ? <Text children="Got result!" />
          : <ActivityIndicator />}
      </View>
    );
  },
);

const styles = StyleSheet.create({
  center: {alignItems: 'center', justifyContent: 'center'},
});

✌️License

MIT

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago