Skip to content

Commit

Permalink
Merge branch 'v4-tests' of https://github.com/bcnmy/sdk-demo into v4-…
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
GabiDev45 committed Feb 28, 2024
2 parents 1bb8003 + 9cc7511 commit 2bf623a
Show file tree
Hide file tree
Showing 21 changed files with 1,953 additions and 1,330 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"@biconomy-devx/account": "2.2.12",
"@alchemy/aa-core": "1.2.2",
"@biconomy/account": "4.0.0",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.12",
"@mui/styles": "^5.11.12",
"@rainbow-me/rainbowkit": "^1.2.0",
"@rainbow-me/rainbowkit": "^2.0.0",
"@tanstack/react-query": "^5.22.2",
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
Expand All @@ -22,8 +23,8 @@
"react-scripts": "5.0.1",
"react-toastify": "^9.0.8",
"typescript": "5.2.0",
"viem": "^1.20.3",
"wagmi": "^1.4.5",
"viem": "^2.7.3",
"wagmi": "^2.5.5",
"web-vitals": "^2.1.0"
},
"scripts": {
Expand Down Expand Up @@ -67,4 +68,4 @@
"tls": "^0.0.1",
"url": "^0.11.0"
}
}
}
6 changes: 3 additions & 3 deletions src/components/AA/BatchLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
showSuccessMessage,
showErrorMessage,
} from "../../utils";
import { PaymasterMode } from "@biconomy-devx/account";
import { PaymasterMode } from "@biconomy/account";

const BatchLiquidity: React.FC = () => {
const classes = useStyles();
Expand All @@ -23,7 +23,7 @@ const BatchLiquidity: React.FC = () => {
const approveCallData = encodeFunctionData({
abi: config.usdc.abi,
functionName: "approve",
args: [config.hyphenLP.address, parseEther("0.001", "gwei")],
args: [config.hyphenLP.address, parseEther("1")],
});
const tx1 = {
to: config.usdc.address as Hex,
Expand All @@ -34,7 +34,7 @@ const BatchLiquidity: React.FC = () => {
const addLiquidityData = encodeFunctionData({
abi: config.hyphenLP.abi,
functionName: "addTokenLiquidity",
args: [config.usdc.address, parseEther("0.001", "gwei")],
args: [config.usdc.address, parseUnits("0.001", 6)],
});
const tx2 = {
to: config.hyphenLP.address as Hex,
Expand Down
4 changes: 2 additions & 2 deletions src/components/AA/MintNft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
showErrorMessage,
showSuccessMessage,
} from "../../utils";
import { PaymasterMode } from "@biconomy-devx/account";
import { PaymasterMode } from "@biconomy/account";

const MintNft: React.FC = () => {
const classes = useStyles();
Expand All @@ -23,7 +23,7 @@ const MintNft: React.FC = () => {
const nftContract = getContract({
address: config.nft.address as Hex,
abi: config.nft.abi,
publicClient,
client: publicClient,
});
const count = await nftContract.read.balanceOf([scwAddress]);
console.log("count", count);
Expand Down
10 changes: 4 additions & 6 deletions src/components/Forward/BatchLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CircularProgress } from "@mui/material";
import {
PaymasterFeeQuote,
PaymasterMode,
} from "@biconomy-devx/account";
} from "@biconomy/account";

import Button from "../Button";
import { useSmartAccountContext } from "../../contexts/SmartAccountContext";
Expand All @@ -13,7 +13,7 @@ import {
showSuccessMessage,
showErrorMessage,
} from "../../utils";
import { Hex, encodeFunctionData, parseEther } from "viem";
import { Hex, encodeFunctionData, parseEther, parseUnits } from "viem";

const BatchLiquidity: React.FC = () => {
const classes = useStyles();
Expand All @@ -36,22 +36,20 @@ const BatchLiquidity: React.FC = () => {
const approveCallData = encodeFunctionData({
abi: config.usdc.abi,
functionName: "approve",
args: [config.hyphenLP.address, parseEther("0.001", "gwei")],
args: [config.hyphenLP.address, parseEther("1")],
});
const tx1 = {
to: config.usdc.address as Hex,
value: BigInt(0),
data: approveCallData,
};

const addLiquidityData = encodeFunctionData({
abi: config.hyphenLP.abi,
functionName: "addTokenLiquidity",
args: [config.usdc.address, parseEther("0.001", "gwei")],
args: [config.usdc.address, parseUnits("0.001", 6)],
});
const tx2 = {
to: config.hyphenLP.address as Hex,
value: BigInt(0),
data: addLiquidityData,
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/Forward/MintNft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CircularProgress from "@mui/material/CircularProgress";
import {
PaymasterFeeQuote,
PaymasterMode,
} from "@biconomy-devx/account";
} from "@biconomy/account";

import Button from "../Button";
import { useSmartAccountContext } from "../../contexts/SmartAccountContext";
Expand Down Expand Up @@ -35,7 +35,7 @@ const MintNftForward: React.FC = () => {
const nftContract = getContract({
address: config.nft.address as Hex,
abi: config.nft.abi,
publicClient,
client: publicClient,
});
const count = await nftContract.read.balanceOf([scwAddress as Hex]);
console.log("count", Number(count));
Expand Down
64 changes: 64 additions & 0 deletions src/components/Modules/ABI_SVM.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

import { useState } from 'react';
import { Contract, ethers } from 'ethers'
import abis from "../../utils/configs/contractsInfo.json";
import { useSmartAccountContext } from '../../contexts/SmartAccountContext';
import { useAccount } from 'wagmi';
import CreateABISVM from './CreateABISVM';
import { ABI_SVM } from '../../utils/constants';


export default function ABISVM() {
const { address } = useAccount();
const { smartAccount, scwAddress } = useSmartAccountContext();
const [loading, setLoading] = useState<boolean>(false);
const [provider, setProvider] = useState<ethers.providers.Provider | null>(null)

const [mockStake, setMockStake] = useState<Contract>();

const connect = async () => {
// @ts-ignore
const { ethereum } = window;
try {
setLoading(true)
const provider = new ethers.providers.Web3Provider(ethereum)
await provider.send("eth_requestAccounts", []);
setProvider(provider)

setMockStake(mockStake);
setLoading(false)
} catch (error) {
console.error(error);
}
};

console.log(smartAccount);
console.log(provider);

return (
<>
<main >
<h1>ABI SVM Demo</h1>
{!loading && !address && <button onClick={connect} >Connect to Web3</button>}
{loading && <p>Loading Smart Account...</p>}
{scwAddress && <h2>Smart Account: {scwAddress}</h2>}

{
smartAccount && (
<CreateABISVM
smartAccount={smartAccount}
address={scwAddress}
provider={provider!}
nftContract={new ethers.Contract(
"0x1758f42Af7026fBbB559Dc60EcE0De3ef81f665e",
abis.nft.abi,
provider!
)!}
abiSVMAddress={ABI_SVM}
/>
)
}
</main>
</>
)
}
Loading

0 comments on commit 2bf623a

Please sign in to comment.