groups.ts 1.0 KB

1234567891011121314151617181920
  1. import { ApplicationOf, OpeningOf } from "@joystream/types/augment-codec/all";
  2. import { Application, ApplicationId, Opening, OpeningId } from "@joystream/types/hiring";
  3. import { ApiPromise } from "@polkadot/api";
  4. import { Hash } from "@polkadot/types/interfaces";
  5. export const getOpening = async (api: ApiPromise, group: string, hash: Hash, openingId: OpeningId): Promise<OpeningOf> => {
  6. return api.query[group].openingById.at(hash, openingId)
  7. }
  8. export const getHiringOpening = async (api: ApiPromise, hash: Hash, openingId: OpeningId): Promise<Opening> => {
  9. return (await api.query.hiring.openingById.at(hash, openingId))
  10. }
  11. export const getApplication = async (api: ApiPromise, group: string, hash: Hash, applicationId: ApplicationId): Promise<ApplicationOf> => {
  12. return api.query[group].applicationById.at(hash, applicationId)
  13. }
  14. export const getHiringApplication = async (api: ApiPromise, group: string, hash: Hash, applicationId: ApplicationId): Promise<Application> => {
  15. return api.query.hiring.applicationById.at(hash, applicationId)
  16. }