Skip to content

Commit

Permalink
ci: 🎡 merge eoa-dev1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
y-ptk committed Jan 25, 2025
2 parents cad1cbd + 257dfb7 commit fba63a8
Show file tree
Hide file tree
Showing 184 changed files with 16,927 additions and 737 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
6 changes: 6 additions & 0 deletions packages/api/api-eoa/activity/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
activityList: '/api/app/user/activities/activities',
activity: '/api/app/user/activities/activity',
activityListWithAddress: '/api/app/user/activities/transactions',
reportTransaction: '/api/app/report/transaction',
} as const;
39 changes: 39 additions & 0 deletions packages/api/api-eoa/assets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export default {
fetchAccountTokenList: '/api/app/user/assets/token',
fetchAccountTokenListV2: '/api/app/v2/user/assets/token',
fetchAccountNftCollectionList: '/api/app/user/assets/nftCollections',
fetchAccountNftCollectionItemList: '/api/app/user/assets/nftItems',
fetchAccountNftCollectionItem: {
target: '/api/app/user/assets/nftItem',
config: {
method: 'POST',
timeout: 20 * 1000,
},
},
// nft and tokens
fetchAccountAssetsByKeywords: '/api/app/user/assets/searchUserAssets',
fetchAccountAssetsByKeywordsV2: '/api/app/v2/user/assets/searchUserAssets',
// nft and token in crypto box
fetchCryptoBoxAccountAssetsByKeywords: '/api/app/v2/user/assets/searchUserPackageAssets',
fetchTokenPrice: {
target: '/api/app/tokens/prices',
config: { method: 'GET' },
},
fetchTokenAllowanceList: '/api/app/tokens/allowances',
getSymbolImages: {
target: '/api/app/user/assets/symbolImages',
config: { method: 'GET' },
},
getTokenBalance: {
target: '/api/app/user/assets/tokenBalance',
config: { method: 'GET' },
},
getAssetsEstimation: {
target: '/api/app/user/assets/asset-estimation',
config: { method: 'GET' },
},
getAwakenTokenList: {
target: '/api/app/user/assets/awaken/token',
config: { method: 'GET' },
},
} as const;
Empty file.
14 changes: 14 additions & 0 deletions packages/api/api-eoa/awaken/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
getSwapRoutes: {
target: '/api/app/route/best-swap-routes',
config: { method: 'GET' },
},
getAwakenGasFee: {
target: '/api/app/transaction-fee',
config: { method: 'GET' },
},
getAwakenTokenPrice: {
target: '/api/app/token/price',
config: { method: 'GET' },
},
} as const;
3 changes: 3 additions & 0 deletions packages/api/api-eoa/chain/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
getChains: '/api/app/getChains',
} as const;
82 changes: 82 additions & 0 deletions packages/api/api-eoa/contact/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { BaseConfig } from '../../types';

const BASE_URL = `/api/app/contacts`;
const BASE_URL_V2 = `/api/app/address-book`;

const KeyList = [
'addContact',
'editContact',
'deleteContact',
'checkContactName',
'readImputation',
'contactPrivacyList',
'updateContactPrivacy',
] as const;

const KeyListV2 = [
'createSaved',
'updateSaved',
'deleteSaved',
'checkSavedName',
'getSavedList',
'getSupportNetworkList',
] as const;

const ApiObject: Record<(typeof KeyList)[number], BaseConfig> = {
addContact: {
target: `${BASE_URL}`,
config: { method: 'POST' },
},
editContact: {
target: `${BASE_URL}`,
config: { method: 'PUT' },
},
deleteContact: {
target: `${BASE_URL}`,
config: { method: 'DELETE' },
},
checkContactName: {
target: `${BASE_URL}/exist`,
config: { method: 'GET' },
},
readImputation: {
target: `${BASE_URL}/read`,
config: { method: 'POST' },
},
contactPrivacyList: {
target: `/api/app/privacyPermission`,
config: { method: 'GET' },
},
updateContactPrivacy: {
target: `/api/app/privacyPermission`,
config: { method: 'POST' },
},
};
const ApiObjectV2: Record<(typeof KeyListV2)[number], BaseConfig> = {
createSaved: {
target: `${BASE_URL_V2}/create`,
config: { method: 'POST' },
},
updateSaved: {
target: `${BASE_URL_V2}/update`,
config: { method: 'POST' },
},
deleteSaved: {
target: `${BASE_URL_V2}/delete`,
config: { method: 'POST' },
},
checkSavedName: {
target: `${BASE_URL_V2}/exist`,
config: { method: 'GET' },
},
getSavedList: {
target: `${BASE_URL_V2}/read`,
config: { method: 'GET' },
},
getSupportNetworkList: {
target: `${BASE_URL_V2}/network`,
config: { method: 'GET' },
},
};

export default Object.assign(ApiObject, ApiObjectV2);
3 changes: 3 additions & 0 deletions packages/api/api-eoa/contact/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface CheckContactNameResponseType {
existed: boolean;
}
35 changes: 35 additions & 0 deletions packages/api/api-eoa/deposit/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export default {
getTokenList: {
target: '/api/app/transfer/token/list',
config: { method: 'GET' },
},
getTokenListByNetwork: {
target: '/api/app/transfer/network/tokens',
config: { method: 'GET' },
},
getDepositTokenList: {
target: '/api/app/transfer/token/option',
config: { method: 'GET' },
},
getNetworkList: {
target: '/api/app/transfer/network/list',
config: { method: 'GET' },
},
getDepositInfo: {
target: '/api/app/transfer/deposit/info',
config: { method: 'GET' },
},
depositCalculator: {
target: '/api/app/transfer/deposit/calculator',
config: { method: 'GET' },
},
recordList: {
target: '/api/app/transfer/record/list',
config: { method: 'GET' },
},
getTransferToken: {
target: '/api/app/transfer/connect/token',
config: { method: 'POST' },
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
},
} as const;
4 changes: 4 additions & 0 deletions packages/api/api-eoa/device/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
fetchEncrypt: '/api/app/account/device/encrypt',
fetchDecrypt: '/api/app/account/device/decrypt',
} as const;
22 changes: 22 additions & 0 deletions packages/api/api-eoa/discover/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
addBookmark: '/api/app/bookmarks',
deleteAllBookmark: {
target: '/api/app/bookmarks',
config: { method: 'DELETE' },
},
deleteBookmark: '/api/app/bookmarks/modify',
getBookmarks: {
target: '/api/app/bookmarks',
config: { method: 'GET' },
},
getCryptoCurrencyList: {
target: '/api/app/cryptocurrency/list',
config: { method: 'GET' },
},
markFavorite: {
target: '/api/app/cryptocurrency/mark',
},
unMarkFavorite: {
target: '/api/app/cryptocurrency/unmark',
},
} as const;
47 changes: 47 additions & 0 deletions packages/api/api-eoa/es/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ESBaseConfig } from './type';

const Method = 'GET';
const BaseESUrl = `/api/app/`;

const KeyList = [
'getUserTokenList',
'getChainsInfo',
'getRegisterResult',
'getRecoverResult',
'getContactList',
'getContactListNew',
'getCaHolder',
] as const;

const ApiObject: Record<(typeof KeyList)[number], ESBaseConfig> = {
getUserTokenList: {
target: `${BaseESUrl}search/usertokenindex`,
config: { method: Method },
},
getChainsInfo: {
target: `${BaseESUrl}search/chainsinfoindex`,
config: { method: Method, params: { sort: 'chainId' } },
},
getRegisterResult: {
target: `${BaseESUrl}search/accountregisterindex`,
config: { method: Method },
},
getRecoverResult: {
target: `${BaseESUrl}search/accountrecoverindex`,
config: { method: Method },
},
getContactList: {
target: `${BaseESUrl}contacts/list`,
config: { method: Method },
},
getContactListNew: {
target: `${BaseESUrl}address-book/list`,
config: { method: Method },
},
getCaHolder: {
target: `${BaseESUrl}search/caholderindex`,
config: { method: Method },
},
};

export default ApiObject;
25 changes: 25 additions & 0 deletions packages/api/api-eoa/es/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CustomFetchConfig } from '@portkey-wallet/utils/fetch';
import { BaseConfig, RequestConfig } from '../../types';

export interface ESConfig extends CustomFetchConfig {
params?: {
filter?: string;
sort?: string;
sortType?: 0 | 1;
skipCount?: number;
maxResultCount?: number;
};
}

export type ESBaseConfig = BaseConfig & {
config: ESConfig;
};

export type ES_API_REQ_FUNCTION = (config?: RequestConfig & ESConfig) => Promise<{ type: 'timeout' } | any>;

export interface IGetContactListParams {
page: number;
size: number;
modificationTime: string;
keyword?: string;
}
Loading

0 comments on commit fba63a8

Please sign in to comment.