Skip to content

Commit

Permalink
Merge pull request #1830 from Web3Auth/feat/aa-pimlico
Browse files Browse the repository at this point in the history
AA Support
  • Loading branch information
chaitanyapotti authored Sep 24, 2024
2 parents edaea56 + 44faa60 commit 5c35066
Show file tree
Hide file tree
Showing 46 changed files with 3,212 additions and 2,980 deletions.
634 changes: 354 additions & 280 deletions demo/react-app/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions demo/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"@taquito/taquito": "^19.2.0",
"@taquito/utils": "^19.2.0",
"@tezos-core-tools/crypto-utils": "^0.0.7",
"@web3auth/account-abstraction-provider": "file:../../packages/providers/account-abstraction-provider",
"@web3auth/base": "file:../../packages/base",
"@web3auth/openlogin-adapter": "file:../../packages/adapters/openlogin-adapter",
"@web3auth/solana-provider": "file:../../packages/providers/solana-provider",
"@web3auth/ethereum-provider": "file:../../packages/providers/ethereum-provider",
"@web3auth/modal": "file:../../packages/modal",
"@web3auth/openlogin-adapter": "file:../../packages/adapters/openlogin-adapter",
"@web3auth/solana-provider": "file:../../packages/providers/solana-provider",
"@web3auth/wallet-services-plugin": "file:../../packages/plugins/wallet-services-plugin",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
14 changes: 7 additions & 7 deletions demo/react-app/src/services/ethProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ethProvider = (provider: IProvider, uiConsole: (...args: unknown[]) => voi
try {
const web3 = new Web3(provider);
const accounts = await web3.eth.getAccounts();
const balance = await web3.eth.getBalance(accounts[0]);
const balance = await web3.eth.getBalance(accounts[1]);
uiConsole("Eth balance", balance);
} catch (error) {
console.error("Error", error);
Expand Down Expand Up @@ -81,7 +81,7 @@ const ethProvider = (provider: IProvider, uiConsole: (...args: unknown[]) => voi
const web3 = new Web3(provider);
const message = "Some string";
const hash = web3.utils.sha3(message) as string;
const fromAddress = (await web3.eth.getAccounts())[0];
const fromAddress = (await web3.eth.getAccounts())[1];
const sig = await web3.eth.personal.sign(hash, fromAddress, "");
uiConsole("personal sign", sig);
uiConsole("Eth sign message => true", sig);
Expand All @@ -95,12 +95,12 @@ const ethProvider = (provider: IProvider, uiConsole: (...args: unknown[]) => voi
try {
const web3 = new Web3(provider as any);
const accounts = await web3.eth.getAccounts();
const gasestimate = await web3.eth.estimateGas({ from: accounts[0], to: accounts[0], value: web3.utils.toWei("0.001", "ether") });
const gasestimate = await web3.eth.estimateGas({ from: accounts[0], to: accounts[0], value: web3.utils.toWei("0", "ether") });
// console.log("gasestimate", gasestimate);
const txRes = await web3.eth.sendTransaction({
from: accounts[0],
to: accounts[0],
value: web3.utils.toWei("0.001", "ether"),
value: web3.utils.toWei("0", "ether"),
gas: gasestimate,
});
uiConsole("txRes", txRes);
Expand All @@ -116,7 +116,7 @@ const ethProvider = (provider: IProvider, uiConsole: (...args: unknown[]) => voi
const accounts = await web3.eth.getAccounts();
const contract = new web3.eth.Contract(erc20Abi, getTokenAddress());
const txRes = await contract.methods
.transfer("0x3E2a1F4f6b6b5d281Ee9a9B36Bb33F7FBf0614C3", web3.utils.toWei("0.002", "ether"))
.transfer("0x3E2a1F4f6b6b5d281Ee9a9B36Bb33F7FBf0614C3", web3.utils.toWei("0", "ether"))
.send({ from: accounts[0] });
uiConsole("txRes", txRes);
} catch (error) {
Expand Down Expand Up @@ -149,8 +149,8 @@ const ethProvider = (provider: IProvider, uiConsole: (...args: unknown[]) => voi
const accounts = await web3.eth.getAccounts();
// only supported with social logins (openlogin adapter)
const txRes = await web3.eth.signTransaction({
from: accounts[0],
to: accounts[0],
from: accounts[1],
to: accounts[1],
value: web3.utils.toWei("0.001", "ether"),
});
uiConsole("txRes", txRes);
Expand Down
11 changes: 9 additions & 2 deletions demo/react-app/src/services/web3auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ADAPTER_EVENTS, CHAIN_NAMESPACES, CustomChainConfig, IProvider, WALLET_
import { Web3Auth } from "@web3auth/modal";
import { OpenloginAdapter } from "@web3auth/openlogin-adapter";
import { WalletServicesPlugin } from "@web3auth/wallet-services-plugin";
import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import { AccountAbstractionProvider } from "@web3auth/account-abstraction-provider";
import { SolanaPrivateKeyProvider } from "@web3auth/solana-provider";
import { createContext, FunctionComponent, ReactNode, useCallback, useContext, useEffect, useState } from "react";
import { CHAIN_CONFIG, CHAIN_CONFIG_TYPE } from "../config/chainConfig";
Expand Down Expand Up @@ -134,7 +134,8 @@ export const Web3AuthProvider: FunctionComponent<IWeb3AuthState> = ({ children,
if (currentChainConfig.chainNamespace === CHAIN_NAMESPACES.SOLANA) {
privateKeyProvider = new SolanaPrivateKeyProvider({ config: { chainConfig: currentChainConfig } });
} else {
privateKeyProvider = new EthereumPrivateKeyProvider({ config: { chainConfig: currentChainConfig } });
privateKeyProvider = new AccountAbstractionProvider({ config: { chainConfig: currentChainConfig } });
// privateKeyProvider = new EthereumPrivateKeyProvider({ config: { chainConfig: currentChainConfig } });
}
setIsLoading(true);
const clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ";
Expand Down Expand Up @@ -196,6 +197,12 @@ export const Web3AuthProvider: FunctionComponent<IWeb3AuthState> = ({ children,
// @ts-ignore
buildEnv: "development",
whiteLabel: { showWidgetButton: true },
walletUrls: {
production: {
url: "http://localhost:4050",
logLevel: "debug",
},
},
},
});
subscribePluginEvents(walletServicesPlugin);
Expand Down
1 change: 1 addition & 0 deletions demo/vue-app-new/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_APP_PIMLICO_API_KEY=
Loading

0 comments on commit 5c35066

Please sign in to comment.