Skip to content

Commit

Permalink
Wallet connect fix
Browse files Browse the repository at this point in the history
Signed-off-by: Akintayo A. Olusegun <[email protected]>
  • Loading branch information
segun committed Nov 14, 2023
1 parent 88c4183 commit 8f8363e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
1 change: 1 addition & 0 deletions app/components/Views/QRScanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const QRScanner = () => {
if (
origin === Routes.SEND_FLOW.SEND_TO ||
origin === Routes.SETTINGS.CONTACT_FORM
// origin === Routes.WALLET_VIEW
) {
if (!isValidAddressInputViaQRCode(content)) {
showAlertForInvalidAddress();
Expand Down
27 changes: 23 additions & 4 deletions app/core/WalletConnect/WalletConnect.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import URL from 'url-parse';
import parseWalletConnectUri from './wc-utils';
import { store } from '../../store';
import { selectChainId } from '../../selectors/networkController';
import ppomUtil from '../../../app/lib/ppom/ppom-util';

const hub = new EventEmitter();
let connectors = [];
Expand Down Expand Up @@ -180,14 +181,32 @@ class WalletConnect {
hostname: payloadHostname,
});

const hash = await (
await TransactionController.addTransaction(payload.params[0], {
const trx = await TransactionController.addTransaction(
payload.params[0],
{
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: this.url.current
? WALLET_CONNECT_ORIGIN + this.url.current
: undefined,
})
).result;
},
);

const id = trx.transactionMeta.id;
const reqObject = {
jsonrpc: '2.0',
method: 'eth_sendTransaction',
params: [
{
from: payload.params[0].from,
to: payload.params[0].to,
value: payload.params[0].value,
},
],
};

ppomUtil.validateRequest(reqObject, id);

const hash = await trx.result;
this.approveRequest({
id: payload.id,
result: hash,
Expand Down
36 changes: 17 additions & 19 deletions app/core/WalletConnect/WalletConnectV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import parseWalletConnectUri, {
import { selectChainId } from '../../selectors/networkController';
import { store } from '../../store';
import { WALLET_CONNECT_ORIGIN } from '../../../app/util/walletconnect';
import { isBlockaidFeatureEnabled } from '../../../app/util/blockaid';
import ppomUtil from '../../../app/lib/ppom/ppom-util';

const { PROJECT_ID } = AppConstants.WALLET_CONNECT;
Expand Down Expand Up @@ -286,31 +285,30 @@ class WalletConnect2Session {
Engine.context as { TransactionController: TransactionController }
).TransactionController;

let securityAlertResponse;

if (isBlockaidFeatureEnabled()) {
const reqObject = {
jsonrpc: '2.0',
method: 'eth_sendTransaction',
params: [
{
from: methodParams[0].from,
to: methodParams[0].to,
value: methodParams[0].value,
},
],
};
securityAlertResponse = await ppomUtil.validateRequest(reqObject);
}

const trx = await transactionController.addTransaction(
methodParams[0],
{
origin,
deviceConfirmedOn: WalletDevice.MM_MOBILE,
securityAlertResponse,
securityAlertResponse: undefined,
},
);

const id = trx.transactionMeta.id;
const reqObject = {
jsonrpc: '2.0',
method: 'eth_sendTransaction',
params: [
{
from: methodParams[0].from,
to: methodParams[0].to,
value: methodParams[0].value,
},
],
};

ppomUtil.validateRequest(reqObject, id);

const hash = await trx.result;

await this.approveRequest({ id: requestEvent.id + '', result: hash });
Expand Down

0 comments on commit 8f8363e

Please sign in to comment.