Skip to content

Commit

Permalink
docs(examples/cbdc): fix mismatch of fabric identities
Browse files Browse the repository at this point in the history
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping)
* An initial fix was deployed in #2802 but only the Mint
function was changed
* This commit changes the crypto material files and
reverts the workaround in PR #2802
The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)
* For critical operations, access control is being performed
by the chaincode by using the call at the begining of the
relevant methods

Signed-off-by: André Augusto <[email protected]>
  • Loading branch information
AndreAugusto11 committed Nov 30, 2023
1 parent e171d15 commit 7c46c08
Show file tree
Hide file tree
Showing 7 changed files with 33,479 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"info": {
{ "info": {
"description": "this file contains data to be used for testing purposes only. It should not be changed. It should remain consistent with the crypto material in the fabric chaincode"
},
"accounts": {
"userA": {
"ethAddress": "0x1A86D6f4b5D30A07D1a94bb232eF916AFe5DbDbc",
"privateKey": "0xb47c3ba5a816dbbb2271db721e76e6c80e58fe54972d26a42f00bc97a92a2535",
"fabricID": "x509::/OU=client/OU=org1/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
"fabricID": "x509::/OU=org1/OU=client/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
},
"bridge": {
"ethAddress": "0xf28d5769171bfbD2B3628d722e58129a6aE15022",
"privateKey": "0x2917bd3b0dced512d3555f171a0979fedd37bb0593883089396d9b893aa0505d",
"fabricID": "x509::/OU=client/OU=org2/OU=department1/CN=bridge::/C=UK/ST=Hampshire/L=Hursley/O=org2.example.com/CN=ca.org2.example.com"
"fabricID": "x509::/OU=org2/OU=client/OU=department1/CN=bridge::/C=UK/ST=Hampshire/L=Hursley/O=org2.example.com/CN=ca.org2.example.com"
},
"userB": {
"ethAddress": "0xB264c626D7D09789AbfD2a431A28a054366e7b63",
"privateKey": "0xfe95d40663e60e9a8a2e1f4153c9e207ac26d928e8a5631647735d91e93be402",
"fabricID": "x509::/OU=client/OU=org1/OU=department1/CN=userB::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
"fabricID": "x509::/OU=org1/OU=client/OU=department1/CN=userB::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
}
},
"gateways": {
Expand All @@ -37,4 +36,4 @@
"id": "d741fb4a-c95c-4205-8afa-758a9423234f"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import * as sinonChai from "sinon-chai";
const bridgedOutAmountKey = "amountBridgedOut";

const USER_A_FABRIC_ID =
"x509::/OU=client/OU=org1/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com";
"x509::/OU=org1/OU=client/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com";

const USER_A_ETH_ADDRESS =
"x509::/OU=client/OU=org1/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com";
"x509::/OU=org1/OU=client/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com";

chai.should();
chai.use(chaiAsPromised);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"userA": {
"ethAddress": "0x1A86D6f4b5D30A07D1a94bb232eF916AFe5DbDbc",
"privateKey": "0xb47c3ba5a816dbbb2271db721e76e6c80e58fe54972d26a42f00bc97a92a2535",
"fabricID": "x509::/OU=client/OU=org1/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
"fabricID": "x509::/OU=org1/OU=client/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
},
"bridge": {
"ethAddress": "0xf28d5769171bfbD2B3628d722e58129a6aE15022",
"privateKey": "0x2917bd3b0dced512d3555f171a0979fedd37bb0593883089396d9b893aa0505d",
"fabricID": "x509::/OU=client/OU=org2/OU=department1/CN=bridge::/C=UK/ST=Hampshire/L=Hursley/O=org2.example.com/CN=ca.org2.example.com"
"fabricID": "x509::/OU=org2/OU=client/OU=department1/CN=bridge::/C=UK/ST=Hampshire/L=Hursley/O=org2.example.com/CN=ca.org2.example.com"
},
"userB": {
"ethAddress": "0xB264c626D7D09789AbfD2a431A28a054366e7b63",
"privateKey": "0xfe95d40663e60e9a8a2e1f4153c9e207ac26d928e8a5631647735d91e93be402",
"fabricID": "x509::/OU=client/OU=org1/OU=department1/CN=userB::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
"fabricID": "x509::/OU=org1/OU=client/OU=department1/CN=userB::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,12 @@ class TokenERC20Contract extends Contract {
* @param {Integer} amount amount of tokens to be minted
* @returns {Object} The balance
*/
async Mint(ctx, amount, minter) {
async Mint(ctx, amount) {
//check contract options are already set first to execute the function
await this.CheckInitialized(ctx);

const minter = ctx.clientIdentity.getID();

// Check minter authorization - this sample assumes Org1 is the central banker with privilege to mint new tokens
const clientMSPID = ctx.clientIdentity.getMSPID();

Expand Down
Loading

0 comments on commit 7c46c08

Please sign in to comment.