Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add swap template #103

Merged
merged 3 commits into from
Apr 12, 2024
Merged
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
1 change: 1 addition & 0 deletions src/components/EvmEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const EvmEditor = (): ReactJSXElement => {
<EvmBatchTxEditor
setRequestObject={setRequestObject}
account={account}
chainId={chainId}
/>
</TabPanel>
</TabPanels>
Expand Down
26 changes: 23 additions & 3 deletions src/components/EvmEditors/EvmBatchTxEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface EvmBatchTxEditorProps {
SetStateAction<EthereumTypes.EIP1193RequestPayload | undefined>
>;
account: string | null;
chainId: string | null;
}

const RevertOptionMap: Record<string, any> = {
Expand All @@ -32,6 +33,7 @@ const RevertOptionMap: Record<string, any> = {
const EvmBatchTxEditor = ({
setRequestObject,
account,
chainId,
}: EvmBatchTxEditorProps): ReactJSXElement => {
const [revert, setRevert] = useState<string>("false");
const [txs, setTxs] = useState<any[]>();
Expand Down Expand Up @@ -75,6 +77,17 @@ const EvmBatchTxEditor = ({
});
};

const SwapToken = () => {
mordochi marked this conversation as resolved.
Show resolved Hide resolved
const obj = {
from: account,
to: "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD",
data: "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000066053af000000000000000000000000000000000000000000000000000000000000000020b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000000000b99e289c676500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bfff9976782d46cc05630d1f6ebab18b2324d6b140001f41f9840a85d5af5bf1d1762f925bdaddc4201f984000000000000000000000000000000000000000000",
};
setTxs((state) => {
return [...(state || []), obj];
});
};

const removeTransfer = (index: number) => {
setTxs((state) => {
if (Array.isArray(state) && state.length === 1) {
Expand Down Expand Up @@ -113,9 +126,16 @@ const EvmBatchTxEditor = ({
<Button w="110px" onClick={addTransfer}>
Transfer
</Button>
<Button w="110px" onClick={mintNFT}>
Mint NFT
</Button>
{chainId === "0x8274f" && (
<Button w="110px" onClick={mintNFT}>
Mint NFT
</Button>
)}
{chainId === "0xaa36a7" && (
<Button w="110px" onClick={SwapToken}>
Swap
</Button>
)}
</Grid>
<Flex flexDir="column" mt={2} pl={4}>
{Array.isArray(txs) &&
Expand Down
4 changes: 0 additions & 4 deletions src/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ export const ContractInfos: ContractInfosType = {
abi: valueDappAbi,
address: "0x009c403BdFaE357d82AAef2262a163287c30B739",
},
[EvmChainId.EthereumGoerli]: {
abi: valueDappAbi,
address: "0x009c403BdFaE357d82AAef2262a163287c30B739",
},
[EvmChainId.Bsc]: {
abi: valueDappAbi,
address: "0x009c403BdFaE357d82AAef2262a163287c30B739",
Expand Down
50 changes: 1 addition & 49 deletions src/services/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ export const supportedChains = [
],
environment: "mainnet",
},
{
name: "Ethereum Goerli",
chainId: "0x5",
rpcUrls: ["https://rpc.ankr.com/eth_goerli"],
faucet: "https://goerlifaucet.com/",
environment: "testnet",
},
{
name: "Ethereum Sepolia",
chainId: "0xaa36a7",
Expand All @@ -42,13 +35,6 @@ export const supportedChains = [
rpcUrls: ["https://arb1.arbitrum.io/rpc"],
environment: "mainnet",
},
{
name: "Arbitrum Goerli Testnet",
chainId: "0x66eed",
rpcUrls: ["https://goerli-rollup.arbitrum.io/rpc"],
faucet: "https://faucet.triangleplatform.com/arbitrum/goerli",
environment: "testnet",
},
{
name: "Arbitrum Sepolia Testnet",
chainId: "0x66eee",
Expand Down Expand Up @@ -101,13 +87,6 @@ export const supportedChains = [
rpcUrls: ["https://mainnet.optimism.io"],
environment: "mainnet",
},
{
name: "Optimism Testnet",
chainId: "0x1a4",
rpcUrls: ["https://goerli.optimism.io"],
faucet: "https://faucet.paradigm.xyz/",
environment: "testnet",
},
{
name: "Optimism Sepolia Testnet",
chainId: "0xaa37dc",
Expand All @@ -121,13 +100,6 @@ export const supportedChains = [
rpcUrls: ["https://mainnet.base.org"],
environment: "mainnet",
},
{
name: "Base Goerli Testnet",
chainId: "0x14a33",
rpcUrls: ["https://goerli.base.org"],
faucet: "https://faucet.quicknode.com/base/goerli",
environment: "testnet",
},
{
name: "Base Sepolia Testnet",
chainId: "0x14a34",
Expand All @@ -141,13 +113,6 @@ export const supportedChains = [
rpcUrls: ["https://rpc.zora.energy"],
environment: "mainnet",
},
{
name: "Zora Goerli Testnet",
chainId: "0x3E7",
rpcUrls: ["https://testnet.rpc.zora.energy"],
faucet: "https://testnet.zora.co",
environment: "testnet",
},
{
name: "Zora Sepolia Testnet",
chainId: "0x3b9ac9ff",
Expand All @@ -161,12 +126,6 @@ export const supportedChains = [
rpcUrls: ["https://rpc.scroll.io"],
environment: "mainnet",
},
{
name: "Scroll Goerli Testnet",
chainId: "0x82751",
rpcUrls: ["https://alpha-rpc.scroll.io/l2"],
environment: "testnet",
},
{
name: "Scroll Sepolia Testnet",
chainId: "0x8274f",
Expand All @@ -180,13 +139,6 @@ export const supportedChains = [
rpcUrls: ["https://rpc.linea.build"],
environment: "mainnet",
},
{
name: "Linea Goerli Testnet",
chainId: "0xe704",
rpcUrls: ["https://rpc.goerli.linea.build"],
faucet: "https://faucet.goerli.linea.build/",
environment: "testnet",
},
{
name: "zKatana Sepolia Testnet",
chainId: "0x133e40",
Expand Down Expand Up @@ -215,7 +167,7 @@ const bloctoSDK = new BloctoSDK({
// (required for Ethereum) JSON RPC endpoint
rpc: isMainnet
? `https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_KEY}`
: "https://rpc.ankr.com/eth_goerli",
: "https://ethereum-sepolia.blockpi.network/v1/rpc/public",
walletServer: process.env.REACT_APP_WALLET_SERVER,
},
appId: process.env.REACT_APP_DAPP_ID,
Expand Down
1 change: 0 additions & 1 deletion src/types/ChainTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export enum EvmChain {

export enum EvmChainId {
Ethereum = "0x1",
EthereumGoerli = "0x5",
Bsc = "0x38",
BscTestnet = "0x61",
Polygon = "0x89",
Expand Down
Loading