Skip to content

Commit

Permalink
re-add networks
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed May 27, 2024
1 parent f6b3ab7 commit ec6f0f2
Show file tree
Hide file tree
Showing 8 changed files with 1,582 additions and 525 deletions.
192 changes: 192 additions & 0 deletions packages/common/src/allo/abis/FundPool.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
export const fundPoolAbi = [
{
inputs: [],
name: "AMOUNT_MISMATCH",
type: "error",
},
{
inputs: [],
name: "AlreadyInitialized",
type: "error",
},
{
inputs: [],
name: "AmountTooLow",
type: "error",
},
{
inputs: [],
name: "InvalidPool",
type: "error",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "address",
name: "allo",
type: "address",
},
],
name: "Initialized",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint256",
name: "poolId",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
{
components: [
{
internalType: "uint256",
name: "protocol",
type: "uint256",
},
{
internalType: "string",
name: "pointer",
type: "string",
},
],
indexed: false,
internalType: "struct Metadata",
name: "metadata",
type: "tuple",
},
],
name: "PoolFunded",
type: "event",
},
{
inputs: [],
name: "NATIVE",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "allo",
outputs: [
{
internalType: "contract IAllo",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "uint256",
name: "_poolId",
type: "uint256",
},
{
internalType: "uint256",
name: "_amount",
type: "uint256",
},
{
components: [
{
internalType: "uint256",
name: "protocol",
type: "uint256",
},
{
internalType: "string",
name: "pointer",
type: "string",
},
],
internalType: "struct Metadata",
name: "_metadata",
type: "tuple",
},
],
name: "fundPool",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "address",
name: "_allo",
type: "address",
},
],
name: "initialize",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
name: "maxFundings",
outputs: [
{
internalType: "address",
name: "sender",
type: "address",
},
{
internalType: "uint256",
name: "maxAmount",
type: "uint256",
},
{
internalType: "uint256",
name: "totalAmount",
type: "uint256",
},
{
components: [
{
internalType: "uint256",
name: "protocol",
type: "uint256",
},
{
internalType: "string",
name: "pointer",
type: "string",
},
],
internalType: "struct Metadata",
name: "metadata",
type: "tuple",
},
],
stateMutability: "view",
type: "function",
},
] as const;
3 changes: 3 additions & 0 deletions packages/common/src/allo/allo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Result } from "./common";
import { AlloOperation } from "./operation";
import { TransactionReceipt } from "./transaction-sender";
import { PermitSignature } from "./voting";
import { Metadata } from "@allo-team/allo-v2-sdk";

export type CreateRoundArguments = {
roundData: {
Expand Down Expand Up @@ -151,6 +152,8 @@ export interface Allo {
roundId: string;
amount: bigint;
requireTokenApproval?: boolean;
destinationContract?: Address;
metadata?: Metadata;
}) => AlloOperation<
Result<null>,
{
Expand Down
39 changes: 30 additions & 9 deletions packages/common/src/allo/backends/allo-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import {
} from "@allo-team/allo-v2-sdk";
import MRC_ABI from "../abis/allo-v1/multiRoundCheckout";
import { MRC_CONTRACTS } from "../addresses/mrc";
import { CreatePoolArgs, NATIVE } from "@allo-team/allo-v2-sdk/dist/types";
import {
CreatePoolArgs,
Metadata,
NATIVE,
} from "@allo-team/allo-v2-sdk/dist/types";
import {
ApplicationStatus,
DistributionMatch,
Expand Down Expand Up @@ -48,6 +52,7 @@ import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
import { buildUpdatedRowsOfApplicationStatuses } from "../application";
import { BigNumber, utils } from "ethers";
import { Distribution } from "@allo-team/allo-v2-sdk/dist/strategies/DonationVotingMerkleDistributionStrategy/types";
import { fundPoolAbi } from "../abis/FundPool.abi";

function getStrategyAddress(strategy: RoundCategory, chainId: ChainId): string {
let strategyAddresses;
Expand Down Expand Up @@ -899,6 +904,8 @@ export class AlloV2 implements Allo {
roundId: string;
amount: bigint;
requireTokenApproval?: boolean;
destinationContract?: Address;
metadata?: Metadata;
}): AlloOperation<
Result<null>,
{
Expand All @@ -922,7 +929,7 @@ export class AlloV2 implements Allo {
address: args.tokenAddress,
abi: Erc20ABI,
functionName: "approve",
args: [this.allo.address(), args.amount],
args: [args.destinationContract ?? this.allo.address(), args.amount],
});

if (approvalTx.type === "error") {
Expand All @@ -939,13 +946,27 @@ export class AlloV2 implements Allo {
}
}

const tx = await sendTransaction(this.transactionSender, {
address: this.allo.address(),
abi: AlloAbi,
functionName: "fundPool",
args: [poolId, args.amount],
value: args.tokenAddress === zeroAddress ? args.amount : 0n,
});
console.log("APPROVED!!!");

let tx;
if (args.destinationContract) {
console.log("FUNDING POOL!!!");
tx = await sendTransaction(this.transactionSender, {
address: args.destinationContract ?? this.allo.address(),
abi: fundPoolAbi,
functionName: "fundPool",
args: [poolId, args.amount, args.metadata!],
value: args.tokenAddress === zeroAddress ? args.amount : 0n,
});
} else {
tx = await sendTransaction(this.transactionSender, {
address: this.allo.address(),
abi: AlloAbi,
functionName: "fundPool",
args: [poolId, args.amount],
value: args.tokenAddress === zeroAddress ? args.amount : 0n,
});
}

emit("transaction", tx);

Expand Down
8 changes: 2 additions & 6 deletions packages/common/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,10 @@ export const sepolia: Chain = {
...ethereumSepolia,
rpcUrls: {
default: {
http: [
`https://eth-sepolia.g.alchemy.com/v2/${config.blockchain.alchemyId}`,
],
http: [`https://eth-sepolia.public.blastapi.io`],
},
public: {
http: [
`https://eth-sepolia.g.alchemy.com/v2/${config.blockchain.alchemyId}`,
],
http: [`https://eth-sepolia.public.blastapi.io`],
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/grant-explorer/src/app/chainConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const TESTNET_CHAINS = [
arbitrumGoerli,
avalancheFuji,
polygonMumbai,
// zkSyncEraTestnet,
zkSyncEraTestnet,
sepolia,
// seiDevnet,
seiDevnet,
luksoTestnet,
celoAlfajores,
].map(ensureValidChainId);
Expand Down
Loading

0 comments on commit ec6f0f2

Please sign in to comment.