Socket
Socket
Sign inDemoInstall

bls-wallet-clients

Package Overview
Dependencies
58
Maintainers
6
Versions
155
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.2-d39c16b to 0.8.2-f1af837

src/Recovery.ts

2

package.json
{
"name": "bls-wallet-clients",
"version": "0.8.2-d39c16b",
"version": "0.8.2-f1af837",
"description": "Client libraries for interacting with BLS Wallet components",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

import nodeFetch from "node-fetch";
import { ContractReceipt } from "ethers";
import { Bundle, bundleToDto } from "./signer";

@@ -42,15 +41,11 @@

/**
* The BLS Wallet specific values in a {@link BundleReceipt}.
*/
export type BlsBundleReceipt = {
export type BundleReceipt = {
transactionIndex: number;
transactionHash: string;
bundleHash: string;
blockHash: string;
blockNumber: number;
};
/**
* The bundle receipt returned from a BLS Wallet Aggregator instance. It is a combination of an ethers {@link ContractReceipt} and a {@link BlsBundleReceipt} type.
*/
export type BundleReceipt = ContractReceipt & BlsBundleReceipt;
/**
* Client used to interact with a BLS Wallet Aggregator instance

@@ -57,0 +52,0 @@ */

@@ -147,22 +147,21 @@ import { ethers, BigNumber } from "ethers";

// TODO: bls-wallet #412 Update values returned in bundle receipt to more closely match ethers transaction response
return {
to: bundleReceipt.to,
from: bundleReceipt.from,
contractAddress: bundleReceipt.contractAddress,
transactionIndex: bundleReceipt.transactionIndex,
root: bundleReceipt.root,
gasUsed: bundleReceipt.gasUsed,
logsBloom: bundleReceipt.logsBloom,
to: "0x",
from: "0x",
contractAddress: "0x",
transactionIndex: parseInt(bundleReceipt.transactionIndex),
gasUsed: parseEther("0"),
logsBloom: "",
blockHash: bundleReceipt.blockHash,
transactionHash: bundleReceipt.transactionHash,
logs: bundleReceipt.logs,
blockNumber: bundleReceipt.blockNumber,
confirmations: bundleReceipt.confirmations ?? confirmations,
cumulativeGasUsed: bundleReceipt.effectiveGasPrice,
effectiveGasPrice: bundleReceipt.effectiveGasPrice,
byzantium: bundleReceipt.byzantium,
type: bundleReceipt.type,
status: bundleReceipt.status,
logs: [],
blockNumber: parseInt(bundleReceipt.blockNumber),
confirmations,
cumulativeGasUsed: parseEther("0"),
effectiveGasPrice: parseEther("0"),
byzantium: false,
type: 2,
};
}
}

@@ -125,2 +125,3 @@ import { ethers, BigNumber, Signer, Bytes } from "ethers";

// TODO: bls-wallet #412 Update values returned in bundle receipt to more closely match ethers transaction response
return {

@@ -127,0 +128,0 @@ hash,

@@ -256,2 +256,68 @@ /* eslint-disable camelcase */

async getBundleSetRecovery(
salt: string,
recoverWalletAddress: string,
): Promise<Bundle> {
const saltBytes32String = BlsWalletWrapper.saltToBytes32String(salt);
const walletHash = this.blsWalletSigner.getPublicKeyHash(this.privateKey);
const recoveryHash = ethers.utils.solidityKeccak256(
["address", "bytes32", "bytes32"],
[recoverWalletAddress, walletHash, saltBytes32String],
);
return this.sign({
nonce: await this.Nonce(),
actions: [
{
ethValue: 0,
contractAddress: this.walletContract.address,
encodedFunction: this.walletContract.interface.encodeFunctionData(
"setRecoveryHash",
[recoveryHash],
),
},
],
});
}
async getBundleRecoverWallet(
recoveryAddress: string,
newPrivateKey: string,
recoverySalt: string,
verificationGateway: VerificationGateway,
): Promise<Bundle> {
const updatedWallet = await BlsWalletWrapper.connect(
newPrivateKey,
verificationGateway.address,
verificationGateway.provider,
);
const addressMessage = solidityPack(["address"], [recoveryAddress]);
const addressSignature = updatedWallet.signMessage(addressMessage);
const recoveryWalletHash = await verificationGateway.hashFromWallet(
recoveryAddress,
);
const saltBytes32String =
BlsWalletWrapper.saltToBytes32String(recoverySalt);
return this.sign({
nonce: await this.Nonce(),
actions: [
{
ethValue: 0,
contractAddress: verificationGateway.address,
encodedFunction: verificationGateway.interface.encodeFunctionData(
"recoverWallet",
[
addressSignature,
recoveryWalletHash,
saltBytes32String,
updatedWallet.PublicKey(),
],
),
},
],
});
}
static async #BlsWalletSigner(

@@ -320,2 +386,10 @@ signerOrProvider: SignerOrProvider,

}
private static saltToBytes32String(salt: string): string {
try {
return ethers.utils.formatBytes32String(salt);
} catch (e) {
throw new Error("Error convirting salt string to bytes 32 string.");
}
}
}

@@ -12,2 +12,3 @@ import { signer } from "@thehubbleproject/bls";

import verify from "./verify";
import getRandomPrivateKey from "./getRandomPrivateKey";

@@ -42,3 +43,4 @@ export * from "./types";

verify: verify(domain, chainId),
getRandomPrivateKey,
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc