Skip to content

Commit

Permalink
fix(plugin-ledger-connector-quorum): no keychain endpoints
Browse files Browse the repository at this point in the history
1. Endpoint invoke-contract without keychain was failing because,
on deploy, network information was saved inside the contractJson
object, which was keeping it on memory and for this reason it was
not failing calling the connector.

2. Now, when no keychain is used, instead of save the contracts
addresses in memory indexed by contractName, this parameter
should be sent in the request to avoid that there can only be a
single instance for each contract name. When keychain is used,
contract address is still saved indexed by contractName.

3. Openapi specs were changed to consider these changes,
including remove fields that are inside the contractJSON object
and definition of this object structure.

4. Includes openapi validation test for new endpoints.

Signed-off-by: Elena Izaguirre <[email protected]>
  • Loading branch information
elenaizaguirre authored and petermetz committed Oct 8, 2021
1 parent 373e199 commit 15cf65c
Show file tree
Hide file tree
Showing 21 changed files with 2,239 additions and 578 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export class SupplyChainAppDummyInfrastructure {

const res = await connector.deployContract({
contractName: BambooHarvestRepositoryJSON.contractName,
bytecode: BambooHarvestRepositoryJSON.bytecode,
gas: 1000000,
web3SigningCredential: {
ethAccount: this.quorumAccount.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint {
const fnTag = `${this.className}#constructor()`;
Checks.truthy(opts, `${fnTag} arg options`);
Checks.truthy(opts.apiClient, `${fnTag} options.apiClient`);
// Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
// Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
Checks.nonBlankString(
opts.contractName,
Expand Down Expand Up @@ -120,7 +119,7 @@ export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint {
methodName: "insertRecord",
gas: 1000000,
params: [bambooHarvest],
signingCredential: this.opts.web3SigningCredential,
web3SigningCredential: this.opts.web3SigningCredential,
keychainId: this.opts.keychainId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ListBambooHarvestEndpoint implements IWebServiceEndpoint {
const fnTag = `${this.className}#constructor()`;
Checks.truthy(opts, `${fnTag} arg options`);
Checks.truthy(opts.apiClient, `${fnTag} options.apiClient`);
// Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
// Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
// Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
Checks.nonBlankString(
opts.contractName,
Expand Down Expand Up @@ -103,7 +103,7 @@ export class ListBambooHarvestEndpoint implements IWebServiceEndpoint {
methodName: "getAllRecords",
gas: 1000000,
params: [],
signingCredential: {
web3SigningCredential: {
type: Web3SigningCredentialType.None,
},
keychainId: this.opts.keychainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,63 @@
}
}
},
"ContractJSON": {
"type": "object",
"required": [
"contractName",
"bytecode"
],
"additionalProperties": true,
"properties": {
"contractName": {
"type": "string",
"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"
},
"abi": {
"description": "The application binary interface of the solidity contract, optional parameter",
"type": "array",
"items": {},
"nullable": false
},
"metadata": {
"type": "string"
},
"deployedBytecode": {
"type": "string"
},
"sourceMap": {
"type": "string"
},
"deployedSourceMap": {
"type": "string"
},
"sourcePath": {
"type": "string"
},
"compiler": {
"type": "object"
},
"networks": {
"type": "object"
},
"ast": {
"type": "object"
},
"functionHashes": {
"type": "object"
},
"gasEstimates": {
"type": "object"
}
}
},
"RunTransactionRequest": {
"type": "object",
"required": [
Expand Down Expand Up @@ -388,7 +445,6 @@
"type": "object",
"required": [
"contractName",
"bytecode",
"web3SigningCredential",
"keychainId"
],
Expand All @@ -405,13 +461,6 @@
"$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"
},
"keychainId": {
"type": "string",
"description": "The keychainId for retrieve the contracts json.",
Expand Down Expand Up @@ -455,30 +504,15 @@
"DeployContractSolidityBytecodeJsonObjectV1Request": {
"type": "object",
"required": [
"contractName",
"bytecode",
"web3SigningCredential",
"contractJson"
"contractJSON"
],
"additionalProperties": false,
"properties": {
"contractName": {
"type": "string",
"description": "The contract name for retrieve the contracts json on the keychain.",
"minLength": 1,
"maxLength": 100,
"nullable": false
},
"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
Expand All @@ -494,8 +528,8 @@
"default": 60000,
"nullable": false
},
"contractJSON": {
"type": "object",
"contractJSON": {
"$ref": "#/components/schemas/ContractJSON",
"description": "For use when not using keychain, pass the contract in as this variable",
"nullable": false
}
Expand All @@ -504,19 +538,21 @@
"InvokeContractV1Request": {
"type": "object",
"required": [
"contractName",
"signingCredential",
"web3SigningCredential",
"invocationType",
"methodName",
"params"
"params",
"contractName",
"keychainId"
],
"additionalProperties": false,
"properties": {
"contractName": {
"description": "The contract name to find it in the keychain plugin",
"type": "string",
"nullable": false
},
"signingCredential": {
"web3SigningCredential": {
"$ref": "#/components/schemas/Web3SigningCredential",
"nullable": false
},
Expand All @@ -538,17 +574,6 @@
"default": [],
"items": {}
},
"contractAbi": {
"description": "The application binary interface of the solidity contract, optional parameter",
"type": "array",
"items": {},
"nullable": false
},
"contractAddress": {
"description": "Address of the solidity contract, optional parameter",
"type": "string",
"nullable": false
},
"value": {
"oneOf": [
{
Expand Down Expand Up @@ -594,30 +619,22 @@
"description": "The keychainId for retrieve the contracts json.",
"minLength": 1,
"maxLength": 100
},
"contractJSON":{
"type": "object",
"description": "The contract object to be passed if not using keychain.",
"nullable": false
}
}
},
"InvokeContractJsonObjectV1Request": {
"type": "object",
"required": [
"contractName",
"signingCredential",
"web3SigningCredential",
"invocationType",
"methodName",
"params",
"contractJson"
"contractJSON",
"contractAddress"
],
"additionalProperties": false,
"properties": {
"contractName": {
"type": "string",
"nullable": false
},
"signingCredential": {
"web3SigningCredential": {
"$ref": "#/components/schemas/Web3SigningCredential",
"nullable": false
},
Expand All @@ -639,14 +656,8 @@
"default": [],
"items": {}
},
"contractAbi": {
"description": "The application binary interface of the solidity contract, optional parameter",
"type": "array",
"items": {},
"nullable": false
},
"contractAddress": {
"description": "Address of the solidity contract, optional parameter",
"description": "Address of the solidity contract",
"type": "string",
"nullable": false
},
Expand Down Expand Up @@ -690,9 +701,9 @@
"default": 60000,
"nullable": false
},
"contractJSON":{
"type": "object",
"description": "The contract object to be passed if not using keychain.",
"contractJSON": {
"$ref": "#/components/schemas/ContractJSON",
"description": "For use when not using keychain, pass the contract in as this variable",
"nullable": false
}
}
Expand Down
Loading

0 comments on commit 15cf65c

Please sign in to comment.