Skip to content

Commit

Permalink
refactor(crypto-transaction-evm-call): add interface types to break u…
Browse files Browse the repository at this point in the history
…p cyclic dependency on evm (#462)

* evm interfaces

* remove hard dependency

* remove unused dep
  • Loading branch information
oXtxNt9U authored Mar 1, 2024
1 parent 982ae2d commit 5710ff7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
20 changes: 20 additions & 0 deletions packages/contracts/source/contracts/evm/evm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export interface Instance {
transact(txContext: TransactionContext): Promise<TransactionResult>;
view(txContext: TransactionContext): Promise<TransactionResult>;
}

export interface TransactionContext {
caller: string;
/** Omit recipient when deploying a contract */
recipient?: string;
data: Buffer;
}

export interface TransactionResult {
gasUsed: bigint;
gasRefunded: bigint;
success: boolean;
deployedContractAddress?: string;
logs: any;
output?: Buffer;
}
1 change: 1 addition & 0 deletions packages/contracts/source/contracts/evm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./evm";
1 change: 1 addition & 0 deletions packages/contracts/source/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * as ApiSync from "./api-sync";
export * as Consensus from "./consensus";
export * as Crypto from "./crypto";
export * as Database from "./database";
export * as Evm from "./evm";
export * as Fee from "./fees";
export * as Kernel from "./kernel";
export * as NetworkGenerator from "./network-generator";
Expand Down
1 change: 0 additions & 1 deletion packages/crypto-transaction-evm-call/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@mainsail/container": "workspace:*",
"@mainsail/contracts": "workspace:*",
"@mainsail/crypto-transaction": "workspace:*",
"@mainsail/evm": "workspace:*",
"@mainsail/kernel": "workspace:*",
"@mainsail/transactions": "workspace:*",
"@mainsail/utils": "workspace:*"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { inject, injectable } from "@mainsail/container";
import { Contracts, Identifiers } from "@mainsail/contracts";
import Transactions from "@mainsail/crypto-transaction";
import { Bindings } from "@mainsail/evm";
import { Utils as AppUtils } from "@mainsail/kernel";
import { Handlers } from "@mainsail/transactions";

Expand All @@ -10,7 +9,7 @@ import { EvmCallTransaction } from "../versions";
@injectable()
export class EvmCallTransactionHandler extends Handlers.TransactionHandler {
@inject(Identifiers.Evm.Instance)
private readonly evm!: Bindings.Evm;
private readonly evm!: Contracts.Evm.Instance;

public dependencies(): ReadonlyArray<Handlers.TransactionHandlerConstructor> {
return [];
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5710ff7

Please sign in to comment.