mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix pool transactions symbols for swap tx, kinda
This commit is contained in:
parent
992c8ac33c
commit
1644b79cb2
@ -1,28 +1,23 @@
|
|||||||
import React, { useState, useEffect, ReactElement } from 'react'
|
import React, { useState, useEffect, ReactElement } from 'react'
|
||||||
import { Datatoken, PoolTransaction } from '.'
|
import { PoolTransaction } from '.'
|
||||||
import { useUserPreferences } from '../../../providers/UserPreferences'
|
import { useUserPreferences } from '../../../providers/UserPreferences'
|
||||||
import ExplorerLink from '../../atoms/ExplorerLink'
|
import ExplorerLink from '../../atoms/ExplorerLink'
|
||||||
import { formatPrice } from '../../atoms/Price/PriceUnit'
|
import { formatPrice } from '../../atoms/Price/PriceUnit'
|
||||||
import styles from './Title.module.css'
|
import styles from './Title.module.css'
|
||||||
|
|
||||||
function getSymbol(tokenId: Datatoken) {
|
|
||||||
const symbol = tokenId === null ? 'OCEAN' : tokenId.symbol
|
|
||||||
return symbol
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getTitle(row: PoolTransaction, locale: string) {
|
async function getTitle(row: PoolTransaction, locale: string) {
|
||||||
let title = ''
|
let title = ''
|
||||||
switch (row.event) {
|
switch (row.event) {
|
||||||
case 'swap': {
|
case 'swap': {
|
||||||
const inToken = row.tokens.filter((x) => x.type === 'in')[0]
|
const inToken = row.tokens.filter((x) => x.type === 'in')[0]
|
||||||
const inTokenSymbol = getSymbol(inToken.poolToken.tokenId)
|
const inTokenSymbol = inToken?.poolToken.symbol
|
||||||
const outToken = row.tokens.filter((x) => x.type === 'out')[0]
|
const outToken = row.tokens.filter((x) => x.type === 'out')[0]
|
||||||
const outTokenSymbol = getSymbol(outToken.poolToken.tokenId)
|
const outTokenSymbol = outToken?.poolToken.symbol
|
||||||
title += `Swap ${formatPrice(
|
title += `Swap ${formatPrice(
|
||||||
Math.abs(inToken.value).toString(),
|
Math.abs(inToken?.value).toString(),
|
||||||
locale
|
locale
|
||||||
)}${inTokenSymbol} for ${formatPrice(
|
)}${inTokenSymbol} for ${formatPrice(
|
||||||
Math.abs(outToken.value).toString(),
|
Math.abs(outToken?.value).toString(),
|
||||||
locale
|
locale
|
||||||
)}${outTokenSymbol}`
|
)}${outTokenSymbol}`
|
||||||
|
|
||||||
@ -34,13 +29,13 @@ async function getTitle(row: PoolTransaction, locale: string) {
|
|||||||
x.tokenAddress.toLowerCase() !==
|
x.tokenAddress.toLowerCase() !==
|
||||||
row.poolAddress.datatokenAddress.toLowerCase()
|
row.poolAddress.datatokenAddress.toLowerCase()
|
||||||
)[0]
|
)[0]
|
||||||
const firstTokenSymbol = await getSymbol(firstToken.poolToken.tokenId)
|
const firstTokenSymbol = firstToken?.poolToken.symbol
|
||||||
const secondToken = row.tokens.filter(
|
const secondToken = row.tokens.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.tokenAddress.toLowerCase() ===
|
x.tokenAddress.toLowerCase() ===
|
||||||
row.poolAddress.datatokenAddress.toLowerCase()
|
row.poolAddress.datatokenAddress.toLowerCase()
|
||||||
)[0]
|
)[0]
|
||||||
const secondTokenSymbol = await getSymbol(secondToken.poolToken.tokenId)
|
const secondTokenSymbol = secondToken?.poolToken.symbol
|
||||||
title += `Create pool with ${formatPrice(
|
title += `Create pool with ${formatPrice(
|
||||||
Math.abs(firstToken.value).toString(),
|
Math.abs(firstToken.value).toString(),
|
||||||
locale
|
locale
|
||||||
@ -53,7 +48,7 @@ async function getTitle(row: PoolTransaction, locale: string) {
|
|||||||
case 'join':
|
case 'join':
|
||||||
case 'exit': {
|
case 'exit': {
|
||||||
for (let i = 0; i < row.tokens.length; i++) {
|
for (let i = 0; i < row.tokens.length; i++) {
|
||||||
const tokenSymbol = await getSymbol(row.tokens[i].poolToken.tokenId)
|
const tokenSymbol = row.tokens[i].poolToken.symbol
|
||||||
if (i > 0) title += '\n'
|
if (i > 0) title += '\n'
|
||||||
title += `${row.event === 'join' ? 'Add' : 'Remove'} ${formatPrice(
|
title += `${row.event === 'join' ? 'Add' : 'Remove'} ${formatPrice(
|
||||||
Math.abs(row.tokens[i].value).toString(),
|
Math.abs(row.tokens[i].value).toString(),
|
||||||
|
@ -6,7 +6,6 @@ import { useUserPreferences } from '../../../providers/UserPreferences'
|
|||||||
import { gql } from 'urql'
|
import { gql } from 'urql'
|
||||||
import { TransactionHistory_poolTransactions as TransactionHistoryPoolTransactions } from '../../../@types/apollo/TransactionHistory'
|
import { TransactionHistory_poolTransactions as TransactionHistoryPoolTransactions } from '../../../@types/apollo/TransactionHistory'
|
||||||
import web3 from 'web3'
|
import web3 from 'web3'
|
||||||
import { useWeb3 } from '../../../providers/Web3'
|
|
||||||
import { fetchDataForMultipleChains } from '../../../utils/subgraph'
|
import { fetchDataForMultipleChains } from '../../../utils/subgraph'
|
||||||
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
|
||||||
import NetworkName from '../../atoms/NetworkName'
|
import NetworkName from '../../atoms/NetworkName'
|
||||||
@ -56,10 +55,12 @@ const txHistoryQuery = gql`
|
|||||||
) {
|
) {
|
||||||
tokens {
|
tokens {
|
||||||
poolToken {
|
poolToken {
|
||||||
tokenId {
|
id
|
||||||
symbol
|
symbol
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
value
|
||||||
|
type
|
||||||
|
tokenAddress
|
||||||
}
|
}
|
||||||
tx
|
tx
|
||||||
event
|
event
|
||||||
@ -67,11 +68,6 @@ const txHistoryQuery = gql`
|
|||||||
poolAddress {
|
poolAddress {
|
||||||
datatokenAddress
|
datatokenAddress
|
||||||
}
|
}
|
||||||
tokens {
|
|
||||||
value
|
|
||||||
type
|
|
||||||
tokenAddress
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
Loading…
Reference in New Issue
Block a user