Skip to content

Commit

Permalink
sfa react firebase working
Browse files Browse the repository at this point in the history
  • Loading branch information
ihsraham committed Sep 20, 2023
1 parent 905a43a commit b46bdf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions single-factor-auth-web/sfa-react-example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from "react";

// Import Single Factor Auth SDK for no redirect flow
import { Web3Auth } from "@web3auth/single-factor-auth";
import { CHAIN_NAMESPACES, SafeEventEmitterProvider } from "@web3auth/base";
import { CHAIN_NAMESPACES, IProvider } from "@web3auth/base";
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";

// RPC libraries for blockchain calls
Expand Down Expand Up @@ -49,7 +49,7 @@ const firebaseConfig = {
function App() {
const [web3authSFAuth, setWeb3authSFAuth] = useState<Web3Auth | null>(null);
const [usesSfaSDK, setUsesSfaSDK] = useState(false);
const [provider, setProvider] = useState<SafeEventEmitterProvider | null>(
const [provider, setProvider] = useState<IProvider | null>(
null
);
const [idToken, setIdToken] = useState<string | null>(null);
Expand Down
6 changes: 3 additions & 3 deletions single-factor-auth-web/sfa-react-example/src/evm.ethers.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { SafeEventEmitterProvider } from "@web3auth/base";
import type { IProvider } from "@web3auth/base";
import { ethers } from "ethers";

export default class EthereumRpc {
private provider: SafeEventEmitterProvider;
private provider: IProvider;

constructor(provider: SafeEventEmitterProvider) {
constructor(provider: IProvider) {
this.provider = provider;
}

Expand Down
12 changes: 6 additions & 6 deletions single-factor-auth-web/sfa-react-example/src/evm.web3.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type {SafeEventEmitterProvider} from '@web3auth/base'
import type {IProvider} from '@web3auth/base'
import Web3 from 'web3'

export default class EthereumRpc {
private provider: SafeEventEmitterProvider
private provider: IProvider

constructor(provider: SafeEventEmitterProvider) {
constructor(provider: IProvider) {
this.provider = provider
}
async getAccounts(): Promise<string[]> {
Expand All @@ -22,7 +22,7 @@ export default class EthereumRpc {
const web3 = new Web3(this.provider as any)
const accounts = await web3.eth.getAccounts()
const balance = await web3.eth.getBalance(accounts[0])
return balance
return balance.toString();
} catch (error) {
return error as string
}
Expand Down Expand Up @@ -61,9 +61,9 @@ export default class EthereumRpc {
const txRes = await web3.eth.sendTransaction({
from: accounts[0],
to: accounts[0],
value: web3.utils.toWei('0.01'),
value: web3.utils.toWei('0.01', 'ether'),
})
return txRes.transactionHash
return txRes.transactionHash.toString();
} catch (error) {
return error as string
}
Expand Down

0 comments on commit b46bdf7

Please sign in to comment.