From 2f3fa841229055c44f6229a790b1bb190c652909 Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 31 Jan 2025 12:05:36 +0400 Subject: [PATCH 01/15] fix(ethereum): show correct token transaction details --- src/protocols/ethereum/libs/EtherscanService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/protocols/ethereum/libs/EtherscanService.ts b/src/protocols/ethereum/libs/EtherscanService.ts index 5f8ce9dca..39d4da039 100644 --- a/src/protocols/ethereum/libs/EtherscanService.ts +++ b/src/protocols/ethereum/libs/EtherscanService.ts @@ -1,5 +1,6 @@ import { ref } from 'vue'; import { fromWei } from 'web3-utils'; +import BigNumber from 'bignumber.js'; import type { AccountAddress, AssetContractId, ITransaction } from '@/types'; import type { EthRpcEtherscanProxyMethod } from '@/protocols/ethereum/types'; @@ -187,6 +188,7 @@ export class EtherscanService { to, value, input, + tokenDecimal, } = transaction; const senderId = toEthChecksumAddress(from) as any; @@ -198,7 +200,7 @@ export class EtherscanService { ); const gasPriceInEther = Number(fromWei(gasPrice, 'ether')); const fee = gasUsed * gasPriceInEther; - const amount = Number(fromWei(value, 'ether')); + const amount = tokenDecimal ? Number(new BigNumber(value).shiftedBy(-tokenDecimal)) : Number(fromWei(value, 'ether')); const pending = parseInt(confirmations, 10) <= ETH_SAFE_CONFIRMATION_COUNT; const microTime = timeStamp * 1000; const isEthTransfer = !contractAddress && (!input || input === '0x'); From f409883892408dba7e35df7c46ec1992ce6c8ab4 Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 31 Jan 2025 12:17:31 +0400 Subject: [PATCH 02/15] feat: be able to set ethplorer api key --- .env | 1 + src/constants/environment.ts | 1 + src/protocols/ethereum/libs/EthplorerService.ts | 8 ++++---- vue.config.js | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.env b/.env index a795f8618..38dd7677d 100644 --- a/.env +++ b/.env @@ -1,5 +1,6 @@ UNFINISHED_FEATURES=true ETHERSCAN_API_KEY= +ETHPLORER_API_KEY= WALLET_CONNECT_PROJECT_ID= TOKEN_SALES_URL_MAINNET= TOKEN_SALES_URL_TESTNET= diff --git a/src/constants/environment.ts b/src/constants/environment.ts index 7185337ec..9831150eb 100644 --- a/src/constants/environment.ts +++ b/src/constants/environment.ts @@ -71,5 +71,6 @@ export const IS_PRODUCTION = process.env.NODE_ENV === 'production'; export const UNFINISHED_FEATURES = !!process.env.UNFINISHED_FEATURES; export const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY!; +export const ETHPLORER_API_KEY = process.env.ETHPLORER_API_KEY!; export const WALLET_CONNECT_PROJECT_ID = process.env.WALLET_CONNECT_PROJECT_ID!; diff --git a/src/protocols/ethereum/libs/EthplorerService.ts b/src/protocols/ethereum/libs/EthplorerService.ts index 80fc2fcbf..a4d26a789 100644 --- a/src/protocols/ethereum/libs/EthplorerService.ts +++ b/src/protocols/ethereum/libs/EthplorerService.ts @@ -1,5 +1,5 @@ import type { IToken, ITokenBalance } from '@/types'; -import { PROTOCOLS } from '@/constants'; +import { PROTOCOLS, ETHPLORER_API_KEY } from '@/constants'; import { fetchJson, toShiftedBigNumber, @@ -9,7 +9,7 @@ import { import { ETH_CONTRACT_ID_EXTERNAL } from '../config'; import { toEthChecksumAddress } from '../helpers'; -const ETHPLORER_API_KEY = 'freekey'; +const ethplorerApiKey = ETHPLORER_API_KEY || 'freekey'; /** * Standard HTTP status code for too many requests * ? https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429 @@ -36,13 +36,13 @@ export class EthplorerService { async fetchFromApi(action: string, params: any = {}) { const query = new URLSearchParams({ ...params, - apiKey: ETHPLORER_API_KEY, // Without API key amount of calls are limited but still possible + apiKey: ethplorerApiKey, // Without API key amount of calls are limited but still possible }).toString(); // Without API key amount of calls are limited to two per every 1 second. // We're adding delays between calls to avoid getting empty results. // TODO: Use own node or paid version - if (!ETHPLORER_API_KEY || ETHPLORER_API_KEY === 'freekey') { + if (!ethplorerApiKey || ethplorerApiKey === 'freekey') { const currTime = new Date().getTime(); const timeToWait = (lastCallTime) ? this.freeVersionTimeDelay - (currTime - lastCallTime) : 0; lastCallTime = currTime + ((timeToWait > 0) ? timeToWait : 0); diff --git a/vue.config.js b/vue.config.js index c0691fb20..83ce95b16 100644 --- a/vue.config.js +++ b/vue.config.js @@ -162,6 +162,7 @@ module.exports = { definitions['process.env.NETWORK'] = JSON.stringify(process.env.NETWORK); definitions['process.env.SDK_VERSION'] = JSON.stringify(sdkVersion); definitions['process.env.ETHERSCAN_API_KEY'] = JSON.stringify(process.env.ETHERSCAN_API_KEY); + definitions['process.env.ETHPLORER_API_KEY'] = JSON.stringify(process.env.ETHPLORER_API_KEY); definitions['process.env.WALLET_CONNECT_PROJECT_ID'] = JSON.stringify(process.env.WALLET_CONNECT_PROJECT_ID); definitions['process.env.TOKEN_SALES_URL_TESTNET'] = JSON.stringify(process.env.TOKEN_SALES_URL_TESTNET); definitions['process.env.TOKEN_SALES_URL_MAINNET'] = JSON.stringify(process.env.TOKEN_SALES_URL_MAINNET); From 35bd8143e397bff1da20b3a32e713a740957d419 Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 31 Jan 2025 16:37:38 +0400 Subject: [PATCH 03/15] feat: show internal spendTx correctly --- .../aeternity/composables/aeMiddleware.ts | 20 ++++++++++++++++++- src/utils/common.ts | 1 - 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/protocols/aeternity/composables/aeMiddleware.ts b/src/protocols/aeternity/composables/aeMiddleware.ts index 0284cbd98..b499b127d 100644 --- a/src/protocols/aeternity/composables/aeMiddleware.ts +++ b/src/protocols/aeternity/composables/aeMiddleware.ts @@ -113,6 +113,16 @@ export function useAeMiddleware() { const groupedActivitiesByHash = groupBy(activities, getActivityHash); return flatMap(groupedActivitiesByHash, (group) => { + if ( + group.length === 1 + && ( + group[0].type === ACTIVITIES_TYPES.aex9TransferEvent + || group[0].type === ACTIVITIES_TYPES.internalContractCallEvent + ) + ) { + return group; + } + const primaryObjectIndex = group.findIndex(({ type }) => ( type !== ACTIVITIES_TYPES.aex9TransferEvent && type !== ACTIVITIES_TYPES.internalTransferEvent @@ -133,7 +143,7 @@ export function useAeMiddleware() { } function normalizeMiddlewareTransactionStructure( - { payload, type }: any, // Response data + { payload, type, blockTime }: any, // Response data transactionOwner?: AccountAddress, ): ITransaction { const normalizedTransaction: ITransaction = { @@ -153,6 +163,14 @@ export function useAeMiddleware() { type: Tag[Tag.ContractCallTx], }; normalizedTransaction.incomplete = true; + } else if ( + type === ACTIVITIES_TYPES.internalContractCallEvent + && payload.internalTx.type === Tag[Tag.SpendTx] + ) { + normalizedTransaction.hash = payload.callTxHash; + normalizedTransaction.tx = payload.internalTx; + // TODO: get an actual time + normalizedTransaction.microTime = blockTime; } const contractCallData = categorizeContractCallTxObject(normalizedTransaction); diff --git a/src/utils/common.ts b/src/utils/common.ts index 124277121..045f2a9e8 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -728,6 +728,5 @@ export function getActivityHash(activity: any) { ?? activity?.payload?.hash ?? activity?.payload?.callTxHash ?? activity?.payload?.refTxHash - ?? activity?.payload?.contractTxHash ); } From 9883c3aced519d98dc47aaba79a7425c367326c5 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 3 Feb 2025 12:17:28 +0400 Subject: [PATCH 04/15] ci: update github actions --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c20d20ddf..baff9ff1c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,13 +49,13 @@ jobs: publish_dir: dist/web/root cname: wallet.superhero.com - - uses: softprops/action-gh-release@v1 + - uses: softprops/action-gh-release@v2.2.1 if: startsWith(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: name: Release ${{ github.ref }} - - uses: alexellis/upload-assets@0.4.0 + - uses: alexellis/upload-assets@0.4.1 if: startsWith(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -64,7 +64,7 @@ jobs: - uses: rlespinasse/github-slug-action@v4.x - name: Deploy to stage - uses: easingthemes/ssh-deploy@v4.1.8 + uses: easingthemes/ssh-deploy@v5.1.0 if: github.event_name == 'push' env: SSH_PRIVATE_KEY: ${{ secrets.STAGE_PRIVATE_KEY }} From 238e022056428adc16e34536361509f54329ff42 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 3 Feb 2025 11:42:23 +0400 Subject: [PATCH 05/15] refactor: adjust transaction details page --- src/popup/components/DetailsItem.vue | 5 ++++- src/protocols/aeternity/views/TransactionDetails.vue | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/popup/components/DetailsItem.vue b/src/popup/components/DetailsItem.vue index d9046d764..89c51785e 100644 --- a/src/popup/components/DetailsItem.vue +++ b/src/popup/components/DetailsItem.vue @@ -112,13 +112,16 @@ export default defineComponent({ .value { @extend %face-sans-15-regular; + display: flex; + flex-wrap: wrap; + gap: 4px; + align-items: center; letter-spacing: 0.05em; color: rgba($color-white, 0.85); margin-bottom: 8px; .secondary { color: $color-grey-light; - margin-left: 4px; white-space: nowrap; } diff --git a/src/protocols/aeternity/views/TransactionDetails.vue b/src/protocols/aeternity/views/TransactionDetails.vue index 0c277156a..810fb071e 100644 --- a/src/protocols/aeternity/views/TransactionDetails.vue +++ b/src/protocols/aeternity/views/TransactionDetails.vue @@ -443,9 +443,14 @@ export default defineComponent({