Support BDFL orgs

This commit is contained in:
Alexis Sellier
2021-05-12 14:10:34 +02:00
parent b949197210
commit 729bfb4b65
3 changed files with 36 additions and 8 deletions
+17 -6
View File
@@ -18,22 +18,30 @@
Success,
}
enum Governance {
BDFL = "bdfl",
Quorum = "quorum",
}
const orgTypes = [
{ label: "Single signer", value: "bdfl" },
{ label: "Quorum", value: "dao" },
{ label: "Single signer", value: Governance.BDFL },
{ label: "Quorum", value: Governance.Quorum },
];
let state = State.Idle;
let error: Err | null = null;
let org: Org | null = null;
let governance: string = "bdfl";
let governance = Governance.BDFL;
const dispatch = createEventDispatcher();
const createOrg = async () => {
state = State.Signing;
try {
let tx = await Org.create(owner, config);
let tx = governance === Governance.Quorum
? await Org.createMultiSig([owner], 1, config)
: await Org.create(owner, config);
state = State.Pending;
let receipt = await tx.wait();
@@ -48,7 +56,10 @@
};
const onGovernanceChanged = (event: { detail: string }) => {
governance = event.detail;
switch (event.detail) {
case "bdfl": governance = Governance.BDFL; break;
case "quorum": governance = Governance.Quorum; break;
}
};
</script>
@@ -90,7 +101,7 @@
{:else if state === State.Signing}
<div class="highlight">Confirm transaction in your wallet</div>
{:else if state === State.Pending}
<div class="highlight">Waiting for transaction to be processed</div>
<div class="highlight">Waiting for transaction to be processed...</div>
{/if}
</span>
+18 -1
View File
@@ -6,6 +6,7 @@ import { assert } from '@app/error';
import type { Config } from '@app/config';
const orgFactoryAbi = [
"function createOrg(address) returns (address)",
"function createOrg(address[], uint256) returns (address)",
"event OrgCreated(address, address)",
];
@@ -59,6 +60,22 @@ export class Org {
}
}
static async createMultiSig(
owners: [string],
threshold: number,
config: Config,
): Promise<TransactionResponse> {
const orgFactory = new ethers.Contract(
config.orgFactory.address,
orgFactoryAbi,
config.signer
);
return orgFactory['createOrg(address[],uint256)'](owners, threshold, {
gasLimit: config.gasLimits.createOrg
});
}
static async create(
owner: string,
config: Config,
@@ -69,7 +86,7 @@ export class Org {
config.signer
);
return orgFactory.createOrg([owner], 1, {
return orgFactory['createOrg(address)'](owner, {
gasLimit: config.gasLimits.createOrg
});
}
+1 -1
View File
@@ -20,7 +20,7 @@
"address": "0x59b5eee36f5fa52400A136Fd4630Ee2bF126a4C0"
},
"orgFactory": {
"address": "0x2007bcEf1247CD03Bb4262eF420D6487368f473B"
"address": "0xe1814B14430CF14f0950A29FF26217115B815676"
}
}
}