Skip to content

Commit

Permalink
dist limit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomquirk committed Nov 14, 2023
1 parent ab7df4e commit e76686b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/react/hooks/juicebox/useEthDistributionLimit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { JB_ETHER_ADDRESS } from "../../../constants";
import { useJbFundAccessConstraintsStoreDistributionLimitOf } from "../../generated/hooks";
import { useJBContractContext } from "src/react/contexts";
import { Ether } from "src/utils";
import { Address } from "viem";
import { JBCurrency, JB_ETHER_ADDRESS } from "../../../constants";
import { useJbFundAccessConstraintsStoreDistributionLimitOf } from "../../generated/hooks";

export interface EthDistributionLimitArgs {
/**
Expand All @@ -15,7 +16,7 @@ export interface EthDistributionLimitArgs {
/**
* The terminal from which distributions are being limited.
*/
terminal: Address;
terminalAddress: Address;
}

/**
Expand All @@ -26,19 +27,28 @@ export interface EthDistributionLimitArgs {
export function useEthDistributionLimit({
projectId,
configuration,
terminal,
terminalAddress,
}: EthDistributionLimitArgs) {
const { contracts: { fundAccessConstraintsStore } } = useJBContractContext();
const {
contracts: { fundAccessConstraintsStore },
} = useJBContractContext();

const args = [
projectId,
configuration,
terminal,
terminalAddress,
JB_ETHER_ADDRESS, // _token
] as const
] as const;

const distributionLimit = useJbFundAccessConstraintsStoreDistributionLimitOf({
address: fundAccessConstraintsStore.data,
args
args,
select: ([distributionLimit, currency]) => {
return {
distributionLimit: new Ether(distributionLimit),
distributionLimitCurrency: currency as JBCurrency,
};
},
});

return distributionLimit;
Expand Down

0 comments on commit e76686b

Please sign in to comment.