Skip to content

Commit

Permalink
feat: add generic propose function
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removal of old propose functions
  • Loading branch information
Will Kim committed Jun 17, 2022
1 parent 59d4e61 commit d058fc9
Show file tree
Hide file tree
Showing 14 changed files with 453 additions and 1,393 deletions.
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

190 changes: 60 additions & 130 deletions docs/classes/Pod.html

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions docs/classes/Proposal.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/modules.html

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions scripts/approve-proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ async function main() {

const pod = await getPod(adminPodAddress);

if ((await pod.getProposals({ queued: true }))[0].status !== 'executed') {
if ((await pod.getProposals({ status: 'queued' }))[0].status !== 'executed') {
throw new Error(
'Super pod had an active/queued transaction. This script expects no enqueued transactions',
);
}

// We mint/burn the dummy account based on whether its a member or not.
const isMember = await pod.isMember(dummyAccount);
let data;
if (isMember) {
await pod.proposeBurnMember(dummyAccount, walletOne);
data = pod.populateBurn(dummyAccount);
} else {
await pod.proposeMintMember(dummyAccount, walletOne);
data = pod.populateMint(dummyAccount);
}

const proposal = (await pod.getProposals())[0];
const proposal = await pod.propose(data, walletOne.address)

// const [proposal] = await pod.getProposals();

await proposal.approve(walletOne);
await proposal.approve(walletTwo);
await proposal.executeApprove(walletTwo);

Expand Down
19 changes: 12 additions & 7 deletions scripts/approve-superproposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ async function main() {
const subPodTwo = await getPod(subPodTwoAddress);

if (
(await superPod.getProposals({ queued: true }))[0].status !== 'executed' ||
(await subPod.getProposals({ queued: true }))[0].status !== 'executed' ||
(await subPodTwo.getProposals({ queued: true }))[0].status !== 'executed'
(await superPod.getProposals({ status: 'queued' }))[0].status !== 'executed' ||
(await subPod.getProposals({ status: 'queued' }))[0].status !== 'executed' ||
(await subPodTwo.getProposals({ status: 'queued' }))[0].status !== 'executed'
) {
throw new Error(
'Admin or sub pod had an active/queued transaction. This script expects no enqueued transactions',
Expand All @@ -23,12 +23,14 @@ async function main() {
// We mint/burn the dummy account based on whether its a member or not.
const isMember = await superPod.isMember(dummyAccount);
console.log('Creating super proposal + sub proposal on subPod');
let data;
try {
if (isMember) {
await superPod.proposeBurnMemberFromSubPod(subPod, dummyAccount, walletOne);
data = superPod.populateBurn(dummyAccount);
} else {
await superPod.proposeMintMemberFromSubPod(subPod, dummyAccount, walletOne);
data = superPod.populateMint(dummyAccount);
}
await superPod.propose(data, subPod.safe);
} catch (err) {
console.log(err);
throw new Error('Error creating proposal on subpod');
Expand All @@ -42,15 +44,18 @@ async function main() {
[superProposal] = await superPod.getProposals();
}

console.log('Approving super proposal from sub pod two');
await superProposal.approveFromSubPod(subPodTwo, walletOne);
console.log('Approving super proposal from sub pods');
await subPod.propose(superProposal, walletOne.address);
await subPodTwo.propose(superProposal, walletOne.address);
await sleep(5000);

console.log('Executing both sub proposals');
const subProposal = (await subPod.getProposals())[0];
await subProposal.approve(walletOne)
await subProposal.executeApprove(walletOne);

const subProposalTwo = (await subPodTwo.getProposals())[0];
await subProposalTwo.approve(walletOne);
await subProposalTwo.executeApprove(walletOne);

console.log('Letting the blockchain + transaction service catch up');
Expand Down
15 changes: 7 additions & 8 deletions scripts/mint-from-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@ async function main() {
const adminPod = await getPod(adminPodAddress);
const subPod = await getPod(subPodAddress);

if ((await adminPod.getProposals({ queued: true }))[0].status !== 'executed') {
if ((await adminPod.getProposals({ status: 'queued' }))[0].status !== 'executed') {
throw new Error(
'Super pod had an active/queued transaction. This script expects no enqueued transactions',
);
}

console.log('subPod.admin', subPod.admin);

// We mint/burn the dummy account based on whether its a member or not.
const isMember = await subPod.isMember(dummyAccount);
let data;
if (isMember) {
await subPod.burnMemberFromAdminPod(adminPod, dummyAccount, walletOne);
data = subPod.populateBurn(dummyAccount);
} else {
await subPod.mintMemberFromAdminPod(adminPod, dummyAccount, walletOne);
data = subPod.populateMint(dummyAccount);
}

const proposal = (await adminPod.getProposals())[0];

const proposal = await adminPod.propose(data, walletOne.address);
await proposal.approve(walletOne);
await proposal.approve(walletTwo);
await proposal.executeApprove(walletTwo);
await proposal.executeApprove(walletOne);
}

main();
19 changes: 10 additions & 9 deletions scripts/reject-proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@ import { setup, sleep } from './utils';
async function main() {
const { walletOne, walletTwo } = setup();

const superPod = await getPod(adminPodAddress);
const pod = await getPod(adminPodAddress);

if ((await superPod.getProposals({ queued: true }))[0].status !== 'executed') {
if ((await pod.getProposals({ status: 'queued' }))[0].status !== 'executed') {
throw new Error(
'Super pod had an active/queued transaction. This script expects no enqueued transactions',
);
}

// We mint/burn the dummy account based on whether its a member or not.
const isMember = await superPod.isMember(dummyAccount);
const isMember = await pod.isMember(dummyAccount);
let data;
if (isMember) {
await superPod.proposeBurnMember(dummyAccount, walletOne);
data = pod.populateBurn(dummyAccount);
} else {
await superPod.proposeMintMember(dummyAccount, walletOne);
data = pod.populateMint(dummyAccount);
}

const proposal = (await superPod.getProposals())[0];
const proposal = await pod.propose(data, walletOne.address)

// await proposal.reject(walletOne);
// await proposal.reject(walletTwo);
await proposal.reject(walletOne);
await proposal.reject(walletTwo);
await proposal.executeReject(walletTwo);

// Let gnosis catch up.
await sleep(5000);

if (proposal.status !== 'executed') throw new Error('Proposal status not right');
const refetchProposal = (await superPod.getProposals())[0];
const refetchProposal = (await pod.getProposals())[0];
if (!refetchProposal.safeTransaction.isExecuted)
throw new Error('Proposal not executed according to gnosis');
}
Expand Down
38 changes: 16 additions & 22 deletions scripts/reject-superproposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ async function main() {
const subPodTwo = await getPod(subPodTwoAddress);

if (
(await superPod.getProposals({ queued: true }))[0].status !== 'executed' ||
(await subPod.getProposals({ queued: true }))[0].status !== 'executed' ||
(await subPodTwo.getProposals({ queued: true }))[0].status !== 'executed'
(await superPod.getProposals({ status: 'queued' }))[0].status !== 'executed' ||
(await subPod.getProposals({ status: 'queued' }))[0].status !== 'executed' ||
(await subPodTwo.getProposals({ status: 'queued' }))[0].status !== 'executed'
) {
throw new Error(
'Admin or sub pod had an active/queued transaction. This script expects no enqueued transactions',
Expand All @@ -23,44 +23,38 @@ async function main() {
// We mint/burn the dummy account based on whether its a member or not.
const isMember = await superPod.isMember(dummyAccount);
console.log('Creating super proposal');
let data;
try {
if (isMember) {
console.log('Burning');
await superPod.proposeBurnMemberFromSubPod(subPod, dummyAccount, walletOne);
data = superPod.populateBurn(dummyAccount);
} else {
console.log('Minting');
await superPod.proposeMintMemberFromSubPod(subPod, dummyAccount, walletOne);
data = superPod.populateMint(dummyAccount);
}
await superPod.propose(data, subPod.safe);
} catch (err) {
console.log(err);
throw new Error('Error creating proposal on subpod');
}

let [superProposal] = await superPod.getProposals();
console.log('superProposal', superProposal);

console.log('Rejecting the first sub proposal');
await superProposal.rejectFromSubPod(subPod, walletOne);
const [subProposal] = await subPod.getProposals();
console.log('Executing the sub proposal reject');
// This would approve the proposal, and then reject it
const subProposal = await subPod.propose(superProposal, await walletOne.getAddress());
await subProposal.reject(walletOne);
await subProposal.executeReject(walletOne);

console.log('Rejecting super proposal from subPodTwo');
[superProposal] = await superPod.getProposals();
await superProposal.rejectFromSubPod(subPod, walletTwo);

console.log('Creating the second sub reject');
await superProposal.rejectFromSubPod(subPodTwo, walletOne);
await sleep(5000);

console.log('Executing the second reject');
const [subProposalTwo] = await subPodTwo.getProposals();
console.log('subProposalTwo', subProposalTwo);
await subProposalTwo.executeReject(walletOne);
console.log('Rejecting the second sub proposal');
const subProposal2 = await subPodTwo.propose(superProposal, walletOne.address);
await subProposal2.reject(walletOne);
await subProposal2.executeReject(walletOne);

console.log('Letting tx service catch up...');
await sleep(40000);

[superProposal] = await superPod.getProposals();
console.log('superProposal', superProposal);
await superProposal.executeReject(walletOne);

console.log('Rejection seems to have worked, now waiting to refetch from Gnosis');
Expand Down
Loading

0 comments on commit d058fc9

Please sign in to comment.