From 699d3201eb3c8abe0ce9dee8092565c0e00b6e47 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Wed, 27 Nov 2024 18:35:09 -0300 Subject: [PATCH 1/6] feat: add support for L2 networks [zksync] --- .../Background/controllers/MainController.ts | 14 ++++++++++++-- .../scripts/Background/controllers/balances/evm.ts | 7 +++++-- .../Background/controllers/balances/index.ts | 9 ++++++--- .../Background/controllers/balances/types.ts | 7 +++++-- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/source/scripts/Background/controllers/MainController.ts b/source/scripts/Background/controllers/MainController.ts index 43e2c8956..acb77de0a 100644 --- a/source/scripts/Background/controllers/MainController.ts +++ b/source/scripts/Background/controllers/MainController.ts @@ -9,6 +9,7 @@ import { KeyringAccountType, IWalletState, CustomJsonRpcProvider, + CustomL2JsonRpcProvider, } from '@pollum-io/sysweb3-keyring'; import { getSysRpc, @@ -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 ); diff --git a/source/scripts/Background/controllers/balances/evm.ts b/source/scripts/Background/controllers/balances/evm.ts index b7fde10d9..e7de3aa9b 100644 --- a/source/scripts/Background/controllers/balances/evm.ts +++ b/source/scripts/Background/controllers/balances/evm.ts @@ -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'; @@ -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 { diff --git a/source/scripts/Background/controllers/balances/index.ts b/source/scripts/Background/controllers/balances/index.ts index f9373d9a6..6c29d2ed2 100644 --- a/source/scripts/Background/controllers/balances/index.ts +++ b/source/scripts/Background/controllers/balances/index.ts @@ -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'; @@ -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: diff --git a/source/scripts/Background/controllers/balances/types.ts b/source/scripts/Background/controllers/balances/types.ts index 34cae1cb5..95cf36ea2 100644 --- a/source/scripts/Background/controllers/balances/types.ts +++ b/source/scripts/Background/controllers/balances/types.ts @@ -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'; @@ -18,7 +21,7 @@ export interface IBalancesManagerUtils { currentAccount: IPaliAccount, isBitcoinBased: boolean, networkUrl: string, - provider?: CustomJsonRpcProvider + provider?: CustomJsonRpcProvider | CustomL2JsonRpcProvider ) => Promise; } From ea9e92deca82fe6211d06fc8df35a414982f518a Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Thu, 28 Nov 2024 09:44:14 -0300 Subject: [PATCH 2/6] fix: solve fee bug --- source/pages/Send/Confirm.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/source/pages/Send/Confirm.tsx b/source/pages/Send/Confirm.tsx index 96e96eccf..f0bbfcbc4 100755 --- a/source/pages/Send/Confirm.tsx +++ b/source/pages/Send/Confirm.tsx @@ -913,8 +913,6 @@ export const SendConfirm = () => { const arrayValidation = [ !fee?.gasLimit, !fee?.maxFeePerGas, - !fee?.baseFee, - !fee?.maxPriorityFeePerGas, isBitcoinBased, ]; @@ -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; From c8e05a3140df275aa9e28fc66b27b0dbd90ef46d Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Mon, 9 Dec 2024 08:22:49 -0300 Subject: [PATCH 3/6] chore: update sysweb3 --- package.json | 2 +- yarn.lock | 43 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index fd000c3ca..d1b43f5c9 100644 --- a/package.json +++ b/package.json @@ -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.484", + "@pollum-io/sysweb3-keyring": "^1.0.486", "@pollum-io/sysweb3-network": "^1.0.95", "@pollum-io/sysweb3-utils": "^1.1.234", "@reduxjs/toolkit": "^1.4.0", diff --git a/yarn.lock b/yarn.lock index 0f7fca65f..2945cb22c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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.484": - version "1.0.484" - resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-keyring/-/sysweb3-keyring-1.0.484.tgz#65d9fbd7305f9c6f2c1e19d88da1197c67b6980a" - integrity sha512-AMO+H/9NW2ETlXR/v06SRM7g7+nSOv1lW3YYondRzSIq0p15Un9nwRhGeJZ8F0vaD/S4vlsTtXLgsRfyV0fO8w== +"@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" @@ -2391,7 +2391,7 @@ "@ledgerhq/logs" "^6.10.1" "@pollum-io/sysweb3-core" "^1.0.27" "@pollum-io/sysweb3-network" "^1.0.95" - "@pollum-io/sysweb3-utils" "^1.1.234" + "@pollum-io/sysweb3-utils" "^1.1.235" "@trezor/connect-web" "^9.1.5" "@trezor/connect-webextension" "^9.3.0" "@trezor/utxo-lib" "^1.0.12" @@ -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" @@ -2451,6 +2452,29 @@ syscointx-js "^1.0.106" web3 "^1.7.1" +"@pollum-io/sysweb3-utils@^1.1.235": + version "1.1.235" + resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-utils/-/sysweb3-utils-1.1.235.tgz#9ae08757631b40a4e2e4fe3da13b14457137f9f4" + integrity sha512-El0fvuZg1AQ/a/fb8dwEfLQwDuVPR8Xj12uVWC2hPal5HjAVH9fNDXyHwUWeblH9oUUUyR5bXjbbf5slVW3KgA== + dependencies: + "@ethersproject/contracts" "^5.6.2" + axios "^0.26.1" + bech32 "^2.0.0" + bip32 "^3.0.1" + bip44-constants "^114.0.0" + bip84 "^0.2.7" + bitcoinjs-lib "^5.2.0" + camelcase-keys "^7.0.2" + coinselectsyscoin "^1.0.77" + crypto-js "^4.1.1" + eth-object "https://github.com/syscoin/eth-object.git" + eth-proof "^2.1.6" + eth-util-lite "^1.0.1" + ethers "^5.6.4" + syscoinjs-lib "^1.0.218" + syscointx-js "^1.0.106" + web3 "^1.7.1" + "@popperjs/core@^2.9.0": version "2.11.8" resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" @@ -7233,7 +7257,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== -ethers@5.7.2, ethers@^5.5.4, ethers@^5.6.4, ethers@^5.6.9: +ethers@5.7.2, 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== @@ -15270,3 +15294,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" From 08d2bccfbcb6ebf9338e9103c0e35178371b6cc7 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Mon, 9 Dec 2024 08:28:29 -0300 Subject: [PATCH 4/6] chore: update yarn.lock --- yarn.lock | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index c7a2073a6..1bd83944b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2391,7 +2391,7 @@ "@ledgerhq/logs" "^6.10.1" "@pollum-io/sysweb3-core" "^1.0.27" "@pollum-io/sysweb3-network" "^1.0.95" - "@pollum-io/sysweb3-utils" "^1.1.234" + "@pollum-io/sysweb3-utils" "^1.1.235" "@trezor/connect-web" "^9.1.5" "@trezor/connect-webextension" "^9.3.0" "@trezor/utxo-lib" "^1.0.12" @@ -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" @@ -2451,6 +2452,29 @@ syscointx-js "^1.0.106" web3 "^1.7.1" +"@pollum-io/sysweb3-utils@^1.1.235": + version "1.1.235" + resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-utils/-/sysweb3-utils-1.1.235.tgz#9ae08757631b40a4e2e4fe3da13b14457137f9f4" + integrity sha512-El0fvuZg1AQ/a/fb8dwEfLQwDuVPR8Xj12uVWC2hPal5HjAVH9fNDXyHwUWeblH9oUUUyR5bXjbbf5slVW3KgA== + dependencies: + "@ethersproject/contracts" "^5.6.2" + axios "^0.26.1" + bech32 "^2.0.0" + bip32 "^3.0.1" + bip44-constants "^114.0.0" + bip84 "^0.2.7" + bitcoinjs-lib "^5.2.0" + camelcase-keys "^7.0.2" + coinselectsyscoin "^1.0.77" + crypto-js "^4.1.1" + eth-object "https://github.com/syscoin/eth-object.git" + eth-proof "^2.1.6" + eth-util-lite "^1.0.1" + ethers "^5.6.4" + syscoinjs-lib "^1.0.218" + syscointx-js "^1.0.106" + web3 "^1.7.1" + "@popperjs/core@^2.9.0": version "2.11.8" resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" From 916e350bfbef9a8488ad7283644d2dcb1af9b1b3 Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Mon, 9 Dec 2024 08:38:34 -0300 Subject: [PATCH 5/6] chore: update yarn.lock --- yarn.lock | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1bd83944b..1c99a199f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2429,29 +2429,6 @@ ethers "^5.6.9" web3 "^1.7.1" -"@pollum-io/sysweb3-utils@^1.1.234": - version "1.1.234" - resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-utils/-/sysweb3-utils-1.1.234.tgz#f259e781510bef19fd74130eb60ea28845494f0e" - integrity sha512-Kgu2CPl3L22XYsfc0UCL9tBnoSCRT0sVda/zlxAUuTqIp1tP+3k6JNAwDOkJjPBc8h+wYds4Y39YSU+KYLgbdg== - dependencies: - "@ethersproject/contracts" "^5.6.2" - axios "^0.26.1" - bech32 "^2.0.0" - bip32 "^3.0.1" - bip44-constants "^114.0.0" - bip84 "^0.2.7" - bitcoinjs-lib "^5.2.0" - camelcase-keys "^7.0.2" - coinselectsyscoin "^1.0.77" - crypto-js "^4.1.1" - eth-object "https://github.com/syscoin/eth-object.git" - eth-proof "^2.1.6" - eth-util-lite "^1.0.1" - ethers "^5.6.4" - syscoinjs-lib "^1.0.218" - syscointx-js "^1.0.106" - web3 "^1.7.1" - "@pollum-io/sysweb3-utils@^1.1.235": version "1.1.235" resolved "https://registry.yarnpkg.com/@pollum-io/sysweb3-utils/-/sysweb3-utils-1.1.235.tgz#9ae08757631b40a4e2e4fe3da13b14457137f9f4" @@ -7257,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== -ethers@5.7.2, ethers@^5.5.4, ethers@^5.6.4, ethers@^5.6.9: +ethers@5.7.2, 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== @@ -15294,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" From ce5c34e329f34bcd02bb7a5ffc7ef5282748b21d Mon Sep 17 00:00:00 2001 From: Lucas Santos Date: Mon, 9 Dec 2024 08:45:12 -0300 Subject: [PATCH 6/6] chore: update pali version [canary] --- source/config/consts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/config/consts.js b/source/config/consts.js index 106349d54..cdcfcb99d 100644 --- a/source/config/consts.js +++ b/source/config/consts.js @@ -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',