Skip to content

Commit 9c71ec1

Browse files
Merge pull request #83 from soonaverse/fixes
Fixes
2 parents cc18578 + f9a4603 commit 9c71ec1

File tree

18 files changed

+63
-52
lines changed

18 files changed

+63
-52
lines changed

src/app/@api/base.api.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { HttpClient } from '@angular/common/http';
22
import { environment } from '@env/environment';
33
import {
4-
EthAddress,
4+
NetworkAddress,
55
PublicCollections,
66
BUILD5_PROD_ADDRESS_API,
77
BUILD5_TEST_ADDRESS_API,
88
WEN_FUNC,
9+
WenRequest,
910
} from '@build-5/interfaces';
10-
import { Build5Env } from '@build-5/lib';
11-
import { CrudRepository } from '@build-5/lib/lib/repositories/CrudRepository';
11+
import { Build5Env, CrudRepository } from '@build-5/lib';
1212
import { Observable, map, of } from 'rxjs';
1313

1414
export const DEFAULT_LIST_SIZE = 50;
@@ -29,12 +29,12 @@ export class BaseApi<T> {
2929

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

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

3535
public top = (lastValue?: string, limit?: number) => this.repo.getTopLive(lastValue, limit);
3636

37-
protected request<T>(func: WEN_FUNC, req: any): Observable<T | undefined> {
37+
protected request<T>(func: WEN_FUNC, req: WenRequest): Observable<T | undefined> {
3838
const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API;
3939
return this.httpClient.post(origin + func, { data: req }).pipe(map((b: any) => b.data));
4040
}

src/app/@api/member.api.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
33
import { environment } from '@env/environment';
44
import {
5-
EthAddress,
5+
NetworkAddress,
66
Member,
77
Proposal,
88
PublicCollections,
@@ -74,7 +74,7 @@ export class MemberApi extends BaseApi<Member> {
7474
super(PublicCollections.MEMBER, httpClient);
7575
}
7676

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

93-
public listenMultiple = (ids: EthAddress[]) =>
93+
public listenMultiple = (ids: NetworkAddress[]) =>
9494
ids.length
9595
? this.memberRepo
9696
.getByFieldLive(
@@ -105,7 +105,10 @@ export class MemberApi extends BaseApi<Member> {
105105
)
106106
: of([]);
107107

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

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

140143
public topSpaces = (
141-
memberId: EthAddress,
144+
memberId: NetworkAddress,
142145
orderBy = ['createdOn'],
143146
orderByDir = ['desc'],
144147
lastValue?: string,
145148
limit?: number,
146149
) => this.spaceRepo.getTopByMember(memberId, orderBy, orderByDir, lastValue, limit);
147150

148151
public pendingSpaces = (
149-
memberId: EthAddress,
152+
memberId: NetworkAddress,
150153
orderBy = ['createdOn'],
151154
orderByDir = ['desc'],
152155
lastValue?: string,
153156
) => this.spaceRepo.getPendingSpacesByMemberLive(memberId, orderBy, orderByDir, lastValue);
154157

155-
public topAwardsPending = (memberId: EthAddress, lastValue?: string) =>
158+
public topAwardsPending = (memberId: NetworkAddress, lastValue?: string) =>
156159
this.awardRepo.getTopByMemberLive(memberId, false, lastValue);
157160

158-
public topAwardsCompleted = (memberId: EthAddress, lastValue?: string) =>
161+
public topAwardsCompleted = (memberId: NetworkAddress, lastValue?: string) =>
159162
this.awardRepo.getTopByMemberLive(memberId, true, lastValue);
160163

161164
public topProposals = (
162-
memberId: EthAddress,
165+
memberId: NetworkAddress,
163166
orderBy = ['createdOn'],
164167
orderByDir = ['desc'],
165168
lastValue?: string,
@@ -211,7 +214,7 @@ export class MemberApi extends BaseApi<Member> {
211214
);
212215
}
213216

214-
public allSpacesAsMember = (memberId: EthAddress, lastValue?: string) =>
217+
public allSpacesAsMember = (memberId: NetworkAddress, lastValue?: string) =>
215218
this.spaceMemberRepo.getTopBySubColIdLive(memberId, [], [], lastValue).pipe(
216219
switchMap(async (spaceMembers) => {
217220
const spacePromises = spaceMembers.map(
@@ -222,7 +225,11 @@ export class MemberApi extends BaseApi<Member> {
222225
);
223226

224227
public createIfNotExists = (address: string): Observable<Member | undefined> =>
225-
this.request(WEN_FUNC.createMember, address);
228+
this.request(WEN_FUNC.createMember, {
229+
address: '',
230+
projectApiKey: environment.build5Token,
231+
body: address,
232+
});
226233

227234
public updateMember = (req: WenRequest): Observable<Member | undefined> =>
228235
this.request(WEN_FUNC.updateMember, req);

src/app/@api/order.api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
33
import {
4-
EthAddress,
4+
NetworkAddress,
55
PublicCollections,
66
Transaction,
77
WEN_FUNC,
@@ -33,7 +33,7 @@ export class OrderApi extends BaseApi<Transaction> {
3333
public openBid = (req: WenRequest): Observable<Transaction | undefined> =>
3434
this.request(WEN_FUNC.openBid, req);
3535

36-
public listenMultiple = (ids: EthAddress[]) =>
36+
public listenMultiple = (ids: NetworkAddress[]) =>
3737
ids.length
3838
? this.transactionRepo.getByFieldLive(
3939
ids.map(() => 'uid'),

src/app/@api/proposal.api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
33
import {
4-
EthAddress,
4+
NetworkAddress,
55
Member,
66
Proposal,
77
PublicCollections,
@@ -53,7 +53,7 @@ export class ProposalApi extends BaseApi<Proposal> {
5353
super(PublicCollections.PROPOSAL, httpClient);
5454
}
5555

56-
public listen = (id: EthAddress) => this.proposalRepo.getByIdLive(id);
56+
public listen = (id: NetworkAddress) => this.proposalRepo.getByIdLive(id);
5757

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

src/app/components/auth/services/auth.service.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import { undefinedToEmpty } from '@core/utils/manipulations.utils';
1212
import { ROUTER_UTILS } from '@core/utils/router.utils';
1313
import detectEthereumProvider from '@metamask/detect-provider';
1414
import {
15-
EthAddress,
15+
NetworkAddress,
1616
Member,
1717
Network,
1818
StakeType,
19-
tiers,
2019
TOKEN_EXPIRY_HOURS,
2120
WenRequest,
2221
} from '@build-5/interfaces';
@@ -145,12 +144,11 @@ export class AuthService {
145144
this.memberSoonDistribution$.subscribe((v) => {
146145
if (v && (v?.stakes?.[StakeType.DYNAMIC]?.value || 0) > 0) {
147146
let l = -1;
148-
tiers.forEach((a) => {
147+
environment.tiers.forEach((a) => {
149148
if ((v?.stakes?.[StakeType.DYNAMIC]?.value || 0) >= a) {
150149
l++;
151150
}
152151
});
153-
154152
this.memberLevel$.next(l);
155153
} else {
156154
this.memberLevel$.next(0);
@@ -418,7 +416,7 @@ export class AuthService {
418416
}
419417
}
420418

421-
public monitorMember(address: EthAddress): void {
419+
public monitorMember(address: NetworkAddress): void {
422420
this.memberSubscription$ = this.memberApi.listen(address).subscribe((v) => {
423421
this.member$.next(v);
424422
});

src/app/components/nft/components/nft-checkout/nft-checkout.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ export class NftCheckoutComponent implements OnInit, OnDestroy {
230230
if (val.payload.nft) {
231231
firstValueFrom(this.nftApi.listen(val.payload.nft)).then((obj) => {
232232
if (obj) {
233-
this.purchasedNft = obj;
233+
this.purchasedNft = <Nft>obj;
234234
this.fileApi
235-
.getMetadata(this.purchasedNft.media)
235+
.getMetadata(this.purchasedNft?.media)
236236
.pipe(take(1), untilDestroyed(this))
237237
.subscribe((o) => {
238238
this.mediaType = o;

src/app/components/token/components/token-all-token-row/token-all-token-row.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ export class TokenAllTokenRowComponent implements OnInit, OnDestroy {
5757
this.tokenApi
5858
.listen(this.tokenId)
5959
.pipe(untilDestroyed(this))
60-
.subscribe((token) => {
60+
.subscribe((token: any) => {
6161
if (token) {
6262
this.token = token;
63-
this.listenToStats(this.token.uid);
63+
if (this.token?.uid) {
64+
this.listenToStats(this.token.uid);
65+
}
6466
this.cd.markForCheck();
6567
}
6668
});

src/app/components/token/components/token-info/token-info-description.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class TokenInfoDescriptionComponent {
5050
const distributions = await this.tokenApi.getAllDistributions(this.token?.uid);
5151
const fields = [
5252
'',
53-
'ethAddress',
53+
'NetworkAddress',
5454
'tokenOwned',
5555
'unclaimedTokens',
5656
'tokenClaimed',

src/app/components/token/components/token-stake/token-stake.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import {
4444
TransactionType,
4545
calcStakedMultiplier,
4646
getDefDecimalIfNotSet,
47-
tiers,
4847
} from '@build-5/interfaces';
4948
import dayjs from 'dayjs';
5049
import { BehaviorSubject, Subscription, interval, merge } from 'rxjs';
@@ -157,14 +156,14 @@ export class TokenStakeComponent implements OnInit, OnDestroy {
157156
(this.auth.memberSoonDistribution$.value?.stakes?.[StakeType.DYNAMIC]?.value || 0) +
158157
Math.pow(10, getDefDecimalIfNotSet(this.token?.decimals)) * val;
159158
let l = 0;
160-
tiers.forEach((a) => {
159+
environment.tiers.forEach((a) => {
161160
if (newTotal >= a) {
162161
l++;
163162
}
164163
});
165164

166-
if (l > tiers.length - 1) {
167-
l = tiers.length - 1;
165+
if (l > environment.tiers.length - 1) {
166+
l = environment.tiers.length - 1;
168167
}
169168

170169
this.levelControl.setValue(l);

src/app/components/token/components/token-trading-pair-row/token-trading-pair-row.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class TokenTradingPairRowComponent implements OnInit, OnDestroy {
3434
@Input() tableMode = false;
3535
@Output() wenOnFavouriteClick = new EventEmitter<void>();
3636
@Output() wenOnClick = new EventEmitter<void>();
37-
public token?: Token;
37+
public token?: any;
3838
public path = ROUTER_UTILS.config.token.root;
3939
public tradePath = ROUTER_UTILS.config.token.trade;
4040
public listenAvgPrice$: BehaviorSubject<number | undefined> = new BehaviorSubject<
@@ -64,7 +64,7 @@ export class TokenTradingPairRowComponent implements OnInit, OnDestroy {
6464
this.tokenApi
6565
.listen(this.tokenId)
6666
.pipe(untilDestroyed(this))
67-
.subscribe((token) => {
67+
.subscribe((token: any) => {
6868
if (token) {
6969
this.token = token;
7070
this.listenToStats(this.token.uid, [token.status || TokenStatus.PRE_MINTED]);

src/app/pages/award/pages/new/new.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class NewPage implements OnInit, OnDestroy {
126126
filter((space) => !!space),
127127
untilDestroyed(this),
128128
)
129-
.subscribe((space) => {
129+
.subscribe((space: any) => {
130130
this.spaceControl.setValue(space?.uid);
131131

132132
this.seo.setTags(

src/app/pages/collection/pages/upsert/upsert.page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export class UpsertPage implements OnInit, OnDestroy {
255255

256256
// Load selected options for award/collections
257257
o.accessAwards?.forEach(async (a) => {
258-
const award = await firstValueFrom(this.awardApi.listen(a));
258+
const award: any = await firstValueFrom(this.awardApi.listen(a));
259259
if (award) {
260260
this.filteredAwards$.next([
261261
...(this.filteredAwards$.value || []),
@@ -274,7 +274,7 @@ export class UpsertPage implements OnInit, OnDestroy {
274274
});
275275

276276
o.accessCollections?.forEach(async (a) => {
277-
const collection = await firstValueFrom(this.collectionApi.listen(a));
277+
const collection: any = await firstValueFrom(this.collectionApi.listen(a));
278278
if (collection) {
279279
this.filteredCollections$.next([
280280
...(this.filteredCollections$.value || []),

src/app/pages/proposal/pages/new/new.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class NewPage implements OnInit, OnDestroy {
131131
filter((space) => !!space),
132132
untilDestroyed(this),
133133
)
134-
.subscribe((space) => {
134+
.subscribe((space: any) => {
135135
this.spaceControl.setValue(space?.uid);
136136

137137
this.seo.setTags(

src/app/pages/soon-staking/pages/staking/staking.page.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
TokenStats,
3131
calcStakedMultiplier,
3232
getDefDecimalIfNotSet,
33-
tiers,
3433
} from '@build-5/interfaces';
3534
import { BehaviorSubject, Observable, Subscription, map, merge, of } from 'rxjs';
3635

@@ -123,14 +122,14 @@ export class StakingPage implements OnInit, OnDestroy {
123122
(this.auth.memberSoonDistribution$.value?.stakes?.[StakeType.DYNAMIC]?.value || 0) +
124123
Math.pow(10, getDefDecimalIfNotSet(this.token$.value?.decimals)) * val;
125124
let l = -1;
126-
tiers.forEach((a) => {
125+
environment.tiers.forEach((a) => {
127126
if (newTotal >= a) {
128127
l++;
129128
}
130129
});
131130

132-
if (l > tiers.length) {
133-
l = tiers.length;
131+
if (l > environment.tiers.length) {
132+
l = environment.tiers.length;
134133
}
135134

136135
this.levelControl.setValue(l);
@@ -206,11 +205,11 @@ export class StakingPage implements OnInit, OnDestroy {
206205
key: '1',
207206
category: 'Requirements',
208207
category_extra: 'Staked value', // auth.memberLevel$ | async
209-
level0: tiers[0].toString(),
210-
level1: tiers[1].toString(),
211-
level2: tiers[2].toString(),
212-
level3: tiers[3].toString(),
213-
level4: tiers[4].toString(),
208+
level0: environment.tiers[0].toString(),
209+
level1: environment.tiers[1].toString(),
210+
level2: environment.tiers[2].toString(),
211+
level3: environment.tiers[3].toString(),
212+
level4: environment.tiers[4].toString(),
214213
},
215214
{
216215
key: '2',

src/app/pages/tokens/pages/tokens/tokens.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class TokensPage implements OnInit {
9292
this.tokenApi
9393
.listenMultiple(HIGHLIGHT_TOKENS)
9494
.pipe(
95-
filter((r) => r.every((token) => token)),
95+
filter((r: any) => r.every((token) => token)),
9696
untilDestroyed(this),
9797
)
9898
.subscribe((r) => {

src/environments/environment.prod.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { MIN_IOTA_AMOUNT } from '@build-5/interfaces';
2+
13
export const environment = {
24
production: true,
35
algolia: {
@@ -6,4 +8,5 @@ export const environment = {
68
},
79
soonaversePlaceholder: 'https://soonaverse.com/favicon.ico',
810
build5Token: '',
11+
tiers: [0, 10, 4000, 6000, 15000].map((v) => v * MIN_IOTA_AMOUNT),
912
};

0 commit comments

Comments
 (0)