Skip to content

Commit

Permalink
Merge pull request #33 from bcnmy/feat/v4.2
Browse files Browse the repository at this point in the history
chore: v4.2 + amoy changes
  • Loading branch information
livingrockrises authored Apr 25, 2024
2 parents 1dde69c + dfb0b3e commit 3a28d0b
Show file tree
Hide file tree
Showing 20 changed files with 2,168 additions and 2,173 deletions.
138 changes: 69 additions & 69 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
{
"name": "biconomy-sdk-demo",
"version": "1.0.0",
"private": true,
"dependencies": {
"@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": "^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",
"buffer": "^6.0.3",
"ethers": "^5.6.9",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-toastify": "^9.0.8",
"typescript": "^5",
"viem": "^2.7.3",
"wagmi": "^2.5.5",
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
"chrome >= 67",
"edge >= 79",
"firefox >= 68",
"opera >= 54",
"safari >= 14"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"c-kzg": "^1.0.9",
"crypto-browserify": "^3.12.0",
"https-browserify": "^1.0.0",
"net": "^1.0.2",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"react-app-rewired": "^2.2.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"tls": "^0.0.1",
"url": "^0.11.0"
}
"name": "biconomy-sdk-demo",
"version": "1.0.0",
"private": true,
"dependencies": {
"@biconomy-devx/account": "^4.2.12",
"@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": "^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",
"buffer": "^6.0.3",
"ethers": "^5.6.9",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-toastify": "^9.0.8",
"typescript": "^5",
"viem": "latest",
"wagmi": "latest",
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
"chrome >= 67",
"edge >= 79",
"firefox >= 68",
"opera >= 54",
"safari >= 14"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"c-kzg": "^1.0.9",
"crypto-browserify": "^3.12.0",
"https-browserify": "^1.0.0",
"net": "^1.0.2",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"react-app-rewired": "^2.2.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
"tls": "^0.0.1",
"url": "^0.11.0"
}
}
196 changes: 99 additions & 97 deletions src/components/AA/BatchLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,118 +4,120 @@ import { Hex, encodeFunctionData, parseEther, parseUnits } from "viem";
import Button from "../Button";
import { useSmartAccountContext } from "../../contexts/SmartAccountContext";
import {
configInfo as config,
showSuccessMessage,
showErrorMessage,
configInfo as config,
showSuccessMessage,
showErrorMessage,
} from "../../utils";
import { PaymasterMode } from "@biconomy/account";
import { PaymasterMode } from "@biconomy-devx/account";

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

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

const approveCallData = encodeFunctionData({
abi: config.usdc.abi,
functionName: "approve",
args: [config.hyphenLP.address, parseEther("1")],
});
const tx1 = {
to: config.usdc.address as Hex,
value: BigInt(0),
data: approveCallData,
};
const approveCallData = encodeFunctionData({
abi: config.usdc.abi,
functionName: "approve",
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, parseUnits("0.001", 6)],
});
const tx2 = {
to: config.hyphenLP.address as Hex,
value: BigInt(0),
data: addLiquidityData,
};
const addLiquidityData = encodeFunctionData({
abi: config.hyphenLP.abi,
functionName: "addTokenLiquidity",
args: [config.usdc.address, parseUnits("0.001", 6)],
});
const tx2 = {
to: config.hyphenLP.address as Hex,
value: BigInt(0),
data: addLiquidityData,
};

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
);
setLoading(false);
} catch (err: any) {
console.error(err);
setLoading(false);
showErrorMessage(err.message || "Error in sending the transaction");
}
};
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,
);
setLoading(false);
} catch (err: any) {
console.error(err);
setLoading(false);
showErrorMessage(err.message || "Error in sending the transaction");
}
};

return (
<main className={classes.main}>
<p style={{ color: "#7E7E7E" }}>
Use Cases {"->"} Gasless {"->"} USDC Liquidity on Hyphen
</p>
return (
<main className={classes.main}>
<p style={{ color: "#7E7E7E" }}>
Use Cases {"->"} Gasless {"->"} USDC Liquidity on Hyphen
</p>

<h3 className={classes.subTitle}>Approve and Add Liquidity in Hyphen</h3>
<h3 className={classes.subTitle}>Approve and Add Liquidity in Hyphen</h3>

<p>
This magic bundle will approve USDC then provide the USDC liquidity to
Hyphen Pool
</p>
<p>
This magic bundle will approve USDC then provide the USDC liquidity to
Hyphen Pool
</p>

<h3 className={classes.h3Title}>Transaction Batched</h3>
<ul>
<li>Approve USDC</li>
<li>Provide USDC Liquidity on Hyphen</li>
</ul>
<h3 className={classes.h3Title}>Transaction Batched</h3>
<ul>
<li>Approve USDC</li>
<li>Provide USDC Liquidity on Hyphen</li>
</ul>

<Button
title="Do transaction (One Click LP)"
isLoading={loading}
onClickFunc={makeTx}
/>
</main>
);
<Button
title="Do transaction (One Click LP)"
isLoading={loading}
onClickFunc={makeTx}
/>
</main>
);
};

const useStyles = makeStyles(() => ({
main: {
padding: "10px 40px",
color: "#EEEEEE",
},
subTitle: {
color: "#FFB999",
fontSize: 36,
margin: 0,
},
h3Title: {
color: "#e6e6e6",
},
container: {
// backgroundColor: "rgb(29, 31, 33)",
},
containerBtn: {
display: "flex",
gap: 15,
// justifyContent: "space-between",
},
tab: {
padding: "5px 15px",
backgroundColor: "#FCF8E8",
marginBottom: 10,
},
listHover: {
"&:hover": {
color: "#FF9551",
},
},
main: {
padding: "10px 40px",
color: "#EEEEEE",
},
subTitle: {
color: "#FFB999",
fontSize: 36,
margin: 0,
},
h3Title: {
color: "#e6e6e6",
},
container: {
// backgroundColor: "rgb(29, 31, 33)",
},
containerBtn: {
display: "flex",
gap: 15,
// justifyContent: "space-between",
},
tab: {
padding: "5px 15px",
backgroundColor: "#FCF8E8",
marginBottom: 10,
},
listHover: {
"&:hover": {
color: "#FF9551",
},
},
}));

export default BatchLiquidity;
Loading

0 comments on commit 3a28d0b

Please sign in to comment.