Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Oct 4, 2024
1 parent 1cfffdd commit 9e569c6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
12 changes: 5 additions & 7 deletions frontend/src/components/ACLs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type StatusUpdater = (status: string | undefined) => void
/**
* This data structure describes an ACL
*/
export type ACL<Name, ConfigInputValues, Options extends AclOptions, Extra> = Choice<Name> & {
export type ACL<Name, ConfigInputValues, Options extends AclOptions> = Choice<Name> & {
/**
* Estimated cost per vote
*
Expand Down Expand Up @@ -56,13 +56,11 @@ export type ACL<Name, ConfigInputValues, Options extends AclOptions, Extra> = Ch
proposalId: string,
userAddress: string,
options: Options,
) => Promise<
{ canVote: DecisionWithReason; explanation?: ReactNode; proof: BytesLike; error?: string } & Extra
>
) => Promise<{ canVote: DecisionWithReason; explanation?: ReactNode; proof: BytesLike; error?: string }>
}

export function defineACL<Name, ConfigInputValues, Options extends AclOptions, Extra>(
acl: ACL<Name, ConfigInputValues, Options, Extra>,
): ACL<Name, ConfigInputValues, Options, Extra> {
export function defineACL<Name, ConfigInputValues, Options extends AclOptions>(
acl: ACL<Name, ConfigInputValues, Options>,
): ACL<Name, ConfigInputValues, Options> {
return acl
}
16 changes: 7 additions & 9 deletions frontend/src/components/ACLs/xchain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,17 @@ export const xchain = defineACL({
isThisMine: options => 'xchain' in options,

checkPermission: async (pollACL, daoAddress, proposalId, userAddress, options) => {
const xChainOptions = options
const { xchain } = options
const chainId = xchain.c
const blockHash = hexlify(xchain.b)
const tokenAddress = hexlify(xchain.a)
const slot = xchain.s

let explanation: ReactNode = ''
let error = ''
let proof: BytesLike = ''
let tokenInfo: TokenInfo | NFTInfo | undefined
let canVote: DecisionWithReason = true
const {
xchain: { c: chainId, s: slot },
} = xChainOptions
const tokenAddress = hexlify(xChainOptions.xchain.a)
const blockHash = hexlify(xChainOptions.xchain.b)
const provider = xchainRPC(chainId)
const chainDefinition = getChainDefinition(chainId)

Expand All @@ -343,8 +343,6 @@ export const xchain = defineACL({
explanation: 'This poll is invalid, since it references and unknown chain.',
error,
proof,
tokenInfo,
xChainOptions,
}
}

Expand Down Expand Up @@ -408,6 +406,6 @@ export const xchain = defineACL({
console.error('proof:', proof)
canVote = denyWithReason(`there was a technical problem verifying your permissions`)
}
return { canVote, explanation, error, proof, tokenInfo, xChainOptions }
return { canVote, explanation, error, proof }
},
} as const)
4 changes: 0 additions & 4 deletions frontend/src/hooks/usePollPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const blackPermissions: PollPermissions = {
proof: '',
explanation: undefined,
canVote: denyWithReason(NOT_CHECKED),
tokenInfo: undefined,
xChainOptions: undefined,
canManage: false,
error: '',
}
Expand Down Expand Up @@ -49,8 +47,6 @@ export const usePollPermissions = (poll: ExtendedPoll | undefined, onDashboard:
proof: '',
explanation: '',
canVote: true,
tokenInfo: undefined,
xChainOptions: undefined,
canManage: false,
error: '',
})
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/utils/poll.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
guessStorageSlot,
getNftContractType,
ChainDefinition,
AclOptionsXchain,
IPollACL__factory,
TokenInfo,
NFTInfo,
Expand Down Expand Up @@ -286,8 +285,6 @@ export type PollPermissions = {
explanation: ReactNode
canVote: DecisionWithReason
canManage: boolean
tokenInfo?: TokenInfo | NFTInfo | undefined
xChainOptions?: AclOptionsXchain | undefined
error: string
}

Expand Down Expand Up @@ -322,8 +319,6 @@ export const checkPollPermission = async (
canVote: denyWithReason(
'this poll has some unknown access control settings. (Poll created by newer version of software?)',
),
tokenInfo: undefined,
xChainOptions: undefined,
error: '',
canManage,
}
Expand Down

0 comments on commit 9e569c6

Please sign in to comment.