Skip to content

Commit

Permalink
Merge pull request #7 from soonaverse/develop
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
adamunchained authored Jul 4, 2023
2 parents 4e4723a + f13dd62 commit 1acd1d5
Show file tree
Hide file tree
Showing 53 changed files with 229 additions and 208 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Action | Auto deploy "develop" to wen.soonaverse.com

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm install
- name: Build project
run: npm run build
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
branch: main
directory: dist
33 changes: 33 additions & 0 deletions .github/workflows/deploy-wen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Action | Auto deploy "develop" to wen.soonaverse.com

on:
push:
branches:
- develop

jobs:
publish:
runs-on: ubuntu-latest
environment: develop
permissions:
contents: read
deployments: write
name: Publish to Cloudflare Pages
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm install
- name: Build project
run: npm run build
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
branch: main
directory: dist
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"endOfLine": "auto"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"i18n": "ng extract-i18n --out-file=src/locale/messages.xlf",
"analyze": "webpack-bundle-analyzer dist/soonaverse/stats.json",
"dev:ssr": "node --max-old-space-size=8192 node_modules/@angular/cli/bin/ng run soonaverse:serve-ssr",
"serve:ssr": "node dist/soonaverse-server/main.js"
"serve:ssr": "node dist/soonaverse-server/main.js",
"prettier": "npx prettier --write ./src"
},
"dependencies": {
"@angular/animations": "15.1.3",
Expand Down
12 changes: 5 additions & 7 deletions src/app/@api/base.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { environment } from '@env/environment';
import {
EthAddress,
PublicCollections,
SOON_PROD_ADDRESS_API,
SOON_TEST_ADDRESS_API,
BUILD5_PROD_ADDRESS_API,
BUILD5_TEST_ADDRESS_API,
WEN_FUNC,
} from '@build-5/interfaces';
import { SoonEnv, initSoonEnv } from '@build-5/lib';
import { Build5Env } from '@build-5/lib';
import { CrudRepository } from '@build-5/lib/lib/repositories/CrudRepository';
import { Observable, map } from 'rxjs';

Expand All @@ -18,9 +18,7 @@ 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 ? SoonEnv.PROD : SoonEnv.TEST;

initSoonEnv(SOON_ENV);
export const SOON_ENV = environment.production ? Build5Env.PROD : Build5Env.TEST;

export class BaseApi<T> {
protected repo: CrudRepository<T>;
Expand All @@ -36,7 +34,7 @@ export class BaseApi<T> {
public top = (lastValue?: string, limit?: number) => this.repo.getTopLive(lastValue, limit);

protected request<T>(func: WEN_FUNC, req: any): Observable<T | undefined> {
const origin = environment.production ? SOON_PROD_ADDRESS_API : SOON_TEST_ADDRESS_API;
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));
}
}
6 changes: 3 additions & 3 deletions src/app/@api/file.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Injectable } from '@angular/core';
import { environment } from '@env/environment';
import {
FILE_SIZES,
SOON_PROD_ADDRESS_API,
SOON_TEST_ADDRESS_API,
BUILD5_PROD_ADDRESS_API,
BUILD5_TEST_ADDRESS_API,
WEN_FUNC,
} from '@build-5/interfaces';
import { NzUploadXHRArgs } from 'ng-zorro-antd/upload';
Expand Down Expand Up @@ -47,7 +47,7 @@ export class FileApi {
formData.append('file', <Blob>item.postFile);
formData.append('member', memberId);
formData.append('uid', item.file.uid);
const origin = environment.production ? SOON_PROD_ADDRESS_API : SOON_TEST_ADDRESS_API;
const origin = environment.production ? BUILD5_PROD_ADDRESS_API : BUILD5_TEST_ADDRESS_API;
return this.httpClient
.post(origin + WEN_FUNC.uploadFile, formData)
.pipe(
Expand Down
20 changes: 9 additions & 11 deletions src/app/@api/nft.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import {
Nft,
PublicCollections,
Transaction,
TransactionOrder,
TransactionOrderType,
TransactionPayment,
TransactionPayloadType,
TransactionType,
WEN_FUNC,
WenRequest,
Expand All @@ -19,13 +17,13 @@ import { BaseApi, SOON_ENV } from './base.api';

export interface SuccesfullOrdersWithFullHistory {
newMember: Member;
order: TransactionOrder;
order: Transaction;
transactions: Transaction[];
}

export interface OffersHistory {
member: Member;
transaction: TransactionPayment;
transaction: Transaction;
}

@Injectable({
Expand Down Expand Up @@ -77,7 +75,7 @@ export class NftApi extends BaseApi<Nft> {
const sourceTransaction = Array.isArray(sourceTransactions)
? sourceTransactions[sourceTransactions.length - 1]
: sourceTransactions;
const order = (await this.transactionRepo.getById(sourceTransaction))!;
const order = (await this.transactionRepo.getById(sourceTransaction!))!;
const member = (await this.memberRepo.getById(transaction.member!))!;

const successfullOrder: SuccesfullOrdersWithFullHistory = {
Expand All @@ -86,7 +84,7 @@ export class NftApi extends BaseApi<Nft> {
transactions: [],
};

for (const link of order.linkedTransactions) {
for (const link of order.linkedTransactions!) {
const linkedTransaction = (await this.transactionRepo.getById(link))!;
if (
(!linkedTransaction.payload.void && !linkedTransaction.payload.invalidPayment) ||
Expand Down Expand Up @@ -121,7 +119,7 @@ export class NftApi extends BaseApi<Nft> {
return { member, transaction } as OffersHistory;
});
return (await Promise.all(promises)).sort(
(a, b) => b.transaction.payload.amount - a.transaction.payload.amount,
(a, b) => Number(b.transaction.payload.amount) - Number(a.transaction.payload.amount),
);
}),
);
Expand All @@ -135,16 +133,16 @@ export class NftApi extends BaseApi<Nft> {
let sourceTransactionId = Array.isArray(sourceTransactions)
? sourceTransactions[sourceTransactions.length - 1]
: sourceTransactions;
let sourceTransaction = (await this.transactionRepo.getById(sourceTransactionId))!;
let sourceTransaction = (await this.transactionRepo.getById(sourceTransactionId!))!;

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.transactionRepo.getById(sourceTransactionId!))!;
}
const isNftBid = sourceTransaction.payload.type === TransactionOrderType.NFT_BID;
const isNftBid = sourceTransaction.payload.type === TransactionPayloadType.NFT_BID;
return isNftBid ? transaction : undefined;
});

Expand Down
16 changes: 9 additions & 7 deletions src/app/@api/space.api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import {
Member,
PublicCollections,
QUERY_MAX_LENGTH,
Space,
SpaceMember,
WEN_FUNC,
Expand All @@ -16,6 +18,7 @@ import {
} from '@build-5/lib';
import { Observable, map, of, switchMap } from 'rxjs';
import { BaseApi, SOON_ENV } from './base.api';
import { chunkArray } from '@core/utils/common.utils';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -55,10 +58,8 @@ export class SpaceApi extends BaseApi<Space> {
public listenGuardians = (spaceId: string, lastValue?: string) =>
this.spaceGuardianRepo.getAllLive(spaceId, lastValue).pipe(switchMap(this.getMembers));

public listenMembersWithoutData = (spaceId: string, lastValue?: string) =>
this.spaceMemberRepo
.getAllLive(spaceId, lastValue)
.pipe(map((members) => members.map((m) => ({ uid: m.uid }))));
public getMembersWithoutData = (spaceId: string, lastValue?: string) =>
this.spaceMemberRepo.getAll(spaceId, lastValue);

public listenMembers = (spaceId: string, lastValue?: string) =>
this.spaceMemberRepo.getAllLive(spaceId, lastValue).pipe(switchMap(this.getMembers));
Expand All @@ -70,10 +71,11 @@ export class SpaceApi extends BaseApi<Space> {
this.spaceKnockingRepo.getAllLive(spaceId, lastValue).pipe(switchMap(this.getMembers));

private getMembers = async (spaceMembers: SpaceMember[]) => {
const promises = spaceMembers.map(
async (spaceMember) => (await this.memberRepo.getById(spaceMember.uid))!,
const uids = spaceMembers.map((m) => m.uid);
const promises = chunkArray(uids, QUERY_MAX_LENGTH).map((chunk) =>
this.memberRepo.getManyById(chunk),
);
return await Promise.all(promises);
return (await Promise.all(promises)).flat();
};

public create = (req: WenRequest): Observable<Space | undefined> =>
Expand Down
9 changes: 1 addition & 8 deletions src/app/@api/token.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import {
WEN_FUNC,
WenRequest,
} from '@build-5/interfaces';
import {
TokenDistributionRepository,
TokenRepository,
TokenStatsRepository,
} from '@build-5/lib';
import { TokenDistributionRepository, TokenRepository, TokenStatsRepository } from '@build-5/lib';
import { Observable, of } from 'rxjs';
import { BaseApi, SOON_ENV } from './base.api';

Expand Down Expand Up @@ -94,9 +90,6 @@ export class TokenApi extends BaseApi<Token> {
public topPublic = (lastValue?: string, limit?: number) =>
this.tokenRepo.getByStatusLive([], lastValue, limit);

public top = (lastValue?: string, limit?: number): Observable<Token[]> =>
this.tokenRepo.getTopLive(lastValue, limit);

public space = (space: string, lastValue?: string) =>
this.tokenRepo.getBySpaceLive(space, lastValue);
}
8 changes: 1 addition & 7 deletions src/app/@api/token_mint.api.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import {
PublicCollections,
Token,
Transaction,
WEN_FUNC,
WenRequest,
} from '@build-5/interfaces';
import { PublicCollections, Token, Transaction, WEN_FUNC, WenRequest } from '@build-5/interfaces';
import { Observable } from 'rxjs';
import { BaseApi } from './base.api';

Expand Down
6 changes: 4 additions & 2 deletions src/app/@core/pipes/formatToken/format-token.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ export class FormatTokenPipe implements PipeTransform {
}

public async transform(
value: number | null | undefined | ConvertValue,
value: string | number | null | undefined | ConvertValue,
tokenUidOrNetwork?: string | null,
removeZeroes = false,
showUnit = true,
defDecimals = DEF_DECIMALS,
): Promise<string> {
let network = DEFAULT_NETWORK;
if (typeof value === 'object') {
if (typeof value === 'string') {
value = Number(value);
} else if (typeof value === 'object') {
if (value?.value) {
value = this.multiValue(value);
} else {
Expand Down
18 changes: 9 additions & 9 deletions src/app/@core/services/transaction/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {
DEF_WALLET_PAY_IN_PROGRESS,
Network,
Transaction,
TransactionMintCollectionType,
TransactionMintTokenType,
TransactionPayloadType,
TransactionType,
} from '@build-5/interfaces';

Expand Down Expand Up @@ -45,15 +44,15 @@ export class TransactionService {

public getMintedSubtypesText(t: Transaction): string {
let base = '';
if (t.payload.type === TransactionMintCollectionType.MINT_ALIAS) {
if (t.payload.type === TransactionPayloadType.MINT_ALIAS) {
base += ' ' + $localize`(Mint Alias)`;
} else if (t.payload.type === TransactionMintCollectionType.MINT_NFTS) {
} else if (t.payload.type === TransactionPayloadType.MINT_NFTS) {
base += ' ' + $localize`(Mint NFTs)`;
} else if (t.payload.type === TransactionMintTokenType.MINT_FOUNDRY) {
} else if (t.payload.type === TransactionPayloadType.MINT_FOUNDRY) {
base += ' ' + $localize`(Mint Foundry)`;
} else if (t.payload.type === TransactionMintCollectionType.SEND_ALIAS_TO_GUARDIAN) {
} else if (t.payload.type === TransactionPayloadType.SEND_ALIAS_TO_GUARDIAN) {
base += ' ' + $localize`(Send Alias to Guardian)`;
} else if (t.payload.type === TransactionMintCollectionType.LOCK_COLLECTION) {
} else if (t.payload.type === TransactionPayloadType.LOCK_COLLECTION) {
base += ' ' + $localize`(Lock Collection)`;
}

Expand All @@ -65,7 +64,7 @@ export class TransactionService {
if (this.paymentNotProcessedOrInProgress(t)) return null;
const link = t.payload.chainReference || t.payload?.walletReference?.chainReference;

return this.generateLink(link, t.network);
return this.generateLink(link!, t.network);
}

public generateLink(link: string, network?: Network): string {
Expand All @@ -85,7 +84,8 @@ export class TransactionService {
public paymentNotProcessedOrInProgress(tran: Transaction | undefined | null): boolean {
return (
(!tran?.payload.chainReference && !tran?.payload.walletReference?.chainReference) ||
tran.payload.walletReference?.chainReference.startsWith(DEF_WALLET_PAY_IN_PROGRESS)
tran.payload.walletReference?.chainReference?.startsWith(DEF_WALLET_PAY_IN_PROGRESS) ||
false
);
}
}
8 changes: 8 additions & 0 deletions src/app/@core/utils/common.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const chunkArray = <T>(array: T[], size: number) => {
const chunks: T[][] = [];
for (let i = 0; i < array.length; i += size) {
const chunk = array.slice(i, i + size);
chunks.push(chunk);
}
return chunks;
};
6 changes: 3 additions & 3 deletions src/app/@shell/ui/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
Notification,
NotificationType,
TRANSACTION_AUTO_EXPIRY_MS,
TransactionOrder,
Transaction,
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { NzNotificationRef, NzNotificationService } from 'ng-zorro-antd/notification';
Expand Down Expand Up @@ -82,8 +82,8 @@ export class HeaderComponent implements OnInit, OnDestroy {
private notificationRef?: NzNotificationRef;
public expiryTicker$: BehaviorSubject<dayjs.Dayjs | null> =
new BehaviorSubject<dayjs.Dayjs | null>(null);
private transaction$: BehaviorSubject<TransactionOrder | undefined> = new BehaviorSubject<
TransactionOrder | undefined
private transaction$: BehaviorSubject<Transaction | undefined> = new BehaviorSubject<
Transaction | undefined
>(undefined);
private subscriptionTransaction$?: Subscription;
private subscriptionNotification$?: Subscription;
Expand Down
Loading

0 comments on commit 1acd1d5

Please sign in to comment.