Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move views out of execution #440

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions packages/core/src/internal/execution/execution-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from "../../types/module";
import { DeploymentLoader } from "../deployment-loader/types";
import { getFuturesFromModule } from "../utils/get-futures-from-module";
import { getPendingNonceAndSender } from "../views/execution-state/get-pending-nonce-and-sender";
import { hasExecutionFailed } from "../views/has-execution-failed";

import { applyNewMessage } from "./deployment-state-helpers";
import { FutureProcessor } from "./future-processor/future-processor";
Expand All @@ -24,8 +26,6 @@ import {
import { TransactionTrackingTimer } from "./transaction-tracking-timer";
import { DeploymentState } from "./types/deployment-state";
import { ExecutionStrategy } from "./types/execution-strategy";
import { getPendingNonceAndSender } from "./views/execution-state/get-pending-nonce-and-sender";
import { hasExecutionFailed } from "./views/has-execution-failed";

/**
* This class is used to execute a module to completion, returning the new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DeploymentParameters } from "../../../types/deploy";
import { Future } from "../../../types/module";
import { DeploymentLoader } from "../../deployment-loader/types";
import { assertIgnitionInvariant } from "../../utils/assertions";
import { isExecutionStateComplete } from "../../views/is-execution-state-complete";
import { applyNewMessage } from "../deployment-state-helpers";
import { JsonRpcClient } from "../jsonrpc-client";
import { NonceManager } from "../nonce-management";
Expand All @@ -18,7 +19,6 @@ import {
} from "../types/execution-state";
import { ExecutionStrategy } from "../types/execution-strategy";
import { JournalMessage, JournalMessageType } from "../types/messages";
import { isExecutionStateComplete } from "../views/is-execution-state-complete";

import { monitorOnchainInteraction } from "./handlers/monitor-onchain-interaction";
import { queryStaticCall } from "./handlers/query-static-call";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import { DeploymentLoader } from "../../../deployment-loader/types";
import { assertIgnitionInvariant } from "../../../utils/assertions";
import { replaceWithinArg } from "../../../utils/replace-within-arg";
import { resolveModuleParameter } from "../../../utils/resolve-module-parameter";
import { findAddressForContractFuture } from "../../../views/find-address-for-contract-future-by-id";
import { findConfirmedTransactionByFutureId } from "../../../views/find-confirmed-transaction-by-future-id";
import { findResultForFutureById } from "../../../views/find-result-for-future-by-id";
import { getEventArgumentFromReceipt } from "../../abi";
import { DeploymentState } from "../../types/deployment-state";
import { convertEvmValueToSolidityParam } from "../../utils/convert-evm-tuple-to-solidity-param";
import { findAddressForContractFuture } from "../../views/find-address-for-contract-future-by-id";
import { findConfirmedTransactionByFutureId } from "../../views/find-confirmed-transaction-by-future-id";
import { findResultForFutureById } from "../../views/find-result-for-future-by-id";

/**
* Resolve a futures value to a bigint.
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/internal/execution/nonce-management.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { IgnitionError } from "../../errors";
import { getPendingNonceAndSender } from "../views/execution-state/get-pending-nonce-and-sender";
import { getPendingOnchainInteraction } from "../views/execution-state/get-pending-onchain-interaction";

import { JsonRpcClient } from "./jsonrpc-client";
import { DeploymentState } from "./types/deployment-state";
Expand All @@ -8,8 +10,6 @@ import {
OnchainInteractionDroppedMessage,
OnchainInteractionReplacedByUserMessage,
} from "./types/messages";
import { getPendingNonceAndSender } from "./views/execution-state/get-pending-nonce-and-sender";
import { getPendingOnchainInteraction } from "./views/execution-state/get-pending-onchain-interaction";

/**
* This function is meant to be used to sync the local state's nonces
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { produce } from "immer";

import { assertIgnitionInvariant } from "../../../utils/assertions";
import { findOnchainInteractionBy } from "../../../views/execution-state/find-onchain-interaction-by";
import { findStaticCallBy } from "../../../views/execution-state/find-static-call-by";
import { findTransactionBy } from "../../../views/execution-state/find-transaction-by";
import {
CallExecutionState,
DeploymentExecutionState,
Expand All @@ -20,9 +23,6 @@ import {
TransactionSendMessage,
} from "../../types/messages";
import { NetworkInteractionType } from "../../types/network-interaction";
import { findOnchainInteractionBy } from "../../views/execution-state/find-onchain-interaction-by";
import { findStaticCallBy } from "../../views/execution-state/find-static-call-by";
import { findTransactionBy } from "../../views/execution-state/find-transaction-by";

/**
* Add a new network interaction to the execution state.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { assertIgnitionInvariant } from "../../../utils/assertions";
import {
CallExecutionState,
DeploymentExecutionState,
SendDataExecutionState,
StaticCallExecutionState,
} from "../../types/execution-state";
} from "../../execution/types/execution-state";
import {
NetworkInteractionType,
OnchainInteraction,
} from "../../types/network-interaction";
} from "../../execution/types/network-interaction";
import { assertIgnitionInvariant } from "../../utils/assertions";

export function findOnchainInteractionBy(
executionState:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { assertIgnitionInvariant } from "../../../utils/assertions";
import {
CallExecutionState,
DeploymentExecutionState,
SendDataExecutionState,
StaticCallExecutionState,
} from "../../types/execution-state";
} from "../../execution/types/execution-state";
import {
NetworkInteractionType,
StaticCall,
} from "../../types/network-interaction";
} from "../../execution/types/network-interaction";
import { assertIgnitionInvariant } from "../../utils/assertions";

export function findStaticCallBy(
executionState:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { assertIgnitionInvariant } from "../../../utils/assertions";
import {
CallExecutionState,
DeploymentExecutionState,
SendDataExecutionState,
StaticCallExecutionState,
} from "../../types/execution-state";
import { Transaction } from "../../types/jsonrpc";
} from "../../execution/types/execution-state";
import { Transaction } from "../../execution/types/jsonrpc";
import { assertIgnitionInvariant } from "../../utils/assertions";

import { findOnchainInteractionBy } from "./find-onchain-interaction-by";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ExecutionSateType, ExecutionState } from "../../types/execution-state";
import {
ExecutionSateType,
ExecutionState,
} from "../../execution/types/execution-state";

import { getPendingOnchainInteraction } from "./get-pending-onchain-interaction";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { assertIgnitionInvariant } from "../../../utils/assertions";
import { ExecutionSateType, ExecutionState } from "../../types/execution-state";
import {
ExecutionSateType,
ExecutionState,
} from "../../execution/types/execution-state";
import {
NetworkInteractionType,
OnchainInteraction,
} from "../../types/network-interaction";
} from "../../execution/types/network-interaction";
import { assertIgnitionInvariant } from "../../utils/assertions";

/**
* Returns the last NetworkInteraction if there's one and it's an
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertIgnitionInvariant } from "../../utils/assertions";
import { DeploymentState } from "../types/deployment-state";
import { ExecutionResultType } from "../types/execution-result";
import { ExecutionSateType } from "../types/execution-state";
import { DeploymentState } from "../execution/types/deployment-state";
import { ExecutionResultType } from "../execution/types/execution-result";
import { ExecutionSateType } from "../execution/types/execution-state";
import { assertIgnitionInvariant } from "../utils/assertions";

/**
* Find the address for the future by its id. Only works for ContractAt, NamedLibrary,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assertIgnitionInvariant } from "../../utils/assertions";
import { DeploymentState } from "../types/deployment-state";
import { ExecutionSateType } from "../types/execution-state";
import { Transaction, TransactionReceipt } from "../types/jsonrpc";
import { NetworkInteractionType } from "../types/network-interaction";
import { DeploymentState } from "../execution/types/deployment-state";
import { ExecutionSateType } from "../execution/types/execution-state";
import { Transaction, TransactionReceipt } from "../execution/types/jsonrpc";
import { NetworkInteractionType } from "../execution/types/network-interaction";
import { assertIgnitionInvariant } from "../utils/assertions";

export function findConfirmedTransactionByFutureId(
deploymentState: DeploymentState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { assertIgnitionInvariant } from "../../utils/assertions";
import { DeploymentState } from "../types/deployment-state";
import { ExecutionResultType } from "../types/execution-result";
import { DeploymentState } from "../execution/types/deployment-state";
import { ExecutionResultType } from "../execution/types/execution-result";
import {
ContractAtExecutionState,
DeploymentExecutionState,
ExecutionSateType,
ExecutionStatus,
} from "../types/execution-state";
} from "../execution/types/execution-state";
import { assertIgnitionInvariant } from "../utils/assertions";

interface DeployedContract {
futureId: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertIgnitionInvariant } from "../../utils/assertions";
import { MapExStateTypeToExState } from "../type-helpers";
import { DeploymentState } from "../types/deployment-state";
import { ExecutionSateType } from "../types/execution-state";
import { MapExStateTypeToExState } from "../execution/type-helpers";
import { DeploymentState } from "../execution/types/deployment-state";
import { ExecutionSateType } from "../execution/types/execution-state";
import { assertIgnitionInvariant } from "../utils/assertions";

export function findExecutionStateById<ExStateT extends ExecutionSateType>(
exStateType: ExStateT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { SolidityParameterType } from "../../../types/module";
import { assertIgnitionInvariant } from "../../utils/assertions";
import { DeploymentState } from "../types/deployment-state";
import { ExecutionResultType } from "../types/execution-result";
import { ExecutionSateType } from "../types/execution-state";
import { SolidityParameterType } from "../../types/module";
import { DeploymentState } from "../execution/types/deployment-state";
import { ExecutionResultType } from "../execution/types/execution-result";
import { ExecutionSateType } from "../execution/types/execution-state";
import { assertIgnitionInvariant } from "../utils/assertions";

export function findResultForFutureById(
deploymentState: DeploymentState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Future } from "../../../types/module";
import { DeploymentState } from "../types/deployment-state";
import { ExecutionStatus } from "../types/execution-state";
import { Future } from "../../types/module";
import { DeploymentState } from "../execution/types/deployment-state";
import { ExecutionStatus } from "../execution/types/execution-state";

/**
* Returns true if the execution of the given future has failed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ExecutionState, ExecutionStatus } from "../types/execution-state";
import {
ExecutionState,
ExecutionStatus,
} from "../execution/types/execution-state";

/**
* Determine if an execution state has reached completion, either
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/execution/reducers/running-a-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
TransactionSendMessage,
} from "../../../src/internal/execution/types/messages";
import { NetworkInteractionType } from "../../../src/internal/execution/types/network-interaction";
import { findOnchainInteractionBy } from "../../../src/internal/execution/views/execution-state/find-onchain-interaction-by";
import { findTransactionBy } from "../../../src/internal/execution/views/execution-state/find-transaction-by";
import { findExecutionStateById } from "../../../src/internal/execution/views/find-execution-state-by-id";
import { assertIgnitionInvariant } from "../../../src/internal/utils/assertions";
import { findOnchainInteractionBy } from "../../../src/internal/views/execution-state/find-onchain-interaction-by";
import { findTransactionBy } from "../../../src/internal/views/execution-state/find-transaction-by";
import { findExecutionStateById } from "../../../src/internal/views/find-execution-state-by-id";

import { applyMessages } from "./utils";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
TransactionSendMessage,
} from "../../../src/internal/execution/types/messages";
import { NetworkInteractionType } from "../../../src/internal/execution/types/network-interaction";
import { findOnchainInteractionBy } from "../../../src/internal/execution/views/execution-state/find-onchain-interaction-by";
import { findTransactionBy } from "../../../src/internal/execution/views/execution-state/find-transaction-by";
import { findExecutionStateById } from "../../../src/internal/execution/views/find-execution-state-by-id";
import { assertIgnitionInvariant } from "../../../src/internal/utils/assertions";
import { findOnchainInteractionBy } from "../../../src/internal/views/execution-state/find-onchain-interaction-by";
import { findTransactionBy } from "../../../src/internal/views/execution-state/find-transaction-by";
import { findExecutionStateById } from "../../../src/internal/views/find-execution-state-by-id";
import { FutureType } from "../../../src/types/module";

import { applyMessages } from "./utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
TransactionSendMessage,
} from "../../../src/internal/execution/types/messages";
import { NetworkInteractionType } from "../../../src/internal/execution/types/network-interaction";
import { findExecutionStateById } from "../../../src/internal/execution/views/find-execution-state-by-id";
import { findExecutionStateById } from "../../../src/internal/views/find-execution-state-by-id";
import { FutureType } from "../../../src/types/module";

import { applyMessages } from "./utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
JournalMessageType,
ReadEventArgExecutionStateInitializeMessage,
} from "../../../src/internal/execution/types/messages";
import { findExecutionStateById } from "../../../src/internal/execution/views/find-execution-state-by-id";
import { findExecutionStateById } from "../../../src/internal/views/find-execution-state-by-id";

import { applyMessages } from "./utils";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
StaticCallExecutionStateInitializeMessage,
} from "../../../src/internal/execution/types/messages";
import { NetworkInteractionType } from "../../../src/internal/execution/types/network-interaction";
import { findExecutionStateById } from "../../../src/internal/execution/views/find-execution-state-by-id";
import { findExecutionStateById } from "../../../src/internal/views/find-execution-state-by-id";

import { applyMessages } from "./utils";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ContractAtExecutionStateInitializeMessage,
JournalMessageType,
} from "../../../src/internal/execution/types/messages";
import { findExecutionStateById } from "../../../src/internal/execution/views/find-execution-state-by-id";
import { findExecutionStateById } from "../../../src/internal/views/find-execution-state-by-id";
import { FutureType } from "../../../src/types/module";

import { applyMessages } from "./utils";
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/execution/reducers/running-send-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
TransactionSendMessage,
} from "../../../src/internal/execution/types/messages";
import { NetworkInteractionType } from "../../../src/internal/execution/types/network-interaction";
import { findOnchainInteractionBy } from "../../../src/internal/execution/views/execution-state/find-onchain-interaction-by";
import { findTransactionBy } from "../../../src/internal/execution/views/execution-state/find-transaction-by";
import { findExecutionStateById } from "../../../src/internal/execution/views/find-execution-state-by-id";
import { assertIgnitionInvariant } from "../../../src/internal/utils/assertions";
import { findOnchainInteractionBy } from "../../../src/internal/views/execution-state/find-onchain-interaction-by";
import { findTransactionBy } from "../../../src/internal/views/execution-state/find-transaction-by";
import { findExecutionStateById } from "../../../src/internal/views/find-execution-state-by-id";

import { applyMessages } from "./utils";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assert } from "chai";

import { ExecutionResultType } from "../../../src/internal/execution/types/execution-result";
import { ExecutionSateType } from "../../../src/internal/execution/types/execution-state";
import { findResultForFutureById } from "../../../src/internal/execution/views/find-result-for-future-by-id";
import { findResultForFutureById } from "../../../src/internal/views/find-result-for-future-by-id";

describe("find result by future by", () => {
const futureId = "MyFuture";
Expand Down