Skip to content

Commit

Permalink
feat: home&nft*toekndetail&activity
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankFeng1116 committed Jan 23, 2025
1 parent 1a0fa0a commit 68bee7e
Show file tree
Hide file tree
Showing 79 changed files with 14,439 additions and 333 deletions.
22 changes: 21 additions & 1 deletion packages/api/api-did/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class DidService extends ServiceInit {
protected onLockApp?: (expired?: boolean) => void;
locked?: boolean;
exceptionManager?: IExceptionManager;
private transformCallbackList: ((result: any) => any)[] = [];
constructor() {
super();
}
Expand Down Expand Up @@ -72,7 +73,15 @@ export class DidService extends ServiceInit {
};
send = async (base: BaseConfig, config?: RequestConfig, reCount = 0): Promise<any> => {
try {
return await this.sendOrigin(base, config, reCount);
const result = await this.sendOrigin(base, config, reCount);
console.log('this.transformCallbackList.length', this.transformCallbackList.length);
if (this.transformCallbackList.length > 0) {
const i = this.transformCallbackList.reduce((prevResult, callback) => {
return callback(prevResult);
}, result);
return i;
}
return result;
} catch (errResult: any) {
const { URL, fetchConfig } = this.getConfig(base, config);
this.errorReport(URL, fetchConfig, errResult);
Expand Down Expand Up @@ -125,6 +134,17 @@ export class DidService extends ServiceInit {
setExceptionManager = (exceptionManager: IExceptionManager) => {
this.exceptionManager = exceptionManager;
};

addTransform = (callback: (result: any) => any) => {
if (typeof callback !== 'function') {
return;
}
if (!this.transformCallbackList) {
this.transformCallbackList = [];
}
this.transformCallbackList.push(callback);
};

errorReport = (url: string, fetchConfig: any, fetchResult: any) => {
this.exceptionManager?.reportErrorMessage?.(`${URL} request error`, Severity.Fatal, {
req: {
Expand Down
4 changes: 4 additions & 0 deletions packages/constants/constants-ca/backend-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export const BackEndNetWorkMap: {
hamsterUrl: 'https://test-hamster.beangotown.com',
zkLoginVerifyUrl: 'https://zklogin-prover-test.portkey.finance/v1/prove',
cryptoGiftTgUrl: 'https://t.me/PortkeyTestnet_Bot/crypto_gift',
eoaApiUrl: 'https://eoa-portkey-test.portkey.finance',
eoaConnectApiUrl: 'https://auth-eoa-portkey-test.portkey.finance',
},
'back-end-testnet': {
name: 'aelf Testnet',
Expand Down Expand Up @@ -293,5 +295,7 @@ export const BackEndNetWorkMap: {
hamsterUrl: 'https://hamster.beangotown.com',
zkLoginVerifyUrl: 'https://zklogin-prover.portkey.finance/v1/prove',
cryptoGiftTgUrl: 'https://t.me/PortkeyMainnet_Bot/crypto_gift',
eoaApiUrl: 'https://eoa-portkey-test.portkey.finance',
eoaConnectApiUrl: 'https://auth-eoa-portkey-test.portkey.finance',
},
};
48 changes: 48 additions & 0 deletions packages/constants/constants-eoa/activity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export enum TransactionTypes {
TRANSFER = 'Transfer',
CROSS_CHAIN_TRANSFER = 'CrossChainTransfer', // CrossChain Transfer
CLAIM_TOKEN = 'ClaimToken', // faucet receive transfer
TRANSFER_RED_PACKET = 'TransferRedPacket',
CROSS_CHAIN_RECEIVE = 'ReleaseToken', // CrossChain Receive
SWAP = 'SwapExactTokensForTokens', // Awaken
BATCH_BUY_NOW = 'BatchBuyNow',
DEAL = 'Deal',
PALY = 'Play',
ADDTREEPOINTS = 'AddTreePoints',
JOIN = 'Join',
PLACEBID = 'PlaceBid',
}

export const DEFAULT_AMOUNT = 0;
export const DEFAULT_DECIMAL = 8;
export const DEFAULT_DIGITS = 4;
export const DEFAULT_NFT_DECIMAL = 0;

export const ELF_DECIMAL = 8;

export const AELF_CHIAN_TYPE = 'aelf';
export const MAIN_CHAIN_ID = 'AELF';
export const MAIN_CHAIN = 'MainChain';
export const SIDE_CHAIN = 'dAppChain';
export const TESTNET = 'TESTNET';
export const TEST_NET = 'Testnet';

export const SHOW_FROM_TRANSACTION_TYPES = [
TransactionTypes.TRANSFER,
TransactionTypes.CROSS_CHAIN_TRANSFER,
TransactionTypes.CLAIM_TOKEN,
TransactionTypes.TRANSFER_RED_PACKET,
TransactionTypes.SWAP,
TransactionTypes.CROSS_CHAIN_RECEIVE,
TransactionTypes.BATCH_BUY_NOW,
TransactionTypes.DEAL,
TransactionTypes.PALY,
TransactionTypes.ADDTREEPOINTS,
TransactionTypes.JOIN,
TransactionTypes.PLACEBID,
];

export const SHOW_DAPP_TRANSACTION_TYPES = [TransactionTypes.SWAP];

export const ON_END_REACHED_THRESHOLD = 0.3;
export const ACTIVITY_PAGE_SIZE = 20;
66 changes: 66 additions & 0 deletions packages/constants/constants-eoa/assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ITokenSectionResponse } from '@portkey-wallet/types/types-ca/token';

export enum TransactionError {
TOKEN_NOT_ENOUGH = 'Insufficient funds',
NFT_NOT_ENOUGH = 'Insufficient quantity',
FEE_NOT_ENOUGH = 'Insufficient funds for transaction fee',
CROSS_NOT_ENOUGH = 'Insufficient funds for cross-chain transaction fee',
}

export const REFRESH_TIME = 5 * 60 * 1000; // 5min refresh

export const NEW_CLIENT_MOCK_ELF_LIST: ITokenSectionResponse[] = [
{
balance: '0',
balanceInUsd: '0.000000',
price: 0,
decimals: 8,
imageUrl: 'https://portkey-did.s3.ap-northeast-1.amazonaws.com/img/aelf/Coin-ELF.png',
symbol: 'ELF',
tokens: [
{
address: 'JRmBduh4nXWi1aXgdUsj5gJrzeZb2LxmrAbf7W99faZSvoAaE',
balance: '0',
balanceInUsd: '0.000000',
chainId: 'AELF',
decimals: 8,
imageUrl: 'https://portkey-did.s3.ap-northeast-1.amazonaws.com/img/aelf/Coin-ELF.png',
symbol: 'ELF',
tokenContractAddress: 'JRmBduh4nXWi1aXgdUsj5gJrzeZb2LxmrAbf7W99faZSvoAaE',
},
],
},
];

export const PAGE_SIZE_IN_NFT_ITEM = 15;

export const PAGE_SIZE_IN_ACCOUNT_NFT_COLLECTION = 20;

export const PAGE_SIZE_IN_ACCOUNT_TOKEN = 20;

export const PAGE_SIZE_IN_ACCOUNT_ASSETS = 20;

export const PAGE_SIZE_DEFAULT = 50;

export const ELF_SYMBOL = 'ELF';

export const NFT_SMALL_SIZE = 144;
export const NFT_MIDDLE_SIZE = 294;
export const NFT_MIDDLE_X_SIZE = 512;
export const NFT_LARGE_SIZE = 1008;

export enum BalanceTab {
TOKEN = 'token',
NFT = 'nft',
ACTIVITY = 'activity',
}

export enum ContactsTab {
ALL = 'All',
Chats = 'Chats',
}

export enum AssetType {
ft = 1,
nft = 2,
}
29 changes: 29 additions & 0 deletions packages/constants/constants-eoa/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export type ErrorType = {
errorMsg: string;
isError: boolean;
isWarning?: boolean;
};

export const INIT_ERROR: ErrorType = {
errorMsg: '',
isError: false,
};

export const INIT_NONE_ERROR: ErrorType = {
...INIT_ERROR,
};

export const INIT_HAS_ERROR: ErrorType = {
errorMsg: '',
isError: true,
};

export enum contractStatusEnum {
MINED = 'MINED',
FAILED = 'FAILED',
PENDING = 'PENDING',
}

export const HELP_CENTER_URL = 'https://doc.portkey.finance/help';

export const AELF_NETWORK_NAME = 'aelf';
18 changes: 18 additions & 0 deletions packages/constants/constants-eoa/ramp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const SELL_SOCKET_TIMEOUT = 15 * 1000;

export const BUY_SOON_TEXT = 'On-ramp is currently not supported. It will be launched in the coming weeks.';

export const SELL_SOON_TEXT = 'Off-ramp is currently not supported. It will be launched in the coming weeks.';

export const SERVICE_UNAVAILABLE_TEXT = 'Sorry, the service you are using is temporarily unavailable.';

export const DISCLAIMER_TEXT =
' is a fiat-to-crypto platform independently operated by a third-party entity. Portkey shall not be held liable for any losses or damages suffered as a result of using ';

export const INSUFFICIENT_FUNDS_TEXT = 'Insufficient funds';

export const SYNCHRONIZING_CHAIN_TEXT = 'Synchronizing on-chain account information...';

export const SHOW_RAMP_SYMBOL_LIST = ['ELF', 'USDT'];

export const SHOW_RAMP_CHAIN_ID_LIST = ['AELF'];
2 changes: 2 additions & 0 deletions packages/hooks/hooks-eoa/activity/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { useAppEOASelector } from '../index';
export const useActivity = () => useAppEOASelector(state => state.activity);
Loading

0 comments on commit 68bee7e

Please sign in to comment.