Skip to content

Commit

Permalink
fix: consistent naming for proposed calls vars
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Oct 9, 2022
1 parent d5f10b1 commit 85398ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/common/hooks/useContractRead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type ReadContractConfig<ArgsType = []> = Partial<

export type PredefinedReadContractConfig<ArgsType = []> = Omit<
ReadContractConfig<ArgsType>,
'contractReference' | 'functionName'
'contractReference' | 'functionName' | 'addressOrName'
>;

export const useContractRead = <ResultType = any, ArgsType = []>({
Expand Down
26 changes: 13 additions & 13 deletions packages/react/src/core/diamonds/providers/DiamondProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ type DiamondContextValue = {

configValues?: Record<string, any>;
proposedCalls?: ContractCall[];
processingCalls?: boolean;
processingError?: Error | string;
};

isLoading: {
proposedCallsLoading?: boolean;
diamondLoading?: boolean;
smartContractLoading?: boolean;
};

error: {
proposedCallsError?: Error | string | null;
diamondError?: string | Error | null;
smartContractError?: string | Error | null;
};
Expand Down Expand Up @@ -73,8 +73,11 @@ export const DiamondProvider = ({
const [configValues, setConfigValues] = useState<Record<string, any>>();
const [contractFacets, setContractFacets] = useState<FacetManifest[]>();
const [proposedCalls, setProposedCalls] = useState<ContractCall[]>([]);
const [processingCalls, setProcessingCalls] = useState<boolean>(false);
const [processingError, setProcessingError] = useState<Error | string>();
const [proposedCallsLoading, setProposedCallsLoading] =
useState<boolean>(false);
const [proposedCallsError, setProposedCallsError] = useState<
Error | string
>();

const {
data: diamond,
Expand Down Expand Up @@ -142,17 +145,16 @@ export const DiamondProvider = ({
*/
const proposeCall = useCallback(
(call: ContractCall) => {
if (processingCalls) {
if (proposedCallsLoading) {
return;
}

setProposedCalls((calls) =>
[...calls.filter((existing) => existing.id !== call.id), call].filter(
(c) => c.contract && c.function && c.args !== undefined,
),
);
},
[processingCalls],
[proposedCallsLoading],
);

const refresh = useCallback(() => {
Expand All @@ -170,18 +172,16 @@ export const DiamondProvider = ({
contractFacets,
contractInterfaces,
proposedCalls,
processingCalls,
processingError,
},

isLoading: { diamondLoading, smartContractLoading },
isLoading: { proposedCallsLoading, diamondLoading, smartContractLoading },

error: { diamondError, smartContractError },
error: { proposedCallsError, diamondError, smartContractError },

setConfigValues,
setProposedCalls,
setProcessingCalls,
setProcessingError,
setProcessingCalls: setProposedCallsLoading,
setProcessingError: setProposedCallsError,
proposeCall,
refresh,
};
Expand Down

0 comments on commit 85398ce

Please sign in to comment.