Skip to content

Commit

Permalink
Merge pull request #84 from soonaverse/develop
Browse files Browse the repository at this point in the history
Release 2.1
  • Loading branch information
adamunchained authored Nov 14, 2023
2 parents 85e5b8e + da530db commit a716096
Show file tree
Hide file tree
Showing 23 changed files with 118 additions and 85 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/action_stale-issue-pr.yml

This file was deleted.

10 changes: 5 additions & 5 deletions src/app/@api/base.api.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -29,12 +29,12 @@ 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);

protected request<T>(func: WEN_FUNC, req: any): Observable<T | undefined> {
protected request<T>(func: WEN_FUNC, req: WenRequest): Observable<T | undefined> {
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));

Check warning on line 39 in src/app/@api/base.api.ts

View workflow job for this annotation

GitHub Actions / front_end_es_lint

Unexpected any. Specify a different type

Check warning on line 39 in src/app/@api/base.api.ts

View workflow job for this annotation

GitHub Actions / front_end_es_lint

Unexpected any. Specify a different type
}
Expand Down
1 change: 1 addition & 0 deletions src/app/@api/file.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class FileApi {
formData.append('file', <Blob>item.postFile);
formData.append('member', memberId);
formData.append('uid', item.file.uid);
formData.append('projectApiKey', environment.build5Token);
const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API;
return this.httpClient
.post(origin + WEN_FUNC.uploadFile, formData)
Expand Down
31 changes: 19 additions & 12 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 All @@ -222,7 +225,11 @@ export class MemberApi extends BaseApi<Member> {
);

public createIfNotExists = (address: string): Observable<Member | undefined> =>
this.request(WEN_FUNC.createMember, address);
this.request(WEN_FUNC.createMember, {
address: '',
projectApiKey: environment.build5Token,
body: address,
});

public updateMember = (req: WenRequest): Observable<Member | undefined> =>
this.request(WEN_FUNC.updateMember, req);
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
18 changes: 10 additions & 8 deletions src/app/components/auth/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ 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,
TOKEN_EXPIRY_HOURS,
WenRequest,
} from '@build-5/interfaces';
Expand All @@ -25,6 +24,7 @@ import { NzNotificationService } from 'ng-zorro-antd/notification';
import { BehaviorSubject, firstValueFrom, skip, Subscription } from 'rxjs';
import { MemberApi, TokenDistributionWithAirdrops } from './../../../@api/member.api';
import { removeItem } from './../../../@core/utils/local-storage.utils';
import { environment } from '@env/environment';
const tanglePay = (window as any).iota;

export interface MetamaskSignature {
Expand Down Expand Up @@ -144,12 +144,11 @@ export class AuthService {
this.memberSoonDistribution$.subscribe((v) => {
if (v && (v?.stakes?.[StakeType.DYNAMIC]?.value || 0) > 0) {
let l = -1;
tiers.forEach((a) => {
environment.tiers.forEach((a) => {
if ((v?.stakes?.[StakeType.DYNAMIC]?.value || 0) >= a) {
l++;
}
});

this.memberLevel$.next(l);
} else {
this.memberLevel$.next(0);
Expand Down Expand Up @@ -206,14 +205,15 @@ export class AuthService {
public async sign(params: any = {}, cb: SignCallback): Promise<WenRequest | undefined> {
this.showWalletPopup$.next(WalletStatus.ACTIVE);
// We support either resign with metamask or reuse token.
let sc: WenRequest | undefined | false = undefined;
let sc: any | undefined | false = undefined;
const customToken: any = getItem(StorageItem.CustomToken);
const wallet = customToken.wallet || Wallets.Metamask;
// check it's not expired.
if (this.isCustomTokenNotExpired(customToken)) {
sc = {
address: customToken.address,
customToken: customToken.value,
projectApiKey: environment.build5Token,
body: params,
};
} else if (customToken) {
Expand Down Expand Up @@ -271,7 +271,7 @@ export class AuthService {
return true;
}

private async signWithMetamask(params: any = {}): Promise<WenRequest | undefined | false> {
private async signWithMetamask(params: any = {}): Promise<any | undefined | false> {
const provider: any = await detectEthereumProvider();
if (provider) {
try {
Expand Down Expand Up @@ -319,6 +319,7 @@ export class AuthService {
return {
address: provider.selectedAddress,
signature: signature,
projectApiKey: environment.build5Token,
body: params,
};
} catch (e) {
Expand Down Expand Up @@ -389,9 +390,10 @@ export class AuthService {
},
});

const returnObj: WenRequest = {
const returnObj: any = {
address: currentAddress,
signature: signature,
projectApiKey: environment.build5Token,
body: params,
};

Expand All @@ -414,7 +416,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
Original file line number Diff line number Diff line change
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,10 +57,12 @@ export class TokenAllTokenRowComponent implements OnInit, OnDestroy {
this.tokenApi
.listen(this.tokenId)
.pipe(untilDestroyed(this))
.subscribe((token) => {
.subscribe((token: any) => {
if (token) {
this.token = token;
this.listenToStats(this.token.uid);
if (this.token?.uid) {
this.listenToStats(this.token.uid);
}
this.cd.markForCheck();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class TokenInfoDescriptionComponent {
const distributions = await this.tokenApi.getAllDistributions(this.token?.uid);
const fields = [
'',
'ethAddress',
'NetworkAddress',
'tokenOwned',
'unclaimedTokens',
'tokenClaimed',
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 @@ -157,14 +156,14 @@ export class TokenStakeComponent implements OnInit, OnDestroy {
(this.auth.memberSoonDistribution$.value?.stakes?.[StakeType.DYNAMIC]?.value || 0) +
Math.pow(10, getDefDecimalIfNotSet(this.token?.decimals)) * val;
let l = 0;
tiers.forEach((a) => {
environment.tiers.forEach((a) => {
if (newTotal >= a) {
l++;
}
});

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

this.levelControl.setValue(l);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class TokenTradingPairRowComponent implements OnInit, OnDestroy {
@Input() tableMode = false;
@Output() wenOnFavouriteClick = new EventEmitter<void>();
@Output() wenOnClick = new EventEmitter<void>();
public token?: Token;
public token?: any;
public path = ROUTER_UTILS.config.token.root;
public tradePath = ROUTER_UTILS.config.token.trade;
public listenAvgPrice$: BehaviorSubject<number | undefined> = new BehaviorSubject<
Expand Down Expand Up @@ -64,7 +64,7 @@ export class TokenTradingPairRowComponent implements OnInit, OnDestroy {
this.tokenApi
.listen(this.tokenId)
.pipe(untilDestroyed(this))
.subscribe((token) => {
.subscribe((token: any) => {
if (token) {
this.token = token;
this.listenToStats(this.token.uid, [token.status || TokenStatus.PRE_MINTED]);
Expand Down
Loading

0 comments on commit a716096

Please sign in to comment.