import { utils } from "ethers"; import { PureComponent } from "react"; import { Container } from "react-bootstrap"; import { connect } from "react-redux"; import { getBalances, getGasPrice, getPaymasterData, getTokenBalances, getWeb3State } from "../../store/blockchain/selectors"; import { Balance, Paymaster, TokenBalance, Web3State } from "../../types/blockchain"; import { StoreState } from "../../types/store"; interface StateProps { ethBalance: Balance, tokensBalance: Array, gasPrice: string, getPaymasterData: Paymaster, web3State: Web3State } type Props = StateProps; class Balances extends PureComponent { render() { const { ethBalance, tokensBalance, getPaymasterData, web3State } = this.props; if(web3State !== Web3State.Done || !ethBalance || tokensBalance.length === 0) return null return (

Summary

Paymaster Balance: {utils.formatUnits(getPaymasterData.balance.balance)} ETH
Paymaster Min Balance: {utils.formatUnits(getPaymasterData.minBalance)} ETH
Payment Token: {getPaymasterData.paymentData.paymentToken}
Payment Token Fee: {getPaymasterData.paymentData.fee}
Gas Used By Post: {getPaymasterData.gasUsedByPost.toString()} Gas
Min Gas To Swap: {getPaymasterData.minGas.toString()} Gas
Target Contract: {getPaymasterData.targetContract}
) } } const mapStateToProps = (state: StoreState): StateProps => { return { ethBalance: getBalances(state), tokensBalance: getTokenBalances(state), gasPrice: getGasPrice(state), getPaymasterData: getPaymasterData(state), web3State: getWeb3State(state) } } const BalancesContainer = connect(mapStateToProps)(Balances); export { BalancesContainer }