Skip to content

Commit

Permalink
feat(connector-besu): replace invokeContractV2
Browse files Browse the repository at this point in the history
Signed-off-by: AzaharaC <a.castano.benito@accenture.com>
  • Loading branch information
AzaharaC authored and petermetz committed Apr 20, 2021
1 parent b067fdd commit ecd62ea
Show file tree
Hide file tree
Showing 24 changed files with 218 additions and 1,107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"name": "solc",
"version": "0.7.2+commit.51b20bc0"
},
"networks": {},
"ast": {
"absolutePath": "/home/peter/a/blockchain/cactus/packages/cactus-example-supply-chain-backend/src/main/solidity/BambooHarvestRepository.sol",
"exportedSymbols": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"name": "solc",
"version": "0.7.2+commit.51b20bc0"
},
"networks": {},
"ast": {
"absolutePath": "/home/peter/a/blockchain/cactus/packages/cactus-example-supply-chain-backend/src/main/solidity/BookshelfRepository .sol",
"exportedSymbols": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export class SupplyChainAppDummyInfrastructure {
abi: BambooHarvestRepositoryJSON.abi,
address: contractAddress as string,
bytecode: BambooHarvestRepositoryJSON.bytecode,
contractName: BambooHarvestRepositoryJSON.contractName,
keychainId: keychainPlugin.getKeychainId(),
};
}

Expand Down Expand Up @@ -227,6 +229,8 @@ export class SupplyChainAppDummyInfrastructure {
abi: BookshelfRepositoryJSON.abi,
address: contractAddress as string,
bytecode: BookshelfRepositoryJSON.bytecode,
contractName: BookshelfRepositoryJSON.contractName,
keychainId: keychainPlugin.getKeychainId(),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,35 +89,39 @@ export class SupplyChainCactusPlugin
return this.endpoints;
}
const insertBambooHarvest = new InsertBambooHarvestEndpoint({
contractAddress: this.options.contracts.bambooHarvestRepository.address,
contractAbi: this.options.contracts.bambooHarvestRepository.abi,
// contractAddress: this.options.contracts.bambooHarvestRepository.address,
// contractAbi: this.options.contracts.bambooHarvestRepository.abi,
contractName: this.options.contracts.bambooHarvestRepository.contractName,
apiClient: this.options.quorumApiClient,
web3SigningCredential: this.options
.web3SigningCredential as Web3SigningCredential,
logLevel: this.options.logLevel,
keychainId: this.options.contracts.bambooHarvestRepository.keychainId,
});

const listBambooHarvest = new ListBambooHarvestEndpoint({
contractAddress: this.options.contracts.bambooHarvestRepository.address,
contractAbi: this.options.contracts.bambooHarvestRepository.abi,
// contractAddress: this.options.contracts.bambooHarvestRepository.address,
// contractAbi: this.options.contracts.bambooHarvestRepository.abi,
contractName: this.options.contracts.bambooHarvestRepository.contractName,
apiClient: this.options.quorumApiClient,
logLevel: this.options.logLevel,
keychainId: this.options.contracts.bambooHarvestRepository.keychainId,
});

const insertBookshelf = new InsertBookshelfEndpoint({
contractAddress: this.options.contracts.bookshelfRepository.address,
contractAbi: this.options.contracts.bookshelfRepository.abi,
contractName: this.options.contracts.bookshelfRepository.contractName,
besuApi: this.options.besuApiClient,
web3SigningCredential: this.options
.web3SigningCredential as Web3SigningCredential,
logLevel: this.options.logLevel,
keychainId: this.options.contracts.bookshelfRepository.keychainId,
});

const listBookshelf = new ListBookshelfEndpoint({
contractAddress: this.options.contracts.bookshelfRepository.address,
contractAbi: this.options.contracts.bookshelfRepository.abi,
contractName: this.options.contracts.bookshelfRepository.contractName,
besuApi: this.options.besuApiClient,
logLevel: this.options.logLevel,
keychainId: this.options.contracts.bookshelfRepository.keychainId,
});

const insertShipment = new InsertShipmentEndpoint({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import { InsertBambooHarvestRequest } from "../../generated/openapi/typescript-a

export interface IInsertBambooHarvestEndpointOptions {
logLevel?: LogLevelDesc;
contractAddress: string;
contractAbi: any;
contractName: string;
// contractAbi: any;
apiClient: QuorumApi;
web3SigningCredential: Web3SigningCredential;
keychainId: string;
}

export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint {
Expand All @@ -47,10 +48,10 @@ 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.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
// Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
Checks.nonBlankString(
opts.contractAddress,
opts.contractName,
`${fnTag} options.contractAddress`,
);

Expand Down Expand Up @@ -83,18 +84,18 @@ export class InsertBambooHarvestEndpoint implements IWebServiceEndpoint {
this.log.debug(`${tag} %o`, bambooHarvest);

const {
data: { callOutput, transactionReceipt },
data: { success, callOutput, transactionReceipt },
} = await this.opts.apiClient.apiV1QuorumInvokeContract({
contractAbi: this.opts.contractAbi,
contractAddress: this.opts.contractAddress,
contractName: this.opts.contractName,
invocationType: EthContractInvocationType.SEND,
methodName: "insertRecord",
gas: 1000000,
params: [bambooHarvest],
web3SigningCredential: this.opts.web3SigningCredential,
signingCredential: this.opts.web3SigningCredential,
keychainId: this.opts.keychainId,
});

const body = { callOutput, transactionReceipt };
const body = { success, callOutput, transactionReceipt };
res.status(200);
res.json(body);
} catch (ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import { InsertBookshelfRequest } from "../../generated/openapi/typescript-axios

export interface IInsertBookshelfEndpointOptions {
logLevel?: LogLevelDesc;
contractAddress: string;
contractAbi: any;
// contractAddress: string;
// contractAbi: any;
contractName: string;
besuApi: BesuApi;
web3SigningCredential: Web3SigningCredential;
keychainId: string;
}

export class InsertBookshelfEndpoint implements IWebServiceEndpoint {
Expand All @@ -47,10 +49,10 @@ export class InsertBookshelfEndpoint implements IWebServiceEndpoint {
const fnTag = `${this.className}#constructor()`;
Checks.truthy(opts, `${fnTag} arg options`);
Checks.truthy(opts.besuApi, `${fnTag} options.besuApi`);
Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
// Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
// Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
Checks.nonBlankString(
opts.contractAddress,
opts.contractName,
`${fnTag} options.contractAddress`,
);

Expand Down Expand Up @@ -85,13 +87,13 @@ export class InsertBookshelfEndpoint implements IWebServiceEndpoint {
const {
data: { callOutput, transactionReceipt },
} = await this.opts.besuApi.apiV1BesuInvokeContract({
contractAbi: this.opts.contractAbi,
contractAddress: this.opts.contractAddress,
contractName: this.opts.contractName,
invocationType: EthContractInvocationType.SEND,
methodName: "insertRecord",
gas: 1000000,
params: [bookshelf],
web3SigningCredential: this.opts.web3SigningCredential,
signingCredential: this.opts.web3SigningCredential,
keychainId: this.opts.keychainId,
});

const body = { callOutput, transactionReceipt };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import { BambooHarvestConverter } from "../../model/converter/bamboo-harvest-con

export interface IListBambooHarvestEndpointOptions {
logLevel?: LogLevelDesc;
contractAddress: string;
contractAbi: any;
contractName: string;
// contractAbi: any;
apiClient: QuorumApi;
keychainId: string;
}

export class ListBambooHarvestEndpoint implements IWebServiceEndpoint {
Expand All @@ -46,10 +47,10 @@ 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.contractAbi, `${fnTag} options.contractAbi`);
// Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
// Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
Checks.nonBlankString(
opts.contractAddress,
opts.contractName,
`${fnTag} options.contractAddress`,
);

Expand Down Expand Up @@ -81,15 +82,15 @@ export class ListBambooHarvestEndpoint implements IWebServiceEndpoint {
this.log.debug(`${tag}`);

const { data } = await this.opts.apiClient.apiV1QuorumInvokeContract({
contractAbi: this.opts.contractAbi,
contractAddress: this.opts.contractAddress,
contractName: this.opts.contractName,
invocationType: EthContractInvocationType.CALL,
methodName: "getAllRecords",
gas: 1000000,
params: [],
web3SigningCredential: {
signingCredential: {
type: Web3SigningCredentialType.NONE,
},
keychainId: this.opts.keychainId,
});
const { callOutput } = data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import { BookshelfConverter } from "../../model/converter/bookshelf-converter";

export interface IListBookshelfEndpointOptions {
logLevel?: LogLevelDesc;
contractAddress: string;
contractAbi: any;
contractName: string;
// contractAddress: string;
// contractAbi: any;
besuApi: BesuApi;
keychainId: string;
}

export class ListBookshelfEndpoint implements IWebServiceEndpoint {
Expand All @@ -46,12 +48,9 @@ export class ListBookshelfEndpoint implements IWebServiceEndpoint {
const fnTag = `${this.className}#constructor()`;
Checks.truthy(opts, `${fnTag} arg options`);
Checks.truthy(opts.besuApi, `${fnTag} options.besuApi`);
Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
Checks.nonBlankString(
opts.contractAddress,
`${fnTag} options.contractAddress`,
);
// Checks.truthy(opts.contractAddress, `${fnTag} options.contractAddress`);
// Checks.truthy(opts.contractAbi, `${fnTag} options.contractAbi`);
Checks.nonBlankString(opts.contractName, `${fnTag} options.contractName`);

const level = this.opts.logLevel || "INFO";
const label = this.className;
Expand Down Expand Up @@ -81,15 +80,15 @@ export class ListBookshelfEndpoint implements IWebServiceEndpoint {
this.log.debug(`${tag}`);

const { data } = await this.opts.besuApi.apiV1BesuInvokeContract({
contractAbi: this.opts.contractAbi,
contractAddress: this.opts.contractAddress,
contractName: this.opts.contractName,
invocationType: EthContractInvocationType.CALL,
methodName: "getAllRecords",
gas: 1000000,
params: [],
web3SigningCredential: {
signingCredential: {
type: Web3SigningCredentialType.NONE,
},
keychainId: this.opts.keychainId,
});
const { callOutput } = data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export interface IEthContractDeployment {
address: string;
abi: any;
bytecode: string;
contractName: string;
keychainId: string;
}
Loading

0 comments on commit ecd62ea

Please sign in to comment.