From 57b617dbe6a39353a840cea57b6ff09894ccc326 Mon Sep 17 00:00:00 2001 From: AzaharaC Date: Thu, 28 Oct 2021 14:15:53 +0200 Subject: [PATCH] fix(connector-quorum): transaction with different credentials #1098 Signed-off-by: AzaharaC --- .../typescript/plugin-ledger-connector-quorum.ts | 13 +++++++++++++ ...contract-from-json-json-object-endpoints.test.ts | 4 ++-- ...contract-from-json-json-object-endpoints.test.ts | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) 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 3c80035f68..1740e2e8f0 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 @@ -470,6 +470,19 @@ export class PluginLedgerConnectorQuorum // the private key that we need to run the transaction. const privateKeyHex = await keychainPlugin?.get(keychainEntryKey as string); + if (!transactionConfig.gas) { + this.log.debug( + `${fnTag} Gas not specified in the transaction values. Using the estimate from web3`, + ); + transactionConfig.gas = await this.web3.eth.estimateGas( + transactionConfig, + ); + this.log.debug( + `${fnTag} Gas estimated from web3 is: `, + transactionConfig.gas, + ); + } + return this.transactPrivateKey({ transactionConfig, web3SigningCredential: { 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-object-endpoints.test.ts index 864ed1238e..5f7d53ac05 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-object-endpoints.test.ts @@ -326,7 +326,7 @@ test(testCase, async (t: Test) => { invocationType: EthContractInvocationType.Call, methodName: "getName", params: [], - gas: 1000000, + // gas: 1000000, web3SigningCredential: { ethAccount: testEthAccount.address, secret: testEthAccount.privateKey, @@ -345,7 +345,7 @@ test(testCase, async (t: Test) => { invocationType: EthContractInvocationType.Send, methodName: "getName", params: [], - gas: 1000000, + //gas: 1000000, web3SigningCredential: { ethAccount: testEthAccount.address, secret: testEthAccount.privateKey, 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-json-object-endpoints.test.ts index 609af4e0d8..4159264e1d 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-json-object-endpoints.test.ts @@ -301,7 +301,7 @@ test(testCase, async (t: Test) => { invocationType: EthContractInvocationType.Send, methodName: "setName", params: [newName], - gas: 1000000, + // gas: 1000000, web3SigningCredential: { ethAccount: testEthAccount.address, secret: testEthAccount.privateKey, @@ -323,7 +323,7 @@ test(testCase, async (t: Test) => { invocationType: EthContractInvocationType.Call, methodName: "getName", params: [], - gas: 1000000, + // gas: 1000000, web3SigningCredential: { ethAccount: testEthAccount.address, secret: testEthAccount.privateKey,