Skip to content

Commit

Permalink
yet another metamask-webpack fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryongchan committed Jan 26, 2024
1 parent af7ff5c commit a3a7fc2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .erb/configs/webpack.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const configuration: webpack.Configuration = {
// There is no need to add aliases here, the paths in tsconfig get mirrored
plugins: [new TsconfigPathsPlugins()],
alias: {
react: path.resolve('./node_modules/react')
react: path.resolve('./src/node_modules/react')
}
},

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion src/renderer/components/payment/Payment.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { MetaMaskSDK, SDKProvider } from '@metamask/sdk';
import { Box, Typography } from '@mui/material';
import { MetaMaskSDK, SDKProvider } from '../../../node_modules/@metamask/sdk';
import Web3 from '../../../node_modules/web3';
import QRCodePopover from './QRCodePopover';
import WalletDisconnected from './WalletDisconnected';
import WalletConnected from './WalletConnected';
Expand Down Expand Up @@ -29,6 +30,14 @@ const Payment = () => {
setErrorDialogOpen(false);
};

useEffect(()=>{
console.log("sdk", sdk)
}, [sdk])

useEffect(()=>{
console.log("provider", provider)
}, [provider])

useEffect(() => {
const getClientBalance = async () => {
if (provider && account.length === 42) {
Expand All @@ -44,6 +53,7 @@ const Payment = () => {
}, [provider, account]);

const handleConnect = async () => {
console.log('Web3', Web3)
const clientSdk = new MetaMaskSDK({
shouldShimWeb3: false,
storage: {
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/components/payment/handlePay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Web3 from 'web3';
import { AbiItem } from 'web3-utils';
// import { AbiItem } from '../../../web3-utils';
// import { AbiItem } from '../../../node_modules/web3-utils';
// import { AbiItem } from '../../../node_modules/web3-utils';
import Web3 from '../../../node_modules/web3';
import paymentContractAbi from './PaymentContract.json';

const handlePay = async (
Expand All @@ -10,7 +12,7 @@ const handlePay = async (
) => {
try {
const web3 = new Web3(provider);
const paymentContract = paymentContractAbi as AbiItem[];
const paymentContract = paymentContractAbi;
const contract = new web3.eth.Contract(paymentContract, contractAddress);
const did = window.electron.store.get('did');
const amountToSend = web3.utils.toWei(amount.toString(), 'ether');
Expand Down
1 change: 1 addition & 0 deletions src/renderer/utils/cryptoUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import sha3 from 'js-sha3';
import secp256k1 from '../../node_modules/secp256k1';

export const generateKeyPair = async (mnemonic: string) => {
console.log("secp256k1", secp256k1)
const seed = mnemonicToSeedSync(mnemonic).toString('hex');
const privateKey = SHA256(seed).toString();
const privateKeyBuffer = Buffer.from(privateKey, 'hex');
Expand Down

0 comments on commit a3a7fc2

Please sign in to comment.