Skip to content

Commit

Permalink
feat(connector-besu): common interface invoke-contract
Browse files Browse the repository at this point in the history
Signed-off-by: AzaharaC <[email protected]>
  • Loading branch information
AzaharaC authored and petermetz committed Mar 24, 2021
1 parent fea547f commit ee93120
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import {
DeployContractSolidityBytecodeV1Response,
EthContractInvocationType,
InvokeContractV1Request,
InvokeContractV1Response,
InvokeContractV2Request,
InvokeContractV1Response,
InvokeContractV2Response,
RunTransactionRequest,
RunTransactionResponse,
Expand Down Expand Up @@ -298,19 +298,24 @@ export class PluginLedgerConnectorBesu
const payload = (method.send as any).request();
const { params } = payload;
const [transactionConfig] = params;
if (req.gas == undefined) {
req.gas = await this.web3.eth.estimateGas(transactionConfig);
}
transactionConfig.from = web3SigningCredential.ethAccount;
transactionConfig.gas = req.gas;
transactionConfig.gasPrice = req.gasPrice;
transactionConfig.value = req.value;
transactionConfig.nonce = req.nonce;
const txReq: RunTransactionRequest = {
transactionConfig,
web3SigningCredential,
timeoutMs: req.timeoutMs || 60000,
};
const out = await this.transact(txReq);
const transactionReceipt = out.transactionReceipt;
const success = true;
return { success, transactionReceipt };
//const transactionReceipt = out.transactionReceipt;
const success = out.transactionReceipt.status;
const data = { success, out };
return data;
} else {
throw new Error(
`${fnTag} Unsupported invocation type ${req.invocationType}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu";

import OAS from "../../json/openapi.json";

export interface IInvokeContractEndpointOptions {
export interface IInvokeContractEndpointV2Options {
logLevel?: LogLevelDesc;
connector: PluginLedgerConnectorBesu;
}

export class InvokeContractEndpointV2 implements IWebServiceEndpoint {
public static readonly CLASS_NAME = "InvokeContractV2Endpoint";
public static readonly CLASS_NAME = "InvokeContractEndpointV2";

private readonly log: Logger;

public get className(): string {
return InvokeContractEndpointV2.CLASS_NAME;
}

constructor(public readonly options: IInvokeContractEndpointOptions) {
constructor(public readonly options: IInvokeContractEndpointV2Options) {
const fnTag = `${this.className}#constructor()`;
Checks.truthy(options, `${fnTag} arg options`);
Checks.truthy(options.connector, `${fnTag} arg options.connector`);
Expand Down
Loading

0 comments on commit ee93120

Please sign in to comment.