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 support for L2 networks [zksync] #673

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
10 changes: 1 addition & 9 deletions source/pages/Send/Confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,6 @@ export const SendConfirm = () => {
const arrayValidation = [
!fee?.gasLimit,
!fee?.maxFeePerGas,
!fee?.baseFee,
!fee?.maxPriorityFeePerGas,
isBitcoinBased,
];

Expand All @@ -925,13 +923,7 @@ export const SendConfirm = () => {
Number(validateCustomGasLimit ? customFee.gasLimit : fee?.gasLimit)) /
10 ** 9
);
}, [
fee?.maxPriorityFeePerGas,
fee?.gasLimit,
fee?.maxFeePerGas,
customFee,
isBitcoinBased,
]);
}, [fee?.gasLimit, fee?.maxFeePerGas, customFee, isBitcoinBased]);

useEffect(() => {
if (!copied) return;
Expand Down
14 changes: 12 additions & 2 deletions source/scripts/Background/controllers/MainController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
KeyringAccountType,
IWalletState,
CustomJsonRpcProvider,
CustomL2JsonRpcProvider,
} from '@pollum-io/sysweb3-keyring';
import {
getSysRpc,
Expand Down Expand Up @@ -1218,14 +1219,23 @@ class MainController extends KeyringManager {
isPolling?: boolean;
}) {
const { accounts } = store.getState().vault;
const L2Networks = [324, 300];
const isL2Network = L2Networks.includes(activeNetwork.chainId);

const currentAccount = accounts[activeAccount.type][activeAccount.id];

let internalProvider: CustomJsonRpcProvider | undefined;
let internalProvider:
| CustomJsonRpcProvider
| CustomL2JsonRpcProvider
| undefined;

if (isPolling) {
const CurrentProvider = isL2Network
? CustomL2JsonRpcProvider
: CustomJsonRpcProvider;

const abortController = new AbortController();
internalProvider = new CustomJsonRpcProvider(
internalProvider = new CurrentProvider(
abortController.signal,
activeNetwork.url
);
Expand Down
7 changes: 5 additions & 2 deletions source/scripts/Background/controllers/balances/evm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ethers } from 'ethers';

import { CustomJsonRpcProvider } from '@pollum-io/sysweb3-keyring';
import {
CustomJsonRpcProvider,
CustomL2JsonRpcProvider,
} from '@pollum-io/sysweb3-keyring';

import { IPaliAccount } from 'state/vault/types';
import { ONE_MILLION } from 'utils/constants';
Expand All @@ -10,7 +13,7 @@ import { IEvmBalanceController } from './types';
import { zerosRepeatingAtStartOfEvmBalance } from './utils';

const EvmBalanceController = (
web3Provider: CustomJsonRpcProvider
web3Provider: CustomJsonRpcProvider | CustomL2JsonRpcProvider
): IEvmBalanceController => {
const getEvmBalanceForAccount = async (currentAccount: IPaliAccount) => {
try {
Expand Down
9 changes: 6 additions & 3 deletions source/scripts/Background/controllers/balances/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { CustomJsonRpcProvider } from '@pollum-io/sysweb3-keyring';
import {
CustomJsonRpcProvider,
CustomL2JsonRpcProvider,
} from '@pollum-io/sysweb3-keyring';

import { IPaliAccount } from 'state/vault/types';

Expand All @@ -7,14 +10,14 @@ import SyscoinBalanceController from './syscoin';
import { IBalancesManager } from './types';

const BalancesManager = (
web3Provider: CustomJsonRpcProvider
web3Provider: CustomJsonRpcProvider | CustomL2JsonRpcProvider
): IBalancesManager => {
const evmBalanceController = EvmBalanceController(web3Provider);
const getBalanceUpdatedForAccount = async (
currentAccount: IPaliAccount,
isBitcoinBased: boolean,
networkUrl: string,
provider?: CustomJsonRpcProvider
provider?: CustomJsonRpcProvider | CustomL2JsonRpcProvider
) => {
switch (isBitcoinBased) {
case true:
Expand Down
7 changes: 5 additions & 2 deletions source/scripts/Background/controllers/balances/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { CustomJsonRpcProvider } from '@pollum-io/sysweb3-keyring';
import {
CustomJsonRpcProvider,
CustomL2JsonRpcProvider,
} from '@pollum-io/sysweb3-keyring';

import { IPaliAccount } from 'state/vault/types';

Expand All @@ -18,7 +21,7 @@ export interface IBalancesManagerUtils {
currentAccount: IPaliAccount,
isBitcoinBased: boolean,
networkUrl: string,
provider?: CustomJsonRpcProvider
provider?: CustomJsonRpcProvider | CustomL2JsonRpcProvider
) => Promise<string>;
}

Expand Down
Loading