diff --git a/package.json b/package.json index 8fd9549..2fbe929 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "@metamask/detect-provider": "2.0.0", "@ngneat/until-destroy": "9.2.3", "@nguniversal/express-engine": "15.1.0", - "@build-5/interfaces": "2.1.27", - "@build-5/lib": "latest", + "@build-5/interfaces": "latest", + "@build-5/sdk": "latest", "@tailwindcss/line-clamp": "0.4.2", "algoliasearch": "4.14.3", "angular-instantsearch": "4.4.0", diff --git a/src/app/@api/award.api.ts b/src/app/@api/award.api.ts index 9a8685e..653e903 100644 --- a/src/app/@api/award.api.ts +++ b/src/app/@api/award.api.ts @@ -2,21 +2,20 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Award, + AwardApproveParticipantRequest, + AwardCreateRequest, + AwardFundRequest, + AwardParticpateRequest, + AwardRejectRequest, + Build5Request, + Dataset, Member, - PublicCollections, + Subset, Timestamp, WEN_FUNC, - WenRequest, } from '@build-5/interfaces'; -import { - AwardFilter, - AwardOwnerRepository, - AwardParticipantRepository, - AwardRepository, -} from '@build-5/lib'; - import { map, Observable, of } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { AwardFilter, BaseApi } from './base.api'; export interface AwardParticipantWithMember extends Member { comment?: string; @@ -28,31 +27,45 @@ export interface AwardParticipantWithMember extends Member { providedIn: 'root', }) export class AwardApi extends BaseApi { - protected awardRepo = new AwardRepository(SOON_ENV); - protected awardOwnerRepo = new AwardOwnerRepository(SOON_ENV); - protected awardParticipantRepo = new AwardParticipantRepository(SOON_ENV); + private awardDataset = this.project.dataset(Dataset.AWARD); constructor(protected httpClient: HttpClient) { - super(PublicCollections.AWARD, httpClient); + super(Dataset.AWARD, httpClient); } - public listenSpace = (space: string, filter = AwardFilter.ALL) => - this.awardRepo.getBySpaceAndFilterLive(space, filter); + public listenSpace = (space: string, filter = AwardFilter.ALL, lastValue?: string) => { + switch (filter) { + case AwardFilter.ALL: + return this.awardDataset.getBySpaceLive(space, lastValue); + case AwardFilter.ACTIVE: + return this.awardDataset.getActiveLive(space, lastValue); + case AwardFilter.COMPLETED: + return this.awardDataset.getCompletedLive(space, lastValue); + case AwardFilter.DRAFT: + return this.awardDataset.getDraftLive(space, lastValue); + case AwardFilter.REJECTED: + return this.awardDataset.getRejectedLive(space, lastValue); + } + }; public listenOwners = (award: string, lastValue?: string) => - this.awardOwnerRepo.getAllLive(award, lastValue); + this.awardDataset.id(award).subset(Subset.OWNERS).getAllLive(lastValue); - public lastActive = (lastValue?: string) => this.awardRepo.getLastActiveLive(lastValue); + public lastActive = (lastValue?: string) => this.awardDataset.getLastActiveLive(lastValue); public listenPendingParticipants = (award: string, lastValue?: string, searchIds?: string[]) => - this.awardParticipantRepo + this.awardDataset + .id(award) + .subset(Subset.PARTICIPANTS) .getParticipantsLive(award, false, searchIds, lastValue) .pipe( map((participants) => participants.map((p) => ({ ...p, participatedOn: p.createdOn }))), ); public listenIssuedParticipants = (award: string, lastValue?: string, searchIds?: string[]) => - this.awardParticipantRepo + this.awardDataset + .id(award) + .subset(Subset.PARTICIPANTS) .getParticipantsLive(award, true, searchIds, lastValue) .pipe( map((participants) => participants.map((p) => ({ ...p, participatedOn: p.createdOn }))), @@ -62,26 +75,31 @@ export class AwardApi extends BaseApi { if (!awardId || !memberId) { return of(false); } - return this.awardParticipantRepo - .getByIdLive(awardId, memberId) + return this.awardDataset + .id(awardId) + .subset(Subset.PARTICIPANTS) + .subsetId(memberId) + .getLive() .pipe(map((awardMember) => !!awardMember)); } - public create = (req: WenRequest): Observable => + public create = (req: Build5Request): Observable => this.request(WEN_FUNC.createAward, req); - public participate = (req: WenRequest): Observable => - this.request(WEN_FUNC.participateAward, req); + public participate = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.participateAward, req); - public approveParticipant = (req: WenRequest): Observable => - this.request(WEN_FUNC.approveParticipantAward, req); + public approveParticipant = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.approveParticipantAward, req); - public approve = (req: WenRequest): Observable => + public approve = (req: Build5Request): Observable => this.request(WEN_FUNC.fundAward, req); - public reject = (req: WenRequest): Observable => + public reject = (req: Build5Request): Observable => this.request(WEN_FUNC.rejectAward, req); - public fundAndMint = (req: WenRequest): Observable => + public fundAndMint = (req: Build5Request): Observable => this.request(WEN_FUNC.fundAward, req); } diff --git a/src/app/@api/base.api.ts b/src/app/@api/base.api.ts index 26d8d5a..cd74871 100644 --- a/src/app/@api/base.api.ts +++ b/src/app/@api/base.api.ts @@ -2,14 +2,14 @@ import { HttpClient } from '@angular/common/http'; import { environment } from '@env/environment'; import { NetworkAddress, - PublicCollections, BUILD5_PROD_ADDRESS_API, BUILD5_TEST_ADDRESS_API, WEN_FUNC, - WenRequest, + Build5Request, + Dataset, } from '@build-5/interfaces'; -import { Build5Env, CrudRepository } from '@build-5/lib'; -import { Observable, map, of } from 'rxjs'; +import { https, Build5, SoonaverseApiKey } from '@build-5/sdk'; +import { Observable, of } from 'rxjs'; export const DEFAULT_LIST_SIZE = 50; export const WHERE_IN_BATCH = 10; @@ -18,23 +18,34 @@ export const FULL_LIST = 10000; export const FULL_TODO_CHANGE_TO_PAGING = FULL_LIST; export const FULL_TODO_MOVE_TO_PROTOCOL = FULL_LIST; -export const SOON_ENV = environment.production ? Build5Env.PROD : Build5Env.TEST; +export const ORIGIN = environment.production ? Build5.PROD : Build5.TEST; +export const API_KEY = SoonaverseApiKey[ORIGIN]; + +export enum AwardFilter { + ALL = 'all', + DRAFT = 'draft', + ACTIVE = 'active', + COMPLETED = 'completed', + REJECTED = 'rejected', +} export class BaseApi { - protected repo: CrudRepository; + protected project = https(ORIGIN).project(API_KEY); - constructor(public readonly collection: PublicCollections, protected httpClient: HttpClient) { - this.repo = new CrudRepository(SOON_ENV, this.collection); - } + constructor(public readonly dataset: Dataset, protected httpClient: HttpClient) {} - public listen = (id: string) => this.repo.getByIdLive(id); + public listen = (id: string): Observable => + this.project.dataset(this.dataset).id(id).getLive() as Observable; - public listenMultiple = (ids: NetworkAddress[]) => - ids.length ? this.repo.getManyByIdLive(ids) : of([]); + public listenMultiple = (ids: NetworkAddress[]): Observable => + ids.length + ? (this.project.dataset(this.dataset).getManyByIdLive(ids) as Observable) + : of([]); - public top = (lastValue?: string, limit?: number) => this.repo.getTopLive(lastValue, limit); + public top = (lastValue?: string, limit?: number): Observable => + this.project.dataset(this.dataset).getTopLive(lastValue, limit) as Observable; - protected request(func: WEN_FUNC, req: WenRequest): Observable { + protected request(func: WEN_FUNC, req: Build5Request): Observable { const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API; return this.httpClient.post(origin + func, req); } diff --git a/src/app/@api/collection.api.ts b/src/app/@api/collection.api.ts index 52da99a..ffec82b 100644 --- a/src/app/@api/collection.api.ts +++ b/src/app/@api/collection.api.ts @@ -2,14 +2,20 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Collection, - PublicCollections, + Dataset, Transaction, WEN_FUNC, - WenRequest, + Build5Request, + CollectionMintRequest, + VoteRequest, + RankRequest, + CreateCollectionRequest, + UpdateCollectionRequest, + RejectCollectionRequest, + Subset, } from '@build-5/interfaces'; -import { CollectionRepository, CollectionStatsRepository } from '@build-5/lib'; import { Observable, of } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; export enum CollectionFilter { ALL = 'all', @@ -22,40 +28,49 @@ export enum CollectionFilter { providedIn: 'root', }) export class CollectionApi extends BaseApi { - protected colRepo = new CollectionRepository(SOON_ENV); - protected colStatRepo = new CollectionStatsRepository(SOON_ENV); + private collectionDataset = this.project.dataset(Dataset.COLLECTION); constructor(protected httpClient: HttpClient) { - super(PublicCollections.COLLECTION, httpClient); + super(Dataset.COLLECTION, httpClient); } - public mintCollection = (req: WenRequest): Observable => - this.request(WEN_FUNC.mintCollection, req); + public mintCollection = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.mintCollection, req); - public vote = (req: WenRequest): Observable => + public vote = (req: Build5Request): Observable => this.request(WEN_FUNC.voteController, req); - public rank = (req: WenRequest): Observable => + public rank = (req: Build5Request): Observable => this.request(WEN_FUNC.rankController, req); public stats = (collectionId: string) => - collectionId ? this.colStatRepo.getByIdLive(collectionId, collectionId) : of(undefined); + collectionId + ? this.collectionDataset + .id(collectionId) + .subset(Subset.STATS) + .subsetId(collectionId) + .getLive() + : of(undefined); public allPendingSpace = (space: string, lastValue?: string) => - this.colRepo.getAllPendingLive(space, lastValue); + this.collectionDataset.getAllPendingLive(space, lastValue); public allAvailableSpace = (space: string, lastValue?: string) => - this.colRepo.getAllAvailableLive(space, lastValue); + this.collectionDataset.getAllAvailableLive(space, lastValue); public allRejectedSpace = (space: string, lastValue?: string) => - this.colRepo.getAllRejectedLive(space, lastValue); + this.collectionDataset.getAllRejectedLive(space, lastValue); - public create = (req: WenRequest): Observable => - this.request(WEN_FUNC.createCollection, req); + public create = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.createCollection, req); - public update = (req: WenRequest): Observable => - this.request(WEN_FUNC.updateCollection, req); + public update = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.updateCollection, req); - public reject = (req: WenRequest): Observable => - this.request(WEN_FUNC.rejectCollection, req); + public reject = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.rejectCollection, req); } diff --git a/src/app/@api/member.api.ts b/src/app/@api/member.api.ts index cfddf69..a6f4340 100644 --- a/src/app/@api/member.api.ts +++ b/src/app/@api/member.api.ts @@ -5,7 +5,7 @@ import { NetworkAddress, Member, Proposal, - PublicCollections, + Dataset, SOON_TOKEN, SOON_TOKEN_TEST, Stake, @@ -15,28 +15,16 @@ import { TokenDropStatus, Transaction, WEN_FUNC, - WenRequest, + Build5Request, BUILD5_PROD_ADDRESS_API, BUILD5_TEST_ADDRESS_API, + Subset, + MemberUpdateRequest, + CustomTokenRequest, } from '@build-5/interfaces'; -import { - AirdropRepository, - AwardParticipantRepository, - AwardRepository, - MemberRepository, - ProposalMemberRepository, - ProposalRepository, - SpaceKnockingMemberRepository, - SpaceMemberRepository, - SpaceRepository, - StakeRepository, - TokenDistributionRepository, - TokenRepository, - TransactionRepository, -} from '@build-5/lib'; import dayjs from 'dayjs'; import { Observable, combineLatest, map, of, switchMap } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; export interface TokenDistributionWithAirdrops extends TokenDistribution { tokenDrops: TokenDrop[]; @@ -58,43 +46,43 @@ export interface StakeWithTokenRec extends Stake { providedIn: 'root', }) export class MemberApi extends BaseApi { - protected memberRepo = new MemberRepository(SOON_ENV); - protected tokenDistRepo = new TokenDistributionRepository(SOON_ENV); - protected airdropRepo = new AirdropRepository(SOON_ENV); - protected stakeRepo = new StakeRepository(SOON_ENV); - protected tokenRepo = new TokenRepository(SOON_ENV); - protected spaceRepo = new SpaceRepository(SOON_ENV); - protected spaceMemberRepo = new SpaceMemberRepository(SOON_ENV); - protected spaceKnockingRepo = new SpaceKnockingMemberRepository(SOON_ENV); - protected awardRepo = new AwardRepository(SOON_ENV); - protected awardParticipantRepo = new AwardParticipantRepository(SOON_ENV); - protected proposalRepo = new ProposalRepository(SOON_ENV); - protected proposalMemberRepo = new ProposalMemberRepository(SOON_ENV); - protected transactionRepo = new TransactionRepository(SOON_ENV); + protected memberDataset = this.project.dataset(Dataset.MEMBER); + protected airdropDataset = this.project.dataset(Dataset.AIRDROP); + protected stakeDataset = this.project.dataset(Dataset.STAKE); + protected tokenDataset = this.project.dataset(Dataset.TOKEN); + protected spaceDataset = this.project.dataset(Dataset.SPACE); + protected awardDataset = this.project.dataset(Dataset.AWARD); + protected proposalDataset = this.project.dataset(Dataset.PROPOSAL); + protected transactionDataset = this.project.dataset(Dataset.TRANSACTION); constructor(protected httpClient: HttpClient) { - super(PublicCollections.MEMBER, httpClient); + super(Dataset.MEMBER, httpClient); } public soonDistributionStats = (id: NetworkAddress) => { const tokenId = environment.production ? SOON_TOKEN : SOON_TOKEN_TEST; - return this.tokenDistRepo.getByIdLive(tokenId, id.toLowerCase()).pipe( - switchMap(async (distribution) => { - if (!distribution) { - return; - } - const tokenDrops = await this.airdropRepo.getByField( - ['member', 'token', 'status'], - [id.toLowerCase(), tokenId, TokenDropStatus.UNCLAIMED], - ); - return { ...distribution, tokenDrops }; - }), - ) as Observable; + return this.tokenDataset + .id(tokenId) + .subset(Subset.DISTRIBUTION) + .subsetId(id.toLowerCase()) + .getLive() + .pipe( + switchMap(async (distribution) => { + if (!distribution) { + return; + } + const tokenDrops = await this.airdropDataset.getByField( + ['member', 'token', 'status'], + [id.toLowerCase(), tokenId, TokenDropStatus.UNCLAIMED], + ); + return { ...distribution, tokenDrops }; + }), + ) as Observable; }; public listenMultiple = (ids: NetworkAddress[]) => ids.length - ? this.memberRepo + ? this.memberDataset .getByFieldLive( ids.map(() => 'uid'), ids, @@ -111,10 +99,10 @@ export class MemberApi extends BaseApi { memberId: NetworkAddress, lastValue?: string, ): Observable => - this.stakeRepo.getByMemberLive(memberId, lastValue).pipe( + this.stakeDataset.getByMemberLive(memberId, lastValue).pipe( switchMap(async (stakes: Stake[]) => { const tokenIds = Array.from(new Set(stakes.map((s) => s.token))); - const tokenPromises = tokenIds.map((id) => this.tokenRepo.getById(id)); + const tokenPromises = tokenIds.map((id) => this.tokenDataset.id(id).get()); const tokens = await Promise.all(tokenPromises); return stakes.map((stake) => ({ @@ -125,22 +113,25 @@ export class MemberApi extends BaseApi { ); public topTokens = (memberId: NetworkAddress): Observable => - this.tokenDistRepo.getTopBySubColIdLive(memberId, [], []).pipe( - switchMap(async (distributions) => { - const promises = distributions.map(async (distribution) => { - const token = await this.tokenRepo.getById(distribution.parentId); - const tokenDrops = await this.airdropRepo.getByField( - ['member', 'token', 'status'], - [memberId, distribution.parentId, TokenDropStatus.UNCLAIMED], - ); - return { - ...token, - distribution: { ...distribution, tokenDrops }, - } as TokenWithMemberDistribution; - }); - return await Promise.all(promises); - }), - ); + this.tokenDataset + .subset(Subset.DISTRIBUTION) + .getTopBySubColIdLive(memberId, [], []) + .pipe( + switchMap(async (distributions) => { + const promises = distributions.map(async (distribution) => { + const token = await this.tokenDataset.id(distribution.parentId).get(); + const tokenDrops = await this.airdropDataset.getByField( + ['member', 'token', 'status'], + [memberId, distribution.parentId, TokenDropStatus.UNCLAIMED], + ); + return { + ...token, + distribution: { ...distribution, tokenDrops }, + } as TokenWithMemberDistribution; + }); + return await Promise.all(promises); + }), + ); public topSpaces = ( memberId: NetworkAddress, @@ -148,20 +139,20 @@ export class MemberApi extends BaseApi { orderByDir = ['desc'], lastValue?: string, limit?: number, - ) => this.spaceRepo.getTopByMember(memberId, orderBy, orderByDir, lastValue, limit); + ) => this.spaceDataset.getTopByMember(memberId, orderBy, orderByDir, lastValue, limit); public pendingSpaces = ( memberId: NetworkAddress, orderBy = ['createdOn'], orderByDir = ['desc'], lastValue?: string, - ) => this.spaceRepo.getPendingSpacesByMemberLive(memberId, orderBy, orderByDir, lastValue); + ) => this.spaceDataset.getPendingSpacesByMemberLive(memberId, orderBy, orderByDir, lastValue); public topAwardsPending = (memberId: NetworkAddress, lastValue?: string) => - this.awardRepo.getTopByMemberLive(memberId, false, lastValue); + this.awardDataset.getTopByMemberLive(memberId, false, lastValue); public topAwardsCompleted = (memberId: NetworkAddress, lastValue?: string) => - this.awardRepo.getTopByMemberLive(memberId, true, lastValue); + this.awardDataset.getTopByMemberLive(memberId, true, lastValue); public topProposals = ( memberId: NetworkAddress, @@ -169,19 +160,22 @@ export class MemberApi extends BaseApi { orderByDir = ['desc'], lastValue?: string, ) => - this.proposalMemberRepo.getTopBySubColIdLive(memberId, orderBy, orderByDir, lastValue).pipe( - switchMap(async (members) => { - const result: Proposal[] = []; - for (const member of members) { - const proposal = (await this.proposalRepo.getById(member.parentId))!; - const endDate = proposal.settings.endDate?.toDate(); - if (endDate && dayjs(endDate).isAfter(dayjs(new Date()))) { - result.push(proposal); + this.proposalDataset + .subset(Subset.MEMBERS) + .getTopBySubColIdLive(memberId, orderBy, orderByDir, lastValue) + .pipe( + switchMap(async (members) => { + const result: Proposal[] = []; + for (const member of members) { + const proposal = (await this.proposalDataset.id(member.parentId).get())!; + const endDate = proposal.settings.endDate?.toDate(); + if (endDate && dayjs(endDate).isAfter(dayjs(new Date()))) { + result.push(proposal); + } } - } - return result; - }), - ); + return result; + }), + ); public topBadges( memberId: string, @@ -189,7 +183,7 @@ export class MemberApi extends BaseApi { lastValue?: string, ): Observable { const orderBys = Array.isArray(orderBy) ? orderBy : [orderBy]; - return this.transactionRepo.getBadgesForMemberLive(memberId, orderBys, lastValue); + return this.transactionDataset.getBadgesForMemberLive(memberId, orderBys, lastValue); } public topTransactions( @@ -199,11 +193,11 @@ export class MemberApi extends BaseApi { ): Observable { const orderBys = Array.isArray(orderBy) ? orderBy : [orderBy]; - const prevOwner = this.transactionRepo + const prevOwner = this.transactionDataset .getTopTransactionsLive(orderBys, lastValue, undefined, memberId) .pipe(map((result) => result.filter((t) => t.member !== memberId))); - const members = this.transactionRepo.getTopTransactionsLive(orderBys, lastValue, memberId); + const members = this.transactionDataset.getTopTransactionsLive(orderBys, lastValue, memberId); return combineLatest([prevOwner, members]).pipe( map((combined) => @@ -217,14 +211,17 @@ export class MemberApi extends BaseApi { } public allSpacesAsMember = (memberId: NetworkAddress, lastValue?: string) => - this.spaceMemberRepo.getTopBySubColIdLive(memberId, [], [], lastValue).pipe( - switchMap(async (spaceMembers) => { - const spacePromises = spaceMembers.map( - async (member) => (await this.spaceRepo.getById(member.parentId))!, - ); - return await Promise.all(spacePromises); - }), - ); + this.spaceDataset + .subset(Subset.MEMBERS) + .getTopBySubColIdLive(memberId, [], [], lastValue) + .pipe( + switchMap(async (spaceMembers) => { + const spacePromises = spaceMembers.map( + async (member) => (await this.spaceDataset.id(member.parentId).get())!, + ); + return await Promise.all(spacePromises); + }), + ); public createIfNotExists = (address: string): Observable => this.request(WEN_FUNC.createMember, { @@ -235,10 +232,12 @@ export class MemberApi extends BaseApi { }, }); - public updateMember = (req: WenRequest): Observable => + public updateMember = (req: Build5Request): Observable => this.request(WEN_FUNC.updateMember, req); - public generateAuthToken = (req: WenRequest): Observable => { + public generateAuthToken = ( + req: Build5Request, + ): Observable => { const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API; return this.httpClient.post(origin + WEN_FUNC.generateCustomToken, req, { responseType: 'text', diff --git a/src/app/@api/milestone.api.ts b/src/app/@api/milestone.api.ts index 6a1cbb9..27c082b 100644 --- a/src/app/@api/milestone.api.ts +++ b/src/app/@api/milestone.api.ts @@ -1,18 +1,17 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Milestone, PublicCollections } from '@build-5/interfaces'; -import { BaseApi, SOON_ENV } from './base.api'; -import { MilestoneRepository } from '@build-5/lib'; +import { Milestone, Dataset } from '@build-5/interfaces'; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class MilestoneApi extends BaseApi { - protected milestoneRepo = new MilestoneRepository(SOON_ENV); + protected milestoneDataset = this.project.dataset(Dataset.MILESTONE); constructor(protected httpClient: HttpClient) { - super(PublicCollections.MILESTONE, httpClient); + super(Dataset.MILESTONE, httpClient); } - public getTopMilestonesLive = () => this.milestoneRepo.getTopMilestonesLive(); + public getTopMilestonesLive = () => this.milestoneDataset.getTopLive(); } diff --git a/src/app/@api/nft.api.ts b/src/app/@api/nft.api.ts index 875b150..ca4fbe8 100644 --- a/src/app/@api/nft.api.ts +++ b/src/app/@api/nft.api.ts @@ -4,16 +4,20 @@ import { Member, Network, Nft, - PublicCollections, + Dataset, Transaction, TransactionPayloadType, TransactionType, WEN_FUNC, - WenRequest, + Build5Request, + NftCreateRequest, + NftSetForSaleRequest, + NftWithdrawRequest, + NftDepositRequest, + NftStakeRequest, } from '@build-5/interfaces'; -import { MemberRepository, NftRepository, TransactionRepository } from '@build-5/lib'; import { Observable, switchMap } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; export interface SuccesfullOrdersWithFullHistory { newMember: Member; @@ -30,30 +34,32 @@ export interface OffersHistory { providedIn: 'root', }) export class NftApi extends BaseApi { - private transactionRepo = new TransactionRepository(SOON_ENV); - private memberRepo = new MemberRepository(SOON_ENV); - private nftRepo = new NftRepository(SOON_ENV); + protected transactionDataset = this.project.dataset(Dataset.TRANSACTION); + protected memberDataset = this.project.dataset(Dataset.MEMBER); + protected nftDataset = this.project.dataset(Dataset.NFT); constructor(protected httpClient: HttpClient) { - super(PublicCollections.NFT, httpClient); + super(Dataset.NFT, httpClient); } - public create = (req: WenRequest): Observable => + public create = (req: Build5Request): Observable => this.request(WEN_FUNC.createNft, req); - public batchCreate = (req: WenRequest): Observable => + public batchCreate = (req: Build5Request): Observable => this.request(WEN_FUNC.createBatchNft, req); - public setForSaleNft = (req: WenRequest): Observable => + public setForSaleNft = (req: Build5Request): Observable => this.request(WEN_FUNC.setForSaleNft, req); - public withdrawNft = (req: WenRequest): Observable => - this.request(WEN_FUNC.withdrawNft, req); + public withdrawNft = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.withdrawNft, req); - public depositNft = (req: WenRequest): Observable => - this.request(WEN_FUNC.depositNft, req); + public depositNft = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.depositNft, req); - public stakeNft = (req: WenRequest): Observable => + public stakeNft = (req: Build5Request): Observable => this.request(WEN_FUNC.stakeNft, req); public successfullOrders( @@ -67,7 +73,7 @@ export class NftApi extends BaseApi { fieldNames.push('network'); fieldValues.push(network); } - return this.transactionRepo.getByFieldLive(fieldNames, fieldValues, lastValue).pipe( + return this.transactionDataset.getByFieldLive(fieldNames, fieldValues, lastValue).pipe( switchMap(async (transactions) => { const out: SuccesfullOrdersWithFullHistory[] = []; for (const transaction of transactions) { @@ -75,8 +81,8 @@ export class NftApi extends BaseApi { const sourceTransaction = Array.isArray(sourceTransactions) ? sourceTransactions[sourceTransactions.length - 1] : sourceTransactions; - const order = (await this.transactionRepo.getById(sourceTransaction!))!; - const member = (await this.memberRepo.getById(transaction.member!))!; + const order = (await this.transactionDataset.id(sourceTransaction!).get())!; + const member = (await this.memberDataset.id(transaction.member!).get())!; const successfullOrder: SuccesfullOrdersWithFullHistory = { newMember: member!, @@ -85,7 +91,7 @@ export class NftApi extends BaseApi { }; for (const link of order.linkedTransactions!) { - const linkedTransaction = (await this.transactionRepo.getById(link))!; + const linkedTransaction = (await this.transactionDataset.id(link).get())!; if ( (!linkedTransaction.payload.void && !linkedTransaction.payload.invalidPayment) || linkedTransaction.type === TransactionType.BILL_PAYMENT @@ -112,10 +118,10 @@ export class NftApi extends BaseApi { } public getOffers(nft: Nft, lastValue?: string): Observable { - return this.transactionRepo.getNftOffersLive(nft, lastValue).pipe( + return this.transactionDataset.getNftOffersLive(nft, lastValue).pipe( switchMap(async (transactions) => { const promises = transactions.map(async (transaction) => { - const member = (await this.memberRepo.getById(transaction.member!))!; + const member = (await this.memberDataset.id(transaction.member!).get())!; return { member, transaction } as OffersHistory; }); return (await Promise.all(promises)).sort( @@ -126,21 +132,21 @@ export class NftApi extends BaseApi { } public getMembersBids = (member: Member, nft: Nft, currentAuction = false, lastValue?: string) => - this.transactionRepo.getMembersBidsLive(member.uid, nft, currentAuction, lastValue).pipe( + this.transactionDataset.getMembersBidsLive(member.uid, nft, currentAuction, lastValue).pipe( switchMap(async (transactions) => { const promises = transactions.map(async (transaction) => { let sourceTransactions = transaction.payload.sourceTransaction; let sourceTransactionId = Array.isArray(sourceTransactions) ? sourceTransactions[sourceTransactions.length - 1] : sourceTransactions; - let sourceTransaction = (await this.transactionRepo.getById(sourceTransactionId!))!; + let sourceTransaction = (await this.transactionDataset.id(sourceTransactionId!).get())!; if (sourceTransaction.type === TransactionType.PAYMENT) { sourceTransactions = sourceTransaction.payload.sourceTransaction; sourceTransactionId = Array.isArray(sourceTransactions) ? sourceTransactions[sourceTransactions.length - 1] : sourceTransactions; - sourceTransaction = (await this.transactionRepo.getById(sourceTransactionId!))!; + sourceTransaction = (await this.transactionDataset.id(sourceTransactionId!).get())!; } const isNftBid = sourceTransaction.payload.type === TransactionPayloadType.NFT_BID; return isNftBid ? transaction : undefined; @@ -154,11 +160,11 @@ export class NftApi extends BaseApi { ); public lastCollection = (collection: string, lastValue?: string) => - this.nftRepo.getByCollectionLive(collection, ['createdOn'], ['asc'], lastValue); + this.nftDataset.getByCollectionLive(collection, ['createdOn'], ['asc'], lastValue); public positionInCollection = (collection: string, lastValue?: string) => - this.nftRepo.getByCollectionLive(collection, ['position'], ['asc'], lastValue); + this.nftDataset.getByCollectionLive(collection, ['position'], ['asc'], lastValue); public topMember = (member: string, lastValue?: string) => - this.nftRepo.getByOwnerLive(member, lastValue); + this.nftDataset.getByOwnerLive(member, lastValue); } diff --git a/src/app/@api/notification.api.ts b/src/app/@api/notification.api.ts index fba01ba..a9adb72 100644 --- a/src/app/@api/notification.api.ts +++ b/src/app/@api/notification.api.ts @@ -1,19 +1,18 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Notification, PublicCollections } from '@build-5/interfaces'; -import { NotificationRepository } from '@build-5/lib'; -import { BaseApi, SOON_ENV } from './base.api'; +import { Notification, Dataset } from '@build-5/interfaces'; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class NotificationApi extends BaseApi { - private notificationRepo = new NotificationRepository(SOON_ENV); + private notificationDataset = this.project.dataset(Dataset.NOTIFICATION); constructor(protected httpClient: HttpClient) { - super(PublicCollections.NOTIFICATION, httpClient); + super(Dataset.NOTIFICATION, httpClient); } public topMember = (memberUid: string, lastValue?: string, limit?: number) => - this.notificationRepo.getByMemberLive(memberUid, lastValue, limit); + this.notificationDataset.getByMemberLive(memberUid, lastValue, limit); } diff --git a/src/app/@api/order.api.ts b/src/app/@api/order.api.ts index 7f4c912..4ddae44 100644 --- a/src/app/@api/order.api.ts +++ b/src/app/@api/order.api.ts @@ -2,40 +2,45 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { NetworkAddress, - PublicCollections, + Dataset, Transaction, WEN_FUNC, - WenRequest, + Build5Request, + NftPurchaseRequest, + OrderTokenRequest, + AddressValidationRequest, + NftBidRequest, } from '@build-5/interfaces'; -import { TransactionRepository } from '@build-5/lib'; import { Observable, of } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class OrderApi extends BaseApi { - private transactionRepo = new TransactionRepository(SOON_ENV); + private transactionDataset = this.project.dataset(Dataset.TRANSACTION); constructor(protected httpClient: HttpClient) { - super(PublicCollections.TRANSACTION, httpClient); + super(Dataset.TRANSACTION, httpClient); } - public orderNft = (req: WenRequest): Observable => + public orderNft = (req: Build5Request): Observable => this.request(WEN_FUNC.orderNft, req); - public orderToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.orderToken, req); + public orderToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.orderToken, req); - public validateAddress = (req: WenRequest): Observable => - this.request(WEN_FUNC.validateAddress, req); + public validateAddress = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.validateAddress, req); - public openBid = (req: WenRequest): Observable => + public openBid = (req: Build5Request): Observable => this.request(WEN_FUNC.openBid, req); public listenMultiple = (ids: NetworkAddress[]) => ids.length - ? this.transactionRepo.getByFieldLive( + ? this.transactionDataset.getByFieldLive( ids.map(() => 'uid'), ids, ) diff --git a/src/app/@api/proposal.api.ts b/src/app/@api/proposal.api.ts index 752002a..9804f2c 100644 --- a/src/app/@api/proposal.api.ts +++ b/src/app/@api/proposal.api.ts @@ -1,23 +1,21 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { - NetworkAddress, Member, Proposal, - PublicCollections, + Dataset, Timestamp, Transaction, WEN_FUNC, - WenRequest, + Build5Request, + Subset, + ProposalCreateRequest, + ApproveProposalRequest, + RejectProposalRequest, + ProposalVoteRequest, } from '@build-5/interfaces'; -import { - MemberRepository, - ProposalMemberRepository, - ProposalRepository, - TransactionRepository, -} from '@build-5/lib'; import { Observable, map, of, switchMap } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; export enum ProposalFilter { ALL = 'all', @@ -44,30 +42,34 @@ export interface TransactionWithFullMember extends Transaction { providedIn: 'root', }) export class ProposalApi extends BaseApi { - private memberRepo = new MemberRepository(SOON_ENV); - private proposalRepo = new ProposalRepository(SOON_ENV); - private transactionRepo = new TransactionRepository(SOON_ENV); - private proposalMemberRepo = new ProposalMemberRepository(SOON_ENV); + private memberDataset = this.project.dataset(Dataset.MEMBER); + private proposalDataset = this.project.dataset(Dataset.PROPOSAL); + private transactionDataset = this.project.dataset(Dataset.TRANSACTION); constructor(protected httpClient: HttpClient) { - super(PublicCollections.PROPOSAL, httpClient); + super(Dataset.PROPOSAL, httpClient); } - public listen = (id: NetworkAddress) => this.proposalRepo.getByIdLive(id); - - public lastActive = (lastValue?: string) => this.proposalRepo.getActiveLive(lastValue); - - public listenSpace = ( - space: string, - filter: ProposalFilter = ProposalFilter.ALL, - lastValue?: string, - ) => this.proposalRepo.getBySpaceAndFilterLive(space, filter, lastValue); + public listenSpace = (space: string, filter = ProposalFilter.ALL, lastValue?: string) => { + switch (filter) { + case ProposalFilter.ALL: + return this.proposalDataset.getBySpaceLive(space, lastValue); + case ProposalFilter.ACTIVE: + return this.proposalDataset.getActiveLive(space, lastValue); + case ProposalFilter.COMPLETED: + return this.proposalDataset.getCompletedLive(space, lastValue); + case ProposalFilter.REJECTED: + return this.proposalDataset.getRejectedLive(space, lastValue); + case ProposalFilter.DRAFT: + return this.proposalDataset.getDraftLive(space, lastValue); + } + }; public lastVotes = (proposalId: string, lastValue?: string) => - this.transactionRepo.getLatestVotesForProposalLive(proposalId, undefined, lastValue).pipe( + this.transactionDataset.getLatestVotesForProposalLive(proposalId, undefined, lastValue).pipe( switchMap(async (transactions) => { const memberIds = Array.from(new Set(transactions.map((t) => t.member!))); - const memberPromises = memberIds.map((id) => this.memberRepo.getById(id)); + const memberPromises = memberIds.map((id) => this.memberDataset.id(id).get()); const members = await Promise.all(memberPromises); return transactions.map( @@ -81,60 +83,71 @@ export class ProposalApi extends BaseApi { ); public getMembersVotes = (proposalId: string, memberId: string, lastValue?: string) => - this.transactionRepo.getLatestVotesForProposalLive(proposalId, memberId, lastValue); + this.transactionDataset.getLatestVotesForProposalLive(proposalId, memberId, lastValue); public canMemberVote(proposalId: string, memberId: string) { if (!proposalId || !memberId) { return of(false); } - return this.proposalMemberRepo - .getByIdLive(proposalId, memberId) + return this.proposalDataset + .id(proposalId) + .subset(Subset.MEMBERS) + .subsetId(memberId) + .getLive() .pipe(map((member) => !!member)); } public listenPendingMembers = (proposalId: string, lastValue?: string) => - this.proposalMemberRepo.getVotingMembersLive(proposalId, false, lastValue).pipe( - switchMap(async (proposalMembers) => { - const memberPromises = proposalMembers.map(async (propMember) => { - const member = (await this.memberRepo.getById(propMember.uid))!; - return { - ...member, - voted: propMember.voted, - weight: propMember.weight, - values: propMember.values, - _issuedOn: propMember.createdOn, - } as ProposalParticipantWithMember; - }); - return await Promise.all(memberPromises); - }), - ); + this.proposalDataset + .id(proposalId) + .subset(Subset.MEMBERS) + .getVotingMembersLive(false, lastValue) + .pipe( + switchMap(async (proposalMembers) => { + const memberPromises = proposalMembers.map(async (propMember) => { + const member = (await this.memberDataset.id(propMember.uid).get())!; + return { + ...member, + voted: propMember.voted, + weight: propMember.weight, + values: propMember.values, + _issuedOn: propMember.createdOn, + } as ProposalParticipantWithMember; + }); + return await Promise.all(memberPromises); + }), + ); public listenVotedMembers = (proposalId: string, lastValue?: string) => - this.proposalMemberRepo.getVotingMembersLive(proposalId, true, lastValue).pipe( - switchMap(async (proposalMembers) => { - const memberPromises = proposalMembers.map(async (propMember) => { - const member = (await this.memberRepo.getById(propMember.uid))!; - return { - ...member, - voted: propMember.voted, - weight: propMember.weight, - values: propMember.values, - _issuedOn: propMember.createdOn, - } as ProposalParticipantWithMember; - }); - return await Promise.all(memberPromises); - }), - ); - - public create = (req: WenRequest): Observable => + this.proposalDataset + .id(proposalId) + .subset(Subset.MEMBERS) + .getVotingMembersLive(true, lastValue) + .pipe( + switchMap(async (proposalMembers) => { + const memberPromises = proposalMembers.map(async (propMember) => { + const member = (await this.memberDataset.id(propMember.uid).get())!; + return { + ...member, + voted: propMember.voted, + weight: propMember.weight, + values: propMember.values, + _issuedOn: propMember.createdOn, + } as ProposalParticipantWithMember; + }); + return await Promise.all(memberPromises); + }), + ); + + public create = (req: Build5Request): Observable => this.request(WEN_FUNC.createProposal, req); - public approve = (req: WenRequest): Observable => + public approve = (req: Build5Request): Observable => this.request(WEN_FUNC.approveProposal, req); - public reject = (req: WenRequest): Observable => + public reject = (req: Build5Request): Observable => this.request(WEN_FUNC.rejectProposal, req); - public vote = (req: WenRequest): Observable => + public vote = (req: Build5Request): Observable => this.request(WEN_FUNC.voteOnProposal, req); } diff --git a/src/app/@api/space.api.ts b/src/app/@api/space.api.ts index 45a32dd..e43b2bc 100644 --- a/src/app/@api/space.api.ts +++ b/src/app/@api/space.api.ts @@ -1,64 +1,80 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { - PublicCollections, + Build5Request, + Dataset, QUERY_MAX_LENGTH, Space, + SpaceClaimRequest, + SpaceCreateRequest, + SpaceJoinRequest, + SpaceLeaveRequest, SpaceMember, + SpaceMemberUpsertRequest, + SpaceUpdateRequest, + Subset, WEN_FUNC, - WenRequest, } from '@build-5/interfaces'; -import { - MemberRepository, - SpaceBlockedMemberRepository, - SpaceGuardianRepository, - SpaceKnockingMemberRepository, - SpaceMemberRepository, -} from '@build-5/lib'; import { Observable, map, of, switchMap } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; import { chunkArray } from '@core/utils/common.utils'; @Injectable({ providedIn: 'root', }) export class SpaceApi extends BaseApi { - private memberRepo = new MemberRepository(SOON_ENV); - private spaceMemberRepo = new SpaceMemberRepository(SOON_ENV); - private spaceGuardianRepo = new SpaceGuardianRepository(SOON_ENV); - private spaceBlockedRepo = new SpaceBlockedMemberRepository(SOON_ENV); - private spaceKnockingRepo = new SpaceKnockingMemberRepository(SOON_ENV); + private memberDataset = this.project.dataset(Dataset.MEMBER); + private spaceDataset = this.project.dataset(Dataset.SPACE); constructor(protected httpClient: HttpClient) { - super(PublicCollections.SPACE, httpClient); + super(Dataset.SPACE, httpClient); } public isMemberWithinSpace(spaceId: string, memberId: string): Observable { if (!spaceId || !memberId) { return of(false); } - return this.spaceMemberRepo.getByIdLive(spaceId, memberId).pipe(map((member) => !!member)); + return this.spaceDataset + .id(spaceId) + .subset(Subset.MEMBERS) + .subsetId(memberId) + .getLive() + .pipe(map((member) => !!member)); } public isGuardianWithinSpace(spaceId: string, memberId: string): Observable { if (!spaceId || !memberId) { return of(false); } - return this.spaceGuardianRepo.getByIdLive(spaceId, memberId).pipe(map((member) => !!member)); + return this.spaceDataset + .id(spaceId) + .subset(Subset.GUARDIANS) + .subsetId(memberId) + .getLive() + .pipe(map((member) => !!member)); } public isPendingMemberWithinSpace(spaceId: string, memberId: string): Observable { if (!spaceId || !memberId) { return of(false); } - return this.spaceKnockingRepo.getByIdLive(spaceId, memberId).pipe(map((member) => !!member)); + return this.spaceDataset + .id(spaceId) + .subset(Subset.KNOCKING_MEMBERS) + .subsetId(memberId) + .getLive() + .pipe(map((member) => !!member)); } public listenGuardians = (spaceId: string, lastValue?: string) => - this.spaceGuardianRepo.getAllLive(spaceId, lastValue).pipe(switchMap(this.getMembers)); + this.spaceDataset + .id(spaceId) + .subset(Subset.GUARDIANS) + .getAllLive(lastValue) + .pipe(switchMap(this.getMembers)); public getMembersWithoutData = (spaceId: string, lastValue?: string) => - this.spaceMemberRepo.getAll(spaceId, lastValue); + this.spaceDataset.id(spaceId).subset(Subset.MEMBERS).getAll(lastValue); public getAllMembersWithoutData = async (spaceId: string) => { const members: SpaceMember[] = []; @@ -73,66 +89,77 @@ export class SpaceApi extends BaseApi { public listenMembers = (spaceId: string, lastValue?: string, searchIds?: string[]) => { const baseObs = searchIds?.length - ? this.spaceMemberRepo.getManyByIdLive(searchIds.slice(0, 100), spaceId) - : this.spaceMemberRepo.getAllLive(spaceId, lastValue); + ? this.spaceDataset + .id(spaceId) + .subset(Subset.MEMBERS) + .getManyByIdLive(searchIds.slice(0, 100)) + : this.spaceDataset.id(spaceId).subset(Subset.MEMBERS).getAllLive(lastValue); return baseObs.pipe(switchMap(this.getMembers)); }; public listenBlockedMembers = (spaceId: string, lastValue?: string, searchIds?: string[]) => { + const subset = this.spaceDataset.id(spaceId).subset(Subset.BLOCKED_MEMBERS); const baseObs = searchIds?.length - ? this.spaceBlockedRepo.getManyByIdLive(searchIds.slice(0, 100), spaceId) - : this.spaceBlockedRepo.getAllLive(spaceId, lastValue); + ? subset.getManyByIdLive(searchIds.slice(0, 100)) + : subset.getAllLive(lastValue); return baseObs.pipe(switchMap(this.getMembers)); }; public listenPendingMembers = (spaceId: string, lastValue?: string, searchIds?: string[]) => { + const subset = this.spaceDataset.id(spaceId).subset(Subset.KNOCKING_MEMBERS); const baseObs = searchIds?.length - ? this.spaceKnockingRepo.getManyByIdLive(searchIds.slice(0, 100), spaceId) - : this.spaceKnockingRepo.getAllLive(spaceId, lastValue); + ? subset.getManyByIdLive(searchIds.slice(0, 100)) + : subset.getAllLive(lastValue); return baseObs.pipe(switchMap(this.getMembers)); }; private getMembers = async (spaceMembers: SpaceMember[]) => { const uids = spaceMembers.map((m) => m.uid); const promises = chunkArray(uids, QUERY_MAX_LENGTH).map((chunk) => - this.memberRepo.getManyById(chunk), + this.memberDataset.getManyById(chunk), ); return (await Promise.all(promises)).flat(); }; - public create = (req: WenRequest): Observable => + public create = (req: Build5Request): Observable => this.request(WEN_FUNC.createSpace, req); - public save = (req: WenRequest): Observable => + public save = (req: Build5Request): Observable => this.request(WEN_FUNC.updateSpace, req); - public join = (req: WenRequest): Observable => + public join = (req: Build5Request): Observable => this.request(WEN_FUNC.joinSpace, req); - public leave = (req: WenRequest): Observable => + public leave = (req: Build5Request): Observable => this.request(WEN_FUNC.leaveSpace, req); - public setGuardian = (req: WenRequest): Observable => - this.request(WEN_FUNC.addGuardianSpace, req); + public setGuardian = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.addGuardianSpace, req); - public claimSpace = (req: WenRequest): Observable => + public claimSpace = (req: Build5Request): Observable => this.request(WEN_FUNC.claimSpace, req); - public removeGuardian = (req: WenRequest): Observable => - this.request(WEN_FUNC.removeGuardianSpace, req); + public removeGuardian = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.removeGuardianSpace, req); - public blockMember = (req: WenRequest): Observable => - this.request(WEN_FUNC.blockMemberSpace, req); + public blockMember = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.blockMemberSpace, req); - public unblockMember = (req: WenRequest): Observable => - this.request(WEN_FUNC.unblockMemberSpace, req); + public unblockMember = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.unblockMemberSpace, req); - public acceptMember = (req: WenRequest): Observable => - this.request(WEN_FUNC.acceptMemberSpace, req); + public acceptMember = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.acceptMemberSpace, req); - public rejectMember = (req: WenRequest): Observable => - this.request(WEN_FUNC.declineMemberSpace, req); + public rejectMember = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.declineMemberSpace, req); - public update = (req: WenRequest): Observable => + public update = (req: Build5Request): Observable => this.request(WEN_FUNC.updateSpace, req); } diff --git a/src/app/@api/stake.ts b/src/app/@api/stake.ts index 5c6e5bd..8d4a1de 100644 --- a/src/app/@api/stake.ts +++ b/src/app/@api/stake.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { PublicCollections, Stake } from '@build-5/interfaces'; +import { Dataset, Stake } from '@build-5/interfaces'; import { BaseApi } from './base.api'; @Injectable({ @@ -8,6 +8,6 @@ import { BaseApi } from './base.api'; }) export class StakeApi extends BaseApi { constructor(protected httpClient: HttpClient) { - super(PublicCollections.STAKE, httpClient); + super(Dataset.STAKE, httpClient); } } diff --git a/src/app/@api/stake_reward.ts b/src/app/@api/stake_reward.ts index b4f80e7..0ada173 100644 --- a/src/app/@api/stake_reward.ts +++ b/src/app/@api/stake_reward.ts @@ -2,27 +2,28 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { MIN_AMOUNT_TO_TRANSFER, - PublicCollections, + Dataset, StakeReward, StakeRewardStatus, StakeType, TokenStats, WEN_FUNC, - WenRequest, + Build5Request, + TokenStakeRewardRequest, + TokenStakeRewardsRemoveRequest, } from '@build-5/interfaces'; -import { StakeRewardRepository } from '@build-5/lib'; import dayjs from 'dayjs'; import { Observable } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class StakeRewardApi extends BaseApi { - private stakeRewardRepo = new StakeRewardRepository(SOON_ENV); + private stakeRewardDataset = this.project.dataset(Dataset.STAKE_REWARD); constructor(protected httpClient: HttpClient) { - super(PublicCollections.STAKE_REWARD, httpClient); + super(Dataset.STAKE_REWARD, httpClient); } /** @@ -61,11 +62,13 @@ export class StakeRewardApi extends BaseApi { } public token = (token: string, lastValue?: string) => - this.stakeRewardRepo.getByTokenLive(token, lastValue); + this.stakeRewardDataset.getByTokenLive(token, lastValue); - public submit = (req: WenRequest): Observable => - this.request(WEN_FUNC.stakeReward, req); + public submit = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.stakeReward, req); - public remove = (req: WenRequest): Observable => - this.request(WEN_FUNC.removeStakeReward, req); + public remove = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.removeStakeReward, req); } diff --git a/src/app/@api/ticker.api.ts b/src/app/@api/ticker.api.ts index b7087d2..cbd598c 100644 --- a/src/app/@api/ticker.api.ts +++ b/src/app/@api/ticker.api.ts @@ -1,18 +1,13 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { PublicCollections, Ticker } from '@build-5/interfaces'; -import { TickerRepository } from '@build-5/lib'; -import { BaseApi, SOON_ENV } from './base.api'; +import { Dataset, Ticker } from '@build-5/interfaces'; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class TickerApi extends BaseApi { - private tickerRepo = new TickerRepository(SOON_ENV); - constructor(protected httpClient: HttpClient) { - super(PublicCollections.TICKER, httpClient); + super(Dataset.TICKER, httpClient); } - - public listen = (id: string) => this.tickerRepo.getByIdLive(id); } diff --git a/src/app/@api/token.api.ts b/src/app/@api/token.api.ts index 3bac963..a30267a 100644 --- a/src/app/@api/token.api.ts +++ b/src/app/@api/token.api.ts @@ -1,81 +1,108 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { - PublicCollections, + Dataset, QUERY_MAX_LENGTH, Token, TokenDistribution, Transaction, WEN_FUNC, - WenRequest, + Build5Request, + TokenCreateRequest, + TokenUpdateRequest, + VoteRequest, + RankRequest, + CanelPublicSaleRequest, + CreateAirdropsRequest, + SetTokenForSaleRequest, + CreditTokenRequest, + ClaimAirdroppedTokensRequest, + ClaimPreMintedAirdroppedTokensRequest, + TokenStakeRequest, + ProposalVoteRequest, + EnableTokenTradingRequest, + Subset, } from '@build-5/interfaces'; -import { TokenDistributionRepository, TokenRepository, TokenStatsRepository } from '@build-5/lib'; -import { Observable, firstValueFrom, lastValueFrom, of } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { Observable, of } from 'rxjs'; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class TokenApi extends BaseApi { - private tokenRepo = new TokenRepository(SOON_ENV); - private tokenStatsRepo = new TokenStatsRepository(SOON_ENV); - private tokenDistributionRepo = new TokenDistributionRepository(SOON_ENV); + private tokenDataset = this.project.dataset(Dataset.TOKEN); constructor(protected httpClient: HttpClient) { - super(PublicCollections.TOKEN, httpClient); + super(Dataset.TOKEN, httpClient); } - public create = (req: WenRequest): Observable => + public create = (req: Build5Request): Observable => this.request(WEN_FUNC.createToken, req); - public update = (req: WenRequest): Observable => + public update = (req: Build5Request): Observable => this.request(WEN_FUNC.updateToken, req); - public setTokenAvailableForSale = (req: WenRequest): Observable => - this.request(WEN_FUNC.setTokenAvailableForSale, req); + public setTokenAvailableForSale = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.setTokenAvailableForSale, req); - public vote = (req: WenRequest): Observable => + public vote = (req: Build5Request): Observable => this.request(WEN_FUNC.voteController, req); - public rank = (req: WenRequest): Observable => + public rank = (req: Build5Request): Observable => this.request(WEN_FUNC.rankController, req); - public cancelPublicSale = (req: WenRequest): Observable => - this.request(WEN_FUNC.cancelPublicSale, req); + public cancelPublicSale = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.cancelPublicSale, req); - public airdropToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.airdropToken, req); + public airdropToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.airdropToken, req); - public airdropMintedToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.airdropMintedToken, req); + public airdropMintedToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.airdropMintedToken, req); - public creditToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.creditToken, req); + public creditToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.creditToken, req); - public claimAirdroppedToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.claimAirdroppedToken, req); + public claimAirdroppedToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.claimAirdroppedToken, req); - public claimMintedToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.claimMintedTokenOrder, req); + public claimMintedToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.claimMintedTokenOrder, req); - public depositStake = (req: WenRequest): Observable => - this.request(WEN_FUNC.depositStake, req); + public depositStake = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.depositStake, req); - public voteOnProposal = (req: WenRequest): Observable => - this.request(WEN_FUNC.voteOnProposal, req); + public voteOnProposal = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.voteOnProposal, req); - public enableTrading = (req: WenRequest): Observable => - this.request(WEN_FUNC.enableTokenTrading, req); + public enableTrading = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.enableTokenTrading, req); public getMembersDistribution(tokenId: string, memberId: string) { if (!tokenId || !memberId) { return of(undefined); } - return this.tokenDistributionRepo.getByIdLive(tokenId.toLowerCase(), memberId.toLowerCase()); + return this.tokenDataset + .id(tokenId) + .subset(Subset.DISTRIBUTION) + .subsetId(memberId.toLowerCase()) + .getLive(); } public getDistributionsLive = (tokenId?: string, lastValue?: string) => - tokenId ? this.tokenDistributionRepo.getAllLive(tokenId.toLowerCase(), lastValue) : of([]); + tokenId + ? this.tokenDataset.id(tokenId).subset(Subset.DISTRIBUTION).getAllLive(lastValue) + : of([]); public getAllDistributions = async (tokenId?: string) => { if (!tokenId) { @@ -85,7 +112,10 @@ export class TokenApi extends BaseApi { let actDistributions: TokenDistribution[] = []; do { const last = distributions[distributions.length - 1]?.uid; - actDistributions = await this.tokenDistributionRepo.getAll(tokenId.toLowerCase(), last); + actDistributions = await this.tokenDataset + .id(tokenId) + .subset(Subset.DISTRIBUTION) + .getAll(last); distributions.push(...actDistributions); } while (actDistributions.length === QUERY_MAX_LENGTH); return distributions; @@ -96,7 +126,7 @@ export class TokenApi extends BaseApi { let actTokens: Token[] = []; do { const last = tokens[tokens.length - 1]?.uid; - actTokens = await this.tokenRepo.getByField('approved', true, last); + actTokens = await this.tokenDataset.getByField('approved', true, last); tokens.push(...actTokens); } while (actTokens.length === QUERY_MAX_LENGTH); return tokens; @@ -106,12 +136,16 @@ export class TokenApi extends BaseApi { if (!tokenId) { return of(undefined); } - return this.tokenStatsRepo.getByIdLive(tokenId.toLowerCase(), tokenId.toLowerCase()); + return this.tokenDataset + .id(tokenId.toLowerCase()) + .subset(Subset.STATS) + .subsetId(tokenId.toLowerCase()) + .getLive(); } public topPublic = (lastValue?: string, limit?: number) => - this.tokenRepo.getByStatusLive([], lastValue, limit); + this.tokenDataset.getByStatusLive([], lastValue, limit); public space = (space: string, lastValue?: string) => - this.tokenRepo.getBySpaceLive(space, lastValue); + this.tokenDataset.getBySpaceLive(space, lastValue); } diff --git a/src/app/@api/token_market.api.ts b/src/app/@api/token_market.api.ts index 37bf9c3..d5c1c41 100644 --- a/src/app/@api/token_market.api.ts +++ b/src/app/@api/token_market.api.ts @@ -1,29 +1,30 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { - PublicCollections, + Dataset, TokenTradeOrder, TokenTradeOrderStatus, TokenTradeOrderType, WEN_FUNC, - WenRequest, + Build5Request, + TradeTokenRequest, + CancelTokenTradeOrderRequest, } from '@build-5/interfaces'; -import { TokenMarketRepository } from '@build-5/lib'; import { Observable, map } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class TokenMarketApi extends BaseApi { - private tokenMarketRepo = new TokenMarketRepository(SOON_ENV); + private tokenMarketDataset = this.project.dataset(Dataset.TOKEN_MARKET); constructor(protected httpClient: HttpClient) { - super(PublicCollections.TOKEN_MARKET, httpClient); + super(Dataset.TOKEN_MARKET, httpClient); } public bidsActive = (token: string, lastValue?: string) => - this.tokenMarketRepo.getBidsLive( + this.tokenMarketDataset.getBidsLive( token, TokenTradeOrderType.BUY, TokenTradeOrderStatus.ACTIVE, @@ -31,7 +32,7 @@ export class TokenMarketApi extends BaseApi { ); public asksActive = (token: string, lastValue?: string) => - this.tokenMarketRepo.getBidsLive( + this.tokenMarketDataset.getBidsLive( token, TokenTradeOrderType.SELL, TokenTradeOrderStatus.ACTIVE, @@ -39,17 +40,19 @@ export class TokenMarketApi extends BaseApi { ); public membersBids = (member: string, token: string, lastValue?: string) => - this.tokenMarketRepo.getMemberBidsLive(token, member, TokenTradeOrderType.BUY, lastValue); + this.tokenMarketDataset.getMemberBidsLive(token, member, TokenTradeOrderType.BUY, lastValue); public membersAsks = (member: string, token: string, lastValue?: string) => - this.tokenMarketRepo.getMemberBidsLive(token, member, TokenTradeOrderType.SELL, lastValue); + this.tokenMarketDataset.getMemberBidsLive(token, member, TokenTradeOrderType.SELL, lastValue); public listenAvgPrice = (tokenId: string) => - this.tokenMarketRepo.getTokenPriceLive(tokenId).pipe(map((result) => result.price)); + this.tokenMarketDataset.getTokenPriceLive(tokenId).pipe(map((result) => result.price)); - public tradeToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.tradeToken, req); + public tradeToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.tradeToken, req); - public cancel = (req: WenRequest): Observable => - this.request(WEN_FUNC.cancelTradeOrder, req); + public cancel = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.cancelTradeOrder, req); } diff --git a/src/app/@api/token_mint.api.ts b/src/app/@api/token_mint.api.ts index 99c5769..7dec599 100644 --- a/src/app/@api/token_mint.api.ts +++ b/src/app/@api/token_mint.api.ts @@ -1,6 +1,14 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { PublicCollections, Token, Transaction, WEN_FUNC, WenRequest } from '@build-5/interfaces'; +import { + Dataset, + Token, + Transaction, + WEN_FUNC, + Build5Request, + TokenMintRequest, + ImportMintedTokenRequest, +} from '@build-5/interfaces'; import { Observable } from 'rxjs'; import { BaseApi } from './base.api'; @@ -9,12 +17,13 @@ import { BaseApi } from './base.api'; }) export class TokenMintApi extends BaseApi { constructor(protected httpClient: HttpClient) { - super(PublicCollections.TOKEN, httpClient); + super(Dataset.TOKEN, httpClient); } - public mintToken = (req: WenRequest): Observable => + public mintToken = (req: Build5Request): Observable => this.request(WEN_FUNC.mintTokenOrder, req); - public importToken = (req: WenRequest): Observable => - this.request(WEN_FUNC.importMintedToken, req); + public importToken = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.importMintedToken, req); } diff --git a/src/app/@api/token_purchase.api.ts b/src/app/@api/token_purchase.api.ts index d221076..a175ab0 100644 --- a/src/app/@api/token_purchase.api.ts +++ b/src/app/@api/token_purchase.api.ts @@ -1,49 +1,53 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { - PublicCollections, + Dataset, + Subset, TokenPurchase, TokenPurchaseAge, TokenTradeOrder, TokenTradeOrderType, } from '@build-5/interfaces'; -import { TokenPurchaseRepository, TokenStatsRepository } from '@build-5/lib'; import { map } from 'rxjs'; -import { BaseApi, SOON_ENV } from './base.api'; - -const TRADE_HISTORY_SIZE = 100; +import { BaseApi } from './base.api'; @Injectable({ providedIn: 'root', }) export class TokenPurchaseApi extends BaseApi { - private tokenStatRepo = new TokenStatsRepository(SOON_ENV); - private tokenPurchaseRepo = new TokenPurchaseRepository(SOON_ENV); + private tokenDataset = this.project.dataset(Dataset.TOKEN); + private tokenPurchaseDataset = this.project.dataset(Dataset.TOKEN_PURCHASE); constructor(protected httpClient: HttpClient) { - super(PublicCollections.TOKEN_PURCHASE, httpClient); + super(Dataset.TOKEN_PURCHASE, httpClient); } public listenVolume7d = (tokenId: string) => - this.tokenStatRepo - .getByIdLive(tokenId, tokenId) + this.tokenDataset + .id(tokenId) + .subset(Subset.STATS) + .subsetId(tokenId) + .getLive() .pipe(map((stats) => (stats?.volume || {})[TokenPurchaseAge.IN_7_D] || 0)); public listenVolume24h = (tokenId: string) => - this.tokenStatRepo - .getByIdLive(tokenId, tokenId) + this.tokenDataset + .id(tokenId) + .subset(Subset.STATS) + .subsetId(tokenId) + .getLive() .pipe(map((stats) => (stats?.volume || {})[TokenPurchaseAge.IN_24_H] || 0)); - public listenAvgPrice7d = (tokenId: string) => this.tokenPurchaseRepo.getAvgPriceLive(tokenId); + public listenAvgPrice7d = (tokenId: string) => this.tokenPurchaseDataset.getAvgPriceLive(tokenId); public listenChangePrice24h = (tokenId: string) => - this.tokenPurchaseRepo.getPriceChangeLive(tokenId); + this.tokenPurchaseDataset.getPriceChangeLive(tokenId); public listenToPurchases = (tokenId: string, lastValue?: string) => - this.tokenPurchaseRepo.getPuchasesLive(tokenId, lastValue); + this.tokenPurchaseDataset.getPuchasesLive(tokenId, lastValue); public getPurchasesForTrade = (tradeOrder: TokenTradeOrder, lastValue?: string) => - this.tokenPurchaseRepo.getByFieldLive( + this.tokenPurchaseDataset.getByFieldLive( tradeOrder.type === TokenTradeOrderType.BUY ? 'buy' : 'sell', tradeOrder.uid, lastValue, diff --git a/src/app/@api/transaction.api.ts b/src/app/@api/transaction.api.ts index d6daec5..c57faaf 100644 --- a/src/app/@api/transaction.api.ts +++ b/src/app/@api/transaction.api.ts @@ -1,6 +1,12 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { PublicCollections, Transaction, WEN_FUNC, WenRequest } from '@build-5/interfaces'; +import { + Dataset, + Transaction, + WEN_FUNC, + Build5Request, + CreditUnrefundableRequest, +} from '@build-5/interfaces'; import { Observable } from 'rxjs'; import { BaseApi } from './base.api'; @@ -9,9 +15,10 @@ import { BaseApi } from './base.api'; }) export class TransactionApi extends BaseApi { constructor(protected httpClient: HttpClient) { - super(PublicCollections.TRANSACTION, httpClient); + super(Dataset.TRANSACTION, httpClient); } - public creditUnrefundable = (req: WenRequest): Observable => - this.request(WEN_FUNC.creditUnrefundable, req); + public creditUnrefundable = ( + req: Build5Request, + ): Observable => this.request(WEN_FUNC.creditUnrefundable, req); } diff --git a/src/app/components/auth/services/auth.service.ts b/src/app/components/auth/services/auth.service.ts index d9e88b5..7ad5cd3 100644 --- a/src/app/components/auth/services/auth.service.ts +++ b/src/app/components/auth/services/auth.service.ts @@ -17,7 +17,7 @@ import { Network, StakeType, TOKEN_EXPIRY_HOURS, - WenRequest, + Build5Request, } from '@build-5/interfaces'; import dayjs from 'dayjs'; import { NzNotificationService } from 'ng-zorro-antd/notification'; @@ -29,7 +29,7 @@ const tanglePay = (window as any).iota; export interface MetamaskSignature { address: string; - req: WenRequest; + req: Build5Request; } export interface SignCallback { @@ -202,7 +202,7 @@ export class AuthService { return customToken && customToken.expiresOn && dayjs(customToken.expiresOn).isAfter(dayjs()); } - public async sign(params: any = {}, cb: SignCallback): Promise { + public async sign(params: any = {}, cb: SignCallback): Promise | undefined> { this.showWalletPopup$.next(WalletStatus.ACTIVE); // We support either resign with metamask or reuse token. let sc: any | undefined | false = undefined; @@ -332,7 +332,9 @@ export class AuthService { } } - private async signWithTanglePay(params: any = {}): Promise { + private async signWithTanglePay( + params: any = {}, + ): Promise | undefined | false> { let currentAddress: string | undefined = undefined; if (tanglePay.isTanglePay) { try { @@ -438,7 +440,7 @@ export class AuthService { public async signIn(wallet: Wallets = Wallets.Metamask): Promise { this.showWalletPopup$.next(WalletStatus.ACTIVE); - let sc: WenRequest | undefined | false; + let sc: Build5Request | undefined | false; if (wallet === Wallets.Metamask) { sc = await this.signWithMetamask({}); } else if (wallet === Wallets.TanglePay) { diff --git a/src/app/pages/award/pages/award/award.page.html b/src/app/pages/award/pages/award/award.page.html index 3849497..bf2d012 100644 --- a/src/app/pages/award/pages/award/award.page.html +++ b/src/app/pages/award/pages/award/award.page.html @@ -134,7 +134,7 @@

{{(data.award$ | async)?.name}}

class="block p-6 mb-4 lg:p-0" i18n-shareText shareText="Check out award" - [shareUrl]="helper.getShareUrl(data.award$ | async)" + [shareUrl]="helper.getShareUrl()" > @@ -208,7 +208,7 @@

{{(data.award$ | async)?.name}}

class="block p-6 mb-4 lg:p-0" i18n-shareText shareText="Check out award" - [shareUrl]="helper.getShareUrl(data.award$ | async)" + [shareUrl]="helper.getShareUrl()" > diff --git a/src/app/pages/award/services/helper.service.ts b/src/app/pages/award/services/helper.service.ts index 51b8f43..ccc0d06 100644 --- a/src/app/pages/award/services/helper.service.ts +++ b/src/app/pages/award/services/helper.service.ts @@ -25,7 +25,7 @@ export class HelperService { ); } - public getShareUrl(award?: Award | null): string { - return award?.wenUrl || window?.location.href; + public getShareUrl(): string { + return window?.location.href; } } diff --git a/src/app/pages/collection/pages/collection/collection.page.html b/src/app/pages/collection/pages/collection/collection.page.html index 7fb5b0a..165a0d5 100644 --- a/src/app/pages/collection/pages/collection/collection.page.html +++ b/src/app/pages/collection/pages/collection/collection.page.html @@ -214,11 +214,7 @@

{{ (data.collection$ | async)?.name }}

>
Links
- + diff --git a/src/app/pages/collection/services/helper.service.ts b/src/app/pages/collection/services/helper.service.ts index 11f4797..c586da6 100644 --- a/src/app/pages/collection/services/helper.service.ts +++ b/src/app/pages/collection/services/helper.service.ts @@ -64,9 +64,9 @@ export class HelperService { }); } - public getShareUrl(col?: Collection | null): string { + public getShareUrl(): string { const text = $localize`Check out collection`; - const url: string = col?.wenUrl || window?.location.href; + const url: string = window?.location.href; return 'https://twitter.com/share?text= ' + text + ' &url=' + url + '&hashtags=soonaverse'; } diff --git a/src/app/pages/nft/pages/nft/nft.page.html b/src/app/pages/nft/pages/nft/nft.page.html index fe6a96a..2c6a472 100644 --- a/src/app/pages/nft/pages/nft/nft.page.html +++ b/src/app/pages/nft/pages/nft/nft.page.html @@ -46,7 +46,7 @@

{{ getTitle(data.nft$ | async) }}

class="block mt-5 mb-8" i18n-shareText shareText="Check out nft" - [shareUrl]="helper.getShareUrl(data.nft$ | async)" + [shareUrl]="helper.getShareUrl()" > @@ -515,7 +515,7 @@

{{ getTitle(data.nft$ | async) }}

class="block mt-6" i18n-shareText shareText="Check out nft" - [shareUrl]="helper.getShareUrl(data.nft$ | async)" + [shareUrl]="helper.getShareUrl()" > diff --git a/src/app/pages/nft/services/helper.service.ts b/src/app/pages/nft/services/helper.service.ts index a177252..ae5f98a 100644 --- a/src/app/pages/nft/services/helper.service.ts +++ b/src/app/pages/nft/services/helper.service.ts @@ -149,8 +149,8 @@ export class HelperService { return ''; } - public getShareUrl(nft?: Nft | null): string { - return nft?.wenUrl || window?.location.href; + public getShareUrl(): string { + return window?.location.href; } public isLocked(nft?: Nft | null, col?: Collection | null, exceptMember = false): boolean { diff --git a/src/app/pages/proposal/pages/proposal/proposal.page.html b/src/app/pages/proposal/pages/proposal/proposal.page.html index fbc6bcb..18ebb41 100644 --- a/src/app/pages/proposal/pages/proposal/proposal.page.html +++ b/src/app/pages/proposal/pages/proposal/proposal.page.html @@ -77,7 +77,7 @@

{{(data.proposal$ | async)?.name}}

class="block mb-4 p-6 lg:p-0" i18n-shareText shareText="Check out proposal" - [shareUrl]="helper.getShareUrl(data.proposal$ | async)" + [shareUrl]="helper.getShareUrl()" > @@ -150,7 +150,7 @@

{{(data.proposal$ | async)?.name}}

class="block mt-10 mb-4 p-6 lg:p-0" i18n-shareText shareText="Check out proposal" - [shareUrl]="helper.getShareUrl(data.proposal$ | async)" + [shareUrl]="helper.getShareUrl()" > diff --git a/src/app/pages/proposal/services/helper.service.ts b/src/app/pages/proposal/services/helper.service.ts index 801bcf4..70a84e3 100644 --- a/src/app/pages/proposal/services/helper.service.ts +++ b/src/app/pages/proposal/services/helper.service.ts @@ -110,7 +110,7 @@ export class HelperService { return type === ProposalType.NATIVE; } - public getShareUrl(proposal?: Proposal | null): string { - return proposal?.wenUrl || window?.location.href; + public getShareUrl(): string { + return window?.location.href; } } diff --git a/src/app/pages/space/pages/awards/awards.page.ts b/src/app/pages/space/pages/awards/awards.page.ts index 66a6ae2..f4ada43 100644 --- a/src/app/pages/space/pages/awards/awards.page.ts +++ b/src/app/pages/space/pages/awards/awards.page.ts @@ -12,9 +12,9 @@ import { SeoService } from '@core/services/seo'; import { ROUTER_UTILS } from '@core/utils/router.utils'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Award } from '@build-5/interfaces'; -import { AwardFilter } from '@build-5/lib'; import { BehaviorSubject, Subscription } from 'rxjs'; import { DataService } from './../../services/data.service'; +import { AwardFilter } from '@api/base.api'; @UntilDestroy() @Component({ diff --git a/src/app/pages/space/pages/space/space-about/space-about.component.html b/src/app/pages/space/pages/space/space-about/space-about.component.html index e1ff5a5..593822d 100644 --- a/src/app/pages/space/pages/space/space-about/space-about.component.html +++ b/src/app/pages/space/pages/space/space-about/space-about.component.html @@ -32,7 +32,7 @@

{{ (data.space$ | async)?.name }}

class="block p-6 mb-4 lg:p-0" i18n-shareText shareText="Check out space" - [shareUrl]="getShareUrl(data.space$ | async)" + [shareUrl]="getShareUrl()" > diff --git a/src/app/pages/space/pages/space/space-about/space-about.component.ts b/src/app/pages/space/pages/space/space-about/space-about.component.ts index 28c8e3f..b7adbd7 100644 --- a/src/app/pages/space/pages/space/space-about/space-about.component.ts +++ b/src/app/pages/space/pages/space/space-about/space-about.component.ts @@ -91,8 +91,8 @@ export class SpaceAboutComponent implements OnInit, OnDestroy { return item.uid; } - public getShareUrl(space?: Space | null): string { - return space?.wenUrl || window?.location.href; + public getShareUrl(): string { + return window?.location.href; } public loggedInUserStake(): Observable { diff --git a/src/app/pages/space/services/data.service.ts b/src/app/pages/space/services/data.service.ts index 542ad9e..332bde7 100644 --- a/src/app/pages/space/services/data.service.ts +++ b/src/app/pages/space/services/data.service.ts @@ -12,7 +12,6 @@ import { TokenDistribution, TokenStats, } from '@build-5/interfaces'; -import { AwardFilter } from '@build-5/lib'; import { BehaviorSubject, Subscription } from 'rxjs'; import { map } from 'rxjs/operators'; import { @@ -20,7 +19,7 @@ import { AuditOneResponseMember, } from 'src/app/service-modules/audit-one/services/query.service'; import { AwardApi } from './../../../@api/award.api'; -import { DEFAULT_LIST_SIZE } from './../../../@api/base.api'; +import { AwardFilter, DEFAULT_LIST_SIZE } from './../../../@api/base.api'; import { ProposalApi, ProposalFilter } from './../../../@api/proposal.api'; import { SpaceApi } from './../../../@api/space.api'; import { AuthService } from './../../../components/auth/services/auth.service'; diff --git a/src/app/pages/token/pages/token/token-buy/token-buy.component.html b/src/app/pages/token/pages/token/token-buy/token-buy.component.html index 2f72097..fd68fbf 100644 --- a/src/app/pages/token/pages/token/token-buy/token-buy.component.html +++ b/src/app/pages/token/pages/token/token-buy/token-buy.component.html @@ -98,7 +98,7 @@ class="block mb-4" i18n-shareText shareText="Check out token" - [shareUrl]="helper.getShareUrl(data.token$ | async)" + [shareUrl]="helper.getShareUrl()" [size]="shareSizes.LARGE" > diff --git a/src/app/pages/token/pages/trade/trade.page.html b/src/app/pages/token/pages/trade/trade.page.html index 557a601..17abb42 100644 --- a/src/app/pages/token/pages/trade/trade.page.html +++ b/src/app/pages/token/pages/trade/trade.page.html @@ -57,7 +57,7 @@
Token Info
- + @@ -621,7 +621,7 @@ > - +