Skip to content

Update arb ts #25

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@apollo/client": "^3.6.4",
"@arbitrum/sdk": "^1.1.4",
"@devprotocol/util-ts": "^2.2.1",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-regular-svg-icons": "^5.15.4",
Expand All @@ -18,7 +20,6 @@
"@types/react-dom": "^17.0.0",
"@walletconnect/web3-provider": "^1.6.5",
"@web3-react/core": "^6.1.9",
"arb-ts": "^0.0.42",
"ethers": "^5.4.6",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down Expand Up @@ -65,6 +66,7 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.25.1",
"eslint-plugin-react-hooks": "^4.2.0",
"graphql": "^16.5.0",
"postcss": "^7",
"prettier": "^2.3.2",
"tailwindcss": "npm:@tailwindcss/postcss7-compat"
Expand Down
42 changes: 32 additions & 10 deletions src/components/convert/Convert.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// import { getL1Network, getL2Network } from '@arbitrum/sdk';
// import { isL1Network } from '@arbitrum/sdk/dist/lib/dataEntities/networks';
import { UndefinedOr } from '@devprotocol/util-ts';
import { networks } from 'arb-ts';
// import { networks } from 'arb-ts';
import { ethers } from 'ethers';
import React, { useContext, useState } from 'react';
import { BridgeContext } from '../../context/arbitrumBridgeContext';
import { AvailableNetwork } from '../../types/types';
import { isValidL1Chain } from '../../utils/utils';
import DepositConfirmationModal from './ConvertConfirmationModal';

interface ConvertParams {
Expand All @@ -25,29 +28,48 @@ const Convert: React.FC<ConvertParams> = ({ formValid, amount, network, selected

const submitTransaction = async (): Promise<void> => {
setLoading(true);
const currentNetwork = networks[network.chainId];
if (!currentNetwork) {
setLoading(false);
return;
}

// const currentNetwork = isValidL1Chain(network.chainId)
// ? getL1Network(network.chainId)
// : getL2Network(network.chainId);

// getL1Network()

// const currentNetwork = networks[network.chainId];
// if (!currentNetwork) {
// setLoading(false);
// return;
// }

if (!amount || amount?.isZero()) {
setLoading(false);
return;
}

try {
if (currentNetwork.isArbitrum) {
// Withdraw
await bridgeContext.withdraw(amount);
} else {
if (isValidL1Chain(network.chainId)) {
// Deposit
await bridgeContext.deposit(amount);
} else {
// Withdraw
await bridgeContext.withdraw(amount);
}
} catch (error) {
setLoading(false);
}

// try {
// if (currentNetwork.isArbitrum) {
// // Withdraw
// await bridgeContext.withdraw(amount);
// } else {
// // Deposit
// await bridgeContext.deposit(amount);
// }
// } catch (error) {
// setLoading(false);
// }

setLoading(false);
setDisplayModal(false);
};
Expand Down
Loading