Skip to content

Commit

Permalink
Merge pull request #28 from bcnmy/v4-tests
Browse files Browse the repository at this point in the history
Update sdk-demo
  • Loading branch information
VGabriel45 authored Feb 28, 2024
2 parents 3080bdc + a868e64 commit 23902f4
Show file tree
Hide file tree
Showing 27 changed files with 2,830 additions and 3,318 deletions.
19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"@biconomy/account": "3.1.1",
"@biconomy/bundler": "3.1.1",
"@biconomy/common": "3.1.1",
"@biconomy/core-types": "3.1.1",
"@biconomy/modules": "3.1.1",
"@biconomy/paymaster": "3.1.1",
"@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 @@ -25,9 +22,9 @@
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-toastify": "^9.0.8",
"typescript": "^4.4.2",
"viem": "^1.18.3",
"wagmi": "^1.4.5",
"typescript": "5.2.0",
"viem": "^2.7.3",
"wagmi": "^2.5.5",
"web-vitals": "^2.1.0"
},
"scripts": {
Expand Down Expand Up @@ -71,4 +68,4 @@
"tls": "^0.0.1",
"url": "^0.11.0"
}
}
}
55 changes: 23 additions & 32 deletions src/components/AA/BatchLiquidity.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,54 @@
import React, { useState } from "react";
import { ethers } from "ethers";
import { makeStyles } from "@mui/styles";
import { PaymasterMode } from "@biconomy/paymaster";
import { Hex, encodeFunctionData, parseEther, parseUnits } from "viem";
import Button from "../Button";
import { useEthersSigner } from "../../contexts/ethers";
import { useSmartAccountContext } from "../../contexts/SmartAccountContext";
import {
configInfo as config,
showSuccessMessage,
showErrorMessage,
} from "../../utils";

const iFace = new ethers.utils.Interface(config.usdc.abi);
import { PaymasterMode } from "@biconomy/account";

const BatchLiquidity: React.FC = () => {
const classes = useStyles();
const signer = useEthersSigner();
const { smartAccount, scwAddress } = useSmartAccountContext();
const [loading, setLoading] = useState(false);

const makeTx = async () => {
if (!scwAddress || !smartAccount || !signer) return;
if (!scwAddress || !smartAccount) return;
try {
setLoading(true);
const txs = [];

const approveCallData = iFace.encodeFunctionData("approve", [
config.hyphenLP.address,
ethers.BigNumber.from("1000000"),
]);
const approveCallData = encodeFunctionData({
abi: config.usdc.abi,
functionName: "approve",
args: [config.hyphenLP.address, parseEther("1")],
});
const tx1 = {
to: config.usdc.address,
to: config.usdc.address as Hex,
value: BigInt(0),
data: approveCallData,
};
txs.push(tx1);

const hyphenContract = new ethers.Contract(
config.hyphenLP.address,
config.hyphenLP.abi,
signer
);
const addLiquidityData = hyphenContract.interface.encodeFunctionData("addTokenLiquidity", [config.usdc.address,
ethers.BigNumber.from("1000000")])
const addLiquidityData = encodeFunctionData({
abi: config.hyphenLP.abi,
functionName: "addTokenLiquidity",
args: [config.usdc.address, parseUnits("0.001", 6)],
});
const tx2 = {
to: config.hyphenLP.address,
to: config.hyphenLP.address as Hex,
value: BigInt(0),
data: addLiquidityData,
};
txs.push(tx2);

let userOp = await smartAccount.buildUserOp(txs, {
paymasterServiceData: {
mode: PaymasterMode.SPONSORED,
},
});
const userOpResponse = await smartAccount.sendUserOp(userOp);
console.log("userOpHash", userOpResponse);
const { transactionHash } = await userOpResponse.waitForTxHash();
let { waitForTxHash } = await smartAccount.sendTransaction([tx1, tx2], { paymasterServiceData: { mode: PaymasterMode.SPONSORED } });
const { transactionHash } = await waitForTxHash();
console.log("txHash", transactionHash);
showSuccessMessage(`Added batch liquidity ${transactionHash}`, transactionHash);
showSuccessMessage(
`Added batch liquidity ${transactionHash}`,
transactionHash
);
setLoading(false);
} catch (err: any) {
console.error(err);
Expand Down
137 changes: 0 additions & 137 deletions src/components/AA/BatchMintNft.tsx

This file was deleted.

Loading

0 comments on commit 23902f4

Please sign in to comment.