mirror of
https://github.com/anonklub/anonklub.git
synced 2026-01-09 18:07:55 -05:00
* chore: replace `prettier` and `eslint` by `biome` (#421) * chore: replace `prettier` and `eslint` by `biome` * chore: lint * changeset
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { URLS } from '../CONSTANTS'
|
|
import { fetchJson } from '../fetch-json'
|
|
import type {
|
|
EnsProposalVotersRequest,
|
|
Erc20BalanceAnonSetRequest,
|
|
EthBalanceAnonSetRequest,
|
|
} from '../requests'
|
|
import {
|
|
Endpoint,
|
|
Environment,
|
|
type Request,
|
|
type RequestClass,
|
|
} from '../types'
|
|
import type { AnonymitySetI } from './interface'
|
|
|
|
export class AnonymitySet implements AnonymitySetI {
|
|
constructor(public env = Environment.PRODUCTION) {}
|
|
|
|
fromBeaconDepositors = this._fetchWithoutParams(Endpoint.BeaconDepositors)
|
|
|
|
fromCryptoPunkOwners = this._fetchWithoutParams(Endpoint.CryptoPunks)
|
|
|
|
fromErc20Balance = this._fetchWithParams<Erc20BalanceAnonSetRequest>(
|
|
Endpoint.Erc20Balance,
|
|
)
|
|
|
|
fromEthBalance = this._fetchWithParams<EthBalanceAnonSetRequest>(
|
|
Endpoint.EthBalance,
|
|
)
|
|
|
|
fromEnsProposalVoters = this._fetchWithParams<EnsProposalVotersRequest>(
|
|
Endpoint.EnsProposalVoters,
|
|
)
|
|
|
|
private _fetchWithParams<T extends RequestClass>(endpoint: Endpoint) {
|
|
return async (params: Request<T>) =>
|
|
await fetchJson(`${URLS[this.env]}/${endpoint}`, params)
|
|
}
|
|
|
|
private _fetchWithoutParams(endpoint: Endpoint) {
|
|
return async () => await fetchJson(`${URLS[this.env]}/${endpoint}`)
|
|
}
|
|
}
|