From bec3e9d5ecbdf6d319476bd78b6dbfb561160b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 12 Sep 2024 14:28:15 +0200 Subject: [PATCH 1/2] fix: dApps unable to connect when on non-EVM network --- package.json | 8 ++-- .../DAppConnectionController.ts | 2 - .../middlewares/RPCCallsMiddleware.ts | 25 ------------ yarn.lock | 38 +++++++++---------- 4 files changed, 23 insertions(+), 50 deletions(-) delete mode 100644 src/background/connections/middlewares/RPCCallsMiddleware.ts diff --git a/package.json b/package.json index 3b3f5dd4..e7aafdea 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "sentry": "node sentryscript.js" }, "dependencies": { + "@avalabs/avalanche-module": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", "@avalabs/avalanchejs": "4.0.5", - "@avalabs/bitcoin-module": "0.6.0", - "@avalabs/avalanche-module": "0.6.0", + "@avalabs/bitcoin-module": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", "@avalabs/bridge-unified": "2.1.0", "@avalabs/core-bridge-sdk": "3.1.0-alpha.4", "@avalabs/core-chains-sdk": "3.1.0-alpha.4", @@ -37,11 +37,11 @@ "@avalabs/core-token-prices-sdk": "3.1.0-alpha.4", "@avalabs/core-utils-sdk": "3.1.0-alpha.4", "@avalabs/core-wallets-sdk": "3.1.0-alpha.4", - "@avalabs/evm-module": "0.6.0", + "@avalabs/evm-module": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", "@avalabs/glacier-sdk": "3.1.0-alpha.4", "@avalabs/hw-app-avalanche": "0.14.1", "@avalabs/types": "3.1.0-alpha.3", - "@avalabs/vm-module-types": "0.6.0", + "@avalabs/vm-module-types": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", diff --git a/src/background/connections/dAppConnection/DAppConnectionController.ts b/src/background/connections/dAppConnection/DAppConnectionController.ts index 7b2a4a49..2302279b 100644 --- a/src/background/connections/dAppConnection/DAppConnectionController.ts +++ b/src/background/connections/dAppConnection/DAppConnectionController.ts @@ -22,7 +22,6 @@ import { PermissionsService } from '@src/background/services/permissions/Permiss import { AccountsService } from '@src/background/services/accounts/AccountsService'; import './registry'; -import { RPCCallsMiddleware } from '../middlewares/RPCCallsMiddleware'; import { NetworkService } from '@src/background/services/network/NetworkService'; import { DAppRequestHandler } from './DAppRequestHandler'; import { LockService } from '@src/background/services/lock/LockService'; @@ -76,7 +75,6 @@ export class DAppConnectionController implements ConnectionController { // @ts-ignore LoggerMiddleware(SideToLog.REQUEST), SiteMetadataMiddleware(connection), - RPCCallsMiddleware(this.networkService), PermissionMiddleware( this.permissionsService, this.accountsService, diff --git a/src/background/connections/middlewares/RPCCallsMiddleware.ts b/src/background/connections/middlewares/RPCCallsMiddleware.ts deleted file mode 100644 index 0a928e8e..00000000 --- a/src/background/connections/middlewares/RPCCallsMiddleware.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Middleware } from './models'; -import { NetworkService } from '@src/background/services/network/NetworkService'; -import { NetworkVMType } from '@avalabs/core-chains-sdk'; -import { JsonRpcRequest, JsonRpcResponse } from '../dAppConnection/models'; - -export function RPCCallsMiddleware( - networkService: NetworkService -): Middleware { - return async (context, next, error) => { - const network = await networkService.getNetwork( - context.request.params.scope - ); - const { method } = context.request.params.request; - const declineMethodsPattern = /(^eth_|_watchAsset$)/; - if ( - network && - network.vmName !== NetworkVMType.EVM && - declineMethodsPattern.test(method) - ) { - error(new Error(`Method not supported`)); - } else { - next(); - } - }; -} diff --git a/yarn.lock b/yarn.lock index 5a882aff..c1ffb6cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,10 +29,10 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.6.0.tgz#19c9711c16606b0ba4a5ffa6d6d7d0ea56e3dfed" - integrity sha512-e6YzasOU6w2rSnqZ3alThYSpjTu8TjgmXjny+lAenQTEomMDNc3/8XCXTcnSN7ItmrwcEXVjBsxGrVof5VFR4w== +"@avalabs/avalanche-module@0.0.0-fix-evm-provider-intercept-cha-20240912122849": + version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#46318f9b2958cdf540b6175e3fd62dc99e84adc8" + integrity sha512-8l4ZE46jljTo3k1iFJG3HPZPK7Usr1L1E/inrxtEHpfdZNowxw5bwnLFA93NYw55ISbRUptqA4DCLTUceWyBzQ== dependencies: "@avalabs/avalanchejs" "4.0.5" "@avalabs/core-chains-sdk" "3.1.0-alpha.5" @@ -42,7 +42,7 @@ "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" "@avalabs/glacier-sdk" "3.1.0-alpha.5" "@avalabs/types" "3.1.0-alpha.5" - "@avalabs/vm-module-types" "0.6.0" + "@avalabs/vm-module-types" "0.0.0-fix-evm-provider-intercept-cha-20240912122849" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.6.0.tgz#39d977dc76987e34bac98c74a43ca74e4d1f27a3" - integrity sha512-dFCV43j1nU7TL2/206/8O+TpnT2InUx5sH8N9bbwZ9yNHEX45T+iSGmALCSb2fnuYvD2uvNQOQ+UkEe8e9ttiQ== +"@avalabs/bitcoin-module@0.0.0-fix-evm-provider-intercept-cha-20240912122849": + version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#0a3572a59c83483165b2af6f2e66fbc04d5233a5" + integrity sha512-IrjF4yriuUFGlI2YEbK0fjCrGrOGx9lfjcWXt44GZy9miSgp33bruw9cQyTBWyldpchNCskjCy56JvbifOdr5Q== dependencies: "@avalabs/core-coingecko-sdk" "3.1.0-alpha.5" "@avalabs/core-utils-sdk" "3.1.0-alpha.5" "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" - "@avalabs/vm-module-types" "0.6.0" + "@avalabs/vm-module-types" "0.0.0-fix-evm-provider-intercept-cha-20240912122849" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -245,10 +245,10 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/evm-module@0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.6.0.tgz#b38f8f2a8050fd9028e1bf32fad122cec73a0e80" - integrity sha512-AwY2TMUEyZ1i2gbotBq92NoOq2SZY5mVd5F1uCGwZBAQSJ0WJwwWZiVIKtZEMBG1E6XJxWXOThwFNtmQROR5hA== +"@avalabs/evm-module@0.0.0-fix-evm-provider-intercept-cha-20240912122849": + version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#d27b07fd14a211983c04291c324a9a7723b3f90b" + integrity sha512-xbrVLrczLWYeVVInpZLR/BzujMRaUnHfFQVekcMNS7QjU14hS9Z2sw2WCAedqzrCCpFPX0OeQRcb1BfYlgTtPg== dependencies: "@avalabs/core-coingecko-sdk" "3.1.0-alpha.5" "@avalabs/core-etherscan-sdk" "3.1.0-alpha.5" @@ -256,7 +256,7 @@ "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" "@avalabs/glacier-sdk" "3.1.0-alpha.5" "@avalabs/types" "3.1.0-alpha.5" - "@avalabs/vm-module-types" "0.6.0" + "@avalabs/vm-module-types" "0.0.0-fix-evm-provider-intercept-cha-20240912122849" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" bn.js "5.2.1" @@ -294,10 +294,10 @@ resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.5.tgz#82dcb2cdb63b47186689186e09ad13e207180e8c" integrity sha512-OpHTXQL/RGzL9FOfQAN4mc6jD/kZVthRtzS2eCqoI6gAZmNzf3Paq46U6cKabti1coyJDIcrXrRl1U1qtCpoYg== -"@avalabs/vm-module-types@0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.6.0.tgz#dc3ed2be67c52e1a9babd894cdee4665cb7598e2" - integrity sha512-4HGWDnH1qKQK1nBHe8/uCVT2pZcbh4YLltMWyMSsvsy0l+FXnU9RSaAxDIyPnok5IJQ6STIkLbkrSDTcbOtWLg== +"@avalabs/vm-module-types@0.0.0-fix-evm-provider-intercept-cha-20240912122849": + version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#6252abd2c8f2473bc16f65b03e13ba017940279d" + integrity sha512-K8fIsV2Aeokr+t+qWV9rv+D9KylTRhuCacRmmiE2B4o+gdanbsTaSEyR0/wX0DBrHmQSKCku3QSYm5KvVPw1zQ== dependencies: "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" "@avalabs/glacier-sdk" "3.1.0-alpha.5" From 36770e0b88647266003470ebe1199d25c3c11aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczyk?= Date: Thu, 12 Sep 2024 15:03:22 +0200 Subject: [PATCH 2/2] chore: update vm modules --- package.json | 13 ++++++++----- yarn.lock | 38 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index e7aafdea..4ee7816b 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "sentry": "node sentryscript.js" }, "dependencies": { - "@avalabs/avalanche-module": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", + "@avalabs/avalanche-module": "0.7.0", "@avalabs/avalanchejs": "4.0.5", - "@avalabs/bitcoin-module": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", + "@avalabs/bitcoin-module": "0.7.0", "@avalabs/bridge-unified": "2.1.0", "@avalabs/core-bridge-sdk": "3.1.0-alpha.4", "@avalabs/core-chains-sdk": "3.1.0-alpha.4", @@ -37,11 +37,11 @@ "@avalabs/core-token-prices-sdk": "3.1.0-alpha.4", "@avalabs/core-utils-sdk": "3.1.0-alpha.4", "@avalabs/core-wallets-sdk": "3.1.0-alpha.4", - "@avalabs/evm-module": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", + "@avalabs/evm-module": "0.7.0", "@avalabs/glacier-sdk": "3.1.0-alpha.4", "@avalabs/hw-app-avalanche": "0.14.1", "@avalabs/types": "3.1.0-alpha.3", - "@avalabs/vm-module-types": "0.0.0-fix-evm-provider-intercept-cha-20240912122849", + "@avalabs/vm-module-types": "0.7.0", "@blockaid/client": "0.10.0", "@coinbase/cbpay-js": "1.6.0", "@cubist-labs/cubesigner-sdk": "0.3.28", @@ -251,7 +251,10 @@ "@avalabs/evm-module": false, "@avalabs/bitcoin-module>@avalabs/vm-module-types>@avalabs/core-wallets-sdk>@avalabs/hw-app-avalanche>@ledgerhq/hw-app-eth>@ledgerhq/domain-service>eip55>keccak": false, "@avalabs/bitcoin-module>@avalabs/vm-module-types>@avalabs/core-wallets-sdk>@ledgerhq/hw-app-btc>bitcoinjs-lib>bip32>tiny-secp256k1": false, - "@avalabs/bitcoin-module>@avalabs/vm-module-types>@avalabs/core-wallets-sdk>hdkey>secp256k1": false + "@avalabs/bitcoin-module>@avalabs/vm-module-types>@avalabs/core-wallets-sdk>hdkey>secp256k1": false, + "@avalabs/avalanche-module>@avalabs/core-wallets-sdk>@avalabs/hw-app-avalanche>@ledgerhq/hw-app-eth>@ledgerhq/domain-service>eip55>keccak": false, + "@avalabs/avalanche-module>@avalabs/core-wallets-sdk>@ledgerhq/hw-app-btc>bitcoinjs-lib>bip32>tiny-secp256k1": false, + "@avalabs/avalanche-module>@avalabs/core-wallets-sdk>hdkey>secp256k1": false } } } diff --git a/yarn.lock b/yarn.lock index c1ffb6cd..e7080f65 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,10 +29,10 @@ resolved "https://registry.yarnpkg.com/@apocentre/alias-sampling/-/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08" integrity sha512-7UDWIIF9hIeJqfKXkNIzkVandlwLf1FWTSdrb9iXvOP8oF544JRXQjCbiTmCv2c9n44n/FIWtehhBfNuAx2CZA== -"@avalabs/avalanche-module@0.0.0-fix-evm-provider-intercept-cha-20240912122849": - version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" - resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#46318f9b2958cdf540b6175e3fd62dc99e84adc8" - integrity sha512-8l4ZE46jljTo3k1iFJG3HPZPK7Usr1L1E/inrxtEHpfdZNowxw5bwnLFA93NYw55ISbRUptqA4DCLTUceWyBzQ== +"@avalabs/avalanche-module@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@avalabs/avalanche-module/-/avalanche-module-0.7.0.tgz#6c6b62bcc5a98e2aadb51495fbb70635bc567302" + integrity sha512-Pp9tsJZ0kOL9WxLLmYTTUcVi3vFZN/OmMHMiar1p7Ij0IpMFimzK67rcVJIwCQrmYP0lDu+jQylv5A40r8J9Kg== dependencies: "@avalabs/avalanchejs" "4.0.5" "@avalabs/core-chains-sdk" "3.1.0-alpha.5" @@ -42,7 +42,7 @@ "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" "@avalabs/glacier-sdk" "3.1.0-alpha.5" "@avalabs/types" "3.1.0-alpha.5" - "@avalabs/vm-module-types" "0.0.0-fix-evm-provider-intercept-cha-20240912122849" + "@avalabs/vm-module-types" "0.7.0" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bn.js "5.2.1" @@ -59,15 +59,15 @@ "@scure/base" "1.1.5" micro-eth-signer "0.7.2" -"@avalabs/bitcoin-module@0.0.0-fix-evm-provider-intercept-cha-20240912122849": - version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" - resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#0a3572a59c83483165b2af6f2e66fbc04d5233a5" - integrity sha512-IrjF4yriuUFGlI2YEbK0fjCrGrOGx9lfjcWXt44GZy9miSgp33bruw9cQyTBWyldpchNCskjCy56JvbifOdr5Q== +"@avalabs/bitcoin-module@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@avalabs/bitcoin-module/-/bitcoin-module-0.7.0.tgz#ab16ea50bc774056a8090481534a9a9cdaa094be" + integrity sha512-IaCI/cd44oedtAM54WmKaMUmtDu/TAnK9r9QD6eU2K0IkikMscl+G65MhOFsZf8jTTArlYFHxANeGme96Ri7BA== dependencies: "@avalabs/core-coingecko-sdk" "3.1.0-alpha.5" "@avalabs/core-utils-sdk" "3.1.0-alpha.5" "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" - "@avalabs/vm-module-types" "0.0.0-fix-evm-provider-intercept-cha-20240912122849" + "@avalabs/vm-module-types" "0.7.0" "@metamask/rpc-errors" "6.3.0" big.js "6.2.1" bitcoinjs-lib "5.2.0" @@ -245,10 +245,10 @@ ledger-bitcoin "0.2.3" xss "1.0.14" -"@avalabs/evm-module@0.0.0-fix-evm-provider-intercept-cha-20240912122849": - version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" - resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#d27b07fd14a211983c04291c324a9a7723b3f90b" - integrity sha512-xbrVLrczLWYeVVInpZLR/BzujMRaUnHfFQVekcMNS7QjU14hS9Z2sw2WCAedqzrCCpFPX0OeQRcb1BfYlgTtPg== +"@avalabs/evm-module@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@avalabs/evm-module/-/evm-module-0.7.0.tgz#c9215ef101261b421e6f8867a68215d0703b3b4a" + integrity sha512-mKP/N2MaGeB86IwNzp9NwmmlcYLZ8zMBfnZqt3SkF+nMaf/zlAbpGwRw0xWaW8A04qZhQ5Jk9eRO9cd7tNg9iw== dependencies: "@avalabs/core-coingecko-sdk" "3.1.0-alpha.5" "@avalabs/core-etherscan-sdk" "3.1.0-alpha.5" @@ -256,7 +256,7 @@ "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" "@avalabs/glacier-sdk" "3.1.0-alpha.5" "@avalabs/types" "3.1.0-alpha.5" - "@avalabs/vm-module-types" "0.0.0-fix-evm-provider-intercept-cha-20240912122849" + "@avalabs/vm-module-types" "0.7.0" "@blockaid/client" "0.11.0" "@metamask/rpc-errors" "6.3.0" bn.js "5.2.1" @@ -294,10 +294,10 @@ resolved "https://registry.yarnpkg.com/@avalabs/types/-/types-3.1.0-alpha.5.tgz#82dcb2cdb63b47186689186e09ad13e207180e8c" integrity sha512-OpHTXQL/RGzL9FOfQAN4mc6jD/kZVthRtzS2eCqoI6gAZmNzf3Paq46U6cKabti1coyJDIcrXrRl1U1qtCpoYg== -"@avalabs/vm-module-types@0.0.0-fix-evm-provider-intercept-cha-20240912122849": - version "0.0.0-fix-evm-provider-intercept-cha-20240912122849" - resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.0.0-fix-evm-provider-intercept-cha-20240912122849.tgz#6252abd2c8f2473bc16f65b03e13ba017940279d" - integrity sha512-K8fIsV2Aeokr+t+qWV9rv+D9KylTRhuCacRmmiE2B4o+gdanbsTaSEyR0/wX0DBrHmQSKCku3QSYm5KvVPw1zQ== +"@avalabs/vm-module-types@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@avalabs/vm-module-types/-/vm-module-types-0.7.0.tgz#f6eaa5b0b3b6d1a657b9460a58638d59d7a909cd" + integrity sha512-wDLQ7xUfgmWxjElrguhx35KEo7ptqpN9IFvt8PEHzTPcFisYDCME25XbTNM3iDdT8O4fE4BWFVxij/Uzq8j4uQ== dependencies: "@avalabs/core-wallets-sdk" "3.1.0-alpha.5" "@avalabs/glacier-sdk" "3.1.0-alpha.5"