Skip to content

Commit

Permalink
Merge pull request #3567 from Portkey-Wallet/feature/eoa-contract
Browse files Browse the repository at this point in the history
feat: 🎸 adjust eoa contract
  • Loading branch information
thomas-portkey authored Jan 22, 2025
2 parents fa1406a + fbfa82d commit 06ffe19
Show file tree
Hide file tree
Showing 56 changed files with 1,818 additions and 224 deletions.
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;
}
94 changes: 94 additions & 0 deletions packages/api/api-eoa/es/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { request } from '@portkey-wallet/api/api-did';
import { GetContractListApiType } from '@portkey-wallet/types/types-ca/contact';
import { TGetContactListApiType } from '@portkey-wallet/types/types-ca/contactNew';

import { IGetContactListParams } from '../type';

export const getContactList = (
baseURL: string,
{ page, size, modificationTime, keyword }: IGetContactListParams,
): Promise<GetContractListApiType> => {
return request.es.getContactList({
baseURL,
params: {
filter: `modificationTime: [* TO ${modificationTime}] AND isDeleted: false`,
sort: 'modificationTime',
sortType: 0,
skipCount: (page - 1) * size,
maxResultCount: size,
keyword,
},
});
};

export const getContactEventList = (
baseURL: string,
{ page, size, modificationTime, fetchTime, keyword }: IGetContactListParams & { fetchTime: string },
): Promise<GetContractListApiType> => {
return request.es.getContactList({
baseURL,
params: {
filter: `modificationTime: [${modificationTime} TO ${fetchTime}]`,
sort: 'modificationTime',
sortType: 0,
skipCount: (page - 1) * size,
maxResultCount: size,
keyword,
},
});
};

export const getContactListV2 = (
baseURL: string,
{ page, size, modificationTime, keyword }: IGetContactListParams,
): Promise<TGetContactListApiType> => {
return request.es.getContactListNew({
baseURL,
params: {
filter: `modificationTime: [* TO ${modificationTime}] AND isDeleted: false`,
sort: 'modificationTime',
sortType: 0,
skipCount: (page - 1) * size,
maxResultCount: size,
keyword,
},
});
};

export const getContactEventListV2 = (
baseURL: string,
{ page, size, modificationTime, fetchTime, keyword }: IGetContactListParams & { fetchTime: string },
): Promise<TGetContactListApiType> => {
return request.es.getContactListNew({
baseURL,
params: {
filter: `modificationTime: [${modificationTime} TO ${fetchTime}]`,
sort: 'modificationTime',
sortType: 0,
skipCount: (page - 1) * size,
maxResultCount: size,
keyword,
},
});
};

export const getCaHolder = (
baseURL: string,
{ caHash }: { caHash: string },
): Promise<{
items: Array<{
userId: string;
caAddress: string;
caHash: string;
id: string;
nickName: string;
avatar: string;
}>;
}> => {
return request.es.getCaHolder({
baseURL,
params: {
filter: `caHash: ${caHash}`,
},
});
};
Loading

0 comments on commit 06ffe19

Please sign in to comment.