@@ -33,6 +33,7 @@ import { DwnInterfaceName, DwnMethodName } from '../../../core/message.js';
3333export type RecordsWriteOptions = {
3434 recipient ?: string ;
3535 protocol ?: string ;
36+ protocolPath ?: string ;
3637 contextId ?: string ;
3738 schema ?: string ;
3839 recordId ?: string ;
@@ -137,7 +138,10 @@ export class RecordsWrite extends Message<RecordsWriteMessage> {
137138 * @param options.dateModified If `undefined`, it will be auto-filled with current time.
138139 */
139140 public static async create ( options : RecordsWriteOptions ) : Promise < RecordsWrite > {
140- const currentTime = getCurrentTimeInHighPrecision ( ) ;
141+ if ( ( options . protocol === undefined && options . protocolPath !== undefined ) ||
142+ ( options . protocol !== undefined && options . protocolPath === undefined ) ) {
143+ throw new Error ( '`protocol` and `protocolPath` must both be defined or undefined at the same time' ) ;
144+ }
141145
142146 if ( ( options . data === undefined && options . dataCid === undefined ) ||
143147 ( options . data !== undefined && options . dataCid !== undefined ) ) {
@@ -152,10 +156,13 @@ export class RecordsWrite extends Message<RecordsWriteMessage> {
152156 const dataCid = options . dataCid ?? await Cid . computeDagPbCidFromBytes ( options . data ! ) ;
153157 const dataSize = options . dataSize ?? options . data ! . length ;
154158
159+ const currentTime = getCurrentTimeInHighPrecision ( ) ;
160+
155161 const descriptor : RecordsWriteDescriptor = {
156162 interface : DwnInterfaceName . Records ,
157163 method : DwnMethodName . Write ,
158164 protocol : options . protocol ,
165+ protocolPath : options . protocolPath ,
159166 recipient : options . recipient ! ,
160167 schema : options . schema ,
161168 parentId : options . parentId ,
@@ -270,6 +277,7 @@ export class RecordsWrite extends Message<RecordsWriteMessage> {
270277 dateCreated : unsignedMessage . descriptor . dateCreated ,
271278 contextId : unsignedMessage . contextId ,
272279 protocol : unsignedMessage . descriptor . protocol ,
280+ protocolPath : unsignedMessage . descriptor . protocolPath ,
273281 parentId : unsignedMessage . descriptor . parentId ,
274282 schema : unsignedMessage . descriptor . schema ,
275283 dataFormat : unsignedMessage . descriptor . dataFormat ,
0 commit comments