Skip to content

Commit

Permalink
chore: simplify payout tokens handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vacekj committed Nov 22, 2023
1 parent 78ef31a commit 12dba4d
Show file tree
Hide file tree
Showing 16 changed files with 339 additions and 359 deletions.
4 changes: 2 additions & 2 deletions packages/round-manager/src/context/application/usePayout.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Dispatch, SetStateAction, useState } from "react";
import { ProgressStatus, ProgressStep } from "../../features/api/types";
import { PayoutToken } from "../../features/api/utils";
import {
DirectPayoutStrategy__factory,
Erc20__factory,
} from "../../types/generated/typechain";
import { BigNumber, ethers } from "ethers";
import { waitForSubgraphSyncTo } from "../../features/api/subgraph";
import { PayoutTokens } from "../../features/api/payoutTokens";

export function usePayout() {
const [contractApproveSpendStatus, setContractApproveSpendStatus] =
Expand Down Expand Up @@ -71,7 +71,7 @@ export function usePayout() {
type Args = {
address: string;
signer: ethers.Signer;
token: PayoutToken;
token: PayoutTokens;
projectId: string;
applicationIndex: number;
payoutStrategyAddress: string;
Expand Down
11 changes: 6 additions & 5 deletions packages/round-manager/src/context/round/FundContractContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { fundRoundContract } from "../../features/api/application";
import { waitForSubgraphSyncTo } from "../../features/api/subgraph";

import { ProgressStatus } from "../../features/api/types";
import { PayoutToken } from "../../features/api/utils";

import { PayoutTokens } from "../../features/api/payoutTokens";

export interface FundContractState {
tokenApprovalStatus: ProgressStatus;
Expand All @@ -30,14 +31,14 @@ export interface FundContractState {
export type FundContractParams = {
roundId: string;
fundAmount: number;
payoutToken: PayoutToken;
payoutToken: PayoutTokens;
};

interface SubmitFundParams {
signer: Signer;
context: FundContractState;
roundId: string;
payoutToken: PayoutToken;
payoutToken: PayoutTokens;
fundAmount: number;
}

Expand Down Expand Up @@ -179,7 +180,7 @@ async function _fundContract({
async function approveTokenForFunding(
signerOrProvider: Signer,
roundId: string,
token: PayoutToken,
token: PayoutTokens,
amount: number,
context: FundContractState
): Promise<void> {
Expand All @@ -203,7 +204,7 @@ async function approveTokenForFunding(
async function fund(
signerOrProvider: Signer,
roundId: string,
token: PayoutToken,
token: PayoutTokens,
fundAmount: number,
context: FundContractState
): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { saveToIPFS } from "../../features/api/ipfs";
import { TransactionBuilder, UpdateAction } from "../../features/api/round";
import { waitForSubgraphSyncTo } from "../../features/api/subgraph";
import { EditedGroups, ProgressStatus, Round } from "../../features/api/types";
import { getPayoutTokenOptions } from "../../features/api/utils";
import { useWallet } from "../../features/common/Auth";
import subSeconds from "date-fns/subSeconds";
import { getPayoutTokenOptions } from "../../features/api/payoutTokens";

type SetStatusFn = React.Dispatch<SetStateAction<ProgressStatus>>;

Expand Down
5 changes: 3 additions & 2 deletions packages/round-manager/src/features/api/application.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchFromIPFS, PayoutToken, pinToIPFS } from "./utils";
import { fetchFromIPFS, pinToIPFS } from "./utils";
import {
AppStatus,
GrantApplication,
Expand All @@ -19,6 +19,7 @@ import { Signer } from "@ethersproject/abstract-signer";
import { Web3Provider } from "@ethersproject/providers";
import { graphql_fetch } from "common";
import { DirectPayoutStrategy__factory } from "../../types/generated/typechain";
import { PayoutTokens } from "./payoutTokens";
// import { verifyApplicationMetadata } from "common/src/verification";
// import { fetchProjectOwners } from "common/src/registry";

Expand Down Expand Up @@ -484,7 +485,7 @@ export const updateApplicationList = async (
export const fundRoundContract = async (
roundId: string,
signer: Signer,
payoutToken: PayoutToken,
payoutToken: PayoutTokens,
amount: BigNumber
): Promise<{ txBlockNumber: number; txHash: string }> => {
// checksum conversion
Expand Down
Loading

0 comments on commit 12dba4d

Please sign in to comment.