Skip to content

Commit

Permalink
Merge pull request #26 from bcnmy/contract-call-abi-svm-demo
Browse files Browse the repository at this point in the history
Contract call abi svm demo
  • Loading branch information
AmanRaj1608 authored Dec 12, 2023
2 parents e3569f3 + 3fe859f commit 3080bdc
Show file tree
Hide file tree
Showing 12 changed files with 1,124 additions and 167 deletions.
13 changes: 3 additions & 10 deletions src/components/AA/BatchLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,12 @@ const BatchLiquidity: React.FC = () => {
config.hyphenLP.abi,
signer
);
const hyphenLPTx =
await hyphenContract.populateTransaction.addTokenLiquidity(
config.usdc.address,
ethers.BigNumber.from("1000000"),
{
from: scwAddress,
}
);
const addLiquidityData = hyphenContract.interface.encodeFunctionData("addTokenLiquidity", [config.usdc.address,
ethers.BigNumber.from("1000000")])
const tx2 = {
to: config.hyphenLP.address,
data: hyphenLPTx.data,
data: addLiquidityData,
};
// todo check this for hyphen LP on Mumbai!
txs.push(tx2);

let userOp = await smartAccount.buildUserOp(txs, {
Expand Down
116 changes: 62 additions & 54 deletions src/components/AA/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { makeStyles } from "@mui/styles";
import ControlPointIcon from "@mui/icons-material/ControlPoint";
// import ControlPointIcon from "@mui/icons-material/ControlPoint";
import ImageIcon from "@mui/icons-material/Image";
import ControlPointDuplicateIcon from "@mui/icons-material/ControlPointDuplicate";
import CollectionsIcon from "@mui/icons-material/Collections";
// import CollectionsIcon from "@mui/icons-material/Collections";

interface Props {
useCase: number;
Expand All @@ -12,24 +12,24 @@ interface Props {
}

const cardItems = [
{
title: "Mint ERC20 Token",
description: "This is single transaction to give Mint an ERC-20 token",
index: 4,
icon: (
<ControlPointIcon
style={{
color: "#FFB999",
fontSize: 72,
}}
/>
),
},
// {
// title: "Mint ERC20 Token",
// description: "This is single transaction to give Mint an ERC-20 token",
// index: 4,
// icon: (
// <ControlPointIcon
// style={{
// color: "#FFB999",
// fontSize: 72,
// }}
// />
// ),
// },
{
title: "Mint NFT",
description:
"This is single transaction to give Mint an ERC-721 (NFT) token",
index: 5,
index: 3,
icon: (
<ImageIcon
style={{
Expand All @@ -43,7 +43,7 @@ const cardItems = [
title: "BatchTx - Liquidity",
description:
"This magic bundle will approve USDC then provide the USDC liquidity to Hyphen Pool.",
index: 6,
index: 4,
icon: (
<ControlPointDuplicateIcon
style={{
Expand All @@ -53,23 +53,27 @@ const cardItems = [
/>
),
},
{
title: "BatchTx - NFT",
description:
"This magic bundle will batch two single safeMint into one transaction.",
index: 7,
icon: (
<CollectionsIcon
style={{
color: "#FFB999",
fontSize: 72,
}}
/>
),
},
// {
// title: "BatchTx - NFT",
// description:
// "This magic bundle will batch two single safeMint into one transaction.",
// index: 7,
// icon: (
// <CollectionsIcon
// style={{
// color: "#FFB999",
// fontSize: 72,
// }}
// />
// ),
// },
];

const AccountAbstraction: React.FC<Props> = ({ useCase, setUseCase, pageIndexChange }) => {
const AccountAbstraction: React.FC<Props> = ({
useCase,
setUseCase,
pageIndexChange,
}) => {
const classes = useStyles();

return (
Expand All @@ -96,28 +100,32 @@ const AccountAbstraction: React.FC<Props> = ({ useCase, setUseCase, pageIndexCha

<div className={classes.cardContainer}>
{cardItems.map((item, index) => (
<div onClick={(e)=>pageIndexChange(e,item.index)} key={index} className={classes.card}>
<div
onClick={(e) => pageIndexChange(e, item.index)}
key={index}
className={classes.card}
>
{item.icon}
<div className={classes.textBox}>
<h3
style={{
color: "#FFB999",
textAlign: "start",
fontSize: "auto",
margin: 0,
}}
>
{item.title}
</h3>
<p
style={{
fontSize: 14,
margin: 0,
textAlign: "center",
}}
>
{item.description}
</p>
<h3
style={{
color: "#FFB999",
textAlign: "start",
fontSize: "auto",
margin: 0,
}}
>
{item.title}
</h3>
<p
style={{
fontSize: 14,
margin: 0,
textAlign: "center",
}}
>
{item.description}
</p>
</div>
</div>
))}
Expand Down Expand Up @@ -186,15 +194,15 @@ const useStyles = makeStyles(() => ({
fontSize: 36,
margin: 0,
},
textBox:{
textBox: {
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
gap: 8,
"@media (max-width:1640px)": {
alignItems: "start",
}
},
},
subSubTitle: {
fontFamily: "Rubik",
Expand Down
15 changes: 6 additions & 9 deletions src/components/Forward/BatchLiquidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,16 @@ const BatchLiquidity: React.FC = () => {
};
txs.push(tx1);

const hyphenLPTx =
await hyphenContract.populateTransaction.addTokenLiquidity(
config.usdc.address,
ethers.BigNumber.from("1000000")
);

const addLiquidityData = hyphenContract.interface.encodeFunctionData("addTokenLiquidity", [config.usdc.address,
ethers.BigNumber.from("1000000")]) // 1 USDC (mumbai USDC has 6 decimals)
const tx2 = {
to: config.hyphenLP.address,
data: hyphenLPTx.data,
data: addLiquidityData,
};

txs.push(tx2);
console.log("Tx array created", txs);
let partialUserOp = await smartAccount.buildUserOp([tx1], {
let partialUserOp = await smartAccount.buildUserOp(txs, {
paymasterServiceData: {
mode: PaymasterMode.ERC20,
},
Expand All @@ -84,7 +81,7 @@ const BatchLiquidity: React.FC = () => {
// here we are explicitly telling by mode ERC20 that we want to pay in ERC20 tokens and expect fee quotes
mode: PaymasterMode.ERC20,
// one can pass tokenList empty array. and it would return fee quotes for all tokens supported by the Biconomy paymaster
tokenList: [],
tokenList: [config.usdc.address, config.usdt.address],
// preferredToken is optional. If you want to pay in a specific token, you can pass its address here and get fee quotes for that token only
// preferredToken: config.preferredToken,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/Forward/MintNft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const MintNftForward: React.FC = () => {
// here we are explicitly telling by mode ERC20 that we want to pay in ERC20 tokens and expect fee quotes
mode: PaymasterMode.ERC20,
// one can pass tokenList empty array. and it would return fee quotes for all tokens supported by the Biconomy paymaster
tokenList: [],
tokenList: [config.usdc.address, config.usdt.address],
// preferredToken is optional. If you want to pay in a specific token, you can pass its address here and get fee quotes for that token only
// preferredToken: config.preferredToken,
});
Expand Down
16 changes: 8 additions & 8 deletions src/components/Forward/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ interface Props {

const cardItems = [
{
title: "Batch Liquidity",
title: "Batch NFT",
description:
"This magic bundle will approve USDC then provide the USDC liquidity to Hyphen Pool.",
index: 9,
"This magic bundle will batch two single safeMint into one transaction.",
index: 6,
icon: (
<ControlPointDuplicateIcon
<CollectionsIcon
style={{
color: "#FFB999",
fontSize: 72,
Expand All @@ -25,12 +25,12 @@ const cardItems = [
),
},
{
title: "Batch NFT",
title: "Batch Liquidity",
description:
"This magic bundle will batch two single safeMint into one transaction.",
index: 10,
"This magic bundle will approve USDC then provide the USDC liquidity to Hyphen Pool.",
index: 7,
icon: (
<CollectionsIcon
<ControlPointDuplicateIcon
style={{
color: "#FFB999",
fontSize: 72,
Expand Down
Loading

0 comments on commit 3080bdc

Please sign in to comment.