utils#ZERO_HASH TypeScript Examples

The following examples show how to use utils#ZERO_HASH. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: useProposalCalls.ts    From dxvote with GNU Affero General Public License v3.0 5 votes vote down vote up
useProposalCalls = (guildId: string, proposalId: string) => {
  // Decode calls from existing proposal
  const { data: proposal } = useProposal(guildId, proposalId);
  const { contracts } = useContractRegistry();
  const { chainId } = useWeb3React();

  const theme = useTheme();

  const options: Option[] = useMemo(() => {
    if (!guildId || !proposalId || !proposal) return null;

    const {
      totalActions: totalOptions,
      to: toArray,
      data: dataArray,
      value: valuesArray,
    } = proposal;

    const calls: Call[] = toArray.map((to, index) => ({
      from: guildId,
      to: to,
      data: dataArray[index],
      value: valuesArray[index],
    }));

    const totalOptionsNum = totalOptions.toNumber();

    const callsPerOption = toArray.length / totalOptionsNum;
    const splitCalls: Call[][] = [];
    for (let i = 0; i < totalOptionsNum; i++) {
      splitCalls.push(
        calls.slice(i * callsPerOption, (i + 1) * callsPerOption)
      );
    }

    const encodedOptions: Option[] = splitCalls.map((calls, index) => ({
      id: `option-${index}`,
      label: `Option ${index + 1}`,
      color: theme?.colors?.votes?.[options.length],
      actions: calls.filter(
        call => call.data !== ZERO_HASH || !call.value?.isZero()
      ),
    }));

    return bulkDecodeCallsFromOptions(encodedOptions, contracts, chainId);
  }, [theme, proposal, proposalId, guildId, chainId, contracts]);

  return {
    options,
  };
}
Example #2
Source File: CreateProposal.tsx    From dxvote with GNU Affero General Public License v3.0 5 votes vote down vote up
EMPTY_CALL: Call = {
  data: ZERO_HASH,
  from: ZERO_ADDRESS,
  to: ZERO_ADDRESS,
  value: BigNumber.from(0),
}