From 9137e62fbc34d6acf1447a709a39b4b31f6b5566 Mon Sep 17 00:00:00 2001 From: Zahin Mohammad Date: Wed, 4 Sep 2024 23:30:26 -0400 Subject: [PATCH] fix: DI openSSLBytes --- electron/main/index.ts | 42 +++++++++++++++++++++++++----------------- package-lock.json | 6 ++++++ package.json | 1 + 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index e49df508..5052db9a 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -29,7 +29,12 @@ import { Dash } from '@bitgo/sdk-coin-dash'; import { Doge, Tdoge } from '@bitgo/sdk-coin-doge'; import { Dot, Tdot } from '@bitgo/sdk-coin-dot'; import { Eos, Teos } from '@bitgo/sdk-coin-eos'; -import { AbstractEthLikeNewCoins, Erc20Token, Eth, Hteth } from '@bitgo/sdk-coin-eth'; +import { + AbstractEthLikeNewCoins, + Erc20Token, + Eth, + Hteth, +} from '@bitgo/sdk-coin-eth'; import { Ethw } from '@bitgo/sdk-coin-ethw'; import { Etc, Tetc } from '@bitgo/sdk-coin-etc'; import { Ltc } from '@bitgo/sdk-coin-ltc'; @@ -56,6 +61,7 @@ import { Hbar, Thbar } from '@bitgo/sdk-coin-hbar'; import { Algo, Talgo } from '@bitgo/sdk-coin-algo'; import { EthLikeCoin, TethLikeCoin } from '@bitgo/sdk-coin-ethlike'; import { Sui, Tsui } from '@bitgo/sdk-coin-sui'; +import { loadWebAssembly } from '@bitgo/sdk-opensslbytes'; const bip32 = BIP32Factory(ecc); @@ -303,10 +309,17 @@ async function createWindow() { const baseCoin = sdk.coin(coin) as AbstractEthLikeNewCoins; if (parameters.ethCommonParams) { parameters.common = EthereumCommon.custom({ - ...parameters.ethCommonParams + ...parameters.ethCommonParams, }); } - return await baseCoin.recover(parameters); + const openSSLBytes = loadWebAssembly().buffer; + return await baseCoin.recover( + { + ...parameters, + openSSLBytes, + }, + openSSLBytes + ); }); ipcMain.handle('broadcastTransaction', async (event, coin, parameters) => { @@ -455,22 +468,17 @@ async function createWindow() { return response; }); - ipcMain.handle( - 'sweepV1', - async (event, coin, parameters) => { - switch (coin) { - case 'btc': - case 'tbtc': { - const coinInstance = sdk.coin(coin) as AbstractUtxoCoin; - return await coinInstance.sweepV1(parameters); - } - default: - return new Error( - `Coin: ${coin} does not support v1 wallets sweep` - ); + ipcMain.handle('sweepV1', async (event, coin, parameters) => { + switch (coin) { + case 'btc': + case 'tbtc': { + const coinInstance = sdk.coin(coin) as AbstractUtxoCoin; + return await coinInstance.sweepV1(parameters); } + default: + return new Error(`Coin: ${coin} does not support v1 wallets sweep`); } - ); + }); } void app.whenReady().then(createWindow); diff --git a/package-lock.json b/package-lock.json index ebe4aaf1..7aa52fa8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,6 +50,7 @@ "@bitgo/sdk-coin-xrp": "2.1.15", "@bitgo/sdk-coin-zec": "2.0.34", "@bitgo/sdk-coin-zeta": "3.0.3", + "@bitgo/sdk-opensslbytes": "^2.0.0", "@bitgo/utxo-lib": "10.3.0", "@ethereumjs/common": "2.6.5", "@lottiefiles/react-lottie-player": "3.4.9", @@ -4716,6 +4717,11 @@ "node": ">=14.0.0" } }, + "node_modules/@bitgo/sdk-opensslbytes": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@bitgo/sdk-opensslbytes/-/sdk-opensslbytes-2.0.0.tgz", + "integrity": "sha512-xJBVWT2Rr6BwGyMiQOYxqVOoBFAEdK6SVBWSSXaGk76ONbLR9YTI0meS0qB8esrTmrd9tn0H/9JRUpNeIN3/pg==" + }, "node_modules/@bitgo/sjcl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@bitgo/sjcl/-/sjcl-1.0.1.tgz", diff --git a/package.json b/package.json index e7286629..ec59045a 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "@bitgo/abstract-cosmos": "11.0.3", "@bitgo/abstract-utxo": "8.14.0", + "@bitgo/sdk-opensslbytes": "^2.0.0", "@bitgo/sdk-api": "1.53.3", "@bitgo/sdk-coin-ada": "4.2.12", "@bitgo/sdk-coin-algo": "2.1.32",