From 69a81560dda862a20903d1930fc4c860b788c8ec Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Wed, 6 Mar 2024 18:57:45 +0200 Subject: [PATCH 1/3] adapter for executing smart contract queries --- src/adaptors/index.ts | 1 + src/adaptors/smartContractQueriesAdaptor.ts | 51 +++++++++++++++++++++ src/smartContractQueriesController.spec.ts | 48 +++++++++++++------ src/smartContractQueriesController.ts | 31 +++++-------- 4 files changed, 98 insertions(+), 33 deletions(-) create mode 100644 src/adaptors/index.ts create mode 100644 src/adaptors/smartContractQueriesAdaptor.ts diff --git a/src/adaptors/index.ts b/src/adaptors/index.ts new file mode 100644 index 00000000..9fa9c9a3 --- /dev/null +++ b/src/adaptors/index.ts @@ -0,0 +1 @@ +export * from "./smartContractQueriesAdaptor"; diff --git a/src/adaptors/smartContractQueriesAdaptor.ts b/src/adaptors/smartContractQueriesAdaptor.ts new file mode 100644 index 00000000..b8c2151f --- /dev/null +++ b/src/adaptors/smartContractQueriesAdaptor.ts @@ -0,0 +1,51 @@ +import { Address } from "../address"; +import { IAddress } from "../interface"; +import { IContractQueryResponse } from "../interfaceOfNetwork"; +import { SmartContractQuery, SmartContractQueryResponse } from "../smartContractQuery"; +import { ContractFunction, EndpointDefinition } from "../smartcontracts"; + +interface INetworkProvider { + queryContract(query: ILegacyQuery): Promise; +} + +interface IAbi { + getEndpoint(name: string | ContractFunction): EndpointDefinition; +} + +interface ILegacyQuery { + address: IAddress; + caller?: IAddress; + func: { toString(): string }; + value?: { toString(): string }; + getEncodedArguments(): string[]; +} + +export class SmartContractQueriesAdaptor { + abi?: IAbi; + networkProvider: INetworkProvider; + + constructor(options: { abi?: IAbi; networkProvider: INetworkProvider }) { + this.abi = options.abi; + this.networkProvider = options.networkProvider; + } + + async queryContract(query: SmartContractQuery): Promise { + const legacyQuery: ILegacyQuery = { + address: Address.fromBech32(query.contract), + caller: query.caller ? Address.fromBech32(query.caller) : undefined, + func: query.function, + value: query.value, + getEncodedArguments: () => query.arguments.map((arg) => Buffer.from(arg).toString("hex")), + }; + + const legacyQueryResponse = await this.networkProvider.queryContract(legacyQuery); + const queryResponse = new SmartContractQueryResponse({ + function: query.function, + returnCode: legacyQueryResponse.returnCode.toString(), + returnMessage: legacyQueryResponse.returnMessage, + returnDataParts: legacyQueryResponse.getReturnDataParts(), + }); + + return queryResponse; + } +} diff --git a/src/smartContractQueriesController.spec.ts b/src/smartContractQueriesController.spec.ts index 69954b45..915c0c64 100644 --- a/src/smartContractQueriesController.spec.ts +++ b/src/smartContractQueriesController.spec.ts @@ -6,12 +6,14 @@ import { SmartContractQueryResponse } from "./smartContractQuery"; import { AbiRegistry, BigUIntValue, BooleanValue, BytesValue, Tuple, U16Value, U64Value } from "./smartcontracts"; import { bigIntToBuffer } from "./smartcontracts/codec/utils"; import { MockNetworkProvider, loadAbiRegistry } from "./testutils"; +import { SmartContractQueriesAdaptor } from "./adaptors/smartContractQueriesAdaptor"; describe("test smart contract queries controller", () => { describe("createQuery", () => { it("works without ABI, when arguments are buffers", function () { + const adapter = new SmartContractQueriesAdaptor({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ - networkProvider: new MockNetworkProvider(), + queryRunner: adapter, }); const query = controller.createQuery({ @@ -26,8 +28,9 @@ describe("test smart contract queries controller", () => { }); it("works without ABI, when arguments are typed values", function () { + const adapter = new SmartContractQueriesAdaptor({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ - networkProvider: new MockNetworkProvider(), + queryRunner: adapter, }); const query = controller.createQuery({ @@ -42,8 +45,9 @@ describe("test smart contract queries controller", () => { }); it("fails without ABI, when arguments aren't buffers, nor typed values", function () { + const adapter = new SmartContractQueriesAdaptor({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ - networkProvider: new MockNetworkProvider(), + queryRunner: adapter, }); assert.throws(() => { @@ -56,9 +60,12 @@ describe("test smart contract queries controller", () => { }); it("works with ABI, when arguments are native JS objects", async function () { - const controller = new SmartContractQueriesController({ - networkProvider: new MockNetworkProvider(), + const adapter = new SmartContractQueriesAdaptor({ abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), + networkProvider: new MockNetworkProvider(), + }); + const controller = new SmartContractQueriesController({ + queryRunner: adapter, }); const query = controller.createQuery({ @@ -73,9 +80,12 @@ describe("test smart contract queries controller", () => { }); it("works with ABI, when arguments typed values", async function () { - const controller = new SmartContractQueriesController({ - networkProvider: new MockNetworkProvider(), + const adapter = new SmartContractQueriesAdaptor({ abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), + networkProvider: new MockNetworkProvider(), + }); + const controller = new SmartContractQueriesController({ + queryRunner: adapter, }); const query = controller.createQuery({ @@ -113,9 +123,12 @@ describe("test smart contract queries controller", () => { ], }); - const controller = new SmartContractQueriesController({ - networkProvider: new MockNetworkProvider(), + const adapter = new SmartContractQueriesAdaptor({ abi: abi, + networkProvider: new MockNetworkProvider(), + }); + const controller = new SmartContractQueriesController({ + queryRunner: adapter, }); const query = controller.createQuery({ @@ -149,9 +162,12 @@ describe("test smart contract queries controller", () => { describe("runQuery", () => { it("calls queryContract on the network provider", async function () { const networkProvider = new MockNetworkProvider(); - const controller = new SmartContractQueriesController({ + const adapter = new SmartContractQueriesAdaptor({ networkProvider: networkProvider, }); + const controller = new SmartContractQueriesController({ + queryRunner: adapter, + }); networkProvider.mockQueryContractOnFunction( "bar", @@ -176,9 +192,12 @@ describe("test smart contract queries controller", () => { describe("parseQueryResponse", () => { it("works without ABI", function () { - const controller = new SmartContractQueriesController({ + const adapter = new SmartContractQueriesAdaptor({ networkProvider: new MockNetworkProvider(), }); + const controller = new SmartContractQueriesController({ + queryRunner: adapter, + }); const response = new SmartContractQueryResponse({ function: "bar", @@ -193,9 +212,12 @@ describe("test smart contract queries controller", () => { }); it("works with ABI", async function () { - const controller = new SmartContractQueriesController({ - networkProvider: new MockNetworkProvider(), + const adapter = new SmartContractQueriesAdaptor({ abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), + networkProvider: new MockNetworkProvider(), + }); + const controller = new SmartContractQueriesController({ + queryRunner: adapter, }); const response = new SmartContractQueryResponse({ diff --git a/src/smartContractQueriesController.ts b/src/smartContractQueriesController.ts index 64155645..afcf0521 100644 --- a/src/smartContractQueriesController.ts +++ b/src/smartContractQueriesController.ts @@ -21,14 +21,20 @@ interface ILegacyQuery { getEncodedArguments(): string[]; } +interface IQueryRunner { + abi?: IAbi; + networkProvider: INetworkProvider; + queryContract(query: SmartContractQuery): Promise; +} + export class SmartContractQueriesController { private readonly abi?: IAbi; - private readonly networkProvider: INetworkProvider; + private readonly queryRunner: IQueryRunner; private readonly legacyResultsParser: ResultsParser; - constructor(options: { abi?: IAbi; networkProvider: INetworkProvider }) { - this.abi = options.abi; - this.networkProvider = options.networkProvider; + constructor(options: { queryRunner: IQueryRunner }) { + this.abi = options.queryRunner.abi; + this.queryRunner = options.queryRunner; this.legacyResultsParser = new ResultsParser(); } @@ -92,22 +98,7 @@ export class SmartContractQueriesController { } async runQuery(query: SmartContractQuery): Promise { - const legacyQuery: ILegacyQuery = { - address: Address.fromBech32(query.contract), - caller: query.caller ? Address.fromBech32(query.caller) : undefined, - func: query.function, - value: query.value, - getEncodedArguments: () => query.arguments.map((arg) => Buffer.from(arg).toString("hex")), - }; - - const legacyQueryResponse = await this.networkProvider.queryContract(legacyQuery); - const queryResponse = new SmartContractQueryResponse({ - function: query.function, - returnCode: legacyQueryResponse.returnCode.toString(), - returnMessage: legacyQueryResponse.returnMessage, - returnDataParts: legacyQueryResponse.getReturnDataParts(), - }); - + const queryResponse = await this.queryRunner.queryContract(query); return queryResponse; } From 127937cf4de7f65cf08aa978db228d573693a806 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Mar 2024 10:10:04 +0200 Subject: [PATCH 2/3] refactoring --- src/adapters/index.ts | 1 + .../smartContractQueriesAdapter.ts} | 11 ++------ src/adaptors/index.ts | 1 - src/smartContractQueriesController.spec.ts | 28 +++++++++---------- src/smartContractQueriesController.ts | 6 ++-- 5 files changed, 19 insertions(+), 28 deletions(-) create mode 100644 src/adapters/index.ts rename src/{adaptors/smartContractQueriesAdaptor.ts => adapters/smartContractQueriesAdapter.ts} (82%) delete mode 100644 src/adaptors/index.ts diff --git a/src/adapters/index.ts b/src/adapters/index.ts new file mode 100644 index 00000000..e6409c29 --- /dev/null +++ b/src/adapters/index.ts @@ -0,0 +1 @@ +export * from "./smartContractQueriesAdapter"; diff --git a/src/adaptors/smartContractQueriesAdaptor.ts b/src/adapters/smartContractQueriesAdapter.ts similarity index 82% rename from src/adaptors/smartContractQueriesAdaptor.ts rename to src/adapters/smartContractQueriesAdapter.ts index b8c2151f..61e52704 100644 --- a/src/adaptors/smartContractQueriesAdaptor.ts +++ b/src/adapters/smartContractQueriesAdapter.ts @@ -2,16 +2,11 @@ import { Address } from "../address"; import { IAddress } from "../interface"; import { IContractQueryResponse } from "../interfaceOfNetwork"; import { SmartContractQuery, SmartContractQueryResponse } from "../smartContractQuery"; -import { ContractFunction, EndpointDefinition } from "../smartcontracts"; interface INetworkProvider { queryContract(query: ILegacyQuery): Promise; } -interface IAbi { - getEndpoint(name: string | ContractFunction): EndpointDefinition; -} - interface ILegacyQuery { address: IAddress; caller?: IAddress; @@ -20,12 +15,10 @@ interface ILegacyQuery { getEncodedArguments(): string[]; } -export class SmartContractQueriesAdaptor { - abi?: IAbi; +export class SmartContractQueriesAdapter { networkProvider: INetworkProvider; - constructor(options: { abi?: IAbi; networkProvider: INetworkProvider }) { - this.abi = options.abi; + constructor(options: { networkProvider: INetworkProvider }) { this.networkProvider = options.networkProvider; } diff --git a/src/adaptors/index.ts b/src/adaptors/index.ts deleted file mode 100644 index 9fa9c9a3..00000000 --- a/src/adaptors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./smartContractQueriesAdaptor"; diff --git a/src/smartContractQueriesController.spec.ts b/src/smartContractQueriesController.spec.ts index 915c0c64..36d71a33 100644 --- a/src/smartContractQueriesController.spec.ts +++ b/src/smartContractQueriesController.spec.ts @@ -6,12 +6,12 @@ import { SmartContractQueryResponse } from "./smartContractQuery"; import { AbiRegistry, BigUIntValue, BooleanValue, BytesValue, Tuple, U16Value, U64Value } from "./smartcontracts"; import { bigIntToBuffer } from "./smartcontracts/codec/utils"; import { MockNetworkProvider, loadAbiRegistry } from "./testutils"; -import { SmartContractQueriesAdaptor } from "./adaptors/smartContractQueriesAdaptor"; +import { SmartContractQueriesAdapter } from "./adapters/smartContractQueriesAdapter"; describe("test smart contract queries controller", () => { describe("createQuery", () => { it("works without ABI, when arguments are buffers", function () { - const adapter = new SmartContractQueriesAdaptor({ networkProvider: new MockNetworkProvider() }); + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ queryRunner: adapter, }); @@ -28,7 +28,7 @@ describe("test smart contract queries controller", () => { }); it("works without ABI, when arguments are typed values", function () { - const adapter = new SmartContractQueriesAdaptor({ networkProvider: new MockNetworkProvider() }); + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ queryRunner: adapter, }); @@ -45,7 +45,7 @@ describe("test smart contract queries controller", () => { }); it("fails without ABI, when arguments aren't buffers, nor typed values", function () { - const adapter = new SmartContractQueriesAdaptor({ networkProvider: new MockNetworkProvider() }); + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ queryRunner: adapter, }); @@ -60,11 +60,11 @@ describe("test smart contract queries controller", () => { }); it("works with ABI, when arguments are native JS objects", async function () { - const adapter = new SmartContractQueriesAdaptor({ - abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ + abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), queryRunner: adapter, }); @@ -80,11 +80,11 @@ describe("test smart contract queries controller", () => { }); it("works with ABI, when arguments typed values", async function () { - const adapter = new SmartContractQueriesAdaptor({ - abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ + abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), queryRunner: adapter, }); @@ -123,11 +123,11 @@ describe("test smart contract queries controller", () => { ], }); - const adapter = new SmartContractQueriesAdaptor({ - abi: abi, + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ + abi: abi, queryRunner: adapter, }); @@ -162,7 +162,7 @@ describe("test smart contract queries controller", () => { describe("runQuery", () => { it("calls queryContract on the network provider", async function () { const networkProvider = new MockNetworkProvider(); - const adapter = new SmartContractQueriesAdaptor({ + const adapter = new SmartContractQueriesAdapter({ networkProvider: networkProvider, }); const controller = new SmartContractQueriesController({ @@ -192,7 +192,7 @@ describe("test smart contract queries controller", () => { describe("parseQueryResponse", () => { it("works without ABI", function () { - const adapter = new SmartContractQueriesAdaptor({ + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ @@ -212,11 +212,11 @@ describe("test smart contract queries controller", () => { }); it("works with ABI", async function () { - const adapter = new SmartContractQueriesAdaptor({ - abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), + const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ + abi: await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"), queryRunner: adapter, }); diff --git a/src/smartContractQueriesController.ts b/src/smartContractQueriesController.ts index afcf0521..aceb1b57 100644 --- a/src/smartContractQueriesController.ts +++ b/src/smartContractQueriesController.ts @@ -1,4 +1,3 @@ -import { Address } from "./address"; import { Err } from "./errors"; import { IAddress } from "./interface"; import { IContractQueryResponse } from "./interfaceOfNetwork"; @@ -22,7 +21,6 @@ interface ILegacyQuery { } interface IQueryRunner { - abi?: IAbi; networkProvider: INetworkProvider; queryContract(query: SmartContractQuery): Promise; } @@ -32,8 +30,8 @@ export class SmartContractQueriesController { private readonly queryRunner: IQueryRunner; private readonly legacyResultsParser: ResultsParser; - constructor(options: { queryRunner: IQueryRunner }) { - this.abi = options.queryRunner.abi; + constructor(options: { abi?: IAbi; queryRunner: IQueryRunner }) { + this.abi = options.abi; this.queryRunner = options.queryRunner; this.legacyResultsParser = new ResultsParser(); } From f921d342f6eb9b105d8709fb900ad760c26290a2 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Thu, 7 Mar 2024 11:32:05 +0200 Subject: [PATCH 3/3] renamings --- src/adapters/index.ts | 2 +- ...ueriesAdapter.ts => queryRunnerAdapter.ts} | 12 +++++------ src/smartContractQueriesController.spec.ts | 20 +++++++++---------- src/smartContractQueriesController.ts | 18 ++--------------- 4 files changed, 19 insertions(+), 33 deletions(-) rename src/adapters/{smartContractQueriesAdapter.ts => queryRunnerAdapter.ts} (80%) diff --git a/src/adapters/index.ts b/src/adapters/index.ts index e6409c29..e73a1b2d 100644 --- a/src/adapters/index.ts +++ b/src/adapters/index.ts @@ -1 +1 @@ -export * from "./smartContractQueriesAdapter"; +export * from "./queryRunnerAdapter"; diff --git a/src/adapters/smartContractQueriesAdapter.ts b/src/adapters/queryRunnerAdapter.ts similarity index 80% rename from src/adapters/smartContractQueriesAdapter.ts rename to src/adapters/queryRunnerAdapter.ts index 61e52704..b78840c7 100644 --- a/src/adapters/smartContractQueriesAdapter.ts +++ b/src/adapters/queryRunnerAdapter.ts @@ -4,10 +4,10 @@ import { IContractQueryResponse } from "../interfaceOfNetwork"; import { SmartContractQuery, SmartContractQueryResponse } from "../smartContractQuery"; interface INetworkProvider { - queryContract(query: ILegacyQuery): Promise; + queryContract(query: IQuery): Promise; } -interface ILegacyQuery { +interface IQuery { address: IAddress; caller?: IAddress; func: { toString(): string }; @@ -15,15 +15,15 @@ interface ILegacyQuery { getEncodedArguments(): string[]; } -export class SmartContractQueriesAdapter { - networkProvider: INetworkProvider; +export class QueryRunnerAdapter { + private readonly networkProvider: INetworkProvider; constructor(options: { networkProvider: INetworkProvider }) { this.networkProvider = options.networkProvider; } - async queryContract(query: SmartContractQuery): Promise { - const legacyQuery: ILegacyQuery = { + async runQuery(query: SmartContractQuery): Promise { + const legacyQuery: IQuery = { address: Address.fromBech32(query.contract), caller: query.caller ? Address.fromBech32(query.caller) : undefined, func: query.function, diff --git a/src/smartContractQueriesController.spec.ts b/src/smartContractQueriesController.spec.ts index 36d71a33..b1e6861c 100644 --- a/src/smartContractQueriesController.spec.ts +++ b/src/smartContractQueriesController.spec.ts @@ -6,12 +6,12 @@ import { SmartContractQueryResponse } from "./smartContractQuery"; import { AbiRegistry, BigUIntValue, BooleanValue, BytesValue, Tuple, U16Value, U64Value } from "./smartcontracts"; import { bigIntToBuffer } from "./smartcontracts/codec/utils"; import { MockNetworkProvider, loadAbiRegistry } from "./testutils"; -import { SmartContractQueriesAdapter } from "./adapters/smartContractQueriesAdapter"; +import { QueryRunnerAdapter } from "./adapters/queryRunnerAdapter"; describe("test smart contract queries controller", () => { describe("createQuery", () => { it("works without ABI, when arguments are buffers", function () { - const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider() }); + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ queryRunner: adapter, }); @@ -28,7 +28,7 @@ describe("test smart contract queries controller", () => { }); it("works without ABI, when arguments are typed values", function () { - const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider() }); + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ queryRunner: adapter, }); @@ -45,7 +45,7 @@ describe("test smart contract queries controller", () => { }); it("fails without ABI, when arguments aren't buffers, nor typed values", function () { - const adapter = new SmartContractQueriesAdapter({ networkProvider: new MockNetworkProvider() }); + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider() }); const controller = new SmartContractQueriesController({ queryRunner: adapter, }); @@ -60,7 +60,7 @@ describe("test smart contract queries controller", () => { }); it("works with ABI, when arguments are native JS objects", async function () { - const adapter = new SmartContractQueriesAdapter({ + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ @@ -80,7 +80,7 @@ describe("test smart contract queries controller", () => { }); it("works with ABI, when arguments typed values", async function () { - const adapter = new SmartContractQueriesAdapter({ + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ @@ -123,7 +123,7 @@ describe("test smart contract queries controller", () => { ], }); - const adapter = new SmartContractQueriesAdapter({ + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ @@ -162,7 +162,7 @@ describe("test smart contract queries controller", () => { describe("runQuery", () => { it("calls queryContract on the network provider", async function () { const networkProvider = new MockNetworkProvider(); - const adapter = new SmartContractQueriesAdapter({ + const adapter = new QueryRunnerAdapter({ networkProvider: networkProvider, }); const controller = new SmartContractQueriesController({ @@ -192,7 +192,7 @@ describe("test smart contract queries controller", () => { describe("parseQueryResponse", () => { it("works without ABI", function () { - const adapter = new SmartContractQueriesAdapter({ + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ @@ -212,7 +212,7 @@ describe("test smart contract queries controller", () => { }); it("works with ABI", async function () { - const adapter = new SmartContractQueriesAdapter({ + const adapter = new QueryRunnerAdapter({ networkProvider: new MockNetworkProvider(), }); const controller = new SmartContractQueriesController({ diff --git a/src/smartContractQueriesController.ts b/src/smartContractQueriesController.ts index aceb1b57..b676b09c 100644 --- a/src/smartContractQueriesController.ts +++ b/src/smartContractQueriesController.ts @@ -1,5 +1,4 @@ import { Err } from "./errors"; -import { IAddress } from "./interface"; import { IContractQueryResponse } from "./interfaceOfNetwork"; import { SmartContractQuery, SmartContractQueryResponse } from "./smartContractQuery"; import { ArgSerializer, ContractFunction, EndpointDefinition, NativeSerializer, ResultsParser } from "./smartcontracts"; @@ -8,21 +7,8 @@ interface IAbi { getEndpoint(name: string | ContractFunction): EndpointDefinition; } -interface INetworkProvider { - queryContract(query: ILegacyQuery): Promise; -} - -interface ILegacyQuery { - address: IAddress; - caller?: IAddress; - func: { toString(): string }; - value?: { toString(): string }; - getEncodedArguments(): string[]; -} - interface IQueryRunner { - networkProvider: INetworkProvider; - queryContract(query: SmartContractQuery): Promise; + runQuery(query: SmartContractQuery): Promise; } export class SmartContractQueriesController { @@ -96,7 +82,7 @@ export class SmartContractQueriesController { } async runQuery(query: SmartContractQuery): Promise { - const queryResponse = await this.queryRunner.queryContract(query); + const queryResponse = await this.queryRunner.runQuery(query); return queryResponse; }