Skip to content

Commit

Permalink
apply temp fix for USDC issue #262 (#263)
Browse files Browse the repository at this point in the history
* apply temp fix

* Applying prettier

Co-authored-by: nerderlyne <[email protected]>
  • Loading branch information
nerderlyne and nerderlyne authored Aug 15, 2022
1 parent 5e7b246 commit f6611a5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions components/dao-dashboard/proposal/page/visualizer/Call.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Flex, Box, Text, Button } from '../../../../../styles/elements'
import { CopyIcon, ExternalLinkIcon } from '@radix-ui/react-icons'
import getExplorerLink from '../../../../../utils/getExplorerLink'
import decodeTx from './decodeTx'
import { tokens } from '../../../../../constants/tokens'

export default function Call({ accounts, amounts, payloads }) {
const router = useRouter()
Expand All @@ -12,7 +13,7 @@ export default function Call({ accounts, amounts, payloads }) {
const decoded = decodeTx(payloads?.[i], amounts?.[i])
console.log('decoded', decoded)

const params = createParams(decoded)
const params = createParams(accounts[i], router.query.chainId, decoded)
console.log('params', params)
return (
<Flex
Expand Down Expand Up @@ -135,14 +136,25 @@ export default function Call({ accounts, amounts, payloads }) {
}
}

const createParams = (decoded) => {
const createParams = (to, chain, decoded) => {
console.log('decoded', decoded)
if (!decoded || decoded == 'none') return
let array = []
for (let i = 0; i < decoded['tx']['args'].length; i++) {
let value = decoded['tx']['args'][i]
if (decoded['tx']['functionFragment']['inputs'][i]['type'] == 'uint256') {
value = ethers.utils.formatEther(decoded['tx']['args'][i])
value = ethers.utils.formatUnits(decoded['tx']['args'][i], 18)

// FIXME: fetch decimals instead
if (decoded['type'] == 'ERC20') {
const cTokens = tokens[chain]
for (let key in cTokens) {
if (!cTokens.hasOwnProperty(key)) continue
if (cTokens[key]['address'] === to) {
value = ethers.utils.formatUnits(decoded['tx']['args'][i], cTokens[key]['decimals'])
}
}
}
}

array.push({
Expand Down

1 comment on commit f6611a5

@vercel
Copy link

@vercel vercel bot commented on f6611a5 Aug 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.