Socket
Socket
Sign inDemoInstall

@nomicfoundation/ignition-core

Package Overview
Dependencies
47
Maintainers
4
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.15.3 to 0.15.4

dist/src/internal/execution/future-processor/helpers/decode-simulation-result.d.ts

7

CHANGELOG.md

@@ -7,2 +7,9 @@ # Changelog

## 0.15.4 - 2024-05-14
### Fixed
- Reconcile address parameters with mismatched casings ([#748](https://github.com/NomicFoundation/hardhat-ignition/pull/748))
- Display better error messages for insufficient funds ([#754](https://github.com/NomicFoundation/hardhat-ignition/pull/754))
## 0.15.3 - 2024-05-09

@@ -9,0 +16,0 @@

@@ -107,2 +107,14 @@ import { ErrorDescriptor } from "../types/errors";

};
INSUFFICIENT_FUNDS_FOR_TRANSFER: {
number: number;
message: string;
};
INSUFFICIENT_FUNDS_FOR_DEPLOY: {
number: number;
message: string;
};
GAS_ESTIMATION_FAILED: {
number: number;
message: string;
};
};

@@ -109,0 +121,0 @@ RECONCILIATION: {

@@ -167,2 +167,14 @@ "use strict";

},
INSUFFICIENT_FUNDS_FOR_TRANSFER: {
number: 408,
message: "Account %sender% has insufficient funds to transfer %amount% wei",
},
INSUFFICIENT_FUNDS_FOR_DEPLOY: {
number: 409,
message: "Account %sender% has insufficient funds to deploy the contract",
},
GAS_ESTIMATION_FAILED: {
number: 410,
message: "Gas estimation failed: %error%",
},
},

@@ -169,0 +181,0 @@ RECONCILIATION: {

17

dist/src/internal/execution/future-processor/handlers/send-transaction.js

@@ -6,5 +6,5 @@ "use strict";

const execution_result_1 = require("../../types/execution-result");
const execution_strategy_1 = require("../../types/execution-strategy");
const messages_1 = require("../../types/messages");
const network_interaction_1 = require("../../types/network-interaction");
const decode_simulation_result_1 = require("../helpers/decode-simulation-result");
const messages_helpers_1 = require("../helpers/messages-helpers");

@@ -39,16 +39,3 @@ const network_interaction_execution_1 = require("../helpers/network-interaction-execution");

const strategyGenerator = generator;
const result = await (0, network_interaction_execution_1.sendTransactionForOnchainInteraction)(jsonRpcClient, exState.from, lastNetworkInteraction, async (_sender) => nonceManager.getNextNonce(_sender), async (simulationResult) => {
const response = await strategyGenerator.next({
type: execution_strategy_1.OnchainInteractionResponseType.SIMULATION_RESULT,
result: simulationResult,
});
(0, assertions_1.assertIgnitionInvariant)(response.value.type === execution_strategy_1.SIMULATION_SUCCESS_SIGNAL_TYPE ||
response.value.type ===
execution_result_1.ExecutionResultType.STRATEGY_SIMULATION_ERROR ||
response.value.type === execution_result_1.ExecutionResultType.SIMULATION_ERROR, `Invalid response received from strategy after a simulation was run before sending a transaction for ExecutionState ${exState.id}`);
if (response.value.type === execution_strategy_1.SIMULATION_SUCCESS_SIGNAL_TYPE) {
return undefined;
}
return response.value;
});
const result = await (0, network_interaction_execution_1.sendTransactionForOnchainInteraction)(jsonRpcClient, exState.from, lastNetworkInteraction, nonceManager, (0, decode_simulation_result_1.decodeSimulationResult)(strategyGenerator, exState));
// If the transaction failed during simulation, we need to revert the nonce allocation

@@ -55,0 +42,0 @@ if (result.type === execution_result_1.ExecutionResultType.STRATEGY_SIMULATION_ERROR ||

@@ -8,2 +8,3 @@ /**

import { JsonRpcClient } from "../../jsonrpc-client";
import { NonceManager } from "../../nonce-management/json-rpc-nonce-manager";
import { SimulationErrorExecutionResult, StrategySimulationErrorExecutionResult } from "../../types/execution-result";

@@ -68,3 +69,3 @@ import { RawStaticCallResult, Transaction } from "../../types/jsonrpc";

*/
export declare function sendTransactionForOnchainInteraction(client: JsonRpcClient, sender: string, onchainInteraction: OnchainInteraction, getNonce: (sender: string) => Promise<number>, decodeSimulationResult: (simulationResult: RawStaticCallResult) => Promise<SimulationErrorExecutionResult | StrategySimulationErrorExecutionResult | undefined>): Promise<SimulationErrorExecutionResult | StrategySimulationErrorExecutionResult | {
export declare function sendTransactionForOnchainInteraction(client: JsonRpcClient, sender: string, onchainInteraction: OnchainInteraction, nonceManager: NonceManager, decodeSimulationResult: (simulationResult: RawStaticCallResult) => Promise<SimulationErrorExecutionResult | StrategySimulationErrorExecutionResult | undefined>): Promise<SimulationErrorExecutionResult | StrategySimulationErrorExecutionResult | {
type: typeof TRANSACTION_SENT_TYPE;

@@ -71,0 +72,0 @@ transaction: Transaction;

@@ -10,2 +10,4 @@ "use strict";

exports.sendTransactionForOnchainInteraction = exports.TRANSACTION_SENT_TYPE = exports.runStaticCall = void 0;
const errors_1 = require("../../../../errors");
const errors_list_1 = require("../../../errors-list");
const assertions_1 = require("../../../utils/assertions");

@@ -76,4 +78,4 @@ /**

*/
async function sendTransactionForOnchainInteraction(client, sender, onchainInteraction, getNonce, decodeSimulationResult) {
const nonce = onchainInteraction.nonce ?? (await getNonce(sender));
async function sendTransactionForOnchainInteraction(client, sender, onchainInteraction, nonceManager, decodeSimulationResult) {
const nonce = onchainInteraction.nonce ?? (await nonceManager.getNextNonce(sender));
const fees = await getNextTransactionFees(client, onchainInteraction);

@@ -102,10 +104,25 @@ // TODO: Should we check the balance here? Before or after estimating gas?

// about why it failed.
//
// TODO: We are catching every error (e.g. network errors) here, which may be
// too broad and make the assertion below fail. We could try to catch only
// estimation errors.
const failedEstimateGasSimulationResult = await client.call(paramsWithoutFees, "pending");
const decoded = await decodeSimulationResult(failedEstimateGasSimulationResult);
(0, assertions_1.assertIgnitionInvariant)(decoded !== undefined, "Expected failed simulation after having failed to estimate gas");
return decoded;
if (decoded !== undefined) {
return decoded;
}
// this is just for type inference
(0, assertions_1.assertIgnitionInvariant)(error instanceof Error, "Unexpected error type while resolving failed gas estimation");
// If the user has tried to transfer funds (i.e. m.send(...)) and they have insufficient funds
if (/insufficient funds for transfer/.test(error.message)) {
throw new errors_1.IgnitionError(errors_list_1.ERRORS.EXECUTION.INSUFFICIENT_FUNDS_FOR_TRANSFER, { sender, amount: estimateGasPrams.value.toString() });
}
// if the user has insufficient funds to deploy the contract they're trying to deploy
else if (/contract creation code storage out of gas/.test(error.message)) {
throw new errors_1.IgnitionError(errors_list_1.ERRORS.EXECUTION.INSUFFICIENT_FUNDS_FOR_DEPLOY, {
sender,
});
}
// catch-all error for all other errors
else {
throw new errors_1.IgnitionError(errors_list_1.ERRORS.EXECUTION.GAS_ESTIMATION_FAILED, {
error: error.message,
});
}
}

@@ -112,0 +129,0 @@ const transactionParams = {

/**
* Is the string a valid ethereum address?
*/
export declare function isAddress(address: string): boolean;
export declare function isAddress(address: any): address is string;
/**

@@ -6,0 +6,0 @@ * Returns a normalized and checksumed address for the given address.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.equalAddresses = exports.toChecksumFormat = exports.isAddress = void 0;
const ethers_1 = require("ethers");
const assertions_1 = require("../../utils/assertions");

@@ -10,3 +9,4 @@ /**

function isAddress(address) {
return (0, ethers_1.isAddress)(address);
const { isAddress: ethersIsAddress } = require("ethers");
return ethersIsAddress(address);
}

@@ -22,3 +22,4 @@ exports.isAddress = isAddress;

(0, assertions_1.assertIgnitionInvariant)(isAddress(address), `Expected ${address} to be an address`);
return (0, ethers_1.getAddress)(address);
const { getAddress } = require("ethers");
return getAddress(address);
}

@@ -25,0 +26,0 @@ exports.toChecksumFormat = toChecksumFormat;

@@ -7,2 +7,3 @@ "use strict";

const execution_state_1 = require("../../execution/types/execution-state");
const address_1 = require("../../execution/utils/address");
const utils_1 = require("../utils");

@@ -23,3 +24,10 @@ function reconcileArguments(future, exState, context) {

const exStateArg = exStateArgs[i];
if (!isEqual(futureArg, exStateArg)) {
// if both args are addresses, we need to compare the checksummed versions
// to ensure case discrepancies are ignored
if ((0, address_1.isAddress)(futureArg) && (0, address_1.isAddress)(exStateArg)) {
if (!(0, address_1.equalAddresses)(futureArg, exStateArg)) {
return (0, utils_1.fail)(future, `Argument at index ${i} has been changed`);
}
}
else if (!isEqual(futureArg, exStateArg)) {
return (0, utils_1.fail)(future, `Argument at index ${i} has been changed`);

@@ -26,0 +34,0 @@ }

{
"name": "@nomicfoundation/ignition-core",
"version": "0.15.3",
"version": "0.15.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": "Nomic Foundation",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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