Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use NetworkAddress #60

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/@api/base.api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { environment } from '@env/environment';
import {
EthAddress,
NetworkAddress,
PublicCollections,
BUILD5_PROD_ADDRESS_API,
BUILD5_TEST_ADDRESS_API,
Expand Down Expand Up @@ -29,7 +29,7 @@ export class BaseApi<T> {

public listen = (id: string) => this.repo.getByIdLive(id);

public listenMultiple = (ids: EthAddress[]) =>
public listenMultiple = (ids: NetworkAddress[]) =>
ids.length ? this.repo.getManyByIdLive(ids) : of([]);

public top = (lastValue?: string, limit?: number) => this.repo.getTopLive(lastValue, limit);
Expand Down
25 changes: 14 additions & 11 deletions src/app/@api/member.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '@env/environment';
import {
EthAddress,
NetworkAddress,
Member,
Proposal,
PublicCollections,
Expand Down Expand Up @@ -74,7 +74,7 @@ export class MemberApi extends BaseApi<Member> {
super(PublicCollections.MEMBER, httpClient);
}

public soonDistributionStats = (id: EthAddress) => {
public soonDistributionStats = (id: NetworkAddress) => {
const tokenId = environment.production ? SOON_TOKEN : SOON_TOKEN_TEST;
return this.tokenDistRepo.getByIdLive(tokenId, id.toLowerCase()).pipe(
switchMap(async (distribution) => {
Expand All @@ -90,7 +90,7 @@ export class MemberApi extends BaseApi<Member> {
) as Observable<TokenDistributionWithAirdrops | undefined>;
};

public listenMultiple = (ids: EthAddress[]) =>
public listenMultiple = (ids: NetworkAddress[]) =>
ids.length
? this.memberRepo
.getByFieldLive(
Expand All @@ -105,7 +105,10 @@ export class MemberApi extends BaseApi<Member> {
)
: of([]);

public topStakes = (memberId: EthAddress, lastValue?: string): Observable<StakeWithTokenRec[]> =>
public topStakes = (
memberId: NetworkAddress,
lastValue?: string,
): Observable<StakeWithTokenRec[]> =>
this.stakeRepo.getByMemberLive(memberId, lastValue).pipe(
switchMap(async (stakes: Stake[]) => {
const tokenIds = Array.from(new Set(stakes.map((s) => s.token)));
Expand All @@ -119,7 +122,7 @@ export class MemberApi extends BaseApi<Member> {
}),
);

public topTokens = (memberId: EthAddress): Observable<TokenWithMemberDistribution[]> =>
public topTokens = (memberId: NetworkAddress): Observable<TokenWithMemberDistribution[]> =>
this.tokenDistRepo.getTopBySubColIdLive(memberId, [], []).pipe(
switchMap(async (distributions) => {
const promises = distributions.map(async (distribution) => {
Expand All @@ -138,28 +141,28 @@ export class MemberApi extends BaseApi<Member> {
);

public topSpaces = (
memberId: EthAddress,
memberId: NetworkAddress,
orderBy = ['createdOn'],
orderByDir = ['desc'],
lastValue?: string,
limit?: number,
) => this.spaceRepo.getTopByMember(memberId, orderBy, orderByDir, lastValue, limit);

public pendingSpaces = (
memberId: EthAddress,
memberId: NetworkAddress,
orderBy = ['createdOn'],
orderByDir = ['desc'],
lastValue?: string,
) => this.spaceRepo.getPendingSpacesByMemberLive(memberId, orderBy, orderByDir, lastValue);

public topAwardsPending = (memberId: EthAddress, lastValue?: string) =>
public topAwardsPending = (memberId: NetworkAddress, lastValue?: string) =>
this.awardRepo.getTopByMemberLive(memberId, false, lastValue);

public topAwardsCompleted = (memberId: EthAddress, lastValue?: string) =>
public topAwardsCompleted = (memberId: NetworkAddress, lastValue?: string) =>
this.awardRepo.getTopByMemberLive(memberId, true, lastValue);

public topProposals = (
memberId: EthAddress,
memberId: NetworkAddress,
orderBy = ['createdOn'],
orderByDir = ['desc'],
lastValue?: string,
Expand Down Expand Up @@ -211,7 +214,7 @@ export class MemberApi extends BaseApi<Member> {
);
}

public allSpacesAsMember = (memberId: EthAddress, lastValue?: string) =>
public allSpacesAsMember = (memberId: NetworkAddress, lastValue?: string) =>
this.spaceMemberRepo.getTopBySubColIdLive(memberId, [], [], lastValue).pipe(
switchMap(async (spaceMembers) => {
const spacePromises = spaceMembers.map(
Expand Down
4 changes: 2 additions & 2 deletions src/app/@api/order.api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import {
EthAddress,
NetworkAddress,
PublicCollections,
Transaction,
WEN_FUNC,
Expand Down Expand Up @@ -33,7 +33,7 @@ export class OrderApi extends BaseApi<Transaction> {
public openBid = (req: WenRequest): Observable<Transaction | undefined> =>
this.request(WEN_FUNC.openBid, req);

public listenMultiple = (ids: EthAddress[]) =>
public listenMultiple = (ids: NetworkAddress[]) =>
ids.length
? this.transactionRepo.getByFieldLive(
ids.map(() => 'uid'),
Expand Down
4 changes: 2 additions & 2 deletions src/app/@api/proposal.api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import {
EthAddress,
NetworkAddress,
Member,
Proposal,
PublicCollections,
Expand Down Expand Up @@ -53,7 +53,7 @@ export class ProposalApi extends BaseApi<Proposal> {
super(PublicCollections.PROPOSAL, httpClient);
}

public listen = (id: EthAddress) => this.proposalRepo.getByIdLive(id);
public listen = (id: NetworkAddress) => this.proposalRepo.getByIdLive(id);

public lastActive = (lastValue?: string) => this.proposalRepo.getActiveLive(lastValue);

Expand Down
4 changes: 2 additions & 2 deletions src/app/components/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { undefinedToEmpty } from '@core/utils/manipulations.utils';
import { ROUTER_UTILS } from '@core/utils/router.utils';
import detectEthereumProvider from '@metamask/detect-provider';
import {
EthAddress,
NetworkAddress,
Member,
Network,
StakeType,
Expand Down Expand Up @@ -412,7 +412,7 @@ export class AuthService {
}
}

public monitorMember(address: EthAddress): void {
public monitorMember(address: NetworkAddress): void {
this.memberSubscription$ = this.memberApi.listen(address).subscribe((v) => {
this.member$.next(v);
});
Expand Down