Skip to content

Commit

Permalink
Added checks for few private data collection parameters (#510)
Browse files Browse the repository at this point in the history
* added checks for few pdc parameters
* typo correction in chaincode notification wizard
---------
Signed-off-by: Santosh Kumar <[email protected]>
Co-authored-by: Santosh Kumar <[email protected]>
  • Loading branch information
s7santosh authored Jul 11, 2023
1 parent 151b0e0 commit 8698e01
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/apollo/src/assets/i18n/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@
"channel_policy_update_desc": "<strong>${org}</strong> has submitted a change to the <strong>${channel}</strong> channel. The policy to update the configuration of this channel requires ${number_of_signatures} signatures.",
"channel_policy_update_approved": "<strong>${org}</strong> has submitted a change to the <strong>${channel}</strong> channel.",
"new_channel_request_desc": "<strong>${org}</strong> created a new channel: <strong>${channel}</strong>",
"new_channel_pending_request": "New channel request submittted",
"new_channel_pending_request": "New channel request submitted",
"new_channel_pending_request_desc": "<strong>${org}</strong> submitted request to create a new channel: <strong>${channel}</strong> and is waiting for the orderer signature.",
"signature_for_msp": "Signature for ${msp}:",
"signature_for_msp_placeholder": "Select identity to sign with",
Expand Down
36 changes: 32 additions & 4 deletions packages/stitch/src/libs/proto_handlers/collection_pb_lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ export class CollectionLib {
delete config.maxPeerCount;
delete config.max_peer_count;
}
if (config.requiredPeerCount) {
config.required_peer_count = config.requiredPeerCount; // copy sdk's field to fabric's
delete config.requiredPeerCount;
}

if (config.blockToLive) {
config.block_to_live = config.blockToLive; // copy sdk's field to fabric's
delete config.blockToLive;
}

if (config.memberOnlyRead) {
config.member_only_read = config.memberOnlyRead; // copy sdk's field to fabric's
delete config.memberOnlyRead;
}

if (config.memberOnlyWrite) {
config.member_only_write = config.memberOnlyWrite; // copy sdk's field to fabric's
delete config.memberOnlyWrite;
}

// validation
if (!config.member_orgs_policy) {
Expand Down Expand Up @@ -166,7 +185,11 @@ interface MixedPolicySyntax {

interface Scc {
name: string; // name of your collection
required_peer_count: number; // min number of peers that must get the private data to successfully endorse


required_peer_count: number | null | undefined; // min number of peers that must get the private data to successfully endorse
requiredPeerCount: number | null | undefined; // Fabric SDK format uses this...convert to "required_peer_count"


member_orgs_policy: MixedPolicySyntax | string | null; // sig policy of which orgs have access to the private data - supports peer-cli syntax using string
policy: any | null; // [legacy] fabric-sdk syntax uses this field... convert to "member_orgs_policy"
Expand All @@ -175,10 +198,15 @@ interface Scc {
maxPeerCount: number | null | undefined; // [legacy] fabric sdk" format uses this... convert to "maximum_peer_count"
max_peer_count: number | null | undefined; // [legacy 2] fabric sdk" format uses this... convert to "maximum_peer_count" - this version shouldn't exist

block_to_live: number; // when to expire private data, after this number of blocks the private data is deleted, 0 = unlimited
member_only_read: boolean; // if true, only collection member clients can read private data
member_only_write: boolean; // if true, only collection member clients can write private data
block_to_live: number | null | undefined; // when to expire private data, after this number of blocks the private data is deleted, 0 = unlimited
blockToLive: number | null | undefined; // Fabric SDK format uses this...convert to "block_to_live"


member_only_read: boolean | null | undefined; // if true, only collection member clients can read private data
memberOnlyRead: boolean | null | undefined; // Fabric SDK format uses this...convert to "member_only_read"

member_only_write: boolean | null | undefined; // if true, only collection member clients can write private data
memberOnlyWrite: boolean | null | undefined; // Fabric SDK format uses this...convert to "member_only_write"

// proto file: /v2.0/peer/policy.proto
endorsement_policy: {
Expand Down

0 comments on commit 8698e01

Please sign in to comment.