Skip to content

Commit

Permalink
scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed Dec 19, 2023
1 parent fe4df71 commit 01553c6
Show file tree
Hide file tree
Showing 16 changed files with 1,899 additions and 49 deletions.
1 change: 1 addition & 0 deletions cache/solidity-files-cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"_format":"ethers-rs-sol-cache-3","paths":{"artifacts":"out","build_infos":"out/build-info","sources":"src","tests":"test","scripts":"script","libraries":["node_modules"]},"files":{}}
1 change: 1 addition & 0 deletions dist/__live__/createSuperfluidpool.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
107 changes: 107 additions & 0 deletions dist/__live__/createSuperfluidpool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
"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 });
const viem_1 = require("viem");
const accounts_1 = require("viem/accounts");
const chains_1 = require("viem/chains");
const dotenv_1 = require("dotenv");
const SuperFluidStrategy_1 = require("../strategies/SuperFluidStrategy/SuperFluidStrategy");
const Allo_1 = require("../Allo/Allo");
(0, dotenv_1.config)();
const client = (0, viem_1.createWalletClient)({
chain: chains_1.goerli,
transport: (0, viem_1.http)(),
});
const publicClient = (0, viem_1.createPublicClient)({
chain: chains_1.goerli,
transport: (0, viem_1.http)(),
});
if (!process.env.PRIVATE_KEY) {
throw new Error("No private key found in .env file");
}
const account = (0, accounts_1.privateKeyToAccount)(process.env.PRIVATE_KEY);
console.log("Account: " + account.address);
const strategy = new SuperFluidStrategy_1.SuperFluidStrategy({
chain: 5,
});
const deployStrategy = () => __awaiter(void 0, void 0, void 0, function* () {
const deployParams = strategy.getDeployParams();
console.log("DEPLOY PARAMS");
console.log(deployParams);
const hash = yield client.deployContract({
account: account,
abi: deployParams.abi,
bytecode: deployParams.bytecode,
args: [],
});
console.log("HASH");
console.log(hash);
const receipt = yield publicClient.waitForTransactionReceipt({ hash });
console.log("Contract deployed at:");
console.log(receipt.contractAddress);
return receipt.contractAddress;
});
const createPool = () => __awaiter(void 0, void 0, void 0, function* () {
const now = new Date();
const startDate = new Date(now.getTime() + 5 * 60000);
const endDate = new Date(now.getTime() + 6 * 60000);
const deployment = "0x82163F9aD2bc6B04D53e222d7EFC9fE34a698159"; //await deployStrategy();
const params = {
useRegistryAnchor: true,
metadataRequired: false,
passportDecoder: "0xE7eB5D2b5b188777df902e89c54570E7Ef4F59CE",
superfluidHost: "0x22ff293e14F1EC3A09B137e9e06084AFd63adDF9",
allocationSuperToken: "0xf2d68898557ccb2cf4c10c3ef2b034b2a69dad00",
registrationStartTime: BigInt((startDate.getTime() / 1000 - 100).toFixed(0)),
registrationEndTime: BigInt((endDate.getTime() / 1000 - 100).toFixed(0)),
allocationStartTime: BigInt((startDate.getTime() / 1000).toFixed(0)),
allocationEndTime: BigInt((endDate.getTime() / 1000).toFixed(0)),
minPassportScore: BigInt(42069),
initialSuperAppBalance: BigInt(100000),
};
console.log("PARAMS");
console.log(params);
const initParams = yield strategy.getInitializeData(params);
console.log("INIT PARAMS");
console.log(initParams);
const poolCreationData = {
profileId: "0xdd24c7e8a35d4a95f0f4b8f5c819b7c2a0029807a39b0a2f8cb4bf51141816ff",
strategy: deployment,
initStrategyData: initParams,
token: "0xf2d68898557ccb2cf4c10c3ef2b034b2a69dad00",
amount: BigInt(0),
metadata: {
protocol: BigInt(1),
pointer: "bafkreigcxfdotdrh7cm3sy432k2pnyp3n7nisz35npismochqurqcjscfu",
},
managers: [],
};
console.log("POOL CREATION DATA");
console.log(poolCreationData);
const allo = new Allo_1.Allo({
chain: 5,
});
const createPoolData = yield allo.createPoolWithCustomStrategy(poolCreationData);
const tx = yield client.sendTransaction({
account,
to: createPoolData.to,
data: createPoolData.data,
value: BigInt(createPoolData.value),
});
const reciept = yield publicClient.waitForTransactionReceipt({
hash: tx,
});
const { logs } = reciept;
// const poolId = Number(logs[6].topics[1]);
console.log(`Pool created with id:`);
console.log(logs);
});
createPool();
15 changes: 11 additions & 4 deletions dist/__live__/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ const deployStrategy = () => __awaiter(void 0, void 0, void 0, function* () {
const receipt = yield publicClient.waitForTransactionReceipt({ hash });
console.log("Contract deployed at:");
console.log(receipt.contractAddress);
return receipt.contractAddress;
});
deployStrategy(); // 0xa15ab11d078d69ee48ac431720ba5f0877aae492
// deployStrategy(); // 0xa15ab11d078d69ee48ac431720ba5f0877aae492
// bafkreigcxfdotdrh7cm3sy432k2pnyp3n7nisz35npismochqurqcjscfu
const createPool = () => __awaiter(void 0, void 0, void 0, function* () {
const now = new Date();
const startDate = new Date(now.getTime() + 5 * 60000);
const endDate = new Date(now.getTime() + 6 * 60000);
const deployment = yield deployStrategy();
const initParams = yield strategy.getInitializeDataGov({
useRegistryAnchor: false,
allocationStartTime: BigInt((startDate.getTime() / 1000).toFixed(0)),
Expand All @@ -61,9 +63,11 @@ const createPool = () => __awaiter(void 0, void 0, void 0, function* () {
snapshotReference: BigInt((now.getTime() / 1000).toFixed(0)),
minVotePower: BigInt(1),
});
console.log("INIT PARAMS");
console.log(initParams);
const poolCreationData = {
profileId: "0x9685d8aa17031c28b21e654729c9bf546bafe536223eb09e524657cdc840117e",
strategy: "0xd3066e5aae9a2ac9adb27a4754350b06f60d4b06",
strategy: deployment,
initStrategyData: initParams,
token: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
amount: BigInt(10000000000000),
Expand All @@ -73,6 +77,8 @@ const createPool = () => __awaiter(void 0, void 0, void 0, function* () {
},
managers: [],
};
console.log("POOL CREATION DATA");
console.log(poolCreationData);
const allo = new Allo_1.Allo({
chain: 5,
});
Expand All @@ -88,9 +94,10 @@ const createPool = () => __awaiter(void 0, void 0, void 0, function* () {
});
const { logs } = reciept;
// const poolId = Number(logs[6].topics[1]);
console.log(`Pool created with id: ${logs}`);
console.log(`Pool created with id:`);
console.log(logs);
});
// createPool();
createPool();
// const testGetAlloOwner = async () => {
// const registry = new Registry({ chain: chains.goerli });
// const profile: Profile = await registry.getProfileById(
Expand Down
30 changes: 15 additions & 15 deletions dist/strategies/MicroGrantsStrategy/MicroGrantsStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,21 @@ class MicroGrantsStrategy {
}
getStrategyContractId(strategyContract) {
return __awaiter(this, void 0, void 0, function* () {
const abi = [
{
inputs: [],
name: "getStrategyId",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32",
},
],
stateMutability: "view",
type: "function",
},
];
// const abi = [
// {
// inputs: [],
// name: "getStrategyId",
// outputs: [
// {
// internalType: "bytes32",
// name: "",
// type: "bytes32",
// },
// ],
// stateMutability: "view",
// type: "function",
// },
// ];
const contractReader = (0, viem_1.getContract)({
address: strategyContract,
abi: microGrantsGov_config_1.abi,
Expand Down
35 changes: 35 additions & 0 deletions dist/strategies/SuperFluidStrategy/SuperFluidStrategy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Allo } from "../../Allo/Allo";
import { ConstructorArgs, DeployParams, PayoutSummary, Recipient, Status } from "../../types";
import { InitializeParamsSuperFluid } from "./types";
export declare class SuperFluidStrategy {
private client;
private contract;
private strategy;
private poolId;
private allo;
constructor({ chain, rpc, address, poolId }: ConstructorArgs);
setPoolId(poolId: number): Promise<void>;
setContract(address: `0x${string}`): void;
private checkPoolId;
private checkStrategy;
getNative(): Promise<string>;
allocator(allocatorAddress: string): Promise<boolean>;
allocated(allocatorAddress: string, recipientAddress: string): Promise<boolean>;
allocationEndTime(): Promise<number>;
allocationStartTime(): Promise<number>;
approvalThreshold(): Promise<string>;
getAllo(): Promise<Allo>;
getPayouts(recipientIds: string[]): Promise<PayoutSummary[]>;
getPoolAmount(): Promise<number>;
getPoolId(): Promise<number>;
getRecipient(recipientId: string): Promise<Recipient>;
getRecipientStatus(recipientId: string): Promise<Status>;
getStrategyId(): Promise<string>;
isPoolActive(): Promise<boolean>;
isValidAllocator(allocatorAddress: string): Promise<boolean>;
recipientAllocations(recipientId: string, status: Status): Promise<string>;
maxRequestedAmount(): Promise<number>;
useRegistryAnchor(): Promise<boolean>;
getInitializeData(params: InitializeParamsSuperFluid): Promise<`0x${string}`>;
getDeployParams(): DeployParams;
}
Loading

0 comments on commit 01553c6

Please sign in to comment.