Skip to content

Commit

Permalink
Define ACL address as a simple field
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Oct 3, 2024
1 parent a453a12 commit 1cfffdd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions frontend/src/components/ACLs/allowAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { denyWithReason, useOneOfField } from '../InputFields'

export const allowAll = defineACL({
value: 'acl_allowAll',
address: VITE_CONTRACT_ACL_ALLOWALL,
label: 'Everybody',
costEstimation: 0.1,
useConfiguration: active => {
Expand All @@ -26,8 +27,6 @@ export const allowAll = defineACL({
}
},

getAclAddress: () => VITE_CONTRACT_ACL_ALLOWALL,

getAclOptions: () => ({
data: '0x', // Empty bytes is passed
options: { allowAll: true },
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/ACLs/allowList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const splitAddresses = (addressSoup: string): string[] =>

export const allowList = defineACL({
value: 'acl_allowList',
address: VITE_CONTRACT_ACL_VOTERALLOWLIST,
label: 'Address Whitelist',
costEstimation: 0.1,
description: 'You can specify a list of addresses that are allowed to vote.',
Expand Down Expand Up @@ -68,8 +69,6 @@ export const allowList = defineACL({
}
},

getAclAddress: () => VITE_CONTRACT_ACL_VOTERALLOWLIST,

getAclOptions: props => {
if (!props.addresses) throw new Error('Internal errors: parameter mismatch, addresses missing.')
return {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/ACLs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export type ACL<Name, ConfigInputValues, Options extends AclOptions, Extra> = Ch
*/
useConfiguration: (selected: boolean) => { fields: FieldConfiguration; values: ConfigInputValues }

getAclAddress: () => string
/**
* The address of the ACL contract to use
*/
address: string

/**
* Compose the ACL options when creating a poll
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/ACLs/tokenHolder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FLAG_WEIGHT_LOG10, FLAG_WEIGHT_ONE } from '../../types'

export const tokenHolder = defineACL({
value: 'acl_tokenHolder',
address: VITE_CONTRACT_ACL_TOKENHOLDER,
costEstimation: 0.2,
label: `Active Token or NFT balance on ${configuredNetworkName}`,
description:
Expand Down Expand Up @@ -111,8 +112,6 @@ export const tokenHolder = defineACL({
}
},

getAclAddress: () => VITE_CONTRACT_ACL_TOKENHOLDER,

getAclOptions: props => {
if (!props.tokenAddress) throw new Error('Internal errors: parameter mismatch, addresses missing.')
return {
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/components/ACLs/xchain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { FLAG_WEIGHT_LOG10, FLAG_WEIGHT_ONE } from '../../types'

export const xchain = defineACL({
value: 'acl_xchain',
address: VITE_CONTRACT_ACL_STORAGEPROOF,
label: 'Token Snapshot voting',
costEstimation: 0.2,
description: 'take a snapshot of token or NFT balances from another chain',
Expand Down Expand Up @@ -290,8 +291,6 @@ export const xchain = defineACL({
}
},

getAclAddress: () => VITE_CONTRACT_ACL_STORAGEPROOF,

getAclOptions: async ({ chainId, contractAddress, slotNumber, blockHash, flags }, updateStatus) => {
const showStatus = updateStatus ?? ((message?: string | undefined) => console.log(message))
const rpc = xchainRPC(chainId)
Expand Down Expand Up @@ -333,8 +332,8 @@ export const xchain = defineACL({
const {
xchain: { c: chainId, s: slot },
} = xChainOptions
const tokenAddress = hexlify(xChainOptions.xchain.a);
const blockHash = hexlify(xChainOptions.xchain.b);
const tokenAddress = hexlify(xChainOptions.xchain.a)
const blockHash = hexlify(xChainOptions.xchain.b)
const provider = xchainRPC(chainId)
const chainDefinition = getChainDefinition(chainId)

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/CreatePollPage/useCreatePollForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export const useCreatePollForm = () => {
description: description.value,
answers: answers.value,
isHidden: hidden.value,
aclAddress: currentAcl.getAclAddress(),
aclAddress: currentAcl.address,
aclData,
aclOptions,
pollFlags,
Expand Down

0 comments on commit 1cfffdd

Please sign in to comment.