-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from orcaprotocol/willkim/test-scripts
fix: update super/sub proposal logic, add test scripts
- Loading branch information
Showing
20 changed files
with
922 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ test | |
dist | ||
jest.config.ts | ||
docs | ||
scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
.nvmrc | ||
dist | ||
env.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"accountOne": "0xf0C7d25c942264D6F21871c05d3dB3b98344b499", | ||
"accountOnePrivateKey": "", | ||
"accountTwo": "0xA56b297065D814988080b8E765D953651059539c", | ||
"accountTwoPrivateKey": "", | ||
"dummyAccount": "0x1cC62cE7cb56ed99513823064295761f9b7C856e", | ||
"adminPodAddress": "0xBe71ECaA104645ab78ed62A52763b2854e6DaD2E", | ||
"subPodAddress": "0x4d3ba1AdabA15796CC3d11E48e8EC28e3A5F7C41" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { getPod } from '../src'; | ||
import { adminPodAddress, dummyAccount } from '../env.json'; | ||
import { setup, sleep } from './utils'; | ||
|
||
async function main() { | ||
const { walletOne, walletTwo } = setup(); | ||
|
||
// Get the pod we're working with | ||
|
||
const pod = await getPod(adminPodAddress); | ||
|
||
if ((await pod.getProposals({ queued: true }))[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); | ||
if (isMember) { | ||
await pod.proposeBurnMember(dummyAccount, walletOne); | ||
} else { | ||
await pod.proposeMintMember(dummyAccount, walletOne); | ||
} | ||
|
||
const proposal = (await pod.getProposals())[0]; | ||
|
||
await proposal.approve(walletTwo); | ||
await proposal.executeApprove(walletTwo); | ||
|
||
// Let gnosis catch up. | ||
await sleep(5000); | ||
|
||
if (proposal.status !== 'executed') throw new Error('Proposal status not right'); | ||
const refetchProposal = (await pod.getProposals())[0]; | ||
if (!refetchProposal.safeTransaction.isExecuted) | ||
throw new Error('Proposal not executed according to gnosis'); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* eslint-disable no-console */ | ||
import { getPod } from '../src'; | ||
import { adminPodAddress, dummyAccount, subPodAddress, subPodTwoAddress } from '../env.json'; | ||
import { setup, sleep } from './utils'; | ||
|
||
async function main() { | ||
const { walletOne, walletTwo } = setup(); | ||
|
||
const superPod = await getPod(adminPodAddress); | ||
const subPod = await getPod(subPodAddress); | ||
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' | ||
) { | ||
throw new Error( | ||
'Admin or sub 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); | ||
console.log('Creating super proposal + sub proposal on subPod'); | ||
try { | ||
if (isMember) { | ||
await superPod.proposeBurnMemberFromPod(subPod, dummyAccount, walletOne); | ||
} else { | ||
await superPod.proposeMintMemberFromPod(subPod, dummyAccount, walletOne); | ||
} | ||
} catch (err) { | ||
console.log(err); | ||
throw new Error('Error creating proposal on subpod'); | ||
} | ||
|
||
await sleep(5000); | ||
|
||
let [superProposal] = await superPod.getProposals(); | ||
if (superProposal.status !== 'active') { | ||
await sleep(5000); | ||
[superProposal] = await superPod.getProposals(); | ||
} | ||
|
||
console.log('Approving super proposal from sub pod two'); | ||
await superProposal.approveFromSubPod(subPodTwo, walletOne); | ||
await sleep(5000); | ||
|
||
console.log('Executing both sub proposals'); | ||
const subProposal = (await subPod.getProposals())[0]; | ||
await subProposal.executeApprove(walletOne); | ||
|
||
const subProposalTwo = (await subPodTwo.getProposals())[0]; | ||
await subProposalTwo.executeApprove(walletOne); | ||
|
||
console.log('Letting the blockchain + transaction service catch up'); | ||
await sleep(40000); | ||
|
||
console.log('Approving + executing superproposal'); | ||
[superProposal] = await superPod.getProposals(); | ||
await superProposal.executeApprove(walletOne); | ||
|
||
console.log('We did it! 🎉'); | ||
console.log('At least I think so. Check the pod page to be sure lol'); | ||
} | ||
|
||
main(); |
Oops, something went wrong.