コード例 #1
0
 public FileUpdateTransactionBody(Hashgraph.UpdateFileParams updateParameters) : this()
 {
     if (updateParameters is null)
     {
         throw new ArgumentNullException(nameof(updateParameters), "File Update Parameters argument is missing. Please check that it is not null.");
     }
     if (updateParameters.File is null)
     {
         throw new ArgumentNullException(nameof(updateParameters.File), "File identifier is missing. Please check that it is not null.");
     }
     if (updateParameters.Endorsements is null &&
         updateParameters.Contents is null &&
         updateParameters.Memo is null)
     {
         throw new ArgumentException(nameof(updateParameters), "The File Update parameters contain no update properties, it is blank.");
     }
     FileID = new FileID(updateParameters.File);
     if (!(updateParameters.Endorsements is null))
     {
         Keys = new KeyList(updateParameters.Endorsements);
     }
     if (updateParameters.Contents.HasValue)
     {
         Contents = ByteString.CopyFrom(updateParameters.Contents.Value.ToArray());
     }
     if (!(updateParameters.Memo is null))
     {
         Memo = updateParameters.Memo;
     }
 }
コード例 #2
0
 internal FileAppendTransactionBody(Hashgraph.AppendFileParams appendParameters) : this()
 {
     if (appendParameters is null)
     {
         throw new ArgumentNullException(nameof(appendParameters), "File Update Parameters argument is missing. Please check that it is not null.");
     }
     if (appendParameters.File is null)
     {
         throw new ArgumentNullException(nameof(appendParameters.File), "File identifier is missing. Please check that it is not null.");
     }
     FileID   = new FileID(appendParameters.File);
     Contents = ByteString.CopyFrom(appendParameters.Contents.ToArray());
 }
コード例 #3
0
        internal FreezeTransactionBody(Hashgraph.SuspendNetworkParams suspendParameters) : this()
        {
            if (suspendParameters is null)
            {
                throw new ArgumentNullException("Suspend Network Parameters can not be null.", nameof(suspendParameters));
            }
            if (suspendParameters.Duration.Ticks < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(suspendParameters.Duration), "The duration of the suspension must be greater than zero.");
            }
            if (suspendParameters.Duration.TotalHours > 24)
            {
                throw new ArgumentOutOfRangeException(nameof(suspendParameters.Duration), "The duration of suspension must not exceed 24 hours.");
            }
            if (suspendParameters.Starting.TotalHours > 24)
            {
                throw new ArgumentOutOfRangeException(nameof(suspendParameters.Starting), "The starting wait must not exceed 24 hours.");
            }
            var now  = DateTime.UtcNow;
            var then = now.Add(suspendParameters.Starting).Add(suspendParameters.Duration);

            if (then < now)
            {
                throw new ArgumentOutOfRangeException(nameof(suspendParameters.Starting), "The combination of Starting wait and Duration has already passed.");
            }
            if (suspendParameters.UpdateFile.IsNullOrNone())
            {
                if (!suspendParameters.UpdateFileHash.IsEmpty)
                {
                    throw new ArgumentOutOfRangeException(nameof(suspendParameters.UpdateFile), "The the the hash of the file contents is specified, an address for the update file must be included.");
                }
            }
            else if (suspendParameters.UpdateFileHash.IsEmpty)
            {
                throw new ArgumentOutOfRangeException(nameof(suspendParameters.UpdateFileHash), "The an update file address is specified, the hash of the file contents must be included.");
            }
            var startDate = DateTime.UtcNow.Add(suspendParameters.Starting);
            var endDate   = startDate.Add(suspendParameters.Duration);

            StartHour = startDate.Hour;
            StartMin  = startDate.Minute;
            EndHour   = endDate.Hour;
            EndMin    = endDate.Minute;
            if (!suspendParameters.UpdateFile.IsNullOrNone())
            {
                UpdateFile = new FileID(suspendParameters.UpdateFile);
                FileHash   = ByteString.CopyFrom(suspendParameters.UpdateFileHash.Span);
            }
        }
コード例 #4
0
 internal ContractCreateTransactionBody(Hashgraph.CreateContractParams createParameters) : this()
 {
     if (createParameters is null)
     {
         throw new ArgumentNullException(nameof(createParameters), "The create parameters are missing. Please check that the argument is not null.");
     }
     if (createParameters.File is null)
     {
         throw new ArgumentNullException(nameof(createParameters.File), "The File Address containing the contract is missing, it cannot be null.");
     }
     FileID                = new FileID(createParameters.File);
     AdminKey              = createParameters.Administrator is null ? null : new Key(createParameters.Administrator);
     Gas                   = createParameters.Gas;
     InitialBalance        = createParameters.InitialBalance;
     AutoRenewPeriod       = new Duration(createParameters.RenewPeriod);
     ConstructorParameters = ByteString.CopyFrom(Abi.EncodeArguments(createParameters.Arguments).ToArray());
     Memo                  = createParameters.Memo ?? "";
 }
コード例 #5
0
 internal ContractUpdateTransactionBody(UpdateContractParams updateParameters) : this()
 {
     if (updateParameters is null)
     {
         throw new ArgumentNullException(nameof(updateParameters), "Contract Update Parameters argument is missing. Please check that it is not null.");
     }
     if (updateParameters.Contract is null)
     {
         throw new ArgumentNullException(nameof(updateParameters.Contract), "Contract address is missing. Please check that it is not null.");
     }
     if (updateParameters.Expiration is null &&
         updateParameters.Administrator is null &&
         updateParameters.RenewPeriod is null &&
         updateParameters.File is null &&
         updateParameters.Memo is null)
     {
         throw new ArgumentException("The Contract Updates contains no update properties, it is blank.", nameof(updateParameters));
     }
     ContractID = new ContractID(updateParameters.Contract);
     if (updateParameters.Expiration.HasValue)
     {
         ExpirationTime = new Timestamp(updateParameters.Expiration.Value);
     }
     if (!(updateParameters.Administrator is null))
     {
         AdminKey = new Key(updateParameters.Administrator);
     }
     if (updateParameters.RenewPeriod.HasValue)
     {
         AutoRenewPeriod = new Duration(updateParameters.RenewPeriod.Value);
     }
     if (!(updateParameters.File is null))
     {
         FileID = new FileID(updateParameters.File);
     }
     if (!string.IsNullOrWhiteSpace(updateParameters.Memo))
     {
         MemoWrapper = updateParameters.Memo;
     }
 }
コード例 #6
0
 internal FileGetInfoQuery(Address file) : this()
 {
     FileID = new FileID(file);
 }
コード例 #7
0
 internal FileGetContentsQuery(Address file) : this()
 {
     FileID = new FileID(file);
 }
コード例 #8
0
 internal FileReceipt FillProperties(TransactionID transactionId, FileReceipt receipt)
 {
     FillCommonProperties(transactionId, receipt);
     receipt.File = FileID.ToAddress();
     return(receipt);
 }
コード例 #9
0
 internal FileDeleteTransactionBody(Address fileToDelete) : this()
 {
     FileID = new FileID(fileToDelete);
 }