Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Fix issue getting existing wallet addresses #340

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aggregator-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/koa__cors": "^3.3.0",
"@types/koa__router": "^8.0.11",
"@types/node-fetch": "^2.6.1",
"bls-wallet-clients": "^0.7.1",
"bls-wallet-clients": "0.7.1-2790596",
"fp-ts": "^2.12.1",
"io-ts": "^2.2.16",
"io-ts-reporters": "^2.0.1",
Expand Down
8 changes: 4 additions & 4 deletions aggregator-proxy/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,10 @@ bech32@1.1.4:
resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9"
integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==

bls-wallet-clients@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/bls-wallet-clients/-/bls-wallet-clients-0.7.1.tgz#912705c7b997e0cb4ec003796766f20b117b4547"
integrity sha512-LyTad7HsniNIE8dBTrF4aMksHj0sjwpvPuQmdPokXLlsJA/KTI11av5PLJNVpiAF1sQAKnA0BJglrete+TYyIg==
bls-wallet-clients@0.7.1-2790596:
version "0.7.1-2790596"
resolved "https://registry.yarnpkg.com/bls-wallet-clients/-/bls-wallet-clients-0.7.1-2790596.tgz#0a89e8551b25e7c62e12ac1e015e8c6972bc9ecb"
integrity sha512-6paGPxnCu9oGlww0dx6T4H4G/pYK8ElJEeCeKN5Kcvno3BQ7HaK9eUiXYq8RSBLkX915y1ZUj4mPHowBH9iksQ==
dependencies:
"@thehubbleproject/bls" "^0.5.1"
ethers "5.5.4"
Expand Down
6 changes: 3 additions & 3 deletions aggregator/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type {
PublicKey,
Signature,
VerificationGateway,
} from "https://esm.sh/bls-wallet-clients@0.7.1";
} from "https://esm.sh/bls-wallet-clients@0.7.1-2790596";

export {
Aggregator as AggregatorClient,
Expand All @@ -59,10 +59,10 @@ export {
getConfig,
MockERC20__factory,
VerificationGateway__factory,
} from "https://esm.sh/bls-wallet-clients@0.7.1";
} from "https://esm.sh/bls-wallet-clients@0.7.1-2790596";

// Workaround for esbuild's export-star bug
import blsWalletClients from "https://esm.sh/bls-wallet-clients@0.7.1";
import blsWalletClients from "https://esm.sh/bls-wallet-clients@0.7.1-2790596";
const {
bundleFromDto,
bundleToDto,
Expand Down
11 changes: 10 additions & 1 deletion contracts/clients/src/BlsWalletWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export default class BlsWalletWrapper {
verificationGatewayAddress,
signerOrProvider,
);
const pubKeyHash = blsWalletSigner.getPublicKeyHash(privateKey);

// Check for an existing wallet
const existingAddress = await verificationGateway.walletFromHash(
pubKeyHash,
);
if (!BigNumber.from(existingAddress).isZero()) {
return existingAddress;
}

const [proxyAdminAddress, blsWalletLogicAddress] = await Promise.all([
verificationGateway.walletProxyAdmin(),
Expand All @@ -61,7 +70,7 @@ export default class BlsWalletWrapper {

return ethers.utils.getCreate2Address(
verificationGatewayAddress,
blsWalletSigner.getPublicKeyHash(privateKey),
pubKeyHash,
ethers.utils.solidityKeccak256(
["bytes", "bytes"],
[
Expand Down
17 changes: 17 additions & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ task("fundDeployer", "Sends ETH to create2Deployer contract from first signer")
await txnRes.wait();
});

task("sendEth", "Sends ETH to an address")
.addParam("address", "Address to send ETH to", undefined, types.string)
.addOptionalParam("amount", "Amount of ETH to send", "1.0")
.setAction(
async ({ address, amount }: { address: string; amount: string }, hre) => {
const [account0] = await hre.ethers.getSigners();

console.log(`${account0.address} -> ${address} ${amount} ETH`);

const txnRes = await account0.sendTransaction({
to: address,
value: hre.ethers.utils.parseEther(amount),
});
await txnRes.wait();
},
);

// Do any needed pre-test setup here.
task("test").setAction(async (_taskArgs, _hre, runSuper) => {
chai.use(chaiAsPromised);
Expand Down
35 changes: 0 additions & 35 deletions contracts/scripts/test/send_eth.ts

This file was deleted.

2 changes: 1 addition & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"advanced-css-reset": "^1.2.2",
"async-mutex": "^0.3.2",
"axios": "^0.27.2",
"bls-wallet-clients": "0.7.1",
"bls-wallet-clients": "0.7.1-2790596",
"browser-passworder": "^2.0.3",
"bs58check": "^2.1.2",
"crypto-browserify": "^3.12.0",
Expand Down
8 changes: 4 additions & 4 deletions extension/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2649,10 +2649,10 @@ blakejs@^1.1.0:
resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.2.1.tgz#5057e4206eadb4a97f7c0b6e197a505042fc3814"
integrity sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==

bls-wallet-clients@0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/bls-wallet-clients/-/bls-wallet-clients-0.7.1.tgz#912705c7b997e0cb4ec003796766f20b117b4547"
integrity sha512-LyTad7HsniNIE8dBTrF4aMksHj0sjwpvPuQmdPokXLlsJA/KTI11av5PLJNVpiAF1sQAKnA0BJglrete+TYyIg==
bls-wallet-clients@0.7.1-2790596:
version "0.7.1-2790596"
resolved "https://registry.yarnpkg.com/bls-wallet-clients/-/bls-wallet-clients-0.7.1-2790596.tgz#0a89e8551b25e7c62e12ac1e015e8c6972bc9ecb"
integrity sha512-6paGPxnCu9oGlww0dx6T4H4G/pYK8ElJEeCeKN5Kcvno3BQ7HaK9eUiXYq8RSBLkX915y1ZUj4mPHowBH9iksQ==
dependencies:
"@thehubbleproject/bls" "^0.5.1"
ethers "5.5.4"
Expand Down