From 43980b0cb9e2f19ea550a3a1941b6b7099ef8a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Augusto?= Date: Tue, 17 Oct 2023 20:46:58 +0100 Subject: [PATCH] docs(examples/cbdc): fix mismatch of Fabric identities in GET, POST requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The state keys were not being generated correctly for some reason It was working before without code changes so my best guess is that the Fabric ledger/SDK versions were changed and that's what tripped it up somehow. Fixes #2739 [skip ci] Co-authored-by: Peter Somogyvari Signed-off-by: André Augusto Signed-off-by: Peter Somogyvari --- .../cbdc-erc-20/javascript/lib/tokenERC20.js | 5 +---- .../src/api-calls/fabric-api.js | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/cactus-example-cbdc-bridging-backend/src/fabric-contracts/cbdc-erc-20/javascript/lib/tokenERC20.js b/examples/cactus-example-cbdc-bridging-backend/src/fabric-contracts/cbdc-erc-20/javascript/lib/tokenERC20.js index 869d3acd3b..21168b263c 100644 --- a/examples/cactus-example-cbdc-bridging-backend/src/fabric-contracts/cbdc-erc-20/javascript/lib/tokenERC20.js +++ b/examples/cactus-example-cbdc-bridging-backend/src/fabric-contracts/cbdc-erc-20/javascript/lib/tokenERC20.js @@ -373,7 +373,7 @@ class TokenERC20Contract extends Contract { * @param {Integer} amount amount of tokens to be minted * @returns {Object} The balance */ - async Mint(ctx, amount) { + async Mint(ctx, amount, minter) { //check contract options are already set first to execute the function await this.CheckInitialized(ctx); @@ -384,9 +384,6 @@ class TokenERC20Contract extends Contract { throw new Error("client is not authorized to mint new tokens"); } - // Get ID of submitting client identity - const minter = ctx.clientIdentity.getID(); - const amountInt = parseInt(amount); if (amountInt <= 0) { throw new Error("mint amount must be a positive integer"); diff --git a/examples/cactus-example-cbdc-bridging-frontend/src/api-calls/fabric-api.js b/examples/cactus-example-cbdc-bridging-frontend/src/api-calls/fabric-api.js index 559f0f2aef..69f84a3d84 100644 --- a/examples/cactus-example-cbdc-bridging-frontend/src/api-calls/fabric-api.js +++ b/examples/cactus-example-cbdc-bridging-frontend/src/api-calls/fabric-api.js @@ -27,12 +27,14 @@ export async function getFabricBalance(frontendUser) { } export async function mintTokensFabric(frontendUser, amount) { + const fabricID = getFabricId(frontendUser); + const response = await axios.post( "http://localhost:4000/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/run-transaction", { contractName: FABRIC_CONTRACT_CBDC_ERC20_NAME, channelName: FABRIC_CHANNEL_NAME, - params: [amount.toString()], + params: [amount.toString(), fabricID], methodName: "Mint", invocationType: "FabricContractInvocationType.SEND", signingCredential: {