Add AdminList among WL Query Types

This commit is contained in:
Serkan Reis 2023-03-18 11:34:23 +03:00
parent 2c2fc2efbe
commit 4d9ba5a76d
3 changed files with 21 additions and 2 deletions

View File

@ -24,6 +24,7 @@ export interface WhiteListInstance {
isActive: () => Promise<boolean> isActive: () => Promise<boolean>
members: (startAfter?: string, limit?: number) => Promise<string[]> members: (startAfter?: string, limit?: number) => Promise<string[]>
hasMember: (member: string) => Promise<boolean> hasMember: (member: string) => Promise<boolean>
adminList: () => Promise<string[]>
config: () => Promise<ConfigResponse> config: () => Promise<ConfigResponse>
//Execute //Execute
@ -149,6 +150,12 @@ export const WhiteList = (client: SigningCosmWasmClient, txSigner: string): Whit
}) })
} }
const adminList = async (): Promise<string[]> => {
return client.queryContractSmart(contractAddress, {
admin_list: {},
})
}
const config = async (): Promise<ConfigResponse> => { const config = async (): Promise<ConfigResponse> => {
return client.queryContractSmart(contractAddress, { return client.queryContractSmart(contractAddress, {
config: {}, config: {},
@ -233,6 +240,7 @@ export const WhiteList = (client: SigningCosmWasmClient, txSigner: string): Whit
isActive, isActive,
members, members,
hasMember, hasMember,
adminList,
config, config,
} }
} }

View File

@ -2,7 +2,15 @@ import type { WhiteListInstance } from '../contract'
export type QueryType = typeof QUERY_TYPES[number] export type QueryType = typeof QUERY_TYPES[number]
export const QUERY_TYPES = ['has_started', 'has_ended', 'is_active', 'members', 'has_member', 'config'] as const export const QUERY_TYPES = [
'has_started',
'has_ended',
'is_active',
'members',
'admin_list',
'has_member',
'config',
] as const
export interface QueryListItem { export interface QueryListItem {
id: QueryType id: QueryType
@ -15,6 +23,7 @@ export const QUERY_LIST: QueryListItem[] = [
{ id: 'has_ended', name: 'Has Ended', description: 'Check if the whitelist minting has ended' }, { id: 'has_ended', name: 'Has Ended', description: 'Check if the whitelist minting has ended' },
{ id: 'is_active', name: 'Is Active', description: 'Check if the whitelist minting is active' }, { id: 'is_active', name: 'Is Active', description: 'Check if the whitelist minting is active' },
{ id: 'members', name: 'Members', description: 'View the whitelist members' }, { id: 'members', name: 'Members', description: 'View the whitelist members' },
{ id: 'admin_list', name: 'Admin List', description: 'View the whitelist admin list' },
{ id: 'has_member', name: 'Has Member', description: 'Check if a member is in the whitelist' }, { id: 'has_member', name: 'Has Member', description: 'Check if a member is in the whitelist' },
{ id: 'config', name: 'Config', description: 'View the whitelist configuration' }, { id: 'config', name: 'Config', description: 'View the whitelist configuration' },
] ]
@ -36,6 +45,8 @@ export const dispatchQuery = (props: DispatchQueryProps) => {
return messages?.isActive() return messages?.isActive()
case 'members': case 'members':
return messages?.members() return messages?.members()
case 'admin_list':
return messages?.adminList()
case 'has_member': case 'has_member':
return messages?.hasMember(address) return messages?.hasMember(address)
case 'config': case 'config':

View File

@ -108,7 +108,7 @@ const WhitelistQueryPage: NextPage = () => {
onChange={(e) => setType(e.target.value as QueryType)} onChange={(e) => setType(e.target.value as QueryType)}
> >
{QUERY_LIST.map(({ id, name }) => ( {QUERY_LIST.map(({ id, name }) => (
<option key={`query-${id}`} value={id}> <option key={`query-${id}`} className="mt-2 text-lg bg-[#1A1A1A]" value={id}>
{name} {name}
</option> </option>
))} ))}