Files
anonklub/pkgs/query/src/AnonymitySet/index.ts
sripwoud 94eac87e5c chore: replace prettier and eslint by biome (#422)
* chore: replace `prettier` and `eslint` by `biome` (#421)

* chore: replace `prettier` and `eslint` by `biome`

* chore: lint

* changeset
2024-03-30 22:15:54 +00:00

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}`)
}
}