Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

ENS Resolving + Mai Stablecoin + Misc Fix #42

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"license": "MIT",
"resolutions": {
"@chainsafe/as-sha256": "0.4.0"
},
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
Expand Down Expand Up @@ -60,6 +60,7 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@ensdomains/ensjs": "3.0.0-alpha.62",
"@metamask/eth-sig-util": "^4.0.1",
"@types/qrcode": "^1.5.0",
"@types/react-router-dom": "^5.3.3",
Expand Down
Binary file added src/assets/dapps/mai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/tokens/mai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 28 additions & 4 deletions src/components/SendAssets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import cn from "classnames";
import { Input } from "../Input";
import { TokenSelect } from "../TokenSelect";
import { toast } from "material-react-toastify";
import { ENS } from '@ensdomains/ensjs';
import { ethers } from "ethers";

const ethersProvider = new ethers.providers.JsonRpcProvider(config.providerEth);
const ENSInstance = new ENS()

interface ErrorProps {
receiverAddress: string;
Expand All @@ -35,14 +40,31 @@ export default function SendAssets({ tokenAddress = "" }: ISendAssets) {
const { balance } = useBalanceStore();
const [sendToken, setSendToken] = useState(tokenAddress);
const [receiverAddress, setReceiverAddress] = useState<string>("");
const [receiverEnsAddress, setReceiverEnsAddress] = useState<string>("");

const [errors, setErrors] = useState<ErrorProps>(defaultErrorValues);
const { web3 } = useWalletContext();

const { sendErc20, sendEth } = useTransaction();

const confirmAddress = () => {
if (!receiverAddress || !web3.utils.isAddress(receiverAddress)) {

const confirmAddress = async () => {
await ENSInstance.setProvider(ethersProvider)

let ensAddress;

if(receiverAddress.includes(".eth")) {
const profile = await ENSInstance.getProfile(receiverAddress);
ensAddress = profile?.address;
if(ensAddress && web3.utils.isAddress(ensAddress)) {
//console.log("ensAddress", ensAddress)
setReceiverEnsAddress(ensAddress)
}
}

if ((!receiverAddress || !web3.utils.isAddress(receiverAddress)) && (!ensAddress || !web3.utils.isAddress(ensAddress)) ) {
toast.error("Address not valid");
//console.log(receiverAddress);
return;
}
setStep(1);
Expand All @@ -54,6 +76,8 @@ export default function SendAssets({ tokenAddress = "" }: ISendAssets) {
return;
}

let receiverResolved = (web3.utils.isAddress(receiverEnsAddress) ) ? receiverEnsAddress : receiverAddress;

const tokenBalance = balance.get(sendToken);

if (!tokenBalance || new BN(amount).isGreaterThan(tokenBalance)) {
Expand All @@ -63,9 +87,9 @@ export default function SendAssets({ tokenAddress = "" }: ISendAssets) {
setSending(true);
try {
if (sendToken === config.zeroAddress) {
await sendEth(receiverAddress, amount);
await sendEth(receiverResolved, amount);
} else {
await sendErc20(sendToken, receiverAddress, amount);
await sendErc20(sendToken, receiverResolved, amount);
}
goBack();
} finally {
Expand Down
14 changes: 13 additions & 1 deletion src/config/arb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import IconETH from "@src/assets/tokens/eth.svg";
import IconUSDC from "@src/assets/tokens/usdc.svg";
import IconDAI from "@src/assets/tokens/dai.png";
import IconUSDT from "@src/assets/tokens/usdt.png";
import IconMAI from "@src/assets/tokens/mai.png";

const paymasterToken_DAI = "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1";
const paymasterToken_USDC = "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8";
const paymasterToken_USDT = "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9";
const paymasterToken_MAI = "0x3F56e0c36d275367b8C502090EDF38289b3dEa0d";

export const assetsList = [
{
Expand All @@ -29,6 +31,15 @@ export const assetsList = [
payable: true,
paymaster: false,
},
{
icon: IconMAI,
symbol: "MAI",
address: paymasterToken_MAI,
name: "Mai Stablecoin",
decimals: 18,
payable: false,
paymaster: false,
},
{
icon: IconDAI,
name: "Dai Stablecoin",
Expand Down Expand Up @@ -1404,7 +1415,8 @@ export default {
provider: `https://arb1.arbitrum.io/rpc`,
backendURL: "https://dev.internalversion.api.soulwallets.me",
soulScanURL: "https://api.4337scan.dev.soulwallets.me",
scanUrl: "https://arbiscan.io/",
scanUrl: "https://arbiscan.io",
providerEth: "https://eth.llamarpc.com",
// should it override state when we set new?
defaultBundlerUrl: "https://bundler-arb-main.soulwallets.me/rpc",
maxCostMultiplier: 120,
Expand Down
8 changes: 8 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import IconAave from "@src/assets/dapps/aave.svg";
import IconUniswap from "@src/assets/dapps/uniswap.svg";
import IconSushiswap from "@src/assets/dapps/sushiswap.svg";
import IconGmx from "@src/assets/dapps/gmx.svg";
import IconMai from "@src/assets/dapps/mai.png";

// import IconYearn from "@src/assets/dapps/yearn.svg";
// import envConf from './arb-goerli'

Expand Down Expand Up @@ -32,6 +34,12 @@ export const dappsList = [
category: "DeFi",
link: "https://app.gmx.io/",
},
{
icon: IconMai,
title: "QiDao",
category: "DeFi",
link: "https://app.mai.finance/",
},

// {
// icon: Icon1inch,
Expand Down