Skip to content

Commit

Permalink
refactor: rename tokenSwaps to tokenSales
Browse files Browse the repository at this point in the history
  • Loading branch information
CedrikNikita committed Oct 31, 2024
1 parent 5de6021 commit 4a7d815
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 133 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
UNFINISHED_FEATURES=true
ETHERSCAN_API_KEY=
WALLET_CONNECT_PROJECT_ID=
TOKEN_SWAP_URL_TESTNET=
TOKEN_SWAP_URL_MAINNET=
TOKEN_SALES_URL_MAINNET=
TOKEN_SALES_URL_TESTNET=
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
env:
APP_NAME: wallet
WALLET_CONNECT_PROJECT_ID: ${{ secrets.WALLET_CONNECT_PROJECT_ID }}
TOKEN_SWAP_URL_MAINNET: ${{ secrets.TOKEN_SWAP_URL_MAINNET }}
TOKEN_SWAP_URL_TESTNET: ${{ secrets.TOKEN_SWAP_URL_TESTNET }}
TOKEN_SALES_URL_MAINNET: ${{ secrets.TOKEN_SALES_URL_MAINNET }}
TOKEN_SALES_URL_TESTNET: ${{ secrets.TOKEN_SALES_URL_TESTNET }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ jobs:
runs-on: ubuntu-latest
env:
APP_NAME: wallet
TOKEN_SWAP_URL_MAINNET: ${{ secrets.TOKEN_SWAP_URL_MAINNET }}
TOKEN_SWAP_URL_TESTNET: ${{ secrets.TOKEN_SWAP_URL_TESTNET }}
TOKEN_SALES_URL_MAINNET: ${{ secrets.TOKEN_SALES_URL_MAINNET }}
TOKEN_SALES_URL_TESTNET: ${{ secrets.TOKEN_SALES_URL_TESTNET }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
36 changes: 18 additions & 18 deletions src/composables/transactionData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
TX_FUNCTIONS,
TX_FUNCTIONS_MULTISIG,
TX_FUNCTIONS_TYPE_DEX,
TX_FUNCTIONS_TOKEN_SWAP,
TX_FUNCTIONS_TOKEN_SALE,
} from '@/protocols/aeternity/config';
import {
aettosToAe,
Expand All @@ -40,7 +40,7 @@ import {
isTxDex,
} from '@/protocols/aeternity/helpers';
import { useFungibleTokens } from '@/composables/fungibleTokens';
import { useAeTokenSwaps } from '@/protocols/aeternity/composables/aeTokenSwaps';
import { useAeTokenSales } from '@/protocols/aeternity/composables/aeTokenSales';
import { useAccounts } from './accounts';
import { useAeSdk } from './aeSdk';

Expand Down Expand Up @@ -68,9 +68,9 @@ export function useTransactionData({
const { getProtocolAvailableTokens, getTxAmountTotal, getTxAssetSymbol } = useFungibleTokens();
const {
tokenContractAddresses,
tokenSwapAddresses,
tokenSwapAddressToTokenContractAddress,
} = useAeTokenSwaps();
tokenSaleAddresses,
tokenSaleAddressToTokenContractAddress,
} = useAeTokenSales();

const protocol = computed(() => transaction.value?.protocol || PROTOCOLS.aeternity);
const outerTx = computed(() => transaction.value?.tx);
Expand Down Expand Up @@ -116,24 +116,24 @@ export function useTransactionData({
),
);

const isTokenSwap = computed(
const isTokenSale = computed(
(): boolean => [
...tokenContractAddresses.value,
...tokenSwapAddresses.value,
...tokenSaleAddresses.value,
].some((address) => address === innerTx.value?.contractId),
);

const isTokenSwapBuy = computed(
const isTokenSaleBuy = computed(
(): boolean => (
isTokenSwap.value
&& includes(TX_FUNCTIONS_TOKEN_SWAP.buy, txFunctionRaw.value)
isTokenSale.value
&& includes(TX_FUNCTIONS_TOKEN_SALE.buy, txFunctionRaw.value)
),
);

const isTokenSwapSell = computed(
const isTokenSaleSell = computed(
(): boolean => (
isTokenSwap.value
&& includes(TX_FUNCTIONS_TOKEN_SWAP.sell, txFunctionRaw.value)
isTokenSale.value
&& includes(TX_FUNCTIONS_TOKEN_SALE.sell, txFunctionRaw.value)
),
);

Expand Down Expand Up @@ -255,7 +255,7 @@ export function useTransactionData({
if (protocol.value === PROTOCOLS.aeternity) {
// AE DEX and wrapped AE (WAE)
if (
(isDex.value || isTokenSwap.value)
(isDex.value || isTokenSale.value)
&& txFunctionParsed.value
&& (!isDexAllowance.value || showDetailedAllowanceInfo)
) {
Expand All @@ -264,7 +264,7 @@ export function useTransactionData({
return functionResolver(
{ tx: outerTx.value } as ITransaction,
protocolTokens,
tokenSwapAddressToTokenContractAddress,
tokenSaleAddressToTokenContractAddress,
)
.tokens
.map(({
Expand Down Expand Up @@ -343,9 +343,9 @@ export function useTransactionData({
isAex9,
isErrorTransaction,

isTokenSwap,
isTokenSwapBuy,
isTokenSwapSell,
isTokenSale,
isTokenSaleBuy,
isTokenSaleSell,

isDex,
isDexAllowance,
Expand Down
28 changes: 14 additions & 14 deletions src/popup/components/Modals/ConfirmTransactionSign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<!-- Aeternity DEX & Tokaen transactions any ETH transactions involving multiple assets -->
<template
v-if="(
(isDex || isTokenSwap) && tokenList.length
(isDex || isTokenSale) && tokenList.length
|| protocol === PROTOCOLS.ethereum && tokenList.length > 1
)"
>
Expand All @@ -61,7 +61,7 @@
:token="token"
:tokens="token.tokens || null"
:label="getLabels(token, idx)"
:hide-amount="isDexSwap || isTokenSwap"
:hide-amount="isDexSwap || isTokenSale"
:protocol="protocol"
/>
</template>
Expand All @@ -78,7 +78,7 @@
</DetailsItem>
<DetailsItem
v-if="isDexSwap || isTokenSwap"
v-if="isDexSwap || isTokenSale"
:label="swapDirectionTranslation"
>
<TokenAmount
Expand Down Expand Up @@ -137,7 +137,7 @@
>
<TokenAmount
:amount="executionCost || amountTotal"
:symbol="isTokenSwap ? undefined : tokenSymbol"
:symbol="isTokenSale ? undefined : tokenSymbol"
:hide-fiat="isAex9"
:protocol="protocol"
high-precision
Expand Down Expand Up @@ -301,7 +301,7 @@ import { decodeTxData } from '@/protocols/ethereum/helpers';
import { ProtocolAdapterFactory } from '@/lib/ProtocolAdapterFactory';
import type { EthDecodedCallData } from '@/protocols/ethereum/types';
import { useAeTokenSwaps } from '@/protocols/aeternity/composables/aeTokenSwaps';
import { useAeTokenSales } from '@/protocols/aeternity/composables/aeTokenSales';
import { type SignAirGapTransactionResolvedVal } from './SignAirGapTransaction.vue';
import Modal from '../Modal.vue';
Expand Down Expand Up @@ -361,7 +361,7 @@ export default defineComponent({
const { popupProps, setPopupProps } = usePopupProps();
const { getProtocolAvailableTokens, getTxAssetSymbol } = useFungibleTokens();
const { openModal } = useModals();
const { areTokenSwapsReady, tokenSwapAddressToTokenContractAddress } = useAeTokenSwaps();
const { areTokenSalesReady, tokenSaleAddressToTokenContractAddress } = useAeTokenSales();
const protocol = popupProps.value?.protocol || PROTOCOLS.aeternity;
const adapter = ProtocolAdapterFactory.getAdapter(protocol);
Expand Down Expand Up @@ -394,7 +394,7 @@ export default defineComponent({
isDexMinReceived,
isDexPool,
isDexSwap,
isTokenSwap,
isTokenSale,
txFunctionParsed,
transactionAssets,
} = useTransactionData({
Expand Down Expand Up @@ -479,23 +479,23 @@ export default defineComponent({
: undefined);
async function getTokens(txParams: ITx): Promise<ITokenResolved[]> {
if (!isDex.value && !isDexAllowance.value && !isTokenSwap.value) {
if (!isDex.value && !isDexAllowance.value && !isTokenSale.value) {
return [singleToken.value];
}
const resolver = getTransactionTokenInfoResolver(txFunctionParsed.value!);
if (!resolver) {
return [];
}
if (protocol === PROTOCOLS.aeternity && isTokenSwap.value) {
// Wait until token swap tokens are resolved
await watchUntilTruthy(areTokenSwapsReady);
if (protocol === PROTOCOLS.aeternity && isTokenSale.value) {
// Wait until token sale tokens are resolved
await watchUntilTruthy(areTokenSalesReady);
}
const tokens = resolver(
{ tx: { ...txParams, ...popupProps.value?.tx } } as ITransaction,
getProtocolAvailableTokens(PROTOCOLS.aeternity),
tokenSwapAddressToTokenContractAddress,
tokenSaleAddressToTokenContractAddress,
)?.tokens;
if (!(isDexPool.value || isTokenSwap.value)) {
if (!(isDexPool.value || isTokenSale.value)) {
return tokens;
}
if (isDexLiquidityAdd.value) {
Expand Down Expand Up @@ -703,7 +703,7 @@ export default defineComponent({
isDexMaxSpent,
isDexMinReceived,
isDexSwap,
isTokenSwap,
isTokenSale,
isHash,
loading,
nameAeFee,
Expand Down
10 changes: 5 additions & 5 deletions src/popup/components/SwapRates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import type { ITransaction } from '@/types';
import { PROTOCOLS } from '@/constants';
import { getTransactionTokenInfoResolver } from '@/protocols/aeternity/helpers';
import { useFungibleTokens, useTransactionData } from '@/composables';
import { useAeTokenSwaps } from '@/protocols/aeternity/composables/aeTokenSwaps';
import { useAeTokenSales } from '@/protocols/aeternity/composables/aeTokenSales';
import DetailsItem from './DetailsItem.vue';
import Tokens from './Tokens.vue';
Expand All @@ -63,14 +63,14 @@ export default defineComponent({
},
setup(props) {
const { getProtocolAvailableTokens } = useFungibleTokens();
const { tokenSwapAddressToTokenContractAddress } = useAeTokenSwaps();
const { tokenSaleAddressToTokenContractAddress } = useAeTokenSales();
const { isDexSwap, txFunctionParsed, isTokenSwap } = useTransactionData({
const { isDexSwap, txFunctionParsed, isTokenSale } = useTransactionData({
transaction: toRef(() => props.transaction),
});
const rates = computed(() => {
if (!isDexSwap.value || !isTokenSwap.value || !txFunctionParsed.value) {
if (!isDexSwap.value || !isTokenSale.value || !txFunctionParsed.value) {
return [];
}
Expand All @@ -82,7 +82,7 @@ export default defineComponent({
const { tokens } = resolver(
props.transaction,
getProtocolAvailableTokens(PROTOCOLS.aeternity),
tokenSwapAddressToTokenContractAddress,
tokenSaleAddressToTokenContractAddress,
);
if (tokens?.length <= 1) {
Expand Down
12 changes: 6 additions & 6 deletions src/popup/components/TransactionLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ export default defineComponent({
isDexAllowance,
isDexLiquidityAdd,
isDexLiquidityRemove,
isTokenSwapBuy,
isTokenSwapSell,
isTokenSaleBuy,
isTokenSaleSell,
isErrorTransaction,
isTip,
txTypeListLabel,
Expand Down Expand Up @@ -167,10 +167,10 @@ export default defineComponent({
} else if (isDex.value) {
text = t('common.swap');
hasComma = true;
} else if (isTokenSwapBuy.value) {
text = t('transaction.tokenSwap.bought');
} else if (isTokenSwapSell.value) {
text = t('transaction.tokenSwap.sold');
} else if (isTokenSaleBuy.value) {
text = t('transaction.tokenSale.bought');
} else if (isTokenSaleSell.value) {
text = t('transaction.tokenSale.sold');
} else if (isTip.value && props.transaction.claim) {
text = t('transaction.listType.tipReceived');
} else if (isTip.value) {
Expand Down
14 changes: 7 additions & 7 deletions src/popup/components/TransactionTagList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export default defineComponent({
isDex,
isDexPool,
isDexAllowance,
isTokenSwap,
isTokenSwapBuy,
isTokenSwapSell,
isTokenSale,
isTokenSaleBuy,
isTokenSaleSell,
} = useTransactionData({
transaction: toRef(() => props.transaction),
});
Expand Down Expand Up @@ -119,13 +119,13 @@ export default defineComponent({
? t('transaction.dexType.pool')
: t('common.swap'),
);
} else if (isTokenSwap.value) {
} else if (isTokenSale.value) {
arr.push(
t('transaction.tokenSwap.tag'),
(isTokenSwapBuy.value)
t('transaction.tokenSale.tag'),
(isTokenSaleBuy.value)
? t('common.buy')
: '',
(isTokenSwapSell.value)
(isTokenSaleSell.value)
? t('common.sell')
: '',
);
Expand Down
6 changes: 3 additions & 3 deletions src/popup/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@
"abort": "Failed",
"revert": "Reverted"
},
"tokenSwap": {
"tag": "token swap",
"tokenSale": {
"tag": "token sale",
"bought": "Bought",
"sold": "Sold"
}
Expand Down Expand Up @@ -839,7 +839,7 @@
"pooled": "Pooled",
"daoBalance": "Dao balance",
"ownerAddress": "Dao address",
"swapAddress": "Swap address",
"saleAddress": "Sale address",
"creatorAddress": "Creator address"
},
"more": {
Expand Down
Loading

0 comments on commit 4a7d815

Please sign in to comment.