From 49d62e347c5193be4b0ad6b3b4031a1c9b17c4b5 Mon Sep 17 00:00:00 2001 From: jagpreetsinghsasan Date: Wed, 3 Apr 2024 11:54:11 +0530 Subject: [PATCH] feat(connector): remove keychain dependency Primary Changes --------------- 1. Updated besu, ethereum, quorum and xdai connectors to remove hard dependencies on keychain Changes required to incorporate 1) 2. Updated openapi.json file of the above mentioned connectors to include the new no-keychain endpoints 3. Generated code and updated related web-services for the same Fixes #963 Signed-off-by: jagpreetsinghsasan --- .../src/main/json/openapi.json | 67 +++ .../generated/openapi/typescript-axios/api.ts | 67 +++ .../plugin-ledger-connector-besu.ts | 78 +++ ...loy-contract-from-json-no-keychain.test.ts | 492 ++++++++++++++++++ ...private-deploy-contract-from-json.test.ts} | 0 .../src/main/json/openapi.json | 87 +++- .../generated/openapi/typescript-axios/api.ts | 114 +++- .../plugin-ledger-connector-ethereum.ts | 43 +- ...deploy-contract-no-keychain-v1-endpoint.ts | 113 ++++ ...-deploy-and-invoke-no-keychain-v1.test.ts} | 12 +- .../src/main/json/openapi.json | 18 +- .../generated/openapi/typescript-axios/api.ts | 96 ++-- .../plugin-ledger-connector-quorum.ts | 20 +- ...solidity-bytecode-endpoint-no-keychain.ts} | 18 +- ...> invoke-contract-endpoint-no-keychain.ts} | 12 +- .../openapi-validation-no-keychain.test.ts | 28 +- ...m-json-json-no-keychain-endpoints.test.ts} | 2 +- ...oy-contract-from-json-no-keychain.test.ts} | 2 +- ...ke-contract-no-keychain-endpoints.test.ts} | 2 +- ...2.3.0-invoke-contract-no-keychain.test.ts} | 2 +- ...t-from-json-no-keychain-endpoints.test.ts} | 2 +- ...oy-contract-from-json-no-keychain.test.ts} | 2 +- ...ke-contract-no-keychain-endpoints.test.ts} | 2 +- ...1.4.1-invoke-contract-no-keychain.test.ts} | 2 +- .../src/main/json/openapi.json | 20 +- .../generated/openapi/typescript-axios/api.ts | 94 ++-- .../plugin-ledger-connector-xdai.ts | 24 +- ...solidity-bytecode-no-keychain-endpoint.ts} | 20 +- ...> invoke-contract-no-keychain-endpoint.ts} | 20 +- ...ntract-from-json-xdai-no-keychain.test.ts} | 16 +- ... invoke-contract-xdai-no-keychain.test.ts} | 16 +- .../openapi-validation-no-keychain.test.ts | 34 +- 32 files changed, 1258 insertions(+), 267 deletions(-) create mode 100644 packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json-no-keychain.test.ts rename packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/{private-deploy-contract-from-json-cactus.test.ts => private-deploy-contract-from-json.test.ts} (100%) create mode 100644 packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/deploy-contract-no-keychain-v1-endpoint.ts rename packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/{geth-contract-deploy-and-invoke-using-json-object-v1.test.ts => geth-contract-deploy-and-invoke-no-keychain-v1.test.ts} (97%) rename packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/{deploy-contract-solidity-bytecode-endpoint-json-object.ts => deploy-contract-solidity-bytecode-endpoint-no-keychain.ts} (83%) rename packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/{invoke-contract-endpoint-json-object.ts => invoke-contract-endpoint-no-keychain.ts} (88%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts => v2.3.0-deploy-contract-from-json-json-no-keychain-endpoints.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v2.3.0-deploy-contract-from-json-json-object.test.ts => v2.3.0-deploy-contract-from-json-no-keychain.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v2.3.0-invoke-contract-json-object-endpoints.test.ts => v2.3.0-invoke-contract-no-keychain-endpoints.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v2.3.0-invoke-contract-json-object.test.ts => v2.3.0-invoke-contract-no-keychain.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts => v21.4.1-deploy-contract-from-json-no-keychain-endpoints.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v21.4.1-deploy-contract-from-json-json-object.test.ts => v21.4.1-deploy-contract-from-json-no-keychain.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v21.4.1-invoke-contract-json-object-endpoints.test.ts => v21.4.1-invoke-contract-no-keychain-endpoints.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/{v21.4.1-invoke-contract-json-object.test.ts => v21.4.1-invoke-contract-no-keychain.test.ts} (99%) rename packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/{deploy-contract-solidity-bytecode-json-object-endpoint.ts => deploy-contract-solidity-bytecode-no-keychain-endpoint.ts} (81%) rename packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/{invoke-contract-json-object-endpoint.ts => invoke-contract-no-keychain-endpoint.ts} (80%) rename packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/{deploy-contract-from-json-xdai-json-object.test.ts => deploy-contract-from-json-xdai-no-keychain.test.ts} (95%) rename packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/{invoke-contract-xdai-json-object.test.ts => invoke-contract-xdai-no-keychain.test.ts} (95%) diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json index 73f3a57fccd..1f16d937f33 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json @@ -752,6 +752,73 @@ } } }, + "DeployContractSolidityBytecodeNoKeychainV1Request": { + "type": "object", + "required": [ + "contractName", + "contractAbi", + "contractJson", + "bytecode", + "web3SigningCredential", + "keychainId", + "constructorArgs" + ], + "additionalProperties": false, + "properties": { + "contractName": { + "type": "string", + "description": "The contract name for retrieve the contracts json on the keychain.", + "minLength": 1, + "maxLength": 100, + "nullable": false + }, + "contractAbi": { + "description": "The application binary interface of the solidity contract", + "type": "array", + "items": {}, + "nullable": false + }, + "contractJSONString": { + "description": "For use when not using keychain, pass the contract in as this string variable", + "nullable": false, + "type": "string" + }, + "constructorArgs": { + "type": "array", + "items": {}, + "default": [] + }, + "web3SigningCredential": { + "$ref": "#/components/schemas/Web3SigningCredential", + "nullable": false + }, + "bytecode": { + "type": "string", + "nullable": false, + "minLength": 1, + "maxLength": 24576, + "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" + }, + "gas": { + "type": "number", + "nullable": false + }, + "gasPrice": { + "type": "string", + "nullable": false + }, + "timeoutMs": { + "type": "number", + "description": "The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing.", + "minimum": 0, + "default": 60000, + "nullable": false + }, + "privateTransactionConfig": { + "$ref": "#/components/schemas/BesuPrivateTransactionConfig" + } + } + }, "DeployContractSolidityBytecodeV1Response": { "type": "object", "required": ["transactionReceipt"], diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts index cc33fe0a580..e833fd82bcf 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -132,6 +132,73 @@ export interface ConsistencyStrategy { } +/** + * + * @export + * @interface DeployContractSolidityBytecodeNoKeychainV1Request + */ +export interface DeployContractSolidityBytecodeNoKeychainV1Request { + /** + * The contract name for retrieve the contracts json on the keychain. + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'contractName': string; + /** + * The application binary interface of the solidity contract + * @type {Array} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'contractAbi': Array; + /** + * For use when not using keychain, pass the contract in as this string variable + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'contractJSONString'?: string; + /** + * + * @type {Array} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'constructorArgs': Array; + /** + * + * @type {Web3SigningCredential} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'web3SigningCredential': Web3SigningCredential; + /** + * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'bytecode': string; + /** + * + * @type {number} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'gas'?: number; + /** + * + * @type {string} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'gasPrice'?: string; + /** + * The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing. + * @type {number} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'timeoutMs'?: number; + /** + * + * @type {BesuPrivateTransactionConfig} + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request + */ + 'privateTransactionConfig'?: BesuPrivateTransactionConfig; +} /** * * @export diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts index a562b15a44c..27b5804e8b8 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/plugin-ledger-connector-besu.ts @@ -18,6 +18,7 @@ import Web3JsQuorum, { IWeb3Quorum } from "web3js-quorum"; import { Contract, ContractSendMethod } from "web3-eth-contract"; import { TransactionReceipt } from "web3-eth"; import { + DeployContractSolidityBytecodeNoKeychainV1Request, GetBalanceV1Request, GetBalanceV1Response, Web3TransactionReceipt, @@ -912,6 +913,83 @@ export class PluginLedgerConnectorBesu return deployResponse; } + public async deployContractNoKeychain( + req: DeployContractSolidityBytecodeNoKeychainV1Request, + ): Promise { + const fnTag = `${this.className}#deployContract()`; + Checks.truthy(req, `${fnTag} req`); + if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { + throw new Error(`${fnTag} Cannot deploy contract with pre-signed TX`); + } + const { contractName, contractJSONString } = req; + const networkId = await this.web3.eth.net.getId(); + + const tmpContract = new this.web3.eth.Contract(req.contractAbi); + const deployment = tmpContract.deploy({ + data: req.bytecode, + arguments: req.constructorArgs, + }); + + const abi = deployment.encodeABI(); + const data = abi.startsWith("0x") ? abi : `0x${abi}`; + this.log.debug(`Deploying "${req.contractName}" with data %o`, data); + + const web3SigningCredential = req.web3SigningCredential as + | Web3SigningCredentialPrivateKeyHex + | Web3SigningCredentialCactusKeychainRef; + + const runTxResponse = await this.transact({ + transactionConfig: { + data, + from: web3SigningCredential.ethAccount, + gas: req.gas, + gasPrice: req.gasPrice, + }, + consistencyStrategy: { + blockConfirmations: 0, + receiptType: ReceiptType.NodeTxPoolAck, + timeoutMs: req.timeoutMs || 60000, + }, + web3SigningCredential, + privateTransactionConfig: req.privateTransactionConfig, + }); + + const { transactionReceipt: receipt } = runTxResponse; + const { status, contractAddress } = receipt; + + Checks.truthy(status, `${this.className}#deployContract():status`); + + Checks.truthy( + contractAddress, + `${this.className}#deployContract():contractAddress`, + ); + + if (contractJSONString) { + const networkInfo = { address: contractAddress }; + const contractJSON = JSON.parse(contractJSONString); + this.log.debug("Contract JSON: \n%o", JSON.stringify(contractJSON)); + const contract = new this.web3.eth.Contract( + contractJSON.abi, + contractAddress || " ", + ); + this.contracts[contractName] = contract; + const network = { [networkId]: networkInfo }; + contractJSON.networks = network; + } else { + const errorMessage = + `${fnTag} Cannot create an instance of the contract instance because` + + `the contractName in the request does not exist on the keychain`; + throw new createHttpError[400](errorMessage); + } + + // creating solidity byte code response + const deployResponse: DeployContractSolidityBytecodeV1Response = { + transactionReceipt: runTxResponse.transactionReceipt, + }; + + return deployResponse; + } + public async signTransaction( req: SignTransactionRequest, ): Promise> { diff --git a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json-no-keychain.test.ts b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json-no-keychain.test.ts new file mode 100644 index 00000000000..0291a183a2c --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json-no-keychain.test.ts @@ -0,0 +1,492 @@ +import test, { Test } from "tape-promise/tape"; +import { v4 as uuidv4 } from "uuid"; +import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json"; +import Web3 from "web3"; +import Web3JsQuorum, { IPrivateTransactionReceipt } from "web3js-quorum"; +import { BesuMpTestLedger } from "@hyperledger/cactus-test-tooling"; +import { LogLevelDesc } from "@hyperledger/cactus-common"; +import { + EthContractInvocationType, + PluginFactoryLedgerConnector, + Web3SigningCredentialType, +} from "../../../../../main/typescript"; +import { PluginImportType } from "@hyperledger/cactus-core-api"; +import { PluginRegistry } from "@hyperledger/cactus-core"; + +const containerImageName = + "ghcr.io/hyperledger/cactus-besu-all-in-one-multi-party"; +const containerImageTag = "2023-08-08-pr-2596"; +const testCase = "Executes private transactions on Hyperledger Besu"; +const logLevel: LogLevelDesc = "TRACE"; + +const doctorCactusHex = + "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d446f63746f722043616374757300000000000000000000000000000000000000"; + +// WARNING: the keys here are demo purposes ONLY. Please use a tool like Orchestrate or EthSigner for production, rather than hard coding private keys +const keysStatic = { + tessera: { + member1: { + publicKey: "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=", + }, + member2: { + publicKey: "QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=", + }, + member3: { + publicKey: "1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=", + }, + }, + besu: { + member1: { + url: "http://127.0.0.1:20000", + wsUrl: "ws://127.0.0.1:20001", + privateKey: + "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63", + }, + member2: { + url: "http://127.0.0.1:20002", + wsUrl: "ws://127.0.0.1:20003", + privateKey: + "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3", + }, + member3: { + url: "http://127.0.0.1:20004", + wsUrl: "ws://127.0.0.1:20005", + privateKey: + "ae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f", + }, + ethsignerProxy: { + url: "http://127.0.0.1:18545", + accountAddress: "9b790656b9ec0db1936ed84b3bea605873558198", + }, + }, +}; + +test(testCase, async (t: Test) => { + // At development time one can specify this environment variable if there is + // a multi-party network already running, which is doable with something like + // this on the terminal: + // docker run --rm --privileged --publish 2222:22 --publish 3000:3000 --publish 8545:8545 --publish 8546:8546 --publish 9001:9001 --publish 9081:9081 --publish 9082:9082 --publish 9083:9083 --publish 9090:9090 --publish 18545:18545 --publish 20000:20000 --publish 20001:20001 --publish 20002:20002 --publish 20003:20003 --publish 20004:20004 --publish 20005:20005 --publish 25000:25000 petermetz/cactus-besu-multi-party-all-in-one:0.1.2 + // + // The upside of this approach is that a new container is not launched from + // scratch for every test execution which enables faster iteration. + const preWarmedLedger = process.env.CACTUS_TEST_PRE_WARMED_LEDGER === "true"; + + let keys: any; + if (preWarmedLedger) { + keys = keysStatic; + } else { + const ledger = new BesuMpTestLedger({ + logLevel, + imageName: containerImageName, + imageTag: containerImageTag, + emitContainerLogs: false, + }); + test.onFinish(() => ledger.stop()); + await ledger.start(); + keys = await ledger.getKeys(); + } + + const rpcApiHttpHostMember1 = keys.besu.member1.url; + const rpcApiHttpHostMember2 = keys.besu.member2.url; + const rpcApiHttpHostMember3 = keys.besu.member3.url; + + const rpcApiWsHostMember1 = keys.besu.member1.wsUrl; + const rpcApiWsHostMember2 = keys.besu.member2.wsUrl; + const rpcApiWsHostMember3 = keys.besu.member3.wsUrl; + + const web3Member1 = new Web3(rpcApiHttpHostMember1); + const web3Member2 = new Web3(rpcApiHttpHostMember2); + const web3Member3 = new Web3(rpcApiHttpHostMember3); + + const pluginRegistry1 = new PluginRegistry(); + const pluginRegistry2 = new PluginRegistry(); + const pluginRegistry3 = new PluginRegistry(); + + const pluginFactoryLedgerConnector = new PluginFactoryLedgerConnector({ + pluginImportType: PluginImportType.Local, + }); + + const connectorInstanceId1 = "besu1_" + uuidv4(); + const connectorInstanceId2 = "besu2_" + uuidv4(); + const connectorInstanceId3 = "besu3_" + uuidv4(); + + const connector1 = await pluginFactoryLedgerConnector.create({ + instanceId: connectorInstanceId1, + pluginRegistry: pluginRegistry1, + rpcApiHttpHost: rpcApiHttpHostMember1, + rpcApiWsHost: rpcApiWsHostMember1, + logLevel, + }); + t.ok(connector1, "connector1 truthy OK"); + test.onFinish(() => connector1.shutdown()); + pluginRegistry1.add(connector1); + + const connector2 = await pluginFactoryLedgerConnector.create({ + instanceId: connectorInstanceId2, + pluginRegistry: pluginRegistry2, + rpcApiHttpHost: rpcApiHttpHostMember2, + rpcApiWsHost: rpcApiWsHostMember2, + logLevel, + }); + t.ok(connector2, "connector2 truthy OK"); + test.onFinish(() => connector2.shutdown()); + pluginRegistry2.add(connector2); + + const connector3 = await pluginFactoryLedgerConnector.create({ + instanceId: connectorInstanceId3, + pluginRegistry: pluginRegistry3, + rpcApiHttpHost: rpcApiHttpHostMember3, + rpcApiWsHost: rpcApiWsHostMember3, + logLevel, + }); + t.ok(connector3, "connector3 truthy OK"); + test.onFinish(() => connector3.shutdown()); + pluginRegistry3.add(connector3); + + await connector1.onPluginInit(); + await connector2.onPluginInit(); + await connector3.onPluginInit(); + + const chainIdMember1 = await web3Member1.eth.getChainId(); + t.comment(`chainIdMember1=${chainIdMember1}`); + const chainIdMember2 = await web3Member2.eth.getChainId(); + t.comment(`chainIdMember2=${chainIdMember2}`); + const chainIdMember3 = await web3Member3.eth.getChainId(); + t.comment(`chainIdMember3=${chainIdMember3}`); + + const web3QuorumMember1 = Web3JsQuorum(web3Member1); + t.ok(web3QuorumMember1, "web3QuorumMember1 truthy OK"); + + const web3QuorumMember2 = Web3JsQuorum(web3Member2); + t.ok(web3QuorumMember2, "web3QuorumMember2 truthy OK"); + + const web3QuorumMember3 = Web3JsQuorum(web3Member3); + t.ok(web3QuorumMember3, "web3QuorumMember3 truthy OK"); + + const deployRes = await connector1.deployContractNoKeychain({ + bytecode: HelloWorldContractJson.bytecode, + contractAbi: HelloWorldContractJson.abi, + contractName: HelloWorldContractJson.contractName, + constructorArgs: [], + privateTransactionConfig: { + privateFrom: keys.tessera.member1.publicKey, + privateFor: [ + keys.tessera.member1.publicKey, + keys.tessera.member2.publicKey, + ], + }, + web3SigningCredential: { + secret: keys.besu.member1.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + contractJSONString: JSON.stringify(HelloWorldContractJson), + gas: 3000000, + }); + + t.ok(deployRes, "deployRes truthy OK"); + t.ok(deployRes.transactionReceipt, "deployRes.transactionReceipt truthy OK"); + t.ok( + deployRes.transactionReceipt.contractAddress, + "deployRes.transactionReceipt.contractAddress truthy OK", + ); + t.ok( + deployRes.transactionReceipt.commitmentHash, + "deployRes.transactionReceipt.commitmentHash truthy OK", + ); + + // t.ok(deployRes.status, "deployRes.status truthy OK"); + // t.equal(deployRes.status, 200, "deployRes.status === 200 OK"); + // t.ok(deployRes.data, "deployRes.data truthy OK"); + // t.ok( + // deployRes.data.transactionReceipt, + // "deployRes.data.transactionReceipt truthy OK", + // ); + + // t.ok(privacyMarkerTxHash, "privacyMarkerTxHash truthy OK"); + + const contractDeployReceipt = + (await web3QuorumMember1.priv.waitForTransactionReceipt( + deployRes.transactionReceipt.commitmentHash, + )) as IPrivateTransactionReceipt; + + t.ok(contractDeployReceipt, "contractDeployReceipt truthy OK"); + const receipt = contractDeployReceipt as IPrivateTransactionReceipt; + + const { contractAddress } = receipt; + t.comment(`Private contract address: ${contractAddress}`); + t.ok(contractAddress, "contractAddress truthy OK"); + + // Check that the third node does not see the transaction of the contract + // deployment that was sent to node 1 and 2 only, not 3. + const txReceiptNever = await web3QuorumMember3.priv.waitForTransactionReceipt( + deployRes.transactionReceipt.commitmentHash, + ); + t.notok(txReceiptNever, "txReceiptNever falsy OK"); + + // Check that node 1 and 2 can indeed see the transaction for the contract + // deployment that was sent to them and them only (node 3 was left out) + + // Note that changing this to use web3QuorumMember3 breaks it and I'm suspecting + // that this is what's plaguing the tests that are based on the connector + // which is instantiated with a single web3+web3 Quorum client. + // What I will try next is to have 3 connectors each with a web3 Quorum client + // that points to one of the 3 nodes and see if that makes it work. + const txReceiptAlways1 = + await web3QuorumMember1.priv.waitForTransactionReceipt( + deployRes.transactionReceipt.commitmentHash, + ); + t.ok(txReceiptAlways1, "txReceiptAlways1 truthy OK"); + + const txReceiptAlways2 = + await web3QuorumMember2.priv.waitForTransactionReceipt( + deployRes.transactionReceipt.commitmentHash, + ); + t.ok(txReceiptAlways2, "txReceiptAlways2 truthy OK"); + + const contract = new web3Member1.eth.Contract( + HelloWorldContractJson.abi as never, + ); + + { + t.comment("Checking if member1 can call setName()"); + const data = contract.methods.setName("ProfessorCactus - #1").encodeABI(); + const functionParams = { + to: contractDeployReceipt.contractAddress, + data, + privateFrom: keys.tessera.member1.publicKey, + privateFor: [keys.tessera.member2.publicKey], + privateKey: keys.besu.member1.privateKey, + }; + const transactionHash = + await web3QuorumMember1.priv.generateAndSendRawTransaction( + functionParams, + ); + t.comment(`Transaction hash: ${transactionHash}`); + t.ok(transactionHash, "transactionHash truthy OK"); + + const result = + await web3QuorumMember1.priv.waitForTransactionReceipt(transactionHash); + t.comment(`Transaction receipt for set() call: ${JSON.stringify(result)}`); + t.ok(result, "set() result member 1 truthy OK"); + } + + { + t.comment("Checking if member1 can see new name via getName()"); + const data = contract.methods.getName().encodeABI(); + const fnParams = { + to: contractDeployReceipt.contractAddress, + data, + privateFrom: keys.tessera.member1.publicKey, + privateFor: [keys.tessera.member2.publicKey], + privateKey: keys.besu.member1.privateKey, + }; + + const privacyGroupId = + web3QuorumMember1.utils.generatePrivacyGroup(fnParams); + const callOutput = await web3QuorumMember1.priv.call(privacyGroupId, { + to: contractDeployReceipt.contractAddress, + data: contract.methods.getName().encodeABI(), + }); + t.comment(`getName Call output: ${JSON.stringify(callOutput)}`); + t.ok(callOutput, "callOutput truthy OK"); + const name = web3Member1.eth.abi.decodeParameter("string", callOutput); + t.equal(name, "ProfessorCactus - #1", "getName() member 1 equals #1"); + } + + { + // Member 3 cannot see into the privacy group of 1 and 2 so the getName + // will not return the value that was set earlier in that privacy group. + t.comment("Checking if member3 can see new name via getName()"); + const data = contract.methods.getName().encodeABI(); + const fnParams = { + to: contractDeployReceipt.contractAddress, + data, + privateFrom: keys.tessera.member1.publicKey, + privateFor: [keys.tessera.member2.publicKey], + privateKey: keys.besu.member3.privateKey, + }; + + const privacyGroupId = + web3QuorumMember3.utils.generatePrivacyGroup(fnParams); + const callOutput = await web3QuorumMember3.priv.call(privacyGroupId, { + to: contractDeployReceipt.contractAddress, + data, + }); + t.comment(`getName member3 output: ${JSON.stringify(callOutput)}`); + t.equal(callOutput, "0x", "member3 getName callOutput === 0x OK"); + } + + { + const data = contract.methods.setName("ProfessorCactus - #2").encodeABI(); + t.comment("Checking if member2 can call setName()"); + const functionParams = { + to: contractDeployReceipt.contractAddress, + data, + privateFrom: keys.tessera.member2.publicKey, + privateFor: [keys.tessera.member2.publicKey], + privateKey: keys.besu.member2.privateKey, + }; + const transactionHash = + await web3QuorumMember2.priv.generateAndSendRawTransaction( + functionParams, + ); + t.comment(`Transaction hash: ${transactionHash}`); + t.ok(transactionHash, "transactionHash truthy OK"); + + const result = + await web3QuorumMember2.priv.waitForTransactionReceipt(transactionHash); + t.comment(`Transaction receipt for set() call: ${JSON.stringify(result)}`); + t.ok(result, "set() result member 2 truthy OK"); + } + + { + const data = contract.methods.setName("ProfessorCactus - #3").encodeABI(); + t.comment("Checking if member3 can call setName()"); + const functionParams = { + to: contractDeployReceipt.contractAddress, + data, + privateFrom: keys.tessera.member3.publicKey, + privateKey: keys.besu.member3.privateKey, + privateFor: [keys.tessera.member2.publicKey], + }; + const transactionHash = + await web3QuorumMember3.priv.generateAndSendRawTransaction( + functionParams, + ); + t.comment(`setName tx hash for member 3: ${transactionHash}`); + t.ok(transactionHash, "setName tx hash for member 3 truthy OK"); + + const result = + await web3QuorumMember3.priv.waitForTransactionReceipt(transactionHash); + t.comment(`Transaction receipt for set() call: ${JSON.stringify(result)}`); + t.ok(result, "set() result for member 3 truthy OK"); + } + + { + t.comment("Checking that private contract cannot be called anonymously"); + const contractInvocationNoPrivTxConfig = connector1.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress: contractDeployReceipt.contractAddress, + invocationType: EthContractInvocationType.Call, + gas: 3000000, + methodName: "getName", + params: [], + signingCredential: { + secret: "incorrect-secret", + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + await t.rejects( + contractInvocationNoPrivTxConfig, + /Returned values aren't valid, did it run Out of Gas\? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced\./, + "private contract call fails without Besu member credentials OK", + ); + } + + { + t.comment("Ensuring member1 can call setName() via connector"); + const res = await connector1.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress: contractDeployReceipt.contractAddress, + invocationType: EthContractInvocationType.Send, + gas: 3000000, + methodName: "setName", + params: ["Doctor Cactus"], + privateTransactionConfig: { + privateFrom: keys.tessera.member1.publicKey, + privateFor: [keys.tessera.member2.publicKey], + }, + signingCredential: { + secret: keys.besu.member1.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + + t.equal(res.success, "0x1", "member1 setName callOutput === 0x1 OK"); + } + + { + t.comment( + "Ensuring member1 can call getName() and receive correct value after setName call", + ); + const res = await connector1.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress: contractDeployReceipt.contractAddress, + invocationType: EthContractInvocationType.Call, + gas: 3000000, + methodName: "getName", + params: [], + privateTransactionConfig: { + privateFrom: keys.tessera.member1.publicKey, + privateFor: [keys.tessera.member2.publicKey], + }, + signingCredential: { + secret: keys.besu.member1.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + + t.equals( + res.callOutput, + doctorCactusHex, + "member1 getName callOutput === DoctorCactus", + ); + } + + { + t.comment( + "Ensuring member2 can call getName() and receive correct value after setName call", + ); + const res = await connector2.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress: contractDeployReceipt.contractAddress, + invocationType: EthContractInvocationType.Call, + gas: 3000000, + methodName: "getName", + params: [], + privateTransactionConfig: { + privateFrom: keys.tessera.member1.publicKey, + privateFor: [keys.tessera.member2.publicKey], + }, + signingCredential: { + secret: keys.besu.member1.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + + t.equals( + res.callOutput, + doctorCactusHex, + "member2 getName callOutput === DoctorCactus", + ); + } + + { + t.comment("Checking if member3 can call getName() via connector"); + const res = await connector3.invokeContract({ + contractName: HelloWorldContractJson.contractName, + contractAbi: HelloWorldContractJson.abi, + contractAddress: contractDeployReceipt.contractAddress, + invocationType: EthContractInvocationType.Call, + gas: 3000000, + methodName: "getName", + params: [], + privateTransactionConfig: { + privateFrom: keys.tessera.member1.publicKey, + privateFor: [keys.tessera.member2.publicKey], + }, + signingCredential: { + secret: keys.besu.member3.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + }); + + t.equal(res.callOutput, "0x", "member3 getName callOutput === 0x OK"); + } + + t.end(); +}); diff --git a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json-cactus.test.ts b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json.test.ts similarity index 100% rename from packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json-cactus.test.ts rename to packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/private-deploy-contract-from-json.test.ts diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-ethereum/src/main/json/openapi.json index 0ce13c9492a..1292740357c 100644 --- a/packages/cactus-plugin-ledger-connector-ethereum/src/main/json/openapi.json +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/main/json/openapi.json @@ -447,18 +447,41 @@ "nullable": false }, "contract": { - "oneOf": [ - { - "$ref": "#/components/schemas/ContractJsonDefinition", - "description": "Send contract ABI directly in the request." - }, - { - "$ref": "#/components/schemas/ContractKeychainDefinition", - "description": "Read contract definition from the keychain plugin." - } - ], + "$ref": "#/components/schemas/ContractKeychainDefinition", + "description": "Send contract ABI directly in the request.", + "nullable": false + }, + "constructorArgs": { + "description": "The list of arguments to pass in to the constructor of the contract being deployed.", + "type": "array", + "default": [], + "items": {} + }, + "gasConfig": { + "$ref": "#/components/schemas/GasTransactionConfig", "nullable": false }, + "value": { + "type": "string", + "description": "Ether balance to send on deployment.", + "nullable": false + } + } + }, + "DeployContractNoKeychainV1Request": { + "type": "object", + "required": ["web3SigningCredential", "contract"], + "additionalProperties": false, + "properties": { + "web3SigningCredential": { + "$ref": "#/components/schemas/Web3SigningCredential", + "nullable": false + }, + "contract": { + "$ref": "#/components/schemas/ContractJsonDefinition", + "description": "Send contract ABI directly in the request.", + "nullable": false + }, "constructorArgs": { "description": "The list of arguments to pass in to the constructor of the contract being deployed.", "type": "array", @@ -971,6 +994,50 @@ } } }, + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain": { + "post": { + "x-hyperledger-cacti": { + "http": { + "verbLowerCase": "post", + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain" + } + }, + "operationId": "deployContractNoKeychain", + "summary": "Deploys the contract to ethereum ledger without keychain.", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeployContractNoKeychainV1Request" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RunTransactionResponse" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorExceptionResponseV1" + } + } + } + } + } + } + }, "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/run-transaction": { "post": { "x-hyperledger-cacti": { diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/generated/openapi/typescript-axios/api.ts index 43057a25899..83de012ac4a 100644 --- a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -142,6 +142,43 @@ export interface ContractKeychainDefinition { */ 'keychainId': string; } +/** + * + * @export + * @interface DeployContractNoKeychainV1Request + */ +export interface DeployContractNoKeychainV1Request { + /** + * + * @type {Web3SigningCredential} + * @memberof DeployContractNoKeychainV1Request + */ + 'web3SigningCredential': Web3SigningCredential; + /** + * + * @type {ContractJsonDefinition} + * @memberof DeployContractNoKeychainV1Request + */ + 'contract': ContractJsonDefinition; + /** + * The list of arguments to pass in to the constructor of the contract being deployed. + * @type {Array} + * @memberof DeployContractNoKeychainV1Request + */ + 'constructorArgs'?: Array; + /** + * + * @type {GasTransactionConfig} + * @memberof DeployContractNoKeychainV1Request + */ + 'gasConfig'?: GasTransactionConfig; + /** + * Ether balance to send on deployment. + * @type {string} + * @memberof DeployContractNoKeychainV1Request + */ + 'value'?: string; +} /** * * @export @@ -156,10 +193,10 @@ export interface DeployContractV1Request { 'web3SigningCredential': Web3SigningCredential; /** * - * @type {DeployContractV1RequestContract} + * @type {ContractKeychainDefinition} * @memberof DeployContractV1Request */ - 'contract': DeployContractV1RequestContract; + 'contract': ContractKeychainDefinition; /** * The list of arguments to pass in to the constructor of the contract being deployed. * @type {Array} @@ -179,12 +216,6 @@ export interface DeployContractV1Request { */ 'value'?: string; } -/** - * @type DeployContractV1RequestContract - * @export - */ -export type DeployContractV1RequestContract = ContractJsonDefinition | ContractKeychainDefinition; - /** * * @export @@ -1269,6 +1300,40 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati options: localVarRequestOptions, }; }, + /** + * + * @summary Deploys the contract to ethereum ledger without keychain. + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deployContractNoKeychain: async (deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(deployContractNoKeychainV1Request, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, /** * * @summary Get the Prometheus Metrics @@ -1456,6 +1521,17 @@ export const DefaultApiFp = function(configuration?: Configuration) { const localVarAxiosArgs = await localVarAxiosParamCreator.deployContract(deployContractV1Request, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, + /** + * + * @summary Deploys the contract to ethereum ledger without keychain. + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async deployContractNoKeychain(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractNoKeychain(deployContractNoKeychainV1Request, options); + return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); + }, /** * * @summary Get the Prometheus Metrics @@ -1530,6 +1606,16 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa deployContract(deployContractV1Request?: DeployContractV1Request, options?: any): AxiosPromise { return localVarFp.deployContract(deployContractV1Request, options).then((request) => request(axios, basePath)); }, + /** + * + * @summary Deploys the contract to ethereum ledger without keychain. + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + deployContractNoKeychain(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: any): AxiosPromise { + return localVarFp.deployContractNoKeychain(deployContractNoKeychainV1Request, options).then((request) => request(axios, basePath)); + }, /** * * @summary Get the Prometheus Metrics @@ -1601,6 +1687,18 @@ export class DefaultApi extends BaseAPI { return DefaultApiFp(this.configuration).deployContract(deployContractV1Request, options).then((request) => request(this.axios, this.basePath)); } + /** + * + * @summary Deploys the contract to ethereum ledger without keychain. + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public deployContractNoKeychain(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: AxiosRequestConfig) { + return DefaultApiFp(this.configuration).deployContractNoKeychain(deployContractNoKeychainV1Request, options).then((request) => request(this.axios, this.basePath)); + } + /** * * @summary Get the Prometheus Metrics diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts index 551baf07fba..95ad2af3697 100644 --- a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts @@ -39,6 +39,7 @@ import { } from "@hyperledger/cactus-common"; import { DeployContractEndpoint } from "./web-services/deploy-contract-v1-endpoint"; +import { DeployContractNoKeychainEndpoint } from "./web-services/deploy-contract-no-keychain-v1-endpoint"; import { DeployContractV1Request, @@ -60,6 +61,7 @@ import { ContractKeychainDefinition, GasTransactionConfig, ContractJSON, + DeployContractNoKeychainV1Request, } from "./generated/openapi/typescript-axios"; import { RunTransactionEndpoint } from "./web-services/run-transaction-v1-endpoint"; @@ -73,7 +75,6 @@ import { InvokeRawWeb3EthMethodEndpoint } from "./web-services/invoke-raw-web3et import { InvokeRawWeb3EthContractEndpoint } from "./web-services/invoke-raw-web3eth-contract-v1-endpoint"; import { - isContractJsonDefinition, isContractKeychainDefinition, isDeployedContractJsonDefinition, isGasTransactionConfigEIP1559, @@ -369,6 +370,13 @@ export class PluginLedgerConnectorEthereum }); endpoints.push(endpoint); } + { + const endpoint = new DeployContractNoKeychainEndpoint({ + connector: this, + logLevel: this.options.logLevel, + }); + endpoints.push(endpoint); + } { const endpoint = new RunTransactionEndpoint({ connector: this, @@ -946,24 +954,25 @@ export class PluginLedgerConnectorEthereum if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { throw new Error(`Cannot deploy contract with pre-signed TX`); } + return this.deployContractFromKeychain(req, req.contract); + } - if (isContractJsonDefinition(req.contract)) { - return this.runContractDeployment({ - web3SigningCredential: req.web3SigningCredential, - gasConfig: req.gasConfig, - constructorArgs: req.constructorArgs, - value: req.value, - contractJSON: req.contract.contractJSON, - }); - } else if (isContractKeychainDefinition(req.contract)) { - return this.deployContractFromKeychain(req, req.contract); - } else { - // Exhaustive check - const unknownContract: never = req.contract; - throw new Error( - `Unknown contract definition provided: ${unknownContract}`, - ); + public async deployContractNoKeychain( + req: DeployContractNoKeychainV1Request, + ): Promise { + Checks.truthy(req, "deployContractNoKeychain() request arg"); + + if (isWeb3SigningCredentialNone(req.web3SigningCredential)) { + throw new Error(`Cannot deploy contract with pre-signed TX`); } + + return this.runContractDeployment({ + web3SigningCredential: req.web3SigningCredential, + gasConfig: req.gasConfig, + constructorArgs: req.constructorArgs, + value: req.value, + contractJSON: req.contract.contractJSON, + }); } /** diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/deploy-contract-no-keychain-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/deploy-contract-no-keychain-v1-endpoint.ts new file mode 100644 index 00000000000..e99808b9f3c --- /dev/null +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/deploy-contract-no-keychain-v1-endpoint.ts @@ -0,0 +1,113 @@ +import { Express, Request, Response } from "express"; + +import { + IWebServiceEndpoint, + IExpressRequestHandler, + IEndpointAuthzOptions, +} from "@hyperledger/cactus-core-api"; + +import { + Logger, + Checks, + LogLevelDesc, + LoggerProvider, + IAsyncProvider, + safeStringifyException, +} from "@hyperledger/cactus-common"; + +import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; + +import { PluginLedgerConnectorEthereum } from "../plugin-ledger-connector-ethereum"; +import OAS from "../../json/openapi.json"; +import { ERR_INVALID_RESPONSE } from "web3"; +import { isWeb3Error } from "../public-api"; + +export interface IDeployContractSolidityBytecodeOptions { + logLevel?: LogLevelDesc; + connector: PluginLedgerConnectorEthereum; +} + +export class DeployContractNoKeychainEndpoint implements IWebServiceEndpoint { + public static readonly CLASS_NAME = "DeployContractNoKeychainEndpoint"; + + private readonly log: Logger; + + public get className(): string { + return DeployContractNoKeychainEndpoint.CLASS_NAME; + } + + constructor(public readonly options: IDeployContractSolidityBytecodeOptions) { + const fnTag = `${this.className}#constructor()`; + Checks.truthy(options, `${fnTag} arg options`); + Checks.truthy(options.connector, `${fnTag} arg options.connector`); + + const level = this.options.logLevel || "INFO"; + const label = this.className; + this.log = LoggerProvider.getOrCreate({ level, label }); + } + + public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain"] { + return OAS.paths[ + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain" + ]; + } + + public getPath(): string { + return this.oasPath.post["x-hyperledger-cacti"].http.path; + } + + public getVerbLowerCase(): string { + return this.oasPath.post["x-hyperledger-cacti"].http.verbLowerCase; + } + + public getOperationId(): string { + return this.oasPath.post.operationId; + } + + getAuthorizationOptionsProvider(): IAsyncProvider { + // TODO: make this an injectable dependency in the constructor + return { + get: async () => ({ + isProtected: true, + requiredRoles: [], + }), + }; + } + + public async registerExpress( + expressApp: Express, + ): Promise { + await registerWebServiceEndpoint(expressApp, this); + return this; + } + + public getExpressRequestHandler(): IExpressRequestHandler { + return this.handleRequest.bind(this); + } + + public async handleRequest(req: Request, res: Response): Promise { + const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; + this.log.debug(reqTag); + try { + res + .status(200) + .json(await this.options.connector.deployContractNoKeychain(req.body)); + } catch (ex) { + this.log.error(`Crash while serving ${reqTag}`, ex); + + // Return errors responses from ethereum node as user errors + if (isWeb3Error(ex) && ex.code === ERR_INVALID_RESPONSE) { + res.status(400).json({ + message: "Invalid Response Error", + error: safeStringifyException(ex), + }); + return; + } + + res.status(500).json({ + message: "Internal Server Error", + error: safeStringifyException(ex), + }); + } + } +} diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts b/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-no-keychain-v1.test.ts similarity index 97% rename from packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts rename to packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-no-keychain-v1.test.ts index 8c6815ad9aa..32431351e0c 100644 --- a/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-no-keychain-v1.test.ts @@ -42,8 +42,8 @@ import { Web3SigningCredentialType, DefaultApi as EthereumApi, ContractJsonDefinition, - DeployContractV1Request, InvokeContractV1Request, + DeployContractNoKeychainV1Request, } from "../../../main/typescript/public-api"; const containerImageName = "ghcr.io/hyperledger/cacti-geth-all-in-one"; @@ -168,7 +168,7 @@ describe("Ethereum contract deploy and invoke using keychain tests", () => { ////////////////////////////////// test("deploys contract using json object", async () => { - const deployOut = await apiClient.deployContract({ + const deployOut = await apiClient.deployContractNoKeychain({ contract: { contractJSON: HelloWorldContractJson, }, @@ -209,7 +209,7 @@ describe("Ethereum contract deploy and invoke using keychain tests", () => { }); test("deploys contract using json object with constructorArgs", async () => { - const deployOut = await apiClient.deployContract({ + const deployOut = await apiClient.deployContractNoKeychain({ contract: { contractJSON: HelloWorldWithArgContractJson, }, @@ -228,7 +228,7 @@ describe("Ethereum contract deploy and invoke using keychain tests", () => { test("deployContract without contractJSON should fail", async () => { try { - await apiClient.deployContract({ + await apiClient.deployContractNoKeychain({ contract: {} as ContractJsonDefinition, web3SigningCredential: { ethAccount: WHALE_ACCOUNT_ADDRESS, @@ -244,7 +244,7 @@ describe("Ethereum contract deploy and invoke using keychain tests", () => { test("deployContract with additional parameters should fail", async () => { try { - await apiClient.deployContract({ + await apiClient.deployContractNoKeychain({ contract: { contractJSON: HelloWorldContractJson, }, @@ -255,7 +255,7 @@ describe("Ethereum contract deploy and invoke using keychain tests", () => { }, gas: 1000000, fake: 4, - } as DeployContractV1Request); + } as DeployContractNoKeychainV1Request); fail("Expected deployContract call to fail but it succeeded."); } catch (error) { console.log("deployContract failed as expected"); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.json index 09dd3b60549..adc5cd4a8da 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.json +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/json/openapi.json @@ -566,7 +566,7 @@ } } }, - "DeployContractSolidityBytecodeJsonObjectV1Request": { + "DeployContractSolidityBytecodeNoKeychainV1Request": { "type": "object", "required": ["web3SigningCredential", "contractJSON"], "additionalProperties": false, @@ -690,7 +690,7 @@ } } }, - "InvokeContractJsonObjectV1Request": { + "InvokeContractNoKeychainV1Request": { "type": "object", "required": [ "web3SigningCredential", @@ -1201,22 +1201,22 @@ } } }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object": { + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-no-keychain": { "post": { "x-hyperledger-cacti": { "http": { "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object" + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-no-keychain" } }, - "operationId": "deployContractSolBytecodeJsonObjectV1", + "operationId": "deployContractSolBytecodeNoKeychainV1", "summary": "Deploys the bytecode of a Solidity contract.", "parameters": [], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeployContractSolidityBytecodeJsonObjectV1Request" + "$ref": "#/components/schemas/DeployContractSolidityBytecodeNoKeychainV1Request" } } } @@ -1303,12 +1303,12 @@ } } }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object": { + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-no-keychain": { "post": { "x-hyperledger-cacti": { "http": { "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object" + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-no-keychain" } }, "operationId": "invokeContractV1NoKeychain", @@ -1318,7 +1318,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/InvokeContractJsonObjectV1Request" + "$ref": "#/components/schemas/InvokeContractNoKeychainV1Request" } } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/api.ts index 0eb1bdf4ecb..3bea278e541 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -113,43 +113,43 @@ export interface ContractJSON { /** * * @export - * @interface DeployContractSolidityBytecodeJsonObjectV1Request + * @interface DeployContractSolidityBytecodeNoKeychainV1Request */ -export interface DeployContractSolidityBytecodeJsonObjectV1Request { +export interface DeployContractSolidityBytecodeNoKeychainV1Request { /** * * @type {Web3SigningCredential} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request */ 'web3SigningCredential': Web3SigningCredential; /** * * @type {number} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request */ 'gas'?: number; /** * * @type {string} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request */ 'gasPrice'?: string; /** * The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing. * @type {number} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request */ 'timeoutMs'?: number; /** * * @type {ContractJSON} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request */ 'contractJSON': ContractJSON; /** * The list of arguments to pass in to the constructor of the contract being deployed. * @type {Array} - * @memberof DeployContractSolidityBytecodeJsonObjectV1Request + * @memberof DeployContractSolidityBytecodeNoKeychainV1Request */ 'constructorArgs'?: Array; } @@ -284,79 +284,79 @@ export type EthContractInvocationWeb3Method = typeof EthContractInvocationWeb3Me /** * * @export - * @interface InvokeContractJsonObjectV1Request + * @interface InvokeContractNoKeychainV1Request */ -export interface InvokeContractJsonObjectV1Request { +export interface InvokeContractNoKeychainV1Request { /** * * @type {Web3SigningCredential} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'web3SigningCredential': Web3SigningCredential; /** * * @type {EthContractInvocationType} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'invocationType': EthContractInvocationType; /** * The name of the contract method to invoke. * @type {string} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'methodName': string; /** * The list of arguments to pass in to the contract method being invoked. * @type {Array} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'params': Array; /** * Address of the solidity contract * @type {string} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'contractAddress': string; /** * * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'value'?: QuorumTransactionConfigFrom; /** * * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'gas'?: QuorumTransactionConfigFrom; /** * * @type {QuorumTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'gasPrice'?: QuorumTransactionConfigFrom; /** * * @type {number} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'nonce'?: number; /** * The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND * @type {number} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'timeoutMs'?: number; /** * * @type {ContractJSON} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'contractJSON': ContractJSON; /** * * @type {QuorumPrivateTransactionConfig} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'privateTransactionConfig'?: QuorumPrivateTransactionConfig; } @@ -1473,12 +1473,12 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deployContractSolBytecodeJsonObjectV1: async (deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object`; + deployContractSolBytecodeNoKeychainV1: async (deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-no-keychain`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; @@ -1497,7 +1497,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(deployContractSolidityBytecodeJsonObjectV1Request, localVarRequestOptions, configuration) + localVarRequestOptions.data = serializeDataIfNeeded(deployContractSolidityBytecodeNoKeychainV1Request, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), @@ -1605,12 +1605,12 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - invokeContractV1NoKeychain: async (invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object`; + invokeContractV1NoKeychain: async (invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-no-keychain`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; @@ -1629,7 +1629,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(invokeContractJsonObjectV1Request, localVarRequestOptions, configuration) + localVarRequestOptions.data = serializeDataIfNeeded(invokeContractNoKeychainV1Request, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), @@ -1751,12 +1751,12 @@ export const DefaultApiFp = function(configuration?: Configuration) { /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request, options); + async deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** @@ -1794,12 +1794,12 @@ export const DefaultApiFp = function(configuration?: Configuration) { /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async invokeContractV1NoKeychain(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.invokeContractV1NoKeychain(invokeContractJsonObjectV1Request, options); + async invokeContractV1NoKeychain(invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.invokeContractV1NoKeychain(invokeContractNoKeychainV1Request, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** @@ -1848,12 +1848,12 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options?: any): AxiosPromise { - return localVarFp.deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request, options).then((request) => request(axios, basePath)); + deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options?: any): AxiosPromise { + return localVarFp.deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request, options).then((request) => request(axios, basePath)); }, /** * @@ -1887,12 +1887,12 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - invokeContractV1NoKeychain(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: any): AxiosPromise { - return localVarFp.invokeContractV1NoKeychain(invokeContractJsonObjectV1Request, options).then((request) => request(axios, basePath)); + invokeContractV1NoKeychain(invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options?: any): AxiosPromise { + return localVarFp.invokeContractV1NoKeychain(invokeContractNoKeychainV1Request, options).then((request) => request(axios, basePath)); }, /** * @@ -1937,13 +1937,13 @@ export class DefaultApi extends BaseAPI { /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractSolidityBytecodeJsonObjectV1Request} [deployContractSolidityBytecodeJsonObjectV1Request] + * @param {DeployContractSolidityBytecodeNoKeychainV1Request} [deployContractSolidityBytecodeNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DefaultApi */ - public deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request?: DeployContractSolidityBytecodeJsonObjectV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).deployContractSolBytecodeJsonObjectV1(deployContractSolidityBytecodeJsonObjectV1Request, options).then((request) => request(this.axios, this.basePath)); + public deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request?: DeployContractSolidityBytecodeNoKeychainV1Request, options?: AxiosRequestConfig) { + return DefaultApiFp(this.configuration).deployContractSolBytecodeNoKeychainV1(deployContractSolidityBytecodeNoKeychainV1Request, options).then((request) => request(this.axios, this.basePath)); } /** @@ -1984,13 +1984,13 @@ export class DefaultApi extends BaseAPI { /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DefaultApi */ - public invokeContractV1NoKeychain(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).invokeContractV1NoKeychain(invokeContractJsonObjectV1Request, options).then((request) => request(this.axios, this.basePath)); + public invokeContractV1NoKeychain(invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options?: AxiosRequestConfig) { + return DefaultApiFp(this.configuration).invokeContractV1NoKeychain(invokeContractNoKeychainV1Request, options).then((request) => request(this.axios, this.basePath)); } /** diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts index bfcc3bde5c0..fbe13fb111c 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts @@ -49,16 +49,15 @@ import { } from "@hyperledger/cactus-common"; import { DeployContractSolidityBytecodeEndpoint } from "./web-services/deploy-contract-solidity-bytecode-endpoint"; -import { DeployContractSolidityBytecodeJsonObjectEndpoint } from "./web-services/deploy-contract-solidity-bytecode-endpoint-json-object"; +import { DeployContractSolidityBytecodeNoKeychainEndpoint } from "./web-services/deploy-contract-solidity-bytecode-endpoint-no-keychain"; import { DeployContractSolidityBytecodeV1Request, - DeployContractSolidityBytecodeJsonObjectV1Request, DeployContractSolidityBytecodeV1Response, EthContractInvocationType, EthContractInvocationWeb3Method, InvokeContractV1Request, - InvokeContractJsonObjectV1Request, + InvokeContractNoKeychainV1Request, InvokeContractV1Response, RunTransactionRequest, RunTransactionResponse, @@ -70,11 +69,12 @@ import { WatchBlocksV1Options, InvokeRawWeb3EthMethodV1Request, InvokeRawWeb3EthContractV1Request, + DeployContractSolidityBytecodeNoKeychainV1Request, } from "./generated/openapi/typescript-axios/"; import { RunTransactionEndpoint } from "./web-services/run-transaction-endpoint"; import { InvokeContractEndpoint } from "./web-services/invoke-contract-endpoint"; -import { InvokeContractJsonObjectEndpoint } from "./web-services/invoke-contract-endpoint-json-object"; +import { InvokeContractNoKeychainEndpoint } from "./web-services/invoke-contract-endpoint-no-keychain"; import { WatchBlocksV1Endpoint } from "./web-services/watch-blocks-v1-endpoint"; import { GetPrometheusExporterMetricsEndpointV1 } from "./web-services/get-prometheus-exporter-metrics-endpoint-v1"; import { InvokeRawWeb3EthMethodEndpoint } from "./web-services/invoke-raw-web3eth-method-v1-endpoint"; @@ -240,7 +240,7 @@ export class PluginLedgerConnectorQuorum endpoints.push(endpoint); } { - const endpoint = new DeployContractSolidityBytecodeJsonObjectEndpoint({ + const endpoint = new DeployContractSolidityBytecodeNoKeychainEndpoint({ connector: this, logLevel: this.options.logLevel, }); @@ -261,7 +261,7 @@ export class PluginLedgerConnectorQuorum endpoints.push(endpoint); } { - const endpoint = new InvokeContractJsonObjectEndpoint({ + const endpoint = new InvokeContractNoKeychainEndpoint({ connector: this, logLevel: this.options.logLevel, }); @@ -415,7 +415,7 @@ export class PluginLedgerConnectorQuorum } public async getContractInfo( - req: InvokeContractJsonObjectV1Request, + req: InvokeContractNoKeychainV1Request, ): Promise { const fnTag = `${this.className}#invokeContractNoKeychain()`; const { contractJSON, contractAddress } = req; @@ -429,7 +429,7 @@ export class PluginLedgerConnectorQuorum } public async invokeContract( - req: InvokeContractJsonObjectV1Request, + req: InvokeContractNoKeychainV1Request, ): Promise { const fnTag = `${this.className}#invokeContract()`; @@ -831,8 +831,8 @@ export class PluginLedgerConnectorQuorum return receipt; } - public async deployContractJsonObject( - req: DeployContractSolidityBytecodeJsonObjectV1Request, + public async deployContractNoKeychain( + req: DeployContractSolidityBytecodeNoKeychainV1Request, ): Promise { const fnTag = `${this.className}#deployContractNoKeychain()`; if ( diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-no-keychain.ts similarity index 83% rename from packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-no-keychain.ts index b69f0e28ffa..7a0ae2759e9 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-no-keychain.ts @@ -17,28 +17,28 @@ import { import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; -import { DeployContractSolidityBytecodeJsonObjectV1Request } from "../generated/openapi/typescript-axios"; +import { DeployContractSolidityBytecodeNoKeychainV1Request } from "../generated/openapi/typescript-axios"; import OAS from "../../json/openapi.json"; -export interface IDeployContractSolidityBytecodeOptionsJsonObject { +export interface IDeployContractSolidityBytecodeOptionsNoKeychain { logLevel?: LogLevelDesc; connector: PluginLedgerConnectorQuorum; } -export class DeployContractSolidityBytecodeJsonObjectEndpoint +export class DeployContractSolidityBytecodeNoKeychainEndpoint implements IWebServiceEndpoint { public static readonly CLASS_NAME = - "DeployContractSolidityBytecodeEndpointJsonObject"; + "DeployContractSolidityBytecodeEndpointNoKeychain"; private readonly log: Logger; public get className(): string { - return DeployContractSolidityBytecodeJsonObjectEndpoint.CLASS_NAME; + return DeployContractSolidityBytecodeNoKeychainEndpoint.CLASS_NAME; } constructor( - public readonly options: IDeployContractSolidityBytecodeOptionsJsonObject, + public readonly options: IDeployContractSolidityBytecodeOptionsNoKeychain, ) { const fnTag = `${this.className}#constructor()`; Checks.truthy(options, `${fnTag} arg options`); @@ -51,7 +51,7 @@ export class DeployContractSolidityBytecodeJsonObjectEndpoint public getOasPath() { return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-json-object" + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/deploy-contract-solidity-bytecode-no-keychain" ]; } @@ -93,10 +93,10 @@ export class DeployContractSolidityBytecodeJsonObjectEndpoint public async handleRequest(req: Request, res: Response): Promise { const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; this.log.debug(reqTag); - const reqBody: DeployContractSolidityBytecodeJsonObjectV1Request = req.body; + const reqBody: DeployContractSolidityBytecodeNoKeychainV1Request = req.body; try { const resBody = - await this.options.connector.deployContractJsonObject(reqBody); + await this.options.connector.deployContractNoKeychain(reqBody); res.json(resBody); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-no-keychain.ts similarity index 88% rename from packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-no-keychain.ts index 2f1990fcc74..a4b7b51d2ff 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-json-object.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/invoke-contract-endpoint-no-keychain.ts @@ -18,22 +18,22 @@ import { PluginLedgerConnectorQuorum } from "../plugin-ledger-connector-quorum"; import OAS from "../../json/openapi.json"; -export interface IInvokeContractEndpointJsonObjectOptions { +export interface IInvokeContractEndpointNoKeychainOptions { logLevel?: LogLevelDesc; connector: PluginLedgerConnectorQuorum; } -export class InvokeContractJsonObjectEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "InvokeContractJsonObjectEndpoint"; +export class InvokeContractNoKeychainEndpoint implements IWebServiceEndpoint { + public static readonly CLASS_NAME = "InvokeContractNoKeychainEndpoint"; private readonly log: Logger; public get className(): string { - return InvokeContractJsonObjectEndpoint.CLASS_NAME; + return InvokeContractNoKeychainEndpoint.CLASS_NAME; } constructor( - public readonly options: IInvokeContractEndpointJsonObjectOptions, + public readonly options: IInvokeContractEndpointNoKeychainOptions, ) { const fnTag = `${this.className}#constructor()`; Checks.truthy(options, `${fnTag} arg options`); @@ -46,7 +46,7 @@ export class InvokeContractJsonObjectEndpoint implements IWebServiceEndpoint { public getOasPath() { return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-json-object" + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-quorum/invoke-contract-no-keychain" ]; } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts index 9691f9215e8..c174fc1a56a 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts @@ -14,8 +14,8 @@ import { PluginLedgerConnectorQuorum, Web3SigningCredentialType, DefaultApi as QuorumApi, - DeployContractSolidityBytecodeJsonObjectV1Request, - InvokeContractJsonObjectV1Request, + DeployContractSolidityBytecodeNoKeychainV1Request, + InvokeContractNoKeychainV1Request, } from "../../../../../../main/typescript/public-api"; import { @@ -114,7 +114,7 @@ test(testCase, async (t: Test) => { const fDeploy = "deployContractSolBytecodeJsonObjectV1"; const fInvoke = "invokeContractV1NoKeychain"; const cOk = "without bad request error"; - const cWithoutParams = "not sending all required parameters"; + const cNoParams = "not sending all required parameters"; const cInvalidParams = "sending invalid parameters"; let contractAddress: string; @@ -131,8 +131,8 @@ test(testCase, async (t: Test) => { gas: 1000000, contractJSON: HelloWorldContractJson, }; - const res = await apiClient.deployContractSolBytecodeJsonObjectV1( - parameters as DeployContractSolidityBytecodeJsonObjectV1Request, + const res = await apiClient.deployContractSolBytecodeNoKeychainV1( + parameters as DeployContractSolidityBytecodeNoKeychainV1Request, ); t2.ok(res, "Contract deployed successfully"); t2.ok(res.data); @@ -162,7 +162,7 @@ test(testCase, async (t: Test) => { contractJSON: HelloWorldContractJson, }; const res = await apiClient.invokeContractV1NoKeychain( - parameters as InvokeContractJsonObjectV1Request, + parameters as InvokeContractNoKeychainV1Request, ); t2.ok(res, "Contract invoked successfully"); t2.ok(res.data); @@ -175,7 +175,7 @@ test(testCase, async (t: Test) => { t2.end(); }); - test(`${testCase} - ${fDeploy} - ${cWithoutParams}`, async (t2: Test) => { + test(`${testCase} - ${fDeploy} - ${cNoParams}`, async (t2: Test) => { try { const parameters = { contractAddress, @@ -187,8 +187,8 @@ test(testCase, async (t: Test) => { bytecode: HelloWorldContractJson.bytecode, gas: 1000000, }; - await apiClient.deployContractSolBytecodeJsonObjectV1( - parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request, + await apiClient.deployContractSolBytecodeNoKeychainV1( + parameters as any as DeployContractSolidityBytecodeNoKeychainV1Request, ); } catch (e) { t2.equal( @@ -223,8 +223,8 @@ test(testCase, async (t: Test) => { contractJSON: HelloWorldContractJson, fake: 4, }; - await apiClient.deployContractSolBytecodeJsonObjectV1( - parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request, + await apiClient.deployContractSolBytecodeNoKeychainV1( + parameters as any as DeployContractSolidityBytecodeNoKeychainV1Request, ); } catch (e) { t2.equal( @@ -244,7 +244,7 @@ test(testCase, async (t: Test) => { t2.end(); }); - test(`${testCase} - ${fInvoke} - ${cWithoutParams}`, async (t2: Test) => { + test(`${testCase} - ${fInvoke} - ${cNoParams}`, async (t2: Test) => { try { const parameters = { contractAddress, @@ -260,7 +260,7 @@ test(testCase, async (t: Test) => { nonce: 2, }; await apiClient.invokeContractV1NoKeychain( - parameters as any as InvokeContractJsonObjectV1Request, + parameters as any as InvokeContractNoKeychainV1Request, ); } catch (e) { t2.equal( @@ -299,7 +299,7 @@ test(testCase, async (t: Test) => { fake: 4, }; await apiClient.invokeContractV1NoKeychain( - parameters as any as InvokeContractJsonObjectV1Request, + parameters as any as InvokeContractNoKeychainV1Request, ); } catch (e) { t2.equal( diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-no-keychain-endpoints.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-no-keychain-endpoints.test.ts index ea85cd1951d..f8aa187f55a 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object-endpoints.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-no-keychain-endpoints.test.ts @@ -129,7 +129,7 @@ test(testCase, async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ + const deployOut = await apiClient.deployContractSolBytecodeNoKeychainV1({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-no-keychain.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-no-keychain.test.ts index 88141afedc8..7791ee41cf4 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-json-object.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-deploy-contract-from-json-no-keychain.test.ts @@ -129,7 +129,7 @@ test(testCase, async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ + const deployOut = await connector.deployContractNoKeychain({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-no-keychain-endpoints.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-no-keychain-endpoints.test.ts index e1164b97561..f797149f075 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object-endpoints.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-no-keychain-endpoints.test.ts @@ -115,7 +115,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ + const deployOut = await apiClient.deployContractSolBytecodeNoKeychainV1({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-no-keychain.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-no-keychain.test.ts index fc46cf44730..e6c1ba5a7ff 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-json-object.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v2.3.0-invoke-contract-no-keychain.test.ts @@ -77,7 +77,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ + const deployOut = await connector.deployContractNoKeychain({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-no-keychain-endpoints.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-no-keychain-endpoints.test.ts index 121064e3f68..dee81c286fc 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object-endpoints.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-no-keychain-endpoints.test.ts @@ -126,7 +126,7 @@ test(testCase, async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ + const deployOut = await apiClient.deployContractSolBytecodeNoKeychainV1({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-no-keychain.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-no-keychain.test.ts index b6af9ab35fc..5f9f6813cc0 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-json-object.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-deploy-contract-from-json-no-keychain.test.ts @@ -126,7 +126,7 @@ test(testCase, async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ + const deployOut = await connector.deployContractNoKeychain({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-no-keychain-endpoints.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-no-keychain-endpoints.test.ts index 4479b17ae73..1c805bf6f4a 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object-endpoints.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-no-keychain-endpoints.test.ts @@ -115,7 +115,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await apiClient.deployContractSolBytecodeJsonObjectV1({ + const deployOut = await apiClient.deployContractSolBytecodeNoKeychainV1({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-no-keychain.test.ts similarity index 99% rename from packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts rename to packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-no-keychain.test.ts index 89010f500c4..55793d99419 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-json-object.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/v21.4.1-invoke-contract-no-keychain.test.ts @@ -77,7 +77,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ + const deployOut = await connector.deployContractNoKeychain({ web3SigningCredential: { ethAccount: firstHighNetWorthAccount, secret: "", diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-xdai/src/main/json/openapi.json index c92639de5ca..e0700841fcf 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/json/openapi.json +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/json/openapi.json @@ -461,7 +461,7 @@ } } }, - "DeployContractJsonObjectV1Request": { + "DeployContractNoKeychainV1Request": { "type": "object", "required": ["web3SigningCredential", "contractJSON"], "additionalProperties": false, @@ -594,7 +594,7 @@ } } }, - "InvokeContractJsonObjectV1Request": { + "InvokeContractNoKeychainV1Request": { "type": "object", "required": [ "web3SigningCredential", @@ -868,22 +868,22 @@ } } }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-json-object": { + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-no-keychain": { "post": { "x-hyperledger-cacti": { "http": { "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-json-object" + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-no-keychain" } }, - "operationId": "deployContractJsonObjectV1", + "operationId": "deployContractNoKeychainV1", "summary": "Deploys the bytecode of a Solidity contract.", "parameters": [], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DeployContractJsonObjectV1Request" + "$ref": "#/components/schemas/DeployContractNoKeychainV1Request" } } } @@ -970,22 +970,22 @@ } } }, - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-json-object": { + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-no-keychain": { "post": { "x-hyperledger-cacti": { "http": { "verbLowerCase": "post", - "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-json-object" + "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-no-keychain" } }, - "operationId": "invokeContractJsonObject", + "operationId": "invokeContractNoKeychain", "summary": "Invokes a contract on a besu ledger", "parameters": [], "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/InvokeContractJsonObjectV1Request" + "$ref": "#/components/schemas/InvokeContractNoKeychainV1Request" } } } diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/generated/openapi/typescript-axios/api.ts index 1382b0ae99f..3941ec9b9a0 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -146,43 +146,43 @@ export interface ContractJSON { /** * * @export - * @interface DeployContractJsonObjectV1Request + * @interface DeployContractNoKeychainV1Request */ -export interface DeployContractJsonObjectV1Request { +export interface DeployContractNoKeychainV1Request { /** * * @type {Web3SigningCredential} - * @memberof DeployContractJsonObjectV1Request + * @memberof DeployContractNoKeychainV1Request */ 'web3SigningCredential': Web3SigningCredential; /** * * @type {number} - * @memberof DeployContractJsonObjectV1Request + * @memberof DeployContractNoKeychainV1Request */ 'gas'?: number; /** * * @type {string} - * @memberof DeployContractJsonObjectV1Request + * @memberof DeployContractNoKeychainV1Request */ 'gasPrice'?: string; /** * The amount of milliseconds to wait for a transaction receipt with theaddress of the contract(which indicates successful deployment) beforegiving up and crashing. * @type {number} - * @memberof DeployContractJsonObjectV1Request + * @memberof DeployContractNoKeychainV1Request */ 'timeoutMs'?: number; /** * * @type {ContractJSON} - * @memberof DeployContractJsonObjectV1Request + * @memberof DeployContractNoKeychainV1Request */ 'contractJSON': ContractJSON; /** * The list of arguments to pass in to the constructor of the contract being deployed. * @type {Array} - * @memberof DeployContractJsonObjectV1Request + * @memberof DeployContractNoKeychainV1Request */ 'constructorArgs'?: Array; } @@ -308,73 +308,73 @@ export type EthContractInvocationType = typeof EthContractInvocationType[keyof t /** * * @export - * @interface InvokeContractJsonObjectV1Request + * @interface InvokeContractNoKeychainV1Request */ -export interface InvokeContractJsonObjectV1Request { +export interface InvokeContractNoKeychainV1Request { /** * * @type {Web3SigningCredential} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'web3SigningCredential': Web3SigningCredential; /** * * @type {EthContractInvocationType} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'invocationType': EthContractInvocationType; /** * The name of the contract method to invoke. * @type {string} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'methodName': string; /** * The list of arguments to pass in to the contract method being invoked. * @type {Array} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'params': Array; /** * Address of the solidity contract * @type {string} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'contractAddress': string; /** * * @type {XdaiTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'value'?: XdaiTransactionConfigFrom; /** * * @type {XdaiTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'gas'?: XdaiTransactionConfigFrom; /** * * @type {XdaiTransactionConfigFrom} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'gasPrice'?: XdaiTransactionConfigFrom; /** * * @type {number} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'nonce'?: number; /** * The amount of milliseconds to wait for a transaction receipt beforegiving up and crashing. Only has any effect if the invocation type is SEND * @type {number} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'timeoutMs'?: number; /** * * @type {ContractJSON} - * @memberof InvokeContractJsonObjectV1Request + * @memberof InvokeContractNoKeychainV1Request */ 'contractJSON': ContractJSON; } @@ -978,12 +978,12 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractJsonObjectV1Request} [deployContractJsonObjectV1Request] + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deployContractJsonObjectV1: async (deployContractJsonObjectV1Request?: DeployContractJsonObjectV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-json-object`; + deployContractNoKeychainV1: async (deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-no-keychain`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; @@ -1002,7 +1002,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(deployContractJsonObjectV1Request, localVarRequestOptions, configuration) + localVarRequestOptions.data = serializeDataIfNeeded(deployContractNoKeychainV1Request, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), @@ -1076,12 +1076,12 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - invokeContractJsonObject: async (invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options: AxiosRequestConfig = {}): Promise => { - const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-json-object`; + invokeContractNoKeychain: async (invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options: AxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-no-keychain`; // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); let baseOptions; @@ -1100,7 +1100,7 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; - localVarRequestOptions.data = serializeDataIfNeeded(invokeContractJsonObjectV1Request, localVarRequestOptions, configuration) + localVarRequestOptions.data = serializeDataIfNeeded(invokeContractNoKeychainV1Request, localVarRequestOptions, configuration) return { url: toPathString(localVarUrlObj), @@ -1188,12 +1188,12 @@ export const DefaultApiFp = function(configuration?: Configuration) { /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractJsonObjectV1Request} [deployContractJsonObjectV1Request] + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async deployContractJsonObjectV1(deployContractJsonObjectV1Request?: DeployContractJsonObjectV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractJsonObjectV1(deployContractJsonObjectV1Request, options); + async deployContractNoKeychainV1(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractNoKeychainV1(deployContractNoKeychainV1Request, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** @@ -1220,12 +1220,12 @@ export const DefaultApiFp = function(configuration?: Configuration) { /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - async invokeContractJsonObject(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { - const localVarAxiosArgs = await localVarAxiosParamCreator.invokeContractJsonObject(invokeContractJsonObjectV1Request, options); + async invokeContractNoKeychain(invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.invokeContractNoKeychain(invokeContractNoKeychainV1Request, options); return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration); }, /** @@ -1263,12 +1263,12 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractJsonObjectV1Request} [deployContractJsonObjectV1Request] + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - deployContractJsonObjectV1(deployContractJsonObjectV1Request?: DeployContractJsonObjectV1Request, options?: any): AxiosPromise { - return localVarFp.deployContractJsonObjectV1(deployContractJsonObjectV1Request, options).then((request) => request(axios, basePath)); + deployContractNoKeychainV1(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: any): AxiosPromise { + return localVarFp.deployContractNoKeychainV1(deployContractNoKeychainV1Request, options).then((request) => request(axios, basePath)); }, /** * @@ -1292,12 +1292,12 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} */ - invokeContractJsonObject(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: any): AxiosPromise { - return localVarFp.invokeContractJsonObject(invokeContractJsonObjectV1Request, options).then((request) => request(axios, basePath)); + invokeContractNoKeychain(invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options?: any): AxiosPromise { + return localVarFp.invokeContractNoKeychain(invokeContractNoKeychainV1Request, options).then((request) => request(axios, basePath)); }, /** * @@ -1332,13 +1332,13 @@ export class DefaultApi extends BaseAPI { /** * * @summary Deploys the bytecode of a Solidity contract. - * @param {DeployContractJsonObjectV1Request} [deployContractJsonObjectV1Request] + * @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DefaultApi */ - public deployContractJsonObjectV1(deployContractJsonObjectV1Request?: DeployContractJsonObjectV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).deployContractJsonObjectV1(deployContractJsonObjectV1Request, options).then((request) => request(this.axios, this.basePath)); + public deployContractNoKeychainV1(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: AxiosRequestConfig) { + return DefaultApiFp(this.configuration).deployContractNoKeychainV1(deployContractNoKeychainV1Request, options).then((request) => request(this.axios, this.basePath)); } /** @@ -1367,13 +1367,13 @@ export class DefaultApi extends BaseAPI { /** * * @summary Invokes a contract on a besu ledger - * @param {InvokeContractJsonObjectV1Request} [invokeContractJsonObjectV1Request] + * @param {InvokeContractNoKeychainV1Request} [invokeContractNoKeychainV1Request] * @param {*} [options] Override http request option. * @throws {RequiredError} * @memberof DefaultApi */ - public invokeContractJsonObject(invokeContractJsonObjectV1Request?: InvokeContractJsonObjectV1Request, options?: AxiosRequestConfig) { - return DefaultApiFp(this.configuration).invokeContractJsonObject(invokeContractJsonObjectV1Request, options).then((request) => request(this.axios, this.basePath)); + public invokeContractNoKeychain(invokeContractNoKeychainV1Request?: InvokeContractNoKeychainV1Request, options?: AxiosRequestConfig) { + return DefaultApiFp(this.configuration).invokeContractNoKeychain(invokeContractNoKeychainV1Request, options).then((request) => request(this.axios, this.basePath)); } /** diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/plugin-ledger-connector-xdai.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/plugin-ledger-connector-xdai.ts index 672525fd94d..af2b7b39f8d 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/plugin-ledger-connector-xdai.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/plugin-ledger-connector-xdai.ts @@ -32,12 +32,12 @@ import { DeployContractSolidityBytecodeEndpoint } from "./web-services/deploy-co import { ConsistencyStrategy, - DeployContractJsonObjectV1Request, + DeployContractNoKeychainV1Request, DeployContractV1Request, DeployContractV1Response, DeployRequestBaseV1, EthContractInvocationType, - InvokeContractJsonObjectV1Request, + InvokeContractNoKeychainV1Request, InvokeContractV1Request, InvokeContractV1Response, InvokeRequestBaseV1, @@ -57,8 +57,8 @@ import { GetPrometheusExporterMetricsEndpointV1, IGetPrometheusExporterMetricsEndpointV1Options, } from "./web-services/get-prometheus-exporter-metrics-endpoint-v1"; -import { DeployContractSolidityBytecodeJsonObjectEndpoint } from "./web-services/deploy-contract-solidity-bytecode-json-object-endpoint"; -import { InvokeContractJsonObjectEndpoint } from "./web-services/invoke-contract-json-object-endpoint"; +import { DeployContractSolidityBytecodeNoKeychainEndpoint } from "./web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint"; +import { InvokeContractNoKeychainEndpoint } from "./web-services/invoke-contract-no-keychain-endpoint"; import { RuntimeError } from "run-time-error-cjs"; export const E_KEYCHAIN_NOT_FOUND = "cactus.connector.xdai.keychain_not_found"; @@ -180,7 +180,7 @@ export class PluginLedgerConnectorXdai endpoints.push(endpoint); } { - const endpoint = new DeployContractSolidityBytecodeJsonObjectEndpoint({ + const endpoint = new DeployContractSolidityBytecodeNoKeychainEndpoint({ connector: this, logLevel: this.options.logLevel, }); @@ -201,7 +201,7 @@ export class PluginLedgerConnectorXdai endpoints.push(endpoint); } { - const endpoint = new InvokeContractJsonObjectEndpoint({ + const endpoint = new InvokeContractNoKeychainEndpoint({ connector: this, logLevel: this.options.logLevel, }); @@ -403,10 +403,10 @@ export class PluginLedgerConnectorXdai return this.runInvoke(invokeBaseReq); } - public async invokeContractJsonObject( - req: InvokeContractJsonObjectV1Request, + public async invokeContractNoKeychain( + req: InvokeContractNoKeychainV1Request, ): Promise { - const fnTag = `${this.className}#invokeContractJsonObject()`; + const fnTag = `${this.className}#invokeContractNoKeychain()`; const { contractJSON, contractAddress } = req; if (!contractJSON) { throw new Error(`${fnTag} The contractJson param is needed`); @@ -706,10 +706,10 @@ export class PluginLedgerConnectorXdai return receipt; } - public async deployContractJsonObject( - req: DeployContractJsonObjectV1Request, + public async deployContractNoKeychain( + req: DeployContractNoKeychainV1Request, ): Promise { - const fnTag = `${this.className}#deployContractJsonObject()`; + const fnTag = `${this.className}#deployContractNoKeychain()`; if ( !req.contractJSON || !req.contractJSON.bytecode || diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-json-object-endpoint.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint.ts similarity index 81% rename from packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-json-object-endpoint.ts rename to packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint.ts index b24a3709584..16290c3bbc0 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-json-object-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-no-keychain-endpoint.ts @@ -17,28 +17,28 @@ import { import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; import { PluginLedgerConnectorXdai } from "../plugin-ledger-connector-xdai"; -import { DeployContractJsonObjectV1Request } from "../generated/openapi/typescript-axios"; +import { DeployContractNoKeychainV1Request } from "../generated/openapi/typescript-axios"; import OAS from "../../json/openapi.json"; -export interface IDeployContractSolidityBytecodeJsonObjectOptions { +export interface IDeployContractSolidityBytecodeNoKeychainOptions { logLevel?: LogLevelDesc; connector: PluginLedgerConnectorXdai; } -export class DeployContractSolidityBytecodeJsonObjectEndpoint +export class DeployContractSolidityBytecodeNoKeychainEndpoint implements IWebServiceEndpoint { public static readonly CLASS_NAME = - "DeployContractSolidityBytecodeJsonObjectEndpoint"; + "DeployContractSolidityBytecodeNoKeychainEndpoint"; private readonly log: Logger; public get className(): string { - return DeployContractSolidityBytecodeJsonObjectEndpoint.CLASS_NAME; + return DeployContractSolidityBytecodeNoKeychainEndpoint.CLASS_NAME; } constructor( - public readonly options: IDeployContractSolidityBytecodeJsonObjectOptions, + public readonly options: IDeployContractSolidityBytecodeNoKeychainOptions, ) { const fnTag = `${this.className}#constructor()`; Checks.truthy(options, `${fnTag} arg options`); @@ -49,9 +49,9 @@ export class DeployContractSolidityBytecodeJsonObjectEndpoint this.log = LoggerProvider.getOrCreate({ level, label }); } - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-json-object"] { + public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-no-keychain"] { return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-json-object" + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/deploy-contract-solidity-bytecode-no-keychain" ]; } @@ -91,10 +91,10 @@ export class DeployContractSolidityBytecodeJsonObjectEndpoint public async handleRequest(req: Request, res: Response): Promise { const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; this.log.debug(reqTag); - const reqBody: DeployContractJsonObjectV1Request = req.body; + const reqBody: DeployContractNoKeychainV1Request = req.body; try { const resBody = - await this.options.connector.deployContractJsonObject(reqBody); + await this.options.connector.deployContractNoKeychain(reqBody); res.json(resBody); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-json-object-endpoint.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-no-keychain-endpoint.ts similarity index 80% rename from packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-json-object-endpoint.ts rename to packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-no-keychain-endpoint.ts index 746941353db..391c8b68afb 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-json-object-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/invoke-contract-no-keychain-endpoint.ts @@ -17,24 +17,24 @@ import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; import { PluginLedgerConnectorXdai } from "../plugin-ledger-connector-xdai"; import OAS from "../../json/openapi.json"; -import { InvokeContractJsonObjectV1Request } from "../generated/openapi/typescript-axios"; +import { InvokeContractNoKeychainV1Request } from "../generated/openapi/typescript-axios"; -export interface IInvokeContractJsonObjectEndpointOptions { +export interface IInvokeContractNoKeychainEndpointOptions { logLevel?: LogLevelDesc; connector: PluginLedgerConnectorXdai; } -export class InvokeContractJsonObjectEndpoint implements IWebServiceEndpoint { - public static readonly CLASS_NAME = "InvokeContractJsonObjectEndpoint"; +export class InvokeContractNoKeychainEndpoint implements IWebServiceEndpoint { + public static readonly CLASS_NAME = "InvokeContractNoKeychainEndpoint"; private readonly log: Logger; public get className(): string { - return InvokeContractJsonObjectEndpoint.CLASS_NAME; + return InvokeContractNoKeychainEndpoint.CLASS_NAME; } constructor( - public readonly options: IInvokeContractJsonObjectEndpointOptions, + public readonly options: IInvokeContractNoKeychainEndpointOptions, ) { const fnTag = `${this.className}#constructor()`; Checks.truthy(options, `${fnTag} arg options`); @@ -45,9 +45,9 @@ export class InvokeContractJsonObjectEndpoint implements IWebServiceEndpoint { this.log = LoggerProvider.getOrCreate({ level, label }); } - public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-json-object"] { + public get oasPath(): (typeof OAS.paths)["/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-no-keychain"] { return OAS.paths[ - "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-json-object" + "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-xdai/invoke-contract-no-keychain" ]; } @@ -87,10 +87,10 @@ export class InvokeContractJsonObjectEndpoint implements IWebServiceEndpoint { public async handleRequest(req: Request, res: Response): Promise { const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; this.log.debug(reqTag); - const reqBody: InvokeContractJsonObjectV1Request = req.body; + const reqBody: InvokeContractNoKeychainV1Request = req.body; try { const resBody = - await this.options.connector.invokeContractJsonObject(reqBody); + await this.options.connector.invokeContractNoKeychain(reqBody); res.json(resBody); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-json-object.test.ts b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-no-keychain.test.ts similarity index 95% rename from packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-json-object.test.ts rename to packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-no-keychain.test.ts index d9122a7e2b5..d7245c69d1f 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-json-object.test.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/deploy-contract-from-json-xdai-no-keychain.test.ts @@ -116,7 +116,7 @@ test(testCase, async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ + const deployOut = await connector.deployContractNoKeychain({ web3SigningCredential: { ethAccount: whalePubKey, secret: whalePrivKey, @@ -141,7 +141,7 @@ test(testCase, async (t: Test) => { "contractAddress typeof string OK", ); - const { callOutput: helloMsg } = await connector.invokeContractJsonObject({ + const { callOutput: helloMsg } = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "sayHello", @@ -196,7 +196,7 @@ test(testCase, async (t: Test) => { test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { const newName = `DrCactus${uuidv4()}`; - const setNameOut = await connector.invokeContractJsonObject({ + const setNameOut = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -212,7 +212,7 @@ test(testCase, async (t: Test) => { t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); try { - const setNameOutInvalid = await connector.invokeContractJsonObject({ + const setNameOutInvalid = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -234,7 +234,7 @@ test(testCase, async (t: Test) => { "setName() invocation with invalid nonce", ); } - const { callOutput: getNameOut } = await connector.invokeContractJsonObject( + const { callOutput: getNameOut } = await connector.invokeContractNoKeychain( { contractAddress, invocationType: EthContractInvocationType.Call, @@ -251,7 +251,7 @@ test(testCase, async (t: Test) => { ); t2.equal(getNameOut, newName, `getName() output reflects the update OK`); - const getNameOut2 = await connector.invokeContractJsonObject({ + const getNameOut2 = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "getName", @@ -266,7 +266,7 @@ test(testCase, async (t: Test) => { }); t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK"); - const response = await connector.invokeContractJsonObject({ + const response = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "deposit", @@ -282,7 +282,7 @@ test(testCase, async (t: Test) => { }); t2.ok(response, "deposit() payable invocation output is truthy OK"); - const { callOutput } = await connector.invokeContractJsonObject({ + const { callOutput } = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "getNameByIndex", diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-json-object.test.ts b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-no-keychain.test.ts similarity index 95% rename from packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-json-object.test.ts rename to packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-no-keychain.test.ts index 46d8917aa17..4c2a86ac18f 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-json-object.test.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai-no-keychain.test.ts @@ -86,7 +86,7 @@ test("deploys contract via .json file", async (t: Test) => { let contractAddress: string; test("deploys contract via .json file", async (t2: Test) => { - const deployOut = await connector.deployContractJsonObject({ + const deployOut = await connector.deployContractNoKeychain({ constructorArgs: [], web3SigningCredential: { ethAccount: whalePubKey, @@ -112,7 +112,7 @@ test("deploys contract via .json file", async (t: Test) => { "contractAddress typeof string OK", ); - const { callOutput: helloMsg } = await connector.invokeContractJsonObject({ + const { callOutput: helloMsg } = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "sayHello", @@ -165,7 +165,7 @@ test("deploys contract via .json file", async (t: Test) => { test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { const newName = `DrCactus${uuidv4()}`; - const setNameOut = await connector.invokeContractJsonObject({ + const setNameOut = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -181,7 +181,7 @@ test("deploys contract via .json file", async (t: Test) => { t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); try { - const setNameOutInvalid = await connector.invokeContractJsonObject({ + const setNameOutInvalid = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -203,7 +203,7 @@ test("deploys contract via .json file", async (t: Test) => { "setName() invocation with invalid nonce", ); } - const { callOutput: getNameOut } = await connector.invokeContractJsonObject( + const { callOutput: getNameOut } = await connector.invokeContractNoKeychain( { contractAddress, invocationType: EthContractInvocationType.Call, @@ -220,7 +220,7 @@ test("deploys contract via .json file", async (t: Test) => { ); t2.equal(getNameOut, newName, `getName() output reflects the update OK`); - const getNameOut2 = await connector.invokeContractJsonObject({ + const getNameOut2 = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "getName", @@ -235,7 +235,7 @@ test("deploys contract via .json file", async (t: Test) => { }); t2.ok(getNameOut2, "getName() invocation #2 output is truthy OK"); - const response = await connector.invokeContractJsonObject({ + const response = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "deposit", @@ -251,7 +251,7 @@ test("deploys contract via .json file", async (t: Test) => { }); t2.ok(response, "deposit() payable invocation output is truthy OK"); - const { callOutput } = await connector.invokeContractJsonObject({ + const { callOutput } = await connector.invokeContractNoKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "getNameByIndex", diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts index 44e59e2c142..572b06dcbbe 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts @@ -5,8 +5,8 @@ import { Web3SigningCredentialType, PluginLedgerConnectorXdai, DefaultApi as XdaiApi, - DeployContractJsonObjectV1Request, - InvokeContractJsonObjectV1Request, + DeployContractNoKeychainV1Request, + InvokeContractNoKeychainV1Request, } from "../../../../main/typescript/public-api"; import { Containers, @@ -92,10 +92,10 @@ test(testCase, async (t: Test) => { await connector.getOrCreateWebServices(); await connector.registerWebServices(expressApp); - const fDeploy = "deployContractJsonObjectV1"; + const fDeploy = "deployContractNoKeychainV1"; const fInvoke = "invokeContractV1"; const cOk = "without bad request error"; - const cWithoutParams = "not sending all required parameters"; + const cNoParams = "not sending all required parameters"; const cInvalidParams = "sending invalid parameters"; let contractAddress: string; @@ -111,8 +111,8 @@ test(testCase, async (t: Test) => { gas: 1000000, contractJSON: HelloWorldContractJson, }; - const res = await apiClient.deployContractJsonObjectV1( - parameters as DeployContractJsonObjectV1Request, + const res = await apiClient.deployContractNoKeychainV1( + parameters as DeployContractNoKeychainV1Request, ); t2.ok(res, "Contract deployed successfully"); t2.ok(res.data); @@ -127,7 +127,7 @@ test(testCase, async (t: Test) => { t2.end(); }); - test(`${testCase} - ${fDeploy} - ${cWithoutParams}`, async (t2: Test) => { + test(`${testCase} - ${fDeploy} - ${cNoParams}`, async (t2: Test) => { try { const parameters = { constructorArgs: [], @@ -138,8 +138,8 @@ test(testCase, async (t: Test) => { }, gas: 1000000, }; - await apiClient.deployContractJsonObjectV1( - parameters as any as DeployContractJsonObjectV1Request, + await apiClient.deployContractNoKeychainV1( + parameters as any as DeployContractNoKeychainV1Request, ); } catch (e) { t2.equal( @@ -172,8 +172,8 @@ test(testCase, async (t: Test) => { contractJSON: HelloWorldContractJson, fake: 4, }; - await apiClient.deployContractJsonObjectV1( - parameters as any as DeployContractJsonObjectV1Request, + await apiClient.deployContractNoKeychainV1( + parameters as any as DeployContractNoKeychainV1Request, ); } catch (e) { t2.equal( @@ -207,7 +207,7 @@ test(testCase, async (t: Test) => { }, contractJSON: HelloWorldContractJson, }; - const res = await apiClient.invokeContractJsonObject(parameters); + const res = await apiClient.invokeContractNoKeychain(parameters); t2.ok(res, "Contract invoked successfully"); t2.ok(res.data); t2.equal( @@ -219,7 +219,7 @@ test(testCase, async (t: Test) => { t2.end(); }); - test(`${testCase} - ${fInvoke} - ${cWithoutParams}`, async (t2: Test) => { + test(`${testCase} - ${fInvoke} - ${cNoParams}`, async (t2: Test) => { try { const parameters = { contractAddress, @@ -233,8 +233,8 @@ test(testCase, async (t: Test) => { type: Web3SigningCredentialType.PrivateKeyHex, }, }; - await apiClient.invokeContractJsonObject( - parameters as any as InvokeContractJsonObjectV1Request, + await apiClient.invokeContractNoKeychain( + parameters as any as InvokeContractNoKeychainV1Request, ); } catch (e) { t2.equal( @@ -270,8 +270,8 @@ test(testCase, async (t: Test) => { contractJSON: HelloWorldContractJson, fake: 4, }; - await apiClient.invokeContractJsonObject( - parameters as any as InvokeContractJsonObjectV1Request, + await apiClient.invokeContractNoKeychain( + parameters as any as InvokeContractNoKeychainV1Request, ); } catch (e) { t2.equal(