Skip to content

Commit

Permalink
remove isAdapters and move types/journals to internal
Browse files Browse the repository at this point in the history
Fixes #315
  • Loading branch information
zoeyTM authored and kanej committed Jul 27, 2023
1 parent ef1e2e5 commit 123df69
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 73 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/new-api/internal/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import { Artifact, ArtifactResolver } from "../types/artifact";
import { DeployConfig, DeploymentResult } from "../types/deployer";
import { DeploymentLoader } from "../types/deployment-loader";
import { Journal } from "../types/journal";

import { Batcher } from "./batcher";
import { ExecutionEngine } from "./execution/execution-engine";
Expand All @@ -36,6 +35,7 @@ import {
DeploymentExecutionState,
ExecutionStateMap,
} from "./types/execution-state";
import { Journal } from "./types/journal";
import { TransactionLookupTimer } from "./types/transaction-timer";
import { assertIgnitionInvariant } from "./utils/assertions";
import { getFuturesFromModule } from "./utils/get-futures-from-module";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Artifact, ArtifactResolver, BuildInfo } from "../../types/artifact";
import { DeploymentLoader } from "../../types/deployment-loader";
import { Journal } from "../../types/journal";
import { MemoryJournal } from "../journal/memory-journal";
import { Journal } from "../types/journal";
import { assertIgnitionInvariant } from "../utils/assertions";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from "path";

import { Artifact, BuildInfo } from "../../types/artifact";
import { DeploymentLoader } from "../../types/deployment-loader";
import { Journal } from "../../types/journal";
import { FileJournal } from "../journal/file-journal";
import { Journal } from "../types/journal";

export class FileDeploymentLoader implements DeploymentLoader {
public journal: Journal;
Expand Down
18 changes: 9 additions & 9 deletions packages/core/src/new-api/internal/execution/execution-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ import {
DeploymentResultContracts,
} from "../../types/deployer";
import { DeploymentLoader } from "../../types/deployment-loader";
import {
ExecutionResultMessage,
ExecutionTimeout,
FutureStartMessage,
JournalableMessage,
OnchainTransactionReset,
StartRunMessage,
TransactionMessage,
} from "../../types/journal";
import {
AccountRuntimeValue,
ArgumentType,
Expand Down Expand Up @@ -53,6 +44,15 @@ import {
ExecutionStateMap,
ExecutionStatus,
} from "../types/execution-state";
import {
ExecutionResultMessage,
ExecutionTimeout,
FutureStartMessage,
JournalableMessage,
OnchainTransactionReset,
StartRunMessage,
TransactionMessage,
} from "../types/journal";
import { assertIgnitionInvariant } from "../utils/assertions";
import { getFuturesFromModule } from "../utils/get-futures-from-module";
import { replaceWithinArg } from "../utils/replace-within-arg";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IgnitionError } from "../../../errors";
import { FutureStartMessage, JournalableMessage } from "../../types/journal";
import {
isCallFunctionStartMessage,
isContractAtStartMessage,
Expand All @@ -24,6 +23,7 @@ import {
SendDataExecutionState,
StaticCallExecutionState,
} from "../types/execution-state";
import { FutureStartMessage, JournalableMessage } from "../types/journal";
import { assertIgnitionInvariant } from "../utils/assertions";

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { isOnChainResultMessage } from "../journal/type-guards";
import { ExecutionState } from "../types/execution-state";
import {
ExecutionSuccess,
OnchainInteractionMessage,
OnchainResultMessage,
TransactionMessage,
} from "../../types/journal";
import { isOnChainResultMessage } from "../journal/type-guards";
import { ExecutionState } from "../types/execution-state";

} from "../types/journal";
export class ExecutionStategyCycler {
/**
* Given a execution strategy and history of on chain transactions
Expand Down
38 changes: 19 additions & 19 deletions packages/core/src/new-api/internal/execution/execution-strategy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import { IgnitionError } from "../../../errors";
import {
isCallExecutionState,
isContractAtExecutionState,
isDeploymentExecutionState,
isReadEventArgumentExecutionState,
isSendDataExecutionState,
isStaticCallExecutionState,
} from "../type-guards";
import { ExecutionStrategy } from "../types/execution-engine";
import {
CallExecutionState,
ContractAtExecutionState,
DeploymentExecutionState,
ExecutionState,
ReadEventArgumentExecutionState,
SendDataExecutionState,
StaticCallExecutionState,
} from "../types/execution-state";
import {
CallFunctionInteractionMessage,
CalledFunctionExecutionSuccess,
Expand All @@ -21,25 +39,7 @@ import {
SendDataInteractionMessage,
StaticCallExecutionSuccess,
StaticCallInteractionMessage,
} from "../../types/journal";
import {
isCallExecutionState,
isContractAtExecutionState,
isDeploymentExecutionState,
isReadEventArgumentExecutionState,
isSendDataExecutionState,
isStaticCallExecutionState,
} from "../type-guards";
import { ExecutionStrategy } from "../types/execution-engine";
import {
CallExecutionState,
ContractAtExecutionState,
DeploymentExecutionState,
ExecutionState,
ReadEventArgumentExecutionState,
SendDataExecutionState,
StaticCallExecutionState,
} from "../types/execution-state";
} from "../types/journal";
import { assertIgnitionInvariant } from "../utils/assertions";

export class BasicExecutionStrategy implements ExecutionStrategy {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/new-api/internal/execution/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SendDataInteractionMessage,
StaticCallExecutionSuccess,
StaticCallInteractionMessage,
} from "../../types/journal";
} from "../types/journal";

export function isExecutionResultMessage(
potential: JournalableMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IgnitionError } from "../../../errors";
import { TransactionMessage } from "../../types/journal";
import {
isOnchainCallFunctionSuccessMessage,
isOnchainContractAtSuccessMessage,
Expand All @@ -14,6 +13,7 @@ import {
} from "../journal/type-guards";
import { serializeReplacer } from "../journal/utils/serialize-replacer";
import { OnchainState, OnchainStatuses } from "../types/execution-state";
import { TransactionMessage } from "../types/journal";
import { assertIgnitionInvariant } from "../utils/assertions";

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
SendDataInteractionMessage,
StaticCallInteractionMessage,
TransactionMessage,
} from "../../types/journal";
} from "../../internal/types/journal";
import { ArgumentType } from "../../types/module";
import {
isOnChainResultMessage,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/new-api/internal/journal/file-journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fs, { closeSync, constants, openSync, writeFileSync } from "fs";
import { parse } from "ndjson";

import { Journal, JournalableMessage } from "../../types/journal";
import { Journal, JournalableMessage } from "../types/journal";

import { deserializeReplacer } from "./utils/deserialize-replacer";
import { logJournalableMessage } from "./utils/log";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Journal, JournalableMessage } from "../../types/journal";
import { Journal, JournalableMessage } from "../types/journal";

import { deserializeReplacer } from "./utils/deserialize-replacer";
import { logJournalableMessage } from "./utils/log";
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/new-api/internal/journal/type-guards.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { FutureType } from "../../types/module";
import { isOnchainInteractionMessage } from "../execution/guards";
import {
CallFunctionStartMessage,
ContractAtStartMessage,
Expand All @@ -22,9 +24,7 @@ import {
StaticCallStartMessage,
TransactionMessage,
WipeMessage,
} from "../../types/journal";
import { FutureType } from "../../types/module";
import { isOnchainInteractionMessage } from "../execution/guards";
} from "../types/journal";

/**
* Determines if potential is a StartRunMessage.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/new-api/internal/journal/utils/log.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { JournalableMessage } from "../../../types/journal";
import { SolidityParameterType } from "../../../types/module";
import {
isCallFunctionInteraction,
Expand All @@ -17,6 +16,7 @@ import {
isStaticCallExecutionSuccess,
isStaticCallInteraction,
} from "../../execution/guards";
import { JournalableMessage } from "../../types/journal";
import {
isCallFunctionStartMessage,
isContractAtStartMessage,
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/new-api/internal/types/execution-engine.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { ArtifactResolver } from "../../types/artifact";
import { DeploymentLoader } from "../../types/deployment-loader";
import {
ExecutionSuccess,
OnchainInteractionMessage,
OnchainResultMessage,
} from "../../types/journal";
import {
IgnitionModule,
IgnitionModuleResult,
Expand All @@ -13,6 +8,11 @@ import {

import { ChainDispatcher } from "./chain-dispatcher";
import { ExecutionState, ExecutionStateMap } from "./execution-state";
import {
ExecutionSuccess,
OnchainInteractionMessage,
OnchainResultMessage,
} from "./journal";
import { TransactionLookupTimer } from "./transaction-timer";

interface ExecutionConfig {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/new-api/internal/types/execution-state.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { TransactionMessage } from "../../types/journal";
import {
ArgumentType,
FutureType,
SolidityParameterType,
} from "../../types/module";

import { TransactionMessage } from "./journal";

/**
* The execution history of a future is a sequence of onchain interactions.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ArgumentType, FutureType, SolidityParameterType } from "./module";
import {
ArgumentType,
FutureType,
SolidityParameterType,
} from "../../types/module";

/**
* Store a deployments execution state as a transaction log.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/new-api/internal/wiper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IgnitionError } from "../../errors";
import { Journal, WipeMessage } from "../types/journal";

import { executionStateReducer } from "./execution/execution-state-reducer";
import { ExecutionStateMap } from "./types/execution-state";
import { Journal, WipeMessage } from "./types/journal";

export class Wiper {
constructor(private _journal: Journal) {}
Expand Down
17 changes: 0 additions & 17 deletions packages/core/src/new-api/type-guards.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Adapters } from "./types/adapters";
import { Artifact } from "./types/artifact";
import {
AccountRuntimeValue,
Expand Down Expand Up @@ -331,19 +330,3 @@ export function isModuleParameterRuntimeValue(
potential.type === RuntimeValueType.MODULE_PARAMETER
);
}

/**
* Returns true if potential is a set of adapters.
*
* @beta
*/
export function isAdapters(potential: unknown): potential is Adapters {
return (
typeof potential === "object" &&
potential !== null &&
/* TODO: make this type safe */
"signer" in potential &&
"gas" in potential &&
"transactions" in potential
);
}
3 changes: 2 additions & 1 deletion packages/core/src/new-api/types/deployment-loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Journal } from "../internal/types/journal";

import { Artifact, BuildInfo } from "./artifact";
import { Journal } from "./journal";

/**
* Read and write to the deployment storage.
Expand Down
5 changes: 4 additions & 1 deletion packages/core/test/new-api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import {
OnchainState,
OnchainStatuses,
} from "../../src/new-api/internal/types/execution-state";
import {
Journal,
JournalableMessage,
} from "../../src/new-api/internal/types/journal";
import {
DeploymentResult,
DeploymentResultContract,
DeploymentResultContracts,
} from "../../src/new-api/types/deployer";
import { DeploymentLoader } from "../../src/new-api/types/deployment-loader";
import { Journal, JournalableMessage } from "../../src/new-api/types/journal";

export const exampleAccounts: string[] = [
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/new-api/wipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { assert } from "chai";

import { defineModule } from "../../src/new-api/define-module";
import { MemoryJournal } from "../../src/new-api/internal/journal/memory-journal";
import { Journal } from "../../src/new-api/internal/types/journal";
import { Wiper } from "../../src/new-api/internal/wiper";
import { Journal } from "../../src/new-api/types/journal";
import { IgnitionModuleResult } from "../../src/new-api/types/module";
import { IgnitionModuleDefinition } from "../../src/new-api/types/module-builder";

Expand Down

0 comments on commit 123df69

Please sign in to comment.