kyscott18 / reverse-mirage

Application level TypeScript utilities for Ethereum
https://reversemirage.com
MIT License
49 stars 3 forks source link

getERC20 not working #66

Closed 7flash closed 7 months ago

7flash commented 7 months ago

Given following code

import { publicActionReverseMirage, amountToNumber } from 'reverse-mirage'

window.publicEthClient = createPublicClient({
  chain: mainnet,
  transport: http()
}).extend(publicActionReverseMirage)

await publicEthClient.getERC20({
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc
  id: 1,
})

throws an error

Uncaught TypeError: Cannot read properties of undefined (reading 'address')
    at getERC20Name (index.js:1033:18)
    at getERC20 (index.js:1046:3)
    at Object.getERC20 (index.js:1672:23)
    at <anonymous>:1:23
Screenshot 2024-03-15 at 17 25 55
kyscott18 commented 7 months ago

You're passing in the wrong arguments to the function. Should be:

await publicEthClient.getERC20({
  erc20: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc
  id: 1,
})

What you have might be more intuitive, will think about changing it