Skip to content

Commit a234b78

Browse files
dankelleherchriteixeirandrabinsmitchcivic
authored
Feature/qv milestone 3 (#2204)
Co-authored-by: Christiano <[email protected]> Co-authored-by: dawggydawg <[email protected]> Co-authored-by: Noah Drabinsky <[email protected]> Co-authored-by: mitchcivic <[email protected]>
1 parent dc516b2 commit a234b78

File tree

196 files changed

+5502
-3460
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+5502
-3460
lines changed

.github/workflows/ci-main-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
- name: Setup Node
7272
uses: actions/setup-node@v4
7373
with:
74-
node-version: 18
74+
node-version: 20
7575
cache: yarn
7676

7777
- name: Cache dependencies

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.19.0
1+
lts/iron

@types/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ export interface EndpointInfo {
44
name: EndpointTypes
55
url: string
66
}
7+
8+
export type GovernanceRole = 'council' | 'community';

GatewayPlugin/config.ts

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
// A list of "passes" offered by Civic to verify or gate access to a DAO.
2-
export const availablePasses = [
3-
{
4-
name: 'Uniqueness',
5-
value: 'uniqobk8oGh4XBLMqM68K8M2zNu3CdYX7q5go7whQiv',
6-
description: 'A biometric proof of personhood, preventing Sybil attacks while retaining privacy'
7-
},
8-
{
9-
name: 'ID Verification',
10-
value: 'bni1ewus6aMxTxBi5SAfzEmmXLf8KcVFRmTfproJuKw',
11-
description: 'A KYC process for your DAO, allowing users to prove their identity by presenting a government-issued ID'
12-
},
13-
{
14-
name: 'Bot Resistance',
15-
value: 'ignREusXmGrscGNUesoU9mxfds9AiYTezUKex2PsZV6',
16-
description: 'A simple CAPTCHA to prevent bots from spamming your DAO'
17-
},
18-
{
19-
name: 'Other',
20-
value: '',
21-
description: 'Set up your own custom verification (contact Civic.com for options)'
22-
},
23-
] as const;
2+
export const availablePasses: {
3+
name: string
4+
value: string
5+
description: string
6+
isSybilResistance: boolean
7+
}[] = [
8+
// Default
9+
{
10+
name: 'Uniqueness',
11+
value: 'uniqobk8oGh4XBLMqM68K8M2zNu3CdYX7q5go7whQiv',
12+
description:
13+
'A biometric proof of personhood, preventing Sybil attacks while retaining privacy',
14+
isSybilResistance: true,
15+
},
16+
{
17+
name: 'ID Verification',
18+
value: 'bni1ewus6aMxTxBi5SAfzEmmXLf8KcVFRmTfproJuKw',
19+
description:
20+
'A KYC process for your DAO, allowing users to prove their identity by presenting a government-issued ID',
21+
isSybilResistance: false,
22+
},
23+
{
24+
name: 'Bot Resistance',
25+
value: 'ignREusXmGrscGNUesoU9mxfds9AiYTezUKex2PsZV6',
26+
description: 'A simple CAPTCHA to prevent bots from spamming your DAO',
27+
isSybilResistance: false,
28+
},
29+
{
30+
name: 'Other',
31+
value: '',
32+
description:
33+
'Set up your own custom verification (contact Civic.com for options)',
34+
isSybilResistance: false,
35+
},
36+
]
37+
38+
// Infer the types from the available passes, giving type safety on the `other` and `default` pass types
39+
type ArrayElement<
40+
ArrayType extends readonly unknown[]
41+
> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never
42+
export type CivicPass = ArrayElement<typeof availablePasses>
43+
44+
// Use this when populating a dropdown
45+
export const defaultPass: CivicPass = availablePasses[0]
46+
// Use this in cases where you are implicitly adding sybil resistance to a DAO (e.g. QV DAO creation), rather than
47+
// offering a choice - this allows defaultPass to be something *other than* sybil resistance without breaking things.
48+
export const defaultSybilResistancePass = availablePasses[0]

GatewayPlugin/sdk/accounts.tsx

Lines changed: 0 additions & 124 deletions
This file was deleted.

GatewayPlugin/sdk/api.ts

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,65 @@
1-
import { PublicKey } from '@solana/web3.js'
2-
import { GatewayClient } from '@solana/governance-program-library'
1+
import {PublicKey} from '@solana/web3.js'
2+
import {GatewayClient} from '@solana/governance-program-library'
3+
import {ProgramAccount, Realm, SYSTEM_PROGRAM_ID} from "@solana/spl-governance";
4+
import {getRegistrarPDA} from "@utils/plugin/accounts";
35

4-
export const tryGetGatewayRegistrar = async (
5-
registrarPk: PublicKey,
6-
client: GatewayClient
6+
7+
// Create an instruction to create a registrar account for a given realm
8+
export const createCivicRegistrarIx = async (
9+
realm: ProgramAccount<Realm>,
10+
payer: PublicKey,
11+
gatewayClient: GatewayClient,
12+
gatekeeperNetwork: PublicKey,
13+
predecessor?: PublicKey
714
) => {
8-
try {
9-
const existingRegistrar = await client.program.account.registrar.fetch(
10-
registrarPk
11-
)
12-
return existingRegistrar
13-
} catch (e) {
14-
return null
15-
}
15+
const {registrar} = getRegistrarPDA(
16+
realm.pubkey,
17+
realm.account.communityMint,
18+
gatewayClient.program.programId
19+
)
20+
21+
const remainingAccounts = predecessor
22+
? [{pubkey: predecessor, isSigner: false, isWritable: false}]
23+
: []
24+
25+
return gatewayClient!.program.methods
26+
.createRegistrar(!!predecessor)
27+
.accounts({
28+
registrar,
29+
realm: realm.pubkey,
30+
governanceProgramId: realm.owner,
31+
realmAuthority: realm.account.authority!,
32+
governingTokenMint: realm.account.communityMint!,
33+
gatekeeperNetwork,
34+
payer,
35+
systemProgram: SYSTEM_PROGRAM_ID,
36+
})
37+
.remainingAccounts(remainingAccounts)
38+
.instruction()
1639
}
40+
// Create an instruction to configure a registrar account for a given realm
41+
export const configureCivicRegistrarIx = async (
42+
realm: ProgramAccount<Realm>,
43+
gatewayClient: GatewayClient,
44+
gatekeeperNetwork: PublicKey,
45+
predecessor?: PublicKey
46+
) => {
47+
const {registrar} = getRegistrarPDA(
48+
realm.pubkey,
49+
realm.account.communityMint,
50+
gatewayClient.program.programId
51+
)
52+
const remainingAccounts = predecessor
53+
? [{pubkey: predecessor, isSigner: false, isWritable: false}]
54+
: []
55+
return gatewayClient.program.methods
56+
.configureRegistrar(false)
57+
.accounts({
58+
registrar,
59+
realm: realm.pubkey,
60+
realmAuthority: realm.account.authority!,
61+
gatekeeperNetwork: gatekeeperNetwork,
62+
})
63+
.remainingAccounts(remainingAccounts)
64+
.instruction()
65+
}

GatewayPlugin/store/gatewayPluginStore.ts

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)