Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip/adding audited contract support #51

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/chains.config.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { Chain } from "viem";
/** Reference for supported chains: https://github.com/gitcoinco/grants-stack/issues/3107 */
export declare const supportedChains: Chain[];
2 changes: 2 additions & 0 deletions dist/chains.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.supportedChains = void 0;
const chains_1 = require("viem/chains");
/** Local development chain support */
const devChain1 = {
id: 1337,
name: "Development 1",
Expand All @@ -22,6 +23,7 @@ const devChain1 = {
},
},
};
/** Reference for supported chains: https://github.com/gitcoinco/grants-stack/issues/3107 */
exports.supportedChains = [
chains_1.mainnet,
chains_1.optimism,
Expand Down
8 changes: 7 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { MicroGrantsStrategy } from "./strategies/MicroGrantsStrategy/MicroGrant
import { SQFSuperFluidStrategy } from "./strategies/SuperFluidStrategy/SQFSuperFluidStrategy";
import { DonationVotingMerkleDistributionStrategy } from "./strategies/DonationVotingMerkleDistributionStrategy/DonationVotingMerkleDistribution";
import { DirectGrantsStrategy } from "./strategies/DirectGrants/DirectGrantsStrategy";
import { QVSimpleStrategy } from "./strategies/QVSimpleStrategy/QVSimpleStrategy";
import { RFPSimpleStrategy } from "./strategies/RFPSimpleStrategy/RFPSimpleStrategy";
export * from "./types";
export * from "./strategies/types";
export * from "./Registry/types";
Expand All @@ -12,11 +14,15 @@ export * as DonationVotingMerkleDistributionStrategyTypes from "./strategies/Don
export * as MicroGrantsStrategyTypes from "./strategies/MicroGrantsStrategy/types";
export * as SQFSuperFluidStrategyTypes from "./strategies/SuperFluidStrategy/types";
export * as DirectGrantsStrategyTypes from "./strategies/DirectGrants/types";
export * as QVSimpleStrategyTypes from "./strategies/QVSimpleStrategy/types";
export * as RFPSimpleStrategyTypes from "./strategies/RFPSimpleStrategy/types";
export { abi as AlloAbi } from "./Allo/allo.config";
export { abi as RegistryAbi } from "./Registry/registry.config";
export { abi as DonationVotingMerkleDistributionDirectTransferStrategyAbi } from "./strategies/DonationVotingMerkleDistributionStrategy/donationVotingDirect.config";
export { abi as DonationVotingMerkleDistributionVaultStrategyAbi } from "./strategies/DonationVotingMerkleDistributionStrategy/donationVotingVault.config";
export { abi as MicroGrantsStrategyAbi } from "./strategies/MicroGrantsStrategy/microGrants.config";
export { abi as SQFSuperFluidStrategyAbi } from "./strategies/SuperFluidStrategy/superfluid.config";
export { abi as DirectGrantsStrategyAbi } from "./strategies/DirectGrants/directGrants.config";
export { Allo, Registry, MicroGrantsStrategy, SQFSuperFluidStrategy, DonationVotingMerkleDistributionStrategy, DirectGrantsStrategy, };
export { abi as QVSimpleStrategyAbi } from "./strategies/QVSimpleStrategy/qvSimple.config";
export { abi as RFPSimpleStrategyAbi } from "./strategies/RFPSimpleStrategy/rfpSimple.config";
export { Allo, Registry, MicroGrantsStrategy, SQFSuperFluidStrategy, DonationVotingMerkleDistributionStrategy, DirectGrantsStrategy, QVSimpleStrategy, RFPSimpleStrategy, };
12 changes: 11 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DirectGrantsStrategy = exports.DonationVotingMerkleDistributionStrategy = exports.SQFSuperFluidStrategy = exports.MicroGrantsStrategy = exports.Registry = exports.Allo = exports.DirectGrantsStrategyAbi = exports.SQFSuperFluidStrategyAbi = exports.MicroGrantsStrategyAbi = exports.DonationVotingMerkleDistributionVaultStrategyAbi = exports.DonationVotingMerkleDistributionDirectTransferStrategyAbi = exports.RegistryAbi = exports.AlloAbi = exports.DirectGrantsStrategyTypes = exports.SQFSuperFluidStrategyTypes = exports.MicroGrantsStrategyTypes = exports.DonationVotingMerkleDistributionStrategyTypes = void 0;
exports.RFPSimpleStrategy = exports.QVSimpleStrategy = exports.DirectGrantsStrategy = exports.DonationVotingMerkleDistributionStrategy = exports.SQFSuperFluidStrategy = exports.MicroGrantsStrategy = exports.Registry = exports.Allo = exports.RFPSimpleStrategyAbi = exports.QVSimpleStrategyAbi = exports.DirectGrantsStrategyAbi = exports.SQFSuperFluidStrategyAbi = exports.MicroGrantsStrategyAbi = exports.DonationVotingMerkleDistributionVaultStrategyAbi = exports.DonationVotingMerkleDistributionDirectTransferStrategyAbi = exports.RegistryAbi = exports.AlloAbi = exports.RFPSimpleStrategyTypes = exports.QVSimpleStrategyTypes = exports.DirectGrantsStrategyTypes = exports.SQFSuperFluidStrategyTypes = exports.MicroGrantsStrategyTypes = exports.DonationVotingMerkleDistributionStrategyTypes = void 0;
const Allo_1 = require("./Allo/Allo");
Object.defineProperty(exports, "Allo", { enumerable: true, get: function () { return Allo_1.Allo; } });
const Registry_1 = require("./Registry/Registry");
Expand All @@ -27,6 +27,10 @@ const DonationVotingMerkleDistribution_1 = require("./strategies/DonationVotingM
Object.defineProperty(exports, "DonationVotingMerkleDistributionStrategy", { enumerable: true, get: function () { return DonationVotingMerkleDistribution_1.DonationVotingMerkleDistributionStrategy; } });
const DirectGrantsStrategy_1 = require("./strategies/DirectGrants/DirectGrantsStrategy");
Object.defineProperty(exports, "DirectGrantsStrategy", { enumerable: true, get: function () { return DirectGrantsStrategy_1.DirectGrantsStrategy; } });
const QVSimpleStrategy_1 = require("./strategies/QVSimpleStrategy/QVSimpleStrategy");
Object.defineProperty(exports, "QVSimpleStrategy", { enumerable: true, get: function () { return QVSimpleStrategy_1.QVSimpleStrategy; } });
const RFPSimpleStrategy_1 = require("./strategies/RFPSimpleStrategy/RFPSimpleStrategy");
Object.defineProperty(exports, "RFPSimpleStrategy", { enumerable: true, get: function () { return RFPSimpleStrategy_1.RFPSimpleStrategy; } });
__exportStar(require("./types"), exports);
__exportStar(require("./strategies/types"), exports);
__exportStar(require("./Registry/types"), exports);
Expand All @@ -35,6 +39,8 @@ exports.DonationVotingMerkleDistributionStrategyTypes = require("./strategies/Do
exports.MicroGrantsStrategyTypes = require("./strategies/MicroGrantsStrategy/types");
exports.SQFSuperFluidStrategyTypes = require("./strategies/SuperFluidStrategy/types");
exports.DirectGrantsStrategyTypes = require("./strategies/DirectGrants/types");
exports.QVSimpleStrategyTypes = require("./strategies/QVSimpleStrategy/types");
exports.RFPSimpleStrategyTypes = require("./strategies/RFPSimpleStrategy/types");
var allo_config_1 = require("./Allo/allo.config");
Object.defineProperty(exports, "AlloAbi", { enumerable: true, get: function () { return allo_config_1.abi; } });
var registry_config_1 = require("./Registry/registry.config");
Expand All @@ -49,3 +55,7 @@ var superfluid_config_1 = require("./strategies/SuperFluidStrategy/superfluid.co
Object.defineProperty(exports, "SQFSuperFluidStrategyAbi", { enumerable: true, get: function () { return superfluid_config_1.abi; } });
var directGrants_config_1 = require("./strategies/DirectGrants/directGrants.config");
Object.defineProperty(exports, "DirectGrantsStrategyAbi", { enumerable: true, get: function () { return directGrants_config_1.abi; } });
var qvSimple_config_1 = require("./strategies/QVSimpleStrategy/qvSimple.config");
Object.defineProperty(exports, "QVSimpleStrategyAbi", { enumerable: true, get: function () { return qvSimple_config_1.abi; } });
var rfpSimple_config_1 = require("./strategies/RFPSimpleStrategy/rfpSimple.config");
Object.defineProperty(exports, "RFPSimpleStrategyAbi", { enumerable: true, get: function () { return rfpSimple_config_1.abi; } });
14 changes: 14 additions & 0 deletions dist/strategies/QVSimpleStrategy/QVSimpleStrategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ConstructorArgs, DeployParams } from "../../types";
import { InitializeParamsSimple } from "./types";
export declare class QVSimpleStrategy {
private client;
private contract;
private strategy;
private poolId;
private allo;
constructor({ chain, rpc, address, poolId }: ConstructorArgs);
getInitializeData(params: InitializeParamsSimple): `0x${string}`;
getDeployParams(): DeployParams;
setPoolId(poolId: bigint): Promise<void>;
setContract(address: `0x${string}`): void;
}
76 changes: 76 additions & 0 deletions dist/strategies/QVSimpleStrategy/QVSimpleStrategy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QVSimpleStrategy = void 0;
const viem_1 = require("viem");
const Allo_1 = require("../../Allo/Allo");
const chains_config_1 = require("../../chains.config");
const Client_1 = require("../../Client/Client");
const qvSimple_config_1 = require("./qvSimple.config");
class QVSimpleStrategy {
constructor({ chain, rpc, address, poolId }) {
const usedChain = (0, viem_1.extractChain)({
chains: chains_config_1.supportedChains,
id: chain,
});
this.client = (0, Client_1.create)(usedChain, rpc);
this.allo = new Allo_1.Allo({ chain, rpc });
if (address) {
this.contract = (0, viem_1.getContract)({
address: address,
abi: [],
publicClient: this.client,
});
this.strategy = address;
}
this.poolId = poolId || BigInt(-1);
}
getInitializeData(params) {
const encoded = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("uint256, (bool, bool, uint256, uint64, uint64, uint64, uint64)"), [
params.maxVoiceCreditsPerAllocator,
[
params.params.registryGating,
params.params.metadataRequired,
params.params.reviewThreshold,
params.params.registrationStartTime,
params.params.registrationEndTime,
params.params.allocationStartTime,
params.params.allocationEndTime,
],
]);
return encoded;
}
getDeployParams() {
const constructorArgs = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("address, string"), [this.allo.address(), "QVSimpleStrategy1.0"]);
const constructorArgsNo0x = constructorArgs.slice(2);
return {
abi: qvSimple_config_1.abi,
bytecode: (qvSimple_config_1.bytecode +
constructorArgsNo0x),
};
}
setPoolId(poolId) {
return __awaiter(this, void 0, void 0, function* () {
this.poolId = poolId;
const strategyAddress = yield this.allo.getStrategy(poolId);
this.setContract(strategyAddress);
});
}
setContract(address) {
this.contract = (0, viem_1.getContract)({
address: address,
abi: qvSimple_config_1.abi,
publicClient: this.client,
});
this.strategy = address;
}
}
exports.QVSimpleStrategy = QVSimpleStrategy;
98 changes: 98 additions & 0 deletions dist/strategies/QVSimpleStrategy/qvSimple.config.d.ts

Large diffs are not rendered by default.

Loading
Loading