From 76e324bbdc8ba3e26f15d9e6d5245714e96c8876 Mon Sep 17 00:00:00 2001 From: jagpreetsinghsasan Date: Thu, 14 Dec 2023 08:07:50 +0530 Subject: [PATCH] Updated code for quorum part2 Signed-off-by: jagpreetsinghsasan --- .../openapi-validation-no-keychain.test.ts | 28 +++--- ...oke-contract-json-object-endpoints.test.ts | 89 ++++++++++--------- ...v2.3.0-invoke-contract-json-object.test.ts | 2 +- ...loy-contract-from-json-json-object.test.ts | 2 +- ...oke-contract-json-object-endpoints.test.ts | 89 ++++++++++--------- 5 files changed, 110 insertions(+), 100 deletions(-) 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 26294d40079..6f0debeeb8b 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, + DeployContractSolidityBytecodeWithoutKeychainV1Request, + InvokeContractWithoutKeychainV1Request, } from "../../../../../../main/typescript/public-api"; import { @@ -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.deployContractSolBytecodeWithoutKeychainV1( + parameters as DeployContractSolidityBytecodeWithoutKeychainV1Request, ); t2.ok(res, "Contract deployed successfully"); t2.ok(res.data); @@ -161,8 +161,8 @@ test(testCase, async (t: Test) => { }, contractJSON: HelloWorldContractJson, }; - const res = await apiClient.invokeContractV1NoKeychain( - parameters as InvokeContractJsonObjectV1Request, + const res = await apiClient.invokeContractV1WithoutKeychain( + parameters as InvokeContractWithoutKeychainV1Request, ); t2.ok(res, "Contract invoked successfully"); t2.ok(res.data); @@ -187,8 +187,8 @@ test(testCase, async (t: Test) => { bytecode: HelloWorldContractJson.bytecode, gas: 1000000, }; - await apiClient.deployContractSolBytecodeJsonObjectV1( - parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request, + await apiClient.deployContractSolBytecodeWithoutKeychainV1( + parameters as any as DeployContractSolidityBytecodeWithoutKeychainV1Request, ); } 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.deployContractSolBytecodeWithoutKeychainV1( + parameters as any as DeployContractSolidityBytecodeWithoutKeychainV1Request, ); } catch (e) { t2.equal( @@ -259,8 +259,8 @@ test(testCase, async (t: Test) => { }, nonce: 2, }; - await apiClient.invokeContractV1NoKeychain( - parameters as any as InvokeContractJsonObjectV1Request, + await apiClient.invokeContractV1WithoutKeychain( + parameters as any as InvokeContractWithoutKeychainV1Request, ); } catch (e) { t2.equal( @@ -298,8 +298,8 @@ test(testCase, async (t: Test) => { contractJSON: HelloWorldContractJson, fake: 4, }; - await apiClient.invokeContractV1NoKeychain( - parameters as any as InvokeContractJsonObjectV1Request, + await apiClient.invokeContractV1WithoutKeychain( + parameters as any as InvokeContractWithoutKeychainV1Request, ); } 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-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-json-object-endpoints.test.ts index bb1066d1d6b..951e2162989 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-json-object-endpoints.test.ts @@ -115,15 +115,16 @@ 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({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); + const deployOut = + await apiClient.deployContractSolBytecodeWithoutKeychainV1({ + web3SigningCredential: { + ethAccount: firstHighNetWorthAccount, + secret: "", + type: Web3SigningCredentialType.GethKeychainPassword, + }, + gas: 1000000, + contractJSON: HelloWorldContractJson, + }); t2.ok(deployOut, "deployContract() output is truthy OK"); t2.ok( deployOut.data.transactionReceipt, @@ -141,7 +142,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { "contractAddress typeof string OK", ); - const helloMsgRes = await apiClient.invokeContractV1NoKeychain({ + const helloMsgRes = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "sayHello", @@ -166,7 +167,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { const txCount = await web3.eth.getTransactionCount( firstHighNetWorthAccount, ); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ + const setNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -183,20 +184,22 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, + const setNameOutInvalid = await apiClient.invokeContractV1WithoutKeychain( + { + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + gas: 1000000, + web3SigningCredential: { + ethAccount: firstHighNetWorthAccount, + secret: "", + type: Web3SigningCredentialType.GethKeychainPassword, + }, + nonce: 2, + contractJSON: HelloWorldContractJson, }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); + ); t2.ifError(setNameOutInvalid.data.transactionReceipt); } catch (error) { t2.notStrictEqual( @@ -206,7 +209,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { ); } - const getNameOut = await apiClient.invokeContractV1NoKeychain({ + const getNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "getName", @@ -224,7 +227,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { `getName() SEND invocation produced receipt OK`, ); - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ + const getNameOut2 = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "getName", @@ -276,7 +279,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { const newName = `DrCactus${uuidV4()}`; - const setNameOut = await apiClient.invokeContractV1NoKeychain({ + const setNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -293,20 +296,22 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { t2.ok(setNameOut, "setName() invocation #1 output is truthy OK"); try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, + const setNameOutInvalid = await apiClient.invokeContractV1WithoutKeychain( + { + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + gas: 1000000, + web3SigningCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + nonce: 1, + contractJSON: HelloWorldContractJson, }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); + ); t2.ifError(setNameOutInvalid.data.transactionReceipt); } catch (error) { t2.notStrictEqual( @@ -316,7 +321,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { ); } - const getNameOut = await apiClient.invokeContractV1NoKeychain({ + const getNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "getName", @@ -335,7 +340,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { `getName() output reflects the update OK`, ); - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ + const getNameOut2 = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "getName", 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-json-object.test.ts index fc46cf44730..e45976e4402 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-json-object.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.deployContractWithoutKeychain({ 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-json-object.test.ts index 8b86d175613..a6198e263e2 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-json-object.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.deployContractWithoutKeychain({ 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-json-object-endpoints.test.ts index 968ec8f8d3c..6ec11b85b30 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-json-object-endpoints.test.ts @@ -115,15 +115,16 @@ 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({ - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, - }, - gas: 1000000, - contractJSON: HelloWorldContractJson, - }); + const deployOut = + await apiClient.deployContractSolBytecodeWithoutKeychainV1({ + web3SigningCredential: { + ethAccount: firstHighNetWorthAccount, + secret: "", + type: Web3SigningCredentialType.GethKeychainPassword, + }, + gas: 1000000, + contractJSON: HelloWorldContractJson, + }); t2.ok(deployOut, "deployContract() output is truthy OK"); t2.ok( deployOut.data.transactionReceipt, @@ -141,7 +142,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { "contractAddress typeof string OK", ); - const helloMsg = await apiClient.invokeContractV1NoKeychain({ + const helloMsg = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "sayHello", @@ -165,7 +166,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { const txCount = await web3.eth.getTransactionCount( firstHighNetWorthAccount, ); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ + const setNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -181,20 +182,22 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { t2.ok(setNameOut.data, "setName() invocation #1 output is truthy OK"); try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: firstHighNetWorthAccount, - secret: "", - type: Web3SigningCredentialType.GethKeychainPassword, + const setNameOutInvalid = await apiClient.invokeContractV1WithoutKeychain( + { + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + gas: 1000000, + web3SigningCredential: { + ethAccount: firstHighNetWorthAccount, + secret: "", + type: Web3SigningCredentialType.GethKeychainPassword, + }, + nonce: 2, + contractJSON: HelloWorldContractJson, }, - nonce: 2, - contractJSON: HelloWorldContractJson, - }); + ); t2.ifError(setNameOutInvalid.data.transactionReceipt); } catch (error) { t2.notStrictEqual( @@ -204,7 +207,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { ); } - const getNameOut = await apiClient.invokeContractV1NoKeychain({ + const getNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "getName", @@ -221,7 +224,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { `getName() SEND invocation produced receipt OK`, ); - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ + const getNameOut2 = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "getName", @@ -273,7 +276,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { test("invoke Web3SigningCredentialType.PrivateKeyHex", async (t2: Test) => { const newName = `DrCactus${uuidV4()}`; const txCount = await web3.eth.getTransactionCount(testEthAccount.address); - const setNameOut = await apiClient.invokeContractV1NoKeychain({ + const setNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "setName", @@ -289,20 +292,22 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { t2.ok(setNameOut.data, "setName() invocation #1 output is truthy OK"); try { - const setNameOutInvalid = await apiClient.invokeContractV1NoKeychain({ - contractAddress, - invocationType: EthContractInvocationType.Send, - methodName: "setName", - params: [newName], - gas: 1000000, - web3SigningCredential: { - ethAccount: testEthAccount.address, - secret: testEthAccount.privateKey, - type: Web3SigningCredentialType.PrivateKeyHex, + const setNameOutInvalid = await apiClient.invokeContractV1WithoutKeychain( + { + contractAddress, + invocationType: EthContractInvocationType.Send, + methodName: "setName", + params: [newName], + gas: 1000000, + web3SigningCredential: { + ethAccount: testEthAccount.address, + secret: testEthAccount.privateKey, + type: Web3SigningCredentialType.PrivateKeyHex, + }, + nonce: 1, + contractJSON: HelloWorldContractJson, }, - nonce: 1, - contractJSON: HelloWorldContractJson, - }); + ); t2.ifError(setNameOutInvalid.data.transactionReceipt); } catch (error) { t2.notStrictEqual( @@ -311,7 +316,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { "setName() invocation with invalid nonce", ); } - const getNameOut = await apiClient.invokeContractV1NoKeychain({ + const getNameOut = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Call, methodName: "getName", @@ -330,7 +335,7 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => { `getName() output reflects the update OK`, ); - const getNameOut2 = await apiClient.invokeContractV1NoKeychain({ + const getNameOut2 = await apiClient.invokeContractV1WithoutKeychain({ contractAddress, invocationType: EthContractInvocationType.Send, methodName: "getName",