diff --git a/src/app/@api/base.api.ts b/src/app/@api/base.api.ts index 0ce1d21..eac516f 100644 --- a/src/app/@api/base.api.ts +++ b/src/app/@api/base.api.ts @@ -1,14 +1,14 @@ import { HttpClient } from '@angular/common/http'; import { environment } from '@env/environment'; import { - EthAddress, + NetworkAddress, PublicCollections, BUILD5_PROD_ADDRESS_API, BUILD5_TEST_ADDRESS_API, WEN_FUNC, + WenRequest, } from '@build-5/interfaces'; -import { Build5Env } from '@build-5/lib'; -import { CrudRepository } from '@build-5/lib/lib/repositories/CrudRepository'; +import { Build5Env, CrudRepository } from '@build-5/lib'; import { Observable, map, of } from 'rxjs'; export const DEFAULT_LIST_SIZE = 50; @@ -29,12 +29,12 @@ export class BaseApi { 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); - protected request(func: WEN_FUNC, req: any): Observable { + protected request(func: WEN_FUNC, req: WenRequest): Observable { const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API; return this.httpClient.post(origin + func, { data: req }).pipe(map((b: any) => b.data)); } diff --git a/src/app/@api/member.api.ts b/src/app/@api/member.api.ts index 1ae8a95..321f032 100644 --- a/src/app/@api/member.api.ts +++ b/src/app/@api/member.api.ts @@ -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, @@ -74,7 +74,7 @@ export class MemberApi extends BaseApi { 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) => { @@ -90,7 +90,7 @@ export class MemberApi extends BaseApi { ) as Observable; }; - public listenMultiple = (ids: EthAddress[]) => + public listenMultiple = (ids: NetworkAddress[]) => ids.length ? this.memberRepo .getByFieldLive( @@ -105,7 +105,10 @@ export class MemberApi extends BaseApi { ) : of([]); - public topStakes = (memberId: EthAddress, lastValue?: string): Observable => + public topStakes = ( + memberId: NetworkAddress, + lastValue?: string, + ): Observable => this.stakeRepo.getByMemberLive(memberId, lastValue).pipe( switchMap(async (stakes: Stake[]) => { const tokenIds = Array.from(new Set(stakes.map((s) => s.token))); @@ -119,7 +122,7 @@ export class MemberApi extends BaseApi { }), ); - public topTokens = (memberId: EthAddress): Observable => + public topTokens = (memberId: NetworkAddress): Observable => this.tokenDistRepo.getTopBySubColIdLive(memberId, [], []).pipe( switchMap(async (distributions) => { const promises = distributions.map(async (distribution) => { @@ -138,7 +141,7 @@ export class MemberApi extends BaseApi { ); public topSpaces = ( - memberId: EthAddress, + memberId: NetworkAddress, orderBy = ['createdOn'], orderByDir = ['desc'], lastValue?: string, @@ -146,20 +149,20 @@ export class MemberApi extends BaseApi { ) => 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, @@ -211,7 +214,7 @@ export class MemberApi extends BaseApi { ); } - 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( @@ -222,7 +225,11 @@ export class MemberApi extends BaseApi { ); public createIfNotExists = (address: string): Observable => - this.request(WEN_FUNC.createMember, address); + this.request(WEN_FUNC.createMember, { + address: '', + projectApiKey: environment.build5Token, + body: address, + }); public updateMember = (req: WenRequest): Observable => this.request(WEN_FUNC.updateMember, req); diff --git a/src/app/@api/order.api.ts b/src/app/@api/order.api.ts index a868e7e..7f4c912 100644 --- a/src/app/@api/order.api.ts +++ b/src/app/@api/order.api.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { - EthAddress, + NetworkAddress, PublicCollections, Transaction, WEN_FUNC, @@ -33,7 +33,7 @@ export class OrderApi extends BaseApi { public openBid = (req: WenRequest): Observable => this.request(WEN_FUNC.openBid, req); - public listenMultiple = (ids: EthAddress[]) => + public listenMultiple = (ids: NetworkAddress[]) => ids.length ? this.transactionRepo.getByFieldLive( ids.map(() => 'uid'), diff --git a/src/app/@api/proposal.api.ts b/src/app/@api/proposal.api.ts index 4410754..752002a 100644 --- a/src/app/@api/proposal.api.ts +++ b/src/app/@api/proposal.api.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { - EthAddress, + NetworkAddress, Member, Proposal, PublicCollections, @@ -53,7 +53,7 @@ export class ProposalApi extends BaseApi { 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); diff --git a/src/app/components/auth/services/auth.service.ts b/src/app/components/auth/services/auth.service.ts index 9b99cc5..0de6020 100644 --- a/src/app/components/auth/services/auth.service.ts +++ b/src/app/components/auth/services/auth.service.ts @@ -12,11 +12,11 @@ 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, - tiers, + // tiers, TOKEN_EXPIRY_HOURS, WenRequest, } from '@build-5/interfaces'; @@ -144,14 +144,13 @@ export class AuthService { this.memberSoonDistribution$.subscribe((v) => { if (v && (v?.stakes?.[StakeType.DYNAMIC]?.value || 0) > 0) { - let l = -1; - tiers.forEach((a) => { - if ((v?.stakes?.[StakeType.DYNAMIC]?.value || 0) >= a) { - l++; - } - }); - - this.memberLevel$.next(l); + // let l = -1; + // tiers.forEach((a) => { + // if ((v?.stakes?.[StakeType.DYNAMIC]?.value || 0) >= a) { + // l++; + // } + // }); + // this.memberLevel$.next(l); } else { this.memberLevel$.next(0); } @@ -418,7 +417,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); }); diff --git a/src/app/components/token/components/token-info/token-info-description.component.ts b/src/app/components/token/components/token-info/token-info-description.component.ts index b038b96..7604d1a 100644 --- a/src/app/components/token/components/token-info/token-info-description.component.ts +++ b/src/app/components/token/components/token-info/token-info-description.component.ts @@ -50,7 +50,7 @@ export class TokenInfoDescriptionComponent { const distributions = await this.tokenApi.getAllDistributions(this.token?.uid); const fields = [ '', - 'ethAddress', + 'NetworkAddress', 'tokenOwned', 'unclaimedTokens', 'tokenClaimed', diff --git a/src/app/components/token/components/token-stake/token-stake.component.ts b/src/app/components/token/components/token-stake/token-stake.component.ts index 07cc56c..997e9f9 100644 --- a/src/app/components/token/components/token-stake/token-stake.component.ts +++ b/src/app/components/token/components/token-stake/token-stake.component.ts @@ -44,7 +44,7 @@ import { TransactionType, calcStakedMultiplier, getDefDecimalIfNotSet, - tiers, + // tiers, } from '@build-5/interfaces'; import dayjs from 'dayjs'; import { BehaviorSubject, Subscription, interval, merge } from 'rxjs'; @@ -153,21 +153,21 @@ export class TokenStakeComponent implements OnInit, OnDestroy { const val = calcStakedMultiplier(this.weekControl.value) * (this.amountControl.value || 0); this.stakeControl.setValue(val.toFixed(2)); - const newTotal = - (this.auth.memberSoonDistribution$.value?.stakes?.[StakeType.DYNAMIC]?.value || 0) + - Math.pow(10, getDefDecimalIfNotSet(this.token?.decimals)) * val; - let l = 0; - tiers.forEach((a) => { - if (newTotal >= a) { - l++; - } - }); - - if (l > tiers.length - 1) { - l = tiers.length - 1; - } - - this.levelControl.setValue(l); + // const newTotal = + // (this.auth.memberSoonDistribution$.value?.stakes?.[StakeType.DYNAMIC]?.value || 0) + + // Math.pow(10, getDefDecimalIfNotSet(this.token?.decimals)) * val; + // let l = 0; + // tiers.forEach((a) => { + // if (newTotal >= a) { + // l++; + // } + // }); + + // if (l > tiers.length - 1) { + // l = tiers.length - 1; + // } + + // this.levelControl.setValue(l); this.multiplierControl.setValue(calcStakedMultiplier(this.weekControl.value)); if (this.tokenStats && this.rewards) { this.earnControl.setValue( diff --git a/src/app/pages/soon-staking/pages/staking/staking.page.ts b/src/app/pages/soon-staking/pages/staking/staking.page.ts index aecaba7..2c0166a 100644 --- a/src/app/pages/soon-staking/pages/staking/staking.page.ts +++ b/src/app/pages/soon-staking/pages/staking/staking.page.ts @@ -30,7 +30,7 @@ import { TokenStats, calcStakedMultiplier, getDefDecimalIfNotSet, - tiers, + // tiers, } from '@build-5/interfaces'; import { BehaviorSubject, Observable, Subscription, map, merge, of } from 'rxjs'; @@ -119,21 +119,21 @@ export class StakingPage implements OnInit, OnDestroy { if ((this.amountControl.value || 0) > 0 && (this.weekControl.value || 0) > 0) { const val = calcStakedMultiplier(this.weekControl.value) * (this.amountControl.value || 0); this.stakeControl.setValue(val.toFixed(2)); - const newTotal = - (this.auth.memberSoonDistribution$.value?.stakes?.[StakeType.DYNAMIC]?.value || 0) + - Math.pow(10, getDefDecimalIfNotSet(this.token$.value?.decimals)) * val; - let l = -1; - tiers.forEach((a) => { - if (newTotal >= a) { - l++; - } - }); + // const newTotal = + // (this.auth.memberSoonDistribution$.value?.stakes?.[StakeType.DYNAMIC]?.value || 0) + + // Math.pow(10, getDefDecimalIfNotSet(this.token$.value?.decimals)) * val; + // let l = -1; + // tiers.forEach((a) => { + // if (newTotal >= a) { + // l++; + // } + // }); - if (l > tiers.length) { - l = tiers.length; - } + // if (l > tiers.length) { + // l = tiers.length; + // } - this.levelControl.setValue(l); + // this.levelControl.setValue(l); this.multiplierControl.setValue(calcStakedMultiplier(this.weekControl.value)); if (this.tokenStats$.value && this.stakeRewards$.value) { this.earnControl.setValue( @@ -206,11 +206,11 @@ export class StakingPage implements OnInit, OnDestroy { key: '1', category: 'Requirements', category_extra: 'Staked value', // auth.memberLevel$ | async - level0: tiers[0].toString(), - level1: tiers[1].toString(), - level2: tiers[2].toString(), - level3: tiers[3].toString(), - level4: tiers[4].toString(), + level0: '0', // tiers[0].toString(), + level1: '0', // tiers[1].toString(), + level2: '0', // tiers[2].toString(), + level3: '0', // tiers[3].toString(), + level4: '0', // tiers[4].toString(), }, { key: '2',