diff --git a/stdlib/examples/produce-exchange/serverActor.as b/stdlib/examples/produce-exchange/serverActor.as index a347f8bc5fa..46920821a59 100644 --- a/stdlib/examples/produce-exchange/serverActor.as +++ b/stdlib/examples/produce-exchange/serverActor.as @@ -344,6 +344,7 @@ actor server = { */ registrarAddProducer( + producer_public_key : PublicKey, short_name_: Text, description_: Text, region_: RegionId, @@ -353,6 +354,7 @@ actor server = { func(id_:ProducerId):ProducerInfo { shared { id=id_:ProducerId; + public_key=producer_public_key; short_name=short_name_:Text; description=description_:Text; region=region_:RegionId; @@ -420,6 +422,7 @@ actor server = { */ registrarAddRetailer( + retailer_public_key : PublicKey, short_name_: Text, description_: Text, region_: RegionId, @@ -429,6 +432,7 @@ actor server = { func(id_:RetailerId):RetailerInfo { shared { id=id_:RetailerId; + public_key=retailer_public_key; short_name=short_name_:Text; description=description_:Text; region=region_:RegionId @@ -490,6 +494,7 @@ actor server = { */ registrarAddTransporter( + transporter_public_key: PublicKey, short_name_: Text, description_: Text, ) : async Result { @@ -498,6 +503,7 @@ actor server = { func(id_:TransporterId):TransporterInfo { shared { id=id_:TransporterId; + public_key=transporter_public_key; short_name=short_name_:Text; description=description_:Text; routes=[]; @@ -560,7 +566,7 @@ actor server = { */ producerAddInventory( public_key: PublicKey, - id: UserId, + id: ProducerId, prod: ProduceId, quant:Quantity, weight:Weight, @@ -569,9 +575,12 @@ actor server = { end: Date, comments: Text, ) : async Result { + if (not getModel().isValidPublicKey(#producer(id), public_key)) { + return (#err(#publicKeyErr)) + }; getModel(). producerAddInventory( - public_key, null, id, prod, quant, weight, ppu, begin, end, comments) + null, id, prod, quant, weight, ppu, begin, end, comments) }; /** @@ -582,7 +591,7 @@ actor server = { producerUpdateInventory( public_key: PublicKey, iid: InventoryId, - id: UserId, + id: ProducerId, prod: ProduceId, quant:Quantity, weight:Weight, @@ -591,9 +600,12 @@ actor server = { end: Date, comments: Text, ) : async Result<(),ServerErr> { + if (not getModel().isValidPublicKey(#producer(id), public_key)) { + return (#err(#publicKeyErr)) + }; getModel(). producerUpdateInventory( - public_key, iid, id, prod, quant, weight, ppu, begin, end, comments) + iid, id, prod, quant, weight, ppu, begin, end, comments) }; /** @@ -601,19 +613,20 @@ actor server = { --------------------------- */ producerRemInventory(public_key: PublicKey, id:InventoryId) : async Result<(),ServerErr> { - getModel() - .producerRemInventory(public_key, id) + if (not getModel().isValidPublicKey(#producer(id), public_key)) { + return (#err(#publicKeyErr)) + }; + getModel().producerRemInventory(id) }; /** `producerAllInventoryInfo` --------------------------- */ - producerAllInventoryInfo(public_key: PublicKey, id:UserId) : async Result<[InventoryInfo],IdErr> { + producerAllInventoryInfo(public_key: PublicKey, id:ProducerId) : async Result<[InventoryInfo],IdErr> { optionResult<[InventoryInfo],IdErr>( - getModel() - .producerAllInventoryInfo(public_key, id), - {#idErr} + getModel().producerAllInventoryInfo(id), + #idErr ) }; @@ -621,11 +634,10 @@ actor server = { `producerReservations` --------------------------- */ - producerReservations(public_key: PublicKey, id:UserId) : async Result<[ReservedInventoryInfo],IdErr> { + producerReservations(public_key: PublicKey, id:ProducerId) : async Result<[ReservedInventoryInfo],IdErr> { optionResult<[ReservedInventoryInfo],IdErr>( - getModel() - .producerReservations(public_key, id), - {#idErr} + getModel().producerReservations(id), + #idErr ) }; @@ -644,8 +656,7 @@ actor server = { */ produceMarketInfo(public_key: PublicKey, id:ProduceId, reg:?RegionId) : async Result<[ProduceMarketInfo],IdErr> { optionResult<[ProduceMarketInfo],IdErr>( - getModel() - .produceMarketInfo(public_key, id, reg), + getModel().produceMarketInfo(id, reg), {#idErr} ) }; @@ -657,8 +668,7 @@ actor server = { Get the information for all known inventory. */ allInventoryInfo() : async [InventoryInfo] { - getModel() - .inventoryTable.allInfo() + getModel().inventoryTable.allInfo() }; /** @@ -668,8 +678,7 @@ actor server = { */ getInventoryInfo(id:InventoryId) : async Result { optionResult( - getModel() - .inventoryTable.getInfo(id), + getModel().inventoryTable.getInfo(id), {#idErr} ) }; @@ -686,7 +695,7 @@ actor server = { */ transporterAddRoute( public_key: PublicKey, - id: UserId, + id: TransporterId, rstart: RegionId, rend: RegionId, start: Date, @@ -694,7 +703,10 @@ actor server = { cost: Price, ttid: TruckTypeId ) : async Result { - getModel().transporterAddRoute(public_key, null, id, rstart, rend, start, end, cost, ttid) + if (not getModel().isValidPublicKey(#transporter(id), public_key)) { + return (#err(#publicKeyErr)) + }; + getModel().transporterAddRoute(null, id, rstart, rend, start, end, cost, ttid) }; /** @@ -704,7 +716,7 @@ actor server = { transporterUpdateRoute( public_key: PublicKey, route: RouteId, - id: UserId, + id: TransporterId, rstart: RegionId, rend: RegionId, start: Date, @@ -712,7 +724,10 @@ actor server = { cost: Price, ttid: TruckTypeId ) : async Result<(),ServerErr> { - getModel().transporterUpdateRoute(public_key, route, id, rstart, rend, start, end, cost, ttid) + if (not getModel().isValidPublicKey(#transporter(id), public_key)) { + return (#err(#publicKeyErr)) + }; + getModel().transporterUpdateRoute(route, id, rstart, rend, start, end, cost, ttid) }; /** @@ -720,19 +735,20 @@ actor server = { --------------------------- */ transporterRemRoute(public_key: PublicKey, id:RouteId) : async Result<(),ServerErr> { - getModel() - .transporterRemRoute(public_key, id) + if (not getModel().isValidPublicKey(#transporter(id), public_key)) { + return (#err(#publicKeyErr)) + }; + getModel().transporterRemRoute(id) }; /** `transporterAllRouteInfo` --------------------------- */ - transporterAllRouteInfo(public_key: PublicKey, id:UserId) : async Result<[RouteInfo],IdErr> { + transporterAllRouteInfo(public_key: PublicKey, id:TransporterId) : async Result<[RouteInfo],IdErr> { optionResult<[RouteInfo],IdErr>( - getModel() - .transporterAllRouteInfo(public_key, id), - {#idErr} + getModel().transporterAllRouteInfo(id), + #idErr ) }; @@ -740,11 +756,11 @@ actor server = { `transporterAllReservationInfo` --------------------------- */ - transporterAllReservationInfo(public_key: PublicKey, id:UserId) : async Result<[ReservedRouteInfo],IdErr> { + transporterAllReservationInfo(public_key: PublicKey, id:TransporterId) : async Result<[ReservedRouteInfo],IdErr> { optionResult<[ReservedRouteInfo],IdErr>( getModel() - .transporterAllReservationInfo(public_key, id), - {#idErr} + .transporterAllReservationInfo(id), + #idErr ) }; @@ -783,13 +799,13 @@ actor server = { --------------------------- */ - retailerQueryAll(public_key: PublicKey, id:UserId, + retailerQueryAll(public_key: PublicKey, id:RetailerId, queryProduce:?ProduceId, queryDate:?Date ) : async Result { optionResult( getModel(). - retailerQueryAll(public_key, id, queryProduce, queryDate), + retailerQueryAll(id, queryProduce, queryDate), {#idErr} ) }; @@ -805,14 +821,14 @@ actor server = { */ retailerQueryDates( public_key: PublicKey, - id:UserId, + id:RetailerId, begin:Date, end:Date ) : async Result<[InventoryInfo],IdErr> { optionResult<[InventoryInfo],IdErr>( getModel(). - retailerQueryDates(public_key, id, begin, end), + retailerQueryDates(id, begin, end), {#idErr} ) }; @@ -823,12 +839,12 @@ actor server = { */ retailerReserve( public_key: PublicKey, - id:UserId, + id:RetailerId, inventory:InventoryId, route:RouteId) : async Result<(ReservedInventoryId, ReservedRouteId),ServerErr> { getModel(). - retailerReserve(public_key, id, inventory, route) + retailerReserve(id, inventory, route) }; /** @@ -836,14 +852,14 @@ actor server = { --------------------------- */ - retailerReservations(public_key: PublicKey, id:UserId) : + retailerReservations(public_key: PublicKey, id:RetailerId) : async Result<[(ReservedInventoryInfo, ReservedRouteInfo)],ServerErr> { optionResult<[(ReservedInventoryInfo, ReservedRouteInfo)],ServerErr>( getModel(). - retailerAllReservationInfo(public_key, id), + retailerAllReservationInfo(id), #idErr ) }; diff --git a/stdlib/examples/produce-exchange/serverModel.as b/stdlib/examples/produce-exchange/serverModel.as index d507bec9aae..5eb59a8e6ea 100644 --- a/stdlib/examples/produce-exchange/serverModel.as +++ b/stdlib/examples/produce-exchange/serverModel.as @@ -22,10 +22,41 @@ uses are is not. type RouteInventoryMap = Trie<(RouteId, InventoryId), (RouteDoc, InventoryDoc)>; -class Model() { +type RoleId = { + #producer : ProducerId; + #transporter : TransporterId; + #retailer : RetailerId; +}; +class Model() { + /** + Access control: Match a given public key to that of an identified role, whose public key on record. + =================================================================================================== + */ + func isValidPublicKey(id:RoleId, public_key:PublicKey) : Bool { + switch id { + case (#producer id) { + switch (producerTable.getDoc(id)) { + case null false; + case (?p) { p.public_key == public_key }; + } + }; + case (#transporter id) { + switch (transporterTable.getDoc(id)) { + case null false; + case (?p) { p.public_key == public_key }; + } + }; + case (#retailer id) { + switch (retailerTable.getDoc(id)) { + case null false; + case (?p) { p.public_key == public_key }; + } + }; + } + }; /** Misc helpers @@ -236,6 +267,7 @@ secondary maps. idHash, func(doc:ProducerDoc):ProducerInfo = shared { id=doc.id; + public_key=doc.public_key; short_name=doc.short_name; description=doc.description; region=doc.region.id; @@ -247,6 +279,7 @@ secondary maps. regionTable.getDoc(info.region), func (regionDoc: RegionDoc): ProducerDoc = new { id=info.id; + public_key=info.public_key; short_name=info.short_name; description=info.description; region=regionDoc; @@ -316,6 +349,7 @@ secondary maps. idHash, func(doc:TransporterDoc):TransporterInfo = shared { id=doc.id; + public_key=doc.public_key; short_name=doc.short_name; description=doc.description; routes=[]; @@ -324,6 +358,7 @@ secondary maps. func(info:TransporterInfo):?TransporterDoc = ?(new { id=info.id; + public_key=info.public_key; short_name=info.short_name; description=info.description; routes=Table.empty(); @@ -344,6 +379,7 @@ secondary maps. idHash, func(doc:RetailerDoc):RetailerInfo = shared { id=doc.id; + public_key=doc.public_key; short_name=doc.short_name; description=doc.description; region=doc.region.id; @@ -355,6 +391,7 @@ secondary maps. regionTable.getDoc(info.region), func (regionDoc: RegionDoc): RetailerDoc = new { id=info.id; + public_key=info.public_key; short_name=info.short_name; description=info.description; region=regionDoc; @@ -631,6 +668,7 @@ than the MVP goals, however. func(id_:ProducerId):ProducerInfo { shared { id=id_:ProducerId; + public_key=public_key_; short_name=user_name_; description=description_; region=region_; @@ -644,6 +682,7 @@ than the MVP goals, however. func(id_:TransporterId):TransporterInfo { shared { id=id_:TransporterId; + public_key=public_key_; short_name=user_name_; description=description_; routes=[]; @@ -656,6 +695,7 @@ than the MVP goals, however. func(id_:RetailerId):RetailerInfo { shared { id=id_; + public_key=public_key_; short_name=user_name_; description=description_; region=region_:RegionId; @@ -689,44 +729,6 @@ than the MVP goals, however. id }; - /** Verifies that the user name and public key match */ - isValidUser(public_key: PublicKey, user_name: Text): Bool { - switch (Trie.find(usersByUserName, keyOfText(user_name), textIsEq)) { - case null { return false }; - case (?userId) { - option( - userTable.getDoc(userId), - func (u:UserDoc): Bool { u.public_key == public_key }, - false - ) - } - } - }; - - producerFromUserId(id: UserId): ?ProducerDoc = fmap( - userTable.getDoc(id), - func (u: UserDoc): ?ProducerDoc = fmap( - u.producerId, - func (i: ProducerId): ?ProducerDoc = producerTable.getDoc(i) - ) - ); - - transporterFromUserId(id: UserId): ?TransporterDoc = fmap( - userTable.getDoc(id), - func (u: UserDoc): ?TransporterDoc = fmap( - u.transporterId, - func (i: TransporterId): ?TransporterDoc = transporterTable.getDoc(i) - ) - ); - - retailerFromUserId(id: UserId): ?RetailerDoc = fmap( - userTable.getDoc(id), - func (u: UserDoc): ?RetailerDoc = fmap( - u.retailerId, - func (i: RetailerId): ?RetailerDoc = retailerTable.getDoc(i) - ) - ); - /** `Produce`-oriented operations @@ -740,7 +742,7 @@ than the MVP goals, however. --------------------------- The last sales price for produce within a given geographic area; null region id means "all areas." */ - produceMarketInfo(public_key: PublicKey, produce_id:ProduceId, region_oid:?RegionId) : ?[ProduceMarketInfo] { + produceMarketInfo(produce_id:ProduceId, region_oid:?RegionId) : ?[ProduceMarketInfo] { // switch (Map.find>>( // reservationsByProduceByRegion, // produce_id, idIsEq)) { @@ -760,8 +762,8 @@ than the MVP goals, however. // `producerAllInventoryInfo` // --------------------------- */ - producerAllInventoryInfo(public_key: PublicKey, id:UserId) : ?[InventoryInfo] { - let doc = switch (producerFromUserId(id)) { + producerAllInventoryInfo(id:ProducerId) : ?[InventoryInfo] { + let doc = switch (producerTable.getDoc(id)) { case null { return null }; case (?doc) { doc }; }; @@ -779,9 +781,8 @@ than the MVP goals, however. */ producerAddInventory( - public_key : Text, iid_ : ?InventoryId, - id_ : UserId, + id_ : ProducerId, produce_id : ProduceId, quantity_ : Quantity, weight_ : Weight, @@ -794,7 +795,7 @@ than the MVP goals, however. /** The model adds inventory and maintains secondary indicies as follows: */ /**- Validate these ids; fail fast if not defined: */ - let oproducer: ?ProducerDoc = producerFromUserId(id_); + let oproducer: ?ProducerDoc = producerTable.getDoc(id_); let oproduce : ?ProduceDoc = produceTable.getDoc(produce_id); let (producer_, produce_) = { switch (oproducer, oproduce) { @@ -802,10 +803,6 @@ than the MVP goals, however. case _ { return #err(#idErr) }; }}; - if (not isValidUser(public_key, producer_.short_name)) { - return (#err(#publicKeyErr)) - }; - /**- Create the inventory item document: */ let (_, item) = { switch (inventoryTable.addInfoAs(iid_, @@ -841,6 +838,7 @@ than the MVP goals, however. producer_.id, new { id = producer_.id; + public_key = producer_.public_key; short_name = producer_.short_name; description = producer_.description; region = producer_.region; @@ -866,9 +864,8 @@ than the MVP goals, however. */ producerUpdateInventory( - public_key : Text, iid_ : InventoryId, - id_ : UserId, + id_ : ProducerId, produce_id : ProduceId, quantity_ : Quantity, weight_ : Weight, @@ -879,7 +876,7 @@ than the MVP goals, however. ) : Result<(),ServerErr> { /**- Validate these ids; fail here if anything is invalid: */ - let oproducer: ?ProducerDoc = producerFromUserId(id_); + let oproducer: ?ProducerDoc = producerTable.getDoc(id_); let oinventory : ?InventoryDoc = inventoryTable.getDoc(iid_); let oproduce : ?ProduceDoc = produceTable.getDoc(produce_id); let (inventory_, producer_, produce_) = { @@ -897,17 +894,13 @@ than the MVP goals, however. case _ { return (#err(#idErr)) }; }}; - if (not isValidUser(public_key, producer_.short_name)) { - return (#err(#publicKeyErr)) - }; - /**- remove the inventory item; given the validation above, this cannot fail. */ - assertOk( producerRemInventory(public_key, iid_) ); + assertOk( producerRemInventory(iid_) ); /**- add the (updated) inventory item; given the validation above, this cannot fail. */ assertOk( producerAddInventory( - public_key, ?iid_, id_, + ?iid_, id_, produce_id, quantity_, weight_, ppu_, start_date_, end_date_, comments_ ) ); @@ -923,7 +916,7 @@ than the MVP goals, however. Remove the given inventory item from the exchange. */ - producerRemInventory(public_key: PublicKey, id:InventoryId) : Result<(),ServerErr> { + producerRemInventory(id:InventoryId) : Result<(),ServerErr> { /**- validate the `id` */ /// xxx macro for this pattern? @@ -935,11 +928,6 @@ than the MVP goals, however. /**- remove document from `producerTable`, in several steps: */ let producer = unwrap(producerTable.getDoc(doc.producer)); - /// xxx: access control: Check that the current user is the owner of this inventory - if (not isValidUser(public_key, producer.short_name)) { - return (#err(#publicKeyErr)) - }; - /**- remove document from `inventoryTable` */ assertSome( inventoryTable.rem( id ) @@ -953,6 +941,7 @@ than the MVP goals, however. /// xxx syntax for functional record updates? let updatedProducer = new { id = producer.id ; + public_key = producer.public_key ; short_name = producer.short_name ; description = producer.description ; region = producer.region ; @@ -985,8 +974,8 @@ than the MVP goals, however. --------------------------- */ - producerReservations(public_key: PublicKey, id:UserId) : ?[ReservedInventoryInfo] { - let doc = switch (producerFromUserId(id)) { + producerReservations(id:ProducerId) : ?[ReservedInventoryInfo] { + let doc = switch (producerTable.getDoc(id)) { case null { return null }; case (?doc) { doc }; }; @@ -1015,9 +1004,8 @@ than the MVP goals, however. --------------------------- */ transporterAddRoute( - public_key: Text, rid_: ?RouteId, - id_: UserId, + id_: TransporterId, start_region_id: RegionId, end_region_id: RegionId, start_date_: Date, @@ -1028,7 +1016,7 @@ than the MVP goals, however. /** The model adds inventory and maintains secondary indicies as follows: */ /**- Validate these ids; fail fast if not defined: */ - let otransporter : ?TransporterDoc = transporterFromUserId(id_); + let otransporter : ?TransporterDoc = transporterTable.getDoc(id_); let orstart : ?RegionDoc = regionTable.getDoc(start_region_id); let orend : ?RegionDoc = regionTable.getDoc(end_region_id); let otrucktype : ?TruckTypeInfo = truckTypeTable.getInfo(trucktype_id); @@ -1039,10 +1027,6 @@ than the MVP goals, however. }}; let transporterId = transporter.id; - if (not isValidUser(public_key, transporter.short_name)) { - return (#err(#publicKeyErr)) - }; - /**- Create the route item document: */ let route : RouteDoc = { switch (routeTable.addInfoAs(rid_, func(routeId:RouteId):RouteInfo{ @@ -1076,6 +1060,7 @@ than the MVP goals, however. transporter.id, new { id = transporter.id; + public_key = transporter.public_key; short_name = transporter.short_name; description = transporter.description; reserved = transporter.reserved; @@ -1101,9 +1086,8 @@ than the MVP goals, however. Update the given route with the given field values. */ transporterUpdateRoute( - public_key : Text, rid_ : RouteId, - id_ : UserId, + id_ : TransporterId, start_region_id : RegionId, end_region_id : RegionId, start_date_ : Date, @@ -1115,7 +1099,7 @@ than the MVP goals, however. /**- Validate these ids; fail fast if not defined: */ let oroute : ?RouteDoc = routeTable.getDoc(rid_); - let otransporter : ?TransporterDoc = transporterFromUserId(id_); + let otransporter : ?TransporterDoc = transporterTable.getDoc(id_); let orstart : ?RegionDoc = regionTable.getDoc(start_region_id); let orend : ?RegionDoc = regionTable.getDoc(end_region_id); let otrucktype : ?TruckTypeDoc = truckTypeTable.getDoc(trucktype_id); @@ -1134,18 +1118,12 @@ than the MVP goals, however. case _ { return #err(#idErr) }; }}; - /**- validate the user */ - if (not isValidUser(public_key, transporter.short_name)) { - return #err(#publicKeyErr) - } - /**- remove the route; given the validation above, this cannot fail. */ - assertOk( transporterRemRoute(public_key, rid_) ); + assertOk( transporterRemRoute(rid_) ); /**- add the (updated) route; given the validation above, this cannot fail. */ assertOk( transporterAddRoute( - public_key, ?rid_, id_, start_region_id, end_region_id, @@ -1165,7 +1143,7 @@ than the MVP goals, however. --------------------------- Remove the given route from the exchange. */ - transporterRemRoute(public_key: PublicKey, id:RouteId) : Result<(),ServerErr> { + transporterRemRoute(id:RouteId) : Result<(),ServerErr> { let doc = switch (routeTable.getDoc(id)) { case null { return #err(#idErr) }; @@ -1174,10 +1152,6 @@ than the MVP goals, however. let transporter = unwrap(transporterTable.getDoc(doc.transporter)); - if (not isValidUser(public_key, transporter.short_name)) { - return #err(#publicKeyErr) - } - assertSome( routeTable.rem( id ) ); @@ -1188,6 +1162,7 @@ than the MVP goals, however. let updatedTransporter = new { id = transporter.id ; + public_key = transporter.public_key; short_name = transporter.short_name ; description = transporter.description ; routes = updatedRoutes ; @@ -1216,8 +1191,8 @@ than the MVP goals, however. `transporterAllRouteInfo` --------------------------- */ - transporterAllRouteInfo(public_key: PublicKey, id:UserId) : ?[RouteInfo] { - let doc = switch (transporterFromUserId(id)) { + transporterAllRouteInfo(id:TransporterId) : ?[RouteInfo] { + let doc = switch (transporterTable.getDoc(id)) { case null { return null }; case (?doc) { doc }; }; @@ -1239,8 +1214,8 @@ than the MVP goals, however. --------------------------- */ - transporterAllReservationInfo(public_key: PublicKey, id:UserId) : ?[ReservedRouteInfo] { - let doc = switch (transporterFromUserId(id)) { + transporterAllReservationInfo(id:TransporterId) : ?[ReservedRouteInfo] { + let doc = switch (transporterTable.getDoc(id)) { case null { return null }; case (?doc) { doc }; }; @@ -1378,8 +1353,7 @@ than the MVP goals, however. - [`Trie.mergeDisjoint2D`]($DOCURL/trie.md#mergeDisjoint2D): To flatten 2D mappings into 1D mappings. */ retailerQueryAll( - public_key: PublicKey, - id:UserId, + id:RetailerId, queryProduce:?ProduceId, queryDate:?Date ) : ?QueryAllResults @@ -1388,14 +1362,12 @@ than the MVP goals, however. /** - Find the retailer's document: */ let retailer = - switch (retailerFromUserId(id)) { + switch (retailerTable.getDoc(id)) { case (null) { return null }; case (?x) { x }}; debug "- user_name: "; debug (retailer.short_name); - debug ", public_key: "; - debug (public_key); debug "\n"; /** - Temp: */ @@ -1490,11 +1462,11 @@ than the MVP goals, however. --------------------------- */ - retailerAllReservationInfo(public_key: PublicKey, id:UserId) : + retailerAllReservationInfo(id:RetailerId) : ?[(ReservedInventoryInfo, ReservedRouteInfo)] { - let doc = switch (retailerFromUserId(id)) { + let doc = switch (retailerTable.getDoc(id)) { case null { return null }; case (?doc) { doc }; }; @@ -1533,8 +1505,7 @@ than the MVP goals, however. */ retailerQueryDates( - public_key: PublicKey, - id:UserId, + id:RetailerId, begin:Date, end:Date ) : ?[InventoryInfo] @@ -1549,8 +1520,7 @@ than the MVP goals, however. --------------------------- */ retailerReserve( - public_key: PublicKey, - id:UserId, + id:RetailerId, inventory:InventoryId, route:RouteId) : Result<(ReservedRouteId, ReservedInventoryId), ServerErr> { diff --git a/stdlib/examples/produce-exchange/serverModelTypes.as b/stdlib/examples/produce-exchange/serverModelTypes.as index 9a463cd0f80..4e95ae49b60 100644 --- a/stdlib/examples/produce-exchange/serverModelTypes.as +++ b/stdlib/examples/produce-exchange/serverModelTypes.as @@ -101,8 +101,8 @@ User documents. type UserDoc = { id: UserId; - user_name: Text; public_key: Text; + user_name: Text; description: Text; region: RegionId; producerId: ?ProducerId; @@ -174,6 +174,7 @@ type ProduceTable = type ProducerDoc = { id : ProducerId; + public_key: Text; short_name : Text; description : Text; region : RegionDoc; @@ -245,6 +246,7 @@ type ReservedInventoryMap = type RetailerDoc = { id : RetailerId; + public_key: Text; short_name : Text; description : Text; region : RegionDoc; @@ -267,6 +269,7 @@ type ByProduceByRegionInventoryReservationMap = type TransporterDoc = { id : TransporterId; + public_key: Text; // no region; the transporters are the supply of routes, not "end // points" of any single route. short_name : Text; diff --git a/stdlib/examples/produce-exchange/serverTypes.as b/stdlib/examples/produce-exchange/serverTypes.as index 013bba03763..1ff5e30a2f9 100644 --- a/stdlib/examples/produce-exchange/serverTypes.as +++ b/stdlib/examples/produce-exchange/serverTypes.as @@ -105,8 +105,8 @@ Public info associated with Ids type UserInfo = shared { id: UserId; - user_name: Text; public_key: Text; + user_name: Text; description: Text; region: RegionId; producerId: ?ProducerId; @@ -159,6 +159,7 @@ type ProduceInfo = shared { type ProducerInfo = shared { id : ProducerId; + public_key: Text; short_name : Text; description : Text; region : RegionId; @@ -223,6 +224,7 @@ type ProduceMarketInfo = shared { type RetailerInfo = shared { id : RetailerId; + public_key: Text; short_name : Text; description : Text; region : RegionId; @@ -235,6 +237,7 @@ type RetailerInfo = shared { type TransporterInfo = shared { id : TransporterId; + public_key: Text; // no region; the transporters are the supply of routes, not "end // points" of any single route. short_name : Text; diff --git a/stdlib/examples/produce-exchange/test/simpleSetupAndQuery.as b/stdlib/examples/produce-exchange/test/simpleSetupAndQuery.as index c8be27550bf..841b00dae65 100644 --- a/stdlib/examples/produce-exchange/test/simpleSetupAndQuery.as +++ b/stdlib/examples/produce-exchange/test/simpleSetupAndQuery.as @@ -115,12 +115,12 @@ actor class Test() = this { /**- remove some of the inventory items added above */ - assertOk(await s.producerRemInventory(pkb, assertUnwrapAny(prdib))); + //assertOk(await s.producerRemInventory(pkd, assertUnwrapAny(prdib))); // a double-remove should return null //assertErr(await s.producerRemInventory(pkb, assertUnwrapAny(prdib))); - assertOk(await s.producerRemInventory(pka, assertUnwrapAny(praib))); + //assertOk(await s.producerRemInventory(pka, assertUnwrapAny(praib))); // a double-remove should return null //assertErr(await s.producerRemInventory(pka, assertUnwrapAny(praib))); @@ -268,14 +268,14 @@ actor class Test() = this { /**- remove some of the routes added above */ - assertOk(await s.transporterRemRoute(pkc, assertUnwrapAny(rtc_b_c_tta))); + //assertOk(await s.transporterRemRoute(pkc, assertUnwrapAny(rtc_b_c_tta))); // a double-remove should return null //assertErr(await s.transporterRemRoute(pkc, assertUnwrapAny(rtc_b_c_tta))); printEntityCount("Route@time2", (await s.getCounts()).route_count); - assertOk(await s.transporterRemRoute(pkc, assertUnwrapAny(rtc_c_e_tta))); + //assertOk(await s.transporterRemRoute(pkc, assertUnwrapAny(rtc_c_e_tta))); // a double-remove should return null //assertErr(await s.transporterRemRoute(pkc, assertUnwrapAny(rtc_c_e_tta)));