Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam committed Nov 8, 2023
1 parent bdf0cba commit 0097060
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 53 deletions.
15 changes: 7 additions & 8 deletions src/app/components/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
Member,
Network,
StakeType,
// tiers,
TOKEN_EXPIRY_HOURS,
WenRequest,
} from '@build-5/interfaces';
Expand Down Expand Up @@ -144,13 +143,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;
environment.tiers.forEach((a) => {
if ((v?.stakes?.[StakeType.DYNAMIC]?.value || 0) >= a) {
l++;
}
});
this.memberLevel$.next(l);
} else {
this.memberLevel$.next(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
Timestamp,
Transaction,
TransactionType,
TRANSACTION_AUTO_EXPIRY_MS,
TRANSACTION_AUTO_EXPIRY_MS
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { BehaviorSubject, firstValueFrom, interval, Subscription, take } from 'rxjs';
Expand Down Expand Up @@ -230,9 +230,9 @@ export class NftCheckoutComponent implements OnInit, OnDestroy {
if (val.payload.nft) {
firstValueFrom(this.nftApi.listen(val.payload.nft)).then((obj) => {
if (obj) {
this.purchasedNft = obj;
this.purchasedNft = <Nft>obj;
this.fileApi
.getMetadata(this.purchasedNft.media)
.getMetadata(this.purchasedNft?.media)
.pipe(take(1), untilDestroyed(this))
.subscribe((o) => {
this.mediaType = o;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class TokenAllTokenRowComponent implements OnInit, OnDestroy {
this.tokenApi
.listen(this.tokenId)
.pipe(untilDestroyed(this))
.subscribe((token) => {
.subscribe((token: Token) => {
if (token) {
this.token = token;
this.listenToStats(this.token.uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
TransactionType,
calcStakedMultiplier,
getDefDecimalIfNotSet,
// tiers,
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { BehaviorSubject, Subscription, interval, merge } from 'rxjs';
Expand Down Expand Up @@ -153,21 +152,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;
environment.tiers.forEach((a) => {
if (newTotal >= a) {
l++;
}
});

if (l > environment.tiers.length - 1) {
l = environment.tiers.length - 1;
}

this.levelControl.setValue(l);
this.multiplierControl.setValue(calcStakedMultiplier(this.weekControl.value));
if (this.tokenStats && this.rewards) {
this.earnControl.setValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class TokenTradingPairRowComponent implements OnInit, OnDestroy {
this.tokenApi
.listen(this.tokenId)
.pipe(untilDestroyed(this))
.subscribe((token) => {
.subscribe((token: Token) => {
if (token) {
this.token = token;
this.listenToStats(this.token.uid, [token.status || TokenStatus.PRE_MINTED]);
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/award/pages/new/new.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class NewPage implements OnInit, OnDestroy {
filter((space) => !!space),
untilDestroyed(this),
)
.subscribe((space) => {
.subscribe((space: any) => {
this.spaceControl.setValue(space?.uid);

this.seo.setTags(
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/collection/pages/upsert/upsert.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export class UpsertPage implements OnInit, OnDestroy {

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

o.accessCollections?.forEach(async (a) => {
const collection = await firstValueFrom(this.collectionApi.listen(a));
const collection: any = await firstValueFrom(this.collectionApi.listen(a));
if (collection) {
this.filteredCollections$.next([
...(this.filteredCollections$.value || []),
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/proposal/pages/new/new.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class NewPage implements OnInit, OnDestroy {
filter((space) => !!space),
untilDestroyed(this),
)
.subscribe((space) => {
.subscribe((space: any) => {
this.spaceControl.setValue(space?.uid);

this.seo.setTags(
Expand Down
37 changes: 18 additions & 19 deletions src/app/pages/soon-staking/pages/staking/staking.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
TokenStats,
calcStakedMultiplier,
getDefDecimalIfNotSet,
// tiers,
} from '@build-5/interfaces';
import { BehaviorSubject, Observable, Subscription, map, merge, of } from 'rxjs';

Expand Down Expand Up @@ -119,21 +118,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;
environment.tiers.forEach((a) => {
if (newTotal >= a) {
l++;
}
});

// if (l > tiers.length) {
// l = tiers.length;
// }
if (l > environment.tiers.length) {
l = environment.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(
Expand Down Expand Up @@ -206,11 +205,11 @@ export class StakingPage implements OnInit, OnDestroy {
key: '1',
category: 'Requirements',
category_extra: 'Staked value', // auth.memberLevel$ | async
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(),
level0: environment.tiers[0].toString(),
level1: environment.tiers[1].toString(),
level2: environment.tiers[2].toString(),
level3: environment.tiers[3].toString(),
level4: environment.tiers[4].toString(),
},
{
key: '2',
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/tokens/pages/tokens/tokens.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class TokensPage implements OnInit {
this.tokenApi
.listenMultiple(HIGHLIGHT_TOKENS)
.pipe(
filter((r) => r.every((token) => token)),
filter((r: any) => r.every((token) => token)),
untilDestroyed(this),
)
.subscribe((r) => {
Expand Down
3 changes: 3 additions & 0 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MIN_IOTA_AMOUNT } from '@build-5/interfaces';

export const environment = {
production: true,
algolia: {
Expand All @@ -6,4 +8,5 @@ export const environment = {
},
soonaversePlaceholder: 'https://soonaverse.com/favicon.ico',
build5Token: '',
tiers: [0, 10, 4000, 6000, 15000].map((v) => v * MIN_IOTA_AMOUNT),
};
3 changes: 3 additions & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MIN_IOTA_AMOUNT } from '@build-5/interfaces';

export const environment = {
production: false,
algolia: {
Expand All @@ -7,4 +9,5 @@ export const environment = {
soonaversePlaceholder: 'https://soonaverse.com/favicon.ico',
build5Token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIweDU1MWZkMmM3YzdiZjM1NmJhYzE5NDU4N2RhYjJmY2Q0NjQyMDA1NGIiLCJwcm9qZWN0IjoiMHg0NjIyM2VkZDQxNTc2MzVkZmM2Mzk5MTU1NjA5ZjMwMWRlY2JmZDg4IiwiaWF0IjoxNjk1ODUyNTk2fQ.WT9L4H9eDdFfJZMrfxTKhEq4PojNWSGNv_CbmlG9sJg',
tiers: [0, 10, 4000, 6000, 15000].map((v) => v * MIN_IOTA_AMOUNT),
};

0 comments on commit 0097060

Please sign in to comment.