public CommercioDoc(String senderDid, List <String> recipientDids, String uuid, CommercioDocMetadata metadata, String contentUri = null, CommercioDocChecksum checksum = null, CommercioDocEncryptionData encryptionData = null, CommercioDoSign doSign = null) { Trace.Assert(senderDid != null); Trace.Assert(recipientDids != null); Trace.Assert(recipientDids.Count > 0); Trace.Assert(uuid != null); Trace.Assert(metadata != null); // Trace.Assert(contentUri != null); Removed - conflict with opt param //Check if contenturi is valorize 15/07/2021 Luigi Arena test se contenturi è valorizzato if (!string.IsNullOrEmpty(contentUri)) { Trace.Assert(contentUri.Length <= 512, "metadata.content_uri must have a valid length"); } this.uuid = uuid; this.senderDid = senderDid; this.recipientDids = recipientDids; this.contentUri = contentUri; this.metadata = metadata; this.checksum = checksum; this.encryptionData = encryptionData; this.doSign = doSign; }
/// Creates a CommercioDoc from the given [wallet], /// [recipients], [id], [metadata] /// and optionally [contentUri], [checksum], /// [doSign], [encryptedData], [aesKey]. public static async Task <CommercioDoc> fromWallet( Wallet wallet, List <String> recipients, String id, CommercioDocMetadata metadata, String contentUri = null, CommercioDocChecksum checksum = null, CommercioDoSign doSign = null, List <EncryptedData> encryptedData = null, KeyParameter aesKey = null ) { // Build a generic document CommercioDoc commercioDocument = new CommercioDoc( senderDid: wallet.bech32Address, recipientDids: recipients, uuid: id, contentUri: contentUri, metadata: metadata, checksum: checksum, encryptionData: null, doSign: doSign ); // Encrypt its contents, if necessary if ((encryptedData != null) && (encryptedData.Count > 0)) { // Get a default aes key for encryption if needed if (aesKey == null) { aesKey = KeysHelper.generateAesKey(); } // Encrypt its contents, if necessary commercioDocument = await DocsUtils.encryptField( commercioDocument, aesKey, encryptedData, recipients, wallet ); } return(commercioDocument); }
// This doesn't seem to be used, although it is there in Dart code... I will keep it as a placeholder // Use static HttpClient to avoid exhausting system resources for network connections. // private static HttpClient client = new HttpClient(); #endregion #region Properties #endregion #region Constructors #endregion #region Public Methods /// Creates a new transaction that allows to share the document associated /// with the given [contentUri] and having the given [metadata] /// and [checksum]. If [encryptedData] is specified, encrypts the proper /// data for the specified [recipients] and then sends the transaction /// to the blockchain. public static async Task <TransactionResult> shareDocument( String id, CommercioDocMetadata metadata, List <String> recipients, Wallet wallet, CommercioDoSign doSign = null, CommercioDocChecksum checksum = null, KeyParameter aesKey = null, List <EncryptedData> encryptedData = null, StdFee fee = null, String contentUri = null, BroadcastingMode mode = BroadcastingMode.SYNC ) { // Build a generic document CommercioDoc commercioDoc = await CommercioDocHelper.fromWallet( wallet : wallet, recipients : recipients, id : id, metadata : metadata, checksum : checksum, contentUri : contentUri, doSign : doSign, encryptedData : encryptedData, aesKey : aesKey ); // Build the tx message MsgShareDocument msg = new MsgShareDocument(document: commercioDoc); // Careful here, Eugene: we are passing a list of BaseType containing the derived MsgSetDidDocument msg return(await TxHelper.createSignAndSendTx(new List <StdMsg> { msg }, wallet, fee : fee, mode : mode)); }
public CommercioDoc(String senderDid, List<String> recipientDids, String uuid, CommercioDocMetadata metadata, String contentUri = null, CommercioDocChecksum checksum = null, CommercioDocEncryptionData encryptionData = null, CommercioDoSign doSign = null) { Trace.Assert(senderDid != null); Trace.Assert(recipientDids != null); Trace.Assert(recipientDids.Count > 0); Trace.Assert(uuid != null); Trace.Assert(metadata != null); // Trace.Assert(contentUri != null); Removed - conflict with opt param this.uuid = uuid; this.senderDid = senderDid; this.recipientDids = recipientDids; this.contentUri = contentUri; this.metadata = metadata; this.checksum = checksum; this.encryptionData = encryptionData; this.doSign = doSign; }