Skip to content

Commit

Permalink
Merge pull request #673 from syscoin/feat/add-zksync-support
Browse files Browse the repository at this point in the history
feat: add support for L2 networks [zksync]
  • Loading branch information
lucasgabrielgsp authored Dec 9, 2024
2 parents 603e5e3 + ce5c34e commit 71a4fc6
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@headlessui/react": "^1.6.0",
"@heroicons/react": "^1.0.5",
"@pollum-io/sysweb3-core": "^1.0.27",
"@pollum-io/sysweb3-keyring": "^1.0.485",
"@pollum-io/sysweb3-keyring": "^1.0.486",
"@pollum-io/sysweb3-network": "^1.0.95",
"@pollum-io/sysweb3-utils": "^1.1.235",
"@reduxjs/toolkit": "^1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion source/config/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const MV2_OPTIONS = {
const MV3_OPTIONS = {
manifest_version: 3,
name: 'Pali Wallet',
version: '3.2.0',
version: '3.2.1',
icons: {
16: 'assets/icons/favicon-16.png',
32: 'assets/icons/favicon-32.png',
Expand Down
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
18 changes: 13 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2379,10 +2379,10 @@
resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-core/-/sysweb3-core-1.0.27.tgz#2ecbf38c3b5f6821ec2bcc95472eed0a2f11cd10"
integrity sha512-HHW2ozdXCac2Xo0oUQgRk/sczBIGQCBvsqYBIwondipA3Rx4/jGC6Y9U/M4wpTi5wQ+ZD18DyEbKAVMXElGcbQ==

"@pollum-io/sysweb3-keyring@^1.0.485":
version "1.0.485"
resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-keyring/-/sysweb3-keyring-1.0.485.tgz#88095c5b87dd83e9f38e641db2ee90d5669e896c"
integrity sha512-sz6Q0Q49ObTo+ewYEcQBYW51fep5X57wkNLJialI2Y8h1mF/b4xg+dkHQvkqjEIx+05fpyVtpC4RrhiWifKTNQ==
"@pollum-io/sysweb3-keyring@^1.0.486":
version "1.0.486"
resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-keyring/-/sysweb3-keyring-1.0.486.tgz#199b75b917a3cecf5e536c49999646898bec3ba1"
integrity sha512-vZpZ7PllQT2KAbL1I75mJH8rZlCjMJi5jA/1/Gi3urSIP/JLCqhx4jQ7iVK/rkuNU0ceCT0ZT/JAmVFBHzavgQ==
dependencies:
"@bitcoinerlab/descriptors" "^2.0.1"
"@bitcoinerlab/secp256k1" "^1.0.5"
Expand Down Expand Up @@ -2415,6 +2415,7 @@
syscoinjs-lib "^1.0.218"
syscointx-js "^1.0.106"
web3 "^1.7.1"
zksync-ethers "5"

"@pollum-io/sysweb3-network@^1.0.95":
version "1.0.95"
Expand Down Expand Up @@ -7233,7 +7234,7 @@ ethers-eip712@^0.2.0:
resolved "https://registry.yarnpkg.com/ethers-eip712/-/ethers-eip712-0.2.0.tgz#52973b3a9a22638f7357283bf66624994c6e91ed"
integrity sha512-fgS196gCIXeiLwhsWycJJuxI9nL/AoUPGSQ+yvd+8wdWR+43G+J1n69LmWVWvAON0M6qNaf2BF4/M159U8fujQ==

[email protected], ethers@^5.5.4, ethers@^5.6.4, ethers@^5.6.9:
[email protected], ethers@^5.5.4, ethers@^5.6.4, ethers@^5.6.9, ethers@~5.7.0:
version "5.7.2"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e"
integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg==
Expand Down Expand Up @@ -15270,3 +15271,10 @@ zip-webpack-plugin@^4.0.1:
integrity sha512-G041Q4qUaog44Ynit6gs4o+o3JIv0WWfOLvc8Q3IxvPfuqd2KBHhpJWAXUB9Cm1JcWHTIOp9vS3oGMWa1p1Ehw==
dependencies:
yazl "^2.5.1"

zksync-ethers@5:
version "5.10.0"
resolved "https://registry.yarnpkg.com/zksync-ethers/-/zksync-ethers-5.10.0.tgz#3caf25478539a3fd6e170c13555cec6a1dae32e2"
integrity sha512-OAjTGAHF9wbdkRGkj7XZuF/a1Sk/FVbwH4pmLjAKlR7mJ7sQtQhBhrPU2dCc67xLaNvEESPfwil19ES5wooYFg==
dependencies:
ethers "~5.7.0"

0 comments on commit 71a4fc6

Please sign in to comment.