Add more logging

This commit is contained in:
JohnGuilding
2023-03-30 14:55:19 +01:00
parent 18efc622b9
commit f1564ae0f2
2 changed files with 26 additions and 16 deletions

View File

@@ -75,6 +75,7 @@ export default class BlsProvider extends ethers.providers.JsonRpcProvider {
contractAddress: resolvedTransaction.to.toString(),
encodedFunction: resolvedTransaction.data?.toString() ?? "0x",
};
console.log("action:", action);
const nonce = await this.getTransactionCount(
resolvedTransaction.from.toString(),
@@ -89,12 +90,13 @@ export default class BlsProvider extends ethers.providers.JsonRpcProvider {
// alternative would be to use a signer instance in this method which is undesirable,
// as this would result in tight coupling between a provider and a signer.
const throwawayPrivateKey = await BlsWalletWrapper.getRandomBlsPrivateKey();
console.log("throwawayPrivateKey:", throwawayPrivateKey);
console.log("throwaway privateKey:", throwawayPrivateKey);
const throwawayBlsWalletWrapper = await BlsWalletWrapper.connect(
throwawayPrivateKey,
this.verificationGatewayAddress,
this,
);
console.log("throwaway wallet:", throwawayBlsWalletWrapper);
const feeEstimate = await this.aggregator.estimateFee(
throwawayBlsWalletWrapper.sign({
@@ -104,7 +106,10 @@ export default class BlsProvider extends ethers.providers.JsonRpcProvider {
);
const feeRequired = BigNumber.from(feeEstimate.feeRequired);
console.log("feeRequired:", ethers.utils.formatUnits(feeRequired));
console.log(
"feeEstimate:",
ethers.utils.formatUnits(addSafetyPremiumToFee(feeRequired)),
);
return addSafetyPremiumToFee(feeRequired);
}

View File

@@ -16,7 +16,7 @@ import {
// MockERC20__factory,
} from "../clients/src";
import getNetworkConfig from "../shared/helpers/getNetworkConfig";
import addSafetyPremiumToFee from "../clients/src/helpers/addSafetyDivisorToFee";
// import addSafetyPremiumToFee from "../clients/src/helpers/addSafetyDivisorToFee";
let networkConfig: NetworkConfig;
@@ -499,12 +499,15 @@ describe("BlsSigner", () => {
encodedFunction: "0x",
};
console.log("expectedAction:", expectedAction);
const wallet = await BlsWalletWrapper.connect(
privateKey,
verificationGateway,
blsProvider,
);
const walletAddress = wallet.address;
console.log("expected wallet:", wallet);
const expectedNonce = await BlsWalletWrapper.Nonce(
wallet.PublicKey(),
@@ -522,25 +525,27 @@ describe("BlsSigner", () => {
sinon.fake.resolves(privateKey),
);
const actionsWithFeePaymentAction =
blsProvider._addFeePaymentActionForFeeEstimation([expectedAction]);
const expectedFeeEstimate = await blsProvider.estimateGas(transaction);
const expectedFeeEstimate = await blsProvider.aggregator.estimateFee(
blsSigner.wallet.sign({
nonce: expectedNonce,
actions: [...actionsWithFeePaymentAction],
}),
);
// const actionsWithFeePaymentAction =
// blsProvider._addFeePaymentActionForFeeEstimation([expectedAction]);
console.log("expected feeRequired", expectedFeeEstimate.feeRequired);
// const expectedFeeEstimate = await blsProvider.aggregator.estimateFee(
// blsSigner.wallet.sign({
// nonce: expectedNonce,
// actions: [...actionsWithFeePaymentAction],
// }),
// );
const safeFee = addSafetyPremiumToFee(
BigNumber.from(expectedFeeEstimate.feeRequired),
);
console.log("expectedFeeEstimate", expectedFeeEstimate);
// const safeFee = addSafetyPremiumToFee(
// BigNumber.from(expectedFeeEstimate.feeRequired),
// );
const actionsWithSafeFee = blsProvider._addFeePaymentActionWithSafeFee(
[expectedAction],
safeFee,
expectedFeeEstimate,
);
const expectedOperation = {